blob: d88cb515b470f8efba94160a7de262d233ea5fc2 [file] [log] [blame]
Ian Romanickadfb0cd2010-03-10 10:43:16 -08001/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
Eric Anholtac95f2f2010-06-22 10:38:52 -070024#include "ir.h"
Ian Romanickadfb0cd2010-03-10 10:43:16 -080025#include "glsl_parser_extras.h"
Ian Romanick8bde4ce2010-03-19 11:57:24 -070026#include "glsl_symbol_table.h"
Ian Romanickadfb0cd2010-03-10 10:43:16 -080027#include "builtin_variables.h"
28
29#ifndef Elements
30#define Elements(x) (sizeof(x)/sizeof(*(x)))
31#endif
32
Ian Romanick22971e92010-06-29 15:29:56 -070033static void generate_ARB_draw_buffers_variables(exec_list *,
34 struct _mesa_glsl_parse_state *,
35 bool, _mesa_glsl_parser_targets);
Ian Romanick9c4b1f22010-06-29 15:10:09 -070036
Ian Romanickc77b2572010-04-07 16:59:46 -070037static ir_variable *
Ian Romanicked0626e2010-06-21 11:42:57 -070038add_variable(const char *name, enum ir_variable_mode mode, int slot,
Ian Romanick3f9a73d2010-04-02 11:59:57 -070039 const glsl_type *type, exec_list *instructions,
Ian Romanick8bde4ce2010-03-19 11:57:24 -070040 glsl_symbol_table *symtab)
Ian Romanickadfb0cd2010-03-10 10:43:16 -080041{
Ian Romanick7e2aa912010-07-19 17:12:42 -070042 ir_variable *var = new(symtab) ir_variable(type, name, mode);
Ian Romanickadfb0cd2010-03-10 10:43:16 -080043
Eric Anholt71df19f2010-04-19 11:10:37 -070044 switch (var->mode) {
Ian Romanicke2f84f02010-06-29 15:19:11 -070045 case ir_var_auto:
Eric Anholt71df19f2010-04-19 11:10:37 -070046 case ir_var_in:
Eric Anholt046bef22010-08-04 20:33:57 -070047 case ir_var_uniform:
Ian Romanickadfb0cd2010-03-10 10:43:16 -080048 var->read_only = true;
Eric Anholt71df19f2010-04-19 11:10:37 -070049 break;
50 case ir_var_inout:
Eric Anholt71df19f2010-04-19 11:10:37 -070051 case ir_var_out:
Eric Anholt71df19f2010-04-19 11:10:37 -070052 break;
53 default:
54 assert(0);
55 break;
56 }
Ian Romanickadfb0cd2010-03-10 10:43:16 -080057
Ian Romanicked0626e2010-06-21 11:42:57 -070058 var->location = slot;
59
Ian Romanickadfb0cd2010-03-10 10:43:16 -080060 /* Once the variable is created an initialized, add it to the symbol table
61 * and add the declaration to the IR stream.
62 */
63 instructions->push_tail(var);
64
Ian Romanick8bde4ce2010-03-19 11:57:24 -070065 symtab->add_variable(var->name, var);
Ian Romanickc77b2572010-04-07 16:59:46 -070066 return var;
Ian Romanickadfb0cd2010-03-10 10:43:16 -080067}
68
Eric Anholt85b5dba2010-07-28 12:23:51 -070069static ir_variable *
70add_uniform(exec_list *instructions,
71 struct _mesa_glsl_parse_state *state,
72 const char *name, const glsl_type *type)
73{
74 return add_variable(name, ir_var_uniform, -1, type, instructions,
75 state->symbols);
76}
Ian Romanick3f9a73d2010-04-02 11:59:57 -070077
78static void
79add_builtin_variable(const builtin_variable *proto, exec_list *instructions,
80 glsl_symbol_table *symtab)
81{
82 /* Create a new variable declaration from the description supplied by
83 * the caller.
84 */
85 const glsl_type *const type = symtab->get_type(proto->type);
86
87 assert(type != NULL);
88
Ian Romanicked0626e2010-06-21 11:42:57 -070089 add_variable(proto->name, proto->mode, proto->slot, type, instructions,
90 symtab);
Ian Romanick3f9a73d2010-04-02 11:59:57 -070091}
92
Eric Anholtf8946692010-07-20 14:03:35 -070093static void
94add_builtin_constant(exec_list *instructions,
95 struct _mesa_glsl_parse_state *state,
96 const char *name, int value)
97{
98 ir_variable *const var = add_variable(name, ir_var_auto,
99 -1, glsl_type::int_type,
100 instructions, state->symbols);
101 var->constant_value = new(var) ir_constant(value);
102}
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700103
Eric Anholt78fe3c92010-03-28 01:46:48 -0700104static void
105generate_110_uniforms(exec_list *instructions,
Ian Romanick127308b2010-07-01 13:30:50 -0700106 struct _mesa_glsl_parse_state *state)
Eric Anholt78fe3c92010-03-28 01:46:48 -0700107{
108 for (unsigned i = 0
109 ; i < Elements(builtin_110_deprecated_uniforms)
110 ; i++) {
111 add_builtin_variable(& builtin_110_deprecated_uniforms[i],
Ian Romanick127308b2010-07-01 13:30:50 -0700112 instructions, state->symbols);
Eric Anholt78fe3c92010-03-28 01:46:48 -0700113 }
114
Eric Anholtf8946692010-07-20 14:03:35 -0700115 add_builtin_constant(instructions, state, "gl_MaxLights",
116 state->Const.MaxLights);
117 add_builtin_constant(instructions, state, "gl_MaxClipPlanes",
118 state->Const.MaxClipPlanes);
119 add_builtin_constant(instructions, state, "gl_MaxTextureUnits",
120 state->Const.MaxTextureUnits);
121 add_builtin_constant(instructions, state, "gl_MaxTextureCoords",
122 state->Const.MaxTextureCoords);
123 add_builtin_constant(instructions, state, "gl_MaxVertexAttribs",
124 state->Const.MaxVertexAttribs);
125 add_builtin_constant(instructions, state, "gl_MaxVertexUniformComponents",
126 state->Const.MaxVertexUniformComponents);
127 add_builtin_constant(instructions, state, "gl_MaxVaryingFloats",
128 state->Const.MaxVaryingFloats);
129 add_builtin_constant(instructions, state, "gl_MaxVertexTextureImageUnits",
130 state->Const.MaxVertexTextureImageUnits);
131 add_builtin_constant(instructions, state, "gl_MaxCombinedTextureImageUnits",
132 state->Const.MaxCombinedTextureImageUnits);
133 add_builtin_constant(instructions, state, "gl_MaxTextureImageUnits",
134 state->Const.MaxTextureImageUnits);
135 add_builtin_constant(instructions, state, "gl_MaxFragmentUniformComponents",
136 state->Const.MaxFragmentUniformComponents);
Ian Romanick127308b2010-07-01 13:30:50 -0700137
Ian Romanick3eba5932010-04-26 14:59:32 -0700138 const glsl_type *const mat4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700139 glsl_type::get_array_instance(glsl_type::mat4_type,
Ian Romanick127308b2010-07-01 13:30:50 -0700140 state->Const.MaxTextureCoords);
Ian Romanick3eba5932010-04-26 14:59:32 -0700141
Eric Anholt85b5dba2010-07-28 12:23:51 -0700142 add_uniform(instructions, state, "gl_TextureMatrix", mat4_array_type);
Eric Anholt78fe3c92010-03-28 01:46:48 -0700143
Kenneth Graunkedbff7b52010-08-07 02:28:40 -0700144 add_uniform(instructions, state, "gl_DepthRange",
Eric Anholt85b5dba2010-07-28 12:23:51 -0700145 state->symbols->get_type("gl_DepthRangeParameters"));
Eric Anholt78fe3c92010-03-28 01:46:48 -0700146
Eric Anholt85b5dba2010-07-28 12:23:51 -0700147 add_uniform(instructions, state, "gl_ClipPlane",
148 glsl_type::get_array_instance(glsl_type::vec4_type,
149 state->Const.MaxClipPlanes));
150 add_uniform(instructions, state, "gl_Point",
151 state->symbols->get_type("gl_PointParameters"));
152
153 const glsl_type *const material_parameters_type =
154 state->symbols->get_type("gl_MaterialParameters");
155 add_uniform(instructions, state, "gl_FrontMaterial", material_parameters_type);
156 add_uniform(instructions, state, "gl_BackMaterial", material_parameters_type);
Eric Anholt78fe3c92010-03-28 01:46:48 -0700157
Eric Anholtaa579432010-05-19 14:09:04 -0700158 const glsl_type *const light_source_array_type =
Eric Anholt73df6362010-07-28 08:18:59 -0700159 glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), state->Const.MaxLights);
Eric Anholtaa579432010-05-19 14:09:04 -0700160
Eric Anholt85b5dba2010-07-28 12:23:51 -0700161 add_uniform(instructions, state, "gl_LightSource", light_source_array_type);
Eric Anholtaa579432010-05-19 14:09:04 -0700162
Eric Anholt85b5dba2010-07-28 12:23:51 -0700163 const glsl_type *const light_model_products_type =
164 state->symbols->get_type("gl_LightModelProducts");
165 add_uniform(instructions, state, "gl_FrontLightModelProduct",
166 light_model_products_type);
167 add_uniform(instructions, state, "gl_BackLightModelProduct",
168 light_model_products_type);
169
170 const glsl_type *const light_products_type =
171 glsl_type::get_array_instance(state->symbols->get_type("gl_LightProducts"),
172 state->Const.MaxLights);
173 add_uniform(instructions, state, "gl_FrontLightProduct", light_products_type);
174 add_uniform(instructions, state, "gl_BackLightProduct", light_products_type);
175
176 add_uniform(instructions, state, "gl_TextureEnvColor",
177 glsl_type::get_array_instance(glsl_type::vec4_type,
178 state->Const.MaxTextureUnits));
179
180 const glsl_type *const texcoords_vec4 =
181 glsl_type::get_array_instance(glsl_type::vec4_type,
182 state->Const.MaxTextureCoords);
183 add_uniform(instructions, state, "gl_EyePlaneS", texcoords_vec4);
184 add_uniform(instructions, state, "gl_EyePlaneT", texcoords_vec4);
185 add_uniform(instructions, state, "gl_EyePlaneR", texcoords_vec4);
186 add_uniform(instructions, state, "gl_EyePlaneQ", texcoords_vec4);
187 add_uniform(instructions, state, "gl_ObjectPlaneS", texcoords_vec4);
188 add_uniform(instructions, state, "gl_ObjectPlaneT", texcoords_vec4);
189 add_uniform(instructions, state, "gl_ObjectPlaneR", texcoords_vec4);
190 add_uniform(instructions, state, "gl_ObjectPlaneQ", texcoords_vec4);
191
192 add_uniform(instructions, state, "gl_Fog",
193 state->symbols->get_type("gl_FogParameters"));
Eric Anholt78fe3c92010-03-28 01:46:48 -0700194}
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800195
196static void
197generate_110_vs_variables(exec_list *instructions,
Ian Romanick22971e92010-06-29 15:29:56 -0700198 struct _mesa_glsl_parse_state *state)
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800199{
200 for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) {
201 add_builtin_variable(& builtin_core_vs_variables[i],
Ian Romanick22971e92010-06-29 15:29:56 -0700202 instructions, state->symbols);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800203 }
204
205 for (unsigned i = 0
206 ; i < Elements(builtin_110_deprecated_vs_variables)
207 ; i++) {
208 add_builtin_variable(& builtin_110_deprecated_vs_variables[i],
Ian Romanick22971e92010-06-29 15:29:56 -0700209 instructions, state->symbols);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800210 }
Ian Romanick127308b2010-07-01 13:30:50 -0700211 generate_110_uniforms(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800212
Ian Romanickcd00d5b2010-07-01 13:17:54 -0700213 /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
214 *
215 * "As with all arrays, indices used to subscript gl_TexCoord must
216 * either be an integral constant expressions, or this array must be
217 * re-declared by the shader with a size. The size can be at most
218 * gl_MaxTextureCoords. Using indexes close to 0 may aid the
219 * implementation in preserving varying resources."
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800220 */
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700221 const glsl_type *const vec4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700222 glsl_type::get_array_instance(glsl_type::vec4_type, 0);
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700223
Ian Romanicked0626e2010-06-21 11:42:57 -0700224 add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type,
Ian Romanick22971e92010-06-29 15:29:56 -0700225 instructions, state->symbols);
226
227 generate_ARB_draw_buffers_variables(instructions, state, false,
228 vertex_shader);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800229}
230
231
232static void
233generate_120_vs_variables(exec_list *instructions,
Ian Romanick22971e92010-06-29 15:29:56 -0700234 struct _mesa_glsl_parse_state *state)
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800235{
236 /* GLSL version 1.20 did not add any built-in variables in the vertex
237 * shader.
238 */
Ian Romanick22971e92010-06-29 15:29:56 -0700239 generate_110_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800240}
241
242
243static void
244generate_130_vs_variables(exec_list *instructions,
Ian Romanick22971e92010-06-29 15:29:56 -0700245 struct _mesa_glsl_parse_state *state)
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800246{
Ian Romanick22971e92010-06-29 15:29:56 -0700247 generate_120_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800248
249 for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) {
250 add_builtin_variable(& builtin_130_vs_variables[i],
Ian Romanick22971e92010-06-29 15:29:56 -0700251 instructions, state->symbols);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800252 }
253
Eric Anholt271e1992010-04-02 23:47:06 -0700254 const glsl_type *const clip_distance_array_type =
Eric Anholt73df6362010-07-28 08:18:59 -0700255 glsl_type::get_array_instance(glsl_type::float_type,
256 state->Const.MaxClipPlanes);
Ian Romanicked0626e2010-06-21 11:42:57 -0700257
258 /* FINISHME: gl_ClipDistance needs a real location assigned. */
259 add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type,
Ian Romanick22971e92010-06-29 15:29:56 -0700260 instructions, state->symbols);
Eric Anholt271e1992010-04-02 23:47:06 -0700261
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800262}
263
264
265static void
266initialize_vs_variables(exec_list *instructions,
267 struct _mesa_glsl_parse_state *state)
268{
269
270 switch (state->language_version) {
271 case 110:
Ian Romanick22971e92010-06-29 15:29:56 -0700272 generate_110_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800273 break;
274 case 120:
Ian Romanick22971e92010-06-29 15:29:56 -0700275 generate_120_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800276 break;
277 case 130:
Ian Romanick22971e92010-06-29 15:29:56 -0700278 generate_130_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800279 break;
280 }
281}
282
Eric Anholtb3f743a2010-03-25 14:48:25 -0700283static void
284generate_110_fs_variables(exec_list *instructions,
Ian Romanick5e18b052010-06-29 14:21:05 -0700285 struct _mesa_glsl_parse_state *state)
Eric Anholtb3f743a2010-03-25 14:48:25 -0700286{
287 for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) {
288 add_builtin_variable(& builtin_core_fs_variables[i],
Ian Romanick5e18b052010-06-29 14:21:05 -0700289 instructions, state->symbols);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700290 }
291
Eric Anholt0f09aea2010-03-27 12:48:57 -0700292 for (unsigned i = 0
293 ; i < Elements(builtin_110_deprecated_fs_variables)
294 ; i++) {
295 add_builtin_variable(& builtin_110_deprecated_fs_variables[i],
Ian Romanick5e18b052010-06-29 14:21:05 -0700296 instructions, state->symbols);
Eric Anholt0f09aea2010-03-27 12:48:57 -0700297 }
Ian Romanick127308b2010-07-01 13:30:50 -0700298 generate_110_uniforms(instructions, state);
Eric Anholt0f09aea2010-03-27 12:48:57 -0700299
Ian Romanickcd00d5b2010-07-01 13:17:54 -0700300 /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
301 *
302 * "As with all arrays, indices used to subscript gl_TexCoord must
303 * either be an integral constant expressions, or this array must be
304 * re-declared by the shader with a size. The size can be at most
305 * gl_MaxTextureCoords. Using indexes close to 0 may aid the
306 * implementation in preserving varying resources."
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700307 */
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700308 const glsl_type *const vec4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700309 glsl_type::get_array_instance(glsl_type::vec4_type, 0);
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700310
Ian Romanicked0626e2010-06-21 11:42:57 -0700311 add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type,
Ian Romanick5e18b052010-06-29 14:21:05 -0700312 instructions, state->symbols);
Ian Romanick9c4b1f22010-06-29 15:10:09 -0700313
Ian Romanick22971e92010-06-29 15:29:56 -0700314 generate_ARB_draw_buffers_variables(instructions, state, false,
315 fragment_shader);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700316}
317
Ian Romanickc77b2572010-04-07 16:59:46 -0700318
319static void
Ian Romanick22971e92010-06-29 15:29:56 -0700320generate_ARB_draw_buffers_variables(exec_list *instructions,
321 struct _mesa_glsl_parse_state *state,
322 bool warn, _mesa_glsl_parser_targets target)
Ian Romanickc77b2572010-04-07 16:59:46 -0700323{
Ian Romanick22971e92010-06-29 15:29:56 -0700324 /* gl_MaxDrawBuffers is available in all shader stages.
325 */
Ian Romanicke2f84f02010-06-29 15:19:11 -0700326 ir_variable *const mdb =
327 add_variable("gl_MaxDrawBuffers", ir_var_auto, -1,
328 glsl_type::int_type, instructions, state->symbols);
329
330 if (warn)
331 mdb->warn_extension = "GL_ARB_draw_buffers";
332
333 mdb->constant_value = new(mdb)
334 ir_constant(int(state->Const.MaxDrawBuffers));
335
Ian Romanickc77b2572010-04-07 16:59:46 -0700336
Ian Romanick22971e92010-06-29 15:29:56 -0700337 /* gl_FragData is only available in the fragment shader.
338 */
339 if (target == fragment_shader) {
340 const glsl_type *const vec4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700341 glsl_type::get_array_instance(glsl_type::vec4_type,
Ian Romanick22971e92010-06-29 15:29:56 -0700342 state->Const.MaxDrawBuffers);
Ian Romanickc77b2572010-04-07 16:59:46 -0700343
Ian Romanick22971e92010-06-29 15:29:56 -0700344 ir_variable *const fd =
345 add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0,
346 vec4_array_type, instructions, state->symbols);
347
348 if (warn)
349 fd->warn_extension = "GL_ARB_draw_buffers";
350 }
Ian Romanickc77b2572010-04-07 16:59:46 -0700351}
352
353
Eric Anholtb3f743a2010-03-25 14:48:25 -0700354static void
355generate_120_fs_variables(exec_list *instructions,
Ian Romanick5e18b052010-06-29 14:21:05 -0700356 struct _mesa_glsl_parse_state *state)
Eric Anholtb3f743a2010-03-25 14:48:25 -0700357{
Ian Romanick5e18b052010-06-29 14:21:05 -0700358 generate_110_fs_variables(instructions, state);
Eric Anholt152b55e2010-07-07 19:45:22 -0700359
360 for (unsigned i = 0
361 ; i < Elements(builtin_120_fs_variables)
362 ; i++) {
363 add_builtin_variable(& builtin_120_fs_variables[i],
364 instructions, state->symbols);
365 }
Eric Anholtb3f743a2010-03-25 14:48:25 -0700366}
367
368static void
369generate_130_fs_variables(exec_list *instructions,
Ian Romanick5e18b052010-06-29 14:21:05 -0700370 struct _mesa_glsl_parse_state *state)
Eric Anholtb3f743a2010-03-25 14:48:25 -0700371{
Ian Romanick5e18b052010-06-29 14:21:05 -0700372 generate_120_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700373
Ian Romanick8645a952010-04-07 16:47:44 -0700374 const glsl_type *const clip_distance_array_type =
Eric Anholt73df6362010-07-28 08:18:59 -0700375 glsl_type::get_array_instance(glsl_type::float_type,
376 state->Const.MaxClipPlanes);
Ian Romanicked0626e2010-06-21 11:42:57 -0700377
378 /* FINISHME: gl_ClipDistance needs a real location assigned. */
379 add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type,
Ian Romanick5e18b052010-06-29 14:21:05 -0700380 instructions, state->symbols);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700381}
382
383static void
384initialize_fs_variables(exec_list *instructions,
385 struct _mesa_glsl_parse_state *state)
386{
387
388 switch (state->language_version) {
389 case 110:
Ian Romanick5e18b052010-06-29 14:21:05 -0700390 generate_110_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700391 break;
392 case 120:
Ian Romanick5e18b052010-06-29 14:21:05 -0700393 generate_120_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700394 break;
395 case 130:
Ian Romanick5e18b052010-06-29 14:21:05 -0700396 generate_130_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700397 break;
398 }
399}
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800400
401void
402_mesa_glsl_initialize_variables(exec_list *instructions,
403 struct _mesa_glsl_parse_state *state)
404{
405 switch (state->target) {
406 case vertex_shader:
407 initialize_vs_variables(instructions, state);
408 break;
409 case geometry_shader:
Eric Anholtb3f743a2010-03-25 14:48:25 -0700410 break;
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800411 case fragment_shader:
Eric Anholtb3f743a2010-03-25 14:48:25 -0700412 initialize_fs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800413 break;
Eric Anholt81f49a72010-04-29 17:57:28 -0700414 case ir_shader:
415 fprintf(stderr, "ir reader has no builtin variables");
416 exit(1);
417 break;
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800418 }
419}