From 5521dc2477f109d2fbe77c6c70be44974900d356 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 25 May 2017 12:18:45 +0200 Subject: mesa: add KHR_no_error support for glActiveTexture() Signed-off-by: Samuel Pitoiset Reviewed-by: Ian Romanick --- src/mesa/main/texstate.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'src/mesa/main/texstate.c') diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 1aac3cdbd8b..1949ec2a849 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -279,14 +279,12 @@ calculate_derived_texenv( struct gl_tex_env_combine_state *state, } - - /* GL_ARB_multitexture */ -void GLAPIENTRY -_mesa_ActiveTexture(GLenum texture) +static ALWAYS_INLINE void +active_texture(GLenum texture, bool no_error) { const GLuint texUnit = texture - GL_TEXTURE0; - GLuint k; + GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) @@ -296,14 +294,16 @@ _mesa_ActiveTexture(GLenum texture) if (ctx->Texture.CurrentUnit == texUnit) return; - k = _mesa_max_tex_unit(ctx); + if (!no_error) { + GLuint k = _mesa_max_tex_unit(ctx); - assert(k <= ARRAY_SIZE(ctx->Texture.Unit)); + assert(k <= ARRAY_SIZE(ctx->Texture.Unit)); - if (texUnit >= k) { - _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", - _mesa_enum_to_string(texture)); - return; + if (texUnit >= k) { + _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", + _mesa_enum_to_string(texture)); + return; + } } FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); @@ -316,6 +316,20 @@ _mesa_ActiveTexture(GLenum texture) } +void GLAPIENTRY +_mesa_ActiveTexture_no_error(GLenum texture) +{ + active_texture(texture, true); +} + + +void GLAPIENTRY +_mesa_ActiveTexture(GLenum texture) +{ + active_texture(texture, false); +} + + /* GL_ARB_multitexture */ void GLAPIENTRY _mesa_ClientActiveTexture(GLenum texture) -- cgit v1.2.3