Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
GrVkPrimaryCommandBuffer Class Reference

#include <GrVkCommandBuffer.h>

Inheritance diagram for GrVkPrimaryCommandBuffer:
GrVkCommandBuffer

Public Member Functions

 ~GrVkPrimaryCommandBuffer () override
 
void begin (GrVkGpu *gpu)
 
void end (GrVkGpu *gpu, bool abandoningBuffer=false)
 
bool beginRenderPass (GrVkGpu *gpu, const GrVkRenderPass *, sk_sp< const GrVkFramebuffer >, const VkClearValue clearValues[], const GrSurface *target, const SkIRect &bounds, bool forSecondaryCB)
 
void endRenderPass (const GrVkGpu *gpu)
 
void nexSubpass (GrVkGpu *gpu, bool forSecondaryCB)
 
void executeCommands (const GrVkGpu *gpu, std::unique_ptr< GrVkSecondaryCommandBuffer > secondaryBuffer)
 
void clearColorImage (const GrVkGpu *gpu, GrVkImage *image, const VkClearColorValue *color, uint32_t subRangeCount, const VkImageSubresourceRange *subRanges)
 
void clearDepthStencilImage (const GrVkGpu *gpu, GrVkImage *image, const VkClearDepthStencilValue *color, uint32_t subRangeCount, const VkImageSubresourceRange *subRanges)
 
void copyImage (const GrVkGpu *gpu, GrVkImage *srcImage, VkImageLayout srcLayout, GrVkImage *dstImage, VkImageLayout dstLayout, uint32_t copyRegionCount, const VkImageCopy *copyRegions)
 
void blitImage (const GrVkGpu *gpu, const GrManagedResource *srcResource, VkImage srcImage, VkImageLayout srcLayout, const GrManagedResource *dstResource, VkImage dstImage, VkImageLayout dstLayout, uint32_t blitRegionCount, const VkImageBlit *blitRegions, VkFilter filter)
 
void blitImage (const GrVkGpu *gpu, const GrVkImage &srcImage, const GrVkImage &dstImage, uint32_t blitRegionCount, const VkImageBlit *blitRegions, VkFilter filter)
 
void copyImageToBuffer (const GrVkGpu *gpu, GrVkImage *srcImage, VkImageLayout srcLayout, sk_sp< GrGpuBuffer > dstBuffer, uint32_t copyRegionCount, const VkBufferImageCopy *copyRegions)
 
void copyBufferToImage (const GrVkGpu *gpu, VkBuffer srcBuffer, GrVkImage *dstImage, VkImageLayout dstLayout, uint32_t copyRegionCount, const VkBufferImageCopy *copyRegions)
 
void fillBuffer (GrVkGpu *gpu, sk_sp< GrGpuBuffer >, VkDeviceSize offset, VkDeviceSize size, uint32_t data)
 
void copyBuffer (GrVkGpu *gpu, sk_sp< GrGpuBuffer > srcBuffer, sk_sp< GrGpuBuffer > dstBuffer, uint32_t regionCount, const VkBufferCopy *regions)
 
void updateBuffer (GrVkGpu *gpu, sk_sp< GrVkBuffer > dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void *data)
 
void resolveImage (GrVkGpu *gpu, const GrVkImage &srcImage, const GrVkImage &dstImage, uint32_t regionCount, const VkImageResolve *regions)
 
bool submitToQueue (GrVkGpu *gpu, VkQueue queue, skia_private::TArray< GrVkSemaphore::Resource * > &signalSemaphores, skia_private::TArray< GrVkSemaphore::Resource * > &waitSemaphores)
 
void forceSync (GrVkGpu *gpu)
 
bool finished (GrVkGpu *gpu)
 
void addFinishedProc (sk_sp< skgpu::RefCntedCallback > finishedProc)
 
void callFinishedProcs ()
 
void recycleSecondaryCommandBuffers (GrVkCommandPool *cmdPool)
 
- Public Member Functions inherited from GrVkCommandBuffer
virtual ~GrVkCommandBuffer ()
 
void invalidateState ()
 
void pipelineBarrier (const GrVkGpu *gpu, const GrManagedResource *resource, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, bool byRegion, BarrierType barrierType, void *barrier)
 
void bindInputBuffer (GrVkGpu *gpu, uint32_t binding, sk_sp< const GrBuffer > buffer)
 
