mtypes: move gl_linked_shader and gl_shader_program to new shader_types.h
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14437>
This commit is contained in:
parent
fa5788b889
commit
d6dfa370ee
|
@ -2474,57 +2474,6 @@ struct gl_subroutine_function
|
|||
const struct glsl_type **types;
|
||||
};
|
||||
|
||||
/**
|
||||
* A linked GLSL shader object.
|
||||
*/
|
||||
struct gl_linked_shader
|
||||
{
|
||||
gl_shader_stage Stage;
|
||||
|
||||
/** All gl_shader::compiled_source_sha1 combined. */
|
||||
uint8_t linked_source_sha1[SHA1_DIGEST_LENGTH];
|
||||
|
||||
struct gl_program *Program; /**< Post-compile assembly code */
|
||||
|
||||
/**
|
||||
* \name Sampler tracking
|
||||
*
|
||||
* \note Each of these fields is only set post-linking.
|
||||
*/
|
||||
/*@{*/
|
||||
GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Number of default uniform block components used by this shader.
|
||||
*
|
||||
* This field is only set post-linking.
|
||||
*/
|
||||
unsigned num_uniform_components;
|
||||
|
||||
/**
|
||||
* Number of combined uniform components used by this shader.
|
||||
*
|
||||
* This field is only set post-linking. It is the sum of the uniform block
|
||||
* sizes divided by sizeof(float), and num_uniform_compoennts.
|
||||
*/
|
||||
unsigned num_combined_uniform_components;
|
||||
|
||||
struct exec_list *ir;
|
||||
struct exec_list *packed_varyings;
|
||||
struct exec_list *fragdata_arrays;
|
||||
struct glsl_symbol_table *symbols;
|
||||
|
||||
/**
|
||||
* ARB_gl_spirv related data.
|
||||
*
|
||||
* This is actually a reference to the gl_shader::spirv_data, which
|
||||
* stores information that is also needed during linking.
|
||||
*/
|
||||
struct gl_shader_spirv_data *spirv_data;
|
||||
};
|
||||
|
||||
|
||||
struct gl_uniform_buffer_variable
|
||||
{
|
||||
char *Name;
|
||||
|
@ -2725,231 +2674,6 @@ struct gl_program_resource
|
|||
uint8_t StageReferences; /** Bitmask of shader stage references. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Link status enum. LINKING_SKIPPED is used to indicate linking
|
||||
* was skipped due to the shader being loaded from the on-disk cache.
|
||||
*/
|
||||
enum gl_link_status
|
||||
{
|
||||
LINKING_FAILURE = 0,
|
||||
LINKING_SUCCESS,
|
||||
LINKING_SKIPPED
|
||||
};
|
||||
|
||||
/* All GLSL program resource types are next to each other, so we can use that
|
||||
* to make them 0-based like this:
|
||||
*/
|
||||
#define GET_PROGRAM_RESOURCE_TYPE_FROM_GLENUM(x) ((x) - GL_UNIFORM)
|
||||
#define NUM_PROGRAM_RESOURCE_TYPES (GL_TRANSFORM_FEEDBACK_VARYING - GL_UNIFORM + 1)
|
||||
|
||||
/**
|
||||
* A data structure to be shared by gl_shader_program and gl_program.
|
||||
*/
|
||||
struct gl_shader_program_data
|
||||
{
|
||||
GLint RefCount; /**< Reference count */
|
||||
|
||||
/** SHA1 hash of linked shader program */
|
||||
unsigned char sha1[20];
|
||||
|
||||
unsigned NumUniformStorage;
|
||||
unsigned NumHiddenUniforms;
|
||||
struct gl_uniform_storage *UniformStorage;
|
||||
|
||||
unsigned NumUniformBlocks;
|
||||
unsigned NumShaderStorageBlocks;
|
||||
|
||||
struct gl_uniform_block *UniformBlocks;
|
||||
struct gl_uniform_block *ShaderStorageBlocks;
|
||||
|
||||
struct gl_active_atomic_buffer *AtomicBuffers;
|
||||
unsigned NumAtomicBuffers;
|
||||
|
||||
/* Shader cache variables used during restore */
|
||||
unsigned NumUniformDataSlots;
|
||||
union gl_constant_value *UniformDataSlots;
|
||||
|
||||
/* Used to hold initial uniform values for program binary restores.
|
||||
*
|
||||
* From the ARB_get_program_binary spec:
|
||||
*
|
||||
* "A successful call to ProgramBinary will reset all uniform
|
||||
* variables to their initial values. The initial value is either
|
||||
* the value of the variable's initializer as specified in the
|
||||
* original shader source, or 0 if no initializer was present.
|
||||
*/
|
||||
union gl_constant_value *UniformDataDefaults;
|
||||
|
||||
/** Hash for quick search by name. */
|
||||
struct hash_table *ProgramResourceHash[NUM_PROGRAM_RESOURCE_TYPES];
|
||||
|
||||
GLboolean Validated;
|
||||
|
||||
/** List of all active resources after linking. */
|
||||
struct gl_program_resource *ProgramResourceList;
|
||||
unsigned NumProgramResourceList;
|
||||
|
||||
enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
|
||||
GLchar *InfoLog;
|
||||
|
||||
unsigned Version; /**< GLSL version used for linking */
|
||||
|
||||
/* Mask of stages this program was linked against */
|
||||
unsigned linked_stages;
|
||||
|
||||
/* Whether the shaders of this program are loaded from SPIR-V binaries
|
||||
* (all have the SPIR_V_BINARY_ARB state). This was introduced by the
|
||||
* ARB_gl_spirv extension.
|
||||
*/
|
||||
bool spirv;
|
||||
};
|
||||
|
||||
/**
|
||||
* A GLSL program object.
|
||||
* Basically a linked collection of vertex and fragment shaders.
|
||||
*/
|
||||
struct gl_shader_program
|
||||
{
|
||||
GLenum16 Type; /**< Always GL_SHADER_PROGRAM (internal token) */
|
||||
GLuint Name; /**< aka handle or ID */
|
||||
GLchar *Label; /**< GL_KHR_debug */
|
||||
GLint RefCount; /**< Reference count */
|
||||
GLboolean DeletePending;
|
||||
|
||||
/**
|
||||
* Is the application intending to glGetProgramBinary this program?
|
||||
*
|
||||
* BinaryRetrievableHint is the currently active hint that gets set
|
||||
* during initialization and after linking and BinaryRetrievableHintPending
|
||||
* is the hint set by the user to be active when program is linked next time.
|
||||
*/
|
||||
GLboolean BinaryRetrievableHint;
|
||||
GLboolean BinaryRetrievableHintPending;
|
||||
|
||||
/**
|
||||
* Indicates whether program can be bound for individual pipeline stages
|
||||
* using UseProgramStages after it is next linked.
|
||||
*/
|
||||
GLboolean SeparateShader;
|
||||
|
||||
GLuint NumShaders; /**< number of attached shaders */
|
||||
struct gl_shader **Shaders; /**< List of attached the shaders */
|
||||
|
||||
/**
|
||||
* User-defined attribute bindings
|
||||
*
|
||||
* These are set via \c glBindAttribLocation and are used to direct the
|
||||
* GLSL linker. These are \b not the values used in the compiled shader,
|
||||
* and they are \b not the values returned by \c glGetAttribLocation.
|
||||
*/
|
||||
struct string_to_uint_map *AttributeBindings;
|
||||
|
||||
/**
|
||||
* User-defined fragment data bindings
|
||||
*
|
||||
* These are set via \c glBindFragDataLocation and are used to direct the
|
||||
* GLSL linker. These are \b not the values used in the compiled shader,
|
||||
* and they are \b not the values returned by \c glGetFragDataLocation.
|
||||
*/
|
||||
struct string_to_uint_map *FragDataBindings;
|
||||
struct string_to_uint_map *FragDataIndexBindings;
|
||||
|
||||
/**
|
||||
* Transform feedback varyings last specified by
|
||||
* glTransformFeedbackVaryings().
|
||||
*
|
||||
* For the current set of transform feedback varyings used for transform
|
||||
* feedback output, see LinkedTransformFeedback.
|
||||
*/
|
||||
struct {
|
||||
GLenum16 BufferMode;
|
||||
/** Global xfb_stride out qualifier if any */
|
||||
GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
|
||||
GLuint NumVarying;
|
||||
GLchar **VaryingNames; /**< Array [NumVarying] of char * */
|
||||
} TransformFeedback;
|
||||
|
||||
struct gl_program *last_vert_prog;
|
||||
|
||||
/** Post-link gl_FragDepth layout for ARB_conservative_depth. */
|
||||
enum gl_frag_depth_layout FragDepthLayout;
|
||||
|
||||
/**
|
||||
* Geometry shader state - copied into gl_program by
|
||||
* _mesa_copy_linked_program_data().
|
||||
*/
|
||||
struct {
|
||||
GLint VerticesIn;
|
||||
|
||||
bool UsesEndPrimitive;
|
||||
unsigned ActiveStreamMask;
|
||||
} Geom;
|
||||
|
||||
/**
|
||||
* Compute shader state - copied into gl_program by
|
||||
* _mesa_copy_linked_program_data().
|
||||
*/
|
||||
struct {
|
||||
/**
|
||||
* Size of shared variables accessed by the compute shader.
|
||||
*/
|
||||
unsigned SharedSize;
|
||||
} Comp;
|
||||
|
||||
/** Data shared by gl_program and gl_shader_program */
|
||||
struct gl_shader_program_data *data;
|
||||
|
||||
/**
|
||||
* Mapping from GL uniform locations returned by \c glUniformLocation to
|
||||
* UniformStorage entries. Arrays will have multiple contiguous slots
|
||||
* in the UniformRemapTable, all pointing to the same UniformStorage entry.
|
||||
*/
|
||||
unsigned NumUniformRemapTable;
|
||||
struct gl_uniform_storage **UniformRemapTable;
|
||||
|
||||
/**
|
||||
* Sometimes there are empty slots left over in UniformRemapTable after we
|
||||
* allocate slots to explicit locations. This list stores the blocks of
|
||||
* continuous empty slots inside UniformRemapTable.
|
||||
*/
|
||||
struct exec_list EmptyUniformLocations;
|
||||
|
||||
/**
|
||||
* Total number of explicit uniform location including inactive uniforms.
|
||||
*/
|
||||
unsigned NumExplicitUniformLocations;
|
||||
|
||||
/**
|
||||
* Map of active uniform names to locations
|
||||
*
|
||||
* Maps any active uniform that is not an array element to a location.
|
||||
* Each active uniform, including individual structure members will appear
|
||||
* in this map. This roughly corresponds to the set of names that would be
|
||||
* enumerated by \c glGetActiveUniform.
|
||||
*/
|
||||
struct string_to_uint_map *UniformHash;
|
||||
|
||||
GLboolean SamplersValidated; /**< Samplers validated against texture units? */
|
||||
|
||||
bool IsES; /**< True if this program uses GLSL ES */
|
||||
|
||||
/**
|
||||
* Per-stage shaders resulting from the first stage of linking.
|
||||
*
|
||||
* Set of linked shaders for this program. The array is accessed using the
|
||||
* \c MESA_SHADER_* defines. Entries for non-existent stages will be
|
||||
* \c NULL.
|
||||
*/
|
||||
struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
|
||||
|
||||
/**
|
||||
* True if any of the fragment shaders attached to this program use:
|
||||
* #extension ARB_fragment_coord_conventions: enable
|
||||
*/
|
||||
GLboolean ARB_fragment_coord_conventions_enable;
|
||||
};
|
||||
|
||||
|
||||
#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
|
||||
#define GLSL_LOG 0x2 /**< Write shaders to files */
|
||||
#define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "main/config.h" /* for MAX_FEEDBACK_BUFFERS */
|
||||
#include "main/glheader.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
#include "compiler/glsl/list.h"
|
||||
|
||||
/**
|
||||
* Shader information needed by both gl_shader and gl_linked shader.
|
||||
|
@ -221,4 +222,280 @@ struct gl_shader
|
|||
struct gl_shader_spirv_data *spirv_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* A linked GLSL shader object.
|
||||
*/
|
||||
struct gl_linked_shader
|
||||
{
|
||||
gl_shader_stage Stage;
|
||||
|
||||
/** All gl_shader::compiled_source_sha1 combined. */
|
||||
uint8_t linked_source_sha1[SHA1_DIGEST_LENGTH];
|
||||
|
||||
struct gl_program *Program; /**< Post-compile assembly code */
|
||||
|
||||
/**
|
||||
* \name Sampler tracking
|
||||
*
|
||||
* \note Each of these fields is only set post-linking.
|
||||
*/
|
||||
/*@{*/
|
||||
GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* Number of default uniform block components used by this shader.
|
||||
*
|
||||
* This field is only set post-linking.
|
||||
*/
|
||||
unsigned num_uniform_components;
|
||||
|
||||
/**
|
||||
* Number of combined uniform components used by this shader.
|
||||
*
|
||||
* This field is only set post-linking. It is the sum of the uniform block
|
||||
* sizes divided by sizeof(float), and num_uniform_compoennts.
|
||||
*/
|
||||
unsigned num_combined_uniform_components;
|
||||
|
||||
struct exec_list *ir;
|
||||
struct exec_list *packed_varyings;
|
||||
struct exec_list *fragdata_arrays;
|
||||
struct glsl_symbol_table *symbols;
|
||||
|
||||
/**
|
||||
* ARB_gl_spirv related data.
|
||||
*
|
||||
* This is actually a reference to the gl_shader::spirv_data, which
|
||||
* stores information that is also needed during linking.
|
||||
*/
|
||||
struct gl_shader_spirv_data *spirv_data;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Link status enum. LINKING_SKIPPED is used to indicate linking
|
||||
* was skipped due to the shader being loaded from the on-disk cache.
|
||||
*/
|
||||
enum gl_link_status
|
||||
{
|
||||
LINKING_FAILURE = 0,
|
||||
LINKING_SUCCESS,
|
||||
LINKING_SKIPPED
|
||||
};
|
||||
|
||||
/* All GLSL program resource types are next to each other, so we can use that
|
||||
* to make them 0-based like this:
|
||||
*/
|
||||
#define GET_PROGRAM_RESOURCE_TYPE_FROM_GLENUM(x) ((x) - GL_UNIFORM)
|
||||
#define NUM_PROGRAM_RESOURCE_TYPES (GL_TRANSFORM_FEEDBACK_VARYING - GL_UNIFORM + 1)
|
||||
|
||||
/**
|
||||
* A data structure to be shared by gl_shader_program and gl_program.
|
||||
*/
|
||||
struct gl_shader_program_data
|
||||
{
|
||||
GLint RefCount; /**< Reference count */
|
||||
|
||||
/** SHA1 hash of linked shader program */
|
||||
unsigned char sha1[20];
|
||||
|
||||
unsigned NumUniformStorage;
|
||||
unsigned NumHiddenUniforms;
|
||||
struct gl_uniform_storage *UniformStorage;
|
||||
|
||||
unsigned NumUniformBlocks;
|
||||
unsigned NumShaderStorageBlocks;
|
||||
|
||||
struct gl_uniform_block *UniformBlocks;
|
||||
struct gl_uniform_block *ShaderStorageBlocks;
|
||||
|
||||
struct gl_active_atomic_buffer *AtomicBuffers;
|
||||
unsigned NumAtomicBuffers;
|
||||
|
||||
/* Shader cache variables used during restore */
|
||||
unsigned NumUniformDataSlots;
|
||||
union gl_constant_value *UniformDataSlots;
|
||||
|
||||
/* Used to hold initial uniform values for program binary restores.
|
||||
*
|
||||
* From the ARB_get_program_binary spec:
|
||||
*
|
||||
* "A successful call to ProgramBinary will reset all uniform
|
||||
* variables to their initial values. The initial value is either
|
||||
* the value of the variable's initializer as specified in the
|
||||
* original shader source, or 0 if no initializer was present.
|
||||
*/
|
||||
union gl_constant_value *UniformDataDefaults;
|
||||
|
||||
/** Hash for quick search by name. */
|
||||
struct hash_table *ProgramResourceHash[NUM_PROGRAM_RESOURCE_TYPES];
|
||||
|
||||
GLboolean Validated;
|
||||
|
||||
/** List of all active resources after linking. */
|
||||
struct gl_program_resource *ProgramResourceList;
|
||||
unsigned NumProgramResourceList;
|
||||
|
||||
enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
|
||||
GLchar *InfoLog;
|
||||
|
||||
unsigned Version; /**< GLSL version used for linking */
|
||||
|
||||
/* Mask of stages this program was linked against */
|
||||
unsigned linked_stages;
|
||||
|
||||
/* Whether the shaders of this program are loaded from SPIR-V binaries
|
||||
* (all have the SPIR_V_BINARY_ARB state). This was introduced by the
|
||||
* ARB_gl_spirv extension.
|
||||
*/
|
||||
bool spirv;
|
||||
};
|
||||
|
||||
/**
|
||||
* A GLSL program object.
|
||||
* Basically a linked collection of vertex and fragment shaders.
|
||||
*/
|
||||
struct gl_shader_program
|
||||
{
|
||||
GLenum16 Type; /**< Always GL_SHADER_PROGRAM (internal token) */
|
||||
GLuint Name; /**< aka handle or ID */
|
||||
GLchar *Label; /**< GL_KHR_debug */
|
||||
GLint RefCount; /**< Reference count */
|
||||
GLboolean DeletePending;
|
||||
|
||||
/**
|
||||
* Is the application intending to glGetProgramBinary this program?
|
||||
*
|
||||
* BinaryRetrievableHint is the currently active hint that gets set
|
||||
* during initialization and after linking and BinaryRetrievableHintPending
|
||||
* is the hint set by the user to be active when program is linked next time.
|
||||
*/
|
||||
GLboolean BinaryRetrievableHint;
|
||||
GLboolean BinaryRetrievableHintPending;
|
||||
|
||||
/**
|
||||
* Indicates whether program can be bound for individual pipeline stages
|
||||
* using UseProgramStages after it is next linked.
|
||||
*/
|
||||
GLboolean SeparateShader;
|
||||
|
||||
GLuint NumShaders; /**< number of attached shaders */
|
||||
struct gl_shader **Shaders; /**< List of attached the shaders */
|
||||
|
||||
/**
|
||||
* User-defined attribute bindings
|
||||
*
|
||||
* These are set via \c glBindAttribLocation and are used to direct the
|
||||
* GLSL linker. These are \b not the values used in the compiled shader,
|
||||
* and they are \b not the values returned by \c glGetAttribLocation.
|
||||
*/
|
||||
struct string_to_uint_map *AttributeBindings;
|
||||
|
||||
/**
|
||||
* User-defined fragment data bindings
|
||||
*
|
||||
* These are set via \c glBindFragDataLocation and are used to direct the
|
||||
* GLSL linker. These are \b not the values used in the compiled shader,
|
||||
* and they are \b not the values returned by \c glGetFragDataLocation.
|
||||
*/
|
||||
struct string_to_uint_map *FragDataBindings;
|
||||
struct string_to_uint_map *FragDataIndexBindings;
|
||||
|
||||
/**
|
||||
* Transform feedback varyings last specified by
|
||||
* glTransformFeedbackVaryings().
|
||||
*
|
||||
* For the current set of transform feedback varyings used for transform
|
||||
* feedback output, see LinkedTransformFeedback.
|
||||
*/
|
||||
struct {
|
||||
GLenum16 BufferMode;
|
||||
/** Global xfb_stride out qualifier if any */
|
||||
GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
|
||||
GLuint NumVarying;
|
||||
GLchar **VaryingNames; /**< Array [NumVarying] of char * */
|
||||
} TransformFeedback;
|
||||
|
||||
struct gl_program *last_vert_prog;
|
||||
|
||||
/** Post-link gl_FragDepth layout for ARB_conservative_depth. */
|
||||
enum gl_frag_depth_layout FragDepthLayout;
|
||||
|
||||
/**
|
||||
* Geometry shader state - copied into gl_program by
|
||||
* _mesa_copy_linked_program_data().
|
||||
*/
|
||||
struct {
|
||||
GLint VerticesIn;
|
||||
|
||||
bool UsesEndPrimitive;
|
||||
unsigned ActiveStreamMask;
|
||||
} Geom;
|
||||
|
||||
/**
|
||||
* Compute shader state - copied into gl_program by
|
||||
* _mesa_copy_linked_program_data().
|
||||
*/
|
||||
struct {
|
||||
/**
|
||||
* Size of shared variables accessed by the compute shader.
|
||||
*/
|
||||
unsigned SharedSize;
|
||||
} Comp;
|
||||
|
||||
/** Data shared by gl_program and gl_shader_program */
|
||||
struct gl_shader_program_data *data;
|
||||
|
||||
/**
|
||||
* Mapping from GL uniform locations returned by \c glUniformLocation to
|
||||
* UniformStorage entries. Arrays will have multiple contiguous slots
|
||||
* in the UniformRemapTable, all pointing to the same UniformStorage entry.
|
||||
*/
|
||||
unsigned NumUniformRemapTable;
|
||||
struct gl_uniform_storage **UniformRemapTable;
|
||||
|
||||
/**
|
||||
* Sometimes there are empty slots left over in UniformRemapTable after we
|
||||
* allocate slots to explicit locations. This list stores the blocks of
|
||||
* continuous empty slots inside UniformRemapTable.
|
||||
*/
|
||||
struct exec_list EmptyUniformLocations;
|
||||
|
||||
/**
|
||||
* Total number of explicit uniform location including inactive uniforms.
|
||||
*/
|
||||
unsigned NumExplicitUniformLocations;
|
||||
|
||||
/**
|
||||
* Map of active uniform names to locations
|
||||
*
|
||||
* Maps any active uniform that is not an array element to a location.
|
||||
* Each active uniform, including individual structure members will appear
|
||||
* in this map. This roughly corresponds to the set of names that would be
|
||||
* enumerated by \c glGetActiveUniform.
|
||||
*/
|
||||
struct string_to_uint_map *UniformHash;
|
||||
|
||||
GLboolean SamplersValidated; /**< Samplers validated against texture units? */
|
||||
|
||||
bool IsES; /**< True if this program uses GLSL ES */
|
||||
|
||||
/**
|
||||
* Per-stage shaders resulting from the first stage of linking.
|
||||
*
|
||||
* Set of linked shaders for this program. The array is accessed using the
|
||||
* \c MESA_SHADER_* defines. Entries for non-existent stages will be
|
||||
* \c NULL.
|
||||
*/
|
||||
struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
|
||||
|
||||
/**
|
||||
* True if any of the fragment shaders attached to this program use:
|
||||
* #extension ARB_fragment_coord_conventions: enable
|
||||
*/
|
||||
GLboolean ARB_fragment_coord_conventions_enable;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue