2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
27 * \file prog_parameter.c
28 * Program parameter lists and functions.
32 #ifndef PROG_PARAMETER_H
33 #define PROG_PARAMETER_H
35 #include "main/mtypes.h"
36 #include "prog_statevars.h"
45 * Actual data for constant values of parameters.
47 typedef union gl_constant_value
58 * Used by shaders/programs for uniforms, constants, varying vars, etc.
60 struct gl_program_parameter
62 const char *Name
; /**< Null-terminated string */
63 gl_register_file Type
; /**< PROGRAM_CONSTANT or STATE_VAR */
64 GLenum DataType
; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
66 * Number of components (1..4), or more.
67 * If the number of components is greater than 4,
68 * this parameter is part of a larger uniform like a GLSL matrix or array.
69 * The next program parameter's Size will be Size-4 of this parameter.
72 GLboolean Initialized
; /**< debug: Has the ParameterValue[] been set? */
74 * A sequence of STATE_* tokens and integers to identify GL state.
76 gl_state_index StateIndexes
[STATE_LENGTH
];
81 * List of gl_program_parameter instances.
83 struct gl_program_parameter_list
85 GLuint Size
; /**< allocated size of Parameters, ParameterValues */
86 GLuint NumParameters
; /**< number of parameters in arrays */
87 struct gl_program_parameter
*Parameters
; /**< Array [Size] */
88 gl_constant_value (*ParameterValues
)[4]; /**< Array [Size] of constant[4] */
89 GLbitfield StateFlags
; /**< _NEW_* flags indicating which state changes
90 might invalidate ParameterValues[] */
94 extern struct gl_program_parameter_list
*
95 _mesa_new_parameter_list(void);
97 extern struct gl_program_parameter_list
*
98 _mesa_new_parameter_list_sized(unsigned size
);
101 _mesa_free_parameter_list(struct gl_program_parameter_list
*paramList
);
103 extern struct gl_program_parameter_list
*
104 _mesa_clone_parameter_list(const struct gl_program_parameter_list
*list
);
106 extern struct gl_program_parameter_list
*
107 _mesa_combine_parameter_lists(const struct gl_program_parameter_list
*a
,
108 const struct gl_program_parameter_list
*b
);
111 _mesa_num_parameters(const struct gl_program_parameter_list
*list
)
113 return list
? list
->NumParameters
: 0;
117 _mesa_add_parameter(struct gl_program_parameter_list
*paramList
,
118 gl_register_file type
, const char *name
,
119 GLuint size
, GLenum datatype
,
120 const gl_constant_value
*values
,
121 const gl_state_index state
[STATE_LENGTH
]);
124 _mesa_add_named_constant(struct gl_program_parameter_list
*paramList
,
125 const char *name
, const gl_constant_value values
[4],
129 _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list
*paramList
,
130 const gl_constant_value values
[4], GLuint size
,
131 GLenum datatype
, GLuint
*swizzleOut
);
134 _mesa_add_unnamed_constant(struct gl_program_parameter_list
*paramList
,
135 const gl_constant_value values
[4], GLuint size
,
139 _mesa_add_state_reference(struct gl_program_parameter_list
*paramList
,
140 const gl_state_index stateTokens
[STATE_LENGTH
]);
142 extern gl_constant_value
*
143 _mesa_lookup_parameter_value(const struct gl_program_parameter_list
*paramList
,
144 GLsizei nameLen
, const char *name
);
147 _mesa_lookup_parameter_index(const struct gl_program_parameter_list
*paramList
,
148 GLsizei nameLen
, const char *name
);
151 _mesa_lookup_parameter_constant(const struct gl_program_parameter_list
*list
,
152 const gl_constant_value v
[], GLuint vSize
,
153 GLint
*posOut
, GLuint
*swizzleOut
);
159 #endif /* PROG_PARAMETER_H */