[Mesa-dev] [PATCH 04/78] i965/nir/vec4: Add setup of input variables in NIR->vec4 pass
Jason Ekstrand
jason at jlekstrand.net
Mon Jun 29 15:55:31 PDT 2015
On Fri, Jun 26, 2015 at 1:06 AM, Eduardo Lima Mitev <elima at igalia.com> wrote:
> This implementation sets up a map of input variable offsets to source registers
> that are already initialized with the corresponding register offset.
>
> This map will then be queried when processing load_input intrinsic operations,
> to obtain the correct register source from which the input data will be loaded.
>
> This pattern of initializing an array map at setup time and then consuming it
> during instruction emission is common in fs_nir, while the actual offset
> calculations are taken from vec4_visitor.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89580
> ---
> src/mesa/drivers/dri/i965/brw_vec4.h | 2 ++
> src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 13 ++++++++++++-
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
> index 7f78e7f..be47c82 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4.h
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.h
> @@ -411,6 +411,8 @@ public:
> virtual void nir_emit_jump(nir_jump_instr *instr);
> virtual void nir_emit_texture(nir_tex_instr *instr);
>
> + src_reg *nir_inputs;
> +
> protected:
> void emit_vertex();
> void lower_attributes_to_hw_regs(const int *attribute_map,
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> index ae3b962..c2342b6 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> @@ -71,7 +71,18 @@ vec4_visitor::nir_setup_system_values(nir_shader *shader)
> void
> vec4_visitor::nir_setup_inputs(nir_shader *shader)
> {
> - /* @TODO: Not yet implemented */
> + nir_inputs = ralloc_array(mem_ctx, src_reg, shader->num_inputs);
> +
> + foreach_list_typed(nir_variable, var, node, &shader->inputs) {
> + int offset = var->data.driver_location;
> + unsigned size = type_size(var->type);
> + for (unsigned i = 0; i < size; i++) {
> + src_reg src = src_reg(ATTR, var->data.location + i, var->type);
> + src = retype(src, brw_type_for_base_type(var->type));
I looked at the src_reg constructor called and it turns out we don't
bother to set the actual type. We should do that in the src_reg
constructor instead of inserting a retype.
> + nir_inputs[offset] = src;
> + offset++;
> + }
> + }
> }
>
> void
> --
> 2.1.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list