2 * Copyright © 2008, 2009 Intel Corporation
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:
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
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.
29 #include "main/core.h" /* for struct gl_context */
30 #include "main/context.h"
35 #include "glsl_parser_extras.h"
36 #include "glsl_parser.h"
37 #include "ir_optimization.h"
38 #include "loop_analysis.h"
41 * Format a short human-readable description of the given GLSL version.
44 glsl_compute_version_string(void *mem_ctx
, bool is_es
, unsigned version
)
46 return ralloc_asprintf(mem_ctx
, "GLSL%s %d.%02d", is_es
? " ES" : "",
47 version
/ 100, version
% 100);
50 _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context
*_ctx
,
51 GLenum target
, void *mem_ctx
)
55 case GL_VERTEX_SHADER
: this->target
= vertex_shader
; break;
56 case GL_FRAGMENT_SHADER
: this->target
= fragment_shader
; break;
57 case GL_GEOMETRY_SHADER
: this->target
= geometry_shader
; break;
61 this->translation_unit
.make_empty();
62 this->symbols
= new(mem_ctx
) glsl_symbol_table
;
63 this->info_log
= ralloc_strdup(mem_ctx
, "");
65 this->loop_nesting_ast
= NULL
;
66 this->switch_state
.switch_nesting_ast
= NULL
;
68 this->num_builtins_to_link
= 0;
70 /* Set default language version and extensions */
71 this->language_version
= 110;
72 this->es_shader
= false;
73 this->ARB_texture_rectangle_enable
= true;
75 /* OpenGL ES 2.0 has different defaults from desktop GL. */
76 if (ctx
->API
== API_OPENGLES2
) {
77 this->language_version
= 100;
78 this->es_shader
= true;
79 this->ARB_texture_rectangle_enable
= false;
82 this->extensions
= &ctx
->Extensions
;
84 this->Const
.MaxLights
= ctx
->Const
.MaxLights
;
85 this->Const
.MaxClipPlanes
= ctx
->Const
.MaxClipPlanes
;
86 this->Const
.MaxTextureUnits
= ctx
->Const
.MaxTextureUnits
;
87 this->Const
.MaxTextureCoords
= ctx
->Const
.MaxTextureCoordUnits
;
88 this->Const
.MaxVertexAttribs
= ctx
->Const
.VertexProgram
.MaxAttribs
;
89 this->Const
.MaxVertexUniformComponents
= ctx
->Const
.VertexProgram
.MaxUniformComponents
;
90 this->Const
.MaxVaryingFloats
= ctx
->Const
.MaxVarying
* 4;
91 this->Const
.MaxVertexTextureImageUnits
= ctx
->Const
.MaxVertexTextureImageUnits
;
92 this->Const
.MaxCombinedTextureImageUnits
= ctx
->Const
.MaxCombinedTextureImageUnits
;
93 this->Const
.MaxTextureImageUnits
= ctx
->Const
.MaxTextureImageUnits
;
94 this->Const
.MaxFragmentUniformComponents
= ctx
->Const
.FragmentProgram
.MaxUniformComponents
;
96 this->Const
.MaxDrawBuffers
= ctx
->Const
.MaxDrawBuffers
;
98 const unsigned lowest_version
=
99 (ctx
->API
== API_OPENGLES2
) || ctx
->Extensions
.ARB_ES2_compatibility
101 const unsigned highest_version
=
102 _mesa_is_desktop_gl(ctx
) ? ctx
->Const
.GLSLVersion
: 100;
103 char *supported
= ralloc_strdup(this, "");
105 for (unsigned ver
= lowest_version
; ver
<= highest_version
; ver
+= 10) {
106 const char *const prefix
= (ver
== lowest_version
)
108 : ((ver
== highest_version
) ? ", and " : ", ");
110 ralloc_asprintf_append(& supported
, "%s%d.%02d%s",
112 ver
/ 100, ver
% 100,
113 (ver
== 100) ? " ES" : "");
116 this->supported_version_string
= supported
;
118 if (ctx
->Const
.ForceGLSLExtensionsWarn
)
119 _mesa_glsl_process_extension("all", NULL
, "warn", NULL
, this);
121 this->default_uniform_qualifier
= new(this) ast_type_qualifier();
122 this->default_uniform_qualifier
->flags
.q
.shared
= 1;
123 this->default_uniform_qualifier
->flags
.q
.column_major
= 1;
127 _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target
)
130 case vertex_shader
: return "vertex";
131 case fragment_shader
: return "fragment";
132 case geometry_shader
: return "geometry";
135 assert(!"Should not get here.");
139 /* This helper function will append the given message to the shader's
140 info log and report it via GL_ARB_debug_output. Per that extension,
141 'type' is one of the enum values classifying the message, and
142 'id' is the implementation-defined ID of the given message. */
144 _mesa_glsl_msg(const YYLTYPE
*locp
, _mesa_glsl_parse_state
*state
,
145 GLenum type
, GLuint id
, const char *fmt
, va_list ap
)
147 bool error
= (type
== GL_DEBUG_TYPE_ERROR_ARB
);
149 assert(state
->info_log
!= NULL
);
151 /* Get the offset that the new message will be written to. */
152 int msg_offset
= strlen(state
->info_log
);
154 ralloc_asprintf_append(&state
->info_log
, "%u:%u(%u): %s: ",
158 error
? "error" : "warning");
159 ralloc_vasprintf_append(&state
->info_log
, fmt
, ap
);
161 const char *const msg
= &state
->info_log
[msg_offset
];
162 struct gl_context
*ctx
= state
->ctx
;
163 /* Report the error via GL_ARB_debug_output. */
165 _mesa_shader_debug(ctx
, type
, id
, msg
, strlen(msg
));
167 ralloc_strcat(&state
->info_log
, "\n");
171 _mesa_glsl_error(YYLTYPE
*locp
, _mesa_glsl_parse_state
*state
,
172 const char *fmt
, ...)
175 GLenum type
= GL_DEBUG_TYPE_ERROR_ARB
;
180 _mesa_glsl_msg(locp
, state
, type
, SHADER_ERROR_UNKNOWN
, fmt
, ap
);
186 _mesa_glsl_warning(const YYLTYPE
*locp
, _mesa_glsl_parse_state
*state
,
187 const char *fmt
, ...)
190 GLenum type
= GL_DEBUG_TYPE_OTHER_ARB
;
193 _mesa_glsl_msg(locp
, state
, type
, 0, fmt
, ap
);
199 * Enum representing the possible behaviors that can be specified in
200 * an #extension directive.
210 * Element type for _mesa_glsl_supported_extensions
212 struct _mesa_glsl_extension
{
214 * Name of the extension when referred to in a GLSL extension
219 /** True if this extension is available to vertex shaders */
222 /** True if this extension is available to geometry shaders */
225 /** True if this extension is available to fragment shaders */
228 /** True if this extension is available to desktop GL shaders */
231 /** True if this extension is available to GLES shaders */
235 * Flag in the gl_extensions struct indicating whether this
236 * extension is supported by the driver, or
237 * &gl_extensions::dummy_true if supported by all drivers.
239 * Note: the type (GLboolean gl_extensions::*) is a "pointer to
240 * member" type, the type-safe alternative to the "offsetof" macro.
243 * - foo bar::* p declares p to be an "offset" to a field of type
244 * foo that exists within struct bar
245 * - &bar::baz computes the "offset" of field baz within struct bar
246 * - x.*p accesses the field of x that exists at "offset" p
247 * - x->*p is equivalent to (*x).*p
249 const GLboolean
gl_extensions::* supported_flag
;
252 * Flag in the _mesa_glsl_parse_state struct that should be set
253 * when this extension is enabled.
255 * See note in _mesa_glsl_extension::supported_flag about "pointer
258 bool _mesa_glsl_parse_state::* enable_flag
;
261 * Flag in the _mesa_glsl_parse_state struct that should be set
262 * when the shader requests "warn" behavior for this extension.
264 * See note in _mesa_glsl_extension::supported_flag about "pointer
267 bool _mesa_glsl_parse_state::* warn_flag
;
270 bool compatible_with_state(const _mesa_glsl_parse_state
*state
) const;
271 void set_flags(_mesa_glsl_parse_state
*state
, ext_behavior behavior
) const;
274 #define EXT(NAME, VS, GS, FS, GL, ES, SUPPORTED_FLAG) \
275 { "GL_" #NAME, VS, GS, FS, GL, ES, &gl_extensions::SUPPORTED_FLAG, \
276 &_mesa_glsl_parse_state::NAME##_enable, \
277 &_mesa_glsl_parse_state::NAME##_warn }
280 * Table of extensions that can be enabled/disabled within a shader,
281 * and the conditions under which they are supported.
283 static const _mesa_glsl_extension _mesa_glsl_supported_extensions
[] = {
284 /* target availability API availability */
285 /* name VS GS FS GL ES supported flag */
286 EXT(ARB_conservative_depth
, false, false, true, true, false, ARB_conservative_depth
),
287 EXT(ARB_draw_buffers
, false, false, true, true, false, dummy_true
),
288 EXT(ARB_draw_instanced
, true, false, false, true, false, ARB_draw_instanced
),
289 EXT(ARB_explicit_attrib_location
, true, false, true, true, false, ARB_explicit_attrib_location
),
290 EXT(ARB_fragment_coord_conventions
, true, false, true, true, false, ARB_fragment_coord_conventions
),
291 EXT(ARB_texture_rectangle
, true, false, true, true, false, dummy_true
),
292 EXT(EXT_texture_array
, true, false, true, true, false, EXT_texture_array
),
293 EXT(ARB_shader_texture_lod
, true, false, true, true, false, ARB_shader_texture_lod
),
294 EXT(ARB_shader_stencil_export
, false, false, true, true, false, ARB_shader_stencil_export
),
295 EXT(AMD_conservative_depth
, false, false, true, true, false, ARB_conservative_depth
),
296 EXT(AMD_shader_stencil_export
, false, false, true, true, false, ARB_shader_stencil_export
),
297 EXT(OES_texture_3D
, true, false, true, false, true, EXT_texture3D
),
298 EXT(OES_EGL_image_external
, true, false, true, false, true, OES_EGL_image_external
),
299 EXT(ARB_shader_bit_encoding
, true, true, true, true, false, ARB_shader_bit_encoding
),
300 EXT(ARB_uniform_buffer_object
, true, false, true, true, false, ARB_uniform_buffer_object
),
301 EXT(OES_standard_derivatives
, false, false, true, false, true, OES_standard_derivatives
),
302 EXT(ARB_texture_cube_map_array
, true, false, true, true, false, ARB_texture_cube_map_array
),
309 * Determine whether a given extension is compatible with the target,
310 * API, and extension information in the current parser state.
312 bool _mesa_glsl_extension::compatible_with_state(const _mesa_glsl_parse_state
*
315 /* Check that this extension matches the type of shader we are
318 switch (state
->target
) {
320 if (!this->avail_in_VS
) {
324 case geometry_shader
:
325 if (!this->avail_in_GS
) {
329 case fragment_shader
:
330 if (!this->avail_in_FS
) {
335 assert (!"Unrecognized shader target");
339 /* Check that this extension matches whether we are compiling
340 * for desktop GL or GLES.
342 if (state
->es_shader
) {
343 if (!this->avail_in_ES
) return false;
345 if (!this->avail_in_GL
) return false;
348 /* Check that this extension is supported by the OpenGL
351 * Note: the ->* operator indexes into state->extensions by the
352 * offset this->supported_flag. See
353 * _mesa_glsl_extension::supported_flag for more info.
355 return state
->extensions
->*(this->supported_flag
);
359 * Set the appropriate flags in the parser state to establish the
360 * given behavior for this extension.
362 void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state
*state
,
363 ext_behavior behavior
) const
365 /* Note: the ->* operator indexes into state by the
366 * offsets this->enable_flag and this->warn_flag. See
367 * _mesa_glsl_extension::supported_flag for more info.
369 state
->*(this->enable_flag
) = (behavior
!= extension_disable
);
370 state
->*(this->warn_flag
) = (behavior
== extension_warn
);
374 * Find an extension by name in _mesa_glsl_supported_extensions. If
375 * the name is not found, return NULL.
377 static const _mesa_glsl_extension
*find_extension(const char *name
)
379 for (unsigned i
= 0; i
< Elements(_mesa_glsl_supported_extensions
); ++i
) {
380 if (strcmp(name
, _mesa_glsl_supported_extensions
[i
].name
) == 0) {
381 return &_mesa_glsl_supported_extensions
[i
];
389 _mesa_glsl_process_extension(const char *name
, YYLTYPE
*name_locp
,
390 const char *behavior_string
, YYLTYPE
*behavior_locp
,
391 _mesa_glsl_parse_state
*state
)
393 ext_behavior behavior
;
394 if (strcmp(behavior_string
, "warn") == 0) {
395 behavior
= extension_warn
;
396 } else if (strcmp(behavior_string
, "require") == 0) {
397 behavior
= extension_require
;
398 } else if (strcmp(behavior_string
, "enable") == 0) {
399 behavior
= extension_enable
;
400 } else if (strcmp(behavior_string
, "disable") == 0) {
401 behavior
= extension_disable
;
403 _mesa_glsl_error(behavior_locp
, state
,
404 "Unknown extension behavior `%s'",
409 if (strcmp(name
, "all") == 0) {
410 if ((behavior
== extension_enable
) || (behavior
== extension_require
)) {
411 _mesa_glsl_error(name_locp
, state
, "Cannot %s all extensions",
412 (behavior
== extension_enable
)
413 ? "enable" : "require");
417 i
< Elements(_mesa_glsl_supported_extensions
); ++i
) {
418 const _mesa_glsl_extension
*extension
419 = &_mesa_glsl_supported_extensions
[i
];
420 if (extension
->compatible_with_state(state
)) {
421 _mesa_glsl_supported_extensions
[i
].set_flags(state
, behavior
);
426 const _mesa_glsl_extension
*extension
= find_extension(name
);
427 if (extension
&& extension
->compatible_with_state(state
)) {
428 extension
->set_flags(state
, behavior
);
430 static const char *const fmt
= "extension `%s' unsupported in %s shader";
432 if (behavior
== extension_require
) {
433 _mesa_glsl_error(name_locp
, state
, fmt
,
434 name
, _mesa_glsl_shader_target_name(state
->target
));
437 _mesa_glsl_warning(name_locp
, state
, fmt
,
438 name
, _mesa_glsl_shader_target_name(state
->target
));
447 _mesa_ast_type_qualifier_print(const struct ast_type_qualifier
*q
)
449 if (q
->flags
.q
.constant
)
452 if (q
->flags
.q
.invariant
)
453 printf("invariant ");
455 if (q
->flags
.q
.attribute
)
456 printf("attribute ");
458 if (q
->flags
.q
.varying
)
461 if (q
->flags
.q
.in
&& q
->flags
.q
.out
)
471 if (q
->flags
.q
.centroid
)
473 if (q
->flags
.q
.uniform
)
475 if (q
->flags
.q
.smooth
)
479 if (q
->flags
.q
.noperspective
)
480 printf("noperspective ");
485 ast_node::print(void) const
487 printf("unhandled node ");
491 ast_node::ast_node(void)
493 this->location
.source
= 0;
494 this->location
.line
= 0;
495 this->location
.column
= 0;
500 ast_opt_array_size_print(bool is_array
, const ast_expression
*array_size
)
514 ast_compound_statement::print(void) const
518 foreach_list_const(n
, &this->statements
) {
519 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
527 ast_compound_statement::ast_compound_statement(int new_scope
,
528 ast_node
*statements
)
530 this->new_scope
= new_scope
;
532 if (statements
!= NULL
) {
533 this->statements
.push_degenerate_list_at_head(&statements
->link
);
539 ast_expression::print(void) const
553 subexpressions
[0]->print();
554 printf("%s ", operator_string(oper
));
555 subexpressions
[1]->print();
558 case ast_field_selection
:
559 subexpressions
[0]->print();
560 printf(". %s ", primary_expression
.identifier
);
569 printf("%s ", operator_string(oper
));
570 subexpressions
[0]->print();
575 subexpressions
[0]->print();
576 printf("%s ", operator_string(oper
));
579 case ast_conditional
:
580 subexpressions
[0]->print();
582 subexpressions
[1]->print();
584 subexpressions
[2]->print();
587 case ast_array_index
:
588 subexpressions
[0]->print();
590 subexpressions
[1]->print();
594 case ast_function_call
: {
595 subexpressions
[0]->print();
598 foreach_list_const (n
, &this->expressions
) {
599 if (n
!= this->expressions
.get_head())
602 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
611 printf("%s ", primary_expression
.identifier
);
614 case ast_int_constant
:
615 printf("%d ", primary_expression
.int_constant
);
618 case ast_uint_constant
:
619 printf("%u ", primary_expression
.uint_constant
);
622 case ast_float_constant
:
623 printf("%f ", primary_expression
.float_constant
);
626 case ast_bool_constant
:
628 primary_expression
.bool_constant
634 foreach_list_const(n
, & this->expressions
) {
635 if (n
!= this->expressions
.get_head())
638 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
651 ast_expression::ast_expression(int oper
,
656 this->oper
= ast_operators(oper
);
657 this->subexpressions
[0] = ex0
;
658 this->subexpressions
[1] = ex1
;
659 this->subexpressions
[2] = ex2
;
660 this->non_lvalue_description
= NULL
;
665 ast_expression_statement::print(void) const
674 ast_expression_statement::ast_expression_statement(ast_expression
*ex
) :
682 ast_function::print(void) const
684 return_type
->print();
685 printf(" %s (", identifier
);
687 foreach_list_const(n
, & this->parameters
) {
688 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
696 ast_function::ast_function(void)
697 : is_definition(false), signature(NULL
)
704 ast_fully_specified_type::print(void) const
706 _mesa_ast_type_qualifier_print(& qualifier
);
712 ast_parameter_declarator::print(void) const
716 printf("%s ", identifier
);
717 ast_opt_array_size_print(is_array
, array_size
);
722 ast_function_definition::print(void) const
730 ast_declaration::print(void) const
732 printf("%s ", identifier
);
733 ast_opt_array_size_print(is_array
, array_size
);
737 initializer
->print();
742 ast_declaration::ast_declaration(const char *identifier
, int is_array
,
743 ast_expression
*array_size
,
744 ast_expression
*initializer
)
746 this->identifier
= identifier
;
747 this->is_array
= is_array
;
748 this->array_size
= array_size
;
749 this->initializer
= initializer
;
754 ast_declarator_list::print(void) const
756 assert(type
|| invariant
);
761 printf("invariant ");
763 foreach_list_const (ptr
, & this->declarations
) {
764 if (ptr
!= this->declarations
.get_head())
767 ast_node
*ast
= exec_node_data(ast_node
, ptr
, link
);
775 ast_declarator_list::ast_declarator_list(ast_fully_specified_type
*type
)
778 this->invariant
= false;
779 this->ubo_qualifiers_valid
= false;
783 ast_jump_statement::print(void) const
787 printf("continue; ");
794 if (opt_return_value
)
795 opt_return_value
->print();
806 ast_jump_statement::ast_jump_statement(int mode
, ast_expression
*return_value
)
808 this->mode
= ast_jump_modes(mode
);
810 if (mode
== ast_return
)
811 opt_return_value
= return_value
;
816 ast_selection_statement::print(void) const
822 then_statement
->print();
824 if (else_statement
) {
826 else_statement
->print();
832 ast_selection_statement::ast_selection_statement(ast_expression
*condition
,
833 ast_node
*then_statement
,
834 ast_node
*else_statement
)
836 this->condition
= condition
;
837 this->then_statement
= then_statement
;
838 this->else_statement
= else_statement
;
843 ast_switch_statement::print(void) const
846 test_expression
->print();
853 ast_switch_statement::ast_switch_statement(ast_expression
*test_expression
,
856 this->test_expression
= test_expression
;
862 ast_switch_body::print(void) const
872 ast_switch_body::ast_switch_body(ast_case_statement_list
*stmts
)
878 void ast_case_label::print(void) const
880 if (test_value
!= NULL
) {
890 ast_case_label::ast_case_label(ast_expression
*test_value
)
892 this->test_value
= test_value
;
896 void ast_case_label_list::print(void) const
898 foreach_list_const(n
, & this->labels
) {
899 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
906 ast_case_label_list::ast_case_label_list(void)
911 void ast_case_statement::print(void) const
914 foreach_list_const(n
, & this->stmts
) {
915 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
922 ast_case_statement::ast_case_statement(ast_case_label_list
*labels
)
924 this->labels
= labels
;
928 void ast_case_statement_list::print(void) const
930 foreach_list_const(n
, & this->cases
) {
931 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
937 ast_case_statement_list::ast_case_statement_list(void)
943 ast_iteration_statement::print(void) const
949 init_statement
->print();
957 rest_expression
->print();
983 ast_iteration_statement::ast_iteration_statement(int mode
,
986 ast_expression
*rest_expression
,
989 this->mode
= ast_iteration_modes(mode
);
990 this->init_statement
= init
;
991 this->condition
= condition
;
992 this->rest_expression
= rest_expression
;
998 ast_struct_specifier::print(void) const
1000 printf("struct %s { ", name
);
1001 foreach_list_const(n
, &this->declarations
) {
1002 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
1009 ast_struct_specifier::ast_struct_specifier(const char *identifier
,
1010 ast_declarator_list
*declarator_list
)
1012 if (identifier
== NULL
) {
1013 static unsigned anon_count
= 1;
1014 identifier
= ralloc_asprintf(this, "#anon_struct_%04x", anon_count
);
1018 this->declarations
.push_degenerate_list_at_head(&declarator_list
->link
);
1022 * Do the set of common optimizations passes
1024 * \param ir List of instructions to be optimized
1025 * \param linked Is the shader linked? This enables
1026 * optimizations passes that remove code at
1027 * global scope and could cause linking to
1029 * \param uniform_locations_assigned Have locations already been assigned for
1030 * uniforms? This prevents the declarations
1031 * of unused uniforms from being removed.
1032 * The setting of this flag only matters if
1033 * \c linked is \c true.
1034 * \param max_unroll_iterations Maximum number of loop iterations to be
1035 * unrolled. Setting to 0 forces all loops
1039 do_common_optimization(exec_list
*ir
, bool linked
,
1040 bool uniform_locations_assigned
,
1041 unsigned max_unroll_iterations
)
1043 GLboolean progress
= GL_FALSE
;
1045 progress
= lower_instructions(ir
, SUB_TO_ADD_NEG
) || progress
;
1048 progress
= do_function_inlining(ir
) || progress
;
1049 progress
= do_dead_functions(ir
) || progress
;
1050 progress
= do_structure_splitting(ir
) || progress
;
1052 progress
= do_if_simplification(ir
) || progress
;
1053 progress
= do_copy_propagation(ir
) || progress
;
1054 progress
= do_copy_propagation_elements(ir
) || progress
;
1056 progress
= do_dead_code(ir
, uniform_locations_assigned
) || progress
;
1058 progress
= do_dead_code_unlinked(ir
) || progress
;
1059 progress
= do_dead_code_local(ir
) || progress
;
1060 progress
= do_tree_grafting(ir
) || progress
;
1061 progress
= do_constant_propagation(ir
) || progress
;
1063 progress
= do_constant_variable(ir
) || progress
;
1065 progress
= do_constant_variable_unlinked(ir
) || progress
;
1066 progress
= do_constant_folding(ir
) || progress
;
1067 progress
= do_algebraic(ir
) || progress
;
1068 progress
= do_lower_jumps(ir
) || progress
;
1069 progress
= do_vec_index_to_swizzle(ir
) || progress
;
1070 progress
= do_swizzle_swizzle(ir
) || progress
;
1071 progress
= do_noop_swizzle(ir
) || progress
;
1073 progress
= optimize_split_arrays(ir
, linked
) || progress
;
1074 progress
= optimize_redundant_jumps(ir
) || progress
;
1076 loop_state
*ls
= analyze_loop_variables(ir
);
1077 if (ls
->loop_found
) {
1078 progress
= set_loop_controls(ir
, ls
) || progress
;
1079 progress
= unroll_loops(ir
, ls
, max_unroll_iterations
) || progress
;
1089 * To be called at GL teardown time, this frees compiler datastructures.
1091 * After calling this, any previously compiled shaders and shader
1092 * programs would be invalid. So this should happen at approximately
1096 _mesa_destroy_shader_compiler(void)
1098 _mesa_destroy_shader_compiler_caches();
1100 _mesa_glsl_release_types();
1104 * Releases compiler caches to trade off performance for memory.
1106 * Intended to be used with glReleaseShaderCompiler().
1109 _mesa_destroy_shader_compiler_caches(void)
1111 _mesa_glsl_release_functions();