Make sure we are using cached cpu memory for vulkan readback buffers.
Bug: b/175913056 skia:11207 Change-Id: I7fff0e164844850a957ae9374bed13584fd18ae1 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357337 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
34c56a5c3d
commit
1089c0c59c
@ -38,6 +38,8 @@ public:
|
||||
// Buffers that will only be accessed from the device (large const buffers). Will always be
|
||||
// in device local memory.
|
||||
kGpuOnly,
|
||||
// DEPRECATED: Depending on the direction of transfer buffers they should use
|
||||
// kCpuWritesGpuReads or kGpuWritesCpuReads instead.
|
||||
// Buffers that will be accessed on the host and copied to and from a GPU resource (transfer
|
||||
// buffers). Will always be mappable and coherent memory.
|
||||
kCpuOnly,
|
||||
@ -46,7 +48,7 @@ public:
|
||||
// in device local memory.
|
||||
kCpuWritesGpuReads,
|
||||
// Buffers which are typically writted to by the GPU and then read on the host. Will always
|
||||
// be mappable memory, and will prefer coherent and cached memory.
|
||||
// be mappable memory, and will prefer cached memory.
|
||||
kGpuWritesCpuReads,
|
||||
};
|
||||
|
||||
|
@ -172,8 +172,7 @@ VkResult GrVkAMDMemoryAllocator::allocateBufferMemory(VkBuffer buffer, BufferUsa
|
||||
break;
|
||||
case BufferUsage::kGpuWritesCpuReads:
|
||||
info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
info.preferredFlags = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
|
||||
VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||
info.preferredFlags = VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -259,7 +258,7 @@ VkResult GrVkAMDMemoryAllocator::invalidateMemory(const GrVkBackendMemory& memor
|
||||
VkDeviceSize offset, VkDeviceSize size) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
const VmaAllocation allocation = (const VmaAllocation)memoryHandle;
|
||||
return vmaFlushAllocation(fAllocator, allocation, offset, size);
|
||||
return vmaInvalidateAllocation(fAllocator, allocation, offset, size);
|
||||
}
|
||||
|
||||
uint64_t GrVkAMDMemoryAllocator::totalUsedMemory() const {
|
||||
|
@ -21,12 +21,12 @@ static BufferUsage get_buffer_usage(GrVkBuffer::Type type, bool dynamic) {
|
||||
case GrVkBuffer::kIndirect_Type: // fall through
|
||||
case GrVkBuffer::kTexel_Type:
|
||||
return dynamic ? BufferUsage::kCpuWritesGpuReads : BufferUsage::kGpuOnly;
|
||||
case GrVkBuffer::kUniform_Type:
|
||||
case GrVkBuffer::kUniform_Type: // fall through
|
||||
case GrVkBuffer::kCopyRead_Type:
|
||||
SkASSERT(dynamic);
|
||||
return BufferUsage::kCpuWritesGpuReads;
|
||||
case GrVkBuffer::kCopyRead_Type: // fall through
|
||||
case GrVkBuffer::kCopyWrite_Type:
|
||||
return BufferUsage::kCpuOnly;
|
||||
return BufferUsage::kGpuWritesCpuReads;
|
||||
}
|
||||
SK_ABORT("Invalid GrVkBuffer::Type");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user