Change GrRingBuffer::finishSubmit to be a finishedProc
Change-Id: I307669ee928152ea3616f3814716da7476a03c46 Bug: skia:10530 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305716 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
a40e7b77fb
commit
1aaf41b7a7
@ -382,9 +382,11 @@ public:
|
||||
virtual void insertSemaphore(GrSemaphore* semaphore) = 0;
|
||||
virtual void waitSemaphore(GrSemaphore* semaphore) = 0;
|
||||
|
||||
virtual void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) = 0;
|
||||
virtual void checkFinishProcs() = 0;
|
||||
|
||||
virtual void takeOwnershipOfStagingBuffer(sk_sp<GrGpuBuffer>) {}
|
||||
virtual void takeOwnershipOfBuffer(sk_sp<GrGpuBuffer>) {}
|
||||
|
||||
/**
|
||||
* Checks if we detected an OOM from the underlying 3D API and if so returns true and resets
|
||||
@ -820,9 +822,6 @@ private:
|
||||
virtual bool onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
|
||||
const SkIPoint& dstPoint) = 0;
|
||||
|
||||
virtual void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) = 0;
|
||||
|
||||
virtual void prepareSurfacesForBackendAccessAndStateUpdates(
|
||||
GrSurfaceProxy* proxies[],
|
||||
int numProxies,
|
||||
|
@ -79,17 +79,27 @@ GrRingBuffer::Slice GrRingBuffer::suballocate(size_t size) {
|
||||
}
|
||||
|
||||
// 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;
|
||||
void GrRingBuffer::startSubmit(GrGpu* gpu) {
|
||||
for (unsigned int i = 0; i < fTrackedBuffers.size(); ++i) {
|
||||
gpu->takeOwnershipOfBuffer(std::move(fTrackedBuffers[i]));
|
||||
}
|
||||
fTrackedBuffers.clear();
|
||||
// add current buffer to be tracked for next submit
|
||||
fTrackedBuffers.push_back(fCurrentBuffer);
|
||||
|
||||
SubmitData* submitData = new SubmitData();
|
||||
submitData->fOwner = this;
|
||||
submitData->fLastHead = fHead;
|
||||
submitData->fGenID = fGenID;
|
||||
gpu->addFinishedProc(FinishSubmit, submitData);
|
||||
}
|
||||
|
||||
// used when current command buffer/command list is completed
|
||||
void GrRingBuffer::finishSubmit(const GrRingBuffer::SubmitData& submitData) {
|
||||
if (submitData.fGenID == fGenID) {
|
||||
fTail = submitData.fLastHead;
|
||||
void GrRingBuffer::FinishSubmit(void* finishedContext) {
|
||||
GrRingBuffer::SubmitData* submitData = (GrRingBuffer::SubmitData*)finishedContext;
|
||||
if (submitData && submitData->fOwner && submitData->fGenID == submitData->fOwner->fGenID) {
|
||||
submitData->fOwner->fTail = submitData->fLastHead;
|
||||
submitData->fOwner = nullptr;
|
||||
}
|
||||
delete submitData;
|
||||
}
|
||||
|
@ -41,24 +41,19 @@ public:
|
||||
};
|
||||
Slice suballocate(size_t size);
|
||||
|
||||
class SubmitData {
|
||||
public:
|
||||
const GrRingBuffer* fRingBuffer;
|
||||
std::vector<sk_sp<GrGpuBuffer>> fTrackedBuffers;
|
||||
private:
|
||||
friend class GrRingBuffer;
|
||||
size_t fLastHead;
|
||||
size_t fGenID;
|
||||
};
|
||||
// Backends should call startSubmit() at submit time, and finishSubmit() when the
|
||||
// command buffer/list finishes.
|
||||
void startSubmit(SubmitData*);
|
||||
void finishSubmit(const SubmitData&);
|
||||
// Backends should call startSubmit() at submit time
|
||||
void startSubmit(GrGpu*);
|
||||
|
||||
size_t size() const { return fTotalSize; }
|
||||
|
||||
private:
|
||||
size_t getAllocationOffset(size_t size);
|
||||
struct SubmitData {
|
||||
GrRingBuffer* fOwner;
|
||||
size_t fLastHead;
|
||||
size_t fGenID;
|
||||
};
|
||||
static void FinishSubmit(void*);
|
||||
|
||||
GrGpu* fGpu;
|
||||
sk_sp<GrGpuBuffer> fCurrentBuffer;
|
||||
|
@ -54,7 +54,7 @@ GrStagingBufferManager::Slice GrStagingBufferManager::allocateStagingBufferSlice
|
||||
void GrStagingBufferManager::detachBuffers() {
|
||||
for (size_t i = 0; i < fBuffers.size(); ++i) {
|
||||
fBuffers[i].fBuffer->unmap();
|
||||
fGpu->takeOwnershipOfStagingBuffer(std::move(fBuffers[i].fBuffer));
|
||||
fGpu->takeOwnershipOfBuffer(std::move(fBuffers[i].fBuffer));
|
||||
}
|
||||
fBuffers.clear();
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ public:
|
||||
Slice allocateStagingBufferSlice(size_t size, size_t requiredAlignment = 1);
|
||||
|
||||
// This call is used to move all the buffers off of the manager and to backend gpu by calling
|
||||
// the virtual GrGpu::takeOwnershipOfStagingBuffer on each buffer. This is called during
|
||||
// the virtual GrGpu::takeOwnershipOfBuffer on each buffer. This is called during
|
||||
// submitToGpu. It is up to the backend to take refs to the buffers in their implemented
|
||||
// takeOwnershipOfStagingBuffer implementation if they need to. After this call returns the
|
||||
// takeOwnershipOfBuffer implementation if they need to. After this call returns the
|
||||
// manager will have released all refs to its buffers.
|
||||
void detachBuffers();
|
||||
|
||||
|
@ -223,7 +223,6 @@ GrD3DDirectCommandList::GrD3DDirectCommandList(gr_cp<ID3D12CommandAllocator> all
|
||||
, fCurrentInstanceBuffer(nullptr)
|
||||
, fCurrentInstanceStride(0)
|
||||
, fCurrentIndexBuffer(nullptr)
|
||||
, fCurrentConstantRingBuffer(nullptr)
|
||||
, fCurrentConstantBufferAddress(0)
|
||||
, fCurrentSRVCRVDescriptorHeap(nullptr)
|
||||
, fCurrentSamplerDescriptorHeap(nullptr) {
|
||||
@ -238,10 +237,6 @@ void GrD3DDirectCommandList::onReset() {
|
||||
fCurrentInstanceBuffer = nullptr;
|
||||
fCurrentInstanceStride = 0;
|
||||
fCurrentIndexBuffer = nullptr;
|
||||
if (fCurrentConstantRingBuffer) {
|
||||
fCurrentConstantRingBuffer->finishSubmit(fConstantRingBufferSubmitData);
|
||||
fCurrentConstantRingBuffer = nullptr;
|
||||
}
|
||||
fCurrentConstantBufferAddress = 0;
|
||||
sk_bzero(fCurrentRootDescriptorTable, sizeof(fCurrentRootDescriptorTable));
|
||||
fCurrentSRVCRVDescriptorHeap = nullptr;
|
||||
@ -257,18 +252,6 @@ void GrD3DDirectCommandList::setPipelineState(sk_sp<GrD3DPipelineState> pipeline
|
||||
}
|
||||
}
|
||||
|
||||
void GrD3DDirectCommandList::setCurrentConstantBuffer(GrRingBuffer* constantsRingBuffer) {
|
||||
fCurrentConstantRingBuffer = constantsRingBuffer;
|
||||
if (fCurrentConstantRingBuffer) {
|
||||
constantsRingBuffer->startSubmit(&fConstantRingBufferSubmitData);
|
||||
for (unsigned int i = 0; i < fConstantRingBufferSubmitData.fTrackedBuffers.size(); ++i) {
|
||||
this->addGrBuffer(std::move(fConstantRingBufferSubmitData.fTrackedBuffers[i]));
|
||||
}
|
||||
// we don't need these any more so clear this copy out
|
||||
fConstantRingBufferSubmitData.fTrackedBuffers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void GrD3DDirectCommandList::setStencilRef(unsigned int stencilRef) {
|
||||
SkASSERT(fIsActive);
|
||||
fCommandList->OMSetStencilRef(stencilRef);
|
||||
|
@ -152,8 +152,6 @@ public:
|
||||
|
||||
void setPipelineState(sk_sp<GrD3DPipelineState> pipelineState);
|
||||
|
||||
void setCurrentConstantBuffer(GrRingBuffer* constantsRingBuffer);
|
||||
|
||||
void setStencilRef(unsigned int stencilRef);
|
||||
void setBlendFactor(const float blendFactor[4]);
|
||||
void setPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY primitiveTopology);
|
||||
@ -207,9 +205,6 @@ private:
|
||||
size_t fCurrentInstanceStride;
|
||||
const GrBuffer* fCurrentIndexBuffer;
|
||||
|
||||
GrRingBuffer* fCurrentConstantRingBuffer;
|
||||
GrRingBuffer::SubmitData fConstantRingBufferSubmitData;
|
||||
|
||||
D3D12_GPU_VIRTUAL_ADDRESS fCurrentConstantBufferAddress;
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE fCurrentRootDescriptorTable[GrD3DRootSignature::kParamIndexCount];
|
||||
const ID3D12DescriptorHeap* fCurrentSRVCRVDescriptorHeap;
|
||||
|
@ -121,7 +121,7 @@ bool GrD3DGpu::submitDirectCommandList(SyncQueue sync) {
|
||||
SkASSERT(fCurrentDirectCommandList);
|
||||
|
||||
// set up constant data
|
||||
fCurrentDirectCommandList->setCurrentConstantBuffer(&fConstantsRingBuffer);
|
||||
fConstantsRingBuffer.startSubmit(this);
|
||||
|
||||
fResourceProvider.prepForSubmit();
|
||||
|
||||
@ -1290,7 +1290,7 @@ void GrD3DGpu::prepareSurfacesForBackendAccessAndStateUpdates(
|
||||
}
|
||||
}
|
||||
|
||||
void GrD3DGpu::takeOwnershipOfStagingBuffer(sk_sp<GrGpuBuffer> buffer) {
|
||||
void GrD3DGpu::takeOwnershipOfBuffer(sk_sp<GrGpuBuffer> buffer) {
|
||||
fCurrentDirectCommandList->addGrBuffer(std::move(buffer));
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
GrD3DDirectCommandList* currentCommandList() const { return fCurrentDirectCommandList.get(); }
|
||||
|
||||
GrStagingBufferManager* stagingBufferManager() override { return &fStagingBufferManager; }
|
||||
void takeOwnershipOfStagingBuffer(sk_sp<GrGpuBuffer>) override;
|
||||
void takeOwnershipOfBuffer(sk_sp<GrGpuBuffer>) override;
|
||||
|
||||
// TODO: hoist up to GrGpu
|
||||
GrRingBuffer* constantsRingBuffer() { return &fConstantsRingBuffer; }
|
||||
|
@ -497,7 +497,7 @@ void GrDawnGpu::waitOnAllBusyStagingBuffers() {
|
||||
}
|
||||
}
|
||||
|
||||
void GrDawnGpu::takeOwnershipOfStagingBuffer(sk_sp<GrGpuBuffer> buffer) {
|
||||
void GrDawnGpu::takeOwnershipOfBuffer(sk_sp<GrGpuBuffer> buffer) {
|
||||
fSubmittedStagingBuffers.push_back(std::move(buffer));
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
void disconnect(DisconnectType) override;
|
||||
|
||||
GrStagingBufferManager* stagingBufferManager() override { return &fStagingBufferManager; }
|
||||
void takeOwnershipOfStagingBuffer(sk_sp<GrGpuBuffer>) override;
|
||||
void takeOwnershipOfBuffer(sk_sp<GrGpuBuffer>) override;
|
||||
|
||||
const wgpu::Device& device() const { return fDevice; }
|
||||
const wgpu::Queue& queue() const { return fQueue; }
|
||||
|
@ -2042,7 +2042,7 @@ void GrVkGpu::addFinishedCallback(sk_sp<GrRefCntedCallback> finishedCallback) {
|
||||
fResourceProvider.addFinishedProcToActiveCommandBuffers(std::move(finishedCallback));
|
||||
}
|
||||
|
||||
void GrVkGpu::takeOwnershipOfStagingBuffer(sk_sp<GrGpuBuffer> buffer) {
|
||||
void GrVkGpu::takeOwnershipOfBuffer(sk_sp<GrGpuBuffer> buffer) {
|
||||
this->currentCommandBuffer()->addGrBuffer(std::move(buffer));
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
const GrVkCaps& vkCaps() const { return *fVkCaps; }
|
||||
|
||||
GrStagingBufferManager* stagingBufferManager() override { return &fStagingBufferManager; }
|
||||
void takeOwnershipOfStagingBuffer(sk_sp<GrGpuBuffer>) override;
|
||||
void takeOwnershipOfBuffer(sk_sp<GrGpuBuffer>) override;
|
||||
|
||||
bool isDeviceLost() const override { return fDeviceIsLost; }
|
||||
void setDeviceLost() { fDeviceIsLost = true; }
|
||||
|
Loading…
Reference in New Issue
Block a user