GLAPI/glGetProgramResource

From OpenGL.org
Jump to: navigation, search
glGetProgramResource
Core in version 4.5
Core since version 4.3
Core ARB extension ARB_program_interface_query

glGetProgramResource: retrieve values for multiple properties of a single active resource within a program object

Function Definition

 void glGetProgramResourceiv(GLuint program​, GLenum programInterface​, GLuint index​, GLsizei propCount​, const Glenum * props​, GLsizei bufSize​, GLsizei * length​, GLint * params​);
program
The name of a program object whose resources to query.
programInterface
A token identifying the interface within program​ containing the resource named name​.
index
The index within the programInterface​ to query information about.
propCount
The number of properties being queried.
props
An array of properties of length propCount​ to query.
bufSize
The number of GLint values in the params​ array.
length
If not NULL, then this value will be filled in with the number of actual parameters written to params​.
params
The output array of parameters to write.

Description

glGetProgramResourceiv returns values for multiple properties of a single active resource with an index of index​ in the interface programInterface​ of program object program​. For each resource, values for propCount​ properties specified by the array props​ are returned. propCount​ may not be zero. An error is generated if any value in props​ is not one of the properties described immediately belowor if any value in props​ is not allowed for programInterface​. The set of allowed programInterface​ values for each property can be found in the following table:

Property Supported Interfaces
GL_NAME_LENGTH Any except GL_ATOMIC_COUNTER_BUFFER and GL_TRANSFORM_FEEDBACK_BUFFER
GL_TYPE GL_UNIFORM, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT, GL_TRANSFORM_FEEDBACK_VARYING, GL_BUFFER_VARIABLE
GL_ARRAY_SIZE GL_UNIFORM, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT, VERTEX_SUBROUTINE_UNIFORM, GL_TESS_CONTROL_SUBROUTINE_UNIFORM, GL_TESS_EVALUATION_SUBROUTINE_UNIFORM, GL_GEOMETRY_SUBROUTINE_UNIFORM, GL_FRAGMENT_SUBROUTINE_UNIFORM, GL_COMPUTE_SUBROUTINE_UNIFORM, GL_TRANSFORM_FEEDBACK_VARYING
GL_OFFSET GL_UNIFORM, GL_BUFFER_VARIABLE, GL_TRANSFORM_FEEDBACK_VARYING
GL_BLOCK_INDEX GL_UNIFORM, GL_BUFFER_VARIABLE
GL_ARRAY_STRIDE GL_UNIFORM, GL_BUFFER_VARIABLE
GL_MATRIX_STRIDE GL_UNIFORM, GL_BUFFER_VARIABLE
GL_IS_ROW_MAJOR GL_UNIFORM, GL_BUFFER_VARIABLE
GL_ATOMIC_COUNTER_BUFFER_INDEX GL_UNIFORM
GL_BUFFER_BINDING GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_TRANSFORM_FEEDBACK_BUFFER
GL_BUFFER_DATA_SIZE GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_TRANSFORM_FEEDBACK_BUFFER
GL_NUM_ACTIVE_VARIABLES GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_TRANSFORM_FEEDBACK_BUFFER
GL_ACTIVE_VARIABLES GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_TRANSFORM_FEEDBACK_BUFFER
GL_REFERENCED_BY_VERTEX_SHADER GL_UNIFORM, GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_SHADER, GL_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_REFERENCED_BY_TESS_CONTROL_SHADER GL_UNIFORM, GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_SHADER, GL_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_REFERENCED_BY_TESS_EVALUATION_SHADER GL_UNIFORM, GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_SHADER, GL_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_REFERENCED_BY_GEOMETRY_SHADER GL_UNIFORM, GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_SHADER, GL_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_REFERENCED_BY_FRAGMENT_SHADER GL_UNIFORM, GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_SHADER, GL_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_REFERENCED_BY_COMPUTE_SHADER GL_UNIFORM, GL_UNIFORM_BLOCK, GL_ATOMIC_COUNTER_SHADER, GL_BUFFER, GL_SHADER_STORAGE_BLOCK, GL_BUFFER_VARIABLE, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_NUM_COMPATIBLE_SUBROUTINES GL_VERTEX_SUBROUTINE_UNIFORM, GL_TESS_CONTROL_SUBROUTINE_UNIFORM, GL_TESS_EVALUATION_SUBROUTINE_UNIFORM, GL_GEOMETRY_SUBROUTINE_UNIFORM, GL_FRAGMENT_SUBROUTINE_UNIFORM, GL_COMPUTE_SUBROUTINE_UNIFORM
GL_COMPATIBLE_SUBROUTINES GL_VERTEX_SUBROUTINE_UNIFORM, GL_TESS_CONTROL_SUBROUTINE_UNIFORM, GL_TESS_EVALUATION_SUBROUTINE_UNIFORM, GL_GEOMETRY_SUBROUTINE_UNIFORM, GL_FRAGMENT_SUBROUTINE_UNIFORM, GL_COMPUTE_SUBROUTINE_UNIFORM
GL_TOP_LEVEL_ARRAY_SIZE GL_BUFFER_VARIABLE
GL_TOP_LEVEL_ARRAY_STRIDE GL_BUFFER_VARIABLE
GL_LOCATION GL_UNIFORM, GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT, GL_VERTEX_SUBROUTINE_UNIFORM, GL_TESS_CONTROL_SUBROUTINE_UNIFORM, GL_TESS_EVALUATION_SUBROUTINE_UNIFORM, GL_GEOMETRY_SUBROUTINE_UNIFORM, GL_FRAGMENT_SUBROUTINE_UNIFORM, GL_COMPUTE_SUBROUTINE_UNIFORM
GL_LOCATION_INDEX GL_PROGRAM_OUTPUT
GL_IS_PER_PATCH GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_LOCATION_COMPONENT GL_PROGRAM_INPUT, GL_PROGRAM_OUTPUT
GL_TRANSFORM_FEEDBACK_BUFFER_INDEX GL_TRANSFORM_FEEDBACK_VARYING
GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE GL_TRANSFORM_FEEDBACK_BUFFER

