summaryrefslogtreecommitdiff
path: root/src/mesa/slang/slang_typeinfo.h
blob: 9a6407a31bf23e4e1eafeabe34aa5238c4b706c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
 * Mesa 3-D graphics library
 * Version:  6.5
 *
 * Copyright (C) 2005-2006  Brian Paul   All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef SLANG_TYPEINFO_H
#define SLANG_TYPEINFO_H 1

#include "main/imports.h"
#include "main/mtypes.h"
#include "slang_log.h"
#include "slang_utility.h"
#include "slang_vartable.h"


struct slang_operation_;

struct slang_name_space_;



/**
 * Holds complete information about vector swizzle - the <swizzle>
 * array contains vector component source indices, where 0 is "x", 1
 * is "y", 2 is "z" and 3 is "w".
 * Example: "xwz" --> { 3, { 0, 3, 2, not used } }.
 */
typedef struct slang_swizzle_
{
   GLuint num_components;
   GLuint swizzle[4];
} slang_swizzle;

extern GLboolean
_slang_is_swizzle(const char *field, GLuint rows, slang_swizzle *swz);


typedef enum slang_type_variant_
{
   SLANG_VARIANT,    /* the default */
   SLANG_INVARIANT   /* indicates the "invariant" keyword */
} slang_type_variant;


typedef enum slang_type_centroid_
{
   SLANG_CENTER,    /* the default */
   SLANG_CENTROID   /* indicates the "centroid" keyword */
} slang_type_centroid;


/**
 * These only apply to gl_FragCoord, but other layout qualifiers may
 * appear in the future.
 */
typedef enum slang_layout_qualifier_
{
   SLANG_LAYOUT_NONE                      = 0x0,
   SLANG_LAYOUT_UPPER_LEFT_BIT            = 0x1,
   SLANG_LAYOUT_PIXEL_CENTER_INTEGER_BIT  = 0x2
} slang_layout_qualifier;


typedef enum slang_type_qualifier_
{
   SLANG_QUAL_NONE,
   SLANG_QUAL_CONST,
   SLANG_QUAL_ATTRIBUTE,
   SLANG_QUAL_VARYING,
   SLANG_QUAL_UNIFORM,
   SLANG_QUAL_OUT,
   SLANG_QUAL_INOUT,
   SLANG_QUAL_FIXEDOUTPUT,      /* internal */
   SLANG_QUAL_FIXEDINPUT        /* internal */
} slang_type_qualifier;


typedef enum slang_type_precision_
{
   SLANG_PREC_DEFAULT,
   SLANG_PREC_LOW,
   SLANG_PREC_MEDIUM,
   SLANG_PREC_HIGH
} slang_type_precision;


/**
 * The basic shading language types (float, vec4, mat3, etc)
 */
typedef enum slang_type_specifier_type_
{
   SLANG_SPEC_VOID,
   SLANG_SPEC_BOOL,
   SLANG_SPEC_BVEC2,
   SLANG_SPEC_BVEC3,
   SLANG_SPEC_BVEC4,
   SLANG_SPEC_INT,
   SLANG_SPEC_IVEC2,
   SLANG_SPEC_IVEC3,
   SLANG_SPEC_IVEC4,
   SLANG_SPEC_FLOAT,
   SLANG_SPEC_VEC2,
   SLANG_SPEC_VEC3,
   SLANG_SPEC_VEC4,
   SLANG_SPEC_MAT2,
   SLANG_SPEC_MAT3,
   SLANG_SPEC_MAT4,
   SLANG_SPEC_MAT23,
   SLANG_SPEC_MAT32,
   SLANG_SPEC_MAT24,
   SLANG_SPEC_MAT42,
   SLANG_SPEC_MAT34,
   SLANG_SPEC_MAT43,
   SLANG_SPEC_SAMPLER_1D,
   SLANG_SPEC_SAMPLER_2D,
   SLANG_SPEC_SAMPLER_3D,
   SLANG_SPEC_SAMPLER_CUBE,
   SLANG_SPEC_SAMPLER_RECT,
   SLANG_SPEC_SAMPLER_1D_SHADOW,
   SLANG_SPEC_SAMPLER_2D_SHADOW,
   SLANG_SPEC_SAMPLER_RECT_SHADOW,
   SLANG_SPEC_SAMPLER_1D_ARRAY,
   SLANG_SPEC_SAMPLER_2D_ARRAY,
   SLANG_SPEC_SAMPLER_1D_ARRAY_SHADOW,
   SLANG_SPEC_SAMPLER_2D_ARRAY_SHADOW,
   SLANG_SPEC_STRUCT,
   SLANG_SPEC_ARRAY
} slang_type_specifier_type;


