Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
GrD3DOpsRenderPass Class Reference

#include <GrD3DOpsRenderPass.h>

Inheritance diagram for GrD3DOpsRenderPass:
GrOpsRenderPass

Public Member Functions

 GrD3DOpsRenderPass (GrD3DGpu *)
 
 ~GrD3DOpsRenderPass () override
 
void inlineUpload (GrOpFlushState *state, GrDeferredTextureUploadFn &upload) override
 
void onExecuteDrawable (std::unique_ptr< SkDrawable::GpuDrawHandler >) override
 
bool set (GrRenderTarget *, GrSurfaceOrigin, const SkIRect &bounds, const GrOpsRenderPass::LoadAndStoreInfo &, const GrOpsRenderPass::StencilLoadAndStoreInfo &, const skia_private::TArray< GrSurfaceProxy *, true > &sampledProxies)
 
void submit ()
 
- Public Member Functions inherited from GrOpsRenderPass
virtual ~GrOpsRenderPass ()
 
void begin ()
 
void end ()
 
void bindPipeline (const GrProgramInfo &, const SkRect &drawBounds)
 
void setScissorRect (const SkIRect &)
 
void bindTextures (const GrGeometryProcessor &, const GrSurfaceProxy *const geomProcTextures[], const GrPipeline &)
 
void bindBuffers (sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart=GrPrimitiveRestart::kNo)
 
void draw (int vertexCount, int baseVertex)
 
void drawIndexed (int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex)
 
void drawInstanced (int instanceCount, int baseInstance, int vertexCount, int baseVertex)
 
void drawIndexedInstanced (int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex)
 
void drawIndirect (const GrBuffer *drawIndirectBuffer, size_t bufferOffset, int drawCount)
 
void drawIndexedIndirect (const GrBuffer *drawIndirectBuffer, size_t bufferOffset, int drawCount)
 
void drawIndexPattern (int patternIndexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, int patternVertexCount, int baseVertex)
 
void clear (const GrScissorState &scissor, std::array< float, 4 > color)
 
void clearStencilClip (const GrScissorState &scissor, bool insideStencilMask)
 
void executeDrawable (std::unique_ptr< SkDrawable::GpuDrawHandler >)
 

Private Member Functions

GrGpugpu () override
 
void onBegin () override
 
bool onBindPipeline (const GrProgramInfo &, const SkRect &drawBounds) override
 
void onSetScissorRect (const SkIRect &) override
 
bool onBindTextures (const GrGeometryProcessor &, const GrSurfaceProxy *const geomProcTextures[], const GrPipeline &) override
 
void onBindBuffers (sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart) override
 
void onDraw (int vertexCount, int baseVertex) override
 
void onDrawIndexed (int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex) override
 
void onDrawInstanced (int instanceCount, int baseInstance, int vertexCount, int baseVertex) override
 
void onDrawIndexedInstanced (int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex) override
 
void onDrawIndirect (const GrBuffer *, size_t offset, int drawCount) override
 
void onDrawIndexedIndirect (const GrBuffer *, size_t offset, int drawCount) override
 
void onClear (const GrScissorState &scissor, std::array< float, 4 > color) override
 
void onClearStencilClip (const GrScissorState &scissor, bool insideStencilMask) override
 

Additional Inherited Members

- Protected Member Functions inherited from GrOpsRenderPass
 GrOpsRenderPass ()
 
 GrOpsRenderPass (GrRenderTarget *rt, GrSurfaceOrigin origin)
 
void set (GrRenderTarget *rt, GrSurfaceOrigin origin)
 
- Protected Attributes inherited from GrOpsRenderPass
GrSurfaceOrigin fOrigin
 
GrRenderTargetfRenderTarget
 
sk_sp< const GrBufferfActiveIndexBuffer
 
sk_sp< const GrBufferfActiveVertexBuffer
 
sk_sp< const GrBufferfActiveInstanceBuffer
 

Detailed Description

Definition at line 19 of file GrD3DOpsRenderPass.h.

Constructor & Destructor Documentation

◆ GrD3DOpsRenderPass()

GrD3DOpsRenderPass::GrD3DOpsRenderPass ( GrD3DGpu gpu)

Definition at line 31 of file GrD3DOpsRenderPass.cpp.

31: fGpu(gpu) {}
GrGpu * gpu() override

◆ ~GrD3DOpsRenderPass()

