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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \file prog_parameter.c
27 * Program parameter lists and functions.
31 #ifndef PROG_PARAMETER_H
32 #define PROG_PARAMETER_H
34 #include "main/mtypes.h"
35 #include "prog_statevars.h"
44 * Program parameter flags
47 #define PROG_PARAM_BIT_CENTROID 0x1 /**< for varying vars (GLSL 1.20) */
48 #define PROG_PARAM_BIT_INVARIANT 0x2 /**< for varying vars (GLSL 1.20) */
49 #define PROG_PARAM_BIT_FLAT 0x4 /**< for varying vars (GLSL 1.30) */
50 #define PROG_PARAM_BIT_LINEAR 0x8 /**< for varying vars (GLSL 1.30) */
51 #define PROG_PARAM_BIT_CYL_WRAP 0x10 /**< XXX gallium debug */
56 * Actual data for constant values of parameters.
58 typedef union gl_constant_value
69 * Used by shaders/programs for uniforms, constants, varying vars, etc.
71 struct gl_program_parameter
73 const char *Name
; /**< Null-terminated string */
74 gl_register_file Type
; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
75 GLenum DataType
; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
77 * Number of components (1..4), or more.
78 * If the number of components is greater than 4,
79 * this parameter is part of a larger uniform like a GLSL matrix or array.
80 * The next program parameter's Size will be Size-4 of this parameter.
83 GLboolean Initialized
; /**< debug: Has the ParameterValue[] been set? */
84 GLbitfield Flags
; /**< Bitmask of PROG_PARAM_*_BIT */
86 * A sequence of STATE_* tokens and integers to identify GL state.
88 gl_state_index StateIndexes
[STATE_LENGTH
];
93 * List of gl_program_parameter instances.
95 struct gl_program_parameter_list
97 GLuint Size
; /**< allocated size of Parameters, ParameterValues */
98 GLuint NumParameters
; /**< number of parameters in arrays */
99 struct gl_program_parameter
*Parameters
; /**< Array [Size] */
100 gl_constant_value (*ParameterValues
)[4]; /**< Array [Size] of constant[4] */
101 GLbitfield StateFlags
; /**< _NEW_* flags indicating which state changes
102 might invalidate ParameterValues[] */
106 extern struct gl_program_parameter_list
*
107 _mesa_new_parameter_list(void);
109 extern struct gl_program_parameter_list
*
110 _mesa_new_parameter_list_sized(unsigned size
);
113 _mesa_free_parameter_list(struct gl_program_parameter_list
*paramList
);
115 extern struct gl_program_parameter_list
*
116 _mesa_clone_parameter_list(const struct gl_program_parameter_list
*list
);
118 extern struct gl_program_parameter_list
*
119 _mesa_combine_parameter_lists(const struct gl_program_parameter_list
*a
,
120 const struct gl_program_parameter_list
*b
);
123 _mesa_num_parameters(const struct gl_program_parameter_list
*list
)
125 return list
? list
->NumParameters
: 0;
129 _mesa_add_parameter(struct gl_program_parameter_list
*paramList
,
130 gl_register_file type
, const char *name
,
131 GLuint size
, GLenum datatype
,
132 const gl_constant_value
*values
,
133 const gl_state_index state
[STATE_LENGTH
],
137 _mesa_add_named_parameter(struct gl_program_parameter_list
*paramList
,
138 const char *name
, const gl_constant_value values
[4]);
141 _mesa_add_named_constant(struct gl_program_parameter_list
*paramList
,
142 const char *name
, const gl_constant_value values
[4],
146 _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list
*paramList
,
147 const gl_constant_value values
[4], GLuint size
,
148 GLenum datatype
, GLuint
*swizzleOut
);
151 _mesa_add_unnamed_constant(struct gl_program_parameter_list
*paramList
,
152 const gl_constant_value values
[4], GLuint size
,
156 _mesa_add_varying(struct gl_program_parameter_list
*paramList
,
157 const char *name
, GLuint size
, GLenum datatype
,
161 _mesa_add_attribute(struct gl_program_parameter_list
*paramList
,
162 const char *name
, GLint size
, GLenum datatype
, GLint attrib
);
165 _mesa_add_state_reference(struct gl_program_parameter_list
*paramList
,
166 const gl_state_index stateTokens
[STATE_LENGTH
]);
168 extern gl_constant_value
*
169 _mesa_lookup_parameter_value(const struct gl_program_parameter_list
*paramList
,
170 GLsizei nameLen
, const char *name
);
173 _mesa_lookup_parameter_index(const struct gl_program_parameter_list
*paramList
,
174 GLsizei nameLen
, const char *name
);
177 _mesa_lookup_parameter_constant(const struct gl_program_parameter_list
*list
,
178 const gl_constant_value v
[], GLuint vSize
,
179 GLint
*posOut
, GLuint
*swizzleOut
);
182 _mesa_num_parameters_of_type(const struct gl_program_parameter_list
*list
,
183 gl_register_file type
);
190 #endif /* PROG_PARAMETER_H */