diff options
author | Kenneth Graunke <[email protected]> | 2015-08-03 16:02:16 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2015-09-08 18:02:08 -0700 |
commit | d5d74d0b86207cff2820561cc3c8b40546a11bc9 (patch) | |
tree | f8ca6b80d7c3ff8434a7238411a895eedbfb1a4b | |
parent | 8fbc4ae330b9ef51bce9023c2f58d1888fb6b796 (diff) |
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 <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
-rw-r--r-- | src/glsl/nir/nir.c | 34 | ||||
-rw-r--r-- | src/glsl/nir/nir.h | 2 |
2 files changed, 36 insertions, 0 deletions
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 |