[Mesa-dev] [Mesa-dev, 4/4] i965/nir: Support gl_WorkGroupID variable

Kristian Høgsberg krh at bitplanet.net
Thu Sep 10 12:30:17 PDT 2015


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

> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
>
> ---
> 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 711ace6..a0b20c4 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -347,6 +347,13 @@ emit_system_values_block(nir_block *block, void *void_visitor)
>              *reg = *v->emit_cs_local_invocation_id_setup();
>           break;
>  
> +      case nir_intrinsic_load_work_group_id:
> +         assert(v->stage == MESA_SHADER_COMPUTE);
> +         reg = &v->nir_system_values[SYSTEM_VALUE_WORK_GROUP_ID];
> +         if (reg->file == BAD_FILE)
> +            *reg = *v->emit_cs_work_group_id_setup();
> +         break;
> +
>
>        default:
>           break;
>        }
> @@ -1581,6 +1588,15 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
>        break;
>     }
>  
> +   case nir_intrinsic_load_work_group_id: {
> +      fs_reg work_group_id = nir_system_values[SYSTEM_VALUE_WORK_GROUP_ID];
> +      assert(work_group_id.file != BAD_FILE);
> +      dest.type = work_group_id.type;
> +      for (unsigned i = 0; i < 3; i++)
> +         bld.MOV(offset(dest, bld, i), offset(work_group_id, bld, i));
> +      break;
> +   }
> +

With nir_intrinsic_load_local_invocation_id and
nir_intrinsic_load_work_group_id added to
nir_system_value_from_intrinsic() you can group those two cases
together, similiar to how we group the various VS built-ins.

With that,

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

>     case nir_intrinsic_barrier:
>        assert(stage == MESA_SHADER_COMPUTE);
>        emit_barrier();


More information about the mesa-dev mailing list