| 1 |
From 066bfbac72820a8b7ec8159aef3c3e630063ee5d Mon Sep 17 00:00:00 2001 |
| 2 |
From: Michael Ludwig <[email protected]> |
| 3 |
Date: Tue, 16 Jun 2026 11:08:01 -0400 |
| 4 |
Subject: [PATCH] [graphite] Track resources before adding barriers to |
| 5 |
VulkanCommandBuffer |
| 6 |
|
| 7 |
Bug: https://issues.chromium.org/issues/514078656 |
| 8 |
Change-Id: I8e26fb2b7b193b33428818079ea2570f729476a7 |
| 9 |
Fixed: 514078656 |
| 10 |
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1267777 |
| 11 |
Commit-Queue: Nicolette Prevost <[email protected]> |
| 12 |
Auto-Submit: Michael Ludwig <[email protected]> |
| 13 |
Reviewed-by: Nicolette Prevost <[email protected]> |
| 14 |
--- |
| 15 |
src/gpu/graphite/vk/VulkanCommandBuffer.cpp | 18 +++++++----------- |
| 16 |
src/gpu/graphite/vk/VulkanCommandBuffer.h | 2 +- |
| 17 |
2 files changed, 8 insertions(+), 12 deletions(-) |
| 18 |
|
| 19 |
diff --git a/src/gpu/graphite/vk/VulkanCommandBuffer.cpp b/src/gpu/graphite/vk/VulkanCommandBuffer.cpp |
| 20 |
index 6e0a049bca..6f2a39f0d5 100644 |
| 21 |
--- a/src/gpu/graphite/vk/VulkanCommandBuffer.cpp |
| 22 |
+++ b/src/gpu/graphite/vk/VulkanCommandBuffer.cpp |
| 23 |
@@ -614,6 +614,11 @@ bool VulkanCommandBuffer::onAddRenderPass(const RenderPassDesc& rpDesc, |
| 24 |
const DrawPassList& drawPasses) { |
| 25 |
SkASSERT(resolveOffset.isZero()); |
| 26 |
for (const auto& drawPass : drawPasses) { |
| 27 |
+ // Track resources now since the barriers will reference them. |
| 28 |
+ if (!drawPass->addResourceRefs(fResourceProvider, this)) SK_UNLIKELY { |
| 29 |
+ return false; |
| 30 |
+ } |
| 31 |
+ |
| 32 |
// Our current implementation of setting texture image layouts does not allow layout changes |
| 33 |
// once we have already begun a render pass, so prior to any other commands, set the layout |
| 34 |
// of all sampled textures from the drawpass so they can be sampled from the shader. |
| 35 |
@@ -648,10 +653,7 @@ bool VulkanCommandBuffer::onAddRenderPass(const RenderPassDesc& rpDesc, |
| 36 |
viewport, rpDesc.fDstReadStrategy == DstReadStrategy::kReadFromInput); |
| 37 |
|
| 38 |
for (const auto& drawPass : drawPasses) { |
| 39 |
- if (!this->addDrawPass(drawPass.get())) SK_UNLIKELY { |
| 40 |
- this->endRenderPass(); |
| 41 |
- return false; |
| 42 |
- } |
| 43 |
+ this->addDrawPass(drawPass.get()); |
| 44 |
} |
| 45 |
|
| 46 |
this->endRenderPass(); |
| 47 |
@@ -1110,17 +1112,13 @@ void VulkanCommandBuffer::endRenderPass() { |
| 48 |
fTargetTexture = nullptr; |
| 49 |
} |
| 50 |
|
| 51 |
-bool VulkanCommandBuffer::addDrawPass(DrawPass* drawPass) { |
| 52 |
+void VulkanCommandBuffer::addDrawPass(DrawPass* drawPass) { |
| 53 |
// If there is gradient data to bind, it must be done prior to draws. |
| 54 |
if (drawPass->floatStorageManager()->hasData()) { |
| 55 |
this->recordBufferBindingInfo(drawPass->floatStorageManager()->getBufferInfo(), |
| 56 |
UniformSlot::kGradient); |
| 57 |
} |
| 58 |
|
| 59 |
- if (!drawPass->addResourceRefs(fResourceProvider, this)) SK_UNLIKELY { |
| 60 |
- return false; |
| 61 |
- } |
| 62 |
- |
| 63 |
for (auto [type, cmdPtr] : drawPass->commands()) { |
| 64 |
switch (type) { |
| 65 |
case DrawPassCommands::Type::kBindGraphicsPipeline: { |
| 66 |
@@ -1219,8 +1217,6 @@ bool VulkanCommandBuffer::addDrawPass(DrawPass* drawPass) { |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
- |
| 71 |
- return true; |
| 72 |
} |
| 73 |
|
| 74 |
void VulkanCommandBuffer::bindGraphicsPipeline(const GraphicsPipeline* graphicsPipeline) { |
| 75 |
diff --git a/src/gpu/graphite/vk/VulkanCommandBuffer.h b/src/gpu/graphite/vk/VulkanCommandBuffer.h |
| 76 |
index 60e3f16f17..52c8267b91 100644 |
| 77 |
--- a/src/gpu/graphite/vk/VulkanCommandBuffer.h |
| 78 |
+++ b/src/gpu/graphite/vk/VulkanCommandBuffer.h |
| 79 |
@@ -96,7 +96,7 @@ private: |
| 80 |
|
| 81 |
void endRenderPass(); |
| 82 |
|
| 83 |
- [[nodiscard]] bool addDrawPass(DrawPass*); |
| 84 |
+ void addDrawPass(DrawPass*); |
| 85 |
|
| 86 |
// Track descriptor changes for binding prior to draw calls |
| 87 |
void recordBufferBindingInfo(const BindBufferInfo& info, UniformSlot); |
| 88 |
-- |
| 89 |
2.53.0 |
| 90 |
|