| 1 |
From 04b084c10b54142767250e736ea44fc82f30d4d6 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Thomas Smith <[email protected]> |
| 3 |
Date: Fri, 29 May 2026 12:42:22 -0400 |
| 4 |
Subject: [PATCH] Reland "[graphite] BufferSubAllocator respects failed mapping |
| 5 |
on reset" |
| 6 |
|
| 7 |
* `getMappedUniformBuffer` was changed after M148 but before M149. This caused comments in the unit test to be wrong, causing M148 cherry pick to fail CQ. |
| 8 |
|
| 9 |
* Change the unit test to instead use `getMappedIndexBuffer`, which is stable across the relevant releases, and has been confirmed to trigger the bug. |
| 10 |
|
| 11 |
* These changes purely affect the unit test and not the fix itself. |
| 12 |
|
| 13 |
This reverts commit c329e877d1848877d459999a4ed43b3728892b7b. |
| 14 |
|
| 15 |
Original change's description: |
| 16 |
> Revert "[graphite] BufferSubAllocator respects failed mapping on reset" |
| 17 |
> |
| 18 |
> This reverts commit e7bff78bf5d2994f627742aaf5040b2ba55c4475. |
| 19 |
> |
| 20 |
> Fails clang-tidy |
| 21 |
> |
| 22 |
> Original change's description: |
| 23 |
> > [graphite] BufferSubAllocator respects failed mapping on reset |
| 24 |
> > |
| 25 |
> > Bug: b/516981393 |
| 26 |
> > Change-Id: If6837e26ee520ad34c8df46a34850220ec5b538c |
| 27 |
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1247536 |
| 28 |
> > Commit-Queue: Thomas Smith <[email protected]> |
| 29 |
> > Reviewed-by: Michael Ludwig <[email protected]> |
| 30 |
> |
| 31 |
> Bug: b/516981393 |
| 32 |
> No-Presubmit: true |
| 33 |
> No-Tree-Checks: true |
| 34 |
> No-Try: true |
| 35 |
> Change-Id: I8cf69a8ba2ff318aab65033af821954e4493e5cb |
| 36 |
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1249556 |
| 37 |
> Auto-Submit: Thomas Smith <[email protected]> |
| 38 |
> Commit-Queue: [email protected] <[email protected]> |
| 39 |
> Bot-Commit: [email protected] <[email protected]> |
| 40 |
|
| 41 |
Bug: https://issues.chromium.org/issues/516981393 |
| 42 |
Change-Id: I3688a446d9042ffdb79a6c91d73f72bd5016716e |
| 43 |
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1249557 |
| 44 |
Commit-Queue: Thomas Smith <[email protected]> |
| 45 |
Reviewed-by: Michael Ludwig <[email protected]> |
| 46 |
--- |
| 47 |
src/gpu/graphite/BufferManager.cpp | 14 ++++++---- |
| 48 |
src/gpu/graphite/BufferManager.h | 4 +++ |
| 49 |
tests/graphite/BufferManagerTest.cpp | 41 ++++++++++++++++++++++++++++ |
| 50 |
3 files changed, 54 insertions(+), 5 deletions(-) |
| 51 |
|
| 52 |
--- a/src/gpu/graphite/BufferManager.cpp |
| 53 |
+++ b/src/gpu/graphite/BufferManager.cpp |
| 54 |
@@ -253,6 +253,13 @@ |
| 55 |
if (fBuffer) { |
| 56 |
SkASSERT(fOwner); |
| 57 |
|
| 58 |
+ if (fOwner->fMappingFailed) { |
| 59 |
+ fBuffer = nullptr; |
| 60 |
+ fRemaining = 0; |
| 61 |
+ fTransferBuffer = {}; |
| 62 |
+ return; |
| 63 |
+ } |
| 64 |
+ |
| 65 |
DrawBufferManager::BufferState& state = fOwner->fCurrentBuffers[fStateIndex]; |
| 66 |
if (fBuffer->shareable() == Shareable::kScratch) { |
| 67 |
// TODO: Merge this reuse of scratch resources with the ScratchResourceManager, but |
| 68 |
@@ -261,11 +268,8 @@ |
| 69 |
// The scratch buffer's availability for reuse (scoped to the owning DrawBufferManager) |
| 70 |
// was tied to this BufferSubAllocator, so when that is reset, we just remove the buffer |
| 71 |
// from the set of unavailable buffers. |
| 72 |
- SkASSERT((fOwner->fMappingFailed && state.fUnavailableScratchBuffers.empty()) || |
| 73 |
- state.fUnavailableScratchBuffers.contains(fBuffer.get())); |
| 74 |
- if (!fOwner->fMappingFailed) { |
| 75 |
- state.fUnavailableScratchBuffers.remove(fBuffer.get()); |
| 76 |
- } |
| 77 |
+ SkASSERT(state.fUnavailableScratchBuffers.contains(fBuffer.get())); |
| 78 |
+ state.fUnavailableScratchBuffers.remove(fBuffer.get()); |
| 79 |
|
| 80 |
SkASSERT(!fTransferBuffer); // Scratch buffers shouldn't be using transfer buffers |
| 81 |
fOwner->fUsedBuffers.emplace_back(std::move(fBuffer), BindBufferInfo{}); |
| 82 |
--- a/src/gpu/graphite/BufferManager.h |
| 83 |
+++ b/src/gpu/graphite/BufferManager.h |
| 84 |
@@ -327,6 +327,10 @@ |
| 85 |
// for recording buffer data for the next Recording. |
| 86 |
[[nodiscard]] bool transferToRecording(Recording*); |
| 87 |
|
| 88 |
+#if defined(GPU_TEST_UTILS) |
| 89 |
+ void testingOnly_onFailedBuffer() { this->onFailedBuffer(); } |
| 90 |
+#endif |
| 91 |
+ |
| 92 |
private: |
| 93 |
friend class BufferSubAllocator; |
| 94 |
|