This implementation sets up a map of output variable offsets to output indexes
and types.

This map will then be queried when processing store_output intrinsic operations,
to use it as an index into the output_reg array where the output registers are
stored. The original type of the variable is also mapped, as it has to be
transferred to the output register.

The array map setup is fundamentally similar to how fs_nir does.

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 | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index be47c82..673df4e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -412,6 +412,8 @@ public:
    virtual void nir_emit_texture(nir_tex_instr *instr);
 
    src_reg *nir_inputs;
+   int *nir_outputs;
+   brw_reg_type *nir_output_types;
 
 protected:
    void emit_vertex();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index c2342b6..2d457a6 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -88,7 +88,19 @@ vec4_visitor::nir_setup_inputs(nir_shader *shader)
 void
 vec4_visitor::nir_setup_outputs(nir_shader *shader)
 {
-   /* @TODO: Not yet implemented */
+   nir_outputs = ralloc_array(mem_ctx, int, shader->num_outputs);
+   nir_output_types = ralloc_array(mem_ctx, brw_reg_type, shader->num_outputs);
+
+   foreach_list_typed(nir_variable, var, node, &shader->outputs) {
+      int offset = var->data.driver_location;
+      unsigned size = type_size(var->type);
+      brw_reg_type type = brw_type_for_base_type(var->type);
+
+      for (unsigned i = 0; i < size; i++) {
+         nir_outputs[offset + i] = var->data.location + i;
+         nir_output_types[offset + i] = type;
+      }
+   }
 }
 
 void
-- 
2.1.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to