• 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     // Device loss
120     gl::GraphicsResetStatus getResetStatus() override;
121 
122     // Vendor and description strings.
123     std::string getVendorString() const override;
124     std::string getRendererDescription() const override;
125 
126     // EXT_debug_marker
127     angle::Result insertEventMarker(GLsizei length, const char *marker) override;
128     angle::Result pushGroupMarker(GLsizei length, const char *marker) override;
129     angle::Result popGroupMarker() override;
130 
131     // KHR_debug
132     angle::Result pushDebugGroup(const gl::Context *context,
133                                  GLenum source,
134                                  GLuint id,
135                                  const std::string &message) override;
136     angle::Result popDebugGroup(const gl::Context *context) override;
137 
138     // State sync with dirty bits.
139     angle::Result syncState(const gl::Context *context,
140                             const gl::State::DirtyBits &dirtyBits,
141                             const gl::State::DirtyBits &bitMask) override;
142 
143     // Disjoint timer queries
144     GLint getGPUDisjoint() override;
145     GLint64 getTimestamp() override;
146 
147     // Context switching
148     angle::Result onMakeCurrent(const gl::Context *context) override;
149 
150     // Native capabilities, unmodified by gl::Context.
151     gl::Caps getNativeCaps() const override;
152     const gl::TextureCapsMap &getNativeTextureCaps() const override;
153     const gl::Extensions &getNativeExtensions() const override;
154     const gl::Limitations &getNativeLimitations() const override;
155 
156     // Shader creation
157     CompilerImpl *createCompiler() override;
158     ShaderImpl *createShader(const gl::ShaderState &data) override;
159     ProgramImpl *createProgram(const gl::ProgramState &data) override;
160 
161     // Framebuffer creation
162     FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override;
163 
164     // Texture creation
165     TextureImpl *createTexture(const gl::TextureState &state) override;
166 
167     // Renderbuffer creation
168     RenderbufferImpl *createRenderbuffer(const gl::RenderbufferState &state) override;
169 
170     // Buffer creation
171     BufferImpl *createBuffer(const gl::BufferState &state) override;
172 
173     // Vertex Array creation
174     VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override;
175 
176     // Query and Fence creation
177     QueryImpl *createQuery(gl::QueryType type) override;
178     FenceNVImpl *createFenceNV() override;
179     SyncImpl *createSync() override;
180 
181     // Transform Feedback creation
182     TransformFeedbackImpl *createTransformFeedback(
183         const gl::TransformFeedbackState &state) override;
184 
185     // Sampler object creation
186     SamplerImpl *createSampler(const gl::SamplerState &state) override;
187 
188     // Program Pipeline object creation
189     ProgramPipelineImpl *createProgramPipeline(const gl::ProgramPipelineState &data) override;
190 
191     // Memory object creation.
192     MemoryObjectImpl *createMemoryObject() override;
193 
194     // Semaphore creation.
195     SemaphoreImpl *createSemaphore() override;
196 
197     // Overlay creation.
198     OverlayImpl *createOverlay(const gl::OverlayState &state) override;
199 
200     angle::Result dispatchCompute(const gl::Context *context,
201                                   GLuint numGroupsX,
202                                   GLuint numGroupsY,
203                                   GLuint numGroupsZ) override;
204     angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) override;
205 
206     angle::Result memoryBarrier(const gl::Context *context, GLbitfield barriers) override;
207     angle::Result memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
208 
209     void handleError(GLenum errorCode,
210                      const char *message,
211                      const char *file,
212                      const char *function,
213                      unsigned int line);
214 
215   private:
216     gl::Caps mCaps;
217     gl::TextureCapsMap mTextureCaps;
218     gl::Extensions mExtensions;
219     gl::Limitations mLimitations;
220 
221     AllocationTrackerNULL *mAllocationTracker;
222 };
223 
224 }  // namespace rx
225 
226 #endif  // LIBANGLE_RENDERER_NULL_CONTEXTNULL_H_
227