void bindIndexBuffer (GrVkGpu *gpu, sk_sp< const GrBuffer > buffer)
 
void bindPipeline (const GrVkGpu *gpu, sk_sp< const GrVkPipeline > pipeline)
 
void bindDescriptorSets (const GrVkGpu *gpu, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet *descriptorSets, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets)
 
void pushConstants (const GrVkGpu *gpu, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void *values)
 
void setViewport (const GrVkGpu *gpu, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *viewports)
 
void setScissor (const GrVkGpu *gpu, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *scissors)
 
void setBlendConstants (const GrVkGpu *gpu, const float blendConstants[4])
 
void clearAttachments (const GrVkGpu *gpu, int numAttachments, const VkClearAttachment *attachments, int numRects, const VkClearRect *clearRects)
 
void drawIndexed (const GrVkGpu *gpu, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
 
void draw (const GrVkGpu *gpu, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
 
void drawIndirect (const GrVkGpu *gpu, sk_sp< const GrBuffer > indirectBuffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
 
void drawIndexedIndirect (const GrVkGpu *gpu, sk_sp< const GrBuffer > indirectBuffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
 
void addResource (sk_sp< const GrManagedResource > resource)
 
void addResource (const GrManagedResource *resource)
 
void addRecycledResource (gr_rp< const GrRecycledResource > resource)
 
void addRecycledResource (const GrRecycledResource *resource)
 
void addGrBuffer (sk_sp< const GrBuffer > buffer)
 
void addGrSurface (sk_sp< const GrSurface > surface)
 
void releaseResources ()
 
void freeGPUData (const GrGpu *gpu, VkCommandPool pool) const
 
bool hasWork () const
 

Static Public Member Functions

static GrVkPrimaryCommandBufferCreate (GrVkGpu *gpu, VkCommandPool cmdPool)
 

Additional Inherited Members

- Public Types inherited from GrVkCommandBuffer
enum  BarrierType { kBufferMemory_BarrierType , kImageMemory_BarrierType }
 
- Protected Types inherited from GrVkCommandBuffer
template<typename T >
using TrackedResourceArray = skia_private::STArray< kInitialTrackedResourcesCount, T >
 
- Protected Member Functions inherited from GrVkCommandBuffer
 GrVkCommandBuffer (VkCommandBuffer cmdBuffer, bool isWrapped=false)
 
bool isWrapped () const
 
void addingWork (const GrVkGpu *gpu)
 
void submitPipelineBarriers (const GrVkGpu *gpu, bool forSelfDependency=false)
 
virtual void onReleaseResources ()
 
virtual void onFreeGPUData (const GrVkGpu *gpu) const =0
 
- Protected Attributes inherited from GrVkCommandBuffer
TrackedResourceArray< sk_sp< const GrManagedResource > > fTrackedResources
 
TrackedResourceArray< gr_rp< const GrRecycledResource > > fTrackedRecycledResources
 
skia_private::STArray< 16, sk_sp< const GrBuffer > > fTrackedGpuBuffers
 
skia_private::STArray< 16, gr_cb< const GrSurface > > fTrackedGpuSurfaces
 
bool fIsActive
 
bool fHasWork = false
 
const GrVkRenderPassfActiveRenderPass = nullptr
 
VkCommandBuffer fCmdBuffer
 
VkBuffer fBoundInputBuffers [kMaxInputBuffers]
 
VkBuffer fBoundIndexBuffer
 
VkViewport fCachedViewport
 
VkRect2D fCachedScissor
 
float fCachedBlendConstant [4]
 
skia_private::STArray< 1, VkBufferMemoryBarrierfBufferBarriers
 
skia_private::STArray< 2, VkImageMemoryBarrierfImageBarriers
 
bool fBarriersByRegion = false
 
VkPipelineStageFlags fSrcStageMask = 0
 
VkPipelineStageFlags fDstStageMask = 0
 
bool fIsWrapped
 
- Static Protected Attributes inherited from GrVkCommandBuffer
static constexpr uint32_t kMaxInputBuffers = 2
 

Detailed Description

Definition at line 206 of file GrVkCommandBuffer.h.

Constructor & Destructor Documentation

◆ ~GrVkPrimaryCommandBuffer()

GrVkPrimaryCommandBuffer::~GrVkPrimaryCommandBuffer ( )
override

Definition at line 410 of file GrVkCommandBuffer.cpp.

410 {
411 // Should have ended any render pass we're in the middle of
413}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const GrVkRenderPass * fActiveRenderPass

Member Function Documentation

◆ addFinishedProc()

void GrVkPrimaryCommandBuffer::addFinishedProc ( sk_sp< skgpu::RefCntedCallback finishedProc)

Definition at line 688 of file GrVkCommandBuffer.cpp.

688 {
689 fFinishedProcs.push_back(std::move(finishedProc));
690}

◆ begin()

void GrVkPrimaryCommandBuffer::begin ( GrVkGpu gpu)

Definition at line 434 of file GrVkCommandBuffer.cpp.

434 {
436 VkCommandBufferBeginInfo cmdBufferBeginInfo;
437 memset(&cmdBufferBeginInfo, 0, sizeof(VkCommandBufferBeginInfo));
439 cmdBufferBeginInfo.pNext = nullptr;
441 cmdBufferBeginInfo.pInheritanceInfo = nullptr;
442
443 GR_VK_CALL_ERRCHECK(gpu, BeginCommandBuffer(fCmdBuffer, &cmdBufferBeginInfo));
444 fIsActive = true;
445}
#define GR_VK_CALL_ERRCHECK(GPU, X)
Definition: GrVkUtil.h:50
VkCommandBuffer fCmdBuffer
const VkCommandBufferInheritanceInfo * pInheritanceInfo
Definition: vulkan_core.h:3894
VkStructureType sType
Definition: vulkan_core.h:3891
VkCommandBufferUsageFlags flags
Definition: vulkan_core.h:3893
@ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
Definition: vulkan_core.h:2830
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
Definition: vulkan_core.h:244

◆ beginRenderPass()

bool GrVkPrimaryCommandBuffer::beginRenderPass ( GrVkGpu gpu,
const GrVkRenderPass renderPass,
sk_sp< const GrVkFramebuffer framebuffer,
const VkClearValue  clearValues[],
const GrSurface target,
const SkIRect bounds,
bool  forSecondaryCB 
)

Definition at line 467 of file GrVkCommandBuffer.cpp.

473 {
476
477 SkASSERT(framebuffer);
478
479 this->addingWork(gpu);
480
481 VkRenderPassBeginInfo beginInfo;
482 VkRect2D renderArea;
483 renderArea.offset = { bounds.fLeft , bounds.fTop };
484 renderArea.extent = { (uint32_t)bounds.width(), (uint32_t)bounds.height() };
485
486 memset(&beginInfo, 0, sizeof(VkRenderPassBeginInfo));
488 beginInfo.pNext = nullptr;
489 beginInfo.renderPass = renderPass->vkRenderPass();
490 beginInfo.framebuffer = framebuffer->framebuffer();
491 beginInfo.renderArea = renderArea;
492 beginInfo.clearValueCount = renderPass->clearValueCount();
493 beginInfo.pClearValues = clearValues;
494
497
498 GR_VK_CALL(gpu->vkInterface(), CmdBeginRenderPass(fCmdBuffer, &beginInfo, contents));
499 fActiveRenderPass = renderPass;
500 this->addResource(renderPass);
501 this->addResource(std::move(framebuffer));
502 this->addGrSurface(sk_ref_sp(target));
503 return true;
504}
#define GR_VK_CALL(IFACE, X)
Definition: GrVkUtil.h:24
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
void addResource(sk_sp< const GrManagedResource > resource)
void addingWork(const GrVkGpu *gpu)
void addGrSurface(sk_sp< const GrSurface > surface)
VkFramebuffer framebuffer() const
const skgpu::VulkanInterface * vkInterface() const
Definition: GrVkGpu.h:60
uint32_t clearValueCount() const
VkRenderPass vkRenderPass() const
Optional< SkRect > bounds
Definition: SkRecords.h:189
VkExtent2D extent
Definition: vulkan_core.h:2881
VkOffset2D offset
Definition: vulkan_core.h:2880
const VkClearValue * pClearValues
Definition: vulkan_core.h:3977
VkStructureType sType
Definition: vulkan_core.h:3971
VkRenderPass renderPass
Definition: vulkan_core.h:3973
VkFramebuffer framebuffer
Definition: vulkan_core.h:3974
VkSubpassContents
Definition: vulkan_core.h:2192
@ VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
Definition: vulkan_core.h:2194
@ VK_SUBPASS_CONTENTS_INLINE
Definition: vulkan_core.h:2193
@ VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
Definition: vulkan_core.h:245

◆ blitImage() [1/2]

void GrVkPrimaryCommandBuffer::blitImage ( const GrVkGpu gpu,
const GrManagedResource srcResource,
VkImage  srcImage,
VkImageLayout  srcLayout,
const GrManagedResource dstResource,
VkImage  dstImage,
VkImageLayout  dstLayout,
uint32_t  blitRegionCount,
const VkImageBlit blitRegions,
VkFilter  filter 
)

Definition at line 727 of file GrVkCommandBuffer.cpp.

736 {
739 this->addingWork(gpu);
740 this->addResource(srcResource);
741 this->addResource(dstResource);
742 GR_VK_CALL(gpu->vkInterface(), CmdBlitImage(fCmdBuffer,
743 srcImage,
744 srcLayout,
745 dstImage,
746 dstLayout,
747 blitRegionCount,
748 blitRegions,
749 filter));
750}

◆ blitImage() [2/2]

void GrVkPrimaryCommandBuffer::blitImage ( const GrVkGpu gpu,
const GrVkImage srcImage,
const GrVkImage dstImage,
uint32_t  blitRegionCount,
const VkImageBlit blitRegions,
VkFilter  filter 
)

Definition at line 752 of file GrVkCommandBuffer.cpp.

757 {
758 this->blitImage(gpu,
759 srcImage.resource(),
760 srcImage.image(),
761 srcImage.currentLayout(),
762 dstImage.resource(),
763 dstImage.image(),
764 dstImage.currentLayout(),
765 blitRegionCount,
766 blitRegions,
767 filter);
768}
VkImageLayout currentLayout() const
Definition: GrVkImage.h:133
const Resource * resource() const
Definition: GrVkImage.h:119
VkImage image() const
Definition: GrVkImage.h:70
void blitImage(const GrVkGpu *gpu, const GrManagedResource *srcResource, VkImage srcImage, VkImageLayout srcLayout, const GrManagedResource *dstResource, VkImage dstImage, VkImageLayout dstLayout, uint32_t blitRegionCount, const VkImageBlit *blitRegions, VkFilter filter)

◆ callFinishedProcs()

void GrVkPrimaryCommandBuffer::callFinishedProcs ( )
inline

Definition at line 324 of file GrVkCommandBuffer.h.

324 {
325 fFinishedProcs.clear();
326 }

◆ clearColorImage()

void GrVkPrimaryCommandBuffer::clearColorImage ( const GrVkGpu gpu,
GrVkImage image,
const VkClearColorValue color,
uint32_t  subRangeCount,
const VkImageSubresourceRange subRanges 
)

Definition at line 879 of file GrVkCommandBuffer.cpp.

883 {
886 this->addingWork(gpu);
887 this->addResource(image->resource());
888 GR_VK_CALL(gpu->vkInterface(), CmdClearColorImage(fCmdBuffer,
889 image->image(),
890 image->currentLayout(),
891 color,
892 subRangeCount,
893 subRanges));
894}
DlColor color
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ clearDepthStencilImage()

void GrVkPrimaryCommandBuffer::clearDepthStencilImage ( const GrVkGpu gpu,
GrVkImage image,
const VkClearDepthStencilValue color,
uint32_t  subRangeCount,
const VkImageSubresourceRange subRanges 
)

Definition at line 896 of file GrVkCommandBuffer.cpp.

900 {
903 this->addingWork(gpu);
904 this->addResource(image->resource());
905 GR_VK_CALL(gpu->vkInterface(), CmdClearDepthStencilImage(fCmdBuffer,
906 image->image(),
907 image->currentLayout(),
908 color,
909 subRangeCount,
910 subRanges));
911}

◆ copyBuffer()

void GrVkPrimaryCommandBuffer::copyBuffer ( GrVkGpu gpu,
sk_sp< GrGpuBuffer srcBuffer,
sk_sp< GrGpuBuffer dstBuffer,
uint32_t  regionCount,
const VkBufferCopy regions 
)

Definition at line 829 of file GrVkCommandBuffer.cpp.

833 {
836 this->addingWork(gpu);
837#ifdef SK_DEBUG
838 for (uint32_t i = 0; i < regionCount; ++i) {
839 const VkBufferCopy& region = regions[i];
840 SkASSERT(region.size > 0);
841 SkASSERT(region.srcOffset < srcBuffer->size());
842 SkASSERT(region.dstOffset < dstBuffer->size());
843 SkASSERT(region.srcOffset + region.size <= srcBuffer->size());
844 SkASSERT(region.dstOffset + region.size <= dstBuffer->size());
845 }
846#endif
847
848 const GrVkBuffer* srcVk = static_cast<GrVkBuffer*>(srcBuffer.get());
849 const GrVkBuffer* dstVk = static_cast<GrVkBuffer*>(dstBuffer.get());
850
851 GR_VK_CALL(gpu->vkInterface(), CmdCopyBuffer(fCmdBuffer,
852 srcVk->vkBuffer(),
853 dstVk->vkBuffer(),
854 regionCount,
855 regions));
856 this->addGrBuffer(std::move(srcBuffer));
857 this->addGrBuffer(std::move(dstBuffer));
858}
size_t size() const final
Definition: GrGpuBuffer.h:34
VkBuffer vkBuffer() const
Definition: GrVkBuffer.h:24
void addGrBuffer(sk_sp< const GrBuffer > buffer)
T * get() const
Definition: SkRefCnt.h:303
ClipOpAndAA opAA SkRegion region
Definition: SkRecords.h:238

◆ copyBufferToImage()

void GrVkPrimaryCommandBuffer::copyBufferToImage ( const GrVkGpu gpu,
VkBuffer  srcBuffer,
GrVkImage dstImage,
VkImageLayout  dstLayout,
uint32_t  copyRegionCount,
const VkBufferImageCopy copyRegions 
)

Definition at line 791 of file GrVkCommandBuffer.cpp.

796 {
799 this->addingWork(gpu);
800
801 GR_VK_CALL(gpu->vkInterface(), CmdCopyBufferToImage(fCmdBuffer,
802 srcBuffer,
803 dstImage->image(),
804 dstLayout,
805 copyRegionCount,
806 copyRegions));
807 this->addResource(dstImage->resource());
808}

◆ copyImage()

void GrVkPrimaryCommandBuffer::copyImage ( const GrVkGpu gpu,
GrVkImage srcImage,
VkImageLayout  srcLayout,
GrVkImage dstImage,
VkImageLayout  dstLayout,
uint32_t  copyRegionCount,
const VkImageCopy copyRegions 
)

Definition at line 706 of file GrVkCommandBuffer.cpp.

712 {
715 this->addingWork(gpu);
716 this->addResource(srcImage->resource());
717 this->addResource(dstImage->resource());
718 GR_VK_CALL(gpu->vkInterface(), CmdCopyImage(fCmdBuffer,
719 srcImage->image(),
720 srcLayout,
721 dstImage->image(),
722 dstLayout,
723 copyRegionCount,
724 copyRegions));
725}

◆ copyImageToBuffer()

void GrVkPrimaryCommandBuffer::copyImageToBuffer ( const GrVkGpu gpu,
GrVkImage srcImage,
VkImageLayout  srcLayout,
sk_sp< GrGpuBuffer dstBuffer,
uint32_t  copyRegionCount,
const VkBufferImageCopy copyRegions 
)

Definition at line 771 of file GrVkCommandBuffer.cpp.

776 {
779 this->addingWork(gpu);
780 GrVkBuffer* vkBuffer = static_cast<GrVkBuffer*>(dstBuffer.get());
781 GR_VK_CALL(gpu->vkInterface(), CmdCopyImageToBuffer(fCmdBuffer,
782 srcImage->image(),
783 srcLayout,
784 vkBuffer->vkBuffer(),
785 copyRegionCount,
786 copyRegions));
787 this->addResource(srcImage->resource());
788 this->addGrBuffer(std::move(dstBuffer));
789}

◆ Create()

GrVkPrimaryCommandBuffer * GrVkPrimaryCommandBuffer::Create ( GrVkGpu gpu,
VkCommandPool  cmdPool 
)
static

Definition at line 415 of file GrVkCommandBuffer.cpp.

416 {
417 const VkCommandBufferAllocateInfo cmdInfo = {
419 nullptr, // pNext
420 cmdPool, // commandPool
422 1 // bufferCount
423 };
424
425 VkCommandBuffer cmdBuffer;
426 VkResult err;
427 GR_VK_CALL_RESULT(gpu, err, AllocateCommandBuffers(gpu->device(), &cmdInfo, &cmdBuffer));
428 if (err) {
429 return nullptr;
430 }
431 return new GrVkPrimaryCommandBuffer(cmdBuffer);
432}
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
VkDevice device() const
Definition: GrVkGpu.h:71
@ VK_COMMAND_BUFFER_LEVEL_PRIMARY
Definition: vulkan_core.h:2178
VkResult
Definition: vulkan_core.h:140
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
Definition: vulkan_core.h:242

◆ end()

void GrVkPrimaryCommandBuffer::end ( GrVkGpu gpu,
bool  abandoningBuffer = false 
)

Definition at line 447 of file GrVkCommandBuffer.cpp.

447 {
450
451 // If we are in the process of abandoning the context then the GrResourceCache will have freed
452 // all resources before destroying the GrVkGpu. When we destroy the GrVkGpu we call end on the
453 // command buffer to keep all our state tracking consistent. However, the vulkan validation
454 // layers complain about calling end on a command buffer that contains resources that have
455 // already been deleted. From the vulkan API it isn't required to end the command buffer to
456 // delete it, so we just skip the vulkan API calls and update our own state tracking.
457 if (!abandoningBuffer) {
458 this->submitPipelineBarriers(gpu);
459
460 GR_VK_CALL_ERRCHECK(gpu, EndCommandBuffer(fCmdBuffer));
461 }
462 this->invalidateState();
463 fIsActive = false;
464 fHasWork = false;
465}
void submitPipelineBarriers(const GrVkGpu *gpu, bool forSelfDependency=false)

◆ endRenderPass()

void GrVkPrimaryCommandBuffer::endRenderPass ( const GrVkGpu gpu)

Definition at line 506 of file GrVkCommandBuffer.cpp.

506 {
509 this->addingWork(gpu);
510 GR_VK_CALL(gpu->vkInterface(), CmdEndRenderPass(fCmdBuffer));
511 fActiveRenderPass = nullptr;
512}

◆ executeCommands()

void GrVkPrimaryCommandBuffer::executeCommands ( const GrVkGpu gpu,
std::unique_ptr< GrVkSecondaryCommandBuffer secondaryBuffer 
)

Definition at line 523 of file GrVkCommandBuffer.cpp.

524 {
525 // The Vulkan spec allows secondary command buffers to be executed on a primary command buffer
526 // if the command pools both were created from were created with the same queue family. However,
527 // we currently always create them from the same pool.
529 SkASSERT(!buffer->fIsActive);
531 SkASSERT(fActiveRenderPass->isCompatible(*buffer->fActiveRenderPass));
532
533 this->addingWork(gpu);
534
535 GR_VK_CALL(gpu->vkInterface(), CmdExecuteCommands(fCmdBuffer, 1, &buffer->fCmdBuffer));
536 fSecondaryCommandBuffers.push_back(std::move(buffer));
537 // When executing a secondary command buffer all state (besides render pass state) becomes
538 // invalidated and must be reset. This includes bound buffers, pipelines, dynamic state, etc.
539 this->invalidateState();
540}
bool isCompatible(GrVkRenderTarget *target, SelfDependencyFlags selfDepFlags, LoadFromResolve) const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ fillBuffer()

void GrVkPrimaryCommandBuffer::fillBuffer ( GrVkGpu gpu,
sk_sp< GrGpuBuffer buffer,
VkDeviceSize  offset,
VkDeviceSize  size,
uint32_t  data 
)

Definition at line 810 of file GrVkCommandBuffer.cpp.

814 {
817 this->addingWork(gpu);
818
819 const GrVkBuffer* bufferVk = static_cast<GrVkBuffer*>(buffer.get());
820
821 GR_VK_CALL(gpu->vkInterface(), CmdFillBuffer(fCmdBuffer,
822 bufferVk->vkBuffer(),
823 offset,
824 size,
825 data));
826 this->addGrBuffer(std::move(buffer));
827}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SeparatedVector2 offset
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ finished()

bool GrVkPrimaryCommandBuffer::finished ( GrVkGpu gpu)

Definition at line 665 of file GrVkCommandBuffer.cpp.

665 {
667 if (VK_NULL_HANDLE == fSubmitFence) {
668 return true;
669 }
670
671 VkResult err;
672 GR_VK_CALL_RESULT_NOCHECK(gpu, err, GetFenceStatus(gpu->device(), fSubmitFence));
673 switch (err) {
674 case VK_SUCCESS:
676 return true;
677
678 case VK_NOT_READY:
679 return false;
680
681 default:
682 SkDebugf("Error getting fence status: %d\n", err);
683 SK_ABORT("Got an invalid fence status");
684 return false;
685 }
686}
#define GR_VK_CALL_RESULT_NOCHECK(GPU, RESULT, X)
Definition: GrVkUtil.h:43
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
@ VK_ERROR_DEVICE_LOST
Definition: vulkan_core.h:150
@ VK_SUCCESS
Definition: vulkan_core.h:141
@ VK_NOT_READY
Definition: vulkan_core.h:142
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46

◆ forceSync()

void GrVkPrimaryCommandBuffer::forceSync ( GrVkGpu gpu)

Definition at line 658 of file GrVkCommandBuffer.cpp.

658 {
659 if (fSubmitFence == VK_NULL_HANDLE) {
660 return;
661 }
662 GR_VK_CALL_ERRCHECK(gpu, WaitForFences(gpu->device(), 1, &fSubmitFence, true, UINT64_MAX));
663}

◆ nexSubpass()

void GrVkPrimaryCommandBuffer::nexSubpass ( GrVkGpu gpu,
bool  forSecondaryCB 
)

Definition at line 515 of file GrVkCommandBuffer.cpp.

515 {
520 GR_VK_CALL(gpu->vkInterface(), CmdNextSubpass(fCmdBuffer, contents));
521}

◆ recycleSecondaryCommandBuffers()

void GrVkPrimaryCommandBuffer::recycleSecondaryCommandBuffers ( GrVkCommandPool cmdPool)

Definition at line 699 of file GrVkCommandBuffer.cpp.

699 {
700 for (int i = 0; i < fSecondaryCommandBuffers.size(); ++i) {
701 fSecondaryCommandBuffers[i].release()->recycle(cmdPool);
702 }
703 fSecondaryCommandBuffers.clear();
704}
int size() const
Definition: SkTArray.h:421

◆ resolveImage()

void GrVkPrimaryCommandBuffer::resolveImage ( GrVkGpu gpu,
const GrVkImage srcImage,
const GrVkImage dstImage,
uint32_t  regionCount,
const VkImageResolve regions 
)

Definition at line 913 of file GrVkCommandBuffer.cpp.

917 {
920
921 this->addingWork(gpu);
922 this->addResource(srcImage.resource());
923 this->addResource(dstImage.resource());
924
925 GR_VK_CALL(gpu->vkInterface(), CmdResolveImage(fCmdBuffer,
926 srcImage.image(),
927 srcImage.currentLayout(),
928 dstImage.image(),
929 dstImage.currentLayout(),
930 regionCount,
931 regions));
932}

◆ submitToQueue()

bool GrVkPrimaryCommandBuffer::submitToQueue ( GrVkGpu gpu,
VkQueue  queue,
skia_private::TArray< GrVkSemaphore::Resource * > &  signalSemaphores,
skia_private::TArray< GrVkSemaphore::Resource * > &  waitSemaphores 
)

Definition at line 577 of file GrVkCommandBuffer.cpp.

581 {
583
584 VkResult err;
585 if (VK_NULL_HANDLE == fSubmitFence) {
586 VkFenceCreateInfo fenceInfo;
587 memset(&fenceInfo, 0, sizeof(VkFenceCreateInfo));
589 GR_VK_CALL_RESULT(gpu, err, CreateFence(gpu->device(), &fenceInfo, nullptr,
590 &fSubmitFence));
591 if (err) {
592 fSubmitFence = VK_NULL_HANDLE;
593 return false;
594 }
595 } else {
596 // This cannot return DEVICE_LOST so we assert we succeeded.
597 GR_VK_CALL_RESULT(gpu, err, ResetFences(gpu->device(), 1, &fSubmitFence));
598 SkASSERT(err == VK_SUCCESS);
599 }
600
601 int signalCount = signalSemaphores.size();
602 int waitCount = waitSemaphores.size();
603
604 bool submitted = false;
605
606 if (0 == signalCount && 0 == waitCount) {
607 // This command buffer has no dependent semaphores so we can simply just submit it to the
608 // queue with no worries.
609 submitted = submit_to_queue(
610 gpu, queue, fSubmitFence, 0, nullptr, nullptr, 1, &fCmdBuffer, 0, nullptr,
612 } else {
613 TArray<VkSemaphore> vkSignalSems(signalCount);
614 for (int i = 0; i < signalCount; ++i) {
615 if (signalSemaphores[i]->shouldSignal()) {
616 this->addResource(signalSemaphores[i]);
617 vkSignalSems.push_back(signalSemaphores[i]->semaphore());
618 }
619 }
620
621 TArray<VkSemaphore> vkWaitSems(waitCount);
622 TArray<VkPipelineStageFlags> vkWaitStages(waitCount);
623 for (int i = 0; i < waitCount; ++i) {
624 if (waitSemaphores[i]->shouldWait()) {
625 this->addResource(waitSemaphores[i]);
626 vkWaitSems.push_back(waitSemaphores[i]->semaphore());
627 // We only block the fragment stage since client provided resources are not used
628 // before the fragment stage. This allows the driver to begin vertex work while
629 // waiting on the semaphore. We also add in the transfer stage for uses of clients
630 // calling read or write pixels.
631 vkWaitStages.push_back(VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
633 }
634 }
635 submitted = submit_to_queue(gpu, queue, fSubmitFence, vkWaitSems.size(),
636 vkWaitSems.begin(), vkWaitStages.begin(), 1, &fCmdBuffer,
637 vkSignalSems.size(), vkSignalSems.begin(),
639 if (submitted) {
640 for (int i = 0; i < signalCount; ++i) {
641 signalSemaphores[i]->markAsSignaled();
642 }
643 for (int i = 0; i < waitCount; ++i) {
644 waitSemaphores[i]->markAsWaited();
645 }
646 }
647 }
648
649 if (!submitted) {
650 // Destroy the fence or else we will try to wait forever for it to finish.
651 GR_VK_CALL(gpu->vkInterface(), DestroyFence(gpu->device(), fSubmitFence, nullptr));
652 fSubmitFence = VK_NULL_HANDLE;
653 return false;
654 }
655 return true;
656}
skgpu::Protected GrProtected
Definition: GrTypes.h:139
static bool submit_to_queue(GrVkGpu *gpu, VkQueue queue, VkFence fence, uint32_t waitCount, const VkSemaphore *waitSemaphores, const VkPipelineStageFlags *waitStages, uint32_t commandBufferCount, const VkCommandBuffer *commandBuffers, uint32_t signalCount, const VkSemaphore *signalSemaphores, GrProtected protectedContext)
bool protectedContext() const
Definition: GrVkGpu.h:81
VkQueue queue
Definition: main.cc:55
Protected
Definition: GpuTypes.h:61
VkStructureType sType
Definition: vulkan_core.h:3386
@ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
Definition: vulkan_core.h:2442
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan_core.h:2447
@ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
Definition: vulkan_core.h:210

◆ updateBuffer()

void GrVkPrimaryCommandBuffer::updateBuffer ( GrVkGpu gpu,
sk_sp< GrVkBuffer dstBuffer,
VkDeviceSize  dstOffset,
VkDeviceSize  dataSize,
const void *  data 
)

Definition at line 860 of file GrVkCommandBuffer.cpp.

864 {
867 SkASSERT(0 == (dstOffset & 0x03)); // four byte aligned
868 // TODO: handle larger transfer sizes
869 SkASSERT(dataSize <= 65536);
870 SkASSERT(0 == (dataSize & 0x03)); // four byte aligned
871 this->addingWork(gpu);
873 gpu->vkInterface(),
874 CmdUpdateBuffer(
875 fCmdBuffer, dstBuffer->vkBuffer(), dstOffset, dataSize, (const uint32_t*)data));
876 this->addGrBuffer(std::move(dstBuffer));
877}

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