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

#include <GrVkOpsRenderPass.h>

Inheritance diagram for GrVkOpsRenderPass:
GrOpsRenderPass

Public Member Functions

 GrVkOpsRenderPass (GrVkGpu *)
 
 ~GrVkOpsRenderPass () override
 
void inlineUpload (GrOpFlushState *state, GrDeferredTextureUploadFn &upload) override
 
void onExecuteDrawable (std::unique_ptr< SkDrawable::GpuDrawHandler >) override
 
bool set (GrRenderTarget *, sk_sp< GrVkFramebuffer >, GrSurfaceOrigin, const SkIRect &bounds, const GrOpsRenderPass::LoadAndStoreInfo &, const GrOpsRenderPass::StencilLoadAndStoreInfo &, const GrOpsRenderPass::LoadAndStoreInfo &resolveInfo, GrVkRenderPass::SelfDependencyFlags selfDepFlags, GrVkRenderPass::LoadFromResolve loadFromResolve, const skia_private::TArray< GrSurfaceProxy *, true > &sampledProxies)
 
void reset ()
 
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 onEnd () 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 *drawIndirectBuffer, size_t offset, int drawCount) override
 
void onDrawIndexedIndirect (const GrBuffer *drawIndirectBuffer, 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 25 of file GrVkOpsRenderPass.h.

Constructor & Destructor Documentation

◆ GrVkOpsRenderPass()

GrVkOpsRenderPass::GrVkOpsRenderPass ( GrVkGpu gpu)

Definition at line 67 of file GrVkOpsRenderPass.cpp.

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

◆ ~GrVkOpsRenderPass()

GrVkOpsRenderPass::~GrVkOpsRenderPass ( )
override

Definition at line 288 of file GrVkOpsRenderPass.cpp.

288 {
289 this->reset();
290}

Member Function Documentation

◆ gpu()

GrGpu * GrVkOpsRenderPass::gpu ( )
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 292 of file GrVkOpsRenderPass.cpp.

292{ return fGpu; }

◆ inlineUpload()

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

Implements GrOpsRenderPass.

Definition at line 600 of file GrVkOpsRenderPass.cpp.

600 {
601 if (!fCurrentRenderPass) {
602 SkASSERT(fGpu->isDeviceLost());
603 return;
604 }
605 if (fCurrentSecondaryCommandBuffer) {
606 fCurrentSecondaryCommandBuffer->end(fGpu);
607 fGpu->submitSecondaryCommandBuffer(std::move(fCurrentSecondaryCommandBuffer));
608 }
609 fGpu->endRenderPass(fRenderTarget, fOrigin, fBounds);
610
611 // We pass in true here to signal that after the upload we need to set the upload textures
612 // layout back to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL.
613 state->doUpload(upload, true);
614
615 this->addAdditionalRenderPass(false);
616}
#define SkASSERT(cond)
Definition SkAssert.h:116
GrSurfaceOrigin fOrigin
GrRenderTarget * fRenderTarget
void endRenderPass(GrRenderTarget *target, GrSurfaceOrigin origin, const SkIRect &bounds)
Definition GrVkGpu.cpp:2667
bool isDeviceLost() const override
Definition GrVkGpu.h:66
void submitSecondaryCommandBuffer(std::unique_ptr< GrVkSecondaryCommandBuffer >)
Definition GrVkGpu.cpp:2699
AtkStateType state

◆ onBindBuffers()

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

Implements GrOpsRenderPass.

Definition at line 725 of file GrVkOpsRenderPass.cpp.

728 {
729 SkASSERT(GrPrimitiveRestart::kNo == primRestart);
730 if (!fCurrentRenderPass) {
731 SkASSERT(fGpu->isDeviceLost());
732 return;
733 }
734 SkASSERT(fCurrentPipelineState);
735 SkASSERT(!fGpu->caps()->usePrimitiveRestart()); // Ignore primitiveRestart parameter.
736
737 GrVkCommandBuffer* currCmdBuf = this->currentCommandBuffer();
738 SkASSERT(currCmdBuf);
739
740 // There is no need to put any memory barriers to make sure host writes have finished here.
741 // When a command buffer is submitted to a queue, there is an implicit memory barrier that
742 // occurs for all host writes. Additionally, BufferMemoryBarriers are not allowed inside of
743 // an active RenderPass.
744
745 // Here our vertex and instance inputs need to match the same 0-based bindings they were
746 // assigned in GrVkPipeline. That is, vertex first (if any) followed by instance.
747 uint32_t binding = 0;
748 if (vertexBuffer) {
749 SkDEBUGCODE(auto* gpuVertexBuffer = static_cast<const GrGpuBuffer*>(vertexBuffer.get()));
750 SkASSERT(!gpuVertexBuffer->isCpuBuffer());
751 SkASSERT(!gpuVertexBuffer->isMapped());
752 currCmdBuf->bindInputBuffer(fGpu, binding++, std::move(vertexBuffer));
753 }
754 if (instanceBuffer) {
755 SkDEBUGCODE(auto* gpuInstanceBuffer =
756 static_cast<const GrGpuBuffer*>(instanceBuffer.get()));
757 SkASSERT(!gpuInstanceBuffer->isCpuBuffer());
758 SkASSERT(!gpuInstanceBuffer->isMapped());
759 currCmdBuf->bindInputBuffer(fGpu, binding++, std::move(instanceBuffer));
760 }
761 if (indexBuffer) {
762 SkDEBUGCODE(auto* gpuIndexBuffer = static_cast<const GrGpuBuffer*>(indexBuffer.get()));
763 SkASSERT(!gpuIndexBuffer->isCpuBuffer());
764 SkASSERT(!gpuIndexBuffer->isMapped());
765 currCmdBuf->bindIndexBuffer(fGpu, std::move(indexBuffer));
766 }
767}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
bool usePrimitiveRestart() const
Definition GrCaps.h:112
const GrCaps * caps() const
Definition GrGpu.h:73
void bindIndexBuffer(GrVkGpu *gpu, sk_sp< const GrBuffer > buffer)
void bindInputBuffer(GrVkGpu *gpu, uint32_t binding, sk_sp< const GrBuffer > buffer)
T * get() const
Definition SkRefCnt.h:303

◆ onBindPipeline()

bool GrVkOpsRenderPass::onBindPipeline ( const GrProgramInfo programInfo,
const SkRect drawBounds 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 626 of file GrVkOpsRenderPass.cpp.

626 {
627 if (!fCurrentRenderPass) {
628 SkASSERT(fGpu->isDeviceLost());
629 return false;
630 }
631
632 SkRect rtRect = SkRect::Make(fBounds);
633 if (rtRect.intersect(drawBounds)) {
634 rtRect.roundOut(&fCurrentPipelineBounds);
635 } else {
636 fCurrentPipelineBounds.setEmpty();
637 }
638
639 GrVkCommandBuffer* currentCB = this->currentCommandBuffer();
640 SkASSERT(fCurrentRenderPass);
641
642 VkRenderPass compatibleRenderPass = fCurrentRenderPass->vkRenderPass();
643 fCurrentPipelineState = fGpu->resourceProvider().findOrCreateCompatiblePipelineState(
644 fRenderTarget, programInfo, compatibleRenderPass, fOverridePipelinesForResolveLoad);
645 if (!fCurrentPipelineState) {
646 return false;
647 }
648
649 fCurrentPipelineState->bindPipeline(fGpu, currentCB);
650
651 // Both the 'programInfo' and this renderPass have an origin. Since they come from the
652 // same place (i.e., the target renderTargetProxy) they had best agree.
653 SkASSERT(programInfo.origin() == fOrigin);
654
655 auto colorAttachment = fFramebuffer->colorAttachment();
656 if (!fCurrentPipelineState->setAndBindUniforms(fGpu, colorAttachment->dimensions(), programInfo,
657 currentCB)) {
658 return false;
659 }
660
661 if (!programInfo.pipeline().isScissorTestEnabled()) {
662 // "Disable" scissor by setting it to the full pipeline bounds.
664 fGpu, currentCB, colorAttachment->dimensions(), fOrigin,
665 fCurrentPipelineBounds);
666 }
667 GrVkPipeline::SetDynamicViewportState(fGpu, currentCB, colorAttachment->dimensions());
669 programInfo.pipeline().writeSwizzle(),
670 programInfo.pipeline().getXferProcessor());
671
672 return true;
673}
const skgpu::Swizzle & writeSwizzle() const
Definition GrPipeline.h:197
bool isScissorTestEnabled() const
Definition GrPipeline.h:163
const GrXferProcessor & getXferProcessor() const
Definition GrPipeline.h:116
GrSurfaceOrigin origin() const
const GrPipeline & pipeline() const
GrVkImage * colorAttachment()
GrVkResourceProvider & resourceProvider()
Definition GrVkGpu.h:83
bool setAndBindUniforms(GrVkGpu *, SkISize colorAttachmentDimensions, const GrProgramInfo &, GrVkCommandBuffer *)
void bindPipeline(const GrVkGpu *gpu, GrVkCommandBuffer *commandBuffer)
static void SetDynamicScissorRectState(GrVkGpu *, GrVkCommandBuffer *, SkISize colorAttachmentDimensions, GrSurfaceOrigin, const SkIRect &scissorRect)
static void SetDynamicBlendConstantState(GrVkGpu *, GrVkCommandBuffer *, const skgpu::Swizzle &writeSwizzle, const GrXferProcessor &)
static void SetDynamicViewportState(GrVkGpu *, GrVkCommandBuffer *, SkISize colorAttachmentDimensions)
VkRenderPass vkRenderPass() const
GrVkPipelineState * findOrCreateCompatiblePipelineState(GrRenderTarget *, const GrProgramInfo &, VkRenderPass compatibleRenderPass, bool overrideSubpassForResolveLoad)
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 GrVkOpsRenderPass::onBindTextures ( const GrGeometryProcessor geomProc,
const GrSurfaceProxy *const  geomProcTextures[],
const GrPipeline pipeline 
)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 693 of file GrVkOpsRenderPass.cpp.

