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_
;
39 * Holds complete information about vector swizzle - the <swizzle>
40 * array contains vector component source indices, where 0 is "x", 1
41 * is "y", 2 is "z" and 3 is "w".
42 * Example: "xwz" --> { 3, { 0, 3, 2, not used } }.
44 typedef struct slang_swizzle_
46 GLuint num_components
;
50 typedef struct slang_name_space_
52 struct slang_function_scope_
*funcs
;
53 struct slang_struct_scope_
*structs
;
54 struct slang_variable_scope_
*vars
;
58 typedef struct slang_assemble_ctx_
60 slang_atom_pool
*atoms
;
61 slang_name_space space
;
62 struct gl_program
*program
;
63 slang_var_table
*vartable
;
65 struct slang_label_
*curFuncEndLabel
;
66 struct slang_ir_node_
*CurLoop
;
67 struct slang_function_
*CurFunction
;
71 extern struct slang_function_
*
72 _slang_locate_function(const struct slang_function_scope_
*funcs
,
73 slang_atom name
, struct slang_operation_
*params
,
75 const slang_name_space
*space
,
76 slang_atom_pool
*atoms
, slang_info_log
*log
);
80 _slang_is_swizzle(const char *field
, GLuint rows
, slang_swizzle
*swz
);
83 _slang_is_swizzle_mask(const slang_swizzle
*swz
, GLuint rows
);
86 _slang_multiply_swizzles(slang_swizzle
*, const slang_swizzle
*,
87 const slang_swizzle
*);
91 * The basic shading language types (float, vec4, mat3, etc)
93 typedef enum slang_type_specifier_type_
117 SLANG_SPEC_SAMPLER1D
,
118 SLANG_SPEC_SAMPLER2D
,
119 SLANG_SPEC_SAMPLER3D
,
120 SLANG_SPEC_SAMPLERCUBE
,
121 SLANG_SPEC_SAMPLER2DRECT
,
122 SLANG_SPEC_SAMPLER1DSHADOW
,
123 SLANG_SPEC_SAMPLER2DSHADOW
,
124 SLANG_SPEC_SAMPLER2DRECTSHADOW
,
127 } slang_type_specifier_type
;
131 * Describes more sophisticated types, like structs and arrays.
133 typedef struct slang_type_specifier_
135 slang_type_specifier_type type
;
136 struct slang_struct_
*_struct
; /**< used if type == spec_struct */
137 struct slang_type_specifier_
*_array
; /**< used if type == spec_array */
138 } slang_type_specifier
;
142 slang_type_specifier_ctr(slang_type_specifier
*);
145 slang_type_specifier_dtr(slang_type_specifier
*);
148 slang_type_specifier_copy(slang_type_specifier
*, const slang_type_specifier
*);
151 slang_type_specifier_equal(const slang_type_specifier
*,
152 const slang_type_specifier
*);
155 typedef struct slang_typeinfo_
157 GLboolean can_be_referenced
;
158 GLboolean is_swizzled
;
160 slang_type_specifier spec
;
165 slang_typeinfo_construct(slang_typeinfo
*);
168 slang_typeinfo_destruct(slang_typeinfo
*);
172 * Retrieves type information about an operation.
173 * Returns GL_TRUE on success.
174 * Returns GL_FALSE otherwise.
177 _slang_typeof_operation(const slang_assemble_ctx
*,
178 struct slang_operation_
*,
182 _slang_typeof_operation_(struct slang_operation_
*,
183 const slang_name_space
*,
184 slang_typeinfo
*, slang_atom_pool
*,
185 slang_info_log
*log
);
188 _slang_type_is_matrix(slang_type_specifier_type
);
191 _slang_type_is_vector(slang_type_specifier_type
);
193 extern slang_type_specifier_type
194 _slang_type_base(slang_type_specifier_type
);
197 _slang_type_dim(slang_type_specifier_type
);
200 _slang_gltype_from_specifier(const slang_type_specifier
*type
);