diff options
author | marha <marha@users.sourceforge.net> | 2012-07-31 10:17:14 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-07-31 10:17:14 +0200 |
commit | 83da3ad0287bc51cd16ee6911fe73dc98ebe000b (patch) | |
tree | 48d48590a0b0a3770006aeda8ec2b2a45054d1f1 /mesalib/src/mesa/main/uniforms.c | |
parent | 00e30605ffc7ac3cf1a091ff2c1f46cfefb780d7 (diff) | |
parent | bd27b3d008b0abf9ae2edcb127302728808533e4 (diff) | |
download | vcxsrv-83da3ad0287bc51cd16ee6911fe73dc98ebe000b.tar.gz vcxsrv-83da3ad0287bc51cd16ee6911fe73dc98ebe000b.tar.bz2 vcxsrv-83da3ad0287bc51cd16ee6911fe73dc98ebe000b.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/main/uniforms.c')
-rw-r--r-- | mesalib/src/mesa/main/uniforms.c | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index e6604b1a4..ccbd753db 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -497,6 +497,7 @@ GLint GLAPIENTRY _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) { struct gl_shader_program *shProg; + GLuint index, offset; GET_CURRENT_CONTEXT(ctx); @@ -516,9 +517,71 @@ _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) return -1; } - return _mesa_get_uniform_location(ctx, shProg, name); + index = _mesa_get_uniform_location(ctx, shProg, name, &offset); + if (index == GL_INVALID_INDEX) + return -1; + + return _mesa_uniform_merge_location_offset(index, offset); } +static GLuint GLAPIENTRY +_mesa_GetUniformBlockIndex(GLuint program, + const GLchar *uniformBlockName) +{ + GET_CURRENT_CONTEXT(ctx); + GLuint i; + struct gl_shader_program *shProg; + + if (!ctx->Extensions.ARB_uniform_buffer_object) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformBlockIndex"); + return GL_INVALID_INDEX; + } + + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glGetUniformBlockIndex"); + if (!shProg) + return GL_INVALID_INDEX; + + for (i = 0; i < shProg->NumUniformBlocks; i++) { + if (!strcmp(shProg->UniformBlocks[i].Name, uniformBlockName)) + return i; + } + + return GL_INVALID_INDEX; +} + +static void GLAPIENTRY +_mesa_GetUniformIndices(GLuint program, + GLsizei uniformCount, + const GLchar * const *uniformNames, + GLuint *uniformIndices) +{ + GET_CURRENT_CONTEXT(ctx); + GLsizei i; + struct gl_shader_program *shProg; + + if (!ctx->Extensions.ARB_uniform_buffer_object) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformIndices"); + return; + } + + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glGetUniformIndices"); + if (!shProg) + return; + + if (uniformCount < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetUniformIndices(uniformCount < 0)"); + return; + } + + for (i = 0; i < uniformCount; i++) { + unsigned offset; + uniformIndices[i] = _mesa_get_uniform_location(ctx, shProg, + uniformNames[i], &offset); + } +} /** * Plug in shader uniform-related functions into API dispatch table. @@ -577,5 +640,10 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB); SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */ + /* GL_ARB_uniform_buffer_object / GL 3.1 */ + SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex); + SET_GetUniformIndices(exec, _mesa_GetUniformIndices); + SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv); + #endif /* FEATURE_GL */ } |