diff options
author | Pauli Nieminen <[email protected]> | 2012-06-12 21:38:47 +0300 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2012-08-01 15:31:16 -0700 |
commit | 765509903b3c560f9c19169d736f284480e88942 (patch) | |
tree | ae67f14a96b8042a676e9bc3f4fcf7561014a734 | |
parent | c37efbfe4c415b6fd2d4f968220d7c9b62f11ecf (diff) |
mesa/samplerobj: Support EXT_texture_sRGB_decode
sRGBDecode state is part of sampler object state but mesa was missing
handlers to access the state. This patch adds the support for required
state changes and queries.
GL_EXT_texture_sRGB_decode issue 4:
"4) Should we add forward-looking support for ARB_sampler_objects?
RESOLVED: YES
If ARB_sampler_objects exists in the implementation, the sampler
objects should also include this parameter per sampler."
Fixes piglit GL_ARB_sampler_objects/GL_EXT_texture_sRGB_decode.
Signed-off-by: Pauli Nieminen <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r-- | src/mesa/main/samplerobj.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c index 8c54c9a4c34..5bb90cf72f0 100644 --- a/src/mesa/main/samplerobj.c +++ b/src/mesa/main/samplerobj.c @@ -582,6 +582,23 @@ set_sampler_cube_map_seamless(struct gl_context *ctx, return GL_TRUE; } +static GLuint +set_sampler_srgb_decode(struct gl_context *ctx, + struct gl_sampler_object *samp, GLenum param) +{ + if (!ctx->Extensions.EXT_texture_sRGB_decode) + return INVALID_PNAME; + + if (samp->sRGBDecode == param) + return GL_FALSE; + + if (param != GL_DECODE_EXT && param != GL_SKIP_DECODE_EXT) + return INVALID_VALUE; + + flush(ctx); + samp->sRGBDecode = param; + return GL_TRUE; +} static void GLAPIENTRY _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) @@ -634,6 +651,9 @@ _mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param) case GL_TEXTURE_CUBE_MAP_SEAMLESS: res = set_sampler_cube_map_seamless(ctx, sampObj, param); break; + case GL_TEXTURE_SRGB_DECODE_EXT: + res = set_sampler_srgb_decode(ctx, sampObj, param); + break; case GL_TEXTURE_BORDER_COLOR: /* fall-through */ default: @@ -718,6 +738,9 @@ _mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) case GL_TEXTURE_CUBE_MAP_SEAMLESS: res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) param); break; + case GL_TEXTURE_SRGB_DECODE_EXT: + res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) param); + break; case GL_TEXTURE_BORDER_COLOR: /* fall-through */ default: @@ -799,6 +822,9 @@ _mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params) case GL_TEXTURE_CUBE_MAP_SEAMLESS: res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); break; + case GL_TEXTURE_SRGB_DECODE_EXT: + res = set_sampler_srgb_decode(ctx, sampObj, params[0]); + break; case GL_TEXTURE_BORDER_COLOR: { GLfloat c[4]; @@ -890,6 +916,9 @@ _mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params) case GL_TEXTURE_CUBE_MAP_SEAMLESS: res = set_sampler_cube_map_seamless(ctx, sampObj, (GLboolean) params[0]); break; + case GL_TEXTURE_SRGB_DECODE_EXT: + res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]); + break; case GL_TEXTURE_BORDER_COLOR: res = set_sampler_border_colorf(ctx, sampObj, params); break; @@ -972,6 +1001,9 @@ _mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params) case GL_TEXTURE_CUBE_MAP_SEAMLESS: res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); break; + case GL_TEXTURE_SRGB_DECODE_EXT: + res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]); + break; case GL_TEXTURE_BORDER_COLOR: res = set_sampler_border_colori(ctx, sampObj, params); break; @@ -1055,6 +1087,9 @@ _mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params) case GL_TEXTURE_CUBE_MAP_SEAMLESS: res = set_sampler_cube_map_seamless(ctx, sampObj, params[0]); break; + case GL_TEXTURE_SRGB_DECODE_EXT: + res = set_sampler_srgb_decode(ctx, sampObj, (GLenum) params[0]); + break; case GL_TEXTURE_BORDER_COLOR: res = set_sampler_border_colorui(ctx, sampObj, params); break; @@ -1149,6 +1184,11 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params) goto invalid_pname; *params = sampObj->CubeMapSeamless; break; + case GL_TEXTURE_SRGB_DECODE_EXT: + if (!ctx->Extensions.EXT_texture_sRGB_decode) + goto invalid_pname; + *params = (GLenum) sampObj->sRGBDecode; + break; default: goto invalid_pname; } @@ -1222,6 +1262,11 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params) goto invalid_pname; *params = (GLfloat) sampObj->CubeMapSeamless; break; + case GL_TEXTURE_SRGB_DECODE_EXT: + if (!ctx->Extensions.EXT_texture_sRGB_decode) + goto invalid_pname; + *params = (GLfloat) sampObj->sRGBDecode; + break; default: goto invalid_pname; } @@ -1296,6 +1341,11 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params) goto invalid_pname; *params = sampObj->CubeMapSeamless; break; + case GL_TEXTURE_SRGB_DECODE_EXT: + if (!ctx->Extensions.EXT_texture_sRGB_decode) + goto invalid_pname; + *params = (GLenum) sampObj->sRGBDecode; + break; default: goto invalid_pname; } @@ -1370,6 +1420,11 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params) goto invalid_pname; *params = sampObj->CubeMapSeamless; break; + case GL_TEXTURE_SRGB_DECODE_EXT: + if (!ctx->Extensions.EXT_texture_sRGB_decode) + goto invalid_pname; + *params = (GLenum) sampObj->sRGBDecode; + break; default: goto invalid_pname; } |