spirv: mark all resources as non-uniform by default with descriptor heap

It's required by descriptor heap. There is already a NIR pass that
optimizes non-uniform access, so this should be mostly safe.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40768>
This commit is contained in:
Samuel Pitoiset 2026-04-03 14:56:56 +02:00 committed by Marge Bot
parent 74aa40f6ed
commit 33676d8296
3 changed files with 27 additions and 6 deletions

View file

@ -3473,8 +3473,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
"Type of Image operand of OpSampledImage");
enum gl_access_qualifier access = 0;
if (vtn_has_decoration(b, vtn_untyped_value(b, w[3]), SpvDecorationNonUniformEXT) ||
vtn_has_decoration(b, vtn_untyped_value(b, w[4]), SpvDecorationNonUniformEXT))
if (vtn_value_is_non_uniform(b, vtn_untyped_value(b, w[3])) ||
vtn_value_is_non_uniform(b, vtn_untyped_value(b, w[4])))
access |= ACCESS_NON_UNIFORM;
vtn_push_sampled_image(b, w[2], si, access & ACCESS_NON_UNIFORM);
@ -3483,7 +3483,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
struct vtn_sampled_image si = vtn_get_sampled_image(b, w[3]);
enum gl_access_qualifier access = 0;
if (vtn_has_decoration(b, vtn_untyped_value(b, w[3]), SpvDecorationNonUniformEXT))
if (vtn_value_is_non_uniform(b, vtn_untyped_value(b, w[3])))
access |= ACCESS_NON_UNIFORM;
vtn_push_image(b, w[2], si.image, access & ACCESS_NON_UNIFORM);
@ -4015,7 +4015,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
* can assume it doesn't exist.
*/
enum gl_access_qualifier access = 0;
if (vtn_has_decoration(b, sampled_val, SpvDecorationNonUniformEXT))
if (vtn_value_is_non_uniform(b, sampled_val))
access |= ACCESS_NON_UNIFORM;
if (operands & SpvImageOperandsNontemporalMask)
@ -4473,7 +4473,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
* chains to find the NonUniform decoration. It's either right there or we
* can assume it doesn't exist.
*/
if (vtn_has_decoration(b, res_val, SpvDecorationNonUniformEXT))
if (vtn_value_is_non_uniform(b, res_val))
access |= ACCESS_NON_UNIFORM;
nir_intrinsic_set_access(intrin, access);

View file

@ -1092,4 +1092,17 @@ nir_deref_instr *vtn_create_cmat_temporary(struct vtn_builder *b,
mesa_shader_stage vtn_stage_for_execution_model(SpvExecutionModel model);
static inline bool
vtn_value_is_non_uniform(struct vtn_builder *b, struct vtn_value *value)
{
if (vtn_has_decoration(b, value, SpvDecorationNonUniformEXT))
return true;
if (b->enabled_capabilities.DescriptorHeapEXT &&
!vtn_has_decoration(b, value, SpvDecorationUniform))
return true;
return false;
}
#endif /* _VTN_PRIVATE_H_ */

View file

@ -56,6 +56,10 @@ ptr_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
default:
break;
}
if (b->enabled_capabilities.DescriptorHeapEXT &&
dec->decoration != SpvDecorationUniform)
ptr->access |= ACCESS_NON_UNIFORM;
}
struct access_align {
@ -81,6 +85,10 @@ access_align_cb(struct vtn_builder *b, struct vtn_value *val, int member,
default:
break;
}
if (b->enabled_capabilities.DescriptorHeapEXT &&
dec->decoration != SpvDecorationUniform)
aa->access |= ACCESS_NON_UNIFORM;
}
static struct vtn_pointer*
@ -2888,7 +2896,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
}
/* Workaround for https://gitlab.freedesktop.org/mesa/mesa/-/issues/3406 */
if (vtn_has_decoration(b, link_val, SpvDecorationNonUniformEXT))
if (vtn_value_is_non_uniform(b, link_val))
access |= ACCESS_NON_UNIFORM;
idx++;