summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-07-19 14:37:21 +0200
committerSamuel Pitoiset <[email protected]>2017-07-31 13:53:40 +0200
commit6b9087a45dc4c21bb296110770c3e2b8d98cdb49 (patch)
treef552feec73f69bc360e668c30a1c88643bd24b21 /src/mesa
parentc8ea79272355caf134bf2750cc3b1f408d97d106 (diff)
mesa: add detach_shader_error() helper
And make detach_shader() always inline. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/shaderapi.c30
1 files changed, 21 insertions, 9 deletions
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... */