tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Context11.h (14511B)


      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 multiDrawArraysIndirect(const gl::Context *context,
    162                                          gl::PrimitiveMode mode,
    163                                          const void *indirect,
    164                                          GLsizei drawcount,
    165                                          GLsizei stride) override;
    166    angle::Result multiDrawElements(const gl::Context *context,
    167                                    gl::PrimitiveMode mode,
    168                                    const GLsizei *counts,
    169                                    gl::DrawElementsType type,
    170                                    const GLvoid *const *indices,
    171                                    GLsizei drawcount) override;
    172    angle::Result multiDrawElementsInstanced(const gl::Context *context,
    173                                             gl::PrimitiveMode mode,
    174                                             const GLsizei *counts,
    175                                             gl::DrawElementsType type,
    176                                             const GLvoid *const *indices,
    177                                             const GLsizei *instanceCounts,
    178                                             GLsizei drawcount) override;
    179    angle::Result multiDrawElementsIndirect(const gl::Context *context,
    180                                            gl::PrimitiveMode mode,
    181                                            gl::DrawElementsType type,
    182                                            const void *indirect,
    183                                            GLsizei drawcount,
    184                                            GLsizei stride) override;
    185    angle::Result multiDrawArraysInstancedBaseInstance(const gl::Context *context,
    186                                                       gl::PrimitiveMode mode,
    187                                                       const GLint *firsts,
    188                                                       const GLsizei *counts,
    189                                                       const GLsizei *instanceCounts,
    190                                                       const GLuint *baseInstances,
    191                                                       GLsizei drawcount) override;
    192    angle::Result multiDrawElementsInstancedBaseVertexBaseInstance(const gl::Context *context,
    193                                                                   gl::PrimitiveMode mode,
    194                                                                   const GLsizei *counts,
    195                                                                   gl::DrawElementsType type,
    196                                                                   const GLvoid *const *indices,
    197                                                                   const GLsizei *instanceCounts,
    198                                                                   const GLint *baseVertices,
    199                                                                   const GLuint *baseInstances,
    200                                                                   GLsizei drawcount) override;
    201 
    202    // Device loss
    203    gl::GraphicsResetStatus getResetStatus() override;
    204 
    205    // EXT_debug_marker
    206    angle::Result insertEventMarker(GLsizei length, const char *marker) override;
    207    angle::Result pushGroupMarker(GLsizei length, const char *marker) override;
    208    angle::Result popGroupMarker() override;
    209 
    210    // KHR_debug
    211    angle::Result pushDebugGroup(const gl::Context *context,
    212                                 GLenum source,
    213                                 GLuint id,
    214                                 const std::string &message) override;
    215    angle::Result popDebugGroup(const gl::Context *context) override;
    216 
    217    // State sync with dirty bits.
    218    angle::Result syncState(const gl::Context *context,
    219                            const gl::State::DirtyBits &dirtyBits,
    220                            const gl::State::DirtyBits &bitMask,
    221                            gl::Command command) override;
    222 
    223    // Disjoint timer queries
    224    GLint getGPUDisjoint() override;
    225    GLint64 getTimestamp() override;
    226 
    227    // Context switching
    228    angle::Result onMakeCurrent(const gl::Context *context) override;
    229 
    230    // Caps queries
    231    gl::Caps getNativeCaps() const override;
    232    const gl::TextureCapsMap &getNativeTextureCaps() const override;
    233    const gl::Extensions &getNativeExtensions() const override;
    234    const gl::Limitations &getNativeLimitations() const override;
    235    ShPixelLocalStorageType getNativePixelLocalStorageType() const override;
    236 
    237    Renderer11 *getRenderer() const { return mRenderer; }
    238 
    239    angle::Result dispatchCompute(const gl::Context *context,
    240                                  GLuint numGroupsX,
    241                                  GLuint numGroupsY,
    242                                  GLuint numGroupsZ) override;
    243    angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) override;
    244 
    245    angle::Result memoryBarrier(const gl::Context *context, GLbitfield barriers) override;
    246    angle::Result memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
    247 
    248    angle::Result triggerDrawCallProgramRecompilation(const gl::Context *context,
    249                                                      gl::PrimitiveMode drawMode);
    250    angle::Result triggerDispatchCallProgramRecompilation(const gl::Context *context);
    251    angle::Result getIncompleteTexture(const gl::Context *context,
    252                                       gl::TextureType type,
    253                                       gl::Texture **textureOut);
    254 
    255    angle::Result initializeMultisampleTextureToBlack(const gl::Context *context,
    256                                                      gl::Texture *glTexture) override;
    257 
    258    void handleResult(HRESULT hr,
    259                      const char *message,
    260                      const char *file,
    261                      const char *function,
    262                      unsigned int line) override;
    263 
    264  private:
    265    angle::Result drawElementsImpl(const gl::Context *context,
    266                                   gl::PrimitiveMode mode,
    267                                   GLsizei indexCount,
    268                                   gl::DrawElementsType indexType,
    269                                   const void *indices,
    270                                   GLsizei instanceCount,
    271                                   GLint baseVertex,
    272                                   GLuint baseInstance,
    273                                   bool promoteDynamic,
    274                                   bool isInstancedDraw);
    275 
    276    Renderer11 *mRenderer;
    277    IncompleteTextureSet mIncompleteTextures;
    278    std::stack<std::string> mMarkerStack;
    279 };
    280 }  // namespace rx
    281 
    282 #endif  // LIBANGLE_RENDERER_D3D_D3D11_CONTEXT11_H_