1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 12:42:41 +01:00

vk: Use appropriate layouts depending on use case when creating new textures to avoid needless barriers

This commit is contained in:
kd-11 2020-01-24 19:53:03 +03:00 committed by kd-11
parent 44f2cacf7b
commit 1166ae19bb
2 changed files with 36 additions and 1 deletions

View File

@ -1592,6 +1592,10 @@ void VKGSRender::end()
verify(HERE), sampler_state->upload_context == rsx::texture_upload_context::blit_engine_dst;
raw->change_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
break;
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
verify(HERE), sampler_state->upload_context == rsx::texture_upload_context::blit_engine_src;
raw->change_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
break;
case VK_IMAGE_LAYOUT_GENERAL:
verify(HERE), sampler_state->upload_context == rsx::texture_upload_context::framebuffer_storage;
if (!sampler_state->is_cyclic_reference)
@ -1724,6 +1728,10 @@ void VKGSRender::end()
verify(HERE), sampler_state->upload_context == rsx::texture_upload_context::blit_engine_dst;
raw->change_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
break;
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
verify(HERE), sampler_state->upload_context == rsx::texture_upload_context::blit_engine_src;
raw->change_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
break;
case VK_IMAGE_LAYOUT_GENERAL:
verify(HERE), sampler_state->upload_context == rsx::texture_upload_context::framebuffer_storage;
if (!sampler_state->is_cyclic_reference)

View File

@ -1269,7 +1269,34 @@ namespace vk
vk::leave_uninterruptible();
change_image_layout(cmd, image, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, subres_range);
// Insert appropriate barrier depending on use
VkImageLayout preferred_layout;
switch (context)
{
default:
preferred_layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
break;
case rsx::texture_upload_context::blit_engine_dst:
preferred_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
break;
case rsx::texture_upload_context::blit_engine_src:
preferred_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
break;
}
if (preferred_layout != image->current_layout)
{
change_image_layout(cmd, image, preferred_layout, subres_range);
}
else
{
// Insert ordering barrier
verify(HERE), preferred_layout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
insert_image_memory_barrier(cmd, image->value, image->current_layout, preferred_layout,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
subres_range);
}
section->last_write_tag = rsx::get_shared_tag();
return section;