The GL_EXT_texture_sRGB_decode spec says:
"The conversion of sRGB color space components to linear color space is
always performed if the texel lookup function is one of the texelFetch
builtin functions.
Otherwise, if the texel lookup function is one of the texture builtin
functions or one of the texture gather functions, the conversion of sRGB
color space components to linear color space is controlled by the
TEXTURE_SRGB_DECODE_EXT parameter.
If the TEXTURE_SRGB_DECODE_EXT parameter is DECODE_EXT, the conversion
of sRGB color space components to linear color space is performed.
If the TEXTURE_SRGB_DECODE_EXT parameter is SKIP_DECODE_EXT, the value
is returned without decoding. However, if the texture is also accessed
with a texelFetch function, then the result of texture builtin functions
and/or texture gather functions may be returned with decoding or without
decoding."
This patch makes i965 force sRGB decoding for any textures accessed via
texelFetch(). If textures are accessed via texelFetch() and a regular
texture access function, this will affect the other ones too - which is
fine - it's undefined according to the last paragraph quoted.
We could make both work, but we'd have to emit multiple SURFACE_STATEs,
and have two binding table sections, like we do for texture gather hacks
on older platforms.
Fixes the following Android O CTS test:
dEQP-GLES31.functional.srgb_texture_decode.skip_decode.srgba8.texel_fetch
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
unsigned unit,
uint32_t *surf_offset,
bool for_gather,
+ bool for_txf,
uint32_t plane)
{
struct brw_context *brw = brw_context(ctx);
mesa_format mesa_fmt = plane == 0 ? intel_obj->_Format : mt->format;
enum isl_format format = translate_tex_format(brw, mesa_fmt,
+ for_txf ? GL_DECODE_EXT :
sampler->sRGBDecode);
/* Implement gen6 and gen7 gather work-around */
if (prog->SamplersUsed & (1 << s)) {
const unsigned unit = prog->SamplerUnits[s];
+ const bool used_by_txf = prog->info.textures_used_by_txf & (1 << s);
/* _NEW_TEXTURE */
if (ctx->Texture.Unit[unit]._Current) {
- brw_update_texture_surface(ctx, unit, surf_offset + s, for_gather, plane);
+ brw_update_texture_surface(ctx, unit, surf_offset + s, for_gather,
+ used_by_txf, plane);
}
}
}