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(const angle::ImageLoadContext &imageLoadContext) 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 const gl::state::ExtendedDirtyBits extendedDirtyBits, 191 const gl::state::ExtendedDirtyBits extendedBitMask, 192 gl::Command command) override; 193 194 // Disjoint timer queries 195 GLint getGPUDisjoint() override; 196 GLint64 getTimestamp() override; 197 198 // Context switching 199 angle::Result onMakeCurrent(const gl::Context *context) override; 200 201 // Native capabilities, unmodified by gl::Context. 202 gl::Caps getNativeCaps() const override; 203 const gl::TextureCapsMap &getNativeTextureCaps() const override; 204 const gl::Extensions &getNativeExtensions() const override; 205 const gl::Limitations &getNativeLimitations() const override; 206 const ShPixelLocalStorageOptions &getNativePixelLocalStorageOptions() const override; 207 208 // Shader creation 209 CompilerImpl *createCompiler() override; 210 ShaderImpl *createShader(const gl::ShaderState &data) override; 211 ProgramImpl *createProgram(const gl::ProgramState &data) override; 212 ProgramExecutableImpl *createProgramExecutable( 213 const gl::ProgramExecutable *executable) override; 214 215 // Framebuffer creation 216 FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override; 217 218 // Texture creation 219 TextureImpl *createTexture(const gl::TextureState &state) override; 220 221 // Renderbuffer creation 222 RenderbufferImpl *createRenderbuffer(const gl::RenderbufferState &state) override; 223 224 // Buffer creation 225 BufferImpl *createBuffer(const gl::BufferState &state) override; 226 227 // Vertex Array creation 228 VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; 229 230 // Query and Fence creation 231 QueryImpl *createQuery(gl::QueryType type) override; 232 FenceNVImpl *createFenceNV() override; 233 SyncImpl *createSync() override; 234 235 // Transform Feedback creation 236 TransformFeedbackImpl *createTransformFeedback( 237 const gl::TransformFeedbackState &state) override; 238 239 // Sampler object creation 240 SamplerImpl *createSampler(const gl::SamplerState &state) override; 241 242 // Program Pipeline object creation 243 ProgramPipelineImpl *createProgramPipeline(const gl::ProgramPipelineState &data) override; 244 245 // Memory object creation. 246 MemoryObjectImpl *createMemoryObject() override; 247 248 // Semaphore creation. 249 SemaphoreImpl *createSemaphore() override; 250 251 // Overlay creation. 252 OverlayImpl *createOverlay(const gl::OverlayState &state) override; 253 254 angle::Result dispatchCompute(const gl::Context *context, 255 GLuint numGroupsX, 256 GLuint numGroupsY, 257 GLuint numGroupsZ) override; 258 angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) override; 259 260 angle::Result memoryBarrier(const gl::Context *context, GLbitfield barriers) override; 261 angle::Result memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override; 262 263 void handleError(GLenum errorCode, 264 const char *message, 265 const char *file, 266 const char *function, 267 unsigned int line); 268 269 private: 270 gl::Caps mCaps; 271 gl::TextureCapsMap mTextureCaps; 272 gl::Extensions mExtensions; 273 gl::Limitations mLimitations; 274 ShPixelLocalStorageOptions mPLSOptions; 275 276 AllocationTrackerNULL *mAllocationTracker; 277 }; 278 279 } // namespace rx 280 281 #endif // LIBANGLE_RENDERER_NULL_CONTEXTNULL_H_ 282