695 {
696#ifdef SK_DEBUG
697 SkASSERT(fCurrentPipelineState);
698 auto colorAttachment = fFramebuffer->colorAttachment();
699 for (int i = 0; i < geomProc.numTextureSamplers(); ++i) {
700 check_sampled_texture(geomProcTextures[i]->peekTexture(), colorAttachment, fGpu);
701 }
702 pipeline.visitTextureEffects([&](const GrTextureEffect& te) {
703 check_sampled_texture(te.texture(), colorAttachment, fGpu);
704 });
705 if (GrTexture* dstTexture = pipeline.peekDstTexture()) {
706 check_sampled_texture(dstTexture, colorAttachment, fGpu);
707 }
708#endif
709 if (!fCurrentPipelineState->setAndBindTextures(fGpu, geomProc, pipeline, geomProcTextures,
710 this->currentCommandBuffer())) {
711 return false;
712 }
713 if (fSelfDependencyFlags == SelfDependencyFlags::kForInputAttachment) {
714 // We bind the color attachment as an input attachment
715 auto ds = fFramebuffer->colorAttachment()->inputDescSetForBlending(fGpu);
716 if (!ds) {
717 return false;
718 }
719 return fCurrentPipelineState->setAndBindInputAttachment(fGpu, std::move(ds),
720 this->currentCommandBuffer());
721 }
722 return true;
723}
void visitTextureEffects(const std::function< void(const GrTextureEffect &)> &) const
GrTexture * peekDstTexture() const
Definition GrPipeline.h:145
GrTexture * texture() const
gr_rp< const GrVkDescriptorSet > inputDescSetForBlending(GrVkGpu *gpu)
bool setAndBindTextures(GrVkGpu *, const GrGeometryProcessor &, const GrPipeline &, const GrSurfaceProxy *const geomProcTextures[], GrVkCommandBuffer *)
bool setAndBindInputAttachment(GrVkGpu *, gr_rp< const GrVkDescriptorSet > inputDescSet, GrVkCommandBuffer *)