GrD3DOpsRenderPass::~GrD3DOpsRenderPass ( )
override

Definition at line 53 of file GrD3DOpsRenderPass.cpp.

53{}

Member Function Documentation

◆ gpu()

GrGpu * GrD3DOpsRenderPass::gpu ( )
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 55 of file GrD3DOpsRenderPass.cpp.

55{ return fGpu; }

◆ inlineUpload()

void GrD3DOpsRenderPass::inlineUpload ( GrOpFlushState state,
GrDeferredTextureUploadFn upload 
)
overridevirtual

Implements GrOpsRenderPass.

Definition at line 342 of file GrD3DOpsRenderPass.cpp.

342 {
343 // If we ever start using copy command lists for doing uploads, then we'll need to make sure
344 // we submit our main command list before doing the copy here and then start a new main command
345 // list.
346
347 fGpu->endRenderPass(fRenderTarget, fOrigin, fBounds);
348
349 // We pass in true here to signal that after the upload we need to set the upload texture's
350 // resource state back to D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE.
351 state->doUpload(upload, true);
352}
void endRenderPass(GrRenderTarget *target, GrSurfaceOrigin origin, const SkIRect &bounds)
Definition GrD3DGpu.cpp:240
GrSurfaceOrigin fOrigin
GrRenderTarget * fRenderTarget
AtkStateType state

◆ onBegin()

void GrD3DOpsRenderPass::onBegin ( )
overrideprivatevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 57 of file GrD3DOpsRenderPass.cpp.

57 {
59 if (d3dRT->numSamples() > 1) {
60 d3dRT->msaaTextureResource()->setResourceState(fGpu, D3D12_RESOURCE_STATE_RENDER_TARGET);
61 } else {
62 d3dRT->setResourceState(fGpu, D3D12_RESOURCE_STATE_RENDER_TARGET);
63 }
64 fGpu->currentCommandList()->setRenderTarget(d3dRT);
65
66 if (GrLoadOp::kClear == fColorLoadOp) {
67 // Passing in nullptr for the rect clears the entire d3d RT. Is this correct? Does the load
68 // op respect the logical bounds of a RT?
69 fGpu->currentCommandList()->clearRenderTargetView(d3dRT, fClearColor, nullptr);
70 }
71
72 if (auto stencil = d3dRT->getStencilAttachment()) {
73 GrD3DAttachment* d3dStencil = static_cast<GrD3DAttachment*>(stencil);
74 d3dStencil->setResourceState(fGpu, D3D12_RESOURCE_STATE_DEPTH_WRITE);
75 if (fStencilLoadOp == GrLoadOp::kClear) {
76 fGpu->currentCommandList()->clearDepthStencilView(d3dStencil, 0, nullptr);
77 }
78 }
79}
void clearRenderTargetView(const GrD3DRenderTarget *renderTarget, std::array< float, 4 > color, const D3D12_RECT *rect)
void setRenderTarget(const GrD3DRenderTarget *renderTarget)
void clearDepthStencilView(const GrD3DAttachment *, uint8_t stencilClearValue, const D3D12_RECT *rect)
GrD3DDirectCommandList * currentCommandList() const
Definition GrD3DGpu.h:48
const GrD3DTextureResource * msaaTextureResource() const
void setResourceState(const GrD3DGpu *gpu, D3D12_RESOURCE_STATES newResourceState, unsigned int subresource=D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES)
int numSamples() const
GrAttachment * getStencilAttachment(bool useMSAASurface) const

◆ onBindBuffers()

