Skip to content

Commit

Permalink
[Impeller] Switch back to using explicit flush for device buffers. (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams authored and harryterkelsen committed Jul 20, 2023
1 parent 740e09f commit 8f39d5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
23 changes: 6 additions & 17 deletions impeller/renderer/backend/vulkan/allocator_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ ToVKTextureMemoryPropertyFlags(StorageMode mode,
switch (mode) {
case StorageMode::kHostVisible:
return vk::MemoryPropertyFlagBits::eHostVisible |
vk::MemoryPropertyFlagBits::eDeviceLocal |
vk::MemoryPropertyFlagBits::eHostCoherent;
vk::MemoryPropertyFlagBits::eDeviceLocal;
case StorageMode::kDevicePrivate:
return vk::MemoryPropertyFlagBits::eDeviceLocal;
case StorageMode::kDeviceTransient:
Expand All @@ -266,25 +265,16 @@ ToVKTextureMemoryPropertyFlags(StorageMode mode,
}

static VmaAllocationCreateFlags ToVmaAllocationCreateFlags(StorageMode mode,
bool is_texture,
size_t size) {
VmaAllocationCreateFlags flags = 0;
switch (mode) {
case StorageMode::kHostVisible:
if (is_texture) {
if (size >= kImageSizeThresholdForDedicatedMemoryAllocation) {
flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
} else {
flags |= {};
}
} else {
flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
if (size >= kImageSizeThresholdForDedicatedMemoryAllocation) {
flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
}
return flags;
case StorageMode::kDevicePrivate:
if (is_texture &&
size >= kImageSizeThresholdForDedicatedMemoryAllocation) {
if (size >= kImageSizeThresholdForDedicatedMemoryAllocation) {
flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
}
return flags;
Expand Down Expand Up @@ -328,9 +318,8 @@ class AllocatedTextureSourceVK final : public TextureSourceVK {
alloc_nfo.preferredFlags =
static_cast<VkMemoryPropertyFlags>(ToVKTextureMemoryPropertyFlags(
desc.storage_mode, supports_memoryless_textures));
alloc_nfo.flags =
ToVmaAllocationCreateFlags(desc.storage_mode, /*is_texture=*/true,
desc.GetByteSizeOfBaseMipLevel());
alloc_nfo.flags = ToVmaAllocationCreateFlags(
desc.storage_mode, desc.GetByteSizeOfBaseMipLevel());

auto create_info_native =
static_cast<vk::ImageCreateInfo::NativeType>(image_info);
Expand Down
3 changes: 3 additions & 0 deletions impeller/renderer/backend/vulkan/device_buffer_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ bool DeviceBufferVK::OnCopyHostBuffer(const uint8_t* source,
if (source) {
::memmove(dest + offset, source + source_range.offset, source_range.length);
}
::vmaFlushAllocation(resource_->buffer.get().allocator,
resource_->buffer.get().allocation, offset,
source_range.length);

return true;
}
Expand Down

0 comments on commit 8f39d5e

Please sign in to comment.