radv: implement VK_EXT_attachment_feedback_loop_layout

This extension introduces a new layout which allows applications
to both render and sample from the same image inside the same draw
(aka. feedback loops).

Previously, the GENERAL layout was used and this introduced some
rendering artifacts because the hw can't read&write DCC/HTILE for
the same image, and we try to keep it compressed on GFX10+.

This helps fixing corruption with D3D9 and RPCS3 games which
are candidate for feedback loops.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4411
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17883>
This commit is contained in:
Samuel Pitoiset 2021-03-11 13:58:35 +01:00 committed by Marge Bot
parent 5992b8bbf7
commit 239363f3c6
3 changed files with 20 additions and 0 deletions

View file

@ -1,3 +1,4 @@
GL_ARB_shader_clock on llvmpipe
VK_KHR_shader_clock on lavapipe
Mesa-DB, the new single file cache type
VK_EXT_attachment_feedback_loop_layout on RADV

View file

@ -519,6 +519,7 @@ radv_physical_device_get_supported_extensions(const struct radv_physical_device
.KHR_workgroup_memory_explicit_layout = true,
.KHR_zero_initialize_workgroup_memory = true,
.EXT_4444_formats = true,
.EXT_attachment_feedback_loop_layout = true,
.EXT_border_color_swizzle = device->rad_info.gfx_level >= GFX10,
.EXT_buffer_device_address = true,
.EXT_calibrated_timestamps = RADV_SUPPORT_CALIBRATED_TIMESTAMPS,
@ -1850,6 +1851,12 @@ radv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
features->deviceGeneratedCommands = true;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT: {
VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT *features =
(VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT *)ext;
features->attachmentFeedbackLoopLayout = true;
break;
}
default:
break;
}

View file

@ -2241,6 +2241,11 @@ radv_layout_is_htile_compressed(const struct radv_device *device, const struct r
} else {
return false;
}
case VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT:
/* Do not compress HTILE with feedback loops because we can't read&write it without
* introducing corruption.
*/
return false;
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
if (radv_image_is_tc_compat_htile(image) ||
(radv_image_has_htile(image) &&
@ -2303,6 +2308,13 @@ radv_layout_dcc_compressed(const struct radv_device *device, const struct radv_i
(queue_mask & (1u << RADV_QUEUE_COMPUTE)) && !radv_image_use_dcc_image_stores(device, image))
return false;
if (layout == VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT) {
/* Do not compress DCC with feedback loops because we can't read&write it without introducing
* corruption.
*/
return false;
}
return device->physical_device->rad_info.gfx_level >= GFX10 || layout != VK_IMAGE_LAYOUT_GENERAL;
}