Minor refactoring of where we call addingWork in GrVkCommandBuffer.
This is a quick refactor that a pulled out to setup for a follow on change. Bug: skia: Change-Id: I3be36b44396e7b72abe5d9627c92263ee13b529a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205923 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
dde12a25bb
commit
f346df396a
@ -141,6 +141,9 @@ void GrVkCommandBuffer::pipelineBarrier(const GrVkGpu* gpu,
|
||||
// never have buffer barriers inside of a render pass. For now we will just assert that we are
|
||||
// not in a render pass.
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
|
||||
this->addingWork();
|
||||
|
||||
VkDependencyFlags dependencyFlags = byRegion ? VK_DEPENDENCY_BY_REGION_BIT : 0;
|
||||
|
||||
switch (barrierType) {
|
||||
@ -179,8 +182,6 @@ void GrVkCommandBuffer::pipelineBarrier(const GrVkGpu* gpu,
|
||||
if (resource) {
|
||||
this->addResource(resource);
|
||||
}
|
||||
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkCommandBuffer::bindInputBuffer(GrVkGpu* gpu, uint32_t binding,
|
||||
@ -221,11 +222,14 @@ void GrVkCommandBuffer::clearAttachments(const GrVkGpu* gpu,
|
||||
int numAttachments,
|
||||
const VkClearAttachment* attachments,
|
||||
int numRects,
|
||||
const VkClearRect* clearRects) const {
|
||||
const VkClearRect* clearRects) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(fActiveRenderPass);
|
||||
SkASSERT(numAttachments > 0);
|
||||
SkASSERT(numRects > 0);
|
||||
|
||||
this->addingWork();
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
for (int i = 0; i < numAttachments; ++i) {
|
||||
if (attachments[i].aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||
@ -240,7 +244,6 @@ void GrVkCommandBuffer::clearAttachments(const GrVkGpu* gpu,
|
||||
attachments,
|
||||
numRects,
|
||||
clearRects));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkCommandBuffer::bindDescriptorSets(const GrVkGpu* gpu,
|
||||
@ -303,31 +306,31 @@ void GrVkCommandBuffer::drawIndexed(const GrVkGpu* gpu,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstIndex,
|
||||
int32_t vertexOffset,
|
||||
uint32_t firstInstance) const {
|
||||
uint32_t firstInstance) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(fActiveRenderPass);
|
||||
this->addingWork();
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdDrawIndexed(fCmdBuffer,
|
||||
indexCount,
|
||||
instanceCount,
|
||||
firstIndex,
|
||||
vertexOffset,
|
||||
firstInstance));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkCommandBuffer::draw(const GrVkGpu* gpu,
|
||||
uint32_t vertexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstVertex,
|
||||
uint32_t firstInstance) const {
|
||||
uint32_t firstInstance) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(fActiveRenderPass);
|
||||
this->addingWork();
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdDraw(fCmdBuffer,
|
||||
vertexCount,
|
||||
instanceCount,
|
||||
firstVertex,
|
||||
firstInstance));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkCommandBuffer::setViewport(const GrVkGpu* gpu,
|
||||
@ -434,6 +437,8 @@ void GrVkPrimaryCommandBuffer::beginRenderPass(const GrVkGpu* gpu,
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
SkASSERT(renderPass->isCompatible(target));
|
||||
|
||||
this->addingWork();
|
||||
|
||||
VkRenderPassBeginInfo beginInfo;
|
||||
VkRect2D renderArea;
|
||||
renderArea.offset = { bounds.fLeft , bounds.fTop };
|
||||
@ -455,15 +460,14 @@ void GrVkPrimaryCommandBuffer::beginRenderPass(const GrVkGpu* gpu,
|
||||
fActiveRenderPass = renderPass;
|
||||
this->addResource(renderPass);
|
||||
target.addResources(*this);
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::endRenderPass(const GrVkGpu* gpu) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(fActiveRenderPass);
|
||||
this->addingWork();
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdEndRenderPass(fCmdBuffer));
|
||||
fActiveRenderPass = nullptr;
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::executeCommands(const GrVkGpu* gpu,
|
||||
@ -477,13 +481,14 @@ void GrVkPrimaryCommandBuffer::executeCommands(const GrVkGpu* gpu,
|
||||
SkASSERT(fActiveRenderPass);
|
||||
SkASSERT(fActiveRenderPass->isCompatible(*buffer->fActiveRenderPass));
|
||||
|
||||
this->addingWork();
|
||||
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdExecuteCommands(fCmdBuffer, 1, &buffer->fCmdBuffer));
|
||||
buffer->ref();
|
||||
fSecondaryCommandBuffers.push_back(buffer);
|
||||
// When executing a secondary command buffer all state (besides render pass state) becomes
|
||||
// invalidated and must be reset. This includes bound buffers, pipelines, dynamic state, etc.
|
||||
this->invalidateState();
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
static void submit_to_queue(const GrVkInterface* interface,
|
||||
@ -638,6 +643,7 @@ void GrVkPrimaryCommandBuffer::copyImage(const GrVkGpu* gpu,
|
||||
const VkImageCopy* copyRegions) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
this->addingWork();
|
||||
this->addResource(srcImage->resource());
|
||||
this->addResource(dstImage->resource());
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdCopyImage(fCmdBuffer,
|
||||
@ -647,7 +653,6 @@ void GrVkPrimaryCommandBuffer::copyImage(const GrVkGpu* gpu,
|
||||
dstLayout,
|
||||
copyRegionCount,
|
||||
copyRegions));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::blitImage(const GrVkGpu* gpu,
|
||||
@ -662,6 +667,7 @@ void GrVkPrimaryCommandBuffer::blitImage(const GrVkGpu* gpu,
|
||||
VkFilter filter) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
this->addingWork();
|
||||
this->addResource(srcResource);
|
||||
this->addResource(dstResource);
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdBlitImage(fCmdBuffer,
|
||||
@ -672,7 +678,6 @@ void GrVkPrimaryCommandBuffer::blitImage(const GrVkGpu* gpu,
|
||||
blitRegionCount,
|
||||
blitRegions,
|
||||
filter));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::blitImage(const GrVkGpu* gpu,
|
||||
@ -702,6 +707,7 @@ void GrVkPrimaryCommandBuffer::copyImageToBuffer(const GrVkGpu* gpu,
|
||||
const VkBufferImageCopy* copyRegions) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
this->addingWork();
|
||||
this->addResource(srcImage->resource());
|
||||
this->addResource(dstBuffer->resource());
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdCopyImageToBuffer(fCmdBuffer,
|
||||
@ -710,7 +716,6 @@ void GrVkPrimaryCommandBuffer::copyImageToBuffer(const GrVkGpu* gpu,
|
||||
dstBuffer->buffer(),
|
||||
copyRegionCount,
|
||||
copyRegions));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::copyBufferToImage(const GrVkGpu* gpu,
|
||||
@ -721,6 +726,7 @@ void GrVkPrimaryCommandBuffer::copyBufferToImage(const GrVkGpu* gpu,
|
||||
const VkBufferImageCopy* copyRegions) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
this->addingWork();
|
||||
this->addResource(srcBuffer->resource());
|
||||
this->addResource(dstImage->resource());
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdCopyBufferToImage(fCmdBuffer,
|
||||
@ -729,7 +735,6 @@ void GrVkPrimaryCommandBuffer::copyBufferToImage(const GrVkGpu* gpu,
|
||||
dstLayout,
|
||||
copyRegionCount,
|
||||
copyRegions));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
|
||||
@ -740,6 +745,7 @@ void GrVkPrimaryCommandBuffer::copyBuffer(GrVkGpu* gpu,
|
||||
const VkBufferCopy* regions) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
this->addingWork();
|
||||
#ifdef SK_DEBUG
|
||||
for (uint32_t i = 0; i < regionCount; ++i) {
|
||||
const VkBufferCopy& region = regions[i];
|
||||
@ -757,7 +763,6 @@ void GrVkPrimaryCommandBuffer::copyBuffer(GrVkGpu* gpu,
|
||||
dstBuffer->buffer(),
|
||||
regionCount,
|
||||
regions));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::updateBuffer(GrVkGpu* gpu,
|
||||
@ -771,13 +776,13 @@ void GrVkPrimaryCommandBuffer::updateBuffer(GrVkGpu* gpu,
|
||||
// TODO: handle larger transfer sizes
|
||||
SkASSERT(dataSize <= 65536);
|
||||
SkASSERT(0 == (dataSize & 0x03)); // four byte aligned
|
||||
this->addingWork();
|
||||
this->addResource(dstBuffer->resource());
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdUpdateBuffer(fCmdBuffer,
|
||||
dstBuffer->buffer(),
|
||||
dstOffset,
|
||||
dataSize,
|
||||
(const uint32_t*) data));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::clearColorImage(const GrVkGpu* gpu,
|
||||
@ -787,6 +792,7 @@ void GrVkPrimaryCommandBuffer::clearColorImage(const GrVkGpu* gpu,
|
||||
const VkImageSubresourceRange* subRanges) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
this->addingWork();
|
||||
this->addResource(image->resource());
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdClearColorImage(fCmdBuffer,
|
||||
image->image(),
|
||||
@ -794,7 +800,6 @@ void GrVkPrimaryCommandBuffer::clearColorImage(const GrVkGpu* gpu,
|
||||
color,
|
||||
subRangeCount,
|
||||
subRanges));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::clearDepthStencilImage(const GrVkGpu* gpu,
|
||||
@ -804,6 +809,7 @@ void GrVkPrimaryCommandBuffer::clearDepthStencilImage(const GrVkGpu* gpu,
|
||||
const VkImageSubresourceRange* subRanges) {
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
this->addingWork();
|
||||
this->addResource(image->resource());
|
||||
GR_VK_CALL(gpu->vkInterface(), CmdClearDepthStencilImage(fCmdBuffer,
|
||||
image->image(),
|
||||
@ -811,7 +817,6 @@ void GrVkPrimaryCommandBuffer::clearDepthStencilImage(const GrVkGpu* gpu,
|
||||
color,
|
||||
subRangeCount,
|
||||
subRanges));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::resolveImage(GrVkGpu* gpu,
|
||||
@ -822,6 +827,7 @@ void GrVkPrimaryCommandBuffer::resolveImage(GrVkGpu* gpu,
|
||||
SkASSERT(fIsActive);
|
||||
SkASSERT(!fActiveRenderPass);
|
||||
|
||||
this->addingWork();
|
||||
this->addResource(srcImage.resource());
|
||||
this->addResource(dstImage.resource());
|
||||
|
||||
@ -832,7 +838,6 @@ void GrVkPrimaryCommandBuffer::resolveImage(GrVkGpu* gpu,
|
||||
dstImage.currentLayout(),
|
||||
regionCount,
|
||||
regions));
|
||||
this->addedWork();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::onFreeGPUData(GrVkGpu* gpu) const {
|
||||
|
@ -90,20 +90,20 @@ public:
|
||||
int numAttachments,
|
||||
const VkClearAttachment* attachments,
|
||||
int numRects,
|
||||
const VkClearRect* clearRects) const;
|
||||
const VkClearRect* clearRects);
|
||||
|
||||
void drawIndexed(const GrVkGpu* gpu,
|
||||
uint32_t indexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstIndex,
|
||||
int32_t vertexOffset,
|
||||
uint32_t firstInstance) const;
|
||||
uint32_t firstInstance);
|
||||
|
||||
void draw(const GrVkGpu* gpu,
|
||||
uint32_t vertexCount,
|
||||
uint32_t instanceCount,
|
||||
uint32_t firstVertex,
|
||||
uint32_t firstInstance) const;
|
||||
uint32_t firstInstance);
|
||||
|
||||
// Add ref-counted resource that will be tracked and released when this command buffer finishes
|
||||
// execution
|
||||
@ -151,7 +151,7 @@ protected:
|
||||
return fCmdPool == nullptr;
|
||||
}
|
||||
|
||||
void addedWork() const { fHasWork = true; }
|
||||
void addingWork() { fHasWork = true; }
|
||||
|
||||
SkTDArray<const GrVkResource*> fTrackedResources;
|
||||
SkTDArray<const GrVkRecycledResource*> fTrackedRecycledResources;
|
||||
@ -160,7 +160,7 @@ protected:
|
||||
// Tracks whether we are in the middle of a command buffer begin/end calls and thus can add
|
||||
// new commands to the buffer;
|
||||
bool fIsActive;
|
||||
mutable bool fHasWork = false;
|
||||
bool fHasWork = false;
|
||||
|
||||
// Stores a pointer to the current active render pass (i.e. begin has been called but not
|
||||
// end). A nullptr means there is no active render pass. The GrVKCommandBuffer does not own
|
||||
|
Loading…
Reference in New Issue
Block a user