[Mesa-dev] [PATCH 19/23] program_resource: add subroutine support
Dave Airlie
airlied at gmail.com
Thu Apr 23 18:42:55 PDT 2015
From: Dave Airlie <airlied at redhat.com>
This fleshes out the ARB_program_query support for the
APIs that ARB_shader_subroutine introduces, leaving
some TODOs for later addition.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/main/shader_query.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index bc6fec5..5de0aea 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -60,6 +60,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(XFB, gl_transform_feedback_varying_info);
+DECL_RESOURCE_FUNC(SUB, gl_subroutine_function);
void GLAPIENTRY
_mesa_BindAttribLocation(GLhandleARB program, GLuint index,
@@ -497,6 +498,24 @@ _mesa_program_resource_name(struct gl_program_resource *res)
return RESOURCE_VAR(res)->name;
case GL_UNIFORM:
return RESOURCE_UNI(res)->name;
+ case GL_VERTEX_SUBROUTINE_UNIFORM:
+ case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+ case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+ /* TODO
+ case GL_COMPUTE_SUBROUTINE_UNIFORM:
+ case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
+ case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
+ */
+ return RESOURCE_UNI(res)->name + 9;
+ case GL_VERTEX_SUBROUTINE:
+ case GL_GEOMETRY_SUBROUTINE:
+ case GL_FRAGMENT_SUBROUTINE:
+ /* TODO
+ case GL_COMPUTE_SUBROUTINE:
+ case GL_TESS_CONTROL_SUBROUTINE:
+ case GL_TESS_EVALUATION_SUBROUTINE:
+ */
+ return RESOURCE_SUB(res)->name;
default:
assert(!"support for resource type not implemented");
}
@@ -515,6 +534,9 @@ _mesa_program_resource_array_size(struct gl_program_resource *res)
case GL_PROGRAM_OUTPUT:
return RESOURCE_VAR(res)->data.max_array_access;
case GL_UNIFORM:
+ case GL_VERTEX_SUBROUTINE_UNIFORM:
+ case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+ case GL_FRAGMENT_SUBROUTINE_UNIFORM:
return RESOURCE_UNI(res)->array_elements;
case GL_ATOMIC_COUNTER_BUFFER:
case GL_UNIFORM_BLOCK:
@@ -560,6 +582,12 @@ _mesa_program_resource_find_name(struct gl_shader_program *shProg,
case GL_TRANSFORM_FEEDBACK_VARYING:
case GL_UNIFORM_BLOCK:
case GL_UNIFORM:
+ case GL_VERTEX_SUBROUTINE_UNIFORM:
+ case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+ case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+ case GL_VERTEX_SUBROUTINE:
+ case GL_GEOMETRY_SUBROUTINE:
+ case GL_FRAGMENT_SUBROUTINE:
if (strncmp(rname, name, baselen) == 0) {
/* Basename match, check if array or struct. */
if (name[baselen] == '\0' ||
@@ -640,6 +668,12 @@ _mesa_program_resource_find_index(struct gl_shader_program *shProg,
case GL_PROGRAM_INPUT:
case GL_PROGRAM_OUTPUT:
case GL_UNIFORM:
+ case GL_VERTEX_SUBROUTINE_UNIFORM:
+ case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+ case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+ case GL_VERTEX_SUBROUTINE:
+ case GL_GEOMETRY_SUBROUTINE:
+ case GL_FRAGMENT_SUBROUTINE:
if (++idx == (int) index)
return res;
break;
@@ -729,6 +763,8 @@ program_resource_location(struct gl_shader_program *shProg,
{
unsigned index, offset;
int array_index = -1;
+ long offset_ret;
+ const GLchar *base_name_end;
if (res->Type == GL_PROGRAM_INPUT || res->Type == GL_PROGRAM_OUTPUT) {
array_index = array_index_of_resource(res, name);
@@ -765,6 +801,16 @@ program_resource_location(struct gl_shader_program *shProg,
/* location in remap table + array element offset */
return RESOURCE_UNI(res)->remap_location + offset;
+ case GL_VERTEX_SUBROUTINE_UNIFORM:
+ case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+ case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+ /* TODO
+ case GL_COMPUTE_SUBROUTINE_UNIFORM:
+ case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
+ case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
+ */
+ offset_ret = parse_program_resource_name(name, &base_name_end);
+ return RESOURCE_UNI(res)->subroutine[_mesa_shader_stage_from_subroutine_uniform(res->Type)].index + ((offset_ret != -1) ? offset_ret : 0);
default:
return -1;
}
--
2.1.0
More information about the mesa-dev
mailing list