◆ onClear()

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

Implements GrOpsRenderPass.

Definition at line 485 of file GrVkOpsRenderPass.cpp.

485 {
486 if (!fCurrentRenderPass) {
487 SkASSERT(fGpu->isDeviceLost());
488 return;
489 }
490
491 VkClearColorValue vkColor = {{color[0], color[1], color[2], color[3]}};
492
493 // If we end up in a situation where we are calling clear without a scissior then in general it
494 // means we missed an opportunity higher up the stack to set the load op to be a clear. However,
495 // there are situations where higher up we couldn't discard the previous ops and set a clear
496 // load op (e.g. if we needed to execute a wait op). Thus we also have the empty check here.
497 // TODO: Make the waitOp a RenderTask instead so we can clear out the OpsTask for a clear. We
498 // can then reenable this assert assuming we can't get messed up by a waitOp.
499 //SkASSERT(!fCurrentCBIsEmpty || scissor);
500
501 auto dimensions = fFramebuffer->colorAttachment()->dimensions();
502 // We always do a sub rect clear with clearAttachments since we are inside a render pass
503 VkClearRect clearRect;
504 // Flip rect if necessary
505 SkIRect vkRect;
506 if (!scissor.enabled()) {
507 vkRect.setSize(dimensions);
508 } else if (kBottomLeft_GrSurfaceOrigin != fOrigin) {
509 vkRect = scissor.rect();
510 } else {
511 vkRect.setLTRB(scissor.rect().fLeft, dimensions.height() - scissor.rect().fBottom,
512 scissor.rect().fRight, dimensions.height() - scissor.rect().fTop);
513 }
514 clearRect.rect.offset = { vkRect.fLeft, vkRect.fTop };
515 clearRect.rect.extent = { (uint32_t)vkRect.width(), (uint32_t)vkRect.height() };
516 clearRect.baseArrayLayer = 0;
517 clearRect.layerCount = 1;
518
519 uint32_t colorIndex;
520 SkAssertResult(fCurrentRenderPass->colorAttachmentIndex(&colorIndex));
521
522 VkClearAttachment attachment;
524 attachment.colorAttachment = colorIndex;
525 attachment.clearValue.color = vkColor;
526
527 this->currentCommandBuffer()->clearAttachments(fGpu, 1, &attachment, 1, &clearRect);
528 fCurrentCBIsEmpty = false;
529}
@ kBottomLeft_GrSurfaceOrigin
Definition GrTypes.h:149
SkColor4f color
#define SkAssertResult(cond)
Definition SkAssert.h:123
bool enabled() const
const SkIRect & rect() const
SkISize dimensions() const
Definition GrSurface.h:27
void clearAttachments(const GrVkGpu *gpu, int numAttachments, const VkClearAttachment *attachments, int numRects, const VkClearRect *clearRects)
bool colorAttachmentIndex(uint32_t *index) const
int32_t fBottom
larger y-axis bounds
Definition SkRect.h:36
constexpr int32_t height() const
Definition SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
constexpr int32_t width() const
Definition SkRect.h:158
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33
void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
Definition SkRect.h:253
int32_t fRight
larger x-axis bounds
Definition SkRect.h:35
void setSize(SkISize size)
Definition SkRect.h:282
VkImageAspectFlags aspectMask
VkClearValue clearValue
uint32_t colorAttachment
VkRect2D rect
uint32_t layerCount
uint32_t baseArrayLayer
VkExtent2D extent
VkOffset2D offset
VkClearColorValue color
@ VK_IMAGE_ASPECT_COLOR_BIT

