[Mesa-dev] [Mesa-dev, 7/7] i965/nir: Support gl_LocalInvocationID variable

Kristian Høgsberg krh at bitplanet.net
Thu Sep 10 11:42:10 PDT 2015


Jordan Justen <jordan.l.justen at intel.com> writes:

> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>

Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

>
> ---
> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 5549a2d..711ace6 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -340,6 +340,13 @@ emit_system_values_block(nir_block *block, void *void_visitor)
>                                   BRW_REGISTER_TYPE_D));
>           break;
>  
> +      case nir_intrinsic_load_local_invocation_id:
> +         assert(v->stage == MESA_SHADER_COMPUTE);
> +         reg = &v->nir_system_values[SYSTEM_VALUE_LOCAL_INVOCATION_ID];
> +         if (reg->file == BAD_FILE)
> +            *reg = *v->emit_cs_local_invocation_id_setup();
> +         break;
> +
>        default:
>           break;
>        }
> @@ -1580,6 +1587,15 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
>        ((struct brw_cs_prog_data *) prog_data)->uses_barrier = true;
>        break;
>  
> +   case nir_intrinsic_load_local_invocation_id: {
> +      fs_reg local_invocation_id = nir_system_values[SYSTEM_VALUE_LOCAL_INVOCATION_ID];
> +      assert(local_invocation_id.file != BAD_FILE);
> +      dest.type = local_invocation_id.type;
> +      for (unsigned i = 0; i < 3; i++)
> +         bld.MOV(offset(dest, bld, i), offset(local_invocation_id, bld, i));
> +      break;
> +   }
> +
>     default:
>        unreachable("unknown intrinsic");
>     }


More information about the mesa-dev mailing list