Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
GrVkCommandBuffer Class Referenceabstract

#include <GrVkCommandBuffer.h>

Inheritance diagram for GrVkCommandBuffer:
GrVkPrimaryCommandBuffer GrVkSecondaryCommandBuffer

Public Types

enum  BarrierType { kBufferMemory_BarrierType , kImageMemory_BarrierType }
 

Public Member Functions

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
 

Protected Types

template<typename T >
using TrackedResourceArray = skia_private::STArray< kInitialTrackedResourcesCount, T >
 

Protected Member Functions

 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

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

static constexpr uint32_t kMaxInputBuffers = 2
 

Detailed Description

Definition at line 25 of file GrVkCommandBuffer.h.

Member Typedef Documentation

◆ TrackedResourceArray

template<typename T >
using GrVkCommandBuffer::TrackedResourceArray = skia_private::STArray<kInitialTrackedResourcesCount, T>
protected

Definition at line 163 of file GrVkCommandBuffer.h.

Member Enumeration Documentation

◆ BarrierType

Enumerator
kBufferMemory_BarrierType 
kImageMemory_BarrierType 

Definition at line 34 of file GrVkCommandBuffer.h.

Constructor & Destructor Documentation

◆ ~GrVkCommandBuffer()

virtual GrVkCommandBuffer::~GrVkCommandBuffer ( )
inlinevirtual

Definition at line 27 of file GrVkCommandBuffer.h.

27{}

◆ GrVkCommandBuffer()

GrVkCommandBuffer::GrVkCommandBuffer ( VkCommandBuffer  cmdBuffer,
bool  isWrapped = false 
)
inlineprotected

Definition at line 145 of file GrVkCommandBuffer.h.

146 : fIsActive(isWrapped) // All wrapped command buffers start as active
147 , fCmdBuffer(cmdBuffer)
149 this->invalidateState();
150 }
VkCommandBuffer fCmdBuffer
bool isWrapped() const

Member Function Documentation

◆ addGrBuffer()

void GrVkCommandBuffer::addGrBuffer ( sk_sp< const GrBuffer buffer)
inline

Definition at line 130 of file GrVkCommandBuffer.h.

130 {
132 }
skia_private::STArray< 16, sk_sp< const GrBuffer > > fTrackedGpuBuffers
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

◆ addGrSurface()

void GrVkCommandBuffer::addGrSurface ( sk_sp< const GrSurface surface)
inline

Definition at line 134 of file GrVkCommandBuffer.h.

134 {
135 fTrackedGpuSurfaces.push_back(std::move(surface));
136 }
skia_private::STArray< 16, gr_cb< const GrSurface > > fTrackedGpuSurfaces
VkSurfaceKHR surface
Definition: main.cc:49

◆ addingWork()

void GrVkCommandBuffer::addingWork ( const GrVkGpu gpu)
protected

Definition at line 402 of file GrVkCommandBuffer.cpp.

402 {
403 this->submitPipelineBarriers(gpu);
404 fHasWork = true;
405}
void submitPipelineBarriers(const GrVkGpu *gpu, bool forSelfDependency=false)

◆ addRecycledResource() [1/2]

void GrVkCommandBuffer::addRecycledResource ( const GrRecycledResource resource)
inline

Definition at line 126 of file GrVkCommandBuffer.h.

126 {
127 this->addRecycledResource(gr_ref_rp<const GrRecycledResource>(resource));
128 }
static SkString resource(SkPDFResourceType type, int index)
void addRecycledResource(gr_rp< const GrRecycledResource > resource)

◆ addRecycledResource() [2/2]

void GrVkCommandBuffer::addRecycledResource ( gr_rp< const GrRecycledResource resource)
inline

Definition at line 121 of file GrVkCommandBuffer.h.

