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