Debian Codegraph @

src/gpu/ganesh/vk/GrVkOpsRenderPass.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
8 #ifndef GrVkOpsRenderPass_DEFINED
9 #define GrVkOpsRenderPass_DEFINED
10
11 #include "include/core/SkDrawable.h"
12 #include "include/core/SkRect.h"
13 #include "include/core/SkRefCnt.h"
14 #include "include/private/base/SkDebug.h"
15 #include "include/private/base/SkTArray.h"
16 #include "include/private/gpu/vk/SkiaVulkan.h"
17 #include "src/gpu/ganesh/GrDeferredUpload.h"
18 #include "src/gpu/ganesh/GrGeometryProcessor.h"
19 #include "src/gpu/ganesh/GrOpsRenderPass.h"
20 #include "src/gpu/ganesh/vk/GrVkRenderPass.h"
21
22 #include <array>
23 #include <cstddef>
24 #include <cstdint>
25 #include <memory>
26
27 class GrBuffer;
28 class GrGpu;
29 class GrOpFlushState;
30 class GrPipeline;
31 class GrProgramInfo;
32 class GrRenderTarget;
33 class GrScissorState;
34 class GrSurfaceProxy;
35 class GrVkCommandBuffer;
36 class GrVkFramebuffer;
37 class GrVkGpu;
38 class GrVkPipelineState;
39 class GrVkSecondaryCommandBuffer;
40 enum GrSurfaceOrigin : int;
41 enum class GrPrimitiveRestart : bool;
42
43 class GrVkOpsRenderPass : public GrOpsRenderPass {
44 public:
45 GrVkOpsRenderPass(GrVkGpu*);
46
47 ~GrVkOpsRenderPass() override;
48
•49 // Returns true upon successful upload and false upon failure.
50 bool inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override;
51
52 void onExecuteDrawable(std::unique_ptr<SkDrawable::GpuDrawHandler>) override;
53
54 bool set(GrRenderTarget*,
55 sk_sp<GrVkFramebuffer>,
56 GrSurfaceOrigin,
57 const SkIRect& bounds,
58 const GrOpsRenderPass::LoadAndStoreInfo&,
59 const GrOpsRenderPass::StencilLoadAndStoreInfo&,
60 const GrOpsRenderPass::LoadAndStoreInfo& resolveInfo,
61 GrVkRenderPass::SelfDependencyFlags selfDepFlags,
62 GrVkRenderPass::LoadFromResolve loadFromResolve,
63 const skia_private::TArray<GrSurfaceProxy*, true>& sampledProxies);
64 void reset();
65
66 void submit();
67
68 #ifdef SK_DEBUG
69 bool isActive() const { return fIsActive; }
70 #endif
71
72 private:
73 bool init(const GrOpsRenderPass::LoadAndStoreInfo& colorInfo,
74 const GrOpsRenderPass::LoadAndStoreInfo& resolveInfo,
75 const GrOpsRenderPass::StencilLoadAndStoreInfo&);
76
77 // Called instead of init when we are drawing to a render target that already wraps a secondary
78 // command buffer.
79 bool initWrapped();
80
81 bool wrapsSecondaryCommandBuffer() const;
82
83 GrGpu* gpu() override;
84
85 GrVkCommandBuffer* currentCommandBuffer();
86
87 void onEnd() override;
88
89 bool onBindPipeline(const GrProgramInfo&, const SkRect& drawBounds) override;
90 void onSetScissorRect(const SkIRect&) override;
91 bool onBindTextures(const GrGeometryProcessor&,
92 const GrSurfaceProxy* const geomProcTextures[],
93 const GrPipeline&) override;
94 void onBindBuffers(sk_sp<const GrBuffer> indexBuffer, sk_sp<const GrBuffer> instanceBuffer,
95 sk_sp<const GrBuffer> vertexBuffer, GrPrimitiveRestart) override;
96 void onDraw(int vertexCount, int baseVertex) override {
97 this->onDrawInstanced(1, 0, vertexCount, baseVertex);
98 }
99 void onDrawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue,
100 uint16_t maxIndexValue, int baseVertex) override {
101 this->onDrawIndexedInstanced(indexCount, baseIndex, 1, 0, baseVertex);
102 }
103 void onDrawInstanced(int instanceCount, int baseInstance, int vertexCount,
104 int baseVertex) override;
105 void onDrawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance,
106 int baseVertex) override;
107 void onDrawIndirect(const GrBuffer* drawIndirectBuffer, size_t offset, int drawCount) override;
108 void onDrawIndexedIndirect(const GrBuffer* drawIndirectBuffer, size_t offset,
109 int drawCount) override;
110
111 void onClear(const GrScissorState& scissor, std::array<float, 4> color) override;
112
113 void onClearStencilClip(const GrScissorState& scissor, bool insideStencilMask) override;
114
115 using LoadFromResolve = GrVkRenderPass::LoadFromResolve;
116
117 bool beginRenderPass(const VkClearValue& clearColor, LoadFromResolve loadFromResolve);
118
119 void addAdditionalRenderPass(bool mustUseSecondaryCommandBuffer);
120
121 void setAttachmentLayouts(LoadFromResolve loadFromResolve);
122
123 void loadResolveIntoMSAA(const SkIRect& nativeBounds);
124
125 using SelfDependencyFlags = GrVkRenderPass::SelfDependencyFlags;
126
127 sk_sp<GrVkFramebuffer> fFramebuffer;
128 std::unique_ptr<GrVkSecondaryCommandBuffer> fCurrentSecondaryCommandBuffer;
129 const GrVkRenderPass* fCurrentRenderPass;
130 SkIRect fCurrentPipelineBounds;
131 GrVkPipelineState* fCurrentPipelineState = nullptr;
132 bool fCurrentCBIsEmpty = true;
133 SkIRect fBounds;
134 SelfDependencyFlags fSelfDependencyFlags = SelfDependencyFlags::kNone;
135 LoadFromResolve fLoadFromResolve = LoadFromResolve::kNo;
136 bool fOverridePipelinesForResolveLoad = false;
137
138 GrVkGpu* fGpu;
139
140 #ifdef SK_DEBUG
141 // When we are actively recording into the GrVkOpsRenderPass we set this flag to true. This
142 // then allows us to assert that we never submit a primary command buffer to the queue while in
143 // a recording state. This is needed since when we submit to the queue we change command pools
144 // and may trigger the old one to be reset, but a recording GrVkOpsRenderPass may still have
145 // a outstanding secondary command buffer allocated from that pool that we'll try to access
146 // after the pool as been reset.
147 bool fIsActive = false;
148 #endif
149
150 using INHERITED = GrOpsRenderPass;
151 };
152
153 #endif