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 // ContextGL: 7 // OpenGL-specific functionality associated with a GL Context. 8 // 9 10 #ifndef LIBANGLE_RENDERER_GL_CONTEXTGL_H_ 11 #define LIBANGLE_RENDERER_GL_CONTEXTGL_H_ 12 13 #include "libANGLE/renderer/ContextImpl.h" 14 #include "libANGLE/renderer/gl/RendererGL.h" 15 16 namespace angle 17 { 18 struct FeaturesGL; 19 } // namespace angle 20 21 namespace sh 22 { 23 struct BlockMemberInfo; 24 } // namespace sh 25 26 namespace rx 27 { 28 class BlitGL; 29 class ClearMultiviewGL; 30 class FunctionsGL; 31 class RendererGL; 32 class StateManagerGL; 33 34 class ContextGL : public ContextImpl 35 { 36 public: 37 ContextGL(const gl::State &state, 38 gl::ErrorSet *errorSet, 39 const std::shared_ptr<RendererGL> &renderer); 40 ~ContextGL() override; 41 42 angle::Result initialize() override; 43 44 // Shader creation 45 CompilerImpl *createCompiler() override; 46 ShaderImpl *createShader(const gl::ShaderState &data) override; 47 ProgramImpl *createProgram(const gl::ProgramState &data) override; 48 49 // Framebuffer creation 50 FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override; 51 52 // Texture creation 53 TextureImpl *createTexture(const gl::TextureState &state) override; 54 55 // Renderbuffer creation 56 RenderbufferImpl *createRenderbuffer(const gl::RenderbufferState &state) override; 57 58 // Buffer creation 59 BufferImpl *createBuffer(const gl::BufferState &state) override; 60 61 // Vertex Array creation 62 VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data) override; 63 64 // Query and Fence creation 65 QueryImpl *createQuery(gl::QueryType type) override; 66 FenceNVImpl *createFenceNV() override; 67 SyncImpl *createSync() override; 68 69 // Transform Feedback creation 70 TransformFeedbackImpl *createTransformFeedback( 71 const gl::TransformFeedbackState &state) override; 72 73 // Sampler object creation 74 SamplerImpl *createSampler(const gl::SamplerState &state) override; 75 76 // Program Pipeline object creation 77 ProgramPipelineImpl *createProgramPipeline(const gl::ProgramPipelineState &data) override; 78 79 // Memory object creation. 80 MemoryObjectImpl *createMemoryObject() override; 81 82 // Semaphore creation. 83 SemaphoreImpl *createSemaphore() override; 84 85 // Overlay creation. 86 OverlayImpl *createOverlay(const gl::OverlayState &state) override; 87 88 // Flush and finish. 89 angle::Result flush(const gl::Context *context) override; 90 angle::Result finish(const gl::Context *context) override; 91 92 // Drawing methods. 93 angle::Result drawArrays(const gl::Context *context, 94 gl::PrimitiveMode mode, 95 GLint first, 96 GLsizei count) override; 97 angle::Result drawArraysInstanced(const gl::Context *context, 98 gl::PrimitiveMode mode, 99 GLint first, 100 GLsizei count, 101 GLsizei instanceCount) override; 102 angle::Result drawArraysInstancedBaseInstance(const gl::Context *context, 103 gl::PrimitiveMode mode, 104 GLint first, 105 GLsizei count, 106 GLsizei instanceCount, 107 GLuint baseInstance) override; 108 109 angle::Result drawElements(const gl::Context *context, 110 gl::PrimitiveMode mode, 111 GLsizei count, 112 gl::DrawElementsType type, 113 const void *indices) override; 114 angle::Result drawElementsBaseVertex(const gl::Context *context, 115 gl::PrimitiveMode mode, 116 GLsizei count, 117 gl::DrawElementsType type, 118 const void *indices, 119 GLint baseVertex) override; 120 angle::Result drawElementsInstanced(const gl::Context *context, 121 gl::PrimitiveMode mode, 122 GLsizei count, 123 gl::DrawElementsType type, 124 const void *indices, 125 GLsizei instances) override; 126 angle::Result drawElementsInstancedBaseVertex(const gl::Context *context, 127 gl::PrimitiveMode mode, 128 GLsizei count, 129 gl::DrawElementsType type, 130 const void *indices, 131 GLsizei instanceCount, 132 GLint baseVertex) override; 133 angle::Result drawElementsInstancedBaseVertexBaseInstance(const gl::Context *context, 134 gl::PrimitiveMode mode, 135 GLsizei count, 136 gl::DrawElementsType type, 137 const void *indices, 138 GLsizei instances, 139 GLint baseVertex, 140 GLuint baseInstance) override; 141 angle::Result drawRangeElements(const gl::Context *context, 142 gl::PrimitiveMode mode, 143 GLuint start, 144 GLuint end, 145 GLsizei count, 146 gl::DrawElementsType type, 147 const void *indices) override; 148 angle::Result drawRangeElementsBaseVertex(const gl::Context *context, 149 gl::PrimitiveMode mode, 150 GLuint start, 151 GLuint end, 152 GLsizei count, 153 gl::DrawElementsType type, 154 const void *indices, 155 GLint baseVertex) override; 156 angle::Result drawArraysIndirect(const gl::Context *context, 157 gl::PrimitiveMode mode, 158 const void *indirect) override; 159 angle::Result drawElementsIndirect(const gl::Context *context, 160 gl::PrimitiveMode mode, 161 gl::DrawElementsType type, 162 const void *indirect) override; 163 164 // Device loss 165 gl::GraphicsResetStatus getResetStatus() override; 166 167 // Vendor and description strings. 168 std::string getVendorString() const override; 169 std::string getRendererDescription() const override; 170 171 // EXT_debug_marker 172 angle::Result insertEventMarker(GLsizei length, const char *marker) override; 173 angle::Result pushGroupMarker(GLsizei length, const char *marker) override; 174 angle::Result popGroupMarker() override; 175 176 // KHR_debug 177 angle::Result pushDebugGroup(const gl::Context *context, 178 GLenum source, 179 GLuint id, 180 const std::string &message) override; 181 angle::Result popDebugGroup(const gl::Context *context) override; 182 183 // State sync with dirty bits. 184 angle::Result syncState(const gl::Context *context, 185 const gl::State::DirtyBits &dirtyBits, 186 const gl::State::DirtyBits &bitMask) override; 187 188 // Disjoint timer queries 189 GLint getGPUDisjoint() override; 190 GLint64 getTimestamp() override; 191 192 // Context switching 193 angle::Result onMakeCurrent(const gl::Context *context) override; 194 195 // Caps queries 196 gl::Caps getNativeCaps() const override; 197 const gl::TextureCapsMap &getNativeTextureCaps() const override; 198 const gl::Extensions &getNativeExtensions() const override; 199 const gl::Limitations &getNativeLimitations() const override; 200 201 // Handle helpers getFunctions()202 ANGLE_INLINE const FunctionsGL *getFunctions() const { return mRenderer->getFunctions(); } 203 204 StateManagerGL *getStateManager(); 205 const angle::FeaturesGL &getFeaturesGL() const; 206 BlitGL *getBlitter() const; 207 ClearMultiviewGL *getMultiviewClearer() const; 208 209 angle::Result dispatchCompute(const gl::Context *context, 210 GLuint numGroupsX, 211 GLuint numGroupsY, 212 GLuint numGroupsZ) override; 213 angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) override; 214 215 angle::Result memoryBarrier(const gl::Context *context, GLbitfield barriers) override; 216 angle::Result memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override; 217 218 void setMaxShaderCompilerThreads(GLuint count) override; 219 220 void invalidateTexture(gl::TextureType target) override; 221 222 void validateState() const; 223 224 void setNeedsFlushBeforeDeleteTextures(); 225 void flushIfNecessaryBeforeDeleteTextures(); 226 227 private: 228 angle::Result setDrawArraysState(const gl::Context *context, 229 GLint first, 230 GLsizei count, 231 GLsizei instanceCount); 232 233 angle::Result setDrawElementsState(const gl::Context *context, 234 GLsizei count, 235 gl::DrawElementsType type, 236 const void *indices, 237 GLsizei instanceCount, 238 const void **outIndices); 239 240 gl::AttributesMask updateAttributesForBaseInstance(const gl::Program *program, 241 GLuint baseInstance); 242 void resetUpdatedAttributes(gl::AttributesMask attribMask); 243 244 protected: 245 std::shared_ptr<RendererGL> mRenderer; 246 }; 247 248 } // namespace rx 249 250 #endif // LIBANGLE_RENDERER_GL_CONTEXTGL_H_ 251