aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrBufferAllocPool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrBufferAllocPool.cpp')
-rw-r--r--src/gpu/GrBufferAllocPool.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index ec8a9c9545..db9b2c8d76 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -296,9 +296,21 @@ bool GrBufferAllocPool::createBlock(size_t requestSize) {
GrAssert(NULL == fBufferPtr);
- if (fGpu->getCaps().bufferLockSupport() &&
- size > GR_GEOM_BUFFER_LOCK_THRESHOLD &&
- (!fFrequentResetHint || requestSize > GR_GEOM_BUFFER_LOCK_THRESHOLD)) {
+ // If the buffer is CPU-backed we lock it because it is free to do so and saves a copy.
+ // Otherwise when buffer locking is supported:
+ // a) If the frequently reset hint is set we only lock when the requested size meets a
+ // threshold (since we don't expect it is likely that we will see more vertex data)
+ // b) If the hint is not set we lock if the buffer size is greater than the threshold.
+ bool attemptLock = block.fBuffer->isCPUBacked();
+ if (!attemptLock && fGpu->getCaps().bufferLockSupport()) {
+ if (fFrequentResetHint) {
+ attemptLock = requestSize > GR_GEOM_BUFFER_LOCK_THRESHOLD;
+ } else {
+ attemptLock = size > GR_GEOM_BUFFER_LOCK_THRESHOLD;
+ }
+ }
+
+ if (attemptLock) {
fBufferPtr = block.fBuffer->lock();
}