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