extern slang_type_specifier_type
slang_type_specifier_type_from_string(const char *);

extern const char *
slang_type_specifier_type_to_string(slang_type_specifier_type);


/**
 * Describes more sophisticated types, like structs and arrays.
 */
typedef struct slang_type_specifier_
{
   slang_type_specifier_type type;
   struct slang_struct_ *_struct;         /**< if type == SLANG_SPEC_STRUCT */
   struct slang_type_specifier_ *_array;  /**< if type == SLANG_SPEC_ARRAY */
} slang_type_specifier;


extern GLvoid
slang_type_specifier_ctr(slang_type_specifier *);

extern GLvoid
slang_type_specifier_dtr(slang_type_specifier *);

extern slang_type_specifier *
slang_type_specifier_new(slang_type_specifier_type type,
                         struct slang_struct_ *_struct,
                         struct slang_type_specifier_ *_array);


extern GLboolean
slang_type_specifier_copy(slang_type_specifier *, const slang_type_specifier *);

extern GLboolean
slang_type_specifier_equal(const slang_type_specifier *,
                           const slang_type_specifier *);


extern GLboolean
slang_type_specifier_compatible(const slang_type_specifier *x,
                                const slang_type_specifier *y);


typedef struct slang_fully_specified_type_
{
   slang_type_qualifier qualifier;
   slang_type_specifier specifier;
   slang_type_precision precision;
   slang_type_variant variant;
   slang_type_centroid centroid;
   slang_layout_qualifier layout;
   GLint array_len;           /**< -1 if not an array type */
} slang_fully_specified_type;

extern int
slang_fully_specified_type_construct(slang_fully_specified_type *);

extern void
slang_fully_specified_type_destruct(slang_fully_specified_type *);

extern int
slang_fully_specified_type_copy(slang_fully_specified_type *,
				const slang_fully_specified_type *);

GLboolean
slang_fully_specified_types_compatible(const slang_fully_specified_type * x,
                                       const slang_fully_specified_type * y);


typedef struct slang_typeinfo_
{
   GLboolean can_be_referenced;
   GLboolean is_swizzled;
   slang_swizzle swz;
   slang_type_specifier spec;
   GLuint array_len;
} slang_typeinfo;

extern GLboolean
slang_typeinfo_construct(slang_typeinfo *);

extern GLvoid
slang_typeinfo_destruct(slang_typeinfo *);


extern GLboolean
_slang_typeof_operation(struct slang_operation_ *,
                         const struct slang_name_space_ *,
                         slang_typeinfo *, slang_atom_pool *,
                         slang_info_log *log);

extern GLboolean
_slang_type_is_matrix(slang_type_specifier_type);

extern GLboolean
_slang_type_is_vector(slang_type_specifier_type);

extern GLboolean
_slang_type_is_float_vec_mat(slang_type_specifier_type);

extern slang_type_specifier_type
_slang_type_base(slang_type_specifier_type);

extern GLuint
_slang_type_dim(slang_type_specifier_type);

extern GLenum
_slang_gltype_from_specifier(const slang_type_specifier *type);

#endif