xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/d3d/d3d9/Context9.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2016 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 // Context9:
7 //   D3D9-specific functionality associated with a GL Context.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_
11 #define LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_
12 
13 #include <stack>
14 #include "image_util/loadimage.h"
15 #include "libANGLE/renderer/d3d/ContextD3D.h"
16 
17 namespace rx
18 {
19 class Renderer9;
20 
21 class Context9 : public ContextD3D
22 {
23   public:
24     Context9(const gl::State &state, gl::ErrorSet *errorSet, Renderer9 *renderer);
25     ~Context9() override;
26 
27     angle::Result initialize(const angle::ImageLoadContext &imageLoadContext) override;
28     void onDestroy(const gl::Context *context) override;
29 
30     // Shader creation
31     CompilerImpl *createCompiler() override;
32     ShaderImpl *createShader(const gl::ShaderState &data) override;
33     ProgramImpl *createProgram(const gl::ProgramState &data) override;
34     ProgramExecutableImpl *createProgramExecutable(
35         const gl::ProgramExecutable *executable) override;
36 
37     // Framebuffer creation
38     FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override;
39 
40     // Texture creation
41     TextureImpl *createTexture(const gl::TextureState &state) override;
42 
43     // Renderbuffer creation
44     RenderbufferImpl *createRenderbuffer(const gl::RenderbufferState &state) override;
45 
46     // Buffer creation
47     BufferImpl *createBuffer(const gl::BufferState &state) override;
48 
49     // Vertex Array creation
50     VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override;
51 
52     // Query and Fence creation
53     QueryImpl *createQuery(gl::QueryType type) override;
54     FenceNVImpl *createFenceNV() override;
55     SyncImpl *createSync() override;
56 
57     // Transform Feedback creation
58     TransformFeedbackImpl *createTransformFeedback(
59         const gl::TransformFeedbackState &state) override;
60 
61     // Sampler object creation
62     SamplerImpl *createSampler(const gl::SamplerState &state) override;
63 
64     // Program Pipeline object creation
65     ProgramPipelineImpl *createProgramPipeline(const gl::ProgramPipelineState &data) override;
66 
67     // Memory object creation.
68     MemoryObjectImpl *createMemoryObject() override;
69 
70     // Semaphore creation.
71     SemaphoreImpl *createSemaphore() override;
72 
73     // Overlay creation.
74     OverlayImpl *createOverlay(const gl::OverlayState &state) override;
75 
76     // Flush and finish.
77     angle::Result flush(const gl::Context *context) override;
78     angle::Result finish(const gl::Context *context) override;
79 
80     // Drawing methods.
81     angle::Result drawArrays(const gl::Context *context,
82                              gl::PrimitiveMode mode,
83                              GLint first,
84                              GLsizei count) override;
85     angle::Result drawArraysInstanced(const gl::Context *context,
86                                       gl::PrimitiveMode mode,
87                                       GLint first,
88                                       GLsizei count,
89                                       GLsizei instanceCount) override;
90     angle::Result drawArraysInstancedBaseInstance(const gl::Context *context,
91                                                   gl::PrimitiveMode mode,
92                                                   GLint first,
93                                                   GLsizei count,
94                                                   GLsizei instanceCount,
95                                                   GLuint baseInstance) override;
96 
97     angle::Result drawElements(const gl::Context *context,
98                                gl::PrimitiveMode mode,
99                                GLsizei count,
100                                gl::DrawElementsType type,
101                                const void *indices) override;
102     angle::Result drawElementsBaseVertex(const gl::Context *context,
103                                          gl::PrimitiveMode mode,
104                                          GLsizei count,
105                                          gl::DrawElementsType type,
106                                          const void *indices,
107                                          GLint baseVertex) override;
108     angle::Result drawElementsInstanced(const gl::Context *context,
109                                         gl::PrimitiveMode mode,
110                                         GLsizei count,
111                                         gl::DrawElementsType type,
112                                         const void *indices,
113                                         GLsizei instances) override;
114     angle::Result drawElementsInstancedBaseVertex(const gl::Context *context,
115                                                   gl::PrimitiveMode mode,
116                                                   GLsizei count,
117                                                   gl::DrawElementsType type,
118                                                   const void *indices,
119                                                   GLsizei instances,
120                                                   GLint baseVertex) override;
121     angle::Result drawElementsInstancedBaseVertexBaseInstance(const gl::Context *context,
122                                                               gl::PrimitiveMode mode,
123                                                               GLsizei count,
124                                                               gl::DrawElementsType type,
125                                                               const void *indices,
126                                                               GLsizei instances,
127                                                               GLint baseVertex,
128                                                               GLuint baseInstance) override;
129     angle::Result drawRangeElements(const gl::Context *context,
130                                     gl::PrimitiveMode mode,
131                                     GLuint start,
132                                     GLuint end,
133                                     GLsizei count,
134                                     gl::DrawElementsType type,
135                                     const void *indices) override;
136     angle::Result drawRangeElementsBaseVertex(const gl::Context *context,
137                                               gl::PrimitiveMode mode,
138                                               GLuint start,
139                                               GLuint end,
140                                               GLsizei count,
141                                               gl::DrawElementsType type,
142                                               const void *indices,
143                                               GLint baseVertex) override;
144     angle::Result drawArraysIndirect(const gl::Context *context,
145                                      gl::PrimitiveMode mode,
146                                      const void *indirect) override;
147     angle::Result drawElementsIndirect(const gl::Context *context,
148                                        gl::PrimitiveMode mode,
149                                        gl::DrawElementsType type,
150                                        const void *indirect) override;
151 
152     angle::Result multiDrawArrays(const gl::Context *context,
153                                   gl::PrimitiveMode mode,
154                                   const GLint *firsts,
155                                   const GLsizei *counts,
156                                   GLsizei drawcount) override;
157     angle::Result multiDrawArraysInstanced(const gl::Context *context,
158                                            gl::PrimitiveMode mode,
159                                            const GLint *firsts,
160                                            const GLsizei *counts,
161                                            const GLsizei *instanceCounts,
162                                            GLsizei drawcount) override;
163     angle::Result multiDrawArraysIndirect(const gl::Context *context,
164                                           gl::PrimitiveMode mode,
165                                           const void *indirect,
166                                           GLsizei drawcount,
167                                           GLsizei stride) override;
168     angle::Result multiDrawElements(const gl::Context *context,
169                                     gl::PrimitiveMode mode,
170                                     const GLsizei *counts,
171                                     gl::DrawElementsType type,
172                                     const GLvoid *const *indices,
173                                     GLsizei drawcount) override;
174     angle::Result multiDrawElementsInstanced(const gl::Context *context,
175                                              gl::PrimitiveMode mode,
176                                              const GLsizei *counts,
177                                              gl::DrawElementsType type,
178                                              const GLvoid *const *indices,
179                                              const GLsizei *instanceCounts,
180                                              GLsizei drawcount) override;
181     angle::Result multiDrawElementsIndirect(const gl::Context *context,
182                                             gl::PrimitiveMode mode,
183                                             gl::DrawElementsType type,
184                                             const void *indirect,
185                                             GLsizei drawcount,
186                                             GLsizei stride) override;
187     angle::Result multiDrawArraysInstancedBaseInstance(const gl::Context *context,
188                                                        gl::PrimitiveMode mode,
189                                                        const GLint *firsts,
190                                                        const GLsizei *counts,
191                                                        const GLsizei *instanceCounts,
192                                                        const GLuint *baseInstances,
193                                                        GLsizei drawcount) override;
194     angle::Result multiDrawElementsInstancedBaseVertexBaseInstance(const gl::Context *context,
195                                                                    gl::PrimitiveMode mode,
196                                                                    const GLsizei *counts,
197                                                                    gl::DrawElementsType type,
198                                                                    const GLvoid *const *indices,
199                                                                    const GLsizei *instanceCounts,
200                                                                    const GLint *baseVertices,
201                                                                    const GLuint *baseInstances,
202                                                                    GLsizei drawcount) override;
203 
204     // Device loss
205     gl::GraphicsResetStatus getResetStatus() override;
206 
207     // EXT_debug_marker
208     angle::Result insertEventMarker(GLsizei length, const char *marker) override;
209     angle::Result pushGroupMarker(GLsizei length, const char *marker) override;
210     angle::Result popGroupMarker() override;
211 
212     // KHR_debug
213     angle::Result pushDebugGroup(const gl::Context *context,
214                                  GLenum source,
215                                  GLuint id,
216                                  const std::string &message) override;
217     angle::Result popDebugGroup(const gl::Context *context) override;
218 
219     // State sync with dirty bits.
220     angle::Result syncState(const gl::Context *context,
221                             const gl::state::DirtyBits dirtyBits,
222                             const gl::state::DirtyBits bitMask,
223                             const gl::state::ExtendedDirtyBits extendedDirtyBits,
224                             const gl::state::ExtendedDirtyBits extendedBitMask,
225                             gl::Command command) override;
226 
227     // Disjoint timer queries
228     GLint getGPUDisjoint() override;
229     GLint64 getTimestamp() override;
230 
231     // Context switching
232     angle::Result onMakeCurrent(const gl::Context *context) override;
233 
234     // Caps queries
235     gl::Caps getNativeCaps() const override;
236     const gl::TextureCapsMap &getNativeTextureCaps() const override;
237     const gl::Extensions &getNativeExtensions() const override;
238     const gl::Limitations &getNativeLimitations() const override;
239     const ShPixelLocalStorageOptions &getNativePixelLocalStorageOptions() const override;
240 
241     angle::Result dispatchCompute(const gl::Context *context,
242                                   GLuint numGroupsX,
243                                   GLuint numGroupsY,
244                                   GLuint numGroupsZ) override;
245     angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) override;
246 
247     angle::Result memoryBarrier(const gl::Context *context, GLbitfield barriers) override;
248     angle::Result memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
249 
getRenderer()250     Renderer9 *getRenderer() const { return mRenderer; }
getImageLoadContext()251     const angle::ImageLoadContext &getImageLoadContext() const { return mImageLoadContext; }
252 
253     angle::Result getIncompleteTexture(const gl::Context *context,
254                                        gl::TextureType type,
255                                        gl::Texture **textureOut);
256 
257     void handleResult(HRESULT hr,
258                       const char *message,
259                       const char *file,
260                       const char *function,
261                       unsigned int line) override;
262 
263   private:
264     Renderer9 *mRenderer;
265     angle::ImageLoadContext mImageLoadContext;
266     IncompleteTextureSet mIncompleteTextures;
267     std::stack<std::string> mMarkerStack;
268 };
269 
270 }  // namespace rx
271 
272 #endif  // LIBANGLE_RENDERER_D3D_D3D9_CONTEXT9_H_
273