mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-20 16:30:50 +02:00
compiler/nir: make lowering global-id to local-id optional
For D3D12, we don't want to lower this, as there's a dedicated global-id system-value that might be faster to use, depending on the hardware. Reviewed-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5891>
This commit is contained in:
parent
41e4eb9948
commit
58074143f5
2 changed files with 13 additions and 6 deletions
|
|
@ -3124,6 +3124,9 @@ typedef struct nir_shader_compiler_options {
|
|||
bool lower_cs_local_index_from_id;
|
||||
bool lower_cs_local_id_from_index;
|
||||
|
||||
/* Prevents lowering global_invocation_id to be in terms of work_group_id */
|
||||
bool has_cs_global_id;
|
||||
|
||||
bool lower_device_index_to_zero;
|
||||
|
||||
/* Set if nir_lower_wpos_ytransform() should also invert gl_PointCoord. */
|
||||
|
|
|
|||
|
|
@ -188,13 +188,17 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state)
|
|||
}
|
||||
|
||||
case nir_intrinsic_load_global_invocation_id: {
|
||||
nir_ssa_def *group_size = nir_load_local_group_size(b);
|
||||
nir_ssa_def *group_id = nir_load_work_group_id(b, bit_size);
|
||||
nir_ssa_def *local_id = nir_load_local_invocation_id(b);
|
||||
if (!b->shader->options->has_cs_global_id) {
|
||||
nir_ssa_def *group_size = nir_load_local_group_size(b);
|
||||
nir_ssa_def *group_id = nir_load_work_group_id(b, bit_size);
|
||||
nir_ssa_def *local_id = nir_load_local_invocation_id(b);
|
||||
|
||||
return nir_iadd(b, nir_imul(b, group_id,
|
||||
nir_u2u(b, group_size, bit_size)),
|
||||
nir_u2u(b, local_id, bit_size));
|
||||
return nir_iadd(b, nir_imul(b, group_id,
|
||||
nir_u2u(b, group_size, bit_size)),
|
||||
nir_u2u(b, local_id, bit_size));
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_global_invocation_index: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue