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 all commits
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
16 changes: 5 additions & 11 deletions impeller/renderer/backend/vulkan/allocator_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ static PoolVMA CreateBufferPool(VmaAllocator allocator) {

VmaPoolCreateInfo pool_create_info = {};
pool_create_info.memoryTypeIndex = memTypeIndex;
pool_create_info.flags = VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT |
VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT;
pool_create_info.flags = VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT;

VmaPool pool = {};
result = vk::Result{::vmaCreatePool(allocator, &pool_create_info, &pool)};
Expand Down Expand Up @@ -161,10 +160,8 @@ AllocatorVK::AllocatorVK(std::weak_ptr<Context> context,
VALIDATION_LOG << "Could not create memory allocator";
return;
}
for (size_t i = 0u; i < staging_buffer_pools_.size(); i++) {
staging_buffer_pools_[i].reset(CreateBufferPool(allocator));
created_buffer_pools_ &= staging_buffer_pools_[i].is_valid();
}
staging_buffer_pool_.reset(CreateBufferPool(allocator));
created_buffer_pool_ &= staging_buffer_pool_.is_valid();
allocator_.reset(allocator);
supports_memoryless_textures_ = capabilities.SupportsMemorylessTextures();
is_valid_ = true;
Expand Down Expand Up @@ -460,12 +457,9 @@ std::shared_ptr<DeviceBuffer> AllocatorVK::OnCreateBuffer(
allocation_info.preferredFlags = static_cast<VkMemoryPropertyFlags>(
ToVKBufferMemoryPropertyFlags(desc.storage_mode));
allocation_info.flags = ToVmaAllocationBufferCreateFlags(desc.storage_mode);
if (created_buffer_pools_ && desc.storage_mode == StorageMode::kHostVisible &&
if (created_buffer_pool_ && desc.storage_mode == StorageMode::kHostVisible &&
raster_thread_id_ == std::this_thread::get_id()) {
allocation_info.pool =
staging_buffer_pools_[frame_count_ % staging_buffer_pools_.size()]
.get()
.pool;
allocation_info.pool = staging_buffer_pool_.get().pool;
}

VkBuffer buffer = {};
Expand Down
6 changes: 2 additions & 4 deletions impeller/renderer/backend/vulkan/allocator_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ class AllocatorVK final : public Allocator {
private:
friend class ContextVK;

static constexpr size_t kPoolCount = 3;

fml::RefPtr<vulkan::VulkanProcTable> vk_;
UniqueAllocatorVMA allocator_;
std::array<UniquePoolVMA, kPoolCount> staging_buffer_pools_;
UniquePoolVMA staging_buffer_pool_;
std::weak_ptr<Context> context_;
std::weak_ptr<DeviceHolder> device_holder_;
ISize max_texture_size_;
bool is_valid_ = false;
bool supports_memoryless_textures_ = false;
// TODO(jonahwilliams): figure out why CI can't create these buffer pools.
bool created_buffer_pools_ = true;
bool created_buffer_pool_ = true;
uint32_t frame_count_ = 0;
std::thread::id raster_thread_id_;

Expand Down