void GrD3DOpsRenderPass::onBindBuffers ( sk_sp< const GrBuffer indexBuffer,
sk_sp< const GrBuffer instanceBuffer,
sk_sp< const GrBuffer vertexBuffer,
GrPrimitiveRestart  primRestart 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 243 of file GrD3DOpsRenderPass.cpp.

246 {
247 SkASSERT(GrPrimitiveRestart::kNo == primRestart);
248 SkASSERT(fCurrentPipelineState);
249 SkASSERT(!fGpu->caps()->usePrimitiveRestart()); // Ignore primitiveRestart parameter.
250
251 GrD3DDirectCommandList* currCmdList = fGpu->currentCommandList();
252 SkASSERT(currCmdList);
253
254 fCurrentPipelineState->bindBuffers(fGpu, std::move(indexBuffer), std::move(instanceBuffer),
255 std::move(vertexBuffer), currCmdList);
256}
#define SkASSERT(cond)
Definition SkAssert.h:116
bool usePrimitiveRestart() const
Definition GrCaps.h:112
void bindBuffers(GrD3DGpu *, sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrD3DDirectCommandList *commandList)
const GrCaps * caps() const
Definition GrGpu.h:73

◆ onBindPipeline()

bool GrD3DOpsRenderPass::onBindPipeline ( const GrProgramInfo info,
const SkRect drawBounds 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 172 of file GrD3DOpsRenderPass.cpp.

172 {
173 SkRect rtRect = SkRect::Make(fBounds);
174 if (rtRect.intersect(drawBounds)) {
175 rtRect.roundOut(&fCurrentPipelineBounds);
176 } else {
177 fCurrentPipelineBounds.setEmpty();
178 }
179
180 GrD3DRenderTarget* d3dRT = static_cast<GrD3DRenderTarget*>(fRenderTarget);
181 fCurrentPipelineState =
183 if (!fCurrentPipelineState) {
184 return false;
185 }
186
187 fGpu->currentCommandList()->setGraphicsRootSignature(fCurrentPipelineState->rootSignature());
188 fGpu->currentCommandList()->setPipelineState(fCurrentPipelineState->pipeline());
189 fCurrentPipelineState->setAndBindConstants(fGpu, fRenderTarget, info);
190
191 set_stencil_ref(fGpu, info);
192 set_blend_factor(fGpu, info);
194 if (!info.pipeline().isScissorTestEnabled()) {
195 // "Disable" scissor by setting it to the full pipeline bounds.
196 set_scissor_rects(fGpu, fRenderTarget, fOrigin, fCurrentPipelineBounds);
197 }
199
200 return true;
201}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
void set_blend_factor(GrD3DGpu *gpu, const GrProgramInfo &info)
void set_viewport(GrD3DGpu *gpu, const GrRenderTarget *renderTarget)
void set_scissor_rects(GrD3DGpu *gpu, const GrRenderTarget *renderTarget, GrSurfaceOrigin rtOrigin, const SkIRect &scissorRect)
void set_primitive_topology(GrD3DGpu *gpu, const GrProgramInfo &info)
void set_stencil_ref(GrD3DGpu *gpu, const GrProgramInfo &info)
void setGraphicsRootSignature(const sk_sp< GrD3DRootSignature > &rootSignature)
void setPipelineState(const sk_sp< GrD3DPipeline > &pipeline)
GrD3DResourceProvider & resourceProvider()
Definition GrD3DGpu.h:38
const sk_sp< GrD3DPipeline > & pipeline() const
void setAndBindConstants(GrD3DGpu *, const GrRenderTarget *, const GrProgramInfo &)
const sk_sp< GrD3DRootSignature > & rootSignature() const
GrD3DPipelineState * findOrCreateCompatiblePipelineState(GrD3DRenderTarget *, const GrProgramInfo &)
void setEmpty()
Definition SkRect.h:242
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
bool intersect(const SkRect &r)
Definition SkRect.cpp:114
void roundOut(SkIRect *dst) const
Definition SkRect.h:1241

◆ onBindTextures()

bool GrD3DOpsRenderPass::onBindTextures ( const GrGeometryProcessor geomProc,
const GrSurfaceProxy *const  geomProcTextures[],
const GrPipeline pipeline 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 219 of file GrD3DOpsRenderPass.cpp.

221 {
222 SkASSERT(fCurrentPipelineState);
223
224 // update textures to sampled resource state
225 for (int i = 0; i < geomProc.numTextureSamplers(); ++i) {
226 update_resource_state(geomProcTextures[i]->peekTexture(), fRenderTarget, fGpu);
227 }
228
229 pipeline.visitTextureEffects([&](const GrTextureEffect& te) {
231 });
232
233 if (GrTexture* dstTexture = pipeline.peekDstTexture()) {
234 update_resource_state(dstTexture, fRenderTarget, fGpu);
235 }
236
237 // TODO: possibly check for success once we start binding properly
238 fCurrentPipelineState->setAndBindTextures(fGpu, geomProc, geomProcTextures, pipeline);
239
240 return true;
241}
void update_resource_state(GrTexture *tex, GrRenderTarget *rt, GrD3DGpu *gpu)
void setAndBindTextures(GrD3DGpu *, const GrGeometryProcessor &, const GrSurfaceProxy *const geomProcTextures[], const GrPipeline &)
void visitTextureEffects(const std::function< void(const GrTextureEffect &)> &) const
GrTexture * peekDstTexture() const
Definition GrPipeline.h:145
GrTexture * texture() const

◆ onClear()

void GrD3DOpsRenderPass::onClear ( const GrScissorState scissor,
std::array< float, 4 >  color 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 314 of file GrD3DOpsRenderPass.cpp.

314 {
315 D3D12_RECT clearRect = scissor_to_d3d_clear_rect(scissor, fRenderTarget, fOrigin);
316 auto d3dRT = static_cast<GrD3DRenderTarget*>(fRenderTarget);
317 SkASSERT(d3dRT->grD3DResourceState()->getResourceState() == D3D12_RESOURCE_STATE_RENDER_TARGET);
318 fGpu->currentCommandList()->clearRenderTargetView(d3dRT, color, &clearRect);
319}
static D3D12_RECT scissor_to_d3d_clear_rect(const GrScissorState &scissor, const GrSurface *surface, GrSurfaceOrigin origin)
SkColor4f color

◆ onClearStencilClip()

void GrD3DOpsRenderPass::onClearStencilClip ( const GrScissorState scissor,
bool  insideStencilMask 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 321 of file GrD3DOpsRenderPass.cpp.

321 {
323 // this should only be called internally when we know we have a
324 // stencil buffer.
325 SkASSERT(sb);
326 int stencilBitCount = GrBackendFormatStencilBits(sb->backendFormat());
327
328 // The contract with the callers does not guarantee that we preserve all bits in the stencil
329 // during this clear. Thus we will clear the entire stencil to the desired value.
330
331 uint8_t stencilColor = 0;
332 if (insideStencilMask) {
333 stencilColor = (1 << (stencilBitCount - 1));
334 }
335
336 D3D12_RECT clearRect = scissor_to_d3d_clear_rect(scissor, fRenderTarget, fOrigin);
337
338 auto d3dStencil = static_cast<GrD3DAttachment*>(sb);
339 fGpu->currentCommandList()->clearDepthStencilView(d3dStencil, stencilColor, &clearRect);
340}
int GrBackendFormatStencilBits(const GrBackendFormat &format)
virtual GrBackendFormat backendFormat() const =0

◆ onDraw()

void GrD3DOpsRenderPass::onDraw ( int  vertexCount,
int  baseVertex 
)
inlineoverrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 48 of file GrD3DOpsRenderPass.h.

48 {
49 this->onDrawInstanced(1, 0, vertexCount, baseVertex);
50 }
void onDrawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex) override

◆ onDrawIndexed()

void GrD3DOpsRenderPass::onDrawIndexed ( int  indexCount,
int  baseIndex,
uint16_t  minIndexValue,
uint16_t  maxIndexValue,
int  baseVertex 
)
inlineoverrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 51 of file GrD3DOpsRenderPass.h.

52 {
53 this->onDrawIndexedInstanced(indexCount, baseIndex, 1, 0, baseVertex);
54 }
void onDrawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex) override

◆ onDrawIndexedIndirect()

void GrD3DOpsRenderPass::onDrawIndexedIndirect ( const GrBuffer buffer,
size_t  offset,
int  drawCount 
)
overrideprivatevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 282 of file GrD3DOpsRenderPass.cpp.

283 {
284 constexpr unsigned int kSlot = 0;
287 fGpu->currentCommandList()->executeIndirect(cmdSig, drawCount,
288 static_cast<const GrD3DBuffer*>(buffer), offset);
289 fGpu->stats()->incNumDraws();
290}
void executeIndirect(const sk_sp< GrD3DCommandSignature > commandSig, unsigned int maxCommandCnt, const GrD3DBuffer *argumentBuffer, size_t argumentBufferOffset)
sk_sp< GrD3DCommandSignature > findOrCreateCommandSignature(GrD3DCommandSignature::ForIndexed, unsigned int slot)
void incNumDraws()
Definition GrGpu.h:541
Stats * stats()
Definition GrGpu.h:551
static const uint8_t buffer[]
Point offset

◆ onDrawIndexedInstanced()

void GrD3DOpsRenderPass::onDrawIndexedInstanced ( int  indexCount,
int  baseIndex,
int  instanceCount,
int  baseInstance,
int  baseVertex 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 265 of file GrD3DOpsRenderPass.cpp.

266 {
267 SkASSERT(fCurrentPipelineState);
268 fGpu->currentCommandList()->drawIndexedInstanced(indexCount, instanceCount, baseIndex,
269 baseVertex, baseInstance);
270 fGpu->stats()->incNumDraws();
271}
void drawIndexedInstanced(unsigned int indexCount, unsigned int instanceCount, unsigned int startIndex, unsigned int baseVertex, unsigned int startInstance)

◆ onDrawIndirect()

void GrD3DOpsRenderPass::onDrawIndirect ( const GrBuffer buffer,
size_t  offset,
int  drawCount 
)
overrideprivatevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 273 of file GrD3DOpsRenderPass.cpp.

273 {
274 constexpr unsigned int kSlot = 0;
277 fGpu->currentCommandList()->executeIndirect(cmdSig, drawCount,
278 static_cast<const GrD3DBuffer*>(buffer), offset);
279 fGpu->stats()->incNumDraws();
280}

◆ onDrawInstanced()

void GrD3DOpsRenderPass::onDrawInstanced ( int  instanceCount,
int  baseInstance,
int  vertexCount,
int  baseVertex 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 258 of file GrD3DOpsRenderPass.cpp.

259 {
260 SkASSERT(fCurrentPipelineState);
261 fGpu->currentCommandList()->drawInstanced(vertexCount, instanceCount, baseVertex, baseInstance);
262 fGpu->stats()->incNumDraws();
263}
void drawInstanced(unsigned int vertexCount, unsigned int instanceCount, unsigned int startVertex, unsigned int startInstance)

◆ onExecuteDrawable()

void GrD3DOpsRenderPass::onExecuteDrawable ( std::unique_ptr< SkDrawable::GpuDrawHandler )
inlineoverridevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 27 of file GrD3DOpsRenderPass.h.

27{}

◆ onSetScissorRect()

void GrD3DOpsRenderPass::onSetScissorRect ( const SkIRect scissor)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 203 of file GrD3DOpsRenderPass.cpp.

203 {
204 SkIRect combinedScissorRect;
205 if (!combinedScissorRect.intersect(fCurrentPipelineBounds, scissor)) {
206 combinedScissorRect = SkIRect::MakeEmpty();
207 }
208
209 set_scissor_rects(fGpu, fRenderTarget, fOrigin, combinedScissorRect);
210}
bool intersect(const SkIRect &r)
Definition SkRect.h:513
static constexpr SkIRect MakeEmpty()
Definition SkRect.h:45

◆ set()

bool GrD3DOpsRenderPass::set ( GrRenderTarget rt,
GrSurfaceOrigin  origin,
const SkIRect bounds,
const GrOpsRenderPass::LoadAndStoreInfo colorInfo,
const GrOpsRenderPass::StencilLoadAndStoreInfo stencilInfo,
const skia_private::TArray< GrSurfaceProxy *, true > &  sampledProxies 
)

Definition at line 33 of file GrD3DOpsRenderPass.cpp.

36 {
38 SkASSERT(fGpu == rt->getContext()->priv().getGpu());
39
40 this->INHERITED::set(rt, origin);
41
42 fBounds = bounds;
43
44 fColorLoadOp = colorInfo.fLoadOp;
45 fClearColor = colorInfo.fClearColor;
46 fStencilLoadOp = stencilInfo.fLoadOp;
47
48 // TODO
49
50 return true;
51}
GrDirectContextPriv priv()
const GrDirectContext * getContext() const
void set(GrRenderTarget *rt, GrSurfaceOrigin origin)
Optional< SkRect > bounds
Definition SkRecords.h:189
std::array< float, 4 > fClearColor

◆ submit()

void GrD3DOpsRenderPass::submit ( )

Definition at line 354 of file GrD3DOpsRenderPass.cpp.

354 {
355 if (!fRenderTarget) {
356 return;
357 }
358
359 // We don't use render passes in d3d, so there is nothing to submit here as all commands have
360 // already been recorded on the main command list. If in the future we start to use render
361 // passes on d3d12 devices that support them (most likely ARM devices), then we
362 // will submit them here.
363 fGpu->endRenderPass(fRenderTarget, fOrigin, fBounds);
364}

The documentation for this class was generated from the following files: