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"
40 _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context
*_ctx
,
41 GLenum target
, void *mem_ctx
)
45 case GL_VERTEX_SHADER
: this->target
= vertex_shader
; break;
46 case GL_FRAGMENT_SHADER
: this->target
= fragment_shader
; break;
47 case GL_GEOMETRY_SHADER
: this->target
= geometry_shader
; break;
51 this->translation_unit
.make_empty();
52 this->symbols
= new(mem_ctx
) glsl_symbol_table
;
53 this->info_log
= ralloc_strdup(mem_ctx
, "");
55 this->loop_nesting_ast
= NULL
;
56 this->switch_state
.switch_nesting_ast
= NULL
;
58 this->num_builtins_to_link
= 0;
60 /* Set default language version and extensions */
61 this->language_version
= 110;
62 this->es_shader
= false;
63 this->ARB_texture_rectangle_enable
= true;
65 /* OpenGL ES 2.0 has different defaults from desktop GL. */
66 if (ctx
->API
== API_OPENGLES2
) {
67 this->language_version
= 100;
68 this->es_shader
= true;
69 this->ARB_texture_rectangle_enable
= false;
72 this->extensions
= &ctx
->Extensions
;
74 this->Const
.MaxLights
= ctx
->Const
.MaxLights
;
75 this->Const
.MaxClipPlanes
= ctx
->Const
.MaxClipPlanes
;
76 this->Const
.MaxTextureUnits
= ctx
->Const
.MaxTextureUnits
;
77 this->Const
.MaxTextureCoords
= ctx
->Const
.MaxTextureCoordUnits
;
78 this->Const
.MaxVertexAttribs
= ctx
->Const
.VertexProgram
.MaxAttribs
;
79 this->Const
.MaxVertexUniformComponents
= ctx
->Const
.VertexProgram
.MaxUniformComponents
;
80 this->Const
.MaxVaryingFloats
= ctx
->Const
.MaxVarying
* 4;
81 this->Const
.MaxVertexTextureImageUnits
= ctx
->Const
.MaxVertexTextureImageUnits
;
82 this->Const
.MaxCombinedTextureImageUnits
= ctx
->Const
.MaxCombinedTextureImageUnits
;
83 this->Const
.MaxTextureImageUnits
= ctx
->Const
.MaxTextureImageUnits
;
84 this->Const
.MaxFragmentUniformComponents
= ctx
->Const
.FragmentProgram
.MaxUniformComponents
;
86 this->Const
.MaxDrawBuffers
= ctx
->Const
.MaxDrawBuffers
;
88 const unsigned lowest_version
=
89 (ctx
->API
== API_OPENGLES2
) || ctx
->Extensions
.ARB_ES2_compatibility
91 const unsigned highest_version
=
92 _mesa_is_desktop_gl(ctx
) ? ctx
->Const
.GLSLVersion
: 100;
93 char *supported
= ralloc_strdup(this, "");
95 for (unsigned ver
= lowest_version
; ver
<= highest_version
; ver
+= 10) {
96 const char *const prefix
= (ver
== lowest_version
)
98 : ((ver
== highest_version
) ? ", and " : ", ");
100 ralloc_asprintf_append(& supported
, "%s%d.%02d%s",
102 ver
/ 100, ver
% 100,
103 (ver
== 100) ? " ES" : "");
106 this->supported_version_string
= supported
;
108 if (ctx
->Const
.ForceGLSLExtensionsWarn
)
109 _mesa_glsl_process_extension("all", NULL
, "warn", NULL
, this);
111 this->default_uniform_qualifier
= new(this) ast_type_qualifier();
112 this->default_uniform_qualifier
->flags
.q
.shared
= 1;
113 this->default_uniform_qualifier
->flags
.q
.column_major
= 1;
117 _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target
)
120 case vertex_shader
: return "vertex";
121 case fragment_shader
: return "fragment";
122 case geometry_shader
: return "geometry";
125 assert(!"Should not get here.");
129 /* This helper function will append the given message to the shader's
130 info log and report it via GL_ARB_debug_output. Per that extension,
131 'type' is one of the enum values classifying the message, and
132 'id' is the implementation-defined ID of the given message. */
134 _mesa_glsl_msg(const YYLTYPE
*locp
, _mesa_glsl_parse_state
*state
,
135 GLenum type
, GLuint id
, const char *fmt
, va_list ap
)
137 bool error
= (type
== GL_DEBUG_TYPE_ERROR_ARB
);
139 assert(state
->info_log
!= NULL
);
141 /* Get the offset that the new message will be written to. */
142 int msg_offset
= strlen(state
->info_log
);
144 ralloc_asprintf_append(&state
->info_log
, "%u:%u(%u): %s: ",
148 error
? "error" : "warning");
149 ralloc_vasprintf_append(&state
->info_log
, fmt
, ap
);
151 const char *const msg
= &state
->info_log
[msg_offset
];
152 struct gl_context
*ctx
= state
->ctx
;
153 /* Report the error via GL_ARB_debug_output. */
155 _mesa_shader_debug(ctx
, type
, id
, msg
, strlen(msg
));
157 ralloc_strcat(&state
->info_log
, "\n");
161 _mesa_glsl_error(YYLTYPE
*locp
, _mesa_glsl_parse_state
*state
,
162 const char *fmt
, ...)
165 GLenum type
= GL_DEBUG_TYPE_ERROR_ARB
;
170 _mesa_glsl_msg(locp
, state
, type
, SHADER_ERROR_UNKNOWN
, fmt
, ap
);
176 _mesa_glsl_warning(const YYLTYPE
*locp
, _mesa_glsl_parse_state
*state
,
177 const char *fmt
, ...)
180 GLenum type
= GL_DEBUG_TYPE_OTHER_ARB
;
183 _mesa_glsl_msg(locp
, state
, type
, 0, fmt
, ap
);
189 * Enum representing the possible behaviors that can be specified in
190 * an #extension directive.
200 * Element type for _mesa_glsl_supported_extensions
202 struct _mesa_glsl_extension
{
204 * Name of the extension when referred to in a GLSL extension
209 /** True if this extension is available to vertex shaders */
212 /** True if this extension is available to geometry shaders */
215 /** True if this extension is available to fragment shaders */
218 /** True if this extension is available to desktop GL shaders */
221 /** True if this extension is available to GLES shaders */
225 * Flag in the gl_extensions struct indicating whether this
226 * extension is supported by the driver, or
227 * &gl_extensions::dummy_true if supported by all drivers.
229 * Note: the type (GLboolean gl_extensions::*) is a "pointer to
230 * member" type, the type-safe alternative to the "offsetof" macro.
233 * - foo bar::* p declares p to be an "offset" to a field of type
234 * foo that exists within struct bar
235 * - &bar::baz computes the "offset" of field baz within struct bar
236 * - x.*p accesses the field of x that exists at "offset" p
237 * - x->*p is equivalent to (*x).*p
239 const GLboolean
gl_extensions::* supported_flag
;
242 * Flag in the _mesa_glsl_parse_state struct that should be set
243 * when this extension is enabled.
245 * See note in _mesa_glsl_extension::supported_flag about "pointer
248 bool _mesa_glsl_parse_state::* enable_flag
;
251 * Flag in the _mesa_glsl_parse_state struct that should be set
252 * when the shader requests "warn" behavior for this extension.
254 * See note in _mesa_glsl_extension::supported_flag about "pointer
257 bool _mesa_glsl_parse_state::* warn_flag
;
260 bool compatible_with_state(const _mesa_glsl_parse_state
*state
) const;
261 void set_flags(_mesa_glsl_parse_state
*state
, ext_behavior behavior
) const;
264 #define EXT(NAME, VS, GS, FS, GL, ES, SUPPORTED_FLAG) \
265 { "GL_" #NAME, VS, GS, FS, GL, ES, &gl_extensions::SUPPORTED_FLAG, \
266 &_mesa_glsl_parse_state::NAME##_enable, \
267 &_mesa_glsl_parse_state::NAME##_warn }
270 * Table of extensions that can be enabled/disabled within a shader,
271 * and the conditions under which they are supported.
273 static const _mesa_glsl_extension _mesa_glsl_supported_extensions
[] = {
274 /* target availability API availability */
275 /* name VS GS FS GL ES supported flag */
276 EXT(ARB_conservative_depth
, false, false, true, true, false, ARB_conservative_depth
),
277 EXT(ARB_draw_buffers
, false, false, true, true, false, dummy_true
),
278 EXT(ARB_draw_instanced
, true, false, false, true, false, ARB_draw_instanced
),
279 EXT(ARB_explicit_attrib_location
, true, false, true, true, false, ARB_explicit_attrib_location
),
280 EXT(ARB_fragment_coord_conventions
, true, false, true, true, false, ARB_fragment_coord_conventions
),
281 EXT(ARB_texture_rectangle
, true, false, true, true, false, dummy_true
),
282 EXT(EXT_texture_array
, true, false, true, true, false, EXT_texture_array
),
283 EXT(ARB_shader_texture_lod
, true, false, true, true, false, ARB_shader_texture_lod
),
284 EXT(ARB_shader_stencil_export
, false, false, true, true, false, ARB_shader_stencil_export
),
285 EXT(AMD_conservative_depth
, false, false, true, true, false, ARB_conservative_depth
),
286 EXT(AMD_shader_stencil_export
, false, false, true, true, false, ARB_shader_stencil_export
),
287 EXT(OES_texture_3D
, true, false, true, false, true, EXT_texture3D
),
288 EXT(OES_EGL_image_external
, true, false, true, false, true, OES_EGL_image_external
),
289 EXT(ARB_shader_bit_encoding
, true, true, true, true, false, ARB_shader_bit_encoding
),
290 EXT(ARB_uniform_buffer_object
, true, false, true, true, false, ARB_uniform_buffer_object
),
291 EXT(OES_standard_derivatives
, false, false, true, false, true, OES_standard_derivatives
),
292 EXT(ARB_texture_cube_map_array
, true, false, true, true, false, ARB_texture_cube_map_array
),
299 * Determine whether a given extension is compatible with the target,
300 * API, and extension information in the current parser state.
302 bool _mesa_glsl_extension::compatible_with_state(const _mesa_glsl_parse_state
*
305 /* Check that this extension matches the type of shader we are
308 switch (state
->target
) {
310 if (!this->avail_in_VS
) {
314 case geometry_shader
:
315 if (!this->avail_in_GS
) {
319 case fragment_shader
:
320 if (!this->avail_in_FS
) {
325 assert (!"Unrecognized shader target");
329 /* Check that this extension matches whether we are compiling
330 * for desktop GL or GLES.
332 if (state
->es_shader
) {
333 if (!this->avail_in_ES
) return false;
335 if (!this->avail_in_GL
) return false;
338 /* Check that this extension is supported by the OpenGL
341 * Note: the ->* operator indexes into state->extensions by the
342 * offset this->supported_flag. See
343 * _mesa_glsl_extension::supported_flag for more info.
345 return state
->extensions
->*(this->supported_flag
);
349 * Set the appropriate flags in the parser state to establish the
350 * given behavior for this extension.
352 void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state
*state
,
353 ext_behavior behavior
) const
355 /* Note: the ->* operator indexes into state by the
356 * offsets this->enable_flag and this->warn_flag. See
357 * _mesa_glsl_extension::supported_flag for more info.
359 state
->*(this->enable_flag
) = (behavior
!= extension_disable
);
360 state
->*(this->warn_flag
) = (behavior
== extension_warn
);
364 * Find an extension by name in _mesa_glsl_supported_extensions. If
365 * the name is not found, return NULL.
367 static const _mesa_glsl_extension
*find_extension(const char *name
)
369 for (unsigned i
= 0; i
< Elements(_mesa_glsl_supported_extensions
); ++i
) {
370 if (strcmp(name
, _mesa_glsl_supported_extensions
[i
].name
) == 0) {
371 return &_mesa_glsl_supported_extensions
[i
];
379 _mesa_glsl_process_extension(const char *name
, YYLTYPE
*name_locp
,
380 const char *behavior_string
, YYLTYPE
*behavior_locp
,
381 _mesa_glsl_parse_state
*state
)
383 ext_behavior behavior
;
384 if (strcmp(behavior_string
, "warn") == 0) {
385 behavior
= extension_warn
;
386 } else if (strcmp(behavior_string
, "require") == 0) {
387 behavior
= extension_require
;
388 } else if (strcmp(behavior_string
, "enable") == 0) {
389 behavior
= extension_enable
;
390 } else if (strcmp(behavior_string
, "disable") == 0) {
391 behavior
= extension_disable
;
393 _mesa_glsl_error(behavior_locp
, state
,
394 "Unknown extension behavior `%s'",
399 if (strcmp(name
, "all") == 0) {
400 if ((behavior
== extension_enable
) || (behavior
== extension_require
)) {
401 _mesa_glsl_error(name_locp
, state
, "Cannot %s all extensions",
402 (behavior
== extension_enable
)
403 ? "enable" : "require");
407 i
< Elements(_mesa_glsl_supported_extensions
); ++i
) {
408 const _mesa_glsl_extension
*extension
409 = &_mesa_glsl_supported_extensions
[i
];
410 if (extension
->compatible_with_state(state
)) {
411 _mesa_glsl_supported_extensions
[i
].set_flags(state
, behavior
);
416 const _mesa_glsl_extension
*extension
= find_extension(name
);
417 if (extension
&& extension
->compatible_with_state(state
)) {
418 extension
->set_flags(state
, behavior
);
420 static const char *const fmt
= "extension `%s' unsupported in %s shader";
422 if (behavior
== extension_require
) {
423 _mesa_glsl_error(name_locp
, state
, fmt
,
424 name
, _mesa_glsl_shader_target_name(state
->target
));
427 _mesa_glsl_warning(name_locp
, state
, fmt
,
428 name
, _mesa_glsl_shader_target_name(state
->target
));
437 _mesa_ast_type_qualifier_print(const struct ast_type_qualifier
*q
)
439 if (q
->flags
.q
.constant
)
442 if (q
->flags
.q
.invariant
)
443 printf("invariant ");
445 if (q
->flags
.q
.attribute
)
446 printf("attribute ");
448 if (q
->flags
.q
.varying
)
451 if (q
->flags
.q
.in
&& q
->flags
.q
.out
)
461 if (q
->flags
.q
.centroid
)
463 if (q
->flags
.q
.uniform
)
465 if (q
->flags
.q
.smooth
)
469 if (q
->flags
.q
.noperspective
)
470 printf("noperspective ");
475 ast_node::print(void) const
477 printf("unhandled node ");
481 ast_node::ast_node(void)
483 this->location
.source
= 0;
484 this->location
.line
= 0;
485 this->location
.column
= 0;
490 ast_opt_array_size_print(bool is_array
, const ast_expression
*array_size
)
504 ast_compound_statement::print(void) const
508 foreach_list_const(n
, &this->statements
) {
509 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
517 ast_compound_statement::ast_compound_statement(int new_scope
,
518 ast_node
*statements
)
520 this->new_scope
= new_scope
;
522 if (statements
!= NULL
) {
523 this->statements
.push_degenerate_list_at_head(&statements
->link
);
529 ast_expression::print(void) const
543 subexpressions
[0]->print();
544 printf("%s ", operator_string(oper
));
545 subexpressions
[1]->print();
548 case ast_field_selection
:
549 subexpressions
[0]->print();
550 printf(". %s ", primary_expression
.identifier
);
559 printf("%s ", operator_string(oper
));
560 subexpressions
[0]->print();
565 subexpressions
[0]->print();
566 printf("%s ", operator_string(oper
));
569 case ast_conditional
:
570 subexpressions
[0]->print();
572 subexpressions
[1]->print();
574 subexpressions
[2]->print();
577 case ast_array_index
:
578 subexpressions
[0]->print();
580 subexpressions
[1]->print();
584 case ast_function_call
: {
585 subexpressions
[0]->print();
588 foreach_list_const (n
, &this->expressions
) {
589 if (n
!= this->expressions
.get_head())
592 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
601 printf("%s ", primary_expression
.identifier
);
604 case ast_int_constant
:
605 printf("%d ", primary_expression
.int_constant
);
608 case ast_uint_constant
:
609 printf("%u ", primary_expression
.uint_constant
);
612 case ast_float_constant
:
613 printf("%f ", primary_expression
.float_constant
);
616 case ast_bool_constant
:
618 primary_expression
.bool_constant
624 foreach_list_const(n
, & this->expressions
) {
625 if (n
!= this->expressions
.get_head())
628 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
641 ast_expression::ast_expression(int oper
,
646 this->oper
= ast_operators(oper
);
647 this->subexpressions
[0] = ex0
;
648 this->subexpressions
[1] = ex1
;
649 this->subexpressions
[2] = ex2
;
650 this->non_lvalue_description
= NULL
;
655 ast_expression_statement::print(void) const
664 ast_expression_statement::ast_expression_statement(ast_expression
*ex
) :
672 ast_function::print(void) const
674 return_type
->print();
675 printf(" %s (", identifier
);
677 foreach_list_const(n
, & this->parameters
) {
678 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
686 ast_function::ast_function(void)
687 : is_definition(false), signature(NULL
)
694 ast_fully_specified_type::print(void) const
696 _mesa_ast_type_qualifier_print(& qualifier
);
702 ast_parameter_declarator::print(void) const
706 printf("%s ", identifier
);
707 ast_opt_array_size_print(is_array
, array_size
);
712 ast_function_definition::print(void) const
720 ast_declaration::print(void) const
722 printf("%s ", identifier
);
723 ast_opt_array_size_print(is_array
, array_size
);
727 initializer
->print();
732 ast_declaration::ast_declaration(const char *identifier
, int is_array
,
733 ast_expression
*array_size
,
734 ast_expression
*initializer
)
736 this->identifier
= identifier
;
737 this->is_array
= is_array
;
738 this->array_size
= array_size
;
739 this->initializer
= initializer
;
744 ast_declarator_list::print(void) const
746 assert(type
|| invariant
);
751 printf("invariant ");
753 foreach_list_const (ptr
, & this->declarations
) {
754 if (ptr
!= this->declarations
.get_head())
757 ast_node
*ast
= exec_node_data(ast_node
, ptr
, link
);
765 ast_declarator_list::ast_declarator_list(ast_fully_specified_type
*type
)
768 this->invariant
= false;
769 this->ubo_qualifiers_valid
= false;
773 ast_jump_statement::print(void) const
777 printf("continue; ");
784 if (opt_return_value
)
785 opt_return_value
->print();
796 ast_jump_statement::ast_jump_statement(int mode
, ast_expression
*return_value
)
798 this->mode
= ast_jump_modes(mode
);
800 if (mode
== ast_return
)
801 opt_return_value
= return_value
;
806 ast_selection_statement::print(void) const
812 then_statement
->print();
814 if (else_statement
) {
816 else_statement
->print();
822 ast_selection_statement::ast_selection_statement(ast_expression
*condition
,
823 ast_node
*then_statement
,
824 ast_node
*else_statement
)
826 this->condition
= condition
;
827 this->then_statement
= then_statement
;
828 this->else_statement
= else_statement
;
833 ast_switch_statement::print(void) const
836 test_expression
->print();
843 ast_switch_statement::ast_switch_statement(ast_expression
*test_expression
,
846 this->test_expression
= test_expression
;
852 ast_switch_body::print(void) const
862 ast_switch_body::ast_switch_body(ast_case_statement_list
*stmts
)
868 void ast_case_label::print(void) const
870 if (test_value
!= NULL
) {
880 ast_case_label::ast_case_label(ast_expression
*test_value
)
882 this->test_value
= test_value
;
886 void ast_case_label_list::print(void) const
888 foreach_list_const(n
, & this->labels
) {
889 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
896 ast_case_label_list::ast_case_label_list(void)
901 void ast_case_statement::print(void) const
904 foreach_list_const(n
, & this->stmts
) {
905 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
912 ast_case_statement::ast_case_statement(ast_case_label_list
*labels
)
914 this->labels
= labels
;
918 void ast_case_statement_list::print(void) const
920 foreach_list_const(n
, & this->cases
) {
921 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
927 ast_case_statement_list::ast_case_statement_list(void)
933 ast_iteration_statement::print(void) const
939 init_statement
->print();
947 rest_expression
->print();
973 ast_iteration_statement::ast_iteration_statement(int mode
,
976 ast_expression
*rest_expression
,
979 this->mode
= ast_iteration_modes(mode
);
980 this->init_statement
= init
;
981 this->condition
= condition
;
982 this->rest_expression
= rest_expression
;
988 ast_struct_specifier::print(void) const
990 printf("struct %s { ", name
);
991 foreach_list_const(n
, &this->declarations
) {
992 ast_node
*ast
= exec_node_data(ast_node
, n
, link
);
999 ast_struct_specifier::ast_struct_specifier(const char *identifier
,
1000 ast_declarator_list
*declarator_list
)
1002 if (identifier
== NULL
) {
1003 static unsigned anon_count
= 1;
1004 identifier
= ralloc_asprintf(this, "#anon_struct_%04x", anon_count
);
1008 this->declarations
.push_degenerate_list_at_head(&declarator_list
->link
);
1012 * Do the set of common optimizations passes
1014 * \param ir List of instructions to be optimized
1015 * \param linked Is the shader linked? This enables
1016 * optimizations passes that remove code at
1017 * global scope and could cause linking to
1019 * \param uniform_locations_assigned Have locations already been assigned for
1020 * uniforms? This prevents the declarations
1021 * of unused uniforms from being removed.
1022 * The setting of this flag only matters if
1023 * \c linked is \c true.
1024 * \param max_unroll_iterations Maximum number of loop iterations to be
1025 * unrolled. Setting to 0 forces all loops
1029 do_common_optimization(exec_list
*ir
, bool linked
,
1030 bool uniform_locations_assigned
,
1031 unsigned max_unroll_iterations
)
1033 GLboolean progress
= GL_FALSE
;
1035 progress
= lower_instructions(ir
, SUB_TO_ADD_NEG
) || progress
;
1038 progress
= do_function_inlining(ir
) || progress
;
1039 progress
= do_dead_functions(ir
) || progress
;
1040 progress
= do_structure_splitting(ir
) || progress
;
1042 progress
= do_if_simplification(ir
) || progress
;
1043 progress
= do_copy_propagation(ir
) || progress
;
1044 progress
= do_copy_propagation_elements(ir
) || progress
;
1046 progress
= do_dead_code(ir
, uniform_locations_assigned
) || progress
;
1048 progress
= do_dead_code_unlinked(ir
) || progress
;
1049 progress
= do_dead_code_local(ir
) || progress
;
1050 progress
= do_tree_grafting(ir
) || progress
;
1051 progress
= do_constant_propagation(ir
) || progress
;
1053 progress
= do_constant_variable(ir
) || progress
;
1055 progress
= do_constant_variable_unlinked(ir
) || progress
;
1056 progress
= do_constant_folding(ir
) || progress
;
1057 progress
= do_algebraic(ir
) || progress
;
1058 progress
= do_lower_jumps(ir
) || progress
;
1059 progress
= do_vec_index_to_swizzle(ir
) || progress
;
1060 progress
= do_swizzle_swizzle(ir
) || progress
;
1061 progress
= do_noop_swizzle(ir
) || progress
;
1063 progress
= optimize_split_arrays(ir
, linked
) || progress
;
1064 progress
= optimize_redundant_jumps(ir
) || progress
;
1066 loop_state
*ls
= analyze_loop_variables(ir
);
1067 if (ls
->loop_found
) {
1068 progress
= set_loop_controls(ir
, ls
) || progress
;
1069 progress
= unroll_loops(ir
, ls
, max_unroll_iterations
) || progress
;
1079 * To be called at GL teardown time, this frees compiler datastructures.
1081 * After calling this, any previously compiled shaders and shader
1082 * programs would be invalid. So this should happen at approximately
1086 _mesa_destroy_shader_compiler(void)
1088 _mesa_destroy_shader_compiler_caches();
1090 _mesa_glsl_release_types();
1094 * Releases compiler caches to trade off performance for memory.
1096 * Intended to be used with glReleaseShaderCompiler().
1099 _mesa_destroy_shader_compiler_caches(void)
1101 _mesa_glsl_release_functions();