<div dir="ltr"><div>I think I mentioned this at least once before, but I don't think that this is a good long-term solution. The nir_lower_io function does two things primarily. 1) It assigns each variable a "device location" and 2) changes the variable loads to loads with an offset. In the long-term, I think we want to split 1) out and let the backend control what "device location" gets assigned to each input/output. Then, add a knob to 2) to select how we want things packed. Doing this will let us avoid this whole re-mapping mess and, in the case of uniforms, better control things so that we can push some of them. That said, this is *not* a NAK of the current patch. If you want to hold off on that for a while, this looks ok.<br></div>--Jason<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 9, 2015 at 1:58 AM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 23 ++++++++++++++++++++++-<br>
1 file changed, 22 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
index 3baafc4..1734d03 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
@@ -199,11 +199,32 @@ fs_visitor::nir_setup_inputs(nir_shader *shader)<br>
struct hash_entry *entry;<br>
hash_table_foreach(shader->inputs, entry) {<br>
nir_variable *var = (nir_variable *) entry->data;<br>
+ enum brw_reg_type type = brw_type_for_base_type(var->type);<br>
fs_reg input = offset(nir_inputs, var->data.driver_location);<br>
<br>
fs_reg reg;<br>
switch (stage) {<br>
- case MESA_SHADER_VERTEX:<br>
+ case MESA_SHADER_VERTEX: {<br>
+ /* Our ATTR file is indexed by VERT_ATTRIB_*, which is the value<br>
+ * stored in nir_variable::location.<br>
+ *<br>
+ * However, NIR's load_input intrinsics use a different index - an<br>
+ * offset into a single contiguous array containing all inputs.<br>
+ * This index corresponds to the nir_variable::driver_location field.<br>
+ *<br>
+ * So, we need to copy from fs_reg(ATTR, var->location) to<br>
+ * offset(nir_inputs, var->data.driver_location).<br>
+ */<br>
+ unsigned components = var->type->without_array()->components();<br>
+ unsigned array_length = var->type->is_array() ? var->type->length : 1;<br>
+ for (unsigned i = 0; i < array_length; i++) {<br>
+ for (unsigned j = 0; j < components; j++) {<br>
+ emit(MOV(retype(offset(input, components * i + j), type),<br>
+ offset(fs_reg(ATTR, var->data.location + i, type), j)));<br>
+ }<br>
+ }<br>
+ break;<br>
+ }<br>
case MESA_SHADER_GEOMETRY:<br>
case MESA_SHADER_COMPUTE:<br>
unreachable("fs_visitor not used for these stages yet.");<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.2.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>