Merge commit 'mesa_7_6_branch' into mesa_7_7_branch
[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 typedef enum slang_type_qualifier_
72 {
73 SLANG_QUAL_NONE,
74 SLANG_QUAL_CONST,
75 SLANG_QUAL_ATTRIBUTE,
76 SLANG_QUAL_VARYING,
77 SLANG_QUAL_UNIFORM,
78 SLANG_QUAL_OUT,
79 SLANG_QUAL_INOUT,
80 SLANG_QUAL_FIXEDOUTPUT, /* internal */
81 SLANG_QUAL_FIXEDINPUT /* internal */
82 } slang_type_qualifier;
83
84
85 typedef enum slang_type_precision_
86 {
87 SLANG_PREC_DEFAULT,
88 SLANG_PREC_LOW,
89 SLANG_PREC_MEDIUM,
90 SLANG_PREC_HIGH
91 } slang_type_precision;
92
93
94 /**
95 * The basic shading language types (float, vec4, mat3, etc)
96 */
97 typedef enum slang_type_specifier_type_
98 {
99 SLANG_SPEC_VOID,
100 SLANG_SPEC_BOOL,
101 SLANG_SPEC_BVEC2,
102 SLANG_SPEC_BVEC3,
103 SLANG_SPEC_BVEC4,
104 SLANG_SPEC_INT,
105 SLANG_SPEC_IVEC2,
106 SLANG_SPEC_IVEC3,
107 SLANG_SPEC_IVEC4,
108 SLANG_SPEC_FLOAT,
109 SLANG_SPEC_VEC2,
110 SLANG_SPEC_VEC3,
111 SLANG_SPEC_VEC4,
112 SLANG_SPEC_MAT2,
113 SLANG_SPEC_MAT3,
114 SLANG_SPEC_MAT4,
115 SLANG_SPEC_MAT23,
116 SLANG_SPEC_MAT32,
117 SLANG_SPEC_MAT24,
118 SLANG_SPEC_MAT42,
119 SLANG_SPEC_MAT34,
120 SLANG_SPEC_MAT43,
121 SLANG_SPEC_SAMPLER1D,
122 SLANG_SPEC_SAMPLER2D,
123 SLANG_SPEC_SAMPLER3D,
124 SLANG_SPEC_SAMPLERCUBE,
125 SLANG_SPEC_SAMPLER2DRECT,
126 SLANG_SPEC_SAMPLER1DSHADOW,
127 SLANG_SPEC_SAMPLER2DSHADOW,
128 SLANG_SPEC_SAMPLER2DRECTSHADOW,
129 SLANG_SPEC_STRUCT,
130 SLANG_SPEC_ARRAY
131 } slang_type_specifier_type;
132
133
134 extern slang_type_specifier_type
135 slang_type_specifier_type_from_string(const char *);
136
137 extern const char *
138 slang_type_specifier_type_to_string(slang_type_specifier_type);
139
140
141 /**
142 * Describes more sophisticated types, like structs and arrays.
143 */
144 typedef struct slang_type_specifier_
145 {
146 slang_type_specifier_type type;
147 struct slang_struct_ *_struct; /**< if type == SLANG_SPEC_STRUCT */
148 struct slang_type_specifier_ *_array; /**< if type == SLANG_SPEC_ARRAY */
149 } slang_type_specifier;
150
151
152 extern GLvoid
153 slang_type_specifier_ctr(slang_type_specifier *);
154
155 extern GLvoid
156 slang_type_specifier_dtr(slang_type_specifier *);
157
158 extern slang_type_specifier *
159 slang_type_specifier_new(slang_type_specifier_type type,
160 struct slang_struct_ *_struct,
161 struct slang_type_specifier_ *_array);
162
163
164 extern GLboolean
165 slang_type_specifier_copy(slang_type_specifier *, const slang_type_specifier *);
166
167 extern GLboolean
168 slang_type_specifier_equal(const slang_type_specifier *,
169 const slang_type_specifier *);
170
171
172 extern GLboolean
173 slang_type_specifier_compatible(const slang_type_specifier * x,
174 const slang_type_specifier * y);
175
176
177 typedef struct slang_fully_specified_type_
178 {
179 slang_type_qualifier qualifier;
180 slang_type_specifier specifier;
181 slang_type_precision precision;
182 slang_type_variant variant;
183 slang_type_centroid centroid;
184 GLint array_len; /**< -1 if not an array type */
185 } slang_fully_specified_type;
186
187 extern int
188 slang_fully_specified_type_construct(slang_fully_specified_type *);
189
190 extern void
191 slang_fully_specified_type_destruct(slang_fully_specified_type *);
192
193 extern int
194 slang_fully_specified_type_copy(slang_fully_specified_type *,
195 const slang_fully_specified_type *);
196
197
198
199 typedef struct slang_typeinfo_
200 {
201 GLboolean can_be_referenced;
202 GLboolean is_swizzled;
203 slang_swizzle swz;
204 slang_type_specifier spec;
205 GLuint array_len;
206 } slang_typeinfo;
207
208 extern GLboolean
209 slang_typeinfo_construct(slang_typeinfo *);
210
211 extern GLvoid
212 slang_typeinfo_destruct(slang_typeinfo *);
213
214
215 extern GLboolean
216 _slang_typeof_operation(struct slang_operation_ *,
217 const struct slang_name_space_ *,
218 slang_typeinfo *, slang_atom_pool *,
219 slang_info_log *log);
220
221 extern GLboolean
222 _slang_type_is_matrix(slang_type_specifier_type);
223
224 extern GLboolean
225 _slang_type_is_vector(slang_type_specifier_type);
226
227 extern GLboolean
228 _slang_type_is_float_vec_mat(slang_type_specifier_type);
229
230 extern slang_type_specifier_type
231 _slang_type_base(slang_type_specifier_type);
232
233 extern GLuint
234 _slang_type_dim(slang_type_specifier_type);
235
236 extern GLenum
237 _slang_gltype_from_specifier(const slang_type_specifier *type);
238
239 #endif