From: Kenneth Graunke Date: Mon, 3 Aug 2015 23:02:16 +0000 (-0700) Subject: nir: Add a nir_system_value_from_intrinsic() function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d5d74d0b86207cff2820561cc3c8b40546a11bc9;p=mesa.git nir: Add a nir_system_value_from_intrinsic() function. This converts NIR intrinsics that load system values into Mesa's SYSTEM_VALUE_* enumerations. Signed-off-by: Kenneth Graunke Reviewed-by: Iago Toral Quiroga --- diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index 3f4bec4625d..ab06ea2bc19 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -1404,3 +1404,37 @@ nir_index_ssa_defs(nir_function_impl *impl) nir_foreach_block(impl, index_ssa_block, &index); impl->ssa_alloc = index; } + +gl_system_value +nir_system_value_from_intrinsic(nir_intrinsic_op intrin) +{ + switch (intrin) { + case nir_intrinsic_load_vertex_id: + return SYSTEM_VALUE_VERTEX_ID; + case nir_intrinsic_load_instance_id: + return SYSTEM_VALUE_INSTANCE_ID; + case nir_intrinsic_load_vertex_id_zero_base: + return SYSTEM_VALUE_VERTEX_ID_ZERO_BASE; + case nir_intrinsic_load_base_vertex: + return SYSTEM_VALUE_BASE_VERTEX; + case nir_intrinsic_load_invocation_id: + return SYSTEM_VALUE_INVOCATION_ID; + case nir_intrinsic_load_front_face: + return SYSTEM_VALUE_FRONT_FACE; + case nir_intrinsic_load_sample_id: + return SYSTEM_VALUE_SAMPLE_ID; + case nir_intrinsic_load_sample_pos: + return SYSTEM_VALUE_SAMPLE_POS; + case nir_intrinsic_load_sample_mask_in: + return SYSTEM_VALUE_SAMPLE_MASK_IN; + /* FINISHME: Add tessellation intrinsics. + return SYSTEM_VALUE_TESS_COORD; + return SYSTEM_VALUE_VERTICES_IN; + return SYSTEM_VALUE_PRIMITIVE_ID; + return SYSTEM_VALUE_TESS_LEVEL_OUTER; + return SYSTEM_VALUE_TESS_LEVEL_INNER; + */ + default: + unreachable("intrinsic doesn't produce a system value"); + } +} diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index e73b7fbc4e1..3c375f30c53 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1842,6 +1842,8 @@ bool nir_opt_undef(nir_shader *shader); void nir_sweep(nir_shader *shader); +gl_system_value nir_system_value_from_intrinsic(nir_intrinsic_op intrin); + #ifdef __cplusplus } /* extern "C" */ #endif