mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-29 09:05:41 +00:00
VulkanHostDisplay: Use coherent memory type for downloads on Adreno
Otherwise it spends a ton of CPU time invalidating the buffer.
This commit is contained in:
parent
4dc3014fcd
commit
6af5a2486c
|
@ -253,6 +253,9 @@ bool VulkanHostDisplay::CreateRenderDevice(const WindowInfo& wi, std::string_vie
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_is_adreno = (g_vulkan_context->GetDeviceProperties().vendorID == 0x5143 ||
|
||||||
|
g_vulkan_context->GetDeviceDriverProperties().driverID == VK_DRIVER_ID_QUALCOMM_PROPRIETARY);
|
||||||
|
|
||||||
m_window_info = m_swap_chain ? m_swap_chain->GetWindowInfo() : local_wi;
|
m_window_info = m_swap_chain ? m_swap_chain->GetWindowInfo() : local_wi;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -292,40 +295,6 @@ VkRenderPass VulkanHostDisplay::GetRenderPassForDisplay() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VulkanHostDisplay::CheckStagingBufferSize(u32 required_size)
|
|
||||||
{
|
|
||||||
if (m_readback_staging_buffer_size >= required_size)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
DestroyStagingBuffer();
|
|
||||||
|
|
||||||
const VkBufferCreateInfo bci = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
|
||||||
nullptr,
|
|
||||||
0u,
|
|
||||||
required_size,
|
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
|
||||||
VK_SHARING_MODE_EXCLUSIVE,
|
|
||||||
0u,
|
|
||||||
nullptr};
|
|
||||||
|
|
||||||
VmaAllocationCreateInfo aci = {};
|
|
||||||
aci.usage = VMA_MEMORY_USAGE_GPU_TO_CPU;
|
|
||||||
aci.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT;
|
|
||||||
aci.preferredFlags = VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
|
||||||
|
|
||||||
VmaAllocationInfo ai = {};
|
|
||||||
VkResult res = vmaCreateBuffer(g_vulkan_context->GetAllocator(), &bci, &aci, &m_readback_staging_buffer,
|
|
||||||
&m_readback_staging_allocation, &ai);
|
|
||||||
if (res != VK_SUCCESS)
|
|
||||||
{
|
|
||||||
LOG_VULKAN_ERROR(res, "vmaCreateBuffer() failed: ");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_readback_staging_buffer_map = static_cast<u8*>(ai.pMappedData);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VulkanHostDisplay::DestroyStagingBuffer()
|
void VulkanHostDisplay::DestroyStagingBuffer()
|
||||||
{
|
{
|
||||||
// unmapped as part of the buffer destroy
|
// unmapped as part of the buffer destroy
|
||||||
|
@ -407,6 +376,41 @@ bool VulkanHostDisplay::DownloadTexture(const void* texture_handle, HostDisplayP
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VulkanHostDisplay::CheckStagingBufferSize(u32 required_size)
|
||||||
|
{
|
||||||
|
if (m_readback_staging_buffer_size >= required_size)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
DestroyStagingBuffer();
|
||||||
|
|
||||||
|
const VkBufferCreateInfo bci = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
|
nullptr,
|
||||||
|
0u,
|
||||||
|
required_size,
|
||||||
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
||||||
|
VK_SHARING_MODE_EXCLUSIVE,
|
||||||
|
0u,
|
||||||
|
nullptr};
|
||||||
|
|
||||||
|
VmaAllocationCreateInfo aci = {};
|
||||||
|
aci.usage = VMA_MEMORY_USAGE_GPU_TO_CPU;
|
||||||
|
aci.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT;
|
||||||
|
aci.preferredFlags = m_is_adreno ? (VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) :
|
||||||
|
VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
|
||||||
|
|
||||||
|
VmaAllocationInfo ai = {};
|
||||||
|
VkResult res = vmaCreateBuffer(g_vulkan_context->GetAllocator(), &bci, &aci, &m_readback_staging_buffer,
|
||||||
|
&m_readback_staging_allocation, &ai);
|
||||||
|
if (res != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
LOG_VULKAN_ERROR(res, "vmaCreateBuffer() failed: ");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_readback_staging_buffer_map = static_cast<u8*>(ai.pMappedData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool VulkanHostDisplay::CreateResources()
|
bool VulkanHostDisplay::CreateResources()
|
||||||
{
|
{
|
||||||
static constexpr char fullscreen_quad_vertex_shader[] = R"(
|
static constexpr char fullscreen_quad_vertex_shader[] = R"(
|
||||||
|
|
|
@ -124,6 +124,7 @@ protected:
|
||||||
VkBuffer m_readback_staging_buffer = VK_NULL_HANDLE;
|
VkBuffer m_readback_staging_buffer = VK_NULL_HANDLE;
|
||||||
u8* m_readback_staging_buffer_map = nullptr;
|
u8* m_readback_staging_buffer_map = nullptr;
|
||||||
u32 m_readback_staging_buffer_size = 0;
|
u32 m_readback_staging_buffer_size = 0;
|
||||||
|
bool m_is_adreno = false;
|
||||||
|
|
||||||
VkDescriptorSetLayout m_post_process_descriptor_set_layout = VK_NULL_HANDLE;
|
VkDescriptorSetLayout m_post_process_descriptor_set_layout = VK_NULL_HANDLE;
|
||||||
VkDescriptorSetLayout m_post_process_ubo_descriptor_set_layout = VK_NULL_HANDLE;
|
VkDescriptorSetLayout m_post_process_ubo_descriptor_set_layout = VK_NULL_HANDLE;
|
||||||
|
|
Loading…
Reference in a new issue