freedreno/ir3: force i/j pixel to r0.x
authorRob Clark <robdclark@chromium.org>
Fri, 11 Oct 2019 02:36:30 +0000 (19:36 -0700)
committerRob Clark <robdclark@gmail.com>
Fri, 18 Oct 2019 21:11:54 +0000 (21:11 +0000)
It seems that pre-fs texture fetch only works if ij_pix ends up in r0.x.
I've tried unknown zero bits, to no avail, and blob also seems to force
r0.x when this feature is used.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
src/freedreno/ir3/ir3_compiler_nir.c

index 38c60f8cfe698324bf5dc0da041b1b625dac85b7..5b1adf29e3dcc7877dd433278933fd666e305099 100644 (file)
@@ -3211,6 +3211,28 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
                ctx->primitive_id->regs[0]->num = 1;
                struct ir3_instruction *precolor[] = { ctx->gs_header, ctx->primitive_id };
                ret = ir3_ra(so, precolor, ARRAY_SIZE(precolor));
+       } else if (so->num_sampler_prefetch) {
+               assert(so->type == MESA_SHADER_FRAGMENT);
+               struct ir3_instruction *precolor[2];
+               int idx = 0;
+
+               for (unsigned i = 0; i < ir->ninputs; i++) {
+                       struct ir3_instruction *instr = ctx->ir->inputs[i];
+
+                       if (!instr)
+                               continue;
+
+                       if (instr->input.sysval != SYSTEM_VALUE_BARYCENTRIC_PIXEL)
+                               continue;
+
+                       assert(idx < ARRAY_SIZE(precolor));
+
+                       precolor[idx] = instr;
+                       instr->regs[0]->num = idx;
+
+                       idx++;
+               }
+               ret = ir3_ra(so, precolor, idx);
        } else {
                ret = ir3_ra(so, NULL, 0);
        }