[Mesa-dev] [PATCH] i965/nir/fs: removed unneeded support for global variables

Kenneth Graunke kenneth at whitecape.org
Thu Jul 16 16:23:25 PDT 2015


On Friday, June 26, 2015 01:47:48 PM Alejandro PiƱeiro wrote:
> As functions are inlined, and nir_lower_global_vars_to_local gets
> run, all global variables are lowered to local variables.
> ---
> 
> Jason Enkstrand already confirmed that global support is not needed
> on the bug open for the nir/vec4 support:
> https://bugs.freedesktop.org/show_bug.cgi?id=89580#c9
> 
> So this patch just apply that answer to the fs path. 
> 
> Full piglit run. No regressions.
> 
>  src/mesa/drivers/dri/i965/brw_fs.h           |  1 -
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp     | 14 ++------------
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 -
>  3 files changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
> index 243baf6..c49d0f8 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.h
> +++ b/src/mesa/drivers/dri/i965/brw_fs.h
> @@ -345,7 +345,6 @@ public:
>     unsigned max_grf;
>  
>     fs_reg *nir_locals;
> -   fs_reg *nir_globals;
>     fs_reg nir_inputs;
>     fs_reg nir_outputs;
>     fs_reg *nir_system_values;
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 59081ea..a648a5a 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -55,14 +55,6 @@ fs_visitor::emit_nir_code()
>  
>     nir_emit_system_values(nir);
>  
> -   nir_globals = ralloc_array(mem_ctx, fs_reg, nir->reg_alloc);
> -   foreach_list_typed(nir_register, reg, node, &nir->registers) {
> -      unsigned array_elems =
> -         reg->num_array_elems == 0 ? 1 : reg->num_array_elems;
> -      unsigned size = array_elems * reg->num_components;
> -      nir_globals[reg->index] = bld.vgrf(BRW_REGISTER_TYPE_F, size);
> -   }
> -
>     /* get the main function and emit it */
>     nir_foreach_overload(nir, overload) {
>        assert(strcmp(overload->function->name, "main") == 0);
> @@ -1151,10 +1143,8 @@ fs_reg_for_nir_reg(fs_visitor *v, nir_register *nir_reg,
>                     unsigned base_offset, nir_src *indirect)
>  {
>     fs_reg reg;
> -   if (nir_reg->is_global)
> -      reg = v->nir_globals[nir_reg->index];
> -   else
> -      reg = v->nir_locals[nir_reg->index];
> +

Perhaps include a sanity check:

   assert(!nir_reg->is_global);

Either way,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

> +   reg = v->nir_locals[nir_reg->index];
>  
>     reg = offset(reg, base_offset * nir_reg->num_components);
>     if (indirect) {
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index 9a4bad6..90d5706 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -2012,7 +2012,6 @@ fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
>     this->no16_msg = NULL;
>  
>     this->nir_locals = NULL;
> -   this->nir_globals = NULL;
>  
>     memset(&this->payload, 0, sizeof(this->payload));
>     memset(this->outputs, 0, sizeof(this->outputs));
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150716/da9200a3/attachment.sig>


More information about the mesa-dev mailing list