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

#include <GrVkCommandBuffer.h>

Inheritance diagram for GrVkSecondaryCommandBuffer:
GrVkCommandBuffer

Public Member Functions

void begin (GrVkGpu *gpu, const GrVkFramebuffer *framebuffer, const GrVkRenderPass *compatibleRenderPass)
 
void end (GrVkGpu *gpu)
 
void recycle (GrVkCommandPool *cmdPool)
 
VkCommandBuffer vkCommandBuffer ()
 
- 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 GrVkSecondaryCommandBufferCreate (GrVkGpu *gpu, GrVkCommandPool *cmdPool)
 
static GrVkSecondaryCommandBufferCreate (VkCommandBuffer externalSecondaryCB, const GrVkRenderPass *externalRenderPass)
 

Friends

class GrVkPrimaryCommandBuffer
 

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 346 of file GrVkCommandBuffer.h.

Member Function Documentation

◆ begin()

void GrVkSecondaryCommandBuffer::begin ( GrVkGpu gpu,
const GrVkFramebuffer framebuffer,
const GrVkRenderPass compatibleRenderPass 
)

Definition at line 972 of file GrVkCommandBuffer.cpp.

973 {
975 SkASSERT(!this->isWrapped());
976 SkASSERT(compatibleRenderPass);
977 fActiveRenderPass = compatibleRenderPass;
978
979 VkCommandBufferInheritanceInfo inheritanceInfo;
980 memset(&inheritanceInfo, 0, sizeof(VkCommandBufferInheritanceInfo));
982 inheritanceInfo.pNext = nullptr;
983 inheritanceInfo.renderPass = fActiveRenderPass->vkRenderPass();
984 inheritanceInfo.subpass = 0; // Currently only using 1 subpass for each render pass
985 inheritanceInfo.framebuffer = framebuffer ? framebuffer->framebuffer() : VK_NULL_HANDLE;
986 inheritanceInfo.occlusionQueryEnable = false;
987 inheritanceInfo.queryFlags = 0;
988 inheritanceInfo.pipelineStatistics = 0;
989
990 VkCommandBufferBeginInfo cmdBufferBeginInfo;
991 memset(&cmdBufferBeginInfo, 0, sizeof(VkCommandBufferBeginInfo));
993 cmdBufferBeginInfo.pNext = nullptr;
996 cmdBufferBeginInfo.pInheritanceInfo = &inheritanceInfo;
997
998 GR_VK_CALL_ERRCHECK(gpu, BeginCommandBuffer(fCmdBuffer, &cmdBufferBeginInfo));
999
1000 fIsActive = true;
1001}
#define GR_VK_CALL_ERRCHECK(GPU, X)
Definition: GrVkUtil.h:50
#define SkASSERT(cond)
Definition: SkAssert.h:116
VkCommandBuffer fCmdBuffer
const GrVkRenderPass * fActiveRenderPass
bool isWrapped() const
VkFramebuffer framebuffer() const
VkRenderPass vkRenderPass() const
const VkCommandBufferInheritanceInfo * pInheritanceInfo
Definition: vulkan_core.h:3894
VkStructureType sType
Definition: vulkan_core.h:3891
VkCommandBufferUsageFlags flags
Definition: vulkan_core.h:3893
VkQueryControlFlags queryFlags
Definition: vulkan_core.h:3886
VkQueryPipelineStatisticFlags pipelineStatistics
Definition: vulkan_core.h:3887
@ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
Definition: vulkan_core.h:2830
@ VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT
Definition: vulkan_core.h:2831
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO
Definition: vulkan_core.h:243
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
Definition: vulkan_core.h:244

◆ Create() [1/2]

GrVkSecondaryCommandBuffer * GrVkSecondaryCommandBuffer::Create ( GrVkGpu gpu,
GrVkCommandPool cmdPool 
)
static

Definition at line 947 of file GrVkCommandBuffer.cpp.

948 {
949 SkASSERT(cmdPool);
950 const VkCommandBufferAllocateInfo cmdInfo = {
952 nullptr, // pNext
953 cmdPool->vkCommandPool(), // commandPool
955 1 // bufferCount
956 };
957
958 VkCommandBuffer cmdBuffer;
959 VkResult err;
960 GR_VK_CALL_RESULT(gpu, err, AllocateCommandBuffers(gpu->device(), &cmdInfo, &cmdBuffer));
961 if (err) {
962 return nullptr;
963 }
964 return new GrVkSecondaryCommandBuffer(cmdBuffer, /*externalRenderPass=*/nullptr);
965}
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
VkCommandPool vkCommandPool() const
VkDevice device() const
Definition: GrVkGpu.h:71
@ VK_COMMAND_BUFFER_LEVEL_SECONDARY
Definition: vulkan_core.h:2179
VkResult
Definition: vulkan_core.h:140
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
Definition: vulkan_core.h:242

◆ Create() [2/2]

GrVkSecondaryCommandBuffer * GrVkSecondaryCommandBuffer::Create ( VkCommandBuffer  externalSecondaryCB,
const GrVkRenderPass externalRenderPass 
)
static

Definition at line 967 of file GrVkCommandBuffer.cpp.

968 {
969 return new GrVkSecondaryCommandBuffer(cmdBuffer, externalRenderPass);
970}

◆ end()

void GrVkSecondaryCommandBuffer::end ( GrVkGpu gpu)

Definition at line 1003 of file GrVkCommandBuffer.cpp.

1003 {
1005 SkASSERT(!this->isWrapped());
1006 GR_VK_CALL_ERRCHECK(gpu, EndCommandBuffer(fCmdBuffer));
1007 this->invalidateState();
1008 fHasWork = false;
1009 fIsActive = false;
1010}

◆ recycle()

void GrVkSecondaryCommandBuffer::recycle ( GrVkCommandPool cmdPool)

Definition at line 1012 of file GrVkCommandBuffer.cpp.

1012 {
1013 if (this->isWrapped()) {
1014 delete this;
1015 } else {
1016 cmdPool->recycleSecondaryCommandBuffer(this);
1017 }
1018}
void recycleSecondaryCommandBuffer(GrVkSecondaryCommandBuffer *buffer)

◆ vkCommandBuffer()

VkCommandBuffer GrVkSecondaryCommandBuffer::vkCommandBuffer ( )
inline

Definition at line 359 of file GrVkCommandBuffer.h.

359{ return fCmdBuffer; }

Friends And Related Function Documentation

◆ GrVkPrimaryCommandBuffer

friend class GrVkPrimaryCommandBuffer
friend

Definition at line 371 of file GrVkCommandBuffer.h.


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