For the property GL_NAME_LENGTH, a single integer identifying the length of the name string associated with an active variable, interface block, or subroutine is written to params​. The name length includes a terminating null character.

For the property GL_TYPE, a single integer identifying the type of an active variable is written to params​. The integer returned is one of the following values:

Returned Symbolic Contant Shader Uniform Type
GL_FLOAT float
GL_FLOAT_VEC2 vec2
GL_FLOAT_VEC3 vec3
GL_FLOAT_VEC4 vec4
GL_DOUBLE double
GL_DOUBLE_VEC2 dvec2
GL_DOUBLE_VEC3 dvec3
GL_DOUBLE_VEC4 dvec4
GL_INT int
GL_INT_VEC2 ivec2
GL_INT_VEC3 ivec3
GL_INT_VEC4 ivec4
GL_UNSIGNED_INT unsigned int
GL_UNSIGNED_INT_VEC2 uvec2
GL_UNSIGNED_INT_VEC3 uvec3
GL_UNSIGNED_INT_VEC4 uvec4
GL_BOOL bool
GL_BOOL_VEC2 bvec2
GL_BOOL_VEC3 bvec3
GL_BOOL_VEC4 bvec4
GL_FLOAT_MAT2 mat2
GL_FLOAT_MAT3 mat3
GL_FLOAT_MAT4 mat4
GL_FLOAT_MAT2x3 mat2x3
GL_FLOAT_MAT2x4 mat2x4
GL_FLOAT_MAT3x2 mat3x2
GL_FLOAT_MAT3x4 mat3x4
GL_FLOAT_MAT4x2 mat4x2
GL_FLOAT_MAT4x3 mat4x3
GL_DOUBLE_MAT2 dmat2
GL_DOUBLE_MAT3 dmat3
GL_DOUBLE_MAT4 dmat4
GL_DOUBLE_MAT2x3 dmat2x3
GL_DOUBLE_MAT2x4 dmat2x4
GL_DOUBLE_MAT3x2 dmat3x2
GL_DOUBLE_MAT3x4 dmat3x4
GL_DOUBLE_MAT4x2 dmat4x2
GL_DOUBLE_MAT4x3 dmat4x3
GL_SAMPLER_1D sampler1D
GL_SAMPLER_2D sampler2D
GL_SAMPLER_3D sampler3D
GL_SAMPLER_CUBE samplerCube
GL_SAMPLER_1D_SHADOW sampler1DShadow
GL_SAMPLER_2D_SHADOW sampler2DShadow
GL_SAMPLER_1D_ARRAY sampler1DArray
GL_SAMPLER_2D_ARRAY sampler2DArray
GL_SAMPLER_1D_ARRAY_SHADOW sampler1DArrayShadow
GL_SAMPLER_2D_ARRAY_SHADOW sampler2DArrayShadow
GL_SAMPLER_2D_MULTISAMPLE sampler2DMS
GL_SAMPLER_2D_MULTISAMPLE_ARRAY sampler2DMSArray
GL_SAMPLER_CUBE_SHADOW samplerCubeShadow
GL_SAMPLER_BUFFER samplerBuffer
GL_SAMPLER_2D_RECT sampler2DRect
GL_SAMPLER_2D_RECT_SHADOW sampler2DRectShadow
GL_INT_SAMPLER_1D isampler1D
GL_INT_SAMPLER_2D isampler2D
GL_INT_SAMPLER_3D isampler3D
GL_INT_SAMPLER_CUBE isamplerCube
GL_INT_SAMPLER_1D_ARRAY isampler1DArray
GL_INT_SAMPLER_2D_ARRAY isampler2DArray
GL_INT_SAMPLER_2D_MULTISAMPLE isampler2DMS
GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY isampler2DMSArray
GL_INT_SAMPLER_BUFFER isamplerBuffer
GL_INT_SAMPLER_2D_RECT isampler2DRect
GL_UNSIGNED_INT_SAMPLER_1D usampler1D
GL_UNSIGNED_INT_SAMPLER_2D usampler2D
GL_UNSIGNED_INT_SAMPLER_3D usampler3D
GL_UNSIGNED_INT_SAMPLER_CUBE usamplerCube
GL_UNSIGNED_INT_SAMPLER_1D_ARRAY usampler2DArray
GL_UNSIGNED_INT_SAMPLER_2D_ARRAY usampler2DArray
GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE usampler2DMS
GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY usampler2DMSArray
GL_UNSIGNED_INT_SAMPLER_BUFFER usamplerBuffer
GL_UNSIGNED_INT_SAMPLER_2D_RECT usampler2DRect

