[Mesa-dev] [PATCH 3/8] nir: add a helper for getting the bitmask for a variable's location
Eduardo Lima Mitev
elima at igalia.com
Thu Sep 14 07:03:02 UTC 2017
On 09/13/2017 01:37 AM, Timothy Arceri wrote:
> ---
> src/compiler/nir/nir.h | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index fab2110f619..e52a1006896 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -351,6 +351,37 @@ typedef struct nir_variable {
> #define nir_foreach_variable_safe(var, var_list) \
> foreach_list_typed_safe(nir_variable, var, node, var_list)
>
> +/**
> + * Returns the bits in the inputs_read, outputs_written, or
> + * system_values_read bitfield corresponding to this variable.
> + */
> +static inline uint64_t
> +nir_variable_get_io_mask(nir_variable *var, gl_shader_stage stage)
>
Maybe "const nir_variable *var" instead?
I think I prefer if this function is not inlined. It calls at least
other function that is not inlined.
> +{
> + /* TODO: add support for tess patches */
> + if (var->data.patch || var->data.location < 0)
> + return 0;
> +
> + assert(var->data.mode == nir_var_shader_in ||
> + var->data.mode == nir_var_shader_out ||
> + var->data.mode == nir_var_system_value);
> + assert(var->data.location >= 0);
> +
> + const struct glsl_type *var_type = var->type;
> + if ((var->data.mode == nir_var_shader_in &&
> + (stage == MESA_SHADER_GEOMETRY ||
> + stage == MESA_SHADER_TESS_CTRL ||
> + stage == MESA_SHADER_TESS_EVAL)) ||
> + (var->data.mode == nir_var_shader_out &&
> + stage == MESA_SHADER_TESS_CTRL)) {
> + if (glsl_type_is_array(var_type))
> + var_type = glsl_get_array_element(var_type);
> + }
> +
> + unsigned slots = glsl_count_attribute_slots(var_type, false);
> + return ((1ull << slots) - 1) << var->data.location;
> +}
> +
> static inline bool
> nir_variable_is_global(const nir_variable *var)
> {
>
More information about the mesa-dev
mailing list