We had an approximation that was assuming any ddx or tex instruction
needed helper invocations, but that's not true for texelFetch() or
textureSize(). It also meant that we were setting PIXLOD on vertex and
compute shaders doing texturing, which doesn't really make sense.
shader-db (with a hack to log pixlod):
total pixlod in shared programs: 582 -> 573 (-1.55%)
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2681
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4308>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4308>
/* Collect sampling instructions eligible for pre-dispatch. */
collect_tex_prefetches(ctx, ir);
+ if (so->type == MESA_SHADER_FRAGMENT &&
+ ctx->s->info.fs.needs_helper_invocations)
+ so->need_pixlod = true;
+
out:
if (ret) {
if (so->ir)
if (is_tex_or_prefetch(n)) {
regmask_set(&state->needs_sy, n->regs[0]);
- ctx->so->need_pixlod = true;
if (n->opc == OPC_META_TEX_PREFETCH)
has_tex_prefetch = true;
} else if (n->opc == OPC_RESINFO) {
nir_ssa_def *foo = nir_fddx(b, sij);
nir_ssa_def *bar = nir_fddy(b, sij);
+ if (b->shader->info.stage == MESA_SHADER_FRAGMENT)
+ b->shader->info.fs.needs_helper_invocations = true;
+
nir_ssa_def *x, *y, *z, *i, *j;
x = nir_ffma(b, chan(off, 0), chan(foo, 0), chan(sij, 0));