spirv: move workarounds to an inner struct in spirv_to_nir_options

To be more explicit.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33866>
This commit is contained in:
Samuel Pitoiset 2025-03-04 09:18:00 +01:00 committed by Marge Bot
parent 2c6837260e
commit f2eb31b1a2
5 changed files with 20 additions and 14 deletions

View file

@ -386,9 +386,12 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
.func = radv_spirv_nir_debug,
.private_data = &spirv_debug_data,
},
.force_tex_non_uniform = pdev->cache_key.tex_non_uniform,
.force_ssbo_non_uniform = pdev->cache_key.ssbo_non_uniform,
.lower_terminate_to_discard = pdev->cache_key.lower_terminate_to_discard,
.workarounds =
{
.force_tex_non_uniform = pdev->cache_key.tex_non_uniform,
.force_ssbo_non_uniform = pdev->cache_key.ssbo_non_uniform,
.lower_terminate_to_discard = pdev->cache_key.lower_terminate_to_discard,
},
.emit_debug_break = !!device->trap_handler_shader,
.debug_info = !!(instance->debug_flags & RADV_DEBUG_NIR_DEBUG_INFO),
};

View file

@ -131,15 +131,17 @@ struct spirv_to_nir_options {
/* Whether debug_break instructions should be emitted. */
bool emit_debug_break;
/* Force texture sampling to be non-uniform. */
bool force_tex_non_uniform;
/* Force SSBO accesses to be non-uniform. */
bool force_ssbo_non_uniform;
struct {
/* Force texture sampling to be non-uniform. */
bool force_tex_non_uniform;
/* Force SSBO accesses to be non-uniform. */
bool force_ssbo_non_uniform;
/* Whether OpTerminateInvocation should be lowered to OpKill to workaround
* game bugs.
*/
bool lower_terminate_to_discard;
/* Whether OpTerminateInvocation should be lowered to OpKill to workaround
* game bugs.
*/
bool lower_terminate_to_discard;
} workarounds;
/* 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
@ -149,6 +151,7 @@ struct spirv_to_nir_options {
/* Shader index provided by VkPipelineShaderStageNodeCreateInfoAMDX */
uint32_t shader_index;
};
enum spirv_verify_result {

View file

@ -3598,7 +3598,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
if (operands & SpvImageOperandsNontemporalMask)
access |= ACCESS_NON_TEMPORAL;
if (sampler && b->options->force_tex_non_uniform)
if (sampler && b->options->workarounds.force_tex_non_uniform)
access |= ACCESS_NON_UNIFORM;
if (sampled_val->propagated_non_uniform)

View file

@ -976,7 +976,7 @@ branch_type_for_terminator(struct vtn_builder *b, struct vtn_block *block)
case SpvOpKill:
return vtn_branch_type_discard;
case SpvOpTerminateInvocation:
if (b->options->lower_terminate_to_discard)
if (b->options->workarounds.lower_terminate_to_discard)
return vtn_branch_type_discard;
else
return vtn_branch_type_terminate_invocation;

View file

@ -2735,7 +2735,7 @@ 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)
if (base->mode == vtn_variable_mode_ssbo && b->options->workarounds.force_ssbo_non_uniform)
access |= ACCESS_NON_UNIFORM;
struct vtn_pointer *ptr = vtn_pointer_dereference(b, base, chain);