A gather push constant table entry is able to fetch in 128-bit
increments from the constant buffer. A channel mask is provided to
narrow down which channels are loaded in that entry. This patch
generates the mask for enabled entries only.

The ir_swizzle visitor which is run prior this function determines
which registers are loaded in the push constant array. This function
basically walks the live registers and appends the live entries
in the channel mask.

Signed-off-by: Abdiel Janulgue <abdiel.janul...@linux.intel.com>
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 9a73691..8a03581 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2170,6 +2170,25 @@ fs_visitor::assign_constant_locations()
             continue;
 
          int constant_nr = inst->src[i].reg + inst->src[i].reg_offset;
+         for (unsigned int p = 0; p < stage_prog_data->nr_gather_table; p++) {
+            if (stage_prog_data->gather_table[p].reg == inst->src[i].reg) {
+               /* Is the constant a uniform or a ubo? */
+               unsigned offset = (constant_nr < (int) uniforms) ?
+                  (constant_nr % 4): inst->src[i].reg_offset;
+               /* Generate the channel mask to determine which entries 
starting from
+                * the offset above should be packed into the 16-byte entry. If 
the
+                * offset is aligned to a 16-byte boundary, just set the 
position based on
+                * the reg_offset. Otherwise, set the mask based on the positon 
of the offset
+                * from the boundary.
+                */
+               unsigned mask = ((prog_data->gather_table[p].const_offset % 16) 
== 0) ?
+                  1 << offset : 1 << ((prog_data->gather_table[p].const_offset 
% 16) / 4);
+
+               stage_prog_data->gather_table[p].channel_mask |= mask;
+               break;
+            }
+         }
+
          if (constant_nr >= 0 && constant_nr < (int) total_uniforms)
             is_live[constant_nr] = true;
       }
-- 
1.9.1

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

Reply via email to