[Mesa-dev] [PATCH 3/3] i965: Ignore GL_SKIP_DECODE_EXT for textures accessed via texelFetch().
Kenneth Graunke
kenneth at whitecape.org
Wed Oct 11 19:15:29 UTC 2017
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
---
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 5e0fcafbce1..b62d1e22a12 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -456,6 +456,7 @@ brw_update_texture_surface(struct gl_context *ctx,
unsigned unit,
uint32_t *surf_offset,
bool for_gather,
+ bool for_txf,
uint32_t plane)
{
struct brw_context *brw = brw_context(ctx);
@@ -501,6 +502,7 @@ brw_update_texture_surface(struct gl_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 */
@@ -1152,10 +1154,12 @@ update_stage_texture_surfaces(struct brw_context *brw,
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);
}
}
}
--
2.14.2
More information about the mesa-dev
mailing list