X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fprogram%2Fprog_parameter.h;h=c91156f623c57c298ad613a56b2035e643d7e755;hb=7893872a6c46a65d2f12bc0ae6bc4bd61fd3f8a1;hp=c17d703040d0108d5819c73f49fa425c6aed5784;hpb=350b1ef027167af12156df92f449f370a0f8d396;p=mesa.git diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h index c17d703040d..c91156f623c 100644 --- a/src/mesa/program/prog_parameter.h +++ b/src/mesa/program/prog_parameter.h @@ -31,14 +31,46 @@ #ifndef PROG_PARAMETER_H #define PROG_PARAMETER_H -#include "main/mtypes.h" #include "prog_statevars.h" +#include #ifdef __cplusplus extern "C" { #endif +/** + * Names of the various vertex/fragment program register files, etc. + * + * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) + * All values should fit in a 4-bit field. + * + * NOTE: PROGRAM_STATE_VAR, PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be + * considered to be "uniform" variables since they can only be set outside + * glBegin/End. They're also all stored in the same Parameters array. + */ +typedef enum +{ + PROGRAM_TEMPORARY, /**< machine->Temporary[] */ + PROGRAM_ARRAY, /**< Arrays & Matrixes */ + PROGRAM_INPUT, /**< machine->Inputs[] */ + PROGRAM_OUTPUT, /**< machine->Outputs[] */ + PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ + PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ + PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ + PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ + PROGRAM_ADDRESS, /**< machine->AddressReg */ + PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ + PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */ + PROGRAM_UNDEFINED, /**< Invalid/TBD value */ + PROGRAM_IMMEDIATE, /**< Immediate value, used by TGSI */ + PROGRAM_BUFFER, /**< for shader buffers, compile-time only */ + PROGRAM_MEMORY, /**< for shared, global and local memory */ + PROGRAM_IMAGE, /**< for shader images, compile-time only */ + PROGRAM_HW_ATOMIC, /**< for hw atomic counters, compile-time only */ + PROGRAM_FILE_MAX +} gl_register_file; + /** * Actual data for constant values of parameters. @@ -59,20 +91,38 @@ typedef union gl_constant_value struct gl_program_parameter { const char *Name; /**< Null-terminated string */ - gl_register_file Type; /**< PROGRAM_CONSTANT or STATE_VAR */ - GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ + gl_register_file Type:5; /**< PROGRAM_CONSTANT or STATE_VAR */ + + /** + * We need to keep track of whether the param is padded for use in the + * shader cache. + */ + bool Padded:1; + + GLenum16 DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ + /** * Number of components (1..4), or more. * If the number of components is greater than 4, * this parameter is part of a larger uniform like a GLSL matrix or array. * The next program parameter's Size will be Size-4 of this parameter. */ - GLuint Size; - GLboolean Initialized; /**< debug: Has the ParameterValue[] been set? */ + GLushort Size; /** * A sequence of STATE_* tokens and integers to identify GL state. */ - gl_state_index StateIndexes[STATE_LENGTH]; + gl_state_index16 StateIndexes[STATE_LENGTH]; + + /** + * Index of this parameter's uniform storage. + */ + uint32_t UniformStorageIndex; + + /** + * Index of the first uniform storage that is associated with the same + * variable as this parameter. + */ + uint32_t MainUniformStorageIndex; }; @@ -82,9 +132,11 @@ struct gl_program_parameter struct gl_program_parameter_list { GLuint Size; /**< allocated size of Parameters, ParameterValues */ - GLuint NumParameters; /**< number of parameters in arrays */ + GLuint NumParameters; /**< number of used parameters in array */ + unsigned NumParameterValues; /**< number of used parameter values array */ struct gl_program_parameter *Parameters; /**< Array [Size] */ - gl_constant_value (*ParameterValues)[4]; /**< Array [Size] of constant[4] */ + unsigned *ParameterValueOffset; + gl_constant_value *ParameterValues; /**< Array [Size] of gl_constant_value */ GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes might invalidate ParameterValues[] */ }; @@ -108,25 +160,80 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, gl_register_file type, const char *name, GLuint size, GLenum datatype, const gl_constant_value *values, - const gl_state_index state[STATE_LENGTH]); + const gl_state_index16 state[STATE_LENGTH], + bool pad_and_align); extern GLint _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList, const gl_constant_value values[4], GLuint size, GLenum datatype, GLuint *swizzleOut); -extern GLint +static inline GLint _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, const gl_constant_value values[4], GLuint size, - GLuint *swizzleOut); + GLuint *swizzleOut) +{ + return _mesa_add_typed_unnamed_constant(paramList, values, size, GL_NONE, + swizzleOut); +} extern GLint -_mesa_add_state_reference(struct gl_program_parameter_list *paramList, - const gl_state_index stateTokens[STATE_LENGTH]); +_mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList, + const gl_state_index16 stateTokens[STATE_LENGTH], + const unsigned size, bool pad_and_align); extern GLint +_mesa_add_state_reference(struct gl_program_parameter_list *paramList, + const gl_state_index16 stateTokens[]); + + +static inline GLint _mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList, - GLsizei nameLen, const char *name); + const char *name) +{ + if (!paramList) + return -1; + + /* name must be null-terminated */ + for (GLint i = 0; i < (GLint) paramList->NumParameters; i++) { + if (paramList->Parameters[i].Name && + strcmp(paramList->Parameters[i].Name, name) == 0) + return i; + } + + return -1; +} + +static inline bool +_mesa_gl_datatype_is_64bit(GLenum datatype) +{ + switch (datatype) { + case GL_DOUBLE: + case GL_DOUBLE_VEC2: + case GL_DOUBLE_VEC3: + case GL_DOUBLE_VEC4: + case GL_DOUBLE_MAT2: + case GL_DOUBLE_MAT2x3: + case GL_DOUBLE_MAT2x4: + case GL_DOUBLE_MAT3: + case GL_DOUBLE_MAT3x2: + case GL_DOUBLE_MAT3x4: + case GL_DOUBLE_MAT4: + case GL_DOUBLE_MAT4x2: + case GL_DOUBLE_MAT4x3: + case GL_INT64_ARB: + case GL_INT64_VEC2_ARB: + case GL_INT64_VEC3_ARB: + case GL_INT64_VEC4_ARB: + case GL_UNSIGNED_INT64_ARB: + case GL_UNSIGNED_INT64_VEC2_ARB: + case GL_UNSIGNED_INT64_VEC3_ARB: + case GL_UNSIGNED_INT64_VEC4_ARB: + return true; + default: + return false; + } +} #ifdef __cplusplus }