For the property GL_ARRAY_SIZE, a single integer identifying the number of active array elements of an active variable is written to params​. The array size returned is in units of the type associated with the property TYPE. For active variables not corresponding to an array of basic types, the value zero is written to params​.

For the property GL_BLOCK_INDEX, a single integer identifying the index of the active interface block containing an active variable is written to params​. If the variable is not the member of an interface block, the value -1 is written to params​.

For the property GL_OFFSET, a single integer identifying the offset of an active variable is written to params​. For active variables backed by a buffer object, the value written is the offset, in basic machine units, relative to the base of buffer range holding the values of the variable. For GL_TRANSFORM_FEEDBACK_VARYINGs, this is the byte-offset for the variable that goes into the buffer object, or -1 for the "special names" used by glTransformFeedbackVaryings. For active variables not backed by a buffer object, an offset of -1 is written to params​.

For the property GL_ARRAY_STRIDE, a single integer identifying the stride between array elements in an active variable is written to params​. For active variables declared as an array of basic types, the value written is the difference, in basic machine units, between the offsets of consecutive elements in an array. For active variables not declared as an array of basic types, zero is written to params​. For active variables not backed by a buffer object, -1 is written to params​, regardless of the variable type.

For the property GL_MATRIX_STRIDE, a single integer identifying the stride between columns of a column-major matrix or rows of a row-major matrix is written to params​. For active variables declared a single matrix or array of matrices, the value written is the difference, in basic machine units, between the offsets of consecutive columns or rows in each matrix. For active variables not declared as a matrix or array of matrices, zero is written to params​. For active variables not backed by a buffer object, -1 is written to params​, regardless of the variable type.

For the property GL_IS_ROW_MAJOR, a single integer identifying whether an active variable is a row-major matrix is written to params​. For active variables backed by a buffer object, declared as a single matrix or array of matrices, and stored in row-major order, one is written to params​. For all other active variables, zero is written to params​.

For the property GL_ATOMIC_COUNTER_BUFFER_INDEX, a single integer identifying the index of the active atomic counter buffer containing an active variable is written to params​. If the variable is not an atomic counter uniform, the value -1 is written to params​.

For the property GL_BUFFER_BINDING, to index of the buffer binding point associated with the active uniform block, shader storage block, or atomic counter buffer is written to params​.

