Revert "Make GrRingBuffer more generic so it can be used over all backends"
This reverts commit b6d4ad92adcac186c3bc52feef85de38752a1f1d.
Reason for revert: Breaking the bots
Original change's description:
> Make GrRingBuffer more generic so it can be used over all backends
>
> * Removes the spinlock (should no longer be necessary)
> * Uses GrGpuBuffer and creation through GrResourceProvider
> instead of internal native creation
> * Changes the SubmitData to pass up all buffers used over a given submit
> so the backend can track that better
>
> Bug: skia:10530
> Change-Id: I0d3a686b950dd5cb5f720f827b573238386b9524
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305567
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>
TBR=egdaniel@google.com,jvanverth@google.com
Change-Id: Ief7df521f66e85d9bfb85508e5a5f8223d7d6725
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10530
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305720
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/GrRingBuffer.cpp b/src/gpu/GrRingBuffer.cpp
index a911c20..145c88a 100644
--- a/src/gpu/GrRingBuffer.cpp
+++ b/src/gpu/GrRingBuffer.cpp
@@ -7,15 +7,12 @@
#include "src/gpu/GrRingBuffer.h"
-#include "src/gpu/GrContextPriv.h"
-#include "src/gpu/GrGpu.h"
-#include "src/gpu/GrResourceProvider.h"
-
// Get offset into buffer that has enough space for size
// Returns fTotalSize if no space
size_t GrRingBuffer::getAllocationOffset(size_t size) {
// capture current state locally (because fTail could be overwritten by the completion handler)
size_t head, tail;
+ SkAutoSpinlock lock(fMutex);
head = fHead;
tail = fTail;
@@ -55,40 +52,39 @@
}
GrRingBuffer::Slice GrRingBuffer::suballocate(size_t size) {
- if (fCurrentBuffer) {
- size_t offset = this->getAllocationOffset(size);
- if (offset < fTotalSize) {
- return { fCurrentBuffer.get(), offset };
- }
-
- // Try to grow allocation (old allocation will age out).
- fTotalSize *= 2;
+ size_t offset = this->getAllocationOffset(size);
+ if (offset < fTotalSize) {
+ return { fBuffer, offset };
}
- GrResourceProvider* resourceProvider = fGpu->getContext()->priv().resourceProvider();
- fCurrentBuffer = resourceProvider->createBuffer(fTotalSize, fType, kDynamic_GrAccessPattern);
-
- SkASSERT(fCurrentBuffer);
- fTrackedBuffers.push_back(fCurrentBuffer);
- fHead = 0;
- fTail = 0;
- fGenID++;
- size_t offset = this->getAllocationOffset(size);
+ // Try to grow allocation (old allocation will age out).
+ fTotalSize *= 2;
+ fBuffer = this->createBuffer(fTotalSize);
+ SkASSERT(fBuffer);
+ {
+ SkAutoSpinlock lock(fMutex);
+ fHead = 0;
+ fTail = 0;
+ fGenID++;
+ }
+ offset = this->getAllocationOffset(size);
SkASSERT(offset < fTotalSize);
- return { fCurrentBuffer.get(), offset };
+ return { fBuffer, offset };
}
// used when current command buffer/command list is submitted
-void GrRingBuffer::startSubmit(GrRingBuffer::SubmitData* submitData) {
- submitData->fTrackedBuffers = std::move(fTrackedBuffers);
- submitData->fLastHead = fHead;
- submitData->fGenID = fGenID;
- // add current buffer to be tracked for next submit
- fTrackedBuffers.push_back(fCurrentBuffer);
+GrRingBuffer::SubmitData GrRingBuffer::startSubmit() {
+ SubmitData submitData;
+ SkAutoSpinlock lock(fMutex);
+ submitData.fBuffer = fBuffer;
+ submitData.fLastHead = fHead;
+ submitData.fGenID = fGenID;
+ return submitData;
}
// used when current command buffer/command list is completed
void GrRingBuffer::finishSubmit(const GrRingBuffer::SubmitData& submitData) {
+ SkAutoSpinlock lock(fMutex);
if (submitData.fGenID == fGenID) {
fTail = submitData.fLastHead;
}