summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/get.c2
-rw-r--r--src/mesa/main/mtypes.h13
-rw-r--r--src/mesa/main/shaderapi.c40
-rw-r--r--src/mesa/main/uniforms.c66
4 files changed, 73 insertions, 48 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 39ce177fcd3..da9df27bdb6 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1579,7 +1579,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
case GL_CURRENT_PROGRAM:
v->value_int =
- ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0;
+ ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0;
break;
case GL_READ_FRAMEBUFFER_BINDING_EXT:
v->value_int = ctx->ReadBuffer->Name;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index eb8accc8c8c..7863ef382de 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2141,7 +2141,18 @@ struct gl_shader_program
*/
struct gl_shader_state
{
- struct gl_shader_program *CurrentProgram; /**< The user-bound program */
+ /**
+ * Program used for rendering.
+ */
+ struct gl_shader_program *CurrentProgram;
+
+ /**
+ * Program used by glUniform calls.
+ *
+ * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
+ */
+ struct gl_shader_program *ActiveProgram;
+
void *MemPool;
GLbitfield Flags; /**< Mask of GLSL_x flags */
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 968db07e9c1..26c9a181aa0 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;
}
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 9359db18929..b5bae0337b2 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -1227,7 +1227,7 @@ void GLAPIENTRY
_mesa_Uniform1fARB(GLint location, GLfloat v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_FLOAT);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_FLOAT);
}
void GLAPIENTRY
@@ -1237,7 +1237,7 @@ _mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1)
GLfloat v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC2);
}
void GLAPIENTRY
@@ -1248,7 +1248,7 @@ _mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC3);
}
void GLAPIENTRY
@@ -1261,14 +1261,14 @@ _mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1iARB(GLint location, GLint v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_INT);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_INT);
}
void GLAPIENTRY
@@ -1278,7 +1278,7 @@ _mesa_Uniform2iARB(GLint location, GLint v0, GLint v1)
GLint v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC2);
}
void GLAPIENTRY
@@ -1289,7 +1289,7 @@ _mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC3);
}
void GLAPIENTRY
@@ -1301,63 +1301,63 @@ _mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT);
}
void GLAPIENTRY
_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC2);
}
void GLAPIENTRY
_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC3);
}
void GLAPIENTRY
_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT);
}
void GLAPIENTRY
_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC2);
}
void GLAPIENTRY
_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC3);
}
void GLAPIENTRY
_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC4);
}
@@ -1366,7 +1366,7 @@ void GLAPIENTRY
_mesa_Uniform1ui(GLint location, GLuint v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT);
}
void GLAPIENTRY
@@ -1376,7 +1376,7 @@ _mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1)
GLuint v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2);
}
void GLAPIENTRY
@@ -1387,7 +1387,7 @@ _mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3);
}
void GLAPIENTRY
@@ -1399,35 +1399,35 @@ _mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT);
}
void GLAPIENTRY
_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2);
}
void GLAPIENTRY
_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3);
}
void GLAPIENTRY
_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4);
}
@@ -1437,7 +1437,7 @@ _mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
2, 2, location, count, transpose, value);
}
@@ -1446,7 +1446,7 @@ _mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
3, 3, location, count, transpose, value);
}
@@ -1455,7 +1455,7 @@ _mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
4, 4, location, count, transpose, value);
}
@@ -1468,7 +1468,7 @@ _mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
2, 3, location, count, transpose, value);
}
@@ -1477,7 +1477,7 @@ _mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
3, 2, location, count, transpose, value);
}
@@ -1486,7 +1486,7 @@ _mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
2, 4, location, count, transpose, value);
}
@@ -1495,7 +1495,7 @@ _mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
4, 2, location, count, transpose, value);
}
@@ -1504,7 +1504,7 @@ _mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
3, 4, location, count, transpose, value);
}
@@ -1513,7 +1513,7 @@ _mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram,
4, 3, location, count, transpose, value);
}