blob: 917c06743b45b8046b0396db0d17c7abaf6cb654 [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
Ian Romanick261bbc02010-08-12 15:05:39 -070024#include "main/compiler.h"
Eric Anholtac95f2f2010-06-22 10:38:52 -070025#include "ir.h"
Ian Romanickadfb0cd2010-03-10 10:43:16 -080026#include "glsl_parser_extras.h"
Ian Romanick8bde4ce2010-03-19 11:57:24 -070027#include "glsl_symbol_table.h"
Ian Romanickadfb0cd2010-03-10 10:43:16 -080028#include "builtin_variables.h"
29
Ian Romanick22971e92010-06-29 15:29:56 -070030static void generate_ARB_draw_buffers_variables(exec_list *,
31 struct _mesa_glsl_parse_state *,
32 bool, _mesa_glsl_parser_targets);
Ian Romanick9c4b1f22010-06-29 15:10:09 -070033
Ian Romanickc77b2572010-04-07 16:59:46 -070034static ir_variable *
Ian Romanicked0626e2010-06-21 11:42:57 -070035add_variable(const char *name, enum ir_variable_mode mode, int slot,
Ian Romanick3f9a73d2010-04-02 11:59:57 -070036 const glsl_type *type, exec_list *instructions,
Ian Romanick8bde4ce2010-03-19 11:57:24 -070037 glsl_symbol_table *symtab)
Ian Romanickadfb0cd2010-03-10 10:43:16 -080038{
Ian Romanick7e2aa912010-07-19 17:12:42 -070039 ir_variable *var = new(symtab) ir_variable(type, name, mode);
Ian Romanickadfb0cd2010-03-10 10:43:16 -080040
Eric Anholt71df19f2010-04-19 11:10:37 -070041 switch (var->mode) {
Ian Romanicke2f84f02010-06-29 15:19:11 -070042 case ir_var_auto:
Eric Anholt71df19f2010-04-19 11:10:37 -070043 case ir_var_in:
Eric Anholt046bef22010-08-04 20:33:57 -070044 case ir_var_uniform:
Ian Romanickadfb0cd2010-03-10 10:43:16 -080045 var->read_only = true;
Eric Anholt71df19f2010-04-19 11:10:37 -070046 break;
47 case ir_var_inout:
Eric Anholt71df19f2010-04-19 11:10:37 -070048 case ir_var_out:
Eric Anholt71df19f2010-04-19 11:10:37 -070049 break;
50 default:
51 assert(0);
52 break;
53 }
Ian Romanickadfb0cd2010-03-10 10:43:16 -080054
Ian Romanicked0626e2010-06-21 11:42:57 -070055 var->location = slot;
56
Ian Romanickadfb0cd2010-03-10 10:43:16 -080057 /* Once the variable is created an initialized, add it to the symbol table
58 * and add the declaration to the IR stream.
59 */
60 instructions->push_tail(var);
61
Ian Romanick8bde4ce2010-03-19 11:57:24 -070062 symtab->add_variable(var->name, var);
Ian Romanickc77b2572010-04-07 16:59:46 -070063 return var;
Ian Romanickadfb0cd2010-03-10 10:43:16 -080064}
65
Eric Anholt85b5dba2010-07-28 12:23:51 -070066static ir_variable *
67add_uniform(exec_list *instructions,
68 struct _mesa_glsl_parse_state *state,
69 const char *name, const glsl_type *type)
70{
71 return add_variable(name, ir_var_uniform, -1, type, instructions,
72 state->symbols);
73}
Ian Romanick3f9a73d2010-04-02 11:59:57 -070074
75static void
76add_builtin_variable(const builtin_variable *proto, exec_list *instructions,
77 glsl_symbol_table *symtab)
78{
79 /* Create a new variable declaration from the description supplied by
80 * the caller.
81 */
82 const glsl_type *const type = symtab->get_type(proto->type);
83
84 assert(type != NULL);
85
Ian Romanicked0626e2010-06-21 11:42:57 -070086 add_variable(proto->name, proto->mode, proto->slot, type, instructions,
87 symtab);
Ian Romanick3f9a73d2010-04-02 11:59:57 -070088}
89
Eric Anholtf8946692010-07-20 14:03:35 -070090static void
91add_builtin_constant(exec_list *instructions,
92 struct _mesa_glsl_parse_state *state,
93 const char *name, int value)
94{
95 ir_variable *const var = add_variable(name, ir_var_auto,
96 -1, glsl_type::int_type,
97 instructions, state->symbols);
98 var->constant_value = new(var) ir_constant(value);
99}
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700100
Eric Anholt78fe3c92010-03-28 01:46:48 -0700101static void
102generate_110_uniforms(exec_list *instructions,
Ian Romanick127308b2010-07-01 13:30:50 -0700103 struct _mesa_glsl_parse_state *state)
Eric Anholt78fe3c92010-03-28 01:46:48 -0700104{
105 for (unsigned i = 0
106 ; i < Elements(builtin_110_deprecated_uniforms)
107 ; i++) {
108 add_builtin_variable(& builtin_110_deprecated_uniforms[i],
Ian Romanick127308b2010-07-01 13:30:50 -0700109 instructions, state->symbols);
Eric Anholt78fe3c92010-03-28 01:46:48 -0700110 }
111
Eric Anholtf8946692010-07-20 14:03:35 -0700112 add_builtin_constant(instructions, state, "gl_MaxLights",
113 state->Const.MaxLights);
114 add_builtin_constant(instructions, state, "gl_MaxClipPlanes",
115 state->Const.MaxClipPlanes);
116 add_builtin_constant(instructions, state, "gl_MaxTextureUnits",
117 state->Const.MaxTextureUnits);
118 add_builtin_constant(instructions, state, "gl_MaxTextureCoords",
119 state->Const.MaxTextureCoords);
120 add_builtin_constant(instructions, state, "gl_MaxVertexAttribs",
121 state->Const.MaxVertexAttribs);
122 add_builtin_constant(instructions, state, "gl_MaxVertexUniformComponents",
123 state->Const.MaxVertexUniformComponents);
124 add_builtin_constant(instructions, state, "gl_MaxVaryingFloats",
125 state->Const.MaxVaryingFloats);
126 add_builtin_constant(instructions, state, "gl_MaxVertexTextureImageUnits",
127 state->Const.MaxVertexTextureImageUnits);
128 add_builtin_constant(instructions, state, "gl_MaxCombinedTextureImageUnits",
129 state->Const.MaxCombinedTextureImageUnits);
130 add_builtin_constant(instructions, state, "gl_MaxTextureImageUnits",
131 state->Const.MaxTextureImageUnits);
132 add_builtin_constant(instructions, state, "gl_MaxFragmentUniformComponents",
133 state->Const.MaxFragmentUniformComponents);
Ian Romanick127308b2010-07-01 13:30:50 -0700134
Ian Romanick3eba5932010-04-26 14:59:32 -0700135 const glsl_type *const mat4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700136 glsl_type::get_array_instance(glsl_type::mat4_type,
Ian Romanick127308b2010-07-01 13:30:50 -0700137 state->Const.MaxTextureCoords);
Ian Romanick3eba5932010-04-26 14:59:32 -0700138
Eric Anholt85b5dba2010-07-28 12:23:51 -0700139 add_uniform(instructions, state, "gl_TextureMatrix", mat4_array_type);
Eric Anholt78fe3c92010-03-28 01:46:48 -0700140
Kenneth Graunkedbff7b52010-08-07 02:28:40 -0700141 add_uniform(instructions, state, "gl_DepthRange",
Eric Anholt85b5dba2010-07-28 12:23:51 -0700142 state->symbols->get_type("gl_DepthRangeParameters"));
Eric Anholt78fe3c92010-03-28 01:46:48 -0700143
Eric Anholt85b5dba2010-07-28 12:23:51 -0700144 add_uniform(instructions, state, "gl_ClipPlane",
145 glsl_type::get_array_instance(glsl_type::vec4_type,
146 state->Const.MaxClipPlanes));
147 add_uniform(instructions, state, "gl_Point",
148 state->symbols->get_type("gl_PointParameters"));
149
150 const glsl_type *const material_parameters_type =
151 state->symbols->get_type("gl_MaterialParameters");
152 add_uniform(instructions, state, "gl_FrontMaterial", material_parameters_type);
153 add_uniform(instructions, state, "gl_BackMaterial", material_parameters_type);
Eric Anholt78fe3c92010-03-28 01:46:48 -0700154
Eric Anholtaa579432010-05-19 14:09:04 -0700155 const glsl_type *const light_source_array_type =
Eric Anholt73df6362010-07-28 08:18:59 -0700156 glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), state->Const.MaxLights);
Eric Anholtaa579432010-05-19 14:09:04 -0700157
Eric Anholt85b5dba2010-07-28 12:23:51 -0700158 add_uniform(instructions, state, "gl_LightSource", light_source_array_type);
Eric Anholtaa579432010-05-19 14:09:04 -0700159
Eric Anholt85b5dba2010-07-28 12:23:51 -0700160 const glsl_type *const light_model_products_type =
161 state->symbols->get_type("gl_LightModelProducts");
162 add_uniform(instructions, state, "gl_FrontLightModelProduct",
163 light_model_products_type);
164 add_uniform(instructions, state, "gl_BackLightModelProduct",
165 light_model_products_type);
166
167 const glsl_type *const light_products_type =
168 glsl_type::get_array_instance(state->symbols->get_type("gl_LightProducts"),
169 state->Const.MaxLights);
170 add_uniform(instructions, state, "gl_FrontLightProduct", light_products_type);
171 add_uniform(instructions, state, "gl_BackLightProduct", light_products_type);
172
173 add_uniform(instructions, state, "gl_TextureEnvColor",
174 glsl_type::get_array_instance(glsl_type::vec4_type,
175 state->Const.MaxTextureUnits));
176
177 const glsl_type *const texcoords_vec4 =
178 glsl_type::get_array_instance(glsl_type::vec4_type,
179 state->Const.MaxTextureCoords);
180 add_uniform(instructions, state, "gl_EyePlaneS", texcoords_vec4);
181 add_uniform(instructions, state, "gl_EyePlaneT", texcoords_vec4);
182 add_uniform(instructions, state, "gl_EyePlaneR", texcoords_vec4);
183 add_uniform(instructions, state, "gl_EyePlaneQ", texcoords_vec4);
184 add_uniform(instructions, state, "gl_ObjectPlaneS", texcoords_vec4);
185 add_uniform(instructions, state, "gl_ObjectPlaneT", texcoords_vec4);
186 add_uniform(instructions, state, "gl_ObjectPlaneR", texcoords_vec4);
187 add_uniform(instructions, state, "gl_ObjectPlaneQ", texcoords_vec4);
188
189 add_uniform(instructions, state, "gl_Fog",
190 state->symbols->get_type("gl_FogParameters"));
Eric Anholt78fe3c92010-03-28 01:46:48 -0700191}
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800192
193static void
194generate_110_vs_variables(exec_list *instructions,
Ian Romanick22971e92010-06-29 15:29:56 -0700195 struct _mesa_glsl_parse_state *state)
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800196{
197 for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) {
198 add_builtin_variable(& builtin_core_vs_variables[i],
Ian Romanick22971e92010-06-29 15:29:56 -0700199 instructions, state->symbols);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800200 }
201
202 for (unsigned i = 0
203 ; i < Elements(builtin_110_deprecated_vs_variables)
204 ; i++) {
205 add_builtin_variable(& builtin_110_deprecated_vs_variables[i],
Ian Romanick22971e92010-06-29 15:29:56 -0700206 instructions, state->symbols);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800207 }
Ian Romanick127308b2010-07-01 13:30:50 -0700208 generate_110_uniforms(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800209
Ian Romanickcd00d5b2010-07-01 13:17:54 -0700210 /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
211 *
212 * "As with all arrays, indices used to subscript gl_TexCoord must
213 * either be an integral constant expressions, or this array must be
214 * re-declared by the shader with a size. The size can be at most
215 * gl_MaxTextureCoords. Using indexes close to 0 may aid the
216 * implementation in preserving varying resources."
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800217 */
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700218 const glsl_type *const vec4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700219 glsl_type::get_array_instance(glsl_type::vec4_type, 0);
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700220
Ian Romanicked0626e2010-06-21 11:42:57 -0700221 add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type,
Ian Romanick22971e92010-06-29 15:29:56 -0700222 instructions, state->symbols);
223
224 generate_ARB_draw_buffers_variables(instructions, state, false,
225 vertex_shader);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800226}
227
228
229static void
230generate_120_vs_variables(exec_list *instructions,
Ian Romanick22971e92010-06-29 15:29:56 -0700231 struct _mesa_glsl_parse_state *state)
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800232{
233 /* GLSL version 1.20 did not add any built-in variables in the vertex
234 * shader.
235 */
Ian Romanick22971e92010-06-29 15:29:56 -0700236 generate_110_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800237}
238
239
240static void
241generate_130_vs_variables(exec_list *instructions,
Ian Romanick22971e92010-06-29 15:29:56 -0700242 struct _mesa_glsl_parse_state *state)
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800243{
Ian Romanick22971e92010-06-29 15:29:56 -0700244 generate_120_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800245
246 for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) {
247 add_builtin_variable(& builtin_130_vs_variables[i],
Ian Romanick22971e92010-06-29 15:29:56 -0700248 instructions, state->symbols);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800249 }
250
Eric Anholt271e1992010-04-02 23:47:06 -0700251 const glsl_type *const clip_distance_array_type =
Eric Anholt73df6362010-07-28 08:18:59 -0700252 glsl_type::get_array_instance(glsl_type::float_type,
253 state->Const.MaxClipPlanes);
Ian Romanicked0626e2010-06-21 11:42:57 -0700254
255 /* FINISHME: gl_ClipDistance needs a real location assigned. */
256 add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type,
Ian Romanick22971e92010-06-29 15:29:56 -0700257 instructions, state->symbols);
Eric Anholt271e1992010-04-02 23:47:06 -0700258
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800259}
260
261
262static void
263initialize_vs_variables(exec_list *instructions,
264 struct _mesa_glsl_parse_state *state)
265{
266
267 switch (state->language_version) {
268 case 110:
Ian Romanick22971e92010-06-29 15:29:56 -0700269 generate_110_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800270 break;
271 case 120:
Ian Romanick22971e92010-06-29 15:29:56 -0700272 generate_120_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800273 break;
274 case 130:
Ian Romanick22971e92010-06-29 15:29:56 -0700275 generate_130_vs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800276 break;
277 }
278}
279
Eric Anholtb3f743a2010-03-25 14:48:25 -0700280static void
281generate_110_fs_variables(exec_list *instructions,
Ian Romanick5e18b052010-06-29 14:21:05 -0700282 struct _mesa_glsl_parse_state *state)
Eric Anholtb3f743a2010-03-25 14:48:25 -0700283{
284 for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) {
285 add_builtin_variable(& builtin_core_fs_variables[i],
Ian Romanick5e18b052010-06-29 14:21:05 -0700286 instructions, state->symbols);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700287 }
288
Eric Anholt0f09aea2010-03-27 12:48:57 -0700289 for (unsigned i = 0
290 ; i < Elements(builtin_110_deprecated_fs_variables)
291 ; i++) {
292 add_builtin_variable(& builtin_110_deprecated_fs_variables[i],
Ian Romanick5e18b052010-06-29 14:21:05 -0700293 instructions, state->symbols);
Eric Anholt0f09aea2010-03-27 12:48:57 -0700294 }
Ian Romanick127308b2010-07-01 13:30:50 -0700295 generate_110_uniforms(instructions, state);
Eric Anholt0f09aea2010-03-27 12:48:57 -0700296
Ian Romanickcd00d5b2010-07-01 13:17:54 -0700297 /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
298 *
299 * "As with all arrays, indices used to subscript gl_TexCoord must
300 * either be an integral constant expressions, or this array must be
301 * re-declared by the shader with a size. The size can be at most
302 * gl_MaxTextureCoords. Using indexes close to 0 may aid the
303 * implementation in preserving varying resources."
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700304 */
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700305 const glsl_type *const vec4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700306 glsl_type::get_array_instance(glsl_type::vec4_type, 0);
Ian Romanick3f9a73d2010-04-02 11:59:57 -0700307
Ian Romanicked0626e2010-06-21 11:42:57 -0700308 add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type,
Ian Romanick5e18b052010-06-29 14:21:05 -0700309 instructions, state->symbols);
Ian Romanick9c4b1f22010-06-29 15:10:09 -0700310
Ian Romanick22971e92010-06-29 15:29:56 -0700311 generate_ARB_draw_buffers_variables(instructions, state, false,
312 fragment_shader);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700313}
314
Ian Romanickc77b2572010-04-07 16:59:46 -0700315
316static void
Ian Romanick22971e92010-06-29 15:29:56 -0700317generate_ARB_draw_buffers_variables(exec_list *instructions,
318 struct _mesa_glsl_parse_state *state,
319 bool warn, _mesa_glsl_parser_targets target)
Ian Romanickc77b2572010-04-07 16:59:46 -0700320{
Ian Romanick22971e92010-06-29 15:29:56 -0700321 /* gl_MaxDrawBuffers is available in all shader stages.
322 */
Ian Romanicke2f84f02010-06-29 15:19:11 -0700323 ir_variable *const mdb =
324 add_variable("gl_MaxDrawBuffers", ir_var_auto, -1,
325 glsl_type::int_type, instructions, state->symbols);
326
327 if (warn)
328 mdb->warn_extension = "GL_ARB_draw_buffers";
329
330 mdb->constant_value = new(mdb)
331 ir_constant(int(state->Const.MaxDrawBuffers));
332
Ian Romanickc77b2572010-04-07 16:59:46 -0700333
Ian Romanick22971e92010-06-29 15:29:56 -0700334 /* gl_FragData is only available in the fragment shader.
335 */
336 if (target == fragment_shader) {
337 const glsl_type *const vec4_array_type =
Ian Romanickf38d15b2010-07-20 15:33:40 -0700338 glsl_type::get_array_instance(glsl_type::vec4_type,
Ian Romanick22971e92010-06-29 15:29:56 -0700339 state->Const.MaxDrawBuffers);
Ian Romanickc77b2572010-04-07 16:59:46 -0700340
Ian Romanick22971e92010-06-29 15:29:56 -0700341 ir_variable *const fd =
342 add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0,
343 vec4_array_type, instructions, state->symbols);
344
345 if (warn)
346 fd->warn_extension = "GL_ARB_draw_buffers";
347 }
Ian Romanickc77b2572010-04-07 16:59:46 -0700348}
349
350
Eric Anholtb3f743a2010-03-25 14:48:25 -0700351static void
352generate_120_fs_variables(exec_list *instructions,
Ian Romanick5e18b052010-06-29 14:21:05 -0700353 struct _mesa_glsl_parse_state *state)
Eric Anholtb3f743a2010-03-25 14:48:25 -0700354{
Ian Romanick5e18b052010-06-29 14:21:05 -0700355 generate_110_fs_variables(instructions, state);
Eric Anholt152b55e2010-07-07 19:45:22 -0700356
357 for (unsigned i = 0
358 ; i < Elements(builtin_120_fs_variables)
359 ; i++) {
360 add_builtin_variable(& builtin_120_fs_variables[i],
361 instructions, state->symbols);
362 }
Eric Anholtb3f743a2010-03-25 14:48:25 -0700363}
364
365static void
366generate_130_fs_variables(exec_list *instructions,
Ian Romanick5e18b052010-06-29 14:21:05 -0700367 struct _mesa_glsl_parse_state *state)
Eric Anholtb3f743a2010-03-25 14:48:25 -0700368{
Ian Romanick5e18b052010-06-29 14:21:05 -0700369 generate_120_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700370
Ian Romanick8645a952010-04-07 16:47:44 -0700371 const glsl_type *const clip_distance_array_type =
Eric Anholt73df6362010-07-28 08:18:59 -0700372 glsl_type::get_array_instance(glsl_type::float_type,
373 state->Const.MaxClipPlanes);
Ian Romanicked0626e2010-06-21 11:42:57 -0700374
375 /* FINISHME: gl_ClipDistance needs a real location assigned. */
376 add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type,
Ian Romanick5e18b052010-06-29 14:21:05 -0700377 instructions, state->symbols);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700378}
379
380static void
381initialize_fs_variables(exec_list *instructions,
382 struct _mesa_glsl_parse_state *state)
383{
384
385 switch (state->language_version) {
386 case 110:
Ian Romanick5e18b052010-06-29 14:21:05 -0700387 generate_110_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700388 break;
389 case 120:
Ian Romanick5e18b052010-06-29 14:21:05 -0700390 generate_120_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700391 break;
392 case 130:
Ian Romanick5e18b052010-06-29 14:21:05 -0700393 generate_130_fs_variables(instructions, state);
Eric Anholtb3f743a2010-03-25 14:48:25 -0700394 break;
395 }
396}
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800397
398void
399_mesa_glsl_initialize_variables(exec_list *instructions,
400 struct _mesa_glsl_parse_state *state)
401{
402 switch (state->target) {
403 case vertex_shader:
404 initialize_vs_variables(instructions, state);
405 break;
406 case geometry_shader:
Eric Anholtb3f743a2010-03-25 14:48:25 -0700407 break;
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800408 case fragment_shader:
Eric Anholtb3f743a2010-03-25 14:48:25 -0700409 initialize_fs_variables(instructions, state);
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800410 break;
Eric Anholt81f49a72010-04-29 17:57:28 -0700411 case ir_shader:
412 fprintf(stderr, "ir reader has no builtin variables");
413 exit(1);
414 break;
Ian Romanickadfb0cd2010-03-10 10:43:16 -0800415 }
416}