2 // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 // renderer9_utils.h: Conversion functions and other utility routines
8 // specific to the D3D9 renderer
10 #ifndef LIBGLESV2_RENDERER_RENDERER9_UTILS_H
11 #define LIBGLESV2_RENDERER_RENDERER9_UTILS_H
13 #include "libGLESv2/angletypes.h"
14 #include "libGLESv2/Caps.h"
15 #include "libGLESv2/Error.h"
19 class FramebufferAttachment;
30 D3DCMPFUNC ConvertComparison(GLenum comparison);
31 D3DCOLOR ConvertColor(gl::ColorF color);
32 D3DBLEND ConvertBlendFunc(GLenum blend);
33 D3DBLENDOP ConvertBlendOp(GLenum blendOp);
34 D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
35 D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap);
36 D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace);
37 D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace);
38 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
39 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy);
40 void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float maxAnisotropy);
42 D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples);
49 GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type);
51 bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
53 void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceType, UINT adapter, gl::Caps *caps,
54 gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions);
61 GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height);
63 void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
65 inline bool isDeviceLostError(HRESULT errorCode)
69 case D3DERR_DRIVERINTERNALERROR:
70 case D3DERR_DEVICELOST:
71 case D3DERR_DEVICEHUNG:
72 case D3DERR_DEVICEREMOVED:
79 gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget9 **outRT);
80 Workarounds GenerateWorkarounds();
86 #endif // LIBGLESV2_RENDERER_RENDERER9_UTILS_H