◆ onClearStencilClip()

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

Implements GrOpsRenderPass.

Definition at line 432 of file GrVkOpsRenderPass.cpp.

432 {
433 if (!fCurrentRenderPass) {
434 SkASSERT(fGpu->isDeviceLost());
435 return;
436 }
437
438 GrAttachment* sb = fFramebuffer->stencilAttachment();
439 // this should only be called internally when we know we have a
440 // stencil buffer.
441 SkASSERT(sb);
442 int stencilBitCount = GrBackendFormatStencilBits(sb->backendFormat());
443
444 // The contract with the callers does not guarantee that we preserve all bits in the stencil
445 // during this clear. Thus we will clear the entire stencil to the desired value.
446
447 VkClearDepthStencilValue vkStencilColor;
448 memset(&vkStencilColor, 0, sizeof(VkClearDepthStencilValue));
449 if (insideStencilMask) {
450 vkStencilColor.stencil = (1 << (stencilBitCount - 1));
451 } else {
452 vkStencilColor.stencil = 0;
453 }
454
455 VkClearRect clearRect;
456 // Flip rect if necessary
457 SkIRect vkRect;
458 if (!scissor.enabled()) {
459 vkRect.setXYWH(0, 0, sb->width(), sb->height());
460 } else if (kBottomLeft_GrSurfaceOrigin != fOrigin) {
461 vkRect = scissor.rect();
462 } else {
463 vkRect.setLTRB(scissor.rect().fLeft, sb->height() - scissor.rect().fBottom,
464 scissor.rect().fRight, sb->height() - scissor.rect().fTop);
465 }
466
467 clearRect.rect.offset = { vkRect.fLeft, vkRect.fTop };
468 clearRect.rect.extent = { (uint32_t)vkRect.width(), (uint32_t)vkRect.height() };
469
470 clearRect.baseArrayLayer = 0;
471 clearRect.layerCount = 1;
472
473 uint32_t stencilIndex;
474 SkAssertResult(fCurrentRenderPass->stencilAttachmentIndex(&stencilIndex));
475
476 VkClearAttachment attachment;
478 attachment.colorAttachment = 0; // this value shouldn't matter
479 attachment.clearValue.depthStencil = vkStencilColor;
480
481 this->currentCommandBuffer()->clearAttachments(fGpu, 1, &attachment, 1, &clearRect);
482 fCurrentCBIsEmpty = false;
483}
int GrBackendFormatStencilBits(const GrBackendFormat &format)
virtual GrBackendFormat backendFormat() const =0
int height() const
Definition GrSurface.h:37
int width() const
Definition GrSurface.h:32
GrVkImage * stencilAttachment()
bool stencilAttachmentIndex(uint32_t *index) const
void setXYWH(int32_t x, int32_t y, int32_t width, int32_t height)
Definition SkRect.h:268
VkClearDepthStencilValue depthStencil
@ VK_IMAGE_ASPECT_STENCIL_BIT

