Home | History | Annotate | Download | only in renderer
      1 //
      2 // Copyright (c) 2002-2012 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/utilities.h"
     14 
     15 const D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I','N','T','Z')));
     16 const D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N','U','L','L')));
     17 
     18 namespace gl_d3d9
     19 {
     20 
     21 D3DCMPFUNC ConvertComparison(GLenum comparison);
     22 D3DCOLOR ConvertColor(gl::Color color);
     23 D3DBLEND ConvertBlendFunc(GLenum blend);
     24 D3DBLENDOP ConvertBlendOp(GLenum blendOp);
     25 D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
     26 D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap);
     27 D3DCULL ConvertCullMode(GLenum cullFace, GLenum frontFace);
     28 D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace);
     29 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
     30 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy);
     31 void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter, float maxAnisotropy);
     32 D3DFORMAT ConvertRenderbufferFormat(GLenum format);
     33 D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples);
     34 
     35 }
     36 
     37 namespace d3d9_gl
     38 {
     39 
     40 GLuint GetAlphaSize(D3DFORMAT colorFormat);
     41 GLuint GetStencilSize(D3DFORMAT stencilFormat);
     42 
     43 GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type);
     44 
     45 bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
     46 GLenum ConvertBackBufferFormat(D3DFORMAT format);
     47 GLenum ConvertDepthStencilFormat(D3DFORMAT format);
     48 GLenum ConvertRenderTargetFormat(D3DFORMAT format);
     49 GLenum GetEquivalentFormat(D3DFORMAT format);
     50 
     51 }
     52 
     53 namespace d3d9
     54 {
     55 bool IsCompressedFormat(D3DFORMAT format);
     56 size_t ComputeRowSize(D3DFORMAT format, unsigned int width);
     57 
     58 inline bool isDeviceLostError(HRESULT errorCode)
     59 {
     60     switch (errorCode)
     61     {
     62       case D3DERR_DRIVERINTERNALERROR:
     63       case D3DERR_DEVICELOST:
     64       case D3DERR_DEVICEHUNG:
     65       case D3DERR_DEVICEREMOVED:
     66         return true;
     67       default:
     68         return false;
     69     }
     70 }
     71 
     72 }
     73 
     74 #endif // LIBGLESV2_RENDERER_RENDERER9_UTILS_H
     75