[Mesa-dev] [PATCH 1/2] nir: Add a nir_system_value_from_intrinsic() function.
Iago Toral
itoral at igalia.com
Mon Sep 7 07:04:56 PDT 2015
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
On Mon, 2015-09-07 at 00:30 -0700, Kenneth Graunke wrote:
> This converts NIR intrinsics that load system values into Mesa's
> SYSTEM_VALUE_* enumerations.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> src/glsl/nir/nir.c | 34 ++++++++++++++++++++++++++++++++++
> src/glsl/nir/nir.h | 2 ++
> 2 files changed, 36 insertions(+)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 3f4bec4..ab06ea2 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 53e883e..b13e92d 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1843,6 +1843,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
More information about the mesa-dev
mailing list