Debian Codegraph @

src/gpu/ganesh/gl/GrGLOpsRenderPass.h

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #ifndef GrGLOpsRenderPass_DEFINED
8 #define GrGLOpsRenderPass_DEFINED
9
10 #include "include/core/SkRect.h"
11 #include "include/core/SkRefCnt.h"
12 #include "include/private/base/SkDebug.h"
13 #include "src/gpu/ganesh/GrDeferredUpload.h"
14 #include "src/gpu/ganesh/GrGeometryProcessor.h"
15 #include "src/gpu/ganesh/GrNativeRect.h"
16 #include "src/gpu/ganesh/GrOpFlushState.h"
17 #include "src/gpu/ganesh/GrOpsRenderPass.h"
18 #include "src/gpu/ganesh/gl/GrGLGpu.h"
19
20 #include <array>
21 #include <cstddef>
22 #include <cstdint>
23
24 class GrBuffer;
25 class GrGLAttribArrayState;
26 class GrGpu;
27 class GrPipeline;
28 class GrProgramInfo;
29 class GrRenderTarget;
30 class GrScissorState;
31 class GrSurfaceProxy;
32 enum GrSurfaceOrigin : int;
33 enum class GrPrimitiveRestart : bool;
34 enum class GrPrimitiveType : uint8_t;
35
36 class GrGLOpsRenderPass : public GrOpsRenderPass {
37 /**
38 * We do not actually buffer up draws or do any work in the this class for GL. Instead commands
39 * are immediately sent to the gpu to execute. Thus all the commands in this class are simply
40 * pass through functions to corresponding calls in the GrGLGpu class.
41 */
42 public:
43 GrGLOpsRenderPass(GrGLGpu* gpu) : fGpu(gpu) {}
44
•45 bool inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override {
46 state->doUpload(upload);
•47 return true;
48 }
49
50 void set(GrRenderTarget*, bool useMSAASurface, const SkIRect& contentBounds, GrSurfaceOrigin,
51 const LoadAndStoreInfo&, const StencilLoadAndStoreInfo&);
52
53 void reset() {
54 fRenderTarget = nullptr;
55 }
56
57 private:
58 GrGpu* gpu() override { return fGpu; }
59
60 void bindInstanceBuffer(const GrBuffer*, int baseInstance);
61 void bindVertexBuffer(const GrBuffer*, int baseVertex);
62
63 const void* offsetForBaseIndex(int baseIndex) const {
64 if (!fIndexPointer) {
65 // nullptr != 0. Adding an offset to a nullptr is undefined.
66 return (void*)(baseIndex * sizeof(uint16_t));
67 }
68 return fIndexPointer + baseIndex;
69 }
70
71 // Ideally we load and store DMSAA only within the content bounds of our render pass, but if
72 // the caps don't allow for partial framebuffer blits, we resolve the full target.
73 // We resolve the same bounds during load and store both because if we have to do a full size
74 // resolve at the end, the full DMSAA attachment needs to have valid content.
75 GrNativeRect dmsaaLoadStoreBounds() const;
76
77 void onBegin() override;
78 void onEnd() override;
79 bool onBindPipeline(const GrProgramInfo& programInfo, const SkRect& drawBounds) override;
80 void onSetScissorRect(const SkIRect& scissor) override;
81 bool onBindTextures(const GrGeometryProcessor&,
82 const GrSurfaceProxy* const geomProcTextures[],
83 const GrPipeline&) override;
84 void onBindBuffers(sk_sp<const GrBuffer> indexBuffer, sk_sp<const GrBuffer> instanceBuffer,
85 sk_sp<const GrBuffer> vertexBuffer, GrPrimitiveRestart) override;
86 void onDraw(int vertexCount, int baseVertex) override;
87 void onDrawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue,
88 uint16_t maxIndexValue, int baseVertex) override;
89 void onDrawInstanced(int instanceCount, int baseInstance, int vertexCount,
90 int baseVertex) override;
91 void onDrawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance,
92 int baseVertex) override;
93 void onDrawIndirect(const GrBuffer* drawIndirectBuffer, size_t offset, int drawCount) override;
94 void multiDrawArraysANGLEOrWebGL(const GrBuffer* drawIndirectBuffer, size_t offset,
95 int drawCount);
96 void onDrawIndexedIndirect(const GrBuffer* drawIndirectBuffer, size_t offset,
97 int drawCount) override;
98 void multiDrawElementsANGLEOrWebGL(const GrBuffer* drawIndirectBuffer, size_t offset,
99 int drawCount);
100 void onClear(const GrScissorState& scissor, std::array<float, 4> color) override;
101 void onClearStencilClip(const GrScissorState& scissor, bool insideStencilMask) override;
102
103 GrGLGpu* const fGpu;
104
105 bool fUseMultisampleFBO;
106 SkIRect fContentBounds;
107 LoadAndStoreInfo fColorLoadAndStoreInfo;
108 StencilLoadAndStoreInfo fStencilLoadAndStoreInfo;
109
110 // Per-pipeline state.
111 GrPrimitiveType fPrimitiveType;
112 GrGLAttribArrayState* fAttribArrayState = nullptr;
113
114 // If using an index buffer, this gets set during onBindBuffers. It is either the CPU address of
115 // the indices, or nullptr if they reside physically in GPU memory.
116 const uint16_t* fIndexPointer;
117
118 // This tracks whether or not we bound the respective buffers during the bindBuffers call.
119 SkDEBUGCODE(bool fDidBindVertexBuffer = false;)
120 SkDEBUGCODE(bool fDidBindInstanceBuffer = false;)
121
122 using INHERITED = GrOpsRenderPass;
123 };
124
125 #endif