From 7e829b2c287d511bda2f52e73308a0ca21e87c27 Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Thu, 30 Jul 2020 17:04:35 -0400 Subject: [PATCH] Hoist up uniform GrRingBuffer to GrGpu Change-Id: Ib829c883c260ef8ff4a3f5326922d66476b7306f Bug: skia:10530 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306949 Reviewed-by: Brian Osman Commit-Queue: Jim Van Verth --- src/gpu/GrGpu.cpp | 5 +++++ src/gpu/GrGpu.h | 3 +++ src/gpu/d3d/GrD3DGpu.cpp | 3 --- src/gpu/d3d/GrD3DGpu.h | 3 +-- src/gpu/d3d/GrD3DResourceProvider.cpp | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 2bd5ce83bd..2aff1a02b5 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -26,6 +26,7 @@ #include "src/gpu/GrRenderTarget.h" #include "src/gpu/GrResourceCache.h" #include "src/gpu/GrResourceProvider.h" +#include "src/gpu/GrRingBuffer.h" #include "src/gpu/GrSemaphore.h" #include "src/gpu/GrStagingBufferManager.h" #include "src/gpu/GrStencilAttachment.h" @@ -659,6 +660,10 @@ bool GrGpu::submitToGpu(bool syncCpu) { manager->detachBuffers(); } + if (auto uniformsBuffer = this->uniformsRingBuffer()) { + uniformsBuffer->startSubmit(this); + } + bool submitted = this->onSubmitToGpu(syncCpu); this->callSubmittedProcs(submitted); diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 6883d736a0..8cd9bd040a 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -33,6 +33,7 @@ class GrPathRendering; class GrPipeline; class GrPrimitiveProcessor; class GrRenderTarget; +class GrRingBuffer; class GrSemaphore; class GrStagingBufferManager; class GrStencilAttachment; @@ -59,6 +60,8 @@ public: virtual GrStagingBufferManager* stagingBufferManager() { return nullptr; } + virtual GrRingBuffer* uniformsRingBuffer() { return nullptr; } + enum class DisconnectType { // No cleanup should be attempted, immediately cease making backend API calls kAbandon, diff --git a/src/gpu/d3d/GrD3DGpu.cpp b/src/gpu/d3d/GrD3DGpu.cpp index 07b8a08060..1f91bf9a91 100644 --- a/src/gpu/d3d/GrD3DGpu.cpp +++ b/src/gpu/d3d/GrD3DGpu.cpp @@ -120,9 +120,6 @@ GrOpsRenderPass* GrD3DGpu::getOpsRenderPass( bool GrD3DGpu::submitDirectCommandList(SyncQueue sync) { SkASSERT(fCurrentDirectCommandList); - // set up constant data - fConstantsRingBuffer.startSubmit(this); - fResourceProvider.prepForSubmit(); GrD3DDirectCommandList::SubmitResult result = fCurrentDirectCommandList->submit(fQueue.get()); diff --git a/src/gpu/d3d/GrD3DGpu.h b/src/gpu/d3d/GrD3DGpu.h index 2b93b80c4c..d28912bb38 100644 --- a/src/gpu/d3d/GrD3DGpu.h +++ b/src/gpu/d3d/GrD3DGpu.h @@ -48,8 +48,7 @@ public: GrStagingBufferManager* stagingBufferManager() override { return &fStagingBufferManager; } void takeOwnershipOfBuffer(sk_sp) override; - // TODO: hoist up to GrGpu - GrRingBuffer* constantsRingBuffer() { return &fConstantsRingBuffer; } + GrRingBuffer* uniformsRingBuffer() override { return &fConstantsRingBuffer; } bool protectedContext() const { return false; } diff --git a/src/gpu/d3d/GrD3DResourceProvider.cpp b/src/gpu/d3d/GrD3DResourceProvider.cpp index ccaee3b4fb..14ff7bd8c9 100644 --- a/src/gpu/d3d/GrD3DResourceProvider.cpp +++ b/src/gpu/d3d/GrD3DResourceProvider.cpp @@ -199,7 +199,7 @@ D3D12_GPU_VIRTUAL_ADDRESS GrD3DResourceProvider::uploadConstantData(void* data, // upload the data size_t paddedSize = GrAlignTo(size, kConstantAlignment); - GrRingBuffer::Slice slice = fGpu->constantsRingBuffer()->suballocate(paddedSize); + GrRingBuffer::Slice slice = fGpu->uniformsRingBuffer()->suballocate(paddedSize); char* destPtr = static_cast(slice.fBuffer->map()) + slice.fOffset; memcpy(destPtr, data, size);