[Impeller] re-enable buffer to texture blit Vulkan. (flutter/engine#43129)

I was missing the VMA flush.

Because skia is writing directly to the exposed ptr, we don't go through the OnSetContents which makes a flush call. Add a flush API and implement it for Vk DeviceBuffers.
This commit is contained in:
Jonah Williams
2023-06-23 09:27:51 -07:00
committed by GitHub
parent 85e29db9d4
commit 07e900baf6
6 changed files with 17 additions and 1 deletions

View File

@@ -39,6 +39,8 @@ std::shared_ptr<Texture> DeviceBuffer::AsTexture(
return texture;
}
void DeviceBuffer::Flush() {}
const DeviceBufferDescriptor& DeviceBuffer::GetDeviceBufferDescriptor() const {
return desc_;
}

View File

@@ -32,6 +32,8 @@ class DeviceBuffer : public Buffer,
BufferView AsBufferView() const;
virtual void Flush();
virtual std::shared_ptr<Texture> AsTexture(
Allocator& allocator,
const TextureDescriptor& descriptor,

View File

@@ -327,7 +327,7 @@ bool CapabilitiesVK::SupportsSSBO() const {
// |Capabilities|
bool CapabilitiesVK::SupportsBufferToTextureBlits() const {
return false;
return true;
}
// |Capabilities|

View File

@@ -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_) {

View File

@@ -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;

View File

@@ -510,6 +510,9 @@ ImpellerAllocator::ImpellerAllocator(
std::optional<std::shared_ptr<impeller::DeviceBuffer>>
ImpellerAllocator::GetDeviceBuffer() const {
if (buffer_.has_value()) {
buffer_.value()->Flush();
}
return buffer_;
}