i965/nir/vec4: Add shader function implementation
authorEduardo Lima Mitev <elima@igalia.com>
Wed, 22 Jul 2015 07:34:35 +0000 (09:34 +0200)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 3 Aug 2015 16:40:47 +0000 (09:40 -0700)
It basically allocates registers local to a function in a nir_locals map,
then emits all its control-flow blocks.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_nir.cpp

index 722f9a1f4c5ed8893a3a5ac90d537d07533bf9b7..01f88e641e7f4231b35a8fee7d5fbeb48845e4c8 100644 (file)
@@ -414,6 +414,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;
index 989b8e3b6b5623361608b9346da01d68be960817..f8bcbb7cd4200eb41d581579b301e4ab1364f976 100644 (file)
@@ -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