Reland "Add option for clients to set default gpu staging buffer size."
This is a reland of commit 8641e7b97ef27a969173481abe43904a70a3d166
Original change's description:
> Add option for clients to set default gpu staging buffer size.
>
> Bug: b/298029730
> Change-Id: I4e94341b56e706cb6368642887d38cfc6fb558c2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/752280
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
Bug: b/298029730
Change-Id: I04fe1fd2e66b27428a10f44563c431b318771c36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/755457
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index 230f6d7..e1da172 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -97,6 +97,12 @@
deduce the optimal value for this platform. */
int fBufferMapThreshold = -1;
+ /** Default minimum size to use when allocating buffers for uploading data to textures. The
+ larger the value the more uploads can be packed into one buffer, but at the cost of
+ more gpu memory allocated that may not be used. Uploads larger than the minimum will still
+ work by allocating a dedicated buffer. */
+ size_t fMinimumStagingBufferSize = 64 * 1024;
+
/**
* Executor to handle threaded work within Ganesh. If this is nullptr, then all work will be
* done serially on the main thread. To have worker threads assist with various tasks, set this
diff --git a/src/gpu/ganesh/GrStagingBufferManager.cpp b/src/gpu/ganesh/GrStagingBufferManager.cpp
index 3ed0fa0..7edcc97 100644
--- a/src/gpu/ganesh/GrStagingBufferManager.cpp
+++ b/src/gpu/ganesh/GrStagingBufferManager.cpp
@@ -28,7 +28,8 @@
if (!buffer) {
GrResourceProvider* resourceProvider = fGpu->getContext()->priv().resourceProvider();
- size_t bufferSize = std::max(size, kMinStagingBufferSize);
+ size_t minSize = fGpu->getContext()->priv().options().fMinimumStagingBufferSize;
+ size_t bufferSize = std::max(size, minSize);
sk_sp<GrGpuBuffer> newBuffer = resourceProvider->createBuffer(
bufferSize,
GrGpuBufferType::kXferCpuToGpu,
diff --git a/src/gpu/ganesh/GrStagingBufferManager.h b/src/gpu/ganesh/GrStagingBufferManager.h
index 315dbbc..658c14e 100644
--- a/src/gpu/ganesh/GrStagingBufferManager.h
+++ b/src/gpu/ganesh/GrStagingBufferManager.h
@@ -46,8 +46,6 @@
}
private:
- inline static constexpr size_t kMinStagingBufferSize = 64 * 1024;
-
struct StagingBuffer {
StagingBuffer(sk_sp<GrGpuBuffer> buffer, void* mapPtr)
: fBuffer(std::move(buffer))