diff --git a/impeller/core/device_buffer.cc b/impeller/core/device_buffer.cc index 741a4d7ee2386..0498ee3e894bc 100644 --- a/impeller/core/device_buffer.cc +++ b/impeller/core/device_buffer.cc @@ -39,6 +39,8 @@ std::shared_ptr DeviceBuffer::AsTexture( return texture; } +void DeviceBuffer::Flush() {} + const DeviceBufferDescriptor& DeviceBuffer::GetDeviceBufferDescriptor() const { return desc_; } diff --git a/impeller/core/device_buffer.h b/impeller/core/device_buffer.h index 507a4157d53be..739d46ca224a8 100644 --- a/impeller/core/device_buffer.h +++ b/impeller/core/device_buffer.h @@ -32,6 +32,8 @@ class DeviceBuffer : public Buffer, BufferView AsBufferView() const; + virtual void Flush(); + virtual std::shared_ptr AsTexture( Allocator& allocator, const TextureDescriptor& descriptor, diff --git a/impeller/renderer/backend/vulkan/capabilities_vk.cc b/impeller/renderer/backend/vulkan/capabilities_vk.cc index ddbbdb9160fd2..c9cb8722cb652 100644 --- a/impeller/renderer/backend/vulkan/capabilities_vk.cc +++ b/impeller/renderer/backend/vulkan/capabilities_vk.cc @@ -327,7 +327,7 @@ bool CapabilitiesVK::SupportsSSBO() const { // |Capabilities| bool CapabilitiesVK::SupportsBufferToTextureBlits() const { - return false; + return true; } // |Capabilities| diff --git a/impeller/renderer/backend/vulkan/device_buffer_vk.cc b/impeller/renderer/backend/vulkan/device_buffer_vk.cc index cb84dcd5eff38..e88a2cbc13868 100644 --- a/impeller/renderer/backend/vulkan/device_buffer_vk.cc +++ b/impeller/renderer/backend/vulkan/device_buffer_vk.cc @@ -53,6 +53,10 @@ bool DeviceBufferVK::OnCopyHostBuffer(const uint8_t* source, return true; } +void DeviceBufferVK::Flush() { + ::vmaFlushAllocation(allocator_, allocation_, 0, VK_WHOLE_SIZE); +} + bool DeviceBufferVK::SetLabel(const std::string& label) { auto context = context_.lock(); if (!context || !buffer_) { diff --git a/impeller/renderer/backend/vulkan/device_buffer_vk.h b/impeller/renderer/backend/vulkan/device_buffer_vk.h index 229a1b6b04325..25d910beff98f 100644 --- a/impeller/renderer/backend/vulkan/device_buffer_vk.h +++ b/impeller/renderer/backend/vulkan/device_buffer_vk.h @@ -28,6 +28,11 @@ class DeviceBufferVK final : public DeviceBuffer, vk::Buffer GetBuffer() const; + // If the contents of this buffer have been written to with + // `OnGetContents`, then calling flush may be necessary if the memory is + // non-coherent. + void Flush() override; + private: friend class AllocatorVK; diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc index ecb455c1bdaa0..c0776b0caa35e 100644 --- a/lib/ui/painting/image_decoder_impeller.cc +++ b/lib/ui/painting/image_decoder_impeller.cc @@ -510,6 +510,9 @@ ImpellerAllocator::ImpellerAllocator( std::optional> ImpellerAllocator::GetDeviceBuffer() const { + if (buffer_.has_value()) { + buffer_.value()->Flush(); + } return buffer_; }