xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/d3d/d3d9/renderer9_utils.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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/autogen/FeaturesD3D_autogen.h"
17 #include "platform/autogen/FrontendFeatures_autogen.h"
18 
19 namespace gl
20 {
21 class FramebufferAttachment;
22 }
23 
24 namespace rx
25 {
26 class RenderTarget9;
27 
28 namespace gl_d3d9
29 {
30 
31 D3DCMPFUNC ConvertComparison(GLenum comparison);
32 D3DCOLOR ConvertColor(gl::ColorF color);
33 D3DBLEND ConvertBlendFunc(GLenum blend);
34 D3DBLENDOP ConvertBlendOp(GLenum blendOp);
35 D3DSTENCILOP ConvertStencilOp(GLenum stencilOp);
36 D3DTEXTUREADDRESS ConvertTextureWrap(GLenum wrap);
37 D3DCULL ConvertCullMode(gl::CullFaceMode cullFace, GLenum frontFace);
38 D3DCUBEMAP_FACES ConvertCubeFace(gl::TextureTarget cubeFace);
39 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
40 D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter, float maxAnisotropy);
41 void ConvertMinFilter(GLenum minFilter,
42                       D3DTEXTUREFILTERTYPE *d3dMinFilter,
43                       D3DTEXTUREFILTERTYPE *d3dMipFilter,
44                       float *d3dLodBias,
45                       float maxAnisotropy,
46                       size_t baseLevel);
47 D3DQUERYTYPE ConvertQueryType(gl::QueryType type);
48 
49 D3DMULTISAMPLE_TYPE GetMultisampleType(GLuint samples);
50 
51 }  // namespace gl_d3d9
52 
53 namespace d3d9_gl
54 {
55 
56 unsigned int GetReservedVaryingVectors();
57 
58 unsigned int GetReservedVertexUniformVectors();
59 
60 unsigned int GetReservedFragmentUniformVectors();
61 
62 GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type);
63 
64 bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
65 
66 void GenerateCaps(IDirect3D9 *d3d9,
67                   IDirect3DDevice9 *device,
68                   D3DDEVTYPE deviceType,
69                   UINT adapter,
70                   gl::Caps *caps,
71                   gl::TextureCapsMap *textureCapsMap,
72                   gl::Extensions *extensions,
73                   gl::Limitations *limitations);
74 }  // namespace d3d9_gl
75 
76 namespace d3d9
77 {
78 
79 GLuint ComputeBlockSize(D3DFORMAT format, GLuint width, GLuint height);
80 
81 void MakeValidSize(bool isImage,
82                    D3DFORMAT format,
83                    GLsizei *requestWidth,
84                    GLsizei *requestHeight,
85                    int *levelOffset);
86 
isDeviceLostError(HRESULT errorCode)87 inline bool isDeviceLostError(HRESULT errorCode)
88 {
89     switch (errorCode)
90     {
91         case D3DERR_DRIVERINTERNALERROR:
92         case D3DERR_DEVICELOST:
93         case D3DERR_DEVICEHUNG:
94         case D3DERR_DEVICEREMOVED:
95             return true;
96         default:
97             return false;
98     }
99 }
100 
101 void InitializeFeatures(angle::FeaturesD3D *features, DWORD VendorID);
102 void InitializeFrontendFeatures(angle::FrontendFeatures *features, DWORD VendorID);
103 }  // namespace d3d9
104 
105 }  // namespace rx
106 
107 #endif  // LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_
108