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 multiDrawElements(const gl::Context *context, 131 gl::PrimitiveMode mode, 132 const GLsizei *counts, 133 gl::DrawElementsType type, 134 const GLvoid *const *indices, 135 GLsizei drawcount) override; 136 angle::Result multiDrawElementsInstanced(const gl::Context *context, 137 gl::PrimitiveMode mode, 138 const GLsizei *counts, 139 gl::DrawElementsType type, 140 const GLvoid *const *indices, 141 const GLsizei *instanceCounts, 142 GLsizei drawcount) override; 143 angle::Result multiDrawArraysInstancedBaseInstance(const gl::Context *context, 144 gl::PrimitiveMode mode, 145 const GLint *firsts, 146 const GLsizei *counts, 147 const GLsizei *instanceCounts, 148 const GLuint *baseInstances, 149 GLsizei drawcount) override; 150 angle::Result multiDrawElementsInstancedBaseVertexBaseInstance(const gl::Context *context, 151 gl::PrimitiveMode mode, 152 const GLsizei *counts, 153 gl::DrawElementsType type, 154 const GLvoid *const *indices, 155 const GLsizei *instanceCounts, 156 const GLint *baseVertices, 157 const GLuint *baseInstances, 158 GLsizei drawcount) override; 159 160 // Device loss 161 gl::GraphicsResetStatus getResetStatus() override; 162 163 // EXT_debug_marker 164 angle::Result insertEventMarker(GLsizei length, const char *marker) override; 165 angle::Result pushGroupMarker(GLsizei length, const char *marker) override; 166 angle::Result popGroupMarker() override; 167 168 // KHR_debug 169 angle::Result pushDebugGroup(const gl::Context *context, 170 GLenum source, 171 GLuint id, 172 const std::string &message) override; 173 angle::Result popDebugGroup(const gl::Context *context) override; 174 175 // State sync with dirty bits. 176 angle::Result syncState(const gl::Context *context, 177 const gl::State::DirtyBits &dirtyBits, 178 const gl::State::DirtyBits &bitMask) override; 179 180 // Disjoint timer queries 181 GLint getGPUDisjoint() override; 182 GLint64 getTimestamp() override; 183 184 // Context switching 185 angle::Result onMakeCurrent(const gl::Context *context) override; 186 187 // Native capabilities, unmodified by gl::Context. 188 gl::Caps getNativeCaps() const override; 189 const gl::TextureCapsMap &getNativeTextureCaps() const override; 190 const gl::Extensions &getNativeExtensions() const override; 191 const gl::Limitations &getNativeLimitations() const override; 192 193 // Shader creation 194 CompilerImpl *createCompiler() override; 195 ShaderImpl *createShader(const gl::ShaderState &data) override; 196 ProgramImpl *createProgram(const gl::ProgramState &data) override; 197 198 // Framebuffer creation 199 FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override; 200 201 // Texture creation 202 TextureImpl *createTexture(const gl::TextureState &state) override; 203 204 // Renderbuffer creation 205 RenderbufferImpl *createRenderbuffer(const gl::RenderbufferState &state) override; 206 207 // Buffer creation 208 BufferImpl *createBuffer(const gl::BufferState &state) override; 209 210 // Vertex Array creation 211 VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; 212 213 // Query and Fence creation 214 QueryImpl *createQuery(gl::QueryType type) override; 215 FenceNVImpl *createFenceNV() override; 216 SyncImpl *createSync() override; 217 218 // Transform Feedback creation 219 TransformFeedbackImpl *createTransformFeedback( 220 const gl::TransformFeedbackState &state) override; 221 222 // Sampler object creation 223 SamplerImpl *createSampler(const gl::SamplerState &state) override; 224 225 // Program Pipeline object creation 226 ProgramPipelineImpl *createProgramPipeline(const gl::ProgramPipelineState &data) override; 227 228 // Memory object creation. 229 MemoryObjectImpl *createMemoryObject() override; 230 231 // Semaphore creation. 232 SemaphoreImpl *createSemaphore() override; 233 234 // Overlay creation. 235 OverlayImpl *createOverlay(const gl::OverlayState &state) override; 236 237 angle::Result dispatchCompute(const gl::Context *context, 238 GLuint numGroupsX, 239 GLuint numGroupsY, 240 GLuint numGroupsZ) override; 241 angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) override; 242 243 angle::Result memoryBarrier(const gl::Context *context, GLbitfield barriers) override; 244 angle::Result memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override; 245 246 void handleError(GLenum errorCode, 247 const char *message, 248 const char *file, 249 const char *function, 250 unsigned int line); 251 252 private: 253 gl::Caps mCaps; 254 gl::TextureCapsMap mTextureCaps; 255 gl::Extensions mExtensions; 256 gl::Limitations mLimitations; 257 258 AllocationTrackerNULL *mAllocationTracker; 259 }; 260 261 } // namespace rx 262 263 #endif // LIBANGLE_RENDERER_NULL_CONTEXTNULL_H_ 264