On Radeon GPUs VK_IMAGE_LAYOUT_GENERAL images don't use Delta Color Compression, but SRC/DST optimal images do. Transitioning from GENERAL to SRC/DST causes a big performance hit.
As a next step we should try harder to avoid VK_IMAGE_LAYOUT_GENERAL.
Signed-off-by: Stefan Dösinger [email protected]
---
This improves Rocket League from 50fps to 67fps when it is GPU limited. Using VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL instead of GENERAL further improves it to 80 fps. Switching from COLOR_ATTACHMENT_OPTIMAL to SRC/DST optimal seems cheap (it just stays compressed), but first we need logic to transition BIND_RENDER_TARGET | BIND_SHADER_RESOURCE textures between COLOR_ATTACHMENT_OPTIMAL and SHADER_READ_ONLY_OPTIMAL.
From: Stefan Dösinger [email protected]
On Radeon GPUs VK_IMAGE_LAYOUT_GENERAL images don't use Delta Color Compression, but SRC/DST optimal images do. Transitioning from GENERAL to SRC/DST causes a big performance hit.
As a next step we should try harder to avoid VK_IMAGE_LAYOUT_GENERAL.
Signed-off-by: Stefan Dösinger [email protected]
---
This improves Rocket League from 50fps to 67fps when it is GPU limited. Using VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL instead of GENERAL further improves it to 80 fps. Switching from COLOR_ATTACHMENT_OPTIMAL to SRC/DST optimal seems cheap (it just stays compressed), but first we need logic to transition BIND_RENDER_TARGET | BIND_SHADER_RESOURCE textures between COLOR_ATTACHMENT_OPTIMAL and SHADER_READ_ONLY_OPTIMAL. --- dlls/wined3d/texture.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 18a60ecbf52..d29cfb3b8bb 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -6919,6 +6919,7 @@ static DWORD vk_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_ struct wined3d_context_vk *context_vk = wined3d_context_vk(context); const struct wined3d_vk_info *vk_info = context_vk->vk_info; VkImageSubresourceRange vk_src_range, vk_dst_range; + VkImageLayout src_layout, dst_layout; VkCommandBuffer vk_command_buffer; struct wined3d_blitter *next; unsigned src_sample_count; @@ -6979,17 +6980,25 @@ static DWORD vk_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_ goto next; }
+ if (src_texture_vk->layout == VK_IMAGE_LAYOUT_GENERAL) + src_layout = VK_IMAGE_LAYOUT_GENERAL; + else + src_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; + + if (dst_texture_vk->layout == VK_IMAGE_LAYOUT_GENERAL) + dst_layout = VK_IMAGE_LAYOUT_GENERAL; + else + dst_layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; + wined3d_context_vk_image_barrier(context_vk, vk_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, vk_access_mask_from_bind_flags(src_texture_vk->t.resource.bind_flags), - VK_ACCESS_TRANSFER_READ_BIT, - src_texture_vk->layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_ACCESS_TRANSFER_READ_BIT, src_texture_vk->layout, src_layout, src_texture_vk->image.vk_image, &vk_src_range); wined3d_context_vk_image_barrier(context_vk, vk_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, vk_access_mask_from_bind_flags(dst_texture_vk->t.resource.bind_flags), - VK_ACCESS_TRANSFER_WRITE_BIT, - dst_texture_vk->layout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_ACCESS_TRANSFER_WRITE_BIT, dst_texture_vk->layout, dst_layout, dst_texture_vk->image.vk_image, &vk_dst_range);
if (resolve) @@ -7215,14 +7224,12 @@ static DWORD vk_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_ VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, vk_access_mask_from_bind_flags(dst_texture_vk->t.resource.bind_flags), - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, dst_texture_vk->layout, - dst_texture_vk->image.vk_image, &vk_dst_range); + dst_layout, dst_texture_vk->layout, dst_texture_vk->image.vk_image, &vk_dst_range); wined3d_context_vk_image_barrier(context_vk, vk_command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_READ_BIT, vk_access_mask_from_bind_flags(src_texture_vk->t.resource.bind_flags), - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, src_texture_vk->layout, - src_texture_vk->image.vk_image, &vk_src_range); + src_layout, src_texture_vk->layout, src_texture_vk->image.vk_image, &vk_src_range);
wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB); @@ -7239,14 +7246,12 @@ barrier_next: VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, vk_access_mask_from_bind_flags(dst_texture_vk->t.resource.bind_flags), - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, dst_texture_vk->layout, - dst_texture_vk->image.vk_image, &vk_dst_range); + dst_layout, dst_texture_vk->layout, dst_texture_vk->image.vk_image, &vk_dst_range); wined3d_context_vk_image_barrier(context_vk, vk_command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_READ_BIT, vk_access_mask_from_bind_flags(src_texture_vk->t.resource.bind_flags), - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, src_texture_vk->layout, - src_texture_vk->image.vk_image, &vk_src_range); + src_layout, src_texture_vk->layout, src_texture_vk->image.vk_image, &vk_src_range);
next: if (!(next = blitter->next))
On Tue, 26 Apr 2022 at 14:04, Stefan Dösinger [email protected] wrote:
From: Stefan Dösinger [email protected]
On Radeon GPUs VK_IMAGE_LAYOUT_GENERAL images don't use Delta Color Compression, but SRC/DST optimal images do. Transitioning from GENERAL to SRC/DST causes a big performance hit.
As a next step we should try harder to avoid VK_IMAGE_LAYOUT_GENERAL.
Signed-off-by: Stefan Dösinger [email protected]
This improves Rocket League from 50fps to 67fps when it is GPU limited. Using VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL instead of GENERAL further improves it to 80 fps. Switching from COLOR_ATTACHMENT_OPTIMAL to SRC/DST optimal seems cheap (it just stays compressed), but first we need logic to transition BIND_RENDER_TARGET | BIND_SHADER_RESOURCE textures between COLOR_ATTACHMENT_OPTIMAL and SHADER_READ_ONLY_OPTIMAL.
dlls/wined3d/texture.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
For the benefit of the mailing list, nothing seems particularly wrong about this patch, but Stefan found it causes a regression in an application. So this patch is effectively pending until that is figured out.