1 // 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. 5 // 6 7 // renderer9_utils.h: Conversion functions and other utility routines 8 // specific to the D3D9 renderer 9 10 #ifndef LIBGLESV2_RENDERER_RENDERER9_UTILS_H 11 #define LIBGLESV2_RENDERER_RENDERER9_UTILS_H 12 13 #include "libGLESv2/angletypes.h" 14 #include "libGLESv2/Caps.h" 15 16 namespace gl 17 { 18 class FramebufferAttachment; 19 } 20 21 namespace rx 22 { 23 class RenderTarget9; 24 25 namespace gl_d3d9 26 { 27 28 D3DCMPFUNC ConvertComparison(GLenum comparison); 29 D3DCOLOR ConvertColor(gl::ColorF color); 30 D3DBLEND ConvertBlendFunc(GLenum blend); 31 D3DBLENDOP ConvertBlendOp(GLenum blendOp); 32 D3DSTENCILOP ConvertStencilOp(GLenum stencilOp); 33 D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap); 34 D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace); 35 D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace); 36 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha); 37 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy); 38 void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float maxAnisotropy); 39 40 D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples); 41 42 } 43 44 namespace d3d9_gl 45 { 46 47 GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type); 48 49 bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format); 50 51 void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceType, UINT adapter, gl::Caps *caps, 52 gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions); 53 54 } 55 56 namespace d3d9 57 { 58 59 GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height); 60 61 void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset); 62 63 inline bool isDeviceLostError(HRESULT errorCode) 64 { 65 switch (errorCode) 66 { 67 case D3DERR_DRIVERINTERNALERROR: 68 case D3DERR_DEVICELOST: 69 case D3DERR_DEVICEHUNG: 70 case D3DERR_DEVICEREMOVED: 71 return true; 72 default: 73 return false; 74 } 75 } 76 77 RenderTarget9 *GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment); 78 79 } 80 81 } 82 83 #endif // LIBGLESV2_RENDERER_RENDERER9_UTILS_H 84