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
Next Next commit
test readback
  • Loading branch information
jonahwilliams committed Feb 24, 2024
commit 98092cf7e7fc6775daaef0bd110af55817160810
3 changes: 3 additions & 0 deletions impeller/core/device_buffer_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace impeller {
struct DeviceBufferDescriptor {
StorageMode storage_mode = StorageMode::kDeviceTransient;
size_t size = 0u;
// Perhaps we could combine this with storage mode and create appropriate
// host-write and host-read flags.
bool readback = false;
};

} // namespace impeller
Expand Down
2 changes: 1 addition & 1 deletion impeller/entity/contents/content_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class ContentContext {
///
// TODO(bdero): Remove this setting once StC is fully de-risked
// https://github.com/flutter/flutter/issues/123671
static constexpr bool kEnableStencilThenCover = false;
static constexpr bool kEnableStencilThenCover = true;

#if IMPELLER_ENABLE_3D
std::shared_ptr<scene::SceneContext> GetSceneContext() const;
Expand Down
23 changes: 16 additions & 7 deletions impeller/renderer/backend/vulkan/allocator_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@ ToVKBufferMemoryPropertyFlags(StorageMode mode) {
}

static VmaAllocationCreateFlags ToVmaAllocationBufferCreateFlags(
StorageMode mode) {
StorageMode mode,
bool readback) {
VmaAllocationCreateFlags flags = 0;
switch (mode) {
case StorageMode::kHostVisible:
flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
if (!readback) {
flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
} else {
flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT;
}
return flags;
case StorageMode::kDevicePrivate:
FML_DCHECK(!readback);
return flags;
case StorageMode::kDeviceTransient:
FML_DCHECK(!readback);
return flags;
}
FML_UNREACHABLE();
Expand All @@ -62,8 +69,8 @@ static PoolVMA CreateBufferPool(VmaAllocator allocator) {
allocation_info.usage = VMA_MEMORY_USAGE_AUTO;
allocation_info.preferredFlags = static_cast<VkMemoryPropertyFlags>(
ToVKBufferMemoryPropertyFlags(StorageMode::kHostVisible));
allocation_info.flags =
ToVmaAllocationBufferCreateFlags(StorageMode::kHostVisible);
allocation_info.flags = ToVmaAllocationBufferCreateFlags(
StorageMode::kHostVisible, /*readback=*/false);

uint32_t memTypeIndex;
auto result = vk::Result{vmaFindMemoryTypeIndexForBufferInfo(
Expand Down Expand Up @@ -455,8 +462,10 @@ std::shared_ptr<DeviceBuffer> AllocatorVK::OnCreateBuffer(
allocation_info.usage = ToVMAMemoryUsage();
allocation_info.preferredFlags = static_cast<VkMemoryPropertyFlags>(
ToVKBufferMemoryPropertyFlags(desc.storage_mode));
allocation_info.flags = ToVmaAllocationBufferCreateFlags(desc.storage_mode);
if (created_buffer_pool_ && desc.storage_mode == StorageMode::kHostVisible) {
allocation_info.flags =
ToVmaAllocationBufferCreateFlags(desc.storage_mode, desc.readback);
if (created_buffer_pool_ && desc.storage_mode == StorageMode::kHostVisible &&
!desc.readback) {
allocation_info.pool = staging_buffer_pool_.get().pool;
}

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 @@ -157,6 +157,7 @@ void ImageEncodingImpeller::ConvertDlImageToSkImage(

impeller::DeviceBufferDescriptor buffer_desc;
buffer_desc.storage_mode = impeller::StorageMode::kHostVisible;
buffer_desc.readback = true;
buffer_desc.size =
texture->GetTextureDescriptor().GetByteSizeOfBaseMipLevel();
auto buffer =
Expand Down