{ "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GL },
{ "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL },
{ "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL },
+ { "GL_EXT_texture_sRGB_decode", o(EXT_texture_sRGB_decode), GL },
{ "GL_EXT_texture_swizzle", o(EXT_texture_swizzle), GL },
{ "GL_EXT_texture_type_2_10_10_10_REV", o(dummy_true), ES2 },
{ "GL_EXT_timer_query", o(EXT_timer_query), GL },
ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
#if FEATURE_EXT_texture_sRGB
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
+ ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE;
#endif
ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
#if FEATURE_EXT_transform_feedback
}
}
+gl_format
+_mesa_get_srgb_format_linear(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_SRGB8:
+ format = MESA_FORMAT_RGB888;
+ break;
+ case MESA_FORMAT_SRGBA8:
+ format = MESA_FORMAT_RGBA8888;
+ break;
+ case MESA_FORMAT_SARGB8:
+ format = MESA_FORMAT_ARGB8888;
+ break;
+ case MESA_FORMAT_SL8:
+ format = MESA_FORMAT_L8;
+ break;
+ case MESA_FORMAT_SLA8:
+ format = MESA_FORMAT_AL88;
+ break;
+ case MESA_FORMAT_SRGB_DXT1:
+ format = MESA_FORMAT_RGB_DXT1;
+ break;
+ case MESA_FORMAT_SRGBA_DXT1:
+ format = MESA_FORMAT_RGBA_DXT1;
+ break;
+ case MESA_FORMAT_SRGBA_DXT3:
+ format = MESA_FORMAT_RGBA_DXT3;
+ break;
+ case MESA_FORMAT_SRGBA_DXT5:
+ format = MESA_FORMAT_RGBA_DXT5;
+ break;
+ default:
+ break;
+ }
+ return format;
+}
+
/**
* Return number of bytes needed to store an image of the given size
extern void
_mesa_test_formats(void);
+extern gl_format
+_mesa_get_srgb_format_linear(gl_format format);
+
#endif /* FORMATS_H */
GLboolean _Complete; /**< Is texture object complete? */
GLboolean _RenderToTexture; /**< Any rendering to this texture? */
GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
+ GLenum sRGBDecode;
/** Actual texture images, indexed by [cube face] and [mipmap level] */
struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
GLboolean EXT_texture_mirror_clamp;
GLboolean EXT_texture_shared_exponent;
GLboolean EXT_texture_sRGB;
+ GLboolean EXT_texture_sRGB_decode;
GLboolean EXT_texture_swizzle;
GLboolean EXT_transform_feedback;
GLboolean EXT_timer_query;
#include "texcompress_fxt1.h"
#include "texcompress_s3tc.h"
#include "texfetch.h"
+#include "teximage.h"
/**
_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
{
ASSERT(dims == 1 || dims == 2 || dims == 3);
+ GLuint format = texImage->TexFormat;
+ 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(texImage->TexFormat, dims);
+ _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);
+ }
+ }
+ }
+}
extern void
_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims);
+void
+_mesa_update_fetch_functions(struct gl_texture_object *texObj);
#endif
obj->Swizzle[2] = GL_BLUE;
obj->Swizzle[3] = GL_ALPHA;
obj->_Swizzle = SWIZZLE_NOOP;
+ obj->sRGBDecode = GL_DECODE_EXT;
}
#include "main/texparam.h"
#include "main/teximage.h"
#include "main/texstate.h"
+#include "main/texfetch.h"
#include "program/prog_instruction.h"
}
_mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
return GL_FALSE;
-
+ case GL_TEXTURE_SRGB_DECODE_EXT:
+ if (ctx->Extensions.EXT_texture_sRGB_decode) {
+ GLenum decode = params[0];
+ if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) {
+ if (texObj->sRGBDecode != decode) {
+ flush(ctx, texObj);
+ texObj->sRGBDecode = decode;
+ _mesa_update_fetch_functions(texObj);
+ }
+ return GL_TRUE;
+ }
+ }
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
+ return GL_FALSE;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
}
case GL_TEXTURE_COMPARE_MODE_ARB:
case GL_TEXTURE_COMPARE_FUNC_ARB:
case GL_DEPTH_TEXTURE_MODE_ARB:
+ case GL_TEXTURE_SRGB_DECODE_EXT:
{
/* convert float param to int */
GLint p[4];
case GL_TEXTURE_COMPARE_MODE_ARB:
case GL_TEXTURE_COMPARE_FUNC_ARB:
case GL_DEPTH_TEXTURE_MODE_ARB:
+ case GL_TEXTURE_SRGB_DECODE_EXT:
{
/* convert float param to int */
GLint p[4];