[Mesa-dev] [PATCH 1/7] nir: add nir_var_all enum

Jason Ekstrand jason at jlekstrand.net
Fri Nov 6 15:24:52 PST 2015


On Fri, Nov 6, 2015 at 8:35 AM, Rob Clark <robdclark at gmail.com> wrote:
> Otherwise, passing -1 gets you:
>
>   error: invalid conversion from 'int' to 'nir_variable_mode' [-fpermissive]
>
> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
> I was going to convert the enum values to bitmask/flags which could
> be OR'd, but that doesn't play nicely w/ nir_variable::data which
> tries to stuff this into a 4 bit bitfield.. so just re-sending this
> one as-is since it's at least good enough to fix a compiler warn.

Bah!  Oh, well, makes sense.

Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

>
>  src/glsl/nir/nir.c                  | 4 ++++
>  src/glsl/nir/nir.h                  | 1 +
>  src/glsl/nir/nir_lower_io.c         | 2 +-
>  src/mesa/drivers/dri/i965/brw_nir.c | 3 ++-
>  4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index bb7a5fa..e1e3f0c 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -107,6 +107,10 @@ void
>  nir_shader_add_variable(nir_shader *shader, nir_variable *var)
>  {
>     switch (var->data.mode) {
> +   case nir_var_all:
> +      assert(!"invalid mode");
> +      break;
> +
>     case nir_var_local:
>        assert(!"nir_shader_add_variable cannot be used for local variables");
>        break;
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index ef39df5..e2d75df 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -82,6 +82,7 @@ typedef struct {
>  } nir_state_slot;
>
>  typedef enum {
> +   nir_var_all = -1,
>     nir_var_shader_in,
>     nir_var_shader_out,
>     nir_var_global,
> diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
> index 688b48f..b4ed857 100644
> --- a/src/glsl/nir/nir_lower_io.c
> +++ b/src/glsl/nir/nir_lower_io.c
> @@ -176,7 +176,7 @@ nir_lower_io_block(nir_block *block, void *void_state)
>
>        nir_variable_mode mode = intrin->variables[0]->var->data.mode;
>
> -      if (state->mode != -1 && state->mode != mode)
> +      if (state->mode != nir_var_all && state->mode != mode)
>           continue;
>
>        switch (intrin->intrinsic) {
> diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c
> index dece208..07cb476 100644
> --- a/src/mesa/drivers/dri/i965/brw_nir.c
> +++ b/src/mesa/drivers/dri/i965/brw_nir.c
> @@ -270,7 +270,8 @@ brw_create_nir(struct brw_context *brw,
>     nir_assign_var_locations(&nir->uniforms,
>                              &nir->num_uniforms,
>                              is_scalar ? type_size_scalar : type_size_vec4);
> -   nir_lower_io(nir, -1, is_scalar ? type_size_scalar : type_size_vec4);
> +   nir_lower_io(nir, nir_var_all,
> +                is_scalar ? type_size_scalar : type_size_vec4);
>     nir_validate_shader(nir);
>
>     nir_remove_dead_variables(nir);
> --
> 2.5.0
>


More information about the mesa-dev mailing list