121 {
123 fTrackedRecycledResources.push_back(std::move(resource));
124 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
TrackedResourceArray< gr_rp< const GrRecycledResource > > fTrackedRecycledResources

◆ addResource() [1/2]

void GrVkCommandBuffer::addResource ( const GrManagedResource resource)
inline

Definition at line 115 of file GrVkCommandBuffer.h.

115 {
116 this->addResource(sk_ref_sp(resource));
117 }
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
void addResource(sk_sp< const GrManagedResource > resource)

◆ addResource() [2/2]

void GrVkCommandBuffer::addResource ( sk_sp< const GrManagedResource resource)
inline

Definition at line 111 of file GrVkCommandBuffer.h.

111 {
113 fTrackedResources.push_back(std::move(resource));
114 }
TrackedResourceArray< sk_sp< const GrManagedResource > > fTrackedResources

◆ bindDescriptorSets()

void GrVkCommandBuffer::bindDescriptorSets ( const GrVkGpu gpu,
VkPipelineLayout  layout,
uint32_t  firstSet,
uint32_t  setCount,
const VkDescriptorSet *  descriptorSets,
uint32_t  dynamicOffsetCount,
const uint32_t *  dynamicOffsets 
)

Definition at line 254 of file GrVkCommandBuffer.cpp.

260 {
262 GR_VK_CALL(gpu->vkInterface(), CmdBindDescriptorSets(fCmdBuffer,
264 layout,
265 firstSet,
266 setCount,
267 descriptorSets,
268 dynamicOffsetCount,
269 dynamicOffsets));
270}
#define GR_VK_CALL(IFACE, X)
Definition: GrVkUtil.h:24
const skgpu::VulkanInterface * vkInterface() const
Definition: GrVkGpu.h:60
@ VK_PIPELINE_BIND_POINT_GRAPHICS
Definition: vulkan_core.h:2166

◆ bindIndexBuffer()

void GrVkCommandBuffer::bindIndexBuffer ( GrVkGpu gpu,
sk_sp< const GrBuffer buffer 
)

Definition at line 209 of file GrVkCommandBuffer.cpp.

209 {
210 VkBuffer vkBuffer = static_cast<const GrVkBuffer*>(buffer.get())->vkBuffer();
211 SkASSERT(VK_NULL_HANDLE != vkBuffer);
212 // TODO: once ibuffer->offset() no longer always returns 0, we will need to track the offset
213 // to know if we can skip binding or not.
214 if (vkBuffer != fBoundIndexBuffer) {
215 GR_VK_CALL(gpu->vkInterface(), CmdBindIndexBuffer(fCmdBuffer,
216 vkBuffer, /*offset=*/0,
218 fBoundIndexBuffer = vkBuffer;
219 this->addGrBuffer(std::move(buffer));
220 }
221}
void addGrBuffer(sk_sp< const GrBuffer > buffer)
@ VK_INDEX_TYPE_UINT16
Definition: vulkan_core.h:2184
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46

◆ bindInputBuffer()

void GrVkCommandBuffer::bindInputBuffer ( GrVkGpu gpu,
uint32_t  binding,
sk_sp< const GrBuffer buffer 
)

Definition at line 190 of file GrVkCommandBuffer.cpp.

191 {
192 VkBuffer vkBuffer = static_cast<const GrVkBuffer*>(buffer.get())->vkBuffer();
193 SkASSERT(VK_NULL_HANDLE != vkBuffer);
194 SkASSERT(binding < kMaxInputBuffers);
195 // TODO: once vbuffer->offset() no longer always returns 0, we will need to track the offset
196 // to know if we can skip binding or not.
197 if (vkBuffer != fBoundInputBuffers[binding]) {
199 GR_VK_CALL(gpu->vkInterface(), CmdBindVertexBuffers(fCmdBuffer,
200 binding,
201 1,
202 &vkBuffer,
203 &offset));
204 fBoundInputBuffers[binding] = vkBuffer;
205 this->addGrBuffer(std::move(buffer));
206 }
207}
static constexpr uint32_t kMaxInputBuffers
VkBuffer fBoundInputBuffers[kMaxInputBuffers]
SeparatedVector2 offset
uint64_t VkDeviceSize
Definition: vulkan_core.h:96

◆ bindPipeline()

void GrVkCommandBuffer::bindPipeline ( const GrVkGpu gpu,
sk_sp< const GrVkPipeline pipeline 
)

Definition at line 272 of file GrVkCommandBuffer.cpp.

272 {
274 GR_VK_CALL(gpu->vkInterface(), CmdBindPipeline(fCmdBuffer,
276 pipeline->pipeline()));
277 this->addResource(std::move(pipeline));
278}
VkPipeline pipeline() const
Definition: GrVkPipeline.h:63

◆ clearAttachments()

void GrVkCommandBuffer::clearAttachments ( const GrVkGpu gpu,
int  numAttachments,
const VkClearAttachment attachments,
int  numRects,
const VkClearRect clearRects 
)

Definition at line 223 of file GrVkCommandBuffer.cpp.

227 {
230 SkASSERT(numAttachments > 0);
231 SkASSERT(numRects > 0);
232
233 this->addingWork(gpu);
234
235#ifdef SK_DEBUG
236 for (int i = 0; i < numAttachments; ++i) {
237 if (attachments[i].aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) {
238 uint32_t testIndex;
240 SkASSERT(testIndex == attachments[i].colorAttachment);
241 }
242 }
243#endif
244 GR_VK_CALL(gpu->vkInterface(), CmdClearAttachments(fCmdBuffer,
245 numAttachments,
246 attachments,
247 numRects,
248 clearRects));
250 this->invalidateState();
251 }
252}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
bool mustInvalidatePrimaryCmdBufferStateAfterClearAttachments() const
Definition: GrVkCaps.h:185
void addingWork(const GrVkGpu *gpu)
const GrVkRenderPass * fActiveRenderPass
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61
bool colorAttachmentIndex(uint32_t *index) const
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan_core.h:2238

◆ draw()

void GrVkCommandBuffer::draw ( const GrVkGpu gpu,
uint32_t  vertexCount,
uint32_t  instanceCount,
uint32_t  firstVertex,
uint32_t  firstInstance 
)

Definition at line 312 of file GrVkCommandBuffer.cpp.

316 {
319 this->addingWork(gpu);
320 GR_VK_CALL(gpu->vkInterface(), CmdDraw(fCmdBuffer,
321 vertexCount,
322 instanceCount,
323 firstVertex,
324 firstInstance));
325}

◆ drawIndexed()

void GrVkCommandBuffer::drawIndexed ( const GrVkGpu gpu,
uint32_t  indexCount,
uint32_t  instanceCount,
uint32_t  firstIndex,
int32_t  vertexOffset,
uint32_t  firstInstance 
)

Definition at line 295 of file GrVkCommandBuffer.cpp.

300 {
303 this->addingWork(gpu);
304 GR_VK_CALL(gpu->vkInterface(), CmdDrawIndexed(fCmdBuffer,
305 indexCount,
306 instanceCount,
307 firstIndex,
308 vertexOffset,
309 firstInstance));
310}

◆ drawIndexedIndirect()

void GrVkCommandBuffer::drawIndexedIndirect ( const GrVkGpu gpu,
sk_sp< const GrBuffer indirectBuffer,
VkDeviceSize  offset,
uint32_t  drawCount,
uint32_t  stride 
)

Definition at line 345 of file GrVkCommandBuffer.cpp.

349 {
352 SkASSERT(!indirectBuffer->isCpuBuffer());
353 this->addingWork(gpu);
354 VkBuffer vkBuffer = static_cast<const GrVkBuffer*>(indirectBuffer.get())->vkBuffer();
355 GR_VK_CALL(gpu->vkInterface(), CmdDrawIndexedIndirect(fCmdBuffer,
356 vkBuffer,
357 offset,
358 drawCount,
359 stride));
360 this->addGrBuffer(std::move(indirectBuffer));
361}
virtual bool isCpuBuffer() const =0
T * get() const
Definition: SkRefCnt.h:303

◆ drawIndirect()

void GrVkCommandBuffer::drawIndirect ( const GrVkGpu gpu,
sk_sp< const GrBuffer indirectBuffer,
VkDeviceSize  offset,
uint32_t  drawCount,
uint32_t  stride 
)

Definition at line 327 of file GrVkCommandBuffer.cpp.

331 {
334 SkASSERT(!indirectBuffer->isCpuBuffer());
335 this->addingWork(gpu);
336 VkBuffer vkBuffer = static_cast<const GrVkBuffer*>(indirectBuffer.get())->vkBuffer();
337 GR_VK_CALL(gpu->vkInterface(), CmdDrawIndirect(fCmdBuffer,
338 vkBuffer,
339 offset,
340 drawCount,
341 stride));
342 this->addGrBuffer(std::move(indirectBuffer));
343}

◆ freeGPUData()

void GrVkCommandBuffer::freeGPUData ( const GrGpu gpu,
VkCommandPool  pool 
) const

Definition at line 43 of file GrVkCommandBuffer.cpp.

43 {
44 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
50 SkASSERT(cmdPool != VK_NULL_HANDLE);
51 SkASSERT(!this->isWrapped());
52
53 const GrVkGpu* vkGpu = (const GrVkGpu*)gpu;
54 GR_VK_CALL(vkGpu->vkInterface(), FreeCommandBuffers(vkGpu->device(), cmdPool, 1, &fCmdBuffer));
55
56 this->onFreeGPUData(vkGpu);
57}
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
virtual void onFreeGPUData(const GrVkGpu *gpu) const =0
VkDevice device() const
Definition: GrVkGpu.h:71
bool empty() const
Definition: SkTArray.h:199
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ hasWork()

bool GrVkCommandBuffer::hasWork ( ) const
inline

Definition at line 142 of file GrVkCommandBuffer.h.

142{ return fHasWork; }

◆ invalidateState()

void GrVkCommandBuffer::invalidateState ( )

Definition at line 26 of file GrVkCommandBuffer.cpp.

26 {
27 for (auto& boundInputBuffer : fBoundInputBuffers) {
28 boundInputBuffer = VK_NULL_HANDLE;
29 }
31
32 memset(&fCachedViewport, 0, sizeof(VkViewport));
33 fCachedViewport.width = - 1.0f; // Viewport must have a width greater than 0
34
35 memset(&fCachedScissor, 0, sizeof(VkRect2D));
36 fCachedScissor.offset.x = -1; // Scissor offset must be greater that 0 to be valid
37
38 for (int i = 0; i < 4; ++i) {
39 fCachedBlendConstant[i] = -1.0;
40 }
41}
VkViewport fCachedViewport
int32_t x
Definition: vulkan_core.h:2869
VkOffset2D offset
Definition: vulkan_core.h:2880

◆ isWrapped()

bool GrVkCommandBuffer::isWrapped ( ) const
inlineprotected

Definition at line 152 of file GrVkCommandBuffer.h.

152{ return fIsWrapped; }

◆ onFreeGPUData()

virtual void GrVkCommandBuffer::onFreeGPUData ( const GrVkGpu gpu) const
protectedpure virtual

◆ onReleaseResources()

virtual void GrVkCommandBuffer::onReleaseResources ( )
inlineprotectedvirtual

Definition at line 181 of file GrVkCommandBuffer.h.

181{}

◆ pipelineBarrier()

void GrVkCommandBuffer::pipelineBarrier ( const GrVkGpu gpu,
const GrManagedResource resource,
VkPipelineStageFlags  srcStageMask,
VkPipelineStageFlags  dstStageMask,
bool  byRegion,
BarrierType  barrierType,
void *  barrier 
)

Definition at line 77 of file GrVkCommandBuffer.cpp.

83 {
84 SkASSERT(!this->isWrapped());
86#ifdef SK_DEBUG
87 // For images we can have barriers inside of render passes but they require us to add more
88 // support in subpasses which need self dependencies to have barriers inside them. Also, we can
89 // never have buffer barriers inside of a render pass. For now we will just assert that we are
90 // not in a render pass.
91 bool isValidSubpassBarrier = false;
92 if (barrierType == kImageMemory_BarrierType) {
93 VkImageMemoryBarrier* imgBarrier = static_cast<VkImageMemoryBarrier*>(barrier);
94 isValidSubpassBarrier = (imgBarrier->newLayout == imgBarrier->oldLayout) &&
97 byRegion;
98 }
99 SkASSERT(!fActiveRenderPass || isValidSubpassBarrier);
100#endif
101
102 if (barrierType == kBufferMemory_BarrierType) {
103 const VkBufferMemoryBarrier* barrierPtr = static_cast<VkBufferMemoryBarrier*>(barrier);
104 fBufferBarriers.push_back(*barrierPtr);
105 } else {
106 SkASSERT(barrierType == kImageMemory_BarrierType);
107 const VkImageMemoryBarrier* barrierPtr = static_cast<VkImageMemoryBarrier*>(barrier);
108 // We need to check if we are adding a pipeline barrier that covers part of the same
109 // subresource range as a barrier that is already in current batch. If it does, then we must
110 // submit the first batch because the vulkan spec does not define a specific ordering for
111 // barriers submitted in the same batch.
112 // TODO: Look if we can gain anything by merging barriers together instead of submitting
113 // the old ones.
114 for (int i = 0; i < fImageBarriers.size(); ++i) {
115 VkImageMemoryBarrier& currentBarrier = fImageBarriers[i];
116 if (barrierPtr->image == currentBarrier.image) {
117 const VkImageSubresourceRange newRange = barrierPtr->subresourceRange;
118 const VkImageSubresourceRange oldRange = currentBarrier.subresourceRange;
119 SkASSERT(newRange.aspectMask == oldRange.aspectMask);
120 SkASSERT(newRange.baseArrayLayer == oldRange.baseArrayLayer);
121 SkASSERT(newRange.layerCount == oldRange.layerCount);
122 uint32_t newStart = newRange.baseMipLevel;
123 uint32_t newEnd = newRange.baseMipLevel + newRange.levelCount - 1;
124 uint32_t oldStart = oldRange.baseMipLevel;
125 uint32_t oldEnd = oldRange.baseMipLevel + oldRange.levelCount - 1;
126 if (std::max(newStart, oldStart) <= std::min(newEnd, oldEnd)) {
127 this->submitPipelineBarriers(gpu);
128 break;
129 }
130 }
131 }
132 fImageBarriers.push_back(*barrierPtr);
133 }
134 fBarriersByRegion |= byRegion;
135 fSrcStageMask = fSrcStageMask | srcStageMask;
136 fDstStageMask = fDstStageMask | dstStageMask;
137
138 fHasWork = true;
139 if (resource) {
140 this->addResource(resource);
141 }
142 if (fActiveRenderPass) {
143 this->submitPipelineBarriers(gpu, true);
144 }
145}
VkPipelineStageFlags fDstStageMask
skia_private::STArray< 2, VkImageMemoryBarrier > fImageBarriers
skia_private::STArray< 1, VkBufferMemoryBarrier > fBufferBarriers
VkPipelineStageFlags fSrcStageMask
int size() const
Definition: SkTArray.h:421
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
uint32_t dstQueueFamilyIndex
Definition: vulkan_core.h:2943
VkImageLayout newLayout
Definition: vulkan_core.h:2941
VkImageSubresourceRange subresourceRange
Definition: vulkan_core.h:2945
VkImageLayout oldLayout
Definition: vulkan_core.h:2940
uint32_t srcQueueFamilyIndex
Definition: vulkan_core.h:2942
VkImageAspectFlags aspectMask
Definition: vulkan_core.h:2928
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan_core.h:127

◆ pushConstants()

void GrVkCommandBuffer::pushConstants ( const GrVkGpu gpu,
VkPipelineLayout  layout,
VkShaderStageFlags  stageFlags,
uint32_t  offset,
uint32_t  size,
const void *  values 
)

Definition at line 280 of file GrVkCommandBuffer.cpp.

282 {
284 // offset and size must be a multiple of 4
285 SkASSERT(!SkToBool(offset & 0x3));
286 SkASSERT(!SkToBool(size & 0x3));
287 GR_VK_CALL(gpu->vkInterface(), CmdPushConstants(fCmdBuffer,
288 layout,
289 stageFlags,
290 offset,
291 size,
292 values));
293}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
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

◆ releaseResources()

void GrVkCommandBuffer::releaseResources ( )

Definition at line 59 of file GrVkCommandBuffer.cpp.

59 {
60 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
61 SkASSERT(!fIsActive || this->isWrapped());
62 fTrackedResources.clear();
64
66 fTrackedGpuSurfaces.clear();
67
68 this->invalidateState();
69
70 this->onReleaseResources();
71}
virtual void onReleaseResources()

◆ setBlendConstants()

void GrVkCommandBuffer::setBlendConstants ( const GrVkGpu gpu,
const float  blendConstants[4] 
)

Definition at line 393 of file GrVkCommandBuffer.cpp.

394 {
396 if (0 != memcmp(blendConstants, fCachedBlendConstant, 4 * sizeof(float))) {
397 GR_VK_CALL(gpu->vkInterface(), CmdSetBlendConstants(fCmdBuffer, blendConstants));
398 memcpy(fCachedBlendConstant, blendConstants, 4 * sizeof(float));
399 }
400}

◆ setScissor()

void GrVkCommandBuffer::setScissor ( const GrVkGpu gpu,
uint32_t  firstScissor,
uint32_t  scissorCount,
const VkRect2D scissors 
)

Definition at line 378 of file GrVkCommandBuffer.cpp.

381 {
383 SkASSERT(1 == scissorCount);
384 if (0 != memcmp(scissors, &fCachedScissor, sizeof(VkRect2D))) {
385 GR_VK_CALL(gpu->vkInterface(), CmdSetScissor(fCmdBuffer,
386 firstScissor,
387 scissorCount,
388 scissors));
389 fCachedScissor = scissors[0];
390 }
391}

◆ setViewport()

void GrVkCommandBuffer::setViewport ( const GrVkGpu gpu,
uint32_t  firstViewport,
uint32_t  viewportCount,
const VkViewport viewports 
)

Definition at line 363 of file GrVkCommandBuffer.cpp.

366 {
368 SkASSERT(1 == viewportCount);
369 if (0 != memcmp(viewports, &fCachedViewport, sizeof(VkViewport))) {
370 GR_VK_CALL(gpu->vkInterface(), CmdSetViewport(fCmdBuffer,
371 firstViewport,
372 viewportCount,
373 viewports));
374 fCachedViewport = viewports[0];
375 }
376}

◆ submitPipelineBarriers()

void GrVkCommandBuffer::submitPipelineBarriers ( const GrVkGpu gpu,
bool  forSelfDependency = false 
)
protected

Definition at line 147 of file GrVkCommandBuffer.cpp.

147 {
149
150 // Currently we never submit a pipeline barrier without at least one memory barrier.
152 // For images we can have barriers inside of render passes but they require us to add more
153 // support in subpasses which need self dependencies to have barriers inside them. Also, we
154 // can never have buffer barriers inside of a render pass. For now we will just assert that
155 // we are not in a render pass.
156 SkASSERT(!fActiveRenderPass || forSelfDependency);
157 SkASSERT(!this->isWrapped());
159
160 // TODO(https://crbug.com/1469231): The linked bug references a crash report from calling
161 // CmdPipelineBarrier. The checks below were added to ensure that we are passing in buffer
162 // counts >= 0, and in the case of >0, that the buffers are non-null. Evaluate whether this
163 // change leads to a reduction in crash instances. If not, the issue may lie within the
164 // driver itself and these checks can be removed.
165 if (!fBufferBarriers.empty() && fBufferBarriers.begin() == nullptr) {
166 fBufferBarriers.clear(); // Sets the size to 0
167 }
168 if (!fImageBarriers.empty() && fImageBarriers.begin() == nullptr) {
169 fImageBarriers.clear(); // Sets the size to 0
170 }
171
173 GR_VK_CALL(gpu->vkInterface(), CmdPipelineBarrier(
174 fCmdBuffer, fSrcStageMask, fDstStageMask, dependencyFlags, 0, nullptr,
179 fBarriersByRegion = false;
180 fSrcStageMask = 0;
181 fDstStageMask = 0;
182 }
188}
@ VK_DEPENDENCY_BY_REGION_BIT
Definition: vulkan_core.h:2776
VkFlags VkDependencyFlags
Definition: vulkan_core.h:2784

Member Data Documentation

◆ fActiveRenderPass

const GrVkRenderPass* GrVkCommandBuffer::fActiveRenderPass = nullptr
protected

Definition at line 177 of file GrVkCommandBuffer.h.

◆ fBarriersByRegion

bool GrVkCommandBuffer::fBarriersByRegion = false
protected

Definition at line 197 of file GrVkCommandBuffer.h.

◆ fBoundIndexBuffer

VkBuffer GrVkCommandBuffer::fBoundIndexBuffer
protected

Definition at line 187 of file GrVkCommandBuffer.h.

◆ fBoundInputBuffers

VkBuffer GrVkCommandBuffer::fBoundInputBuffers[kMaxInputBuffers]
protected

Definition at line 186 of file GrVkCommandBuffer.h.

◆ fBufferBarriers

skia_private::STArray<1, VkBufferMemoryBarrier> GrVkCommandBuffer::fBufferBarriers
protected

Definition at line 195 of file GrVkCommandBuffer.h.

◆ fCachedBlendConstant

float GrVkCommandBuffer::fCachedBlendConstant[4]
protected

Definition at line 192 of file GrVkCommandBuffer.h.

◆ fCachedScissor

VkRect2D GrVkCommandBuffer::fCachedScissor
protected

Definition at line 191 of file GrVkCommandBuffer.h.

◆ fCachedViewport

VkViewport GrVkCommandBuffer::fCachedViewport
protected

Definition at line 190 of file GrVkCommandBuffer.h.

◆ fCmdBuffer

VkCommandBuffer GrVkCommandBuffer::fCmdBuffer
protected

Definition at line 179 of file GrVkCommandBuffer.h.

◆ fDstStageMask

VkPipelineStageFlags GrVkCommandBuffer::fDstStageMask = 0
protected

Definition at line 199 of file GrVkCommandBuffer.h.

◆ fHasWork

bool GrVkCommandBuffer::fHasWork = false
protected

Definition at line 172 of file GrVkCommandBuffer.h.

◆ fImageBarriers

skia_private::STArray<2, VkImageMemoryBarrier> GrVkCommandBuffer::fImageBarriers
protected

Definition at line 196 of file GrVkCommandBuffer.h.

◆ fIsActive

bool GrVkCommandBuffer::fIsActive
protected

Definition at line 171 of file GrVkCommandBuffer.h.

◆ fIsWrapped

bool GrVkCommandBuffer::fIsWrapped
protected

Definition at line 201 of file GrVkCommandBuffer.h.

◆ fSrcStageMask

VkPipelineStageFlags GrVkCommandBuffer::fSrcStageMask = 0
protected

Definition at line 198 of file GrVkCommandBuffer.h.

◆ fTrackedGpuBuffers

skia_private::STArray<16, sk_sp<const GrBuffer> > GrVkCommandBuffer::fTrackedGpuBuffers
protected

Definition at line 166 of file GrVkCommandBuffer.h.

◆ fTrackedGpuSurfaces

skia_private::STArray<16, gr_cb<const GrSurface> > GrVkCommandBuffer::fTrackedGpuSurfaces
protected

Definition at line 167 of file GrVkCommandBuffer.h.

◆ fTrackedRecycledResources

TrackedResourceArray<gr_rp<const GrRecycledResource> > GrVkCommandBuffer::fTrackedRecycledResources
protected

Definition at line 165 of file GrVkCommandBuffer.h.

◆ fTrackedResources

TrackedResourceArray<sk_sp<const GrManagedResource> > GrVkCommandBuffer::fTrackedResources
protected

Definition at line 164 of file GrVkCommandBuffer.h.

◆ kMaxInputBuffers

constexpr uint32_t GrVkCommandBuffer::kMaxInputBuffers = 2
staticconstexprprotected

Definition at line 184 of file GrVkCommandBuffer.h.


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