X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Ftexfetch.c;h=8aa1e4970d5feb88c8e49b512adad55b557f73dc;hb=751fe9058bc15f4f8608f0fdc02209542991ff23;hp=77bbc91795f23b0855b2166eb5af0cf90af9a141;hpb=cd1cf788280a1eb10d54e1a2b8b069ed7b89c724;p=mesa.git diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index 77bbc91795f..8aa1e4970d5 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -39,6 +39,7 @@ #include "texcompress_fxt1.h" #include "texcompress_s3tc.h" #include "texfetch.h" +#include "teximage.h" /** @@ -759,7 +760,7 @@ texfetch_funcs[MESA_FORMAT_COUNT] = }; -static FetchTexelFuncF +FetchTexelFuncF _mesa_get_texel_fetch_func(gl_format format, GLuint dims) { #ifdef DEBUG @@ -857,13 +858,36 @@ fetch_texel_chan_to_float(const struct gl_texture_image *texImage, void _mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims) { + gl_format format = texImage->TexFormat; + ASSERT(dims == 1 || dims == 2 || dims == 3); - texImage->FetchTexelf = - _mesa_get_texel_fetch_func(texImage->TexFormat, dims); + if (texImage->TexObject->sRGBDecode == GL_SKIP_DECODE_EXT && + _mesa_get_format_color_encoding(format) == GL_SRGB) { + format = _mesa_get_srgb_format_linear(format); + } + + texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims); texImage->FetchTexelc = fetch_texel_float_to_chan; ASSERT(texImage->FetchTexelc); ASSERT(texImage->FetchTexelf); } + +void +_mesa_update_fetch_functions(struct gl_texture_object *texObj) +{ + GLuint face, i; + GLuint dims; + + dims = _mesa_get_texture_dimensions(texObj->Target); + + for (face = 0; face < 6; face++) { + for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + if (texObj->Image[face][i]) { + _mesa_set_fetch_functions(texObj->Image[face][i], dims); + } + } + } +}