mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 22:20:14 +01:00
vc4: Use NIR lowering for sRGB decode.
This should get us the same decode code generated, but with a lot less custom code in the driver.
This commit is contained in:
parent
4b326341f3
commit
226bd92945
2 changed files with 3 additions and 40 deletions
|
|
@ -240,22 +240,6 @@ ntq_rsq(struct vc4_compile *c, struct qreg x)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct qreg
|
|
||||||
qir_srgb_decode(struct vc4_compile *c, struct qreg srgb)
|
|
||||||
{
|
|
||||||
struct qreg low = qir_FMUL(c, srgb, qir_uniform_f(c, 1.0 / 12.92));
|
|
||||||
struct qreg high = qir_POW(c,
|
|
||||||
qir_FMUL(c,
|
|
||||||
qir_FADD(c,
|
|
||||||
srgb,
|
|
||||||
qir_uniform_f(c, 0.055)),
|
|
||||||
qir_uniform_f(c, 1.0 / 1.055)),
|
|
||||||
qir_uniform_f(c, 2.4));
|
|
||||||
|
|
||||||
qir_SF(c, qir_FSUB(c, srgb, qir_uniform_f(c, 0.04045)));
|
|
||||||
return qir_SEL(c, QPU_COND_NS, low, high);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct qreg
|
static struct qreg
|
||||||
ntq_umul(struct vc4_compile *c, struct qreg src0, struct qreg src1)
|
ntq_umul(struct vc4_compile *c, struct qreg src0, struct qreg src1)
|
||||||
{
|
{
|
||||||
|
|
@ -326,11 +310,6 @@ ntq_emit_txf(struct vc4_compile *c, nir_tex_instr *instr)
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
dest[i] = qir_UNPACK_8_F(c, tex, i);
|
dest[i] = qir_UNPACK_8_F(c, tex, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
if (c->tex_srgb_decode[unit] & (1 << i))
|
|
||||||
dest[i] = qir_srgb_decode(c, dest[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -476,11 +455,6 @@ ntq_emit_tex(struct vc4_compile *c, nir_tex_instr *instr)
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
dest[i] = qir_UNPACK_8_F(c, tex, i);
|
dest[i] = qir_UNPACK_8_F(c, tex, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
if (c->tex_srgb_decode[unit] & (1 << i))
|
|
||||||
dest[i] = qir_srgb_decode(c, dest[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1864,16 +1838,10 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
|
||||||
} else {
|
} else {
|
||||||
tex_options.swizzles[i][j] = arb_swiz;
|
tex_options.swizzles[i][j] = arb_swiz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If ARB_texture_swizzle is reading from the R, G, or
|
|
||||||
* B channels of an sRGB texture, then we need to
|
|
||||||
* apply sRGB decode to this channel at sample time.
|
|
||||||
*/
|
|
||||||
if (arb_swiz < 3 && util_format_is_srgb(format)) {
|
|
||||||
c->tex_srgb_decode[i] |= (1 << j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if (util_format_is_srgb(format))
|
||||||
|
tex_options.lower_srgb |= (1 << i);
|
||||||
}
|
}
|
||||||
|
|
||||||
NIR_PASS_V(c->s, nir_normalize_cubemap_coords);
|
NIR_PASS_V(c->s, nir_normalize_cubemap_coords);
|
||||||
|
|
|
||||||
|
|
@ -379,11 +379,6 @@ struct vc4_compile {
|
||||||
|
|
||||||
uint8_t vattr_sizes[8];
|
uint8_t vattr_sizes[8];
|
||||||
|
|
||||||
/* Bitfield for whether a given channel of a sampler needs sRGB
|
|
||||||
* decode.
|
|
||||||
*/
|
|
||||||
uint8_t tex_srgb_decode[VC4_MAX_TEXTURE_SAMPLERS];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of the VARYING_SLOT_* of all FS QFILE_VARY reads.
|
* Array of the VARYING_SLOT_* of all FS QFILE_VARY reads.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue