renderer9_utils.h (2966B)
1 // 2 // Copyright 2002 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. 5 // 6 7 // renderer9_utils.h: Conversion functions and other utility routines 8 // specific to the D3D9 renderer 9 10 #ifndef LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_ 11 #define LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_ 12 13 #include "common/Color.h" 14 #include "libANGLE/Caps.h" 15 #include "libANGLE/Error.h" 16 #include "platform/FeaturesD3D_autogen.h" 17 18 namespace gl 19 { 20 class FramebufferAttachment; 21 } 22 23 namespace rx 24 { 25 class RenderTarget9; 26 27 namespace gl_d3d9 28 { 29 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(gl::CullFaceMode cullFace, GLenum frontFace); 37 D3DCUBEMAP_FACES ConvertCubeFace(gl::TextureTarget cubeFace); 38 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha); 39 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy); 40 void ConvertMinFilter(GLenum minFilter, 41 D3DTEXTUREFILTERTYPE *d3dMinFilter, 42 D3DTEXTUREFILTERTYPE *d3dMipFilter, 43 float *d3dLodBias, 44 float maxAnisotropy, 45 size_t baseLevel); 46 D3DQUERYTYPE ConvertQueryType(gl::QueryType type); 47 48 D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples); 49 50 } // namespace gl_d3d9 51 52 namespace d3d9_gl 53 { 54 55 unsigned int GetReservedVaryingVectors(); 56 57 unsigned int GetReservedVertexUniformVectors(); 58 59 unsigned int GetReservedFragmentUniformVectors(); 60 61 GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type); 62 63 bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format); 64 65 void GenerateCaps(IDirect3D9 *d3d9, 66 IDirect3DDevice9 *device, 67 D3DDEVTYPE deviceType, 68 UINT adapter, 69 gl::Caps *caps, 70 gl::TextureCapsMap *textureCapsMap, 71 gl::Extensions *extensions, 72 gl::Limitations *limitations); 73 } // namespace d3d9_gl 74 75 namespace d3d9 76 { 77 78 GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height); 79 80 void MakeValidSize(bool isImage, 81 D3DFORMAT format, 82 GLsizei *requestWidth, 83 GLsizei *requestHeight, 84 int *levelOffset); 85 86 inline bool isDeviceLostError(HRESULT errorCode) 87 { 88 switch (errorCode) 89 { 90 case D3DERR_DRIVERINTERNALERROR: 91 case D3DERR_DEVICELOST: 92 case D3DERR_DEVICEHUNG: 93 case D3DERR_DEVICEREMOVED: 94 return true; 95 default: 96 return false; 97 } 98 } 99 100 void InitializeFeatures(angle::FeaturesD3D *features); 101 } // namespace d3d9 102 103 } // namespace rx 104 105 #endif // LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_