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 Mike Blumenkrantz
parent 38d6ae933d
commit f8bdbbdd90
3 changed files with 20 additions and 0 deletions

View file

@ -14,3 +14,4 @@ VK_EXT_multisampled_render_to_single_sampled on lavapipe
VK_EXT_shader_subgroup_vote/ballot on lavapipe
EGL_KHR_context_flush_control for all drivers
GLX_ARB_context_flush_control for all drivers
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;
}