2 * Copyright © 2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
29 /* stdbool.h is necessary because this file is included in both C and C++ code.
33 #include "program/prog_parameter.h" /* For union gl_constant_value. */
40 enum gl_uniform_driver_format
{
41 uniform_native
= 0, /**< Store data in the native format. */
42 uniform_int_float
, /**< Store integer data as floats. */
43 uniform_bool_float
, /**< Store boolean data as floats. */
46 * Store boolean data as integer using 1 for \c true.
51 * Store boolean data as integer using ~0 for \c true.
53 uniform_bool_int_0_not0
56 struct gl_uniform_driver_storage
{
58 * Number of bytes from one array element to the next.
60 uint8_t element_stride
;
63 * Number of bytes from one vector in a matrix to the next.
65 uint8_t vector_stride
;
68 * Base format of the stored data.
70 * This field must have a value from \c GLSL_TYPE_UINT through \c
76 * Pointer to the base of the data.
81 struct gl_opaque_uniform_index
{
83 * Base opaque uniform index
85 * If \c gl_uniform_storage::base_type is an opaque type, this
86 * represents its uniform index. If \c
87 * gl_uniform_storage::array_elements is not zero, the array will
88 * use opaque uniform indices \c index through \c index + \c
89 * gl_uniform_storage::array_elements - 1, inclusive.
91 * Note that the index may be different in each shader stage.
96 * Whether this opaque uniform is used in this shader stage.
101 struct gl_uniform_storage
{
103 /** Type of this uniform data stored.
105 * In the case of an array, it's the type of a single array element.
107 const struct glsl_type
*type
;
110 * The number of elements in this uniform.
112 * For non-arrays, this is always 0. For arrays, the value is the size of
115 unsigned array_elements
;
118 * Has this uniform ever been set?
122 struct gl_opaque_uniform_index sampler
[MESA_SHADER_STAGES
];
124 struct gl_opaque_uniform_index image
[MESA_SHADER_STAGES
];
127 * Storage used by the driver for the uniform
129 unsigned num_driver_storage
;
130 struct gl_uniform_driver_storage
*driver_storage
;
133 * Storage used by Mesa for the uniform
135 * This form of the uniform is used by Mesa's implementation of \c
136 * glGetUniform. It can also be used by drivers to obtain the value of the
137 * uniform if the \c ::driver_storage interface is not used.
139 union gl_constant_value
*storage
;
141 /** Fields for GL_ARB_uniform_buffer_object
146 * GL_UNIFORM_BLOCK_INDEX: index of the uniform block containing
147 * the uniform, or -1 for the default uniform block. Note that the
148 * index is into the linked program's UniformBlocks[] array, not
149 * the linked shader's.
153 /** GL_UNIFORM_OFFSET: byte offset within the uniform block, or -1. */
157 * GL_UNIFORM_MATRIX_STRIDE: byte stride between columns or rows of
158 * a matrix. Set to 0 for non-matrices in UBOs, or -1 for uniforms
159 * in the default uniform block.
164 * GL_UNIFORM_ARRAY_STRIDE: byte stride between elements of the
165 * array. Set to zero for non-arrays in UBOs, or -1 for uniforms
166 * in the default uniform block.
170 /** GL_UNIFORM_ROW_MAJOR: true iff it's a row-major matrix in a UBO */
176 * Index within gl_shader_program::AtomicBuffers[] of the atomic
177 * counter buffer this uniform is stored in, or -1 if this is not
180 int atomic_buffer_index
;
183 * The 'base location' for this uniform in the uniform remap table. For
184 * arrays this is the first element in the array.
186 unsigned remap_location
;
193 #endif /* IR_UNIFORM_H */