radv,vtn,driconf: Add and use radv_rt_ssbo_non_uniform workaround for Crysis 2/3 Remastered

Crysis 2 and 3 Remastered's RT shaders non-uniformly index into SSBO
descriptor arrays without specifying the NonUniformEXT qualifier on the
relevant access chains/load ops. This leads to artifacts around objects.

To add insult to injury, the game fails to provide a meaningful
applicationName/engineName in the Vulkan part of the DX11-Vulkan interop
solution used for RT. Both of these fields are set to "nvpro-sample"
(perhaps the code has been copied from NVIDIA's sample applications).
Therefore, fall back to executable name matching.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9883
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26391>
This commit is contained in:
Friedrich Vock 2023-11-29 01:20:54 +01:00 committed by Marge Bot
parent 63e2bba592
commit f1817ab7e0
9 changed files with 24 additions and 0 deletions

View file

@ -157,6 +157,7 @@ static const driOptionDescription radv_dri_options[] = {
DRI_CONF_RADV_OVERRIDE_GRAPHICS_SHADER_VERSION(0)
DRI_CONF_RADV_OVERRIDE_COMPUTE_SHADER_VERSION(0)
DRI_CONF_RADV_OVERRIDE_RAY_TRACING_SHADER_VERSION(0)
DRI_CONF_RADV_SSBO_NON_UNIFORM(false)
DRI_CONF_RADV_APP_LAYER()
DRI_CONF_SECTION_END
};
@ -207,6 +208,8 @@ radv_init_dri_options(struct radv_instance *instance)
instance->tex_non_uniform = driQueryOptionb(&instance->dri_options, "radv_tex_non_uniform");
instance->ssbo_non_uniform = driQueryOptionb(&instance->dri_options, "radv_ssbo_non_uniform");
instance->app_layer = driQueryOptionstr(&instance->dri_options, "radv_app_layer");
instance->flush_before_timestamp_write =

View file

@ -162,6 +162,7 @@ radv_generate_pipeline_key(const struct radv_device *device, const VkPipelineSha
key.image_2d_view_of_3d = device->image_2d_view_of_3d && device->physical_device->rad_info.gfx_level == GFX9;
key.tex_non_uniform = device->instance->tex_non_uniform;
key.ssbo_non_uniform = device->instance->ssbo_non_uniform;
for (unsigned i = 0; i < num_stages; ++i) {
const VkPipelineShaderStageCreateInfo *const stage = &stages[i];

View file

@ -420,6 +420,7 @@ struct radv_instance {
bool flush_before_query_copy;
bool enable_unified_heap_on_apu;
bool tex_non_uniform;
bool ssbo_non_uniform;
bool flush_before_timestamp_write;
bool force_rt_wave64;
bool dual_color_blend_by_location;

View file

@ -471,6 +471,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
.private_data = &spirv_debug_data,
},
.force_tex_non_uniform = key->tex_non_uniform,
.force_ssbo_non_uniform = key->ssbo_non_uniform,
};
nir = spirv_to_nir(spirv, stage->spirv.size / 4, spec_entries, num_spec_entries, stage->stage, stage->entrypoint,
&spirv_options, &device->physical_device->nir_options[stage->stage]);

View file

@ -99,6 +99,7 @@ struct radv_pipeline_key {
uint32_t dynamic_provoking_vtx_mode : 1;
uint32_t dynamic_line_rast_mode : 1;
uint32_t tex_non_uniform : 1;
uint32_t ssbo_non_uniform : 1;
uint32_t enable_remove_point_size : 1;
uint32_t unknown_rast_prim : 1;
uint32_t mesh_shader_queries : 1;

View file

@ -116,6 +116,8 @@ struct spirv_to_nir_options {
/* Force texture sampling to be non-uniform. */
bool force_tex_non_uniform;
/* Force SSBO accesses to be non-uniform. */
bool force_ssbo_non_uniform;
/* In Debug Builds, instead of emitting an OS break on failure, just return NULL from
* spirv_to_nir(). This is useful for the unit tests that want to report a test failed

View file

@ -2685,6 +2685,9 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
/* Workaround for https://gitlab.freedesktop.org/mesa/mesa/-/issues/3406 */
access |= base->access & ACCESS_NON_UNIFORM;
if (base->mode == vtn_variable_mode_ssbo && b->options->force_ssbo_non_uniform)
access |= ACCESS_NON_UNIFORM;
struct vtn_pointer *ptr = vtn_pointer_dereference(b, base, chain);
ptr->ptr_type = ptr_type;
ptr->access |= access;

View file

@ -149,6 +149,14 @@ Application bugs worked around in this file:
<option name="radv_invariant_geom" value="true"/>
</application>
<application name="Crysis 2 Remastered" executable="Crysis2Remastered.exe">
<option name="radv_ssbo_non_uniform" value="true" />
</application>
<application name="Crysis 3 Remastered" executable="Crysis3Remastered.exe">
<option name="radv_ssbo_non_uniform" value="true" />
</application>
<!-- OpenGL Game workarounds (zink) -->
<application name="Black Geyser: Couriers of Darkness" executable="BlackGeyser.x86_64">
<option name="radv_zero_vram" value="true" />

View file

@ -678,6 +678,10 @@
DRI_CONF_OPT_B(radv_tex_non_uniform, def, \
"Always mark texture sample operations as non-uniform.")
#define DRI_CONF_RADV_SSBO_NON_UNIFORM(def) \
DRI_CONF_OPT_B(radv_ssbo_non_uniform, def, \
"Always mark SSBO operations as non-uniform.")
#define DRI_CONF_RADV_FLUSH_BEFORE_TIMESTAMP_WRITE(def) \
DRI_CONF_OPT_B(radv_flush_before_timestamp_write, def, \
"Wait for previous commands to finish before writing timestamps")