From c796ce4108ccc4987c24df43606d04a0f3658d44 Mon Sep 17 00:00:00 2001 From: Tapani Pälli Date: Fri, 6 Mar 2015 09:14:49 +0200 Subject: mesa/glsl: build list of program resources during linking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch adds ProgramResourceList to gl_shader_program structure. List contains references to active program resources and is constructed during linking phase. This list will be used by follow-up patches to implement hooks for GL_ARB_program_interface_query. It can be also used to implement any of the older shader program query APIs. v2: code cleanups + note for SSBO and subroutines (Ilia Mirkin) v3: code cleanups + assert(MESA_SHADER_STAGES < 8) (Martin Peres) Signed-off-by: Tapani Pälli Reviewed-by: Martin Peres --- src/mesa/main/mtypes.h | 14 ++++++++++++++ src/mesa/main/shaderobj.c | 6 ++++++ 2 files changed, 20 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 56d3b7e1e89..1c751cfff25 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2603,6 +2603,16 @@ struct gl_active_atomic_buffer GLboolean StageReferences[MESA_SHADER_STAGES]; }; +/** + * Active resource in a gl_shader_program + */ +struct gl_program_resource +{ + GLenum Type; /** Program interface type. */ + const void *Data; /** Pointer to resource associated data structure. */ + uint8_t StageReferences; /** Bitmask of shader stage references. */ +}; + /** * A GLSL program object. * Basically a linked collection of vertex and fragment shaders. @@ -2777,6 +2787,10 @@ struct gl_shader_program */ struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES]; + /** List of all active resources after linking. */ + struct gl_program_resource *ProgramResourceList; + unsigned NumProgramResourceList; + /* True if any of the fragment shaders attached to this program use: * #extension ARB_fragment_coord_conventions: enable */ diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index d7620c8ef7e..e428960362d 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -315,6 +315,12 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg) ralloc_free(shProg->AtomicBuffers); shProg->AtomicBuffers = NULL; shProg->NumAtomicBuffers = 0; + + if (shProg->ProgramResourceList) { + ralloc_free(shProg->ProgramResourceList); + shProg->ProgramResourceList = NULL; + shProg->NumProgramResourceList = 0; + } } -- cgit v1.2.3