Commit 627a9bf4 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Add a CpuWritesGpuReadsCached finch flag

In this CL, we want to relax the requirement for CACHED memory as part
of a finch experiment. On Mali GPU, we have roughly 3 types:

    a) HOST | COHERENT| DEVICE (coherent is not cached)
    b) HOST | CACHED | DEVICE  (cached is non-coherent)
    c) DEVICE

By relaxing the CACHED condition, the driver is free to give
us (a) or (b) based on what it thinks is more performant.
This is roughtly equivalent to
https://skia-review.googlesource.com/c/skia/+/312056

Change-Id: Ib8a76b1870b6284ba1cb83128f5349e96f56fc9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2376447Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Jonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801624}
parent ceb19533
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <vk_mem_alloc.h> #include <vk_mem_alloc.h>
#include "base/feature_list.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "gpu/vulkan/vma_wrapper.h" #include "gpu/vulkan/vma_wrapper.h"
#include "gpu/vulkan/vulkan_device_queue.h" #include "gpu/vulkan/vulkan_device_queue.h"
...@@ -14,6 +15,9 @@ namespace gpu { ...@@ -14,6 +15,9 @@ namespace gpu {
namespace { namespace {
const base::Feature kCpuWritesGpuReadsCached{"CpuWritesGpuReadsCached",
base::FEATURE_ENABLED_BY_DEFAULT};
class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator { class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator {
public: public:
explicit GrVkMemoryAllocatorImpl(VmaAllocator allocator) explicit GrVkMemoryAllocatorImpl(VmaAllocator allocator)
...@@ -82,9 +86,10 @@ class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator { ...@@ -82,9 +86,10 @@ class GrVkMemoryAllocatorImpl : public GrVkMemoryAllocator {
info.preferredFlags = VK_MEMORY_PROPERTY_HOST_CACHED_BIT; info.preferredFlags = VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
break; break;
case BufferUsage::kCpuWritesGpuReads: case BufferUsage::kCpuWritesGpuReads:
// First attempt to try memory is also cached info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | if (base::FeatureList::IsEnabled(kCpuWritesGpuReadsCached))
VK_MEMORY_PROPERTY_HOST_CACHED_BIT; info.requiredFlags |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
info.preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; info.preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
break; break;
case BufferUsage::kGpuWritesCpuReads: case BufferUsage::kGpuWritesCpuReads:
...@@ -217,4 +222,4 @@ sk_sp<GrVkMemoryAllocator> CreateGrVkMemoryAllocator( ...@@ -217,4 +222,4 @@ sk_sp<GrVkMemoryAllocator> CreateGrVkMemoryAllocator(
return sk_make_sp<GrVkMemoryAllocatorImpl>(device_queue->vma_allocator()); return sk_make_sp<GrVkMemoryAllocatorImpl>(device_queue->vma_allocator());
} }
} // namespace gpu } // namespace gpu
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment