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
;
72 * These only apply to gl_FragCoord, but other layout qualifiers may
73 * appear in the future.
75 typedef enum slang_layout_qualifier_
77 SLANG_LAYOUT_NONE
= 0x0,
78 SLANG_LAYOUT_UPPER_LEFT_BIT
= 0x1,
79 SLANG_LAYOUT_PIXEL_CENTER_INTEGER_BIT
= 0x2
80 } slang_layout_qualifier
;
83 typedef enum slang_type_qualifier_
92 SLANG_QUAL_FIXEDOUTPUT
, /* internal */
93 SLANG_QUAL_FIXEDINPUT
/* internal */
94 } slang_type_qualifier
;
97 typedef enum slang_type_precision_
103 } slang_type_precision
;
107 * The basic shading language types (float, vec4, mat3, etc)
109 typedef enum slang_type_specifier_type_
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
,
147 } slang_type_specifier_type
;
150 extern slang_type_specifier_type
151 slang_type_specifier_type_from_string(const char *);
154 slang_type_specifier_type_to_string(slang_type_specifier_type
);
158 * Describes more sophisticated types, like structs and arrays.
160 typedef struct slang_type_specifier_
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
;
169 slang_type_specifier_ctr(slang_type_specifier
*);
172 slang_type_specifier_dtr(slang_type_specifier
*);
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
);
181 slang_type_specifier_copy(slang_type_specifier
*, const slang_type_specifier
*);
184 slang_type_specifier_equal(const slang_type_specifier
*,
185 const slang_type_specifier
*);
189 slang_type_specifier_compatible(const slang_type_specifier
*x
,
190 const slang_type_specifier
*y
);
193 typedef struct slang_fully_specified_type_
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
;
205 slang_fully_specified_type_construct(slang_fully_specified_type
*);
208 slang_fully_specified_type_destruct(slang_fully_specified_type
*);
211 slang_fully_specified_type_copy(slang_fully_specified_type
*,
212 const slang_fully_specified_type
*);
215 slang_fully_specified_types_compatible(const slang_fully_specified_type
* x
,
216 const slang_fully_specified_type
* y
);
219 typedef struct slang_typeinfo_
221 GLboolean can_be_referenced
;
222 GLboolean is_swizzled
;
224 slang_type_specifier spec
;
229 slang_typeinfo_construct(slang_typeinfo
*);
232 slang_typeinfo_destruct(slang_typeinfo
*);
236 _slang_typeof_operation(struct slang_operation_
*,
237 const struct slang_name_space_
*,
238 slang_typeinfo
*, slang_atom_pool
*,
239 slang_info_log
*log
);
242 _slang_type_is_matrix(slang_type_specifier_type
);
245 _slang_type_is_vector(slang_type_specifier_type
);
248 _slang_type_is_float_vec_mat(slang_type_specifier_type
);
250 extern slang_type_specifier_type
251 _slang_type_base(slang_type_specifier_type
);
254 _slang_type_dim(slang_type_specifier_type
);
257 _slang_gltype_from_specifier(const slang_type_specifier
*type
);