summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniforms.c
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2013-10-07 18:53:40 -0700
committerFrancisco Jerez <[email protected]>2013-10-29 12:40:55 -0700
commit1c7dcfed7ceb9e47943d6adaacc1ca483c97fcf6 (patch)
tree2452628247d8021725a47e408c1300d4f0d63363 /src/mesa/main/uniforms.c
parente3fd31dc411c023495970ac51ce28b4d0deb80e6 (diff)
mesa: Add support for ARB_shader_atomic_counters.
This patch implements the common support code required for the ARB_shader_atomic_counters extension. It defines the necessary data structures for tracking atomic counter buffer objects (from now on "ABOs") associated with some specific context or shader program, it implements support for binding buffers to an ABO binding point and querying the existing atomic counters and buffers declared by GLSL shaders. v2: Fix extension checks. Drop unused MAX_ATOMIC_BUFFERS constant. Acked-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main/uniforms.c')
-rw-r--r--src/mesa/main/uniforms.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 07e7ea37998..2e847fe3147 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -535,7 +535,8 @@ _mesa_GetUniformLocation(GLhandleARB programObj, const GLcharARB *name)
* with a named uniform block, or if <name> starts with the reserved
* prefix "gl_"."
*/
- if (shProg->UniformStorage[index].block_index != -1)
+ if (shProg->UniformStorage[index].block_index != -1 ||
+ shProg->UniformStorage[index].atomic_buffer_index != -1)
return -1;
return _mesa_uniform_merge_location_offset(shProg, index, offset);
@@ -849,4 +850,63 @@ void GLAPIENTRY
_mesa_GetActiveAtomicCounterBufferiv(GLuint program, GLuint bufferIndex,
GLenum pname, GLint *params)
{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg;
+ struct gl_active_atomic_buffer *ab;
+ int i;
+
+ if (!ctx->Extensions.ARB_shader_atomic_counters) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetActiveAtomicCounterBufferiv");
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetActiveAtomicCounterBufferiv");
+ if (!shProg)
+ return;
+
+ if (bufferIndex >= shProg->NumAtomicBuffers) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveAtomicCounterBufferiv(bufferIndex)");
+ return;
+ }
+
+ ab = &shProg->AtomicBuffers[bufferIndex];
+
+ switch (pname) {
+ case GL_ATOMIC_COUNTER_BUFFER_BINDING:
+ params[0] = ab->Binding;
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE:
+ params[0] = ab->MinimumSize;
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS:
+ params[0] = ab->NumUniforms;
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES:
+ for (i = 0; i < ab->NumUniforms; ++i)
+ params[i] = ab->Uniforms[i];
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER:
+ params[0] = ab->StageReferences[MESA_SHADER_VERTEX];
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER:
+ params[0] = ab->StageReferences[MESA_SHADER_GEOMETRY];
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER:
+ params[0] = ab->StageReferences[MESA_SHADER_FRAGMENT];
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER:
+ params[0] = GL_FALSE;
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER:
+ params[0] = GL_FALSE;
+ return;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetActiveAtomicCounterBufferiv(pname 0x%x (%s))",
+ pname, _mesa_lookup_enum_by_nr(pname));
+ return;
+ }
}