Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase and refactor fix for staging buffer memory types #1173

Merged
merged 5 commits into from
Jun 29, 2023
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
36 changes: 19 additions & 17 deletions framework/decode/vulkan_rebind_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,13 @@ void VulkanRebindAllocator::GetDeviceMemoryCommitment(VkDeviceMemory memory,
GFXRECON_UNREFERENCED_PARAMETER(allocator_data);
}

VkResult VulkanRebindAllocator::BindBufferMemory(VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memory_offset,
ResourceData allocator_buffer_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties)
VkResult VulkanRebindAllocator::BindBufferMemory(VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memory_offset,
ResourceData allocator_buffer_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties,
const VkPhysicalDeviceMemoryProperties& device_memory_properties)
{
GFXRECON_UNREFERENCED_PARAMETER(memory);

Expand All @@ -407,10 +408,10 @@ VkResult VulkanRebindAllocator::BindBufferMemory(VkBuffer buffer,

VmaAllocationCreateInfo create_info;
create_info.flags = 0;
create_info.usage = GetBufferMemoryUsage(
resource_alloc_info->usage,
capture_memory_properties_.memoryTypes[memory_alloc_info->original_index].propertyFlags,
requirements);
create_info.usage =
GetBufferMemoryUsage(resource_alloc_info->usage,
device_memory_properties.memoryTypes[memory_alloc_info->original_index].propertyFlags,
requirements);
create_info.requiredFlags = 0;
create_info.preferredFlags = 0;
create_info.memoryTypeBits = 0;
Expand Down Expand Up @@ -550,12 +551,13 @@ VkResult VulkanRebindAllocator::BindBufferMemory2(uint32_t
return result;
}

VkResult VulkanRebindAllocator::BindImageMemory(VkImage image,
VkDeviceMemory memory,
VkDeviceSize memory_offset,
ResourceData allocator_image_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties)
VkResult VulkanRebindAllocator::BindImageMemory(VkImage image,
VkDeviceMemory memory,
VkDeviceSize memory_offset,
ResourceData allocator_image_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties,
const VkPhysicalDeviceMemoryProperties& device_memory_properties)
{
GFXRECON_UNREFERENCED_PARAMETER(memory);

Expand All @@ -576,7 +578,7 @@ VkResult VulkanRebindAllocator::BindImageMemory(VkImage image,
create_info.usage =
GetImageMemoryUsage(resource_alloc_info->usage,
resource_alloc_info->tiling,
capture_memory_properties_.memoryTypes[memory_alloc_info->original_index].propertyFlags,
device_memory_properties.memoryTypes[memory_alloc_info->original_index].propertyFlags,
requirements);
create_info.requiredFlags = 0;
create_info.preferredFlags = 0;
Expand Down
56 changes: 50 additions & 6 deletions framework/decode/vulkan_rebind_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ class VulkanRebindAllocator : public VulkanResourceAllocator
VkDeviceSize memory_offset,
ResourceData allocator_buffer_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties) override;
VkMemoryPropertyFlags* bind_memory_properties) override
{
return BindBufferMemory(buffer,
memory,
memory_offset,
allocator_buffer_data,
allocator_memory_data,
bind_memory_properties,
capture_memory_properties_);
}

virtual VkResult BindBufferMemory2(uint32_t bind_info_count,
const VkBindBufferMemoryInfo* bind_infos,
Expand All @@ -114,7 +123,16 @@ class VulkanRebindAllocator : public VulkanResourceAllocator
VkDeviceSize memory_offset,
ResourceData allocator_image_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties) override;
VkMemoryPropertyFlags* bind_memory_properties) override
{
return BindImageMemory(image,
memory,
memory_offset,
allocator_image_data,
allocator_memory_data,
bind_memory_properties,
capture_memory_properties_);
}

virtual VkResult BindImageMemory2(uint32_t bind_info_count,
const VkBindImageMemoryInfo* bind_infos,
Expand Down Expand Up @@ -217,8 +235,13 @@ class VulkanRebindAllocator : public VulkanResourceAllocator
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties) override
{
return BindBufferMemory(
buffer, memory, memory_offset, allocator_buffer_data, allocator_memory_data, bind_memory_properties);
return BindBufferMemory(buffer,
memory,
memory_offset,
allocator_buffer_data,
allocator_memory_data,
bind_memory_properties,
replay_memory_properties_);
}

virtual VkResult BindImageMemoryDirect(VkImage image,
Expand All @@ -228,8 +251,13 @@ class VulkanRebindAllocator : public VulkanResourceAllocator
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties) override
{
return BindImageMemory(
image, memory, memory_offset, allocator_image_data, allocator_memory_data, bind_memory_properties);
return BindImageMemory(image,
memory,
memory_offset,
allocator_image_data,
allocator_memory_data,
bind_memory_properties,
replay_memory_properties_);
}

virtual VkResult MapResourceMemoryDirect(VkDeviceSize size,
Expand Down Expand Up @@ -342,6 +370,22 @@ class VulkanRebindAllocator : public VulkanResourceAllocator

void ReportBindIncompatibility(const ResourceData* allocator_resource_datas, uint32_t resource_count);

VkResult BindBufferMemory(VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memory_offset,
ResourceData allocator_buffer_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties,
const VkPhysicalDeviceMemoryProperties& device_memory_properties);

VkResult BindImageMemory(VkImage image,
VkDeviceMemory memory,
VkDeviceSize memory_offset,
ResourceData allocator_image_data,
MemoryData allocator_memory_data,
VkMemoryPropertyFlags* bind_memory_properties,
const VkPhysicalDeviceMemoryProperties& device_memory_properties);

private:
VkDevice device_;
VmaAllocator allocator_;
Expand Down