summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-03-10 16:17:13 +1100
committerTimothy Arceri <[email protected]>2016-03-31 12:53:02 +1100
commitc5704bb350425162011367e47be8c69d424a8797 (patch)
tree31ae70054e4c8dc3972590f29961884db20edc4b /src/mesa
parent7234be0338813c0acd5b700ea2f7f20f7a972e51 (diff)
mesa: add query support for GL_TRANSFORM_FEEDBACK_BUFFER interface
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/program_resource.c16
-rw-r--r--src/mesa/main/shader_query.cpp35
3 files changed, 51 insertions, 2 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 33923d195c9..ff0707d03ba 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1650,6 +1650,8 @@ struct gl_transform_feedback_buffer
{
unsigned Binding;
+ unsigned NumVaryings;
+
/**
* Total number of components stored in each buffer. This may be used by
* hardware back-ends to determine the correct stride when interleaving
diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c
index 0d9f8aecf08..f2a9f006dd8 100644
--- a/src/mesa/main/program_resource.c
+++ b/src/mesa/main/program_resource.c
@@ -39,6 +39,7 @@ supported_interface_enum(struct gl_context *ctx, GLenum iface)
case GL_UNIFORM_BLOCK:
case GL_PROGRAM_INPUT:
case GL_PROGRAM_OUTPUT:
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
case GL_TRANSFORM_FEEDBACK_VARYING:
case GL_ATOMIC_COUNTER_BUFFER:
case GL_BUFFER_VARIABLE:
@@ -105,7 +106,8 @@ _mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
(*params)++;
break;
case GL_MAX_NAME_LENGTH:
- if (programInterface == GL_ATOMIC_COUNTER_BUFFER) {
+ if (programInterface == GL_ATOMIC_COUNTER_BUFFER ||
+ programInterface == GL_TRANSFORM_FEEDBACK_BUFFER) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetProgramInterfaceiv(%s pname %s)",
_mesa_enum_to_string(programInterface),
@@ -165,6 +167,16 @@ _mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
}
}
break;
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
+ if (shProg->ProgramResourceList[i].Type == programInterface) {
+ struct gl_transform_feedback_buffer *buffer =
+ (struct gl_transform_feedback_buffer *)
+ shProg->ProgramResourceList[i].Data;
+ *params = MAX2(*params, buffer->NumVaryings);
+ }
+ }
+ break;
default:
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetProgramInterfaceiv(%s pname %s)",
@@ -289,6 +301,7 @@ _mesa_GetProgramResourceIndex(GLuint program, GLenum programInterface,
return _mesa_program_resource_index(shProg, res);
case GL_ATOMIC_COUNTER_BUFFER:
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramResourceIndex(%s)",
_mesa_enum_to_string(programInterface));
@@ -318,6 +331,7 @@ _mesa_GetProgramResourceName(GLuint program, GLenum programInterface,
return;
if (programInterface == GL_ATOMIC_COUNTER_BUFFER ||
+ programInterface == GL_TRANSFORM_FEEDBACK_BUFFER ||
!supported_interface_enum(ctx, programInterface)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramResourceName(%s)",
_mesa_enum_to_string(programInterface));
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index ee2eeab0f8d..993dc863220 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -61,6 +61,7 @@ DECL_RESOURCE_FUNC(UBO, gl_uniform_block);
DECL_RESOURCE_FUNC(UNI, gl_uniform_storage);
DECL_RESOURCE_FUNC(ATC, gl_active_atomic_buffer);
DECL_RESOURCE_FUNC(XFV, gl_transform_feedback_varying_info);
+DECL_RESOURCE_FUNC(XFB, gl_transform_feedback_buffer);
DECL_RESOURCE_FUNC(SUB, gl_subroutine_function);
void GLAPIENTRY
@@ -670,6 +671,7 @@ _mesa_program_resource_index(struct gl_shader_program *shProg,
return RESOURCE_SUB(res)->index;
case GL_UNIFORM_BLOCK:
case GL_SHADER_STORAGE_BLOCK:
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
case GL_TRANSFORM_FEEDBACK_VARYING:
default:
return calc_resource_index(shProg, res);
@@ -707,6 +709,7 @@ _mesa_program_resource_find_index(struct gl_shader_program *shProg,
case GL_UNIFORM_BLOCK:
case GL_ATOMIC_COUNTER_BUFFER:
case GL_SHADER_STORAGE_BLOCK:
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
if (_mesa_program_resource_index(shProg, res) == index)
return res;
break;
@@ -1009,7 +1012,8 @@ get_buffer_property(struct gl_shader_program *shProg,
GET_CURRENT_CONTEXT(ctx);
if (res->Type != GL_UNIFORM_BLOCK &&
res->Type != GL_ATOMIC_COUNTER_BUFFER &&
- res->Type != GL_SHADER_STORAGE_BLOCK)
+ res->Type != GL_SHADER_STORAGE_BLOCK &&
+ res->Type != GL_TRANSFORM_FEEDBACK_BUFFER)
goto invalid_operation;
if (res->Type == GL_UNIFORM_BLOCK) {
@@ -1110,6 +1114,30 @@ get_buffer_property(struct gl_shader_program *shProg,
}
return RESOURCE_ATC(res)->NumUniforms;
}
+ } else if (res->Type == GL_TRANSFORM_FEEDBACK_BUFFER) {
+ switch (prop) {
+ case GL_BUFFER_BINDING:
+ *val = RESOURCE_XFB(res)->Binding;
+ return 1;
+ case GL_NUM_ACTIVE_VARIABLES:
+ *val = RESOURCE_XFB(res)->NumVaryings;
+ return 1;
+ case GL_ACTIVE_VARIABLES:
+ int i = 0;
+ for ( ; i < shProg->LinkedTransformFeedback.NumVarying; i++) {
+ unsigned index =
+ shProg->LinkedTransformFeedback.Varyings[i].BufferIndex;
+ struct gl_program_resource *buf_res =
+ _mesa_program_resource_find_index(shProg,
+ GL_TRANSFORM_FEEDBACK_BUFFER,
+ index);
+ assert(buf_res);
+ if (res == buf_res) {
+ *val++ = i;
+ }
+ }
+ return RESOURCE_XFB(res)->NumVaryings;
+ }
}
assert(!"support for property type not implemented");
@@ -1140,6 +1168,7 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
case GL_NAME_LENGTH:
switch (res->Type) {
case GL_ATOMIC_COUNTER_BUFFER:
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
goto invalid_operation;
default:
/* Resource name length + terminator. */
@@ -1327,6 +1356,10 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
VALIDATE_TYPE(GL_TRANSFORM_FEEDBACK_VARYING);
*val = RESOURCE_XFV(res)->BufferIndex;
return 1;
+ case GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE:
+ VALIDATE_TYPE(GL_TRANSFORM_FEEDBACK_BUFFER);
+ *val = RESOURCE_XFB(res)->Stride * 4;
+ return 1;
default:
goto invalid_enum;