◆ onDraw()

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

Implements GrOpsRenderPass.

Definition at line 77 of file GrVkOpsRenderPass.h.

77 {
78 this->onDrawInstanced(1, 0, vertexCount, baseVertex);
79 }
void onDrawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex) override

◆ onDrawIndexed()

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

Implements GrOpsRenderPass.

Definition at line 80 of file GrVkOpsRenderPass.h.

81 {
82 this->onDrawIndexedInstanced(indexCount, baseIndex, 1, 0, baseVertex);
83 }
void onDrawIndexedInstanced(int indexCount, int baseIndex, int instanceCount, int baseInstance, int baseVertex) override

◆ onDrawIndexedIndirect()

void GrVkOpsRenderPass::onDrawIndexedIndirect ( const GrBuffer drawIndirectBuffer,
size_t  offset,
int  drawCount 
)
overrideprivatevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 820 of file GrVkOpsRenderPass.cpp.

821 {
822 SkASSERT(!drawIndirectBuffer->isCpuBuffer());
823 if (!fCurrentRenderPass) {
824 SkASSERT(fGpu->isDeviceLost());
825 return;
826 }
827 const GrVkCaps& caps = fGpu->vkCaps();
829 SkASSERT(fCurrentPipelineState);
830 const uint32_t maxDrawCount = caps.maxDrawIndirectDrawCount();
831 uint32_t remainingDraws = drawCount;
832 const size_t stride = sizeof(GrDrawIndexedIndirectCommand);
833 while (remainingDraws >= 1) {
834 uint32_t currDrawCount = std::min(remainingDraws, maxDrawCount);
835 this->currentCommandBuffer()->drawIndexedIndirect(
836 fGpu, sk_ref_sp(drawIndirectBuffer), offset, currDrawCount, stride);
837 remainingDraws -= currDrawCount;
838 offset += stride * currDrawCount;
839 fGpu->stats()->incNumDraws();
840 }
841 fCurrentCBIsEmpty = false;
842}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
virtual bool isCpuBuffer() const =0
bool nativeDrawIndirectSupport() const
Definition GrCaps.h:84
void incNumDraws()
Definition GrGpu.h:541
Stats * stats()
Definition GrGpu.h:551
uint32_t maxDrawIndirectDrawCount() const
Definition GrVkCaps.h:203
void drawIndexedIndirect(const GrVkGpu *gpu, sk_sp< const GrBuffer > indirectBuffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
const GrVkCaps & vkCaps() const
Definition GrVkGpu.h:61
Point offset

◆ onDrawIndexedInstanced()

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

Implements GrOpsRenderPass.

Definition at line 782 of file GrVkOpsRenderPass.cpp.

783 {
784 if (!fCurrentRenderPass) {
785 SkASSERT(fGpu->isDeviceLost());
786 return;
787 }
788 SkASSERT(fCurrentPipelineState);
789 this->currentCommandBuffer()->drawIndexed(fGpu, indexCount, instanceCount,
790 baseIndex, baseVertex, baseInstance);
791 fGpu->stats()->incNumDraws();
792 fCurrentCBIsEmpty = false;
793}
void drawIndexed(const GrVkGpu *gpu, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)

◆ onDrawIndirect()

void GrVkOpsRenderPass::onDrawIndirect ( const GrBuffer drawIndirectBuffer,
size_t  offset,
int  drawCount 
)
overrideprivatevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 795 of file GrVkOpsRenderPass.cpp.

796 {
797 SkASSERT(!drawIndirectBuffer->isCpuBuffer());
798 if (!fCurrentRenderPass) {
799 SkASSERT(fGpu->isDeviceLost());
800 return;
801 }
802 const GrVkCaps& caps = fGpu->vkCaps();
804 SkASSERT(fCurrentPipelineState);
805
806 const uint32_t maxDrawCount = caps.maxDrawIndirectDrawCount();
807 uint32_t remainingDraws = drawCount;
808 const size_t stride = sizeof(GrDrawIndirectCommand);
809 while (remainingDraws >= 1) {
810 uint32_t currDrawCount = std::min(remainingDraws, maxDrawCount);
811 this->currentCommandBuffer()->drawIndirect(
812 fGpu, sk_ref_sp(drawIndirectBuffer), offset, currDrawCount, stride);
813 remainingDraws -= currDrawCount;
814 offset += stride * currDrawCount;
815 fGpu->stats()->incNumDraws();
816 }
817 fCurrentCBIsEmpty = false;
818}
void drawIndirect(const GrVkGpu *gpu, sk_sp< const GrBuffer > indirectBuffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)

◆ onDrawInstanced()

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

Implements GrOpsRenderPass.

Definition at line 769 of file GrVkOpsRenderPass.cpp.

771 {
772 if (!fCurrentRenderPass) {
773 SkASSERT(fGpu->isDeviceLost());
774 return;
775 }
776 SkASSERT(fCurrentPipelineState);
777 this->currentCommandBuffer()->draw(fGpu, vertexCount, instanceCount, baseVertex, baseInstance);
778 fGpu->stats()->incNumDraws();
779 fCurrentCBIsEmpty = false;
780}
void draw(const GrVkGpu *gpu, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)

◆ onEnd()

void GrVkOpsRenderPass::onEnd ( )
overrideprivatevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 620 of file GrVkOpsRenderPass.cpp.

620 {
621 if (fCurrentSecondaryCommandBuffer && !this->wrapsSecondaryCommandBuffer()) {
622 fCurrentSecondaryCommandBuffer->end(fGpu);
623 }
624}

◆ onExecuteDrawable()

void GrVkOpsRenderPass::onExecuteDrawable ( std::unique_ptr< SkDrawable::GpuDrawHandler drawable)
overridevirtual

Reimplemented from GrOpsRenderPass.

Definition at line 846 of file GrVkOpsRenderPass.cpp.

846 {
847 if (!fCurrentRenderPass) {
848 SkASSERT(fGpu->isDeviceLost());
849 return;
850 }
851
853 bounds.offset = { 0, 0 };
854 bounds.extent = { 0, 0 };
855
856 if (!fCurrentSecondaryCommandBuffer) {
857 fGpu->endRenderPass(fRenderTarget, fOrigin, fBounds);
858 this->addAdditionalRenderPass(true);
859 // We may have failed to start a new render pass
860 if (!fCurrentRenderPass) {
861 SkASSERT(fGpu->isDeviceLost());
862 return;
863 }
864 }
865 SkASSERT(fCurrentSecondaryCommandBuffer);
866
867 GrVkDrawableInfo vkInfo;
868 vkInfo.fSecondaryCommandBuffer = fCurrentSecondaryCommandBuffer->vkCommandBuffer();
869 vkInfo.fCompatibleRenderPass = fCurrentRenderPass->vkRenderPass();
870 SkAssertResult(fCurrentRenderPass->colorAttachmentIndex(&vkInfo.fColorAttachmentIndex));
871 vkInfo.fFormat = fFramebuffer->colorAttachment()->imageFormat();
872 vkInfo.fDrawBounds = &bounds;
873#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
874 vkInfo.fFromSwapchainOrAndroidWindow =
875 fFramebuffer->colorAttachment()->vkImageInfo().fPartOfSwapchainOrAndroidWindow;
876#endif //SK_BUILD_FOR_ANDROID_FRAMEWORK
877
879
880 // After we draw into the command buffer via the drawable, cached state we have may be invalid.
881 this->currentCommandBuffer()->invalidateState();
882 // Also assume that the drawable produced output.
883 fCurrentCBIsEmpty = false;
884
885 drawable->draw(info);
886 fGpu->addDrawable(std::move(drawable));
887}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
void addDrawable(std::unique_ptr< SkDrawable::GpuDrawHandler > drawable)
Definition GrVkGpu.cpp:2769
VkFormat imageFormat() const
Definition GrVkImage.h:82
const GrVkImageInfo & vkImageInfo() const
Definition GrVkImage.h:81
Optional< SkRect > bounds
Definition SkRecords.h:189
VkRect2D * fDrawBounds
Definition GrVkTypes.h:89
VkFormat fFormat
Definition GrVkTypes.h:88
uint32_t fColorAttachmentIndex
Definition GrVkTypes.h:86
VkRenderPass fCompatibleRenderPass
Definition GrVkTypes.h:87
VkCommandBuffer fSecondaryCommandBuffer
Definition GrVkTypes.h:85

◆ onSetScissorRect()

void GrVkOpsRenderPass::onSetScissorRect ( const SkIRect scissor)
overrideprivatevirtual

Implements GrOpsRenderPass.

Definition at line 675 of file GrVkOpsRenderPass.cpp.

675 {
676 SkIRect combinedScissorRect;
677 if (!combinedScissorRect.intersect(fCurrentPipelineBounds, scissor)) {
678 combinedScissorRect = SkIRect::MakeEmpty();
679 }
680 GrVkPipeline::SetDynamicScissorRectState(fGpu, this->currentCommandBuffer(),
681 fFramebuffer->colorAttachment()->dimensions(),
682 fOrigin, combinedScissorRect);
683}
bool intersect(const SkIRect &r)
Definition SkRect.h:513
static constexpr SkIRect MakeEmpty()
Definition SkRect.h:45

◆ reset()

void GrVkOpsRenderPass::reset ( )

Definition at line 400 of file GrVkOpsRenderPass.cpp.

400 {
401 if (fCurrentSecondaryCommandBuffer) {
402 // The active GrVkCommandPool on the GrVkGpu should still be the same pool we got the
403 // secondary command buffer from since we haven't submitted any work yet.
404 SkASSERT(fGpu->cmdPool());
405 fCurrentSecondaryCommandBuffer.release()->recycle(fGpu->cmdPool());
406 }
407 if (fCurrentRenderPass) {
408 fCurrentRenderPass->unref();
409 fCurrentRenderPass = nullptr;
410 }
411 fCurrentCBIsEmpty = true;
412
413 fRenderTarget = nullptr;
414 fFramebuffer.reset();
415
416 fSelfDependencyFlags = GrVkRenderPass::SelfDependencyFlags::kNone;
417
418 fLoadFromResolve = LoadFromResolve::kNo;
419 fOverridePipelinesForResolveLoad = false;
420
421#ifdef SK_DEBUG
422 fIsActive = false;
423#endif
424}
GrVkCommandPool * cmdPool() const
Definition GrVkGpu.h:74
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310

◆ set()

bool GrVkOpsRenderPass::set ( GrRenderTarget rt,
sk_sp< GrVkFramebuffer framebuffer,
GrSurfaceOrigin  origin,
const SkIRect bounds,
const GrOpsRenderPass::LoadAndStoreInfo colorInfo,
const GrOpsRenderPass::StencilLoadAndStoreInfo stencilInfo,
const GrOpsRenderPass::LoadAndStoreInfo resolveInfo,
GrVkRenderPass::SelfDependencyFlags  selfDepFlags,
GrVkRenderPass::LoadFromResolve  loadFromResolve,
const skia_private::TArray< GrSurfaceProxy *, true > &  sampledProxies 
)

Definition at line 344 of file GrVkOpsRenderPass.cpp.

353 {
355 SkASSERT(fGpu == rt->getContext()->priv().getGpu());
356
357#ifdef SK_DEBUG
358 fIsActive = true;
359#endif
360
361 // We check to make sure the GrVkGpu has a valid current command buffer instead of each time we
362 // access it. If the command buffer is valid here should be valid throughout the use of the
363 // render pass since nothing should trigger a submit while this render pass is active.
364 if (!fGpu->currentCommandBuffer()) {
365 return false;
366 }
367
368 this->INHERITED::set(rt, origin);
369
370 for (int i = 0; i < sampledProxies.size(); ++i) {
371 if (sampledProxies[i]->isInstantiated()) {
372 SkASSERT(sampledProxies[i]->asTextureProxy());
373 GrVkTexture* vkTex = static_cast<GrVkTexture*>(sampledProxies[i]->peekTexture());
374 SkASSERT(vkTex);
375 GrVkImage* texture = vkTex->textureImage();
377 texture->setImageLayout(
380 }
381 }
382
383 SkASSERT(framebuffer);
384 fFramebuffer = std::move(framebuffer);
385
386 SkASSERT(bounds.isEmpty() ||
387 SkIRect::MakeSize(fFramebuffer->colorAttachment()->dimensions()).contains(bounds));
388 fBounds = bounds;
389
390 fSelfDependencyFlags = selfDepFlags;
391 fLoadFromResolve = loadFromResolve;
392
393 if (this->wrapsSecondaryCommandBuffer()) {
394 return this->initWrapped();
395 }
396
397 return this->init(colorInfo, resolveInfo, stencilInfo);
398}
GrDirectContextPriv priv()
const GrDirectContext * getContext() const
void set(GrRenderTarget *rt, GrSurfaceOrigin origin)
GrVkPrimaryCommandBuffer * currentCommandBuffer() const
Definition GrVkGpu.h:85
GrVkImage * textureImage() const
Definition GrVkTexture.h:50
int size() const
Definition SkTArray.h:416
FlTexture * texture
static constexpr SkIRect MakeSize(const SkISize &size)
Definition SkRect.h:66
bool contains(int32_t x, int32_t y) const
Definition SkRect.h:463
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@ VK_ACCESS_SHADER_READ_BIT
@ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT

◆ submit()

void GrVkOpsRenderPass::submit ( )

Definition at line 319 of file GrVkOpsRenderPass.cpp.

319 {
320 if (!fRenderTarget) {
321 return;
322 }
323 if (!fCurrentRenderPass) {
324 SkASSERT(fGpu->isDeviceLost());
325 return;
326 }
327
328 // We don't want to actually submit the secondary command buffer if it is wrapped.
329 if (this->wrapsSecondaryCommandBuffer()) {
330 // We pass the ownership of the GrVkSecondaryCommandBuffer to the external framebuffer
331 // since it's lifetime matches the lifetime we need to keep the GrManagedResources on the
332 // GrVkSecondaryCommandBuffer alive.
334 std::move(fCurrentSecondaryCommandBuffer));
335 return;
336 }
337
338 if (fCurrentSecondaryCommandBuffer) {
339 fGpu->submitSecondaryCommandBuffer(std::move(fCurrentSecondaryCommandBuffer));
340 }
341 fGpu->endRenderPass(fRenderTarget, fOrigin, fBounds);
342}
void returnExternalGrSecondaryCommandBuffer(std::unique_ptr< GrVkSecondaryCommandBuffer >)

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