Some fixes for Flutter memory issues.
Now that we're using GrBuffers for uploads, we need to match the size of the upload buffer a little better to avoid wasting memory, so this switches to a using either a power-of-two size, or the midpoint between two powers-of-two. Also, the mechanism of adding the staging buffers to the current command buffer was not being invoked when calling submit for a cross- context texture. Switching to submitToGpu() should handle this. Change-Id: I8e0e5ae7e4dd00b5969d5e5554e3a2bff5758e81 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310339 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
e0da379fb7
commit
939cc7a630
@ -464,9 +464,13 @@ sk_sp<GrGpuBuffer> GrResourceProvider::createBuffer(size_t size, GrGpuBufferType
|
||||
if (kDynamic_GrAccessPattern != accessPattern) {
|
||||
return this->gpu()->createBuffer(size, intendedType, accessPattern, data);
|
||||
}
|
||||
// bin by pow2 with a reasonable min
|
||||
// bin by pow2+midpoint with a reasonable min
|
||||
static const size_t MIN_SIZE = 1 << 12;
|
||||
size_t allocSize = std::max(MIN_SIZE, GrNextSizePow2(size));
|
||||
size_t allocSize = std::max(size, MIN_SIZE);
|
||||
size_t ceilPow2 = GrNextSizePow2(allocSize);
|
||||
size_t floorPow2 = ceilPow2 >> 1;
|
||||
size_t mid = floorPow2 + (floorPow2 >> 1);
|
||||
allocSize = (allocSize <= mid) ? mid : ceilPow2;
|
||||
|
||||
GrScratchKey key;
|
||||
GrGpuBuffer::ComputeScratchKeyForDynamicVBO(allocSize, intendedType, &key);
|
||||
|
@ -278,7 +278,7 @@ bool GrMtlGpu::onSubmitToGpu(bool syncCpu) {
|
||||
}
|
||||
|
||||
std::unique_ptr<GrSemaphore> GrMtlGpu::prepareTextureForCrossContextUsage(GrTexture*) {
|
||||
submitCommandBuffer(SyncQueue::kSkip_SyncQueue);
|
||||
this->submitToGpu(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2647,7 +2647,7 @@ std::unique_ptr<GrSemaphore> GrVkGpu::prepareTextureForCrossContextUsage(GrTextu
|
||||
// TODO: should we have a way to notify the caller that this has failed? Currently if the submit
|
||||
// fails (caused by DEVICE_LOST) this will just cause us to fail the next use of the gpu.
|
||||
// Eventually we will abandon the whole GPU if this fails.
|
||||
this->submitCommandBuffer(kSkip_SyncQueue);
|
||||
this->submitToGpu(false);
|
||||
|
||||
// The image layout change serves as a barrier, so no semaphore is needed.
|
||||
// If we ever decide we need to return a semaphore here, we need to make sure GrVkSemaphore is
|
||||
|
Loading…
Reference in New Issue
Block a user