Flutter Engine
The Flutter Engine
Public 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)
 
virtual void inlineUpload (GrOpFlushState *, GrDeferredTextureUploadFn &)=0
 
void clear (const GrScissorState &scissor, std::array< float, 4 > color)
 
void clearStencilClip (const GrScissorState &scissor, bool insideStencilMask)
 
void executeDrawable (std::unique_ptr< SkDrawable::GpuDrawHandler >)
 

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) {}

◆ ~GrVkOpsRenderPass()

GrVkOpsRenderPass::~GrVkOpsRenderPass ( )
override

Definition at line 288 of file GrVkOpsRenderPass.cpp.

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

Member Function Documentation

◆ 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:2651
bool isDeviceLost() const override
Definition: GrVkGpu.h:66
void submitSecondaryCommandBuffer(std::unique_ptr< GrVkSecondaryCommandBuffer >)
Definition: GrVkGpu.cpp:2683
AtkStateType state
Definition: upload.py:1

◆ 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
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
GrVkImage * colorAttachment()
void addDrawable(std::unique_ptr< SkDrawable::GpuDrawHandler > drawable)
Definition: GrVkGpu.cpp:2753
VkFormat imageFormat() const
Definition: GrVkImage.h:83
const GrVkImageInfo & vkImageInfo() const
Definition: GrVkImage.h:82
bool colorAttachmentIndex(uint32_t *index) const
VkRenderPass vkRenderPass() const
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

◆ 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() ||
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)
SkISize dimensions() const
Definition: GrSurface.h:27
GrVkPrimaryCommandBuffer * currentCommandBuffer() const
Definition: GrVkGpu.h:85
GrVkImage * textureImage() const
Definition: GrVkTexture.h:50
int size() const
Definition: SkTArray.h:421
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
Definition: vulkan_core.h:1336
@ VK_ACCESS_SHADER_READ_BIT
Definition: vulkan_core.h:2205
@ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
Definition: vulkan_core.h:2442

◆ 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: