[Mesa-dev] [PATCH v2 08/78] i965/nir/vec4: Add shader function implementation
Eduardo Lima Mitev
elima at igalia.com
Thu Jul 23 03:16:48 PDT 2015
It basically allocates registers local to a function in a nir_locals map,
then emits all its control-flow blocks.
---
src/mesa/drivers/dri/i965/brw_vec4.h | 1 +
src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index a1df216..e0698ee 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -411,6 +411,7 @@ public:
virtual dst_reg *make_reg_for_system_value(int location,
const glsl_type *type) = 0;
+ dst_reg *nir_locals;
src_reg *nir_inputs;
unsigned *nir_uniform_driver_location;
dst_reg *nir_system_values;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index c6f8126..f6b213e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -241,7 +241,16 @@ vec4_visitor::nir_setup_builtin_uniform(nir_variable *var)
void
vec4_visitor::nir_emit_impl(nir_function_impl *impl)
{
- /* @TODO: Not yet implemented */
+ nir_locals = ralloc_array(mem_ctx, dst_reg, impl->reg_alloc);
+
+ foreach_list_typed(nir_register, reg, node, &impl->registers) {
+ unsigned array_elems =
+ reg->num_array_elems == 0 ? 1 : reg->num_array_elems;
+
+ nir_locals[reg->index] = dst_reg(GRF, alloc.allocate(array_elems));
+ }
+
+ nir_emit_cf_list(&impl->body);
}
void
--
2.1.4
More information about the mesa-dev
mailing list