From: Samuel Pitoiset Date: Wed, 19 Jul 2017 12:37:21 +0000 (+0200) Subject: mesa: add detach_shader_error() helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6b9087a45dc4c21bb296110770c3e2b8d98cdb49;p=mesa.git mesa: add detach_shader_error() helper And make detach_shader() always inline. Signed-off-by: Samuel Pitoiset Reviewed-by: Timothy Arceri --- diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index c6e90edc944..29e2ed75a5a 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -423,16 +423,21 @@ delete_shader(struct gl_context *ctx, GLuint shader) } -static void -detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) +static ALWAYS_INLINE void +detach_shader(struct gl_context *ctx, GLuint program, GLuint shader, + bool no_error) { struct gl_shader_program *shProg; GLuint n; GLuint i, j; - shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); - if (!shProg) - return; + if (!no_error) { + shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); + if (!shProg) + return; + } else { + shProg = _mesa_lookup_shader_program(ctx, program); + } n = shProg->NumShaders; @@ -480,7 +485,7 @@ detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) } /* not found */ - { + if (!no_error) { GLenum err; if (is_shader(ctx, shader) || is_program(ctx, shader)) err = GL_INVALID_OPERATION; @@ -492,6 +497,13 @@ detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) } +static void +detach_shader_error(struct gl_context *ctx, GLuint program, GLuint shader) +{ + detach_shader(ctx, program, shader, false); +} + + /** * Return list of shaders attached to shader program. */ @@ -1499,7 +1511,7 @@ void GLAPIENTRY _mesa_DetachObjectARB(GLhandleARB program, GLhandleARB shader) { GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); + detach_shader_error(ctx, program, shader); } @@ -1507,7 +1519,7 @@ void GLAPIENTRY _mesa_DetachShader(GLuint program, GLuint shader) { GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); + detach_shader_error(ctx, program, shader); } @@ -2344,7 +2356,7 @@ _mesa_CreateShaderProgramv(GLenum type, GLsizei count, if (compiled) { attach_shader_err(ctx, program, shader, "glCreateShaderProgramv"); _mesa_link_program(ctx, shProg); - detach_shader(ctx, program, shader); + detach_shader_error(ctx, program, shader); #if 0 /* Possibly... */