[Mesa-dev] [HACK] i965/fs: Fix rescale_texcoord() for SIMD16 and remove no16 fall-back.

Francisco Jerez currojerez at riseup.net
Thu Jul 9 12:22:57 PDT 2015


Aside from the trivial GRF underallocation problem in the
"devinfo->gen < 6 && is_rect" if-block, the texrect scale uniform
look-up code was assuming a one-to-one mapping between UNIFORM
register indices and the param array, which only holds during the
SIMD8 run.

It seems dubious that this needs to manipulate the param array
directly even though it doesn't have a fixed meaning (all constants if
you're building SIMD8, push constants if you're building SIMD16).  We
would probably be better off not using the ancient state token
tracking stuff which forces you to recompile the program anytime a
sampler uniform binding changes and doesn't work at all for
ARB_gpu_shader5-style variable indexing of samplers.  Instead this
could be implemented like images do by passing sampler metadata
preemptively at a fixed offset from the sampler uniform that is later
on eliminated by the optimizer in case it's not needed.

This depends on another patch I sent a while ago "i965/fs: Don't
overwrite fs_visitor::uniforms and ::param_size during the SIMD16
run." [1].  No piglit regressions.

[1] http://lists.freedesktop.org/archives/mesa-dev/2015-May/083484.html
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 94d6a58..dcd2e4e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -708,17 +708,23 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
 	 0
       };
 
-      no16("rectangle scale uniform setup not supported on SIMD16\n");
-      if (dispatch_width == 16) {
-	 return coordinate;
-      }
-
       GLuint index = _mesa_add_state_reference(params,
 					       (gl_state_index *)tokens);
       /* Try to find existing copies of the texrect scale uniforms. */
       for (unsigned i = 0; i < uniforms; i++) {
-         if (stage_prog_data->param[i] ==
-             &prog->Parameters->ParameterValues[index][0]) {
+         /* Neat, there's an extra level of indirection between the fake
+          * UNIFORM file and the push/pull param arrays, but *only* during
+          * non-SIMD8 runs (i.e. SIMD16).
+          */
+         const gl_constant_value *param =
+            (dispatch_width == 8 ? stage_prog_data->param[i] :
+             push_constant_loc[i] >= 0 ?
+                stage_prog_data->param[push_constant_loc[i]] :
+             pull_constant_loc[i] >= 0 ?
+                stage_prog_data->pull_param[pull_constant_loc[i]] :
+             NULL);
+
+         if (param == &prog->Parameters->ParameterValues[index][0]) {
             scale_x = fs_reg(UNIFORM, i);
             scale_y = fs_reg(UNIFORM, i + 1);
             break;
@@ -727,6 +733,7 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
 
       /* If we didn't already set them up, do so now. */
       if (scale_x.file == BAD_FILE) {
+         assert(dispatch_width == 8);
          scale_x = fs_reg(UNIFORM, uniforms);
          scale_y = fs_reg(UNIFORM, uniforms + 1);
 
@@ -742,7 +749,7 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
     * tracking to get the scaling factor.
     */
    if (devinfo->gen < 6 && is_rect) {
-      fs_reg dst = fs_reg(GRF, alloc.allocate(coord_components));
+      fs_reg dst = bld.vgrf(BRW_REGISTER_TYPE_F, coord_components);
       fs_reg src = coordinate;
       coordinate = dst;
 
-- 
2.4.3



More information about the mesa-dev mailing list