2 * Mesa 3-D graphics library
5 * Copyright (C) 2005-2006 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.
25 #ifndef SLANG_TYPEINFO_H
26 #define SLANG_TYPEINFO_H 1
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"
35 struct slang_operation_
;
37 struct slang_name_space_
;
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 } }.
47 typedef struct slang_swizzle_
49 GLuint num_components
;
54 _slang_is_swizzle(const char *field
, GLuint rows
, slang_swizzle
*swz
);
57 typedef enum slang_type_variant_
59 SLANG_VARIANT
, /* the default */
60 SLANG_INVARIANT
/* indicates the "invariant" keyword */
64 typedef enum slang_type_centroid_
66 SLANG_CENTER
, /* the default */
67 SLANG_CENTROID
/* indicates the "centroid" keyword */
68 } slang_type_centroid
;
71 typedef enum slang_type_qualifier_
80 SLANG_QUAL_FIXEDOUTPUT
, /* internal */
81 SLANG_QUAL_FIXEDINPUT
/* internal */
82 } slang_type_qualifier
;
85 typedef enum slang_type_precision_
91 } slang_type_precision
;
95 * The basic shading language types (float, vec4, mat3, etc)
97 typedef enum slang_type_specifier_type_
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
,
131 } slang_type_specifier_type
;
134 extern slang_type_specifier_type
135 slang_type_specifier_type_from_string(const char *);
138 slang_type_specifier_type_to_string(slang_type_specifier_type
);
142 * Describes more sophisticated types, like structs and arrays.
144 typedef struct slang_type_specifier_
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
;
153 slang_type_specifier_ctr(slang_type_specifier
*);
156 slang_type_specifier_dtr(slang_type_specifier
*);
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
);
165 slang_type_specifier_copy(slang_type_specifier
*, const slang_type_specifier
*);
168 slang_type_specifier_equal(const slang_type_specifier
*,
169 const slang_type_specifier
*);
173 slang_type_specifier_compatible(const slang_type_specifier
* x
,
174 const slang_type_specifier
* y
);
177 typedef struct slang_fully_specified_type_
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
;
188 slang_fully_specified_type_construct(slang_fully_specified_type
*);
191 slang_fully_specified_type_destruct(slang_fully_specified_type
*);
194 slang_fully_specified_type_copy(slang_fully_specified_type
*,
195 const slang_fully_specified_type
*);
199 typedef struct slang_typeinfo_
201 GLboolean can_be_referenced
;
202 GLboolean is_swizzled
;
204 slang_type_specifier spec
;
209 slang_typeinfo_construct(slang_typeinfo
*);
212 slang_typeinfo_destruct(slang_typeinfo
*);
216 _slang_typeof_operation(struct slang_operation_
*,
217 const struct slang_name_space_
*,
218 slang_typeinfo
*, slang_atom_pool
*,
219 slang_info_log
*log
);
222 _slang_type_is_matrix(slang_type_specifier_type
);
225 _slang_type_is_vector(slang_type_specifier_type
);
228 _slang_type_is_float_vec_mat(slang_type_specifier_type
);
230 extern slang_type_specifier_type
231 _slang_type_base(slang_type_specifier_type
);
234 _slang_type_dim(slang_type_specifier_type
);
237 _slang_gltype_from_specifier(const slang_type_specifier
*type
);