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 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/WorkaroundsD3D.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(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,
41 float *d3dLodBias, float maxAnisotropy, size_t baseLevel);
42 D3DQUERYTYPE ConvertQueryType(GLenum queryType);
43
44 D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples);
45
46 }
47
48 namespace d3d9_gl
49 {
50
51 unsigned int GetReservedVaryingVectors();
52
53 unsigned int GetReservedVertexUniformVectors();
54
55 unsigned int GetReservedFragmentUniformVectors();
56
57 GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type);
58
59 bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
60
61 void GenerateCaps(IDirect3D9 *d3d9,
62 IDirect3DDevice9 *device,
63 D3DDEVTYPE deviceType,
64 UINT adapter,
65 gl::Caps *caps,
66 gl::TextureCapsMap *textureCapsMap,
67 gl::Extensions *extensions,
68 gl::Limitations *limitations);
69 }
70
71 namespace d3d9
72 {
73
74 GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height);
75
76 void MakeValidSize(bool isImage, D3DFORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
77
isDeviceLostError(HRESULT errorCode)78 inline bool isDeviceLostError(HRESULT errorCode)
79 {
80 switch (errorCode)
81 {
82 case D3DERR_DRIVERINTERNALERROR:
83 case D3DERR_DEVICELOST:
84 case D3DERR_DEVICEHUNG:
85 case D3DERR_DEVICEREMOVED:
86 return true;
87 default:
88 return false;
89 }
90 }
91
92 angle::WorkaroundsD3D GenerateWorkarounds();
93 }
94
95 } // namespace d3d9
96
97 #endif // LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_
98