Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 34f9837

Browse files
author
Jonah Williams
authored
[Impeller] re-enable buffer to texture blit Vulkan. (#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.
1 parent cd30a48 commit 34f9837

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

impeller/core/device_buffer.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ std::shared_ptr<Texture> DeviceBuffer::AsTexture(
3939
return texture;
4040
}
4141

42+
void DeviceBuffer::Flush() {}
43+
4244
const DeviceBufferDescriptor& DeviceBuffer::GetDeviceBufferDescriptor() const {
4345
return desc_;
4446
}

impeller/core/device_buffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class DeviceBuffer : public Buffer,
3232

3333
BufferView AsBufferView() const;
3434

35+
virtual void Flush();
36+
3537
virtual std::shared_ptr<Texture> AsTexture(
3638
Allocator& allocator,
3739
const TextureDescriptor& descriptor,

impeller/renderer/backend/vulkan/capabilities_vk.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ bool CapabilitiesVK::SupportsSSBO() const {
327327

328328
// |Capabilities|
329329
bool CapabilitiesVK::SupportsBufferToTextureBlits() const {
330-
return false;
330+
return true;
331331
}
332332

333333
// |Capabilities|

impeller/renderer/backend/vulkan/device_buffer_vk.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ bool DeviceBufferVK::OnCopyHostBuffer(const uint8_t* source,
5353
return true;
5454
}
5555

56+
void DeviceBufferVK::Flush() {
57+
::vmaFlushAllocation(allocator_, allocation_, 0, VK_WHOLE_SIZE);
58+
}
59+
5660
bool DeviceBufferVK::SetLabel(const std::string& label) {
5761
auto context = context_.lock();
5862
if (!context || !buffer_) {

impeller/renderer/backend/vulkan/device_buffer_vk.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class DeviceBufferVK final : public DeviceBuffer,
2828

2929
vk::Buffer GetBuffer() const;
3030

31+
// If the contents of this buffer have been written to with
32+
// `OnGetContents`, then calling flush may be necessary if the memory is
33+
// non-coherent.
34+
void Flush() override;
35+
3136
private:
3237
friend class AllocatorVK;
3338

lib/ui/painting/image_decoder_impeller.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ ImpellerAllocator::ImpellerAllocator(
510510

511511
std::optional<std::shared_ptr<impeller::DeviceBuffer>>
512512
ImpellerAllocator::GetDeviceBuffer() const {
513+
if (buffer_.has_value()) {
514+
buffer_.value()->Flush();
515+
}
513516
return buffer_;
514517
}
515518

0 commit comments

Comments
 (0)