summaryrefslogtreecommitdiff
path: root/src/mesa/main/shaderapi.c
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-10-11 16:07:08 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-10-27 13:35:53 -0700
commit75c6f472880706dcbb9d1e20727fa8f71db8b11c (patch)
treefae106114612981994bbfb5642aec517929de47b /src/mesa/main/shaderapi.c
parent01abcf3b79c9ba18fef2de423b51e7e1f9bb1b3f (diff)
mesa: Track an ActiveProgram distinct from CurrentProgram
ActiveProgram is the GL_EXT_separate_shader_objects state variable used for glUniform calls. glUseProgram also sets this.
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r--src/mesa/main/shaderapi.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 968db07e9c..26c9a181aa 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -117,6 +117,7 @@ void
_mesa_free_shader_state(struct gl_context *ctx)
{
_mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram, NULL);
+ _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
}
@@ -607,8 +608,8 @@ static GLuint
get_handle(struct gl_context *ctx, GLenum pname)
{
if (pname == GL_PROGRAM_OBJECT_ARB) {
- if (ctx->Shader.CurrentProgram)
- return ctx->Shader.CurrentProgram->Name;
+ if (ctx->Shader.ActiveProgram)
+ return ctx->Shader.ActiveProgram->Name;
else
return 0;
}
@@ -908,6 +909,24 @@ print_shader_info(const struct gl_shader_program *shProg)
/**
+ * Use the named shader program for subsequent glUniform calls
+ */
+static void
+active_program(struct gl_context *ctx, struct gl_shader_program *shProg,
+ const char *caller)
+{
+ if ((shProg != NULL) && !shProg->LinkStatus) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(program %u not linked)", caller, shProg->Name);
+ return;
+ }
+
+ if (ctx->Shader.ActiveProgram != shProg) {
+ _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, shProg);
+ }
+}
+
+/**
* Use the named shader program for subsequent rendering.
*/
void
@@ -940,6 +959,8 @@ _mesa_use_program(struct gl_context *ctx, GLuint program)
return;
}
+ active_program(ctx, shProg, "glUseProgram");
+
/* debug code */
if (ctx->Shader.Flags & GLSL_USE_PROG) {
print_shader_info(shProg);
@@ -1657,18 +1678,11 @@ void GLAPIENTRY
_mesa_ActiveProgramEXT(GLuint program)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_shader_program *shProg;
-
- shProg = _mesa_lookup_shader_program_err(ctx, program,
- "glActiveProgramEXT");
- if (!shProg->LinkStatus) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glActiveProgramEXT(program not linked)");
- return;
- }
+ struct gl_shader_program *shProg = (program != 0)
+ ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT")
+ : NULL;
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glActiveProgramEXT(NOT YET IMPLEMENTED)");
+ active_program(ctx, shProg, "glActiveProgramEXT");
return;
}