Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add invalidate
  • Loading branch information
jonahwilliams committed Feb 24, 2024
commit 3fda4d401267187b23a99542e109614369ec7377
2 changes: 2 additions & 0 deletions impeller/core/device_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ DeviceBuffer::~DeviceBuffer() = default;

void DeviceBuffer::Flush(std::optional<Range> range) const {}

void DeviceBuffer::Invalidate(std::optional<Range> range) const {}

// static
BufferView DeviceBuffer::AsBufferView(std::shared_ptr<DeviceBuffer> buffer) {
BufferView view;
Expand Down
2 changes: 2 additions & 0 deletions impeller/core/device_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class DeviceBuffer {
/// If the range is not provided, the entire buffer is flushed.
virtual void Flush(std::optional<Range> range = std::nullopt) const;

virtual void Invalidate(std::optional<Range> range = std::nullopt) const;

protected:
const DeviceBufferDescriptor desc_;

Expand Down
8 changes: 8 additions & 0 deletions impeller/renderer/backend/vulkan/device_buffer_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "impeller/renderer/backend/vulkan/device_buffer_vk.h"

#include "flutter/fml/trace_event.h"
#include "flutter_vma/flutter_vma.h"
#include "impeller/renderer/backend/vulkan/context_vk.h"
#include "vulkan/vulkan_core.h"

Expand Down Expand Up @@ -70,6 +71,13 @@ void DeviceBufferVK::Flush(std::optional<Range> range) const {
flush_range.length);
}

void DeviceBufferVK::Invalidate(std::optional<Range> range) const {
auto flush_range = range.value_or(Range{0, GetDeviceBufferDescriptor().size});
::vmaInvalidateAllocation(resource_->buffer.get().allocator,
resource_->buffer.get().allocation,
flush_range.offset, flush_range.length);
}

bool DeviceBufferVK::SetLabel(const std::string& label, Range range) {
// We do not have the ability to name ranges. Just name the whole thing.
return SetLabel(label);
Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/backend/vulkan/device_buffer_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class DeviceBufferVK final : public DeviceBuffer,
// |DeviceBuffer|
void Flush(std::optional<Range> range) const override;

// |DeviceBuffer|
void Invalidate(std::optional<Range> range) const override;

DeviceBufferVK(const DeviceBufferVK&) = delete;

DeviceBufferVK& operator=(const DeviceBufferVK&) = delete;
Expand Down
1 change: 1 addition & 0 deletions lib/ui/painting/image_encoding_impeller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ void ImageEncodingImpeller::ConvertDlImageToSkImage(
encode_task(fml::Status(fml::StatusCode::kUnknown, ""));
return;
}
buffer->Invalidate();
auto sk_image = ConvertBufferToSkImage(buffer, color_type, dimensions);
encode_task(sk_image);
};
Expand Down