summaryrefslogtreecommitdiff
path: root/chromium/gpu/vulkan/init
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/gpu/vulkan/init')
-rw-r--r--chromium/gpu/vulkan/init/gr_vk_memory_allocator_impl.cc54
1 files changed, 24 insertions, 30 deletions
diff --git a/chromium/gpu/vulkan/init/gr_vk_memory_allocator_impl.cc b/chromium/gpu/vulkan/init/gr_vk_memory_allocator_impl.cc
index 4192cd859ce..0a900d01805 100644
--- a/chromium/gpu/vulkan/init/gr_vk_memory_allocator_impl.cc
+++ b/chromium/gpu/vulkan/init/gr_vk_memory_allocator_impl.cc
@@ -24,9 +24,9 @@ class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator {
GrVkMemoryAllocatorImpl& operator=(const GrVkMemoryAllocatorImpl&) = delete;
private:
- bool allocateMemoryForImage(VkImage image,
- AllocationPropertyFlags flags,
- GrVkBackendMemory* backend_memory) override {
+ VkResult allocateImageMemory(VkImage image,
+ AllocationPropertyFlags flags,
+ GrVkBackendMemory* backend_memory) override {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("gpu.vulkan.vma"),
"GrVkMemoryAllocatorImpl::allocateMemoryForImage");
VmaAllocationCreateInfo info;
@@ -53,17 +53,15 @@ class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator {
VmaAllocation allocation;
VkResult result = vma::AllocateMemoryForImage(allocator_, image, &info,
&allocation, nullptr);
- if (VK_SUCCESS != result) {
- return false;
- }
- *backend_memory = reinterpret_cast<GrVkBackendMemory>(allocation);
- return true;
+ if (VK_SUCCESS == result)
+ *backend_memory = reinterpret_cast<GrVkBackendMemory>(allocation);
+ return result;
}
- bool allocateMemoryForBuffer(VkBuffer buffer,
- BufferUsage usage,
- AllocationPropertyFlags flags,
- GrVkBackendMemory* backend_memory) override {
+ VkResult allocateBufferMemory(VkBuffer buffer,
+ BufferUsage usage,
+ AllocationPropertyFlags flags,
+ GrVkBackendMemory* backend_memory) override {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("gpu.vulkan.vma"),
"GrVkMemoryAllocatorImpl::allocateMemoryForBuffer");
VmaAllocationCreateInfo info;
@@ -121,12 +119,11 @@ class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator {
&allocation, nullptr);
}
}
- if (VK_SUCCESS != result) {
- return false;
- }
- *backend_memory = reinterpret_cast<GrVkBackendMemory>(allocation);
- return true;
+ if (VK_SUCCESS == result)
+ *backend_memory = reinterpret_cast<GrVkBackendMemory>(allocation);
+
+ return result;
}
void freeMemory(const GrVkBackendMemory& memory) override {
@@ -162,15 +159,12 @@ class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator {
alloc->fBackendMemory = memory;
}
- void* mapMemory(const GrVkBackendMemory& memory) override {
+ VkResult mapMemory(const GrVkBackendMemory& memory, void** data) override {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("gpu.vulkan.vma"),
"GrVkMemoryAllocatorImpl::mapMemory");
const VmaAllocation allocation =
reinterpret_cast<const VmaAllocation>(memory);
- void* data;
- return vma::MapMemory(allocator_, allocation, &data) == VK_SUCCESS
- ? data
- : nullptr;
+ return vma::MapMemory(allocator_, allocation, data);
}
void unmapMemory(const GrVkBackendMemory& memory) override {
@@ -181,24 +175,24 @@ class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator {
vma::UnmapMemory(allocator_, allocation);
}
- void flushMappedMemory(const GrVkBackendMemory& memory,
- VkDeviceSize offset,
- VkDeviceSize size) override {
+ VkResult flushMemory(const GrVkBackendMemory& memory,
+ VkDeviceSize offset,
+ VkDeviceSize size) override {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("gpu.vulkan.vma"),
"GrVkMemoryAllocatorImpl::flushMappedMemory");
const VmaAllocation allocation =
reinterpret_cast<const VmaAllocation>(memory);
- vma::FlushAllocation(allocator_, allocation, offset, size);
+ return vma::FlushAllocation(allocator_, allocation, offset, size);
}
- void invalidateMappedMemory(const GrVkBackendMemory& memory,
- VkDeviceSize offset,
- VkDeviceSize size) override {
+ VkResult invalidateMemory(const GrVkBackendMemory& memory,
+ VkDeviceSize offset,
+ VkDeviceSize size) override {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("gpu.vulkan.vma"),
"GrVkMemoryAllocatorImpl::invalidateMappedMemory");
const VmaAllocation allocation =
reinterpret_cast<const VmaAllocation>(memory);
- vma::InvalidateAllocation(allocator_, allocation, offset, size);
+ return vma::InvalidateAllocation(allocator_, allocation, offset, size);
}
uint64_t totalUsedMemory() const override {