For the property GL_BUFFER_DATA_SIZE, then the implementation-dependent minimum total buffer object size, in basic machine units, required to hold all active variables associated with an active uniform block, shader storage block, or atomic counter buffer is written to params​. If the final member of an active shader storage block is array with no declared size, the minimum buffer size is computed assuming the array was declared as an array with one element.

For the property GL_NUM_ACTIVE_VARIABLES, the number of active variables associated with an active uniform block, shader storage block, or atomic counter buffer is written to params​.

For the property GL_ACTIVE_VARIABLES, an array of active variable indices associated with an active uniform block, shader storage block, or atomic counter buffer is written to params​. The number of values written to params​ for an active resource is given by the value of the property GL_NUM_ACTIVE_VARIABLES for the resource.

For the properties GL_REFERENCED_BY_VERTEX_SHADER, GL_REFERENCED_BY_TESS_CONTROL_SHADER, GL_REFERENCED_BY_TESS_EVALUATION_SHADER, GL_REFERENCED_BY_GEOMETRY_SHADER, GL_REFERENCED_BY_FRAGMENT_SHADER, and GL_REFERENCED_BY_COMPUTE_SHADER, a single integer is written to params​, identifying whether the active resource is referenced by the vertex, tessellation control, tessellation evaluation, geometry, or fragment shaders, respectively, in the program object. The value one is written to params​ if an active variable is referenced by the corresponding shader, or if an active uniform block, shader storage block, or atomic counter buffer contains at least one variable referenced by the corresponding shader. Otherwise, the value zero is written to params​.

For the property GL_TOP_LEVEL_ARRAY_SIZE, a single integer identifying the number of active array elements of the top-level shader storage block member containing to the active variable is written to params​. If the top-level block member is not declared as an array, the value one is written to params​. If the top-level block member is an array with no declared size, the value zero is written to params​.

For the property GL_TOP_LEVEL_ARRAY_STRIDE, a single integer identifying the stride between array elements of the top-level shader storage block member containing the active variable is written to params​. For top-level block members declared as arrays, the value written is the difference, in basic machine units, between the offsets of the active variable for consecutive elements in the top-level array. For top-level block members not declared as an array, zero is written to params​.

For the property GL_LOCATION, a single integer identifying the assigned location for an active uniform, input, output, or subroutine uniform variable is written to params​. For input, output, or uniform variables with locations specified by a layout qualifier, the specified location is used. For vertex shader input or fragment shader output variables without a layout qualifier, the location assigned when a program is linked is written to params​. For all other input and output variables, the value -1 is written to params​. For uniforms in uniform blocks, the value -1 is written to params​.

For the property GL_LOCATION_INDEX, a single integer identifying the fragment color index of an active fragment shader output variable is written to params​. If the active variable is an output for a non-fragment shader, the value -1 will be written to params​.

For the property GL_IS_PER_PATCH, a single integer identifying whether the input or output is a per-patch attribute. If the active variable is a per-patch attribute (declared with the patch​ qualifier), the value one is written to params​; otherwise, the value zero is written to params​.

For the property GL_TRANSFORM_FEEDBACK_BUFFER_INDEX, a single integer identifying the index of the active transform feedback buffer associated with an active variable is written to params​. For variables corresponding to the special names "gl_NextBuffer"​, "gl_SkipComponents1"​, "gl_SkipComponents2"​, "gl_SkipComponents3"​, and "gl_SkipComponents4"​, -1 is written to params​.

For the property GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE, a single integer identifying the stride, in basic machine units, between consecutive vertices written to the transform feedback buffer is written to params​.

Errors

GL_INVALID_VALUE is generated if program​ is not the name of an existing program object.

GL_INVALID_VALUE is generated if propCount​ is zero.

GL_INVALID_ENUM is generated if programInterface​ is not one of the accepted interface types.

GL_INVLALID_ENUM is generated if any value in props​ is not one of the accepted tokens for the interface programInterface​

Associated Gets

glGetProgramInterface with the same programInterface​ and GL_ACTIVE_RESOURCES

See Also

glGetProgramResourceName, glGetProgramResourceIndex, glGetProgramResourceLocation, glGetProgramResourceLocationIndex, glUniform, glUniformSubroutines, glGetUniform, glGetUniformSubroutine

Copyright

Copyright © 2012 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.