mesa: move nvprogram.[ch] to main/
[mesa.git] / src / mesa / shader / slang / slang_typeinfo.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25 #ifndef SLANG_TYPEINFO_H
26 #define SLANG_TYPEINFO_H 1
27
28 #include "main/imports.h"
29 #include "main/mtypes.h"
30 #include "slang_log.h"
31 #include "slang_utility.h"
32 #include "slang_vartable.h"
33
34
35 struct slang_operation_;
36
37 struct slang_name_space_;
38
39
40
41 /**
42 * Holds complete information about vector swizzle - the <swizzle>
43 * array contains vector component source indices, where 0 is "x", 1
44 * is "y", 2 is "z" and 3 is "w".
45 * Example: "xwz" --> { 3, { 0, 3, 2, not used } }.
46 */
47 typedef struct slang_swizzle_
48 {
49 GLuint num_components;
50 GLuint swizzle[4];
51 } slang_swizzle;
52
53 extern GLboolean
54 _slang_is_swizzle(const char *field, GLuint rows, slang_swizzle *swz);
55
56
57 typedef enum slang_type_variant_
58 {
59 SLANG_VARIANT, /* the default */
60 SLANG_INVARIANT /* indicates the "invariant" keyword */
61 } slang_type_variant;
62
63
64 typedef enum slang_type_centroid_
65 {
66 SLANG_CENTER, /* the default */
67 SLANG_CENTROID /* indicates the "centroid" keyword */
68 } slang_type_centroid;
69
70
71 /**
72 * These only apply to gl_FragCoord, but other layout qualifiers may
73 * appear in the future.
74 */
75 typedef enum slang_layout_qualifier_
76 {
77 SLANG_LAYOUT_NONE = 0x0,
78 SLANG_LAYOUT_UPPER_LEFT_BIT = 0x1,
79 SLANG_LAYOUT_PIXEL_CENTER_INTEGER_BIT = 0x2
80 } slang_layout_qualifier;
81
82
83 typedef enum slang_type_qualifier_
84 {
85 SLANG_QUAL_NONE,
86 SLANG_QUAL_CONST,
87 SLANG_QUAL_ATTRIBUTE,
88 SLANG_QUAL_VARYING,
89 SLANG_QUAL_UNIFORM,
90 SLANG_QUAL_OUT,
91 SLANG_QUAL_INOUT,
92 SLANG_QUAL_FIXEDOUTPUT, /* internal */
93 SLANG_QUAL_FIXEDINPUT /* internal */
94 } slang_type_qualifier;
95
96
97 typedef enum slang_type_precision_
98 {
99 SLANG_PREC_DEFAULT,
100 SLANG_PREC_LOW,
101 SLANG_PREC_MEDIUM,
102 SLANG_PREC_HIGH
103 } slang_type_precision;
104
105
106 /**
107 * The basic shading language types (float, vec4, mat3, etc)
108 */
109 typedef enum slang_type_specifier_type_
110 {
111 SLANG_SPEC_VOID,
112 SLANG_SPEC_BOOL,
113 SLANG_SPEC_BVEC2,
114 SLANG_SPEC_BVEC3,
115 SLANG_SPEC_BVEC4,
116 SLANG_SPEC_INT,
117 SLANG_SPEC_IVEC2,
118 SLANG_SPEC_IVEC3,
119 SLANG_SPEC_IVEC4,
120 SLANG_SPEC_FLOAT,
121 SLANG_SPEC_VEC2,
122 SLANG_SPEC_VEC3,
123 SLANG_SPEC_VEC4,
124 SLANG_SPEC_MAT2,
125 SLANG_SPEC_MAT3,
126 SLANG_SPEC_MAT4,
127 SLANG_SPEC_MAT23,
128 SLANG_SPEC_MAT32,
129 SLANG_SPEC_MAT24,
130 SLANG_SPEC_MAT42,
131 SLANG_SPEC_MAT34,
132 SLANG_SPEC_MAT43,
133 SLANG_SPEC_SAMPLER_1D,
134 SLANG_SPEC_SAMPLER_2D,
135 SLANG_SPEC_SAMPLER_3D,
136 SLANG_SPEC_SAMPLER_CUBE,
137 SLANG_SPEC_SAMPLER_RECT,
138 SLANG_SPEC_SAMPLER_1D_SHADOW,
139 SLANG_SPEC_SAMPLER_2D_SHADOW,
140 SLANG_SPEC_SAMPLER_RECT_SHADOW,
141 SLANG_SPEC_SAMPLER_1D_ARRAY,
142 SLANG_SPEC_SAMPLER_2D_ARRAY,
143 SLANG_SPEC_SAMPLER_1D_ARRAY_SHADOW,
144 SLANG_SPEC_SAMPLER_2D_ARRAY_SHADOW,
145 SLANG_SPEC_STRUCT,
146 SLANG_SPEC_ARRAY
147 } slang_type_specifier_type;
148
149
150 extern slang_type_specifier_type
151 slang_type_specifier_type_from_string(const char *);
152
153 extern const char *
154 slang_type_specifier_type_to_string(slang_type_specifier_type);
155
156
157 /**
158 * Describes more sophisticated types, like structs and arrays.
159 */
160 typedef struct slang_type_specifier_
161 {
162 slang_type_specifier_type type;
163 struct slang_struct_ *_struct; /**< if type == SLANG_SPEC_STRUCT */
164 struct slang_type_specifier_ *_array; /**< if type == SLANG_SPEC_ARRAY */
165 } slang_type_specifier;
166
167
168 extern GLvoid
169 slang_type_specifier_ctr(slang_type_specifier *);
170
171 extern GLvoid
172 slang_type_specifier_dtr(slang_type_specifier *);
173
174 extern slang_type_specifier *
175 slang_type_specifier_new(slang_type_specifier_type type,
176 struct slang_struct_ *_struct,
177 struct slang_type_specifier_ *_array);
178
179
180 extern GLboolean
181 slang_type_specifier_copy(slang_type_specifier *, const slang_type_specifier *);
182
183 extern GLboolean
184 slang_type_specifier_equal(const slang_type_specifier *,
185 const slang_type_specifier *);
186
187
188 extern GLboolean
189 slang_type_specifier_compatible(const slang_type_specifier *x,
190 const slang_type_specifier *y);
191
192
193 typedef struct slang_fully_specified_type_
194 {
195 slang_type_qualifier qualifier;
196 slang_type_specifier specifier;
197 slang_type_precision precision;
198 slang_type_variant variant;
199 slang_type_centroid centroid;
200 slang_layout_qualifier layout;
201 GLint array_len; /**< -1 if not an array type */
202 } slang_fully_specified_type;
203
204 extern int
205 slang_fully_specified_type_construct(slang_fully_specified_type *);
206
207 extern void
208 slang_fully_specified_type_destruct(slang_fully_specified_type *);
209
210 extern int
211 slang_fully_specified_type_copy(slang_fully_specified_type *,
212 const slang_fully_specified_type *);
213
214 GLboolean
215 slang_fully_specified_types_compatible(const slang_fully_specified_type * x,
216 const slang_fully_specified_type * y);
217
218
219 typedef struct slang_typeinfo_
220 {
221 GLboolean can_be_referenced;
222 GLboolean is_swizzled;
223 slang_swizzle swz;
224 slang_type_specifier spec;
225 GLuint array_len;
226 } slang_typeinfo;
227
228 extern GLboolean
229 slang_typeinfo_construct(slang_typeinfo *);
230
231 extern GLvoid
232 slang_typeinfo_destruct(slang_typeinfo *);
233
234
235 extern GLboolean
236 _slang_typeof_operation(struct slang_operation_ *,
237 const struct slang_name_space_ *,
238 slang_typeinfo *, slang_atom_pool *,
239 slang_info_log *log);
240
241 extern GLboolean
242 _slang_type_is_matrix(slang_type_specifier_type);
243
244 extern GLboolean
245 _slang_type_is_vector(slang_type_specifier_type);
246
247 extern GLboolean
248 _slang_type_is_float_vec_mat(slang_type_specifier_type);
249
250 extern slang_type_specifier_type
251 _slang_type_base(slang_type_specifier_type);
252
253 extern GLuint
254 _slang_type_dim(slang_type_specifier_type);
255
256 extern GLenum
257 _slang_gltype_from_specifier(const slang_type_specifier *type);
258
259 #endif