From c73334d7d3bf58a34fff9873d6e8d80d767b143d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 7 Oct 2013 13:53:08 +0000 Subject: [PATCH] [MESA] - leaner build part 13 of X - Get rid of shaders and programs support (with assorted extensions), ARB_multitexture and ATI_envmap_bumpmap extensions. CORE-7499 svn path=/trunk/; revision=60576 --- reactos/dll/opengl/mesa/src/CMakeLists.txt | 1 - .../dll/opengl/mesa/src/glsl/CMakeLists.txt | 88 - .../dll/opengl/mesa/src/glsl/Makefile.sources | 105 - reactos/dll/opengl/mesa/src/glsl/README | 229 - reactos/dll/opengl/mesa/src/glsl/SConscript | 131 - reactos/dll/opengl/mesa/src/glsl/TODO | 27 - reactos/dll/opengl/mesa/src/glsl/ast.h | 804 --- reactos/dll/opengl/mesa/src/glsl/ast_expr.cpp | 95 - .../dll/opengl/mesa/src/glsl/ast_function.cpp | 1506 ----- .../dll/opengl/mesa/src/glsl/ast_to_hir.cpp | 3830 ----------- reactos/dll/opengl/mesa/src/glsl/ast_type.cpp | 139 - .../opengl/mesa/src/glsl/builtin_stubs.cpp | 39 - .../dll/opengl/mesa/src/glsl/builtin_types.h | 248 - .../mesa/src/glsl/builtin_variables.cpp | 969 --- reactos/dll/opengl/mesa/src/glsl/glcpp/README | 32 - .../opengl/mesa/src/glsl/glcpp/glcpp-lex.c | 2621 -------- .../opengl/mesa/src/glsl/glcpp/glcpp-lex.l | 332 - .../opengl/mesa/src/glsl/glcpp/glcpp-parse.c | 4224 ------------ .../opengl/mesa/src/glsl/glcpp/glcpp-parse.h | 100 - .../opengl/mesa/src/glsl/glcpp/glcpp-parse.y | 1918 ------ .../dll/opengl/mesa/src/glsl/glcpp/glcpp.c | 122 - .../dll/opengl/mesa/src/glsl/glcpp/glcpp.h | 222 - reactos/dll/opengl/mesa/src/glsl/glcpp/pp.c | 165 - .../glcpp/tests/000-content-with-spaces.c | 1 - .../tests/000-content-with-spaces.c.expected | 2 - .../mesa/src/glsl/glcpp/tests/001-define.c | 2 - .../glsl/glcpp/tests/001-define.c.expected | 3 - .../src/glsl/glcpp/tests/002-define-chain.c | 3 - .../glcpp/tests/002-define-chain.c.expected | 4 - .../glcpp/tests/003-define-chain-reverse.c | 3 - .../tests/003-define-chain-reverse.c.expected | 4 - .../glsl/glcpp/tests/004-define-recursive.c | 6 - .../tests/004-define-recursive.c.expected | 7 - .../glcpp/tests/005-define-composite-chain.c | 3 - .../005-define-composite-chain.c.expected | 4 - .../006-define-composite-chain-reverse.c | 3 - ...-define-composite-chain-reverse.c.expected | 4 - .../tests/007-define-composite-recursive.c | 6 - .../007-define-composite-recursive.c.expected | 7 - .../src/glsl/glcpp/tests/008-define-empty.c | 2 - .../glcpp/tests/008-define-empty.c.expected | 3 - .../mesa/src/glsl/glcpp/tests/009-undef.c | 4 - .../src/glsl/glcpp/tests/009-undef.c.expected | 5 - .../glsl/glcpp/tests/010-undef-re-define.c | 6 - .../tests/010-undef-re-define.c.expected | 7 - .../glsl/glcpp/tests/011-define-func-empty.c | 2 - .../tests/011-define-func-empty.c.expected | 3 - .../glcpp/tests/012-define-func-no-args.c | 2 - .../tests/012-define-func-no-args.c.expected | 3 - .../tests/013-define-func-1-arg-unused.c | 2 - .../013-define-func-1-arg-unused.c.expected | 3 - .../tests/014-define-func-2-arg-unused.c | 2 - .../014-define-func-2-arg-unused.c.expected | 3 - .../tests/015-define-object-with-parens.c | 4 - .../015-define-object-with-parens.c.expected | 5 - .../glsl/glcpp/tests/016-define-func-1-arg.c | 2 - .../tests/016-define-func-1-arg.c.expected | 3 - .../glsl/glcpp/tests/017-define-func-2-args.c | 2 - .../tests/017-define-func-2-args.c.expected | 3 - .../018-define-func-macro-as-parameter.c | 3 - ...-define-func-macro-as-parameter.c.expected | 4 - .../glcpp/tests/019-define-func-1-arg-multi.c | 2 - .../019-define-func-1-arg-multi.c.expected | 3 - .../glcpp/tests/020-define-func-2-arg-multi.c | 2 - .../020-define-func-2-arg-multi.c.expected | 3 - .../glcpp/tests/021-define-func-compose.c | 3 - .../tests/021-define-func-compose.c.expected | 4 - .../tests/022-define-func-arg-with-parens.c | 2 - ...022-define-func-arg-with-parens.c.expected | 3 - .../glcpp/tests/023-define-extra-whitespace.c | 8 - .../023-define-extra-whitespace.c.expected | 9 - .../024-define-chain-to-self-recursion.c | 3 - ...-define-chain-to-self-recursion.c.expected | 4 - .../glcpp/tests/025-func-macro-as-non-macro.c | 2 - .../025-func-macro-as-non-macro.c.expected | 3 - .../tests/026-define-func-extra-newlines.c | 6 - .../026-define-func-extra-newlines.c.expected | 4 - .../tests/027-define-chain-obj-to-func.c | 3 - .../027-define-chain-obj-to-func.c.expected | 4 - .../tests/028-define-chain-obj-to-non-func.c | 3 - ...28-define-chain-obj-to-non-func.c.expected | 4 - .../029-define-chain-obj-to-func-with-args.c | 3 - ...ine-chain-obj-to-func-with-args.c.expected | 4 - .../030-define-chain-obj-to-func-compose.c | 4 - ...efine-chain-obj-to-func-compose.c.expected | 5 - .../031-define-chain-func-to-func-compose.c | 4 - ...fine-chain-func-to-func-compose.c.expected | 5 - .../tests/032-define-func-self-recurse.c | 2 - .../032-define-func-self-recurse.c.expected | 3 - .../tests/033-define-func-self-compose.c | 2 - .../033-define-func-self-compose.c.expected | 3 - .../034-define-func-self-compose-non-func.c | 2 - ...fine-func-self-compose-non-func.c.expected | 3 - ...lf-compose-non-func-multi-token-argument.c | 2 - ...e-non-func-multi-token-argument.c.expected | 3 - ...fine-func-non-macro-multi-token-argument.c | 3 - ...-non-macro-multi-token-argument.c.expected | 4 - .../tests/037-finalize-unexpanded-macro.c | 3 - .../037-finalize-unexpanded-macro.c.expected | 4 - .../glcpp/tests/038-func-arg-with-commas.c | 2 - .../tests/038-func-arg-with-commas.c.expected | 3 - .../tests/039-func-arg-obj-macro-with-comma.c | 3 - ...9-func-arg-obj-macro-with-comma.c.expected | 4 - .../src/glsl/glcpp/tests/040-token-pasting.c | 2 - .../glcpp/tests/040-token-pasting.c.expected | 3 - .../mesa/src/glsl/glcpp/tests/041-if-0.c | 5 - .../src/glsl/glcpp/tests/041-if-0.c.expected | 6 - .../mesa/src/glsl/glcpp/tests/042-if-1.c | 5 - .../src/glsl/glcpp/tests/042-if-1.c.expected | 6 - .../mesa/src/glsl/glcpp/tests/043-if-0-else.c | 7 - .../glsl/glcpp/tests/043-if-0-else.c.expected | 8 - .../mesa/src/glsl/glcpp/tests/044-if-1-else.c | 7 - .../glsl/glcpp/tests/044-if-1-else.c.expected | 8 - .../mesa/src/glsl/glcpp/tests/045-if-0-elif.c | 11 - .../glsl/glcpp/tests/045-if-0-elif.c.expected | 12 - .../src/glsl/glcpp/tests/046-if-1-elsif.c | 11 - .../glcpp/tests/046-if-1-elsif.c.expected | 12 - .../src/glsl/glcpp/tests/047-if-elif-else.c | 11 - .../glcpp/tests/047-if-elif-else.c.expected | 12 - .../mesa/src/glsl/glcpp/tests/048-if-nested.c | 11 - .../glsl/glcpp/tests/048-if-nested.c.expected | 12 - .../tests/049-if-expression-precedence.c | 5 - .../049-if-expression-precedence.c.expected | 6 - .../src/glsl/glcpp/tests/050-if-defined.c | 17 - .../glcpp/tests/050-if-defined.c.expected | 18 - .../src/glsl/glcpp/tests/051-if-relational.c | 35 - .../glcpp/tests/051-if-relational.c.expected | 36 - .../src/glsl/glcpp/tests/052-if-bitwise.c | 20 - .../glcpp/tests/052-if-bitwise.c.expected | 21 - .../glcpp/tests/053-if-divide-and-shift.c | 15 - .../tests/053-if-divide-and-shift.c.expected | 16 - .../src/glsl/glcpp/tests/054-if-with-macros.c | 34 - .../glcpp/tests/054-if-with-macros.c.expected | 35 - ...-define-chain-obj-to-func-parens-in-text.c | 3 - ...hain-obj-to-func-parens-in-text.c.expected | 4 - .../tests/056-macro-argument-with-comma.c | 4 - .../056-macro-argument-with-comma.c.expected | 5 - .../glsl/glcpp/tests/057-empty-arguments.c | 6 - .../tests/057-empty-arguments.c.expected | 7 - .../tests/058-token-pasting-empty-arguments.c | 5 - ...8-token-pasting-empty-arguments.c.expected | 6 - .../glcpp/tests/059-token-pasting-integer.c | 4 - .../059-token-pasting-integer.c.expected | 5 - ...-left-paren-in-macro-right-paren-in-text.c | 3 - ...en-in-macro-right-paren-in-text.c.expected | 4 - .../061-define-chain-obj-to-func-multi.c | 5 - ...-define-chain-obj-to-func-multi.c.expected | 6 - .../glsl/glcpp/tests/062-if-0-skips-garbage.c | 5 - .../tests/062-if-0-skips-garbage.c.expected | 6 - .../mesa/src/glsl/glcpp/tests/063-comments.c | 20 - .../glsl/glcpp/tests/063-comments.c.expected | 21 - .../mesa/src/glsl/glcpp/tests/064-version.c | 2 - .../glsl/glcpp/tests/064-version.c.expected | 3 - .../glsl/glcpp/tests/065-if-defined-parens.c | 17 - .../tests/065-if-defined-parens.c.expected | 18 - .../glcpp/tests/066-if-nospace-expression.c | 3 - .../066-if-nospace-expression.c.expected | 4 - .../glcpp/tests/067-nested-ifdef-ifndef.c | 40 - .../tests/067-nested-ifdef-ifndef.c.expected | 41 - .../glsl/glcpp/tests/068-accidental-pasting.c | 11 - .../tests/068-accidental-pasting.c.expected | 12 - .../glsl/glcpp/tests/069-repeated-argument.c | 2 - .../tests/069-repeated-argument.c.expected | 3 - .../tests/070-undefined-macro-in-expression.c | 2 - ...0-undefined-macro-in-expression.c.expected | 2 - .../src/glsl/glcpp/tests/071-punctuator.c | 1 - .../glcpp/tests/071-punctuator.c.expected | 2 - .../glcpp/tests/072-token-pasting-same-line.c | 2 - .../072-token-pasting-same-line.c.expected | 3 - .../src/glsl/glcpp/tests/073-if-in-ifdef.c | 4 - .../glcpp/tests/073-if-in-ifdef.c.expected | 5 - .../src/glsl/glcpp/tests/074-elif-undef.c | 3 - .../glcpp/tests/074-elif-undef.c.expected | 4 - .../glsl/glcpp/tests/075-elif-elif-undef.c | 4 - .../tests/075-elif-elif-undef.c.expected | 5 - .../glsl/glcpp/tests/076-elif-undef-nested.c | 5 - .../tests/076-elif-undef-nested.c.expected | 6 - .../glsl/glcpp/tests/077-else-without-if.c | 1 - .../tests/077-else-without-if.c.expected | 4 - .../glsl/glcpp/tests/078-elif-without-if.c | 1 - .../tests/078-elif-without-if.c.expected | 4 - .../glsl/glcpp/tests/079-endif-without-if.c | 1 - .../tests/079-endif-without-if.c.expected | 4 - .../glcpp/tests/080-if-without-expression.c | 4 - .../080-if-without-expression.c.expected | 6 - .../glcpp/tests/081-elif-without-expression.c | 3 - .../081-elif-without-expression.c.expected | 5 - .../src/glsl/glcpp/tests/082-invalid-paste.c | 2 - .../glcpp/tests/082-invalid-paste.c.expected | 5 - .../glsl/glcpp/tests/083-unterminated-if.c | 2 - .../tests/083-unterminated-if.c.expected | 5 - .../glcpp/tests/084-unbalanced-parentheses.c | 2 - .../084-unbalanced-parentheses.c.expected | 2 - .../tests/085-incorrect-argument-count.c | 5 - .../085-incorrect-argument-count.c.expected | 12 - .../glcpp/tests/086-reserved-macro-names.c | 3 - .../tests/086-reserved-macro-names.c.expected | 10 - .../src/glsl/glcpp/tests/087-if-comments.c | 5 - .../glcpp/tests/087-if-comments.c.expected | 6 - .../tests/088-redefine-macro-legitimate.c | 5 - .../088-redefine-macro-legitimate.c.expected | 6 - .../glcpp/tests/089-redefine-macro-error.c | 17 - .../tests/089-redefine-macro-error.c.expected | 30 - .../src/glsl/glcpp/tests/090-hash-error.c | 1 - .../glcpp/tests/090-hash-error.c.expected | 3 - .../mesa/src/glsl/glcpp/tests/091-hash-line.c | 8 - .../glsl/glcpp/tests/091-hash-line.c.expected | 13 - .../glcpp/tests/092-redefine-macro-error-2.c | 5 - .../092-redefine-macro-error-2.c.expected | 10 - .../src/glsl/glcpp/tests/093-divide-by-zero.c | 2 - .../glcpp/tests/093-divide-by-zero.c.expected | 4 - .../tests/094-divide-by-zero-short-circuit.c | 13 - ...94-divide-by-zero-short-circuit.c.expected | 15 - .../glsl/glcpp/tests/095-recursive-define.c | 3 - .../tests/095-recursive-define.c.expected | 4 - .../src/glsl/glcpp/tests/096-paste-twice.c | 3 - .../glcpp/tests/096-paste-twice.c.expected | 4 - .../tests/097-paste-with-non-function-macro.c | 3 - ...7-paste-with-non-function-macro.c.expected | 4 - .../src/glsl/glcpp/tests/098-elif-undefined.c | 3 - .../glcpp/tests/098-elif-undefined.c.expected | 5 - .../src/glsl/glcpp/tests/099-c99-example.c | 17 - .../glcpp/tests/099-c99-example.c.expected | 17 - .../mesa/src/glsl/glcpp/tests/glcpp-test | 80 - .../dll/opengl/mesa/src/glsl/glsl_lexer.cpp | 3784 ----------- .../dll/opengl/mesa/src/glsl/glsl_lexer.ll | 506 -- .../dll/opengl/mesa/src/glsl/glsl_parser.cpp | 5574 ---------------- .../dll/opengl/mesa/src/glsl/glsl_parser.h | 306 - .../dll/opengl/mesa/src/glsl/glsl_parser.yy | 1853 ------ .../mesa/src/glsl/glsl_parser_extras.cpp | 1052 --- .../opengl/mesa/src/glsl/glsl_parser_extras.h | 293 - .../mesa/src/glsl/glsl_symbol_table.cpp | 165 - .../opengl/mesa/src/glsl/glsl_symbol_table.h | 124 - .../dll/opengl/mesa/src/glsl/glsl_types.cpp | 550 -- reactos/dll/opengl/mesa/src/glsl/glsl_types.h | 538 -- .../mesa/src/glsl/hir_field_selection.cpp | 102 - reactos/dll/opengl/mesa/src/glsl/ir.cpp | 1576 ----- reactos/dll/opengl/mesa/src/glsl/ir.h | 1705 ----- .../opengl/mesa/src/glsl/ir_basic_block.cpp | 149 - .../dll/opengl/mesa/src/glsl/ir_basic_block.h | 28 - reactos/dll/opengl/mesa/src/glsl/ir_clone.cpp | 431 -- .../mesa/src/glsl/ir_constant_expression.cpp | 1422 ---- .../src/glsl/ir_expression_flattening.cpp | 92 - .../mesa/src/glsl/ir_expression_flattening.h | 38 - .../dll/opengl/mesa/src/glsl/ir_function.cpp | 216 - .../mesa/src/glsl/ir_function_can_inline.cpp | 76 - .../src/glsl/ir_function_detect_recursion.cpp | 374 -- .../mesa/src/glsl/ir_function_inlining.h | 30 - .../mesa/src/glsl/ir_hierarchical_visitor.cpp | 297 - .../mesa/src/glsl/ir_hierarchical_visitor.h | 184 - .../dll/opengl/mesa/src/glsl/ir_hv_accept.cpp | 396 -- .../mesa/src/glsl/ir_import_prototypes.cpp | 122 - .../opengl/mesa/src/glsl/ir_optimization.h | 80 - .../opengl/mesa/src/glsl/ir_print_visitor.cpp | 523 -- .../opengl/mesa/src/glsl/ir_print_visitor.h | 94 - .../dll/opengl/mesa/src/glsl/ir_reader.cpp | 1018 --- reactos/dll/opengl/mesa/src/glsl/ir_reader.h | 34 - .../mesa/src/glsl/ir_rvalue_visitor.cpp | 143 - .../opengl/mesa/src/glsl/ir_rvalue_visitor.h | 47 - .../mesa/src/glsl/ir_set_program_inouts.cpp | 183 - reactos/dll/opengl/mesa/src/glsl/ir_uniform.h | 128 - .../dll/opengl/mesa/src/glsl/ir_validate.cpp | 629 -- .../mesa/src/glsl/ir_variable_refcount.cpp | 113 - .../mesa/src/glsl/ir_variable_refcount.h | 78 - reactos/dll/opengl/mesa/src/glsl/ir_visitor.h | 84 - .../opengl/mesa/src/glsl/link_functions.cpp | 286 - .../opengl/mesa/src/glsl/link_uniforms.cpp | 431 -- reactos/dll/opengl/mesa/src/glsl/linker.cpp | 1882 ------ reactos/dll/opengl/mesa/src/glsl/linker.h | 82 - reactos/dll/opengl/mesa/src/glsl/list.h | 501 -- .../opengl/mesa/src/glsl/loop_analysis.cpp | 528 -- .../dll/opengl/mesa/src/glsl/loop_analysis.h | 255 - .../opengl/mesa/src/glsl/loop_controls.cpp | 304 - .../dll/opengl/mesa/src/glsl/loop_unroll.cpp | 229 - .../mesa/src/glsl/lower_clip_distance.cpp | 344 - .../opengl/mesa/src/glsl/lower_discard.cpp | 198 - .../mesa/src/glsl/lower_if_to_cond_assign.cpp | 252 - .../mesa/src/glsl/lower_instructions.cpp | 312 - .../dll/opengl/mesa/src/glsl/lower_jumps.cpp | 1011 --- .../mesa/src/glsl/lower_mat_op_to_vec.cpp | 428 -- .../dll/opengl/mesa/src/glsl/lower_noise.cpp | 71 - .../mesa/src/glsl/lower_output_reads.cpp | 141 - .../src/glsl/lower_texture_projection.cpp | 99 - .../lower_variable_index_to_cond_assign.cpp | 536 -- .../glsl/lower_vec_index_to_cond_assign.cpp | 293 - .../src/glsl/lower_vec_index_to_swizzle.cpp | 175 - .../dll/opengl/mesa/src/glsl/lower_vector.cpp | 224 - reactos/dll/opengl/mesa/src/glsl/main.cpp | 279 - .../opengl/mesa/src/glsl/opt_algebraic.cpp | 411 -- .../mesa/src/glsl/opt_constant_folding.cpp | 147 - .../src/glsl/opt_constant_propagation.cpp | 445 -- .../mesa/src/glsl/opt_constant_variable.cpp | 195 - .../mesa/src/glsl/opt_copy_propagation.cpp | 345 - .../glsl/opt_copy_propagation_elements.cpp | 490 -- .../opengl/mesa/src/glsl/opt_dead_code.cpp | 148 - .../mesa/src/glsl/opt_dead_code_local.cpp | 222 - .../mesa/src/glsl/opt_dead_functions.cpp | 155 - .../src/glsl/opt_discard_simplification.cpp | 205 - .../mesa/src/glsl/opt_function_inlining.cpp | 421 -- .../mesa/src/glsl/opt_if_simplification.cpp | 95 - .../opengl/mesa/src/glsl/opt_noop_swizzle.cpp | 80 - .../mesa/src/glsl/opt_redundant_jumps.cpp | 120 - .../mesa/src/glsl/opt_structure_splitting.cpp | 367 -- .../mesa/src/glsl/opt_swizzle_swizzle.cpp | 93 - .../mesa/src/glsl/opt_tree_grafting.cpp | 386 -- reactos/dll/opengl/mesa/src/glsl/program.h | 35 - reactos/dll/opengl/mesa/src/glsl/ralloc.c | 489 -- reactos/dll/opengl/mesa/src/glsl/ralloc.h | 402 -- .../dll/opengl/mesa/src/glsl/s_expression.cpp | 219 - .../dll/opengl/mesa/src/glsl/s_expression.h | 180 - .../mesa/src/glsl/standalone_scaffolding.cpp | 88 - .../mesa/src/glsl/standalone_scaffolding.h | 54 - reactos/dll/opengl/mesa/src/glsl/strtod.c | 57 - reactos/dll/opengl/mesa/src/glsl/strtod.h | 43 - reactos/dll/opengl/mesa/src/glsl/test.cpp | 78 - .../dll/opengl/mesa/src/glsl/test_optpass.cpp | 273 - .../dll/opengl/mesa/src/glsl/test_optpass.h | 30 - .../dll/opengl/mesa/src/mesa/CMakeLists.txt | 4 - .../src/mesa/drivers/common/driverfuncs.c | 9 - .../mesa/src/mesa/drivers/common/meta.c | 152 +- .../mesa/src/mesa/drivers/common/meta.h | 1 - .../opengl/mesa/src/mesa/main/CMakeLists.txt | 6 - .../opengl/mesa/src/mesa/main/api_arrayelt.c | 784 +-- .../dll/opengl/mesa/src/mesa/main/api_exec.c | 120 - .../opengl/mesa/src/mesa/main/api_loopback.c | 452 -- .../opengl/mesa/src/mesa/main/api_validate.c | 24 +- .../opengl/mesa/src/mesa/main/arbprogram.c | 905 --- .../opengl/mesa/src/mesa/main/arbprogram.h | 131 - .../dll/opengl/mesa/src/mesa/main/attrib.c | 301 +- .../dll/opengl/mesa/src/mesa/main/config.h | 99 +- .../dll/opengl/mesa/src/mesa/main/context.c | 237 - reactos/dll/opengl/mesa/src/mesa/main/dd.h | 83 - .../dll/opengl/mesa/src/mesa/main/dispatch.h | 2703 -------- reactos/dll/opengl/mesa/src/mesa/main/dlist.c | 1844 +----- .../dll/opengl/mesa/src/mesa/main/drawpix.c | 44 +- .../dll/opengl/mesa/src/mesa/main/enable.c | 215 +- reactos/dll/opengl/mesa/src/mesa/main/eval.c | 64 - .../opengl/mesa/src/mesa/main/extensions.c | 71 - .../opengl/mesa/src/mesa/main/format_pack.c | 25 - .../opengl/mesa/src/mesa/main/format_unpack.c | 14 - .../dll/opengl/mesa/src/mesa/main/formats.c | 17 +- .../dll/opengl/mesa/src/mesa/main/formats.h | 1 - reactos/dll/opengl/mesa/src/mesa/main/get.c | 280 +- .../dll/opengl/mesa/src/mesa/main/getstring.c | 44 +- reactos/dll/opengl/mesa/src/mesa/main/hint.c | 13 - reactos/dll/opengl/mesa/src/mesa/main/image.c | 35 - reactos/dll/opengl/mesa/src/mesa/main/image.h | 3 - .../dll/opengl/mesa/src/mesa/main/matrix.c | 80 +- .../dll/opengl/mesa/src/mesa/main/mtypes.h | 824 +-- .../dll/opengl/mesa/src/mesa/main/nvprogram.c | 920 --- .../dll/opengl/mesa/src/mesa/main/nvprogram.h | 119 - reactos/dll/opengl/mesa/src/mesa/main/pack.c | 137 - reactos/dll/opengl/mesa/src/mesa/main/pack.h | 8 - .../dll/opengl/mesa/src/mesa/main/points.c | 6 +- .../dll/opengl/mesa/src/mesa/main/rastpos.c | 14 +- .../mesa/src/mesa/main/shader_query.cpp | 329 - .../dll/opengl/mesa/src/mesa/main/shaderapi.c | 1501 ----- .../dll/opengl/mesa/src/mesa/main/shaderapi.h | 196 - .../dll/opengl/mesa/src/mesa/main/shaderobj.c | 409 -- .../dll/opengl/mesa/src/mesa/main/shaderobj.h | 137 - .../dll/opengl/mesa/src/mesa/main/shared.c | 132 - reactos/dll/opengl/mesa/src/mesa/main/state.c | 294 +- reactos/dll/opengl/mesa/src/mesa/main/state.h | 12 - .../dll/opengl/mesa/src/mesa/main/texenv.c | 303 +- .../dll/opengl/mesa/src/mesa/main/texenv.h | 12 - .../dll/opengl/mesa/src/mesa/main/texformat.c | 11 - .../dll/opengl/mesa/src/mesa/main/texgen.c | 28 +- .../opengl/mesa/src/mesa/main/texgetimage.c | 15 +- .../dll/opengl/mesa/src/mesa/main/teximage.c | 57 +- .../dll/opengl/mesa/src/mesa/main/teximage.h | 4 - .../dll/opengl/mesa/src/mesa/main/texobj.c | 24 +- .../dll/opengl/mesa/src/mesa/main/texparam.c | 20 +- .../dll/opengl/mesa/src/mesa/main/texstate.c | 363 +- .../dll/opengl/mesa/src/mesa/main/texstate.h | 29 +- .../opengl/mesa/src/mesa/main/texstorage.c | 4 +- .../dll/opengl/mesa/src/mesa/main/texstore.c | 87 - .../mesa/src/mesa/main/uniform_query.cpp | 986 --- .../dll/opengl/mesa/src/mesa/main/uniforms.c | 580 -- .../dll/opengl/mesa/src/mesa/main/uniforms.h | 299 - .../dll/opengl/mesa/src/mesa/main/varray.c | 353 +- .../dll/opengl/mesa/src/mesa/main/varray.h | 51 - .../dll/opengl/mesa/src/mesa/main/version.c | 30 - .../dll/opengl/mesa/src/mesa/main/version.h | 3 - .../dll/opengl/mesa/src/mesa/main/vtxfmt.c | 36 - .../mesa/src/mesa/program/CMakeLists.txt | 32 - .../mesa/src/mesa/program/arbprogparse.c | 214 - .../mesa/src/mesa/program/arbprogparse.h | 45 - .../opengl/mesa/src/mesa/program/hash_table.c | 234 - .../opengl/mesa/src/mesa/program/hash_table.h | 279 - .../mesa/src/mesa/program/ir_to_mesa.cpp | 3397 ---------- .../opengl/mesa/src/mesa/program/ir_to_mesa.h | 54 - .../dll/opengl/mesa/src/mesa/program/lex.yy.c | 3671 ----------- .../mesa/src/mesa/program/nvfragparse.c | 1592 ----- .../mesa/src/mesa/program/nvfragparse.h | 47 - .../mesa/src/mesa/program/nvvertparse.c | 1460 ----- .../mesa/src/mesa/program/nvvertparse.h | 49 - .../opengl/mesa/src/mesa/program/prog_cache.c | 251 - .../opengl/mesa/src/mesa/program/prog_cache.h | 68 - .../mesa/src/mesa/program/prog_execute.c | 1903 ------ .../mesa/src/mesa/program/prog_execute.h | 87 - .../mesa/src/mesa/program/prog_instruction.c | 354 - .../mesa/src/mesa/program/prog_instruction.h | 454 -- .../opengl/mesa/src/mesa/program/prog_noise.c | 638 -- .../opengl/mesa/src/mesa/program/prog_noise.h | 36 - .../src/mesa/program/prog_opt_constant_fold.c | 451 -- .../mesa/src/mesa/program/prog_optimize.c | 1366 ---- .../mesa/src/mesa/program/prog_optimize.h | 50 - .../mesa/src/mesa/program/prog_parameter.c | 658 -- .../mesa/src/mesa/program/prog_parameter.h | 190 - .../src/mesa/program/prog_parameter_layout.c | 216 - .../src/mesa/program/prog_parameter_layout.h | 42 - .../opengl/mesa/src/mesa/program/prog_print.c | 1126 ---- .../opengl/mesa/src/mesa/program/prog_print.h | 119 - .../mesa/src/mesa/program/prog_statevars.c | 1182 ---- .../mesa/src/mesa/program/prog_statevars.h | 159 - .../opengl/mesa/src/mesa/program/program.c | 975 --- .../opengl/mesa/src/mesa/program/program.h | 195 - .../mesa/src/mesa/program/program_lexer.l | 507 -- .../mesa/src/mesa/program/program_parse.tab.c | 5739 ----------------- .../mesa/src/mesa/program/program_parse.tab.h | 208 - .../mesa/src/mesa/program/program_parse.y | 2806 -------- .../src/mesa/program/program_parse_extra.c | 244 - .../mesa/src/mesa/program/program_parser.h | 298 - .../opengl/mesa/src/mesa/program/programopt.c | 685 -- .../opengl/mesa/src/mesa/program/programopt.h | 55 - .../mesa/src/mesa/program/register_allocate.c | 564 -- .../mesa/src/mesa/program/register_allocate.h | 74 - .../opengl/mesa/src/mesa/program/sampler.cpp | 124 - .../opengl/mesa/src/mesa/program/sampler.h | 29 - .../src/mesa/program/string_to_uint_map.cpp | 42 - .../mesa/src/mesa/program/symbol_table.c | 489 -- .../mesa/src/mesa/program/symbol_table.h | 62 - .../opengl/mesa/src/mesa/swrast/s_aaline.c | 2 +- .../mesa/src/mesa/swrast/s_aalinetemp.h | 10 +- .../mesa/src/mesa/swrast/s_aatriangle.c | 2 +- .../opengl/mesa/src/mesa/swrast/s_context.c | 108 +- .../opengl/mesa/src/mesa/swrast/s_context.h | 7 +- .../opengl/mesa/src/mesa/swrast/s_drawpix.c | 16 +- .../opengl/mesa/src/mesa/swrast/s_feedback.c | 2 +- .../dll/opengl/mesa/src/mesa/swrast/s_lines.c | 2 +- .../opengl/mesa/src/mesa/swrast/s_points.c | 23 +- .../dll/opengl/mesa/src/mesa/swrast/s_span.c | 196 +- .../dll/opengl/mesa/src/mesa/swrast/s_span.h | 2 +- .../mesa/src/mesa/swrast/s_texcombine.c | 105 +- .../opengl/mesa/src/mesa/swrast/s_texfetch.c | 8 - .../mesa/src/mesa/swrast/s_texfetch_tmp.h | 16 - .../opengl/mesa/src/mesa/swrast/s_texfilter.c | 28 +- .../opengl/mesa/src/mesa/swrast/s_texture.c | 20 +- .../opengl/mesa/src/mesa/swrast/s_triangle.c | 57 +- .../opengl/mesa/src/mesa/swrast/s_tritemp.h | 40 +- .../dll/opengl/mesa/src/mesa/swrast/swrast.h | 2 +- .../mesa/src/mesa/swrast_setup/ss_context.c | 78 +- .../mesa/src/mesa/swrast_setup/ss_triangle.c | 3 +- .../mesa/src/mesa/swrast_setup/ss_tritmp.h | 49 +- .../mesa/src/mesa/swrast_setup/swrast_setup.h | 6 - .../dll/opengl/mesa/src/mesa/tnl/t_context.c | 39 +- .../dll/opengl/mesa/src/mesa/tnl/t_context.h | 71 +- reactos/dll/opengl/mesa/src/mesa/tnl/t_draw.c | 6 +- .../dll/opengl/mesa/src/mesa/tnl/t_pipeline.c | 2 +- .../opengl/mesa/src/mesa/tnl/t_rasterpos.c | 174 +- .../dll/opengl/mesa/src/mesa/tnl/t_vb_fog.c | 2 +- .../dll/opengl/mesa/src/mesa/tnl/t_vb_light.c | 6 +- .../opengl/mesa/src/mesa/tnl/t_vb_normals.c | 5 +- .../opengl/mesa/src/mesa/tnl/t_vb_points.c | 2 +- .../opengl/mesa/src/mesa/tnl/t_vb_texgen.c | 111 +- .../opengl/mesa/src/mesa/tnl/t_vb_texmat.c | 27 +- .../opengl/mesa/src/mesa/tnl/t_vb_vertex.c | 3 - reactos/dll/opengl/mesa/src/mesa/vbo/vbo.h | 41 - .../dll/opengl/mesa/src/mesa/vbo/vbo_attrib.h | 61 +- .../opengl/mesa/src/mesa/vbo/vbo_attrib_tmp.h | 358 +- .../opengl/mesa/src/mesa/vbo/vbo_context.c | 54 +- .../opengl/mesa/src/mesa/vbo/vbo_context.h | 21 - .../dll/opengl/mesa/src/mesa/vbo/vbo_exec.c | 2 +- .../dll/opengl/mesa/src/mesa/vbo/vbo_exec.h | 6 +- .../opengl/mesa/src/mesa/vbo/vbo_exec_api.c | 185 +- .../opengl/mesa/src/mesa/vbo/vbo_exec_array.c | 259 +- .../opengl/mesa/src/mesa/vbo/vbo_exec_draw.c | 52 +- .../opengl/mesa/src/mesa/vbo/vbo_exec_eval.c | 37 +- .../dll/opengl/mesa/src/mesa/vbo/vbo_noop.c | 106 - .../dll/opengl/mesa/src/mesa/vbo/vbo_rebase.c | 30 +- .../dll/opengl/mesa/src/mesa/vbo/vbo_save.c | 20 +- .../opengl/mesa/src/mesa/vbo/vbo_save_api.c | 68 +- .../opengl/mesa/src/mesa/vbo/vbo_save_draw.c | 57 +- .../opengl/mesa/src/mesa/vbo/vbo_split_copy.c | 9 +- .../opengl/mesa/src/mesa/x86/gen_matypes.c | 5 +- reactos/dll/opengl/opengl32/CMakeLists.txt | 4 - 486 files changed, 907 insertions(+), 111908 deletions(-) delete mode 100644 reactos/dll/opengl/mesa/src/glsl/CMakeLists.txt delete mode 100644 reactos/dll/opengl/mesa/src/glsl/Makefile.sources delete mode 100644 reactos/dll/opengl/mesa/src/glsl/README delete mode 100644 reactos/dll/opengl/mesa/src/glsl/SConscript delete mode 100644 reactos/dll/opengl/mesa/src/glsl/TODO delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ast.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ast_expr.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ast_function.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ast_to_hir.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ast_type.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/builtin_stubs.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/builtin_types.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/builtin_variables.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/README delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.l delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.y delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/pp.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c.expected delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glcpp/tests/glcpp-test delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_lexer.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_lexer.ll delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_parser.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_parser.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_parser.yy delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_types.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/glsl_types.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/hir_field_selection.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_basic_block.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_basic_block.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_clone.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_constant_expression.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_function.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_function_can_inline.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_function_detect_recursion.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_function_inlining.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_hv_accept.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_import_prototypes.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_optimization.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_reader.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_reader.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_set_program_inouts.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_uniform.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_validate.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ir_visitor.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/link_functions.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/link_uniforms.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/linker.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/linker.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/list.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/loop_analysis.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/loop_analysis.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/loop_controls.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/loop_unroll.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_clip_distance.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_discard.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_if_to_cond_assign.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_instructions.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_jumps.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_mat_op_to_vec.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_noise.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_output_reads.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_texture_projection.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_variable_index_to_cond_assign.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_cond_assign.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_swizzle.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/lower_vector.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/main.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_algebraic.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_constant_folding.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_constant_propagation.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_constant_variable.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation_elements.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_dead_code.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_dead_code_local.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_dead_functions.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_discard_simplification.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_function_inlining.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_if_simplification.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_noop_swizzle.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_redundant_jumps.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_structure_splitting.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_swizzle_swizzle.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/opt_tree_grafting.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/program.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ralloc.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/ralloc.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/s_expression.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/s_expression.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/strtod.c delete mode 100644 reactos/dll/opengl/mesa/src/glsl/strtod.h delete mode 100644 reactos/dll/opengl/mesa/src/glsl/test.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/test_optpass.cpp delete mode 100644 reactos/dll/opengl/mesa/src/glsl/test_optpass.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/arbprogram.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/arbprogram.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/nvprogram.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/nvprogram.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/shader_query.cpp delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/shaderapi.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/shaderapi.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/shaderobj.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/shaderobj.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/uniform_query.cpp delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/uniforms.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/main/uniforms.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/CMakeLists.txt delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/hash_table.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/hash_table.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.cpp delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/lex.yy.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_cache.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_cache.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_execute.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_execute.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_noise.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_noise.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_opt_constant_fold.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_print.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_print.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program_lexer.l delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program_parse.y delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program_parse_extra.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/program_parser.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/programopt.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/programopt.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/register_allocate.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/register_allocate.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/sampler.cpp delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/sampler.h delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/string_to_uint_map.cpp delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/symbol_table.c delete mode 100644 reactos/dll/opengl/mesa/src/mesa/program/symbol_table.h diff --git a/reactos/dll/opengl/mesa/src/CMakeLists.txt b/reactos/dll/opengl/mesa/src/CMakeLists.txt index 6a236d51081..ff02d684194 100644 --- a/reactos/dll/opengl/mesa/src/CMakeLists.txt +++ b/reactos/dll/opengl/mesa/src/CMakeLists.txt @@ -1,3 +1,2 @@ -add_subdirectory(glsl) add_subdirectory(mesa) diff --git a/reactos/dll/opengl/mesa/src/glsl/CMakeLists.txt b/reactos/dll/opengl/mesa/src/glsl/CMakeLists.txt deleted file mode 100644 index fde70ecf591..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ - -set_cpp(WITH_STL) - -# From Sconscript -include_directories( - ../mapi - ../mesa - . - glcpp - ../../generated/glsl) - -list(APPEND SOURCE -# generated files - ../../generated/glsl/glcpp/glcpp-lex.c - ../../generated/glsl/glcpp/glcpp-parse.c - ../../generated/glsl/glsl_lexer.cpp - ../../generated/glsl/glsl_parser.cpp - ../../generated/glsl/builtin_function.cpp -# Regular files - strtod.c - ralloc.c - glcpp/pp.c - ast_expr.cpp - ast_function.cpp - ast_to_hir.cpp - ast_type.cpp - builtin_variables.cpp - glsl_parser_extras.cpp - glsl_types.cpp - glsl_symbol_table.cpp - hir_field_selection.cpp - ir_basic_block.cpp - ir_clone.cpp - ir_constant_expression.cpp - ir.cpp - ir_expression_flattening.cpp - ir_function_can_inline.cpp - ir_function_detect_recursion.cpp - ir_function.cpp - ir_hierarchical_visitor.cpp - ir_hv_accept.cpp - ir_import_prototypes.cpp - ir_print_visitor.cpp - ir_reader.cpp - ir_rvalue_visitor.cpp - ir_set_program_inouts.cpp - ir_validate.cpp - ir_variable_refcount.cpp - linker.cpp - link_functions.cpp - link_uniforms.cpp - loop_analysis.cpp - loop_controls.cpp - loop_unroll.cpp - lower_clip_distance.cpp - lower_discard.cpp - lower_if_to_cond_assign.cpp - lower_instructions.cpp - lower_jumps.cpp - lower_mat_op_to_vec.cpp - lower_noise.cpp - lower_texture_projection.cpp - lower_variable_index_to_cond_assign.cpp - lower_vec_index_to_cond_assign.cpp - lower_vec_index_to_swizzle.cpp - lower_vector.cpp - lower_output_reads.cpp - opt_algebraic.cpp - opt_constant_folding.cpp - opt_constant_propagation.cpp - opt_constant_variable.cpp - opt_copy_propagation.cpp - opt_copy_propagation_elements.cpp - opt_dead_code.cpp - opt_dead_code_local.cpp - opt_dead_functions.cpp - opt_discard_simplification.cpp - opt_function_inlining.cpp - opt_if_simplification.cpp - opt_noop_swizzle.cpp - opt_redundant_jumps.cpp - opt_structure_splitting.cpp - opt_swizzle_swizzle.cpp - opt_tree_grafting.cpp - s_expression.cpp) - -# this is just a helper library, don't include it in the all target -add_library(mesa_glsl STATIC EXCLUDE_FROM_ALL ${SOURCE}) diff --git a/reactos/dll/opengl/mesa/src/glsl/Makefile.sources b/reactos/dll/opengl/mesa/src/glsl/Makefile.sources deleted file mode 100644 index 5e80af297c0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/Makefile.sources +++ /dev/null @@ -1,105 +0,0 @@ -# shared source lists for Makefile, SConscript, and Android.mk - -# libglcpp - -LIBGLCPP_SOURCES := \ - glcpp/pp.c - -LIBGLCPP_GENERATED_SOURCES := \ - glcpp/glcpp-lex.c \ - glcpp/glcpp-parse.c - -# libglsl - -LIBGLSL_SOURCES := \ - strtod.c \ - ralloc.c - -LIBGLSL_CXX_SOURCES := \ - ast_expr.cpp \ - ast_function.cpp \ - ast_to_hir.cpp \ - ast_type.cpp \ - builtin_variables.cpp \ - glsl_parser_extras.cpp \ - glsl_types.cpp \ - glsl_symbol_table.cpp \ - hir_field_selection.cpp \ - ir_basic_block.cpp \ - ir_clone.cpp \ - ir_constant_expression.cpp \ - ir.cpp \ - ir_expression_flattening.cpp \ - ir_function_can_inline.cpp \ - ir_function_detect_recursion.cpp \ - ir_function.cpp \ - ir_hierarchical_visitor.cpp \ - ir_hv_accept.cpp \ - ir_import_prototypes.cpp \ - ir_print_visitor.cpp \ - ir_reader.cpp \ - ir_rvalue_visitor.cpp \ - ir_set_program_inouts.cpp \ - ir_validate.cpp \ - ir_variable_refcount.cpp \ - linker.cpp \ - link_functions.cpp \ - link_uniforms.cpp \ - loop_analysis.cpp \ - loop_controls.cpp \ - loop_unroll.cpp \ - lower_clip_distance.cpp \ - lower_discard.cpp \ - lower_if_to_cond_assign.cpp \ - lower_instructions.cpp \ - lower_jumps.cpp \ - lower_mat_op_to_vec.cpp \ - lower_noise.cpp \ - lower_texture_projection.cpp \ - lower_variable_index_to_cond_assign.cpp \ - lower_vec_index_to_cond_assign.cpp \ - lower_vec_index_to_swizzle.cpp \ - lower_vector.cpp \ - lower_output_reads.cpp \ - opt_algebraic.cpp \ - opt_constant_folding.cpp \ - opt_constant_propagation.cpp \ - opt_constant_variable.cpp \ - opt_copy_propagation.cpp \ - opt_copy_propagation_elements.cpp \ - opt_dead_code.cpp \ - opt_dead_code_local.cpp \ - opt_dead_functions.cpp \ - opt_discard_simplification.cpp \ - opt_function_inlining.cpp \ - opt_if_simplification.cpp \ - opt_noop_swizzle.cpp \ - opt_redundant_jumps.cpp \ - opt_structure_splitting.cpp \ - opt_swizzle_swizzle.cpp \ - opt_tree_grafting.cpp \ - s_expression.cpp - -# glsl_compiler - -GLSL_COMPILER_CXX_SOURCES := \ - standalone_scaffolding.cpp \ - main.cpp - -# builtin_compiler -# -# This is built before libglsl to generate builtin_funciton.cpp for libglsl. -# For this to work, a dummy version of builtin_function.cpp, -# builtin_stubs.cpp, is used. - -BUILTIN_COMPILER_CXX_SOURCES := \ - builtin_stubs.cpp - -BUILTIN_COMPILER_GENERATED_CXX_SOURCES := \ - glsl_lexer.cpp \ - glsl_parser.cpp - -# libglsl generated sources -LIBGLSL_GENERATED_CXX_SOURCES := \ - $(BUILTIN_COMPILER_GENERATED_CXX_SOURCES) \ - builtin_function.cpp diff --git a/reactos/dll/opengl/mesa/src/glsl/README b/reactos/dll/opengl/mesa/src/glsl/README deleted file mode 100644 index dd80a53d476..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/README +++ /dev/null @@ -1,229 +0,0 @@ -Welcome to Mesa's GLSL compiler. A brief overview of how things flow: - -1) lex and yacc-based preprocessor takes the incoming shader string -and produces a new string containing the preprocessed shader. This -takes care of things like #if, #ifdef, #define, and preprocessor macro -invocations. Note that #version, #extension, and some others are -passed straight through. See glcpp/* - -2) lex and yacc-based parser takes the preprocessed string and -generates the AST (abstract syntax tree). Almost no checking is -performed in this stage. See glsl_lexer.lpp and glsl_parser.ypp. - -3) The AST is converted to "HIR". This is the intermediate -representation of the compiler. Constructors are generated, function -calls are resolved to particular function signatures, and all the -semantic checking is performed. See ast_*.cpp for the conversion, and -ir.h for the IR structures. - -4) The driver (Mesa, or main.cpp for the standalone binary) performs -optimizations. These include copy propagation, dead code elimination, -constant folding, and others. Generally the driver will call -optimizations in a loop, as each may open up opportunities for other -optimizations to do additional work. See most files called ir_*.cpp - -5) linking is performed. This does checking to ensure that the -outputs of the vertex shader match the inputs of the fragment shader, -and assigns locations to uniforms, attributes, and varyings. See -linker.cpp. - -6) The driver may perform additional optimization at this point, as -for example dead code elimination previously couldn't remove functions -or global variable usage when we didn't know what other code would be -linked in. - -7) The driver performs code generation out of the IR, taking a linked -shader program and producing a compiled program for each stage. See -ir_to_mesa.cpp for Mesa IR code generation. - -FAQ: - -Q: What is HIR versus IR versus LIR? - -A: The idea behind the naming was that ast_to_hir would produce a -high-level IR ("HIR"), with things like matrix operations, structure -assignments, etc., present. A series of lowering passes would occur -that do things like break matrix multiplication into a series of dot -products/MADs, make structure assignment be a series of assignment of -components, flatten if statements into conditional moves, and such, -producing a low level IR ("LIR"). - -However, it now appears that each driver will have different -requirements from a LIR. A 915-generation chipset wants all functions -inlined, all loops unrolled, all ifs flattened, no variable array -accesses, and matrix multiplication broken down. The Mesa IR backend -for swrast would like matrices and structure assignment broken down, -but it can support function calls and dynamic branching. A 965 vertex -shader IR backend could potentially even handle some matrix operations -without breaking them down, but the 965 fragment shader IR backend -would want to break to have (almost) all operations down channel-wise -and perform optimization on that. As a result, there's no single -low-level IR that will make everyone happy. So that usage has fallen -out of favor, and each driver will perform a series of lowering passes -to take the HIR down to whatever restrictions it wants to impose -before doing codegen. - -Q: How is the IR structured? - -A: The best way to get started seeing it would be to run the -standalone compiler against a shader: - -./glsl_compiler --dump-lir \ - ~/src/piglit/tests/shaders/glsl-orangebook-ch06-bump.frag - -So for example one of the ir_instructions in main() contains: - -(assign (constant bool (1)) (var_ref litColor) (expression vec3 * (var_ref Surf -aceColor) (var_ref __retval) ) ) - -Or more visually: - (assign) - / | \ - (var_ref) (expression *) (constant bool 1) - / / \ -(litColor) (var_ref) (var_ref) - / \ - (SurfaceColor) (__retval) - -which came from: - -litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0); - -(the max call is not represented in this expression tree, as it was a -function call that got inlined but not brought into this expression -tree) - -Each of those nodes is a subclass of ir_instruction. A particular -ir_instruction instance may only appear once in the whole IR tree with -the exception of ir_variables, which appear once as variable -declarations: - -(declare () vec3 normDelta) - -and multiple times as the targets of variable dereferences: -... -(assign (constant bool (1)) (var_ref __retval) (expression float dot - (var_ref normDelta) (var_ref LightDir) ) ) -... -(assign (constant bool (1)) (var_ref __retval) (expression vec3 - - (var_ref LightDir) (expression vec3 * (constant float (2.000000)) - (expression vec3 * (expression float dot (var_ref normDelta) (var_ref - LightDir) ) (var_ref normDelta) ) ) ) ) -... - -Each node has a type. Expressions may involve several different types: -(declare (uniform ) mat4 gl_ModelViewMatrix) -((assign (constant bool (1)) (var_ref constructor_tmp) (expression - vec4 * (var_ref gl_ModelViewMatrix) (var_ref gl_Vertex) ) ) - -An expression tree can be arbitrarily deep, and the compiler tries to -keep them structured like that so that things like algebraic -optimizations ((color * 1.0 == color) and ((mat1 * mat2) * vec == mat1 -* (mat2 * vec))) or recognizing operation patterns for code generation -(vec1 * vec2 + vec3 == mad(vec1, vec2, vec3)) are easier. This comes -at the expense of additional trickery in implementing some -optimizations like CSE where one must navigate an expression tree. - -Q: Why no SSA representation? - -A: Converting an IR tree to SSA form makes dead code elmimination, -common subexpression elimination, and many other optimizations much -easier. However, in our primarily vector-based language, there's some -major questions as to how it would work. Do we do SSA on the scalar -or vector level? If we do it at the vector level, we're going to end -up with many different versions of the variable when encountering code -like: - -(assign (constant bool (1)) (swiz x (var_ref __retval) ) (var_ref a) ) -(assign (constant bool (1)) (swiz y (var_ref __retval) ) (var_ref b) ) -(assign (constant bool (1)) (swiz z (var_ref __retval) ) (var_ref c) ) - -If every masked update of a component relies on the previous value of -the variable, then we're probably going to be quite limited in our -dead code elimination wins, and recognizing common expressions may -just not happen. On the other hand, if we operate channel-wise, then -we'll be prone to optimizing the operation on one of the channels at -the expense of making its instruction flow different from the other -channels, and a vector-based GPU would end up with worse code than if -we didn't optimize operations on that channel! - -Once again, it appears that our optimization requirements are driven -significantly by the target architecture. For now, targeting the Mesa -IR backend, SSA does not appear to be that important to producing -excellent code, but we do expect to do some SSA-based optimizations -for the 965 fragment shader backend when that is developed. - -Q: How should I expand instructions that take multiple backend instructions? - -Sometimes you'll have to do the expansion in your code generation -- -see, for example, ir_to_mesa.cpp's handling of ir_unop_sqrt. However, -in many cases you'll want to do a pass over the IR to convert -non-native instructions to a series of native instructions. For -example, for the Mesa backend we have ir_div_to_mul_rcp.cpp because -Mesa IR (and many hardware backends) only have a reciprocal -instruction, not a divide. Implementing non-native instructions this -way gives the chance for constant folding to occur, so (a / 2.0) -becomes (a * 0.5) after codegen instead of (a * (1.0 / 2.0)) - -Q: How shoud I handle my special hardware instructions with respect to IR? - -Our current theory is that if multiple targets have an instruction for -some operation, then we should probably be able to represent that in -the IR. Generally this is in the form of an ir_{bin,un}op expression -type. For example, we initially implemented fract() using (a - -floor(a)), but both 945 and 965 have instructions to give that result, -and it would also simplify the implementation of mod(), so -ir_unop_fract was added. The following areas need updating to add a -new expression type: - -ir.h (new enum) -ir.cpp:get_num_operands() (used for ir_reader) -ir.cpp:operator_strs (used for ir_reader) -ir_constant_expression.cpp (you probably want to be able to constant fold) -ir_validate.cpp (check users have the right types) - -You may also need to update the backends if they will see the new expr type: - -../mesa/shaders/ir_to_mesa.cpp - -You can then use the new expression from builtins (if all backends -would rather see it), or scan the IR and convert to use your new -expression type (see ir_mod_to_fract, for example). - -Q: How is memory management handled in the compiler? - -The hierarchical memory allocator "talloc" developed for the Samba -project is used, so that things like optimization passes don't have to -worry about their garbage collection so much. It has a few nice -features, including low performance overhead and good debugging -support that's trivially available. - -Generally, each stage of the compile creates a talloc context and -allocates its memory out of that or children of it. At the end of the -stage, the pieces still live are stolen to a new context and the old -one freed, or the whole context is kept for use by the next stage. - -For IR transformations, a temporary context is used, then at the end -of all transformations, reparent_ir reparents all live nodes under the -shader's IR list, and the old context full of dead nodes is freed. -When developing a single IR transformation pass, this means that you -want to allocate instruction nodes out of the temporary context, so if -it becomes dead it doesn't live on as the child of a live node. At -the moment, optimization passes aren't passed that temporary context, -so they find it by calling talloc_parent() on a nearby IR node. The -talloc_parent() call is expensive, so many passes will cache the -result of the first talloc_parent(). Cleaning up all the optimization -passes to take a context argument and not call talloc_parent() is left -as an exercise. - -Q: What is the file naming convention in this directory? - -Initially, there really wasn't one. We have since adopted one: - - - Files that implement code lowering passes should be named lower_* - (e.g., lower_noise.cpp). - - Files that implement optimization passes should be named opt_*. - - Files that implement a class that is used throught the code should - take the name of that class (e.g., ir_hierarchical_visitor.cpp). - - Files that contain code not fitting in one of the previous - categories should have a sensible name (e.g., glsl_parser.ypp). diff --git a/reactos/dll/opengl/mesa/src/glsl/SConscript b/reactos/dll/opengl/mesa/src/glsl/SConscript deleted file mode 100644 index b8154d6083c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/SConscript +++ /dev/null @@ -1,131 +0,0 @@ -import common - -Import('*') - -from sys import executable as python_cmd - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '#include', - '#src/mapi', - '#src/mesa', - '#src/glsl', - '#src/glsl/glcpp', -]) - -# Make glcpp/glcpp-parse.h and glsl_parser.h reacheable from the include path -env.Append(CPPPATH = [Dir('.').abspath]) - -env.Append(YACCFLAGS = '-d') - -parser_env = env.Clone() -parser_env.Append(YACCFLAGS = [ - '--defines=%s' % File('glsl_parser.h').abspath, - '-p', '_mesa_glsl_', -]) - -glcpp_lexer = env.CFile('glcpp/glcpp-lex.c', 'glcpp/glcpp-lex.l') -glcpp_parser = env.CFile('glcpp/glcpp-parse.c', 'glcpp/glcpp-parse.y') -glsl_lexer = parser_env.CXXFile('glsl_lexer.cpp', 'glsl_lexer.ll') -glsl_parser = parser_env.CXXFile('glsl_parser.cpp', 'glsl_parser.yy') - -# common generated sources -glsl_sources = [ - glcpp_lexer, - glcpp_parser[0], - glsl_lexer, - glsl_parser[0], -] - -# parse Makefile.sources -source_lists = env.ParseSourceList('Makefile.sources') - -# add non-generated sources -for l in ('LIBGLCPP_SOURCES', 'LIBGLSL_SOURCES', 'LIBGLSL_CXX_SOURCES'): - glsl_sources += source_lists[l] - -if env['msvc']: - env.Prepend(CPPPATH = ['#/src/getopt']) - env.PrependUnique(LIBS = [getopt]) - -if env['crosscompile'] and not env['embedded']: - Import('builtin_glsl_function') -else: - # Copy these files to avoid generation object files into src/mesa/program - env.Prepend(CPPPATH = ['#src/mesa/program']) - env.Command('hash_table.c', '#src/mesa/program/hash_table.c', Copy('$TARGET', '$SOURCE')) - env.Command('symbol_table.c', '#src/mesa/program/symbol_table.c', Copy('$TARGET', '$SOURCE')) - - compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_SOURCES']) - - mesa_objs = env.StaticObject([ - 'hash_table.c', - 'symbol_table.c', - ]) - - compiler_objs += mesa_objs - - builtin_compiler = env.Program( - target = 'builtin_compiler', - source = compiler_objs + glsl_sources + \ - source_lists['BUILTIN_COMPILER_CXX_SOURCES'], - ) - - # SCons builtin dependency scanner doesn't detect that glsl_lexer.ll - # depends on glsl_parser.h - env.Depends(builtin_compiler, glsl_parser) - - builtin_glsl_function = env.CodeGenerate( - target = 'builtin_function.cpp', - script = 'builtins/tools/generate_builtins.py', - source = builtin_compiler, - command = python_cmd + ' $SCRIPT $SOURCE > $TARGET' - ) - - env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*')) - - Export('builtin_glsl_function') - - if env['hostonly']: - Return() - - -glsl_sources += builtin_glsl_function - -glsl = env.ConvenienceLibrary( - target = 'glsl', - source = glsl_sources, -) - -# SCons builtin dependency scanner doesn't detect that glsl_lexer.ll depends on -# glsl_parser.h -env.Depends(glsl, glsl_parser) - -Export('glsl') - -# Skip building these programs as they will cause SCons error "Two environments -# with different actions were specified for the same target" -if env['crosscompile'] or env['embedded']: - Return() - -env = env.Clone() - -if env['platform'] == 'windows': - env.PrependUnique(LIBS = [ - 'user32', - ]) - -env.Prepend(LIBS = [glsl]) - -glsl2 = env.Program( - target = 'glsl2', - source = compiler_objs, -) -env.Alias('glsl2', glsl2) - -glcpp = env.Program( - target = 'glcpp/glcpp', - source = ['glcpp/glcpp.c'] + mesa_objs, -) -env.Alias('glcpp', glcpp) diff --git a/reactos/dll/opengl/mesa/src/glsl/TODO b/reactos/dll/opengl/mesa/src/glsl/TODO deleted file mode 100644 index c99d7e152d6..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/TODO +++ /dev/null @@ -1,27 +0,0 @@ -- Detect code paths in non-void functions that don't reach a return statement - -- Improve handling of constants and their initializers. Constant initializers - should never generate any code. This is trival for scalar constants. It is - also trivial for arrays, matrices, and vectors that are accessed with - constant index values. For others it is more complicated. Perhaps these - cases should be silently converted to uniforms? - -- Implement support for ir_binop_dot in ir_algebraic.cpp. Perform - transformations such as "dot(v, vec3(0.0, 1.0, 0.0))" -> v.y. - -- Track source locations throughout the IR. There are currently several - places where we cannot emit line numbers for errors (and currently emit 0:0) - because we've "lost" the line number information. This is particularly - noticeable at link time. - -1.30 features: - -- Implement AST-to-HIR conversion of switch-statements - - switch - - case - - Update break to correcly handle mixed nexting of switch-statements - and loops. - -- Implement support for gl_ClipDistance. This is non-trivial because - gl_ClipDistance is exposed as a float[8], but all hardware actually - implements it as vec4[2]. \ No newline at end of file diff --git a/reactos/dll/opengl/mesa/src/glsl/ast.h b/reactos/dll/opengl/mesa/src/glsl/ast.h deleted file mode 100644 index a01aac07376..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ast.h +++ /dev/null @@ -1,804 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef AST_H -#define AST_H - -#include "list.h" -#include "glsl_parser_extras.h" - -struct _mesa_glsl_parse_state; - -struct YYLTYPE; - -/** - * \defgroup AST Abstract syntax tree node definitions - * - * An abstract syntax tree is generated by the parser. This is a fairly - * direct representation of the gramma derivation for the source program. - * No symantic checking is done during the generation of the AST. Only - * syntactic checking is done. Symantic checking is performed by a later - * stage that converts the AST to a more generic intermediate representation. - * - *@{ - */ -/** - * Base class of all abstract syntax tree nodes - */ -class ast_node { -public: - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = rzalloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *table) - { - ralloc_free(table); - } - - /** - * Print an AST node in something approximating the original GLSL code - */ - virtual void print(void) const; - - /** - * Convert the AST node to the high-level intermediate representation - */ - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - /** - * Retrieve the source location of an AST node - * - * This function is primarily used to get the source position of an AST node - * into a form that can be passed to \c _mesa_glsl_error. - * - * \sa _mesa_glsl_error, ast_node::set_location - */ - struct YYLTYPE get_location(void) const - { - struct YYLTYPE locp; - - locp.source = this->location.source; - locp.first_line = this->location.line; - locp.first_column = this->location.column; - locp.last_line = locp.first_line; - locp.last_column = locp.first_column; - - return locp; - } - - /** - * Set the source location of an AST node from a parser location - * - * \sa ast_node::get_location - */ - void set_location(const struct YYLTYPE &locp) - { - this->location.source = locp.source; - this->location.line = locp.first_line; - this->location.column = locp.first_column; - } - - /** - * Source location of the AST node. - */ - struct { - unsigned source; /**< GLSL source number. */ - unsigned line; /**< Line number within the source string. */ - unsigned column; /**< Column in the line. */ - } location; - - exec_node link; - -protected: - /** - * The only constructor is protected so that only derived class objects can - * be created. - */ - ast_node(void); -}; - - -/** - * Operators for AST expression nodes. - */ -enum ast_operators { - ast_assign, - ast_plus, /**< Unary + operator. */ - ast_neg, - ast_add, - ast_sub, - ast_mul, - ast_div, - ast_mod, - ast_lshift, - ast_rshift, - ast_less, - ast_greater, - ast_lequal, - ast_gequal, - ast_equal, - ast_nequal, - ast_bit_and, - ast_bit_xor, - ast_bit_or, - ast_bit_not, - ast_logic_and, - ast_logic_xor, - ast_logic_or, - ast_logic_not, - - ast_mul_assign, - ast_div_assign, - ast_mod_assign, - ast_add_assign, - ast_sub_assign, - ast_ls_assign, - ast_rs_assign, - ast_and_assign, - ast_xor_assign, - ast_or_assign, - - ast_conditional, - - ast_pre_inc, - ast_pre_dec, - ast_post_inc, - ast_post_dec, - ast_field_selection, - ast_array_index, - - ast_function_call, - - ast_identifier, - ast_int_constant, - ast_uint_constant, - ast_float_constant, - ast_bool_constant, - - ast_sequence -}; - -/** - * Representation of any sort of expression. - */ -class ast_expression : public ast_node { -public: - ast_expression(int oper, ast_expression *, - ast_expression *, ast_expression *); - - ast_expression(const char *identifier) : - oper(ast_identifier) - { - subexpressions[0] = NULL; - subexpressions[1] = NULL; - subexpressions[2] = NULL; - primary_expression.identifier = (char *) identifier; - this->non_lvalue_description = NULL; - } - - static const char *operator_string(enum ast_operators op); - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - virtual void print(void) const; - - enum ast_operators oper; - - ast_expression *subexpressions[3]; - - union { - char *identifier; - int int_constant; - float float_constant; - unsigned uint_constant; - int bool_constant; - } primary_expression; - - - /** - * List of expressions for an \c ast_sequence or parameters for an - * \c ast_function_call - */ - exec_list expressions; - - /** - * For things that can't be l-values, this describes what it is. - * - * This text is used by the code that generates IR for assignments to - * detect and emit useful messages for assignments to some things that - * can't be l-values. For example, pre- or post-incerement expressions. - * - * \note - * This pointer may be \c NULL. - */ - const char *non_lvalue_description; -}; - -class ast_expression_bin : public ast_expression { -public: - ast_expression_bin(int oper, ast_expression *, ast_expression *); - - virtual void print(void) const; -}; - -/** - * Subclass of expressions for function calls - */ -class ast_function_expression : public ast_expression { -public: - ast_function_expression(ast_expression *callee) - : ast_expression(ast_function_call, callee, - NULL, NULL), - cons(false) - { - /* empty */ - } - - ast_function_expression(class ast_type_specifier *type) - : ast_expression(ast_function_call, (ast_expression *) type, - NULL, NULL), - cons(true) - { - /* empty */ - } - - bool is_constructor() const - { - return cons; - } - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -private: - /** - * Is this function call actually a constructor? - */ - bool cons; -}; - - -/** - * Number of possible operators for an ast_expression - * - * This is done as a define instead of as an additional value in the enum so - * that the compiler won't generate spurious messages like "warning: - * enumeration value ‘ast_num_operators’ not handled in switch" - */ -#define AST_NUM_OPERATORS (ast_sequence + 1) - - -class ast_compound_statement : public ast_node { -public: - ast_compound_statement(int new_scope, ast_node *statements); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - int new_scope; - exec_list statements; -}; - -class ast_declaration : public ast_node { -public: - ast_declaration(char *identifier, int is_array, ast_expression *array_size, - ast_expression *initializer); - virtual void print(void) const; - - char *identifier; - - int is_array; - ast_expression *array_size; - - ast_expression *initializer; -}; - - -enum { - ast_precision_none = 0, /**< Absence of precision qualifier. */ - ast_precision_high, - ast_precision_medium, - ast_precision_low -}; - -struct ast_type_qualifier { - union { - struct { - unsigned invariant:1; - unsigned constant:1; - unsigned attribute:1; - unsigned varying:1; - unsigned in:1; - unsigned out:1; - unsigned centroid:1; - unsigned uniform:1; - unsigned smooth:1; - unsigned flat:1; - unsigned noperspective:1; - - /** \name Layout qualifiers for GL_AMD_conservative_depth */ - /** \{ */ - unsigned depth_any:1; - unsigned depth_greater:1; - unsigned depth_less:1; - unsigned depth_unchanged:1; - /** \} */ - } - /** \brief Set of flags, accessed by name. */ - q; - - /** \brief Set of flags, accessed as a bitmask. */ - unsigned i; - } flags; - - /** - * Return true if and only if an interpolation qualifier is present. - */ - bool has_interpolation() const; - - /** - * \brief Return string representation of interpolation qualifier. - * - * If an interpolation qualifier is present, then return that qualifier's - * string representation. Otherwise, return null. For example, if the - * noperspective bit is set, then this returns "noperspective". - * - * If multiple interpolation qualifiers are somehow present, then the - * returned string is undefined but not null. - */ - const char *interpolation_string() const; -}; - -class ast_struct_specifier : public ast_node { -public: - ast_struct_specifier(char *identifier, ast_node *declarator_list); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - char *name; - exec_list declarations; -}; - - -enum ast_types { - ast_void, - ast_float, - ast_int, - ast_uint, - ast_bool, - ast_vec2, - ast_vec3, - ast_vec4, - ast_bvec2, - ast_bvec3, - ast_bvec4, - ast_ivec2, - ast_ivec3, - ast_ivec4, - ast_uvec2, - ast_uvec3, - ast_uvec4, - ast_mat2, - ast_mat2x3, - ast_mat2x4, - ast_mat3x2, - ast_mat3, - ast_mat3x4, - ast_mat4x2, - ast_mat4x3, - ast_mat4, - ast_sampler1d, - ast_sampler2d, - ast_sampler2drect, - ast_sampler3d, - ast_samplercube, - ast_samplerexternaloes, - ast_sampler1dshadow, - ast_sampler2dshadow, - ast_sampler2drectshadow, - ast_samplercubeshadow, - ast_sampler1darray, - ast_sampler2darray, - ast_sampler1darrayshadow, - ast_sampler2darrayshadow, - ast_isampler1d, - ast_isampler2d, - ast_isampler3d, - ast_isamplercube, - ast_isampler1darray, - ast_isampler2darray, - ast_usampler1d, - ast_usampler2d, - ast_usampler3d, - ast_usamplercube, - ast_usampler1darray, - ast_usampler2darray, - - ast_struct, - ast_type_name -}; - - -class ast_type_specifier : public ast_node { -public: - ast_type_specifier(int specifier); - - /** Construct a type specifier from a type name */ - ast_type_specifier(const char *name) - : type_specifier(ast_type_name), type_name(name), structure(NULL), - is_array(false), array_size(NULL), precision(ast_precision_none), - is_precision_statement(false) - { - /* empty */ - } - - /** Construct a type specifier from a structure definition */ - ast_type_specifier(ast_struct_specifier *s) - : type_specifier(ast_struct), type_name(s->name), structure(s), - is_array(false), array_size(NULL), precision(ast_precision_none), - is_precision_statement(false) - { - /* empty */ - } - - const struct glsl_type *glsl_type(const char **name, - struct _mesa_glsl_parse_state *state) - const; - - virtual void print(void) const; - - ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); - - enum ast_types type_specifier; - - const char *type_name; - ast_struct_specifier *structure; - - int is_array; - ast_expression *array_size; - - unsigned precision:2; - - bool is_precision_statement; -}; - - -class ast_fully_specified_type : public ast_node { -public: - virtual void print(void) const; - bool has_qualifiers() const; - - ast_type_qualifier qualifier; - ast_type_specifier *specifier; -}; - - -class ast_declarator_list : public ast_node { -public: - ast_declarator_list(ast_fully_specified_type *); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_fully_specified_type *type; - exec_list declarations; - - /** - * Special flag for vertex shader "invariant" declarations. - * - * Vertex shaders can contain "invariant" variable redeclarations that do - * not include a type. For example, "invariant gl_Position;". This flag - * is used to note these cases when no type is specified. - */ - int invariant; -}; - - -class ast_parameter_declarator : public ast_node { -public: - ast_parameter_declarator() - { - this->identifier = NULL; - this->is_array = false; - this->array_size = 0; - } - - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_fully_specified_type *type; - char *identifier; - int is_array; - ast_expression *array_size; - - static void parameters_to_hir(exec_list *ast_parameters, - bool formal, exec_list *ir_parameters, - struct _mesa_glsl_parse_state *state); - -private: - /** Is this parameter declaration part of a formal parameter list? */ - bool formal_parameter; - - /** - * Is this parameter 'void' type? - * - * This field is set by \c ::hir. - */ - bool is_void; -}; - - -class ast_function : public ast_node { -public: - ast_function(void); - - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_fully_specified_type *return_type; - char *identifier; - - exec_list parameters; - -private: - /** - * Is this prototype part of the function definition? - * - * Used by ast_function_definition::hir to process the parameters, etc. - * of the function. - * - * \sa ::hir - */ - bool is_definition; - - /** - * Function signature corresponding to this function prototype instance - * - * Used by ast_function_definition::hir to process the parameters, etc. - * of the function. - * - * \sa ::hir - */ - class ir_function_signature *signature; - - friend class ast_function_definition; -}; - - -class ast_expression_statement : public ast_node { -public: - ast_expression_statement(ast_expression *); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_expression *expression; -}; - - -class ast_case_label : public ast_node { -public: - ast_case_label(ast_expression *test_value); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - /** - * An test value of NULL means 'default'. - */ - ast_expression *test_value; -}; - - -class ast_case_label_list : public ast_node { -public: - ast_case_label_list(void); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - /** - * A list of case labels. - */ - exec_list labels; -}; - - -class ast_case_statement : public ast_node { -public: - ast_case_statement(ast_case_label_list *labels); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_case_label_list *labels; - - /** - * A list of statements. - */ - exec_list stmts; -}; - - -class ast_case_statement_list : public ast_node { -public: - ast_case_statement_list(void); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - /** - * A list of cases. - */ - exec_list cases; -}; - - -class ast_switch_body : public ast_node { -public: - ast_switch_body(ast_case_statement_list *stmts); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_case_statement_list *stmts; -}; - - -class ast_selection_statement : public ast_node { -public: - ast_selection_statement(ast_expression *condition, - ast_node *then_statement, - ast_node *else_statement); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_expression *condition; - ast_node *then_statement; - ast_node *else_statement; -}; - - -class ast_switch_statement : public ast_node { -public: - ast_switch_statement(ast_expression *test_expression, - ast_node *body); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_expression *test_expression; - ast_node *body; - -protected: - void test_to_hir(exec_list *, struct _mesa_glsl_parse_state *); -}; - -class ast_iteration_statement : public ast_node { -public: - ast_iteration_statement(int mode, ast_node *init, ast_node *condition, - ast_expression *rest_expression, ast_node *body); - - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *); - - enum ast_iteration_modes { - ast_for, - ast_while, - ast_do_while - } mode; - - - ast_node *init_statement; - ast_node *condition; - ast_expression *rest_expression; - - ast_node *body; - -private: - /** - * Generate IR from the condition of a loop - * - * This is factored out of ::hir because some loops have the condition - * test at the top (for and while), and others have it at the end (do-while). - */ - void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *); -}; - - -class ast_jump_statement : public ast_node { -public: - ast_jump_statement(int mode, ast_expression *return_value); - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - enum ast_jump_modes { - ast_continue, - ast_break, - ast_return, - ast_discard - } mode; - - ast_expression *opt_return_value; -}; - - -class ast_function_definition : public ast_node { -public: - virtual void print(void) const; - - virtual ir_rvalue *hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - - ast_function *prototype; - ast_compound_statement *body; -}; -/*@}*/ - -extern void -_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state); - -extern ir_rvalue * -_mesa_ast_field_selection_to_hir(const ast_expression *expr, - exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -void -emit_function(_mesa_glsl_parse_state *state, ir_function *f); - -#endif /* AST_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/ast_expr.cpp b/reactos/dll/opengl/mesa/src/glsl/ast_expr.cpp deleted file mode 100644 index e624d11cf3b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ast_expr.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include "ast.h" - -const char * -ast_expression::operator_string(enum ast_operators op) -{ - static const char *const operators[] = { - "=", - "+", - "-", - "+", - "-", - "*", - "/", - "%", - "<<", - ">>", - "<", - ">", - "<=", - ">=", - "==", - "!=", - "&", - "^", - "|", - "~", - "&&", - "^^", - "||", - "!", - - "*=", - "/=", - "%=", - "+=", - "-=", - "<<=", - ">>=", - "&=", - "^=", - "|=", - - "?:", - - "++", - "--", - "++", - "--", - ".", - }; - - assert((unsigned int)op < sizeof(operators) / sizeof(operators[0])); - - return operators[op]; -} - - -ast_expression_bin::ast_expression_bin(int oper, ast_expression *ex0, - ast_expression *ex1) : - ast_expression(oper, ex0, ex1, NULL) -{ - assert((oper >= ast_plus) && (oper <= ast_logic_not)); -} - - -void -ast_expression_bin::print(void) const -{ - subexpressions[0]->print(); - printf("%s ", operator_string(oper)); - subexpressions[1]->print(); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ast_function.cpp b/reactos/dll/opengl/mesa/src/glsl/ast_function.cpp deleted file mode 100644 index a7961102cdf..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ast_function.cpp +++ /dev/null @@ -1,1506 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "glsl_symbol_table.h" -#include "ast.h" -#include "glsl_types.h" -#include "ir.h" -#include "main/core.h" /* for MIN2 */ - -static ir_rvalue * -convert_component(ir_rvalue *src, const glsl_type *desired_type); - -bool -apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, - struct _mesa_glsl_parse_state *state); - -static unsigned -process_parameters(exec_list *instructions, exec_list *actual_parameters, - exec_list *parameters, - struct _mesa_glsl_parse_state *state) -{ - unsigned count = 0; - - foreach_list (n, parameters) { - ast_node *const ast = exec_node_data(ast_node, n, link); - ir_rvalue *result = ast->hir(instructions, state); - - ir_constant *const constant = result->constant_expression_value(); - if (constant != NULL) - result = constant; - - actual_parameters->push_tail(result); - count++; - } - - return count; -} - - -/** - * Generate a source prototype for a function signature - * - * \param return_type Return type of the function. May be \c NULL. - * \param name Name of the function. - * \param parameters List of \c ir_instruction nodes representing the - * parameter list for the function. This may be either a - * formal (\c ir_variable) or actual (\c ir_rvalue) - * parameter list. Only the type is used. - * - * \return - * A ralloced string representing the prototype of the function. - */ -char * -prototype_string(const glsl_type *return_type, const char *name, - exec_list *parameters) -{ - char *str = NULL; - - if (return_type != NULL) - str = ralloc_asprintf(NULL, "%s ", return_type->name); - - ralloc_asprintf_append(&str, "%s(", name); - - const char *comma = ""; - foreach_list(node, parameters) { - const ir_instruction *const param = (ir_instruction *) node; - - ralloc_asprintf_append(&str, "%s%s", comma, param->type->name); - comma = ", "; - } - - ralloc_strcat(&str, ")"); - return str; -} - -/** - * If a function call is generated, \c call_ir will point to it on exit. - * Otherwise \c call_ir will be set to \c NULL. - */ -static ir_rvalue * -generate_call(exec_list *instructions, ir_function_signature *sig, - YYLTYPE *loc, exec_list *actual_parameters, - ir_call **call_ir, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - exec_list post_call_conversions; - - *call_ir = NULL; - - /* Verify that 'out' and 'inout' actual parameters are lvalues. This - * isn't done in ir_function::matching_signature because that function - * cannot generate the necessary diagnostics. - * - * Also, validate that 'const_in' formal parameters (an extension of our - * IR) correspond to ir_constant actual parameters. - * - * Also, perform implicit conversion of arguments. Note: to implicitly - * convert out parameters, we need to place them in a temporary - * variable, and do the conversion after the call takes place. Since we - * haven't emitted the call yet, we'll place the post-call conversions - * in a temporary exec_list, and emit them later. - */ - exec_list_iterator actual_iter = actual_parameters->iterator(); - exec_list_iterator formal_iter = sig->parameters.iterator(); - - while (actual_iter.has_next()) { - ir_rvalue *actual = (ir_rvalue *) actual_iter.get(); - ir_variable *formal = (ir_variable *) formal_iter.get(); - - assert(actual != NULL); - assert(formal != NULL); - - if (formal->mode == ir_var_const_in && !actual->as_constant()) { - _mesa_glsl_error(loc, state, - "parameter `%s' must be a constant expression", - formal->name); - return ir_call::get_error_instruction(ctx); - } - - if ((formal->mode == ir_var_out) - || (formal->mode == ir_var_inout)) { - const char *mode = NULL; - switch (formal->mode) { - case ir_var_out: mode = "out"; break; - case ir_var_inout: mode = "inout"; break; - default: assert(false); break; - } - /* FIXME: 'loc' is incorrect (as of 2011-01-21). It is always - * FIXME: 0:0(0). - */ - if (actual->variable_referenced() - && actual->variable_referenced()->read_only) { - _mesa_glsl_error(loc, state, - "function parameter '%s %s' references the " - "read-only variable '%s'", - mode, formal->name, - actual->variable_referenced()->name); - - } else if (!actual->is_lvalue()) { - _mesa_glsl_error(loc, state, - "function parameter '%s %s' is not an lvalue", - mode, formal->name); - } - } - - if (formal->type->is_numeric() || formal->type->is_boolean()) { - switch (formal->mode) { - case ir_var_const_in: - case ir_var_in: { - ir_rvalue *converted - = convert_component(actual, formal->type); - actual->replace_with(converted); - break; - } - case ir_var_out: - if (actual->type != formal->type) { - /* To convert an out parameter, we need to create a - * temporary variable to hold the value before conversion, - * and then perform the conversion after the function call - * returns. - * - * This has the effect of transforming code like this: - * - * void f(out int x); - * float value; - * f(value); - * - * Into IR that's equivalent to this: - * - * void f(out int x); - * float value; - * int out_parameter_conversion; - * f(out_parameter_conversion); - * value = float(out_parameter_conversion); - */ - ir_variable *tmp = - new(ctx) ir_variable(formal->type, - "out_parameter_conversion", - ir_var_temporary); - instructions->push_tail(tmp); - ir_dereference_variable *deref_tmp_1 - = new(ctx) ir_dereference_variable(tmp); - ir_dereference_variable *deref_tmp_2 - = new(ctx) ir_dereference_variable(tmp); - ir_rvalue *converted_tmp - = convert_component(deref_tmp_1, actual->type); - ir_assignment *assignment - = new(ctx) ir_assignment(actual, converted_tmp); - post_call_conversions.push_tail(assignment); - actual->replace_with(deref_tmp_2); - } - break; - case ir_var_inout: - /* Inout parameters should never require conversion, since that - * would require an implicit conversion to exist both to and - * from the formal parameter type, and there are no - * bidirectional implicit conversions. - */ - assert (actual->type == formal->type); - break; - default: - assert (!"Illegal formal parameter mode"); - break; - } - } - - actual_iter.next(); - formal_iter.next(); - } - - /* Always insert the call in the instruction stream, and return a deref - * of its return val if it returns a value, since we don't know if - * the rvalue is going to be assigned to anything or not. - * - * Also insert any out parameter conversions after the call. - */ - ir_call *call = new(ctx) ir_call(sig, actual_parameters); - ir_dereference_variable *deref; - if (!sig->return_type->is_void()) { - /* If the function call is a constant expression, don't - * generate the instructions to call it; just generate an - * ir_constant representing the constant value. - * - * Function calls can only be constant expressions starting - * in GLSL 1.20. - */ - if (state->language_version >= 120) { - ir_constant *const_val = call->constant_expression_value(); - if (const_val) { - return const_val; - } - } - - ir_variable *var; - - var = new(ctx) ir_variable(sig->return_type, - ralloc_asprintf(ctx, "%s_retval", - sig->function_name()), - ir_var_temporary); - instructions->push_tail(var); - - deref = new(ctx) ir_dereference_variable(var); - ir_assignment *assign = new(ctx) ir_assignment(deref, call, NULL); - instructions->push_tail(assign); - *call_ir = call; - - deref = new(ctx) ir_dereference_variable(var); - } else { - instructions->push_tail(call); - *call_ir = call; - deref = NULL; - } - instructions->append_list(&post_call_conversions); - return deref; -} - -static ir_rvalue * -match_function_by_name(exec_list *instructions, const char *name, - YYLTYPE *loc, exec_list *actual_parameters, - ir_call **call_ir, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - ir_function *f = state->symbols->get_function(name); - ir_function_signature *local_sig = NULL; - ir_function_signature *sig = NULL; - - /* Is the function hidden by a record type constructor? */ - if (state->symbols->get_type(name)) - goto done; /* no match */ - - /* Is the function hidden by a variable (impossible in 1.10)? */ - if (state->language_version != 110 && state->symbols->get_variable(name)) - goto done; /* no match */ - - if (f != NULL) { - /* Look for a match in the local shader. If exact, we're done. */ - bool is_exact = false; - sig = local_sig = f->matching_signature(actual_parameters, &is_exact); - if (is_exact) - goto done; - - if (f->has_user_signature()) { - /* In desktop GL, the presence of a user-defined signature hides any - * built-in signatures, so we must ignore them. In contrast, in ES2 - * user-defined signatures add new overloads, so we must proceed. - */ - goto done; - } - } - - /* Local shader has no exact candidates; check the built-ins. */ - _mesa_glsl_initialize_functions(state); - for (unsigned i = 0; i < state->num_builtins_to_link; i++) { - ir_function *builtin = - state->builtins_to_link[i]->symbols->get_function(name); - if (builtin == NULL) - continue; - - bool is_exact = false; - ir_function_signature *builtin_sig = - builtin->matching_signature(actual_parameters, &is_exact); - - if (builtin_sig == NULL) - continue; - - /* If the built-in signature is exact, we can stop. */ - if (is_exact) { - sig = builtin_sig; - goto done; - } - - if (sig == NULL) { - /* We found an inexact match, which is better than nothing. However, - * we should keep searching for an exact match. - */ - sig = builtin_sig; - } - } - -done: - if (sig != NULL) { - /* If the match is from a linked built-in shader, import the prototype. */ - if (sig != local_sig) { - if (f == NULL) { - f = new(ctx) ir_function(name); - state->symbols->add_global_function(f); - emit_function(state, f); - } - f->add_signature(sig->clone_prototype(f, NULL)); - } - - /* Finally, generate a call instruction. */ - return generate_call(instructions, sig, loc, actual_parameters, - call_ir, state); - } else { - char *str = prototype_string(NULL, name, actual_parameters); - - _mesa_glsl_error(loc, state, "no matching function for call to `%s'", - str); - ralloc_free(str); - - const char *prefix = "candidates are: "; - - for (int i = -1; i < (int) state->num_builtins_to_link; i++) { - glsl_symbol_table *syms = i >= 0 ? state->builtins_to_link[i]->symbols - : state->symbols; - f = syms->get_function(name); - if (f == NULL) - continue; - - foreach_list (node, &f->signatures) { - ir_function_signature *sig = (ir_function_signature *) node; - - str = prototype_string(sig->return_type, f->name, &sig->parameters); - _mesa_glsl_error(loc, state, "%s%s", prefix, str); - ralloc_free(str); - - prefix = " "; - } - - } - - return ir_call::get_error_instruction(ctx); - } -} - - -/** - * Perform automatic type conversion of constructor parameters - * - * This implements the rules in the "Conversion and Scalar Constructors" - * section (GLSL 1.10 section 5.4.1), not the "Implicit Conversions" rules. - */ -static ir_rvalue * -convert_component(ir_rvalue *src, const glsl_type *desired_type) -{ - void *ctx = ralloc_parent(src); - const unsigned a = desired_type->base_type; - const unsigned b = src->type->base_type; - ir_expression *result = NULL; - - if (src->type->is_error()) - return src; - - assert(a <= GLSL_TYPE_BOOL); - assert(b <= GLSL_TYPE_BOOL); - - if (a == b) - return src; - - switch (a) { - case GLSL_TYPE_UINT: - switch (b) { - case GLSL_TYPE_INT: - result = new(ctx) ir_expression(ir_unop_i2u, src); - break; - case GLSL_TYPE_FLOAT: - result = new(ctx) ir_expression(ir_unop_i2u, - new(ctx) ir_expression(ir_unop_f2i, src)); - break; - case GLSL_TYPE_BOOL: - result = new(ctx) ir_expression(ir_unop_i2u, - new(ctx) ir_expression(ir_unop_b2i, src)); - break; - } - break; - case GLSL_TYPE_INT: - switch (b) { - case GLSL_TYPE_UINT: - result = new(ctx) ir_expression(ir_unop_u2i, src); - break; - case GLSL_TYPE_FLOAT: - result = new(ctx) ir_expression(ir_unop_f2i, src); - break; - case GLSL_TYPE_BOOL: - result = new(ctx) ir_expression(ir_unop_b2i, src); - break; - } - break; - case GLSL_TYPE_FLOAT: - switch (b) { - case GLSL_TYPE_UINT: - result = new(ctx) ir_expression(ir_unop_u2f, desired_type, src, NULL); - break; - case GLSL_TYPE_INT: - result = new(ctx) ir_expression(ir_unop_i2f, desired_type, src, NULL); - break; - case GLSL_TYPE_BOOL: - result = new(ctx) ir_expression(ir_unop_b2f, desired_type, src, NULL); - break; - } - break; - case GLSL_TYPE_BOOL: - switch (b) { - case GLSL_TYPE_UINT: - result = new(ctx) ir_expression(ir_unop_i2b, - new(ctx) ir_expression(ir_unop_u2i, src)); - break; - case GLSL_TYPE_INT: - result = new(ctx) ir_expression(ir_unop_i2b, desired_type, src, NULL); - break; - case GLSL_TYPE_FLOAT: - result = new(ctx) ir_expression(ir_unop_f2b, desired_type, src, NULL); - break; - } - break; - } - - assert(result != NULL); - assert(result->type == desired_type); - - /* Try constant folding; it may fold in the conversion we just added. */ - ir_constant *const constant = result->constant_expression_value(); - return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result; -} - -/** - * Dereference a specific component from a scalar, vector, or matrix - */ -static ir_rvalue * -dereference_component(ir_rvalue *src, unsigned component) -{ - void *ctx = ralloc_parent(src); - assert(component < src->type->components()); - - /* If the source is a constant, just create a new constant instead of a - * dereference of the existing constant. - */ - ir_constant *constant = src->as_constant(); - if (constant) - return new(ctx) ir_constant(constant, component); - - if (src->type->is_scalar()) { - return src; - } else if (src->type->is_vector()) { - return new(ctx) ir_swizzle(src, component, 0, 0, 0, 1); - } else { - assert(src->type->is_matrix()); - - /* Dereference a row of the matrix, then call this function again to get - * a specific element from that row. - */ - const int c = component / src->type->column_type()->vector_elements; - const int r = component % src->type->column_type()->vector_elements; - ir_constant *const col_index = new(ctx) ir_constant(c); - ir_dereference *const col = new(ctx) ir_dereference_array(src, col_index); - - col->type = src->type->column_type(); - - return dereference_component(col, r); - } - - assert(!"Should not get here."); - return NULL; -} - - -static ir_rvalue * -process_array_constructor(exec_list *instructions, - const glsl_type *constructor_type, - YYLTYPE *loc, exec_list *parameters, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - /* Array constructors come in two forms: sized and unsized. Sized array - * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4 - * variables. In this case the number of parameters must exactly match the - * specified size of the array. - * - * Unsized array constructors look like 'vec4[](a, b)', where 'a' and 'b' - * are vec4 variables. In this case the size of the array being constructed - * is determined by the number of parameters. - * - * From page 52 (page 58 of the PDF) of the GLSL 1.50 spec: - * - * "There must be exactly the same number of arguments as the size of - * the array being constructed. If no size is present in the - * constructor, then the array is explicitly sized to the number of - * arguments provided. The arguments are assigned in order, starting at - * element 0, to the elements of the constructed array. Each argument - * must be the same type as the element type of the array, or be a type - * that can be converted to the element type of the array according to - * Section 4.1.10 "Implicit Conversions."" - */ - exec_list actual_parameters; - const unsigned parameter_count = - process_parameters(instructions, &actual_parameters, parameters, state); - - if ((parameter_count == 0) - || ((constructor_type->length != 0) - && (constructor_type->length != parameter_count))) { - const unsigned min_param = (constructor_type->length == 0) - ? 1 : constructor_type->length; - - _mesa_glsl_error(loc, state, "array constructor must have %s %u " - "parameter%s", - (constructor_type->length != 0) ? "at least" : "exactly", - min_param, (min_param <= 1) ? "" : "s"); - return ir_call::get_error_instruction(ctx); - } - - if (constructor_type->length == 0) { - constructor_type = - glsl_type::get_array_instance(constructor_type->element_type(), - parameter_count); - assert(constructor_type != NULL); - assert(constructor_type->length == parameter_count); - } - - bool all_parameters_are_constant = true; - - /* Type cast each parameter and, if possible, fold constants. */ - foreach_list_safe(n, &actual_parameters) { - ir_rvalue *ir = (ir_rvalue *) n; - ir_rvalue *result = ir; - - /* Apply implicit conversions (not the scalar constructor rules!). See - * the spec quote above. */ - if (constructor_type->element_type()->is_float()) { - const glsl_type *desired_type = - glsl_type::get_instance(GLSL_TYPE_FLOAT, - ir->type->vector_elements, - ir->type->matrix_columns); - if (result->type->can_implicitly_convert_to(desired_type)) { - /* Even though convert_component() implements the constructor - * conversion rules (not the implicit conversion rules), its safe - * to use it here because we already checked that the implicit - * conversion is legal. - */ - result = convert_component(ir, desired_type); - } - } - - if (result->type != constructor_type->element_type()) { - _mesa_glsl_error(loc, state, "type error in array constructor: " - "expected: %s, found %s", - constructor_type->element_type()->name, - result->type->name); - } - - /* Attempt to convert the parameter to a constant valued expression. - * After doing so, track whether or not all the parameters to the - * constructor are trivially constant valued expressions. - */ - ir_rvalue *const constant = result->constant_expression_value(); - - if (constant != NULL) - result = constant; - else - all_parameters_are_constant = false; - - ir->replace_with(result); - } - - if (all_parameters_are_constant) - return new(ctx) ir_constant(constructor_type, &actual_parameters); - - ir_variable *var = new(ctx) ir_variable(constructor_type, "array_ctor", - ir_var_temporary); - instructions->push_tail(var); - - int i = 0; - foreach_list(node, &actual_parameters) { - ir_rvalue *rhs = (ir_rvalue *) node; - ir_rvalue *lhs = new(ctx) ir_dereference_array(var, - new(ctx) ir_constant(i)); - - ir_instruction *assignment = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(assignment); - - i++; - } - - return new(ctx) ir_dereference_variable(var); -} - - -/** - * Try to convert a record constructor to a constant expression - */ -static ir_constant * -constant_record_constructor(const glsl_type *constructor_type, - exec_list *parameters, void *mem_ctx) -{ - foreach_list(node, parameters) { - ir_constant *constant = ((ir_instruction *) node)->as_constant(); - if (constant == NULL) - return NULL; - node->replace_with(constant); - } - - return new(mem_ctx) ir_constant(constructor_type, parameters); -} - - -/** - * Determine if a list consists of a single scalar r-value - */ -bool -single_scalar_parameter(exec_list *parameters) -{ - const ir_rvalue *const p = (ir_rvalue *) parameters->head; - assert(((ir_rvalue *)p)->as_rvalue() != NULL); - - return (p->type->is_scalar() && p->next->is_tail_sentinel()); -} - - -/** - * Generate inline code for a vector constructor - * - * The generated constructor code will consist of a temporary variable - * declaration of the same type as the constructor. A sequence of assignments - * from constructor parameters to the temporary will follow. - * - * \return - * An \c ir_dereference_variable of the temprorary generated in the constructor - * body. - */ -ir_rvalue * -emit_inline_vector_constructor(const glsl_type *type, - exec_list *instructions, - exec_list *parameters, - void *ctx) -{ - assert(!parameters->is_empty()); - - ir_variable *var = new(ctx) ir_variable(type, "vec_ctor", ir_var_temporary); - instructions->push_tail(var); - - /* There are two kinds of vector constructors. - * - * - Construct a vector from a single scalar by replicating that scalar to - * all components of the vector. - * - * - Construct a vector from an arbirary combination of vectors and - * scalars. The components of the constructor parameters are assigned - * to the vector in order until the vector is full. - */ - const unsigned lhs_components = type->components(); - if (single_scalar_parameter(parameters)) { - ir_rvalue *first_param = (ir_rvalue *)parameters->head; - ir_rvalue *rhs = new(ctx) ir_swizzle(first_param, 0, 0, 0, 0, - lhs_components); - ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(var); - const unsigned mask = (1U << lhs_components) - 1; - - assert(rhs->type == lhs->type); - - ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL, mask); - instructions->push_tail(inst); - } else { - unsigned base_component = 0; - unsigned base_lhs_component = 0; - ir_constant_data data; - unsigned constant_mask = 0, constant_components = 0; - - memset(&data, 0, sizeof(data)); - - foreach_list(node, parameters) { - ir_rvalue *param = (ir_rvalue *) node; - unsigned rhs_components = param->type->components(); - - /* Do not try to assign more components to the vector than it has! - */ - if ((rhs_components + base_lhs_component) > lhs_components) { - rhs_components = lhs_components - base_lhs_component; - } - - const ir_constant *const c = param->as_constant(); - if (c != NULL) { - for (unsigned i = 0; i < rhs_components; i++) { - switch (c->type->base_type) { - case GLSL_TYPE_UINT: - data.u[i + base_component] = c->get_uint_component(i); - break; - case GLSL_TYPE_INT: - data.i[i + base_component] = c->get_int_component(i); - break; - case GLSL_TYPE_FLOAT: - data.f[i + base_component] = c->get_float_component(i); - break; - case GLSL_TYPE_BOOL: - data.b[i + base_component] = c->get_bool_component(i); - break; - default: - assert(!"Should not get here."); - break; - } - } - - /* Mask of fields to be written in the assignment. - */ - constant_mask |= ((1U << rhs_components) - 1) << base_lhs_component; - constant_components += rhs_components; - - base_component += rhs_components; - } - /* Advance the component index by the number of components - * that were just assigned. - */ - base_lhs_component += rhs_components; - } - - if (constant_mask != 0) { - ir_dereference *lhs = new(ctx) ir_dereference_variable(var); - const glsl_type *rhs_type = glsl_type::get_instance(var->type->base_type, - constant_components, - 1); - ir_rvalue *rhs = new(ctx) ir_constant(rhs_type, &data); - - ir_instruction *inst = - new(ctx) ir_assignment(lhs, rhs, NULL, constant_mask); - instructions->push_tail(inst); - } - - base_component = 0; - foreach_list(node, parameters) { - ir_rvalue *param = (ir_rvalue *) node; - unsigned rhs_components = param->type->components(); - - /* Do not try to assign more components to the vector than it has! - */ - if ((rhs_components + base_component) > lhs_components) { - rhs_components = lhs_components - base_component; - } - - const ir_constant *const c = param->as_constant(); - if (c == NULL) { - /* Mask of fields to be written in the assignment. - */ - const unsigned write_mask = ((1U << rhs_components) - 1) - << base_component; - - ir_dereference *lhs = new(ctx) ir_dereference_variable(var); - - /* Generate a swizzle so that LHS and RHS sizes match. - */ - ir_rvalue *rhs = - new(ctx) ir_swizzle(param, 0, 1, 2, 3, rhs_components); - - ir_instruction *inst = - new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); - instructions->push_tail(inst); - } - - /* Advance the component index by the number of components that were - * just assigned. - */ - base_component += rhs_components; - } - } - return new(ctx) ir_dereference_variable(var); -} - - -/** - * Generate assignment of a portion of a vector to a portion of a matrix column - * - * \param src_base First component of the source to be used in assignment - * \param column Column of destination to be assiged - * \param row_base First component of the destination column to be assigned - * \param count Number of components to be assigned - * - * \note - * \c src_base + \c count must be less than or equal to the number of components - * in the source vector. - */ -ir_instruction * -assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base, - ir_rvalue *src, unsigned src_base, unsigned count, - void *mem_ctx) -{ - ir_constant *col_idx = new(mem_ctx) ir_constant(column); - ir_dereference *column_ref = new(mem_ctx) ir_dereference_array(var, col_idx); - - assert(column_ref->type->components() >= (row_base + count)); - assert(src->type->components() >= (src_base + count)); - - /* Generate a swizzle that extracts the number of components from the source - * that are to be assigned to the column of the matrix. - */ - if (count < src->type->vector_elements) { - src = new(mem_ctx) ir_swizzle(src, - src_base + 0, src_base + 1, - src_base + 2, src_base + 3, - count); - } - - /* Mask of fields to be written in the assignment. - */ - const unsigned write_mask = ((1U << count) - 1) << row_base; - - return new(mem_ctx) ir_assignment(column_ref, src, NULL, write_mask); -} - - -/** - * Generate inline code for a matrix constructor - * - * The generated constructor code will consist of a temporary variable - * declaration of the same type as the constructor. A sequence of assignments - * from constructor parameters to the temporary will follow. - * - * \return - * An \c ir_dereference_variable of the temprorary generated in the constructor - * body. - */ -ir_rvalue * -emit_inline_matrix_constructor(const glsl_type *type, - exec_list *instructions, - exec_list *parameters, - void *ctx) -{ - assert(!parameters->is_empty()); - - ir_variable *var = new(ctx) ir_variable(type, "mat_ctor", ir_var_temporary); - instructions->push_tail(var); - - /* There are three kinds of matrix constructors. - * - * - Construct a matrix from a single scalar by replicating that scalar to - * along the diagonal of the matrix and setting all other components to - * zero. - * - * - Construct a matrix from an arbirary combination of vectors and - * scalars. The components of the constructor parameters are assigned - * to the matrix in colum-major order until the matrix is full. - * - * - Construct a matrix from a single matrix. The source matrix is copied - * to the upper left portion of the constructed matrix, and the remaining - * elements take values from the identity matrix. - */ - ir_rvalue *const first_param = (ir_rvalue *) parameters->head; - if (single_scalar_parameter(parameters)) { - /* Assign the scalar to the X component of a vec4, and fill the remaining - * components with zero. - */ - ir_variable *rhs_var = - new(ctx) ir_variable(glsl_type::vec4_type, "mat_ctor_vec", - ir_var_temporary); - instructions->push_tail(rhs_var); - - ir_constant_data zero; - zero.f[0] = 0.0; - zero.f[1] = 0.0; - zero.f[2] = 0.0; - zero.f[3] = 0.0; - - ir_instruction *inst = - new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var), - new(ctx) ir_constant(rhs_var->type, &zero), - NULL); - instructions->push_tail(inst); - - ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); - - inst = new(ctx) ir_assignment(rhs_ref, first_param, NULL, 0x01); - instructions->push_tail(inst); - - /* Assign the temporary vector to each column of the destination matrix - * with a swizzle that puts the X component on the diagonal of the - * matrix. In some cases this may mean that the X component does not - * get assigned into the column at all (i.e., when the matrix has more - * columns than rows). - */ - static const unsigned rhs_swiz[4][4] = { - { 0, 1, 1, 1 }, - { 1, 0, 1, 1 }, - { 1, 1, 0, 1 }, - { 1, 1, 1, 0 } - }; - - const unsigned cols_to_init = MIN2(type->matrix_columns, - type->vector_elements); - for (unsigned i = 0; i < cols_to_init; i++) { - ir_constant *const col_idx = new(ctx) ir_constant(i); - ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); - - ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); - ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, rhs_swiz[i], - type->vector_elements); - - inst = new(ctx) ir_assignment(col_ref, rhs, NULL); - instructions->push_tail(inst); - } - - for (unsigned i = cols_to_init; i < type->matrix_columns; i++) { - ir_constant *const col_idx = new(ctx) ir_constant(i); - ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx); - - ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var); - ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, 1, 1, 1, 1, - type->vector_elements); - - inst = new(ctx) ir_assignment(col_ref, rhs, NULL); - instructions->push_tail(inst); - } - } else if (first_param->type->is_matrix()) { - /* From page 50 (56 of the PDF) of the GLSL 1.50 spec: - * - * "If a matrix is constructed from a matrix, then each component - * (column i, row j) in the result that has a corresponding - * component (column i, row j) in the argument will be initialized - * from there. All other components will be initialized to the - * identity matrix. If a matrix argument is given to a matrix - * constructor, it is an error to have any other arguments." - */ - assert(first_param->next->is_tail_sentinel()); - ir_rvalue *const src_matrix = first_param; - - /* If the source matrix is smaller, pre-initialize the relavent parts of - * the destination matrix to the identity matrix. - */ - if ((src_matrix->type->matrix_columns < var->type->matrix_columns) - || (src_matrix->type->vector_elements < var->type->vector_elements)) { - - /* If the source matrix has fewer rows, every column of the destination - * must be initialized. Otherwise only the columns in the destination - * that do not exist in the source must be initialized. - */ - unsigned col = - (src_matrix->type->vector_elements < var->type->vector_elements) - ? 0 : src_matrix->type->matrix_columns; - - const glsl_type *const col_type = var->type->column_type(); - for (/* empty */; col < var->type->matrix_columns; col++) { - ir_constant_data ident; - - ident.f[0] = 0.0; - ident.f[1] = 0.0; - ident.f[2] = 0.0; - ident.f[3] = 0.0; - - ident.f[col] = 1.0; - - ir_rvalue *const rhs = new(ctx) ir_constant(col_type, &ident); - - ir_rvalue *const lhs = - new(ctx) ir_dereference_array(var, new(ctx) ir_constant(col)); - - ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL); - instructions->push_tail(inst); - } - } - - /* Assign columns from the source matrix to the destination matrix. - * - * Since the parameter will be used in the RHS of multiple assignments, - * generate a temporary and copy the paramter there. - */ - ir_variable *const rhs_var = - new(ctx) ir_variable(first_param->type, "mat_ctor_mat", - ir_var_temporary); - instructions->push_tail(rhs_var); - - ir_dereference *const rhs_var_ref = - new(ctx) ir_dereference_variable(rhs_var); - ir_instruction *const inst = - new(ctx) ir_assignment(rhs_var_ref, first_param, NULL); - instructions->push_tail(inst); - - const unsigned last_row = MIN2(src_matrix->type->vector_elements, - var->type->vector_elements); - const unsigned last_col = MIN2(src_matrix->type->matrix_columns, - var->type->matrix_columns); - - unsigned swiz[4] = { 0, 0, 0, 0 }; - for (unsigned i = 1; i < last_row; i++) - swiz[i] = i; - - const unsigned write_mask = (1U << last_row) - 1; - - for (unsigned i = 0; i < last_col; i++) { - ir_dereference *const lhs = - new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i)); - ir_rvalue *const rhs_col = - new(ctx) ir_dereference_array(rhs_var, new(ctx) ir_constant(i)); - - /* If one matrix has columns that are smaller than the columns of the - * other matrix, wrap the column access of the larger with a swizzle - * so that the LHS and RHS of the assignment have the same size (and - * therefore have the same type). - * - * It would be perfectly valid to unconditionally generate the - * swizzles, this this will typically result in a more compact IR tree. - */ - ir_rvalue *rhs; - if (lhs->type->vector_elements != rhs_col->type->vector_elements) { - rhs = new(ctx) ir_swizzle(rhs_col, swiz, last_row); - } else { - rhs = rhs_col; - } - - ir_instruction *inst = - new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); - instructions->push_tail(inst); - } - } else { - const unsigned cols = type->matrix_columns; - const unsigned rows = type->vector_elements; - unsigned col_idx = 0; - unsigned row_idx = 0; - - foreach_list (node, parameters) { - ir_rvalue *const rhs = (ir_rvalue *) node; - const unsigned components_remaining_this_column = rows - row_idx; - unsigned rhs_components = rhs->type->components(); - unsigned rhs_base = 0; - - /* Since the parameter might be used in the RHS of two assignments, - * generate a temporary and copy the paramter there. - */ - ir_variable *rhs_var = - new(ctx) ir_variable(rhs->type, "mat_ctor_vec", ir_var_temporary); - instructions->push_tail(rhs_var); - - ir_dereference *rhs_var_ref = - new(ctx) ir_dereference_variable(rhs_var); - ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs, NULL); - instructions->push_tail(inst); - - /* Assign the current parameter to as many components of the matrix - * as it will fill. - * - * NOTE: A single vector parameter can span two matrix columns. A - * single vec4, for example, can completely fill a mat2. - */ - if (rhs_components >= components_remaining_this_column) { - const unsigned count = MIN2(rhs_components, - components_remaining_this_column); - - rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var); - - ir_instruction *inst = assign_to_matrix_column(var, col_idx, - row_idx, - rhs_var_ref, 0, - count, ctx); - instructions->push_tail(inst); - - rhs_base = count; - - col_idx++; - row_idx = 0; - } - - /* If there is data left in the parameter and components left to be - * set in the destination, emit another assignment. It is possible - * that the assignment could be of a vec4 to the last element of the - * matrix. In this case col_idx==cols, but there is still data - * left in the source parameter. Obviously, don't emit an assignment - * to data outside the destination matrix. - */ - if ((col_idx < cols) && (rhs_base < rhs_components)) { - const unsigned count = rhs_components - rhs_base; - - rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var); - - ir_instruction *inst = assign_to_matrix_column(var, col_idx, - row_idx, - rhs_var_ref, - rhs_base, - count, ctx); - instructions->push_tail(inst); - - row_idx += count; - } - } - } - - return new(ctx) ir_dereference_variable(var); -} - - -ir_rvalue * -emit_inline_record_constructor(const glsl_type *type, - exec_list *instructions, - exec_list *parameters, - void *mem_ctx) -{ - ir_variable *const var = - new(mem_ctx) ir_variable(type, "record_ctor", ir_var_temporary); - ir_dereference_variable *const d = new(mem_ctx) ir_dereference_variable(var); - - instructions->push_tail(var); - - exec_node *node = parameters->head; - for (unsigned i = 0; i < type->length; i++) { - assert(!node->is_tail_sentinel()); - - ir_dereference *const lhs = - new(mem_ctx) ir_dereference_record(d->clone(mem_ctx, NULL), - type->fields.structure[i].name); - - ir_rvalue *const rhs = ((ir_instruction *) node)->as_rvalue(); - assert(rhs != NULL); - - ir_instruction *const assign = new(mem_ctx) ir_assignment(lhs, rhs, NULL); - - instructions->push_tail(assign); - node = node->next; - } - - return d; -} - - -ir_rvalue * -ast_function_expression::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - /* There are three sorts of function calls. - * - * 1. constructors - The first subexpression is an ast_type_specifier. - * 2. methods - Only the .length() method of array types. - * 3. functions - Calls to regular old functions. - * - * Method calls are actually detected when the ast_field_selection - * expression is handled. - */ - if (is_constructor()) { - const ast_type_specifier *type = (ast_type_specifier *) subexpressions[0]; - YYLTYPE loc = type->get_location(); - const char *name; - - const glsl_type *const constructor_type = type->glsl_type(& name, state); - - /* constructor_type can be NULL if a variable with the same name as the - * structure has come into scope. - */ - if (constructor_type == NULL) { - _mesa_glsl_error(& loc, state, "unknown type `%s' (structure name " - "may be shadowed by a variable with the same name)", - type->type_name); - return ir_call::get_error_instruction(ctx); - } - - - /* Constructors for samplers are illegal. - */ - if (constructor_type->is_sampler()) { - _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - if (constructor_type->is_array()) { - if (state->language_version <= 110) { - _mesa_glsl_error(& loc, state, - "array constructors forbidden in GLSL 1.10"); - return ir_call::get_error_instruction(ctx); - } - - return process_array_constructor(instructions, constructor_type, - & loc, &this->expressions, state); - } - - - /* There are two kinds of constructor call. Constructors for built-in - * language types, such as mat4 and vec2, are free form. The only - * requirement is that the parameters must provide enough values of the - * correct scalar type. Constructors for arrays and structures must - * have the exact number of parameters with matching types in the - * correct order. These constructors follow essentially the same type - * matching rules as functions. - */ - if (constructor_type->is_record()) { - exec_list actual_parameters; - - process_parameters(instructions, &actual_parameters, - &this->expressions, state); - - exec_node *node = actual_parameters.head; - for (unsigned i = 0; i < constructor_type->length; i++) { - ir_rvalue *ir = (ir_rvalue *) node; - - if (node->is_tail_sentinel()) { - _mesa_glsl_error(&loc, state, - "insufficient parameters to constructor " - "for `%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - if (apply_implicit_conversion(constructor_type->fields.structure[i].type, - ir, state)) { - node->replace_with(ir); - } else { - _mesa_glsl_error(&loc, state, - "parameter type mismatch in constructor " - "for `%s.%s' (%s vs %s)", - constructor_type->name, - constructor_type->fields.structure[i].name, - ir->type->name, - constructor_type->fields.structure[i].type->name); - return ir_call::get_error_instruction(ctx);; - } - - node = node->next; - } - - if (!node->is_tail_sentinel()) { - _mesa_glsl_error(&loc, state, "too many parameters in constructor " - "for `%s'", constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - ir_rvalue *const constant = - constant_record_constructor(constructor_type, &actual_parameters, - state); - - return (constant != NULL) - ? constant - : emit_inline_record_constructor(constructor_type, instructions, - &actual_parameters, state); - } - - if (!constructor_type->is_numeric() && !constructor_type->is_boolean()) - return ir_call::get_error_instruction(ctx); - - /* Total number of components of the type being constructed. */ - const unsigned type_components = constructor_type->components(); - - /* Number of components from parameters that have actually been - * consumed. This is used to perform several kinds of error checking. - */ - unsigned components_used = 0; - - unsigned matrix_parameters = 0; - unsigned nonmatrix_parameters = 0; - exec_list actual_parameters; - - foreach_list (n, &this->expressions) { - ast_node *ast = exec_node_data(ast_node, n, link); - ir_rvalue *result = ast->hir(instructions, state)->as_rvalue(); - - /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: - * - * "It is an error to provide extra arguments beyond this - * last used argument." - */ - if (components_used >= type_components) { - _mesa_glsl_error(& loc, state, "too many parameters to `%s' " - "constructor", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - if (!result->type->is_numeric() && !result->type->is_boolean()) { - _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " - "non-numeric data type", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - /* Count the number of matrix and nonmatrix parameters. This - * is used below to enforce some of the constructor rules. - */ - if (result->type->is_matrix()) - matrix_parameters++; - else - nonmatrix_parameters++; - - actual_parameters.push_tail(result); - components_used += result->type->components(); - } - - /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: - * - * "It is an error to construct matrices from other matrices. This - * is reserved for future use." - */ - if (state->language_version == 110 && matrix_parameters > 0 - && constructor_type->is_matrix()) { - _mesa_glsl_error(& loc, state, "cannot construct `%s' from a " - "matrix in GLSL 1.10", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec: - * - * "If a matrix argument is given to a matrix constructor, it is - * an error to have any other arguments." - */ - if ((matrix_parameters > 0) - && ((matrix_parameters + nonmatrix_parameters) > 1) - && constructor_type->is_matrix()) { - _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, " - "matrix must be only parameter", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec: - * - * "In these cases, there must be enough components provided in the - * arguments to provide an initializer for every component in the - * constructed value." - */ - if (components_used < type_components && components_used != 1 - && matrix_parameters == 0) { - _mesa_glsl_error(& loc, state, "too few components to construct " - "`%s'", - constructor_type->name); - return ir_call::get_error_instruction(ctx); - } - - /* Later, we cast each parameter to the same base type as the - * constructor. Since there are no non-floating point matrices, we - * need to break them up into a series of column vectors. - */ - if (constructor_type->base_type != GLSL_TYPE_FLOAT) { - foreach_list_safe(n, &actual_parameters) { - ir_rvalue *matrix = (ir_rvalue *) n; - - if (!matrix->type->is_matrix()) - continue; - - /* Create a temporary containing the matrix. */ - ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp", - ir_var_temporary); - instructions->push_tail(var); - instructions->push_tail(new(ctx) ir_assignment(new(ctx) - ir_dereference_variable(var), matrix, NULL)); - var->constant_value = matrix->constant_expression_value(); - - /* Replace the matrix with dereferences of its columns. */ - for (int i = 0; i < matrix->type->matrix_columns; i++) { - matrix->insert_before(new (ctx) ir_dereference_array(var, - new(ctx) ir_constant(i))); - } - matrix->remove(); - } - } - - bool all_parameters_are_constant = true; - - /* Type cast each parameter and, if possible, fold constants.*/ - foreach_list_safe(n, &actual_parameters) { - ir_rvalue *ir = (ir_rvalue *) n; - - const glsl_type *desired_type = - glsl_type::get_instance(constructor_type->base_type, - ir->type->vector_elements, - ir->type->matrix_columns); - ir_rvalue *result = convert_component(ir, desired_type); - - /* Attempt to convert the parameter to a constant valued expression. - * After doing so, track whether or not all the parameters to the - * constructor are trivially constant valued expressions. - */ - ir_rvalue *const constant = result->constant_expression_value(); - - if (constant != NULL) - result = constant; - else - all_parameters_are_constant = false; - - if (result != ir) { - ir->replace_with(result); - } - } - - /* If all of the parameters are trivially constant, create a - * constant representing the complete collection of parameters. - */ - if (all_parameters_are_constant) { - return new(ctx) ir_constant(constructor_type, &actual_parameters); - } else if (constructor_type->is_scalar()) { - return dereference_component((ir_rvalue *) actual_parameters.head, - 0); - } else if (constructor_type->is_vector()) { - return emit_inline_vector_constructor(constructor_type, - instructions, - &actual_parameters, - ctx); - } else { - assert(constructor_type->is_matrix()); - return emit_inline_matrix_constructor(constructor_type, - instructions, - &actual_parameters, - ctx); - } - } else { - const ast_expression *id = subexpressions[0]; - YYLTYPE loc = id->get_location(); - exec_list actual_parameters; - - process_parameters(instructions, &actual_parameters, &this->expressions, - state); - - ir_call *call = NULL; - ir_rvalue *const value = - match_function_by_name(instructions, - id->primary_expression.identifier, - &loc, &actual_parameters, &call, state); - - if (call != NULL) { - /* If a function was found, make sure that none of the 'out' or 'inout' - * parameters violate the extra l-value rules. - */ - ir_function_signature *f = call->get_callee(); - assert(f != NULL); - - exec_node *formal_node = f->parameters.head; - - foreach_list (actual_node, &this->expressions) { - /* Both parameter lists had better be the same length! - */ - assert(!actual_node->is_tail_sentinel()); - - const ir_variable *const formal_parameter = - (ir_variable *) formal_node; - const ast_expression *const actual_parameter = - exec_node_data(ast_expression, actual_node, link); - - if ((formal_parameter->mode == ir_var_out - || formal_parameter->mode == ir_var_inout) - && actual_parameter->non_lvalue_description != NULL) { - YYLTYPE loc = actual_parameter->get_location(); - - _mesa_glsl_error(&loc, state, - "function parameter '%s %s' references a %s", - (formal_parameter->mode == ir_var_out) - ? "out" : "inout", - formal_parameter->name, - actual_parameter->non_lvalue_description); - return ir_call::get_error_instruction(ctx); - } - - /* Only advance the formal_node pointer here because the - * foreach_list business already advances actual_node. - */ - formal_node = formal_node->next; - } - } - - return value; - } - - return ir_call::get_error_instruction(ctx); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ast_to_hir.cpp b/reactos/dll/opengl/mesa/src/glsl/ast_to_hir.cpp deleted file mode 100644 index 020766bd118..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ast_to_hir.cpp +++ /dev/null @@ -1,3830 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ast_to_hir.c - * Convert abstract syntax to to high-level intermediate reprensentation (HIR). - * - * During the conversion to HIR, the majority of the symantic checking is - * preformed on the program. This includes: - * - * * Symbol table management - * * Type checking - * * Function binding - * - * The majority of this work could be done during parsing, and the parser could - * probably generate HIR directly. However, this results in frequent changes - * to the parser code. Since we do not assume that every system this complier - * is built on will have Flex and Bison installed, we have to store the code - * generated by these tools in our version control system. In other parts of - * the system we've seen problems where a parser was changed but the generated - * code was not committed, merge conflicts where created because two developers - * had slightly different versions of Bison installed, etc. - * - * I have also noticed that running Bison generated parsers in GDB is very - * irritating. When you get a segfault on '$$ = $1->foo', you can't very - * well 'print $1' in GDB. - * - * As a result, my preference is to put as little C code as possible in the - * parser (and lexer) sources. - */ - -#include "main/core.h" /* for struct gl_extensions */ -#include "glsl_symbol_table.h" -#include "glsl_parser_extras.h" -#include "ast.h" -#include "glsl_types.h" -#include "program/hash_table.h" -#include "ir.h" - -void -_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) -{ - _mesa_glsl_initialize_variables(instructions, state); - - state->symbols->language_version = state->language_version; - - state->current_function = NULL; - - state->toplevel_ir = instructions; - - /* Section 4.2 of the GLSL 1.20 specification states: - * "The built-in functions are scoped in a scope outside the global scope - * users declare global variables in. That is, a shader's global scope, - * available for user-defined functions and global variables, is nested - * inside the scope containing the built-in functions." - * - * Since built-in functions like ftransform() access built-in variables, - * it follows that those must be in the outer scope as well. - * - * We push scope here to create this nesting effect...but don't pop. - * This way, a shader's globals are still in the symbol table for use - * by the linker. - */ - state->symbols->push_scope(); - - foreach_list_typed (ast_node, ast, link, & state->translation_unit) - ast->hir(instructions, state); - - detect_recursion_unlinked(state, instructions); - - state->toplevel_ir = NULL; -} - - -/** - * If a conversion is available, convert one operand to a different type - * - * The \c from \c ir_rvalue is converted "in place". - * - * \param to Type that the operand it to be converted to - * \param from Operand that is being converted - * \param state GLSL compiler state - * - * \return - * If a conversion is possible (or unnecessary), \c true is returned. - * Otherwise \c false is returned. - */ -bool -apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - if (to->base_type == from->type->base_type) - return true; - - /* This conversion was added in GLSL 1.20. If the compilation mode is - * GLSL 1.10, the conversion is skipped. - */ - if (state->language_version < 120) - return false; - - /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec: - * - * "There are no implicit array or structure conversions. For - * example, an array of int cannot be implicitly converted to an - * array of float. There are no implicit conversions between - * signed and unsigned integers." - */ - /* FINISHME: The above comment is partially a lie. There is int/uint - * FINISHME: conversion for immediate constants. - */ - if (!to->is_float() || !from->type->is_numeric()) - return false; - - /* Convert to a floating point type with the same number of components - * as the original type - i.e. int to float, not int to vec4. - */ - to = glsl_type::get_instance(GLSL_TYPE_FLOAT, from->type->vector_elements, - from->type->matrix_columns); - - switch (from->type->base_type) { - case GLSL_TYPE_INT: - from = new(ctx) ir_expression(ir_unop_i2f, to, from, NULL); - break; - case GLSL_TYPE_UINT: - from = new(ctx) ir_expression(ir_unop_u2f, to, from, NULL); - break; - case GLSL_TYPE_BOOL: - from = new(ctx) ir_expression(ir_unop_b2f, to, from, NULL); - break; - default: - assert(0); - } - - return true; -} - - -static const struct glsl_type * -arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, - bool multiply, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - const glsl_type *type_a = value_a->type; - const glsl_type *type_b = value_b->type; - - /* From GLSL 1.50 spec, page 56: - * - * "The arithmetic binary operators add (+), subtract (-), - * multiply (*), and divide (/) operate on integer and - * floating-point scalars, vectors, and matrices." - */ - if (!type_a->is_numeric() || !type_b->is_numeric()) { - _mesa_glsl_error(loc, state, - "Operands to arithmetic operators must be numeric"); - return glsl_type::error_type; - } - - - /* "If one operand is floating-point based and the other is - * not, then the conversions from Section 4.1.10 "Implicit - * Conversions" are applied to the non-floating-point-based operand." - */ - if (!apply_implicit_conversion(type_a, value_b, state) - && !apply_implicit_conversion(type_b, value_a, state)) { - _mesa_glsl_error(loc, state, - "Could not implicitly convert operands to " - "arithmetic operator"); - return glsl_type::error_type; - } - type_a = value_a->type; - type_b = value_b->type; - - /* "If the operands are integer types, they must both be signed or - * both be unsigned." - * - * From this rule and the preceeding conversion it can be inferred that - * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT. - * The is_numeric check above already filtered out the case where either - * type is not one of these, so now the base types need only be tested for - * equality. - */ - if (type_a->base_type != type_b->base_type) { - _mesa_glsl_error(loc, state, - "base type mismatch for arithmetic operator"); - return glsl_type::error_type; - } - - /* "All arithmetic binary operators result in the same fundamental type - * (signed integer, unsigned integer, or floating-point) as the - * operands they operate on, after operand type conversion. After - * conversion, the following cases are valid - * - * * The two operands are scalars. In this case the operation is - * applied, resulting in a scalar." - */ - if (type_a->is_scalar() && type_b->is_scalar()) - return type_a; - - /* "* One operand is a scalar, and the other is a vector or matrix. - * In this case, the scalar operation is applied independently to each - * component of the vector or matrix, resulting in the same size - * vector or matrix." - */ - if (type_a->is_scalar()) { - if (!type_b->is_scalar()) - return type_b; - } else if (type_b->is_scalar()) { - return type_a; - } - - /* All of the combinations of , , - * , , and have been - * handled. - */ - assert(!type_a->is_scalar()); - assert(!type_b->is_scalar()); - - /* "* The two operands are vectors of the same size. In this case, the - * operation is done component-wise resulting in the same size - * vector." - */ - if (type_a->is_vector() && type_b->is_vector()) { - if (type_a == type_b) { - return type_a; - } else { - _mesa_glsl_error(loc, state, - "vector size mismatch for arithmetic operator"); - return glsl_type::error_type; - } - } - - /* All of the combinations of , , - * , , , and - * have been handled. At least one of the operands must - * be matrix. Further, since there are no integer matrix types, the base - * type of both operands must be float. - */ - assert(type_a->is_matrix() || type_b->is_matrix()); - assert(type_a->base_type == GLSL_TYPE_FLOAT); - assert(type_b->base_type == GLSL_TYPE_FLOAT); - - /* "* The operator is add (+), subtract (-), or divide (/), and the - * operands are matrices with the same number of rows and the same - * number of columns. In this case, the operation is done component- - * wise resulting in the same size matrix." - * * The operator is multiply (*), where both operands are matrices or - * one operand is a vector and the other a matrix. A right vector - * operand is treated as a column vector and a left vector operand as a - * row vector. In all these cases, it is required that the number of - * columns of the left operand is equal to the number of rows of the - * right operand. Then, the multiply (*) operation does a linear - * algebraic multiply, yielding an object that has the same number of - * rows as the left operand and the same number of columns as the right - * operand. Section 5.10 "Vector and Matrix Operations" explains in - * more detail how vectors and matrices are operated on." - */ - if (! multiply) { - if (type_a == type_b) - return type_a; - } else { - if (type_a->is_matrix() && type_b->is_matrix()) { - /* Matrix multiply. The columns of A must match the rows of B. Given - * the other previously tested constraints, this means the vector type - * of a row from A must be the same as the vector type of a column from - * B. - */ - if (type_a->row_type() == type_b->column_type()) { - /* The resulting matrix has the number of columns of matrix B and - * the number of rows of matrix A. We get the row count of A by - * looking at the size of a vector that makes up a column. The - * transpose (size of a row) is done for B. - */ - const glsl_type *const type = - glsl_type::get_instance(type_a->base_type, - type_a->column_type()->vector_elements, - type_b->row_type()->vector_elements); - assert(type != glsl_type::error_type); - - return type; - } - } else if (type_a->is_matrix()) { - /* A is a matrix and B is a column vector. Columns of A must match - * rows of B. Given the other previously tested constraints, this - * means the vector type of a row from A must be the same as the - * vector the type of B. - */ - if (type_a->row_type() == type_b) { - /* The resulting vector has a number of elements equal to - * the number of rows of matrix A. */ - const glsl_type *const type = - glsl_type::get_instance(type_a->base_type, - type_a->column_type()->vector_elements, - 1); - assert(type != glsl_type::error_type); - - return type; - } - } else { - assert(type_b->is_matrix()); - - /* A is a row vector and B is a matrix. Columns of A must match rows - * of B. Given the other previously tested constraints, this means - * the type of A must be the same as the vector type of a column from - * B. - */ - if (type_a == type_b->column_type()) { - /* The resulting vector has a number of elements equal to - * the number of columns of matrix B. */ - const glsl_type *const type = - glsl_type::get_instance(type_a->base_type, - type_b->row_type()->vector_elements, - 1); - assert(type != glsl_type::error_type); - - return type; - } - } - - _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication"); - return glsl_type::error_type; - } - - - /* "All other cases are illegal." - */ - _mesa_glsl_error(loc, state, "type mismatch"); - return glsl_type::error_type; -} - - -static const struct glsl_type * -unary_arithmetic_result_type(const struct glsl_type *type, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - /* From GLSL 1.50 spec, page 57: - * - * "The arithmetic unary operators negate (-), post- and pre-increment - * and decrement (-- and ++) operate on integer or floating-point - * values (including vectors and matrices). All unary operators work - * component-wise on their operands. These result with the same type - * they operated on." - */ - if (!type->is_numeric()) { - _mesa_glsl_error(loc, state, - "Operands to arithmetic operators must be numeric"); - return glsl_type::error_type; - } - - return type; -} - -/** - * \brief Return the result type of a bit-logic operation. - * - * If the given types to the bit-logic operator are invalid, return - * glsl_type::error_type. - * - * \param type_a Type of LHS of bit-logic op - * \param type_b Type of RHS of bit-logic op - */ -static const struct glsl_type * -bit_logic_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, - ast_operators op, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - if (state->language_version < 130) { - _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30"); - return glsl_type::error_type; - } - - /* From page 50 (page 56 of PDF) of GLSL 1.30 spec: - * - * "The bitwise operators and (&), exclusive-or (^), and inclusive-or - * (|). The operands must be of type signed or unsigned integers or - * integer vectors." - */ - if (!type_a->is_integer()) { - _mesa_glsl_error(loc, state, "LHS of `%s' must be an integer", - ast_expression::operator_string(op)); - return glsl_type::error_type; - } - if (!type_b->is_integer()) { - _mesa_glsl_error(loc, state, "RHS of `%s' must be an integer", - ast_expression::operator_string(op)); - return glsl_type::error_type; - } - - /* "The fundamental types of the operands (signed or unsigned) must - * match," - */ - if (type_a->base_type != type_b->base_type) { - _mesa_glsl_error(loc, state, "operands of `%s' must have the same " - "base type", ast_expression::operator_string(op)); - return glsl_type::error_type; - } - - /* "The operands cannot be vectors of differing size." */ - if (type_a->is_vector() && - type_b->is_vector() && - type_a->vector_elements != type_b->vector_elements) { - _mesa_glsl_error(loc, state, "operands of `%s' cannot be vectors of " - "different sizes", ast_expression::operator_string(op)); - return glsl_type::error_type; - } - - /* "If one operand is a scalar and the other a vector, the scalar is - * applied component-wise to the vector, resulting in the same type as - * the vector. The fundamental types of the operands [...] will be the - * resulting fundamental type." - */ - if (type_a->is_scalar()) - return type_b; - else - return type_a; -} - -static const struct glsl_type * -modulus_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - if (state->language_version < 130) { - _mesa_glsl_error(loc, state, - "operator '%%' is reserved in %s", - state->version_string); - return glsl_type::error_type; - } - - /* From GLSL 1.50 spec, page 56: - * "The operator modulus (%) operates on signed or unsigned integers or - * integer vectors. The operand types must both be signed or both be - * unsigned." - */ - if (!type_a->is_integer()) { - _mesa_glsl_error(loc, state, "LHS of operator %% must be an integer."); - return glsl_type::error_type; - } - if (!type_b->is_integer()) { - _mesa_glsl_error(loc, state, "RHS of operator %% must be an integer."); - return glsl_type::error_type; - } - if (type_a->base_type != type_b->base_type) { - _mesa_glsl_error(loc, state, - "operands of %% must have the same base type"); - return glsl_type::error_type; - } - - /* "The operands cannot be vectors of differing size. If one operand is - * a scalar and the other vector, then the scalar is applied component- - * wise to the vector, resulting in the same type as the vector. If both - * are vectors of the same size, the result is computed component-wise." - */ - if (type_a->is_vector()) { - if (!type_b->is_vector() - || (type_a->vector_elements == type_b->vector_elements)) - return type_a; - } else - return type_b; - - /* "The operator modulus (%) is not defined for any other data types - * (non-integer types)." - */ - _mesa_glsl_error(loc, state, "type mismatch"); - return glsl_type::error_type; -} - - -static const struct glsl_type * -relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - const glsl_type *type_a = value_a->type; - const glsl_type *type_b = value_b->type; - - /* From GLSL 1.50 spec, page 56: - * "The relational operators greater than (>), less than (<), greater - * than or equal (>=), and less than or equal (<=) operate only on - * scalar integer and scalar floating-point expressions." - */ - if (!type_a->is_numeric() - || !type_b->is_numeric() - || !type_a->is_scalar() - || !type_b->is_scalar()) { - _mesa_glsl_error(loc, state, - "Operands to relational operators must be scalar and " - "numeric"); - return glsl_type::error_type; - } - - /* "Either the operands' types must match, or the conversions from - * Section 4.1.10 "Implicit Conversions" will be applied to the integer - * operand, after which the types must match." - */ - if (!apply_implicit_conversion(type_a, value_b, state) - && !apply_implicit_conversion(type_b, value_a, state)) { - _mesa_glsl_error(loc, state, - "Could not implicitly convert operands to " - "relational operator"); - return glsl_type::error_type; - } - type_a = value_a->type; - type_b = value_b->type; - - if (type_a->base_type != type_b->base_type) { - _mesa_glsl_error(loc, state, "base type mismatch"); - return glsl_type::error_type; - } - - /* "The result is scalar Boolean." - */ - return glsl_type::bool_type; -} - -/** - * \brief Return the result type of a bit-shift operation. - * - * If the given types to the bit-shift operator are invalid, return - * glsl_type::error_type. - * - * \param type_a Type of LHS of bit-shift op - * \param type_b Type of RHS of bit-shift op - */ -static const struct glsl_type * -shift_result_type(const struct glsl_type *type_a, - const struct glsl_type *type_b, - ast_operators op, - struct _mesa_glsl_parse_state *state, YYLTYPE *loc) -{ - if (state->language_version < 130) { - _mesa_glsl_error(loc, state, "bit operations require GLSL 1.30"); - return glsl_type::error_type; - } - - /* From page 50 (page 56 of the PDF) of the GLSL 1.30 spec: - * - * "The shift operators (<<) and (>>). For both operators, the operands - * must be signed or unsigned integers or integer vectors. One operand - * can be signed while the other is unsigned." - */ - if (!type_a->is_integer()) { - _mesa_glsl_error(loc, state, "LHS of operator %s must be an integer or " - "integer vector", ast_expression::operator_string(op)); - return glsl_type::error_type; - - } - if (!type_b->is_integer()) { - _mesa_glsl_error(loc, state, "RHS of operator %s must be an integer or " - "integer vector", ast_expression::operator_string(op)); - return glsl_type::error_type; - } - - /* "If the first operand is a scalar, the second operand has to be - * a scalar as well." - */ - if (type_a->is_scalar() && !type_b->is_scalar()) { - _mesa_glsl_error(loc, state, "If the first operand of %s is scalar, the " - "second must be scalar as well", - ast_expression::operator_string(op)); - return glsl_type::error_type; - } - - /* If both operands are vectors, check that they have same number of - * elements. - */ - if (type_a->is_vector() && - type_b->is_vector() && - type_a->vector_elements != type_b->vector_elements) { - _mesa_glsl_error(loc, state, "Vector operands to operator %s must " - "have same number of elements", - ast_expression::operator_string(op)); - return glsl_type::error_type; - } - - /* "In all cases, the resulting type will be the same type as the left - * operand." - */ - return type_a; -} - -/** - * Validates that a value can be assigned to a location with a specified type - * - * Validates that \c rhs can be assigned to some location. If the types are - * not an exact match but an automatic conversion is possible, \c rhs will be - * converted. - * - * \return - * \c NULL if \c rhs cannot be assigned to a location with type \c lhs_type. - * Otherwise the actual RHS to be assigned will be returned. This may be - * \c rhs, or it may be \c rhs after some type conversion. - * - * \note - * In addition to being used for assignments, this function is used to - * type-check return values. - */ -ir_rvalue * -validate_assignment(struct _mesa_glsl_parse_state *state, - const glsl_type *lhs_type, ir_rvalue *rhs, - bool is_initializer) -{ - /* If there is already some error in the RHS, just return it. Anything - * else will lead to an avalanche of error message back to the user. - */ - if (rhs->type->is_error()) - return rhs; - - /* If the types are identical, the assignment can trivially proceed. - */ - if (rhs->type == lhs_type) - return rhs; - - /* If the array element types are the same and the size of the LHS is zero, - * the assignment is okay for initializers embedded in variable - * declarations. - * - * Note: Whole-array assignments are not permitted in GLSL 1.10, but this - * is handled by ir_dereference::is_lvalue. - */ - if (is_initializer && lhs_type->is_array() && rhs->type->is_array() - && (lhs_type->element_type() == rhs->type->element_type()) - && (lhs_type->array_size() == 0)) { - return rhs; - } - - /* Check for implicit conversion in GLSL 1.20 */ - if (apply_implicit_conversion(lhs_type, rhs, state)) { - if (rhs->type == lhs_type) - return rhs; - } - - return NULL; -} - -static void -mark_whole_array_access(ir_rvalue *access) -{ - ir_dereference_variable *deref = access->as_dereference_variable(); - - if (deref && deref->var) { - deref->var->max_array_access = deref->type->length - 1; - } -} - -ir_rvalue * -do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, - const char *non_lvalue_description, - ir_rvalue *lhs, ir_rvalue *rhs, bool is_initializer, - YYLTYPE lhs_loc) -{ - void *ctx = state; - bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); - - if (!error_emitted) { - if (non_lvalue_description != NULL) { - _mesa_glsl_error(&lhs_loc, state, - "assignment to %s", - non_lvalue_description); - error_emitted = true; - } else if (lhs->variable_referenced() != NULL - && lhs->variable_referenced()->read_only) { - _mesa_glsl_error(&lhs_loc, state, - "assignment to read-only variable '%s'", - lhs->variable_referenced()->name); - error_emitted = true; - - } else if (state->language_version <= 110 && lhs->type->is_array()) { - /* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec: - * - * "Other binary or unary expressions, non-dereferenced - * arrays, function names, swizzles with repeated fields, - * and constants cannot be l-values." - */ - _mesa_glsl_error(&lhs_loc, state, "whole array assignment is not " - "allowed in GLSL 1.10 or GLSL ES 1.00."); - error_emitted = true; - } else if (!lhs->is_lvalue()) { - _mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment"); - error_emitted = true; - } - } - - ir_rvalue *new_rhs = - validate_assignment(state, lhs->type, rhs, is_initializer); - if (new_rhs == NULL) { - _mesa_glsl_error(& lhs_loc, state, "type mismatch"); - } else { - rhs = new_rhs; - - /* If the LHS array was not declared with a size, it takes it size from - * the RHS. If the LHS is an l-value and a whole array, it must be a - * dereference of a variable. Any other case would require that the LHS - * is either not an l-value or not a whole array. - */ - if (lhs->type->array_size() == 0) { - ir_dereference *const d = lhs->as_dereference(); - - assert(d != NULL); - - ir_variable *const var = d->variable_referenced(); - - assert(var != NULL); - - if (var->max_array_access >= unsigned(rhs->type->array_size())) { - /* FINISHME: This should actually log the location of the RHS. */ - _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to " - "previous access", - var->max_array_access); - } - - var->type = glsl_type::get_array_instance(lhs->type->element_type(), - rhs->type->array_size()); - d->type = var->type; - } - mark_whole_array_access(rhs); - mark_whole_array_access(lhs); - } - - /* Most callers of do_assignment (assign, add_assign, pre_inc/dec, - * but not post_inc) need the converted assigned value as an rvalue - * to handle things like: - * - * i = j += 1; - * - * So we always just store the computed value being assigned to a - * temporary and return a deref of that temporary. If the rvalue - * ends up not being used, the temp will get copy-propagated out. - */ - ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp", - ir_var_temporary); - ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var); - instructions->push_tail(var); - instructions->push_tail(new(ctx) ir_assignment(deref_var, - rhs, - NULL)); - deref_var = new(ctx) ir_dereference_variable(var); - - if (!error_emitted) - instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var, NULL)); - - return new(ctx) ir_dereference_variable(var); -} - -static ir_rvalue * -get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) -{ - void *ctx = ralloc_parent(lvalue); - ir_variable *var; - - var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp", - ir_var_temporary); - instructions->push_tail(var); - var->mode = ir_var_auto; - - instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), - lvalue, NULL)); - - return new(ctx) ir_dereference_variable(var); -} - - -ir_rvalue * -ast_node::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - (void) instructions; - (void) state; - - return NULL; -} - -static ir_rvalue * -do_comparison(void *mem_ctx, int operation, ir_rvalue *op0, ir_rvalue *op1) -{ - int join_op; - ir_rvalue *cmp = NULL; - - if (operation == ir_binop_all_equal) - join_op = ir_binop_logic_and; - else - join_op = ir_binop_logic_or; - - switch (op0->type->base_type) { - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_BOOL: - return new(mem_ctx) ir_expression(operation, op0, op1); - - case GLSL_TYPE_ARRAY: { - for (unsigned int i = 0; i < op0->type->length; i++) { - ir_rvalue *e0, *e1, *result; - - e0 = new(mem_ctx) ir_dereference_array(op0->clone(mem_ctx, NULL), - new(mem_ctx) ir_constant(i)); - e1 = new(mem_ctx) ir_dereference_array(op1->clone(mem_ctx, NULL), - new(mem_ctx) ir_constant(i)); - result = do_comparison(mem_ctx, operation, e0, e1); - - if (cmp) { - cmp = new(mem_ctx) ir_expression(join_op, cmp, result); - } else { - cmp = result; - } - } - - mark_whole_array_access(op0); - mark_whole_array_access(op1); - break; - } - - case GLSL_TYPE_STRUCT: { - for (unsigned int i = 0; i < op0->type->length; i++) { - ir_rvalue *e0, *e1, *result; - const char *field_name = op0->type->fields.structure[i].name; - - e0 = new(mem_ctx) ir_dereference_record(op0->clone(mem_ctx, NULL), - field_name); - e1 = new(mem_ctx) ir_dereference_record(op1->clone(mem_ctx, NULL), - field_name); - result = do_comparison(mem_ctx, operation, e0, e1); - - if (cmp) { - cmp = new(mem_ctx) ir_expression(join_op, cmp, result); - } else { - cmp = result; - } - } - break; - } - - case GLSL_TYPE_ERROR: - case GLSL_TYPE_VOID: - case GLSL_TYPE_SAMPLER: - /* I assume a comparison of a struct containing a sampler just - * ignores the sampler present in the type. - */ - break; - - default: - assert(!"Should not get here."); - break; - } - - if (cmp == NULL) - cmp = new(mem_ctx) ir_constant(true); - - return cmp; -} - -/* For logical operations, we want to ensure that the operands are - * scalar booleans. If it isn't, emit an error and return a constant - * boolean to avoid triggering cascading error messages. - */ -ir_rvalue * -get_scalar_boolean_operand(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - ast_expression *parent_expr, - int operand, - const char *operand_name, - bool *error_emitted) -{ - ast_expression *expr = parent_expr->subexpressions[operand]; - void *ctx = state; - ir_rvalue *val = expr->hir(instructions, state); - - if (val->type->is_boolean() && val->type->is_scalar()) - return val; - - if (!*error_emitted) { - YYLTYPE loc = expr->get_location(); - _mesa_glsl_error(&loc, state, "%s of `%s' must be scalar boolean", - operand_name, - parent_expr->operator_string(parent_expr->oper)); - *error_emitted = true; - } - - return new(ctx) ir_constant(true); -} - -/** - * If name refers to a builtin array whose maximum allowed size is less than - * size, report an error and return true. Otherwise return false. - */ -static bool -check_builtin_array_max_size(const char *name, unsigned size, - YYLTYPE loc, struct _mesa_glsl_parse_state *state) -{ - if ((strcmp("gl_TexCoord", name) == 0) - && (size > state->Const.MaxTextureCoords)) { - /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: - * - * "The size [of gl_TexCoord] can be at most - * gl_MaxTextureCoords." - */ - _mesa_glsl_error(&loc, state, "`gl_TexCoord' array size cannot " - "be larger than gl_MaxTextureCoords (%u)\n", - state->Const.MaxTextureCoords); - return true; - } else if (strcmp("gl_ClipDistance", name) == 0 - && size > state->Const.MaxClipPlanes) { - /* From section 7.1 (Vertex Shader Special Variables) of the - * GLSL 1.30 spec: - * - * "The gl_ClipDistance array is predeclared as unsized and - * must be sized by the shader either redeclaring it with a - * size or indexing it only with integral constant - * expressions. ... The size can be at most - * gl_MaxClipDistances." - */ - _mesa_glsl_error(&loc, state, "`gl_ClipDistance' array size cannot " - "be larger than gl_MaxClipDistances (%u)\n", - state->Const.MaxClipPlanes); - return true; - } - return false; -} - -/** - * Create the constant 1, of a which is appropriate for incrementing and - * decrementing values of the given GLSL type. For example, if type is vec4, - * this creates a constant value of 1.0 having type float. - * - * If the given type is invalid for increment and decrement operators, return - * a floating point 1--the error will be detected later. - */ -static ir_rvalue * -constant_one_for_inc_dec(void *ctx, const glsl_type *type) -{ - switch (type->base_type) { - case GLSL_TYPE_UINT: - return new(ctx) ir_constant((unsigned) 1); - case GLSL_TYPE_INT: - return new(ctx) ir_constant(1); - default: - case GLSL_TYPE_FLOAT: - return new(ctx) ir_constant(1.0f); - } -} - -ir_rvalue * -ast_expression::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - static const int operations[AST_NUM_OPERATORS] = { - -1, /* ast_assign doesn't convert to ir_expression. */ - -1, /* ast_plus doesn't convert to ir_expression. */ - ir_unop_neg, - ir_binop_add, - ir_binop_sub, - ir_binop_mul, - ir_binop_div, - ir_binop_mod, - ir_binop_lshift, - ir_binop_rshift, - ir_binop_less, - ir_binop_greater, - ir_binop_lequal, - ir_binop_gequal, - ir_binop_all_equal, - ir_binop_any_nequal, - ir_binop_bit_and, - ir_binop_bit_xor, - ir_binop_bit_or, - ir_unop_bit_not, - ir_binop_logic_and, - ir_binop_logic_xor, - ir_binop_logic_or, - ir_unop_logic_not, - - /* Note: The following block of expression types actually convert - * to multiple IR instructions. - */ - ir_binop_mul, /* ast_mul_assign */ - ir_binop_div, /* ast_div_assign */ - ir_binop_mod, /* ast_mod_assign */ - ir_binop_add, /* ast_add_assign */ - ir_binop_sub, /* ast_sub_assign */ - ir_binop_lshift, /* ast_ls_assign */ - ir_binop_rshift, /* ast_rs_assign */ - ir_binop_bit_and, /* ast_and_assign */ - ir_binop_bit_xor, /* ast_xor_assign */ - ir_binop_bit_or, /* ast_or_assign */ - - -1, /* ast_conditional doesn't convert to ir_expression. */ - ir_binop_add, /* ast_pre_inc. */ - ir_binop_sub, /* ast_pre_dec. */ - ir_binop_add, /* ast_post_inc. */ - ir_binop_sub, /* ast_post_dec. */ - -1, /* ast_field_selection doesn't conv to ir_expression. */ - -1, /* ast_array_index doesn't convert to ir_expression. */ - -1, /* ast_function_call doesn't conv to ir_expression. */ - -1, /* ast_identifier doesn't convert to ir_expression. */ - -1, /* ast_int_constant doesn't convert to ir_expression. */ - -1, /* ast_uint_constant doesn't conv to ir_expression. */ - -1, /* ast_float_constant doesn't conv to ir_expression. */ - -1, /* ast_bool_constant doesn't conv to ir_expression. */ - -1, /* ast_sequence doesn't convert to ir_expression. */ - }; - ir_rvalue *result = NULL; - ir_rvalue *op[3]; - const struct glsl_type *type; /* a temporary variable for switch cases */ - bool error_emitted = false; - YYLTYPE loc; - - loc = this->get_location(); - - switch (this->oper) { - case ast_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - result = do_assignment(instructions, state, - this->subexpressions[0]->non_lvalue_description, - op[0], op[1], false, - this->subexpressions[0]->get_location()); - error_emitted = result->type->is_error(); - break; - } - - case ast_plus: - op[0] = this->subexpressions[0]->hir(instructions, state); - - type = unary_arithmetic_result_type(op[0]->type, state, & loc); - - error_emitted = type->is_error(); - - result = op[0]; - break; - - case ast_neg: - op[0] = this->subexpressions[0]->hir(instructions, state); - - type = unary_arithmetic_result_type(op[0]->type, state, & loc); - - error_emitted = type->is_error(); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], NULL); - break; - - case ast_add: - case ast_sub: - case ast_mul: - case ast_div: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = arithmetic_result_type(op[0], op[1], - (this->oper == ast_mul), - state, & loc); - error_emitted = type->is_error(); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - break; - - case ast_mod: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); - - assert(operations[this->oper] == ir_binop_mod); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - error_emitted = type->is_error(); - break; - - case ast_lshift: - case ast_rshift: - if (state->language_version < 130) { - _mesa_glsl_error(&loc, state, "operator %s requires GLSL 1.30", - operator_string(this->oper)); - error_emitted = true; - } - - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - type = shift_result_type(op[0]->type, op[1]->type, this->oper, state, - &loc); - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - break; - - case ast_less: - case ast_greater: - case ast_lequal: - case ast_gequal: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = relational_result_type(op[0], op[1], state, & loc); - - /* The relational operators must either generate an error or result - * in a scalar boolean. See page 57 of the GLSL 1.50 spec. - */ - assert(type->is_error() - || ((type->base_type == GLSL_TYPE_BOOL) - && type->is_scalar())); - - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - error_emitted = type->is_error(); - break; - - case ast_nequal: - case ast_equal: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - /* From page 58 (page 64 of the PDF) of the GLSL 1.50 spec: - * - * "The equality operators equal (==), and not equal (!=) - * operate on all types. They result in a scalar Boolean. If - * the operand types do not match, then there must be a - * conversion from Section 4.1.10 "Implicit Conversions" - * applied to one operand that can make them match, in which - * case this conversion is done." - */ - if ((!apply_implicit_conversion(op[0]->type, op[1], state) - && !apply_implicit_conversion(op[1]->type, op[0], state)) - || (op[0]->type != op[1]->type)) { - _mesa_glsl_error(& loc, state, "operands of `%s' must have the same " - "type", (this->oper == ast_equal) ? "==" : "!="); - error_emitted = true; - } else if ((state->language_version <= 110) - && (op[0]->type->is_array() || op[1]->type->is_array())) { - _mesa_glsl_error(& loc, state, "array comparisons forbidden in " - "GLSL 1.10"); - error_emitted = true; - } - - if (error_emitted) { - result = new(ctx) ir_constant(false); - } else { - result = do_comparison(ctx, operations[this->oper], op[0], op[1]); - assert(result->type == glsl_type::bool_type); - } - break; - - case ast_bit_and: - case ast_bit_xor: - case ast_bit_or: - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - type = bit_logic_result_type(op[0]->type, op[1]->type, this->oper, - state, &loc); - result = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - break; - - case ast_bit_not: - op[0] = this->subexpressions[0]->hir(instructions, state); - - if (state->language_version < 130) { - _mesa_glsl_error(&loc, state, "bit-wise operations require GLSL 1.30"); - error_emitted = true; - } - - if (!op[0]->type->is_integer()) { - _mesa_glsl_error(&loc, state, "operand of `~' must be an integer"); - error_emitted = true; - } - - type = error_emitted ? glsl_type::error_type : op[0]->type; - result = new(ctx) ir_expression(ir_unop_bit_not, type, op[0], NULL); - break; - - case ast_logic_and: { - exec_list rhs_instructions; - op[0] = get_scalar_boolean_operand(instructions, state, this, 0, - "LHS", &error_emitted); - op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1, - "RHS", &error_emitted); - - ir_constant *op0_const = op[0]->constant_expression_value(); - if (op0_const) { - if (op0_const->value.b[0]) { - instructions->append_list(&rhs_instructions); - result = op[1]; - } else { - result = op0_const; - } - type = glsl_type::bool_type; - } else { - ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, - "and_tmp", - ir_var_temporary); - instructions->push_tail(tmp); - - ir_if *const stmt = new(ctx) ir_if(op[0]); - instructions->push_tail(stmt); - - stmt->then_instructions.append_list(&rhs_instructions); - ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new(ctx) ir_assignment(then_deref, op[1], NULL); - stmt->then_instructions.push_tail(then_assign); - - ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new(ctx) ir_assignment(else_deref, new(ctx) ir_constant(false), NULL); - stmt->else_instructions.push_tail(else_assign); - - result = new(ctx) ir_dereference_variable(tmp); - type = tmp->type; - } - break; - } - - case ast_logic_or: { - exec_list rhs_instructions; - op[0] = get_scalar_boolean_operand(instructions, state, this, 0, - "LHS", &error_emitted); - op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1, - "RHS", &error_emitted); - - ir_constant *op0_const = op[0]->constant_expression_value(); - if (op0_const) { - if (op0_const->value.b[0]) { - result = op0_const; - } else { - result = op[1]; - } - type = glsl_type::bool_type; - } else { - ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type, - "or_tmp", - ir_var_temporary); - instructions->push_tail(tmp); - - ir_if *const stmt = new(ctx) ir_if(op[0]); - instructions->push_tail(stmt); - - ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new(ctx) ir_assignment(then_deref, new(ctx) ir_constant(true), NULL); - stmt->then_instructions.push_tail(then_assign); - - stmt->else_instructions.append_list(&rhs_instructions); - ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new(ctx) ir_assignment(else_deref, op[1], NULL); - stmt->else_instructions.push_tail(else_assign); - - result = new(ctx) ir_dereference_variable(tmp); - type = tmp->type; - } - break; - } - - case ast_logic_xor: - /* From page 33 (page 39 of the PDF) of the GLSL 1.10 spec: - * - * "The logical binary operators and (&&), or ( | | ), and - * exclusive or (^^). They operate only on two Boolean - * expressions and result in a Boolean expression." - */ - op[0] = get_scalar_boolean_operand(instructions, state, this, 0, "LHS", - &error_emitted); - op[1] = get_scalar_boolean_operand(instructions, state, this, 1, "RHS", - &error_emitted); - - result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], op[1]); - break; - - case ast_logic_not: - op[0] = get_scalar_boolean_operand(instructions, state, this, 0, - "operand", &error_emitted); - - result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type, - op[0], NULL); - break; - - case ast_mul_assign: - case ast_div_assign: - case ast_add_assign: - case ast_sub_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = arithmetic_result_type(op[0], op[1], - (this->oper == ast_mul_assign), - state, & loc); - - ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - result = do_assignment(instructions, state, - this->subexpressions[0]->non_lvalue_description, - op[0]->clone(ctx, NULL), temp_rhs, false, - this->subexpressions[0]->get_location()); - error_emitted = (op[0]->type->is_error()); - - /* GLSL 1.10 does not allow array assignment. However, we don't have to - * explicitly test for this because none of the binary expression - * operators allow array operands either. - */ - - break; - } - - case ast_mod_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - - type = modulus_result_type(op[0]->type, op[1]->type, state, & loc); - - assert(operations[this->oper] == ir_binop_mod); - - ir_rvalue *temp_rhs; - temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - result = do_assignment(instructions, state, - this->subexpressions[0]->non_lvalue_description, - op[0]->clone(ctx, NULL), temp_rhs, false, - this->subexpressions[0]->get_location()); - error_emitted = type->is_error(); - break; - } - - case ast_ls_assign: - case ast_rs_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - type = shift_result_type(op[0]->type, op[1]->type, this->oper, state, - &loc); - ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], - type, op[0], op[1]); - result = do_assignment(instructions, state, - this->subexpressions[0]->non_lvalue_description, - op[0]->clone(ctx, NULL), temp_rhs, false, - this->subexpressions[0]->get_location()); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - break; - } - - case ast_and_assign: - case ast_xor_assign: - case ast_or_assign: { - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = this->subexpressions[1]->hir(instructions, state); - type = bit_logic_result_type(op[0]->type, op[1]->type, this->oper, - state, &loc); - ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], - type, op[0], op[1]); - result = do_assignment(instructions, state, - this->subexpressions[0]->non_lvalue_description, - op[0]->clone(ctx, NULL), temp_rhs, false, - this->subexpressions[0]->get_location()); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - break; - } - - case ast_conditional: { - /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: - * - * "The ternary selection operator (?:). It operates on three - * expressions (exp1 ? exp2 : exp3). This operator evaluates the - * first expression, which must result in a scalar Boolean." - */ - op[0] = get_scalar_boolean_operand(instructions, state, this, 0, - "condition", &error_emitted); - - /* The :? operator is implemented by generating an anonymous temporary - * followed by an if-statement. The last instruction in each branch of - * the if-statement assigns a value to the anonymous temporary. This - * temporary is the r-value of the expression. - */ - exec_list then_instructions; - exec_list else_instructions; - - op[1] = this->subexpressions[1]->hir(&then_instructions, state); - op[2] = this->subexpressions[2]->hir(&else_instructions, state); - - /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec: - * - * "The second and third expressions can be any type, as - * long their types match, or there is a conversion in - * Section 4.1.10 "Implicit Conversions" that can be applied - * to one of the expressions to make their types match. This - * resulting matching type is the type of the entire - * expression." - */ - if ((!apply_implicit_conversion(op[1]->type, op[2], state) - && !apply_implicit_conversion(op[2]->type, op[1], state)) - || (op[1]->type != op[2]->type)) { - YYLTYPE loc = this->subexpressions[1]->get_location(); - - _mesa_glsl_error(& loc, state, "Second and third operands of ?: " - "operator must have matching types."); - error_emitted = true; - type = glsl_type::error_type; - } else { - type = op[1]->type; - } - - /* From page 33 (page 39 of the PDF) of the GLSL 1.10 spec: - * - * "The second and third expressions must be the same type, but can - * be of any type other than an array." - */ - if ((state->language_version <= 110) && type->is_array()) { - _mesa_glsl_error(& loc, state, "Second and third operands of ?: " - "operator must not be arrays."); - error_emitted = true; - } - - ir_constant *cond_val = op[0]->constant_expression_value(); - ir_constant *then_val = op[1]->constant_expression_value(); - ir_constant *else_val = op[2]->constant_expression_value(); - - if (then_instructions.is_empty() - && else_instructions.is_empty() - && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) { - result = (cond_val->value.b[0]) ? then_val : else_val; - } else { - ir_variable *const tmp = - new(ctx) ir_variable(type, "conditional_tmp", ir_var_temporary); - instructions->push_tail(tmp); - - ir_if *const stmt = new(ctx) ir_if(op[0]); - instructions->push_tail(stmt); - - then_instructions.move_nodes_to(& stmt->then_instructions); - ir_dereference *const then_deref = - new(ctx) ir_dereference_variable(tmp); - ir_assignment *const then_assign = - new(ctx) ir_assignment(then_deref, op[1], NULL); - stmt->then_instructions.push_tail(then_assign); - - else_instructions.move_nodes_to(& stmt->else_instructions); - ir_dereference *const else_deref = - new(ctx) ir_dereference_variable(tmp); - ir_assignment *const else_assign = - new(ctx) ir_assignment(else_deref, op[2], NULL); - stmt->else_instructions.push_tail(else_assign); - - result = new(ctx) ir_dereference_variable(tmp); - } - break; - } - - case ast_pre_inc: - case ast_pre_dec: { - this->non_lvalue_description = (this->oper == ast_pre_inc) - ? "pre-increment operation" : "pre-decrement operation"; - - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = constant_one_for_inc_dec(ctx, op[0]->type); - - type = arithmetic_result_type(op[0], op[1], false, state, & loc); - - ir_rvalue *temp_rhs; - temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - result = do_assignment(instructions, state, - this->subexpressions[0]->non_lvalue_description, - op[0]->clone(ctx, NULL), temp_rhs, false, - this->subexpressions[0]->get_location()); - error_emitted = op[0]->type->is_error(); - break; - } - - case ast_post_inc: - case ast_post_dec: { - this->non_lvalue_description = (this->oper == ast_post_inc) - ? "post-increment operation" : "post-decrement operation"; - op[0] = this->subexpressions[0]->hir(instructions, state); - op[1] = constant_one_for_inc_dec(ctx, op[0]->type); - - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - type = arithmetic_result_type(op[0], op[1], false, state, & loc); - - ir_rvalue *temp_rhs; - temp_rhs = new(ctx) ir_expression(operations[this->oper], type, - op[0], op[1]); - - /* Get a temporary of a copy of the lvalue before it's modified. - * This may get thrown away later. - */ - result = get_lvalue_copy(instructions, op[0]->clone(ctx, NULL)); - - (void)do_assignment(instructions, state, - this->subexpressions[0]->non_lvalue_description, - op[0]->clone(ctx, NULL), temp_rhs, false, - this->subexpressions[0]->get_location()); - - error_emitted = op[0]->type->is_error(); - break; - } - - case ast_field_selection: - result = _mesa_ast_field_selection_to_hir(this, instructions, state); - break; - - case ast_array_index: { - YYLTYPE index_loc = subexpressions[1]->get_location(); - - op[0] = subexpressions[0]->hir(instructions, state); - op[1] = subexpressions[1]->hir(instructions, state); - - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - ir_rvalue *const array = op[0]; - - result = new(ctx) ir_dereference_array(op[0], op[1]); - - /* Do not use op[0] after this point. Use array. - */ - op[0] = NULL; - - - if (error_emitted) - break; - - if (!array->type->is_array() - && !array->type->is_matrix() - && !array->type->is_vector()) { - _mesa_glsl_error(& index_loc, state, - "cannot dereference non-array / non-matrix / " - "non-vector"); - error_emitted = true; - } - - if (!op[1]->type->is_integer()) { - _mesa_glsl_error(& index_loc, state, - "array index must be integer type"); - error_emitted = true; - } else if (!op[1]->type->is_scalar()) { - _mesa_glsl_error(& index_loc, state, - "array index must be scalar"); - error_emitted = true; - } - - /* If the array index is a constant expression and the array has a - * declared size, ensure that the access is in-bounds. If the array - * index is not a constant expression, ensure that the array has a - * declared size. - */ - ir_constant *const const_index = op[1]->constant_expression_value(); - if (const_index != NULL) { - const int idx = const_index->value.i[0]; - const char *type_name; - unsigned bound = 0; - - if (array->type->is_matrix()) { - type_name = "matrix"; - } else if (array->type->is_vector()) { - type_name = "vector"; - } else { - type_name = "array"; - } - - /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: - * - * "It is illegal to declare an array with a size, and then - * later (in the same shader) index the same array with an - * integral constant expression greater than or equal to the - * declared size. It is also illegal to index an array with a - * negative constant expression." - */ - if (array->type->is_matrix()) { - if (array->type->row_type()->vector_elements <= idx) { - bound = array->type->row_type()->vector_elements; - } - } else if (array->type->is_vector()) { - if (array->type->vector_elements <= idx) { - bound = array->type->vector_elements; - } - } else { - if ((array->type->array_size() > 0) - && (array->type->array_size() <= idx)) { - bound = array->type->array_size(); - } - } - - if (bound > 0) { - _mesa_glsl_error(& loc, state, "%s index must be < %u", - type_name, bound); - error_emitted = true; - } else if (idx < 0) { - _mesa_glsl_error(& loc, state, "%s index must be >= 0", - type_name); - error_emitted = true; - } - - if (array->type->is_array()) { - /* If the array is a variable dereference, it dereferences the - * whole array, by definition. Use this to get the variable. - * - * FINISHME: Should some methods for getting / setting / testing - * FINISHME: array access limits be added to ir_dereference? - */ - ir_variable *const v = array->whole_variable_referenced(); - if ((v != NULL) && (unsigned(idx) > v->max_array_access)) { - v->max_array_access = idx; - - /* Check whether this access will, as a side effect, implicitly - * cause the size of a built-in array to be too large. - */ - if (check_builtin_array_max_size(v->name, idx+1, loc, state)) - error_emitted = true; - } - } - } else if (array->type->array_size() == 0) { - _mesa_glsl_error(&loc, state, "unsized array index must be constant"); - } else { - if (array->type->is_array()) { - /* whole_variable_referenced can return NULL if the array is a - * member of a structure. In this case it is safe to not update - * the max_array_access field because it is never used for fields - * of structures. - */ - ir_variable *v = array->whole_variable_referenced(); - if (v != NULL) - v->max_array_access = array->type->array_size() - 1; - } - } - - /* From page 23 (29 of the PDF) of the GLSL 1.30 spec: - * - * "Samplers aggregated into arrays within a shader (using square - * brackets [ ]) can only be indexed with integral constant - * expressions [...]." - * - * This restriction was added in GLSL 1.30. Shaders using earlier version - * of the language should not be rejected by the compiler front-end for - * using this construct. This allows useful things such as using a loop - * counter as the index to an array of samplers. If the loop in unrolled, - * the code should compile correctly. Instead, emit a warning. - */ - if (array->type->is_array() && - array->type->element_type()->is_sampler() && - const_index == NULL) { - - if (state->language_version == 100) { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is optional in GLSL ES 1.00"); - } else if (state->language_version < 130) { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is forbidden in GLSL 1.30 and " - "later"); - } else { - _mesa_glsl_error(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is forbidden in GLSL 1.30 and " - "later"); - error_emitted = true; - } - } - - if (error_emitted) - result->type = glsl_type::error_type; - - break; - } - - case ast_function_call: - /* Should *NEVER* get here. ast_function_call should always be handled - * by ast_function_expression::hir. - */ - assert(0); - break; - - case ast_identifier: { - /* ast_identifier can appear several places in a full abstract syntax - * tree. This particular use must be at location specified in the grammar - * as 'variable_identifier'. - */ - ir_variable *var = - state->symbols->get_variable(this->primary_expression.identifier); - - result = new(ctx) ir_dereference_variable(var); - - if (var != NULL) { - var->used = true; - } else { - _mesa_glsl_error(& loc, state, "`%s' undeclared", - this->primary_expression.identifier); - - error_emitted = true; - } - break; - } - - case ast_int_constant: - result = new(ctx) ir_constant(this->primary_expression.int_constant); - break; - - case ast_uint_constant: - result = new(ctx) ir_constant(this->primary_expression.uint_constant); - break; - - case ast_float_constant: - result = new(ctx) ir_constant(this->primary_expression.float_constant); - break; - - case ast_bool_constant: - result = new(ctx) ir_constant(bool(this->primary_expression.bool_constant)); - break; - - case ast_sequence: { - /* It should not be possible to generate a sequence in the AST without - * any expressions in it. - */ - assert(!this->expressions.is_empty()); - - /* The r-value of a sequence is the last expression in the sequence. If - * the other expressions in the sequence do not have side-effects (and - * therefore add instructions to the instruction list), they get dropped - * on the floor. - */ - exec_node *previous_tail_pred = NULL; - YYLTYPE previous_operand_loc = loc; - - foreach_list_typed (ast_node, ast, link, &this->expressions) { - /* If one of the operands of comma operator does not generate any - * code, we want to emit a warning. At each pass through the loop - * previous_tail_pred will point to the last instruction in the - * stream *before* processing the previous operand. Naturally, - * instructions->tail_pred will point to the last instruction in the - * stream *after* processing the previous operand. If the two - * pointers match, then the previous operand had no effect. - * - * The warning behavior here differs slightly from GCC. GCC will - * only emit a warning if none of the left-hand operands have an - * effect. However, it will emit a warning for each. I believe that - * there are some cases in C (especially with GCC extensions) where - * it is useful to have an intermediate step in a sequence have no - * effect, but I don't think these cases exist in GLSL. Either way, - * it would be a giant hassle to replicate that behavior. - */ - if (previous_tail_pred == instructions->tail_pred) { - _mesa_glsl_warning(&previous_operand_loc, state, - "left-hand operand of comma expression has " - "no effect"); - } - - /* tail_pred is directly accessed instead of using the get_tail() - * method for performance reasons. get_tail() has extra code to - * return NULL when the list is empty. We don't care about that - * here, so using tail_pred directly is fine. - */ - previous_tail_pred = instructions->tail_pred; - previous_operand_loc = ast->get_location(); - - result = ast->hir(instructions, state); - } - - /* Any errors should have already been emitted in the loop above. - */ - error_emitted = true; - break; - } - } - type = NULL; /* use result->type, not type. */ - assert(result != NULL); - - if (result->type->is_error() && !error_emitted) - _mesa_glsl_error(& loc, state, "type mismatch"); - - return result; -} - - -ir_rvalue * -ast_expression_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - /* It is possible to have expression statements that don't have an - * expression. This is the solitary semicolon: - * - * for (i = 0; i < 5; i++) - * ; - * - * In this case the expression will be NULL. Test for NULL and don't do - * anything in that case. - */ - if (expression != NULL) - expression->hir(instructions, state); - - /* Statements do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_compound_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (new_scope) - state->symbols->push_scope(); - - foreach_list_typed (ast_node, ast, link, &this->statements) - ast->hir(instructions, state); - - if (new_scope) - state->symbols->pop_scope(); - - /* Compound statements do not have r-values. - */ - return NULL; -} - - -static const glsl_type * -process_array_type(YYLTYPE *loc, const glsl_type *base, ast_node *array_size, - struct _mesa_glsl_parse_state *state) -{ - unsigned length = 0; - - /* From page 19 (page 25) of the GLSL 1.20 spec: - * - * "Only one-dimensional arrays may be declared." - */ - if (base->is_array()) { - _mesa_glsl_error(loc, state, - "invalid array of `%s' (only one-dimensional arrays " - "may be declared)", - base->name); - return glsl_type::error_type; - } - - if (array_size != NULL) { - exec_list dummy_instructions; - ir_rvalue *const ir = array_size->hir(& dummy_instructions, state); - YYLTYPE loc = array_size->get_location(); - - if (ir != NULL) { - if (!ir->type->is_integer()) { - _mesa_glsl_error(& loc, state, "array size must be integer type"); - } else if (!ir->type->is_scalar()) { - _mesa_glsl_error(& loc, state, "array size must be scalar type"); - } else { - ir_constant *const size = ir->constant_expression_value(); - - if (size == NULL) { - _mesa_glsl_error(& loc, state, "array size must be a " - "constant valued expression"); - } else if (size->value.i[0] <= 0) { - _mesa_glsl_error(& loc, state, "array size must be > 0"); - } else { - assert(size->type == ir->type); - length = size->value.u[0]; - - /* If the array size is const (and we've verified that - * it is) then no instructions should have been emitted - * when we converted it to HIR. If they were emitted, - * then either the array size isn't const after all, or - * we are emitting unnecessary instructions. - */ - assert(dummy_instructions.is_empty()); - } - } - } - } - - return glsl_type::get_array_instance(base, length); -} - - -const glsl_type * -ast_type_specifier::glsl_type(const char **name, - struct _mesa_glsl_parse_state *state) const -{ - const struct glsl_type *type; - - type = state->symbols->get_type(this->type_name); - *name = this->type_name; - - if (this->is_array) { - YYLTYPE loc = this->get_location(); - type = process_array_type(&loc, type, this->array_size, state); - } - - return type; -} - - -static void -apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, - ir_variable *var, - struct _mesa_glsl_parse_state *state, - YYLTYPE *loc) -{ - if (qual->flags.q.invariant) { - if (var->used) { - _mesa_glsl_error(loc, state, - "variable `%s' may not be redeclared " - "`invariant' after being used", - var->name); - } else { - var->invariant = 1; - } - } - - if (qual->flags.q.constant || qual->flags.q.attribute - || qual->flags.q.uniform - || (qual->flags.q.varying && (state->target == fragment_shader))) - var->read_only = 1; - - if (qual->flags.q.centroid) - var->centroid = 1; - - if (qual->flags.q.attribute && state->target != vertex_shader) { - var->type = glsl_type::error_type; - _mesa_glsl_error(loc, state, - "`attribute' variables may not be declared in the " - "%s shader", - _mesa_glsl_shader_target_name(state->target)); - } - - /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec: - * - * "The varying qualifier can be used only with the data types - * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of - * these." - */ - if (qual->flags.q.varying) { - const glsl_type *non_array_type; - - if (var->type && var->type->is_array()) - non_array_type = var->type->fields.array; - else - non_array_type = var->type; - - if (non_array_type && non_array_type->base_type != GLSL_TYPE_FLOAT) { - var->type = glsl_type::error_type; - _mesa_glsl_error(loc, state, - "varying variables must be of base type float"); - } - } - - /* If there is no qualifier that changes the mode of the variable, leave - * the setting alone. - */ - if (qual->flags.q.in && qual->flags.q.out) - var->mode = ir_var_inout; - else if (qual->flags.q.attribute || qual->flags.q.in - || (qual->flags.q.varying && (state->target == fragment_shader))) - var->mode = ir_var_in; - else if (qual->flags.q.out - || (qual->flags.q.varying && (state->target == vertex_shader))) - var->mode = ir_var_out; - else if (qual->flags.q.uniform) - var->mode = ir_var_uniform; - - if (state->all_invariant && (state->current_function == NULL)) { - switch (state->target) { - case vertex_shader: - if (var->mode == ir_var_out) - var->invariant = true; - break; - case fragment_shader: - if (var->mode == ir_var_in) - var->invariant = true; - break; - } - } - - if (qual->flags.q.flat) - var->interpolation = INTERP_QUALIFIER_FLAT; - else if (qual->flags.q.noperspective) - var->interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; - else if (qual->flags.q.smooth) - var->interpolation = INTERP_QUALIFIER_SMOOTH; - else - var->interpolation = INTERP_QUALIFIER_NONE; - - if (var->interpolation != INTERP_QUALIFIER_NONE && - !(state->target == vertex_shader && var->mode == ir_var_out) && - !(state->target == fragment_shader && var->mode == ir_var_in)) { - const char *qual_string = NULL; - switch (var->interpolation) { - case INTERP_QUALIFIER_FLAT: - qual_string = "flat"; - break; - case INTERP_QUALIFIER_NOPERSPECTIVE: - qual_string = "noperspective"; - break; - case INTERP_QUALIFIER_SMOOTH: - qual_string = "smooth"; - break; - } - - _mesa_glsl_error(loc, state, - "interpolation qualifier `%s' can only be applied to " - "vertex shader outputs and fragment shader inputs.", - qual_string); - - } - - /* Layout qualifiers for gl_FragDepth, which are enabled by extension - * AMD_conservative_depth. - */ - int depth_layout_count = qual->flags.q.depth_any - + qual->flags.q.depth_greater - + qual->flags.q.depth_less - + qual->flags.q.depth_unchanged; - if (depth_layout_count > 0 - && !state->AMD_conservative_depth_enable - && !state->ARB_conservative_depth_enable) { - _mesa_glsl_error(loc, state, - "extension GL_AMD_conservative_depth or " - "GL_ARB_conservative_depth must be enabled " - "to use depth layout qualifiers"); - } else if (depth_layout_count > 0 - && strcmp(var->name, "gl_FragDepth") != 0) { - _mesa_glsl_error(loc, state, - "depth layout qualifiers can be applied only to " - "gl_FragDepth"); - } else if (depth_layout_count > 1 - && strcmp(var->name, "gl_FragDepth") == 0) { - _mesa_glsl_error(loc, state, - "at most one depth layout qualifier can be applied to " - "gl_FragDepth"); - } - if (qual->flags.q.depth_any) - var->depth_layout = ir_depth_layout_any; - else if (qual->flags.q.depth_greater) - var->depth_layout = ir_depth_layout_greater; - else if (qual->flags.q.depth_less) - var->depth_layout = ir_depth_layout_less; - else if (qual->flags.q.depth_unchanged) - var->depth_layout = ir_depth_layout_unchanged; - else - var->depth_layout = ir_depth_layout_none; -} - -/** - * Get the variable that is being redeclared by this declaration - * - * Semantic checks to verify the validity of the redeclaration are also - * performed. If semantic checks fail, compilation error will be emitted via - * \c _mesa_glsl_error, but a non-\c NULL pointer will still be returned. - * - * \returns - * A pointer to an existing variable in the current scope if the declaration - * is a redeclaration, \c NULL otherwise. - */ -ir_variable * -get_variable_being_redeclared(ir_variable *var, ast_declaration *decl, - struct _mesa_glsl_parse_state *state) -{ - /* Check if this declaration is actually a re-declaration, either to - * resize an array or add qualifiers to an existing variable. - * - * This is allowed for variables in the current scope, or when at - * global scope (for built-ins in the implicit outer scope). - */ - ir_variable *earlier = state->symbols->get_variable(decl->identifier); - if (earlier == NULL || - (state->current_function != NULL && - !state->symbols->name_declared_this_scope(decl->identifier))) { - return NULL; - } - - - YYLTYPE loc = decl->get_location(); - - /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec, - * - * "It is legal to declare an array without a size and then - * later re-declare the same name as an array of the same - * type and specify a size." - */ - if ((earlier->type->array_size() == 0) - && var->type->is_array() - && (var->type->element_type() == earlier->type->element_type())) { - /* FINISHME: This doesn't match the qualifiers on the two - * FINISHME: declarations. It's not 100% clear whether this is - * FINISHME: required or not. - */ - - const unsigned size = unsigned(var->type->array_size()); - check_builtin_array_max_size(var->name, size, loc, state); - if ((size > 0) && (size <= earlier->max_array_access)) { - _mesa_glsl_error(& loc, state, "array size must be > %u due to " - "previous access", - earlier->max_array_access); - } - - earlier->type = var->type; - delete var; - var = NULL; - } else if (state->language_version >= 130 - && (strcmp(var->name, "gl_FrontColor") == 0 - || strcmp(var->name, "gl_BackColor") == 0 - || strcmp(var->name, "gl_FrontSecondaryColor") == 0 - || strcmp(var->name, "gl_BackSecondaryColor") == 0 - || strcmp(var->name, "gl_Color") == 0 - || strcmp(var->name, "gl_SecondaryColor") == 0) - && earlier->type == var->type - && earlier->mode == var->mode) { - earlier->interpolation = var->interpolation; - - /* Layout qualifiers for gl_FragDepth. */ - } else if ((state->AMD_conservative_depth_enable || - state->ARB_conservative_depth_enable) - && strcmp(var->name, "gl_FragDepth") == 0 - && earlier->type == var->type - && earlier->mode == var->mode) { - - /** From the AMD_conservative_depth spec: - * Within any shader, the first redeclarations of gl_FragDepth - * must appear before any use of gl_FragDepth. - */ - if (earlier->used) { - _mesa_glsl_error(&loc, state, - "the first redeclaration of gl_FragDepth " - "must appear before any use of gl_FragDepth"); - } - - /* Prevent inconsistent redeclaration of depth layout qualifier. */ - if (earlier->depth_layout != ir_depth_layout_none - && earlier->depth_layout != var->depth_layout) { - _mesa_glsl_error(&loc, state, - "gl_FragDepth: depth layout is declared here " - "as '%s, but it was previously declared as " - "'%s'", - depth_layout_string(var->depth_layout), - depth_layout_string(earlier->depth_layout)); - } - - earlier->depth_layout = var->depth_layout; - - } else { - _mesa_glsl_error(&loc, state, "`%s' redeclared", decl->identifier); - } - - return earlier; -} - -/** - * Generate the IR for an initializer in a variable declaration - */ -ir_rvalue * -process_initializer(ir_variable *var, ast_declaration *decl, - ast_fully_specified_type *type, - exec_list *initializer_instructions, - struct _mesa_glsl_parse_state *state) -{ - ir_rvalue *result = NULL; - - YYLTYPE initializer_loc = decl->initializer->get_location(); - - /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec: - * - * "All uniform variables are read-only and are initialized either - * directly by an application via API commands, or indirectly by - * OpenGL." - */ - if ((state->language_version <= 110) - && (var->mode == ir_var_uniform)) { - _mesa_glsl_error(& initializer_loc, state, - "cannot initialize uniforms in GLSL 1.10"); - } - - if (var->type->is_sampler()) { - _mesa_glsl_error(& initializer_loc, state, - "cannot initialize samplers"); - } - - if ((var->mode == ir_var_in) && (state->current_function == NULL)) { - _mesa_glsl_error(& initializer_loc, state, - "cannot initialize %s shader input / %s", - _mesa_glsl_shader_target_name(state->target), - (state->target == vertex_shader) - ? "attribute" : "varying"); - } - - ir_dereference *const lhs = new(state) ir_dereference_variable(var); - ir_rvalue *rhs = decl->initializer->hir(initializer_instructions, - state); - - /* Calculate the constant value if this is a const or uniform - * declaration. - */ - if (type->qualifier.flags.q.constant - || type->qualifier.flags.q.uniform) { - ir_rvalue *new_rhs = validate_assignment(state, var->type, rhs, true); - if (new_rhs != NULL) { - rhs = new_rhs; - - ir_constant *constant_value = rhs->constant_expression_value(); - if (!constant_value) { - _mesa_glsl_error(& initializer_loc, state, - "initializer of %s variable `%s' must be a " - "constant expression", - (type->qualifier.flags.q.constant) - ? "const" : "uniform", - decl->identifier); - if (var->type->is_numeric()) { - /* Reduce cascading errors. */ - var->constant_value = ir_constant::zero(state, var->type); - } - } else { - rhs = constant_value; - var->constant_value = constant_value; - } - } else { - _mesa_glsl_error(&initializer_loc, state, - "initializer of type %s cannot be assigned to " - "variable of type %s", - rhs->type->name, var->type->name); - if (var->type->is_numeric()) { - /* Reduce cascading errors. */ - var->constant_value = ir_constant::zero(state, var->type); - } - } - } - - if (rhs && !rhs->type->is_error()) { - bool temp = var->read_only; - if (type->qualifier.flags.q.constant) - var->read_only = false; - - /* Never emit code to initialize a uniform. - */ - const glsl_type *initializer_type; - if (!type->qualifier.flags.q.uniform) { - result = do_assignment(initializer_instructions, state, - NULL, - lhs, rhs, true, - type->get_location()); - initializer_type = result->type; - } else - initializer_type = rhs->type; - - var->constant_initializer = rhs->constant_expression_value(); - var->has_initializer = true; - - /* If the declared variable is an unsized array, it must inherrit - * its full type from the initializer. A declaration such as - * - * uniform float a[] = float[](1.0, 2.0, 3.0, 3.0); - * - * becomes - * - * uniform float a[4] = float[](1.0, 2.0, 3.0, 3.0); - * - * The assignment generated in the if-statement (below) will also - * automatically handle this case for non-uniforms. - * - * If the declared variable is not an array, the types must - * already match exactly. As a result, the type assignment - * here can be done unconditionally. For non-uniforms the call - * to do_assignment can change the type of the initializer (via - * the implicit conversion rules). For uniforms the initializer - * must be a constant expression, and the type of that expression - * was validated above. - */ - var->type = initializer_type; - - var->read_only = temp; - } - - return result; -} - -ir_rvalue * -ast_declarator_list::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - const struct glsl_type *decl_type; - const char *type_name = NULL; - ir_rvalue *result = NULL; - YYLTYPE loc = this->get_location(); - - /* From page 46 (page 52 of the PDF) of the GLSL 1.50 spec: - * - * "To ensure that a particular output variable is invariant, it is - * necessary to use the invariant qualifier. It can either be used to - * qualify a previously declared variable as being invariant - * - * invariant gl_Position; // make existing gl_Position be invariant" - * - * In these cases the parser will set the 'invariant' flag in the declarator - * list, and the type will be NULL. - */ - if (this->invariant) { - assert(this->type == NULL); - - if (state->current_function != NULL) { - _mesa_glsl_error(& loc, state, - "All uses of `invariant' keyword must be at global " - "scope\n"); - } - - foreach_list_typed (ast_declaration, decl, link, &this->declarations) { - assert(!decl->is_array); - assert(decl->array_size == NULL); - assert(decl->initializer == NULL); - - ir_variable *const earlier = - state->symbols->get_variable(decl->identifier); - if (earlier == NULL) { - _mesa_glsl_error(& loc, state, - "Undeclared variable `%s' cannot be marked " - "invariant\n", decl->identifier); - } else if ((state->target == vertex_shader) - && (earlier->mode != ir_var_out)) { - _mesa_glsl_error(& loc, state, - "`%s' cannot be marked invariant, vertex shader " - "outputs only\n", decl->identifier); - } else if ((state->target == fragment_shader) - && (earlier->mode != ir_var_in)) { - _mesa_glsl_error(& loc, state, - "`%s' cannot be marked invariant, fragment shader " - "inputs only\n", decl->identifier); - } else if (earlier->used) { - _mesa_glsl_error(& loc, state, - "variable `%s' may not be redeclared " - "`invariant' after being used", - earlier->name); - } else { - earlier->invariant = true; - } - } - - /* Invariant redeclarations do not have r-values. - */ - return NULL; - } - - assert(this->type != NULL); - assert(!this->invariant); - - /* The type specifier may contain a structure definition. Process that - * before any of the variable declarations. - */ - (void) this->type->specifier->hir(instructions, state); - - decl_type = this->type->specifier->glsl_type(& type_name, state); - if (this->declarations.is_empty()) { - /* If there is no structure involved in the program text, there are two - * possible scenarios: - * - * - The program text contained something like 'vec4;'. This is an - * empty declaration. It is valid but weird. Emit a warning. - * - * - The program text contained something like 'S;' and 'S' is not the - * name of a known structure type. This is both invalid and weird. - * Emit an error. - * - * Note that if decl_type is NULL and there is a structure involved, - * there must have been some sort of error with the structure. In this - * case we assume that an error was already generated on this line of - * code for the structure. There is no need to generate an additional, - * confusing error. - */ - assert(this->type->specifier->structure == NULL || decl_type != NULL - || state->error); - if (this->type->specifier->structure == NULL) { - if (decl_type != NULL) { - _mesa_glsl_warning(&loc, state, "empty declaration"); - } else { - _mesa_glsl_error(&loc, state, - "invalid type `%s' in empty declaration", - type_name); - } - } - } - - foreach_list_typed (ast_declaration, decl, link, &this->declarations) { - const struct glsl_type *var_type; - ir_variable *var; - - /* FINISHME: Emit a warning if a variable declaration shadows a - * FINISHME: declaration at a higher scope. - */ - - if ((decl_type == NULL) || decl_type->is_void()) { - if (type_name != NULL) { - _mesa_glsl_error(& loc, state, - "invalid type `%s' in declaration of `%s'", - type_name, decl->identifier); - } else { - _mesa_glsl_error(& loc, state, - "invalid type in declaration of `%s'", - decl->identifier); - } - continue; - } - - if (decl->is_array) { - var_type = process_array_type(&loc, decl_type, decl->array_size, - state); - if (var_type->is_error()) - continue; - } else { - var_type = decl_type; - } - - var = new(ctx) ir_variable(var_type, decl->identifier, ir_var_auto); - - /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification; - * - * "Global variables can only use the qualifiers const, - * attribute, uni form, or varying. Only one may be - * specified. - * - * Local variables can only use the qualifier const." - * - * This is relaxed in GLSL 1.30. It is also relaxed by any extension - * that adds the 'layout' keyword. - */ - if (state->language_version < 130) { - if (this->type->qualifier.flags.q.out) { - _mesa_glsl_error(& loc, state, - "`out' qualifier in declaration of `%s' " - "only valid for function parameters in %s.", - decl->identifier, state->version_string); - } - if (this->type->qualifier.flags.q.in) { - _mesa_glsl_error(& loc, state, - "`in' qualifier in declaration of `%s' " - "only valid for function parameters in %s.", - decl->identifier, state->version_string); - } - /* FINISHME: Test for other invalid qualifiers. */ - } - - apply_type_qualifier_to_variable(& this->type->qualifier, var, state, - & loc); - - if (this->type->qualifier.flags.q.invariant) { - if ((state->target == vertex_shader) && !(var->mode == ir_var_out || - var->mode == ir_var_inout)) { - /* FINISHME: Note that this doesn't work for invariant on - * a function signature outval - */ - _mesa_glsl_error(& loc, state, - "`%s' cannot be marked invariant, vertex shader " - "outputs only\n", var->name); - } else if ((state->target == fragment_shader) && - !(var->mode == ir_var_in || var->mode == ir_var_inout)) { - /* FINISHME: Note that this doesn't work for invariant on - * a function signature inval - */ - _mesa_glsl_error(& loc, state, - "`%s' cannot be marked invariant, fragment shader " - "inputs only\n", var->name); - } - } - - if (state->current_function != NULL) { - const char *mode = NULL; - const char *extra = ""; - - /* There is no need to check for 'inout' here because the parser will - * only allow that in function parameter lists. - */ - if (this->type->qualifier.flags.q.attribute) { - mode = "attribute"; - } else if (this->type->qualifier.flags.q.uniform) { - mode = "uniform"; - } else if (this->type->qualifier.flags.q.varying) { - mode = "varying"; - } else if (this->type->qualifier.flags.q.in) { - mode = "in"; - extra = " or in function parameter list"; - } else if (this->type->qualifier.flags.q.out) { - mode = "out"; - extra = " or in function parameter list"; - } - - if (mode) { - _mesa_glsl_error(& loc, state, - "%s variable `%s' must be declared at " - "global scope%s", - mode, var->name, extra); - } - } else if (var->mode == ir_var_in) { - var->read_only = true; - - if (state->target == vertex_shader) { - bool error_emitted = false; - - /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: - * - * "Vertex shader inputs can only be float, floating-point - * vectors, matrices, signed and unsigned integers and integer - * vectors. Vertex shader inputs can also form arrays of these - * types, but not structures." - * - * From page 31 (page 27 of the PDF) of the GLSL 1.30 spec: - * - * "Vertex shader inputs can only be float, floating-point - * vectors, matrices, signed and unsigned integers and integer - * vectors. They cannot be arrays or structures." - * - * From page 23 (page 29 of the PDF) of the GLSL 1.20 spec: - * - * "The attribute qualifier can be used only with float, - * floating-point vectors, and matrices. Attribute variables - * cannot be declared as arrays or structures." - */ - const glsl_type *check_type = var->type->is_array() - ? var->type->fields.array : var->type; - - switch (check_type->base_type) { - case GLSL_TYPE_FLOAT: - break; - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - if (state->language_version > 120) - break; - /* FALLTHROUGH */ - default: - _mesa_glsl_error(& loc, state, - "vertex shader input / attribute cannot have " - "type %s`%s'", - var->type->is_array() ? "array of " : "", - check_type->name); - error_emitted = true; - } - - if (!error_emitted && (state->language_version <= 130) - && var->type->is_array()) { - _mesa_glsl_error(& loc, state, - "vertex shader input / attribute cannot have " - "array type"); - error_emitted = true; - } - } - } - - /* Integer vertex outputs must be qualified with 'flat'. - * - * From section 4.3.6 of the GLSL 1.30 spec: - * "If a vertex output is a signed or unsigned integer or integer - * vector, then it must be qualified with the interpolation qualifier - * flat." - */ - if (state->language_version >= 130 - && state->target == vertex_shader - && state->current_function == NULL - && var->type->is_integer() - && var->mode == ir_var_out - && var->interpolation != INTERP_QUALIFIER_FLAT) { - - _mesa_glsl_error(&loc, state, "If a vertex output is an integer, " - "then it must be qualified with 'flat'"); - } - - - /* Interpolation qualifiers cannot be applied to 'centroid' and - * 'centroid varying'. - * - * From page 29 (page 35 of the PDF) of the GLSL 1.30 spec: - * "interpolation qualifiers may only precede the qualifiers in, - * centroid in, out, or centroid out in a declaration. They do not apply - * to the deprecated storage qualifiers varying or centroid varying." - */ - if (state->language_version >= 130 - && this->type->qualifier.has_interpolation() - && this->type->qualifier.flags.q.varying) { - - const char *i = this->type->qualifier.interpolation_string(); - assert(i != NULL); - const char *s; - if (this->type->qualifier.flags.q.centroid) - s = "centroid varying"; - else - s = "varying"; - - _mesa_glsl_error(&loc, state, - "qualifier '%s' cannot be applied to the " - "deprecated storage qualifier '%s'", i, s); - } - - - /* Interpolation qualifiers can only apply to vertex shader outputs and - * fragment shader inputs. - * - * From page 29 (page 35 of the PDF) of the GLSL 1.30 spec: - * "Outputs from a vertex shader (out) and inputs to a fragment - * shader (in) can be further qualified with one or more of these - * interpolation qualifiers" - */ - if (state->language_version >= 130 - && this->type->qualifier.has_interpolation()) { - - const char *i = this->type->qualifier.interpolation_string(); - assert(i != NULL); - - switch (state->target) { - case vertex_shader: - if (this->type->qualifier.flags.q.in) { - _mesa_glsl_error(&loc, state, - "qualifier '%s' cannot be applied to vertex " - "shader inputs", i); - } - break; - case fragment_shader: - if (this->type->qualifier.flags.q.out) { - _mesa_glsl_error(&loc, state, - "qualifier '%s' cannot be applied to fragment " - "shader outputs", i); - } - break; - default: - assert(0); - } - } - - - /* From section 4.3.4 of the GLSL 1.30 spec: - * "It is an error to use centroid in in a vertex shader." - */ - if (state->language_version >= 130 - && this->type->qualifier.flags.q.centroid - && this->type->qualifier.flags.q.in - && state->target == vertex_shader) { - - _mesa_glsl_error(&loc, state, - "'centroid in' cannot be used in a vertex shader"); - } - - - /* Precision qualifiers exists only in GLSL versions 1.00 and >= 1.30. - */ - if (this->type->specifier->precision != ast_precision_none - && state->language_version != 100 - && state->language_version < 130) { - - _mesa_glsl_error(&loc, state, - "precision qualifiers are supported only in GLSL ES " - "1.00, and GLSL 1.30 and later"); - } - - - /* Precision qualifiers only apply to floating point and integer types. - * - * From section 4.5.2 of the GLSL 1.30 spec: - * "Any floating point or any integer declaration can have the type - * preceded by one of these precision qualifiers [...] Literal - * constants do not have precision qualifiers. Neither do Boolean - * variables. - * - * In GLSL ES, sampler types are also allowed. - * - * From page 87 of the GLSL ES spec: - * "RESOLUTION: Allow sampler types to take a precision qualifier." - */ - if (this->type->specifier->precision != ast_precision_none - && !var->type->is_float() - && !var->type->is_integer() - && !(var->type->is_array() - && (var->type->fields.array->is_float() - || var->type->fields.array->is_integer()))) { - - _mesa_glsl_error(&loc, state, - "precision qualifiers apply only to floating point" - "and integer types"); - } - - /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: - * - * "[Sampler types] can only be declared as function - * parameters or uniform variables (see Section 4.3.5 - * "Uniform")". - */ - if (var_type->contains_sampler() && - !this->type->qualifier.flags.q.uniform) { - _mesa_glsl_error(&loc, state, "samplers must be declared uniform"); - } - - /* Process the initializer and add its instructions to a temporary - * list. This list will be added to the instruction stream (below) after - * the declaration is added. This is done because in some cases (such as - * redeclarations) the declaration may not actually be added to the - * instruction stream. - */ - exec_list initializer_instructions; - ir_variable *earlier = get_variable_being_redeclared(var, decl, state); - - if (decl->initializer != NULL) { - result = process_initializer((earlier == NULL) ? var : earlier, - decl, this->type, - &initializer_instructions, state); - } - - /* From page 23 (page 29 of the PDF) of the GLSL 1.10 spec: - * - * "It is an error to write to a const variable outside of - * its declaration, so they must be initialized when - * declared." - */ - if (this->type->qualifier.flags.q.constant && decl->initializer == NULL) { - _mesa_glsl_error(& loc, state, - "const declaration of `%s' must be initialized", - decl->identifier); - } - - /* If the declaration is not a redeclaration, there are a few additional - * semantic checks that must be applied. In addition, variable that was - * created for the declaration should be added to the IR stream. - */ - if (earlier == NULL) { - /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, - * - * "Identifiers starting with "gl_" are reserved for use by - * OpenGL, and may not be declared in a shader as either a - * variable or a function." - */ - if (strncmp(decl->identifier, "gl_", 3) == 0) - _mesa_glsl_error(& loc, state, - "identifier `%s' uses reserved `gl_' prefix", - decl->identifier); - else if (strstr(decl->identifier, "__")) { - /* From page 14 (page 20 of the PDF) of the GLSL 1.10 - * spec: - * - * "In addition, all identifiers containing two - * consecutive underscores (__) are reserved as - * possible future keywords." - */ - _mesa_glsl_error(& loc, state, - "identifier `%s' uses reserved `__' string", - decl->identifier); - } - - /* Add the variable to the symbol table. Note that the initializer's - * IR was already processed earlier (though it hasn't been emitted - * yet), without the variable in scope. - * - * This differs from most C-like languages, but it follows the GLSL - * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 - * spec: - * - * "Within a declaration, the scope of a name starts immediately - * after the initializer if present or immediately after the name - * being declared if not." - */ - if (!state->symbols->add_variable(var)) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(&loc, state, "name `%s' already taken in the " - "current scope", decl->identifier); - continue; - } - - /* Push the variable declaration to the top. It means that all the - * variable declarations will appear in a funny last-to-first order, - * but otherwise we run into trouble if a function is prototyped, a - * global var is decled, then the function is defined with usage of - * the global var. See glslparsertest's CorrectModule.frag. - */ - instructions->push_head(var); - } - - instructions->append_list(&initializer_instructions); - } - - - /* Generally, variable declarations do not have r-values. However, - * one is used for the declaration in - * - * while (bool b = some_condition()) { - * ... - * } - * - * so we return the rvalue from the last seen declaration here. - */ - return result; -} - - -ir_rvalue * -ast_parameter_declarator::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - const struct glsl_type *type; - const char *name = NULL; - YYLTYPE loc = this->get_location(); - - type = this->type->specifier->glsl_type(& name, state); - - if (type == NULL) { - if (name != NULL) { - _mesa_glsl_error(& loc, state, - "invalid type `%s' in declaration of `%s'", - name, this->identifier); - } else { - _mesa_glsl_error(& loc, state, - "invalid type in declaration of `%s'", - this->identifier); - } - - type = glsl_type::error_type; - } - - /* From page 62 (page 68 of the PDF) of the GLSL 1.50 spec: - * - * "Functions that accept no input arguments need not use void in the - * argument list because prototypes (or definitions) are required and - * therefore there is no ambiguity when an empty argument list "( )" is - * declared. The idiom "(void)" as a parameter list is provided for - * convenience." - * - * Placing this check here prevents a void parameter being set up - * for a function, which avoids tripping up checks for main taking - * parameters and lookups of an unnamed symbol. - */ - if (type->is_void()) { - if (this->identifier != NULL) - _mesa_glsl_error(& loc, state, - "named parameter cannot have type `void'"); - - is_void = true; - return NULL; - } - - if (formal_parameter && (this->identifier == NULL)) { - _mesa_glsl_error(& loc, state, "formal parameter lacks a name"); - return NULL; - } - - /* This only handles "vec4 foo[..]". The earlier specifier->glsl_type(...) - * call already handled the "vec4[..] foo" case. - */ - if (this->is_array) { - type = process_array_type(&loc, type, this->array_size, state); - } - - if (!type->is_error() && type->array_size() == 0) { - _mesa_glsl_error(&loc, state, "arrays passed as parameters must have " - "a declared size."); - type = glsl_type::error_type; - } - - is_void = false; - ir_variable *var = new(ctx) ir_variable(type, this->identifier, ir_var_in); - - /* Apply any specified qualifiers to the parameter declaration. Note that - * for function parameters the default mode is 'in'. - */ - apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc); - - /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: - * - * "Samplers cannot be treated as l-values; hence cannot be used - * as out or inout function parameters, nor can they be assigned - * into." - */ - if ((var->mode == ir_var_inout || var->mode == ir_var_out) - && type->contains_sampler()) { - _mesa_glsl_error(&loc, state, "out and inout parameters cannot contain samplers"); - type = glsl_type::error_type; - } - - /* From page 39 (page 45 of the PDF) of the GLSL 1.10 spec: - * - * "When calling a function, expressions that do not evaluate to - * l-values cannot be passed to parameters declared as out or inout." - * - * From page 32 (page 38 of the PDF) of the GLSL 1.10 spec: - * - * "Other binary or unary expressions, non-dereferenced arrays, - * function names, swizzles with repeated fields, and constants - * cannot be l-values." - * - * So for GLSL 1.10, passing an array as an out or inout parameter is not - * allowed. This restriction is removed in GLSL 1.20, and in GLSL ES. - */ - if ((var->mode == ir_var_inout || var->mode == ir_var_out) - && type->is_array() && state->language_version == 110) { - _mesa_glsl_error(&loc, state, "Arrays cannot be out or inout parameters in GLSL 1.10"); - type = glsl_type::error_type; - } - - instructions->push_tail(var); - - /* Parameter declarations do not have r-values. - */ - return NULL; -} - - -void -ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters, - bool formal, - exec_list *ir_parameters, - _mesa_glsl_parse_state *state) -{ - ast_parameter_declarator *void_param = NULL; - unsigned count = 0; - - foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) { - param->formal_parameter = formal; - param->hir(ir_parameters, state); - - if (param->is_void) - void_param = param; - - count++; - } - - if ((void_param != NULL) && (count > 1)) { - YYLTYPE loc = void_param->get_location(); - - _mesa_glsl_error(& loc, state, - "`void' parameter must be only parameter"); - } -} - - -void -emit_function(_mesa_glsl_parse_state *state, ir_function *f) -{ - /* IR invariants disallow function declarations or definitions - * nested within other function definitions. But there is no - * requirement about the relative order of function declarations - * and definitions with respect to one another. So simply insert - * the new ir_function block at the end of the toplevel instruction - * list. - */ - state->toplevel_ir->push_tail(f); -} - - -ir_rvalue * -ast_function::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - ir_function *f = NULL; - ir_function_signature *sig = NULL; - exec_list hir_parameters; - - const char *const name = identifier; - - /* New functions are always added to the top-level IR instruction stream, - * so this instruction list pointer is ignored. See also emit_function - * (called below). - */ - (void) instructions; - - /* From page 21 (page 27 of the PDF) of the GLSL 1.20 spec, - * - * "Function declarations (prototypes) cannot occur inside of functions; - * they must be at global scope, or for the built-in functions, outside - * the global scope." - * - * From page 27 (page 33 of the PDF) of the GLSL ES 1.00.16 spec, - * - * "User defined functions may only be defined within the global scope." - * - * Note that this language does not appear in GLSL 1.10. - */ - if ((state->current_function != NULL) && (state->language_version != 110)) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(&loc, state, - "declaration of function `%s' not allowed within " - "function body", name); - } - - /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec, - * - * "Identifiers starting with "gl_" are reserved for use by - * OpenGL, and may not be declared in a shader as either a - * variable or a function." - */ - if (strncmp(name, "gl_", 3) == 0) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(&loc, state, - "identifier `%s' uses reserved `gl_' prefix", name); - } - - /* Convert the list of function parameters to HIR now so that they can be - * used below to compare this function's signature with previously seen - * signatures for functions with the same name. - */ - ast_parameter_declarator::parameters_to_hir(& this->parameters, - is_definition, - & hir_parameters, state); - - const char *return_type_name; - const glsl_type *return_type = - this->return_type->specifier->glsl_type(& return_type_name, state); - - if (!return_type) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(&loc, state, - "function `%s' has undeclared return type `%s'", - name, return_type_name); - return_type = glsl_type::error_type; - } - - /* From page 56 (page 62 of the PDF) of the GLSL 1.30 spec: - * "No qualifier is allowed on the return type of a function." - */ - if (this->return_type->has_qualifiers()) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(& loc, state, - "function `%s' return type has qualifiers", name); - } - - /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: - * - * "[Sampler types] can only be declared as function parameters - * or uniform variables (see Section 4.3.5 "Uniform")". - */ - if (return_type->contains_sampler()) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(&loc, state, - "function `%s' return type can't contain a sampler", - name); - } - - /* Verify that this function's signature either doesn't match a previously - * seen signature for a function with the same name, or, if a match is found, - * that the previously seen signature does not have an associated definition. - */ - f = state->symbols->get_function(name); - if (f != NULL && f->has_user_signature()) { - sig = f->exact_matching_signature(&hir_parameters); - if (sig != NULL) { - const char *badvar = sig->qualifiers_match(&hir_parameters); - if (badvar != NULL) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' " - "qualifiers don't match prototype", name, badvar); - } - - if (sig->return_type != return_type) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(&loc, state, "function `%s' return type doesn't " - "match prototype", name); - } - - if (is_definition && sig->is_defined) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "function `%s' redefined", name); - } - } - } else { - f = new(ctx) ir_function(name); - if (!state->symbols->add_function(f)) { - /* This function name shadows a non-function use of the same name. */ - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(&loc, state, "function name `%s' conflicts with " - "non-function", name); - return NULL; - } - - emit_function(state, f); - } - - /* Verify the return type of main() */ - if (strcmp(name, "main") == 0) { - if (! return_type->is_void()) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "main() must return void"); - } - - if (!hir_parameters.is_empty()) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "main() must not take any parameters"); - } - } - - /* Finish storing the information about this new function in its signature. - */ - if (sig == NULL) { - sig = new(ctx) ir_function_signature(return_type); - f->add_signature(sig); - } - - sig->replace_parameters(&hir_parameters); - signature = sig; - - /* Function declarations (prototypes) do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_function_definition::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - prototype->is_definition = true; - prototype->hir(instructions, state); - - ir_function_signature *signature = prototype->signature; - if (signature == NULL) - return NULL; - - assert(state->current_function == NULL); - state->current_function = signature; - state->found_return = false; - - /* Duplicate parameters declared in the prototype as concrete variables. - * Add these to the symbol table. - */ - state->symbols->push_scope(); - foreach_iter(exec_list_iterator, iter, signature->parameters) { - ir_variable *const var = ((ir_instruction *) iter.get())->as_variable(); - - assert(var != NULL); - - /* The only way a parameter would "exist" is if two parameters have - * the same name. - */ - if (state->symbols->name_declared_this_scope(var->name)) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "parameter `%s' redeclared", var->name); - } else { - state->symbols->add_variable(var); - } - } - - /* Convert the body of the function to HIR. */ - this->body->hir(&signature->body, state); - signature->is_defined = true; - - state->symbols->pop_scope(); - - assert(state->current_function == signature); - state->current_function = NULL; - - if (!signature->return_type->is_void() && !state->found_return) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(& loc, state, "function `%s' has non-void return type " - "%s, but no return statement", - signature->function_name(), - signature->return_type->name); - } - - /* Function definitions do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_jump_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - - switch (mode) { - case ast_return: { - ir_return *inst; - assert(state->current_function); - - if (opt_return_value) { - ir_rvalue *const ret = opt_return_value->hir(instructions, state); - - /* The value of the return type can be NULL if the shader says - * 'return foo();' and foo() is a function that returns void. - * - * NOTE: The GLSL spec doesn't say that this is an error. The type - * of the return value is void. If the return type of the function is - * also void, then this should compile without error. Seriously. - */ - const glsl_type *const ret_type = - (ret == NULL) ? glsl_type::void_type : ret->type; - - /* Implicit conversions are not allowed for return values. */ - if (state->current_function->return_type != ret_type) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`return' with wrong type %s, in function `%s' " - "returning %s", - ret_type->name, - state->current_function->function_name(), - state->current_function->return_type->name); - } - - inst = new(ctx) ir_return(ret); - } else { - if (state->current_function->return_type->base_type != - GLSL_TYPE_VOID) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`return' with no value, in function %s returning " - "non-void", - state->current_function->function_name()); - } - inst = new(ctx) ir_return; - } - - state->found_return = true; - instructions->push_tail(inst); - break; - } - - case ast_discard: - if (state->target != fragment_shader) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`discard' may only appear in a fragment shader"); - } - instructions->push_tail(new(ctx) ir_discard); - break; - - case ast_break: - case ast_continue: - if (mode == ast_continue && - state->loop_nesting_ast == NULL) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "continue may only appear in a loop"); - } else if (mode == ast_break && - state->loop_nesting_ast == NULL && - state->switch_state.switch_nesting_ast == NULL) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "break may only appear in a loop or a switch"); - } else { - /* For a loop, inline the for loop expression again, - * since we don't know where near the end of - * the loop body the normal copy of it - * is going to be placed. - */ - if (state->loop_nesting_ast != NULL && - mode == ast_continue && - state->loop_nesting_ast->rest_expression) { - state->loop_nesting_ast->rest_expression->hir(instructions, - state); - } - - if (state->switch_state.is_switch_innermost && - mode == ast_break) { - /* Force break out of switch by setting is_break switch state. - */ - ir_variable *const is_break_var = state->switch_state.is_break_var; - ir_dereference_variable *const deref_is_break_var = - new(ctx) ir_dereference_variable(is_break_var); - ir_constant *const true_val = new(ctx) ir_constant(true); - ir_assignment *const set_break_var = - new(ctx) ir_assignment(deref_is_break_var, - true_val, - NULL); - - instructions->push_tail(set_break_var); - } - else { - ir_loop_jump *const jump = - new(ctx) ir_loop_jump((mode == ast_break) - ? ir_loop_jump::jump_break - : ir_loop_jump::jump_continue); - instructions->push_tail(jump); - } - } - - break; - } - - /* Jump instructions do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_selection_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - - ir_rvalue *const condition = this->condition->hir(instructions, state); - - /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec: - * - * "Any expression whose type evaluates to a Boolean can be used as the - * conditional expression bool-expression. Vector types are not accepted - * as the expression to if." - * - * The checks are separated so that higher quality diagnostics can be - * generated for cases where both rules are violated. - */ - if (!condition->type->is_boolean() || !condition->type->is_scalar()) { - YYLTYPE loc = this->condition->get_location(); - - _mesa_glsl_error(& loc, state, "if-statement condition must be scalar " - "boolean"); - } - - ir_if *const stmt = new(ctx) ir_if(condition); - - if (then_statement != NULL) { - state->symbols->push_scope(); - then_statement->hir(& stmt->then_instructions, state); - state->symbols->pop_scope(); - } - - if (else_statement != NULL) { - state->symbols->push_scope(); - else_statement->hir(& stmt->else_instructions, state); - state->symbols->pop_scope(); - } - - instructions->push_tail(stmt); - - /* if-statements do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_switch_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - - ir_rvalue *const test_expression = - this->test_expression->hir(instructions, state); - - /* From page 66 (page 55 of the PDF) of the GLSL 1.50 spec: - * - * "The type of init-expression in a switch statement must be a - * scalar integer." - */ - if (!test_expression->type->is_scalar() || - !test_expression->type->is_integer()) { - YYLTYPE loc = this->test_expression->get_location(); - - _mesa_glsl_error(& loc, - state, - "switch-statement expression must be scalar " - "integer"); - } - - /* Track the switch-statement nesting in a stack-like manner. - */ - struct glsl_switch_state saved = state->switch_state; - - state->switch_state.is_switch_innermost = true; - state->switch_state.switch_nesting_ast = this; - state->switch_state.labels_ht = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - state->switch_state.previous_default = NULL; - - /* Initalize is_fallthru state to false. - */ - ir_rvalue *const is_fallthru_val = new (ctx) ir_constant(false); - state->switch_state.is_fallthru_var = - new(ctx) ir_variable(glsl_type::bool_type, - "switch_is_fallthru_tmp", - ir_var_temporary); - instructions->push_tail(state->switch_state.is_fallthru_var); - - ir_dereference_variable *deref_is_fallthru_var = - new(ctx) ir_dereference_variable(state->switch_state.is_fallthru_var); - instructions->push_tail(new(ctx) ir_assignment(deref_is_fallthru_var, - is_fallthru_val, - NULL)); - - /* Initalize is_break state to false. - */ - ir_rvalue *const is_break_val = new (ctx) ir_constant(false); - state->switch_state.is_break_var = new(ctx) ir_variable(glsl_type::bool_type, - "switch_is_break_tmp", - ir_var_temporary); - instructions->push_tail(state->switch_state.is_break_var); - - ir_dereference_variable *deref_is_break_var = - new(ctx) ir_dereference_variable(state->switch_state.is_break_var); - instructions->push_tail(new(ctx) ir_assignment(deref_is_break_var, - is_break_val, - NULL)); - - /* Cache test expression. - */ - test_to_hir(instructions, state); - - /* Emit code for body of switch stmt. - */ - body->hir(instructions, state); - - hash_table_dtor(state->switch_state.labels_ht); - - state->switch_state = saved; - - /* Switch statements do not have r-values. */ - return NULL; -} - - -void -ast_switch_statement::test_to_hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - - /* Cache value of test expression. */ - ir_rvalue *const test_val = - test_expression->hir(instructions, - state); - - state->switch_state.test_var = new(ctx) ir_variable(test_val->type, - "switch_test_tmp", - ir_var_temporary); - ir_dereference_variable *deref_test_var = - new(ctx) ir_dereference_variable(state->switch_state.test_var); - - instructions->push_tail(state->switch_state.test_var); - instructions->push_tail(new(ctx) ir_assignment(deref_test_var, test_val, - NULL)); -} - - -ir_rvalue * -ast_switch_body::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (stmts != NULL) - stmts->hir(instructions, state); - - /* Switch bodies do not have r-values. */ - return NULL; -} - -ir_rvalue * -ast_case_statement_list::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - foreach_list_typed (ast_case_statement, case_stmt, link, & this->cases) - case_stmt->hir(instructions, state); - - /* Case statements do not have r-values. */ - return NULL; -} - -ir_rvalue * -ast_case_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - labels->hir(instructions, state); - - /* Conditionally set fallthru state based on break state. */ - ir_constant *const false_val = new(state) ir_constant(false); - ir_dereference_variable *const deref_is_fallthru_var = - new(state) ir_dereference_variable(state->switch_state.is_fallthru_var); - ir_dereference_variable *const deref_is_break_var = - new(state) ir_dereference_variable(state->switch_state.is_break_var); - ir_assignment *const reset_fallthru_on_break = - new(state) ir_assignment(deref_is_fallthru_var, - false_val, - deref_is_break_var); - instructions->push_tail(reset_fallthru_on_break); - - /* Guard case statements depending on fallthru state. */ - ir_dereference_variable *const deref_fallthru_guard = - new(state) ir_dereference_variable(state->switch_state.is_fallthru_var); - ir_if *const test_fallthru = new(state) ir_if(deref_fallthru_guard); - - foreach_list_typed (ast_node, stmt, link, & this->stmts) - stmt->hir(& test_fallthru->then_instructions, state); - - instructions->push_tail(test_fallthru); - - /* Case statements do not have r-values. */ - return NULL; -} - - -ir_rvalue * -ast_case_label_list::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - foreach_list_typed (ast_case_label, label, link, & this->labels) - label->hir(instructions, state); - - /* Case labels do not have r-values. */ - return NULL; -} - -ir_rvalue * -ast_case_label::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - - ir_dereference_variable *deref_fallthru_var = - new(ctx) ir_dereference_variable(state->switch_state.is_fallthru_var); - - ir_rvalue *const true_val = new(ctx) ir_constant(true); - - /* If not default case, ... */ - if (this->test_value != NULL) { - /* Conditionally set fallthru state based on - * comparison of cached test expression value to case label. - */ - ir_rvalue *const label_rval = this->test_value->hir(instructions, state); - ir_constant *label_const = label_rval->constant_expression_value(); - - if (!label_const) { - YYLTYPE loc = this->test_value->get_location(); - - _mesa_glsl_error(& loc, state, - "switch statement case label must be a " - "constant expression"); - - /* Stuff a dummy value in to allow processing to continue. */ - label_const = new(ctx) ir_constant(0); - } else { - ast_expression *previous_label = (ast_expression *) - hash_table_find(state->switch_state.labels_ht, - (void *)(uintptr_t)label_const->value.u[0]); - - if (previous_label) { - YYLTYPE loc = this->test_value->get_location(); - _mesa_glsl_error(& loc, state, - "duplicate case value"); - - loc = previous_label->get_location(); - _mesa_glsl_error(& loc, state, - "this is the previous case label"); - } else { - hash_table_insert(state->switch_state.labels_ht, - this->test_value, - (void *)(uintptr_t)label_const->value.u[0]); - } - } - - ir_dereference_variable *deref_test_var = - new(ctx) ir_dereference_variable(state->switch_state.test_var); - - ir_rvalue *const test_cond = new(ctx) ir_expression(ir_binop_all_equal, - label_const, - deref_test_var); - - ir_assignment *set_fallthru_on_test = - new(ctx) ir_assignment(deref_fallthru_var, - true_val, - test_cond); - - instructions->push_tail(set_fallthru_on_test); - } else { /* default case */ - if (state->switch_state.previous_default) { - YYLTYPE loc = this->get_location(); - _mesa_glsl_error(& loc, state, - "multiple default labels in one switch"); - - loc = state->switch_state.previous_default->get_location(); - _mesa_glsl_error(& loc, state, - "this is the first default label"); - } - state->switch_state.previous_default = this; - - /* Set falltrhu state. */ - ir_assignment *set_fallthru = - new(ctx) ir_assignment(deref_fallthru_var, true_val, NULL); - - instructions->push_tail(set_fallthru); - } - - /* Case statements do not have r-values. */ - return NULL; -} - -void -ast_iteration_statement::condition_to_hir(ir_loop *stmt, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - - if (condition != NULL) { - ir_rvalue *const cond = - condition->hir(& stmt->body_instructions, state); - - if ((cond == NULL) - || !cond->type->is_boolean() || !cond->type->is_scalar()) { - YYLTYPE loc = condition->get_location(); - - _mesa_glsl_error(& loc, state, - "loop condition must be scalar boolean"); - } else { - /* As the first code in the loop body, generate a block that looks - * like 'if (!condition) break;' as the loop termination condition. - */ - ir_rvalue *const not_cond = - new(ctx) ir_expression(ir_unop_logic_not, cond); - - ir_if *const if_stmt = new(ctx) ir_if(not_cond); - - ir_jump *const break_stmt = - new(ctx) ir_loop_jump(ir_loop_jump::jump_break); - - if_stmt->then_instructions.push_tail(break_stmt); - stmt->body_instructions.push_tail(if_stmt); - } - } -} - - -ir_rvalue * -ast_iteration_statement::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - - /* For-loops and while-loops start a new scope, but do-while loops do not. - */ - if (mode != ast_do_while) - state->symbols->push_scope(); - - if (init_statement != NULL) - init_statement->hir(instructions, state); - - ir_loop *const stmt = new(ctx) ir_loop(); - instructions->push_tail(stmt); - - /* Track the current loop nesting. */ - ast_iteration_statement *nesting_ast = state->loop_nesting_ast; - - state->loop_nesting_ast = this; - - /* Likewise, indicate that following code is closest to a loop, - * NOT closest to a switch. - */ - bool saved_is_switch_innermost = state->switch_state.is_switch_innermost; - state->switch_state.is_switch_innermost = false; - - if (mode != ast_do_while) - condition_to_hir(stmt, state); - - if (body != NULL) - body->hir(& stmt->body_instructions, state); - - if (rest_expression != NULL) - rest_expression->hir(& stmt->body_instructions, state); - - if (mode == ast_do_while) - condition_to_hir(stmt, state); - - if (mode != ast_do_while) - state->symbols->pop_scope(); - - /* Restore previous nesting before returning. */ - state->loop_nesting_ast = nesting_ast; - state->switch_state.is_switch_innermost = saved_is_switch_innermost; - - /* Loops do not have r-values. - */ - return NULL; -} - - -ir_rvalue * -ast_type_specifier::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (!this->is_precision_statement && this->structure == NULL) - return NULL; - - YYLTYPE loc = this->get_location(); - - if (this->precision != ast_precision_none - && state->language_version != 100 - && state->language_version < 130) { - _mesa_glsl_error(&loc, state, - "precision qualifiers exist only in " - "GLSL ES 1.00, and GLSL 1.30 and later"); - return NULL; - } - if (this->precision != ast_precision_none - && this->structure != NULL) { - _mesa_glsl_error(&loc, state, - "precision qualifiers do not apply to structures"); - return NULL; - } - - /* If this is a precision statement, check that the type to which it is - * applied is either float or int. - * - * From section 4.5.3 of the GLSL 1.30 spec: - * "The precision statement - * precision precision-qualifier type; - * can be used to establish a default precision qualifier. The type - * field can be either int or float [...]. Any other types or - * qualifiers will result in an error. - */ - if (this->is_precision_statement) { - assert(this->precision != ast_precision_none); - assert(this->structure == NULL); /* The check for structures was - * performed above. */ - if (this->is_array) { - _mesa_glsl_error(&loc, state, - "default precision statements do not apply to " - "arrays"); - return NULL; - } - if (this->type_specifier != ast_float - && this->type_specifier != ast_int) { - _mesa_glsl_error(&loc, state, - "default precision statements apply only to types " - "float and int"); - return NULL; - } - - /* FINISHME: Translate precision statements into IR. */ - return NULL; - } - - if (this->structure != NULL) - return this->structure->hir(instructions, state); - - return NULL; -} - - -ir_rvalue * -ast_struct_specifier::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - unsigned decl_count = 0; - - /* Make an initial pass over the list of structure fields to determine how - * many there are. Each element in this list is an ast_declarator_list. - * This means that we actually need to count the number of elements in the - * 'declarations' list in each of the elements. - */ - foreach_list_typed (ast_declarator_list, decl_list, link, - &this->declarations) { - foreach_list_const (decl_ptr, & decl_list->declarations) { - decl_count++; - } - } - - /* Allocate storage for the structure fields and process the field - * declarations. As the declarations are processed, try to also convert - * the types to HIR. This ensures that structure definitions embedded in - * other structure definitions are processed. - */ - glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field, - decl_count); - - unsigned i = 0; - foreach_list_typed (ast_declarator_list, decl_list, link, - &this->declarations) { - const char *type_name; - - decl_list->type->specifier->hir(instructions, state); - - const glsl_type *decl_type = - decl_list->type->specifier->glsl_type(& type_name, state); - - foreach_list_typed (ast_declaration, decl, link, - &decl_list->declarations) { - const struct glsl_type *field_type = decl_type; - if (decl->is_array) { - YYLTYPE loc = decl->get_location(); - field_type = process_array_type(&loc, decl_type, decl->array_size, - state); - } - fields[i].type = (field_type != NULL) - ? field_type : glsl_type::error_type; - fields[i].name = decl->identifier; - i++; - } - } - - assert(i == decl_count); - - const glsl_type *t = - glsl_type::get_record_instance(fields, decl_count, this->name); - - YYLTYPE loc = this->get_location(); - if (!state->symbols->add_type(name, t)) { - _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name); - } else { - const glsl_type **s = reralloc(state, state->user_structures, - const glsl_type *, - state->num_user_structures + 1); - if (s != NULL) { - s[state->num_user_structures] = t; - state->user_structures = s; - state->num_user_structures++; - } - } - - /* Structure type definitions do not have r-values. - */ - return NULL; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ast_type.cpp b/reactos/dll/opengl/mesa/src/glsl/ast_type.cpp deleted file mode 100644 index 79c43eefbc5..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ast_type.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ast.h" -extern "C" { -#include "program/symbol_table.h" -} - -void -ast_type_specifier::print(void) const -{ - if (type_specifier == ast_struct) { - structure->print(); - } else { - printf("%s ", type_name); - } - - if (is_array) { - printf("[ "); - - if (array_size) { - array_size->print(); - } - - printf("] "); - } -} - -ast_type_specifier::ast_type_specifier(int specifier) - : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL), - is_array(false), array_size(NULL), precision(ast_precision_none), - is_precision_statement(false) -{ - static const char *const names[] = { - "void", - "float", - "int", - "uint", - "bool", - "vec2", - "vec3", - "vec4", - "bvec2", - "bvec3", - "bvec4", - "ivec2", - "ivec3", - "ivec4", - "uvec2", - "uvec3", - "uvec4", - "mat2", - "mat2x3", - "mat2x4", - "mat3x2", - "mat3", - "mat3x4", - "mat4x2", - "mat4x3", - "mat4", - "sampler1D", - "sampler2D", - "sampler2DRect", - "sampler3D", - "samplerCube", - "samplerExternalOES", - "sampler1DShadow", - "sampler2DShadow", - "sampler2DRectShadow", - "samplerCubeShadow", - "sampler1DArray", - "sampler2DArray", - "sampler1DArrayShadow", - "sampler2DArrayShadow", - "isampler1D", - "isampler2D", - "isampler3D", - "isamplerCube", - "isampler1DArray", - "isampler2DArray", - "usampler1D", - "usampler2D", - "usampler3D", - "usamplerCube", - "usampler1DArray", - "usampler2DArray", - - NULL, /* ast_struct */ - NULL /* ast_type_name */ - }; - - type_name = names[specifier]; -} - -bool -ast_fully_specified_type::has_qualifiers() const -{ - return this->qualifier.flags.i != 0; -} - -bool ast_type_qualifier::has_interpolation() const -{ - return this->flags.q.smooth - || this->flags.q.flat - || this->flags.q.noperspective; -} - -const char* -ast_type_qualifier::interpolation_string() const -{ - if (this->flags.q.smooth) - return "smooth"; - else if (this->flags.q.flat) - return "flat"; - else if (this->flags.q.noperspective) - return "noperspective"; - else - return NULL; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/builtin_stubs.cpp b/reactos/dll/opengl/mesa/src/glsl/builtin_stubs.cpp deleted file mode 100644 index dfa5d324e7f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/builtin_stubs.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include "glsl_parser_extras.h" - -/* A dummy file. When compiling prototypes, we don't care about builtins. - * We really don't want to half-compile builtin_functions.cpp and fail, though. - */ -void -_mesa_glsl_release_functions(void) -{ -} - -void -_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state) -{ - (void) state; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/builtin_types.h b/reactos/dll/opengl/mesa/src/glsl/builtin_types.h deleted file mode 100644 index d9fb40e8e97..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/builtin_types.h +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -const glsl_type glsl_type::_error_type = - glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, ""); - -const glsl_type glsl_type::_void_type = - glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void"); - -const glsl_type glsl_type::_sampler3D_type = - glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, - "sampler3D"); - -const glsl_type *const glsl_type::error_type = & glsl_type::_error_type; -const glsl_type *const glsl_type::void_type = & glsl_type::_void_type; - -/** \name Core built-in types - * - * These types exist in all versions of GLSL. - */ -/*@{*/ - -const glsl_type glsl_type::builtin_core_types[] = { - glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"), - glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"), - glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"), - glsl_type(GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1, "bvec4"), - glsl_type(GL_INT, GLSL_TYPE_INT, 1, 1, "int"), - glsl_type(GL_INT_VEC2, GLSL_TYPE_INT, 2, 1, "ivec2"), - glsl_type(GL_INT_VEC3, GLSL_TYPE_INT, 3, 1, "ivec3"), - glsl_type(GL_INT_VEC4, GLSL_TYPE_INT, 4, 1, "ivec4"), - glsl_type(GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1, "float"), - glsl_type(GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1, "vec2"), - glsl_type(GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1, "vec3"), - glsl_type(GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1, "vec4"), - glsl_type(GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2, "mat2"), - glsl_type(GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3, "mat3"), - glsl_type(GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4, "mat4"), - glsl_type(GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, - "sampler2D"), - glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, - "samplerCube"), -}; - -const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; -const glsl_type *const glsl_type::int_type = & builtin_core_types[4]; -const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7]; -const glsl_type *const glsl_type::float_type = & builtin_core_types[8]; -const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9]; -const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10]; -const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11]; -const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12]; -const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13]; -const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14]; -/*@}*/ - -/** \name GLSL structures that have not been deprecated. - */ -/*@{*/ - -static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = { - { glsl_type::float_type, "near" }, - { glsl_type::float_type, "far" }, - { glsl_type::float_type, "diff" }, -}; - -const glsl_type glsl_type::builtin_structure_types[] = { - glsl_type(gl_DepthRangeParameters_fields, - Elements(gl_DepthRangeParameters_fields), - "gl_DepthRangeParameters"), -}; -/*@}*/ - -/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30 - */ -/*@{*/ - -static const struct glsl_struct_field gl_PointParameters_fields[] = { - { glsl_type::float_type, "size" }, - { glsl_type::float_type, "sizeMin" }, - { glsl_type::float_type, "sizeMax" }, - { glsl_type::float_type, "fadeThresholdSize" }, - { glsl_type::float_type, "distanceConstantAttenuation" }, - { glsl_type::float_type, "distanceLinearAttenuation" }, - { glsl_type::float_type, "distanceQuadraticAttenuation" }, -}; - -static const struct glsl_struct_field gl_MaterialParameters_fields[] = { - { glsl_type::vec4_type, "emission" }, - { glsl_type::vec4_type, "ambient" }, - { glsl_type::vec4_type, "diffuse" }, - { glsl_type::vec4_type, "specular" }, - { glsl_type::float_type, "shininess" }, -}; - -static const struct glsl_struct_field gl_LightSourceParameters_fields[] = { - { glsl_type::vec4_type, "ambient" }, - { glsl_type::vec4_type, "diffuse" }, - { glsl_type::vec4_type, "specular" }, - { glsl_type::vec4_type, "position" }, - { glsl_type::vec4_type, "halfVector" }, - { glsl_type::vec3_type, "spotDirection" }, - { glsl_type::float_type, "spotExponent" }, - { glsl_type::float_type, "spotCutoff" }, - { glsl_type::float_type, "spotCosCutoff" }, - { glsl_type::float_type, "constantAttenuation" }, - { glsl_type::float_type, "linearAttenuation" }, - { glsl_type::float_type, "quadraticAttenuation" }, -}; - -static const struct glsl_struct_field gl_LightModelParameters_fields[] = { - { glsl_type::vec4_type, "ambient" }, -}; - -static const struct glsl_struct_field gl_LightModelProducts_fields[] = { - { glsl_type::vec4_type, "sceneColor" }, -}; - -static const struct glsl_struct_field gl_LightProducts_fields[] = { - { glsl_type::vec4_type, "ambient" }, - { glsl_type::vec4_type, "diffuse" }, - { glsl_type::vec4_type, "specular" }, -}; - -static const struct glsl_struct_field gl_FogParameters_fields[] = { - { glsl_type::vec4_type, "color" }, - { glsl_type::float_type, "density" }, - { glsl_type::float_type, "start" }, - { glsl_type::float_type, "end" }, - { glsl_type::float_type, "scale" }, -}; - -const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = { - glsl_type(gl_PointParameters_fields, - Elements(gl_PointParameters_fields), - "gl_PointParameters"), - glsl_type(gl_MaterialParameters_fields, - Elements(gl_MaterialParameters_fields), - "gl_MaterialParameters"), - glsl_type(gl_LightSourceParameters_fields, - Elements(gl_LightSourceParameters_fields), - "gl_LightSourceParameters"), - glsl_type(gl_LightModelParameters_fields, - Elements(gl_LightModelParameters_fields), - "gl_LightModelParameters"), - glsl_type(gl_LightModelProducts_fields, - Elements(gl_LightModelProducts_fields), - "gl_LightModelProducts"), - glsl_type(gl_LightProducts_fields, - Elements(gl_LightProducts_fields), - "gl_LightProducts"), - glsl_type(gl_FogParameters_fields, - Elements(gl_FogParameters_fields), - "gl_FogParameters"), -}; -/*@}*/ - -/** \name Types in GLSL 1.10 (but not GLSL ES 1.00) - */ -/*@{*/ -const glsl_type glsl_type::builtin_110_types[] = { - glsl_type(GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, - "sampler1D"), - glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, - "sampler1DShadow"), - glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, - "sampler2DShadow"), -}; -/*@}*/ - -/** \name Types added in GLSL 1.20 - */ -/*@{*/ - -const glsl_type glsl_type::builtin_120_types[] = { - glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), - glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), - glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), - glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), - glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), - glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), -}; -const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0]; -const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1]; -const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2]; -const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3]; -const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4]; -const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; -/*@}*/ - -/** \name Types added in GLSL 1.30 - */ -/*@{*/ - -const glsl_type glsl_type::builtin_130_types[] = { - glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"), - glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"), - glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"), - glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"), - - /* cube shadow samplers */ - glsl_type(GL_SAMPLER_CUBE_SHADOW, - GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), - - /* signed and unsigned integer samplers */ - glsl_type(GL_INT_SAMPLER_1D, - GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), - glsl_type(GL_UNSIGNED_INT_SAMPLER_1D, - GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), - glsl_type(GL_INT_SAMPLER_2D, - GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), - glsl_type(GL_UNSIGNED_INT_SAMPLER_2D, - GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), - glsl_type(GL_INT_SAMPLER_3D, - GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), - glsl_type(GL_UNSIGNED_INT_SAMPLER_3D, - GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), - glsl_type(GL_INT_SAMPLER_CUBE, - GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), - glsl_type(GL_INT_SAMPLER_CUBE, - GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), -}; - -const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; -const glsl_type *const glsl_type::uvec2_type = & builtin_130_types[1]; -const glsl_type *const glsl_type::uvec3_type = & builtin_130_types[2]; -const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; -/*@}*/ diff --git a/reactos/dll/opengl/mesa/src/glsl/builtin_variables.cpp b/reactos/dll/opengl/mesa/src/glsl/builtin_variables.cpp deleted file mode 100644 index 2bffdb9ac73..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/builtin_variables.cpp +++ /dev/null @@ -1,969 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir.h" -#include "glsl_parser_extras.h" -#include "glsl_symbol_table.h" -#include "main/core.h" -#include "main/uniforms.h" -#include "program/prog_parameter.h" -#include "program/prog_statevars.h" -#include "program/prog_instruction.h" - -static void generate_ARB_draw_buffers_variables(exec_list *, - struct _mesa_glsl_parse_state *, - bool, _mesa_glsl_parser_targets); - -struct builtin_variable { - enum ir_variable_mode mode; - int slot; - const char *type; - const char *name; -}; - -static const builtin_variable builtin_core_vs_variables[] = { - { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" }, - { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" }, -}; - -static const builtin_variable builtin_core_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" }, - { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" }, - { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, -}; - -static const builtin_variable builtin_100ES_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, -}; - -static const builtin_variable builtin_110_fs_variables[] = { - { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, -}; - -static const builtin_variable builtin_110_deprecated_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" }, - { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" }, - { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_110_deprecated_vs_variables[] = { - { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, - { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, - { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, - { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, - { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, - { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, - { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, - { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, - { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, - { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, - { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, - { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, - { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, - { ir_var_out, VERT_RESULT_CLIP_VERTEX, "vec4", "gl_ClipVertex" }, - { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" }, - { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" }, - { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" }, - { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" }, - { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_120_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, -}; - -static const builtin_variable builtin_130_vs_variables[] = { - { ir_var_system_value, SYSTEM_VALUE_VERTEX_ID, "int", "gl_VertexID" }, -}; - -static const builtin_variable builtin_110_deprecated_uniforms[] = { - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, - { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "float", "gl_NormalScale" }, - { ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"}, - - /* Mesa-internal ATI_envmap_bumpmap state. */ - { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix0MESA"}, - { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix1MESA"}, - { ir_var_uniform, -1, "vec4", "gl_FogParamsOptimizedMESA"}, -}; - -static struct gl_builtin_uniform_element gl_DepthRange_elements[] = { - {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, - {"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY}, - {"diff", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_ZZZZ}, -}; - -static struct gl_builtin_uniform_element gl_ClipPlane_elements[] = { - {NULL, {STATE_CLIPPLANE, 0, 0}, SWIZZLE_XYZW} -}; - -static struct gl_builtin_uniform_element gl_Point_elements[] = { - {"size", {STATE_POINT_SIZE}, SWIZZLE_XXXX}, - {"sizeMin", {STATE_POINT_SIZE}, SWIZZLE_YYYY}, - {"sizeMax", {STATE_POINT_SIZE}, SWIZZLE_ZZZZ}, - {"fadeThresholdSize", {STATE_POINT_SIZE}, SWIZZLE_WWWW}, - {"distanceConstantAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_XXXX}, - {"distanceLinearAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_YYYY}, - {"distanceQuadraticAttenuation", {STATE_POINT_ATTENUATION}, SWIZZLE_ZZZZ}, -}; - -static struct gl_builtin_uniform_element gl_FrontMaterial_elements[] = { - {"emission", {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW}, - {"ambient", {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, - {"diffuse", {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, - {"specular", {STATE_MATERIAL, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, - {"shininess", {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_XXXX}, -}; - -static struct gl_builtin_uniform_element gl_BackMaterial_elements[] = { - {"emission", {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW}, - {"ambient", {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, - {"diffuse", {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, - {"specular", {STATE_MATERIAL, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, - {"shininess", {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_XXXX}, -}; - -static struct gl_builtin_uniform_element gl_LightSource_elements[] = { - {"ambient", {STATE_LIGHT, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, - {"diffuse", {STATE_LIGHT, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, - {"specular", {STATE_LIGHT, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, - {"position", {STATE_LIGHT, 0, STATE_POSITION}, SWIZZLE_XYZW}, - {"halfVector", {STATE_LIGHT, 0, STATE_HALF_VECTOR}, SWIZZLE_XYZW}, - {"spotDirection", {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, - MAKE_SWIZZLE4(SWIZZLE_X, - SWIZZLE_Y, - SWIZZLE_Z, - SWIZZLE_Z)}, - {"spotCosCutoff", {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_WWWW}, - {"spotCutoff", {STATE_LIGHT, 0, STATE_SPOT_CUTOFF}, SWIZZLE_XXXX}, - {"spotExponent", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_WWWW}, - {"constantAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_XXXX}, - {"linearAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_YYYY}, - {"quadraticAttenuation", {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_ZZZZ}, -}; - -static struct gl_builtin_uniform_element gl_LightModel_elements[] = { - {"ambient", {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_FrontLightModelProduct_elements[] = { - {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_BackLightModelProduct_elements[] = { - {"sceneColor", {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_FrontLightProduct_elements[] = { - {"ambient", {STATE_LIGHTPROD, 0, 0, STATE_AMBIENT}, SWIZZLE_XYZW}, - {"diffuse", {STATE_LIGHTPROD, 0, 0, STATE_DIFFUSE}, SWIZZLE_XYZW}, - {"specular", {STATE_LIGHTPROD, 0, 0, STATE_SPECULAR}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_BackLightProduct_elements[] = { - {"ambient", {STATE_LIGHTPROD, 0, 1, STATE_AMBIENT}, SWIZZLE_XYZW}, - {"diffuse", {STATE_LIGHTPROD, 0, 1, STATE_DIFFUSE}, SWIZZLE_XYZW}, - {"specular", {STATE_LIGHTPROD, 0, 1, STATE_SPECULAR}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_TextureEnvColor_elements[] = { - {NULL, {STATE_TEXENV_COLOR, 0}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_EyePlaneS_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_S}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_EyePlaneT_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_T}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_EyePlaneR_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_R}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_EyePlaneQ_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_Q}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_ObjectPlaneS_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_S}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_ObjectPlaneT_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_T}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_ObjectPlaneR_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_R}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_ObjectPlaneQ_elements[] = { - {NULL, {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_Q}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_Fog_elements[] = { - {"color", {STATE_FOG_COLOR}, SWIZZLE_XYZW}, - {"density", {STATE_FOG_PARAMS}, SWIZZLE_XXXX}, - {"start", {STATE_FOG_PARAMS}, SWIZZLE_YYYY}, - {"end", {STATE_FOG_PARAMS}, SWIZZLE_ZZZZ}, - {"scale", {STATE_FOG_PARAMS}, SWIZZLE_WWWW}, -}; - -static struct gl_builtin_uniform_element gl_NormalScale_elements[] = { - {NULL, {STATE_NORMAL_SCALE}, SWIZZLE_XXXX}, -}; - -static struct gl_builtin_uniform_element gl_BumpRotMatrix0MESA_elements[] = { - {NULL, {STATE_INTERNAL, STATE_ROT_MATRIX_0}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_BumpRotMatrix1MESA_elements[] = { - {NULL, {STATE_INTERNAL, STATE_ROT_MATRIX_1}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_FogParamsOptimizedMESA_elements[] = { - {NULL, {STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_CurrentAttribVertMESA_elements[] = { - {NULL, {STATE_INTERNAL, STATE_CURRENT_ATTRIB, 0}, SWIZZLE_XYZW}, -}; - -static struct gl_builtin_uniform_element gl_CurrentAttribFragMESA_elements[] = { - {NULL, {STATE_INTERNAL, STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, 0}, SWIZZLE_XYZW}, -}; - -#define MATRIX(name, statevar, modifier) \ - static struct gl_builtin_uniform_element name ## _elements[] = { \ - { NULL, { statevar, 0, 0, 0, modifier}, SWIZZLE_XYZW }, \ - { NULL, { statevar, 0, 1, 1, modifier}, SWIZZLE_XYZW }, \ - { NULL, { statevar, 0, 2, 2, modifier}, SWIZZLE_XYZW }, \ - { NULL, { statevar, 0, 3, 3, modifier}, SWIZZLE_XYZW }, \ - } - -MATRIX(gl_ModelViewMatrix, - STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE); -MATRIX(gl_ModelViewMatrixInverse, - STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVTRANS); -MATRIX(gl_ModelViewMatrixTranspose, - STATE_MODELVIEW_MATRIX, 0); -MATRIX(gl_ModelViewMatrixInverseTranspose, - STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE); - -MATRIX(gl_ProjectionMatrix, - STATE_PROJECTION_MATRIX, STATE_MATRIX_TRANSPOSE); -MATRIX(gl_ProjectionMatrixInverse, - STATE_PROJECTION_MATRIX, STATE_MATRIX_INVTRANS); -MATRIX(gl_ProjectionMatrixTranspose, - STATE_PROJECTION_MATRIX, 0); -MATRIX(gl_ProjectionMatrixInverseTranspose, - STATE_PROJECTION_MATRIX, STATE_MATRIX_INVERSE); - -MATRIX(gl_ModelViewProjectionMatrix, - STATE_MVP_MATRIX, STATE_MATRIX_TRANSPOSE); -MATRIX(gl_ModelViewProjectionMatrixInverse, - STATE_MVP_MATRIX, STATE_MATRIX_INVTRANS); -MATRIX(gl_ModelViewProjectionMatrixTranspose, - STATE_MVP_MATRIX, 0); -MATRIX(gl_ModelViewProjectionMatrixInverseTranspose, - STATE_MVP_MATRIX, STATE_MATRIX_INVERSE); - -MATRIX(gl_TextureMatrix, - STATE_TEXTURE_MATRIX, STATE_MATRIX_TRANSPOSE); -MATRIX(gl_TextureMatrixInverse, - STATE_TEXTURE_MATRIX, STATE_MATRIX_INVTRANS); -MATRIX(gl_TextureMatrixTranspose, - STATE_TEXTURE_MATRIX, 0); -MATRIX(gl_TextureMatrixInverseTranspose, - STATE_TEXTURE_MATRIX, STATE_MATRIX_INVERSE); - -static struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = { - { NULL, { STATE_MODELVIEW_MATRIX, 0, 0, 0, STATE_MATRIX_INVERSE}, - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) }, - { NULL, { STATE_MODELVIEW_MATRIX, 0, 1, 1, STATE_MATRIX_INVERSE}, - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) }, - { NULL, { STATE_MODELVIEW_MATRIX, 0, 2, 2, STATE_MATRIX_INVERSE}, - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z) }, -}; - -#undef MATRIX - -#define STATEVAR(name) {#name, name ## _elements, Elements(name ## _elements)} - -const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { - STATEVAR(gl_DepthRange), - STATEVAR(gl_ClipPlane), - STATEVAR(gl_Point), - STATEVAR(gl_FrontMaterial), - STATEVAR(gl_BackMaterial), - STATEVAR(gl_LightSource), - STATEVAR(gl_LightModel), - STATEVAR(gl_FrontLightModelProduct), - STATEVAR(gl_BackLightModelProduct), - STATEVAR(gl_FrontLightProduct), - STATEVAR(gl_BackLightProduct), - STATEVAR(gl_TextureEnvColor), - STATEVAR(gl_EyePlaneS), - STATEVAR(gl_EyePlaneT), - STATEVAR(gl_EyePlaneR), - STATEVAR(gl_EyePlaneQ), - STATEVAR(gl_ObjectPlaneS), - STATEVAR(gl_ObjectPlaneT), - STATEVAR(gl_ObjectPlaneR), - STATEVAR(gl_ObjectPlaneQ), - STATEVAR(gl_Fog), - - STATEVAR(gl_ModelViewMatrix), - STATEVAR(gl_ModelViewMatrixInverse), - STATEVAR(gl_ModelViewMatrixTranspose), - STATEVAR(gl_ModelViewMatrixInverseTranspose), - - STATEVAR(gl_ProjectionMatrix), - STATEVAR(gl_ProjectionMatrixInverse), - STATEVAR(gl_ProjectionMatrixTranspose), - STATEVAR(gl_ProjectionMatrixInverseTranspose), - - STATEVAR(gl_ModelViewProjectionMatrix), - STATEVAR(gl_ModelViewProjectionMatrixInverse), - STATEVAR(gl_ModelViewProjectionMatrixTranspose), - STATEVAR(gl_ModelViewProjectionMatrixInverseTranspose), - - STATEVAR(gl_TextureMatrix), - STATEVAR(gl_TextureMatrixInverse), - STATEVAR(gl_TextureMatrixTranspose), - STATEVAR(gl_TextureMatrixInverseTranspose), - - STATEVAR(gl_NormalMatrix), - STATEVAR(gl_NormalScale), - - STATEVAR(gl_BumpRotMatrix0MESA), - STATEVAR(gl_BumpRotMatrix1MESA), - STATEVAR(gl_FogParamsOptimizedMESA), - STATEVAR(gl_CurrentAttribVertMESA), - STATEVAR(gl_CurrentAttribFragMESA), - - {NULL, NULL, 0} -}; - -static ir_variable * -add_variable(exec_list *instructions, glsl_symbol_table *symtab, - const char *name, const glsl_type *type, - enum ir_variable_mode mode, int slot) -{ - ir_variable *var = new(symtab) ir_variable(type, name, mode); - - switch (var->mode) { - case ir_var_auto: - case ir_var_in: - case ir_var_const_in: - case ir_var_uniform: - case ir_var_system_value: - var->read_only = true; - break; - case ir_var_inout: - case ir_var_out: - break; - default: - assert(0); - break; - } - - var->location = slot; - - /* Once the variable is created an initialized, add it to the symbol table - * and add the declaration to the IR stream. - */ - instructions->push_tail(var); - - symtab->add_variable(var); - return var; -} - -static ir_variable * -add_uniform(exec_list *instructions, glsl_symbol_table *symtab, - const char *name, const glsl_type *type) -{ - ir_variable *const uni = - add_variable(instructions, symtab, name, type, ir_var_uniform, -1); - - unsigned i; - for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) { - if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) { - break; - } - } - - assert(_mesa_builtin_uniform_desc[i].name != NULL); - const struct gl_builtin_uniform_desc* const statevar = - &_mesa_builtin_uniform_desc[i]; - - const unsigned array_count = type->is_array() ? type->length : 1; - uni->num_state_slots = array_count * statevar->num_elements; - - ir_state_slot *slots = - ralloc_array(uni, ir_state_slot, uni->num_state_slots); - - uni->state_slots = slots; - - for (unsigned a = 0; a < array_count; a++) { - for (unsigned j = 0; j < statevar->num_elements; j++) { - struct gl_builtin_uniform_element *element = &statevar->elements[j]; - - memcpy(slots->tokens, element->tokens, sizeof(element->tokens)); - if (type->is_array()) { - if (strcmp(name, "gl_CurrentAttribVertMESA") == 0 || - strcmp(name, "gl_CurrentAttribFragMESA") == 0) { - slots->tokens[2] = a; - } else { - slots->tokens[1] = a; - } - } - - slots->swizzle = element->swizzle; - slots++; - } - } - - return uni; -} - -static void -add_builtin_variable(exec_list *instructions, glsl_symbol_table *symtab, - const builtin_variable *proto) -{ - /* Create a new variable declaration from the description supplied by - * the caller. - */ - const glsl_type *const type = symtab->get_type(proto->type); - - assert(type != NULL); - - if (proto->mode == ir_var_uniform) { - add_uniform(instructions, symtab, proto->name, type); - } else { - add_variable(instructions, symtab, proto->name, type, proto->mode, - proto->slot); - } -} - -static ir_variable * -add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab, - const char *name, int value) -{ - ir_variable *const var = add_variable(instructions, symtab, - name, glsl_type::int_type, - ir_var_auto, -1); - var->constant_value = new(var) ir_constant(value); - var->constant_initializer = new(var) ir_constant(value); - var->has_initializer = true; - return var; -} - -/* Several constants in GLSL ES have different names than normal desktop GLSL. - * Therefore, this function should only be called on the ES path. - */ -static void -generate_100ES_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - glsl_symbol_table *const symtab = state->symbols; - - add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs", - state->Const.MaxVertexAttribs); - add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformVectors", - state->Const.MaxVertexUniformComponents); - add_builtin_constant(instructions, symtab, "gl_MaxVaryingVectors", - state->Const.MaxVaryingFloats / 4); - add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits", - state->Const.MaxVertexTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits", - state->Const.MaxCombinedTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", - state->Const.MaxTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformVectors", - state->Const.MaxFragmentUniformComponents); - - add_uniform(instructions, symtab, "gl_DepthRange", - state->symbols->get_type("gl_DepthRangeParameters")); -} - -static void -generate_110_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - glsl_symbol_table *const symtab = state->symbols; - - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_uniforms) - ; i++) { - add_builtin_variable(instructions, symtab, - & builtin_110_deprecated_uniforms[i]); - } - - add_builtin_constant(instructions, symtab, "gl_MaxLights", - state->Const.MaxLights); - add_builtin_constant(instructions, symtab, "gl_MaxClipPlanes", - state->Const.MaxClipPlanes); - add_builtin_constant(instructions, symtab, "gl_MaxTextureUnits", - state->Const.MaxTextureUnits); - add_builtin_constant(instructions, symtab, "gl_MaxTextureCoords", - state->Const.MaxTextureCoords); - add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs", - state->Const.MaxVertexAttribs); - add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformComponents", - state->Const.MaxVertexUniformComponents); - add_builtin_constant(instructions, symtab, "gl_MaxVaryingFloats", - state->Const.MaxVaryingFloats); - add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits", - state->Const.MaxVertexTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits", - state->Const.MaxCombinedTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", - state->Const.MaxTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformComponents", - state->Const.MaxFragmentUniformComponents); - - const glsl_type *const mat4_array_type = - glsl_type::get_array_instance(glsl_type::mat4_type, - state->Const.MaxTextureCoords); - - add_uniform(instructions, symtab, "gl_TextureMatrix", mat4_array_type); - add_uniform(instructions, symtab, "gl_TextureMatrixInverse", mat4_array_type); - add_uniform(instructions, symtab, "gl_TextureMatrixTranspose", mat4_array_type); - add_uniform(instructions, symtab, "gl_TextureMatrixInverseTranspose", mat4_array_type); - - add_uniform(instructions, symtab, "gl_DepthRange", - symtab->get_type("gl_DepthRangeParameters")); - - add_uniform(instructions, symtab, "gl_ClipPlane", - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxClipPlanes)); - add_uniform(instructions, symtab, "gl_Point", - symtab->get_type("gl_PointParameters")); - - const glsl_type *const material_parameters_type = - symtab->get_type("gl_MaterialParameters"); - add_uniform(instructions, symtab, "gl_FrontMaterial", material_parameters_type); - add_uniform(instructions, symtab, "gl_BackMaterial", material_parameters_type); - - const glsl_type *const light_source_array_type = - glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), state->Const.MaxLights); - - add_uniform(instructions, symtab, "gl_LightSource", light_source_array_type); - - const glsl_type *const light_model_products_type = - symtab->get_type("gl_LightModelProducts"); - add_uniform(instructions, symtab, "gl_FrontLightModelProduct", - light_model_products_type); - add_uniform(instructions, symtab, "gl_BackLightModelProduct", - light_model_products_type); - - const glsl_type *const light_products_type = - glsl_type::get_array_instance(symtab->get_type("gl_LightProducts"), - state->Const.MaxLights); - add_uniform(instructions, symtab, "gl_FrontLightProduct", light_products_type); - add_uniform(instructions, symtab, "gl_BackLightProduct", light_products_type); - - add_uniform(instructions, symtab, "gl_TextureEnvColor", - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxTextureUnits)); - - const glsl_type *const texcoords_vec4 = - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxTextureCoords); - add_uniform(instructions, symtab, "gl_EyePlaneS", texcoords_vec4); - add_uniform(instructions, symtab, "gl_EyePlaneT", texcoords_vec4); - add_uniform(instructions, symtab, "gl_EyePlaneR", texcoords_vec4); - add_uniform(instructions, symtab, "gl_EyePlaneQ", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneS", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneT", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneR", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneQ", texcoords_vec4); - - add_uniform(instructions, symtab, "gl_Fog", - symtab->get_type("gl_FogParameters")); - - /* Mesa-internal current attrib state */ - const glsl_type *const vert_attribs = - glsl_type::get_array_instance(glsl_type::vec4_type, VERT_ATTRIB_MAX); - add_uniform(instructions, symtab, "gl_CurrentAttribVertMESA", vert_attribs); - const glsl_type *const frag_attribs = - glsl_type::get_array_instance(glsl_type::vec4_type, FRAG_ATTRIB_MAX); - add_uniform(instructions, symtab, "gl_CurrentAttribFragMESA", frag_attribs); -} - -/* This function should only be called for ES, not desktop GL. */ -static void -generate_100ES_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_vs_variables[i]); - } - - generate_100ES_uniforms(instructions, state); - - generate_ARB_draw_buffers_variables(instructions, state, false, - vertex_shader); -} - - -static void -generate_110_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_vs_variables[i]); - } - - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_vs_variables) - ; i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_110_deprecated_vs_variables[i]); - } - generate_110_uniforms(instructions, state); - - /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: - * - * "As with all arrays, indices used to subscript gl_TexCoord must - * either be an integral constant expressions, or this array must be - * re-declared by the shader with a size. The size can be at most - * gl_MaxTextureCoords. Using indexes close to 0 may aid the - * implementation in preserving varying resources." - */ - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 0); - - add_variable(instructions, state->symbols, - "gl_TexCoord", vec4_array_type, ir_var_out, VERT_RESULT_TEX0); - - generate_ARB_draw_buffers_variables(instructions, state, false, - vertex_shader); -} - - -static void -generate_120_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - /* GLSL version 1.20 did not add any built-in variables in the vertex - * shader. - */ - generate_110_vs_variables(instructions, state); -} - - -static void -generate_130_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - glsl_symbol_table *const symtab = state->symbols; - - add_builtin_constant(instructions, symtab, "gl_MaxClipDistances", - state->Const.MaxClipPlanes); - add_builtin_constant(instructions, symtab, "gl_MaxVaryingComponents", - state->Const.MaxVaryingFloats); -} - - -static void -generate_130_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - generate_120_vs_variables(instructions, state); - - for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_130_vs_variables[i]); - } - - generate_130_uniforms(instructions, state); - - /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special - * Variables): - * - * The gl_ClipDistance array is predeclared as unsized and must - * be sized by the shader either redeclaring it with a size or - * indexing it only with integral constant expressions. - * - * We represent this in Mesa by initially declaring the array as - * size 0. - */ - const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 0); - - add_variable(instructions, state->symbols, - "gl_ClipDistance", clip_distance_array_type, ir_var_out, - VERT_RESULT_CLIP_DIST0); - -} - - -static void -initialize_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - - switch (state->language_version) { - case 100: - generate_100ES_vs_variables(instructions, state); - break; - case 110: - generate_110_vs_variables(instructions, state); - break; - case 120: - generate_120_vs_variables(instructions, state); - break; - case 130: - generate_130_vs_variables(instructions, state); - break; - } -} - - -/* This function should only be called for ES, not desktop GL. */ -static void -generate_100ES_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_fs_variables[i]); - } - - for (unsigned i = 0; i < Elements(builtin_100ES_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_100ES_fs_variables[i]); - } - - generate_100ES_uniforms(instructions, state); - - generate_ARB_draw_buffers_variables(instructions, state, false, - fragment_shader); -} - -static void -generate_110_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_fs_variables[i]); - } - - for (unsigned i = 0; i < Elements(builtin_110_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_110_fs_variables[i]); - } - - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_fs_variables) - ; i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_110_deprecated_fs_variables[i]); - } - generate_110_uniforms(instructions, state); - - /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: - * - * "As with all arrays, indices used to subscript gl_TexCoord must - * either be an integral constant expressions, or this array must be - * re-declared by the shader with a size. The size can be at most - * gl_MaxTextureCoords. Using indexes close to 0 may aid the - * implementation in preserving varying resources." - */ - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 0); - - add_variable(instructions, state->symbols, - "gl_TexCoord", vec4_array_type, ir_var_in, FRAG_ATTRIB_TEX0); - - generate_ARB_draw_buffers_variables(instructions, state, false, - fragment_shader); -} - - -static void -generate_ARB_draw_buffers_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn, _mesa_glsl_parser_targets target) -{ - /* gl_MaxDrawBuffers is available in all shader stages. - */ - ir_variable *const mdb = - add_builtin_constant(instructions, state->symbols, "gl_MaxDrawBuffers", - state->Const.MaxDrawBuffers); - - if (warn) - mdb->warn_extension = "GL_ARB_draw_buffers"; - - /* gl_FragData is only available in the fragment shader. - */ - if (target == fragment_shader) { - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxDrawBuffers); - - ir_variable *const fd = - add_variable(instructions, state->symbols, - "gl_FragData", vec4_array_type, - ir_var_out, FRAG_RESULT_DATA0); - - if (warn) - fd->warn_extension = "GL_ARB_draw_buffers"; - } -} - - -static void -generate_ARB_shader_stencil_export_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn) -{ - /* gl_FragStencilRefARB is only available in the fragment shader. - */ - ir_variable *const fd = - add_variable(instructions, state->symbols, - "gl_FragStencilRefARB", glsl_type::int_type, - ir_var_out, FRAG_RESULT_STENCIL); - - if (warn) - fd->warn_extension = "GL_ARB_shader_stencil_export"; -} - -static void -generate_AMD_shader_stencil_export_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn) -{ - /* gl_FragStencilRefAMD is only available in the fragment shader. - */ - ir_variable *const fd = - add_variable(instructions, state->symbols, - "gl_FragStencilRefAMD", glsl_type::int_type, - ir_var_out, FRAG_RESULT_STENCIL); - - if (warn) - fd->warn_extension = "GL_AMD_shader_stencil_export"; -} - -static void -generate_120_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - generate_110_fs_variables(instructions, state); - - for (unsigned i = 0 - ; i < Elements(builtin_120_fs_variables) - ; i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_120_fs_variables[i]); - } -} - -static void -generate_130_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - generate_120_fs_variables(instructions, state); - - generate_130_uniforms(instructions, state); - - /* From the GLSL 1.30 spec, section 7.2 (Fragment Shader Special - * Variables): - * - * The built-in input variable gl_ClipDistance array contains linearly - * interpolated values for the vertex values written by the vertex shader - * to the gl_ClipDistance vertex output variable. This array must be - * sized in the fragment shader either implicitly or explicitly to be the - * same size as it was sized in the vertex shader. - * - * In other words, the array must be pre-declared as implicitly sized. We - * represent this in Mesa by initially declaring the array as size 0. - */ - const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 0); - - add_variable(instructions, state->symbols, - "gl_ClipDistance", clip_distance_array_type, ir_var_in, - FRAG_ATTRIB_CLIP_DIST0); -} - -static void -initialize_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - - switch (state->language_version) { - case 100: - generate_100ES_fs_variables(instructions, state); - break; - case 110: - generate_110_fs_variables(instructions, state); - break; - case 120: - generate_120_fs_variables(instructions, state); - break; - case 130: - generate_130_fs_variables(instructions, state); - break; - } - - if (state->ARB_shader_stencil_export_enable) - generate_ARB_shader_stencil_export_variables(instructions, state, - state->ARB_shader_stencil_export_warn); - - if (state->AMD_shader_stencil_export_enable) - generate_AMD_shader_stencil_export_variables(instructions, state, - state->AMD_shader_stencil_export_warn); -} - -void -_mesa_glsl_initialize_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - switch (state->target) { - case vertex_shader: - initialize_vs_variables(instructions, state); - break; - case fragment_shader: - initialize_fs_variables(instructions, state); - break; - } -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/README b/reactos/dll/opengl/mesa/src/glsl/glcpp/README deleted file mode 100644 index 0b5ef508ce9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/README +++ /dev/null @@ -1,32 +0,0 @@ -glcpp -- GLSL "C" preprocessor - -This is a simple preprocessor designed to provide the preprocessing -needs of the GLSL language. The requirements for this preprocessor are -specified in the GLSL 1.30 specification availble from: - -http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.10.pdf - -This specification is not precise on some semantics, (for example, -#define and #if), defining these merely "as is standard for C++ -preprocessors". To fill in these details, I've been using a draft of -the C99 standard as available from: - -http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf - -Any downstream compiler accepting output from glcpp should be prepared -to encounter and deal with the following preprocessor macros: - - #line - #pragma - #extension - -All other macros will be handles according to the GLSL specification -and will not appear in the output. - -Known limitations ------------------ -The __LINE__ and __FILE__ macros are not yet supported. - -A file that ends with a function-like macro name as the last -non-whitespace token will result in a parse error, (where it should be -passed through as is). \ No newline at end of file diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.c deleted file mode 100644 index 49ca7ed7a89..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.c +++ /dev/null @@ -1,2621 +0,0 @@ -#line 2 "glcpp/glcpp-lex.c" - -#line 4 "glcpp/glcpp-lex.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE glcpp_restart(yyin ,yyscanner ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via glcpp_restart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void glcpp_restart (FILE *input_file ,yyscan_t yyscanner ); -void glcpp__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE glcpp__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void glcpp__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void glcpp__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void glcpp_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void glcpp_pop_buffer_state (yyscan_t yyscanner ); - -static void glcpp_ensure_buffer_stack (yyscan_t yyscanner ); -static void glcpp__load_buffer_state (yyscan_t yyscanner ); -static void glcpp__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); - -#define YY_FLUSH_BUFFER glcpp__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) - -YY_BUFFER_STATE glcpp__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE glcpp__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE glcpp__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *glcpp_alloc (yy_size_t ,yyscan_t yyscanner ); -void *glcpp_realloc (void *,yy_size_t ,yyscan_t yyscanner ); -void glcpp_free (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer glcpp__create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - glcpp_ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - glcpp_ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define glcpp_wrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 43 -#define YY_END_OF_BUFFER 44 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_acclist[107] = - { 0, - 3, 3, 44, 39, 43, 40, 43, 41, 43, 43, - 38, 43, 43, 38, 43, 38, 43, 38, 43, 25, - 43, 24, 43, 38, 43, 38, 43, 38, 43, 37, - 43, 37, 43, 38, 43, 40, 43, 23, 43, 3, - 43, 4, 43, 5, 43, 42, 43, 18, 43, 18, - 43, 18, 43, 39, 40, 32, 35, 33, 2, 1, - 25, 25, 24, 24, 27, 29, 31, 30, 28, 37, - 37, 34, 40, 23, 23, 3, 4, 5, 6, 5, - 7, 1, 26, 37, 26, 37, 14, 37, 15, 16, - 37, 17, 19, 12, 22, 36, 37, 21, 19, 13, - - 16404, 11, 9, 8, 8212, 10 - } ; - -static yyconst flex_int16_t yy_accept[155] = - { 0, - 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, - 3, 4, 6, 8, 10, 11, 13, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, - 40, 42, 44, 46, 48, 50, 52, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 76, 76, 76, 76, 76, 76, 76, 77, 78, - 79, 80, 81, 82, 82, 82, 82, 82, 83, 84, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 86, 87, 87, 87, 87, 87, 87, 87, 88, - - 88, 88, 88, 88, 88, 88, 89, 89, 90, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 91, 92, - 92, 93, 94, 94, 95, 95, 95, 95, 96, 96, - 98, 99, 100, 100, 101, 101, 101, 101, 102, 102, - 102, 103, 103, 104, 105, 105, 105, 105, 106, 106, - 106, 107, 107, 107 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, - 7, 10, 7, 7, 7, 7, 11, 12, 13, 13, - 13, 13, 13, 13, 13, 14, 14, 1, 7, 15, - 16, 17, 1, 1, 18, 18, 18, 18, 18, 18, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 20, 19, 19, 21, 19, 19, - 7, 1, 7, 7, 19, 1, 22, 18, 18, 23, - - 24, 25, 26, 19, 27, 19, 19, 28, 29, 30, - 31, 32, 19, 33, 34, 35, 36, 37, 19, 38, - 19, 19, 7, 39, 7, 7, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[40] = - { 0, - 1, 2, 3, 1, 1, 1, 1, 1, 4, 5, - 1, 6, 6, 6, 1, 1, 1, 7, 8, 8, - 8, 7, 9, 7, 7, 8, 8, 8, 8, 10, - 8, 8, 8, 8, 8, 8, 8, 8, 1 - } ; - -static yyconst flex_int16_t yy_base[168] = - { 0, - 0, 38, 0, 0, 38, 39, 333, 332, 331, 44, - 333, 331, 329, 337, 337, 314, 323, 337, 320, 41, - 41, 44, 44, 311, 49, 0, 302, 286, 61, 79, - 321, 337, 65, 337, 337, 67, 68, 322, 320, 337, - 337, 337, 337, 0, 74, 337, 0, 76, 337, 337, - 337, 337, 337, 337, 0, 296, 337, 72, 314, 313, - 294, 71, 292, 289, 282, 284, 289, 309, 337, 110, - 337, 114, 337, 91, 81, 112, 15, 0, 35, 284, - 285, 57, 286, 275, 272, 96, 276, 283, 281, 270, - 337, 272, 274, 275, 275, 271, 266, 272, 337, 271, - - 271, 264, 256, 257, 246, 255, 240, 337, 337, 235, - 222, 224, 228, 222, 234, 189, 140, 137, 140, 138, - 337, 0, 127, 337, 135, 116, 137, 337, 127, 0, - 140, 0, 108, 337, 120, 0, 101, 125, 69, 135, - 337, 138, 0, 337, 89, 52, 141, 337, 63, 143, - 337, 154, 337, 168, 178, 188, 198, 203, 213, 223, - 233, 238, 247, 257, 267, 276, 283 - } ; - -static yyconst flex_int16_t yy_def[168] = - { 0, - 153, 1, 154, 154, 155, 155, 156, 156, 157, 157, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 158, 158, 153, 153, 153, - 159, 153, 160, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 161, 153, 153, 162, 153, 153, 153, - 153, 153, 153, 153, 158, 158, 153, 153, 30, 30, - 153, 153, 153, 153, 153, 153, 153, 159, 153, 160, - 153, 160, 153, 153, 153, 153, 153, 161, 162, 158, - 153, 153, 153, 153, 153, 163, 153, 153, 153, 153, - 153, 158, 153, 153, 153, 153, 153, 153, 153, 153, - - 153, 153, 153, 153, 153, 158, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 158, 153, - 153, 164, 153, 153, 153, 153, 153, 153, 153, 158, - 153, 164, 153, 153, 153, 165, 153, 166, 153, 153, - 153, 153, 165, 153, 167, 153, 153, 153, 167, 153, - 153, 153, 0, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153 - } ; - -static yyconst flex_int16_t yy_nxt[377] = - { 0, - 12, 13, 14, 15, 16, 17, 18, 19, 18, 18, - 20, 21, 22, 22, 23, 24, 25, 26, 26, 26, - 26, 26, 27, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 28, 29, - 32, 32, 82, 30, 83, 36, 14, 33, 33, 37, - 43, 44, 45, 45, 91, 48, 48, 48, 50, 51, - 46, 47, 58, 49, 53, 54, 59, 71, 74, 76, - 91, 148, 75, 58, 72, 73, 46, 59, 47, 49, - 60, 136, 76, 94, 41, 45, 45, 48, 48, 48, - 95, 77, 74, 46, 63, 49, 75, 148, 82, 146, - - 83, 61, 62, 84, 77, 63, 64, 63, 85, 46, - 65, 49, 71, 76, 66, 67, 71, 126, 100, 153, - 153, 140, 141, 72, 73, 101, 138, 135, 135, 135, - 144, 142, 142, 142, 139, 77, 140, 141, 63, 140, - 141, 138, 150, 151, 150, 151, 147, 147, 147, 142, - 142, 142, 152, 152, 152, 150, 151, 137, 136, 134, - 133, 131, 130, 129, 128, 152, 152, 152, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, - - 35, 35, 35, 35, 35, 35, 35, 35, 55, 55, - 55, 55, 55, 68, 68, 68, 68, 127, 68, 68, - 68, 68, 68, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 78, 78, 126, 78, 78, 78, 78, - 78, 78, 78, 79, 79, 125, 79, 99, 99, 99, - 99, 99, 124, 123, 122, 99, 99, 132, 132, 121, - 132, 132, 132, 132, 132, 132, 132, 143, 143, 120, - 143, 143, 143, 143, 143, 143, 143, 145, 119, 118, - 117, 116, 145, 145, 145, 145, 149, 115, 149, 149, - 149, 149, 149, 114, 113, 112, 111, 110, 109, 108, - - 107, 106, 105, 104, 103, 102, 98, 97, 96, 93, - 92, 69, 90, 89, 88, 87, 86, 81, 153, 153, - 80, 39, 38, 69, 57, 56, 52, 42, 41, 40, - 39, 38, 153, 14, 15, 15, 11, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153 - } ; - -static yyconst flex_int16_t yy_chk[377] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 5, 6, 77, 2, 77, 10, 10, 5, 6, 10, - 20, 20, 21, 21, 79, 22, 22, 22, 23, 23, - 21, 21, 29, 22, 25, 25, 29, 33, 36, 37, - 79, 149, 36, 58, 33, 33, 21, 58, 21, 22, - 30, 146, 75, 82, 30, 45, 45, 48, 48, 48, - 82, 37, 74, 45, 37, 48, 74, 145, 62, 139, - - 62, 30, 30, 62, 75, 30, 30, 75, 62, 45, - 30, 48, 70, 76, 30, 30, 72, 126, 86, 70, - 70, 135, 135, 72, 72, 86, 138, 126, 126, 126, - 137, 135, 135, 135, 133, 76, 140, 140, 76, 142, - 142, 131, 147, 147, 150, 150, 140, 140, 140, 142, - 142, 142, 147, 147, 147, 152, 152, 129, 127, 125, - 123, 120, 119, 118, 117, 152, 152, 152, 154, 154, - 154, 154, 154, 154, 154, 154, 154, 154, 155, 155, - 155, 155, 155, 155, 155, 155, 155, 155, 156, 156, - 156, 156, 156, 156, 156, 156, 156, 156, 157, 157, - - 157, 157, 157, 157, 157, 157, 157, 157, 158, 158, - 158, 158, 158, 159, 159, 159, 159, 116, 159, 159, - 159, 159, 159, 160, 160, 160, 160, 160, 160, 160, - 160, 160, 160, 161, 161, 115, 161, 161, 161, 161, - 161, 161, 161, 162, 162, 114, 162, 163, 163, 163, - 163, 163, 113, 112, 111, 163, 163, 164, 164, 110, - 164, 164, 164, 164, 164, 164, 164, 165, 165, 107, - 165, 165, 165, 165, 165, 165, 165, 166, 106, 105, - 104, 103, 166, 166, 166, 166, 167, 102, 167, 167, - 167, 167, 167, 101, 100, 98, 97, 96, 95, 94, - - 93, 92, 90, 89, 88, 87, 85, 84, 83, 81, - 80, 68, 67, 66, 65, 64, 63, 61, 60, 59, - 56, 39, 38, 31, 28, 27, 24, 19, 17, 16, - 13, 12, 11, 9, 8, 7, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153 - } ; - -#define YY_TRAILING_MASK 0x2000 -#define YY_TRAILING_HEAD_MASK 0x4000 -#define REJECT \ -{ \ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \ -yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \ -yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \ -yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \ -yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \ -++yyg->yy_lp; \ -goto find_rule; \ -} - -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "glcpp/glcpp-lex.l" -#line 2 "glcpp/glcpp-lex.l" -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include - -#include "glcpp.h" -#include "glcpp-parse.h" - -/* Flex annoyingly generates some functions without making them - * static. Let's declare them here. */ -int glcpp_get_column (yyscan_t yyscanner); -void glcpp_set_column (int column_no , yyscan_t yyscanner); - -#ifdef _MSC_VER -#define YY_NO_UNISTD_H -#endif - -#define YY_NO_INPUT - -#define YY_USER_ACTION \ - do { \ - yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno; \ - yycolumn += yyleng; \ - } while(0); - -#define YY_USER_INIT \ - do { \ - yylineno = 1; \ - yycolumn = 1; \ - yylloc->source = 0; \ - } while(0) - -/* The OTHER class is simply a catch-all for things that the CPP -parser just doesn't care about. Since flex regular expressions that -match longer strings take priority over those matching shorter -strings, we have to be careful to avoid OTHER matching and hiding -something that CPP does care about. So we simply exclude all -characters that appear in any other expressions. */ -#line 652 "glcpp/glcpp-lex.c" - -#define INITIAL 0 -#define DONE 1 -#define COMMENT 2 -#define UNREACHABLE 3 -#define SKIP 4 - -#define YY_EXTRA_TYPE glcpp_parser_t * - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - yy_state_type *yy_state_buf; - yy_state_type *yy_state_ptr; - char *yy_full_match; - int yy_lp; - - /* These are only needed for trailing context rules, - * but there's no conditional variable for that yet. */ - int yy_looking_for_trail_begin; - int yy_full_lp; - int *yy_full_state; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - YYSTYPE * yylval_r; - - YYLTYPE * yylloc_r; - - }; /* end struct yyguts_t */ - -static int yy_init_globals (yyscan_t yyscanner ); - - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval yyg->yylval_r - - # define yylloc yyg->yylloc_r - -int glcpp_lex_init (yyscan_t* scanner); - -int glcpp_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int glcpp_lex_destroy (yyscan_t yyscanner ); - -int glcpp_get_debug (yyscan_t yyscanner ); - -void glcpp_set_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE glcpp_get_extra (yyscan_t yyscanner ); - -void glcpp_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *glcpp_get_in (yyscan_t yyscanner ); - -void glcpp_set_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *glcpp_get_out (yyscan_t yyscanner ); - -void glcpp_set_out (FILE * out_str ,yyscan_t yyscanner ); - -int glcpp_get_leng (yyscan_t yyscanner ); - -char *glcpp_get_text (yyscan_t yyscanner ); - -int glcpp_get_lineno (yyscan_t yyscanner ); - -void glcpp_set_lineno (int line_number ,yyscan_t yyscanner ); - -int glcpp_get_column (yyscan_t yyscanner ); - -void glcpp_set_column (int column_no ,yyscan_t yyscanner ); - -YYSTYPE * glcpp_get_lval (yyscan_t yyscanner ); - -void glcpp_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - - YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner ); - - void glcpp_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int glcpp_wrap (yyscan_t yyscanner ); -#else -extern int glcpp_wrap (yyscan_t yyscanner ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); -#else -static int input (yyscan_t yyscanner ); -#endif - -#endif - - static void yy_push_state (int new_state ,yyscan_t yyscanner); - - static void yy_pop_state (yyscan_t yyscanner ); - - static int yy_top_state (yyscan_t yyscanner ); - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - unsigned n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int glcpp_lex \ - (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); - -#define YY_DECL int glcpp_lex \ - (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - if ( yyleng > 0 ) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -#line 88 "glcpp/glcpp-lex.l" - - /* Implicitly switch between SKIP and INITIAL (non-skipping); - * don't switch if some other state was explicitly set. - */ - glcpp_parser_t *parser = yyextra; - if (YY_START == 0 || YY_START == SKIP) { - if (parser->lexing_if || parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) { - BEGIN 0; - } else { - BEGIN SKIP; - } - } - - /* Single-line comments */ -#line 926 "glcpp/glcpp-lex.c" - - yylval = yylval_param; - - yylloc = yylloc_param; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! yyg->yy_state_buf ) - yyg->yy_state_buf = (yy_state_type *)glcpp_alloc(YY_STATE_BUF_SIZE ,yyscanner); - if ( ! yyg->yy_state_buf ) - YY_FATAL_ERROR( "out of dynamic memory in glcpp_lex()" ); - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - glcpp_ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - glcpp__load_buffer_state(yyscanner ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; - yy_current_state += YY_AT_BOL(); - - yyg->yy_state_ptr = yyg->yy_state_buf; - *yyg->yy_state_ptr++ = yy_current_state; - -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 154 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yyg->yy_state_ptr++ = yy_current_state; - ++yy_cp; - } - while ( yy_current_state != 153 ); - -yy_find_action: - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[yyg->yy_lp]; - if ( yy_act & YY_TRAILING_HEAD_MASK || - yyg->yy_looking_for_trail_begin ) - { - if ( yy_act == yyg->yy_looking_for_trail_begin ) - { - yyg->yy_looking_for_trail_begin = 0; - yy_act &= ~YY_TRAILING_HEAD_MASK; - break; - } - } - else if ( yy_act & YY_TRAILING_MASK ) - { - yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK; - yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK; - } - else - { - yyg->yy_full_match = yy_cp; - yyg->yy_full_state = yyg->yy_state_ptr; - yyg->yy_full_lp = yyg->yy_lp; - break; - } - ++yyg->yy_lp; - goto find_rule; - } - --yy_cp; - yy_current_state = *--yyg->yy_state_ptr; - yyg->yy_lp = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ -case 1: -YY_RULE_SETUP -#line 102 "glcpp/glcpp-lex.l" -{ -} - YY_BREAK -/* Multi-line comments */ -case 2: -YY_RULE_SETUP -#line 106 "glcpp/glcpp-lex.l" -{ yy_push_state(COMMENT, yyscanner); } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 107 "glcpp/glcpp-lex.l" - - YY_BREAK -case 4: -/* rule 4 can match eol */ -YY_RULE_SETUP -#line 108 "glcpp/glcpp-lex.l" -{ yylineno++; yycolumn = 0; return NEWLINE; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 109 "glcpp/glcpp-lex.l" - - YY_BREAK -case 6: -/* rule 6 can match eol */ -YY_RULE_SETUP -#line 110 "glcpp/glcpp-lex.l" -{ yylineno++; yycolumn = 0; return NEWLINE; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 111 "glcpp/glcpp-lex.l" -{ - yy_pop_state(yyscanner); - if (yyextra->space_tokens) - return SPACE; -} - YY_BREAK -case 8: -YY_RULE_SETUP -#line 117 "glcpp/glcpp-lex.l" -{ - yylval->str = ralloc_strdup (yyextra, yytext); - yyextra->space_tokens = 0; - return HASH_VERSION; -} - YY_BREAK -/* glcpp doesn't handle #extension, #version, or #pragma directives. - * Simply pass them through to the main compiler's lexer/parser. */ -case 9: -YY_RULE_SETUP -#line 125 "glcpp/glcpp-lex.l" -{ - yylval->str = ralloc_strdup (yyextra, yytext); - yylineno++; - yycolumn = 0; - return OTHER; -} - YY_BREAK -case 10: -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 132 "glcpp/glcpp-lex.l" -{ - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - yylloc->source = strtol(ptr, NULL, 0); -} - YY_BREAK -case 11: -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 148 "glcpp/glcpp-lex.l" -{ - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; -} - YY_BREAK - -case 12: -YY_RULE_SETUP -#line 164 "glcpp/glcpp-lex.l" -{ - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IFDEF; -} - YY_BREAK -case 13: -YY_RULE_SETUP -#line 170 "glcpp/glcpp-lex.l" -{ - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IFNDEF; -} - YY_BREAK -case 14: -/* rule 14 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 176 "glcpp/glcpp-lex.l" -{ - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IF; -} - YY_BREAK -case 15: -YY_RULE_SETUP -#line 182 "glcpp/glcpp-lex.l" -{ - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_ELIF; -} - YY_BREAK -case 16: -YY_RULE_SETUP -#line 188 "glcpp/glcpp-lex.l" -{ - yyextra->space_tokens = 0; - return HASH_ELSE; -} - YY_BREAK -case 17: -YY_RULE_SETUP -#line 193 "glcpp/glcpp-lex.l" -{ - yyextra->space_tokens = 0; - return HASH_ENDIF; -} - YY_BREAK - -case 18: -YY_RULE_SETUP -#line 199 "glcpp/glcpp-lex.l" -; - YY_BREAK -case 19: -YY_RULE_SETUP -#line 201 "glcpp/glcpp-lex.l" -{ - char *p; - for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */ - p += 5; /* skip "error" */ - glcpp_error(yylloc, yyextra, "#error%s", p); -} - YY_BREAK -case 20: -YY_RULE_SETUP -#line 208 "glcpp/glcpp-lex.l" -{ - yyextra->space_tokens = 0; - return HASH_DEFINE_FUNC; -} - YY_BREAK -case 21: -YY_RULE_SETUP -#line 213 "glcpp/glcpp-lex.l" -{ - yyextra->space_tokens = 0; - return HASH_DEFINE_OBJ; -} - YY_BREAK -case 22: -YY_RULE_SETUP -#line 218 "glcpp/glcpp-lex.l" -{ - yyextra->space_tokens = 0; - return HASH_UNDEF; -} - YY_BREAK -case 23: -YY_RULE_SETUP -#line 223 "glcpp/glcpp-lex.l" -{ - yyextra->space_tokens = 0; - return HASH; -} - YY_BREAK -case 24: -YY_RULE_SETUP -#line 228 "glcpp/glcpp-lex.l" -{ - yylval->str = ralloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - YY_BREAK -case 25: -YY_RULE_SETUP -#line 233 "glcpp/glcpp-lex.l" -{ - yylval->str = ralloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - YY_BREAK -case 26: -YY_RULE_SETUP -#line 238 "glcpp/glcpp-lex.l" -{ - yylval->str = ralloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - YY_BREAK -case 27: -YY_RULE_SETUP -#line 243 "glcpp/glcpp-lex.l" -{ - return LEFT_SHIFT; -} - YY_BREAK -case 28: -YY_RULE_SETUP -#line 247 "glcpp/glcpp-lex.l" -{ - return RIGHT_SHIFT; -} - YY_BREAK -case 29: -YY_RULE_SETUP -#line 251 "glcpp/glcpp-lex.l" -{ - return LESS_OR_EQUAL; -} - YY_BREAK -case 30: -YY_RULE_SETUP -#line 255 "glcpp/glcpp-lex.l" -{ - return GREATER_OR_EQUAL; -} - YY_BREAK -case 31: -YY_RULE_SETUP -#line 259 "glcpp/glcpp-lex.l" -{ - return EQUAL; -} - YY_BREAK -case 32: -YY_RULE_SETUP -#line 263 "glcpp/glcpp-lex.l" -{ - return NOT_EQUAL; -} - YY_BREAK -case 33: -YY_RULE_SETUP -#line 267 "glcpp/glcpp-lex.l" -{ - return AND; -} - YY_BREAK -case 34: -YY_RULE_SETUP -#line 271 "glcpp/glcpp-lex.l" -{ - return OR; -} - YY_BREAK -case 35: -YY_RULE_SETUP -#line 275 "glcpp/glcpp-lex.l" -{ - return PASTE; -} - YY_BREAK -case 36: -YY_RULE_SETUP -#line 279 "glcpp/glcpp-lex.l" -{ - return DEFINED; -} - YY_BREAK -case 37: -YY_RULE_SETUP -#line 283 "glcpp/glcpp-lex.l" -{ - yylval->str = ralloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - YY_BREAK -case 38: -YY_RULE_SETUP -#line 288 "glcpp/glcpp-lex.l" -{ - return yytext[0]; -} - YY_BREAK -case 39: -YY_RULE_SETUP -#line 292 "glcpp/glcpp-lex.l" -{ - yylval->str = ralloc_strdup (yyextra, yytext); - return OTHER; -} - YY_BREAK -case 40: -YY_RULE_SETUP -#line 297 "glcpp/glcpp-lex.l" -{ - if (yyextra->space_tokens) { - return SPACE; - } -} - YY_BREAK -case 41: -/* rule 41 can match eol */ -YY_RULE_SETUP -#line 303 "glcpp/glcpp-lex.l" -{ - yyextra->lexing_if = 0; - yylineno++; - yycolumn = 0; - return NEWLINE; -} - YY_BREAK -/* Handle missing newline at EOF. */ -case YY_STATE_EOF(INITIAL): -#line 311 "glcpp/glcpp-lex.l" -{ - BEGIN DONE; /* Don't keep matching this rule forever. */ - yyextra->lexing_if = 0; - return NEWLINE; -} - YY_BREAK -/* We don't actually use the UNREACHABLE start condition. We - only have this action here so that we can pretend to call some - generated functions, (to avoid "defined but not used" - warnings. */ -case 42: -YY_RULE_SETUP -#line 321 "glcpp/glcpp-lex.l" -{ - unput('.'); - yy_top_state(yyextra); -} - YY_BREAK -case 43: -YY_RULE_SETUP -#line 326 "glcpp/glcpp-lex.l" -ECHO; - YY_BREAK -#line 1418 "glcpp/glcpp-lex.c" - case YY_STATE_EOF(DONE): - case YY_STATE_EOF(COMMENT): - case YY_STATE_EOF(UNREACHABLE): - case YY_STATE_EOF(SKIP): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * glcpp_lex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( glcpp_wrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of glcpp_lex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - glcpp_restart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) glcpp_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_current_state = yyg->yy_start; - yy_current_state += YY_AT_BOL(); - - yyg->yy_state_ptr = yyg->yy_state_buf; - *yyg->yy_state_ptr++ = yy_current_state; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 154 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *yyg->yy_state_ptr++ = yy_current_state; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -{ - register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - - register YY_CHAR yy_c = 1; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 154 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 153); - if ( ! yy_is_jam ) - *yyg->yy_state_ptr++ = yy_current_state; - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) -{ - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_cp = yyg->yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yyg->yy_n_chars + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - yyg->yytext_ptr = yy_bp; - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - glcpp_restart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( glcpp_wrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void glcpp_restart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - glcpp_ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - glcpp__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - glcpp__load_buffer_state(yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void glcpp__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * glcpp_pop_buffer_state(); - * glcpp_push_buffer_state(new_buffer); - */ - glcpp_ensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - glcpp__load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (glcpp_wrap()) processing, but the only time this flag - * is looked at is after glcpp_wrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; -} - -static void glcpp__load_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE glcpp__create_buffer (FILE * file, int size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) glcpp_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in glcpp__create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) glcpp_alloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in glcpp__create_buffer()" ); - - b->yy_is_our_buffer = 1; - - glcpp__init_buffer(b,file ,yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with glcpp__create_buffer() - * @param yyscanner The scanner object. - */ - void glcpp__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - glcpp_free((void *) b->yy_ch_buf ,yyscanner ); - - glcpp_free((void *) b ,yyscanner ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a glcpp_restart() or at EOF. - */ - static void glcpp__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - -{ - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - glcpp__flush_buffer(b ,yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then glcpp__init_buffer was _probably_ - * called from glcpp_restart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void glcpp__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - glcpp__load_buffer_state(yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void glcpp_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - glcpp_ensure_buffer_stack(yyscanner); - - /* This block is copied from glcpp__switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from glcpp__switch_to_buffer. */ - glcpp__load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void glcpp_pop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - glcpp__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - glcpp__load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void glcpp_ensure_buffer_stack (yyscan_t yyscanner) -{ - int num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)glcpp_alloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in glcpp_ensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)glcpp_realloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in glcpp_ensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE glcpp__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) glcpp_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in glcpp__scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - glcpp__switch_to_buffer(b ,yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to glcpp_lex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * glcpp__scan_bytes() instead. - */ -YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner) -{ - - return glcpp__scan_bytes(yystr,strlen(yystr) ,yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to glcpp_lex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE glcpp__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) glcpp_alloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in glcpp__scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = glcpp__scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in glcpp__scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - - static void yy_push_state (int new_state , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth ) - { - yy_size_t new_size; - - yyg->yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yyg->yy_start_stack_depth * sizeof( int ); - - if ( ! yyg->yy_start_stack ) - yyg->yy_start_stack = (int *) glcpp_alloc(new_size ,yyscanner ); - - else - yyg->yy_start_stack = (int *) glcpp_realloc((void *) yyg->yy_start_stack,new_size ,yyscanner ); - - if ( ! yyg->yy_start_stack ) - YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); - } - - yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); -} - - static void yy_pop_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( --yyg->yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]); -} - - static int yy_top_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1]; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE glcpp_get_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int glcpp_get_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int glcpp_get_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *glcpp_get_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *glcpp_get_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int glcpp_get_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *glcpp_get_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void glcpp_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param line_number - * @param yyscanner The scanner object. - */ -void glcpp_set_lineno (int line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "glcpp_set_lineno called with no buffer" , yyscanner); - - yylineno = line_number; -} - -/** Set the current column. - * @param line_number - * @param yyscanner The scanner object. - */ -void glcpp_set_column (int column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "glcpp_set_column called with no buffer" , yyscanner); - - yycolumn = column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * @param yyscanner The scanner object. - * @see glcpp__switch_to_buffer - */ -void glcpp_set_in (FILE * in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; -} - -void glcpp_set_out (FILE * out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; -} - -int glcpp_get_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void glcpp_set_debug (int bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -YYSTYPE * glcpp_get_lval (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylval; -} - -void glcpp_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylval = yylval_param; -} - -YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylloc; -} - -void glcpp_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylloc = yylloc_param; -} - -/* User-visible API */ - -/* glcpp_lex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ - -int glcpp_lex_init(yyscan_t* ptr_yy_globals) - -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) glcpp_alloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - -/* glcpp_lex_init_extra has the same functionality as glcpp_lex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to glcpp_alloc in - * the yyextra field. - */ - -int glcpp_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - -{ - struct yyguts_t dummy_yyguts; - - glcpp_set_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) glcpp_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - glcpp_set_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from glcpp_lex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - - yyg->yy_state_buf = 0; - yyg->yy_state_ptr = 0; - yyg->yy_full_match = 0; - yyg->yy_lp = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * glcpp_lex_init() - */ - return 0; -} - -/* glcpp_lex_destroy is for both reentrant and non-reentrant scanners. */ -int glcpp_lex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - glcpp__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - glcpp_pop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - glcpp_free(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - glcpp_free(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; - - glcpp_free ( yyg->yy_state_buf , yyscanner); - yyg->yy_state_buf = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * glcpp_lex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - glcpp_free ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *glcpp_alloc (yy_size_t size , yyscan_t yyscanner) -{ - return (void *) malloc( size ); -} - -void *glcpp_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void glcpp_free (void * ptr , yyscan_t yyscanner) -{ - free( (char *) ptr ); /* see glcpp_realloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 326 "glcpp/glcpp-lex.l" - - - -void -glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader) -{ - glcpp__scan_string(shader,parser->scanner); -} - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.l b/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.l deleted file mode 100644 index b34f2c0e9ad..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-lex.l +++ /dev/null @@ -1,332 +0,0 @@ -%{ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include - -#include "glcpp.h" -#include "glcpp-parse.h" - -/* Flex annoyingly generates some functions without making them - * static. Let's declare them here. */ -int glcpp_get_column (yyscan_t yyscanner); -void glcpp_set_column (int column_no , yyscan_t yyscanner); - -#ifdef _MSC_VER -#define YY_NO_UNISTD_H -#endif - -#define YY_NO_INPUT - -#define YY_USER_ACTION \ - do { \ - yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno; \ - yycolumn += yyleng; \ - } while(0); - -#define YY_USER_INIT \ - do { \ - yylineno = 1; \ - yycolumn = 1; \ - yylloc->source = 0; \ - } while(0) -%} - -%option bison-bridge bison-locations reentrant noyywrap -%option extra-type="glcpp_parser_t *" -%option prefix="glcpp_" -%option stack -%option never-interactive - -%x DONE COMMENT UNREACHABLE SKIP - -SPACE [[:space:]] -NONSPACE [^[:space:]] -NEWLINE [\n] -HSPACE [ \t] -HASH ^{HSPACE}*#{HSPACE}* -IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]* -PUNCTUATION [][(){}.&*~!/%<>^|;,=+-] - -/* The OTHER class is simply a catch-all for things that the CPP -parser just doesn't care about. Since flex regular expressions that -match longer strings take priority over those matching shorter -strings, we have to be careful to avoid OTHER matching and hiding -something that CPP does care about. So we simply exclude all -characters that appear in any other expressions. */ - -OTHER [^][_#[:space:]#a-zA-Z0-9(){}.&*~!/%<>^|;,=+-] - -DIGITS [0-9][0-9]* -DECIMAL_INTEGER [1-9][0-9]*[uU]? -OCTAL_INTEGER 0[0-7]*[uU]? -HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? - -%% - /* Implicitly switch between SKIP and INITIAL (non-skipping); - * don't switch if some other state was explicitly set. - */ - glcpp_parser_t *parser = yyextra; - if (YY_START == 0 || YY_START == SKIP) { - if (parser->lexing_if || parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) { - BEGIN 0; - } else { - BEGIN SKIP; - } - } - - /* Single-line comments */ -"//"[^\n]* { -} - - /* Multi-line comments */ -"/*" { yy_push_state(COMMENT, yyscanner); } -[^*\n]* -[^*\n]*\n { yylineno++; yycolumn = 0; return NEWLINE; } -"*"+[^*/\n]* -"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; return NEWLINE; } -"*"+"/" { - yy_pop_state(yyscanner); - if (yyextra->space_tokens) - return SPACE; -} - -{HASH}version { - yylval->str = ralloc_strdup (yyextra, yytext); - yyextra->space_tokens = 0; - return HASH_VERSION; -} - - /* glcpp doesn't handle #extension, #version, or #pragma directives. - * Simply pass them through to the main compiler's lexer/parser. */ -{HASH}(extension|pragma)[^\n]+ { - yylval->str = ralloc_strdup (yyextra, yytext); - yylineno++; - yycolumn = 0; - return OTHER; -} - -{HASH}line{HSPACE}+{DIGITS}{HSPACE}+{DIGITS}{HSPACE}*$ { - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - yylloc->source = strtol(ptr, NULL, 0); -} - -{HASH}line{HSPACE}+{DIGITS}{HSPACE}*$ { - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; -} - -{ -{HASH}ifdef { - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IFDEF; -} - -{HASH}ifndef { - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IFNDEF; -} - -{HASH}if/[^_a-zA-Z0-9] { - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_IF; -} - -{HASH}elif { - yyextra->lexing_if = 1; - yyextra->space_tokens = 0; - return HASH_ELIF; -} - -{HASH}else { - yyextra->space_tokens = 0; - return HASH_ELSE; -} - -{HASH}endif { - yyextra->space_tokens = 0; - return HASH_ENDIF; -} -} - -[^\n] ; - -{HASH}error.* { - char *p; - for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */ - p += 5; /* skip "error" */ - glcpp_error(yylloc, yyextra, "#error%s", p); -} - -{HASH}define{HSPACE}+/{IDENTIFIER}"(" { - yyextra->space_tokens = 0; - return HASH_DEFINE_FUNC; -} - -{HASH}define { - yyextra->space_tokens = 0; - return HASH_DEFINE_OBJ; -} - -{HASH}undef { - yyextra->space_tokens = 0; - return HASH_UNDEF; -} - -{HASH} { - yyextra->space_tokens = 0; - return HASH; -} - -{DECIMAL_INTEGER} { - yylval->str = ralloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - -{OCTAL_INTEGER} { - yylval->str = ralloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - -{HEXADECIMAL_INTEGER} { - yylval->str = ralloc_strdup (yyextra, yytext); - return INTEGER_STRING; -} - -"<<" { - return LEFT_SHIFT; -} - -">>" { - return RIGHT_SHIFT; -} - -"<=" { - return LESS_OR_EQUAL; -} - -">=" { - return GREATER_OR_EQUAL; -} - -"==" { - return EQUAL; -} - -"!=" { - return NOT_EQUAL; -} - -"&&" { - return AND; -} - -"||" { - return OR; -} - -"##" { - return PASTE; -} - -"defined" { - return DEFINED; -} - -{IDENTIFIER} { - yylval->str = ralloc_strdup (yyextra, yytext); - return IDENTIFIER; -} - -{PUNCTUATION} { - return yytext[0]; -} - -{OTHER}+ { - yylval->str = ralloc_strdup (yyextra, yytext); - return OTHER; -} - -{HSPACE}+ { - if (yyextra->space_tokens) { - return SPACE; - } -} - -\n { - yyextra->lexing_if = 0; - yylineno++; - yycolumn = 0; - return NEWLINE; -} - - /* Handle missing newline at EOF. */ -<> { - BEGIN DONE; /* Don't keep matching this rule forever. */ - yyextra->lexing_if = 0; - return NEWLINE; -} - - /* We don't actually use the UNREACHABLE start condition. We - only have this action here so that we can pretend to call some - generated functions, (to avoid "defined but not used" - warnings. */ -. { - unput('.'); - yy_top_state(yyextra); -} - -%% - -void -glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader) -{ - yy_scan_string(shader, parser->scanner); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.c deleted file mode 100644 index e9ff4e21fed..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.c +++ /dev/null @@ -1,4224 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.4.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - -/* Using locations. */ -#define YYLSP_NEEDED 1 - - - -/* Copy the first part of user declarations. */ - -/* Line 189 of yacc.c */ -#line 1 "glcpp/glcpp-parse.y" - -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include -#include -#include - -#include "glcpp.h" -#include "main/core.h" /* for struct gl_extensions */ -#include "main/mtypes.h" /* for gl_api enum */ - -static void -yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error); - -static void -_define_object_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *macro, - token_list_t *replacements); - -static void -_define_function_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *macro, - string_list_t *parameters, - token_list_t *replacements); - -static string_list_t * -_string_list_create (void *ctx); - -static void -_string_list_append_item (string_list_t *list, const char *str); - -static int -_string_list_contains (string_list_t *list, const char *member, int *index); - -static int -_string_list_length (string_list_t *list); - -static int -_string_list_equal (string_list_t *a, string_list_t *b); - -static argument_list_t * -_argument_list_create (void *ctx); - -static void -_argument_list_append (argument_list_t *list, token_list_t *argument); - -static int -_argument_list_length (argument_list_t *list); - -static token_list_t * -_argument_list_member_at (argument_list_t *list, int index); - -/* Note: This function ralloc_steal()s the str pointer. */ -static token_t * -_token_create_str (void *ctx, int type, char *str); - -static token_t * -_token_create_ival (void *ctx, int type, int ival); - -static token_list_t * -_token_list_create (void *ctx); - -static void -_token_list_append (token_list_t *list, token_t *token); - -static void -_token_list_append_list (token_list_t *list, token_list_t *tail); - -static int -_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b); - -static void -_parser_active_list_push (glcpp_parser_t *parser, - const char *identifier, - token_node_t *marker); - -static void -_parser_active_list_pop (glcpp_parser_t *parser); - -static int -_parser_active_list_contains (glcpp_parser_t *parser, const char *identifier); - -static void -_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); - -static void -_glcpp_parser_expand_token_list (glcpp_parser_t *parser, - token_list_t *list); - -static void -_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, - token_list_t *list); - -static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, - int condition); - -static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, - const char *type, int condition); - -static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc); - -#define yylex glcpp_parser_lex - -static int -glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); - -static void -glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); - -static void -add_builtin_define(glcpp_parser_t *parser, const char *name, int value); - - - -/* Line 189 of yacc.c */ -#line 215 "glcpp/glcpp-parse.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - COMMA_FINAL = 258, - DEFINED = 259, - ELIF_EXPANDED = 260, - HASH = 261, - HASH_DEFINE_FUNC = 262, - HASH_DEFINE_OBJ = 263, - HASH_ELIF = 264, - HASH_ELSE = 265, - HASH_ENDIF = 266, - HASH_IF = 267, - HASH_IFDEF = 268, - HASH_IFNDEF = 269, - HASH_UNDEF = 270, - HASH_VERSION = 271, - IDENTIFIER = 272, - IF_EXPANDED = 273, - INTEGER = 274, - INTEGER_STRING = 275, - NEWLINE = 276, - OTHER = 277, - PLACEHOLDER = 278, - SPACE = 279, - PASTE = 280, - OR = 281, - AND = 282, - NOT_EQUAL = 283, - EQUAL = 284, - GREATER_OR_EQUAL = 285, - LESS_OR_EQUAL = 286, - RIGHT_SHIFT = 287, - LEFT_SHIFT = 288, - UNARY = 289 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - -/* Copy the second part of user declarations. */ - - -/* Line 264 of yacc.c */ -#line 303 "glcpp/glcpp-parse.c" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ - && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; - YYLTYPE yyls_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 2 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 606 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 57 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 17 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 101 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 162 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 289 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 47, 2, 2, 2, 43, 30, 2, - 45, 46, 41, 39, 49, 40, 54, 42, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 55, - 33, 56, 34, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 50, 2, 51, 29, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 52, 28, 53, 48, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 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, 31, 32, 35, 36, 37, 38, 44 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 4, 7, 9, 11, 13, 16, 20, - 24, 29, 36, 44, 48, 52, 55, 60, 65, 69, - 72, 75, 78, 82, 85, 87, 89, 91, 95, 99, - 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, - 143, 147, 151, 155, 159, 163, 166, 169, 172, 175, - 179, 181, 185, 187, 190, 193, 194, 196, 197, 199, - 202, 207, 209, 211, 214, 216, 219, 221, 223, 225, - 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, - 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, - 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, - 287, 289 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 58, 0, -1, -1, 58, 59, -1, 61, -1, 65, - -1, 60, -1, 6, 66, -1, 18, 63, 21, -1, - 5, 63, 21, -1, 8, 17, 67, 21, -1, 7, - 17, 45, 46, 67, 21, -1, 7, 17, 45, 64, - 46, 67, 21, -1, 15, 17, 21, -1, 12, 70, - 21, -1, 12, 21, -1, 13, 17, 68, 21, -1, - 14, 17, 68, 21, -1, 9, 70, 21, -1, 9, - 21, -1, 10, 21, -1, 11, 21, -1, 16, 62, - 21, -1, 6, 21, -1, 20, -1, 19, -1, 62, - -1, 63, 26, 63, -1, 63, 27, 63, -1, 63, - 28, 63, -1, 63, 29, 63, -1, 63, 30, 63, - -1, 63, 31, 63, -1, 63, 32, 63, -1, 63, - 35, 63, -1, 63, 36, 63, -1, 63, 34, 63, - -1, 63, 33, 63, -1, 63, 37, 63, -1, 63, - 38, 63, -1, 63, 40, 63, -1, 63, 39, 63, - -1, 63, 43, 63, -1, 63, 42, 63, -1, 63, - 41, 63, -1, 47, 63, -1, 48, 63, -1, 40, - 63, -1, 39, 63, -1, 45, 63, 46, -1, 17, - -1, 64, 49, 17, -1, 21, -1, 71, 21, -1, - 71, 21, -1, -1, 71, -1, -1, 71, -1, 4, - 17, -1, 4, 45, 17, 46, -1, 72, -1, 69, - -1, 70, 69, -1, 72, -1, 71, 72, -1, 17, - -1, 20, -1, 73, -1, 22, -1, 24, -1, 50, - -1, 51, -1, 45, -1, 46, -1, 52, -1, 53, - -1, 54, -1, 30, -1, 41, -1, 39, -1, 40, - -1, 48, -1, 47, -1, 42, -1, 43, -1, 38, - -1, 37, -1, 33, -1, 34, -1, 36, -1, 35, - -1, 32, -1, 31, -1, 29, -1, 28, -1, 27, - -1, 26, -1, 55, -1, 49, -1, 56, -1, 25, - -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 180, 180, 182, 186, 189, 194, 195, 199, 202, - 208, 211, 214, 217, 225, 244, 254, 259, 264, 283, - 298, 301, 304, 325, 329, 338, 343, 344, 347, 350, - 353, 356, 359, 362, 365, 368, 371, 374, 377, 380, - 383, 386, 389, 397, 405, 408, 411, 414, 417, 420, - 426, 431, 439, 440, 444, 450, 451, 454, 456, 463, - 467, 471, 476, 480, 487, 492, 499, 503, 507, 511, - 515, 522, 523, 524, 525, 526, 527, 528, 529, 530, - 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, - 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, - 551, 552 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED", - "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ", - "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF", - "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED", - "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE", - "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'", - "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT", - "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'", - "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept", - "input", "line", "expanded_line", "control_line", "integer_constant", - "expression", "identifier_list", "text_line", "non_directive", - "replacement_list", "junk", "conditional_token", "conditional_tokens", - "pp_tokens", "preprocessing_token", "operator", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 124, 94, - 38, 283, 284, 60, 62, 285, 286, 287, 288, 43, - 45, 42, 47, 37, 289, 40, 41, 33, 126, 44, - 91, 93, 123, 125, 46, 59, 61 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 57, 58, 58, 59, 59, 59, 59, 60, 60, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 62, 62, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 64, 64, 65, 65, 66, 67, 67, 68, 68, 69, - 69, 69, 70, 70, 71, 71, 72, 72, 72, 72, - 72, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 0, 2, 1, 1, 1, 2, 3, 3, - 4, 6, 7, 3, 3, 2, 4, 4, 3, 2, - 2, 2, 3, 2, 1, 1, 1, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, - 1, 3, 1, 2, 2, 0, 1, 0, 1, 2, - 4, 1, 1, 2, 1, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 66, 0, 67, 52, 69, - 70, 101, 97, 96, 95, 94, 78, 93, 92, 88, - 89, 91, 90, 87, 86, 80, 81, 79, 84, 85, - 73, 74, 83, 82, 99, 71, 72, 75, 76, 77, - 98, 100, 3, 6, 4, 5, 0, 64, 68, 25, - 24, 0, 0, 0, 0, 0, 26, 0, 23, 7, - 0, 0, 55, 0, 19, 62, 0, 61, 20, 21, - 15, 0, 57, 57, 0, 0, 0, 53, 65, 48, - 47, 0, 45, 46, 9, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 54, 0, 0, 56, 59, 0, 18, - 63, 14, 0, 58, 0, 13, 22, 8, 49, 27, - 28, 29, 30, 31, 32, 33, 37, 36, 34, 35, - 38, 39, 41, 40, 44, 43, 42, 50, 55, 0, - 10, 0, 16, 17, 0, 55, 0, 60, 11, 0, - 51, 12 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 1, 52, 53, 54, 66, 67, 149, 55, 69, - 115, 122, 75, 76, 116, 57, 58 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -147 -static const yytype_int16 yypact[] = -{ - -147, 112, -147, 28, -10, 55, 62, 152, -15, 59, - 192, 85, 86, 87, 51, -147, 28, -147, -147, -147, - -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, - -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, - -147, -147, -147, -147, -147, -147, -147, -147, -147, -147, - -147, -147, -147, -147, -147, -147, 312, -147, -147, -147, - -147, 28, 28, 28, 28, 28, -147, 428, -147, -147, - 352, 63, 392, 17, -147, -147, 232, -147, -147, -147, - -147, 272, 392, 392, 84, 89, 451, -147, -147, -147, - -147, 469, -147, -147, -147, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, -147, 60, 90, 392, -147, 96, -147, - -147, -147, 93, 392, 94, -147, -147, -147, -147, 489, - 505, 520, 534, 547, 558, 558, 18, 18, 18, 18, - 563, 563, 23, 23, -147, -147, -147, -147, 392, 32, - -147, 61, -147, -147, 110, 392, 118, -147, -147, 149, - -147, -147 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -147, -147, -147, -147, -147, 157, -11, -147, -147, -147, - -146, 92, -68, 200, 0, -7, -147 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const yytype_uint8 yytable[] = -{ - 77, 56, 154, 77, 70, 86, 78, 15, 120, 159, - 17, 68, 19, 120, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 117, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 59, 60, 88, - 89, 90, 91, 92, 93, 106, 107, 108, 109, 110, - 111, 112, 118, 88, 110, 111, 112, 61, 62, 77, - 59, 60, 71, 63, 77, 64, 65, 147, 155, 72, - 79, 156, 123, 123, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 82, 83, 84, 125, 148, 157, 114, 88, - 126, 150, 2, 151, 152, 153, 88, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 158, 17, 18, 19, 160, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, - 161, 85, 17, 74, 19, 124, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, - 81, 0, 17, 80, 19, 0, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, - 0, 0, 17, 119, 19, 0, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 73, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, - 0, 0, 17, 121, 19, 0, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, - 0, 0, 17, 87, 19, 0, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, - 0, 0, 17, 113, 19, 0, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 15, - 0, 0, 17, 0, 19, 0, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 0, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 94, - 0, 0, 0, 0, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 112, 127, 0, 0, 0, 0, 95, 96, 97, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 0, 0, 128, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 112, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 112, 108, 109, 110, 111, 112 -}; - -static const yytype_int16 yycheck[] = -{ - 7, 1, 148, 10, 4, 16, 21, 17, 76, 155, - 20, 21, 22, 81, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 17, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 19, 20, 56, - 61, 62, 63, 64, 65, 37, 38, 39, 40, 41, - 42, 43, 45, 70, 41, 42, 43, 39, 40, 76, - 19, 20, 17, 45, 81, 47, 48, 17, 46, 17, - 21, 49, 82, 83, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 112, 17, 17, 17, 21, 46, 46, 45, 116, - 21, 21, 0, 17, 21, 21, 123, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 21, 20, 21, 22, 17, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, - 21, 14, 20, 21, 22, 83, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, - 10, -1, 20, 21, 22, -1, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, - -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 4, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, - -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, - -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, - -1, -1, 20, 21, 22, -1, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 17, - -1, -1, 20, -1, 22, -1, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, -1, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 21, - -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 21, -1, -1, -1, -1, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, -1, -1, 46, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 39, 40, 41, 42, 43 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 58, 0, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 59, 60, 61, 65, 71, 72, 73, 19, - 20, 39, 40, 45, 47, 48, 62, 63, 21, 66, - 71, 17, 17, 4, 21, 69, 70, 72, 21, 21, - 21, 70, 17, 17, 17, 62, 63, 21, 72, 63, - 63, 63, 63, 63, 21, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 21, 45, 67, 71, 17, 45, 21, - 69, 21, 68, 71, 68, 21, 21, 21, 46, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 17, 46, 64, - 21, 17, 21, 21, 67, 46, 49, 46, 21, 67, - 17, 21 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval, &yylloc, parser) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, Location, parser); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - glcpp_parser_t *parser; -#endif -{ - if (!yyvaluep) - return; - YYUSE (yylocationp); - YYUSE (parser); -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - glcpp_parser_t *parser; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - YY_LOCATION_PRINT (yyoutput, *yylocationp); - YYFPRINTF (yyoutput, ": "); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser) -#else -static void -yy_reduce_print (yyvsp, yylsp, yyrule, parser) - YYSTYPE *yyvsp; - YYLTYPE *yylsp; - int yyrule; - glcpp_parser_t *parser; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , &(yylsp[(yyi + 1) - (yynrhs)]) , parser); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, yylsp, Rule, parser); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser) -#else -static void -yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; - YYLTYPE *yylocationp; - glcpp_parser_t *parser; -#endif -{ - YYUSE (yyvaluep); - YYUSE (yylocationp); - YYUSE (parser); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (glcpp_parser_t *parser); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (glcpp_parser_t *parser) -#else -int -yyparse (parser) - glcpp_parser_t *parser; -#endif -#endif -{ -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Location data for the lookahead symbol. */ -YYLTYPE yylloc; - - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls; - YYLTYPE *yylsp; - - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yyls = yylsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - yylsp = yyls; - -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - /* Initialize the default location before parsing starts. */ - yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 1; -#endif - -/* User initialization code. */ - -/* Line 1251 of yacc.c */ -#line 147 "glcpp/glcpp-parse.y" -{ - yylloc.first_line = 1; - yylloc.first_column = 1; - yylloc.last_line = 1; - yylloc.last_column = 1; - yylloc.source = 0; -} - -/* Line 1251 of yacc.c */ -#line 1617 "glcpp/glcpp-parse.c" - yylsp[0] = yylloc; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - YYLTYPE *yyls1 = yyls; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), - &yystacksize); - - yyls = yyls1; - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); - YYSTACK_RELOCATE (yyls_alloc, yyls); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - yylsp = yyls + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - *++yylsp = yylloc; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 4: - -/* Line 1464 of yacc.c */ -#line 186 "glcpp/glcpp-parse.y" - { - ralloc_strcat (&parser->output, "\n"); - ;} - break; - - case 5: - -/* Line 1464 of yacc.c */ -#line 189 "glcpp/glcpp-parse.y" - { - _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); - ralloc_strcat (&parser->output, "\n"); - ralloc_free ((yyvsp[(1) - (1)].token_list)); - ;} - break; - - case 8: - -/* Line 1464 of yacc.c */ -#line 199 "glcpp/glcpp-parse.y" - { - _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); - ;} - break; - - case 9: - -/* Line 1464 of yacc.c */ -#line 202 "glcpp/glcpp-parse.y" - { - _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); - ;} - break; - - case 10: - -/* Line 1464 of yacc.c */ -#line 208 "glcpp/glcpp-parse.y" - { - _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); - ;} - break; - - case 11: - -/* Line 1464 of yacc.c */ -#line 211 "glcpp/glcpp-parse.y" - { - _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); - ;} - break; - - case 12: - -/* Line 1464 of yacc.c */ -#line 214 "glcpp/glcpp-parse.y" - { - _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); - ;} - break; - - case 13: - -/* Line 1464 of yacc.c */ -#line 217 "glcpp/glcpp-parse.y" - { - macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); - if (macro) { - hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str)); - ralloc_free (macro); - } - ralloc_free ((yyvsp[(2) - (3)].str)); - ;} - break; - - case 14: - -/* Line 1464 of yacc.c */ -#line 225 "glcpp/glcpp-parse.y" - { - /* Be careful to only evaluate the 'if' expression if - * we are not skipping. When we are skipping, we - * simply push a new 0-valued 'if' onto the skip - * stack. - * - * This avoids generating diagnostics for invalid - * expressions that are being skipped. */ - if (parser->skip_stack == NULL || - parser->skip_stack->type == SKIP_NO_SKIP) - { - _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list)); - } - else - { - _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0); - parser->skip_stack->type = SKIP_TO_ENDIF; - } - ;} - break; - - case 15: - -/* Line 1464 of yacc.c */ -#line 244 "glcpp/glcpp-parse.y" - { - /* #if without an expression is only an error if we - * are not skipping */ - if (parser->skip_stack == NULL || - parser->skip_stack->type == SKIP_NO_SKIP) - { - glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression"); - } - _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0); - ;} - break; - - case 16: - -/* Line 1464 of yacc.c */ -#line 254 "glcpp/glcpp-parse.y" - { - macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); - ralloc_free ((yyvsp[(2) - (4)].str)); - _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL); - ;} - break; - - case 17: - -/* Line 1464 of yacc.c */ -#line 259 "glcpp/glcpp-parse.y" - { - macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); - ralloc_free ((yyvsp[(2) - (4)].str)); - _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL); - ;} - break; - - case 18: - -/* Line 1464 of yacc.c */ -#line 264 "glcpp/glcpp-parse.y" - { - /* Be careful to only evaluate the 'elif' expression - * if we are not skipping. When we are skipping, we - * simply change to a 0-valued 'elif' on the skip - * stack. - * - * This avoids generating diagnostics for invalid - * expressions that are being skipped. */ - if (parser->skip_stack && - parser->skip_stack->type == SKIP_TO_ELSE) - { - _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list)); - } - else - { - _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), - "elif", 0); - } - ;} - break; - - case 19: - -/* Line 1464 of yacc.c */ -#line 283 "glcpp/glcpp-parse.y" - { - /* #elif without an expression is an error unless we - * are skipping. */ - if (parser->skip_stack && - parser->skip_stack->type == SKIP_TO_ELSE) - { - glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression"); - } - else - { - _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), - "elif", 0); - glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression"); - } - ;} - break; - - case 20: - -/* Line 1464 of yacc.c */ -#line 298 "glcpp/glcpp-parse.y" - { - _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); - ;} - break; - - case 21: - -/* Line 1464 of yacc.c */ -#line 301 "glcpp/glcpp-parse.y" - { - _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); - ;} - break; - - case 22: - -/* Line 1464 of yacc.c */ -#line 304 "glcpp/glcpp-parse.y" - { - macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); - if (macro) { - hash_table_remove (parser->defines, "__VERSION__"); - ralloc_free (macro); - } - add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival)); - - if ((yyvsp[(2) - (3)].ival) == 100) - add_builtin_define (parser, "GL_ES", 1); - - /* Currently, all ES2 implementations support highp in the - * fragment shader, so we always define this macro in ES2. - * If we ever get a driver that doesn't support highp, we'll - * need to add a flag to the gl_context and check that here. - */ - if ((yyvsp[(2) - (3)].ival) >= 130 || (yyvsp[(2) - (3)].ival) == 100) - add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1); - - ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival)); - ;} - break; - - case 24: - -/* Line 1464 of yacc.c */ -#line 329 "glcpp/glcpp-parse.y" - { - if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { - (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); - } else if ((yyvsp[(1) - (1)].str)[0] == '0') { - (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8); - } else { - (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10); - } - ;} - break; - - case 25: - -/* Line 1464 of yacc.c */ -#line 338 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (1)].ival); - ;} - break; - - case 27: - -/* Line 1464 of yacc.c */ -#line 344 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); - ;} - break; - - case 28: - -/* Line 1464 of yacc.c */ -#line 347 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); - ;} - break; - - case 29: - -/* Line 1464 of yacc.c */ -#line 350 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); - ;} - break; - - case 30: - -/* Line 1464 of yacc.c */ -#line 353 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); - ;} - break; - - case 31: - -/* Line 1464 of yacc.c */ -#line 356 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); - ;} - break; - - case 32: - -/* Line 1464 of yacc.c */ -#line 359 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); - ;} - break; - - case 33: - -/* Line 1464 of yacc.c */ -#line 362 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); - ;} - break; - - case 34: - -/* Line 1464 of yacc.c */ -#line 365 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); - ;} - break; - - case 35: - -/* Line 1464 of yacc.c */ -#line 368 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); - ;} - break; - - case 36: - -/* Line 1464 of yacc.c */ -#line 371 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); - ;} - break; - - case 37: - -/* Line 1464 of yacc.c */ -#line 374 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); - ;} - break; - - case 38: - -/* Line 1464 of yacc.c */ -#line 377 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); - ;} - break; - - case 39: - -/* Line 1464 of yacc.c */ -#line 380 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); - ;} - break; - - case 40: - -/* Line 1464 of yacc.c */ -#line 383 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); - ;} - break; - - case 41: - -/* Line 1464 of yacc.c */ -#line 386 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); - ;} - break; - - case 42: - -/* Line 1464 of yacc.c */ -#line 389 "glcpp/glcpp-parse.y" - { - if ((yyvsp[(3) - (3)].ival) == 0) { - yyerror (& (yylsp[(1) - (3)]), parser, - "zero modulus in preprocessor directive"); - } else { - (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); - } - ;} - break; - - case 43: - -/* Line 1464 of yacc.c */ -#line 397 "glcpp/glcpp-parse.y" - { - if ((yyvsp[(3) - (3)].ival) == 0) { - yyerror (& (yylsp[(1) - (3)]), parser, - "division by 0 in preprocessor directive"); - } else { - (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); - } - ;} - break; - - case 44: - -/* Line 1464 of yacc.c */ -#line 405 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); - ;} - break; - - case 45: - -/* Line 1464 of yacc.c */ -#line 408 "glcpp/glcpp-parse.y" - { - (yyval.ival) = ! (yyvsp[(2) - (2)].ival); - ;} - break; - - case 46: - -/* Line 1464 of yacc.c */ -#line 411 "glcpp/glcpp-parse.y" - { - (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); - ;} - break; - - case 47: - -/* Line 1464 of yacc.c */ -#line 414 "glcpp/glcpp-parse.y" - { - (yyval.ival) = - (yyvsp[(2) - (2)].ival); - ;} - break; - - case 48: - -/* Line 1464 of yacc.c */ -#line 417 "glcpp/glcpp-parse.y" - { - (yyval.ival) = + (yyvsp[(2) - (2)].ival); - ;} - break; - - case 49: - -/* Line 1464 of yacc.c */ -#line 420 "glcpp/glcpp-parse.y" - { - (yyval.ival) = (yyvsp[(2) - (3)].ival); - ;} - break; - - case 50: - -/* Line 1464 of yacc.c */ -#line 426 "glcpp/glcpp-parse.y" - { - (yyval.string_list) = _string_list_create (parser); - _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); - ralloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str)); - ;} - break; - - case 51: - -/* Line 1464 of yacc.c */ -#line 431 "glcpp/glcpp-parse.y" - { - (yyval.string_list) = (yyvsp[(1) - (3)].string_list); - _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); - ralloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str)); - ;} - break; - - case 52: - -/* Line 1464 of yacc.c */ -#line 439 "glcpp/glcpp-parse.y" - { (yyval.token_list) = NULL; ;} - break; - - case 54: - -/* Line 1464 of yacc.c */ -#line 444 "glcpp/glcpp-parse.y" - { - yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); - ;} - break; - - case 55: - -/* Line 1464 of yacc.c */ -#line 450 "glcpp/glcpp-parse.y" - { (yyval.token_list) = NULL; ;} - break; - - case 58: - -/* Line 1464 of yacc.c */ -#line 456 "glcpp/glcpp-parse.y" - { - glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); - ;} - break; - - case 59: - -/* Line 1464 of yacc.c */ -#line 463 "glcpp/glcpp-parse.y" - { - int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; - (yyval.token) = _token_create_ival (parser, INTEGER, v); - ;} - break; - - case 60: - -/* Line 1464 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" - { - int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; - (yyval.token) = _token_create_ival (parser, INTEGER, v); - ;} - break; - - case 62: - -/* Line 1464 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" - { - (yyval.token_list) = _token_list_create (parser); - _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token)); - ;} - break; - - case 63: - -/* Line 1464 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" - { - (yyval.token_list) = (yyvsp[(1) - (2)].token_list); - _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); - ;} - break; - - case 64: - -/* Line 1464 of yacc.c */ -#line 487 "glcpp/glcpp-parse.y" - { - parser->space_tokens = 1; - (yyval.token_list) = _token_list_create (parser); - _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token)); - ;} - break; - - case 65: - -/* Line 1464 of yacc.c */ -#line 492 "glcpp/glcpp-parse.y" - { - (yyval.token_list) = (yyvsp[(1) - (2)].token_list); - _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); - ;} - break; - - case 66: - -/* Line 1464 of yacc.c */ -#line 499 "glcpp/glcpp-parse.y" - { - (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); - (yyval.token)->location = yylloc; - ;} - break; - - case 67: - -/* Line 1464 of yacc.c */ -#line 503 "glcpp/glcpp-parse.y" - { - (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); - (yyval.token)->location = yylloc; - ;} - break; - - case 68: - -/* Line 1464 of yacc.c */ -#line 507 "glcpp/glcpp-parse.y" - { - (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); - (yyval.token)->location = yylloc; - ;} - break; - - case 69: - -/* Line 1464 of yacc.c */ -#line 511 "glcpp/glcpp-parse.y" - { - (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); - (yyval.token)->location = yylloc; - ;} - break; - - case 70: - -/* Line 1464 of yacc.c */ -#line 515 "glcpp/glcpp-parse.y" - { - (yyval.token) = _token_create_ival (parser, SPACE, SPACE); - (yyval.token)->location = yylloc; - ;} - break; - - case 71: - -/* Line 1464 of yacc.c */ -#line 522 "glcpp/glcpp-parse.y" - { (yyval.ival) = '['; ;} - break; - - case 72: - -/* Line 1464 of yacc.c */ -#line 523 "glcpp/glcpp-parse.y" - { (yyval.ival) = ']'; ;} - break; - - case 73: - -/* Line 1464 of yacc.c */ -#line 524 "glcpp/glcpp-parse.y" - { (yyval.ival) = '('; ;} - break; - - case 74: - -/* Line 1464 of yacc.c */ -#line 525 "glcpp/glcpp-parse.y" - { (yyval.ival) = ')'; ;} - break; - - case 75: - -/* Line 1464 of yacc.c */ -#line 526 "glcpp/glcpp-parse.y" - { (yyval.ival) = '{'; ;} - break; - - case 76: - -/* Line 1464 of yacc.c */ -#line 527 "glcpp/glcpp-parse.y" - { (yyval.ival) = '}'; ;} - break; - - case 77: - -/* Line 1464 of yacc.c */ -#line 528 "glcpp/glcpp-parse.y" - { (yyval.ival) = '.'; ;} - break; - - case 78: - -/* Line 1464 of yacc.c */ -#line 529 "glcpp/glcpp-parse.y" - { (yyval.ival) = '&'; ;} - break; - - case 79: - -/* Line 1464 of yacc.c */ -#line 530 "glcpp/glcpp-parse.y" - { (yyval.ival) = '*'; ;} - break; - - case 80: - -/* Line 1464 of yacc.c */ -#line 531 "glcpp/glcpp-parse.y" - { (yyval.ival) = '+'; ;} - break; - - case 81: - -/* Line 1464 of yacc.c */ -#line 532 "glcpp/glcpp-parse.y" - { (yyval.ival) = '-'; ;} - break; - - case 82: - -/* Line 1464 of yacc.c */ -#line 533 "glcpp/glcpp-parse.y" - { (yyval.ival) = '~'; ;} - break; - - case 83: - -/* Line 1464 of yacc.c */ -#line 534 "glcpp/glcpp-parse.y" - { (yyval.ival) = '!'; ;} - break; - - case 84: - -/* Line 1464 of yacc.c */ -#line 535 "glcpp/glcpp-parse.y" - { (yyval.ival) = '/'; ;} - break; - - case 85: - -/* Line 1464 of yacc.c */ -#line 536 "glcpp/glcpp-parse.y" - { (yyval.ival) = '%'; ;} - break; - - case 86: - -/* Line 1464 of yacc.c */ -#line 537 "glcpp/glcpp-parse.y" - { (yyval.ival) = LEFT_SHIFT; ;} - break; - - case 87: - -/* Line 1464 of yacc.c */ -#line 538 "glcpp/glcpp-parse.y" - { (yyval.ival) = RIGHT_SHIFT; ;} - break; - - case 88: - -/* Line 1464 of yacc.c */ -#line 539 "glcpp/glcpp-parse.y" - { (yyval.ival) = '<'; ;} - break; - - case 89: - -/* Line 1464 of yacc.c */ -#line 540 "glcpp/glcpp-parse.y" - { (yyval.ival) = '>'; ;} - break; - - case 90: - -/* Line 1464 of yacc.c */ -#line 541 "glcpp/glcpp-parse.y" - { (yyval.ival) = LESS_OR_EQUAL; ;} - break; - - case 91: - -/* Line 1464 of yacc.c */ -#line 542 "glcpp/glcpp-parse.y" - { (yyval.ival) = GREATER_OR_EQUAL; ;} - break; - - case 92: - -/* Line 1464 of yacc.c */ -#line 543 "glcpp/glcpp-parse.y" - { (yyval.ival) = EQUAL; ;} - break; - - case 93: - -/* Line 1464 of yacc.c */ -#line 544 "glcpp/glcpp-parse.y" - { (yyval.ival) = NOT_EQUAL; ;} - break; - - case 94: - -/* Line 1464 of yacc.c */ -#line 545 "glcpp/glcpp-parse.y" - { (yyval.ival) = '^'; ;} - break; - - case 95: - -/* Line 1464 of yacc.c */ -#line 546 "glcpp/glcpp-parse.y" - { (yyval.ival) = '|'; ;} - break; - - case 96: - -/* Line 1464 of yacc.c */ -#line 547 "glcpp/glcpp-parse.y" - { (yyval.ival) = AND; ;} - break; - - case 97: - -/* Line 1464 of yacc.c */ -#line 548 "glcpp/glcpp-parse.y" - { (yyval.ival) = OR; ;} - break; - - case 98: - -/* Line 1464 of yacc.c */ -#line 549 "glcpp/glcpp-parse.y" - { (yyval.ival) = ';'; ;} - break; - - case 99: - -/* Line 1464 of yacc.c */ -#line 550 "glcpp/glcpp-parse.y" - { (yyval.ival) = ','; ;} - break; - - case 100: - -/* Line 1464 of yacc.c */ -#line 551 "glcpp/glcpp-parse.y" - { (yyval.ival) = '='; ;} - break; - - case 101: - -/* Line 1464 of yacc.c */ -#line 552 "glcpp/glcpp-parse.y" - { (yyval.ival) = PASTE; ;} - break; - - - -/* Line 1464 of yacc.c */ -#line 2661 "glcpp/glcpp-parse.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - *++yylsp = yyloc; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (&yylloc, parser, YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (&yylloc, parser, yymsg); - } - else - { - yyerror (&yylloc, parser, YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - yyerror_range[1] = yylloc; - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval, &yylloc, parser); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - yyerror_range[1] = yylsp[1-yylen]; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - yyerror_range[1] = *yylsp; - yydestruct ("Error: popping", - yystos[yystate], yyvsp, yylsp, parser); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - *++yyvsp = yylval; - - yyerror_range[2] = yylloc; - /* Using YYLLOC is tempting, but would change the location of - the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); - *++yylsp = yyloc; - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined(yyoverflow) || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (&yylloc, parser, YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, parser); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, yylsp, parser); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - - -/* Line 1684 of yacc.c */ -#line 555 "glcpp/glcpp-parse.y" - - -string_list_t * -_string_list_create (void *ctx) -{ - string_list_t *list; - - list = ralloc (ctx, string_list_t); - list->head = NULL; - list->tail = NULL; - - return list; -} - -void -_string_list_append_item (string_list_t *list, const char *str) -{ - string_node_t *node; - - node = ralloc (list, string_node_t); - node->str = ralloc_strdup (node, str); - - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; -} - -int -_string_list_contains (string_list_t *list, const char *member, int *index) -{ - string_node_t *node; - int i; - - if (list == NULL) - return 0; - - for (i = 0, node = list->head; node; i++, node = node->next) { - if (strcmp (node->str, member) == 0) { - if (index) - *index = i; - return 1; - } - } - - return 0; -} - -int -_string_list_length (string_list_t *list) -{ - int length = 0; - string_node_t *node; - - if (list == NULL) - return 0; - - for (node = list->head; node; node = node->next) - length++; - - return length; -} - -int -_string_list_equal (string_list_t *a, string_list_t *b) -{ - string_node_t *node_a, *node_b; - - if (a == NULL && b == NULL) - return 1; - - if (a == NULL || b == NULL) - return 0; - - for (node_a = a->head, node_b = b->head; - node_a && node_b; - node_a = node_a->next, node_b = node_b->next) - { - if (strcmp (node_a->str, node_b->str)) - return 0; - } - - /* Catch the case of lists being different lengths, (which - * would cause the loop above to terminate after the shorter - * list). */ - return node_a == node_b; -} - -argument_list_t * -_argument_list_create (void *ctx) -{ - argument_list_t *list; - - list = ralloc (ctx, argument_list_t); - list->head = NULL; - list->tail = NULL; - - return list; -} - -void -_argument_list_append (argument_list_t *list, token_list_t *argument) -{ - argument_node_t *node; - - node = ralloc (list, argument_node_t); - node->argument = argument; - - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; -} - -int -_argument_list_length (argument_list_t *list) -{ - int length = 0; - argument_node_t *node; - - if (list == NULL) - return 0; - - for (node = list->head; node; node = node->next) - length++; - - return length; -} - -token_list_t * -_argument_list_member_at (argument_list_t *list, int index) -{ - argument_node_t *node; - int i; - - if (list == NULL) - return NULL; - - node = list->head; - for (i = 0; i < index; i++) { - node = node->next; - if (node == NULL) - break; - } - - if (node) - return node->argument; - - return NULL; -} - -/* Note: This function ralloc_steal()s the str pointer. */ -token_t * -_token_create_str (void *ctx, int type, char *str) -{ - token_t *token; - - token = ralloc (ctx, token_t); - token->type = type; - token->value.str = str; - - ralloc_steal (token, str); - - return token; -} - -token_t * -_token_create_ival (void *ctx, int type, int ival) -{ - token_t *token; - - token = ralloc (ctx, token_t); - token->type = type; - token->value.ival = ival; - - return token; -} - -token_list_t * -_token_list_create (void *ctx) -{ - token_list_t *list; - - list = ralloc (ctx, token_list_t); - list->head = NULL; - list->tail = NULL; - list->non_space_tail = NULL; - - return list; -} - -void -_token_list_append (token_list_t *list, token_t *token) -{ - token_node_t *node; - - node = ralloc (list, token_node_t); - node->token = token; - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; - if (token->type != SPACE) - list->non_space_tail = node; -} - -void -_token_list_append_list (token_list_t *list, token_list_t *tail) -{ - if (tail == NULL || tail->head == NULL) - return; - - if (list->head == NULL) { - list->head = tail->head; - } else { - list->tail->next = tail->head; - } - - list->tail = tail->tail; - list->non_space_tail = tail->non_space_tail; -} - -static token_list_t * -_token_list_copy (void *ctx, token_list_t *other) -{ - token_list_t *copy; - token_node_t *node; - - if (other == NULL) - return NULL; - - copy = _token_list_create (ctx); - for (node = other->head; node; node = node->next) { - token_t *new_token = ralloc (copy, token_t); - *new_token = *node->token; - _token_list_append (copy, new_token); - } - - return copy; -} - -static void -_token_list_trim_trailing_space (token_list_t *list) -{ - token_node_t *tail, *next; - - if (list->non_space_tail) { - tail = list->non_space_tail->next; - list->non_space_tail->next = NULL; - list->tail = list->non_space_tail; - - while (tail) { - next = tail->next; - ralloc_free (tail); - tail = next; - } - } -} - -static int -_token_list_is_empty_ignoring_space (token_list_t *l) -{ - token_node_t *n; - - if (l == NULL) - return 1; - - n = l->head; - while (n != NULL && n->token->type == SPACE) - n = n->next; - - return n == NULL; -} - -int -_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b) -{ - token_node_t *node_a, *node_b; - - if (a == NULL || b == NULL) { - int a_empty = _token_list_is_empty_ignoring_space(a); - int b_empty = _token_list_is_empty_ignoring_space(b); - return a_empty == b_empty; - } - - node_a = a->head; - node_b = b->head; - - while (1) - { - if (node_a == NULL && node_b == NULL) - break; - - if (node_a == NULL || node_b == NULL) - return 0; - - if (node_a->token->type == SPACE) { - node_a = node_a->next; - continue; - } - - if (node_b->token->type == SPACE) { - node_b = node_b->next; - continue; - } - - if (node_a->token->type != node_b->token->type) - return 0; - - switch (node_a->token->type) { - case INTEGER: - if (node_a->token->value.ival != - node_b->token->value.ival) - { - return 0; - } - break; - case IDENTIFIER: - case INTEGER_STRING: - case OTHER: - if (strcmp (node_a->token->value.str, - node_b->token->value.str)) - { - return 0; - } - break; - } - - node_a = node_a->next; - node_b = node_b->next; - } - - return 1; -} - -static void -_token_print (char **out, token_t *token) -{ - if (token->type < 256) { - ralloc_asprintf_append (out, "%c", token->type); - return; - } - - switch (token->type) { - case INTEGER: - ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival); - break; - case IDENTIFIER: - case INTEGER_STRING: - case OTHER: - ralloc_strcat (out, token->value.str); - break; - case SPACE: - ralloc_strcat (out, " "); - break; - case LEFT_SHIFT: - ralloc_strcat (out, "<<"); - break; - case RIGHT_SHIFT: - ralloc_strcat (out, ">>"); - break; - case LESS_OR_EQUAL: - ralloc_strcat (out, "<="); - break; - case GREATER_OR_EQUAL: - ralloc_strcat (out, ">="); - break; - case EQUAL: - ralloc_strcat (out, "=="); - break; - case NOT_EQUAL: - ralloc_strcat (out, "!="); - break; - case AND: - ralloc_strcat (out, "&&"); - break; - case OR: - ralloc_strcat (out, "||"); - break; - case PASTE: - ralloc_strcat (out, "##"); - break; - case COMMA_FINAL: - ralloc_strcat (out, ","); - break; - case PLACEHOLDER: - /* Nothing to print. */ - break; - default: - assert(!"Error: Don't know how to print token."); - break; - } -} - -/* Return a new token (ralloc()ed off of 'token') formed by pasting - * 'token' and 'other'. Note that this function may return 'token' or - * 'other' directly rather than allocating anything new. - * - * Caution: Only very cursory error-checking is performed to see if - * the final result is a valid single token. */ -static token_t * -_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) -{ - token_t *combined = NULL; - - /* Pasting a placeholder onto anything makes no change. */ - if (other->type == PLACEHOLDER) - return token; - - /* When 'token' is a placeholder, just return 'other'. */ - if (token->type == PLACEHOLDER) - return other; - - /* A very few single-character punctuators can be combined - * with another to form a multi-character punctuator. */ - switch (token->type) { - case '<': - if (other->type == '<') - combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); - else if (other->type == '=') - combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); - break; - case '>': - if (other->type == '>') - combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); - else if (other->type == '=') - combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); - break; - case '=': - if (other->type == '=') - combined = _token_create_ival (token, EQUAL, EQUAL); - break; - case '!': - if (other->type == '=') - combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); - break; - case '&': - if (other->type == '&') - combined = _token_create_ival (token, AND, AND); - break; - case '|': - if (other->type == '|') - combined = _token_create_ival (token, OR, OR); - break; - } - - if (combined != NULL) { - /* Inherit the location from the first token */ - combined->location = token->location; - return combined; - } - - /* Two string-valued tokens can usually just be mashed - * together. - * - * XXX: This isn't actually legitimate. Several things here - * should result in a diagnostic since the result cannot be a - * valid, single pre-processing token. For example, pasting - * "123" and "abc" is not legal, but we don't catch that - * here. */ - if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && - (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) - { - char *str; - - str = ralloc_asprintf (token, "%s%s", token->value.str, - other->value.str); - combined = _token_create_str (token, token->type, str); - combined->location = token->location; - return combined; - } - - glcpp_error (&token->location, parser, ""); - ralloc_strcat (&parser->info_log, "Pasting \""); - _token_print (&parser->info_log, token); - ralloc_strcat (&parser->info_log, "\" and \""); - _token_print (&parser->info_log, other); - ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n"); - - return token; -} - -static void -_token_list_print (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - if (list == NULL) - return; - - for (node = list->head; node; node = node->next) - _token_print (&parser->output, node->token); -} - -void -yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) -{ - glcpp_error(locp, parser, "%s", error); -} - -static void add_builtin_define(glcpp_parser_t *parser, - const char *name, int value) -{ - token_t *tok; - token_list_t *list; - - tok = _token_create_ival (parser, INTEGER, value); - - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, name, list); -} - -glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions) -{ - glcpp_parser_t *parser; - int language_version; - - parser = ralloc (NULL, glcpp_parser_t); - - glcpp_lex_init_extra (parser, &parser->scanner); - parser->defines = hash_table_ctor (32, hash_table_string_hash, - hash_table_string_compare); - parser->active = NULL; - parser->lexing_if = 0; - parser->space_tokens = 1; - parser->newline_as_space = 0; - parser->in_control_line = 0; - parser->paren_count = 0; - - parser->skip_stack = NULL; - - parser->lex_from_list = NULL; - parser->lex_from_node = NULL; - - parser->output = ralloc_strdup(parser, ""); - parser->info_log = ralloc_strdup(parser, ""); - parser->error = 0; - - /* Add pre-defined macros. */ - add_builtin_define(parser, "GL_ARB_draw_buffers", 1); - - if (extensions != NULL) { - - if (extensions->ARB_shader_texture_lod) - add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1); - - if (extensions->ARB_conservative_depth) { - add_builtin_define(parser, "GL_AMD_conservative_depth", 1); - add_builtin_define(parser, "GL_ARB_conservative_depth", 1); - } - } - - language_version = 110; - add_builtin_define(parser, "__VERSION__", language_version); - - return parser; -} - -int -glcpp_parser_parse (glcpp_parser_t *parser) -{ - return yyparse (parser); -} - -void -glcpp_parser_destroy (glcpp_parser_t *parser) -{ - glcpp_lex_destroy (parser->scanner); - hash_table_dtor (parser->defines); - ralloc_free (parser); -} - -typedef enum function_status -{ - FUNCTION_STATUS_SUCCESS, - FUNCTION_NOT_A_FUNCTION, - FUNCTION_UNBALANCED_PARENTHESES -} function_status_t; - -/* Find a set of function-like macro arguments by looking for a - * balanced set of parentheses. - * - * When called, 'node' should be the opening-parenthesis token, (or - * perhaps preceeding SPACE tokens). Upon successful return *last will - * be the last consumed node, (corresponding to the closing right - * parenthesis). - * - * Return values: - * - * FUNCTION_STATUS_SUCCESS: - * - * Successfully parsed a set of function arguments. - * - * FUNCTION_NOT_A_FUNCTION: - * - * Macro name not followed by a '('. This is not an error, but - * simply that the macro name should be treated as a non-macro. - * - * FUNCTION_UNBALANCED_PARENTHESES - * - * Macro name is not followed by a balanced set of parentheses. - */ -static function_status_t -_arguments_parse (argument_list_t *arguments, - token_node_t *node, - token_node_t **last) -{ - token_list_t *argument; - int paren_count; - - node = node->next; - - /* Ignore whitespace before first parenthesis. */ - while (node && node->token->type == SPACE) - node = node->next; - - if (node == NULL || node->token->type != '(') - return FUNCTION_NOT_A_FUNCTION; - - node = node->next; - - argument = _token_list_create (arguments); - _argument_list_append (arguments, argument); - - for (paren_count = 1; node; node = node->next) { - if (node->token->type == '(') - { - paren_count++; - } - else if (node->token->type == ')') - { - paren_count--; - if (paren_count == 0) - break; - } - - if (node->token->type == ',' && - paren_count == 1) - { - _token_list_trim_trailing_space (argument); - argument = _token_list_create (arguments); - _argument_list_append (arguments, argument); - } - else { - if (argument->head == NULL) { - /* Don't treat initial whitespace as - * part of the arguement. */ - if (node->token->type == SPACE) - continue; - } - _token_list_append (argument, node->token); - } - } - - if (paren_count) - return FUNCTION_UNBALANCED_PARENTHESES; - - *last = node; - - return FUNCTION_STATUS_SUCCESS; -} - -static token_list_t * -_token_list_create_with_one_space (void *ctx) -{ - token_list_t *list; - token_t *space; - - list = _token_list_create (ctx); - space = _token_create_ival (list, SPACE, SPACE); - _token_list_append (list, space); - - return list; -} - -static void -_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list) -{ - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, type, type); - _token_list_append (expanded, token); - _glcpp_parser_expand_token_list (parser, list); - _token_list_append_list (expanded, list); - glcpp_parser_lex_from (parser, expanded); -} - -static void -_glcpp_parser_apply_pastes (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - node = list->head; - while (node) - { - token_node_t *next_non_space; - - /* Look ahead for a PASTE token, skipping space. */ - next_non_space = node->next; - while (next_non_space && next_non_space->token->type == SPACE) - next_non_space = next_non_space->next; - - if (next_non_space == NULL) - break; - - if (next_non_space->token->type != PASTE) { - node = next_non_space; - continue; - } - - /* Now find the next non-space token after the PASTE. */ - next_non_space = next_non_space->next; - while (next_non_space && next_non_space->token->type == SPACE) - next_non_space = next_non_space->next; - - if (next_non_space == NULL) { - yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); - return; - } - - node->token = _token_paste (parser, node->token, next_non_space->token); - node->next = next_non_space->next; - if (next_non_space == list->tail) - list->tail = node; - } - - list->non_space_tail = list->tail; -} - -/* This is a helper function that's essentially part of the - * implementation of _glcpp_parser_expand_node. It shouldn't be called - * except for by that function. - * - * Returns NULL if node is a simple token with no expansion, (that is, - * although 'node' corresponds to an identifier defined as a - * function-like macro, it is not followed with a parenthesized - * argument list). - * - * Compute the complete expansion of node (which is a function-like - * macro) and subsequent nodes which are arguments. - * - * Returns the token list that results from the expansion and sets - * *last to the last node in the list that was consumed by the - * expansion. Specifically, *last will be set as follows: as the - * token of the closing right parenthesis. - */ -static token_list_t * -_glcpp_parser_expand_function (glcpp_parser_t *parser, - token_node_t *node, - token_node_t **last) - -{ - macro_t *macro; - const char *identifier; - argument_list_t *arguments; - function_status_t status; - token_list_t *substituted; - int parameter_index; - - identifier = node->token->value.str; - - macro = hash_table_find (parser->defines, identifier); - - assert (macro->is_function); - - arguments = _argument_list_create (parser); - status = _arguments_parse (arguments, node, last); - - switch (status) { - case FUNCTION_STATUS_SUCCESS: - break; - case FUNCTION_NOT_A_FUNCTION: - return NULL; - case FUNCTION_UNBALANCED_PARENTHESES: - glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier); - return NULL; - } - - /* Replace a macro defined as empty with a SPACE token. */ - if (macro->replacements == NULL) { - ralloc_free (arguments); - return _token_list_create_with_one_space (parser); - } - - if (! ((_argument_list_length (arguments) == - _string_list_length (macro->parameters)) || - (_string_list_length (macro->parameters) == 0 && - _argument_list_length (arguments) == 1 && - arguments->head->argument->head == NULL))) - { - glcpp_error (&node->token->location, parser, - "Error: macro %s invoked with %d arguments (expected %d)\n", - identifier, - _argument_list_length (arguments), - _string_list_length (macro->parameters)); - return NULL; - } - - /* Perform argument substitution on the replacement list. */ - substituted = _token_list_create (arguments); - - for (node = macro->replacements->head; node; node = node->next) - { - if (node->token->type == IDENTIFIER && - _string_list_contains (macro->parameters, - node->token->value.str, - ¶meter_index)) - { - token_list_t *argument; - argument = _argument_list_member_at (arguments, - parameter_index); - /* Before substituting, we expand the argument - * tokens, or append a placeholder token for - * an empty argument. */ - if (argument->head) { - token_list_t *expanded_argument; - expanded_argument = _token_list_copy (parser, - argument); - _glcpp_parser_expand_token_list (parser, - expanded_argument); - _token_list_append_list (substituted, - expanded_argument); - } else { - token_t *new_token; - - new_token = _token_create_ival (substituted, - PLACEHOLDER, - PLACEHOLDER); - _token_list_append (substituted, new_token); - } - } else { - _token_list_append (substituted, node->token); - } - } - - /* After argument substitution, and before further expansion - * below, implement token pasting. */ - - _token_list_trim_trailing_space (substituted); - - _glcpp_parser_apply_pastes (parser, substituted); - - return substituted; -} - -/* Compute the complete expansion of node, (and subsequent nodes after - * 'node' in the case that 'node' is a function-like macro and - * subsequent nodes are arguments). - * - * Returns NULL if node is a simple token with no expansion. - * - * Otherwise, returns the token list that results from the expansion - * and sets *last to the last node in the list that was consumed by - * the expansion. Specifically, *last will be set as follows: - * - * As 'node' in the case of object-like macro expansion. - * - * As the token of the closing right parenthesis in the case of - * function-like macro expansion. - */ -static token_list_t * -_glcpp_parser_expand_node (glcpp_parser_t *parser, - token_node_t *node, - token_node_t **last) -{ - token_t *token = node->token; - const char *identifier; - macro_t *macro; - - /* We only expand identifiers */ - if (token->type != IDENTIFIER) { - /* We change any COMMA into a COMMA_FINAL to prevent - * it being mistaken for an argument separator - * later. */ - if (token->type == ',') { - token->type = COMMA_FINAL; - token->value.ival = COMMA_FINAL; - } - - return NULL; - } - - /* Look up this identifier in the hash table. */ - identifier = token->value.str; - macro = hash_table_find (parser->defines, identifier); - - /* Not a macro, so no expansion needed. */ - if (macro == NULL) - return NULL; - - /* Finally, don't expand this macro if we're already actively - * expanding it, (to avoid infinite recursion). */ - if (_parser_active_list_contains (parser, identifier)) { - /* We change the token type here from IDENTIFIER to - * OTHER to prevent any future expansion of this - * unexpanded token. */ - char *str; - token_list_t *expansion; - token_t *final; - - str = ralloc_strdup (parser, token->value.str); - final = _token_create_str (parser, OTHER, str); - expansion = _token_list_create (parser); - _token_list_append (expansion, final); - *last = node; - return expansion; - } - - if (! macro->is_function) - { - token_list_t *replacement; - *last = node; - - /* Replace a macro defined as empty with a SPACE token. */ - if (macro->replacements == NULL) - return _token_list_create_with_one_space (parser); - - replacement = _token_list_copy (parser, macro->replacements); - _glcpp_parser_apply_pastes (parser, replacement); - return replacement; - } - - return _glcpp_parser_expand_function (parser, node, last); -} - -/* Push a new identifier onto the parser's active list. - * - * Here, 'marker' is the token node that appears in the list after the - * expansion of 'identifier'. That is, when the list iterator begins - * examining 'marker', then it is time to pop this node from the - * active stack. - */ -static void -_parser_active_list_push (glcpp_parser_t *parser, - const char *identifier, - token_node_t *marker) -{ - active_list_t *node; - - node = ralloc (parser->active, active_list_t); - node->identifier = ralloc_strdup (node, identifier); - node->marker = marker; - node->next = parser->active; - - parser->active = node; -} - -static void -_parser_active_list_pop (glcpp_parser_t *parser) -{ - active_list_t *node = parser->active; - - if (node == NULL) { - parser->active = NULL; - return; - } - - node = parser->active->next; - ralloc_free (parser->active); - - parser->active = node; -} - -static int -_parser_active_list_contains (glcpp_parser_t *parser, const char *identifier) -{ - active_list_t *node; - - if (parser->active == NULL) - return 0; - - for (node = parser->active; node; node = node->next) - if (strcmp (node->identifier, identifier) == 0) - return 1; - - return 0; -} - -/* Walk over the token list replacing nodes with their expansion. - * Whenever nodes are expanded the walking will walk over the new - * nodes, continuing to expand as necessary. The results are placed in - * 'list' itself; - */ -static void -_glcpp_parser_expand_token_list (glcpp_parser_t *parser, - token_list_t *list) -{ - token_node_t *node_prev; - token_node_t *node, *last = NULL; - token_list_t *expansion; - active_list_t *active_initial = parser->active; - - if (list == NULL) - return; - - _token_list_trim_trailing_space (list); - - node_prev = NULL; - node = list->head; - - while (node) { - - while (parser->active && parser->active->marker == node) - _parser_active_list_pop (parser); - - expansion = _glcpp_parser_expand_node (parser, node, &last); - if (expansion) { - token_node_t *n; - - for (n = node; n != last->next; n = n->next) - while (parser->active && - parser->active->marker == n) - { - _parser_active_list_pop (parser); - } - - _parser_active_list_push (parser, - node->token->value.str, - last->next); - - /* Splice expansion into list, supporting a - * simple deletion if the expansion is - * empty. */ - if (expansion->head) { - if (node_prev) - node_prev->next = expansion->head; - else - list->head = expansion->head; - expansion->tail->next = last->next; - if (last == list->tail) - list->tail = expansion->tail; - } else { - if (node_prev) - node_prev->next = last->next; - else - list->head = last->next; - if (last == list->tail) - list->tail = NULL; - } - } else { - node_prev = node; - } - node = node_prev ? node_prev->next : list->head; - } - - /* Remove any lingering effects of this invocation on the - * active list. That is, pop until the list looks like it did - * at the beginning of this function. */ - while (parser->active && parser->active != active_initial) - _parser_active_list_pop (parser); - - list->non_space_tail = list->tail; -} - -void -_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, - token_list_t *list) -{ - if (list == NULL) - return; - - _glcpp_parser_expand_token_list (parser, list); - - _token_list_trim_trailing_space (list); - - _token_list_print (parser, list); -} - -static void -_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, - const char *identifier) -{ - /* According to the GLSL specification, macro names starting with "__" - * or "GL_" are reserved for future use. So, don't allow them. - */ - if (strstr(identifier, "__")) { - glcpp_error (loc, parser, "Macro names containing \"__\" are reserved.\n"); - } - if (strncmp(identifier, "GL_", 3) == 0) { - glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); - } -} - -static int -_macro_equal (macro_t *a, macro_t *b) -{ - if (a->is_function != b->is_function) - return 0; - - if (a->is_function) { - if (! _string_list_equal (a->parameters, b->parameters)) - return 0; - } - - return _token_list_equal_ignoring_space (a->replacements, - b->replacements); -} - -void -_define_object_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *identifier, - token_list_t *replacements) -{ - macro_t *macro, *previous; - - if (loc != NULL) - _check_for_reserved_macro_name(parser, loc, identifier); - - macro = ralloc (parser, macro_t); - - macro->is_function = 0; - macro->parameters = NULL; - macro->identifier = ralloc_strdup (macro, identifier); - macro->replacements = replacements; - ralloc_steal (macro, replacements); - - previous = hash_table_find (parser->defines, identifier); - if (previous) { - if (_macro_equal (macro, previous)) { - ralloc_free (macro); - return; - } - glcpp_error (loc, parser, "Redefinition of macro %s\n", - identifier); - } - - hash_table_insert (parser->defines, macro, identifier); -} - -void -_define_function_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *identifier, - string_list_t *parameters, - token_list_t *replacements) -{ - macro_t *macro, *previous; - - _check_for_reserved_macro_name(parser, loc, identifier); - - macro = ralloc (parser, macro_t); - ralloc_steal (macro, parameters); - ralloc_steal (macro, replacements); - - macro->is_function = 1; - macro->parameters = parameters; - macro->identifier = ralloc_strdup (macro, identifier); - macro->replacements = replacements; - previous = hash_table_find (parser->defines, identifier); - if (previous) { - if (_macro_equal (macro, previous)) { - ralloc_free (macro); - return; - } - glcpp_error (loc, parser, "Redefinition of macro %s\n", - identifier); - } - - hash_table_insert (parser->defines, macro, identifier); -} - -static int -glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser) -{ - token_node_t *node; - int ret; - - if (parser->lex_from_list == NULL) { - ret = glcpp_lex (yylval, yylloc, parser->scanner); - - /* XXX: This ugly block of code exists for the sole - * purpose of converting a NEWLINE token into a SPACE - * token, but only in the case where we have seen a - * function-like macro name, but have not yet seen its - * closing parenthesis. - * - * There's perhaps a more compact way to do this with - * mid-rule actions in the grammar. - * - * I'm definitely not pleased with the complexity of - * this code here. - */ - if (parser->newline_as_space) - { - if (ret == '(') { - parser->paren_count++; - } else if (ret == ')') { - parser->paren_count--; - if (parser->paren_count == 0) - parser->newline_as_space = 0; - } else if (ret == NEWLINE) { - ret = SPACE; - } else if (ret != SPACE) { - if (parser->paren_count == 0) - parser->newline_as_space = 0; - } - } - else if (parser->in_control_line) - { - if (ret == NEWLINE) - parser->in_control_line = 0; - } - else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC || - ret == HASH_UNDEF || ret == HASH_IF || - ret == HASH_IFDEF || ret == HASH_IFNDEF || - ret == HASH_ELIF || ret == HASH_ELSE || - ret == HASH_ENDIF || ret == HASH) - { - parser->in_control_line = 1; - } - else if (ret == IDENTIFIER) - { - macro_t *macro; - macro = hash_table_find (parser->defines, - yylval->str); - if (macro && macro->is_function) { - parser->newline_as_space = 1; - parser->paren_count = 0; - } - } - - return ret; - } - - node = parser->lex_from_node; - - if (node == NULL) { - ralloc_free (parser->lex_from_list); - parser->lex_from_list = NULL; - return NEWLINE; - } - - *yylval = node->token->value; - ret = node->token->type; - - parser->lex_from_node = node->next; - - return ret; -} - -static void -glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - assert (parser->lex_from_list == NULL); - - /* Copy list, eliminating any space tokens. */ - parser->lex_from_list = _token_list_create (parser); - - for (node = list->head; node; node = node->next) { - if (node->token->type == SPACE) - continue; - _token_list_append (parser->lex_from_list, node->token); - } - - ralloc_free (list); - - parser->lex_from_node = parser->lex_from_list->head; - - /* It's possible the list consisted of nothing but whitespace. */ - if (parser->lex_from_node == NULL) { - ralloc_free (parser->lex_from_list); - parser->lex_from_list = NULL; - } -} - -static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, - int condition) -{ - skip_type_t current = SKIP_NO_SKIP; - skip_node_t *node; - - if (parser->skip_stack) - current = parser->skip_stack->type; - - node = ralloc (parser, skip_node_t); - node->loc = *loc; - - if (current == SKIP_NO_SKIP) { - if (condition) - node->type = SKIP_NO_SKIP; - else - node->type = SKIP_TO_ELSE; - } else { - node->type = SKIP_TO_ENDIF; - } - - node->next = parser->skip_stack; - parser->skip_stack = node; -} - -static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, - const char *type, int condition) -{ - if (parser->skip_stack == NULL) { - glcpp_error (loc, parser, "%s without #if\n", type); - return; - } - - if (parser->skip_stack->type == SKIP_TO_ELSE) { - if (condition) - parser->skip_stack->type = SKIP_NO_SKIP; - } else { - parser->skip_stack->type = SKIP_TO_ENDIF; - } -} - -static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc) -{ - skip_node_t *node; - - if (parser->skip_stack == NULL) { - glcpp_error (loc, parser, "#endif without #if\n"); - return; - } - - node = parser->skip_stack; - parser->skip_stack = node->next; - ralloc_free (node); -} - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.h b/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.h deleted file mode 100644 index 40556854f38..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.h +++ /dev/null @@ -1,100 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - COMMA_FINAL = 258, - DEFINED = 259, - ELIF_EXPANDED = 260, - HASH = 261, - HASH_DEFINE_FUNC = 262, - HASH_DEFINE_OBJ = 263, - HASH_ELIF = 264, - HASH_ELSE = 265, - HASH_ENDIF = 266, - HASH_IF = 267, - HASH_IFDEF = 268, - HASH_IFNDEF = 269, - HASH_UNDEF = 270, - HASH_VERSION = 271, - IDENTIFIER = 272, - IF_EXPANDED = 273, - INTEGER = 274, - INTEGER_STRING = 275, - NEWLINE = 276, - OTHER = 277, - PLACEHOLDER = 278, - SPACE = 279, - PASTE = 280, - OR = 281, - AND = 282, - NOT_EQUAL = 283, - EQUAL = 284, - GREATER_OR_EQUAL = 285, - LESS_OR_EQUAL = 286, - RIGHT_SHIFT = 287, - LEFT_SHIFT = 288, - UNARY = 289 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.y b/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.y deleted file mode 100644 index efcc205c2d3..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp-parse.y +++ /dev/null @@ -1,1918 +0,0 @@ -%{ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include -#include -#include - -#include "glcpp.h" -#include "main/core.h" /* for struct gl_extensions */ -#include "main/mtypes.h" /* for gl_api enum */ - -static void -yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error); - -static void -_define_object_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *macro, - token_list_t *replacements); - -static void -_define_function_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *macro, - string_list_t *parameters, - token_list_t *replacements); - -static string_list_t * -_string_list_create (void *ctx); - -static void -_string_list_append_item (string_list_t *list, const char *str); - -static int -_string_list_contains (string_list_t *list, const char *member, int *index); - -static int -_string_list_length (string_list_t *list); - -static int -_string_list_equal (string_list_t *a, string_list_t *b); - -static argument_list_t * -_argument_list_create (void *ctx); - -static void -_argument_list_append (argument_list_t *list, token_list_t *argument); - -static int -_argument_list_length (argument_list_t *list); - -static token_list_t * -_argument_list_member_at (argument_list_t *list, int index); - -/* Note: This function ralloc_steal()s the str pointer. */ -static token_t * -_token_create_str (void *ctx, int type, char *str); - -static token_t * -_token_create_ival (void *ctx, int type, int ival); - -static token_list_t * -_token_list_create (void *ctx); - -static void -_token_list_append (token_list_t *list, token_t *token); - -static void -_token_list_append_list (token_list_t *list, token_list_t *tail); - -static int -_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b); - -static void -_parser_active_list_push (glcpp_parser_t *parser, - const char *identifier, - token_node_t *marker); - -static void -_parser_active_list_pop (glcpp_parser_t *parser); - -static int -_parser_active_list_contains (glcpp_parser_t *parser, const char *identifier); - -static void -_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); - -static void -_glcpp_parser_expand_token_list (glcpp_parser_t *parser, - token_list_t *list); - -static void -_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, - token_list_t *list); - -static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, - int condition); - -static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, - const char *type, int condition); - -static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc); - -#define yylex glcpp_parser_lex - -static int -glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser); - -static void -glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list); - -static void -add_builtin_define(glcpp_parser_t *parser, const char *name, int value); - -%} - -%pure-parser -%error-verbose - -%locations -%initial-action { - @$.first_line = 1; - @$.first_column = 1; - @$.last_line = 1; - @$.last_column = 1; - @$.source = 0; -} - -%parse-param {glcpp_parser_t *parser} -%lex-param {glcpp_parser_t *parser} - -%expect 0 -%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF HASH_UNDEF HASH_VERSION IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING NEWLINE OTHER PLACEHOLDER SPACE -%token PASTE -%type expression INTEGER operator SPACE integer_constant -%type IDENTIFIER INTEGER_STRING OTHER -%type identifier_list -%type preprocessing_token conditional_token -%type pp_tokens replacement_list text_line conditional_tokens -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOT_EQUAL -%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL -%left LEFT_SHIFT RIGHT_SHIFT -%left '+' '-' -%left '*' '/' '%' -%right UNARY - -%% - -input: - /* empty */ -| input line -; - -line: - control_line { - ralloc_strcat (&parser->output, "\n"); - } -| text_line { - _glcpp_parser_print_expanded_token_list (parser, $1); - ralloc_strcat (&parser->output, "\n"); - ralloc_free ($1); - } -| expanded_line -| HASH non_directive -; - -expanded_line: - IF_EXPANDED expression NEWLINE { - _glcpp_parser_skip_stack_push_if (parser, & @1, $2); - } -| ELIF_EXPANDED expression NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2); - } -; - -control_line: - HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE { - _define_object_macro (parser, & @2, $2, $3); - } -| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE { - _define_function_macro (parser, & @2, $2, NULL, $5); - } -| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE { - _define_function_macro (parser, & @2, $2, $4, $6); - } -| HASH_UNDEF IDENTIFIER NEWLINE { - macro_t *macro = hash_table_find (parser->defines, $2); - if (macro) { - hash_table_remove (parser->defines, $2); - ralloc_free (macro); - } - ralloc_free ($2); - } -| HASH_IF conditional_tokens NEWLINE { - /* Be careful to only evaluate the 'if' expression if - * we are not skipping. When we are skipping, we - * simply push a new 0-valued 'if' onto the skip - * stack. - * - * This avoids generating diagnostics for invalid - * expressions that are being skipped. */ - if (parser->skip_stack == NULL || - parser->skip_stack->type == SKIP_NO_SKIP) - { - _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); - } - else - { - _glcpp_parser_skip_stack_push_if (parser, & @1, 0); - parser->skip_stack->type = SKIP_TO_ENDIF; - } - } -| HASH_IF NEWLINE { - /* #if without an expression is only an error if we - * are not skipping */ - if (parser->skip_stack == NULL || - parser->skip_stack->type == SKIP_NO_SKIP) - { - glcpp_error(& @1, parser, "#if with no expression"); - } - _glcpp_parser_skip_stack_push_if (parser, & @1, 0); - } -| HASH_IFDEF IDENTIFIER junk NEWLINE { - macro_t *macro = hash_table_find (parser->defines, $2); - ralloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL); - } -| HASH_IFNDEF IDENTIFIER junk NEWLINE { - macro_t *macro = hash_table_find (parser->defines, $2); - ralloc_free ($2); - _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); - } -| HASH_ELIF conditional_tokens NEWLINE { - /* Be careful to only evaluate the 'elif' expression - * if we are not skipping. When we are skipping, we - * simply change to a 0-valued 'elif' on the skip - * stack. - * - * This avoids generating diagnostics for invalid - * expressions that are being skipped. */ - if (parser->skip_stack && - parser->skip_stack->type == SKIP_TO_ELSE) - { - _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); - } - else - { - _glcpp_parser_skip_stack_change_if (parser, & @1, - "elif", 0); - } - } -| HASH_ELIF NEWLINE { - /* #elif without an expression is an error unless we - * are skipping. */ - if (parser->skip_stack && - parser->skip_stack->type == SKIP_TO_ELSE) - { - glcpp_error(& @1, parser, "#elif with no expression"); - } - else - { - _glcpp_parser_skip_stack_change_if (parser, & @1, - "elif", 0); - glcpp_warning(& @1, parser, "ignoring illegal #elif without expression"); - } - } -| HASH_ELSE NEWLINE { - _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1); - } -| HASH_ENDIF NEWLINE { - _glcpp_parser_skip_stack_pop (parser, & @1); - } -| HASH_VERSION integer_constant NEWLINE { - macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); - if (macro) { - hash_table_remove (parser->defines, "__VERSION__"); - ralloc_free (macro); - } - add_builtin_define (parser, "__VERSION__", $2); - - if ($2 == 100) - add_builtin_define (parser, "GL_ES", 1); - - /* Currently, all ES2 implementations support highp in the - * fragment shader, so we always define this macro in ES2. - * If we ever get a driver that doesn't support highp, we'll - * need to add a flag to the gl_context and check that here. - */ - if ($2 >= 130 || $2 == 100) - add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1); - - ralloc_asprintf_append (&parser->output, "#version %" PRIiMAX, $2); - } -| HASH NEWLINE -; - -integer_constant: - INTEGER_STRING { - if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) { - $$ = strtoll ($1 + 2, NULL, 16); - } else if ($1[0] == '0') { - $$ = strtoll ($1, NULL, 8); - } else { - $$ = strtoll ($1, NULL, 10); - } - } -| INTEGER { - $$ = $1; - } - -expression: - integer_constant -| expression OR expression { - $$ = $1 || $3; - } -| expression AND expression { - $$ = $1 && $3; - } -| expression '|' expression { - $$ = $1 | $3; - } -| expression '^' expression { - $$ = $1 ^ $3; - } -| expression '&' expression { - $$ = $1 & $3; - } -| expression NOT_EQUAL expression { - $$ = $1 != $3; - } -| expression EQUAL expression { - $$ = $1 == $3; - } -| expression GREATER_OR_EQUAL expression { - $$ = $1 >= $3; - } -| expression LESS_OR_EQUAL expression { - $$ = $1 <= $3; - } -| expression '>' expression { - $$ = $1 > $3; - } -| expression '<' expression { - $$ = $1 < $3; - } -| expression RIGHT_SHIFT expression { - $$ = $1 >> $3; - } -| expression LEFT_SHIFT expression { - $$ = $1 << $3; - } -| expression '-' expression { - $$ = $1 - $3; - } -| expression '+' expression { - $$ = $1 + $3; - } -| expression '%' expression { - if ($3 == 0) { - yyerror (& @1, parser, - "zero modulus in preprocessor directive"); - } else { - $$ = $1 % $3; - } - } -| expression '/' expression { - if ($3 == 0) { - yyerror (& @1, parser, - "division by 0 in preprocessor directive"); - } else { - $$ = $1 / $3; - } - } -| expression '*' expression { - $$ = $1 * $3; - } -| '!' expression %prec UNARY { - $$ = ! $2; - } -| '~' expression %prec UNARY { - $$ = ~ $2; - } -| '-' expression %prec UNARY { - $$ = - $2; - } -| '+' expression %prec UNARY { - $$ = + $2; - } -| '(' expression ')' { - $$ = $2; - } -; - -identifier_list: - IDENTIFIER { - $$ = _string_list_create (parser); - _string_list_append_item ($$, $1); - ralloc_steal ($$, $1); - } -| identifier_list ',' IDENTIFIER { - $$ = $1; - _string_list_append_item ($$, $3); - ralloc_steal ($$, $3); - } -; - -text_line: - NEWLINE { $$ = NULL; } -| pp_tokens NEWLINE -; - -non_directive: - pp_tokens NEWLINE { - yyerror (& @1, parser, "Invalid tokens after #"); - } -; - -replacement_list: - /* empty */ { $$ = NULL; } -| pp_tokens -; - -junk: - /* empty */ -| pp_tokens { - glcpp_warning(&@1, parser, "extra tokens at end of directive"); - } -; - -conditional_token: - /* Handle "defined" operator */ - DEFINED IDENTIFIER { - int v = hash_table_find (parser->defines, $2) ? 1 : 0; - $$ = _token_create_ival (parser, INTEGER, v); - } -| DEFINED '(' IDENTIFIER ')' { - int v = hash_table_find (parser->defines, $3) ? 1 : 0; - $$ = _token_create_ival (parser, INTEGER, v); - } -| preprocessing_token -; - -conditional_tokens: - /* Exactly the same as pp_tokens, but using conditional_token */ - conditional_token { - $$ = _token_list_create (parser); - _token_list_append ($$, $1); - } -| conditional_tokens conditional_token { - $$ = $1; - _token_list_append ($$, $2); - } -; - -pp_tokens: - preprocessing_token { - parser->space_tokens = 1; - $$ = _token_list_create (parser); - _token_list_append ($$, $1); - } -| pp_tokens preprocessing_token { - $$ = $1; - _token_list_append ($$, $2); - } -; - -preprocessing_token: - IDENTIFIER { - $$ = _token_create_str (parser, IDENTIFIER, $1); - $$->location = yylloc; - } -| INTEGER_STRING { - $$ = _token_create_str (parser, INTEGER_STRING, $1); - $$->location = yylloc; - } -| operator { - $$ = _token_create_ival (parser, $1, $1); - $$->location = yylloc; - } -| OTHER { - $$ = _token_create_str (parser, OTHER, $1); - $$->location = yylloc; - } -| SPACE { - $$ = _token_create_ival (parser, SPACE, SPACE); - $$->location = yylloc; - } -; - -operator: - '[' { $$ = '['; } -| ']' { $$ = ']'; } -| '(' { $$ = '('; } -| ')' { $$ = ')'; } -| '{' { $$ = '{'; } -| '}' { $$ = '}'; } -| '.' { $$ = '.'; } -| '&' { $$ = '&'; } -| '*' { $$ = '*'; } -| '+' { $$ = '+'; } -| '-' { $$ = '-'; } -| '~' { $$ = '~'; } -| '!' { $$ = '!'; } -| '/' { $$ = '/'; } -| '%' { $$ = '%'; } -| LEFT_SHIFT { $$ = LEFT_SHIFT; } -| RIGHT_SHIFT { $$ = RIGHT_SHIFT; } -| '<' { $$ = '<'; } -| '>' { $$ = '>'; } -| LESS_OR_EQUAL { $$ = LESS_OR_EQUAL; } -| GREATER_OR_EQUAL { $$ = GREATER_OR_EQUAL; } -| EQUAL { $$ = EQUAL; } -| NOT_EQUAL { $$ = NOT_EQUAL; } -| '^' { $$ = '^'; } -| '|' { $$ = '|'; } -| AND { $$ = AND; } -| OR { $$ = OR; } -| ';' { $$ = ';'; } -| ',' { $$ = ','; } -| '=' { $$ = '='; } -| PASTE { $$ = PASTE; } -; - -%% - -string_list_t * -_string_list_create (void *ctx) -{ - string_list_t *list; - - list = ralloc (ctx, string_list_t); - list->head = NULL; - list->tail = NULL; - - return list; -} - -void -_string_list_append_item (string_list_t *list, const char *str) -{ - string_node_t *node; - - node = ralloc (list, string_node_t); - node->str = ralloc_strdup (node, str); - - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; -} - -int -_string_list_contains (string_list_t *list, const char *member, int *index) -{ - string_node_t *node; - int i; - - if (list == NULL) - return 0; - - for (i = 0, node = list->head; node; i++, node = node->next) { - if (strcmp (node->str, member) == 0) { - if (index) - *index = i; - return 1; - } - } - - return 0; -} - -int -_string_list_length (string_list_t *list) -{ - int length = 0; - string_node_t *node; - - if (list == NULL) - return 0; - - for (node = list->head; node; node = node->next) - length++; - - return length; -} - -int -_string_list_equal (string_list_t *a, string_list_t *b) -{ - string_node_t *node_a, *node_b; - - if (a == NULL && b == NULL) - return 1; - - if (a == NULL || b == NULL) - return 0; - - for (node_a = a->head, node_b = b->head; - node_a && node_b; - node_a = node_a->next, node_b = node_b->next) - { - if (strcmp (node_a->str, node_b->str)) - return 0; - } - - /* Catch the case of lists being different lengths, (which - * would cause the loop above to terminate after the shorter - * list). */ - return node_a == node_b; -} - -argument_list_t * -_argument_list_create (void *ctx) -{ - argument_list_t *list; - - list = ralloc (ctx, argument_list_t); - list->head = NULL; - list->tail = NULL; - - return list; -} - -void -_argument_list_append (argument_list_t *list, token_list_t *argument) -{ - argument_node_t *node; - - node = ralloc (list, argument_node_t); - node->argument = argument; - - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; -} - -int -_argument_list_length (argument_list_t *list) -{ - int length = 0; - argument_node_t *node; - - if (list == NULL) - return 0; - - for (node = list->head; node; node = node->next) - length++; - - return length; -} - -token_list_t * -_argument_list_member_at (argument_list_t *list, int index) -{ - argument_node_t *node; - int i; - - if (list == NULL) - return NULL; - - node = list->head; - for (i = 0; i < index; i++) { - node = node->next; - if (node == NULL) - break; - } - - if (node) - return node->argument; - - return NULL; -} - -/* Note: This function ralloc_steal()s the str pointer. */ -token_t * -_token_create_str (void *ctx, int type, char *str) -{ - token_t *token; - - token = ralloc (ctx, token_t); - token->type = type; - token->value.str = str; - - ralloc_steal (token, str); - - return token; -} - -token_t * -_token_create_ival (void *ctx, int type, int ival) -{ - token_t *token; - - token = ralloc (ctx, token_t); - token->type = type; - token->value.ival = ival; - - return token; -} - -token_list_t * -_token_list_create (void *ctx) -{ - token_list_t *list; - - list = ralloc (ctx, token_list_t); - list->head = NULL; - list->tail = NULL; - list->non_space_tail = NULL; - - return list; -} - -void -_token_list_append (token_list_t *list, token_t *token) -{ - token_node_t *node; - - node = ralloc (list, token_node_t); - node->token = token; - node->next = NULL; - - if (list->head == NULL) { - list->head = node; - } else { - list->tail->next = node; - } - - list->tail = node; - if (token->type != SPACE) - list->non_space_tail = node; -} - -void -_token_list_append_list (token_list_t *list, token_list_t *tail) -{ - if (tail == NULL || tail->head == NULL) - return; - - if (list->head == NULL) { - list->head = tail->head; - } else { - list->tail->next = tail->head; - } - - list->tail = tail->tail; - list->non_space_tail = tail->non_space_tail; -} - -static token_list_t * -_token_list_copy (void *ctx, token_list_t *other) -{ - token_list_t *copy; - token_node_t *node; - - if (other == NULL) - return NULL; - - copy = _token_list_create (ctx); - for (node = other->head; node; node = node->next) { - token_t *new_token = ralloc (copy, token_t); - *new_token = *node->token; - _token_list_append (copy, new_token); - } - - return copy; -} - -static void -_token_list_trim_trailing_space (token_list_t *list) -{ - token_node_t *tail, *next; - - if (list->non_space_tail) { - tail = list->non_space_tail->next; - list->non_space_tail->next = NULL; - list->tail = list->non_space_tail; - - while (tail) { - next = tail->next; - ralloc_free (tail); - tail = next; - } - } -} - -static int -_token_list_is_empty_ignoring_space (token_list_t *l) -{ - token_node_t *n; - - if (l == NULL) - return 1; - - n = l->head; - while (n != NULL && n->token->type == SPACE) - n = n->next; - - return n == NULL; -} - -int -_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b) -{ - token_node_t *node_a, *node_b; - - if (a == NULL || b == NULL) { - int a_empty = _token_list_is_empty_ignoring_space(a); - int b_empty = _token_list_is_empty_ignoring_space(b); - return a_empty == b_empty; - } - - node_a = a->head; - node_b = b->head; - - while (1) - { - if (node_a == NULL && node_b == NULL) - break; - - if (node_a == NULL || node_b == NULL) - return 0; - - if (node_a->token->type == SPACE) { - node_a = node_a->next; - continue; - } - - if (node_b->token->type == SPACE) { - node_b = node_b->next; - continue; - } - - if (node_a->token->type != node_b->token->type) - return 0; - - switch (node_a->token->type) { - case INTEGER: - if (node_a->token->value.ival != - node_b->token->value.ival) - { - return 0; - } - break; - case IDENTIFIER: - case INTEGER_STRING: - case OTHER: - if (strcmp (node_a->token->value.str, - node_b->token->value.str)) - { - return 0; - } - break; - } - - node_a = node_a->next; - node_b = node_b->next; - } - - return 1; -} - -static void -_token_print (char **out, token_t *token) -{ - if (token->type < 256) { - ralloc_asprintf_append (out, "%c", token->type); - return; - } - - switch (token->type) { - case INTEGER: - ralloc_asprintf_append (out, "%" PRIiMAX, token->value.ival); - break; - case IDENTIFIER: - case INTEGER_STRING: - case OTHER: - ralloc_strcat (out, token->value.str); - break; - case SPACE: - ralloc_strcat (out, " "); - break; - case LEFT_SHIFT: - ralloc_strcat (out, "<<"); - break; - case RIGHT_SHIFT: - ralloc_strcat (out, ">>"); - break; - case LESS_OR_EQUAL: - ralloc_strcat (out, "<="); - break; - case GREATER_OR_EQUAL: - ralloc_strcat (out, ">="); - break; - case EQUAL: - ralloc_strcat (out, "=="); - break; - case NOT_EQUAL: - ralloc_strcat (out, "!="); - break; - case AND: - ralloc_strcat (out, "&&"); - break; - case OR: - ralloc_strcat (out, "||"); - break; - case PASTE: - ralloc_strcat (out, "##"); - break; - case COMMA_FINAL: - ralloc_strcat (out, ","); - break; - case PLACEHOLDER: - /* Nothing to print. */ - break; - default: - assert(!"Error: Don't know how to print token."); - break; - } -} - -/* Return a new token (ralloc()ed off of 'token') formed by pasting - * 'token' and 'other'. Note that this function may return 'token' or - * 'other' directly rather than allocating anything new. - * - * Caution: Only very cursory error-checking is performed to see if - * the final result is a valid single token. */ -static token_t * -_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) -{ - token_t *combined = NULL; - - /* Pasting a placeholder onto anything makes no change. */ - if (other->type == PLACEHOLDER) - return token; - - /* When 'token' is a placeholder, just return 'other'. */ - if (token->type == PLACEHOLDER) - return other; - - /* A very few single-character punctuators can be combined - * with another to form a multi-character punctuator. */ - switch (token->type) { - case '<': - if (other->type == '<') - combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT); - else if (other->type == '=') - combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL); - break; - case '>': - if (other->type == '>') - combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT); - else if (other->type == '=') - combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL); - break; - case '=': - if (other->type == '=') - combined = _token_create_ival (token, EQUAL, EQUAL); - break; - case '!': - if (other->type == '=') - combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL); - break; - case '&': - if (other->type == '&') - combined = _token_create_ival (token, AND, AND); - break; - case '|': - if (other->type == '|') - combined = _token_create_ival (token, OR, OR); - break; - } - - if (combined != NULL) { - /* Inherit the location from the first token */ - combined->location = token->location; - return combined; - } - - /* Two string-valued tokens can usually just be mashed - * together. - * - * XXX: This isn't actually legitimate. Several things here - * should result in a diagnostic since the result cannot be a - * valid, single pre-processing token. For example, pasting - * "123" and "abc" is not legal, but we don't catch that - * here. */ - if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && - (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) - { - char *str; - - str = ralloc_asprintf (token, "%s%s", token->value.str, - other->value.str); - combined = _token_create_str (token, token->type, str); - combined->location = token->location; - return combined; - } - - glcpp_error (&token->location, parser, ""); - ralloc_strcat (&parser->info_log, "Pasting \""); - _token_print (&parser->info_log, token); - ralloc_strcat (&parser->info_log, "\" and \""); - _token_print (&parser->info_log, other); - ralloc_strcat (&parser->info_log, "\" does not give a valid preprocessing token.\n"); - - return token; -} - -static void -_token_list_print (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - if (list == NULL) - return; - - for (node = list->head; node; node = node->next) - _token_print (&parser->output, node->token); -} - -void -yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error) -{ - glcpp_error(locp, parser, "%s", error); -} - -static void add_builtin_define(glcpp_parser_t *parser, - const char *name, int value) -{ - token_t *tok; - token_list_t *list; - - tok = _token_create_ival (parser, INTEGER, value); - - list = _token_list_create(parser); - _token_list_append(list, tok); - _define_object_macro(parser, NULL, name, list); -} - -glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions, int api) -{ - glcpp_parser_t *parser; - int language_version; - - parser = ralloc (NULL, glcpp_parser_t); - - glcpp_lex_init_extra (parser, &parser->scanner); - parser->defines = hash_table_ctor (32, hash_table_string_hash, - hash_table_string_compare); - parser->active = NULL; - parser->lexing_if = 0; - parser->space_tokens = 1; - parser->newline_as_space = 0; - parser->in_control_line = 0; - parser->paren_count = 0; - - parser->skip_stack = NULL; - - parser->lex_from_list = NULL; - parser->lex_from_node = NULL; - - parser->output = ralloc_strdup(parser, ""); - parser->info_log = ralloc_strdup(parser, ""); - parser->error = 0; - - /* Add pre-defined macros. */ - add_builtin_define(parser, "GL_ARB_draw_buffers", 1); - add_builtin_define(parser, "GL_ARB_texture_rectangle", 1); - - if (api == API_OPENGLES2) - add_builtin_define(parser, "GL_ES", 1); - - if (extensions != NULL) { - if (extensions->EXT_texture_array) { - add_builtin_define(parser, "GL_EXT_texture_array", 1); - } - - if (extensions->ARB_fragment_coord_conventions) - add_builtin_define(parser, "GL_ARB_fragment_coord_conventions", - 1); - - if (extensions->ARB_explicit_attrib_location) - add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1); - - if (extensions->ARB_shader_texture_lod) - add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1); - - if (extensions->ARB_draw_instanced) - add_builtin_define(parser, "GL_ARB_draw_instanced", 1); - - if (extensions->ARB_conservative_depth) { - add_builtin_define(parser, "GL_AMD_conservative_depth", 1); - add_builtin_define(parser, "GL_ARB_conservative_depth", 1); - } - - if (extensions->OES_EGL_image_external) - add_builtin_define(parser, "GL_OES_EGL_image_external", 1); - } - - language_version = 110; - add_builtin_define(parser, "__VERSION__", language_version); - - return parser; -} - -int -glcpp_parser_parse (glcpp_parser_t *parser) -{ - return yyparse (parser); -} - -void -glcpp_parser_destroy (glcpp_parser_t *parser) -{ - glcpp_lex_destroy (parser->scanner); - hash_table_dtor (parser->defines); - ralloc_free (parser); -} - -typedef enum function_status -{ - FUNCTION_STATUS_SUCCESS, - FUNCTION_NOT_A_FUNCTION, - FUNCTION_UNBALANCED_PARENTHESES -} function_status_t; - -/* Find a set of function-like macro arguments by looking for a - * balanced set of parentheses. - * - * When called, 'node' should be the opening-parenthesis token, (or - * perhaps preceeding SPACE tokens). Upon successful return *last will - * be the last consumed node, (corresponding to the closing right - * parenthesis). - * - * Return values: - * - * FUNCTION_STATUS_SUCCESS: - * - * Successfully parsed a set of function arguments. - * - * FUNCTION_NOT_A_FUNCTION: - * - * Macro name not followed by a '('. This is not an error, but - * simply that the macro name should be treated as a non-macro. - * - * FUNCTION_UNBALANCED_PARENTHESES - * - * Macro name is not followed by a balanced set of parentheses. - */ -static function_status_t -_arguments_parse (argument_list_t *arguments, - token_node_t *node, - token_node_t **last) -{ - token_list_t *argument; - int paren_count; - - node = node->next; - - /* Ignore whitespace before first parenthesis. */ - while (node && node->token->type == SPACE) - node = node->next; - - if (node == NULL || node->token->type != '(') - return FUNCTION_NOT_A_FUNCTION; - - node = node->next; - - argument = _token_list_create (arguments); - _argument_list_append (arguments, argument); - - for (paren_count = 1; node; node = node->next) { - if (node->token->type == '(') - { - paren_count++; - } - else if (node->token->type == ')') - { - paren_count--; - if (paren_count == 0) - break; - } - - if (node->token->type == ',' && - paren_count == 1) - { - _token_list_trim_trailing_space (argument); - argument = _token_list_create (arguments); - _argument_list_append (arguments, argument); - } - else { - if (argument->head == NULL) { - /* Don't treat initial whitespace as - * part of the arguement. */ - if (node->token->type == SPACE) - continue; - } - _token_list_append (argument, node->token); - } - } - - if (paren_count) - return FUNCTION_UNBALANCED_PARENTHESES; - - *last = node; - - return FUNCTION_STATUS_SUCCESS; -} - -static token_list_t * -_token_list_create_with_one_space (void *ctx) -{ - token_list_t *list; - token_t *space; - - list = _token_list_create (ctx); - space = _token_create_ival (list, SPACE, SPACE); - _token_list_append (list, space); - - return list; -} - -static void -_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list) -{ - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, type, type); - _token_list_append (expanded, token); - _glcpp_parser_expand_token_list (parser, list); - _token_list_append_list (expanded, list); - glcpp_parser_lex_from (parser, expanded); -} - -static void -_glcpp_parser_apply_pastes (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - node = list->head; - while (node) - { - token_node_t *next_non_space; - - /* Look ahead for a PASTE token, skipping space. */ - next_non_space = node->next; - while (next_non_space && next_non_space->token->type == SPACE) - next_non_space = next_non_space->next; - - if (next_non_space == NULL) - break; - - if (next_non_space->token->type != PASTE) { - node = next_non_space; - continue; - } - - /* Now find the next non-space token after the PASTE. */ - next_non_space = next_non_space->next; - while (next_non_space && next_non_space->token->type == SPACE) - next_non_space = next_non_space->next; - - if (next_non_space == NULL) { - yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); - return; - } - - node->token = _token_paste (parser, node->token, next_non_space->token); - node->next = next_non_space->next; - if (next_non_space == list->tail) - list->tail = node; - } - - list->non_space_tail = list->tail; -} - -/* This is a helper function that's essentially part of the - * implementation of _glcpp_parser_expand_node. It shouldn't be called - * except for by that function. - * - * Returns NULL if node is a simple token with no expansion, (that is, - * although 'node' corresponds to an identifier defined as a - * function-like macro, it is not followed with a parenthesized - * argument list). - * - * Compute the complete expansion of node (which is a function-like - * macro) and subsequent nodes which are arguments. - * - * Returns the token list that results from the expansion and sets - * *last to the last node in the list that was consumed by the - * expansion. Specifically, *last will be set as follows: as the - * token of the closing right parenthesis. - */ -static token_list_t * -_glcpp_parser_expand_function (glcpp_parser_t *parser, - token_node_t *node, - token_node_t **last) - -{ - macro_t *macro; - const char *identifier; - argument_list_t *arguments; - function_status_t status; - token_list_t *substituted; - int parameter_index; - - identifier = node->token->value.str; - - macro = hash_table_find (parser->defines, identifier); - - assert (macro->is_function); - - arguments = _argument_list_create (parser); - status = _arguments_parse (arguments, node, last); - - switch (status) { - case FUNCTION_STATUS_SUCCESS: - break; - case FUNCTION_NOT_A_FUNCTION: - return NULL; - case FUNCTION_UNBALANCED_PARENTHESES: - glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier); - return NULL; - } - - /* Replace a macro defined as empty with a SPACE token. */ - if (macro->replacements == NULL) { - ralloc_free (arguments); - return _token_list_create_with_one_space (parser); - } - - if (! ((_argument_list_length (arguments) == - _string_list_length (macro->parameters)) || - (_string_list_length (macro->parameters) == 0 && - _argument_list_length (arguments) == 1 && - arguments->head->argument->head == NULL))) - { - glcpp_error (&node->token->location, parser, - "Error: macro %s invoked with %d arguments (expected %d)\n", - identifier, - _argument_list_length (arguments), - _string_list_length (macro->parameters)); - return NULL; - } - - /* Perform argument substitution on the replacement list. */ - substituted = _token_list_create (arguments); - - for (node = macro->replacements->head; node; node = node->next) - { - if (node->token->type == IDENTIFIER && - _string_list_contains (macro->parameters, - node->token->value.str, - ¶meter_index)) - { - token_list_t *argument; - argument = _argument_list_member_at (arguments, - parameter_index); - /* Before substituting, we expand the argument - * tokens, or append a placeholder token for - * an empty argument. */ - if (argument->head) { - token_list_t *expanded_argument; - expanded_argument = _token_list_copy (parser, - argument); - _glcpp_parser_expand_token_list (parser, - expanded_argument); - _token_list_append_list (substituted, - expanded_argument); - } else { - token_t *new_token; - - new_token = _token_create_ival (substituted, - PLACEHOLDER, - PLACEHOLDER); - _token_list_append (substituted, new_token); - } - } else { - _token_list_append (substituted, node->token); - } - } - - /* After argument substitution, and before further expansion - * below, implement token pasting. */ - - _token_list_trim_trailing_space (substituted); - - _glcpp_parser_apply_pastes (parser, substituted); - - return substituted; -} - -/* Compute the complete expansion of node, (and subsequent nodes after - * 'node' in the case that 'node' is a function-like macro and - * subsequent nodes are arguments). - * - * Returns NULL if node is a simple token with no expansion. - * - * Otherwise, returns the token list that results from the expansion - * and sets *last to the last node in the list that was consumed by - * the expansion. Specifically, *last will be set as follows: - * - * As 'node' in the case of object-like macro expansion. - * - * As the token of the closing right parenthesis in the case of - * function-like macro expansion. - */ -static token_list_t * -_glcpp_parser_expand_node (glcpp_parser_t *parser, - token_node_t *node, - token_node_t **last) -{ - token_t *token = node->token; - const char *identifier; - macro_t *macro; - - /* We only expand identifiers */ - if (token->type != IDENTIFIER) { - /* We change any COMMA into a COMMA_FINAL to prevent - * it being mistaken for an argument separator - * later. */ - if (token->type == ',') { - token->type = COMMA_FINAL; - token->value.ival = COMMA_FINAL; - } - - return NULL; - } - - /* Look up this identifier in the hash table. */ - identifier = token->value.str; - macro = hash_table_find (parser->defines, identifier); - - /* Not a macro, so no expansion needed. */ - if (macro == NULL) - return NULL; - - /* Finally, don't expand this macro if we're already actively - * expanding it, (to avoid infinite recursion). */ - if (_parser_active_list_contains (parser, identifier)) { - /* We change the token type here from IDENTIFIER to - * OTHER to prevent any future expansion of this - * unexpanded token. */ - char *str; - token_list_t *expansion; - token_t *final; - - str = ralloc_strdup (parser, token->value.str); - final = _token_create_str (parser, OTHER, str); - expansion = _token_list_create (parser); - _token_list_append (expansion, final); - *last = node; - return expansion; - } - - if (! macro->is_function) - { - token_list_t *replacement; - *last = node; - - /* Replace a macro defined as empty with a SPACE token. */ - if (macro->replacements == NULL) - return _token_list_create_with_one_space (parser); - - replacement = _token_list_copy (parser, macro->replacements); - _glcpp_parser_apply_pastes (parser, replacement); - return replacement; - } - - return _glcpp_parser_expand_function (parser, node, last); -} - -/* Push a new identifier onto the parser's active list. - * - * Here, 'marker' is the token node that appears in the list after the - * expansion of 'identifier'. That is, when the list iterator begins - * examining 'marker', then it is time to pop this node from the - * active stack. - */ -static void -_parser_active_list_push (glcpp_parser_t *parser, - const char *identifier, - token_node_t *marker) -{ - active_list_t *node; - - node = ralloc (parser->active, active_list_t); - node->identifier = ralloc_strdup (node, identifier); - node->marker = marker; - node->next = parser->active; - - parser->active = node; -} - -static void -_parser_active_list_pop (glcpp_parser_t *parser) -{ - active_list_t *node = parser->active; - - if (node == NULL) { - parser->active = NULL; - return; - } - - node = parser->active->next; - ralloc_free (parser->active); - - parser->active = node; -} - -static int -_parser_active_list_contains (glcpp_parser_t *parser, const char *identifier) -{ - active_list_t *node; - - if (parser->active == NULL) - return 0; - - for (node = parser->active; node; node = node->next) - if (strcmp (node->identifier, identifier) == 0) - return 1; - - return 0; -} - -/* Walk over the token list replacing nodes with their expansion. - * Whenever nodes are expanded the walking will walk over the new - * nodes, continuing to expand as necessary. The results are placed in - * 'list' itself; - */ -static void -_glcpp_parser_expand_token_list (glcpp_parser_t *parser, - token_list_t *list) -{ - token_node_t *node_prev; - token_node_t *node, *last = NULL; - token_list_t *expansion; - active_list_t *active_initial = parser->active; - - if (list == NULL) - return; - - _token_list_trim_trailing_space (list); - - node_prev = NULL; - node = list->head; - - while (node) { - - while (parser->active && parser->active->marker == node) - _parser_active_list_pop (parser); - - expansion = _glcpp_parser_expand_node (parser, node, &last); - if (expansion) { - token_node_t *n; - - for (n = node; n != last->next; n = n->next) - while (parser->active && - parser->active->marker == n) - { - _parser_active_list_pop (parser); - } - - _parser_active_list_push (parser, - node->token->value.str, - last->next); - - /* Splice expansion into list, supporting a - * simple deletion if the expansion is - * empty. */ - if (expansion->head) { - if (node_prev) - node_prev->next = expansion->head; - else - list->head = expansion->head; - expansion->tail->next = last->next; - if (last == list->tail) - list->tail = expansion->tail; - } else { - if (node_prev) - node_prev->next = last->next; - else - list->head = last->next; - if (last == list->tail) - list->tail = NULL; - } - } else { - node_prev = node; - } - node = node_prev ? node_prev->next : list->head; - } - - /* Remove any lingering effects of this invocation on the - * active list. That is, pop until the list looks like it did - * at the beginning of this function. */ - while (parser->active && parser->active != active_initial) - _parser_active_list_pop (parser); - - list->non_space_tail = list->tail; -} - -void -_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser, - token_list_t *list) -{ - if (list == NULL) - return; - - _glcpp_parser_expand_token_list (parser, list); - - _token_list_trim_trailing_space (list); - - _token_list_print (parser, list); -} - -static void -_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc, - const char *identifier) -{ - /* According to the GLSL specification, macro names starting with "__" - * or "GL_" are reserved for future use. So, don't allow them. - */ - if (strstr(identifier, "__")) { - glcpp_error (loc, parser, "Macro names containing \"__\" are reserved.\n"); - } - if (strncmp(identifier, "GL_", 3) == 0) { - glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); - } -} - -static int -_macro_equal (macro_t *a, macro_t *b) -{ - if (a->is_function != b->is_function) - return 0; - - if (a->is_function) { - if (! _string_list_equal (a->parameters, b->parameters)) - return 0; - } - - return _token_list_equal_ignoring_space (a->replacements, - b->replacements); -} - -void -_define_object_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *identifier, - token_list_t *replacements) -{ - macro_t *macro, *previous; - - if (loc != NULL) - _check_for_reserved_macro_name(parser, loc, identifier); - - macro = ralloc (parser, macro_t); - - macro->is_function = 0; - macro->parameters = NULL; - macro->identifier = ralloc_strdup (macro, identifier); - macro->replacements = replacements; - ralloc_steal (macro, replacements); - - previous = hash_table_find (parser->defines, identifier); - if (previous) { - if (_macro_equal (macro, previous)) { - ralloc_free (macro); - return; - } - glcpp_error (loc, parser, "Redefinition of macro %s\n", - identifier); - } - - hash_table_insert (parser->defines, macro, identifier); -} - -void -_define_function_macro (glcpp_parser_t *parser, - YYLTYPE *loc, - const char *identifier, - string_list_t *parameters, - token_list_t *replacements) -{ - macro_t *macro, *previous; - - _check_for_reserved_macro_name(parser, loc, identifier); - - macro = ralloc (parser, macro_t); - ralloc_steal (macro, parameters); - ralloc_steal (macro, replacements); - - macro->is_function = 1; - macro->parameters = parameters; - macro->identifier = ralloc_strdup (macro, identifier); - macro->replacements = replacements; - previous = hash_table_find (parser->defines, identifier); - if (previous) { - if (_macro_equal (macro, previous)) { - ralloc_free (macro); - return; - } - glcpp_error (loc, parser, "Redefinition of macro %s\n", - identifier); - } - - hash_table_insert (parser->defines, macro, identifier); -} - -static int -glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser) -{ - token_node_t *node; - int ret; - - if (parser->lex_from_list == NULL) { - ret = glcpp_lex (yylval, yylloc, parser->scanner); - - /* XXX: This ugly block of code exists for the sole - * purpose of converting a NEWLINE token into a SPACE - * token, but only in the case where we have seen a - * function-like macro name, but have not yet seen its - * closing parenthesis. - * - * There's perhaps a more compact way to do this with - * mid-rule actions in the grammar. - * - * I'm definitely not pleased with the complexity of - * this code here. - */ - if (parser->newline_as_space) - { - if (ret == '(') { - parser->paren_count++; - } else if (ret == ')') { - parser->paren_count--; - if (parser->paren_count == 0) - parser->newline_as_space = 0; - } else if (ret == NEWLINE) { - ret = SPACE; - } else if (ret != SPACE) { - if (parser->paren_count == 0) - parser->newline_as_space = 0; - } - } - else if (parser->in_control_line) - { - if (ret == NEWLINE) - parser->in_control_line = 0; - } - else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC || - ret == HASH_UNDEF || ret == HASH_IF || - ret == HASH_IFDEF || ret == HASH_IFNDEF || - ret == HASH_ELIF || ret == HASH_ELSE || - ret == HASH_ENDIF || ret == HASH) - { - parser->in_control_line = 1; - } - else if (ret == IDENTIFIER) - { - macro_t *macro; - macro = hash_table_find (parser->defines, - yylval->str); - if (macro && macro->is_function) { - parser->newline_as_space = 1; - parser->paren_count = 0; - } - } - - return ret; - } - - node = parser->lex_from_node; - - if (node == NULL) { - ralloc_free (parser->lex_from_list); - parser->lex_from_list = NULL; - return NEWLINE; - } - - *yylval = node->token->value; - ret = node->token->type; - - parser->lex_from_node = node->next; - - return ret; -} - -static void -glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list) -{ - token_node_t *node; - - assert (parser->lex_from_list == NULL); - - /* Copy list, eliminating any space tokens. */ - parser->lex_from_list = _token_list_create (parser); - - for (node = list->head; node; node = node->next) { - if (node->token->type == SPACE) - continue; - _token_list_append (parser->lex_from_list, node->token); - } - - ralloc_free (list); - - parser->lex_from_node = parser->lex_from_list->head; - - /* It's possible the list consisted of nothing but whitespace. */ - if (parser->lex_from_node == NULL) { - ralloc_free (parser->lex_from_list); - parser->lex_from_list = NULL; - } -} - -static void -_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc, - int condition) -{ - skip_type_t current = SKIP_NO_SKIP; - skip_node_t *node; - - if (parser->skip_stack) - current = parser->skip_stack->type; - - node = ralloc (parser, skip_node_t); - node->loc = *loc; - - if (current == SKIP_NO_SKIP) { - if (condition) - node->type = SKIP_NO_SKIP; - else - node->type = SKIP_TO_ELSE; - } else { - node->type = SKIP_TO_ENDIF; - } - - node->next = parser->skip_stack; - parser->skip_stack = node; -} - -static void -_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc, - const char *type, int condition) -{ - if (parser->skip_stack == NULL) { - glcpp_error (loc, parser, "%s without #if\n", type); - return; - } - - if (parser->skip_stack->type == SKIP_TO_ELSE) { - if (condition) - parser->skip_stack->type = SKIP_NO_SKIP; - } else { - parser->skip_stack->type = SKIP_TO_ENDIF; - } -} - -static void -_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc) -{ - skip_node_t *node; - - if (parser->skip_stack == NULL) { - glcpp_error (loc, parser, "#endif without #if\n"); - return; - } - - node = parser->skip_stack; - parser->skip_stack = node->next; - ralloc_free (node); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.c deleted file mode 100644 index e6445088187..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include -#include "glcpp.h" -#include "main/mtypes.h" -#include "main/shaderobj.h" - -extern int yydebug; - -void -_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, - struct gl_shader *sh) -{ - (void) ctx; - *ptr = sh; -} - -/* Read from fp until EOF and return a string of everything read. - */ -static char * -load_text_fp (void *ctx, FILE *fp) -{ -#define CHUNK 4096 - char *text = NULL; - size_t text_size = 0; - size_t total_read = 0; - size_t bytes; - - while (1) { - if (total_read + CHUNK + 1 > text_size) { - text_size = text_size ? text_size * 2 : CHUNK + 1; - text = reralloc_size (ctx, text, text_size); - if (text == NULL) { - fprintf (stderr, "Out of memory\n"); - return NULL; - } - } - bytes = fread (text + total_read, 1, CHUNK, fp); - total_read += bytes; - - if (bytes < CHUNK) { - break; - } - } - - text[total_read] = '\0'; - - return text; -} - -static char * -load_text_file(void *ctx, const char *filename) -{ - char *text; - FILE *fp; - - if (filename == NULL || strcmp (filename, "-") == 0) - return load_text_fp (ctx, stdin); - - fp = fopen (filename, "r"); - if (fp == NULL) { - fprintf (stderr, "Failed to open file %s: %s\n", - filename, strerror (errno)); - return NULL; - } - - text = load_text_fp (ctx, fp); - - fclose(fp); - - return text; -} - -int -main (int argc, char *argv[]) -{ - char *filename = NULL; - void *ctx = ralloc(NULL, void*); - char *info_log = ralloc_strdup(ctx, ""); - const char *shader; - int ret; - - if (argc) { - filename = argv[1]; - } - - shader = load_text_file (ctx, filename); - if (shader == NULL) - return 1; - - ret = preprocess(ctx, &shader, &info_log, NULL); - - printf("%s", shader); - fprintf(stderr, "%s", info_log); - - ralloc_free(ctx); - - return ret; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.h b/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.h deleted file mode 100644 index 1fad8cb9993..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/glcpp.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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 GLCPP_H -#define GLCPP_H - -#include - -#include "../ralloc.h" - -#include "program/hash_table.h" - -#define yyscan_t void* - -/* Some data types used for parser values. */ - -typedef struct string_node { - const char *str; - struct string_node *next; -} string_node_t; - -typedef struct string_list { - string_node_t *head; - string_node_t *tail; -} string_list_t; - -typedef struct token token_t; -typedef struct token_list token_list_t; - -typedef union YYSTYPE -{ - intmax_t ival; - char *str; - string_list_t *string_list; - token_t *token; - token_list_t *token_list; -} YYSTYPE; - -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 - -typedef struct YYLTYPE { - int first_line; - int first_column; - int last_line; - int last_column; - unsigned source; -} YYLTYPE; -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 - -# define YYLLOC_DEFAULT(Current, Rhs, N) \ -do { \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC(Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC(Rhs, 0).last_column; \ - } \ - (Current).source = 0; \ -} while (0) - -struct token { - int type; - YYSTYPE value; - YYLTYPE location; -}; - -typedef struct token_node { - token_t *token; - struct token_node *next; -} token_node_t; - -struct token_list { - token_node_t *head; - token_node_t *tail; - token_node_t *non_space_tail; -}; - -typedef struct argument_node { - token_list_t *argument; - struct argument_node *next; -} argument_node_t; - -typedef struct argument_list { - argument_node_t *head; - argument_node_t *tail; -} argument_list_t; - -typedef struct glcpp_parser glcpp_parser_t; - -typedef enum { - TOKEN_CLASS_IDENTIFIER, - TOKEN_CLASS_IDENTIFIER_FINALIZED, - TOKEN_CLASS_FUNC_MACRO, - TOKEN_CLASS_OBJ_MACRO -} token_class_t; - -token_class_t -glcpp_parser_classify_token (glcpp_parser_t *parser, - const char *identifier, - int *parameter_index); - -typedef struct { - int is_function; - string_list_t *parameters; - const char *identifier; - token_list_t *replacements; -} macro_t; - -typedef struct expansion_node { - macro_t *macro; - token_node_t *replacements; - struct expansion_node *next; -} expansion_node_t; - -typedef enum skip_type { - SKIP_NO_SKIP, - SKIP_TO_ELSE, - SKIP_TO_ENDIF -} skip_type_t; - -typedef struct skip_node { - skip_type_t type; - YYLTYPE loc; /* location of the initial #if/#elif/... */ - struct skip_node *next; -} skip_node_t; - -typedef struct active_list { - const char *identifier; - token_node_t *marker; - struct active_list *next; -} active_list_t; - -struct glcpp_parser { - yyscan_t scanner; - struct hash_table *defines; - active_list_t *active; - int lexing_if; - int space_tokens; - int newline_as_space; - int in_control_line; - int paren_count; - skip_node_t *skip_stack; - token_list_t *lex_from_list; - token_node_t *lex_from_node; - char *output; - char *info_log; - int error; -}; - -struct gl_extensions; - -glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions); - -int -glcpp_parser_parse (glcpp_parser_t *parser); - -void -glcpp_parser_destroy (glcpp_parser_t *parser); - -int -preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions); - -/* Functions for writing to the info log */ - -void -glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); - -void -glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...); - -/* Generated by glcpp-lex.l to glcpp-lex.c */ - -int -glcpp_lex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner); - -void -glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader); - -int -glcpp_lex (YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner); - -int -glcpp_lex_destroy (yyscan_t scanner); - -/* Generated by glcpp-parse.y to glcpp-parse.c */ - -int -yyparse (glcpp_parser_t *parser); - -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/pp.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/pp.c deleted file mode 100644 index ae62d0aea1a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/pp.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include -#include "glcpp.h" -#include "main/core.h" /* for isblank() on MSVC */ - -void -glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) -{ - va_list ap; - - parser->error = 1; - ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): " - "preprocessor error: ", - locp->source, - locp->first_line, - locp->first_column); - va_start(ap, fmt); - ralloc_vasprintf_append(&parser->info_log, fmt, ap); - va_end(ap); - ralloc_strcat(&parser->info_log, "\n"); -} - -void -glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) -{ - va_list ap; - - ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): " - "preprocessor warning: ", - locp->source, - locp->first_line, - locp->first_column); - va_start(ap, fmt); - ralloc_vasprintf_append(&parser->info_log, fmt, ap); - va_end(ap); - ralloc_strcat(&parser->info_log, "\n"); -} - -/* Searches backwards for '^ *#' from a given starting point. */ -static int -in_directive(const char *shader, const char *ptr) -{ - assert(ptr >= shader); - - /* Search backwards for '#'. If we find a \n first, it doesn't count */ - for (; ptr >= shader && *ptr != '#'; ptr--) { - if (*ptr == '\n') - return 0; - } - if (ptr >= shader) { - /* Found '#'...look for spaces preceded by a newline */ - for (ptr--; ptr >= shader && isblank(*ptr); ptr--); - // FIXME: I don't think the '\n' case can happen - if (ptr < shader || *ptr == '\n') - return 1; - } - return 0; -} - -/* Remove any line continuation characters in preprocessing directives. - * However, ignore any in GLSL code, as "There is no line continuation - * character" (1.30 page 9) in GLSL. - */ -static char * -remove_line_continuations(glcpp_parser_t *ctx, const char *shader) -{ - int in_continued_line = 0; - int extra_newlines = 0; - char *clean = ralloc_strdup(ctx, ""); - const char *search_start = shader; - const char *newline; - while ((newline = strchr(search_start, '\n')) != NULL) { - const char *backslash = NULL; - - /* # of characters preceding the newline. */ - int n = newline - shader; - - /* Find the preceding '\', if it exists */ - if (n >= 1 && newline[-1] == '\\') - backslash = newline - 1; - else if (n >= 2 && newline[-1] == '\r' && newline[-2] == '\\') - backslash = newline - 2; - - /* Double backslashes don't count (the backslash is escaped) */ - if (backslash != NULL && backslash[-1] == '\\') { - backslash = NULL; - } - - if (backslash != NULL) { - /* We found a line continuation, but do we care? */ - if (!in_continued_line) { - if (in_directive(shader, backslash)) { - in_continued_line = 1; - extra_newlines = 0; - } - } - if (in_continued_line) { - /* Copy everything before the \ */ - ralloc_strncat(&clean, shader, backslash - shader); - shader = newline + 1; - extra_newlines++; - } - } else if (in_continued_line) { - /* Copy everything up to and including the \n */ - ralloc_strncat(&clean, shader, newline - shader + 1); - shader = newline + 1; - /* Output extra newlines to make line numbers match */ - for (; extra_newlines > 0; extra_newlines--) - ralloc_strcat(&clean, "\n"); - in_continued_line = 0; - } - search_start = newline + 1; - } - ralloc_strcat(&clean, shader); - return clean; -} - -int -preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions) -{ - int errors; - glcpp_parser_t *parser = glcpp_parser_create (extensions); - *shader = remove_line_continuations(parser, *shader); - - glcpp_lex_set_source_string (parser, *shader); - - glcpp_parser_parse (parser); - - if (parser->skip_stack) - glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n"); - - ralloc_strcat(info_log, parser->info_log); - - ralloc_steal(ralloc_ctx, parser->output); - *shader = parser->output; - - errors = parser->error; - glcpp_parser_destroy (parser); - return errors; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c deleted file mode 100644 index 696cb3a74fc..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c +++ /dev/null @@ -1 +0,0 @@ -this is four tokens diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c.expected deleted file mode 100644 index 83f7834d547..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/000-content-with-spaces.c.expected +++ /dev/null @@ -1,2 +0,0 @@ -this is four tokens - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c deleted file mode 100644 index cbf2fee0e75..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo 1 -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c.expected deleted file mode 100644 index 878fd15d6f8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/001-define.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c deleted file mode 100644 index 87d75c68751..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo 1 -#define bar foo -bar diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c.expected deleted file mode 100644 index 43d484d7131..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/002-define-chain.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c deleted file mode 100644 index a18b724eca0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar foo -#define foo 1 -bar diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected deleted file mode 100644 index 43d484d7131..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c deleted file mode 100644 index 2ac56ea3dcf..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo bar -#define bar baz -#define baz foo -foo -bar -baz diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c.expected deleted file mode 100644 index 4d2698b7a7f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/004-define-recursive.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - - - -foo -bar -baz - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c deleted file mode 100644 index f5521df968d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo 1 -#define bar a foo -bar diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c.expected deleted file mode 100644 index c67358f4f69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/005-define-composite-chain.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -a 1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c deleted file mode 100644 index 4bb91a1221a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar a foo -#define foo 1 -bar diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected deleted file mode 100644 index c67358f4f69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -a 1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c deleted file mode 100644 index 5784565bdf3..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo a bar -#define bar b baz -#define baz c foo -foo -bar -baz diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected deleted file mode 100644 index 30fe4dc1f62..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - - - -a b c foo -b c a bar -c a b baz - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c deleted file mode 100644 index b1bd17ec215..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c.expected deleted file mode 100644 index c0f53d75c71..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/008-define-empty.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c deleted file mode 100644 index 3fc1fb44243..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c +++ /dev/null @@ -1,4 +0,0 @@ -#define foo 1 -foo -#undef foo -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c.expected deleted file mode 100644 index 03a7061af03..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/009-undef.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - -1 - -foo - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c deleted file mode 100644 index 32ff73798b1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo 1 -foo -#undef foo -foo -#define foo 2 -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c.expected deleted file mode 100644 index f4f7efdc2bf..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/010-undef-re-define.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - -1 - -foo - -2 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c deleted file mode 100644 index d9ce13c2284..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo() -foo() diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c.expected deleted file mode 100644 index c0f53d75c71..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/011-define-func-empty.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c deleted file mode 100644 index c2bb730b115..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo() bar -foo() diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c.expected deleted file mode 100644 index 03537672974..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/012-define-func-no-args.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -bar - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c deleted file mode 100644 index f78fb8b118a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) 1 -foo(bar) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected deleted file mode 100644 index 878fd15d6f8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c deleted file mode 100644 index 11feb2624b7..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x,y) 1 -foo(bar,baz) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected deleted file mode 100644 index 878fd15d6f8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c deleted file mode 100644 index 558da9c617b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c +++ /dev/null @@ -1,4 +0,0 @@ -#define foo ()1 -foo() -#define bar ()2 -bar() diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected deleted file mode 100644 index d6f8cb9dc61..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - -()1() - -()2() - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c deleted file mode 100644 index a2e2404c7c1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) ((x)+1) -foo(bar) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected deleted file mode 100644 index 7f1828a3c61..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -((bar)+1) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c deleted file mode 100644 index c7253835278..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x,y) ((x)*(y)) -foo(bar,baz) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c.expected deleted file mode 100644 index 9f341dac00a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/017-define-func-2-args.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -((bar)*(baz)) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c deleted file mode 100644 index 668130b8f9b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c +++ /dev/null @@ -1,3 +0,0 @@ -#define x 0 -#define foo(x) x -foo(1) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected deleted file mode 100644 index 43d484d7131..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c deleted file mode 100644 index c4e62b25508..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) (x) -foo(this is more than one word) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected deleted file mode 100644 index 4314fc88d83..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -(this is more than one word) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c deleted file mode 100644 index 3049ad15465..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x,y) x,two fish,red fish,y -foo(one fish, blue fish) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected deleted file mode 100644 index 5648e4fb9d4..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -one fish,two fish,red fish,blue fish - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c deleted file mode 100644 index 21ddd0e65f9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar(x) (1+(x)) -#define foo(y) (2*(y)) -foo(bar(3)) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c.expected deleted file mode 100644 index 1d62105de4c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/021-define-func-compose.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -(2*((1+(3)))) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c deleted file mode 100644 index c20d73a4a28..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) (x) -foo(argument(including parens)for the win) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected deleted file mode 100644 index 66c16581758..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -(argument(including parens)for the win) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c deleted file mode 100644 index 7ebfed6516c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c +++ /dev/null @@ -1,8 +0,0 @@ -#define noargs() 1 -# define onearg(foo) foo - # define twoargs( x , y ) x y - # define threeargs( a , b , c ) a b c -noargs ( ) -onearg ( 2 ) -twoargs ( 3 , 4 ) -threeargs ( 5 , 6 , 7 ) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected deleted file mode 100644 index 573829c2d69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected +++ /dev/null @@ -1,9 +0,0 @@ - - - - -1 -2 -3 4 -5 6 7 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c deleted file mode 100644 index e788adce30c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo foo -#define bar foo -bar diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected deleted file mode 100644 index ad955fce6ec..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -foo - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c deleted file mode 100644 index b433671d1bf..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(bar) bar -foo bar diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected deleted file mode 100644 index 960f44511a9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo bar - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c deleted file mode 100644 index 0d837405309..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c +++ /dev/null @@ -1,6 +0,0 @@ -#define foo(a) bar - -foo -( -1 -) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected deleted file mode 100644 index f0888f21b94..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -bar - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c deleted file mode 100644 index 5ccb52caba5..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c +++ /dev/null @@ -1,3 +0,0 @@ -#define failure() success -#define foo failure() -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c deleted file mode 100644 index 44962a71876..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c +++ /dev/null @@ -1,3 +0,0 @@ -#define success() failure -#define foo success -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c deleted file mode 100644 index 261f7d28fc2..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar(failure) failure -#define foo bar(success) -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c deleted file mode 100644 index e56fbefd62d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c +++ /dev/null @@ -1,4 +0,0 @@ -#define baz(failure) failure -#define bar(failure) failure -#define foo bar(baz(success)) -foo diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected deleted file mode 100644 index 729bdd15f80..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c deleted file mode 100644 index 3f4c8744dff..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c +++ /dev/null @@ -1,4 +0,0 @@ -#define baz(failure) failure -#define bar(failure) failure -#define foo() bar(baz(success)) -foo() diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected deleted file mode 100644 index 729bdd15f80..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c deleted file mode 100644 index b3ac70f499c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(a) foo(2*(a)) -foo(3) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected deleted file mode 100644 index 541d44db7ab..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo(2*(3)) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c deleted file mode 100644 index f65e48286cf..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(a) foo(2*(a)) -foo(foo(3)) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected deleted file mode 100644 index 6ea6905d80b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo(2*(foo(2*(3)))) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c deleted file mode 100644 index 209a5f7e07c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(bar) bar -foo(foo) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected deleted file mode 100644 index 24823b1b673..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -foo - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c deleted file mode 100644 index c307fbe830f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(bar) bar -foo(1+foo) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected deleted file mode 100644 index 137a9ea2db8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1+foo - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c deleted file mode 100644 index b21ff336738..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c +++ /dev/null @@ -1,3 +0,0 @@ -#define bar success -#define foo(x) x -foo(more bar) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected deleted file mode 100644 index ff6360bfe4e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -more success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c deleted file mode 100644 index b3a2f37f1b9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c +++ /dev/null @@ -1,3 +0,0 @@ -#define expand(x) expand(x once) -#define foo(x) x -foo(expand(just)) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected deleted file mode 100644 index cbadee848a5..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -expand(just once) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c deleted file mode 100644 index 1407c7d6e3c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c +++ /dev/null @@ -1,2 +0,0 @@ -#define foo(x) success -foo(argument (with,embedded , commas) -- tricky) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected deleted file mode 100644 index 5a28fb3b66c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c deleted file mode 100644 index 0f7fe632b56..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c +++ /dev/null @@ -1,3 +0,0 @@ -#define foo(a) (a) -#define bar two,words -foo(bar) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected deleted file mode 100644 index b73869d0238..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -(two,words) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c deleted file mode 100644 index caab3ba7368..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c +++ /dev/null @@ -1,2 +0,0 @@ -#define paste(a,b) a ## b -paste(one , token) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c.expected deleted file mode 100644 index 36f66992539..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/040-token-pasting.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -onetoken - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c deleted file mode 100644 index 2cab677d3e8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c +++ /dev/null @@ -1,5 +0,0 @@ -success_1 -#if 0 -failure -#endif -success_2 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c.expected deleted file mode 100644 index 3800024c6ff..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/041-if-0.c.expected +++ /dev/null @@ -1,6 +0,0 @@ -success_1 - - - -success_2 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c deleted file mode 100644 index 874a25cf41b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c +++ /dev/null @@ -1,5 +0,0 @@ -success_1 -#if 1 -success_2 -#endif -success_3 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c.expected deleted file mode 100644 index e591044adbb..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/042-if-1.c.expected +++ /dev/null @@ -1,6 +0,0 @@ -success_1 - -success_2 - -success_3 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c deleted file mode 100644 index 323351f9dbf..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c +++ /dev/null @@ -1,7 +0,0 @@ -success_1 -#if 0 -failure -#else -success_2 -#endif -success_3 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c.expected deleted file mode 100644 index ee9e677096e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/043-if-0-else.c.expected +++ /dev/null @@ -1,8 +0,0 @@ -success_1 - - - -success_2 - -success_3 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c deleted file mode 100644 index 28dfc25c6f0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c +++ /dev/null @@ -1,7 +0,0 @@ -success_1 -#if 1 -success_2 -#else -failure -#endif -success_3 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c.expected deleted file mode 100644 index 129f5c8542e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/044-if-1-else.c.expected +++ /dev/null @@ -1,8 +0,0 @@ -success_1 - -success_2 - - - -success_3 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c deleted file mode 100644 index e50f686d461..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 0 -failure_1 -#elif 0 -failure_2 -#elif 1 -success_3 -#elif 1 -failure_3 -#endif -success_4 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c.expected deleted file mode 100644 index 97a11b4472e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/045-if-0-elif.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - - - - - -success_3 - - - -success_4 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c deleted file mode 100644 index 130515a01ea..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 1 -success_2 -#elif 0 -failure_1 -#elif 1 -failure_2 -#elif 0 -failure_3 -#endif -success_3 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c.expected deleted file mode 100644 index b928b917e3d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/046-if-1-elsif.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - -success_2 - - - - - - - -success_3 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c deleted file mode 100644 index e8f0838a9ed..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 0 -failure_1 -#elif 0 -failure_2 -#elif 0 -failure_3 -#else -success_2 -#endif -success_3 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c.expected deleted file mode 100644 index e5b53a3fa59..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/047-if-elif-else.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - - - - - - - -success_2 - -success_3 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c deleted file mode 100644 index fc4679c3be4..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c +++ /dev/null @@ -1,11 +0,0 @@ -success_1 -#if 0 -failure_1 -#if 1 -failure_2 -#else -failure_3 -#endif -failure_4 -#endif -success_2 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c.expected deleted file mode 100644 index c61fd0b3159..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/048-if-nested.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -success_1 - - - - - - - - - -success_2 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c deleted file mode 100644 index 833ea03882a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c +++ /dev/null @@ -1,5 +0,0 @@ -#if 1 + 2 * 3 + - (25 % 17 - + 1) -failure with operator precedence -#else -success -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected deleted file mode 100644 index 569debb0bb6..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - -success - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c deleted file mode 100644 index 34f0f95140e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c +++ /dev/null @@ -1,17 +0,0 @@ -#if defined foo -failure_1 -#else -success_1 -#endif -#define foo -#if defined foo -success_2 -#else -failure_2 -#endif -#undef foo -#if defined foo -failure_3 -#else -success_3 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c.expected deleted file mode 100644 index 3f01955ee40..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/050-if-defined.c.expected +++ /dev/null @@ -1,18 +0,0 @@ - - - -success_1 - - - -success_2 - - - - - - - -success_3 - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c deleted file mode 100644 index c3db488e0de..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c +++ /dev/null @@ -1,35 +0,0 @@ -#if 3 < 2 -failure_1 -#else -success_1 -#endif - -#if 3 >= 2 -success_2 -#else -failure_2 -#endif - -#if 2 + 3 <= 5 -success_3 -#else -failure_3 -#endif - -#if 3 - 2 == 1 -success_3 -#else -failure_3 -#endif - -#if 1 > 3 -failure_4 -#else -success_4 -#endif - -#if 1 != 5 -success_5 -#else -failure_5 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c.expected deleted file mode 100644 index d2b76f14576..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/051-if-relational.c.expected +++ /dev/null @@ -1,36 +0,0 @@ - - - -success_1 - - - -success_2 - - - - - -success_3 - - - - - -success_3 - - - - - - - -success_4 - - - -success_5 - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c deleted file mode 100644 index 2d8e45eb61e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c +++ /dev/null @@ -1,20 +0,0 @@ -#if (0xaaaaaaaa | 0x55555555) != 4294967295 -failure_1 -#else -success_1 -#endif -#if (0x12345678 ^ 0xfdecba98) == 4023971040 -success_2 -#else -failure_2 -#endif -#if (~ 0xdeadbeef) != -3735928560 -failure_3 -#else -success_3 -#endif -#if (0667 & 0733) == 403 -success_4 -#else -failure_4 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c.expected deleted file mode 100644 index bb5d92e8d92..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/052-if-bitwise.c.expected +++ /dev/null @@ -1,21 +0,0 @@ - - - -success_1 - - -success_2 - - - - - - -success_3 - - -success_4 - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c deleted file mode 100644 index d24c54a88d1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c +++ /dev/null @@ -1,15 +0,0 @@ -#if (15 / 2) != 7 -failure_1 -#else -success_1 -#endif -#if (1 << 12) == 4096 -success_2 -#else -failure_2 -#endif -#if (31762 >> 8) != 124 -failure_3 -#else -success_3 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected deleted file mode 100644 index f97e93673cc..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected +++ /dev/null @@ -1,16 +0,0 @@ - - - -success_1 - - -success_2 - - - - - - -success_3 - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c deleted file mode 100644 index 3da79a0d96e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c +++ /dev/null @@ -1,34 +0,0 @@ -#define one 1 -#define two 2 -#define three 3 -#define five 5 -#if five < two -failure_1 -#else -success_1 -#endif -#if three >= two -success_2 -#else -failure_2 -#endif -#if two + three <= five -success_3 -#else -failure_3 -#endif -#if five - two == three -success_4 -#else -failure_4 -#endif -#if one > three -failure_5 -#else -success_5 -#endif -#if one != five -success_6 -#else -failure_6 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c.expected deleted file mode 100644 index 27ea4969628..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/054-if-with-macros.c.expected +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - -success_1 - - -success_2 - - - - -success_3 - - - - -success_4 - - - - - - -success_5 - - -success_6 - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c deleted file mode 100644 index 00f2c2346d6..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c +++ /dev/null @@ -1,3 +0,0 @@ -#define failure() success -#define foo failure -foo() diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected deleted file mode 100644 index aef762e1e69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c deleted file mode 100644 index 58701d1f25b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c +++ /dev/null @@ -1,4 +0,0 @@ -#define bar with,embedded,commas -#define function(x) success -#define foo function -foo(bar) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected deleted file mode 100644 index 729bdd15f80..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c deleted file mode 100644 index 6140232865d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c +++ /dev/null @@ -1,6 +0,0 @@ -#define zero() success -zero() -#define one(x) success -one() -#define two(x,y) success -two(,) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c.expected deleted file mode 100644 index 4e3aad52173..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/057-empty-arguments.c.expected +++ /dev/null @@ -1,7 +0,0 @@ - -success - -success - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c deleted file mode 100644 index 8ac260c76b6..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c +++ /dev/null @@ -1,5 +0,0 @@ -#define paste(x,y) x ## y -paste(a,b) -paste(a,) -paste(,b) -paste(,) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected deleted file mode 100644 index a1c34e5c1f8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - -ab -a -b - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c deleted file mode 100644 index 37b895a4237..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c +++ /dev/null @@ -1,4 +0,0 @@ -#define paste(x,y) x ## y -paste(1,2) -paste(1,000) -paste(identifier,2) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected deleted file mode 100644 index f1a2cd21c13..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - -12 -1000 -identifier2 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c deleted file mode 100644 index ed80ea879ce..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c +++ /dev/null @@ -1,3 +0,0 @@ -#define double(a) a*2 -#define foo double( -foo 5) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected deleted file mode 100644 index c1f0d24a144..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -5*2 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c deleted file mode 100644 index 6dbfd1f62d1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c +++ /dev/null @@ -1,5 +0,0 @@ -#define foo(x) success -#define bar foo -#define baz bar -#define joe baz -joe (failure) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected deleted file mode 100644 index 111f7d10634..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c deleted file mode 100644 index d9e439bb890..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c +++ /dev/null @@ -1,5 +0,0 @@ -#define foo(a,b) -#if 0 -foo(bar) -foo( -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected deleted file mode 100644 index 6fb66a5e2f0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c deleted file mode 100644 index e641d2f0f9e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c +++ /dev/null @@ -1,20 +0,0 @@ -/* this is a comment */ -// so is this -// */ -f = g/**//h; -/*//*/l(); -m = n//**/o -+ p; -/* this -comment spans -multiple lines and -contains *** stars -and slashes / *** / -and other stuff. -****/ -more code here -/* Test that /* nested - comments */ -are not treated like comments. -/*/ this is a comment */ -/*/*/ diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c.expected deleted file mode 100644 index 73ca7071faa..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/063-comments.c.expected +++ /dev/null @@ -1,21 +0,0 @@ - - - -f = g /h; - l(); -m = n -+ p; - - - - - - - -more code here - - -are not treated like comments. - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c deleted file mode 100644 index 21326481b87..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c +++ /dev/null @@ -1,2 +0,0 @@ -#version 130 -#define FOO diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c.expected deleted file mode 100644 index 3af71113c8c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/064-version.c.expected +++ /dev/null @@ -1,3 +0,0 @@ -#version 130 - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c deleted file mode 100644 index 48aa0f8c3ef..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c +++ /dev/null @@ -1,17 +0,0 @@ -#if defined(foo) -failure_1 -#else -success_1 -#endif -#define foo -#if defined ( foo ) -success_2 -#else -failure_2 -#endif -#undef foo -#if defined (foo) -failure_3 -#else -success_3 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c.expected deleted file mode 100644 index 3f01955ee40..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/065-if-defined-parens.c.expected +++ /dev/null @@ -1,18 +0,0 @@ - - - -success_1 - - - -success_2 - - - - - - - -success_3 - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c deleted file mode 100644 index 3b0b47349d0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c +++ /dev/null @@ -1,3 +0,0 @@ -#if(1) -success -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected deleted file mode 100644 index 0e84a7cda39..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - -success - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c deleted file mode 100644 index f46cce4e60a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c +++ /dev/null @@ -1,40 +0,0 @@ -#define D1 -#define D2 - -#define result success - -#ifdef U1 -#ifdef U2 -#undef result -#define result failure -#endif -#endif -result - -#ifndef D1 -#ifndef D2 -#undef result -#define result failure -#endif -#endif -result - -#undef result -#define result failure -#ifdef D1 -#ifdef D2 -#undef result -#define result success -#endif -#endif -result - -#undef result -#define result failure -#ifndef U1 -#ifndef U2 -#undef result -#define result success -#endif -#endif -result diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected deleted file mode 100644 index 3340daaa1f9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - -success - - - - - - - -success - - - - - - - - - -success - - - - - - - - - -success - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c deleted file mode 100644 index 699ac5144e5..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c +++ /dev/null @@ -1,11 +0,0 @@ -#define empty -empty> ->empty= -=empty= -!empty= -&empty& -|empty| -+empty+ --empty- diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c.expected deleted file mode 100644 index ce41cd6e524..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/068-accidental-pasting.c.expected +++ /dev/null @@ -1,12 +0,0 @@ - -< < -< = -> > -> = -= = -! = -& & -| | -+ + -- - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c deleted file mode 100644 index 2b46ead294c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c +++ /dev/null @@ -1,2 +0,0 @@ -#define double(x) x x -double(1) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c.expected deleted file mode 100644 index 755c4d4b56c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/069-repeated-argument.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -1 1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c deleted file mode 100644 index b6dc2ba075f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c +++ /dev/null @@ -1,2 +0,0 @@ -#if UNDEFINED_MACRO -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected deleted file mode 100644 index 2bb38a1411e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected +++ /dev/null @@ -1,2 +0,0 @@ -0:1(21): preprocessor error: syntax error, unexpected IDENTIFIER - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c deleted file mode 100644 index 959d6825988..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c +++ /dev/null @@ -1 +0,0 @@ -a = b diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c.expected deleted file mode 100644 index fee253b7452..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/071-punctuator.c.expected +++ /dev/null @@ -1,2 +0,0 @@ -a = b - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c deleted file mode 100644 index e421e9d5e29..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c +++ /dev/null @@ -1,2 +0,0 @@ -#define paste(x) success_ ## x -paste(1) paste(2) paste(3) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected deleted file mode 100644 index c780b43d70f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected +++ /dev/null @@ -1,3 +0,0 @@ - -success_1 success_2 success_3 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c deleted file mode 100644 index 61a48097ca3..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef UNDEF -#if UNDEF > 1 -#endif -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected deleted file mode 100644 index 3f2ff2d6cc8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c deleted file mode 100644 index 67aac8977e0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c +++ /dev/null @@ -1,3 +0,0 @@ -#ifndef UNDEF -#elif UNDEF < 0 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c.expected deleted file mode 100644 index fd40910d9e7..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/074-elif-undef.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c deleted file mode 100644 index 264bc4f10ee..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef UNDEF -#elif UNDEF < 0 -#elif UNDEF == 3 -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected deleted file mode 100644 index 3f2ff2d6cc8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c deleted file mode 100644 index ebd550ed005..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef UNDEF -#if UNDEF == 4 -#elif UNDEF == 5 -#endif -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected deleted file mode 100644 index 6fb66a5e2f0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c deleted file mode 100644 index 81f00bfe278..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c +++ /dev/null @@ -1 +0,0 @@ -#else diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c.expected deleted file mode 100644 index d289b363562..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/077-else-without-if.c.expected +++ /dev/null @@ -1,4 +0,0 @@ -0:1(2): preprocessor error: else without #if - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c deleted file mode 100644 index 60466b3890a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c +++ /dev/null @@ -1 +0,0 @@ -#elif defined FOO diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c.expected deleted file mode 100644 index 7d41f0ac794..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/078-elif-without-if.c.expected +++ /dev/null @@ -1,4 +0,0 @@ -0:1(2): preprocessor error: elif without #if - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c deleted file mode 100644 index 69331c3ca9d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c +++ /dev/null @@ -1 +0,0 @@ -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c.expected deleted file mode 100644 index 08dd33546f2..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/079-endif-without-if.c.expected +++ /dev/null @@ -1,4 +0,0 @@ -0:1(2): preprocessor error: #endif without #if - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c deleted file mode 100644 index a27ba36a366..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c +++ /dev/null @@ -1,4 +0,0 @@ -/* Error message for unskipped #if with no expression. */ -#if -#endif - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c.expected deleted file mode 100644 index 768ba0f473f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/080-if-without-expression.c.expected +++ /dev/null @@ -1,6 +0,0 @@ -0:2(1): preprocessor error: #if with no expression - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c deleted file mode 100644 index 79c78663dd3..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c +++ /dev/null @@ -1,3 +0,0 @@ -#if 0 -#elif -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c.expected deleted file mode 100644 index 974f0f550eb..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/081-elif-without-expression.c.expected +++ /dev/null @@ -1,5 +0,0 @@ -0:2(1): preprocessor error: #elif with no expression - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c deleted file mode 100644 index 40bf64411c5..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c +++ /dev/null @@ -1,2 +0,0 @@ -#define PASTE(x,y) x ## y -PASTE(<,>) diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c.expected deleted file mode 100644 index 2c924406b59..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/082-invalid-paste.c.expected +++ /dev/null @@ -1,5 +0,0 @@ -0:2(7): preprocessor error: -Pasting "<" and ">" does not give a valid preprocessing token. - -< - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c deleted file mode 100644 index 91806350927..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c +++ /dev/null @@ -1,2 +0,0 @@ -#if 1 - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c.expected deleted file mode 100644 index a69f8bab582..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/083-unterminated-if.c.expected +++ /dev/null @@ -1,5 +0,0 @@ -0:1(7): preprocessor error: Unterminated #if - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c deleted file mode 100644 index 0789ba5e525..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c +++ /dev/null @@ -1,2 +0,0 @@ -#define FUNC(x) (2*(x)) -FUNC(23 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected deleted file mode 100644 index af49a37369d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected +++ /dev/null @@ -1,2 +0,0 @@ -0:2(8): preprocessor error: syntax error, unexpected $end - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c deleted file mode 100644 index 91bea600612..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c +++ /dev/null @@ -1,5 +0,0 @@ -#define MULT(x,y) ((x)*(y)) -MULT() -MULT(1) -MULT(1,2,3) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected deleted file mode 100644 index 1df30cbb56f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected +++ /dev/null @@ -1,12 +0,0 @@ -0:2(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2) - -0:3(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2) - -0:4(1): preprocessor error: Error: macro MULT invoked with 3 arguments (expected 2) - - -MULT() -MULT(1) -MULT(1,2,3) - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c deleted file mode 100644 index a6b7201f95d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c +++ /dev/null @@ -1,3 +0,0 @@ -#define __BAD reserved -#define GL_ALSO_BAD() also reserved -#define THIS__TOO__IS__BAD reserved diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected deleted file mode 100644 index d8aa9f0a648..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected +++ /dev/null @@ -1,10 +0,0 @@ -0:1(10): preprocessor error: Macro names containing "__" are reserved. - -0:2(9): preprocessor error: Macro names starting with "GL_" are reserved. - -0:3(9): preprocessor error: Macro names containing "__" are reserved. - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c deleted file mode 100644 index ce8dc43057f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c +++ /dev/null @@ -1,5 +0,0 @@ -#if (1 == 0) // dangerous comment -fail -#else -win -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c.expected deleted file mode 100644 index 827e548fe55..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/087-if-comments.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - -win - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c deleted file mode 100644 index 0e0666b8b35..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define abc 123 -#define abc 123 - -#define foo(x) (x)+23 -#define foo(x) ( x ) + 23 diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected deleted file mode 100644 index 6fb66a5e2f0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c deleted file mode 100644 index b3d1391e160..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c +++ /dev/null @@ -1,17 +0,0 @@ -#define x y -#define x z - -#define abc 123 -#define abc() 123 - -#define foo() bar -#define foo(x) bar - -#define bar() baz -#define bar baz - -#define biff(a,b) a+b -#define biff(a,b,c) a+b - -#define oper(a,b) a+b -#define oper(a,b) a*b diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c.expected deleted file mode 100644 index 6209ead559e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/089-redefine-macro-error.c.expected +++ /dev/null @@ -1,30 +0,0 @@ -0:2(9): preprocessor error: Redefinition of macro x - -0:5(9): preprocessor error: Redefinition of macro abc - -0:8(9): preprocessor error: Redefinition of macro foo - -0:11(9): preprocessor error: Redefinition of macro bar - -0:14(9): preprocessor error: Redefinition of macro biff - -0:17(9): preprocessor error: Redefinition of macro oper - - - - - - - - - - - - - - - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c deleted file mode 100644 index d19bb7faed8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c +++ /dev/null @@ -1 +0,0 @@ -#error human error diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c.expected deleted file mode 100644 index f2f1fbeaf8a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/090-hash-error.c.expected +++ /dev/null @@ -1,3 +0,0 @@ -0:1(2): preprocessor error: #error human error - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c deleted file mode 100644 index fea35d37b05..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c +++ /dev/null @@ -1,8 +0,0 @@ -#line 0 -#error line 0 error -#line 25 -#error line 25 error -#line 0 1 -#error source 1, line 0 error -#line 30 2 -#error source 2, line 30 error diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c.expected deleted file mode 100644 index e663398c160..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/091-hash-line.c.expected +++ /dev/null @@ -1,13 +0,0 @@ -0:0(1): preprocessor error: #error line 0 error -0:25(1): preprocessor error: #error line 25 error -1:0(1): preprocessor error: #error source 1, line 0 error -2:30(1): preprocessor error: #error source 2, line 30 error - - - - - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c deleted file mode 100644 index 3c161a5c501..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c +++ /dev/null @@ -1,5 +0,0 @@ -#define A -#define A 1 - -#define B 1 -#define B diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected deleted file mode 100644 index 0026f91f32b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected +++ /dev/null @@ -1,10 +0,0 @@ -0:2(9): preprocessor error: Redefinition of macro A - -0:5(9): preprocessor error: Redefinition of macro B - - - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c deleted file mode 100644 index bf65d4f5271..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c +++ /dev/null @@ -1,2 +0,0 @@ -#if (1 / 0) -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c.expected deleted file mode 100644 index 08f183f24f5..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/093-divide-by-zero.c.expected +++ /dev/null @@ -1,4 +0,0 @@ -0:1(13): preprocessor error: division by 0 in preprocessor directive - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c deleted file mode 100644 index 04497b17913..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c +++ /dev/null @@ -1,13 +0,0 @@ -/* glcpp is generating a division-by-zero error for this case. It's - * easy to argue that it should be short-circuiting the evaluation and - * not generating the diagnostic (which happens to be what gcc does). - * But it doesn't seem like we should force this behavior on our - * pre-processor, (and, as always, the GLSL specification of the - * pre-processor is too vague on this point). - * - * If a short-circuit evaluation optimization does get added to the - * pre-processor then it would legitimate to update the expected file - * for this test. -*/ -#if 1 || (1 / 0) -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected deleted file mode 100644 index 84fdc50c920..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected +++ /dev/null @@ -1,15 +0,0 @@ -0:12(17): preprocessor error: division by 0 in preprocessor directive - - - - - - - - - - - - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c deleted file mode 100644 index 801d90ce2e3..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c +++ /dev/null @@ -1,3 +0,0 @@ -#define A(a, b) B(a, b) -#define C A(0, C) -C diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c.expected deleted file mode 100644 index c7aa18ff6cb..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/095-recursive-define.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - - -B(0, C) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c deleted file mode 100644 index 8da756fcba4..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c +++ /dev/null @@ -1,3 +0,0 @@ -#define paste_twice(a,b,c) a ## b ## c -paste_twice(just, one, token) - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c.expected deleted file mode 100644 index e40194112aa..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/096-paste-twice.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - -justonetoken - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c deleted file mode 100644 index 0f46835c29e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c +++ /dev/null @@ -1,3 +0,0 @@ -#define PASTE_MACRO one ## token -PASTE_MACRO - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected deleted file mode 100644 index af92187ee90..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected +++ /dev/null @@ -1,4 +0,0 @@ - -onetoken - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c deleted file mode 100644 index 52a331cc414..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c +++ /dev/null @@ -1,3 +0,0 @@ -#if 0 -#elif UNDEFINED_MACRO -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c.expected deleted file mode 100644 index de967eac438..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/098-elif-undefined.c.expected +++ /dev/null @@ -1,5 +0,0 @@ -0:2(22): preprocessor error: syntax error, unexpected IDENTIFIER -0:1(7): preprocessor error: Unterminated #if - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c deleted file mode 100644 index d1976b1f265..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c +++ /dev/null @@ -1,17 +0,0 @@ -#define x 3 -#define f(a) f(x * (a)) -#undef x -#define x 2 -#define g f -#define z z[0] -#define h g(~ -#define m(a) a(w) -#define w 0,1 -#define t(a) a -#define p() int -#define q(x) x -#define r(x,y) x ## y -f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); -g(x +(3,4)-w) | h 5) & m - (f)^m(m); -p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)}; diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c.expected b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c.expected deleted file mode 100644 index 19be7505552..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/099-c99-example.c.expected +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - -f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); -f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); -int i[] = { 1, 23, 4, 5, }; - diff --git a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/glcpp-test b/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/glcpp-test deleted file mode 100644 index e8f3b546387..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glcpp/tests/glcpp-test +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh - -trap 'rm $test.valgrind-errors; exit 1' INT QUIT - -usage () -{ - cat <&2 - echo >&2 - usage - exit 1 - fi -done - -total=0 -pass=0 -clean=0 - -echo "====== Testing for correctness ======" -for test in *.c; do - echo -n "Testing $test..." - ../glcpp < $test > $test.out 2>&1 - total=$((total+1)) - if cmp $test.expected $test.out >/dev/null 2>&1; then - echo "PASS" - pass=$((pass+1)) - else - echo "FAIL" - diff -u $test.expected $test.out - fi -done - -echo "" -echo "$pass/$total tests returned correct results" -echo "" - -if [ "$do_valgrind" = "yes" ]; then - echo "====== Testing for valgrind cleanliness ======" - for test in *.c; do - echo -n "Testing $test with valgrind..." - valgrind --error-exitcode=31 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null 2>&1 - if [ "$?" = "31" ]; then - echo "ERRORS" - cat $test.valgrind-errors - else - echo "CLEAN" - clean=$((clean+1)) - rm $test.valgrind-errors - fi - done - - echo "" - echo "$pass/$total tests returned correct results" - echo "$clean/$total tests are valgrind-clean" -fi - -if [ "$pass" = "$total" ] && [ "$clean" = "$total" ]; then - exit 0 -else - exit 1 -fi - diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_lexer.cpp b/reactos/dll/opengl/mesa/src/glsl/glsl_lexer.cpp deleted file mode 100644 index 5f71a1883c0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_lexer.cpp +++ /dev/null @@ -1,3784 +0,0 @@ -#line 2 "glsl_lexer.cpp" - -#line 4 "glsl_lexer.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE _mesa_glsl_restart(yyin ,yyscanner ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via _mesa_glsl_restart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void _mesa_glsl_restart (FILE *input_file ,yyscan_t yyscanner ); -void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner ); - -static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner ); -static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner ); -static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); - -#define YY_FLUSH_BUFFER _mesa_glsl__flush_buffer(YY_CURRENT_BUFFER ,yyscanner) - -YY_BUFFER_STATE _mesa_glsl__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *_mesa_glsl_alloc (yy_size_t ,yyscan_t yyscanner ); -void *_mesa_glsl_realloc (void *,yy_size_t ,yyscan_t yyscanner ); -void _mesa_glsl_free (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer _mesa_glsl__create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - _mesa_glsl_ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - _mesa_glsl_ensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define _mesa_glsl_wrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 211 -#define YY_END_OF_BUFFER 212 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[847] = - { 0, - 0, 0, 16, 16, 0, 0, 212, 210, 1, 21, - 210, 210, 210, 210, 210, 210, 210, 210, 121, 119, - 210, 210, 210, 209, 210, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 210, 1, 210, 211, 16, - 20, 211, 19, 17, 18, 14, 13, 1, 103, 112, - 104, 115, 109, 98, 111, 99, 118, 123, 110, 124, - 121, 0, 0, 126, 121, 0, 119, 119, 107, 100, - 102, 101, 108, 209, 116, 106, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 30, 209, - - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 34, 209, 209, 61, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 117, - 105, 1, 0, 0, 2, 0, 0, 0, 0, 16, - 15, 19, 18, 0, 123, 122, 0, 124, 0, 125, - 120, 113, 114, 209, 129, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 33, 209, 209, 209, - - 209, 209, 209, 209, 209, 209, 209, 26, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 62, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 0, 0, 0, 0, 15, 0, 123, 0, 122, 0, - 124, 125, 120, 209, 209, 24, 209, 209, 176, 169, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 32, - 132, 209, 209, 209, 209, 68, 209, 209, 137, 151, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - - 209, 209, 148, 172, 49, 50, 51, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 135, 127, 209, - 209, 27, 209, 209, 209, 209, 209, 209, 209, 46, - 47, 48, 96, 209, 209, 0, 0, 0, 0, 0, - 122, 209, 209, 28, 37, 38, 39, 209, 130, 209, - 23, 209, 209, 209, 209, 159, 160, 161, 209, 128, - 209, 152, 25, 162, 163, 164, 174, 156, 157, 158, - 209, 209, 209, 63, 154, 209, 209, 209, 40, 41, - 42, 209, 209, 209, 209, 209, 209, 209, 209, 209, - - 209, 209, 209, 209, 209, 209, 209, 149, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 131, 209, - 209, 171, 43, 44, 45, 209, 209, 31, 0, 0, - 0, 0, 179, 209, 209, 177, 209, 209, 209, 150, - 145, 182, 209, 209, 209, 209, 209, 209, 140, 209, - 209, 209, 97, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 209, 209, 209, 209, 155, 136, 209, 209, - 143, 36, 209, 209, 168, 69, 144, 95, 180, 138, - 209, 209, 209, 209, 209, 209, 209, 209, 0, 0, - 0, 0, 209, 209, 209, 139, 35, 209, 209, 209, - - 209, 209, 209, 183, 184, 185, 209, 209, 209, 209, - 209, 173, 209, 209, 209, 209, 209, 209, 209, 209, - 133, 209, 209, 209, 209, 209, 64, 209, 209, 65, - 209, 0, 0, 0, 0, 0, 209, 66, 29, 146, - 187, 188, 189, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 141, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 134, 191, 192, 193, - 209, 209, 153, 209, 142, 0, 0, 6, 0, 0, - 0, 12, 3, 22, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 186, 147, 67, 209, 209, 209, 209, - - 170, 209, 178, 175, 208, 71, 72, 73, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 0, - 0, 0, 0, 0, 0, 0, 209, 209, 209, 190, - 209, 209, 209, 209, 209, 82, 83, 84, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 194, 88, 89, 90, 209, 4, 0, 5, - 0, 0, 0, 0, 0, 0, 209, 209, 209, 209, - 209, 209, 209, 205, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 74, 209, 209, 209, 209, - 209, 209, 209, 0, 0, 0, 0, 209, 209, 206, - - 195, 209, 196, 209, 209, 209, 85, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 207, - 209, 209, 91, 0, 0, 0, 197, 198, 209, 201, - 209, 202, 209, 209, 70, 209, 209, 209, 165, 209, - 166, 181, 209, 209, 199, 200, 209, 209, 0, 0, - 0, 209, 209, 209, 209, 75, 209, 76, 209, 209, - 209, 209, 209, 209, 0, 0, 0, 0, 209, 209, - 86, 87, 209, 77, 209, 209, 78, 209, 209, 92, - 93, 0, 0, 0, 0, 209, 209, 209, 209, 209, - 209, 209, 0, 0, 0, 0, 209, 209, 209, 209, - - 209, 79, 209, 0, 0, 0, 7, 0, 0, 203, - 204, 209, 209, 209, 94, 0, 0, 8, 0, 0, - 209, 209, 167, 0, 0, 0, 80, 81, 0, 0, - 0, 9, 0, 0, 10, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 11, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, - 10, 11, 12, 1, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 21, 21, 22, 22, 23, 1, 24, - 25, 26, 1, 1, 27, 28, 29, 30, 31, 32, - 33, 34, 34, 34, 34, 35, 34, 34, 36, 34, - 34, 37, 38, 39, 40, 34, 34, 41, 34, 34, - 1, 1, 1, 42, 43, 1, 44, 45, 46, 47, - - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 34, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 1, 69, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[70] = - { 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, - 3, 3, 1, 1, 1, 1, 4, 4, 4, 4, - 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 1, 5, 4, 4, 4, 4, 3, 3, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 1 - } ; - -static yyconst flex_int16_t yy_base[856] = - { 0, - 0, 68, 74, 0, 1223, 1222, 1224, 1227, 69, 1227, - 1198, 1197, 136, 1196, 133, 134, 132, 1195, 148, 201, - 131, 1194, 146, 0, 121, 114, 123, 146, 134, 136, - 172, 1160, 161, 182, 141, 129, 151, 1154, 140, 187, - 196, 203, 205, 223, 1165, 187, 204, 270, 1227, 224, - 1227, 1200, 258, 1227, 0, 1227, 1227, 240, 1227, 1227, - 1227, 1227, 1227, 1227, 1227, 1227, 1227, 251, 1227, 253, - 224, 321, 275, 1227, 1227, 0, 0, 1227, 1189, 1227, - 1227, 1227, 1188, 0, 1227, 1227, 1150, 1155, 1148, 1151, - 1160, 1159, 1145, 1148, 1160, 247, 1154, 1141, 1138, 1152, - - 1138, 1135, 1135, 1141, 243, 261, 1135, 1146, 1131, 1137, - 1141, 1142, 0, 1133, 1144, 252, 1143, 1138, 1118, 172, - 1122, 1136, 1126, 201, 1119, 260, 1132, 1134, 1116, 1112, - 1120, 1117, 1106, 1115, 264, 1113, 1119, 1114, 1117, 1105, - 1108, 256, 265, 271, 1118, 1105, 1118, 234, 1111, 1227, - 1227, 326, 319, 342, 1227, 1096, 1109, 1100, 1111, 329, - 0, 338, 0, 391, 1227, 315, 402, 1227, 409, 416, - 287, 1227, 1227, 1106, 0, 1097, 1101, 1111, 1108, 300, - 1091, 1091, 1095, 304, 1106, 1103, 1103, 1101, 1098, 1089, - 1096, 1082, 1080, 1093, 1078, 1095, 0, 1092, 1079, 1087, - - 1084, 1088, 1089, 1082, 1079, 1067, 1066, 1080, 1083, 1070, - 1079, 1066, 1073, 1063, 353, 1069, 1072, 1062, 1070, 1058, - 1062, 1053, 1068, 1058, 1049, 1068, 1051, 1049, 1060, 1049, - 1044, 1042, 1056, 1041, 1043, 1040, 1052, 1051, 1054, 1035, - 319, 1044, 1039, 1037, 1047, 1025, 361, 1044, 1046, 1034, - 1026, 1030, 1042, 1025, 0, 423, 434, 451, 1227, 458, - 468, 1227, 1227, 1020, 1031, 0, 1028, 366, 0, 0, - 1021, 1019, 1021, 1016, 1025, 1013, 1031, 1019, 369, 0, - 0, 1013, 1024, 1023, 1023, 0, 1007, 373, 0, 0, - 1009, 376, 1017, 1018, 1008, 1002, 1001, 1002, 1001, 1001, - - 380, 996, 0, 0, 992, 991, 990, 992, 993, 998, - 992, 988, 1002, 997, 996, 995, 986, 989, 989, 981, - 984, 979, 988, 993, 978, 991, 981, 0, 0, 988, - 984, 0, 975, 975, 981, 971, 979, 439, 976, 0, - 0, 0, 0, 965, 978, 977, 976, 973, 961, 475, - 486, 973, 975, 0, 0, 0, 0, 961, 0, 961, - 0, 960, 961, 955, 966, 0, 0, 0, 956, 0, - 952, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 963, 492, 962, 0, 0, 960, 956, 952, 0, 0, - 0, 944, 442, 494, 504, 949, 945, 951, 941, 939, - - 953, 937, 937, 951, 939, 951, 946, 0, 944, 941, - 945, 928, 930, 937, 943, 938, 937, 924, 0, 926, - 927, 0, 0, 0, 0, 924, 928, 0, 922, 976, - 921, 924, 0, 912, 922, 0, 910, 910, 924, 0, - 926, 0, 508, 939, 938, 937, 903, 902, 0, 920, - 919, 914, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 902, 916, 902, 899, 0, 0, 905, 904, - 0, 0, 902, 894, 0, 0, 0, 0, 0, 0, - 891, 903, 511, 895, 902, 901, 898, 892, 885, 529, - 901, 886, 881, 895, 893, 0, 0, 885, 909, 908, - - 907, 873, 872, 378, 505, 0, 885, 888, 886, 874, - 870, 0, 883, 880, 879, 868, 867, 866, 535, 875, - 0, 892, 891, 890, 856, 855, 0, 870, 856, 0, - 867, 862, 539, 565, 911, 855, 863, 0, 0, 0, - 883, 882, 0, 859, 862, 846, 854, 844, 852, 853, - 853, 852, 837, 559, 850, 0, 851, 839, 838, 834, - 863, 862, 861, 827, 826, 822, 0, 860, 859, 0, - 836, 839, 0, 572, 0, 825, 590, 1227, 597, 0, - 617, 593, 1227, 0, 822, 821, 831, 831, 818, 833, - 816, 831, 826, 0, 0, 0, 843, 842, 841, 807, - - 0, 807, 0, 0, 0, 506, 534, 831, 818, 821, - 803, 804, 803, 813, 813, 830, 829, 828, 794, 799, - 625, 651, 373, 816, 806, 794, 792, 791, 802, 0, - 805, 801, 803, 799, 785, 817, 816, 0, 797, 789, - 780, 788, 778, 789, 785, 787, 785, 785, 784, 771, - 770, 781, 0, 801, 800, 0, 781, 1227, 444, 1227, - 658, 0, 678, 795, 779, 761, 778, 777, 760, 752, - 760, 750, 758, 0, 755, 754, 765, 748, 751, 766, - 749, 762, 763, 760, 757, 766, 743, 758, 757, 740, - 739, 738, 749, 479, 763, 732, 742, 726, 725, 0, - - 753, 725, 751, 723, 727, 726, 0, 737, 740, 736, - 738, 719, 733, 717, 718, 726, 719, 708, 707, 0, - 713, 712, 0, 736, 720, 713, 0, 0, 717, 0, - 716, 0, 722, 721, 0, 697, 705, 695, 723, 702, - 0, 0, 715, 714, 0, 0, 713, 712, 753, 560, - 702, 709, 708, 684, 683, 711, 683, 709, 695, 680, - 697, 688, 675, 674, 155, 594, 359, 672, 692, 691, - 0, 0, 686, 0, 685, 691, 0, 676, 690, 0, - 0, 652, 517, 516, 658, 631, 630, 643, 28, 127, - 113, 224, 204, 287, 592, 595, 284, 286, 335, 355, - - 391, 0, 460, 455, 619, 620, 1227, 623, 568, 0, - 0, 443, 457, 451, 0, 474, 645, 1227, 646, 600, - 473, 509, 0, 527, 549, 648, 0, 0, 579, 654, - 680, 1227, 567, 682, 1227, 590, 684, 699, 661, 663, - 604, 607, 700, 701, 1227, 1227, 711, 714, 717, 680, - 682, 720, 724, 727, 729 - } ; - -static yyconst flex_int16_t yy_def[856] = - { 0, - 846, 1, 846, 3, 847, 847, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 848, 846, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 849, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 850, 846, 851, - 19, 846, 846, 846, 846, 852, 20, 846, 846, 846, - 846, 846, 846, 848, 846, 846, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 853, 846, 849, 846, 846, 851, 846, 846, 846, 846, - 852, 846, 846, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 846, 846, 846, 846, 853, 846, 846, 846, 846, 846, - 846, 846, 846, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 846, 846, 846, 846, 846, - 846, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 846, 846, - 846, 846, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 846, 846, - 846, 846, 848, 848, 848, 848, 848, 848, 848, 848, - - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 846, 846, 846, 846, 846, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 846, 846, 846, 846, 854, - 846, 846, 846, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 846, - 846, 846, 854, 846, 846, 846, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 846, 846, 846, - 846, 855, 846, 846, 846, 846, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 855, 846, 846, 846, 848, 848, 848, - - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 846, 846, 846, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 846, 846, - 846, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 848, 848, 848, 846, 846, 846, 846, 848, 848, - 848, 848, 848, 848, 848, 848, 848, 848, 848, 848, - 848, 846, 846, 846, 846, 848, 848, 848, 848, 848, - 848, 848, 846, 846, 846, 846, 848, 848, 848, 848, - - 848, 848, 848, 846, 846, 846, 846, 846, 846, 848, - 848, 848, 848, 848, 848, 846, 846, 846, 846, 846, - 848, 848, 848, 846, 846, 846, 848, 848, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 0, 846, 846, 846, 846, - 846, 846, 846, 846, 846 - } ; - -static yyconst flex_int16_t yy_nxt[1297] = - { 0, - 8, 9, 10, 9, 11, 8, 12, 13, 8, 8, - 14, 15, 16, 17, 18, 19, 20, 20, 20, 20, - 20, 20, 8, 21, 22, 23, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 25, 24, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 24, 24, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 24, 24, 24, 46, 47, - 58, 800, 58, 48, 49, 50, 51, 50, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 52, 49, - 53, 53, 53, 53, 53, 53, 54, 49, 49, 49, - - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 49, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 49, 61, 64, 85, 66, 68, 68, 68, - 68, 68, 68, 68, 79, 80, 765, 65, 67, 87, - 62, 70, 86, 71, 71, 71, 71, 71, 71, 72, - 82, 83, 121, 801, 88, 89, 122, 802, 73, 74, - 90, 97, 91, 126, 119, 98, 92, 75, 76, 93, - 101, 99, 102, 94, 123, 73, 74, 100, 120, 127, - - 95, 103, 128, 96, 110, 152, 782, 58, 124, 153, - 75, 150, 111, 76, 70, 104, 77, 77, 77, 77, - 77, 77, 77, 105, 112, 160, 106, 160, 213, 107, - 113, 73, 74, 114, 129, 108, 214, 115, 116, 131, - 78, 58, 117, 58, 130, 118, 132, 133, 73, 74, - 138, 134, 218, 139, 803, 151, 142, 135, 136, 219, - 137, 143, 140, 78, 846, 144, 146, 804, 145, 141, - 147, 154, 155, 162, 162, 162, 162, 162, 162, 162, - 148, 164, 165, 167, 168, 248, 169, 169, 249, 846, - 170, 170, 170, 170, 170, 170, 170, 193, 164, 165, - - 167, 168, 183, 184, 195, 221, 205, 231, 194, 206, - 207, 239, 240, 208, 243, 209, 241, 156, 196, 222, - 154, 155, 244, 232, 157, 242, 263, 152, 158, 58, - 160, 153, 160, 159, 70, 805, 72, 72, 72, 72, - 72, 72, 72, 154, 155, 258, 259, 269, 810, 263, - 811, 73, 74, 162, 162, 162, 162, 162, 162, 162, - 783, 270, 258, 259, 274, 275, 156, 333, 73, 74, - 305, 306, 307, 157, 577, 578, 334, 158, 340, 341, - 342, 812, 159, 355, 356, 357, 366, 367, 368, 156, - 374, 375, 376, 378, 379, 380, 157, 389, 390, 391, - - 158, 813, 256, 256, 546, 159, 257, 257, 257, 257, - 257, 257, 257, 260, 260, 547, 784, 261, 261, 261, - 261, 261, 261, 261, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 257, 257, - 257, 257, 257, 257, 257, 659, 660, 262, 814, 257, - 257, 257, 257, 257, 257, 257, 423, 424, 425, 454, - 455, 456, 350, 350, 262, 165, 351, 351, 351, 351, - 351, 351, 351, 261, 261, 261, 261, 261, 261, 261, - 659, 660, 165, 261, 261, 261, 261, 261, 261, 261, - 351, 351, 351, 351, 351, 351, 351, 815, 816, 168, - - 821, 351, 351, 351, 351, 351, 351, 351, 444, 445, - 446, 457, 458, 459, 822, 823, 168, 259, 783, 447, - 448, 460, 461, 462, 499, 500, 501, 522, 523, 524, - 490, 548, 641, 824, 259, 502, 503, 827, 525, 526, - 577, 578, 549, 642, 533, 534, 534, 534, 534, 534, - 534, 561, 562, 563, 579, 579, 579, 579, 579, 579, - 643, 766, 564, 565, 794, 566, 577, 578, 767, 819, - 644, 645, 795, 828, 784, 597, 598, 599, 829, 580, - 581, 581, 581, 581, 581, 581, 581, 600, 616, 617, - 618, 577, 578, 806, 582, 766, 808, 830, 577, 578, - - 619, 807, 767, 809, 580, 621, 622, 622, 622, 622, - 622, 622, 579, 579, 579, 579, 579, 579, 577, 578, - 817, 806, 833, 836, 808, 820, 659, 660, 818, 807, - 624, 809, 581, 581, 581, 581, 581, 581, 581, 625, - 661, 661, 661, 661, 661, 661, 817, 819, 825, 831, - 626, 837, 659, 660, 818, 834, 826, 832, 842, 659, - 660, 843, 840, 835, 840, 662, 663, 663, 663, 663, - 663, 663, 663, 661, 661, 661, 661, 661, 661, 659, - 660, 831, 68, 834, 166, 838, 799, 798, 797, 832, - 662, 835, 839, 663, 663, 663, 663, 663, 663, 663, - - 838, 844, 844, 820, 841, 796, 841, 839, 793, 845, - 845, 56, 56, 56, 56, 56, 84, 84, 84, 163, - 163, 163, 171, 171, 255, 792, 255, 255, 255, 623, - 623, 694, 694, 791, 790, 789, 788, 787, 786, 785, - 781, 780, 779, 778, 777, 776, 775, 774, 773, 772, - 771, 770, 769, 768, 765, 764, 763, 762, 761, 760, - 759, 758, 757, 756, 755, 754, 753, 752, 751, 750, - 749, 748, 747, 746, 745, 744, 743, 742, 741, 740, - 739, 738, 737, 736, 735, 734, 733, 732, 731, 730, - 729, 728, 727, 726, 725, 724, 723, 722, 721, 720, - - 719, 718, 717, 716, 715, 714, 713, 712, 711, 710, - 709, 708, 707, 706, 705, 704, 703, 702, 701, 700, - 699, 698, 697, 696, 695, 693, 692, 691, 690, 689, - 688, 687, 686, 685, 684, 683, 682, 681, 680, 679, - 678, 677, 676, 675, 674, 673, 672, 671, 670, 669, - 668, 667, 666, 665, 664, 658, 657, 656, 655, 654, - 653, 652, 651, 650, 649, 648, 647, 646, 640, 639, - 638, 637, 636, 635, 634, 633, 632, 631, 630, 629, - 628, 627, 620, 615, 614, 613, 612, 611, 610, 609, - 608, 607, 606, 605, 604, 603, 602, 601, 596, 595, - - 594, 593, 592, 591, 590, 589, 588, 587, 586, 585, - 584, 583, 582, 576, 575, 574, 573, 572, 571, 570, - 569, 568, 567, 560, 559, 558, 557, 556, 555, 554, - 553, 552, 551, 550, 545, 544, 543, 542, 541, 540, - 539, 538, 537, 536, 535, 532, 531, 530, 529, 528, - 527, 521, 520, 519, 518, 517, 516, 515, 514, 513, - 512, 511, 510, 509, 508, 507, 506, 505, 504, 498, - 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, - 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, - 477, 476, 475, 474, 473, 472, 471, 470, 469, 468, - - 467, 466, 465, 464, 463, 453, 452, 451, 450, 449, - 443, 442, 441, 440, 439, 438, 437, 436, 435, 434, - 433, 432, 431, 430, 429, 428, 427, 426, 422, 421, - 420, 419, 418, 417, 416, 415, 414, 413, 412, 411, - 410, 409, 408, 407, 406, 405, 404, 403, 402, 401, - 400, 399, 398, 397, 396, 395, 394, 393, 392, 388, - 387, 386, 385, 384, 383, 382, 381, 377, 373, 372, - 371, 370, 369, 365, 364, 363, 362, 361, 360, 359, - 358, 354, 353, 352, 349, 348, 347, 346, 345, 344, - 343, 339, 338, 337, 336, 335, 332, 331, 330, 329, - - 328, 327, 326, 325, 324, 323, 322, 321, 320, 319, - 318, 317, 316, 315, 314, 313, 312, 311, 310, 309, - 308, 304, 303, 302, 301, 300, 299, 298, 297, 296, - 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, - 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, - 273, 272, 271, 268, 267, 266, 265, 264, 254, 253, - 252, 251, 250, 247, 246, 245, 238, 237, 236, 235, - 234, 233, 230, 229, 228, 227, 226, 225, 224, 223, - 220, 217, 216, 215, 212, 211, 210, 204, 203, 202, - 201, 200, 199, 198, 197, 192, 191, 190, 189, 188, - - 187, 186, 185, 182, 181, 180, 179, 178, 177, 176, - 175, 174, 173, 172, 161, 149, 125, 109, 81, 69, - 63, 60, 59, 846, 57, 57, 7, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846 - - } ; - -static yyconst flex_int16_t yy_chk[1297] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 9, 789, 9, 2, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 13, 15, 25, 16, 17, 17, 17, - 17, 17, 17, 17, 21, 21, 765, 15, 16, 26, - 13, 19, 25, 19, 19, 19, 19, 19, 19, 19, - 23, 23, 36, 790, 26, 26, 36, 791, 19, 19, - 27, 29, 27, 39, 35, 29, 27, 19, 19, 28, - 30, 29, 30, 28, 37, 19, 19, 29, 35, 39, - - 28, 30, 39, 28, 33, 47, 765, 47, 37, 47, - 19, 46, 33, 19, 20, 31, 20, 20, 20, 20, - 20, 20, 20, 31, 33, 50, 31, 50, 120, 31, - 34, 20, 20, 34, 40, 31, 120, 34, 34, 41, - 20, 58, 34, 58, 40, 34, 41, 41, 20, 20, - 42, 41, 124, 42, 792, 46, 43, 41, 41, 124, - 41, 43, 42, 20, 71, 43, 44, 793, 43, 42, - 44, 48, 48, 53, 53, 53, 53, 53, 53, 53, - 44, 68, 68, 70, 70, 148, 73, 73, 148, 71, - 73, 73, 73, 73, 73, 73, 73, 105, 68, 68, - - 70, 70, 96, 96, 106, 126, 116, 135, 105, 116, - 116, 142, 142, 116, 144, 116, 143, 48, 106, 126, - 153, 153, 144, 135, 48, 143, 171, 152, 48, 152, - 160, 152, 160, 48, 72, 794, 72, 72, 72, 72, - 72, 72, 72, 154, 154, 166, 166, 180, 797, 171, - 798, 72, 72, 162, 162, 162, 162, 162, 162, 162, - 767, 180, 166, 166, 184, 184, 153, 241, 72, 72, - 215, 215, 215, 153, 623, 623, 241, 153, 247, 247, - 247, 799, 153, 268, 268, 268, 279, 279, 279, 154, - 288, 288, 288, 292, 292, 292, 154, 301, 301, 301, - - 154, 800, 164, 164, 504, 154, 164, 164, 164, 164, - 164, 164, 164, 167, 167, 504, 767, 167, 167, 167, - 167, 167, 167, 167, 169, 169, 169, 169, 169, 169, - 169, 170, 170, 170, 170, 170, 170, 170, 256, 256, - 256, 256, 256, 256, 256, 659, 659, 170, 801, 257, - 257, 257, 257, 257, 257, 257, 338, 338, 338, 393, - 393, 393, 258, 258, 170, 257, 258, 258, 258, 258, - 258, 258, 258, 260, 260, 260, 260, 260, 260, 260, - 694, 694, 257, 261, 261, 261, 261, 261, 261, 261, - 350, 350, 350, 350, 350, 350, 350, 803, 804, 261, - - 812, 351, 351, 351, 351, 351, 351, 351, 382, 382, - 382, 394, 394, 394, 813, 814, 261, 351, 783, 382, - 382, 395, 395, 395, 443, 443, 443, 483, 483, 483, - 490, 505, 606, 816, 351, 443, 443, 821, 483, 483, - 533, 533, 505, 606, 490, 490, 490, 490, 490, 490, - 490, 519, 519, 519, 533, 533, 533, 533, 533, 533, - 607, 750, 519, 519, 784, 519, 534, 534, 750, 809, - 607, 607, 784, 822, 783, 554, 554, 554, 824, 533, - 534, 534, 534, 534, 534, 534, 534, 554, 574, 574, - 574, 577, 577, 795, 582, 766, 796, 825, 579, 579, - - 574, 795, 766, 796, 533, 577, 577, 577, 577, 577, - 577, 577, 579, 579, 579, 579, 579, 579, 581, 581, - 805, 806, 829, 833, 808, 809, 621, 621, 805, 806, - 582, 808, 581, 581, 581, 581, 581, 581, 581, 582, - 621, 621, 621, 621, 621, 621, 817, 819, 820, 826, - 582, 836, 622, 622, 817, 830, 820, 826, 841, 661, - 661, 842, 839, 830, 840, 621, 622, 622, 622, 622, - 622, 622, 622, 661, 661, 661, 661, 661, 661, 663, - 663, 831, 850, 834, 851, 837, 788, 787, 786, 831, - 621, 834, 837, 663, 663, 663, 663, 663, 663, 663, - - 838, 843, 844, 819, 839, 785, 840, 838, 782, 843, - 844, 847, 847, 847, 847, 847, 848, 848, 848, 849, - 849, 849, 852, 852, 853, 779, 853, 853, 853, 854, - 854, 855, 855, 778, 776, 775, 773, 770, 769, 768, - 764, 763, 762, 761, 760, 759, 758, 757, 756, 755, - 754, 753, 752, 751, 749, 748, 747, 744, 743, 740, - 739, 738, 737, 736, 734, 733, 731, 729, 726, 725, - 724, 722, 721, 719, 718, 717, 716, 715, 714, 713, - 712, 711, 710, 709, 708, 706, 705, 704, 703, 702, - 701, 699, 698, 697, 696, 695, 693, 692, 691, 690, - - 689, 688, 687, 686, 685, 684, 683, 682, 681, 680, - 679, 678, 677, 676, 675, 673, 672, 671, 670, 669, - 668, 667, 666, 665, 664, 657, 655, 654, 652, 651, - 650, 649, 648, 647, 646, 645, 644, 643, 642, 641, - 640, 639, 637, 636, 635, 634, 633, 632, 631, 629, - 628, 627, 626, 625, 624, 620, 619, 618, 617, 616, - 615, 614, 613, 612, 611, 610, 609, 608, 602, 600, - 599, 598, 597, 593, 592, 591, 590, 589, 588, 587, - 586, 585, 576, 572, 571, 569, 568, 566, 565, 564, - 563, 562, 561, 560, 559, 558, 557, 555, 553, 552, - - 551, 550, 549, 548, 547, 546, 545, 544, 542, 541, - 537, 536, 535, 532, 531, 529, 528, 526, 525, 524, - 523, 522, 520, 518, 517, 516, 515, 514, 513, 511, - 510, 509, 508, 507, 503, 502, 501, 500, 499, 498, - 495, 494, 493, 492, 491, 489, 488, 487, 486, 485, - 484, 482, 481, 474, 473, 470, 469, 466, 465, 464, - 463, 452, 451, 450, 448, 447, 446, 445, 444, 441, - 439, 438, 437, 435, 434, 432, 431, 430, 429, 427, - 426, 421, 420, 418, 417, 416, 415, 414, 413, 412, - 411, 410, 409, 407, 406, 405, 404, 403, 402, 401, - - 400, 399, 398, 397, 396, 392, 388, 387, 386, 383, - 381, 371, 369, 365, 364, 363, 362, 360, 358, 353, - 352, 349, 348, 347, 346, 345, 344, 339, 337, 336, - 335, 334, 333, 331, 330, 327, 326, 325, 324, 323, - 322, 321, 320, 319, 318, 317, 316, 315, 314, 313, - 312, 311, 310, 309, 308, 307, 306, 305, 302, 300, - 299, 298, 297, 296, 295, 294, 293, 291, 287, 285, - 284, 283, 282, 278, 277, 276, 275, 274, 273, 272, - 271, 267, 265, 264, 254, 253, 252, 251, 250, 249, - 248, 246, 245, 244, 243, 242, 240, 239, 238, 237, - - 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, - 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, - 216, 214, 213, 212, 211, 210, 209, 208, 207, 206, - 205, 204, 203, 202, 201, 200, 199, 198, 196, 195, - 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, - 183, 182, 181, 179, 178, 177, 176, 174, 159, 158, - 157, 156, 149, 147, 146, 145, 141, 140, 139, 138, - 137, 136, 134, 133, 132, 131, 130, 129, 128, 127, - 125, 123, 122, 121, 119, 118, 117, 115, 114, 112, - 111, 110, 109, 108, 107, 104, 103, 102, 101, 100, - - 99, 98, 97, 95, 94, 93, 92, 91, 90, 89, - 88, 87, 83, 79, 52, 45, 38, 32, 22, 18, - 14, 12, 11, 7, 6, 5, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846, 846, 846, 846, 846, - 846, 846, 846, 846, 846, 846 - - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "glsl_lexer.ll" -#line 2 "glsl_lexer.ll" -/* - * Copyright © 2008, 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include -#include "strtod.h" -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.h" - -static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); - -#ifdef _MSC_VER -#define YY_NO_UNISTD_H -#endif - -#define YY_USER_ACTION \ - do { \ - yylloc->source = 0; \ - yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno + 1; \ - yycolumn += yyleng; \ - } while(0); - -#define YY_USER_INIT yylineno = 0; yycolumn = 0; - -/* A macro for handling reserved words and keywords across language versions. - * - * Certain words start out as identifiers, become reserved words in - * later language revisions, and finally become language keywords. - * - * For example, consider the following lexer rule: - * samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER) - * - * This means that "samplerBuffer" will be treated as: - * - a keyword (SAMPLERBUFFER token) ...in GLSL >= 1.40 - * - a reserved word - error ...in GLSL >= 1.30 - * - an identifier ...in GLSL < 1.30 - */ -#define KEYWORD(reserved_version, allowed_version, token) \ - do { \ - if (yyextra->language_version >= allowed_version) { \ - return token; \ - } else if (yyextra->language_version >= reserved_version) { \ - _mesa_glsl_error(yylloc, yyextra, \ - "Illegal use of reserved word `%s'", yytext); \ - return ERROR_TOK; \ - } else { \ - yylval->identifier = strdup(yytext); \ - return classify_identifier(yyextra, yytext); \ - } \ - } while (0) - -/* The ES macro can be used in KEYWORD checks: - * - * word KEYWORD(110 || ES, 400, TOKEN) - * ...means the word is reserved in GLSL ES 1.00, while - * - * word KEYWORD(110, 130 || ES, TOKEN) - * ...means the word is a legal keyword in GLSL ES 1.00. - */ -#define ES yyextra->es_shader - -static int -literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, - YYSTYPE *lval, YYLTYPE *lloc, int base) -{ - bool is_uint = (text[len - 1] == 'u' || - text[len - 1] == 'U'); - const char *digits = text; - - /* Skip "0x" */ - if (base == 16) - digits += 2; - -#ifdef _MSC_VER - unsigned __int64 value = _strtoui64(digits, NULL, base); -#else - unsigned long long value = strtoull(digits, NULL, base); -#endif - - lval->n = (int)value; - - if (value > UINT_MAX) { - /* Note that signed 0xffffffff is valid, not out of range! */ - if (state->language_version >= 130) { - _mesa_glsl_error(lloc, state, - "Literal value `%s' out of range", text); - } else { - _mesa_glsl_warning(lloc, state, - "Literal value `%s' out of range", text); - } - } else if (base == 10 && !is_uint && (unsigned)value > (unsigned)INT_MAX + 1) { - /* Tries to catch unintentionally providing a negative value. - * Note that -2147483648 is parsed as -(2147483648), so we don't - * want to warn for INT_MAX. - */ - _mesa_glsl_warning(lloc, state, - "Signed literal value `%s' is interpreted as %d", - text, lval->n); - } - return is_uint ? UINTCONSTANT : INTCONSTANT; -} - -#define LITERAL_INTEGER(base) \ - literal_integer(yytext, yyleng, yyextra, yylval, yylloc, base) - - -#line 1128 "glsl_lexer.cpp" - -#define INITIAL 0 -#define PP 1 -#define PRAGMA 2 - -#define YY_EXTRA_TYPE struct _mesa_glsl_parse_state * - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - YYSTYPE * yylval_r; - - YYLTYPE * yylloc_r; - - }; /* end struct yyguts_t */ - -static int yy_init_globals (yyscan_t yyscanner ); - - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval yyg->yylval_r - - # define yylloc yyg->yylloc_r - -int _mesa_glsl_lex_init (yyscan_t* scanner); - -int _mesa_glsl_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int _mesa_glsl_lex_destroy (yyscan_t yyscanner ); - -int _mesa_glsl_get_debug (yyscan_t yyscanner ); - -void _mesa_glsl_set_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner ); - -void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *_mesa_glsl_get_in (yyscan_t yyscanner ); - -void _mesa_glsl_set_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *_mesa_glsl_get_out (yyscan_t yyscanner ); - -void _mesa_glsl_set_out (FILE * out_str ,yyscan_t yyscanner ); - -int _mesa_glsl_get_leng (yyscan_t yyscanner ); - -char *_mesa_glsl_get_text (yyscan_t yyscanner ); - -int _mesa_glsl_get_lineno (yyscan_t yyscanner ); - -void _mesa_glsl_set_lineno (int line_number ,yyscan_t yyscanner ); - -int _mesa_glsl_get_column (yyscan_t yyscanner ); - -void _mesa_glsl_set_column (int column_no ,yyscan_t yyscanner ); - -YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner ); - -void _mesa_glsl_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - - YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner ); - - void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int _mesa_glsl_wrap (yyscan_t yyscanner ); -#else -extern int _mesa_glsl_wrap (yyscan_t yyscanner ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); -#else -static int input (yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - unsigned n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int _mesa_glsl_lex \ - (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); - -#define YY_DECL int _mesa_glsl_lex \ - (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - if ( yyleng > 0 ) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (yytext[yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -#line 145 "glsl_lexer.ll" - - -#line 1369 "glsl_lexer.cpp" - - yylval = yylval_param; - - yylloc = yylloc_param; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - _mesa_glsl_ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - _mesa_glsl__load_buffer_state(yyscanner ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; - yy_current_state += YY_AT_BOL(); -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 847 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_current_state != 846 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 147 "glsl_lexer.ll" -; - YY_BREAK -/* Preprocessor tokens. */ -case 2: -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 150 "glsl_lexer.ll" -; - YY_BREAK -case 3: -YY_RULE_SETUP -#line 151 "glsl_lexer.ll" -{ BEGIN PP; return VERSION_TOK; } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 152 "glsl_lexer.ll" -{ BEGIN PP; return EXTENSION; } - YY_BREAK -case 5: -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 153 "glsl_lexer.ll" -{ - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - yylloc->source = strtol(ptr, NULL, 0); - } - YY_BREAK -case 6: -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 168 "glsl_lexer.ll" -{ - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 182 "glsl_lexer.ll" -{ - BEGIN PP; - return PRAGMA_DEBUG_ON; - } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 186 "glsl_lexer.ll" -{ - BEGIN PP; - return PRAGMA_DEBUG_OFF; - } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 190 "glsl_lexer.ll" -{ - BEGIN PP; - return PRAGMA_OPTIMIZE_ON; - } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 194 "glsl_lexer.ll" -{ - BEGIN PP; - return PRAGMA_OPTIMIZE_OFF; - } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 198 "glsl_lexer.ll" -{ - BEGIN PP; - return PRAGMA_INVARIANT_ALL; - } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 202 "glsl_lexer.ll" -{ BEGIN PRAGMA; } - YY_BREAK -case 13: -/* rule 13 can match eol */ -YY_RULE_SETUP -#line 204 "glsl_lexer.ll" -{ BEGIN 0; yylineno++; yycolumn = 0; } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 205 "glsl_lexer.ll" -{ } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 207 "glsl_lexer.ll" -{ } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 208 "glsl_lexer.ll" -{ } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 209 "glsl_lexer.ll" -return COLON; - YY_BREAK -case 18: -YY_RULE_SETUP -#line 210 "glsl_lexer.ll" -{ - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 214 "glsl_lexer.ll" -{ - yylval->n = strtol(yytext, NULL, 10); - return INTCONSTANT; - } - YY_BREAK -case 20: -/* rule 20 can match eol */ -YY_RULE_SETUP -#line 218 "glsl_lexer.ll" -{ BEGIN 0; yylineno++; yycolumn = 0; return EOL; } - YY_BREAK -case 21: -/* rule 21 can match eol */ -YY_RULE_SETUP -#line 220 "glsl_lexer.ll" -{ yylineno++; yycolumn = 0; } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 222 "glsl_lexer.ll" -return ATTRIBUTE; - YY_BREAK -case 23: -YY_RULE_SETUP -#line 223 "glsl_lexer.ll" -return CONST_TOK; - YY_BREAK -case 24: -YY_RULE_SETUP -#line 224 "glsl_lexer.ll" -return BOOL_TOK; - YY_BREAK -case 25: -YY_RULE_SETUP -#line 225 "glsl_lexer.ll" -return FLOAT_TOK; - YY_BREAK -case 26: -YY_RULE_SETUP -#line 226 "glsl_lexer.ll" -return INT_TOK; - YY_BREAK -case 27: -YY_RULE_SETUP -#line 227 "glsl_lexer.ll" -KEYWORD(130, 130, UINT_TOK); - YY_BREAK -case 28: -YY_RULE_SETUP -#line 229 "glsl_lexer.ll" -return BREAK; - YY_BREAK -case 29: -YY_RULE_SETUP -#line 230 "glsl_lexer.ll" -return CONTINUE; - YY_BREAK -case 30: -YY_RULE_SETUP -#line 231 "glsl_lexer.ll" -return DO; - YY_BREAK -case 31: -YY_RULE_SETUP -#line 232 "glsl_lexer.ll" -return WHILE; - YY_BREAK -case 32: -YY_RULE_SETUP -#line 233 "glsl_lexer.ll" -return ELSE; - YY_BREAK -case 33: -YY_RULE_SETUP -#line 234 "glsl_lexer.ll" -return FOR; - YY_BREAK -case 34: -YY_RULE_SETUP -#line 235 "glsl_lexer.ll" -return IF; - YY_BREAK -case 35: -YY_RULE_SETUP -#line 236 "glsl_lexer.ll" -return DISCARD; - YY_BREAK -case 36: -YY_RULE_SETUP -#line 237 "glsl_lexer.ll" -return RETURN; - YY_BREAK -case 37: -YY_RULE_SETUP -#line 239 "glsl_lexer.ll" -return BVEC2; - YY_BREAK -case 38: -YY_RULE_SETUP -#line 240 "glsl_lexer.ll" -return BVEC3; - YY_BREAK -case 39: -YY_RULE_SETUP -#line 241 "glsl_lexer.ll" -return BVEC4; - YY_BREAK -case 40: -YY_RULE_SETUP -#line 242 "glsl_lexer.ll" -return IVEC2; - YY_BREAK -case 41: -YY_RULE_SETUP -#line 243 "glsl_lexer.ll" -return IVEC3; - YY_BREAK -case 42: -YY_RULE_SETUP -#line 244 "glsl_lexer.ll" -return IVEC4; - YY_BREAK -case 43: -YY_RULE_SETUP -#line 245 "glsl_lexer.ll" -KEYWORD(130, 130, UVEC2); - YY_BREAK -case 44: -YY_RULE_SETUP -#line 246 "glsl_lexer.ll" -KEYWORD(130, 130, UVEC3); - YY_BREAK -case 45: -YY_RULE_SETUP -#line 247 "glsl_lexer.ll" -KEYWORD(130, 130, UVEC4); - YY_BREAK -case 46: -YY_RULE_SETUP -#line 248 "glsl_lexer.ll" -return VEC2; - YY_BREAK -case 47: -YY_RULE_SETUP -#line 249 "glsl_lexer.ll" -return VEC3; - YY_BREAK -case 48: -YY_RULE_SETUP -#line 250 "glsl_lexer.ll" -return VEC4; - YY_BREAK -case 49: -YY_RULE_SETUP -#line 251 "glsl_lexer.ll" -return MAT2X2; - YY_BREAK -case 50: -YY_RULE_SETUP -#line 252 "glsl_lexer.ll" -return MAT3X3; - YY_BREAK -case 51: -YY_RULE_SETUP -#line 253 "glsl_lexer.ll" -return MAT4X4; - YY_BREAK -case 52: -YY_RULE_SETUP -#line 254 "glsl_lexer.ll" -KEYWORD(120, 120, MAT2X2); - YY_BREAK -case 53: -YY_RULE_SETUP -#line 255 "glsl_lexer.ll" -KEYWORD(120, 120, MAT2X3); - YY_BREAK -case 54: -YY_RULE_SETUP -#line 256 "glsl_lexer.ll" -KEYWORD(120, 120, MAT2X4); - YY_BREAK -case 55: -YY_RULE_SETUP -#line 257 "glsl_lexer.ll" -KEYWORD(120, 120, MAT3X2); - YY_BREAK -case 56: -YY_RULE_SETUP -#line 258 "glsl_lexer.ll" -KEYWORD(120, 120, MAT3X3); - YY_BREAK -case 57: -YY_RULE_SETUP -#line 259 "glsl_lexer.ll" -KEYWORD(120, 120, MAT3X4); - YY_BREAK -case 58: -YY_RULE_SETUP -#line 260 "glsl_lexer.ll" -KEYWORD(120, 120, MAT4X2); - YY_BREAK -case 59: -YY_RULE_SETUP -#line 261 "glsl_lexer.ll" -KEYWORD(120, 120, MAT4X3); - YY_BREAK -case 60: -YY_RULE_SETUP -#line 262 "glsl_lexer.ll" -KEYWORD(120, 120, MAT4X4); - YY_BREAK -case 61: -YY_RULE_SETUP -#line 264 "glsl_lexer.ll" -return IN_TOK; - YY_BREAK -case 62: -YY_RULE_SETUP -#line 265 "glsl_lexer.ll" -return OUT_TOK; - YY_BREAK -case 63: -YY_RULE_SETUP -#line 266 "glsl_lexer.ll" -return INOUT_TOK; - YY_BREAK -case 64: -YY_RULE_SETUP -#line 267 "glsl_lexer.ll" -return UNIFORM; - YY_BREAK -case 65: -YY_RULE_SETUP -#line 268 "glsl_lexer.ll" -return VARYING; - YY_BREAK -case 66: -YY_RULE_SETUP -#line 269 "glsl_lexer.ll" -KEYWORD(120, 120, CENTROID); - YY_BREAK -case 67: -YY_RULE_SETUP -#line 270 "glsl_lexer.ll" -KEYWORD(120 || ES, 120 || ES, INVARIANT); - YY_BREAK -case 68: -YY_RULE_SETUP -#line 271 "glsl_lexer.ll" -KEYWORD(130 || ES, 130, FLAT); - YY_BREAK -case 69: -YY_RULE_SETUP -#line 272 "glsl_lexer.ll" -KEYWORD(130, 130, SMOOTH); - YY_BREAK -case 70: -YY_RULE_SETUP -#line 273 "glsl_lexer.ll" -KEYWORD(130, 130, NOPERSPECTIVE); - YY_BREAK -case 71: -YY_RULE_SETUP -#line 275 "glsl_lexer.ll" -return SAMPLER1D; - YY_BREAK -case 72: -YY_RULE_SETUP -#line 276 "glsl_lexer.ll" -return SAMPLER2D; - YY_BREAK -case 73: -YY_RULE_SETUP -#line 277 "glsl_lexer.ll" -return SAMPLER3D; - YY_BREAK -case 74: -YY_RULE_SETUP -#line 278 "glsl_lexer.ll" -return SAMPLERCUBE; - YY_BREAK -case 75: -YY_RULE_SETUP -#line 279 "glsl_lexer.ll" -KEYWORD(130, 130, SAMPLER1DARRAY); - YY_BREAK -case 76: -YY_RULE_SETUP -#line 280 "glsl_lexer.ll" -KEYWORD(130, 130, SAMPLER2DARRAY); - YY_BREAK -case 77: -YY_RULE_SETUP -#line 281 "glsl_lexer.ll" -return SAMPLER1DSHADOW; - YY_BREAK -case 78: -YY_RULE_SETUP -#line 282 "glsl_lexer.ll" -return SAMPLER2DSHADOW; - YY_BREAK -case 79: -YY_RULE_SETUP -#line 283 "glsl_lexer.ll" -KEYWORD(130, 130, SAMPLERCUBESHADOW); - YY_BREAK -case 80: -YY_RULE_SETUP -#line 284 "glsl_lexer.ll" -KEYWORD(130, 130, SAMPLER1DARRAYSHADOW); - YY_BREAK -case 81: -YY_RULE_SETUP -#line 285 "glsl_lexer.ll" -KEYWORD(130, 130, SAMPLER2DARRAYSHADOW); - YY_BREAK -case 82: -YY_RULE_SETUP -#line 286 "glsl_lexer.ll" -KEYWORD(130, 130, ISAMPLER1D); - YY_BREAK -case 83: -YY_RULE_SETUP -#line 287 "glsl_lexer.ll" -KEYWORD(130, 130, ISAMPLER2D); - YY_BREAK -case 84: -YY_RULE_SETUP -#line 288 "glsl_lexer.ll" -KEYWORD(130, 130, ISAMPLER3D); - YY_BREAK -case 85: -YY_RULE_SETUP -#line 289 "glsl_lexer.ll" -KEYWORD(130, 130, ISAMPLERCUBE); - YY_BREAK -case 86: -YY_RULE_SETUP -#line 290 "glsl_lexer.ll" -KEYWORD(130, 130, ISAMPLER1DARRAY); - YY_BREAK -case 87: -YY_RULE_SETUP -#line 291 "glsl_lexer.ll" -KEYWORD(130, 130, ISAMPLER2DARRAY); - YY_BREAK -case 88: -YY_RULE_SETUP -#line 292 "glsl_lexer.ll" -KEYWORD(130, 130, USAMPLER1D); - YY_BREAK -case 89: -YY_RULE_SETUP -#line 293 "glsl_lexer.ll" -KEYWORD(130, 130, USAMPLER2D); - YY_BREAK -case 90: -YY_RULE_SETUP -#line 294 "glsl_lexer.ll" -KEYWORD(130, 130, USAMPLER3D); - YY_BREAK -case 91: -YY_RULE_SETUP -#line 295 "glsl_lexer.ll" -KEYWORD(130, 130, USAMPLERCUBE); - YY_BREAK -case 92: -YY_RULE_SETUP -#line 296 "glsl_lexer.ll" -KEYWORD(130, 130, USAMPLER1DARRAY); - YY_BREAK -case 93: -YY_RULE_SETUP -#line 297 "glsl_lexer.ll" -KEYWORD(130, 130, USAMPLER2DARRAY); - YY_BREAK -case 94: -YY_RULE_SETUP -#line 299 "glsl_lexer.ll" -{ - return IDENTIFIER; - } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 307 "glsl_lexer.ll" -return STRUCT; - YY_BREAK -case 96: -YY_RULE_SETUP -#line 308 "glsl_lexer.ll" -return VOID_TOK; - YY_BREAK -case 97: -YY_RULE_SETUP -#line 310 "glsl_lexer.ll" -{ - if ((yyextra->language_version >= 140) - || yyextra->AMD_conservative_depth_enable - || yyextra->ARB_conservative_depth_enable) { - return LAYOUT_TOK; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 323 "glsl_lexer.ll" -return INC_OP; - YY_BREAK -case 99: -YY_RULE_SETUP -#line 324 "glsl_lexer.ll" -return DEC_OP; - YY_BREAK -case 100: -YY_RULE_SETUP -#line 325 "glsl_lexer.ll" -return LE_OP; - YY_BREAK -case 101: -YY_RULE_SETUP -#line 326 "glsl_lexer.ll" -return GE_OP; - YY_BREAK -case 102: -YY_RULE_SETUP -#line 327 "glsl_lexer.ll" -return EQ_OP; - YY_BREAK -case 103: -YY_RULE_SETUP -#line 328 "glsl_lexer.ll" -return NE_OP; - YY_BREAK -case 104: -YY_RULE_SETUP -#line 329 "glsl_lexer.ll" -return AND_OP; - YY_BREAK -case 105: -YY_RULE_SETUP -#line 330 "glsl_lexer.ll" -return OR_OP; - YY_BREAK -case 106: -YY_RULE_SETUP -#line 331 "glsl_lexer.ll" -return XOR_OP; - YY_BREAK -case 107: -YY_RULE_SETUP -#line 332 "glsl_lexer.ll" -return LEFT_OP; - YY_BREAK -case 108: -YY_RULE_SETUP -#line 333 "glsl_lexer.ll" -return RIGHT_OP; - YY_BREAK -case 109: -YY_RULE_SETUP -#line 335 "glsl_lexer.ll" -return MUL_ASSIGN; - YY_BREAK -case 110: -YY_RULE_SETUP -#line 336 "glsl_lexer.ll" -return DIV_ASSIGN; - YY_BREAK -case 111: -YY_RULE_SETUP -#line 337 "glsl_lexer.ll" -return ADD_ASSIGN; - YY_BREAK -case 112: -YY_RULE_SETUP -#line 338 "glsl_lexer.ll" -return MOD_ASSIGN; - YY_BREAK -case 113: -YY_RULE_SETUP -#line 339 "glsl_lexer.ll" -return LEFT_ASSIGN; - YY_BREAK -case 114: -YY_RULE_SETUP -#line 340 "glsl_lexer.ll" -return RIGHT_ASSIGN; - YY_BREAK -case 115: -YY_RULE_SETUP -#line 341 "glsl_lexer.ll" -return AND_ASSIGN; - YY_BREAK -case 116: -YY_RULE_SETUP -#line 342 "glsl_lexer.ll" -return XOR_ASSIGN; - YY_BREAK -case 117: -YY_RULE_SETUP -#line 343 "glsl_lexer.ll" -return OR_ASSIGN; - YY_BREAK -case 118: -YY_RULE_SETUP -#line 344 "glsl_lexer.ll" -return SUB_ASSIGN; - YY_BREAK -case 119: -YY_RULE_SETUP -#line 346 "glsl_lexer.ll" -{ - return LITERAL_INTEGER(10); - } - YY_BREAK -case 120: -YY_RULE_SETUP -#line 349 "glsl_lexer.ll" -{ - return LITERAL_INTEGER(16); - } - YY_BREAK -case 121: -YY_RULE_SETUP -#line 352 "glsl_lexer.ll" -{ - return LITERAL_INTEGER(8); - } - YY_BREAK -case 122: -YY_RULE_SETUP -#line 356 "glsl_lexer.ll" -{ - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } - YY_BREAK -case 123: -YY_RULE_SETUP -#line 360 "glsl_lexer.ll" -{ - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } - YY_BREAK -case 124: -YY_RULE_SETUP -#line 364 "glsl_lexer.ll" -{ - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } - YY_BREAK -case 125: -YY_RULE_SETUP -#line 368 "glsl_lexer.ll" -{ - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } - YY_BREAK -case 126: -YY_RULE_SETUP -#line 372 "glsl_lexer.ll" -{ - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } - YY_BREAK -case 127: -YY_RULE_SETUP -#line 377 "glsl_lexer.ll" -{ - yylval->n = 1; - return BOOLCONSTANT; - } - YY_BREAK -case 128: -YY_RULE_SETUP -#line 381 "glsl_lexer.ll" -{ - yylval->n = 0; - return BOOLCONSTANT; - } - YY_BREAK -/* Reserved words in GLSL 1.10. */ -case 129: -YY_RULE_SETUP -#line 388 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, ASM); - YY_BREAK -case 130: -YY_RULE_SETUP -#line 389 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, CLASS); - YY_BREAK -case 131: -YY_RULE_SETUP -#line 390 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, UNION); - YY_BREAK -case 132: -YY_RULE_SETUP -#line 391 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, ENUM); - YY_BREAK -case 133: -YY_RULE_SETUP -#line 392 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, TYPEDEF); - YY_BREAK -case 134: -YY_RULE_SETUP -#line 393 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, TEMPLATE); - YY_BREAK -case 135: -YY_RULE_SETUP -#line 394 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, THIS); - YY_BREAK -case 136: -YY_RULE_SETUP -#line 395 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, PACKED_TOK); - YY_BREAK -case 137: -YY_RULE_SETUP -#line 396 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, GOTO); - YY_BREAK -case 138: -YY_RULE_SETUP -#line 397 "glsl_lexer.ll" -KEYWORD(110 || ES, 130, SWITCH); - YY_BREAK -case 139: -YY_RULE_SETUP -#line 398 "glsl_lexer.ll" -KEYWORD(110 || ES, 130, DEFAULT); - YY_BREAK -case 140: -YY_RULE_SETUP -#line 399 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, INLINE_TOK); - YY_BREAK -case 141: -YY_RULE_SETUP -#line 400 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, NOINLINE); - YY_BREAK -case 142: -YY_RULE_SETUP -#line 401 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, VOLATILE); - YY_BREAK -case 143: -YY_RULE_SETUP -#line 402 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, PUBLIC_TOK); - YY_BREAK -case 144: -YY_RULE_SETUP -#line 403 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, STATIC); - YY_BREAK -case 145: -YY_RULE_SETUP -#line 404 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, EXTERN); - YY_BREAK -case 146: -YY_RULE_SETUP -#line 405 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, EXTERNAL); - YY_BREAK -case 147: -YY_RULE_SETUP -#line 406 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, INTERFACE); - YY_BREAK -case 148: -YY_RULE_SETUP -#line 407 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, LONG_TOK); - YY_BREAK -case 149: -YY_RULE_SETUP -#line 408 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, SHORT_TOK); - YY_BREAK -case 150: -YY_RULE_SETUP -#line 409 "glsl_lexer.ll" -KEYWORD(110 || ES, 400, DOUBLE_TOK); - YY_BREAK -case 151: -YY_RULE_SETUP -#line 410 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, HALF); - YY_BREAK -case 152: -YY_RULE_SETUP -#line 411 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, FIXED_TOK); - YY_BREAK -case 153: -YY_RULE_SETUP -#line 412 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, UNSIGNED); - YY_BREAK -case 154: -YY_RULE_SETUP -#line 413 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, INPUT_TOK); - YY_BREAK -case 155: -YY_RULE_SETUP -#line 414 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, OUTPUT); - YY_BREAK -case 156: -YY_RULE_SETUP -#line 415 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, HVEC2); - YY_BREAK -case 157: -YY_RULE_SETUP -#line 416 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, HVEC3); - YY_BREAK -case 158: -YY_RULE_SETUP -#line 417 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, HVEC4); - YY_BREAK -case 159: -YY_RULE_SETUP -#line 418 "glsl_lexer.ll" -KEYWORD(110 || ES, 400, DVEC2); - YY_BREAK -case 160: -YY_RULE_SETUP -#line 419 "glsl_lexer.ll" -KEYWORD(110 || ES, 400, DVEC3); - YY_BREAK -case 161: -YY_RULE_SETUP -#line 420 "glsl_lexer.ll" -KEYWORD(110 || ES, 400, DVEC4); - YY_BREAK -case 162: -YY_RULE_SETUP -#line 421 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, FVEC2); - YY_BREAK -case 163: -YY_RULE_SETUP -#line 422 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, FVEC3); - YY_BREAK -case 164: -YY_RULE_SETUP -#line 423 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, FVEC4); - YY_BREAK -case 165: -YY_RULE_SETUP -#line 424 "glsl_lexer.ll" -return SAMPLER2DRECT; - YY_BREAK -case 166: -YY_RULE_SETUP -#line 425 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, SAMPLER3DRECT); - YY_BREAK -case 167: -YY_RULE_SETUP -#line 426 "glsl_lexer.ll" -return SAMPLER2DRECTSHADOW; - YY_BREAK -case 168: -YY_RULE_SETUP -#line 427 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, SIZEOF); - YY_BREAK -case 169: -YY_RULE_SETUP -#line 428 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, CAST); - YY_BREAK -case 170: -YY_RULE_SETUP -#line 429 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, NAMESPACE); - YY_BREAK -case 171: -YY_RULE_SETUP -#line 430 "glsl_lexer.ll" -KEYWORD(110 || ES, 999, USING); - YY_BREAK -/* Additional reserved words in GLSL 1.20. */ -case 172: -YY_RULE_SETUP -#line 433 "glsl_lexer.ll" -KEYWORD(120, 130 || ES, LOWP); - YY_BREAK -case 173: -YY_RULE_SETUP -#line 434 "glsl_lexer.ll" -KEYWORD(120, 130 || ES, MEDIUMP); - YY_BREAK -case 174: -YY_RULE_SETUP -#line 435 "glsl_lexer.ll" -KEYWORD(120, 130 || ES, HIGHP); - YY_BREAK -case 175: -YY_RULE_SETUP -#line 436 "glsl_lexer.ll" -KEYWORD(120, 130 || ES, PRECISION); - YY_BREAK -/* Additional reserved words in GLSL 1.30. */ -case 176: -YY_RULE_SETUP -#line 439 "glsl_lexer.ll" -KEYWORD(130, 130, CASE); - YY_BREAK -case 177: -YY_RULE_SETUP -#line 440 "glsl_lexer.ll" -KEYWORD(130, 999, COMMON); - YY_BREAK -case 178: -YY_RULE_SETUP -#line 441 "glsl_lexer.ll" -KEYWORD(130, 999, PARTITION); - YY_BREAK -case 179: -YY_RULE_SETUP -#line 442 "glsl_lexer.ll" -KEYWORD(130, 999, ACTIVE); - YY_BREAK -case 180: -YY_RULE_SETUP -#line 443 "glsl_lexer.ll" -KEYWORD(130 || ES, 999, SUPERP); - YY_BREAK -case 181: -YY_RULE_SETUP -#line 444 "glsl_lexer.ll" -KEYWORD(130, 140, SAMPLERBUFFER); - YY_BREAK -case 182: -YY_RULE_SETUP -#line 445 "glsl_lexer.ll" -KEYWORD(130, 999, FILTER); - YY_BREAK -case 183: -YY_RULE_SETUP -#line 446 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE1D); - YY_BREAK -case 184: -YY_RULE_SETUP -#line 447 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE2D); - YY_BREAK -case 185: -YY_RULE_SETUP -#line 448 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE3D); - YY_BREAK -case 186: -YY_RULE_SETUP -#line 449 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGECUBE); - YY_BREAK -case 187: -YY_RULE_SETUP -#line 450 "glsl_lexer.ll" -KEYWORD(130, 999, IIMAGE1D); - YY_BREAK -case 188: -YY_RULE_SETUP -#line 451 "glsl_lexer.ll" -KEYWORD(130, 999, IIMAGE2D); - YY_BREAK -case 189: -YY_RULE_SETUP -#line 452 "glsl_lexer.ll" -KEYWORD(130, 999, IIMAGE3D); - YY_BREAK -case 190: -YY_RULE_SETUP -#line 453 "glsl_lexer.ll" -KEYWORD(130, 999, IIMAGECUBE); - YY_BREAK -case 191: -YY_RULE_SETUP -#line 454 "glsl_lexer.ll" -KEYWORD(130, 999, UIMAGE1D); - YY_BREAK -case 192: -YY_RULE_SETUP -#line 455 "glsl_lexer.ll" -KEYWORD(130, 999, UIMAGE2D); - YY_BREAK -case 193: -YY_RULE_SETUP -#line 456 "glsl_lexer.ll" -KEYWORD(130, 999, UIMAGE3D); - YY_BREAK -case 194: -YY_RULE_SETUP -#line 457 "glsl_lexer.ll" -KEYWORD(130, 999, UIMAGECUBE); - YY_BREAK -case 195: -YY_RULE_SETUP -#line 458 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE1DARRAY); - YY_BREAK -case 196: -YY_RULE_SETUP -#line 459 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE2DARRAY); - YY_BREAK -case 197: -YY_RULE_SETUP -#line 460 "glsl_lexer.ll" -KEYWORD(130, 999, IIMAGE1DARRAY); - YY_BREAK -case 198: -YY_RULE_SETUP -#line 461 "glsl_lexer.ll" -KEYWORD(130, 999, IIMAGE2DARRAY); - YY_BREAK -case 199: -YY_RULE_SETUP -#line 462 "glsl_lexer.ll" -KEYWORD(130, 999, UIMAGE1DARRAY); - YY_BREAK -case 200: -YY_RULE_SETUP -#line 463 "glsl_lexer.ll" -KEYWORD(130, 999, UIMAGE2DARRAY); - YY_BREAK -case 201: -YY_RULE_SETUP -#line 464 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE1DSHADOW); - YY_BREAK -case 202: -YY_RULE_SETUP -#line 465 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE2DSHADOW); - YY_BREAK -case 203: -YY_RULE_SETUP -#line 466 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE1DARRAYSHADOW); - YY_BREAK -case 204: -YY_RULE_SETUP -#line 467 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGE2DARRAYSHADOW); - YY_BREAK -case 205: -YY_RULE_SETUP -#line 468 "glsl_lexer.ll" -KEYWORD(130, 999, IMAGEBUFFER); - YY_BREAK -case 206: -YY_RULE_SETUP -#line 469 "glsl_lexer.ll" -KEYWORD(130, 999, IIMAGEBUFFER); - YY_BREAK -case 207: -YY_RULE_SETUP -#line 470 "glsl_lexer.ll" -KEYWORD(130, 999, UIMAGEBUFFER); - YY_BREAK -case 208: -YY_RULE_SETUP -#line 471 "glsl_lexer.ll" -KEYWORD(130, 999, ROW_MAJOR); - YY_BREAK -case 209: -YY_RULE_SETUP -#line 473 "glsl_lexer.ll" -{ - struct _mesa_glsl_parse_state *state = yyextra; - void *ctx = state; - yylval->identifier = ralloc_strdup(ctx, yytext); - return classify_identifier(state, yytext); - } - YY_BREAK -case 210: -YY_RULE_SETUP -#line 480 "glsl_lexer.ll" -{ return yytext[0]; } - YY_BREAK -case 211: -YY_RULE_SETUP -#line 482 "glsl_lexer.ll" -ECHO; - YY_BREAK -#line 2620 "glsl_lexer.cpp" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(PP): -case YY_STATE_EOF(PRAGMA): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * _mesa_glsl_lex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( _mesa_glsl_wrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of _mesa_glsl_lex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - _mesa_glsl_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - _mesa_glsl_restart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) _mesa_glsl_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_current_state = yyg->yy_start; - yy_current_state += YY_AT_BOL(); - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 847 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -{ - register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 847 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 846); - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - _mesa_glsl_restart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( _mesa_glsl_wrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void _mesa_glsl_restart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - _mesa_glsl_ensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - _mesa_glsl__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - _mesa_glsl__load_buffer_state(yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * _mesa_glsl_pop_buffer_state(); - * _mesa_glsl_push_buffer_state(new_buffer); - */ - _mesa_glsl_ensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - _mesa_glsl__load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (_mesa_glsl_wrap()) processing, but the only time this flag - * is looked at is after _mesa_glsl_wrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; -} - -static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE * file, int size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) _mesa_glsl_alloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" ); - - b->yy_is_our_buffer = 1; - - _mesa_glsl__init_buffer(b,file ,yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with _mesa_glsl__create_buffer() - * @param yyscanner The scanner object. - */ - void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - _mesa_glsl_free((void *) b->yy_ch_buf ,yyscanner ); - - _mesa_glsl_free((void *) b ,yyscanner ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a _mesa_glsl_restart() or at EOF. - */ - static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - -{ - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - _mesa_glsl__flush_buffer(b ,yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then _mesa_glsl__init_buffer was _probably_ - * called from _mesa_glsl_restart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - _mesa_glsl__load_buffer_state(yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - _mesa_glsl_ensure_buffer_stack(yyscanner); - - /* This block is copied from _mesa_glsl__switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from _mesa_glsl__switch_to_buffer. */ - _mesa_glsl__load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - _mesa_glsl__load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner) -{ - int num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_alloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_realloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE _mesa_glsl__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - _mesa_glsl__switch_to_buffer(b ,yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to _mesa_glsl_lex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * _mesa_glsl__scan_bytes() instead. - */ -YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char * yystr , yyscan_t yyscanner) -{ - - return _mesa_glsl__scan_bytes(yystr,strlen(yystr) ,yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to _mesa_glsl_lex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) _mesa_glsl_alloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = _mesa_glsl__scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in _mesa_glsl__scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int _mesa_glsl_get_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int _mesa_glsl_get_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *_mesa_glsl_get_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *_mesa_glsl_get_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int _mesa_glsl_get_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *_mesa_glsl_get_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param line_number - * @param yyscanner The scanner object. - */ -void _mesa_glsl_set_lineno (int line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "_mesa_glsl_set_lineno called with no buffer" , yyscanner); - - yylineno = line_number; -} - -/** Set the current column. - * @param line_number - * @param yyscanner The scanner object. - */ -void _mesa_glsl_set_column (int column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "_mesa_glsl_set_column called with no buffer" , yyscanner); - - yycolumn = column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * @param yyscanner The scanner object. - * @see _mesa_glsl__switch_to_buffer - */ -void _mesa_glsl_set_in (FILE * in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; -} - -void _mesa_glsl_set_out (FILE * out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; -} - -int _mesa_glsl_get_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void _mesa_glsl_set_debug (int bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylval; -} - -void _mesa_glsl_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylval = yylval_param; -} - -YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylloc; -} - -void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylloc = yylloc_param; -} - -/* User-visible API */ - -/* _mesa_glsl_lex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ - -int _mesa_glsl_lex_init(yyscan_t* ptr_yy_globals) - -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - -/* _mesa_glsl_lex_init_extra has the same functionality as _mesa_glsl_lex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to _mesa_glsl_alloc in - * the yyextra field. - */ - -int _mesa_glsl_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - -{ - struct yyguts_t dummy_yyguts; - - _mesa_glsl_set_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - _mesa_glsl_set_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from _mesa_glsl_lex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * _mesa_glsl_lex_init() - */ - return 0; -} - -/* _mesa_glsl_lex_destroy is for both reentrant and non-reentrant scanners. */ -int _mesa_glsl_lex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - _mesa_glsl_pop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - _mesa_glsl_free(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - _mesa_glsl_free(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * _mesa_glsl_lex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - _mesa_glsl_free ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *_mesa_glsl_alloc (yy_size_t size , yyscan_t yyscanner) -{ - return (void *) malloc( size ); -} - -void *_mesa_glsl_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void _mesa_glsl_free (void * ptr , yyscan_t yyscanner) -{ - free( (char *) ptr ); /* see _mesa_glsl_realloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 482 "glsl_lexer.ll" - - - -int -classify_identifier(struct _mesa_glsl_parse_state *state, const char *name) -{ - if (state->symbols->get_variable(name) || state->symbols->get_function(name)) - return IDENTIFIER; - else if (state->symbols->get_type(name)) - return TYPE_IDENTIFIER; - else - return NEW_IDENTIFIER; -} - -void -_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) -{ - _mesa_glsl_lex_init_extra(state,& state->scanner); - _mesa_glsl__scan_string(string,state->scanner); -} - -void -_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) -{ - _mesa_glsl_lex_destroy(state->scanner); -} - diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_lexer.ll b/reactos/dll/opengl/mesa/src/glsl/glsl_lexer.ll deleted file mode 100644 index 936a90726f0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_lexer.ll +++ /dev/null @@ -1,506 +0,0 @@ -%{ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include -#include "strtod.h" -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.h" - -static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); - -#ifdef _MSC_VER -#define YY_NO_UNISTD_H -#endif - -#define YY_USER_ACTION \ - do { \ - yylloc->source = 0; \ - yylloc->first_column = yycolumn + 1; \ - yylloc->first_line = yylineno + 1; \ - yycolumn += yyleng; \ - } while(0); - -#define YY_USER_INIT yylineno = 0; yycolumn = 0; - -/* A macro for handling reserved words and keywords across language versions. - * - * Certain words start out as identifiers, become reserved words in - * later language revisions, and finally become language keywords. - * - * For example, consider the following lexer rule: - * samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER) - * - * This means that "samplerBuffer" will be treated as: - * - a keyword (SAMPLERBUFFER token) ...in GLSL >= 1.40 - * - a reserved word - error ...in GLSL >= 1.30 - * - an identifier ...in GLSL < 1.30 - */ -#define KEYWORD(reserved_version, allowed_version, token) \ - do { \ - if (yyextra->language_version >= allowed_version) { \ - return token; \ - } else if (yyextra->language_version >= reserved_version) { \ - _mesa_glsl_error(yylloc, yyextra, \ - "Illegal use of reserved word `%s'", yytext); \ - return ERROR_TOK; \ - } else { \ - yylval->identifier = strdup(yytext); \ - return classify_identifier(yyextra, yytext); \ - } \ - } while (0) - -/* The ES macro can be used in KEYWORD checks: - * - * word KEYWORD(110 || ES, 400, TOKEN) - * ...means the word is reserved in GLSL ES 1.00, while - * - * word KEYWORD(110, 130 || ES, TOKEN) - * ...means the word is a legal keyword in GLSL ES 1.00. - */ -#define ES yyextra->es_shader - -static int -literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, - YYSTYPE *lval, YYLTYPE *lloc, int base) -{ - bool is_uint = (text[len - 1] == 'u' || - text[len - 1] == 'U'); - const char *digits = text; - - /* Skip "0x" */ - if (base == 16) - digits += 2; - -#ifdef _MSC_VER - unsigned __int64 value = _strtoui64(digits, NULL, base); -#else - unsigned long long value = strtoull(digits, NULL, base); -#endif - - lval->n = (int)value; - - if (value > UINT_MAX) { - /* Note that signed 0xffffffff is valid, not out of range! */ - if (state->language_version >= 130) { - _mesa_glsl_error(lloc, state, - "Literal value `%s' out of range", text); - } else { - _mesa_glsl_warning(lloc, state, - "Literal value `%s' out of range", text); - } - } else if (base == 10 && !is_uint && (unsigned)value > (unsigned)INT_MAX + 1) { - /* Tries to catch unintentionally providing a negative value. - * Note that -2147483648 is parsed as -(2147483648), so we don't - * want to warn for INT_MAX. - */ - _mesa_glsl_warning(lloc, state, - "Signed literal value `%s' is interpreted as %d", - text, lval->n); - } - return is_uint ? UINTCONSTANT : INTCONSTANT; -} - -#define LITERAL_INTEGER(base) \ - literal_integer(yytext, yyleng, yyextra, yylval, yylloc, base) - -%} - -%option bison-bridge bison-locations reentrant noyywrap -%option nounput noyy_top_state -%option never-interactive -%option prefix="_mesa_glsl_" -%option extra-type="struct _mesa_glsl_parse_state *" - -%x PP PRAGMA - -DEC_INT [1-9][0-9]* -HEX_INT 0[xX][0-9a-fA-F]+ -OCT_INT 0[0-7]* -INT ({DEC_INT}|{HEX_INT}|{OCT_INT}) -SPC [ \t]* -SPCP [ \t]+ -HASH ^{SPC}#{SPC} -%% - -[ \r\t]+ ; - - /* Preprocessor tokens. */ -^[ \t]*#[ \t]*$ ; -^[ \t]*#[ \t]*version { BEGIN PP; return VERSION_TOK; } -^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; } -{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ { - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - yylloc->source = strtol(ptr, NULL, 0); - } -{HASH}line{SPCP}{INT}{SPC}$ { - /* Eat characters until the first digit is - * encountered - */ - char *ptr = yytext; - while (!isdigit(*ptr)) - ptr++; - - /* Subtract one from the line number because - * yylineno is zero-based instead of - * one-based. - */ - yylineno = strtol(ptr, &ptr, 0) - 1; - } -^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}on{SPC}\) { - BEGIN PP; - return PRAGMA_DEBUG_ON; - } -^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}off{SPC}\) { - BEGIN PP; - return PRAGMA_DEBUG_OFF; - } -^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}on{SPC}\) { - BEGIN PP; - return PRAGMA_OPTIMIZE_ON; - } -^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}off{SPC}\) { - BEGIN PP; - return PRAGMA_OPTIMIZE_OFF; - } -^{SPC}#{SPC}pragma{SPCP}STDGL{SPCP}invariant{SPC}\({SPC}all{SPC}\) { - BEGIN PP; - return PRAGMA_INVARIANT_ALL; - } -^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; } - -\n { BEGIN 0; yylineno++; yycolumn = 0; } -. { } - -\/\/[^\n]* { } -[ \t\r]* { } -: return COLON; -[_a-zA-Z][_a-zA-Z0-9]* { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } -[1-9][0-9]* { - yylval->n = strtol(yytext, NULL, 10); - return INTCONSTANT; - } -\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; } - -\n { yylineno++; yycolumn = 0; } - -attribute return ATTRIBUTE; -const return CONST_TOK; -bool return BOOL_TOK; -float return FLOAT_TOK; -int return INT_TOK; -uint KEYWORD(130, 130, UINT_TOK); - -break return BREAK; -continue return CONTINUE; -do return DO; -while return WHILE; -else return ELSE; -for return FOR; -if return IF; -discard return DISCARD; -return return RETURN; - -bvec2 return BVEC2; -bvec3 return BVEC3; -bvec4 return BVEC4; -ivec2 return IVEC2; -ivec3 return IVEC3; -ivec4 return IVEC4; -uvec2 KEYWORD(130, 130, UVEC2); -uvec3 KEYWORD(130, 130, UVEC3); -uvec4 KEYWORD(130, 130, UVEC4); -vec2 return VEC2; -vec3 return VEC3; -vec4 return VEC4; -mat2 return MAT2X2; -mat3 return MAT3X3; -mat4 return MAT4X4; -mat2x2 KEYWORD(120, 120, MAT2X2); -mat2x3 KEYWORD(120, 120, MAT2X3); -mat2x4 KEYWORD(120, 120, MAT2X4); -mat3x2 KEYWORD(120, 120, MAT3X2); -mat3x3 KEYWORD(120, 120, MAT3X3); -mat3x4 KEYWORD(120, 120, MAT3X4); -mat4x2 KEYWORD(120, 120, MAT4X2); -mat4x3 KEYWORD(120, 120, MAT4X3); -mat4x4 KEYWORD(120, 120, MAT4X4); - -in return IN_TOK; -out return OUT_TOK; -inout return INOUT_TOK; -uniform return UNIFORM; -varying return VARYING; -centroid KEYWORD(120, 120, CENTROID); -invariant KEYWORD(120 || ES, 120 || ES, INVARIANT); -flat KEYWORD(130 || ES, 130, FLAT); -smooth KEYWORD(130, 130, SMOOTH); -noperspective KEYWORD(130, 130, NOPERSPECTIVE); - -sampler1D return SAMPLER1D; -sampler2D return SAMPLER2D; -sampler3D return SAMPLER3D; -samplerCube return SAMPLERCUBE; -sampler1DArray KEYWORD(130, 130, SAMPLER1DARRAY); -sampler2DArray KEYWORD(130, 130, SAMPLER2DARRAY); -sampler1DShadow return SAMPLER1DSHADOW; -sampler2DShadow return SAMPLER2DSHADOW; -samplerCubeShadow KEYWORD(130, 130, SAMPLERCUBESHADOW); -sampler1DArrayShadow KEYWORD(130, 130, SAMPLER1DARRAYSHADOW); -sampler2DArrayShadow KEYWORD(130, 130, SAMPLER2DARRAYSHADOW); -isampler1D KEYWORD(130, 130, ISAMPLER1D); -isampler2D KEYWORD(130, 130, ISAMPLER2D); -isampler3D KEYWORD(130, 130, ISAMPLER3D); -isamplerCube KEYWORD(130, 130, ISAMPLERCUBE); -isampler1DArray KEYWORD(130, 130, ISAMPLER1DARRAY); -isampler2DArray KEYWORD(130, 130, ISAMPLER2DARRAY); -usampler1D KEYWORD(130, 130, USAMPLER1D); -usampler2D KEYWORD(130, 130, USAMPLER2D); -usampler3D KEYWORD(130, 130, USAMPLER3D); -usamplerCube KEYWORD(130, 130, USAMPLERCUBE); -usampler1DArray KEYWORD(130, 130, USAMPLER1DARRAY); -usampler2DArray KEYWORD(130, 130, USAMPLER2DARRAY); - -samplerExternalOES { - if (yyextra->OES_EGL_image_external_enable) - return SAMPLEREXTERNALOES; - else - return IDENTIFIER; - } - - -struct return STRUCT; -void return VOID_TOK; - -layout { - if ((yyextra->language_version >= 140) - || yyextra->AMD_conservative_depth_enable - || yyextra->ARB_conservative_depth_enable - || yyextra->ARB_explicit_attrib_location_enable - || yyextra->ARB_fragment_coord_conventions_enable) { - return LAYOUT_TOK; - } else { - yylval->identifier = strdup(yytext); - return IDENTIFIER; - } - } - -\+\+ return INC_OP; --- return DEC_OP; -\<= return LE_OP; ->= return GE_OP; -== return EQ_OP; -!= return NE_OP; -&& return AND_OP; -\|\| return OR_OP; -"^^" return XOR_OP; -"<<" return LEFT_OP; -">>" return RIGHT_OP; - -\*= return MUL_ASSIGN; -\/= return DIV_ASSIGN; -\+= return ADD_ASSIGN; -\%= return MOD_ASSIGN; -\<\<= return LEFT_ASSIGN; ->>= return RIGHT_ASSIGN; -&= return AND_ASSIGN; -"^=" return XOR_ASSIGN; -\|= return OR_ASSIGN; --= return SUB_ASSIGN; - -[1-9][0-9]*[uU]? { - return LITERAL_INTEGER(10); - } -0[xX][0-9a-fA-F]+[uU]? { - return LITERAL_INTEGER(16); - } -0[0-7]*[uU]? { - return LITERAL_INTEGER(8); - } - -[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } -\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } -[0-9]+\.([eE][+-]?[0-9]+)?[fF]? { - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } -[0-9]+[eE][+-]?[0-9]+[fF]? { - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } -[0-9]+[fF] { - yylval->real = glsl_strtod(yytext, NULL); - return FLOATCONSTANT; - } - -true { - yylval->n = 1; - return BOOLCONSTANT; - } -false { - yylval->n = 0; - return BOOLCONSTANT; - } - - - /* Reserved words in GLSL 1.10. */ -asm KEYWORD(110 || ES, 999, ASM); -class KEYWORD(110 || ES, 999, CLASS); -union KEYWORD(110 || ES, 999, UNION); -enum KEYWORD(110 || ES, 999, ENUM); -typedef KEYWORD(110 || ES, 999, TYPEDEF); -template KEYWORD(110 || ES, 999, TEMPLATE); -this KEYWORD(110 || ES, 999, THIS); -packed KEYWORD(110 || ES, 999, PACKED_TOK); -goto KEYWORD(110 || ES, 999, GOTO); -switch KEYWORD(110 || ES, 130, SWITCH); -default KEYWORD(110 || ES, 130, DEFAULT); -inline KEYWORD(110 || ES, 999, INLINE_TOK); -noinline KEYWORD(110 || ES, 999, NOINLINE); -volatile KEYWORD(110 || ES, 999, VOLATILE); -public KEYWORD(110 || ES, 999, PUBLIC_TOK); -static KEYWORD(110 || ES, 999, STATIC); -extern KEYWORD(110 || ES, 999, EXTERN); -external KEYWORD(110 || ES, 999, EXTERNAL); -interface KEYWORD(110 || ES, 999, INTERFACE); -long KEYWORD(110 || ES, 999, LONG_TOK); -short KEYWORD(110 || ES, 999, SHORT_TOK); -double KEYWORD(110 || ES, 400, DOUBLE_TOK); -half KEYWORD(110 || ES, 999, HALF); -fixed KEYWORD(110 || ES, 999, FIXED_TOK); -unsigned KEYWORD(110 || ES, 999, UNSIGNED); -input KEYWORD(110 || ES, 999, INPUT_TOK); -output KEYWORD(110 || ES, 999, OUTPUT); -hvec2 KEYWORD(110 || ES, 999, HVEC2); -hvec3 KEYWORD(110 || ES, 999, HVEC3); -hvec4 KEYWORD(110 || ES, 999, HVEC4); -dvec2 KEYWORD(110 || ES, 400, DVEC2); -dvec3 KEYWORD(110 || ES, 400, DVEC3); -dvec4 KEYWORD(110 || ES, 400, DVEC4); -fvec2 KEYWORD(110 || ES, 999, FVEC2); -fvec3 KEYWORD(110 || ES, 999, FVEC3); -fvec4 KEYWORD(110 || ES, 999, FVEC4); -sampler2DRect return SAMPLER2DRECT; -sampler3DRect KEYWORD(110 || ES, 999, SAMPLER3DRECT); -sampler2DRectShadow return SAMPLER2DRECTSHADOW; -sizeof KEYWORD(110 || ES, 999, SIZEOF); -cast KEYWORD(110 || ES, 999, CAST); -namespace KEYWORD(110 || ES, 999, NAMESPACE); -using KEYWORD(110 || ES, 999, USING); - - /* Additional reserved words in GLSL 1.20. */ -lowp KEYWORD(120, 130 || ES, LOWP); -mediump KEYWORD(120, 130 || ES, MEDIUMP); -highp KEYWORD(120, 130 || ES, HIGHP); -precision KEYWORD(120, 130 || ES, PRECISION); - - /* Additional reserved words in GLSL 1.30. */ -case KEYWORD(130, 130, CASE); -common KEYWORD(130, 999, COMMON); -partition KEYWORD(130, 999, PARTITION); -active KEYWORD(130, 999, ACTIVE); -superp KEYWORD(130 || ES, 999, SUPERP); -samplerBuffer KEYWORD(130, 140, SAMPLERBUFFER); -filter KEYWORD(130, 999, FILTER); -image1D KEYWORD(130, 999, IMAGE1D); -image2D KEYWORD(130, 999, IMAGE2D); -image3D KEYWORD(130, 999, IMAGE3D); -imageCube KEYWORD(130, 999, IMAGECUBE); -iimage1D KEYWORD(130, 999, IIMAGE1D); -iimage2D KEYWORD(130, 999, IIMAGE2D); -iimage3D KEYWORD(130, 999, IIMAGE3D); -iimageCube KEYWORD(130, 999, IIMAGECUBE); -uimage1D KEYWORD(130, 999, UIMAGE1D); -uimage2D KEYWORD(130, 999, UIMAGE2D); -uimage3D KEYWORD(130, 999, UIMAGE3D); -uimageCube KEYWORD(130, 999, UIMAGECUBE); -image1DArray KEYWORD(130, 999, IMAGE1DARRAY); -image2DArray KEYWORD(130, 999, IMAGE2DARRAY); -iimage1DArray KEYWORD(130, 999, IIMAGE1DARRAY); -iimage2DArray KEYWORD(130, 999, IIMAGE2DARRAY); -uimage1DArray KEYWORD(130, 999, UIMAGE1DARRAY); -uimage2DArray KEYWORD(130, 999, UIMAGE2DARRAY); -image1DShadow KEYWORD(130, 999, IMAGE1DSHADOW); -image2DShadow KEYWORD(130, 999, IMAGE2DSHADOW); -image1DArrayShadow KEYWORD(130, 999, IMAGE1DARRAYSHADOW); -image2DArrayShadow KEYWORD(130, 999, IMAGE2DARRAYSHADOW); -imageBuffer KEYWORD(130, 999, IMAGEBUFFER); -iimageBuffer KEYWORD(130, 999, IIMAGEBUFFER); -uimageBuffer KEYWORD(130, 999, UIMAGEBUFFER); -row_major KEYWORD(130, 999, ROW_MAJOR); - -[_a-zA-Z][_a-zA-Z0-9]* { - struct _mesa_glsl_parse_state *state = yyextra; - void *ctx = state; - yylval->identifier = ralloc_strdup(ctx, yytext); - return classify_identifier(state, yytext); - } - -. { return yytext[0]; } - -%% - -int -classify_identifier(struct _mesa_glsl_parse_state *state, const char *name) -{ - if (state->symbols->get_variable(name) || state->symbols->get_function(name)) - return IDENTIFIER; - else if (state->symbols->get_type(name)) - return TYPE_IDENTIFIER; - else - return NEW_IDENTIFIER; -} - -void -_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string) -{ - yylex_init_extra(state, & state->scanner); - yy_scan_string(string, state->scanner); -} - -void -_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) -{ - yylex_destroy(state->scanner); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_parser.cpp b/reactos/dll/opengl/mesa/src/glsl/glsl_parser.cpp deleted file mode 100644 index 17abfc234b2..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_parser.cpp +++ /dev/null @@ -1,5574 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.4.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - -/* Using locations. */ -#define YYLSP_NEEDED 1 - -/* Substitute the variable and function names. */ -#define yyparse _mesa_glsl_parse -#define yylex _mesa_glsl_lex -#define yyerror _mesa_glsl_error -#define yylval _mesa_glsl_lval -#define yychar _mesa_glsl_char -#define yydebug _mesa_glsl_debug -#define yynerrs _mesa_glsl_nerrs -#define yylloc _mesa_glsl_lloc - -/* Copy the first part of user declarations. */ - -/* Line 189 of yacc.c */ -#line 1 "glsl_parser.yy" - -/* - * Copyright © 2008, 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include -#include -#include - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" - -#define YYLEX_PARAM state->scanner - -#undef yyerror - -static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) -{ - _mesa_glsl_error(loc, st, "%s", msg); -} - - -/* Line 189 of yacc.c */ -#line 123 "glsl_parser.cpp" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ATTRIBUTE = 258, - CONST_TOK = 259, - BOOL_TOK = 260, - FLOAT_TOK = 261, - INT_TOK = 262, - UINT_TOK = 263, - BREAK = 264, - CONTINUE = 265, - DO = 266, - ELSE = 267, - FOR = 268, - IF = 269, - DISCARD = 270, - RETURN = 271, - SWITCH = 272, - CASE = 273, - DEFAULT = 274, - BVEC2 = 275, - BVEC3 = 276, - BVEC4 = 277, - IVEC2 = 278, - IVEC3 = 279, - IVEC4 = 280, - UVEC2 = 281, - UVEC3 = 282, - UVEC4 = 283, - VEC2 = 284, - VEC3 = 285, - VEC4 = 286, - CENTROID = 287, - IN_TOK = 288, - OUT_TOK = 289, - INOUT_TOK = 290, - UNIFORM = 291, - VARYING = 292, - NOPERSPECTIVE = 293, - FLAT = 294, - SMOOTH = 295, - MAT2X2 = 296, - MAT2X3 = 297, - MAT2X4 = 298, - MAT3X2 = 299, - MAT3X3 = 300, - MAT3X4 = 301, - MAT4X2 = 302, - MAT4X3 = 303, - MAT4X4 = 304, - SAMPLER1D = 305, - SAMPLER2D = 306, - SAMPLER3D = 307, - SAMPLERCUBE = 308, - SAMPLER1DSHADOW = 309, - SAMPLER2DSHADOW = 310, - SAMPLERCUBESHADOW = 311, - SAMPLER1DARRAY = 312, - SAMPLER2DARRAY = 313, - SAMPLER1DARRAYSHADOW = 314, - SAMPLER2DARRAYSHADOW = 315, - ISAMPLER1D = 316, - ISAMPLER2D = 317, - ISAMPLER3D = 318, - ISAMPLERCUBE = 319, - ISAMPLER1DARRAY = 320, - ISAMPLER2DARRAY = 321, - USAMPLER1D = 322, - USAMPLER2D = 323, - USAMPLER3D = 324, - USAMPLERCUBE = 325, - USAMPLER1DARRAY = 326, - USAMPLER2DARRAY = 327, - SAMPLEREXTERNALOES = 328, - STRUCT = 329, - VOID_TOK = 330, - WHILE = 331, - IDENTIFIER = 332, - TYPE_IDENTIFIER = 333, - NEW_IDENTIFIER = 334, - FLOATCONSTANT = 335, - INTCONSTANT = 336, - UINTCONSTANT = 337, - BOOLCONSTANT = 338, - FIELD_SELECTION = 339, - LEFT_OP = 340, - RIGHT_OP = 341, - INC_OP = 342, - DEC_OP = 343, - LE_OP = 344, - GE_OP = 345, - EQ_OP = 346, - NE_OP = 347, - AND_OP = 348, - OR_OP = 349, - XOR_OP = 350, - MUL_ASSIGN = 351, - DIV_ASSIGN = 352, - ADD_ASSIGN = 353, - MOD_ASSIGN = 354, - LEFT_ASSIGN = 355, - RIGHT_ASSIGN = 356, - AND_ASSIGN = 357, - XOR_ASSIGN = 358, - OR_ASSIGN = 359, - SUB_ASSIGN = 360, - INVARIANT = 361, - LOWP = 362, - MEDIUMP = 363, - HIGHP = 364, - SUPERP = 365, - PRECISION = 366, - VERSION_TOK = 367, - EXTENSION = 368, - LINE = 369, - COLON = 370, - EOL = 371, - INTERFACE = 372, - OUTPUT = 373, - PRAGMA_DEBUG_ON = 374, - PRAGMA_DEBUG_OFF = 375, - PRAGMA_OPTIMIZE_ON = 376, - PRAGMA_OPTIMIZE_OFF = 377, - PRAGMA_INVARIANT_ALL = 378, - LAYOUT_TOK = 379, - ASM = 380, - CLASS = 381, - UNION = 382, - ENUM = 383, - TYPEDEF = 384, - TEMPLATE = 385, - THIS = 386, - PACKED_TOK = 387, - GOTO = 388, - INLINE_TOK = 389, - NOINLINE = 390, - VOLATILE = 391, - PUBLIC_TOK = 392, - STATIC = 393, - EXTERN = 394, - EXTERNAL = 395, - LONG_TOK = 396, - SHORT_TOK = 397, - DOUBLE_TOK = 398, - HALF = 399, - FIXED_TOK = 400, - UNSIGNED = 401, - INPUT_TOK = 402, - OUPTUT = 403, - HVEC2 = 404, - HVEC3 = 405, - HVEC4 = 406, - DVEC2 = 407, - DVEC3 = 408, - DVEC4 = 409, - FVEC2 = 410, - FVEC3 = 411, - FVEC4 = 412, - SAMPLER2DRECT = 413, - SAMPLER3DRECT = 414, - SAMPLER2DRECTSHADOW = 415, - SIZEOF = 416, - CAST = 417, - NAMESPACE = 418, - USING = 419, - ERROR_TOK = 420, - COMMON = 421, - PARTITION = 422, - ACTIVE = 423, - SAMPLERBUFFER = 424, - FILTER = 425, - IMAGE1D = 426, - IMAGE2D = 427, - IMAGE3D = 428, - IMAGECUBE = 429, - IMAGE1DARRAY = 430, - IMAGE2DARRAY = 431, - IIMAGE1D = 432, - IIMAGE2D = 433, - IIMAGE3D = 434, - IIMAGECUBE = 435, - IIMAGE1DARRAY = 436, - IIMAGE2DARRAY = 437, - UIMAGE1D = 438, - UIMAGE2D = 439, - UIMAGE3D = 440, - UIMAGECUBE = 441, - UIMAGE1DARRAY = 442, - UIMAGE2DARRAY = 443, - IMAGE1DSHADOW = 444, - IMAGE2DSHADOW = 445, - IMAGEBUFFER = 446, - IIMAGEBUFFER = 447, - UIMAGEBUFFER = 448, - IMAGE1DARRAYSHADOW = 449, - IMAGE2DARRAYSHADOW = 450, - ROW_MAJOR = 451 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ - -/* Line 214 of yacc.c */ -#line 58 "glsl_parser.yy" - - int n; - float real; - char *identifier; - - struct ast_type_qualifier type_qualifier; - - ast_node *node; - ast_type_specifier *type_specifier; - ast_fully_specified_type *fully_specified_type; - ast_function *function; - ast_parameter_declarator *parameter_declarator; - ast_function_definition *function_definition; - ast_compound_statement *compound_statement; - ast_expression *expression; - ast_declarator_list *declarator_list; - ast_struct_specifier *struct_specifier; - ast_declaration *declaration; - ast_switch_body *switch_body; - ast_case_label *case_label; - ast_case_label_list *case_label_list; - ast_case_statement *case_statement; - ast_case_statement_list *case_statement_list; - - struct { - ast_node *cond; - ast_expression *rest; - } for_rest_statement; - - struct { - ast_node *then_statement; - ast_node *else_statement; - } selection_rest_statement; - - - -/* Line 214 of yacc.c */ -#line 392 "glsl_parser.cpp" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - -/* Copy the second part of user declarations. */ - - -/* Line 264 of yacc.c */ -#line 417 "glsl_parser.cpp" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ - && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; - YYLTYPE yyls_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 5 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 3941 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 221 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 97 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 299 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 445 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 451 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 205, 2, 2, 2, 209, 212, 2, - 197, 198, 207, 203, 202, 204, 201, 208, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 216, 218, - 210, 217, 211, 215, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 199, 2, 200, 213, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 219, 214, 220, 206, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 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 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 4, 9, 10, 14, 17, 20, 23, - 26, 29, 30, 33, 35, 37, 39, 45, 47, 50, - 52, 54, 56, 58, 60, 62, 64, 68, 70, 75, - 77, 81, 84, 87, 89, 91, 93, 97, 100, 103, - 106, 108, 111, 115, 118, 120, 122, 124, 127, 130, - 133, 135, 138, 142, 145, 147, 150, 153, 156, 158, - 160, 162, 164, 166, 170, 174, 178, 180, 184, 188, - 190, 194, 198, 200, 204, 208, 212, 216, 218, 222, - 226, 228, 232, 234, 238, 240, 244, 246, 250, 252, - 256, 258, 262, 264, 270, 272, 276, 278, 280, 282, - 284, 286, 288, 290, 292, 294, 296, 298, 300, 304, - 306, 309, 312, 317, 320, 322, 324, 327, 331, 335, - 338, 344, 348, 351, 355, 358, 359, 361, 363, 365, - 367, 369, 373, 379, 386, 394, 403, 409, 411, 414, - 419, 425, 432, 440, 445, 448, 450, 453, 458, 460, - 464, 466, 470, 472, 474, 476, 478, 480, 482, 485, - 487, 490, 493, 497, 499, 501, 503, 505, 508, 510, - 512, 515, 518, 520, 522, 525, 527, 531, 536, 538, - 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, - 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, - 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, - 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, - 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, - 640, 642, 644, 646, 648, 650, 652, 658, 663, 665, - 668, 672, 674, 678, 680, 685, 687, 689, 691, 693, - 695, 697, 699, 701, 703, 705, 708, 709, 714, 716, - 718, 721, 725, 727, 730, 732, 735, 741, 745, 747, - 749, 754, 760, 763, 767, 771, 774, 776, 779, 782, - 785, 787, 790, 796, 804, 811, 813, 815, 817, 818, - 821, 825, 828, 831, 834, 838, 841, 843, 845, 847 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 222, 0, -1, -1, 224, 226, 223, 229, -1, -1, - 112, 81, 116, -1, 119, 116, -1, 120, 116, -1, - 121, 116, -1, 122, 116, -1, 123, 116, -1, -1, - 226, 228, -1, 77, -1, 78, -1, 79, -1, 113, - 227, 115, 227, 116, -1, 316, -1, 229, 316, -1, - 77, -1, 79, -1, 230, -1, 81, -1, 82, -1, - 80, -1, 83, -1, 197, 261, 198, -1, 231, -1, - 232, 199, 233, 200, -1, 234, -1, 232, 201, 227, - -1, 232, 87, -1, 232, 88, -1, 261, -1, 235, - -1, 236, -1, 232, 201, 241, -1, 238, 198, -1, - 237, 198, -1, 239, 75, -1, 239, -1, 239, 259, - -1, 238, 202, 259, -1, 240, 197, -1, 282, -1, - 230, -1, 84, -1, 243, 198, -1, 242, 198, -1, - 244, 75, -1, 244, -1, 244, 259, -1, 243, 202, - 259, -1, 230, 197, -1, 232, -1, 87, 245, -1, - 88, 245, -1, 246, 245, -1, 203, -1, 204, -1, - 205, -1, 206, -1, 245, -1, 247, 207, 245, -1, - 247, 208, 245, -1, 247, 209, 245, -1, 247, -1, - 248, 203, 247, -1, 248, 204, 247, -1, 248, -1, - 249, 85, 248, -1, 249, 86, 248, -1, 249, -1, - 250, 210, 249, -1, 250, 211, 249, -1, 250, 89, - 249, -1, 250, 90, 249, -1, 250, -1, 251, 91, - 250, -1, 251, 92, 250, -1, 251, -1, 252, 212, - 251, -1, 252, -1, 253, 213, 252, -1, 253, -1, - 254, 214, 253, -1, 254, -1, 255, 93, 254, -1, - 255, -1, 256, 95, 255, -1, 256, -1, 257, 94, - 256, -1, 257, -1, 257, 215, 261, 216, 259, -1, - 258, -1, 245, 260, 259, -1, 217, -1, 96, -1, - 97, -1, 99, -1, 98, -1, 105, -1, 100, -1, - 101, -1, 102, -1, 103, -1, 104, -1, 259, -1, - 261, 202, 259, -1, 258, -1, 264, 218, -1, 272, - 218, -1, 111, 286, 283, 218, -1, 265, 198, -1, - 267, -1, 266, -1, 267, 269, -1, 266, 202, 269, - -1, 274, 230, 197, -1, 282, 227, -1, 282, 227, - 199, 262, 200, -1, 279, 270, 268, -1, 270, 268, - -1, 279, 270, 271, -1, 270, 271, -1, -1, 33, - -1, 34, -1, 35, -1, 282, -1, 273, -1, 272, - 202, 227, -1, 272, 202, 227, 199, 200, -1, 272, - 202, 227, 199, 262, 200, -1, 272, 202, 227, 199, - 200, 217, 292, -1, 272, 202, 227, 199, 262, 200, - 217, 292, -1, 272, 202, 227, 217, 292, -1, 274, - -1, 274, 227, -1, 274, 227, 199, 200, -1, 274, - 227, 199, 262, 200, -1, 274, 227, 199, 200, 217, - 292, -1, 274, 227, 199, 262, 200, 217, 292, -1, - 274, 227, 217, 292, -1, 106, 230, -1, 282, -1, - 280, 282, -1, 124, 197, 276, 198, -1, 277, -1, - 276, 202, 277, -1, 227, -1, 227, 217, 81, -1, - 40, -1, 39, -1, 38, -1, 4, -1, 281, -1, - 275, -1, 275, 281, -1, 278, -1, 278, 281, -1, - 106, 281, -1, 106, 278, 281, -1, 106, -1, 4, - -1, 3, -1, 37, -1, 32, 37, -1, 33, -1, - 34, -1, 32, 33, -1, 32, 34, -1, 36, -1, - 283, -1, 286, 283, -1, 284, -1, 284, 199, 200, - -1, 284, 199, 262, 200, -1, 285, -1, 287, -1, - 78, -1, 75, -1, 6, -1, 7, -1, 8, -1, - 5, -1, 29, -1, 30, -1, 31, -1, 20, -1, - 21, -1, 22, -1, 23, -1, 24, -1, 25, -1, - 26, -1, 27, -1, 28, -1, 41, -1, 42, -1, - 43, -1, 44, -1, 45, -1, 46, -1, 47, -1, - 48, -1, 49, -1, 50, -1, 51, -1, 158, -1, - 52, -1, 53, -1, 73, -1, 54, -1, 55, -1, - 160, -1, 56, -1, 57, -1, 58, -1, 59, -1, - 60, -1, 61, -1, 62, -1, 63, -1, 64, -1, - 65, -1, 66, -1, 67, -1, 68, -1, 69, -1, - 70, -1, 71, -1, 72, -1, 109, -1, 108, -1, - 107, -1, 74, 227, 219, 288, 220, -1, 74, 219, - 288, 220, -1, 289, -1, 288, 289, -1, 282, 290, - 218, -1, 291, -1, 290, 202, 291, -1, 227, -1, - 227, 199, 262, 200, -1, 259, -1, 263, -1, 296, - -1, 295, -1, 293, -1, 301, -1, 302, -1, 305, - -1, 311, -1, 315, -1, 219, 220, -1, -1, 219, - 297, 300, 220, -1, 299, -1, 295, -1, 219, 220, - -1, 219, 300, 220, -1, 294, -1, 300, 294, -1, - 218, -1, 261, 218, -1, 14, 197, 261, 198, 303, - -1, 294, 12, 294, -1, 294, -1, 261, -1, 274, - 227, 217, 292, -1, 17, 197, 261, 198, 306, -1, - 219, 220, -1, 219, 310, 220, -1, 18, 261, 216, - -1, 19, 216, -1, 307, -1, 308, 307, -1, 308, - 294, -1, 309, 294, -1, 309, -1, 310, 309, -1, - 76, 197, 304, 198, 298, -1, 11, 294, 76, 197, - 261, 198, 218, -1, 13, 197, 312, 314, 198, 298, - -1, 301, -1, 293, -1, 304, -1, -1, 313, 218, - -1, 313, 218, 261, -1, 10, 218, -1, 9, 218, - -1, 16, 218, -1, 16, 261, 218, -1, 15, 218, - -1, 317, -1, 263, -1, 225, -1, 264, 299, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 236, 236, 235, 247, 249, 289, 290, 291, 292, - 293, 305, 307, 311, 312, 313, 317, 326, 334, 345, - 346, 350, 357, 364, 371, 378, 385, 392, 393, 399, - 403, 410, 416, 425, 429, 433, 434, 443, 444, 448, - 449, 453, 459, 471, 475, 481, 488, 498, 499, 503, - 504, 508, 514, 526, 537, 538, 544, 550, 560, 561, - 562, 563, 567, 568, 574, 580, 589, 590, 596, 605, - 606, 612, 621, 622, 628, 634, 640, 649, 650, 656, - 665, 666, 675, 676, 685, 686, 695, 696, 705, 706, - 715, 716, 725, 726, 735, 736, 745, 746, 747, 748, - 749, 750, 751, 752, 753, 754, 755, 759, 763, 779, - 783, 788, 792, 801, 805, 806, 810, 815, 823, 837, - 847, 862, 869, 874, 885, 898, 901, 906, 911, 920, - 924, 925, 935, 945, 955, 965, 975, 989, 996, 1005, - 1014, 1023, 1032, 1041, 1050, 1064, 1071, 1082, 1089, 1090, - 1109, 1168, 1209, 1214, 1219, 1227, 1235, 1236, 1237, 1242, - 1243, 1248, 1253, 1259, 1267, 1272, 1277, 1282, 1288, 1293, - 1298, 1303, 1308, 1316, 1320, 1328, 1329, 1335, 1344, 1350, - 1356, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, - 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, - 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, - 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, - 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, - 1414, 1415, 1416, 1420, 1430, 1440, 1453, 1460, 1469, 1474, - 1482, 1497, 1502, 1510, 1517, 1526, 1530, 1536, 1537, 1541, - 1542, 1543, 1544, 1545, 1546, 1550, 1557, 1556, 1570, 1571, - 1575, 1581, 1590, 1600, 1612, 1618, 1627, 1636, 1641, 1649, - 1653, 1671, 1679, 1684, 1692, 1697, 1705, 1713, 1721, 1729, - 1737, 1745, 1753, 1760, 1767, 1777, 1778, 1782, 1784, 1790, - 1795, 1804, 1810, 1816, 1822, 1828, 1837, 1838, 1839, 1843 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "ATTRIBUTE", "CONST_TOK", "BOOL_TOK", - "FLOAT_TOK", "INT_TOK", "UINT_TOK", "BREAK", "CONTINUE", "DO", "ELSE", - "FOR", "IF", "DISCARD", "RETURN", "SWITCH", "CASE", "DEFAULT", "BVEC2", - "BVEC3", "BVEC4", "IVEC2", "IVEC3", "IVEC4", "UVEC2", "UVEC3", "UVEC4", - "VEC2", "VEC3", "VEC4", "CENTROID", "IN_TOK", "OUT_TOK", "INOUT_TOK", - "UNIFORM", "VARYING", "NOPERSPECTIVE", "FLAT", "SMOOTH", "MAT2X2", - "MAT2X3", "MAT2X4", "MAT3X2", "MAT3X3", "MAT3X4", "MAT4X2", "MAT4X3", - "MAT4X4", "SAMPLER1D", "SAMPLER2D", "SAMPLER3D", "SAMPLERCUBE", - "SAMPLER1DSHADOW", "SAMPLER2DSHADOW", "SAMPLERCUBESHADOW", - "SAMPLER1DARRAY", "SAMPLER2DARRAY", "SAMPLER1DARRAYSHADOW", - "SAMPLER2DARRAYSHADOW", "ISAMPLER1D", "ISAMPLER2D", "ISAMPLER3D", - "ISAMPLERCUBE", "ISAMPLER1DARRAY", "ISAMPLER2DARRAY", "USAMPLER1D", - "USAMPLER2D", "USAMPLER3D", "USAMPLERCUBE", "USAMPLER1DARRAY", - "USAMPLER2DARRAY", "SAMPLEREXTERNALOES", "STRUCT", "VOID_TOK", "WHILE", - "IDENTIFIER", "TYPE_IDENTIFIER", "NEW_IDENTIFIER", "FLOATCONSTANT", - "INTCONSTANT", "UINTCONSTANT", "BOOLCONSTANT", "FIELD_SELECTION", - "LEFT_OP", "RIGHT_OP", "INC_OP", "DEC_OP", "LE_OP", "GE_OP", "EQ_OP", - "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN", "DIV_ASSIGN", - "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", - "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "INVARIANT", "LOWP", "MEDIUMP", - "HIGHP", "SUPERP", "PRECISION", "VERSION_TOK", "EXTENSION", "LINE", - "COLON", "EOL", "INTERFACE", "OUTPUT", "PRAGMA_DEBUG_ON", - "PRAGMA_DEBUG_OFF", "PRAGMA_OPTIMIZE_ON", "PRAGMA_OPTIMIZE_OFF", - "PRAGMA_INVARIANT_ALL", "LAYOUT_TOK", "ASM", "CLASS", "UNION", "ENUM", - "TYPEDEF", "TEMPLATE", "THIS", "PACKED_TOK", "GOTO", "INLINE_TOK", - "NOINLINE", "VOLATILE", "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", - "LONG_TOK", "SHORT_TOK", "DOUBLE_TOK", "HALF", "FIXED_TOK", "UNSIGNED", - "INPUT_TOK", "OUPTUT", "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", - "DVEC4", "FVEC2", "FVEC3", "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", - "SAMPLER2DRECTSHADOW", "SIZEOF", "CAST", "NAMESPACE", "USING", - "ERROR_TOK", "COMMON", "PARTITION", "ACTIVE", "SAMPLERBUFFER", "FILTER", - "IMAGE1D", "IMAGE2D", "IMAGE3D", "IMAGECUBE", "IMAGE1DARRAY", - "IMAGE2DARRAY", "IIMAGE1D", "IIMAGE2D", "IIMAGE3D", "IIMAGECUBE", - "IIMAGE1DARRAY", "IIMAGE2DARRAY", "UIMAGE1D", "UIMAGE2D", "UIMAGE3D", - "UIMAGECUBE", "UIMAGE1DARRAY", "UIMAGE2DARRAY", "IMAGE1DSHADOW", - "IMAGE2DSHADOW", "IMAGEBUFFER", "IIMAGEBUFFER", "UIMAGEBUFFER", - "IMAGE1DARRAYSHADOW", "IMAGE2DARRAYSHADOW", "ROW_MAJOR", "'('", "')'", - "'['", "']'", "'.'", "','", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", - "'%'", "'<'", "'>'", "'&'", "'^'", "'|'", "'?'", "':'", "'='", "';'", - "'{'", "'}'", "$accept", "translation_unit", "$@1", "version_statement", - "pragma_statement", "extension_statement_list", "any_identifier", - "extension_statement", "external_declaration_list", - "variable_identifier", "primary_expression", "postfix_expression", - "integer_expression", "function_call", "function_call_or_method", - "function_call_generic", "function_call_header_no_parameters", - "function_call_header_with_parameters", "function_call_header", - "function_identifier", "method_call_generic", - "method_call_header_no_parameters", "method_call_header_with_parameters", - "method_call_header", "unary_expression", "unary_operator", - "multiplicative_expression", "additive_expression", "shift_expression", - "relational_expression", "equality_expression", "and_expression", - "exclusive_or_expression", "inclusive_or_expression", - "logical_and_expression", "logical_xor_expression", - "logical_or_expression", "conditional_expression", - "assignment_expression", "assignment_operator", "expression", - "constant_expression", "declaration", "function_prototype", - "function_declarator", "function_header_with_parameters", - "function_header", "parameter_declarator", "parameter_declaration", - "parameter_qualifier", "parameter_type_specifier", - "init_declarator_list", "single_declaration", "fully_specified_type", - "layout_qualifier", "layout_qualifier_id_list", "layout_qualifier_id", - "interpolation_qualifier", "parameter_type_qualifier", "type_qualifier", - "storage_qualifier", "type_specifier", "type_specifier_no_prec", - "type_specifier_nonarray", "basic_type_specifier_nonarray", - "precision_qualifier", "struct_specifier", "struct_declaration_list", - "struct_declaration", "struct_declarator_list", "struct_declarator", - "initializer", "declaration_statement", "statement", "simple_statement", - "compound_statement", "$@2", "statement_no_new_scope", - "compound_statement_no_new_scope", "statement_list", - "expression_statement", "selection_statement", - "selection_rest_statement", "condition", "switch_statement", - "switch_body", "case_label", "case_label_list", "case_statement", - "case_statement_list", "iteration_statement", "for_init_statement", - "conditionopt", "for_rest_statement", "jump_statement", - "external_declaration", "function_definition", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, - 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, - 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, - 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, - 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, - 445, 446, 447, 448, 449, 450, 451, 40, 41, 91, - 93, 46, 44, 43, 45, 33, 126, 42, 47, 37, - 60, 62, 38, 94, 124, 63, 58, 61, 59, 123, - 125 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint16 yyr1[] = -{ - 0, 221, 223, 222, 224, 224, 225, 225, 225, 225, - 225, 226, 226, 227, 227, 227, 228, 229, 229, 230, - 230, 231, 231, 231, 231, 231, 231, 232, 232, 232, - 232, 232, 232, 233, 234, 235, 235, 236, 236, 237, - 237, 238, 238, 239, 240, 240, 240, 241, 241, 242, - 242, 243, 243, 244, 245, 245, 245, 245, 246, 246, - 246, 246, 247, 247, 247, 247, 248, 248, 248, 249, - 249, 249, 250, 250, 250, 250, 250, 251, 251, 251, - 252, 252, 253, 253, 254, 254, 255, 255, 256, 256, - 257, 257, 258, 258, 259, 259, 260, 260, 260, 260, - 260, 260, 260, 260, 260, 260, 260, 261, 261, 262, - 263, 263, 263, 264, 265, 265, 266, 266, 267, 268, - 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, - 272, 272, 272, 272, 272, 272, 272, 273, 273, 273, - 273, 273, 273, 273, 273, 274, 274, 275, 276, 276, - 277, 277, 278, 278, 278, 279, 280, 280, 280, 280, - 280, 280, 280, 280, 281, 281, 281, 281, 281, 281, - 281, 281, 281, 282, 282, 283, 283, 283, 284, 284, - 284, 285, 285, 285, 285, 285, 285, 285, 285, 285, - 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, - 285, 285, 285, 286, 286, 286, 287, 287, 288, 288, - 289, 290, 290, 291, 291, 292, 293, 294, 294, 295, - 295, 295, 295, 295, 295, 296, 297, 296, 298, 298, - 299, 299, 300, 300, 301, 301, 302, 303, 303, 304, - 304, 305, 306, 306, 307, 307, 308, 308, 309, 309, - 310, 310, 311, 311, 311, 312, 312, 313, 313, 314, - 314, 315, 315, 315, 315, 315, 316, 316, 316, 317 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 0, 4, 0, 3, 2, 2, 2, 2, - 2, 0, 2, 1, 1, 1, 5, 1, 2, 1, - 1, 1, 1, 1, 1, 1, 3, 1, 4, 1, - 3, 2, 2, 1, 1, 1, 3, 2, 2, 2, - 1, 2, 3, 2, 1, 1, 1, 2, 2, 2, - 1, 2, 3, 2, 1, 2, 2, 2, 1, 1, - 1, 1, 1, 3, 3, 3, 1, 3, 3, 1, - 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, - 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, - 1, 3, 1, 5, 1, 3, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, - 2, 2, 4, 2, 1, 1, 2, 3, 3, 2, - 5, 3, 2, 3, 2, 0, 1, 1, 1, 1, - 1, 3, 5, 6, 7, 8, 5, 1, 2, 4, - 5, 6, 7, 4, 2, 1, 2, 4, 1, 3, - 1, 3, 1, 1, 1, 1, 1, 1, 2, 1, - 2, 2, 3, 1, 1, 1, 1, 2, 1, 1, - 2, 2, 1, 1, 2, 1, 3, 4, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 5, 4, 1, 2, - 3, 1, 3, 1, 4, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 0, 4, 1, 1, - 2, 3, 1, 2, 1, 2, 5, 3, 1, 1, - 4, 5, 2, 3, 3, 2, 1, 2, 2, 2, - 1, 2, 5, 7, 6, 1, 1, 1, 0, 2, - 3, 2, 2, 2, 3, 2, 1, 1, 1, 2 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint16 yydefact[] = -{ - 4, 0, 0, 11, 0, 1, 2, 5, 0, 0, - 12, 13, 14, 15, 0, 165, 164, 185, 182, 183, - 184, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 186, 187, 188, 0, 168, 169, 172, 166, 154, 153, - 152, 198, 199, 200, 201, 202, 203, 204, 205, 206, - 207, 208, 210, 211, 213, 214, 216, 217, 218, 219, - 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, - 230, 231, 232, 212, 0, 181, 180, 163, 235, 234, - 233, 0, 0, 0, 0, 0, 0, 0, 209, 215, - 298, 3, 297, 0, 0, 115, 125, 0, 130, 137, - 157, 159, 0, 156, 145, 173, 175, 178, 0, 179, - 17, 296, 0, 170, 171, 167, 0, 0, 19, 20, - 144, 0, 161, 0, 6, 7, 8, 9, 10, 0, - 18, 110, 0, 299, 113, 125, 155, 126, 127, 128, - 116, 0, 125, 0, 111, 13, 15, 138, 0, 158, - 160, 146, 0, 174, 0, 0, 0, 238, 0, 162, - 0, 150, 0, 148, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 24, 22, 23, 25, 46, 0, 0, - 0, 58, 59, 60, 61, 264, 256, 260, 21, 27, - 54, 29, 34, 35, 0, 0, 40, 0, 62, 0, - 66, 69, 72, 77, 80, 82, 84, 86, 88, 90, - 92, 94, 107, 0, 246, 0, 145, 249, 262, 248, - 247, 0, 250, 251, 252, 253, 254, 117, 122, 124, - 129, 0, 131, 0, 0, 118, 176, 62, 109, 0, - 44, 16, 243, 0, 241, 237, 239, 0, 112, 0, - 147, 0, 292, 291, 0, 0, 0, 295, 293, 0, - 0, 0, 55, 56, 0, 255, 0, 31, 32, 0, - 0, 38, 37, 0, 181, 41, 43, 97, 98, 100, - 99, 102, 103, 104, 105, 106, 101, 96, 0, 57, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 265, 261, 263, 119, 121, 123, 0, 0, 139, - 0, 245, 143, 177, 0, 0, 240, 236, 151, 149, - 0, 286, 285, 288, 0, 294, 0, 163, 269, 0, - 0, 26, 0, 0, 33, 30, 0, 36, 0, 0, - 50, 42, 95, 63, 64, 65, 67, 68, 70, 71, - 75, 76, 73, 74, 78, 79, 81, 83, 85, 87, - 89, 91, 0, 108, 0, 132, 0, 136, 0, 140, - 0, 242, 0, 287, 0, 0, 0, 0, 0, 0, - 257, 28, 53, 48, 47, 0, 181, 51, 0, 0, - 0, 133, 141, 0, 244, 0, 289, 0, 268, 266, - 0, 271, 0, 259, 282, 258, 52, 93, 120, 134, - 0, 142, 0, 290, 284, 0, 0, 0, 272, 276, - 0, 280, 0, 270, 135, 283, 267, 0, 275, 278, - 277, 279, 273, 281, 274 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 2, 9, 3, 90, 6, 161, 10, 91, 188, - 189, 190, 343, 191, 192, 193, 194, 195, 196, 197, - 347, 348, 349, 350, 198, 199, 200, 201, 202, 203, - 204, 205, 206, 207, 208, 209, 210, 211, 212, 288, - 213, 239, 214, 215, 94, 95, 96, 228, 140, 141, - 229, 97, 98, 99, 100, 162, 163, 101, 142, 102, - 103, 240, 105, 106, 107, 108, 109, 156, 157, 243, - 244, 322, 217, 218, 219, 220, 266, 414, 415, 221, - 222, 223, 409, 340, 224, 411, 429, 430, 431, 432, - 225, 333, 384, 385, 226, 110, 111 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -355 -static const yytype_int16 yypact[] = -{ - -38, -40, 81, -355, -32, -355, -27, -355, 52, 3587, - -355, -355, -355, -355, -26, -355, -355, -355, -355, -355, - -355, -355, -355, -355, -355, -355, -355, -355, -355, -355, - -355, -355, -355, 38, -355, -355, -355, -355, -355, -355, - -355, -355, -355, -355, -355, -355, -355, -355, -355, -355, - -355, -355, -355, -355, -355, -355, -355, -355, -355, -355, - -355, -355, -355, -355, -355, -355, -355, -355, -355, -355, - -355, -355, -355, -355, -67, -355, -355, 251, -355, -355, - -355, 51, -14, -8, 11, 19, 24, -87, -355, -355, - -355, 3587, -355, -162, -107, -46, 15, -180, -355, 96, - 264, 264, 3707, -355, -355, -355, -57, -355, 3781, -355, - -355, -355, 52, -355, -355, -355, 3707, -48, -355, -355, - -355, 264, -355, 3781, -355, -355, -355, -355, -355, 52, - -355, -355, 422, -355, -355, 29, -355, -355, -355, -355, - -355, 3707, 143, 52, -355, -17, -12, -178, 18, -355, - -355, -355, 2465, -355, 73, 52, 1834, -355, 3707, -355, - 3, 9, -168, -355, 10, 14, 1293, 30, 33, 17, - 2074, 40, 44, -355, -355, -355, -355, -355, 3026, 3026, - 3026, -355, -355, -355, -355, -355, -11, -355, 47, -355, - -60, -355, -355, -355, 49, -125, 3213, 48, 16, 3026, - -25, -138, 12, -66, 46, 37, 45, 36, 158, 164, - -81, -355, -355, -171, -355, 35, 64, -355, -355, -355, - -355, 640, -355, -355, -355, -355, -355, -355, -355, -355, - 52, 3707, -163, 2652, 3026, -355, -355, -355, -355, 65, - -355, -355, 82, -160, -355, -355, -355, 1954, -355, 199, - -355, 52, -355, -355, 210, 1714, 3026, -355, -355, -157, - 3026, 2278, -355, -355, -122, -355, 1293, -355, -355, 3026, - 96, -355, -355, 3026, 94, -355, -355, -355, -355, -355, - -355, -355, -355, -355, -355, -355, -355, -355, 3026, -355, - 3026, 3026, 3026, 3026, 3026, 3026, 3026, 3026, 3026, 3026, - 3026, 3026, 3026, 3026, 3026, 3026, 3026, 3026, 3026, 3026, - 3026, -355, -355, -355, 95, -355, -355, 2839, 3026, 76, - 99, -355, -355, -355, 3026, 52, -355, -355, -355, -355, - 98, -355, -355, 2278, -115, -355, -102, 239, 100, 52, - 105, -355, 858, 104, 100, -355, 108, -355, 109, -76, - 3400, -355, -355, -355, -355, -355, -25, -25, -138, -138, - 12, 12, 12, 12, -66, -66, 46, 37, 45, 36, - 158, 164, -165, -355, 3026, 89, 110, -355, 3026, 91, - 111, -355, 3026, -355, 97, 114, 1293, 90, 102, 1510, - -355, -355, -355, -355, -355, 3026, 115, -355, 3026, 116, - 3026, 103, -355, 3026, -355, -47, 3026, 1510, 302, -355, - -10, -355, 3026, -355, -355, -355, -355, -355, -355, -355, - 3026, -355, 107, 100, -355, 1293, 3026, 101, -355, -355, - 1076, 1293, -2, -355, -355, -355, -355, -147, -355, -355, - -355, -355, -355, 1293, -355 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -355, -355, -355, -355, -355, -355, -7, -355, -355, -59, - -355, -355, -355, -355, -355, -355, -355, -355, -355, -355, - -355, -355, -355, -355, -100, -355, -106, -127, -134, -82, - 20, 22, 26, 21, 27, 13, -355, -145, -164, -355, - -166, -213, -6, 34, -355, -355, -355, 106, 187, 193, - 112, -355, -355, -232, -355, -355, 78, -71, -355, -355, - -75, -9, -64, -355, -355, 255, -355, 180, -141, -355, - 23, -250, 84, -161, -354, -355, -355, -65, 247, 75, - 92, -355, -355, 25, -355, -355, -86, -355, -83, -355, - -355, -355, -355, -355, -355, 254, -355 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -115 -static const yytype_int16 yytable[] = -{ - 104, 14, 122, 92, 259, 254, 121, 238, 426, 427, - 11, 12, 13, 308, 264, 246, 426, 427, 120, 136, - 320, 233, 143, 297, 298, 149, 150, 267, 268, 339, - 250, 310, 275, 136, 251, 413, 317, 310, 144, 234, - 148, 4, 325, 93, 153, 310, 159, 311, 137, 138, - 139, 398, 237, 413, 318, 310, 131, 132, 326, 160, - 313, 335, 137, 138, 139, 293, 294, 117, 377, 444, - 321, 113, 114, 272, 1, 115, 341, 273, 262, 263, - 310, 5, 104, 386, 7, 92, 8, 310, 238, 112, - 334, 134, 147, 151, 336, 338, 387, 295, 296, 289, - 310, 339, 124, 344, 376, 154, 246, 155, 125, 351, - 129, 380, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 394, 216, 352, 93, 395, 126, 402, 11, - 12, 13, 230, 237, 309, 127, 232, 301, 302, 269, - 128, 270, 152, 372, 299, 300, 373, 155, 242, 155, - 419, 422, 116, 421, 321, 310, 135, 216, 78, 79, - 80, 399, 433, 360, 361, 362, 363, 338, 358, 359, - 434, 158, 238, 145, 12, 146, 137, 138, 139, 238, - -19, 313, 290, 291, 292, -20, 397, 356, 357, 241, - 353, 354, 355, 237, 237, 237, 237, 237, 237, 237, - 237, 237, 237, 237, 237, 237, 237, 237, 237, 265, - 428, 346, 216, -114, 321, 235, 405, 237, 442, 364, - 365, 248, 230, 314, 237, 408, 249, 255, 252, 238, - 256, 416, 253, 287, 417, 257, 321, 260, 155, 321, - 423, 261, 15, 16, -45, 276, 216, 271, 321, 303, - 305, 306, 216, 131, 15, 16, 321, 216, 304, 307, - 437, -44, 122, 345, 436, 323, 121, 15, 16, 439, - 441, 33, 34, 35, 237, 36, 37, 38, 39, 40, - 328, 324, 441, 33, 34, 35, 330, 36, 37, 38, - 39, 40, -39, 378, 374, 382, 33, 34, 35, 379, - 36, 37, 310, 389, 391, 392, 400, 393, 403, 410, - 401, 404, 407, -49, 425, 406, 418, 438, 242, 412, - 420, 371, 227, 366, 216, 435, 367, 369, 118, 329, - 119, 368, 388, 216, 370, 231, 123, 315, 247, 331, - 133, 342, 424, 316, 440, 130, 0, 332, 381, 443, - 0, 0, 0, 0, 0, 0, 0, 0, 383, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 216, 0, 0, - 216, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 216, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 216, 0, 0, 0, - 0, 216, 216, 0, 0, 15, 16, 17, 18, 19, - 20, 164, 165, 166, 216, 167, 168, 169, 170, 171, - 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 0, 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, 172, 118, - 76, 119, 173, 174, 175, 176, 177, 0, 0, 178, - 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 77, 78, - 79, 80, 0, 81, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 87, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 88, 0, 89, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, - 0, 0, 0, 0, 0, 181, 182, 183, 184, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 185, 186, 187, 15, 16, 17, 18, 19, 20, 164, - 165, 166, 0, 167, 168, 169, 170, 171, 0, 0, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 0, 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, 172, 118, 76, 119, - 173, 174, 175, 176, 177, 0, 0, 178, 179, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 77, 78, 79, 80, - 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 88, 0, - 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 180, 0, 0, - 0, 0, 0, 181, 182, 183, 184, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 185, 186, - 312, 15, 16, 17, 18, 19, 20, 164, 165, 166, - 0, 167, 168, 169, 170, 171, 0, 0, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 0, 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, 172, 118, 76, 119, 173, 174, - 175, 176, 177, 0, 0, 178, 179, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 77, 78, 79, 80, 0, 81, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 88, 0, 89, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 180, 0, 0, 0, 0, - 0, 181, 182, 183, 184, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 185, 186, 390, 15, - 16, 17, 18, 19, 20, 164, 165, 166, 0, 167, - 168, 169, 170, 171, 426, 427, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 0, 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, 172, 118, 76, 119, 173, 174, 175, 176, - 177, 0, 0, 178, 179, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 77, 78, 79, 80, 0, 81, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 88, 0, 89, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 180, 0, 0, 0, 0, 0, 181, - 182, 183, 184, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 185, 186, 15, 16, 17, 18, - 19, 20, 164, 165, 166, 0, 167, 168, 169, 170, - 171, 0, 0, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 0, 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, 172, - 118, 76, 119, 173, 174, 175, 176, 177, 0, 0, - 178, 179, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, - 78, 79, 80, 0, 81, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 87, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 88, 0, 89, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 180, 0, 0, 0, 0, 0, 181, 182, 183, 184, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 185, 186, 15, 16, 17, 18, 19, 20, 164, - 165, 166, 0, 167, 168, 169, 170, 171, 0, 0, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 0, 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, 172, 118, 76, 119, - 173, 174, 175, 176, 177, 0, 0, 178, 179, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 77, 78, 79, 80, - 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 88, 0, - 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 180, 0, 0, - 0, 0, 0, 181, 182, 183, 184, 15, 16, 17, - 18, 19, 20, 0, 0, 0, 0, 0, 185, 132, - 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, - 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, - 0, 118, 76, 119, 173, 174, 175, 176, 177, 0, - 0, 178, 179, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 77, 78, 79, 80, 0, 81, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 87, 17, - 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, - 0, 0, 88, 0, 89, 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, - 0, 180, 76, 0, 0, 0, 0, 181, 182, 183, - 184, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 185, 0, 0, 0, 0, 0, 0, 0, - 0, 78, 79, 80, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, - 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, - 0, 0, 88, 0, 89, 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, - 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 245, 0, 0, 0, 0, 0, - 0, 78, 79, 80, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, - 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, - 0, 0, 88, 0, 89, 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, - 0, 118, 76, 119, 173, 174, 175, 176, 177, 0, - 0, 178, 179, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 327, 0, 0, 0, 0, 0, - 0, 78, 79, 80, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 88, 0, 89, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 180, 0, 0, 0, 0, 0, 181, 182, 183, - 184, 15, 16, 17, 18, 19, 20, 0, 0, 0, - 0, 0, 258, 0, 0, 0, 0, 0, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 0, 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, 0, 118, 76, 119, 173, 174, - 175, 176, 177, 0, 0, 178, 179, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 337, 78, 79, 80, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 88, 0, 89, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 17, 18, 19, 20, 0, 180, 0, 0, 0, 0, - 0, 181, 182, 183, 184, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 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, 0, 118, 76, 119, 173, 174, 175, 176, 177, - 0, 0, 178, 179, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 78, 79, 80, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 88, 0, 89, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 17, 18, 19, - 20, 0, 180, 0, 0, 236, 0, 0, 181, 182, - 183, 184, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 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, 0, 118, - 76, 119, 173, 174, 175, 176, 177, 0, 0, 178, - 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, - 79, 80, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 88, 0, 89, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 17, 18, 19, 20, 0, 180, - 0, 0, 319, 0, 0, 181, 182, 183, 184, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 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, 0, 118, 76, 119, 173, - 174, 175, 176, 177, 0, 0, 178, 179, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 78, 79, 80, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 88, 0, 89, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 17, 18, 19, 20, 0, 180, 0, 0, 375, - 0, 0, 181, 182, 183, 184, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 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, 0, 118, 76, 119, 173, 174, 175, 176, - 177, 0, 0, 178, 179, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 78, 79, 80, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 88, 0, 89, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, - 19, 20, 0, 180, 0, 0, 0, 0, 0, 181, - 182, 183, 184, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 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, 274, 0, - 118, 76, 119, 173, 174, 175, 176, 177, 0, 0, - 178, 179, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 78, 79, 80, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 88, 0, 89, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 17, 18, 19, 20, 0, - 180, 0, 0, 0, 0, 0, 181, 182, 183, 184, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 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, 396, 0, 118, 76, 119, - 173, 174, 175, 176, 177, 0, 0, 178, 179, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 78, 79, 80, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 88, 0, - 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 15, 16, 17, 18, 19, 20, 0, 180, 0, 0, - 0, 0, 0, 181, 182, 183, 184, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 0, 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, 0, 0, 76, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 77, 78, 79, 80, 0, 81, 0, - 0, 0, 0, 0, 0, 0, 82, 83, 84, 85, - 86, 87, 17, 18, 19, 20, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 0, - 0, 0, 0, 0, 0, 88, 0, 89, 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, 0, 0, 76, 17, 18, 19, 20, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 0, 78, 79, 80, 0, 0, 0, - 0, 0, 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, 0, 0, 76, - 0, 0, 0, 0, 0, 88, 0, 89, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, - 0, 89 -}; - -static const yytype_int16 yycheck[] = -{ - 9, 8, 77, 9, 170, 166, 77, 152, 18, 19, - 77, 78, 79, 94, 180, 156, 18, 19, 77, 4, - 233, 199, 202, 89, 90, 100, 101, 87, 88, 261, - 198, 202, 196, 4, 202, 389, 199, 202, 218, 217, - 99, 81, 202, 9, 108, 202, 121, 218, 33, 34, - 35, 216, 152, 407, 217, 202, 218, 219, 218, 123, - 221, 218, 33, 34, 35, 203, 204, 74, 318, 216, - 234, 33, 34, 198, 112, 37, 198, 202, 178, 179, - 202, 0, 91, 198, 116, 91, 113, 202, 233, 115, - 256, 198, 99, 102, 260, 261, 198, 85, 86, 199, - 202, 333, 116, 269, 317, 112, 247, 116, 116, 273, - 197, 324, 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 198, 132, 288, 91, 202, 116, 378, 77, - 78, 79, 141, 233, 215, 116, 143, 91, 92, 199, - 116, 201, 199, 309, 210, 211, 310, 156, 155, 158, - 400, 198, 219, 403, 318, 202, 202, 166, 107, 108, - 109, 374, 412, 297, 298, 299, 300, 333, 295, 296, - 420, 219, 317, 77, 78, 79, 33, 34, 35, 324, - 197, 342, 207, 208, 209, 197, 350, 293, 294, 116, - 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, - 300, 301, 302, 303, 304, 305, 306, 307, 308, 220, - 220, 270, 221, 198, 378, 197, 382, 317, 220, 301, - 302, 218, 231, 230, 324, 386, 217, 197, 218, 374, - 197, 395, 218, 217, 398, 218, 400, 197, 247, 403, - 406, 197, 3, 4, 197, 197, 255, 198, 412, 212, - 214, 93, 261, 218, 3, 4, 420, 266, 213, 95, - 426, 197, 337, 270, 425, 200, 337, 3, 4, 430, - 431, 32, 33, 34, 374, 36, 37, 38, 39, 40, - 81, 199, 443, 32, 33, 34, 76, 36, 37, 38, - 39, 40, 198, 217, 199, 197, 32, 33, 34, 200, - 36, 37, 202, 198, 200, 197, 217, 198, 217, 219, - 200, 200, 198, 198, 12, 218, 200, 216, 325, 217, - 217, 308, 135, 303, 333, 218, 304, 306, 77, 251, - 79, 305, 339, 342, 307, 142, 81, 231, 158, 255, - 93, 266, 407, 231, 430, 91, -1, 255, 325, 432, - -1, -1, -1, -1, -1, -1, -1, -1, 333, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 386, -1, -1, - 389, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 407, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 425, -1, -1, -1, - -1, 430, 431, -1, -1, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 443, 13, 14, 15, 16, 17, - -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, -1, 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, -1, -1, 87, - 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, - 108, 109, -1, 111, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 158, -1, 160, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 197, - -1, -1, -1, -1, -1, 203, 204, 205, 206, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 218, 219, 220, 3, 4, 5, 6, 7, 8, 9, - 10, 11, -1, 13, 14, 15, 16, 17, -1, -1, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, -1, 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, -1, -1, 87, 88, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, - -1, 111, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 158, -1, - 160, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 197, -1, -1, - -1, -1, -1, 203, 204, 205, 206, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 218, 219, - 220, 3, 4, 5, 6, 7, 8, 9, 10, 11, - -1, 13, 14, 15, 16, 17, -1, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, -1, 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, -1, -1, 87, 88, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 106, 107, 108, 109, -1, 111, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 158, -1, 160, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 197, -1, -1, -1, -1, - -1, 203, 204, 205, 206, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 218, 219, 220, 3, - 4, 5, 6, 7, 8, 9, 10, 11, -1, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, 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, -1, -1, 87, 88, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 106, 107, 108, 109, -1, 111, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 158, -1, 160, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 197, -1, -1, -1, -1, -1, 203, - 204, 205, 206, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 218, 219, 3, 4, 5, 6, - 7, 8, 9, 10, 11, -1, 13, 14, 15, 16, - 17, -1, -1, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, -1, 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, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 106, - 107, 108, 109, -1, 111, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 124, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 158, -1, 160, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 197, -1, -1, -1, -1, -1, 203, 204, 205, 206, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 218, 219, 3, 4, 5, 6, 7, 8, 9, - 10, 11, -1, 13, 14, 15, 16, 17, -1, -1, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, -1, 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, -1, -1, 87, 88, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 106, 107, 108, 109, - -1, 111, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 124, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 158, -1, - 160, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 197, -1, -1, - -1, -1, -1, 203, 204, 205, 206, 3, 4, 5, - 6, 7, 8, -1, -1, -1, -1, -1, 218, 219, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, - 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, - -1, 77, 78, 79, 80, 81, 82, 83, 84, -1, - -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 106, 107, 108, 109, -1, 111, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 124, 5, - 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, - -1, -1, 158, -1, 160, 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, - -1, 197, 78, -1, -1, -1, -1, 203, 204, 205, - 206, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 218, -1, -1, -1, -1, -1, -1, -1, - -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, - 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, - -1, -1, 158, -1, 160, 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, - -1, -1, 78, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 220, -1, -1, -1, -1, -1, - -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, - 6, 7, 8, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, - -1, -1, 158, -1, 160, 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, - -1, 77, 78, 79, 80, 81, 82, 83, 84, -1, - -1, 87, 88, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 220, -1, -1, -1, -1, -1, - -1, 107, 108, 109, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 158, -1, 160, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 197, -1, -1, -1, -1, -1, 203, 204, 205, - 206, 3, 4, 5, 6, 7, 8, -1, -1, -1, - -1, -1, 218, -1, -1, -1, -1, -1, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, -1, 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, -1, 77, 78, 79, 80, 81, - 82, 83, 84, -1, -1, 87, 88, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 106, 107, 108, 109, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 124, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 158, -1, 160, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 5, 6, 7, 8, -1, 197, -1, -1, -1, -1, - -1, 203, 204, 205, 206, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 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, -1, 77, 78, 79, 80, 81, 82, 83, 84, - -1, -1, 87, 88, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 107, 108, 109, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 158, -1, 160, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 5, 6, 7, - 8, -1, 197, -1, -1, 200, -1, -1, 203, 204, - 205, 206, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 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, -1, 77, - 78, 79, 80, 81, 82, 83, 84, -1, -1, 87, - 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 107, - 108, 109, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 158, -1, 160, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 5, 6, 7, 8, -1, 197, - -1, -1, 200, -1, -1, 203, 204, 205, 206, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 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, -1, 77, 78, 79, 80, - 81, 82, 83, 84, -1, -1, 87, 88, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 107, 108, 109, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 158, -1, 160, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 5, 6, 7, 8, -1, 197, -1, -1, 200, - -1, -1, 203, 204, 205, 206, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 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, -1, 77, 78, 79, 80, 81, 82, 83, - 84, -1, -1, 87, 88, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 107, 108, 109, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 158, -1, 160, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, - 7, 8, -1, 197, -1, -1, -1, -1, -1, 203, - 204, 205, 206, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 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, -1, - 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, - 87, 88, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 107, 108, 109, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 158, -1, 160, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 5, 6, 7, 8, -1, - 197, -1, -1, -1, -1, -1, 203, 204, 205, 206, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 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, -1, 77, 78, 79, - 80, 81, 82, 83, 84, -1, -1, 87, 88, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 107, 108, 109, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 158, -1, - 160, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 3, 4, 5, 6, 7, 8, -1, 197, -1, -1, - -1, -1, -1, 203, 204, 205, 206, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, -1, 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, -1, -1, 78, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 106, 107, 108, 109, -1, 111, -1, - -1, -1, -1, -1, -1, -1, 119, 120, 121, 122, - 123, 124, 5, 6, 7, 8, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, - -1, -1, -1, -1, -1, 158, -1, 160, 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, -1, -1, 78, 5, 6, 7, 8, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, -1, 107, 108, 109, -1, -1, -1, - -1, -1, 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, -1, -1, 78, - -1, -1, -1, -1, -1, 158, -1, 160, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 158, - -1, 160 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint16 yystos[] = -{ - 0, 112, 222, 224, 81, 0, 226, 116, 113, 223, - 228, 77, 78, 79, 227, 3, 4, 5, 6, 7, - 8, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 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, 78, 106, 107, 108, - 109, 111, 119, 120, 121, 122, 123, 124, 158, 160, - 225, 229, 263, 264, 265, 266, 267, 272, 273, 274, - 275, 278, 280, 281, 282, 283, 284, 285, 286, 287, - 316, 317, 115, 33, 34, 37, 219, 227, 77, 79, - 230, 278, 281, 286, 116, 116, 116, 116, 116, 197, - 316, 218, 219, 299, 198, 202, 4, 33, 34, 35, - 269, 270, 279, 202, 218, 77, 79, 227, 230, 281, - 281, 282, 199, 283, 227, 282, 288, 289, 219, 281, - 283, 227, 276, 277, 9, 10, 11, 13, 14, 15, - 16, 17, 76, 80, 81, 82, 83, 84, 87, 88, - 197, 203, 204, 205, 206, 218, 219, 220, 230, 231, - 232, 234, 235, 236, 237, 238, 239, 240, 245, 246, - 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, - 257, 258, 259, 261, 263, 264, 282, 293, 294, 295, - 296, 300, 301, 302, 305, 311, 315, 269, 268, 271, - 282, 270, 227, 199, 217, 197, 200, 245, 258, 262, - 282, 116, 227, 290, 291, 220, 289, 288, 218, 217, - 198, 202, 218, 218, 294, 197, 197, 218, 218, 261, - 197, 197, 245, 245, 261, 220, 297, 87, 88, 199, - 201, 198, 198, 202, 75, 259, 197, 96, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 217, 260, 245, - 207, 208, 209, 203, 204, 85, 86, 89, 90, 210, - 211, 91, 92, 212, 213, 214, 93, 95, 94, 215, - 202, 218, 220, 294, 227, 268, 271, 199, 217, 200, - 262, 259, 292, 200, 199, 202, 218, 220, 81, 277, - 76, 293, 301, 312, 261, 218, 261, 106, 261, 274, - 304, 198, 300, 233, 261, 227, 230, 241, 242, 243, - 244, 259, 259, 245, 245, 245, 247, 247, 248, 248, - 249, 249, 249, 249, 250, 250, 251, 252, 253, 254, - 255, 256, 261, 259, 199, 200, 262, 292, 217, 200, - 262, 291, 197, 304, 313, 314, 198, 198, 227, 198, - 220, 200, 197, 198, 198, 202, 75, 259, 216, 262, - 217, 200, 292, 217, 200, 261, 218, 198, 294, 303, - 219, 306, 217, 295, 298, 299, 259, 259, 200, 292, - 217, 292, 198, 261, 298, 12, 18, 19, 220, 307, - 308, 309, 310, 292, 292, 218, 294, 261, 216, 294, - 307, 294, 220, 309, 216 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, state, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval, &yylloc, scanner) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, Location, state); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - struct _mesa_glsl_parse_state *state; -#endif -{ - if (!yyvaluep) - return; - YYUSE (yylocationp); - YYUSE (state); -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, state) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - struct _mesa_glsl_parse_state *state; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - YY_LOCATION_PRINT (yyoutput, *yylocationp); - YYFPRINTF (yyoutput, ": "); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, struct _mesa_glsl_parse_state *state) -#else -static void -yy_reduce_print (yyvsp, yylsp, yyrule, state) - YYSTYPE *yyvsp; - YYLTYPE *yylsp; - int yyrule; - struct _mesa_glsl_parse_state *state; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , &(yylsp[(yyi + 1) - (yynrhs)]) , state); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, yylsp, Rule, state); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct _mesa_glsl_parse_state *state) -#else -static void -yydestruct (yymsg, yytype, yyvaluep, yylocationp, state) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; - YYLTYPE *yylocationp; - struct _mesa_glsl_parse_state *state; -#endif -{ - YYUSE (yyvaluep); - YYUSE (yylocationp); - YYUSE (state); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (struct _mesa_glsl_parse_state *state); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (struct _mesa_glsl_parse_state *state) -#else -int -yyparse (state) - struct _mesa_glsl_parse_state *state; -#endif -#endif -{ -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Location data for the lookahead symbol. */ -YYLTYPE yylloc; - - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls; - YYLTYPE *yylsp; - - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yyls = yylsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - yylsp = yyls; - -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - /* Initialize the default location before parsing starts. */ - yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 1; -#endif - -/* User initialization code. */ - -/* Line 1251 of yacc.c */ -#line 47 "glsl_parser.yy" -{ - yylloc.first_line = 1; - yylloc.first_column = 1; - yylloc.last_line = 1; - yylloc.last_column = 1; - yylloc.source = 0; -} - -/* Line 1251 of yacc.c */ -#line 2726 "glsl_parser.cpp" - yylsp[0] = yylloc; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - YYLTYPE *yyls1 = yyls; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), - &yystacksize); - - yyls = yyls1; - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); - YYSTACK_RELOCATE (yyls_alloc, yyls); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - yylsp = yyls + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - *++yylsp = yylloc; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: - -/* Line 1464 of yacc.c */ -#line 236 "glsl_parser.yy" - { - _mesa_glsl_initialize_types(state); - ;} - break; - - case 3: - -/* Line 1464 of yacc.c */ -#line 240 "glsl_parser.yy" - { - delete state->symbols; - state->symbols = new(ralloc_parent(state)) glsl_symbol_table; - _mesa_glsl_initialize_types(state); - ;} - break; - - case 5: - -/* Line 1464 of yacc.c */ -#line 250 "glsl_parser.yy" - { - bool supported = false; - - switch ((yyvsp[(2) - (3)].n)) { - case 100: - state->es_shader = true; - supported = state->Const.GLSL_100ES; - break; - case 110: - supported = state->Const.GLSL_110; - break; - case 120: - supported = state->Const.GLSL_120; - break; - case 130: - supported = state->Const.GLSL_130; - break; - default: - supported = false; - break; - } - - state->language_version = (yyvsp[(2) - (3)].n); - state->version_string = - ralloc_asprintf(state, "GLSL%s %d.%02d", - state->es_shader ? " ES" : "", - state->language_version / 100, - state->language_version % 100); - - if (!supported) { - _mesa_glsl_error(& (yylsp[(2) - (3)]), state, "%s is not supported. " - "Supported versions are: %s\n", - state->version_string, - state->supported_version_string); - } - ;} - break; - - case 10: - -/* Line 1464 of yacc.c */ -#line 294 "glsl_parser.yy" - { - if (state->language_version < 120) { - _mesa_glsl_warning(& (yylsp[(1) - (2)]), state, - "pragma `invariant(all)' not supported in %s", - state->version_string); - } else { - state->all_invariant = true; - } - ;} - break; - - case 16: - -/* Line 1464 of yacc.c */ -#line 318 "glsl_parser.yy" - { - if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) { - YYERROR; - } - ;} - break; - - case 17: - -/* Line 1464 of yacc.c */ -#line 327 "glsl_parser.yy" - { - /* FINISHME: The NULL test is required because pragmas are set to - * FINISHME: NULL. (See production rule for external_declaration.) - */ - if ((yyvsp[(1) - (1)].node) != NULL) - state->translation_unit.push_tail(& (yyvsp[(1) - (1)].node)->link); - ;} - break; - - case 18: - -/* Line 1464 of yacc.c */ -#line 335 "glsl_parser.yy" - { - /* FINISHME: The NULL test is required because pragmas are set to - * FINISHME: NULL. (See production rule for external_declaration.) - */ - if ((yyvsp[(2) - (2)].node) != NULL) - state->translation_unit.push_tail(& (yyvsp[(2) - (2)].node)->link); - ;} - break; - - case 21: - -/* Line 1464 of yacc.c */ -#line 351 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->primary_expression.identifier = (yyvsp[(1) - (1)].identifier); - ;} - break; - - case 22: - -/* Line 1464 of yacc.c */ -#line 358 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->primary_expression.int_constant = (yyvsp[(1) - (1)].n); - ;} - break; - - case 23: - -/* Line 1464 of yacc.c */ -#line 365 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->primary_expression.uint_constant = (yyvsp[(1) - (1)].n); - ;} - break; - - case 24: - -/* Line 1464 of yacc.c */ -#line 372 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->primary_expression.float_constant = (yyvsp[(1) - (1)].real); - ;} - break; - - case 25: - -/* Line 1464 of yacc.c */ -#line 379 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->primary_expression.bool_constant = (yyvsp[(1) - (1)].n); - ;} - break; - - case 26: - -/* Line 1464 of yacc.c */ -#line 386 "glsl_parser.yy" - { - (yyval.expression) = (yyvsp[(2) - (3)].expression); - ;} - break; - - case 28: - -/* Line 1464 of yacc.c */ -#line 394 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 29: - -/* Line 1464 of yacc.c */ -#line 400 "glsl_parser.yy" - { - (yyval.expression) = (yyvsp[(1) - (1)].expression); - ;} - break; - - case 30: - -/* Line 1464 of yacc.c */ -#line 404 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->primary_expression.identifier = (yyvsp[(3) - (3)].identifier); - ;} - break; - - case 31: - -/* Line 1464 of yacc.c */ -#line 411 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 32: - -/* Line 1464 of yacc.c */ -#line 417 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 36: - -/* Line 1464 of yacc.c */ -#line 435 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 41: - -/* Line 1464 of yacc.c */ -#line 454 "glsl_parser.yy" - { - (yyval.expression) = (yyvsp[(1) - (2)].expression); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->expressions.push_tail(& (yyvsp[(2) - (2)].expression)->link); - ;} - break; - - case 42: - -/* Line 1464 of yacc.c */ -#line 460 "glsl_parser.yy" - { - (yyval.expression) = (yyvsp[(1) - (3)].expression); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); - ;} - break; - - case 44: - -/* Line 1464 of yacc.c */ -#line 476 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 45: - -/* Line 1464 of yacc.c */ -#line 482 "glsl_parser.yy" - { - void *ctx = state; - ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); - (yyval.expression) = new(ctx) ast_function_expression(callee); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 46: - -/* Line 1464 of yacc.c */ -#line 489 "glsl_parser.yy" - { - void *ctx = state; - ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier)); - (yyval.expression) = new(ctx) ast_function_expression(callee); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 51: - -/* Line 1464 of yacc.c */ -#line 509 "glsl_parser.yy" - { - (yyval.expression) = (yyvsp[(1) - (2)].expression); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->expressions.push_tail(& (yyvsp[(2) - (2)].expression)->link); - ;} - break; - - case 52: - -/* Line 1464 of yacc.c */ -#line 515 "glsl_parser.yy" - { - (yyval.expression) = (yyvsp[(1) - (3)].expression); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); - ;} - break; - - case 53: - -/* Line 1464 of yacc.c */ -#line 527 "glsl_parser.yy" - { - void *ctx = state; - ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (2)].identifier)); - (yyval.expression) = new(ctx) ast_function_expression(callee); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 55: - -/* Line 1464 of yacc.c */ -#line 539 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 56: - -/* Line 1464 of yacc.c */ -#line 545 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 57: - -/* Line 1464 of yacc.c */ -#line 551 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 58: - -/* Line 1464 of yacc.c */ -#line 560 "glsl_parser.yy" - { (yyval.n) = ast_plus; ;} - break; - - case 59: - -/* Line 1464 of yacc.c */ -#line 561 "glsl_parser.yy" - { (yyval.n) = ast_neg; ;} - break; - - case 60: - -/* Line 1464 of yacc.c */ -#line 562 "glsl_parser.yy" - { (yyval.n) = ast_logic_not; ;} - break; - - case 61: - -/* Line 1464 of yacc.c */ -#line 563 "glsl_parser.yy" - { (yyval.n) = ast_bit_not; ;} - break; - - case 63: - -/* Line 1464 of yacc.c */ -#line 569 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 64: - -/* Line 1464 of yacc.c */ -#line 575 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 65: - -/* Line 1464 of yacc.c */ -#line 581 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 67: - -/* Line 1464 of yacc.c */ -#line 591 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 68: - -/* Line 1464 of yacc.c */ -#line 597 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 70: - -/* Line 1464 of yacc.c */ -#line 607 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 71: - -/* Line 1464 of yacc.c */ -#line 613 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 73: - -/* Line 1464 of yacc.c */ -#line 623 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 74: - -/* Line 1464 of yacc.c */ -#line 629 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 75: - -/* Line 1464 of yacc.c */ -#line 635 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 76: - -/* Line 1464 of yacc.c */ -#line 641 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 78: - -/* Line 1464 of yacc.c */ -#line 651 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 79: - -/* Line 1464 of yacc.c */ -#line 657 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 81: - -/* Line 1464 of yacc.c */ -#line 667 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 83: - -/* Line 1464 of yacc.c */ -#line 677 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 85: - -/* Line 1464 of yacc.c */ -#line 687 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 87: - -/* Line 1464 of yacc.c */ -#line 697 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 89: - -/* Line 1464 of yacc.c */ -#line 707 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 91: - -/* Line 1464 of yacc.c */ -#line 717 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 93: - -/* Line 1464 of yacc.c */ -#line 727 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression)); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 95: - -/* Line 1464 of yacc.c */ -#line 737 "glsl_parser.yy" - { - void *ctx = state; - (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL); - (yyval.expression)->set_location(yylloc); - ;} - break; - - case 96: - -/* Line 1464 of yacc.c */ -#line 745 "glsl_parser.yy" - { (yyval.n) = ast_assign; ;} - break; - - case 97: - -/* Line 1464 of yacc.c */ -#line 746 "glsl_parser.yy" - { (yyval.n) = ast_mul_assign; ;} - break; - - case 98: - -/* Line 1464 of yacc.c */ -#line 747 "glsl_parser.yy" - { (yyval.n) = ast_div_assign; ;} - break; - - case 99: - -/* Line 1464 of yacc.c */ -#line 748 "glsl_parser.yy" - { (yyval.n) = ast_mod_assign; ;} - break; - - case 100: - -/* Line 1464 of yacc.c */ -#line 749 "glsl_parser.yy" - { (yyval.n) = ast_add_assign; ;} - break; - - case 101: - -/* Line 1464 of yacc.c */ -#line 750 "glsl_parser.yy" - { (yyval.n) = ast_sub_assign; ;} - break; - - case 102: - -/* Line 1464 of yacc.c */ -#line 751 "glsl_parser.yy" - { (yyval.n) = ast_ls_assign; ;} - break; - - case 103: - -/* Line 1464 of yacc.c */ -#line 752 "glsl_parser.yy" - { (yyval.n) = ast_rs_assign; ;} - break; - - case 104: - -/* Line 1464 of yacc.c */ -#line 753 "glsl_parser.yy" - { (yyval.n) = ast_and_assign; ;} - break; - - case 105: - -/* Line 1464 of yacc.c */ -#line 754 "glsl_parser.yy" - { (yyval.n) = ast_xor_assign; ;} - break; - - case 106: - -/* Line 1464 of yacc.c */ -#line 755 "glsl_parser.yy" - { (yyval.n) = ast_or_assign; ;} - break; - - case 107: - -/* Line 1464 of yacc.c */ -#line 760 "glsl_parser.yy" - { - (yyval.expression) = (yyvsp[(1) - (1)].expression); - ;} - break; - - case 108: - -/* Line 1464 of yacc.c */ -#line 764 "glsl_parser.yy" - { - void *ctx = state; - if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) { - (yyval.expression) = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); - (yyval.expression)->set_location(yylloc); - (yyval.expression)->expressions.push_tail(& (yyvsp[(1) - (3)].expression)->link); - } else { - (yyval.expression) = (yyvsp[(1) - (3)].expression); - } - - (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link); - ;} - break; - - case 110: - -/* Line 1464 of yacc.c */ -#line 784 "glsl_parser.yy" - { - state->symbols->pop_scope(); - (yyval.node) = (yyvsp[(1) - (2)].function); - ;} - break; - - case 111: - -/* Line 1464 of yacc.c */ -#line 789 "glsl_parser.yy" - { - (yyval.node) = (yyvsp[(1) - (2)].declarator_list); - ;} - break; - - case 112: - -/* Line 1464 of yacc.c */ -#line 793 "glsl_parser.yy" - { - (yyvsp[(3) - (4)].type_specifier)->precision = (yyvsp[(2) - (4)].n); - (yyvsp[(3) - (4)].type_specifier)->is_precision_statement = true; - (yyval.node) = (yyvsp[(3) - (4)].type_specifier); - ;} - break; - - case 116: - -/* Line 1464 of yacc.c */ -#line 811 "glsl_parser.yy" - { - (yyval.function) = (yyvsp[(1) - (2)].function); - (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link); - ;} - break; - - case 117: - -/* Line 1464 of yacc.c */ -#line 816 "glsl_parser.yy" - { - (yyval.function) = (yyvsp[(1) - (3)].function); - (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link); - ;} - break; - - case 118: - -/* Line 1464 of yacc.c */ -#line 824 "glsl_parser.yy" - { - void *ctx = state; - (yyval.function) = new(ctx) ast_function(); - (yyval.function)->set_location(yylloc); - (yyval.function)->return_type = (yyvsp[(1) - (3)].fully_specified_type); - (yyval.function)->identifier = (yyvsp[(2) - (3)].identifier); - - state->symbols->add_function(new(state) ir_function((yyvsp[(2) - (3)].identifier))); - state->symbols->push_scope(); - ;} - break; - - case 119: - -/* Line 1464 of yacc.c */ -#line 838 "glsl_parser.yy" - { - void *ctx = state; - (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); - (yyval.parameter_declarator)->set_location(yylloc); - (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); - (yyval.parameter_declarator)->type->set_location(yylloc); - (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (2)].type_specifier); - (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (2)].identifier); - ;} - break; - - case 120: - -/* Line 1464 of yacc.c */ -#line 848 "glsl_parser.yy" - { - void *ctx = state; - (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); - (yyval.parameter_declarator)->set_location(yylloc); - (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); - (yyval.parameter_declarator)->type->set_location(yylloc); - (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (5)].type_specifier); - (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (5)].identifier); - (yyval.parameter_declarator)->is_array = true; - (yyval.parameter_declarator)->array_size = (yyvsp[(4) - (5)].expression); - ;} - break; - - case 121: - -/* Line 1464 of yacc.c */ -#line 863 "glsl_parser.yy" - { - (yyvsp[(1) - (3)].type_qualifier).flags.i |= (yyvsp[(2) - (3)].type_qualifier).flags.i; - - (yyval.parameter_declarator) = (yyvsp[(3) - (3)].parameter_declarator); - (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier); - ;} - break; - - case 122: - -/* Line 1464 of yacc.c */ -#line 870 "glsl_parser.yy" - { - (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator); - (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier); - ;} - break; - - case 123: - -/* Line 1464 of yacc.c */ -#line 875 "glsl_parser.yy" - { - void *ctx = state; - (yyvsp[(1) - (3)].type_qualifier).flags.i |= (yyvsp[(2) - (3)].type_qualifier).flags.i; - - (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); - (yyval.parameter_declarator)->set_location(yylloc); - (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); - (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier); - (yyval.parameter_declarator)->type->specifier = (yyvsp[(3) - (3)].type_specifier); - ;} - break; - - case 124: - -/* Line 1464 of yacc.c */ -#line 886 "glsl_parser.yy" - { - void *ctx = state; - (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator(); - (yyval.parameter_declarator)->set_location(yylloc); - (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type(); - (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier); - (yyval.parameter_declarator)->type->specifier = (yyvsp[(2) - (2)].type_specifier); - ;} - break; - - case 125: - -/* Line 1464 of yacc.c */ -#line 898 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - ;} - break; - - case 126: - -/* Line 1464 of yacc.c */ -#line 902 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.in = 1; - ;} - break; - - case 127: - -/* Line 1464 of yacc.c */ -#line 907 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.out = 1; - ;} - break; - - case 128: - -/* Line 1464 of yacc.c */ -#line 912 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.in = 1; - (yyval.type_qualifier).flags.q.out = 1; - ;} - break; - - case 131: - -/* Line 1464 of yacc.c */ -#line 926 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL); - decl->set_location(yylloc); - - (yyval.declarator_list) = (yyvsp[(1) - (3)].declarator_list); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (3)].identifier), ir_var_auto)); - ;} - break; - - case 132: - -/* Line 1464 of yacc.c */ -#line 936 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL); - decl->set_location(yylloc); - - (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (5)].identifier), ir_var_auto)); - ;} - break; - - case 133: - -/* Line 1464 of yacc.c */ -#line 946 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL); - decl->set_location(yylloc); - - (yyval.declarator_list) = (yyvsp[(1) - (6)].declarator_list); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (6)].identifier), ir_var_auto)); - ;} - break; - - case 134: - -/* Line 1464 of yacc.c */ -#line 956 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression)); - decl->set_location(yylloc); - - (yyval.declarator_list) = (yyvsp[(1) - (7)].declarator_list); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (7)].identifier), ir_var_auto)); - ;} - break; - - case 135: - -/* Line 1464 of yacc.c */ -#line 966 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression)); - decl->set_location(yylloc); - - (yyval.declarator_list) = (yyvsp[(1) - (8)].declarator_list); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (8)].identifier), ir_var_auto)); - ;} - break; - - case 136: - -/* Line 1464 of yacc.c */ -#line 976 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression)); - decl->set_location(yylloc); - - (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(3) - (5)].identifier), ir_var_auto)); - ;} - break; - - case 137: - -/* Line 1464 of yacc.c */ -#line 990 "glsl_parser.yy" - { - void *ctx = state; - /* Empty declaration list is valid. */ - (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (1)].fully_specified_type)); - (yyval.declarator_list)->set_location(yylloc); - ;} - break; - - case 138: - -/* Line 1464 of yacc.c */ -#line 997 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); - - (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (2)].fully_specified_type)); - (yyval.declarator_list)->set_location(yylloc); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - ;} - break; - - case 139: - -/* Line 1464 of yacc.c */ -#line 1006 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL); - - (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); - (yyval.declarator_list)->set_location(yylloc); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - ;} - break; - - case 140: - -/* Line 1464 of yacc.c */ -#line 1015 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL); - - (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (5)].fully_specified_type)); - (yyval.declarator_list)->set_location(yylloc); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - ;} - break; - - case 141: - -/* Line 1464 of yacc.c */ -#line 1024 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression)); - - (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (6)].fully_specified_type)); - (yyval.declarator_list)->set_location(yylloc); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - ;} - break; - - case 142: - -/* Line 1464 of yacc.c */ -#line 1033 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression)); - - (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (7)].fully_specified_type)); - (yyval.declarator_list)->set_location(yylloc); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - ;} - break; - - case 143: - -/* Line 1464 of yacc.c */ -#line 1042 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); - - (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); - (yyval.declarator_list)->set_location(yylloc); - (yyval.declarator_list)->declarations.push_tail(&decl->link); - ;} - break; - - case 144: - -/* Line 1464 of yacc.c */ -#line 1051 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL); - - (yyval.declarator_list) = new(ctx) ast_declarator_list(NULL); - (yyval.declarator_list)->set_location(yylloc); - (yyval.declarator_list)->invariant = true; - - (yyval.declarator_list)->declarations.push_tail(&decl->link); - ;} - break; - - case 145: - -/* Line 1464 of yacc.c */ -#line 1065 "glsl_parser.yy" - { - void *ctx = state; - (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); - (yyval.fully_specified_type)->set_location(yylloc); - (yyval.fully_specified_type)->specifier = (yyvsp[(1) - (1)].type_specifier); - ;} - break; - - case 146: - -/* Line 1464 of yacc.c */ -#line 1072 "glsl_parser.yy" - { - void *ctx = state; - (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type(); - (yyval.fully_specified_type)->set_location(yylloc); - (yyval.fully_specified_type)->qualifier = (yyvsp[(1) - (2)].type_qualifier); - (yyval.fully_specified_type)->specifier = (yyvsp[(2) - (2)].type_specifier); - ;} - break; - - case 147: - -/* Line 1464 of yacc.c */ -#line 1083 "glsl_parser.yy" - { - (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier); - ;} - break; - - case 149: - -/* Line 1464 of yacc.c */ -#line 1091 "glsl_parser.yy" - { - if (((yyvsp[(1) - (3)].type_qualifier).flags.i & (yyvsp[(3) - (3)].type_qualifier).flags.i) != 0) { - _mesa_glsl_error(& (yylsp[(3) - (3)]), state, - "duplicate layout qualifiers used\n"); - YYERROR; - } - - (yyval.type_qualifier).flags.i = (yyvsp[(1) - (3)].type_qualifier).flags.i | (yyvsp[(3) - (3)].type_qualifier).flags.i; - ;} - break; - - case 150: - -/* Line 1464 of yacc.c */ -#line 1110 "glsl_parser.yy" - { - bool got_one = false; - - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - - /* Layout qualifiers for AMD/ARB_conservative_depth. */ - if (!got_one && - (state->AMD_conservative_depth_enable || - state->ARB_conservative_depth_enable)) { - if (strcmp((yyvsp[(1) - (1)].identifier), "depth_any") == 0) { - got_one = true; - (yyval.type_qualifier).flags.q.depth_any = 1; - } else if (strcmp((yyvsp[(1) - (1)].identifier), "depth_greater") == 0) { - got_one = true; - (yyval.type_qualifier).flags.q.depth_greater = 1; - } else if (strcmp((yyvsp[(1) - (1)].identifier), "depth_less") == 0) { - got_one = true; - (yyval.type_qualifier).flags.q.depth_less = 1; - } else if (strcmp((yyvsp[(1) - (1)].identifier), "depth_unchanged") == 0) { - got_one = true; - (yyval.type_qualifier).flags.q.depth_unchanged = 1; - } - - if (got_one && state->AMD_conservative_depth_warn) { - _mesa_glsl_warning(& (yylsp[(1) - (1)]), state, - "GL_AMD_conservative_depth " - "layout qualifier `%s' is used\n", (yyvsp[(1) - (1)].identifier)); - } - if (got_one && state->ARB_conservative_depth_warn) { - _mesa_glsl_warning(& (yylsp[(1) - (1)]), state, - "GL_ARB_conservative_depth " - "layout qualifier `%s' is used\n", (yyvsp[(1) - (1)].identifier)); - } - } - - if (!got_one) { - _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "unrecognized layout identifier " - "`%s'\n", (yyvsp[(1) - (1)].identifier)); - YYERROR; - } - ;} - break; - - case 152: - -/* Line 1464 of yacc.c */ -#line 1210 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.smooth = 1; - ;} - break; - - case 153: - -/* Line 1464 of yacc.c */ -#line 1215 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.flat = 1; - ;} - break; - - case 154: - -/* Line 1464 of yacc.c */ -#line 1220 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.noperspective = 1; - ;} - break; - - case 155: - -/* Line 1464 of yacc.c */ -#line 1228 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.constant = 1; - ;} - break; - - case 158: - -/* Line 1464 of yacc.c */ -#line 1238 "glsl_parser.yy" - { - (yyval.type_qualifier) = (yyvsp[(1) - (2)].type_qualifier); - (yyval.type_qualifier).flags.i |= (yyvsp[(2) - (2)].type_qualifier).flags.i; - ;} - break; - - case 160: - -/* Line 1464 of yacc.c */ -#line 1244 "glsl_parser.yy" - { - (yyval.type_qualifier) = (yyvsp[(1) - (2)].type_qualifier); - (yyval.type_qualifier).flags.i |= (yyvsp[(2) - (2)].type_qualifier).flags.i; - ;} - break; - - case 161: - -/* Line 1464 of yacc.c */ -#line 1249 "glsl_parser.yy" - { - (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier); - (yyval.type_qualifier).flags.q.invariant = 1; - ;} - break; - - case 162: - -/* Line 1464 of yacc.c */ -#line 1254 "glsl_parser.yy" - { - (yyval.type_qualifier) = (yyvsp[(2) - (3)].type_qualifier); - (yyval.type_qualifier).flags.i |= (yyvsp[(3) - (3)].type_qualifier).flags.i; - (yyval.type_qualifier).flags.q.invariant = 1; - ;} - break; - - case 163: - -/* Line 1464 of yacc.c */ -#line 1260 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.invariant = 1; - ;} - break; - - case 164: - -/* Line 1464 of yacc.c */ -#line 1268 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.constant = 1; - ;} - break; - - case 165: - -/* Line 1464 of yacc.c */ -#line 1273 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.attribute = 1; - ;} - break; - - case 166: - -/* Line 1464 of yacc.c */ -#line 1278 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.varying = 1; - ;} - break; - - case 167: - -/* Line 1464 of yacc.c */ -#line 1283 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.centroid = 1; - (yyval.type_qualifier).flags.q.varying = 1; - ;} - break; - - case 168: - -/* Line 1464 of yacc.c */ -#line 1289 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.in = 1; - ;} - break; - - case 169: - -/* Line 1464 of yacc.c */ -#line 1294 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.out = 1; - ;} - break; - - case 170: - -/* Line 1464 of yacc.c */ -#line 1299 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.centroid = 1; (yyval.type_qualifier).flags.q.in = 1; - ;} - break; - - case 171: - -/* Line 1464 of yacc.c */ -#line 1304 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.centroid = 1; (yyval.type_qualifier).flags.q.out = 1; - ;} - break; - - case 172: - -/* Line 1464 of yacc.c */ -#line 1309 "glsl_parser.yy" - { - memset(& (yyval.type_qualifier), 0, sizeof((yyval.type_qualifier))); - (yyval.type_qualifier).flags.q.uniform = 1; - ;} - break; - - case 173: - -/* Line 1464 of yacc.c */ -#line 1317 "glsl_parser.yy" - { - (yyval.type_specifier) = (yyvsp[(1) - (1)].type_specifier); - ;} - break; - - case 174: - -/* Line 1464 of yacc.c */ -#line 1321 "glsl_parser.yy" - { - (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier); - (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n); - ;} - break; - - case 176: - -/* Line 1464 of yacc.c */ -#line 1330 "glsl_parser.yy" - { - (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier); - (yyval.type_specifier)->is_array = true; - (yyval.type_specifier)->array_size = NULL; - ;} - break; - - case 177: - -/* Line 1464 of yacc.c */ -#line 1336 "glsl_parser.yy" - { - (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier); - (yyval.type_specifier)->is_array = true; - (yyval.type_specifier)->array_size = (yyvsp[(3) - (4)].expression); - ;} - break; - - case 178: - -/* Line 1464 of yacc.c */ -#line 1345 "glsl_parser.yy" - { - void *ctx = state; - (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n)); - (yyval.type_specifier)->set_location(yylloc); - ;} - break; - - case 179: - -/* Line 1464 of yacc.c */ -#line 1351 "glsl_parser.yy" - { - void *ctx = state; - (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier)); - (yyval.type_specifier)->set_location(yylloc); - ;} - break; - - case 180: - -/* Line 1464 of yacc.c */ -#line 1357 "glsl_parser.yy" - { - void *ctx = state; - (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier)); - (yyval.type_specifier)->set_location(yylloc); - ;} - break; - - case 181: - -/* Line 1464 of yacc.c */ -#line 1365 "glsl_parser.yy" - { (yyval.n) = ast_void; ;} - break; - - case 182: - -/* Line 1464 of yacc.c */ -#line 1366 "glsl_parser.yy" - { (yyval.n) = ast_float; ;} - break; - - case 183: - -/* Line 1464 of yacc.c */ -#line 1367 "glsl_parser.yy" - { (yyval.n) = ast_int; ;} - break; - - case 184: - -/* Line 1464 of yacc.c */ -#line 1368 "glsl_parser.yy" - { (yyval.n) = ast_uint; ;} - break; - - case 185: - -/* Line 1464 of yacc.c */ -#line 1369 "glsl_parser.yy" - { (yyval.n) = ast_bool; ;} - break; - - case 186: - -/* Line 1464 of yacc.c */ -#line 1370 "glsl_parser.yy" - { (yyval.n) = ast_vec2; ;} - break; - - case 187: - -/* Line 1464 of yacc.c */ -#line 1371 "glsl_parser.yy" - { (yyval.n) = ast_vec3; ;} - break; - - case 188: - -/* Line 1464 of yacc.c */ -#line 1372 "glsl_parser.yy" - { (yyval.n) = ast_vec4; ;} - break; - - case 189: - -/* Line 1464 of yacc.c */ -#line 1373 "glsl_parser.yy" - { (yyval.n) = ast_bvec2; ;} - break; - - case 190: - -/* Line 1464 of yacc.c */ -#line 1374 "glsl_parser.yy" - { (yyval.n) = ast_bvec3; ;} - break; - - case 191: - -/* Line 1464 of yacc.c */ -#line 1375 "glsl_parser.yy" - { (yyval.n) = ast_bvec4; ;} - break; - - case 192: - -/* Line 1464 of yacc.c */ -#line 1376 "glsl_parser.yy" - { (yyval.n) = ast_ivec2; ;} - break; - - case 193: - -/* Line 1464 of yacc.c */ -#line 1377 "glsl_parser.yy" - { (yyval.n) = ast_ivec3; ;} - break; - - case 194: - -/* Line 1464 of yacc.c */ -#line 1378 "glsl_parser.yy" - { (yyval.n) = ast_ivec4; ;} - break; - - case 195: - -/* Line 1464 of yacc.c */ -#line 1379 "glsl_parser.yy" - { (yyval.n) = ast_uvec2; ;} - break; - - case 196: - -/* Line 1464 of yacc.c */ -#line 1380 "glsl_parser.yy" - { (yyval.n) = ast_uvec3; ;} - break; - - case 197: - -/* Line 1464 of yacc.c */ -#line 1381 "glsl_parser.yy" - { (yyval.n) = ast_uvec4; ;} - break; - - case 198: - -/* Line 1464 of yacc.c */ -#line 1382 "glsl_parser.yy" - { (yyval.n) = ast_mat2; ;} - break; - - case 199: - -/* Line 1464 of yacc.c */ -#line 1383 "glsl_parser.yy" - { (yyval.n) = ast_mat2x3; ;} - break; - - case 200: - -/* Line 1464 of yacc.c */ -#line 1384 "glsl_parser.yy" - { (yyval.n) = ast_mat2x4; ;} - break; - - case 201: - -/* Line 1464 of yacc.c */ -#line 1385 "glsl_parser.yy" - { (yyval.n) = ast_mat3x2; ;} - break; - - case 202: - -/* Line 1464 of yacc.c */ -#line 1386 "glsl_parser.yy" - { (yyval.n) = ast_mat3; ;} - break; - - case 203: - -/* Line 1464 of yacc.c */ -#line 1387 "glsl_parser.yy" - { (yyval.n) = ast_mat3x4; ;} - break; - - case 204: - -/* Line 1464 of yacc.c */ -#line 1388 "glsl_parser.yy" - { (yyval.n) = ast_mat4x2; ;} - break; - - case 205: - -/* Line 1464 of yacc.c */ -#line 1389 "glsl_parser.yy" - { (yyval.n) = ast_mat4x3; ;} - break; - - case 206: - -/* Line 1464 of yacc.c */ -#line 1390 "glsl_parser.yy" - { (yyval.n) = ast_mat4; ;} - break; - - case 207: - -/* Line 1464 of yacc.c */ -#line 1391 "glsl_parser.yy" - { (yyval.n) = ast_sampler1d; ;} - break; - - case 208: - -/* Line 1464 of yacc.c */ -#line 1392 "glsl_parser.yy" - { (yyval.n) = ast_sampler2d; ;} - break; - - case 209: - -/* Line 1464 of yacc.c */ -#line 1393 "glsl_parser.yy" - { (yyval.n) = ast_sampler2drect; ;} - break; - - case 210: - -/* Line 1464 of yacc.c */ -#line 1394 "glsl_parser.yy" - { (yyval.n) = ast_sampler3d; ;} - break; - - case 211: - -/* Line 1464 of yacc.c */ -#line 1395 "glsl_parser.yy" - { (yyval.n) = ast_samplercube; ;} - break; - - case 212: - -/* Line 1464 of yacc.c */ -#line 1396 "glsl_parser.yy" - { (yyval.n) = ast_samplerexternaloes; ;} - break; - - case 213: - -/* Line 1464 of yacc.c */ -#line 1397 "glsl_parser.yy" - { (yyval.n) = ast_sampler1dshadow; ;} - break; - - case 214: - -/* Line 1464 of yacc.c */ -#line 1398 "glsl_parser.yy" - { (yyval.n) = ast_sampler2dshadow; ;} - break; - - case 215: - -/* Line 1464 of yacc.c */ -#line 1399 "glsl_parser.yy" - { (yyval.n) = ast_sampler2drectshadow; ;} - break; - - case 216: - -/* Line 1464 of yacc.c */ -#line 1400 "glsl_parser.yy" - { (yyval.n) = ast_samplercubeshadow; ;} - break; - - case 217: - -/* Line 1464 of yacc.c */ -#line 1401 "glsl_parser.yy" - { (yyval.n) = ast_sampler1darray; ;} - break; - - case 218: - -/* Line 1464 of yacc.c */ -#line 1402 "glsl_parser.yy" - { (yyval.n) = ast_sampler2darray; ;} - break; - - case 219: - -/* Line 1464 of yacc.c */ -#line 1403 "glsl_parser.yy" - { (yyval.n) = ast_sampler1darrayshadow; ;} - break; - - case 220: - -/* Line 1464 of yacc.c */ -#line 1404 "glsl_parser.yy" - { (yyval.n) = ast_sampler2darrayshadow; ;} - break; - - case 221: - -/* Line 1464 of yacc.c */ -#line 1405 "glsl_parser.yy" - { (yyval.n) = ast_isampler1d; ;} - break; - - case 222: - -/* Line 1464 of yacc.c */ -#line 1406 "glsl_parser.yy" - { (yyval.n) = ast_isampler2d; ;} - break; - - case 223: - -/* Line 1464 of yacc.c */ -#line 1407 "glsl_parser.yy" - { (yyval.n) = ast_isampler3d; ;} - break; - - case 224: - -/* Line 1464 of yacc.c */ -#line 1408 "glsl_parser.yy" - { (yyval.n) = ast_isamplercube; ;} - break; - - case 225: - -/* Line 1464 of yacc.c */ -#line 1409 "glsl_parser.yy" - { (yyval.n) = ast_isampler1darray; ;} - break; - - case 226: - -/* Line 1464 of yacc.c */ -#line 1410 "glsl_parser.yy" - { (yyval.n) = ast_isampler2darray; ;} - break; - - case 227: - -/* Line 1464 of yacc.c */ -#line 1411 "glsl_parser.yy" - { (yyval.n) = ast_usampler1d; ;} - break; - - case 228: - -/* Line 1464 of yacc.c */ -#line 1412 "glsl_parser.yy" - { (yyval.n) = ast_usampler2d; ;} - break; - - case 229: - -/* Line 1464 of yacc.c */ -#line 1413 "glsl_parser.yy" - { (yyval.n) = ast_usampler3d; ;} - break; - - case 230: - -/* Line 1464 of yacc.c */ -#line 1414 "glsl_parser.yy" - { (yyval.n) = ast_usamplercube; ;} - break; - - case 231: - -/* Line 1464 of yacc.c */ -#line 1415 "glsl_parser.yy" - { (yyval.n) = ast_usampler1darray; ;} - break; - - case 232: - -/* Line 1464 of yacc.c */ -#line 1416 "glsl_parser.yy" - { (yyval.n) = ast_usampler2darray; ;} - break; - - case 233: - -/* Line 1464 of yacc.c */ -#line 1420 "glsl_parser.yy" - { - if (!state->es_shader && state->language_version < 130) - _mesa_glsl_error(& (yylsp[(1) - (1)]), state, - "precision qualifier forbidden " - "in %s (1.30 or later " - "required)\n", - state->version_string); - - (yyval.n) = ast_precision_high; - ;} - break; - - case 234: - -/* Line 1464 of yacc.c */ -#line 1430 "glsl_parser.yy" - { - if (!state->es_shader && state->language_version < 130) - _mesa_glsl_error(& (yylsp[(1) - (1)]), state, - "precision qualifier forbidden " - "in %s (1.30 or later " - "required)\n", - state->version_string); - - (yyval.n) = ast_precision_medium; - ;} - break; - - case 235: - -/* Line 1464 of yacc.c */ -#line 1440 "glsl_parser.yy" - { - if (!state->es_shader && state->language_version < 130) - _mesa_glsl_error(& (yylsp[(1) - (1)]), state, - "precision qualifier forbidden " - "in %s (1.30 or later " - "required)\n", - state->version_string); - - (yyval.n) = ast_precision_low; - ;} - break; - - case 236: - -/* Line 1464 of yacc.c */ -#line 1454 "glsl_parser.yy" - { - void *ctx = state; - (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node)); - (yyval.struct_specifier)->set_location(yylloc); - state->symbols->add_type((yyvsp[(2) - (5)].identifier), glsl_type::void_type); - ;} - break; - - case 237: - -/* Line 1464 of yacc.c */ -#line 1461 "glsl_parser.yy" - { - void *ctx = state; - (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node)); - (yyval.struct_specifier)->set_location(yylloc); - ;} - break; - - case 238: - -/* Line 1464 of yacc.c */ -#line 1470 "glsl_parser.yy" - { - (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].declarator_list); - (yyvsp[(1) - (1)].declarator_list)->link.self_link(); - ;} - break; - - case 239: - -/* Line 1464 of yacc.c */ -#line 1475 "glsl_parser.yy" - { - (yyval.node) = (ast_node *) (yyvsp[(1) - (2)].node); - (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link); - ;} - break; - - case 240: - -/* Line 1464 of yacc.c */ -#line 1483 "glsl_parser.yy" - { - void *ctx = state; - ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); - type->set_location(yylloc); - - type->specifier = (yyvsp[(1) - (3)].type_specifier); - (yyval.declarator_list) = new(ctx) ast_declarator_list(type); - (yyval.declarator_list)->set_location(yylloc); - - (yyval.declarator_list)->declarations.push_degenerate_list_at_head(& (yyvsp[(2) - (3)].declaration)->link); - ;} - break; - - case 241: - -/* Line 1464 of yacc.c */ -#line 1498 "glsl_parser.yy" - { - (yyval.declaration) = (yyvsp[(1) - (1)].declaration); - (yyvsp[(1) - (1)].declaration)->link.self_link(); - ;} - break; - - case 242: - -/* Line 1464 of yacc.c */ -#line 1503 "glsl_parser.yy" - { - (yyval.declaration) = (yyvsp[(1) - (3)].declaration); - (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link); - ;} - break; - - case 243: - -/* Line 1464 of yacc.c */ -#line 1511 "glsl_parser.yy" - { - void *ctx = state; - (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL); - (yyval.declaration)->set_location(yylloc); - state->symbols->add_variable(new(state) ir_variable(NULL, (yyvsp[(1) - (1)].identifier), ir_var_auto)); - ;} - break; - - case 244: - -/* Line 1464 of yacc.c */ -#line 1518 "glsl_parser.yy" - { - void *ctx = state; - (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL); - (yyval.declaration)->set_location(yylloc); - ;} - break; - - case 247: - -/* Line 1464 of yacc.c */ -#line 1536 "glsl_parser.yy" - { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} - break; - - case 255: - -/* Line 1464 of yacc.c */ -#line 1551 "glsl_parser.yy" - { - void *ctx = state; - (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL); - (yyval.compound_statement)->set_location(yylloc); - ;} - break; - - case 256: - -/* Line 1464 of yacc.c */ -#line 1557 "glsl_parser.yy" - { - state->symbols->push_scope(); - ;} - break; - - case 257: - -/* Line 1464 of yacc.c */ -#line 1561 "glsl_parser.yy" - { - void *ctx = state; - (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(3) - (4)].node)); - (yyval.compound_statement)->set_location(yylloc); - state->symbols->pop_scope(); - ;} - break; - - case 258: - -/* Line 1464 of yacc.c */ -#line 1570 "glsl_parser.yy" - { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;} - break; - - case 260: - -/* Line 1464 of yacc.c */ -#line 1576 "glsl_parser.yy" - { - void *ctx = state; - (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL); - (yyval.compound_statement)->set_location(yylloc); - ;} - break; - - case 261: - -/* Line 1464 of yacc.c */ -#line 1582 "glsl_parser.yy" - { - void *ctx = state; - (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node)); - (yyval.compound_statement)->set_location(yylloc); - ;} - break; - - case 262: - -/* Line 1464 of yacc.c */ -#line 1591 "glsl_parser.yy" - { - if ((yyvsp[(1) - (1)].node) == NULL) { - _mesa_glsl_error(& (yylsp[(1) - (1)]), state, " statement\n"); - assert((yyvsp[(1) - (1)].node) != NULL); - } - - (yyval.node) = (yyvsp[(1) - (1)].node); - (yyval.node)->link.self_link(); - ;} - break; - - case 263: - -/* Line 1464 of yacc.c */ -#line 1601 "glsl_parser.yy" - { - if ((yyvsp[(2) - (2)].node) == NULL) { - _mesa_glsl_error(& (yylsp[(2) - (2)]), state, " statement\n"); - assert((yyvsp[(2) - (2)].node) != NULL); - } - (yyval.node) = (yyvsp[(1) - (2)].node); - (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].node)->link); - ;} - break; - - case 264: - -/* Line 1464 of yacc.c */ -#line 1613 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_expression_statement(NULL); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 265: - -/* Line 1464 of yacc.c */ -#line 1619 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression)); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 266: - -/* Line 1464 of yacc.c */ -#line 1628 "glsl_parser.yy" - { - (yyval.node) = new(state) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].selection_rest_statement).then_statement, - (yyvsp[(5) - (5)].selection_rest_statement).else_statement); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 267: - -/* Line 1464 of yacc.c */ -#line 1637 "glsl_parser.yy" - { - (yyval.selection_rest_statement).then_statement = (yyvsp[(1) - (3)].node); - (yyval.selection_rest_statement).else_statement = (yyvsp[(3) - (3)].node); - ;} - break; - - case 268: - -/* Line 1464 of yacc.c */ -#line 1642 "glsl_parser.yy" - { - (yyval.selection_rest_statement).then_statement = (yyvsp[(1) - (1)].node); - (yyval.selection_rest_statement).else_statement = NULL; - ;} - break; - - case 269: - -/* Line 1464 of yacc.c */ -#line 1650 "glsl_parser.yy" - { - (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].expression); - ;} - break; - - case 270: - -/* Line 1464 of yacc.c */ -#line 1654 "glsl_parser.yy" - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression)); - ast_declarator_list *declarator = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type)); - decl->set_location(yylloc); - declarator->set_location(yylloc); - - declarator->declarations.push_tail(&decl->link); - (yyval.node) = declarator; - ;} - break; - - case 271: - -/* Line 1464 of yacc.c */ -#line 1672 "glsl_parser.yy" - { - (yyval.node) = new(state) ast_switch_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].switch_body)); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 272: - -/* Line 1464 of yacc.c */ -#line 1680 "glsl_parser.yy" - { - (yyval.switch_body) = new(state) ast_switch_body(NULL); - (yyval.switch_body)->set_location(yylloc); - ;} - break; - - case 273: - -/* Line 1464 of yacc.c */ -#line 1685 "glsl_parser.yy" - { - (yyval.switch_body) = new(state) ast_switch_body((yyvsp[(2) - (3)].case_statement_list)); - (yyval.switch_body)->set_location(yylloc); - ;} - break; - - case 274: - -/* Line 1464 of yacc.c */ -#line 1693 "glsl_parser.yy" - { - (yyval.case_label) = new(state) ast_case_label((yyvsp[(2) - (3)].expression)); - (yyval.case_label)->set_location(yylloc); - ;} - break; - - case 275: - -/* Line 1464 of yacc.c */ -#line 1698 "glsl_parser.yy" - { - (yyval.case_label) = new(state) ast_case_label(NULL); - (yyval.case_label)->set_location(yylloc); - ;} - break; - - case 276: - -/* Line 1464 of yacc.c */ -#line 1706 "glsl_parser.yy" - { - ast_case_label_list *labels = new(state) ast_case_label_list(); - - labels->labels.push_tail(& (yyvsp[(1) - (1)].case_label)->link); - (yyval.case_label_list) = labels; - (yyval.case_label_list)->set_location(yylloc); - ;} - break; - - case 277: - -/* Line 1464 of yacc.c */ -#line 1714 "glsl_parser.yy" - { - (yyval.case_label_list) = (yyvsp[(1) - (2)].case_label_list); - (yyval.case_label_list)->labels.push_tail(& (yyvsp[(2) - (2)].case_label)->link); - ;} - break; - - case 278: - -/* Line 1464 of yacc.c */ -#line 1722 "glsl_parser.yy" - { - ast_case_statement *stmts = new(state) ast_case_statement((yyvsp[(1) - (2)].case_label_list)); - stmts->set_location(yylloc); - - stmts->stmts.push_tail(& (yyvsp[(2) - (2)].node)->link); - (yyval.case_statement) = stmts; - ;} - break; - - case 279: - -/* Line 1464 of yacc.c */ -#line 1730 "glsl_parser.yy" - { - (yyval.case_statement) = (yyvsp[(1) - (2)].case_statement); - (yyval.case_statement)->stmts.push_tail(& (yyvsp[(2) - (2)].node)->link); - ;} - break; - - case 280: - -/* Line 1464 of yacc.c */ -#line 1738 "glsl_parser.yy" - { - ast_case_statement_list *cases= new(state) ast_case_statement_list(); - cases->set_location(yylloc); - - cases->cases.push_tail(& (yyvsp[(1) - (1)].case_statement)->link); - (yyval.case_statement_list) = cases; - ;} - break; - - case 281: - -/* Line 1464 of yacc.c */ -#line 1746 "glsl_parser.yy" - { - (yyval.case_statement_list) = (yyvsp[(1) - (2)].case_statement_list); - (yyval.case_statement_list)->cases.push_tail(& (yyvsp[(2) - (2)].case_statement)->link); - ;} - break; - - case 282: - -/* Line 1464 of yacc.c */ -#line 1754 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, - NULL, (yyvsp[(3) - (5)].node), NULL, (yyvsp[(5) - (5)].node)); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 283: - -/* Line 1464 of yacc.c */ -#line 1761 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, - NULL, (yyvsp[(5) - (7)].expression), NULL, (yyvsp[(2) - (7)].node)); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 284: - -/* Line 1464 of yacc.c */ -#line 1768 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, - (yyvsp[(3) - (6)].node), (yyvsp[(4) - (6)].for_rest_statement).cond, (yyvsp[(4) - (6)].for_rest_statement).rest, (yyvsp[(6) - (6)].node)); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 288: - -/* Line 1464 of yacc.c */ -#line 1784 "glsl_parser.yy" - { - (yyval.node) = NULL; - ;} - break; - - case 289: - -/* Line 1464 of yacc.c */ -#line 1791 "glsl_parser.yy" - { - (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node); - (yyval.for_rest_statement).rest = NULL; - ;} - break; - - case 290: - -/* Line 1464 of yacc.c */ -#line 1796 "glsl_parser.yy" - { - (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node); - (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression); - ;} - break; - - case 291: - -/* Line 1464 of yacc.c */ -#line 1805 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 292: - -/* Line 1464 of yacc.c */ -#line 1811 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 293: - -/* Line 1464 of yacc.c */ -#line 1817 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 294: - -/* Line 1464 of yacc.c */ -#line 1823 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression)); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 295: - -/* Line 1464 of yacc.c */ -#line 1829 "glsl_parser.yy" - { - void *ctx = state; - (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); - (yyval.node)->set_location(yylloc); - ;} - break; - - case 296: - -/* Line 1464 of yacc.c */ -#line 1837 "glsl_parser.yy" - { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;} - break; - - case 297: - -/* Line 1464 of yacc.c */ -#line 1838 "glsl_parser.yy" - { (yyval.node) = (yyvsp[(1) - (1)].node); ;} - break; - - case 298: - -/* Line 1464 of yacc.c */ -#line 1839 "glsl_parser.yy" - { (yyval.node) = NULL; ;} - break; - - case 299: - -/* Line 1464 of yacc.c */ -#line 1844 "glsl_parser.yy" - { - void *ctx = state; - (yyval.function_definition) = new(ctx) ast_function_definition(); - (yyval.function_definition)->set_location(yylloc); - (yyval.function_definition)->prototype = (yyvsp[(1) - (2)].function); - (yyval.function_definition)->body = (yyvsp[(2) - (2)].compound_statement); - - state->symbols->pop_scope(); - ;} - break; - - - -/* Line 1464 of yacc.c */ -#line 5424 "glsl_parser.cpp" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - *++yylsp = yyloc; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (&yylloc, state, YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (&yylloc, state, yymsg); - } - else - { - yyerror (&yylloc, state, YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - yyerror_range[1] = yylloc; - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval, &yylloc, state); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - yyerror_range[1] = yylsp[1-yylen]; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - yyerror_range[1] = *yylsp; - yydestruct ("Error: popping", - yystos[yystate], yyvsp, yylsp, state); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - *++yyvsp = yylval; - - yyerror_range[2] = yylloc; - /* Using YYLLOC is tempting, but would change the location of - the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); - *++yylsp = yyloc; - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined(yyoverflow) || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (&yylloc, state, YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, state); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, yylsp, state); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_parser.h b/reactos/dll/opengl/mesa/src/glsl/glsl_parser.h deleted file mode 100644 index 485f3ba7fdc..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_parser.h +++ /dev/null @@ -1,306 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ATTRIBUTE = 258, - CONST_TOK = 259, - BOOL_TOK = 260, - FLOAT_TOK = 261, - INT_TOK = 262, - UINT_TOK = 263, - BREAK = 264, - CONTINUE = 265, - DO = 266, - ELSE = 267, - FOR = 268, - IF = 269, - DISCARD = 270, - RETURN = 271, - SWITCH = 272, - CASE = 273, - DEFAULT = 274, - BVEC2 = 275, - BVEC3 = 276, - BVEC4 = 277, - IVEC2 = 278, - IVEC3 = 279, - IVEC4 = 280, - UVEC2 = 281, - UVEC3 = 282, - UVEC4 = 283, - VEC2 = 284, - VEC3 = 285, - VEC4 = 286, - CENTROID = 287, - IN_TOK = 288, - OUT_TOK = 289, - INOUT_TOK = 290, - UNIFORM = 291, - VARYING = 292, - NOPERSPECTIVE = 293, - FLAT = 294, - SMOOTH = 295, - MAT2X2 = 296, - MAT2X3 = 297, - MAT2X4 = 298, - MAT3X2 = 299, - MAT3X3 = 300, - MAT3X4 = 301, - MAT4X2 = 302, - MAT4X3 = 303, - MAT4X4 = 304, - SAMPLER1D = 305, - SAMPLER2D = 306, - SAMPLER3D = 307, - SAMPLERCUBE = 308, - SAMPLER1DSHADOW = 309, - SAMPLER2DSHADOW = 310, - SAMPLERCUBESHADOW = 311, - SAMPLER1DARRAY = 312, - SAMPLER2DARRAY = 313, - SAMPLER1DARRAYSHADOW = 314, - SAMPLER2DARRAYSHADOW = 315, - ISAMPLER1D = 316, - ISAMPLER2D = 317, - ISAMPLER3D = 318, - ISAMPLERCUBE = 319, - ISAMPLER1DARRAY = 320, - ISAMPLER2DARRAY = 321, - USAMPLER1D = 322, - USAMPLER2D = 323, - USAMPLER3D = 324, - USAMPLERCUBE = 325, - USAMPLER1DARRAY = 326, - USAMPLER2DARRAY = 327, - SAMPLEREXTERNALOES = 328, - STRUCT = 329, - VOID_TOK = 330, - WHILE = 331, - IDENTIFIER = 332, - TYPE_IDENTIFIER = 333, - NEW_IDENTIFIER = 334, - FLOATCONSTANT = 335, - INTCONSTANT = 336, - UINTCONSTANT = 337, - BOOLCONSTANT = 338, - FIELD_SELECTION = 339, - LEFT_OP = 340, - RIGHT_OP = 341, - INC_OP = 342, - DEC_OP = 343, - LE_OP = 344, - GE_OP = 345, - EQ_OP = 346, - NE_OP = 347, - AND_OP = 348, - OR_OP = 349, - XOR_OP = 350, - MUL_ASSIGN = 351, - DIV_ASSIGN = 352, - ADD_ASSIGN = 353, - MOD_ASSIGN = 354, - LEFT_ASSIGN = 355, - RIGHT_ASSIGN = 356, - AND_ASSIGN = 357, - XOR_ASSIGN = 358, - OR_ASSIGN = 359, - SUB_ASSIGN = 360, - INVARIANT = 361, - LOWP = 362, - MEDIUMP = 363, - HIGHP = 364, - SUPERP = 365, - PRECISION = 366, - VERSION_TOK = 367, - EXTENSION = 368, - LINE = 369, - COLON = 370, - EOL = 371, - INTERFACE = 372, - OUTPUT = 373, - PRAGMA_DEBUG_ON = 374, - PRAGMA_DEBUG_OFF = 375, - PRAGMA_OPTIMIZE_ON = 376, - PRAGMA_OPTIMIZE_OFF = 377, - PRAGMA_INVARIANT_ALL = 378, - LAYOUT_TOK = 379, - ASM = 380, - CLASS = 381, - UNION = 382, - ENUM = 383, - TYPEDEF = 384, - TEMPLATE = 385, - THIS = 386, - PACKED_TOK = 387, - GOTO = 388, - INLINE_TOK = 389, - NOINLINE = 390, - VOLATILE = 391, - PUBLIC_TOK = 392, - STATIC = 393, - EXTERN = 394, - EXTERNAL = 395, - LONG_TOK = 396, - SHORT_TOK = 397, - DOUBLE_TOK = 398, - HALF = 399, - FIXED_TOK = 400, - UNSIGNED = 401, - INPUT_TOK = 402, - OUPTUT = 403, - HVEC2 = 404, - HVEC3 = 405, - HVEC4 = 406, - DVEC2 = 407, - DVEC3 = 408, - DVEC4 = 409, - FVEC2 = 410, - FVEC3 = 411, - FVEC4 = 412, - SAMPLER2DRECT = 413, - SAMPLER3DRECT = 414, - SAMPLER2DRECTSHADOW = 415, - SIZEOF = 416, - CAST = 417, - NAMESPACE = 418, - USING = 419, - ERROR_TOK = 420, - COMMON = 421, - PARTITION = 422, - ACTIVE = 423, - SAMPLERBUFFER = 424, - FILTER = 425, - IMAGE1D = 426, - IMAGE2D = 427, - IMAGE3D = 428, - IMAGECUBE = 429, - IMAGE1DARRAY = 430, - IMAGE2DARRAY = 431, - IIMAGE1D = 432, - IIMAGE2D = 433, - IIMAGE3D = 434, - IIMAGECUBE = 435, - IIMAGE1DARRAY = 436, - IIMAGE2DARRAY = 437, - UIMAGE1D = 438, - UIMAGE2D = 439, - UIMAGE3D = 440, - UIMAGECUBE = 441, - UIMAGE1DARRAY = 442, - UIMAGE2DARRAY = 443, - IMAGE1DSHADOW = 444, - IMAGE2DSHADOW = 445, - IMAGEBUFFER = 446, - IIMAGEBUFFER = 447, - UIMAGEBUFFER = 448, - IMAGE1DARRAYSHADOW = 449, - IMAGE2DARRAYSHADOW = 450, - ROW_MAJOR = 451 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ - -/* Line 1685 of yacc.c */ -#line 58 "glsl_parser.yy" - - int n; - float real; - char *identifier; - - struct ast_type_qualifier type_qualifier; - - ast_node *node; - ast_type_specifier *type_specifier; - ast_fully_specified_type *fully_specified_type; - ast_function *function; - ast_parameter_declarator *parameter_declarator; - ast_function_definition *function_definition; - ast_compound_statement *compound_statement; - ast_expression *expression; - ast_declarator_list *declarator_list; - ast_struct_specifier *struct_specifier; - ast_declaration *declaration; - ast_switch_body *switch_body; - ast_case_label *case_label; - ast_case_label_list *case_label_list; - ast_case_statement *case_statement; - ast_case_statement_list *case_statement_list; - - struct { - ast_node *cond; - ast_expression *rest; - } for_rest_statement; - - struct { - ast_node *then_statement; - ast_node *else_statement; - } selection_rest_statement; - - - -/* Line 1685 of yacc.c */ -#line 284 "glsl_parser.h" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - - diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_parser.yy b/reactos/dll/opengl/mesa/src/glsl/glsl_parser.yy deleted file mode 100644 index d5e85abc021..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_parser.yy +++ /dev/null @@ -1,1853 +0,0 @@ -%{ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include -#include -#include - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" - -#define YYLEX_PARAM state->scanner - -#undef yyerror - -static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) -{ - _mesa_glsl_error(loc, st, "%s", msg); -} -%} - -%pure-parser -%error-verbose - -%locations -%initial-action { - @$.first_line = 1; - @$.first_column = 1; - @$.last_line = 1; - @$.last_column = 1; - @$.source = 0; -} - -%lex-param {void *scanner} -%parse-param {struct _mesa_glsl_parse_state *state} - -%union { - int n; - float real; - char *identifier; - - struct ast_type_qualifier type_qualifier; - - ast_node *node; - ast_type_specifier *type_specifier; - ast_fully_specified_type *fully_specified_type; - ast_function *function; - ast_parameter_declarator *parameter_declarator; - ast_function_definition *function_definition; - ast_compound_statement *compound_statement; - ast_expression *expression; - ast_declarator_list *declarator_list; - ast_struct_specifier *struct_specifier; - ast_declaration *declaration; - ast_switch_body *switch_body; - ast_case_label *case_label; - ast_case_label_list *case_label_list; - ast_case_statement *case_statement; - ast_case_statement_list *case_statement_list; - - struct { - ast_node *cond; - ast_expression *rest; - } for_rest_statement; - - struct { - ast_node *then_statement; - ast_node *else_statement; - } selection_rest_statement; -} - -%token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK -%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT -%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 -%token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING -%token NOPERSPECTIVE FLAT SMOOTH -%token MAT2X2 MAT2X3 MAT2X4 -%token MAT3X2 MAT3X3 MAT3X4 -%token MAT4X2 MAT4X3 MAT4X4 -%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW -%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW -%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE -%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D -%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY -%token SAMPLEREXTERNALOES -%token STRUCT VOID_TOK WHILE -%token IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER -%type any_identifier -%token FLOATCONSTANT -%token INTCONSTANT UINTCONSTANT BOOLCONSTANT -%token FIELD_SELECTION -%token LEFT_OP RIGHT_OP -%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP -%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN -%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN -%token SUB_ASSIGN -%token INVARIANT -%token LOWP MEDIUMP HIGHP SUPERP PRECISION - -%token VERSION_TOK EXTENSION LINE COLON EOL INTERFACE OUTPUT -%token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF -%token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF -%token PRAGMA_INVARIANT_ALL -%token LAYOUT_TOK - - /* Reserved words that are not actually used in the grammar. - */ -%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO -%token INLINE_TOK NOINLINE VOLATILE PUBLIC_TOK STATIC EXTERN EXTERNAL -%token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK OUPTUT -%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4 -%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW -%token SIZEOF CAST NAMESPACE USING - -%token ERROR_TOK - -%token COMMON PARTITION ACTIVE SAMPLERBUFFER FILTER -%token IMAGE1D IMAGE2D IMAGE3D IMAGECUBE IMAGE1DARRAY IMAGE2DARRAY -%token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY -%token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGECUBE UIMAGE1DARRAY UIMAGE2DARRAY -%token IMAGE1DSHADOW IMAGE2DSHADOW IMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER -%token IMAGE1DARRAYSHADOW IMAGE2DARRAYSHADOW -%token ROW_MAJOR - -%type variable_identifier -%type statement -%type statement_list -%type simple_statement -%type precision_qualifier -%type type_qualifier -%type storage_qualifier -%type interpolation_qualifier -%type layout_qualifier -%type layout_qualifier_id_list layout_qualifier_id -%type type_specifier -%type type_specifier_no_prec -%type type_specifier_nonarray -%type basic_type_specifier_nonarray -%type fully_specified_type -%type function_prototype -%type function_header -%type function_header_with_parameters -%type function_declarator -%type parameter_declarator -%type parameter_declaration -%type parameter_qualifier -%type parameter_type_qualifier -%type parameter_type_specifier -%type function_definition -%type compound_statement_no_new_scope -%type compound_statement -%type statement_no_new_scope -%type expression_statement -%type expression -%type primary_expression -%type assignment_expression -%type conditional_expression -%type logical_or_expression -%type logical_xor_expression -%type logical_and_expression -%type inclusive_or_expression -%type exclusive_or_expression -%type and_expression -%type equality_expression -%type relational_expression -%type shift_expression -%type additive_expression -%type multiplicative_expression -%type unary_expression -%type constant_expression -%type integer_expression -%type postfix_expression -%type function_call_header_with_parameters -%type function_call_header_no_parameters -%type function_call_header -%type function_call_generic -%type function_call_or_method -%type function_call -%type method_call_generic -%type method_call_header_with_parameters -%type method_call_header_no_parameters -%type method_call_header -%type assignment_operator -%type unary_operator -%type function_identifier -%type external_declaration -%type init_declarator_list -%type single_declaration -%type initializer -%type declaration -%type declaration_statement -%type jump_statement -%type struct_specifier -%type struct_declaration_list -%type struct_declaration -%type struct_declarator -%type struct_declarator_list -%type selection_statement -%type selection_rest_statement -%type switch_statement -%type switch_body -%type case_label_list -%type case_label -%type case_statement -%type case_statement_list -%type iteration_statement -%type condition -%type conditionopt -%type for_init_statement -%type for_rest_statement -%% - -translation_unit: - version_statement extension_statement_list - { - _mesa_glsl_initialize_types(state); - } - external_declaration_list - { - delete state->symbols; - state->symbols = new(ralloc_parent(state)) glsl_symbol_table; - _mesa_glsl_initialize_types(state); - } - ; - -version_statement: - /* blank - no #version specified: defaults are already set */ - | VERSION_TOK INTCONSTANT EOL - { - bool supported = false; - - switch ($2) { - case 100: - state->es_shader = true; - supported = state->Const.GLSL_100ES; - break; - case 110: - supported = state->Const.GLSL_110; - break; - case 120: - supported = state->Const.GLSL_120; - break; - case 130: - supported = state->Const.GLSL_130; - break; - default: - supported = false; - break; - } - - state->language_version = $2; - state->version_string = - ralloc_asprintf(state, "GLSL%s %d.%02d", - state->es_shader ? " ES" : "", - state->language_version / 100, - state->language_version % 100); - - if (!supported) { - _mesa_glsl_error(& @2, state, "%s is not supported. " - "Supported versions are: %s\n", - state->version_string, - state->supported_version_string); - } - } - ; - -pragma_statement: - PRAGMA_DEBUG_ON EOL - | PRAGMA_DEBUG_OFF EOL - | PRAGMA_OPTIMIZE_ON EOL - | PRAGMA_OPTIMIZE_OFF EOL - | PRAGMA_INVARIANT_ALL EOL - { - if (state->language_version < 120) { - _mesa_glsl_warning(& @1, state, - "pragma `invariant(all)' not supported in %s", - state->version_string); - } else { - state->all_invariant = true; - } - } - ; - -extension_statement_list: - - | extension_statement_list extension_statement - ; - -any_identifier: - IDENTIFIER - | TYPE_IDENTIFIER - | NEW_IDENTIFIER - ; - -extension_statement: - EXTENSION any_identifier COLON any_identifier EOL - { - if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) { - YYERROR; - } - } - ; - -external_declaration_list: - external_declaration - { - /* FINISHME: The NULL test is required because pragmas are set to - * FINISHME: NULL. (See production rule for external_declaration.) - */ - if ($1 != NULL) - state->translation_unit.push_tail(& $1->link); - } - | external_declaration_list external_declaration - { - /* FINISHME: The NULL test is required because pragmas are set to - * FINISHME: NULL. (See production rule for external_declaration.) - */ - if ($2 != NULL) - state->translation_unit.push_tail(& $2->link); - } - ; - -variable_identifier: - IDENTIFIER - | NEW_IDENTIFIER - ; - -primary_expression: - variable_identifier - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.identifier = $1; - } - | INTCONSTANT - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.int_constant = $1; - } - | UINTCONSTANT - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.uint_constant = $1; - } - | FLOATCONSTANT - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.float_constant = $1; - } - | BOOLCONSTANT - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.bool_constant = $1; - } - | '(' expression ')' - { - $$ = $2; - } - ; - -postfix_expression: - primary_expression - | postfix_expression '[' integer_expression ']' - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL); - $$->set_location(yylloc); - } - | function_call - { - $$ = $1; - } - | postfix_expression '.' any_identifier - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL); - $$->set_location(yylloc); - $$->primary_expression.identifier = $3; - } - | postfix_expression INC_OP - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL); - $$->set_location(yylloc); - } - | postfix_expression DEC_OP - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL); - $$->set_location(yylloc); - } - ; - -integer_expression: - expression - ; - -function_call: - function_call_or_method - ; - -function_call_or_method: - function_call_generic - | postfix_expression '.' method_call_generic - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL); - $$->set_location(yylloc); - } - ; - -function_call_generic: - function_call_header_with_parameters ')' - | function_call_header_no_parameters ')' - ; - -function_call_header_no_parameters: - function_call_header VOID_TOK - | function_call_header - ; - -function_call_header_with_parameters: - function_call_header assignment_expression - { - $$ = $1; - $$->set_location(yylloc); - $$->expressions.push_tail(& $2->link); - } - | function_call_header_with_parameters ',' assignment_expression - { - $$ = $1; - $$->set_location(yylloc); - $$->expressions.push_tail(& $3->link); - } - ; - - // Grammar Note: Constructors look like functions, but lexical - // analysis recognized most of them as keywords. They are now - // recognized through "type_specifier". -function_call_header: - function_identifier '(' - ; - -function_identifier: - type_specifier - { - void *ctx = state; - $$ = new(ctx) ast_function_expression($1); - $$->set_location(yylloc); - } - | variable_identifier - { - void *ctx = state; - ast_expression *callee = new(ctx) ast_expression($1); - $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); - } - | FIELD_SELECTION - { - void *ctx = state; - ast_expression *callee = new(ctx) ast_expression($1); - $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); - } - ; - -method_call_generic: - method_call_header_with_parameters ')' - | method_call_header_no_parameters ')' - ; - -method_call_header_no_parameters: - method_call_header VOID_TOK - | method_call_header - ; - -method_call_header_with_parameters: - method_call_header assignment_expression - { - $$ = $1; - $$->set_location(yylloc); - $$->expressions.push_tail(& $2->link); - } - | method_call_header_with_parameters ',' assignment_expression - { - $$ = $1; - $$->set_location(yylloc); - $$->expressions.push_tail(& $3->link); - } - ; - - // Grammar Note: Constructors look like methods, but lexical - // analysis recognized most of them as keywords. They are now - // recognized through "type_specifier". -method_call_header: - variable_identifier '(' - { - void *ctx = state; - ast_expression *callee = new(ctx) ast_expression($1); - $$ = new(ctx) ast_function_expression(callee); - $$->set_location(yylloc); - } - ; - - // Grammar Note: No traditional style type casts. -unary_expression: - postfix_expression - | INC_OP unary_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL); - $$->set_location(yylloc); - } - | DEC_OP unary_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL); - $$->set_location(yylloc); - } - | unary_operator unary_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression($1, $2, NULL, NULL); - $$->set_location(yylloc); - } - ; - - // Grammar Note: No '*' or '&' unary ops. Pointers are not supported. -unary_operator: - '+' { $$ = ast_plus; } - | '-' { $$ = ast_neg; } - | '!' { $$ = ast_logic_not; } - | '~' { $$ = ast_bit_not; } - ; - -multiplicative_expression: - unary_expression - | multiplicative_expression '*' unary_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3); - $$->set_location(yylloc); - } - | multiplicative_expression '/' unary_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_div, $1, $3); - $$->set_location(yylloc); - } - | multiplicative_expression '%' unary_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3); - $$->set_location(yylloc); - } - ; - -additive_expression: - multiplicative_expression - | additive_expression '+' multiplicative_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_add, $1, $3); - $$->set_location(yylloc); - } - | additive_expression '-' multiplicative_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3); - $$->set_location(yylloc); - } - ; - -shift_expression: - additive_expression - | shift_expression LEFT_OP additive_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3); - $$->set_location(yylloc); - } - | shift_expression RIGHT_OP additive_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3); - $$->set_location(yylloc); - } - ; - -relational_expression: - shift_expression - | relational_expression '<' shift_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_less, $1, $3); - $$->set_location(yylloc); - } - | relational_expression '>' shift_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3); - $$->set_location(yylloc); - } - | relational_expression LE_OP shift_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3); - $$->set_location(yylloc); - } - | relational_expression GE_OP shift_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3); - $$->set_location(yylloc); - } - ; - -equality_expression: - relational_expression - | equality_expression EQ_OP relational_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3); - $$->set_location(yylloc); - } - | equality_expression NE_OP relational_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3); - $$->set_location(yylloc); - } - ; - -and_expression: - equality_expression - | and_expression '&' equality_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_bit_and, $1, $3); - $$->set_location(yylloc); - } - ; - -exclusive_or_expression: - and_expression - | exclusive_or_expression '^' and_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3); - $$->set_location(yylloc); - } - ; - -inclusive_or_expression: - exclusive_or_expression - | inclusive_or_expression '|' exclusive_or_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3); - $$->set_location(yylloc); - } - ; - -logical_and_expression: - inclusive_or_expression - | logical_and_expression AND_OP inclusive_or_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3); - $$->set_location(yylloc); - } - ; - -logical_xor_expression: - logical_and_expression - | logical_xor_expression XOR_OP logical_and_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3); - $$->set_location(yylloc); - } - ; - -logical_or_expression: - logical_xor_expression - | logical_or_expression OR_OP logical_xor_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3); - $$->set_location(yylloc); - } - ; - -conditional_expression: - logical_or_expression - | logical_or_expression '?' expression ':' assignment_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5); - $$->set_location(yylloc); - } - ; - -assignment_expression: - conditional_expression - | unary_expression assignment_operator assignment_expression - { - void *ctx = state; - $$ = new(ctx) ast_expression($2, $1, $3, NULL); - $$->set_location(yylloc); - } - ; - -assignment_operator: - '=' { $$ = ast_assign; } - | MUL_ASSIGN { $$ = ast_mul_assign; } - | DIV_ASSIGN { $$ = ast_div_assign; } - | MOD_ASSIGN { $$ = ast_mod_assign; } - | ADD_ASSIGN { $$ = ast_add_assign; } - | SUB_ASSIGN { $$ = ast_sub_assign; } - | LEFT_ASSIGN { $$ = ast_ls_assign; } - | RIGHT_ASSIGN { $$ = ast_rs_assign; } - | AND_ASSIGN { $$ = ast_and_assign; } - | XOR_ASSIGN { $$ = ast_xor_assign; } - | OR_ASSIGN { $$ = ast_or_assign; } - ; - -expression: - assignment_expression - { - $$ = $1; - } - | expression ',' assignment_expression - { - void *ctx = state; - if ($1->oper != ast_sequence) { - $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL); - $$->set_location(yylloc); - $$->expressions.push_tail(& $1->link); - } else { - $$ = $1; - } - - $$->expressions.push_tail(& $3->link); - } - ; - -constant_expression: - conditional_expression - ; - -declaration: - function_prototype ';' - { - state->symbols->pop_scope(); - $$ = $1; - } - | init_declarator_list ';' - { - $$ = $1; - } - | PRECISION precision_qualifier type_specifier_no_prec ';' - { - $3->precision = $2; - $3->is_precision_statement = true; - $$ = $3; - } - ; - -function_prototype: - function_declarator ')' - ; - -function_declarator: - function_header - | function_header_with_parameters - ; - -function_header_with_parameters: - function_header parameter_declaration - { - $$ = $1; - $$->parameters.push_tail(& $2->link); - } - | function_header_with_parameters ',' parameter_declaration - { - $$ = $1; - $$->parameters.push_tail(& $3->link); - } - ; - -function_header: - fully_specified_type variable_identifier '(' - { - void *ctx = state; - $$ = new(ctx) ast_function(); - $$->set_location(yylloc); - $$->return_type = $1; - $$->identifier = $2; - - state->symbols->add_function(new(state) ir_function($2)); - state->symbols->push_scope(); - } - ; - -parameter_declarator: - type_specifier any_identifier - { - void *ctx = state; - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->set_location(yylloc); - $$->type->specifier = $1; - $$->identifier = $2; - } - | type_specifier any_identifier '[' constant_expression ']' - { - void *ctx = state; - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->set_location(yylloc); - $$->type->specifier = $1; - $$->identifier = $2; - $$->is_array = true; - $$->array_size = $4; - } - ; - -parameter_declaration: - parameter_type_qualifier parameter_qualifier parameter_declarator - { - $1.flags.i |= $2.flags.i; - - $$ = $3; - $$->type->qualifier = $1; - } - | parameter_qualifier parameter_declarator - { - $$ = $2; - $$->type->qualifier = $1; - } - | parameter_type_qualifier parameter_qualifier parameter_type_specifier - { - void *ctx = state; - $1.flags.i |= $2.flags.i; - - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->qualifier = $1; - $$->type->specifier = $3; - } - | parameter_qualifier parameter_type_specifier - { - void *ctx = state; - $$ = new(ctx) ast_parameter_declarator(); - $$->set_location(yylloc); - $$->type = new(ctx) ast_fully_specified_type(); - $$->type->qualifier = $1; - $$->type->specifier = $2; - } - ; - -parameter_qualifier: - /* empty */ - { - memset(& $$, 0, sizeof($$)); - } - | IN_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.in = 1; - } - | OUT_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.out = 1; - } - | INOUT_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.in = 1; - $$.flags.q.out = 1; - } - ; - -parameter_type_specifier: - type_specifier - ; - -init_declarator_list: - single_declaration - | init_declarator_list ',' any_identifier - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto)); - } - | init_declarator_list ',' any_identifier '[' ']' - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto)); - } - | init_declarator_list ',' any_identifier '[' constant_expression ']' - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto)); - } - | init_declarator_list ',' any_identifier '[' ']' '=' initializer - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto)); - } - | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' initializer - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto)); - } - | init_declarator_list ',' any_identifier '=' initializer - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5); - decl->set_location(yylloc); - - $$ = $1; - $$->declarations.push_tail(&decl->link); - state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto)); - } - ; - - // Grammar Note: No 'enum', or 'typedef'. -single_declaration: - fully_specified_type - { - void *ctx = state; - /* Empty declaration list is valid. */ - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - } - | fully_specified_type any_identifier - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type any_identifier '[' ']' - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type any_identifier '[' constant_expression ']' - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type any_identifier '[' ']' '=' initializer - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type any_identifier '[' constant_expression ']' '=' initializer - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | fully_specified_type any_identifier '=' initializer - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); - - $$ = new(ctx) ast_declarator_list($1); - $$->set_location(yylloc); - $$->declarations.push_tail(&decl->link); - } - | INVARIANT variable_identifier // Vertex only. - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL); - - $$ = new(ctx) ast_declarator_list(NULL); - $$->set_location(yylloc); - $$->invariant = true; - - $$->declarations.push_tail(&decl->link); - } - ; - -fully_specified_type: - type_specifier - { - void *ctx = state; - $$ = new(ctx) ast_fully_specified_type(); - $$->set_location(yylloc); - $$->specifier = $1; - } - | type_qualifier type_specifier - { - void *ctx = state; - $$ = new(ctx) ast_fully_specified_type(); - $$->set_location(yylloc); - $$->qualifier = $1; - $$->specifier = $2; - } - ; - -layout_qualifier: - LAYOUT_TOK '(' layout_qualifier_id_list ')' - { - $$ = $3; - } - ; - -layout_qualifier_id_list: - layout_qualifier_id - | layout_qualifier_id_list ',' layout_qualifier_id - { - if (($1.flags.i & $3.flags.i) != 0) { - _mesa_glsl_error(& @3, state, - "duplicate layout qualifiers used\n"); - YYERROR; - } - - $$.flags.i = $1.flags.i | $3.flags.i; - - if ($1.flags.q.explicit_location) - $$.location = $1.location; - - if ($3.flags.q.explicit_location) - $$.location = $3.location; - } - ; - -layout_qualifier_id: - any_identifier - { - bool got_one = false; - - memset(& $$, 0, sizeof($$)); - - /* Layout qualifiers for ARB_fragment_coord_conventions. */ - if (!got_one && state->ARB_fragment_coord_conventions_enable) { - if (strcmp($1, "origin_upper_left") == 0) { - got_one = true; - $$.flags.q.origin_upper_left = 1; - } else if (strcmp($1, "pixel_center_integer") == 0) { - got_one = true; - $$.flags.q.pixel_center_integer = 1; - } - - if (got_one && state->ARB_fragment_coord_conventions_warn) { - _mesa_glsl_warning(& @1, state, - "GL_ARB_fragment_coord_conventions layout " - "identifier `%s' used\n", $1); - } - } - - /* Layout qualifiers for AMD/ARB_conservative_depth. */ - if (!got_one && - (state->AMD_conservative_depth_enable || - state->ARB_conservative_depth_enable)) { - if (strcmp($1, "depth_any") == 0) { - got_one = true; - $$.flags.q.depth_any = 1; - } else if (strcmp($1, "depth_greater") == 0) { - got_one = true; - $$.flags.q.depth_greater = 1; - } else if (strcmp($1, "depth_less") == 0) { - got_one = true; - $$.flags.q.depth_less = 1; - } else if (strcmp($1, "depth_unchanged") == 0) { - got_one = true; - $$.flags.q.depth_unchanged = 1; - } - - if (got_one && state->AMD_conservative_depth_warn) { - _mesa_glsl_warning(& @1, state, - "GL_AMD_conservative_depth " - "layout qualifier `%s' is used\n", $1); - } - if (got_one && state->ARB_conservative_depth_warn) { - _mesa_glsl_warning(& @1, state, - "GL_ARB_conservative_depth " - "layout qualifier `%s' is used\n", $1); - } - } - - if (!got_one) { - _mesa_glsl_error(& @1, state, "unrecognized layout identifier " - "`%s'\n", $1); - YYERROR; - } - } - | any_identifier '=' INTCONSTANT - { - bool got_one = false; - - memset(& $$, 0, sizeof($$)); - - if (state->ARB_explicit_attrib_location_enable) { - /* FINISHME: Handle 'index' once GL_ARB_blend_func_exteneded and - * FINISHME: GLSL 1.30 (or later) are supported. - */ - if (strcmp("location", $1) == 0) { - got_one = true; - - $$.flags.q.explicit_location = 1; - - if ($3 >= 0) { - $$.location = $3; - } else { - _mesa_glsl_error(& @3, state, - "invalid location %d specified\n", $3); - YYERROR; - } - } - } - - /* If the identifier didn't match any known layout identifiers, - * emit an error. - */ - if (!got_one) { - _mesa_glsl_error(& @1, state, "unrecognized layout identifier " - "`%s'\n", $1); - YYERROR; - } else if (state->ARB_explicit_attrib_location_warn) { - _mesa_glsl_warning(& @1, state, - "GL_ARB_explicit_attrib_location layout " - "identifier `%s' used\n", $1); - } - } - ; - -interpolation_qualifier: - SMOOTH - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.smooth = 1; - } - | FLAT - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.flat = 1; - } - | NOPERSPECTIVE - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.noperspective = 1; - } - ; - -parameter_type_qualifier: - CONST_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.constant = 1; - } - ; - -type_qualifier: - storage_qualifier - | layout_qualifier - | layout_qualifier storage_qualifier - { - $$ = $1; - $$.flags.i |= $2.flags.i; - } - | interpolation_qualifier - | interpolation_qualifier storage_qualifier - { - $$ = $1; - $$.flags.i |= $2.flags.i; - } - | INVARIANT storage_qualifier - { - $$ = $2; - $$.flags.q.invariant = 1; - } - | INVARIANT interpolation_qualifier storage_qualifier - { - $$ = $2; - $$.flags.i |= $3.flags.i; - $$.flags.q.invariant = 1; - } - | INVARIANT - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.invariant = 1; - } - ; - -storage_qualifier: - CONST_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.constant = 1; - } - | ATTRIBUTE - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.attribute = 1; - } - | VARYING - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.varying = 1; - } - | CENTROID VARYING - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.centroid = 1; - $$.flags.q.varying = 1; - } - | IN_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.in = 1; - } - | OUT_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.out = 1; - } - | CENTROID IN_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.centroid = 1; $$.flags.q.in = 1; - } - | CENTROID OUT_TOK - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.centroid = 1; $$.flags.q.out = 1; - } - | UNIFORM - { - memset(& $$, 0, sizeof($$)); - $$.flags.q.uniform = 1; - } - ; - -type_specifier: - type_specifier_no_prec - { - $$ = $1; - } - | precision_qualifier type_specifier_no_prec - { - $$ = $2; - $$->precision = $1; - } - ; - -type_specifier_no_prec: - type_specifier_nonarray - | type_specifier_nonarray '[' ']' - { - $$ = $1; - $$->is_array = true; - $$->array_size = NULL; - } - | type_specifier_nonarray '[' constant_expression ']' - { - $$ = $1; - $$->is_array = true; - $$->array_size = $3; - } - ; - -type_specifier_nonarray: - basic_type_specifier_nonarray - { - void *ctx = state; - $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); - } - | struct_specifier - { - void *ctx = state; - $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); - } - | TYPE_IDENTIFIER - { - void *ctx = state; - $$ = new(ctx) ast_type_specifier($1); - $$->set_location(yylloc); - } - ; - -basic_type_specifier_nonarray: - VOID_TOK { $$ = ast_void; } - | FLOAT_TOK { $$ = ast_float; } - | INT_TOK { $$ = ast_int; } - | UINT_TOK { $$ = ast_uint; } - | BOOL_TOK { $$ = ast_bool; } - | VEC2 { $$ = ast_vec2; } - | VEC3 { $$ = ast_vec3; } - | VEC4 { $$ = ast_vec4; } - | BVEC2 { $$ = ast_bvec2; } - | BVEC3 { $$ = ast_bvec3; } - | BVEC4 { $$ = ast_bvec4; } - | IVEC2 { $$ = ast_ivec2; } - | IVEC3 { $$ = ast_ivec3; } - | IVEC4 { $$ = ast_ivec4; } - | UVEC2 { $$ = ast_uvec2; } - | UVEC3 { $$ = ast_uvec3; } - | UVEC4 { $$ = ast_uvec4; } - | MAT2X2 { $$ = ast_mat2; } - | MAT2X3 { $$ = ast_mat2x3; } - | MAT2X4 { $$ = ast_mat2x4; } - | MAT3X2 { $$ = ast_mat3x2; } - | MAT3X3 { $$ = ast_mat3; } - | MAT3X4 { $$ = ast_mat3x4; } - | MAT4X2 { $$ = ast_mat4x2; } - | MAT4X3 { $$ = ast_mat4x3; } - | MAT4X4 { $$ = ast_mat4; } - | SAMPLER1D { $$ = ast_sampler1d; } - | SAMPLER2D { $$ = ast_sampler2d; } - | SAMPLER2DRECT { $$ = ast_sampler2drect; } - | SAMPLER3D { $$ = ast_sampler3d; } - | SAMPLERCUBE { $$ = ast_samplercube; } - | SAMPLEREXTERNALOES { $$ = ast_samplerexternaloes; } - | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; } - | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; } - | SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; } - | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; } - | SAMPLER1DARRAY { $$ = ast_sampler1darray; } - | SAMPLER2DARRAY { $$ = ast_sampler2darray; } - | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; } - | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; } - | ISAMPLER1D { $$ = ast_isampler1d; } - | ISAMPLER2D { $$ = ast_isampler2d; } - | ISAMPLER3D { $$ = ast_isampler3d; } - | ISAMPLERCUBE { $$ = ast_isamplercube; } - | ISAMPLER1DARRAY { $$ = ast_isampler1darray; } - | ISAMPLER2DARRAY { $$ = ast_isampler2darray; } - | USAMPLER1D { $$ = ast_usampler1d; } - | USAMPLER2D { $$ = ast_usampler2d; } - | USAMPLER3D { $$ = ast_usampler3d; } - | USAMPLERCUBE { $$ = ast_usamplercube; } - | USAMPLER1DARRAY { $$ = ast_usampler1darray; } - | USAMPLER2DARRAY { $$ = ast_usampler2darray; } - ; - -precision_qualifier: - HIGHP { - if (!state->es_shader && state->language_version < 130) - _mesa_glsl_error(& @1, state, - "precision qualifier forbidden " - "in %s (1.30 or later " - "required)\n", - state->version_string); - - $$ = ast_precision_high; - } - | MEDIUMP { - if (!state->es_shader && state->language_version < 130) - _mesa_glsl_error(& @1, state, - "precision qualifier forbidden " - "in %s (1.30 or later " - "required)\n", - state->version_string); - - $$ = ast_precision_medium; - } - | LOWP { - if (!state->es_shader && state->language_version < 130) - _mesa_glsl_error(& @1, state, - "precision qualifier forbidden " - "in %s (1.30 or later " - "required)\n", - state->version_string); - - $$ = ast_precision_low; - } - ; - -struct_specifier: - STRUCT any_identifier '{' struct_declaration_list '}' - { - void *ctx = state; - $$ = new(ctx) ast_struct_specifier($2, $4); - $$->set_location(yylloc); - state->symbols->add_type($2, glsl_type::void_type); - } - | STRUCT '{' struct_declaration_list '}' - { - void *ctx = state; - $$ = new(ctx) ast_struct_specifier(NULL, $3); - $$->set_location(yylloc); - } - ; - -struct_declaration_list: - struct_declaration - { - $$ = (ast_node *) $1; - $1->link.self_link(); - } - | struct_declaration_list struct_declaration - { - $$ = (ast_node *) $1; - $$->link.insert_before(& $2->link); - } - ; - -struct_declaration: - type_specifier struct_declarator_list ';' - { - void *ctx = state; - ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); - type->set_location(yylloc); - - type->specifier = $1; - $$ = new(ctx) ast_declarator_list(type); - $$->set_location(yylloc); - - $$->declarations.push_degenerate_list_at_head(& $2->link); - } - ; - -struct_declarator_list: - struct_declarator - { - $$ = $1; - $1->link.self_link(); - } - | struct_declarator_list ',' struct_declarator - { - $$ = $1; - $$->link.insert_before(& $3->link); - } - ; - -struct_declarator: - any_identifier - { - void *ctx = state; - $$ = new(ctx) ast_declaration($1, false, NULL, NULL); - $$->set_location(yylloc); - state->symbols->add_variable(new(state) ir_variable(NULL, $1, ir_var_auto)); - } - | any_identifier '[' constant_expression ']' - { - void *ctx = state; - $$ = new(ctx) ast_declaration($1, true, $3, NULL); - $$->set_location(yylloc); - } - ; - -initializer: - assignment_expression - ; - -declaration_statement: - declaration - ; - - // Grammar Note: labeled statements for SWITCH only; 'goto' is not - // supported. -statement: - compound_statement { $$ = (ast_node *) $1; } - | simple_statement - ; - -simple_statement: - declaration_statement - | expression_statement - | selection_statement - | switch_statement - | iteration_statement - | jump_statement - ; - -compound_statement: - '{' '}' - { - void *ctx = state; - $$ = new(ctx) ast_compound_statement(true, NULL); - $$->set_location(yylloc); - } - | '{' - { - state->symbols->push_scope(); - } - statement_list '}' - { - void *ctx = state; - $$ = new(ctx) ast_compound_statement(true, $3); - $$->set_location(yylloc); - state->symbols->pop_scope(); - } - ; - -statement_no_new_scope: - compound_statement_no_new_scope { $$ = (ast_node *) $1; } - | simple_statement - ; - -compound_statement_no_new_scope: - '{' '}' - { - void *ctx = state; - $$ = new(ctx) ast_compound_statement(false, NULL); - $$->set_location(yylloc); - } - | '{' statement_list '}' - { - void *ctx = state; - $$ = new(ctx) ast_compound_statement(false, $2); - $$->set_location(yylloc); - } - ; - -statement_list: - statement - { - if ($1 == NULL) { - _mesa_glsl_error(& @1, state, " statement\n"); - assert($1 != NULL); - } - - $$ = $1; - $$->link.self_link(); - } - | statement_list statement - { - if ($2 == NULL) { - _mesa_glsl_error(& @2, state, " statement\n"); - assert($2 != NULL); - } - $$ = $1; - $$->link.insert_before(& $2->link); - } - ; - -expression_statement: - ';' - { - void *ctx = state; - $$ = new(ctx) ast_expression_statement(NULL); - $$->set_location(yylloc); - } - | expression ';' - { - void *ctx = state; - $$ = new(ctx) ast_expression_statement($1); - $$->set_location(yylloc); - } - ; - -selection_statement: - IF '(' expression ')' selection_rest_statement - { - $$ = new(state) ast_selection_statement($3, $5.then_statement, - $5.else_statement); - $$->set_location(yylloc); - } - ; - -selection_rest_statement: - statement ELSE statement - { - $$.then_statement = $1; - $$.else_statement = $3; - } - | statement - { - $$.then_statement = $1; - $$.else_statement = NULL; - } - ; - -condition: - expression - { - $$ = (ast_node *) $1; - } - | fully_specified_type any_identifier '=' initializer - { - void *ctx = state; - ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4); - ast_declarator_list *declarator = new(ctx) ast_declarator_list($1); - decl->set_location(yylloc); - declarator->set_location(yylloc); - - declarator->declarations.push_tail(&decl->link); - $$ = declarator; - } - ; - -/* - * siwtch_statement grammar is based on the syntax described in the body - * of the GLSL spec, not in it's appendix!!! - */ -switch_statement: - SWITCH '(' expression ')' switch_body - { - $$ = new(state) ast_switch_statement($3, $5); - $$->set_location(yylloc); - } - ; - -switch_body: - '{' '}' - { - $$ = new(state) ast_switch_body(NULL); - $$->set_location(yylloc); - } - | '{' case_statement_list '}' - { - $$ = new(state) ast_switch_body($2); - $$->set_location(yylloc); - } - ; - -case_label: - CASE expression ':' - { - $$ = new(state) ast_case_label($2); - $$->set_location(yylloc); - } - | DEFAULT ':' - { - $$ = new(state) ast_case_label(NULL); - $$->set_location(yylloc); - } - ; - -case_label_list: - case_label - { - ast_case_label_list *labels = new(state) ast_case_label_list(); - - labels->labels.push_tail(& $1->link); - $$ = labels; - $$->set_location(yylloc); - } - | case_label_list case_label - { - $$ = $1; - $$->labels.push_tail(& $2->link); - } - ; - -case_statement: - case_label_list statement - { - ast_case_statement *stmts = new(state) ast_case_statement($1); - stmts->set_location(yylloc); - - stmts->stmts.push_tail(& $2->link); - $$ = stmts; - } - | case_statement statement - { - $$ = $1; - $$->stmts.push_tail(& $2->link); - } - ; - -case_statement_list: - case_statement - { - ast_case_statement_list *cases= new(state) ast_case_statement_list(); - cases->set_location(yylloc); - - cases->cases.push_tail(& $1->link); - $$ = cases; - } - | case_statement_list case_statement - { - $$ = $1; - $$->cases.push_tail(& $2->link); - } - ; - -iteration_statement: - WHILE '(' condition ')' statement_no_new_scope - { - void *ctx = state; - $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while, - NULL, $3, NULL, $5); - $$->set_location(yylloc); - } - | DO statement WHILE '(' expression ')' ';' - { - void *ctx = state; - $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while, - NULL, $5, NULL, $2); - $$->set_location(yylloc); - } - | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope - { - void *ctx = state; - $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for, - $3, $4.cond, $4.rest, $6); - $$->set_location(yylloc); - } - ; - -for_init_statement: - expression_statement - | declaration_statement - ; - -conditionopt: - condition - | /* empty */ - { - $$ = NULL; - } - ; - -for_rest_statement: - conditionopt ';' - { - $$.cond = $1; - $$.rest = NULL; - } - | conditionopt ';' expression - { - $$.cond = $1; - $$.rest = $3; - } - ; - - // Grammar Note: No 'goto'. Gotos are not supported. -jump_statement: - CONTINUE ';' - { - void *ctx = state; - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL); - $$->set_location(yylloc); - } - | BREAK ';' - { - void *ctx = state; - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL); - $$->set_location(yylloc); - } - | RETURN ';' - { - void *ctx = state; - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL); - $$->set_location(yylloc); - } - | RETURN expression ';' - { - void *ctx = state; - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2); - $$->set_location(yylloc); - } - | DISCARD ';' // Fragment shader only. - { - void *ctx = state; - $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL); - $$->set_location(yylloc); - } - ; - -external_declaration: - function_definition { $$ = $1; } - | declaration { $$ = $1; } - | pragma_statement { $$ = NULL; } - ; - -function_definition: - function_prototype compound_statement_no_new_scope - { - void *ctx = state; - $$ = new(ctx) ast_function_definition(); - $$->set_location(yylloc); - $$->prototype = $1; - $$->body = $2; - - state->symbols->pop_scope(); - } - ; diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.cpp b/reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.cpp deleted file mode 100644 index ff64d37704e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.cpp +++ /dev/null @@ -1,1052 +0,0 @@ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include -#include -#include - -extern "C" { -#include "main/core.h" /* for struct gl_context */ -} - -#include "ralloc.h" -#include "ast.h" -#include "glsl_parser_extras.h" -#include "glsl_parser.h" -#include "ir_optimization.h" -#include "loop_analysis.h" - -_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx, - GLenum target, void *mem_ctx) -{ - switch (target) { - case GL_VERTEX_SHADER: this->target = vertex_shader; break; - case GL_FRAGMENT_SHADER: this->target = fragment_shader; break; - } - - this->scanner = NULL; - this->translation_unit.make_empty(); - this->symbols = new(mem_ctx) glsl_symbol_table; - this->info_log = ralloc_strdup(mem_ctx, ""); - this->error = false; - this->loop_nesting_ast = NULL; - this->switch_state.switch_nesting_ast = NULL; - - this->num_builtins_to_link = 0; - - /* Set default language version and extensions */ - this->language_version = 110; - - this->extensions = &ctx->Extensions; - - this->Const.MaxLights = ctx->Const.MaxLights; - this->Const.MaxClipPlanes = ctx->Const.MaxClipPlanes; - this->Const.MaxTextureUnits = ctx->Const.MaxTextureUnits; - this->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits; - this->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs; - this->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents; - this->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4; - this->Const.MaxVertexTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits; - this->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits; - this->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; - this->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents; - - this->Const.MaxDrawBuffers = 1; - - /* Note: Once the OpenGL 3.0 'forward compatible' context or the OpenGL 3.2 - * Core context is supported, this logic will need change. Older versions of - * GLSL are no longer supported outside the compatibility contexts of 3.x. - */ - this->Const.GLSL_110 = true; - this->Const.GLSL_120 = (ctx->Const.GLSLVersion >= 120); - this->Const.GLSL_130 = (ctx->Const.GLSLVersion >= 130); - - const unsigned lowest_version = 110; - const unsigned highest_version = ctx->Const.GLSLVersion; - char *supported = ralloc_strdup(this, ""); - - for (unsigned ver = lowest_version; ver <= highest_version; ver += 10) { - const char *const prefix = (ver == lowest_version) - ? "" - : ((ver == highest_version) ? ", and " : ", "); - - ralloc_asprintf_append(& supported, "%s%d.%02d%s", - prefix, - ver / 100, ver % 100, - (ver == 100) ? " ES" : ""); - } - - this->supported_version_string = supported; - - if (ctx->Const.ForceGLSLExtensionsWarn) - _mesa_glsl_process_extension("all", NULL, "warn", NULL, this); -} - -const char * -_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) -{ - switch (target) { - case vertex_shader: return "vertex"; - case fragment_shader: return "fragment"; - } - - assert(!"Should not get here."); - return "unknown"; -} - - -void -_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, - const char *fmt, ...) -{ - va_list ap; - - state->error = true; - - assert(state->info_log != NULL); - ralloc_asprintf_append(&state->info_log, "%u:%u(%u): error: ", - locp->source, - locp->first_line, - locp->first_column); - va_start(ap, fmt); - ralloc_vasprintf_append(&state->info_log, fmt, ap); - va_end(ap); - ralloc_strcat(&state->info_log, "\n"); -} - - -void -_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, - const char *fmt, ...) -{ - va_list ap; - - assert(state->info_log != NULL); - ralloc_asprintf_append(&state->info_log, "%u:%u(%u): warning: ", - locp->source, - locp->first_line, - locp->first_column); - va_start(ap, fmt); - ralloc_vasprintf_append(&state->info_log, fmt, ap); - va_end(ap); - ralloc_strcat(&state->info_log, "\n"); -} - - -/** - * Enum representing the possible behaviors that can be specified in - * an #extension directive. - */ -enum ext_behavior { - extension_disable, - extension_enable, - extension_require, - extension_warn -}; - -/** - * Element type for _mesa_glsl_supported_extensions - */ -struct _mesa_glsl_extension { - /** - * Name of the extension when referred to in a GLSL extension - * statement - */ - const char *name; - - /** True if this extension is available to vertex shaders */ - bool avail_in_VS; - - /** True if this extension is available to geometry shaders */ - bool avail_in_GS; - - /** True if this extension is available to fragment shaders */ - bool avail_in_FS; - - /** True if this extension is available to desktop GL shaders */ - bool avail_in_GL; - - /** True if this extension is available to GLES shaders */ - bool avail_in_ES; - - /** - * Flag in the gl_extensions struct indicating whether this - * extension is supported by the driver, or - * &gl_extensions::dummy_true if supported by all drivers. - * - * Note: the type (GLboolean gl_extensions::*) is a "pointer to - * member" type, the type-safe alternative to the "offsetof" macro. - * In a nutshell: - * - * - foo bar::* p declares p to be an "offset" to a field of type - * foo that exists within struct bar - * - &bar::baz computes the "offset" of field baz within struct bar - * - x.*p accesses the field of x that exists at "offset" p - * - x->*p is equivalent to (*x).*p - */ - const GLboolean gl_extensions::* supported_flag; - - /** - * Flag in the _mesa_glsl_parse_state struct that should be set - * when this extension is enabled. - * - * See note in _mesa_glsl_extension::supported_flag about "pointer - * to member" types. - */ - bool _mesa_glsl_parse_state::* enable_flag; - - /** - * Flag in the _mesa_glsl_parse_state struct that should be set - * when the shader requests "warn" behavior for this extension. - * - * See note in _mesa_glsl_extension::supported_flag about "pointer - * to member" types. - */ - bool _mesa_glsl_parse_state::* warn_flag; - - - bool compatible_with_state(const _mesa_glsl_parse_state *state) const; - void set_flags(_mesa_glsl_parse_state *state, ext_behavior behavior) const; -}; - -#define EXT(NAME, VS, GS, FS, GL, ES, SUPPORTED_FLAG) \ - { "GL_" #NAME, VS, GS, FS, GL, ES, &gl_extensions::SUPPORTED_FLAG, \ - &_mesa_glsl_parse_state::NAME##_enable, \ - &_mesa_glsl_parse_state::NAME##_warn } - -/** - * Table of extensions that can be enabled/disabled within a shader, - * and the conditions under which they are supported. - */ -static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { - /* target availability API availability */ - /* name VS GS FS GL ES supported flag */ - EXT(ARB_conservative_depth, false, false, true, true, false, ARB_conservative_depth), - EXT(ARB_draw_buffers, false, false, true, true, false, dummy_true), - EXT(ARB_shader_texture_lod, true, false, true, true, false, ARB_shader_texture_lod), - EXT(ARB_shader_stencil_export, false, false, true, true, false, ARB_shader_stencil_export), - EXT(AMD_conservative_depth, false, false, true, true, false, ARB_conservative_depth), - EXT(AMD_shader_stencil_export, false, false, true, true, false, ARB_shader_stencil_export), - EXT(OES_texture_3D, true, false, true, false, true, EXT_texture3D), -}; - -#undef EXT - - -/** - * Determine whether a given extension is compatible with the target, - * API, and extension information in the current parser state. - */ -bool _mesa_glsl_extension::compatible_with_state(const _mesa_glsl_parse_state * - state) const -{ - /* Check that this extension matches the type of shader we are - * compiling to. - */ - switch (state->target) { - case vertex_shader: - if (!this->avail_in_VS) { - return false; - } - break; - case fragment_shader: - if (!this->avail_in_FS) { - return false; - } - break; - default: - assert (!"Unrecognized shader target"); - return false; - } - - /* Check that this extension matches whether we are compiling - * for desktop GL or GLES. - */ - if (!this->avail_in_GL) return false; - - /* Check that this extension is supported by the OpenGL - * implementation. - * - * Note: the ->* operator indexes into state->extensions by the - * offset this->supported_flag. See - * _mesa_glsl_extension::supported_flag for more info. - */ - return state->extensions->*(this->supported_flag); -} - -/** - * Set the appropriate flags in the parser state to establish the - * given behavior for this extension. - */ -void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state, - ext_behavior behavior) const -{ - /* Note: the ->* operator indexes into state by the - * offsets this->enable_flag and this->warn_flag. See - * _mesa_glsl_extension::supported_flag for more info. - */ - state->*(this->enable_flag) = (behavior != extension_disable); - state->*(this->warn_flag) = (behavior == extension_warn); -} - -/** - * Find an extension by name in _mesa_glsl_supported_extensions. If - * the name is not found, return NULL. - */ -static const _mesa_glsl_extension *find_extension(const char *name) -{ - for (unsigned i = 0; i < Elements(_mesa_glsl_supported_extensions); ++i) { - if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) { - return &_mesa_glsl_supported_extensions[i]; - } - } - return NULL; -} - - -bool -_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, - const char *behavior_string, YYLTYPE *behavior_locp, - _mesa_glsl_parse_state *state) -{ - ext_behavior behavior; - if (strcmp(behavior_string, "warn") == 0) { - behavior = extension_warn; - } else if (strcmp(behavior_string, "require") == 0) { - behavior = extension_require; - } else if (strcmp(behavior_string, "enable") == 0) { - behavior = extension_enable; - } else if (strcmp(behavior_string, "disable") == 0) { - behavior = extension_disable; - } else { - _mesa_glsl_error(behavior_locp, state, - "Unknown extension behavior `%s'", - behavior_string); - return false; - } - - if (strcmp(name, "all") == 0) { - if ((behavior == extension_enable) || (behavior == extension_require)) { - _mesa_glsl_error(name_locp, state, "Cannot %s all extensions", - (behavior == extension_enable) - ? "enable" : "require"); - return false; - } else { - for (unsigned i = 0; - i < Elements(_mesa_glsl_supported_extensions); ++i) { - const _mesa_glsl_extension *extension - = &_mesa_glsl_supported_extensions[i]; - if (extension->compatible_with_state(state)) { - _mesa_glsl_supported_extensions[i].set_flags(state, behavior); - } - } - } - } else { - const _mesa_glsl_extension *extension = find_extension(name); - if (extension && extension->compatible_with_state(state)) { - extension->set_flags(state, behavior); - } else { - static const char *const fmt = "extension `%s' unsupported in %s shader"; - - if (behavior == extension_require) { - _mesa_glsl_error(name_locp, state, fmt, - name, _mesa_glsl_shader_target_name(state->target)); - return false; - } else { - _mesa_glsl_warning(name_locp, state, fmt, - name, _mesa_glsl_shader_target_name(state->target)); - } - } - } - - return true; -} - -void -_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q) -{ - if (q->flags.q.constant) - printf("const "); - - if (q->flags.q.invariant) - printf("invariant "); - - if (q->flags.q.attribute) - printf("attribute "); - - if (q->flags.q.varying) - printf("varying "); - - if (q->flags.q.in && q->flags.q.out) - printf("inout "); - else { - if (q->flags.q.in) - printf("in "); - - if (q->flags.q.out) - printf("out "); - } - - if (q->flags.q.centroid) - printf("centroid "); - if (q->flags.q.uniform) - printf("uniform "); - if (q->flags.q.smooth) - printf("smooth "); - if (q->flags.q.flat) - printf("flat "); - if (q->flags.q.noperspective) - printf("noperspective "); -} - - -void -ast_node::print(void) const -{ - printf("unhandled node "); -} - - -ast_node::ast_node(void) -{ - this->location.source = 0; - this->location.line = 0; - this->location.column = 0; -} - - -static void -ast_opt_array_size_print(bool is_array, const ast_expression *array_size) -{ - if (is_array) { - printf("[ "); - - if (array_size) - array_size->print(); - - printf("] "); - } -} - - -void -ast_compound_statement::print(void) const -{ - printf("{\n"); - - foreach_list_const(n, &this->statements) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - printf("}\n"); -} - - -ast_compound_statement::ast_compound_statement(int new_scope, - ast_node *statements) -{ - this->new_scope = new_scope; - - if (statements != NULL) { - this->statements.push_degenerate_list_at_head(&statements->link); - } -} - - -void -ast_expression::print(void) const -{ - switch (oper) { - case ast_assign: - case ast_mul_assign: - case ast_div_assign: - case ast_mod_assign: - case ast_add_assign: - case ast_sub_assign: - case ast_ls_assign: - case ast_rs_assign: - case ast_and_assign: - case ast_xor_assign: - case ast_or_assign: - subexpressions[0]->print(); - printf("%s ", operator_string(oper)); - subexpressions[1]->print(); - break; - - case ast_field_selection: - subexpressions[0]->print(); - printf(". %s ", primary_expression.identifier); - break; - - case ast_plus: - case ast_neg: - case ast_bit_not: - case ast_logic_not: - case ast_pre_inc: - case ast_pre_dec: - printf("%s ", operator_string(oper)); - subexpressions[0]->print(); - break; - - case ast_post_inc: - case ast_post_dec: - subexpressions[0]->print(); - printf("%s ", operator_string(oper)); - break; - - case ast_conditional: - subexpressions[0]->print(); - printf("? "); - subexpressions[1]->print(); - printf(": "); - subexpressions[2]->print(); - break; - - case ast_array_index: - subexpressions[0]->print(); - printf("[ "); - subexpressions[1]->print(); - printf("] "); - break; - - case ast_function_call: { - subexpressions[0]->print(); - printf("( "); - - foreach_list_const (n, &this->expressions) { - if (n != this->expressions.get_head()) - printf(", "); - - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - printf(") "); - break; - } - - case ast_identifier: - printf("%s ", primary_expression.identifier); - break; - - case ast_int_constant: - printf("%d ", primary_expression.int_constant); - break; - - case ast_uint_constant: - printf("%u ", primary_expression.uint_constant); - break; - - case ast_float_constant: - printf("%f ", primary_expression.float_constant); - break; - - case ast_bool_constant: - printf("%s ", - primary_expression.bool_constant - ? "true" : "false"); - break; - - case ast_sequence: { - printf("( "); - foreach_list_const(n, & this->expressions) { - if (n != this->expressions.get_head()) - printf(", "); - - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - printf(") "); - break; - } - - default: - assert(0); - break; - } -} - -ast_expression::ast_expression(int oper, - ast_expression *ex0, - ast_expression *ex1, - ast_expression *ex2) -{ - this->oper = ast_operators(oper); - this->subexpressions[0] = ex0; - this->subexpressions[1] = ex1; - this->subexpressions[2] = ex2; - this->non_lvalue_description = NULL; -} - - -void -ast_expression_statement::print(void) const -{ - if (expression) - expression->print(); - - printf("; "); -} - - -ast_expression_statement::ast_expression_statement(ast_expression *ex) : - expression(ex) -{ - /* empty */ -} - - -void -ast_function::print(void) const -{ - return_type->print(); - printf(" %s (", identifier); - - foreach_list_const(n, & this->parameters) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - - printf(")"); -} - - -ast_function::ast_function(void) - : is_definition(false), signature(NULL) -{ - /* empty */ -} - - -void -ast_fully_specified_type::print(void) const -{ - _mesa_ast_type_qualifier_print(& qualifier); - specifier->print(); -} - - -void -ast_parameter_declarator::print(void) const -{ - type->print(); - if (identifier) - printf("%s ", identifier); - ast_opt_array_size_print(is_array, array_size); -} - - -void -ast_function_definition::print(void) const -{ - prototype->print(); - body->print(); -} - - -void -ast_declaration::print(void) const -{ - printf("%s ", identifier); - ast_opt_array_size_print(is_array, array_size); - - if (initializer) { - printf("= "); - initializer->print(); - } -} - - -ast_declaration::ast_declaration(char *identifier, int is_array, - ast_expression *array_size, - ast_expression *initializer) -{ - this->identifier = identifier; - this->is_array = is_array; - this->array_size = array_size; - this->initializer = initializer; -} - - -void -ast_declarator_list::print(void) const -{ - assert(type || invariant); - - if (type) - type->print(); - else - printf("invariant "); - - foreach_list_const (ptr, & this->declarations) { - if (ptr != this->declarations.get_head()) - printf(", "); - - ast_node *ast = exec_node_data(ast_node, ptr, link); - ast->print(); - } - - printf("; "); -} - - -ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type) -{ - this->type = type; - this->invariant = false; -} - -void -ast_jump_statement::print(void) const -{ - switch (mode) { - case ast_continue: - printf("continue; "); - break; - case ast_break: - printf("break; "); - break; - case ast_return: - printf("return "); - if (opt_return_value) - opt_return_value->print(); - - printf("; "); - break; - case ast_discard: - printf("discard; "); - break; - } -} - - -ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value) -{ - this->mode = ast_jump_modes(mode); - - if (mode == ast_return) - opt_return_value = return_value; -} - - -void -ast_selection_statement::print(void) const -{ - printf("if ( "); - condition->print(); - printf(") "); - - then_statement->print(); - - if (else_statement) { - printf("else "); - else_statement->print(); - } - -} - - -ast_selection_statement::ast_selection_statement(ast_expression *condition, - ast_node *then_statement, - ast_node *else_statement) -{ - this->condition = condition; - this->then_statement = then_statement; - this->else_statement = else_statement; -} - - -void -ast_switch_statement::print(void) const -{ - printf("switch ( "); - test_expression->print(); - printf(") "); - - body->print(); -} - - -ast_switch_statement::ast_switch_statement(ast_expression *test_expression, - ast_node *body) -{ - this->test_expression = test_expression; - this->body = body; -} - - -void -ast_switch_body::print(void) const -{ - printf("{\n"); - if (stmts != NULL) { - stmts->print(); - } - printf("}\n"); -} - - -ast_switch_body::ast_switch_body(ast_case_statement_list *stmts) -{ - this->stmts = stmts; -} - - -void ast_case_label::print(void) const -{ - if (test_value != NULL) { - printf("case "); - test_value->print(); - printf(": "); - } else { - printf("default: "); - } -} - - -ast_case_label::ast_case_label(ast_expression *test_value) -{ - this->test_value = test_value; -} - - -void ast_case_label_list::print(void) const -{ - foreach_list_const(n, & this->labels) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - printf("\n"); -} - - -ast_case_label_list::ast_case_label_list(void) -{ -} - - -void ast_case_statement::print(void) const -{ - labels->print(); - foreach_list_const(n, & this->stmts) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - printf("\n"); - } -} - - -ast_case_statement::ast_case_statement(ast_case_label_list *labels) -{ - this->labels = labels; -} - - -void ast_case_statement_list::print(void) const -{ - foreach_list_const(n, & this->cases) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } -} - - -ast_case_statement_list::ast_case_statement_list(void) -{ -} - - -void -ast_iteration_statement::print(void) const -{ - switch (mode) { - case ast_for: - printf("for( "); - if (init_statement) - init_statement->print(); - printf("; "); - - if (condition) - condition->print(); - printf("; "); - - if (rest_expression) - rest_expression->print(); - printf(") "); - - body->print(); - break; - - case ast_while: - printf("while ( "); - if (condition) - condition->print(); - printf(") "); - body->print(); - break; - - case ast_do_while: - printf("do "); - body->print(); - printf("while ( "); - if (condition) - condition->print(); - printf("); "); - break; - } -} - - -ast_iteration_statement::ast_iteration_statement(int mode, - ast_node *init, - ast_node *condition, - ast_expression *rest_expression, - ast_node *body) -{ - this->mode = ast_iteration_modes(mode); - this->init_statement = init; - this->condition = condition; - this->rest_expression = rest_expression; - this->body = body; -} - - -void -ast_struct_specifier::print(void) const -{ - printf("struct %s { ", name); - foreach_list_const(n, &this->declarations) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - printf("} "); -} - - -ast_struct_specifier::ast_struct_specifier(char *identifier, - ast_node *declarator_list) -{ - if (identifier == NULL) { - static unsigned anon_count = 1; - identifier = ralloc_asprintf(this, "#anon_struct_%04x", anon_count); - anon_count++; - } - name = identifier; - this->declarations.push_degenerate_list_at_head(&declarator_list->link); -} - -/** - * Do the set of common optimizations passes - * - * \param ir List of instructions to be optimized - * \param linked Is the shader linked? This enables - * optimizations passes that remove code at - * global scope and could cause linking to - * fail. - * \param uniform_locations_assigned Have locations already been assigned for - * uniforms? This prevents the declarations - * of unused uniforms from being removed. - * The setting of this flag only matters if - * \c linked is \c true. - * \param max_unroll_iterations Maximum number of loop iterations to be - * unrolled. Setting to 0 forces all loops - * to be unrolled. - */ -bool -do_common_optimization(exec_list *ir, bool linked, - bool uniform_locations_assigned, - unsigned max_unroll_iterations) -{ - GLboolean progress = GL_FALSE; - - progress = lower_instructions(ir, SUB_TO_ADD_NEG) || progress; - - if (linked) { - progress = do_function_inlining(ir) || progress; - progress = do_dead_functions(ir) || progress; - progress = do_structure_splitting(ir) || progress; - } - progress = do_if_simplification(ir) || progress; - progress = do_discard_simplification(ir) || progress; - progress = do_copy_propagation(ir) || progress; - progress = do_copy_propagation_elements(ir) || progress; - if (linked) - progress = do_dead_code(ir, uniform_locations_assigned) || progress; - else - progress = do_dead_code_unlinked(ir) || progress; - progress = do_dead_code_local(ir) || progress; - progress = do_tree_grafting(ir) || progress; - progress = do_constant_propagation(ir) || progress; - if (linked) - progress = do_constant_variable(ir) || progress; - else - progress = do_constant_variable_unlinked(ir) || progress; - progress = do_constant_folding(ir) || progress; - progress = do_algebraic(ir) || progress; - progress = do_lower_jumps(ir) || progress; - progress = do_vec_index_to_swizzle(ir) || progress; - progress = do_swizzle_swizzle(ir) || progress; - progress = do_noop_swizzle(ir) || progress; - - progress = optimize_redundant_jumps(ir) || progress; - - loop_state *ls = analyze_loop_variables(ir); - if (ls->loop_found) { - progress = set_loop_controls(ir, ls) || progress; - progress = unroll_loops(ir, ls, max_unroll_iterations) || progress; - } - delete ls; - - return progress; -} - -extern "C" { - -/** - * To be called at GL teardown time, this frees compiler datastructures. - * - * After calling this, any previously compiled shaders and shader - * programs would be invalid. So this should happen at approximately - * program exit. - */ -void -_mesa_destroy_shader_compiler(void) -{ - _mesa_destroy_shader_compiler_caches(); - - _mesa_glsl_release_types(); -} - -/** - * Releases compiler caches to trade off performance for memory. - * - * Intended to be used with glReleaseShaderCompiler(). - */ -void -_mesa_destroy_shader_compiler_caches(void) -{ - _mesa_glsl_release_functions(); -} - -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.h b/reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.h deleted file mode 100644 index ca8ae04b152..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_parser_extras.h +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef GLSL_PARSER_EXTRAS_H -#define GLSL_PARSER_EXTRAS_H - -/* - * Most of the definitions here only apply to C++ - */ -#ifdef __cplusplus - - -#include -#include "glsl_symbol_table.h" - -enum _mesa_glsl_parser_targets { - vertex_shader, - fragment_shader -}; - -struct gl_context; - -struct glsl_switch_state { - /** Temporary variables needed for switch statement. */ - ir_variable *test_var; - ir_variable *is_fallthru_var; - ir_variable *is_break_var; - class ast_switch_statement *switch_nesting_ast; - - /** Table of constant values already used in case labels */ - struct hash_table *labels_ht; - class ast_case_label *previous_default; - - bool is_switch_innermost; // if switch stmt is closest to break, ... -}; - -struct _mesa_glsl_parse_state { - _mesa_glsl_parse_state(struct gl_context *ctx, GLenum target, - void *mem_ctx); - - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *mem = rzalloc_size(ctx, size); - assert(mem != NULL); - - return mem; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *mem) - { - ralloc_free(mem); - } - - void *scanner; - exec_list translation_unit; - glsl_symbol_table *symbols; - - unsigned language_version; - const char *version_string; - enum _mesa_glsl_parser_targets target; - - /** - * Printable list of GLSL versions supported by the current context - * - * \note - * This string should probably be generated per-context instead of per - * invokation of the compiler. This should be changed when the method of - * tracking supported GLSL versions changes. - */ - const char *supported_version_string; - - /** - * Implementation defined limits that affect built-in variables, etc. - * - * \sa struct gl_constants (in mtypes.h) - */ - struct { - /* 1.10 */ - unsigned MaxLights; - unsigned MaxClipPlanes; - unsigned MaxTextureUnits; - unsigned MaxTextureCoords; - unsigned MaxVertexAttribs; - unsigned MaxVertexUniformComponents; - unsigned MaxVaryingFloats; - unsigned MaxVertexTextureImageUnits; - unsigned MaxCombinedTextureImageUnits; - unsigned MaxTextureImageUnits; - unsigned MaxFragmentUniformComponents; - - /* ARB_draw_buffers */ - unsigned MaxDrawBuffers; - - /** - * Set of GLSL versions supported by the current context - * - * Knowing that version X is supported doesn't mean that versions before - * X are also supported. Version 1.00 is only supported in an ES2 - * context or when GL_ARB_ES2_compatibility is supported. In an OpenGL - * 3.0 "forward compatible" context, GLSL 1.10 and 1.20 are \b not - * supported. - */ - /*@{*/ - unsigned GLSL_110:1; - unsigned GLSL_120:1; - unsigned GLSL_130:1; - /*@}*/ - } Const; - - /** - * During AST to IR conversion, pointer to current IR function - * - * Will be \c NULL whenever the AST to IR conversion is not inside a - * function definition. - */ - class ir_function_signature *current_function; - - /** - * During AST to IR conversion, pointer to the toplevel IR - * instruction list being generated. - */ - exec_list *toplevel_ir; - - /** Have we found a return statement in this function? */ - bool found_return; - - /** Was there an error during compilation? */ - bool error; - - /** - * Are all shader inputs / outputs invariant? - * - * This is set when the 'STDGL invariant(all)' pragma is used. - */ - bool all_invariant; - - /** Loop or switch statement containing the current instructions. */ - class ast_iteration_statement *loop_nesting_ast; - - struct glsl_switch_state switch_state; - - /** List of structures defined in user code. */ - const glsl_type **user_structures; - unsigned num_user_structures; - - char *info_log; - - /** - * \name Enable bits for GLSL extensions - */ - /*@{*/ - bool ARB_draw_buffers_enable; - bool ARB_draw_buffers_warn; - bool ARB_shader_texture_lod_enable; - bool ARB_shader_texture_lod_warn; - bool ARB_shader_stencil_export_enable; - bool ARB_shader_stencil_export_warn; - bool AMD_conservative_depth_enable; - bool AMD_conservative_depth_warn; - bool ARB_conservative_depth_enable; - bool ARB_conservative_depth_warn; - bool AMD_shader_stencil_export_enable; - bool AMD_shader_stencil_export_warn; - bool OES_texture_3D_enable; - bool OES_texture_3D_warn; - /*@}*/ - - /** Extensions supported by the OpenGL implementation. */ - const struct gl_extensions *extensions; - - /** Shaders containing built-in functions that are used for linking. */ - struct gl_shader *builtins_to_link[16]; - unsigned num_builtins_to_link; -}; - -typedef struct YYLTYPE { - int first_line; - int first_column; - int last_line; - int last_column; - unsigned source; -} YYLTYPE; -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 - -# define YYLLOC_DEFAULT(Current, Rhs, N) \ -do { \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC(Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC(Rhs, 0).last_column; \ - } \ - (Current).source = 0; \ -} while (0) - -extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, - const char *fmt, ...); - -/** - * Emit a warning to the shader log - * - * \sa _mesa_glsl_error - */ -extern void _mesa_glsl_warning(const YYLTYPE *locp, - _mesa_glsl_parse_state *state, - const char *fmt, ...); - -extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string); - -extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); - -union YYSTYPE; -extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, - void *scanner); - -extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); - -/** - * Process elements of the #extension directive - * - * \return - * If \c name and \c behavior are valid, \c true is returned. Otherwise - * \c false is returned. - */ -extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, - const char *behavior, - YYLTYPE *behavior_locp, - _mesa_glsl_parse_state *state); - -/** - * Get the textual name of the specified shader target - */ -extern const char * -_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target); - - -#endif /* __cplusplus */ - - -/* - * These definitions apply to C and C++ - */ -#ifdef __cplusplus -extern "C" { -#endif - -extern int preprocess(void *ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions); - -extern void _mesa_destroy_shader_compiler(void); -extern void _mesa_destroy_shader_compiler_caches(void); - -#ifdef __cplusplus -} -#endif - - -#endif /* GLSL_PARSER_EXTRAS_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.cpp b/reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.cpp deleted file mode 100644 index bcb65d30182..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "glsl_symbol_table.h" - -class symbol_table_entry { -public: - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *entry = ralloc_size(ctx, size); - assert(entry != NULL); - return entry; - } - - /* If the user *does* call delete, that's OK, we will just ralloc_free. */ - static void operator delete(void *entry) - { - ralloc_free(entry); - } - - symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {} - symbol_table_entry(ir_function *f) : v(0), f(f), t(0) {} - symbol_table_entry(const glsl_type *t) : v(0), f(0), t(t) {} - - ir_variable *v; - ir_function *f; - const glsl_type *t; -}; - -glsl_symbol_table::glsl_symbol_table() -{ - this->language_version = 120; - this->table = _mesa_symbol_table_ctor(); - this->mem_ctx = ralloc_context(NULL); -} - -glsl_symbol_table::~glsl_symbol_table() -{ - _mesa_symbol_table_dtor(table); - ralloc_free(mem_ctx); -} - -void glsl_symbol_table::push_scope() -{ - _mesa_symbol_table_push_scope(table); -} - -void glsl_symbol_table::pop_scope() -{ - _mesa_symbol_table_pop_scope(table); -} - -bool glsl_symbol_table::name_declared_this_scope(const char *name) -{ - return _mesa_symbol_table_symbol_scope(table, -1, name) == 0; -} - -bool glsl_symbol_table::add_variable(ir_variable *v) -{ - if (this->language_version == 110) { - /* In 1.10, functions and variables have separate namespaces. */ - symbol_table_entry *existing = get_entry(v->name); - if (name_declared_this_scope(v->name)) { - /* If there's already an existing function (not a constructor!) in - * the current scope, just update the existing entry to include 'v'. - */ - if (existing->v == NULL && existing->t == NULL) { - existing->v = v; - return true; - } - } else { - /* If not declared at this scope, add a new entry. But if an existing - * entry includes a function, propagate that to this block - otherwise - * the new variable declaration would shadow the function. - */ - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(v); - if (existing != NULL) - entry->f = existing->f; - int added = _mesa_symbol_table_add_symbol(table, -1, v->name, entry); - assert(added == 0); - (void)added; - return true; - } - return false; - } - - /* 1.20+ rules: */ - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(v); - return _mesa_symbol_table_add_symbol(table, -1, v->name, entry) == 0; -} - -bool glsl_symbol_table::add_type(const char *name, const glsl_type *t) -{ - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(t); - return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0; -} - -bool glsl_symbol_table::add_function(ir_function *f) -{ - if (this->language_version == 110 && name_declared_this_scope(f->name)) { - /* In 1.10, functions and variables have separate namespaces. */ - symbol_table_entry *existing = get_entry(f->name); - if ((existing->f == NULL) && (existing->t == NULL)) { - existing->f = f; - return true; - } - } - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f); - return _mesa_symbol_table_add_symbol(table, -1, f->name, entry) == 0; -} - -void glsl_symbol_table::add_global_function(ir_function *f) -{ - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(f); - int added = _mesa_symbol_table_add_global_symbol(table, -1, f->name, entry); - assert(added == 0); - (void)added; -} - -ir_variable *glsl_symbol_table::get_variable(const char *name) -{ - symbol_table_entry *entry = get_entry(name); - return entry != NULL ? entry->v : NULL; -} - -const glsl_type *glsl_symbol_table::get_type(const char *name) -{ - symbol_table_entry *entry = get_entry(name); - return entry != NULL ? entry->t : NULL; -} - -ir_function *glsl_symbol_table::get_function(const char *name) -{ - symbol_table_entry *entry = get_entry(name); - return entry != NULL ? entry->f : NULL; -} - -symbol_table_entry *glsl_symbol_table::get_entry(const char *name) -{ - return (symbol_table_entry *) - _mesa_symbol_table_find_symbol(table, -1, name); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.h b/reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.h deleted file mode 100644 index 637bc033b93..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_symbol_table.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef GLSL_SYMBOL_TABLE -#define GLSL_SYMBOL_TABLE - -#include - -extern "C" { -#include "program/symbol_table.h" -} -#include "ir.h" -#include "glsl_types.h" - -class symbol_table_entry; - -/** - * Facade class for _mesa_symbol_table - * - * Wraps the existing \c _mesa_symbol_table data structure to enforce some - * type safe and some symbol table invariants. - */ -struct glsl_symbol_table { -private: - static void - _glsl_symbol_table_destructor (glsl_symbol_table *table) - { - table->~glsl_symbol_table(); - } - -public: - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *table; - - table = ralloc_size(ctx, size); - assert(table != NULL); - - ralloc_set_destructor(table, (void (*)(void*)) _glsl_symbol_table_destructor); - - return table; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. Here, C++ will have already called the - * destructor so tell ralloc not to do that again. */ - static void operator delete(void *table) - { - ralloc_set_destructor(table, NULL); - ralloc_free(table); - } - - glsl_symbol_table(); - ~glsl_symbol_table(); - - unsigned int language_version; - - void push_scope(); - void pop_scope(); - - /** - * Determine whether a name was declared at the current scope - */ - bool name_declared_this_scope(const char *name); - - /** - * \name Methods to add symbols to the table - * - * There is some temptation to rename all these functions to \c add_symbol - * or similar. However, this breaks symmetry with the getter functions and - * reduces the clarity of the intention of code that uses these methods. - */ - /*@{*/ - bool add_variable(ir_variable *v); - bool add_type(const char *name, const glsl_type *t); - bool add_function(ir_function *f); - /*@}*/ - - /** - * Add an function at global scope without checking for scoping conflicts. - */ - void add_global_function(ir_function *f); - - /** - * \name Methods to get symbols from the table - */ - /*@{*/ - ir_variable *get_variable(const char *name); - const glsl_type *get_type(const char *name); - ir_function *get_function(const char *name); - /*@}*/ - -private: - symbol_table_entry *get_entry(const char *name); - - struct _mesa_symbol_table *table; - void *mem_ctx; -}; - -#endif /* GLSL_SYMBOL_TABLE */ diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_types.cpp b/reactos/dll/opengl/mesa/src/glsl/glsl_types.cpp deleted file mode 100644 index e7036798e4b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_types.cpp +++ /dev/null @@ -1,550 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include "main/core.h" /* for Elements */ -#include "glsl_symbol_table.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" -#include "builtin_types.h" -extern "C" { -#include "program/hash_table.h" -} - -hash_table *glsl_type::array_types = NULL; -hash_table *glsl_type::record_types = NULL; -void *glsl_type::mem_ctx = NULL; - -void -glsl_type::init_ralloc_type_ctx(void) -{ - if (glsl_type::mem_ctx == NULL) { - glsl_type::mem_ctx = ralloc_autofree_context(); - assert(glsl_type::mem_ctx != NULL); - } -} - -glsl_type::glsl_type(GLenum gl_type, - glsl_base_type base_type, unsigned vector_elements, - unsigned matrix_columns, const char *name) : - gl_type(gl_type), - base_type(base_type), - sampler_dimensionality(0), sampler_shadow(0), - sampler_type(0), - vector_elements(vector_elements), matrix_columns(matrix_columns), - length(0) -{ - init_ralloc_type_ctx(); - this->name = ralloc_strdup(this->mem_ctx, name); - /* Neither dimension is zero or both dimensions are zero. - */ - assert((vector_elements == 0) == (matrix_columns == 0)); - memset(& fields, 0, sizeof(fields)); -} - -glsl_type::glsl_type(GLenum gl_type, - enum glsl_sampler_dim dim, bool shadow, bool array, - unsigned type, const char *name) : - gl_type(gl_type), - base_type(GLSL_TYPE_SAMPLER), - sampler_dimensionality(dim), sampler_shadow(shadow), - sampler_type(type), - vector_elements(0), matrix_columns(0), - length(0) -{ - init_ralloc_type_ctx(); - this->name = ralloc_strdup(this->mem_ctx, name); - memset(& fields, 0, sizeof(fields)); -} - -glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, - const char *name) : - base_type(GLSL_TYPE_STRUCT), - sampler_dimensionality(0), sampler_shadow(0), - sampler_type(0), - vector_elements(0), matrix_columns(0), - length(num_fields) -{ - unsigned int i; - - init_ralloc_type_ctx(); - this->name = ralloc_strdup(this->mem_ctx, name); - this->fields.structure = ralloc_array(this->mem_ctx, - glsl_struct_field, length); - for (i = 0; i < length; i++) { - this->fields.structure[i].type = fields[i].type; - this->fields.structure[i].name = ralloc_strdup(this->fields.structure, - fields[i].name); - } -} - -static void -add_types_to_symbol_table(glsl_symbol_table *symtab, - const struct glsl_type *types, - unsigned num_types, bool warn) -{ - (void) warn; - - for (unsigned i = 0; i < num_types; i++) { - symtab->add_type(types[i].name, & types[i]); - } -} - -bool -glsl_type::contains_sampler() const -{ - if (this->is_array()) { - return this->fields.array->contains_sampler(); - } else if (this->is_record()) { - for (unsigned int i = 0; i < this->length; i++) { - if (this->fields.structure[i].type->contains_sampler()) - return true; - } - return false; - } else { - return this->is_sampler(); - } -} - -gl_texture_index -glsl_type::sampler_index() const -{ - const glsl_type *const t = (this->is_array()) ? this->fields.array : this; - - assert(t->is_sampler()); - - switch (t->sampler_dimensionality) { - case GLSL_SAMPLER_DIM_1D: - return TEXTURE_1D_INDEX; - case GLSL_SAMPLER_DIM_2D: - return TEXTURE_2D_INDEX; - case GLSL_SAMPLER_DIM_3D: - return TEXTURE_3D_INDEX; - case GLSL_SAMPLER_DIM_CUBE: - return TEXTURE_CUBE_INDEX; - default: - assert(!"Should not get here."); - return TEXTURE_2D_INDEX; - } -} - -void -glsl_type::generate_100ES_types(glsl_symbol_table *symtab) -{ - add_types_to_symbol_table(symtab, builtin_core_types, - Elements(builtin_core_types), - false); - add_types_to_symbol_table(symtab, builtin_structure_types, - Elements(builtin_structure_types), - false); - add_types_to_symbol_table(symtab, void_type, 1, false); -} - -void -glsl_type::generate_110_types(glsl_symbol_table *symtab) -{ - generate_100ES_types(symtab); - - add_types_to_symbol_table(symtab, builtin_110_types, - Elements(builtin_110_types), - false); - add_types_to_symbol_table(symtab, &_sampler3D_type, 1, false); - add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types, - Elements(builtin_110_deprecated_structure_types), - false); -} - - -void -glsl_type::generate_120_types(glsl_symbol_table *symtab) -{ - generate_110_types(symtab); - - add_types_to_symbol_table(symtab, builtin_120_types, - Elements(builtin_120_types), false); -} - - -void -glsl_type::generate_130_types(glsl_symbol_table *symtab) -{ - generate_120_types(symtab); - - add_types_to_symbol_table(symtab, builtin_130_types, - Elements(builtin_130_types), false); -} - - -void -glsl_type::generate_OES_texture_3D_types(glsl_symbol_table *symtab, bool warn) -{ - add_types_to_symbol_table(symtab, &_sampler3D_type, 1, warn); -} - -void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) -{ - switch (state->language_version) { - case 110: - glsl_type::generate_110_types(state->symbols); - break; - case 120: - glsl_type::generate_120_types(state->symbols); - break; - case 130: - glsl_type::generate_130_types(state->symbols); - break; - default: - /* error */ - break; - } - - if (state->OES_texture_3D_enable && state->language_version == 100) { - glsl_type::generate_OES_texture_3D_types(state->symbols, - state->OES_texture_3D_warn); - } -} - - -const glsl_type *glsl_type::get_base_type() const -{ - switch (base_type) { - case GLSL_TYPE_UINT: - return uint_type; - case GLSL_TYPE_INT: - return int_type; - case GLSL_TYPE_FLOAT: - return float_type; - case GLSL_TYPE_BOOL: - return bool_type; - default: - return error_type; - } -} - - -const glsl_type *glsl_type::get_scalar_type() const -{ - const glsl_type *type = this; - - /* Handle arrays */ - while (type->base_type == GLSL_TYPE_ARRAY) - type = type->fields.array; - - /* Handle vectors and matrices */ - switch (type->base_type) { - case GLSL_TYPE_UINT: - return uint_type; - case GLSL_TYPE_INT: - return int_type; - case GLSL_TYPE_FLOAT: - return float_type; - default: - /* Handle everything else */ - return type; - } -} - - -void -_mesa_glsl_release_types(void) -{ - if (glsl_type::array_types != NULL) { - hash_table_dtor(glsl_type::array_types); - glsl_type::array_types = NULL; - } - - if (glsl_type::record_types != NULL) { - hash_table_dtor(glsl_type::record_types); - glsl_type::record_types = NULL; - } -} - - -glsl_type::glsl_type(const glsl_type *array, unsigned length) : - base_type(GLSL_TYPE_ARRAY), - sampler_dimensionality(0), sampler_shadow(0), - sampler_type(0), - vector_elements(0), matrix_columns(0), - name(NULL), length(length) -{ - this->fields.array = array; - /* Inherit the gl type of the base. The GL type is used for - * uniform/statevar handling in Mesa and the arrayness of the type - * is represented by the size rather than the type. - */ - this->gl_type = array->gl_type; - - /* Allow a maximum of 10 characters for the array size. This is enough - * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating - * NUL. - */ - const unsigned name_length = strlen(array->name) + 10 + 3; - char *const n = (char *) ralloc_size(this->mem_ctx, name_length); - - if (length == 0) - snprintf(n, name_length, "%s[]", array->name); - else - snprintf(n, name_length, "%s[%u]", array->name, length); - - this->name = n; -} - - -const glsl_type * -glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns) -{ - if (base_type == GLSL_TYPE_VOID) - return void_type; - - if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4)) - return error_type; - - /* Treat GLSL vectors as Nx1 matrices. - */ - if (columns == 1) { - switch (base_type) { - case GLSL_TYPE_UINT: - return uint_type + (rows - 1); - case GLSL_TYPE_INT: - return int_type + (rows - 1); - case GLSL_TYPE_FLOAT: - return float_type + (rows - 1); - case GLSL_TYPE_BOOL: - return bool_type + (rows - 1); - default: - return error_type; - } - } else { - if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1)) - return error_type; - - /* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following - * combinations are valid: - * - * 1 2 3 4 - * 1 - * 2 x x x - * 3 x x x - * 4 x x x - */ -#define IDX(c,r) (((c-1)*3) + (r-1)) - - switch (IDX(columns, rows)) { - case IDX(2,2): return mat2_type; - case IDX(2,3): return mat2x3_type; - case IDX(2,4): return mat2x4_type; - case IDX(3,2): return mat3x2_type; - case IDX(3,3): return mat3_type; - case IDX(3,4): return mat3x4_type; - case IDX(4,2): return mat4x2_type; - case IDX(4,3): return mat4x3_type; - case IDX(4,4): return mat4_type; - default: return error_type; - } - } - - assert(!"Should not get here."); - return error_type; -} - - -const glsl_type * -glsl_type::get_array_instance(const glsl_type *base, unsigned array_size) -{ - - if (array_types == NULL) { - array_types = hash_table_ctor(64, hash_table_string_hash, - hash_table_string_compare); - } - - /* Generate a name using the base type pointer in the key. This is - * done because the name of the base type may not be unique across - * shaders. For example, two shaders may have different record types - * named 'foo'. - */ - char key[128]; - snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size); - - const glsl_type *t = (glsl_type *) hash_table_find(array_types, key); - if (t == NULL) { - t = new glsl_type(base, array_size); - - hash_table_insert(array_types, (void *) t, ralloc_strdup(mem_ctx, key)); - } - - assert(t->base_type == GLSL_TYPE_ARRAY); - assert(t->length == array_size); - assert(t->fields.array == base); - - return t; -} - - -int -glsl_type::record_key_compare(const void *a, const void *b) -{ - const glsl_type *const key1 = (glsl_type *) a; - const glsl_type *const key2 = (glsl_type *) b; - - /* Return zero is the types match (there is zero difference) or non-zero - * otherwise. - */ - if (strcmp(key1->name, key2->name) != 0) - return 1; - - if (key1->length != key2->length) - return 1; - - for (unsigned i = 0; i < key1->length; i++) { - if (key1->fields.structure[i].type != key2->fields.structure[i].type) - return 1; - if (strcmp(key1->fields.structure[i].name, - key2->fields.structure[i].name) != 0) - return 1; - } - - return 0; -} - - -unsigned -glsl_type::record_key_hash(const void *a) -{ - const glsl_type *const key = (glsl_type *) a; - char hash_key[128]; - unsigned size = 0; - - size = snprintf(hash_key, sizeof(hash_key), "%08x", key->length); - - for (unsigned i = 0; i < key->length; i++) { - if (size >= sizeof(hash_key)) - break; - - size += snprintf(& hash_key[size], sizeof(hash_key) - size, - "%p", (void *) key->fields.structure[i].type); - } - - return hash_table_string_hash(& hash_key); -} - - -const glsl_type * -glsl_type::get_record_instance(const glsl_struct_field *fields, - unsigned num_fields, - const char *name) -{ - const glsl_type key(fields, num_fields, name); - - if (record_types == NULL) { - record_types = hash_table_ctor(64, record_key_hash, record_key_compare); - } - - const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key); - if (t == NULL) { - t = new glsl_type(fields, num_fields, name); - - hash_table_insert(record_types, (void *) t, t); - } - - assert(t->base_type == GLSL_TYPE_STRUCT); - assert(t->length == num_fields); - assert(strcmp(t->name, name) == 0); - - return t; -} - - -const glsl_type * -glsl_type::field_type(const char *name) const -{ - if (this->base_type != GLSL_TYPE_STRUCT) - return error_type; - - for (unsigned i = 0; i < this->length; i++) { - if (strcmp(name, this->fields.structure[i].name) == 0) - return this->fields.structure[i].type; - } - - return error_type; -} - - -int -glsl_type::field_index(const char *name) const -{ - if (this->base_type != GLSL_TYPE_STRUCT) - return -1; - - for (unsigned i = 0; i < this->length; i++) { - if (strcmp(name, this->fields.structure[i].name) == 0) - return i; - } - - return -1; -} - - -unsigned -glsl_type::component_slots() const -{ - switch (this->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - return this->components(); - - case GLSL_TYPE_STRUCT: { - unsigned size = 0; - - for (unsigned i = 0; i < this->length; i++) - size += this->fields.structure[i].type->component_slots(); - - return size; - } - - case GLSL_TYPE_ARRAY: - return this->length * this->fields.array->component_slots(); - - default: - return 0; - } -} - -bool -glsl_type::can_implicitly_convert_to(const glsl_type *desired) const -{ - if (this == desired) - return true; - - /* There is no conversion among matrix types. */ - if (this->matrix_columns > 1 || desired->matrix_columns > 1) - return false; - - /* int and uint can be converted to float. */ - return desired->is_float() - && this->is_integer() - && this->vector_elements == desired->vector_elements; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/glsl_types.h b/reactos/dll/opengl/mesa/src/glsl/glsl_types.h deleted file mode 100644 index a6947b2c2a9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/glsl_types.h +++ /dev/null @@ -1,538 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef GLSL_TYPES_H -#define GLSL_TYPES_H - -#include -#include -#include "main/mtypes.h" /* for gl_texture_index, C++'s enum rules are broken */ - -#ifdef __cplusplus -extern "C" { -#endif - -struct _mesa_glsl_parse_state; -struct glsl_symbol_table; - -extern void -_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state); - -extern void -_mesa_glsl_release_types(void); - -#ifdef __cplusplus -} -#endif - -enum glsl_base_type { - GLSL_TYPE_UINT = 0, - GLSL_TYPE_INT, - GLSL_TYPE_FLOAT, - GLSL_TYPE_BOOL, - GLSL_TYPE_SAMPLER, - GLSL_TYPE_STRUCT, - GLSL_TYPE_ARRAY, - GLSL_TYPE_VOID, - GLSL_TYPE_ERROR -}; - -enum glsl_sampler_dim { - GLSL_SAMPLER_DIM_1D = 0, - GLSL_SAMPLER_DIM_2D, - GLSL_SAMPLER_DIM_3D, - GLSL_SAMPLER_DIM_CUBE, - GLSL_SAMPLER_DIM_RECT, - GLSL_SAMPLER_DIM_BUF, - GLSL_SAMPLER_DIM_EXTERNAL -}; - -#ifdef __cplusplus -#include "GL/gl.h" -#include "ralloc.h" - -struct glsl_type { - GLenum gl_type; - glsl_base_type base_type; - - unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */ - unsigned sampler_shadow:1; - unsigned sampler_type:2; /**< Type of data returned using this sampler. - * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT, - * and \c GLSL_TYPE_UINT are valid. - */ - - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'mem_ctx' (or any of its ancestors). */ - static void* operator new(size_t size) - { - if (glsl_type::mem_ctx == NULL) { - glsl_type::mem_ctx = ralloc_context(NULL); - assert(glsl_type::mem_ctx != NULL); - } - - void *type; - - type = ralloc_size(glsl_type::mem_ctx, size); - assert(type != NULL); - - return type; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *type) - { - ralloc_free(type); - } - - /** - * \name Vector and matrix element counts - * - * For scalars, each of these values will be 1. For non-numeric types - * these will be 0. - */ - /*@{*/ - unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */ - unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */ - /*@}*/ - - /** - * Name of the data type - * - * This may be \c NULL for anonymous structures, for arrays, or for - * function types. - */ - const char *name; - - /** - * For \c GLSL_TYPE_ARRAY, this is the length of the array. For - * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and - * the number of values pointed to by \c fields.structure (below). - */ - unsigned length; - - /** - * Subtype of composite data types. - */ - union { - const struct glsl_type *array; /**< Type of array elements. */ - const struct glsl_type *parameters; /**< Parameters to function. */ - struct glsl_struct_field *structure; /**< List of struct fields. */ - } fields; - - - /** - * \name Pointers to various public type singletons - */ - /*@{*/ - static const glsl_type *const error_type; - static const glsl_type *const void_type; - static const glsl_type *const int_type; - static const glsl_type *const ivec4_type; - static const glsl_type *const uint_type; - static const glsl_type *const uvec2_type; - static const glsl_type *const uvec3_type; - static const glsl_type *const uvec4_type; - static const glsl_type *const float_type; - static const glsl_type *const vec2_type; - static const glsl_type *const vec3_type; - static const glsl_type *const vec4_type; - static const glsl_type *const bool_type; - static const glsl_type *const mat2_type; - static const glsl_type *const mat2x3_type; - static const glsl_type *const mat2x4_type; - static const glsl_type *const mat3x2_type; - static const glsl_type *const mat3_type; - static const glsl_type *const mat3x4_type; - static const glsl_type *const mat4x2_type; - static const glsl_type *const mat4x3_type; - static const glsl_type *const mat4_type; - /*@}*/ - - - /** - * For numeric and boolean derrived types returns the basic scalar type - * - * If the type is a numeric or boolean scalar, vector, or matrix type, - * this function gets the scalar type of the individual components. For - * all other types, including arrays of numeric or boolean types, the - * error type is returned. - */ - const glsl_type *get_base_type() const; - - /** - * Get the basic scalar type which this type aggregates. - * - * If the type is a numeric or boolean scalar, vector, or matrix, or an - * array of any of those, this function gets the scalar type of the - * individual components. For structs and arrays of structs, this function - * returns the struct type. For samplers and arrays of samplers, this - * function returns the sampler type. - */ - const glsl_type *get_scalar_type() const; - - /** - * Query the type of elements in an array - * - * \return - * Pointer to the type of elements in the array for array types, or \c NULL - * for non-array types. - */ - const glsl_type *element_type() const - { - return is_array() ? fields.array : NULL; - } - - /** - * Get the instance of a built-in scalar, vector, or matrix type - */ - static const glsl_type *get_instance(unsigned base_type, unsigned rows, - unsigned columns); - - /** - * Get the instance of an array type - */ - static const glsl_type *get_array_instance(const glsl_type *base, - unsigned elements); - - /** - * Get the instance of a record type - */ - static const glsl_type *get_record_instance(const glsl_struct_field *fields, - unsigned num_fields, - const char *name); - - /** - * Query the total number of scalars that make up a scalar, vector or matrix - */ - unsigned components() const - { - return vector_elements * matrix_columns; - } - - /** - * Calculate the number of components slots required to hold this type - * - * This is used to determine how many uniform or varying locations a type - * might occupy. - */ - unsigned component_slots() const; - - /** - * \brief Can this type be implicitly converted to another? - * - * \return True if the types are identical or if this type can be converted - * to \c desired according to Section 4.1.10 of the GLSL spec. - * - * \verbatim - * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10 - * Implicit Conversions: - * - * In some situations, an expression and its type will be implicitly - * converted to a different type. The following table shows all allowed - * implicit conversions: - * - * Type of expression | Can be implicitly converted to - * -------------------------------------------------- - * int float - * uint - * - * ivec2 vec2 - * uvec2 - * - * ivec3 vec3 - * uvec3 - * - * ivec4 vec4 - * uvec4 - * - * There are no implicit array or structure conversions. For example, - * an array of int cannot be implicitly converted to an array of float. - * There are no implicit conversions between signed and unsigned - * integers. - * \endverbatim - */ - bool can_implicitly_convert_to(const glsl_type *desired) const; - - /** - * Query whether or not a type is a scalar (non-vector and non-matrix). - */ - bool is_scalar() const - { - return (vector_elements == 1) - && (base_type >= GLSL_TYPE_UINT) - && (base_type <= GLSL_TYPE_BOOL); - } - - /** - * Query whether or not a type is a vector - */ - bool is_vector() const - { - return (vector_elements > 1) - && (matrix_columns == 1) - && (base_type >= GLSL_TYPE_UINT) - && (base_type <= GLSL_TYPE_BOOL); - } - - /** - * Query whether or not a type is a matrix - */ - bool is_matrix() const - { - /* GLSL only has float matrices. */ - return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT); - } - - /** - * Query whether or not a type is a non-array numeric type - */ - bool is_numeric() const - { - return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT); - } - - /** - * Query whether or not a type is an integral type - */ - bool is_integer() const - { - return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT); - } - - /** - * Query whether or not a type is a float type - */ - bool is_float() const - { - return base_type == GLSL_TYPE_FLOAT; - } - - /** - * Query whether or not a type is a non-array boolean type - */ - bool is_boolean() const - { - return base_type == GLSL_TYPE_BOOL; - } - - /** - * Query whether or not a type is a sampler - */ - bool is_sampler() const - { - return base_type == GLSL_TYPE_SAMPLER; - } - - /** - * Query whether or not type is a sampler, or for struct and array - * types, contains a sampler. - */ - bool contains_sampler() const; - - /** - * Get the Mesa texture target index for a sampler type. - */ - gl_texture_index sampler_index() const; - - /** - * Query whether or not a type is an array - */ - bool is_array() const - { - return base_type == GLSL_TYPE_ARRAY; - } - - /** - * Query whether or not a type is a record - */ - bool is_record() const - { - return base_type == GLSL_TYPE_STRUCT; - } - - /** - * Query whether or not a type is the void type singleton. - */ - bool is_void() const - { - return base_type == GLSL_TYPE_VOID; - } - - /** - * Query whether or not a type is the error type singleton. - */ - bool is_error() const - { - return base_type == GLSL_TYPE_ERROR; - } - - /** - * Query the full type of a matrix row - * - * \return - * If the type is not a matrix, \c glsl_type::error_type is returned. - * Otherwise a type matching the rows of the matrix is returned. - */ - const glsl_type *row_type() const - { - return is_matrix() - ? get_instance(base_type, matrix_columns, 1) - : error_type; - } - - /** - * Query the full type of a matrix column - * - * \return - * If the type is not a matrix, \c glsl_type::error_type is returned. - * Otherwise a type matching the columns of the matrix is returned. - */ - const glsl_type *column_type() const - { - return is_matrix() - ? get_instance(base_type, vector_elements, 1) - : error_type; - } - - - /** - * Get the type of a structure field - * - * \return - * Pointer to the type of the named field. If the type is not a structure - * or the named field does not exist, \c glsl_type::error_type is returned. - */ - const glsl_type *field_type(const char *name) const; - - - /** - * Get the location of a filed within a record type - */ - int field_index(const char *name) const; - - - /** - * Query the number of elements in an array type - * - * \return - * The number of elements in the array for array types or -1 for non-array - * types. If the number of elements in the array has not yet been declared, - * zero is returned. - */ - int array_size() const - { - return is_array() ? length : -1; - } - -private: - /** - * ralloc context for all glsl_type allocations - * - * Set on the first call to \c glsl_type::new. - */ - static void *mem_ctx; - - void init_ralloc_type_ctx(void); - - /** Constructor for vector and matrix types */ - glsl_type(GLenum gl_type, - glsl_base_type base_type, unsigned vector_elements, - unsigned matrix_columns, const char *name); - - /** Constructor for sampler types */ - glsl_type(GLenum gl_type, - enum glsl_sampler_dim dim, bool shadow, bool array, - unsigned type, const char *name); - - /** Constructor for record types */ - glsl_type(const glsl_struct_field *fields, unsigned num_fields, - const char *name); - - /** Constructor for array types */ - glsl_type(const glsl_type *array, unsigned length); - - /** Hash table containing the known array types. */ - static struct hash_table *array_types; - - /** Hash table containing the known record types. */ - static struct hash_table *record_types; - - static int record_key_compare(const void *a, const void *b); - static unsigned record_key_hash(const void *key); - - /** - * \name Pointers to various type singletons - */ - /*@{*/ - static const glsl_type _error_type; - static const glsl_type _void_type; - static const glsl_type _sampler3D_type; - static const glsl_type builtin_core_types[]; - static const glsl_type builtin_structure_types[]; - static const glsl_type builtin_110_deprecated_structure_types[]; - static const glsl_type builtin_110_types[]; - static const glsl_type builtin_120_types[]; - static const glsl_type builtin_130_types[]; - /*@}*/ - - /** - * \name Methods to populate a symbol table with built-in types. - * - * \internal - * This is one of the truely annoying things about C++. Methods that are - * completely internal and private to a type still have to be advertised to - * the world in a public header file. - */ - /*@{*/ - static void generate_100ES_types(glsl_symbol_table *); - static void generate_110_types(glsl_symbol_table *); - static void generate_120_types(glsl_symbol_table *); - static void generate_130_types(glsl_symbol_table *); - static void generate_OES_texture_3D_types(glsl_symbol_table *, bool); - /*@}*/ - - /** - * \name Friend functions. - * - * These functions are friends because they must have C linkage and the - * need to call various private methods or access various private static - * data. - */ - /*@{*/ - friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *); - friend void _mesa_glsl_release_types(void); - /*@}*/ -}; - -struct glsl_struct_field { - const struct glsl_type *type; - const char *name; -}; - -#endif /* __cplusplus */ - -#endif /* GLSL_TYPES_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/hir_field_selection.cpp b/reactos/dll/opengl/mesa/src/glsl/hir_field_selection.cpp deleted file mode 100644 index 3c33127b5f8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/hir_field_selection.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir.h" -#include "program/symbol_table.h" -#include "glsl_parser_extras.h" -#include "ast.h" -#include "glsl_types.h" - -ir_rvalue * -_mesa_ast_field_selection_to_hir(const ast_expression *expr, - exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - void *ctx = state; - ir_rvalue *result = NULL; - ir_rvalue *op; - - op = expr->subexpressions[0]->hir(instructions, state); - - /* There are two kinds of field selection. There is the selection of a - * specific field from a structure, and there is the selection of a - * swizzle / mask from a vector. Which is which is determined entirely - * by the base type of the thing to which the field selection operator is - * being applied. - */ - YYLTYPE loc = expr->get_location(); - if (op->type->is_error()) { - /* silently propagate the error */ - } else if (op->type->is_vector()) { - ir_swizzle *swiz = ir_swizzle::create(op, - expr->primary_expression.identifier, - op->type->vector_elements); - if (swiz != NULL) { - result = swiz; - } else { - /* FINISHME: Logging of error messages should be moved into - * FINISHME: ir_swizzle::create. This allows the generation of more - * FINISHME: specific error messages. - */ - _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'", - expr->primary_expression.identifier); - } - } else if (op->type->base_type == GLSL_TYPE_STRUCT) { - result = new(ctx) ir_dereference_record(op, - expr->primary_expression.identifier); - - if (result->type->is_error()) { - _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " - "structure", - expr->primary_expression.identifier); - } - } else if (expr->subexpressions[1] != NULL) { - /* Handle "method calls" in GLSL 1.20 - namely, array.length() */ - if (state->language_version < 120) - _mesa_glsl_error(&loc, state, "Methods not supported in GLSL 1.10."); - - ast_expression *call = expr->subexpressions[1]; - assert(call->oper == ast_function_call); - - const char *method; - method = call->subexpressions[0]->primary_expression.identifier; - - if (op->type->is_array() && strcmp(method, "length") == 0) { - if (!call->expressions.is_empty()) - _mesa_glsl_error(&loc, state, "length method takes no arguments."); - - if (op->type->array_size() == 0) - _mesa_glsl_error(&loc, state, "length called on unsized array."); - - result = new(ctx) ir_constant(op->type->array_size()); - } else { - _mesa_glsl_error(&loc, state, "Unknown method: `%s'.", method); - } - } else { - _mesa_glsl_error(& loc, state, "Cannot access field `%s' of " - "non-structure / non-vector.", - expr->primary_expression.identifier); - } - - return result ? result : ir_call::get_error_instruction(ctx); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir.cpp b/reactos/dll/opengl/mesa/src/glsl/ir.cpp deleted file mode 100644 index 4d5883c4e6e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir.cpp +++ /dev/null @@ -1,1576 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include "main/core.h" /* for MAX2 */ -#include "ir.h" -#include "ir_visitor.h" -#include "glsl_types.h" - -ir_rvalue::ir_rvalue() -{ - this->type = glsl_type::error_type; -} - -bool ir_rvalue::is_zero() const -{ - return false; -} - -bool ir_rvalue::is_one() const -{ - return false; -} - -bool ir_rvalue::is_negative_one() const -{ - return false; -} - -/** - * Modify the swizzle make to move one component to another - * - * \param m IR swizzle to be modified - * \param from Component in the RHS that is to be swizzled - * \param to Desired swizzle location of \c from - */ -static void -update_rhs_swizzle(ir_swizzle_mask &m, unsigned from, unsigned to) -{ - switch (to) { - case 0: m.x = from; break; - case 1: m.y = from; break; - case 2: m.z = from; break; - case 3: m.w = from; break; - default: assert(!"Should not get here."); - } - - m.num_components = MAX2(m.num_components, (to + 1)); -} - -void -ir_assignment::set_lhs(ir_rvalue *lhs) -{ - void *mem_ctx = this; - bool swizzled = false; - - while (lhs != NULL) { - ir_swizzle *swiz = lhs->as_swizzle(); - - if (swiz == NULL) - break; - - unsigned write_mask = 0; - ir_swizzle_mask rhs_swiz = { 0, 0, 0, 0, 0, 0 }; - - for (unsigned i = 0; i < swiz->mask.num_components; i++) { - unsigned c = 0; - - switch (i) { - case 0: c = swiz->mask.x; break; - case 1: c = swiz->mask.y; break; - case 2: c = swiz->mask.z; break; - case 3: c = swiz->mask.w; break; - default: assert(!"Should not get here."); - } - - write_mask |= (((this->write_mask >> i) & 1) << c); - update_rhs_swizzle(rhs_swiz, i, c); - } - - this->write_mask = write_mask; - lhs = swiz->val; - - this->rhs = new(mem_ctx) ir_swizzle(this->rhs, rhs_swiz); - swizzled = true; - } - - if (swizzled) { - /* Now, RHS channels line up with the LHS writemask. Collapse it - * to just the channels that will be written. - */ - ir_swizzle_mask rhs_swiz = { 0, 0, 0, 0, 0, 0 }; - int rhs_chan = 0; - for (int i = 0; i < 4; i++) { - if (write_mask & (1 << i)) - update_rhs_swizzle(rhs_swiz, i, rhs_chan++); - } - this->rhs = new(mem_ctx) ir_swizzle(this->rhs, rhs_swiz); - } - - assert((lhs == NULL) || lhs->as_dereference()); - - this->lhs = (ir_dereference *) lhs; -} - -ir_variable * -ir_assignment::whole_variable_written() -{ - ir_variable *v = this->lhs->whole_variable_referenced(); - - if (v == NULL) - return NULL; - - if (v->type->is_scalar()) - return v; - - if (v->type->is_vector()) { - const unsigned mask = (1U << v->type->vector_elements) - 1; - - if (mask != this->write_mask) - return NULL; - } - - /* Either all the vector components are assigned or the variable is some - * composite type (and the whole thing is assigned. - */ - return v; -} - -ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, - ir_rvalue *condition, unsigned write_mask) -{ - this->ir_type = ir_type_assignment; - this->condition = condition; - this->rhs = rhs; - this->lhs = lhs; - this->write_mask = write_mask; - - if (lhs->type->is_scalar() || lhs->type->is_vector()) { - int lhs_components = 0; - for (int i = 0; i < 4; i++) { - if (write_mask & (1 << i)) - lhs_components++; - } - - assert(lhs_components == this->rhs->type->vector_elements); - } -} - -ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, - ir_rvalue *condition) -{ - this->ir_type = ir_type_assignment; - this->condition = condition; - this->rhs = rhs; - - /* If the RHS is a vector type, assume that all components of the vector - * type are being written to the LHS. The write mask comes from the RHS - * because we can have a case where the LHS is a vec4 and the RHS is a - * vec3. In that case, the assignment is: - * - * (assign (...) (xyz) (var_ref lhs) (var_ref rhs)) - */ - if (rhs->type->is_vector()) - this->write_mask = (1U << rhs->type->vector_elements) - 1; - else if (rhs->type->is_scalar()) - this->write_mask = 1; - else - this->write_mask = 0; - - this->set_lhs(lhs); -} - - -ir_expression::ir_expression(int op, const struct glsl_type *type, - ir_rvalue *op0) -{ - assert(get_num_operands(ir_expression_operation(op)) == 1); - this->ir_type = ir_type_expression; - this->type = type; - this->operation = ir_expression_operation(op); - this->operands[0] = op0; - this->operands[1] = NULL; - this->operands[2] = NULL; - this->operands[3] = NULL; -} - -ir_expression::ir_expression(int op, const struct glsl_type *type, - ir_rvalue *op0, ir_rvalue *op1) -{ - assert(((op1 == NULL) && (get_num_operands(ir_expression_operation(op)) == 1)) - || (get_num_operands(ir_expression_operation(op)) == 2)); - this->ir_type = ir_type_expression; - this->type = type; - this->operation = ir_expression_operation(op); - this->operands[0] = op0; - this->operands[1] = op1; - this->operands[2] = NULL; - this->operands[3] = NULL; -} - -ir_expression::ir_expression(int op, const struct glsl_type *type, - ir_rvalue *op0, ir_rvalue *op1, - ir_rvalue *op2, ir_rvalue *op3) -{ - this->ir_type = ir_type_expression; - this->type = type; - this->operation = ir_expression_operation(op); - this->operands[0] = op0; - this->operands[1] = op1; - this->operands[2] = op2; - this->operands[3] = op3; -} - -ir_expression::ir_expression(int op, ir_rvalue *op0) -{ - this->ir_type = ir_type_expression; - - this->operation = ir_expression_operation(op); - this->operands[0] = op0; - this->operands[1] = NULL; - this->operands[2] = NULL; - this->operands[3] = NULL; - - assert(op <= ir_last_unop); - - switch (this->operation) { - case ir_unop_bit_not: - case ir_unop_logic_not: - case ir_unop_neg: - case ir_unop_abs: - case ir_unop_sign: - case ir_unop_rcp: - case ir_unop_rsq: - case ir_unop_sqrt: - case ir_unop_exp: - case ir_unop_log: - case ir_unop_exp2: - case ir_unop_log2: - case ir_unop_trunc: - case ir_unop_ceil: - case ir_unop_floor: - case ir_unop_fract: - case ir_unop_round_even: - case ir_unop_sin: - case ir_unop_cos: - case ir_unop_sin_reduced: - case ir_unop_cos_reduced: - case ir_unop_dFdx: - case ir_unop_dFdy: - this->type = op0->type; - break; - - case ir_unop_f2i: - case ir_unop_b2i: - case ir_unop_u2i: - this->type = glsl_type::get_instance(GLSL_TYPE_INT, - op0->type->vector_elements, 1); - break; - - case ir_unop_b2f: - case ir_unop_i2f: - case ir_unop_u2f: - this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT, - op0->type->vector_elements, 1); - break; - - case ir_unop_f2b: - case ir_unop_i2b: - this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, - op0->type->vector_elements, 1); - break; - - case ir_unop_i2u: - this->type = glsl_type::get_instance(GLSL_TYPE_UINT, - op0->type->vector_elements, 1); - break; - - case ir_unop_noise: - this->type = glsl_type::float_type; - break; - - case ir_unop_any: - this->type = glsl_type::bool_type; - break; - - default: - assert(!"not reached: missing automatic type setup for ir_expression"); - this->type = op0->type; - break; - } -} - -ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) -{ - this->ir_type = ir_type_expression; - - this->operation = ir_expression_operation(op); - this->operands[0] = op0; - this->operands[1] = op1; - this->operands[2] = NULL; - this->operands[3] = NULL; - - assert(op > ir_last_unop); - - switch (this->operation) { - case ir_binop_all_equal: - case ir_binop_any_nequal: - this->type = glsl_type::bool_type; - break; - - case ir_binop_add: - case ir_binop_sub: - case ir_binop_min: - case ir_binop_max: - case ir_binop_pow: - case ir_binop_mul: - case ir_binop_div: - case ir_binop_mod: - if (op0->type->is_scalar()) { - this->type = op1->type; - } else if (op1->type->is_scalar()) { - this->type = op0->type; - } else { - /* FINISHME: matrix types */ - assert(!op0->type->is_matrix() && !op1->type->is_matrix()); - assert(op0->type == op1->type); - this->type = op0->type; - } - break; - - case ir_binop_logic_and: - case ir_binop_logic_xor: - case ir_binop_logic_or: - case ir_binop_bit_and: - case ir_binop_bit_xor: - case ir_binop_bit_or: - if (op0->type->is_scalar()) { - this->type = op1->type; - } else if (op1->type->is_scalar()) { - this->type = op0->type; - } - break; - - case ir_binop_equal: - case ir_binop_nequal: - case ir_binop_lequal: - case ir_binop_gequal: - case ir_binop_less: - case ir_binop_greater: - assert(op0->type == op1->type); - this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, - op0->type->vector_elements, 1); - break; - - case ir_binop_dot: - this->type = glsl_type::float_type; - break; - - case ir_binop_lshift: - case ir_binop_rshift: - this->type = op0->type; - break; - - default: - assert(!"not reached: missing automatic type setup for ir_expression"); - this->type = glsl_type::float_type; - } -} - -unsigned int -ir_expression::get_num_operands(ir_expression_operation op) -{ - assert(op <= ir_last_opcode); - - if (op <= ir_last_unop) - return 1; - - if (op <= ir_last_binop) - return 2; - - if (op == ir_quadop_vector) - return 4; - - assert(false); - return 0; -} - -static const char *const operator_strs[] = { - "~", - "!", - "neg", - "abs", - "sign", - "rcp", - "rsq", - "sqrt", - "exp", - "log", - "exp2", - "log2", - "f2i", - "i2f", - "f2b", - "b2f", - "i2b", - "b2i", - "u2f", - "i2u", - "u2i", - "any", - "trunc", - "ceil", - "floor", - "fract", - "round_even", - "sin", - "cos", - "sin_reduced", - "cos_reduced", - "dFdx", - "dFdy", - "noise", - "+", - "-", - "*", - "/", - "%", - "<", - ">", - "<=", - ">=", - "==", - "!=", - "all_equal", - "any_nequal", - "<<", - ">>", - "&", - "^", - "|", - "&&", - "^^", - "||", - "dot", - "min", - "max", - "pow", - "vector", -}; - -const char *ir_expression::operator_string(ir_expression_operation op) -{ - assert((unsigned int) op < Elements(operator_strs)); - assert(Elements(operator_strs) == (ir_quadop_vector + 1)); - return operator_strs[op]; -} - -const char *ir_expression::operator_string() -{ - return operator_string(this->operation); -} - -const char* -depth_layout_string(ir_depth_layout layout) -{ - switch(layout) { - case ir_depth_layout_none: return ""; - case ir_depth_layout_any: return "depth_any"; - case ir_depth_layout_greater: return "depth_greater"; - case ir_depth_layout_less: return "depth_less"; - case ir_depth_layout_unchanged: return "depth_unchanged"; - - default: - assert(0); - return ""; - } -} - -ir_expression_operation -ir_expression::get_operator(const char *str) -{ - const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); - for (int op = 0; op < operator_count; op++) { - if (strcmp(str, operator_strs[op]) == 0) - return (ir_expression_operation) op; - } - return (ir_expression_operation) -1; -} - -ir_constant::ir_constant() -{ - this->ir_type = ir_type_constant; -} - -ir_constant::ir_constant(const struct glsl_type *type, - const ir_constant_data *data) -{ - assert((type->base_type >= GLSL_TYPE_UINT) - && (type->base_type <= GLSL_TYPE_BOOL)); - - this->ir_type = ir_type_constant; - this->type = type; - memcpy(& this->value, data, sizeof(this->value)); -} - -ir_constant::ir_constant(float f) -{ - this->ir_type = ir_type_constant; - this->type = glsl_type::float_type; - this->value.f[0] = f; - for (int i = 1; i < 16; i++) { - this->value.f[i] = 0; - } -} - -ir_constant::ir_constant(unsigned int u) -{ - this->ir_type = ir_type_constant; - this->type = glsl_type::uint_type; - this->value.u[0] = u; - for (int i = 1; i < 16; i++) { - this->value.u[i] = 0; - } -} - -ir_constant::ir_constant(int i) -{ - this->ir_type = ir_type_constant; - this->type = glsl_type::int_type; - this->value.i[0] = i; - for (int i = 1; i < 16; i++) { - this->value.i[i] = 0; - } -} - -ir_constant::ir_constant(bool b) -{ - this->ir_type = ir_type_constant; - this->type = glsl_type::bool_type; - this->value.b[0] = b; - for (int i = 1; i < 16; i++) { - this->value.b[i] = false; - } -} - -ir_constant::ir_constant(const ir_constant *c, unsigned i) -{ - this->ir_type = ir_type_constant; - this->type = c->type->get_base_type(); - - switch (this->type->base_type) { - case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break; - case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break; - case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break; - case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break; - default: assert(!"Should not get here."); break; - } -} - -ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) -{ - this->ir_type = ir_type_constant; - this->type = type; - - assert(type->is_scalar() || type->is_vector() || type->is_matrix() - || type->is_record() || type->is_array()); - - if (type->is_array()) { - this->array_elements = ralloc_array(this, ir_constant *, type->length); - unsigned i = 0; - foreach_list(node, value_list) { - ir_constant *value = (ir_constant *) node; - assert(value->as_constant() != NULL); - - this->array_elements[i++] = value; - } - return; - } - - /* If the constant is a record, the types of each of the entries in - * value_list must be a 1-for-1 match with the structure components. Each - * entry must also be a constant. Just move the nodes from the value_list - * to the list in the ir_constant. - */ - /* FINISHME: Should there be some type checking and / or assertions here? */ - /* FINISHME: Should the new constant take ownership of the nodes from - * FINISHME: value_list, or should it make copies? - */ - if (type->is_record()) { - value_list->move_nodes_to(& this->components); - return; - } - - for (unsigned i = 0; i < 16; i++) { - this->value.u[i] = 0; - } - - ir_constant *value = (ir_constant *) (value_list->head); - - /* Constructors with exactly one scalar argument are special for vectors - * and matrices. For vectors, the scalar value is replicated to fill all - * the components. For matrices, the scalar fills the components of the - * diagonal while the rest is filled with 0. - */ - if (value->type->is_scalar() && value->next->is_tail_sentinel()) { - if (type->is_matrix()) { - /* Matrix - fill diagonal (rest is already set to 0) */ - assert(type->base_type == GLSL_TYPE_FLOAT); - for (unsigned i = 0; i < type->matrix_columns; i++) - this->value.f[i * type->vector_elements + i] = value->value.f[0]; - } else { - /* Vector or scalar - fill all components */ - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - for (unsigned i = 0; i < type->components(); i++) - this->value.u[i] = value->value.u[0]; - break; - case GLSL_TYPE_FLOAT: - for (unsigned i = 0; i < type->components(); i++) - this->value.f[i] = value->value.f[0]; - break; - case GLSL_TYPE_BOOL: - for (unsigned i = 0; i < type->components(); i++) - this->value.b[i] = value->value.b[0]; - break; - default: - assert(!"Should not get here."); - break; - } - } - return; - } - - if (type->is_matrix() && value->type->is_matrix()) { - assert(value->next->is_tail_sentinel()); - - /* From section 5.4.2 of the GLSL 1.20 spec: - * "If a matrix is constructed from a matrix, then each component - * (column i, row j) in the result that has a corresponding component - * (column i, row j) in the argument will be initialized from there." - */ - unsigned cols = MIN2(type->matrix_columns, value->type->matrix_columns); - unsigned rows = MIN2(type->vector_elements, value->type->vector_elements); - for (unsigned i = 0; i < cols; i++) { - for (unsigned j = 0; j < rows; j++) { - const unsigned src = i * value->type->vector_elements + j; - const unsigned dst = i * type->vector_elements + j; - this->value.f[dst] = value->value.f[src]; - } - } - - /* "All other components will be initialized to the identity matrix." */ - for (unsigned i = cols; i < type->matrix_columns; i++) - this->value.f[i * type->vector_elements + i] = 1.0; - - return; - } - - /* Use each component from each entry in the value_list to initialize one - * component of the constant being constructed. - */ - for (unsigned i = 0; i < type->components(); /* empty */) { - assert(value->as_constant() != NULL); - assert(!value->is_tail_sentinel()); - - for (unsigned j = 0; j < value->type->components(); j++) { - switch (type->base_type) { - case GLSL_TYPE_UINT: - this->value.u[i] = value->get_uint_component(j); - break; - case GLSL_TYPE_INT: - this->value.i[i] = value->get_int_component(j); - break; - case GLSL_TYPE_FLOAT: - this->value.f[i] = value->get_float_component(j); - break; - case GLSL_TYPE_BOOL: - this->value.b[i] = value->get_bool_component(j); - break; - default: - /* FINISHME: What to do? Exceptions are not the answer. - */ - break; - } - - i++; - if (i >= type->components()) - break; - } - - value = (ir_constant *) value->next; - } -} - -ir_constant * -ir_constant::zero(void *mem_ctx, const glsl_type *type) -{ - assert(type->is_numeric() || type->is_boolean()); - - ir_constant *c = new(mem_ctx) ir_constant; - c->type = type; - memset(&c->value, 0, sizeof(c->value)); - - return c; -} - -bool -ir_constant::get_bool_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return this->value.u[i] != 0; - case GLSL_TYPE_INT: return this->value.i[i] != 0; - case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0; - case GLSL_TYPE_BOOL: return this->value.b[i]; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return false; -} - -float -ir_constant::get_float_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return (float) this->value.u[i]; - case GLSL_TYPE_INT: return (float) this->value.i[i]; - case GLSL_TYPE_FLOAT: return this->value.f[i]; - case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return 0.0; -} - -int -ir_constant::get_int_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return this->value.u[i]; - case GLSL_TYPE_INT: return this->value.i[i]; - case GLSL_TYPE_FLOAT: return (int) this->value.f[i]; - case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return 0; -} - -unsigned -ir_constant::get_uint_component(unsigned i) const -{ - switch (this->type->base_type) { - case GLSL_TYPE_UINT: return this->value.u[i]; - case GLSL_TYPE_INT: return this->value.i[i]; - case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i]; - case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; - default: assert(!"Should not get here."); break; - } - - /* Must return something to make the compiler happy. This is clearly an - * error case. - */ - return 0; -} - -ir_constant * -ir_constant::get_array_element(unsigned i) const -{ - assert(this->type->is_array()); - - /* From page 35 (page 41 of the PDF) of the GLSL 1.20 spec: - * - * "Behavior is undefined if a shader subscripts an array with an index - * less than 0 or greater than or equal to the size the array was - * declared with." - * - * Most out-of-bounds accesses are removed before things could get this far. - * There are cases where non-constant array index values can get constant - * folded. - */ - if (int(i) < 0) - i = 0; - else if (i >= this->type->length) - i = this->type->length - 1; - - return array_elements[i]; -} - -ir_constant * -ir_constant::get_record_field(const char *name) -{ - int idx = this->type->field_index(name); - - if (idx < 0) - return NULL; - - if (this->components.is_empty()) - return NULL; - - exec_node *node = this->components.head; - for (int i = 0; i < idx; i++) { - node = node->next; - - /* If the end of the list is encountered before the element matching the - * requested field is found, return NULL. - */ - if (node->is_tail_sentinel()) - return NULL; - } - - return (ir_constant *) node; -} - - -bool -ir_constant::has_value(const ir_constant *c) const -{ - if (this->type != c->type) - return false; - - if (this->type->is_array()) { - for (unsigned i = 0; i < this->type->length; i++) { - if (!this->array_elements[i]->has_value(c->array_elements[i])) - return false; - } - return true; - } - - if (this->type->base_type == GLSL_TYPE_STRUCT) { - const exec_node *a_node = this->components.head; - const exec_node *b_node = c->components.head; - - while (!a_node->is_tail_sentinel()) { - assert(!b_node->is_tail_sentinel()); - - const ir_constant *const a_field = (ir_constant *) a_node; - const ir_constant *const b_field = (ir_constant *) b_node; - - if (!a_field->has_value(b_field)) - return false; - - a_node = a_node->next; - b_node = b_node->next; - } - - return true; - } - - for (unsigned i = 0; i < this->type->components(); i++) { - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - if (this->value.u[i] != c->value.u[i]) - return false; - break; - case GLSL_TYPE_INT: - if (this->value.i[i] != c->value.i[i]) - return false; - break; - case GLSL_TYPE_FLOAT: - if (this->value.f[i] != c->value.f[i]) - return false; - break; - case GLSL_TYPE_BOOL: - if (this->value.b[i] != c->value.b[i]) - return false; - break; - default: - assert(!"Should not get here."); - return false; - } - } - - return true; -} - -bool -ir_constant::is_zero() const -{ - if (!this->type->is_scalar() && !this->type->is_vector()) - return false; - - for (unsigned c = 0; c < this->type->vector_elements; c++) { - switch (this->type->base_type) { - case GLSL_TYPE_FLOAT: - if (this->value.f[c] != 0.0) - return false; - break; - case GLSL_TYPE_INT: - if (this->value.i[c] != 0) - return false; - break; - case GLSL_TYPE_UINT: - if (this->value.u[c] != 0) - return false; - break; - case GLSL_TYPE_BOOL: - if (this->value.b[c] != false) - return false; - break; - default: - /* The only other base types are structures, arrays, and samplers. - * Samplers cannot be constants, and the others should have been - * filtered out above. - */ - assert(!"Should not get here."); - return false; - } - } - - return true; -} - -bool -ir_constant::is_one() const -{ - if (!this->type->is_scalar() && !this->type->is_vector()) - return false; - - for (unsigned c = 0; c < this->type->vector_elements; c++) { - switch (this->type->base_type) { - case GLSL_TYPE_FLOAT: - if (this->value.f[c] != 1.0) - return false; - break; - case GLSL_TYPE_INT: - if (this->value.i[c] != 1) - return false; - break; - case GLSL_TYPE_UINT: - if (this->value.u[c] != 1) - return false; - break; - case GLSL_TYPE_BOOL: - if (this->value.b[c] != true) - return false; - break; - default: - /* The only other base types are structures, arrays, and samplers. - * Samplers cannot be constants, and the others should have been - * filtered out above. - */ - assert(!"Should not get here."); - return false; - } - } - - return true; -} - -bool -ir_constant::is_negative_one() const -{ - if (!this->type->is_scalar() && !this->type->is_vector()) - return false; - - if (this->type->is_boolean()) - return false; - - for (unsigned c = 0; c < this->type->vector_elements; c++) { - switch (this->type->base_type) { - case GLSL_TYPE_FLOAT: - if (this->value.f[c] != -1.0) - return false; - break; - case GLSL_TYPE_INT: - if (this->value.i[c] != -1) - return false; - break; - case GLSL_TYPE_UINT: - if (int(this->value.u[c]) != -1) - return false; - break; - default: - /* The only other base types are structures, arrays, samplers, and - * booleans. Samplers cannot be constants, and the others should - * have been filtered out above. - */ - assert(!"Should not get here."); - return false; - } - } - - return true; -} - -ir_loop::ir_loop() -{ - this->ir_type = ir_type_loop; - this->cmp = ir_unop_neg; - this->from = NULL; - this->to = NULL; - this->increment = NULL; - this->counter = NULL; -} - - -ir_dereference_variable::ir_dereference_variable(ir_variable *var) -{ - this->ir_type = ir_type_dereference_variable; - this->var = var; - this->type = (var != NULL) ? var->type : glsl_type::error_type; -} - - -ir_dereference_array::ir_dereference_array(ir_rvalue *value, - ir_rvalue *array_index) -{ - this->ir_type = ir_type_dereference_array; - this->array_index = array_index; - this->set_array(value); -} - - -ir_dereference_array::ir_dereference_array(ir_variable *var, - ir_rvalue *array_index) -{ - void *ctx = ralloc_parent(var); - - this->ir_type = ir_type_dereference_array; - this->array_index = array_index; - this->set_array(new(ctx) ir_dereference_variable(var)); -} - - -void -ir_dereference_array::set_array(ir_rvalue *value) -{ - this->array = value; - this->type = glsl_type::error_type; - - if (this->array != NULL) { - const glsl_type *const vt = this->array->type; - - if (vt->is_array()) { - type = vt->element_type(); - } else if (vt->is_matrix()) { - type = vt->column_type(); - } else if (vt->is_vector()) { - type = vt->get_base_type(); - } - } -} - - -ir_dereference_record::ir_dereference_record(ir_rvalue *value, - const char *field) -{ - this->ir_type = ir_type_dereference_record; - this->record = value; - this->field = ralloc_strdup(this, field); - this->type = (this->record != NULL) - ? this->record->type->field_type(field) : glsl_type::error_type; -} - - -ir_dereference_record::ir_dereference_record(ir_variable *var, - const char *field) -{ - void *ctx = ralloc_parent(var); - - this->ir_type = ir_type_dereference_record; - this->record = new(ctx) ir_dereference_variable(var); - this->field = ralloc_strdup(this, field); - this->type = (this->record != NULL) - ? this->record->type->field_type(field) : glsl_type::error_type; -} - -bool -ir_dereference::is_lvalue() const -{ - ir_variable *var = this->variable_referenced(); - - /* Every l-value derference chain eventually ends in a variable. - */ - if ((var == NULL) || var->read_only) - return false; - - /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: - * - * "Samplers cannot be treated as l-values; hence cannot be used - * as out or inout function parameters, nor can they be - * assigned into." - */ - if (this->type->contains_sampler()) - return false; - - return true; -} - - -const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf", "txs" }; - -const char *ir_texture::opcode_string() -{ - assert((unsigned int) op <= - sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0])); - return tex_opcode_strs[op]; -} - -ir_texture_opcode -ir_texture::get_opcode(const char *str) -{ - const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]); - for (int op = 0; op < count; op++) { - if (strcmp(str, tex_opcode_strs[op]) == 0) - return (ir_texture_opcode) op; - } - return (ir_texture_opcode) -1; -} - - -void -ir_texture::set_sampler(ir_dereference *sampler, const glsl_type *type) -{ - assert(sampler != NULL); - assert(type != NULL); - this->sampler = sampler; - this->type = type; - - if (this->op == ir_txs) { - assert(type->base_type == GLSL_TYPE_INT); - } else { - assert(sampler->type->sampler_type == (int) type->base_type); - if (sampler->type->sampler_shadow) - assert(type->vector_elements == 4 || type->vector_elements == 1); - else - assert(type->vector_elements == 4); - } -} - - -void -ir_swizzle::init_mask(const unsigned *comp, unsigned count) -{ - assert((count >= 1) && (count <= 4)); - - memset(&this->mask, 0, sizeof(this->mask)); - this->mask.num_components = count; - - unsigned dup_mask = 0; - switch (count) { - case 4: - assert(comp[3] <= 3); - dup_mask |= (1U << comp[3]) - & ((1U << comp[0]) | (1U << comp[1]) | (1U << comp[2])); - this->mask.w = comp[3]; - - case 3: - assert(comp[2] <= 3); - dup_mask |= (1U << comp[2]) - & ((1U << comp[0]) | (1U << comp[1])); - this->mask.z = comp[2]; - - case 2: - assert(comp[1] <= 3); - dup_mask |= (1U << comp[1]) - & ((1U << comp[0])); - this->mask.y = comp[1]; - - case 1: - assert(comp[0] <= 3); - this->mask.x = comp[0]; - } - - this->mask.has_duplicates = dup_mask != 0; - - /* Based on the number of elements in the swizzle and the base type - * (i.e., float, int, unsigned, or bool) of the vector being swizzled, - * generate the type of the resulting value. - */ - type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); -} - -ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, - unsigned w, unsigned count) - : val(val) -{ - const unsigned components[4] = { x, y, z, w }; - this->ir_type = ir_type_swizzle; - this->init_mask(components, count); -} - -ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp, - unsigned count) - : val(val) -{ - this->ir_type = ir_type_swizzle; - this->init_mask(comp, count); -} - -ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) -{ - this->ir_type = ir_type_swizzle; - this->val = val; - this->mask = mask; - this->type = glsl_type::get_instance(val->type->base_type, - mask.num_components, 1); -} - -#define X 1 -#define R 5 -#define S 9 -#define I 13 - -ir_swizzle * -ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) -{ - void *ctx = ralloc_parent(val); - - /* For each possible swizzle character, this table encodes the value in - * \c idx_map that represents the 0th element of the vector. For invalid - * swizzle characters (e.g., 'k'), a special value is used that will allow - * detection of errors. - */ - static const unsigned char base_idx[26] = { - /* a b c d e f g h i j k l m */ - R, R, I, I, I, I, R, I, I, I, I, I, I, - /* n o p q r s t u v w x y z */ - I, I, S, S, R, S, S, I, I, X, X, X, X - }; - - /* Each valid swizzle character has an entry in the previous table. This - * table encodes the base index encoded in the previous table plus the actual - * index of the swizzle character. When processing swizzles, the first - * character in the string is indexed in the previous table. Each character - * in the string is indexed in this table, and the value found there has the - * value form the first table subtracted. The result must be on the range - * [0,3]. - * - * For example, the string "wzyx" will get X from the first table. Each of - * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After - * subtraction, the swizzle values are { 3, 2, 1, 0 }. - * - * The string "wzrg" will get X from the first table. Each of the characters - * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the - * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range - * [0,3], the error is detected. - */ - static const unsigned char idx_map[26] = { - /* a b c d e f g h i j k l m */ - R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, - /* n o p q r s t u v w x y z */ - 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 - }; - - int swiz_idx[4] = { 0, 0, 0, 0 }; - unsigned i; - - - /* Validate the first character in the swizzle string and look up the base - * index value as described above. - */ - if ((str[0] < 'a') || (str[0] > 'z')) - return NULL; - - const unsigned base = base_idx[str[0] - 'a']; - - - for (i = 0; (i < 4) && (str[i] != '\0'); i++) { - /* Validate the next character, and, as described above, convert it to a - * swizzle index. - */ - if ((str[i] < 'a') || (str[i] > 'z')) - return NULL; - - swiz_idx[i] = idx_map[str[i] - 'a'] - base; - if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) - return NULL; - } - - if (str[i] != '\0') - return NULL; - - return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], - swiz_idx[3], i); -} - -#undef X -#undef R -#undef S -#undef I - -ir_variable * -ir_swizzle::variable_referenced() const -{ - return this->val->variable_referenced(); -} - - -ir_variable::ir_variable(const struct glsl_type *type, const char *name, - ir_variable_mode mode) - : max_array_access(0), read_only(false), centroid(false), invariant(false), - mode(mode), interpolation(INTERP_QUALIFIER_NONE) -{ - this->ir_type = ir_type_variable; - this->type = type; - this->name = ralloc_strdup(this, name); - this->has_initializer = false; - this->location = -1; - this->warn_extension = NULL; - this->constant_value = NULL; - this->constant_initializer = NULL; - this->depth_layout = ir_depth_layout_none; - this->used = false; - - if (type && type->base_type == GLSL_TYPE_SAMPLER) - this->read_only = true; -} - - -const char * -ir_variable::interpolation_string() const -{ - switch (this->interpolation) { - case INTERP_QUALIFIER_NONE: return "no"; - case INTERP_QUALIFIER_SMOOTH: return "smooth"; - case INTERP_QUALIFIER_FLAT: return "flat"; - case INTERP_QUALIFIER_NOPERSPECTIVE: return "noperspective"; - } - - assert(!"Should not get here."); - return ""; -} - - -glsl_interp_qualifier -ir_variable::determine_interpolation_mode(bool flat_shade) -{ - if (this->interpolation != INTERP_QUALIFIER_NONE) - return (glsl_interp_qualifier) this->interpolation; - int location = this->location; - bool is_gl_Color = - location == FRAG_ATTRIB_COL0 || location == FRAG_ATTRIB_COL1; - if (flat_shade && is_gl_Color) - return INTERP_QUALIFIER_FLAT; - else - return INTERP_QUALIFIER_SMOOTH; -} - - -ir_function_signature::ir_function_signature(const glsl_type *return_type) - : return_type(return_type), is_defined(false), _function(NULL) -{ - this->ir_type = ir_type_function_signature; - this->is_builtin = false; -} - - -static bool -modes_match(unsigned a, unsigned b) -{ - if (a == b) - return true; - - /* Accept "in" vs. "const in" */ - if ((a == ir_var_const_in && b == ir_var_in) || - (b == ir_var_const_in && a == ir_var_in)) - return true; - - return false; -} - - -const char * -ir_function_signature::qualifiers_match(exec_list *params) -{ - exec_list_iterator iter_a = parameters.iterator(); - exec_list_iterator iter_b = params->iterator(); - - /* check that the qualifiers match. */ - while (iter_a.has_next()) { - ir_variable *a = (ir_variable *)iter_a.get(); - ir_variable *b = (ir_variable *)iter_b.get(); - - if (a->read_only != b->read_only || - !modes_match(a->mode, b->mode) || - a->interpolation != b->interpolation || - a->centroid != b->centroid) { - - /* parameter a's qualifiers don't match */ - return a->name; - } - - iter_a.next(); - iter_b.next(); - } - return NULL; -} - - -void -ir_function_signature::replace_parameters(exec_list *new_params) -{ - /* Destroy all of the previous parameter information. If the previous - * parameter information comes from the function prototype, it may either - * specify incorrect parameter names or not have names at all. - */ - foreach_iter(exec_list_iterator, iter, parameters) { - assert(((ir_instruction *) iter.get())->as_variable() != NULL); - - iter.remove(); - } - - new_params->move_nodes_to(¶meters); -} - - -ir_function::ir_function(const char *name) -{ - this->ir_type = ir_type_function; - this->name = ralloc_strdup(this, name); -} - - -bool -ir_function::has_user_signature() -{ - foreach_list(n, &this->signatures) { - ir_function_signature *const sig = (ir_function_signature *) n; - if (!sig->is_builtin) - return true; - } - return false; -} - - -ir_call * -ir_call::get_error_instruction(void *ctx) -{ - ir_call *call = new(ctx) ir_call; - - call->type = glsl_type::error_type; - return call; -} - -void -ir_call::set_callee(ir_function_signature *sig) -{ - assert((this->type == NULL) || (this->type == sig->return_type)); - - this->callee = sig; -} - -void -visit_exec_list(exec_list *list, ir_visitor *visitor) -{ - foreach_iter(exec_list_iterator, iter, *list) { - ((ir_instruction *)iter.get())->accept(visitor); - } -} - - -static void -steal_memory(ir_instruction *ir, void *new_ctx) -{ - ir_variable *var = ir->as_variable(); - ir_constant *constant = ir->as_constant(); - if (var != NULL && var->constant_value != NULL) - steal_memory(var->constant_value, ir); - - if (var != NULL && var->constant_initializer != NULL) - steal_memory(var->constant_initializer, ir); - - /* The components of aggregate constants are not visited by the normal - * visitor, so steal their values by hand. - */ - if (constant != NULL) { - if (constant->type->is_record()) { - foreach_iter(exec_list_iterator, iter, constant->components) { - ir_constant *field = (ir_constant *)iter.get(); - steal_memory(field, ir); - } - } else if (constant->type->is_array()) { - for (unsigned int i = 0; i < constant->type->length; i++) { - steal_memory(constant->array_elements[i], ir); - } - } - } - - ralloc_steal(new_ctx, ir); -} - - -void -reparent_ir(exec_list *list, void *mem_ctx) -{ - foreach_list(node, list) { - visit_tree((ir_instruction *) node, steal_memory, mem_ctx); - } -} - - -static ir_rvalue * -try_min_one(ir_rvalue *ir) -{ - ir_expression *expr = ir->as_expression(); - - if (!expr || expr->operation != ir_binop_min) - return NULL; - - if (expr->operands[0]->is_one()) - return expr->operands[1]; - - if (expr->operands[1]->is_one()) - return expr->operands[0]; - - return NULL; -} - -static ir_rvalue * -try_max_zero(ir_rvalue *ir) -{ - ir_expression *expr = ir->as_expression(); - - if (!expr || expr->operation != ir_binop_max) - return NULL; - - if (expr->operands[0]->is_zero()) - return expr->operands[1]; - - if (expr->operands[1]->is_zero()) - return expr->operands[0]; - - return NULL; -} - -ir_rvalue * -ir_rvalue::as_rvalue_to_saturate() -{ - ir_expression *expr = this->as_expression(); - - if (!expr) - return NULL; - - ir_rvalue *max_zero = try_max_zero(expr); - if (max_zero) { - return try_min_one(max_zero); - } else { - ir_rvalue *min_one = try_min_one(expr); - if (min_one) { - return try_max_zero(min_one); - } - } - - return NULL; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir.h b/reactos/dll/opengl/mesa/src/glsl/ir.h deleted file mode 100644 index 9f88a8eafbf..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir.h +++ /dev/null @@ -1,1705 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef IR_H -#define IR_H - -#include -#include - -#include "ralloc.h" -#include "glsl_types.h" -#include "list.h" -#include "ir_visitor.h" -#include "ir_hierarchical_visitor.h" -#include "main/mtypes.h" - -/** - * \defgroup IR Intermediate representation nodes - * - * @{ - */ - -/** - * Class tags - * - * Each concrete class derived from \c ir_instruction has a value in this - * enumerant. The value for the type is stored in \c ir_instruction::ir_type - * by the constructor. While using type tags is not very C++, it is extremely - * convenient. For example, during debugging you can simply inspect - * \c ir_instruction::ir_type to find out the actual type of the object. - * - * In addition, it is possible to use a switch-statement based on \c - * \c ir_instruction::ir_type to select different behavior for different object - * types. For functions that have only slight differences for several object - * types, this allows writing very straightforward, readable code. - */ -enum ir_node_type { - /** - * Zero is unused so that the IR validator can detect cases where - * \c ir_instruction::ir_type has not been initialized. - */ - ir_type_unset, - ir_type_variable, - ir_type_assignment, - ir_type_call, - ir_type_constant, - ir_type_dereference_array, - ir_type_dereference_record, - ir_type_dereference_variable, - ir_type_discard, - ir_type_expression, - ir_type_function, - ir_type_function_signature, - ir_type_if, - ir_type_loop, - ir_type_loop_jump, - ir_type_return, - ir_type_swizzle, - ir_type_texture, - ir_type_max /**< maximum ir_type enum number, for validation */ -}; - -/** - * Base class of all IR instructions - */ -class ir_instruction : public exec_node { -public: - enum ir_node_type ir_type; - const struct glsl_type *type; - - /** ir_print_visitor helper for debugging. */ - void print(void) const; - - virtual void accept(ir_visitor *) = 0; - virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0; - virtual ir_instruction *clone(void *mem_ctx, - struct hash_table *ht) const = 0; - - /** - * \name IR instruction downcast functions - * - * These functions either cast the object to a derived class or return - * \c NULL if the object's type does not match the specified derived class. - * Additional downcast functions will be added as needed. - */ - /*@{*/ - virtual class ir_variable * as_variable() { return NULL; } - virtual class ir_function * as_function() { return NULL; } - virtual class ir_dereference * as_dereference() { return NULL; } - virtual class ir_dereference_array * as_dereference_array() { return NULL; } - virtual class ir_dereference_variable *as_dereference_variable() { return NULL; } - virtual class ir_expression * as_expression() { return NULL; } - virtual class ir_rvalue * as_rvalue() { return NULL; } - virtual class ir_loop * as_loop() { return NULL; } - virtual class ir_assignment * as_assignment() { return NULL; } - virtual class ir_call * as_call() { return NULL; } - virtual class ir_return * as_return() { return NULL; } - virtual class ir_if * as_if() { return NULL; } - virtual class ir_swizzle * as_swizzle() { return NULL; } - virtual class ir_constant * as_constant() { return NULL; } - virtual class ir_discard * as_discard() { return NULL; } - /*@}*/ - -protected: - ir_instruction() - { - ir_type = ir_type_unset; - type = NULL; - } -}; - - -class ir_rvalue : public ir_instruction { -public: - virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const = 0; - - virtual ir_constant *constant_expression_value() = 0; - - virtual ir_rvalue * as_rvalue() - { - return this; - } - - ir_rvalue *as_rvalue_to_saturate(); - - virtual bool is_lvalue() const - { - return false; - } - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() const - { - return NULL; - } - - - /** - * If an r-value is a reference to a whole variable, get that variable - * - * \return - * Pointer to a variable that is completely dereferenced by the r-value. If - * the r-value is not a dereference or the dereference does not access the - * entire variable (i.e., it's just one array element, struct field), \c NULL - * is returned. - */ - virtual ir_variable *whole_variable_referenced() - { - return NULL; - } - - /** - * Determine if an r-value has the value zero - * - * The base implementation of this function always returns \c false. The - * \c ir_constant class over-rides this function to return \c true \b only - * for vector and scalar types that have all elements set to the value - * zero (or \c false for booleans). - * - * \sa ir_constant::has_value, ir_rvalue::is_one, ir_rvalue::is_negative_one - */ - virtual bool is_zero() const; - - /** - * Determine if an r-value has the value one - * - * The base implementation of this function always returns \c false. The - * \c ir_constant class over-rides this function to return \c true \b only - * for vector and scalar types that have all elements set to the value - * one (or \c true for booleans). - * - * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_negative_one - */ - virtual bool is_one() const; - - /** - * Determine if an r-value has the value negative one - * - * The base implementation of this function always returns \c false. The - * \c ir_constant class over-rides this function to return \c true \b only - * for vector and scalar types that have all elements set to the value - * negative one. For boolean times, the result is always \c false. - * - * \sa ir_constant::has_value, ir_rvalue::is_zero, ir_rvalue::is_one - */ - virtual bool is_negative_one() const; - -protected: - ir_rvalue(); -}; - - -/** - * Variable storage classes - */ -enum ir_variable_mode { - ir_var_auto = 0, /**< Function local variables and globals. */ - ir_var_uniform, /**< Variable declared as a uniform. */ - ir_var_in, - ir_var_out, - ir_var_inout, - ir_var_const_in, /**< "in" param that must be a constant expression */ - ir_var_system_value, /**< Ex: front-face, instance-id, etc. */ - ir_var_temporary /**< Temporary variable generated during compilation. */ -}; - -/** - * \brief Layout qualifiers for gl_FragDepth. - * - * The AMD/ARB_conservative_depth extensions allow gl_FragDepth to be redeclared - * with a layout qualifier. - */ -enum ir_depth_layout { - ir_depth_layout_none, /**< No depth layout is specified. */ - ir_depth_layout_any, - ir_depth_layout_greater, - ir_depth_layout_less, - ir_depth_layout_unchanged -}; - -/** - * \brief Convert depth layout qualifier to string. - */ -const char* -depth_layout_string(ir_depth_layout layout); - -/** - * Description of built-in state associated with a uniform - * - * \sa ir_variable::state_slots - */ -struct ir_state_slot { - int tokens[5]; - int swizzle; -}; - -class ir_variable : public ir_instruction { -public: - ir_variable(const struct glsl_type *, const char *, ir_variable_mode); - - virtual ir_variable *clone(void *mem_ctx, struct hash_table *ht) const; - - virtual ir_variable *as_variable() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - - /** - * Get the string value for the interpolation qualifier - * - * \return The string that would be used in a shader to specify \c - * mode will be returned. - * - * This function is used to generate error messages of the form "shader - * uses %s interpolation qualifier", so in the case where there is no - * interpolation qualifier, it returns "no". - * - * This function should only be used on a shader input or output variable. - */ - const char *interpolation_string() const; - - /** - * Determine how this variable should be interpolated based on its - * interpolation qualifier (if present), whether it is gl_Color or - * gl_SecondaryColor, and whether flatshading is enabled in the current GL - * state. - * - * The return value will always be either INTERP_QUALIFIER_SMOOTH, - * INTERP_QUALIFIER_NOPERSPECTIVE, or INTERP_QUALIFIER_FLAT. - */ - glsl_interp_qualifier determine_interpolation_mode(bool flat_shade); - - /** - * Delcared name of the variable - */ - const char *name; - - /** - * Highest element accessed with a constant expression array index - * - * Not used for non-array variables. - */ - unsigned max_array_access; - - /** - * Is the variable read-only? - * - * This is set for variables declared as \c const, shader inputs, - * and uniforms. - */ - unsigned read_only:1; - unsigned centroid:1; - unsigned invariant:1; - - /** - * Has this variable been used for reading or writing? - * - * Several GLSL semantic checks require knowledge of whether or not a - * variable has been used. For example, it is an error to redeclare a - * variable as invariant after it has been used. - */ - unsigned used:1; - - /** - * Storage class of the variable. - * - * \sa ir_variable_mode - */ - unsigned mode:3; - - /** - * Interpolation mode for shader inputs / outputs - * - * \sa ir_variable_interpolation - */ - unsigned interpolation:2; - - /*@}*/ - - /** - * Does this variable have an initializer? - * - * This is used by the linker to cross-validiate initializers of global - * variables. - */ - unsigned has_initializer:1; - - /** - * \brief Layout qualifier for gl_FragDepth. - * - * This is not equal to \c ir_depth_layout_none if and only if this - * variable is \c gl_FragDepth and a layout qualifier is specified. - */ - ir_depth_layout depth_layout; - - /** - * Storage location of the base of this variable - * - * The precise meaning of this field depends on the nature of the variable. - * - * - Vertex shader input: one of the values from \c gl_vert_attrib. - * - Vertex shader output: one of the values from \c gl_vert_result. - * - Fragment shader input: one of the values from \c gl_frag_attrib. - * - Fragment shader output: one of the values from \c gl_frag_result. - * - Uniforms: Per-stage uniform slot number. - * - Other: This field is not currently used. - * - * If the variable is a uniform, shader input, or shader output, and the - * slot has not been assigned, the value will be -1. - */ - int location; - - /** - * Built-in state that backs this uniform - * - * Once set at variable creation, \c state_slots must remain invariant. - * This is because, ideally, this array would be shared by all clones of - * this variable in the IR tree. In other words, we'd really like for it - * to be a fly-weight. - * - * If the variable is not a uniform, \c num_state_slots will be zero and - * \c state_slots will be \c NULL. - */ - /*@{*/ - unsigned num_state_slots; /**< Number of state slots used */ - ir_state_slot *state_slots; /**< State descriptors. */ - /*@}*/ - - /** - * Emit a warning if this variable is accessed. - */ - const char *warn_extension; - - /** - * Value assigned in the initializer of a variable declared "const" - */ - ir_constant *constant_value; - - /** - * Constant expression assigned in the initializer of the variable - * - * \warning - * This field and \c ::constant_value are distinct. Even if the two fields - * refer to constants with the same value, they must point to separate - * objects. - */ - ir_constant *constant_initializer; -}; - - -/*@{*/ -/** - * The representation of a function instance; may be the full definition or - * simply a prototype. - */ -class ir_function_signature : public ir_instruction { - /* An ir_function_signature will be part of the list of signatures in - * an ir_function. - */ -public: - ir_function_signature(const glsl_type *return_type); - - virtual ir_function_signature *clone(void *mem_ctx, - struct hash_table *ht) const; - ir_function_signature *clone_prototype(void *mem_ctx, - struct hash_table *ht) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Get the name of the function for which this is a signature - */ - const char *function_name() const; - - /** - * Get a handle to the function for which this is a signature - * - * There is no setter function, this function returns a \c const pointer, - * and \c ir_function_signature::_function is private for a reason. The - * only way to make a connection between a function and function signature - * is via \c ir_function::add_signature. This helps ensure that certain - * invariants (i.e., a function signature is in the list of signatures for - * its \c _function) are met. - * - * \sa ir_function::add_signature - */ - inline const class ir_function *function() const - { - return this->_function; - } - - /** - * Check whether the qualifiers match between this signature's parameters - * and the supplied parameter list. If not, returns the name of the first - * parameter with mismatched qualifiers (for use in error messages). - */ - const char *qualifiers_match(exec_list *params); - - /** - * Replace the current parameter list with the given one. This is useful - * if the current information came from a prototype, and either has invalid - * or missing parameter names. - */ - void replace_parameters(exec_list *new_params); - - /** - * Function return type. - * - * \note This discards the optional precision qualifier. - */ - const struct glsl_type *return_type; - - /** - * List of ir_variable of function parameters. - * - * This represents the storage. The paramaters passed in a particular - * call will be in ir_call::actual_paramaters. - */ - struct exec_list parameters; - - /** Whether or not this function has a body (which may be empty). */ - unsigned is_defined:1; - - /** Whether or not this function signature is a built-in. */ - unsigned is_builtin:1; - - /** Body of instructions in the function. */ - struct exec_list body; - -private: - /** Function of which this signature is one overload. */ - class ir_function *_function; - - friend class ir_function; -}; - - -/** - * Header for tracking multiple overloaded functions with the same name. - * Contains a list of ir_function_signatures representing each of the - * actual functions. - */ -class ir_function : public ir_instruction { -public: - ir_function(const char *name); - - virtual ir_function *clone(void *mem_ctx, struct hash_table *ht) const; - - virtual ir_function *as_function() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - void add_signature(ir_function_signature *sig) - { - sig->_function = this; - this->signatures.push_tail(sig); - } - - /** - * Get an iterator for the set of function signatures - */ - exec_list_iterator iterator() - { - return signatures.iterator(); - } - - /** - * Find a signature that matches a set of actual parameters, taking implicit - * conversions into account. Also flags whether the match was exact. - */ - ir_function_signature *matching_signature(const exec_list *actual_param, - bool *match_is_exact); - - /** - * Find a signature that matches a set of actual parameters, taking implicit - * conversions into account. - */ - ir_function_signature *matching_signature(const exec_list *actual_param); - - /** - * Find a signature that exactly matches a set of actual parameters without - * any implicit type conversions. - */ - ir_function_signature *exact_matching_signature(const exec_list *actual_ps); - - /** - * Name of the function. - */ - const char *name; - - /** Whether or not this function has a signature that isn't a built-in. */ - bool has_user_signature(); - - /** - * List of ir_function_signature for each overloaded function with this name. - */ - struct exec_list signatures; -}; - -inline const char *ir_function_signature::function_name() const -{ - return this->_function->name; -} -/*@}*/ - - -/** - * IR instruction representing high-level if-statements - */ -class ir_if : public ir_instruction { -public: - ir_if(ir_rvalue *condition) - : condition(condition) - { - ir_type = ir_type_if; - } - - virtual ir_if *clone(void *mem_ctx, struct hash_table *ht) const; - - virtual ir_if *as_if() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *condition; - /** List of ir_instruction for the body of the then branch */ - exec_list then_instructions; - /** List of ir_instruction for the body of the else branch */ - exec_list else_instructions; -}; - - -/** - * IR instruction representing a high-level loop structure. - */ -class ir_loop : public ir_instruction { -public: - ir_loop(); - - virtual ir_loop *clone(void *mem_ctx, struct hash_table *ht) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - virtual ir_loop *as_loop() - { - return this; - } - - /** - * Get an iterator for the instructions of the loop body - */ - exec_list_iterator iterator() - { - return body_instructions.iterator(); - } - - /** List of ir_instruction that make up the body of the loop. */ - exec_list body_instructions; - - /** - * \name Loop counter and controls - * - * Represents a loop like a FORTRAN \c do-loop. - * - * \note - * If \c from and \c to are the same value, the loop will execute once. - */ - /*@{*/ - ir_rvalue *from; /** Value of the loop counter on the first - * iteration of the loop. - */ - ir_rvalue *to; /** Value of the loop counter on the last - * iteration of the loop. - */ - ir_rvalue *increment; - ir_variable *counter; - - /** - * Comparison operation in the loop terminator. - * - * If any of the loop control fields are non-\c NULL, this field must be - * one of \c ir_binop_less, \c ir_binop_greater, \c ir_binop_lequal, - * \c ir_binop_gequal, \c ir_binop_equal, or \c ir_binop_nequal. - */ - int cmp; - /*@}*/ -}; - - -class ir_assignment : public ir_instruction { -public: - ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition = NULL); - - /** - * Construct an assignment with an explicit write mask - * - * \note - * Since a write mask is supplied, the LHS must already be a bare - * \c ir_dereference. The cannot be any swizzles in the LHS. - */ - ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, ir_rvalue *condition, - unsigned write_mask); - - virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const; - - virtual ir_constant *constant_expression_value(); - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - virtual ir_assignment * as_assignment() - { - return this; - } - - /** - * Get a whole variable written by an assignment - * - * If the LHS of the assignment writes a whole variable, the variable is - * returned. Otherwise \c NULL is returned. Examples of whole-variable - * assignment are: - * - * - Assigning to a scalar - * - Assigning to all components of a vector - * - Whole array (or matrix) assignment - * - Whole structure assignment - */ - ir_variable *whole_variable_written(); - - /** - * Set the LHS of an assignment - */ - void set_lhs(ir_rvalue *lhs); - - /** - * Left-hand side of the assignment. - * - * This should be treated as read only. If you need to set the LHS of an - * assignment, use \c ir_assignment::set_lhs. - */ - ir_dereference *lhs; - - /** - * Value being assigned - */ - ir_rvalue *rhs; - - /** - * Optional condition for the assignment. - */ - ir_rvalue *condition; - - - /** - * Component mask written - * - * For non-vector types in the LHS, this field will be zero. For vector - * types, a bit will be set for each component that is written. Note that - * for \c vec2 and \c vec3 types only the lower bits will ever be set. - * - * A partially-set write mask means that each enabled channel gets - * the value from a consecutive channel of the rhs. For example, - * to write just .xyw of gl_FrontColor with color: - * - * (assign (constant bool (1)) (xyw) - * (var_ref gl_FragColor) - * (swiz xyw (var_ref color))) - */ - unsigned write_mask:4; -}; - -/* Update ir_expression::num_operands() and operator_strs when - * updating this list. - */ -enum ir_expression_operation { - ir_unop_bit_not, - ir_unop_logic_not, - ir_unop_neg, - ir_unop_abs, - ir_unop_sign, - ir_unop_rcp, - ir_unop_rsq, - ir_unop_sqrt, - ir_unop_exp, /**< Log base e on gentype */ - ir_unop_log, /**< Natural log on gentype */ - ir_unop_exp2, - ir_unop_log2, - ir_unop_f2i, /**< Float-to-integer conversion. */ - ir_unop_i2f, /**< Integer-to-float conversion. */ - ir_unop_f2b, /**< Float-to-boolean conversion */ - ir_unop_b2f, /**< Boolean-to-float conversion */ - ir_unop_i2b, /**< int-to-boolean conversion */ - ir_unop_b2i, /**< Boolean-to-int conversion */ - ir_unop_u2f, /**< Unsigned-to-float conversion. */ - ir_unop_i2u, /**< Integer-to-unsigned conversion. */ - ir_unop_u2i, /**< Unsigned-to-integer conversion. */ - ir_unop_any, - - /** - * \name Unary floating-point rounding operations. - */ - /*@{*/ - ir_unop_trunc, - ir_unop_ceil, - ir_unop_floor, - ir_unop_fract, - ir_unop_round_even, - /*@}*/ - - /** - * \name Trigonometric operations. - */ - /*@{*/ - ir_unop_sin, - ir_unop_cos, - ir_unop_sin_reduced, /**< Reduced range sin. [-pi, pi] */ - ir_unop_cos_reduced, /**< Reduced range cos. [-pi, pi] */ - /*@}*/ - - /** - * \name Partial derivatives. - */ - /*@{*/ - ir_unop_dFdx, - ir_unop_dFdy, - /*@}*/ - - ir_unop_noise, - - /** - * A sentinel marking the last of the unary operations. - */ - ir_last_unop = ir_unop_noise, - - ir_binop_add, - ir_binop_sub, - ir_binop_mul, - ir_binop_div, - - /** - * Takes one of two combinations of arguments: - * - * - mod(vecN, vecN) - * - mod(vecN, float) - * - * Does not take integer types. - */ - ir_binop_mod, - - /** - * \name Binary comparison operators which return a boolean vector. - * The type of both operands must be equal. - */ - /*@{*/ - ir_binop_less, - ir_binop_greater, - ir_binop_lequal, - ir_binop_gequal, - ir_binop_equal, - ir_binop_nequal, - /** - * Returns single boolean for whether all components of operands[0] - * equal the components of operands[1]. - */ - ir_binop_all_equal, - /** - * Returns single boolean for whether any component of operands[0] - * is not equal to the corresponding component of operands[1]. - */ - ir_binop_any_nequal, - /*@}*/ - - /** - * \name Bit-wise binary operations. - */ - /*@{*/ - ir_binop_lshift, - ir_binop_rshift, - ir_binop_bit_and, - ir_binop_bit_xor, - ir_binop_bit_or, - /*@}*/ - - ir_binop_logic_and, - ir_binop_logic_xor, - ir_binop_logic_or, - - ir_binop_dot, - ir_binop_min, - ir_binop_max, - - ir_binop_pow, - - /** - * A sentinel marking the last of the binary operations. - */ - ir_last_binop = ir_binop_pow, - - ir_quadop_vector, - - /** - * A sentinel marking the last of all operations. - */ - ir_last_opcode = ir_last_binop -}; - -class ir_expression : public ir_rvalue { -public: - /** - * Constructor for unary operation expressions - */ - ir_expression(int op, const struct glsl_type *type, ir_rvalue *); - ir_expression(int op, ir_rvalue *); - - /** - * Constructor for binary operation expressions - */ - ir_expression(int op, const struct glsl_type *type, - ir_rvalue *, ir_rvalue *); - ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1); - - /** - * Constructor for quad operator expressions - */ - ir_expression(int op, const struct glsl_type *type, - ir_rvalue *, ir_rvalue *, ir_rvalue *, ir_rvalue *); - - virtual ir_expression *as_expression() - { - return this; - } - - virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const; - - /** - * Attempt to constant-fold the expression - * - * If the expression cannot be constant folded, this method will return - * \c NULL. - */ - virtual ir_constant *constant_expression_value(); - - /** - * Determine the number of operands used by an expression - */ - static unsigned int get_num_operands(ir_expression_operation); - - /** - * Determine the number of operands used by an expression - */ - unsigned int get_num_operands() const - { - return (this->operation == ir_quadop_vector) - ? this->type->vector_elements : get_num_operands(operation); - } - - /** - * Return a string representing this expression's operator. - */ - const char *operator_string(); - - /** - * Return a string representing this expression's operator. - */ - static const char *operator_string(ir_expression_operation); - - - /** - * Do a reverse-lookup to translate the given string into an operator. - */ - static ir_expression_operation get_operator(const char *); - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_expression_operation operation; - ir_rvalue *operands[4]; -}; - - -/** - * IR instruction representing a function call - */ -class ir_call : public ir_rvalue { -public: - ir_call(ir_function_signature *callee, exec_list *actual_parameters) - : callee(callee) - { - ir_type = ir_type_call; - assert(callee->return_type != NULL); - type = callee->return_type; - actual_parameters->move_nodes_to(& this->actual_parameters); - this->use_builtin = callee->is_builtin; - } - - virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const; - - virtual ir_constant *constant_expression_value(); - - virtual ir_call *as_call() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Get a generic ir_call object when an error occurs - * - * Any allocation will be performed with 'ctx' as ralloc owner. - */ - static ir_call *get_error_instruction(void *ctx); - - /** - * Get an iterator for the set of acutal parameters - */ - exec_list_iterator iterator() - { - return actual_parameters.iterator(); - } - - /** - * Get the name of the function being called. - */ - const char *callee_name() const - { - return callee->function_name(); - } - - /** - * Get the function signature bound to this function call - */ - ir_function_signature *get_callee() - { - return callee; - } - - /** - * Set the function call target - */ - void set_callee(ir_function_signature *sig); - - /** - * Generates an inline version of the function before @ir, - * returning the return value of the function. - */ - ir_rvalue *generate_inline(ir_instruction *ir); - - /* List of ir_rvalue of paramaters passed in this call. */ - exec_list actual_parameters; - - /** Should this call only bind to a built-in function? */ - bool use_builtin; - -private: - ir_call() - : callee(NULL) - { - this->ir_type = ir_type_call; - } - - ir_function_signature *callee; -}; - - -/** - * \name Jump-like IR instructions. - * - * These include \c break, \c continue, \c return, and \c discard. - */ -/*@{*/ -class ir_jump : public ir_instruction { -protected: - ir_jump() - { - ir_type = ir_type_unset; - } -}; - -class ir_return : public ir_jump { -public: - ir_return() - : value(NULL) - { - this->ir_type = ir_type_return; - } - - ir_return(ir_rvalue *value) - : value(value) - { - this->ir_type = ir_type_return; - } - - virtual ir_return *clone(void *mem_ctx, struct hash_table *) const; - - virtual ir_return *as_return() - { - return this; - } - - ir_rvalue *get_value() const - { - return value; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *value; -}; - - -/** - * Jump instructions used inside loops - * - * These include \c break and \c continue. The \c break within a loop is - * different from the \c break within a switch-statement. - * - * \sa ir_switch_jump - */ -class ir_loop_jump : public ir_jump { -public: - enum jump_mode { - jump_break, - jump_continue - }; - - ir_loop_jump(jump_mode mode) - { - this->ir_type = ir_type_loop_jump; - this->mode = mode; - } - - virtual ir_loop_jump *clone(void *mem_ctx, struct hash_table *) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - bool is_break() const - { - return mode == jump_break; - } - - bool is_continue() const - { - return mode == jump_continue; - } - - /** Mode selector for the jump instruction. */ - enum jump_mode mode; -}; - -/** - * IR instruction representing discard statements. - */ -class ir_discard : public ir_jump { -public: - ir_discard() - { - this->ir_type = ir_type_discard; - this->condition = NULL; - } - - ir_discard(ir_rvalue *cond) - { - this->ir_type = ir_type_discard; - this->condition = cond; - } - - virtual ir_discard *clone(void *mem_ctx, struct hash_table *ht) const; - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - virtual ir_discard *as_discard() - { - return this; - } - - ir_rvalue *condition; -}; -/*@}*/ - - -/** - * Texture sampling opcodes used in ir_texture - */ -enum ir_texture_opcode { - ir_tex, /**< Regular texture look-up */ - ir_txb, /**< Texture look-up with LOD bias */ - ir_txl, /**< Texture look-up with explicit LOD */ - ir_txd, /**< Texture look-up with partial derivatvies */ - ir_txf, /**< Texel fetch with explicit LOD */ - ir_txs /**< Texture size */ -}; - - -/** - * IR instruction to sample a texture - * - * The specific form of the IR instruction depends on the \c mode value - * selected from \c ir_texture_opcodes. In the printed IR, these will - * appear as: - * - * Texel offset (0 or an expression) - * | Projection divisor - * | | Shadow comparitor - * | | | - * v v v - * (tex 0 1 ( )) - * (txb 0 1 ( ) ) - * (txl 0 1 ( ) ) - * (txd 0 1 ( ) (dPdx dPdy)) - * (txf 0 ) - * (txs ) - */ -class ir_texture : public ir_rvalue { -public: - ir_texture(enum ir_texture_opcode op) - : op(op), projector(NULL), shadow_comparitor(NULL), offset(NULL) - { - this->ir_type = ir_type_texture; - } - - virtual ir_texture *clone(void *mem_ctx, struct hash_table *) const; - - virtual ir_constant *constant_expression_value(); - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Return a string representing the ir_texture_opcode. - */ - const char *opcode_string(); - - /** Set the sampler and type. */ - void set_sampler(ir_dereference *sampler, const glsl_type *type); - - /** - * Do a reverse-lookup to translate a string into an ir_texture_opcode. - */ - static ir_texture_opcode get_opcode(const char *); - - enum ir_texture_opcode op; - - /** Sampler to use for the texture access. */ - ir_dereference *sampler; - - /** Texture coordinate to sample */ - ir_rvalue *coordinate; - - /** - * Value used for projective divide. - * - * If there is no projective divide (the common case), this will be - * \c NULL. Optimization passes should check for this to point to a constant - * of 1.0 and replace that with \c NULL. - */ - ir_rvalue *projector; - - /** - * Coordinate used for comparison on shadow look-ups. - * - * If there is no shadow comparison, this will be \c NULL. For the - * \c ir_txf opcode, this *must* be \c NULL. - */ - ir_rvalue *shadow_comparitor; - - /** Texel offset. */ - ir_rvalue *offset; - - union { - ir_rvalue *lod; /**< Floating point LOD */ - ir_rvalue *bias; /**< Floating point LOD bias */ - struct { - ir_rvalue *dPdx; /**< Partial derivative of coordinate wrt X */ - ir_rvalue *dPdy; /**< Partial derivative of coordinate wrt Y */ - } grad; - } lod_info; -}; - - -struct ir_swizzle_mask { - unsigned x:2; - unsigned y:2; - unsigned z:2; - unsigned w:2; - - /** - * Number of components in the swizzle. - */ - unsigned num_components:3; - - /** - * Does the swizzle contain duplicate components? - * - * L-value swizzles cannot contain duplicate components. - */ - unsigned has_duplicates:1; -}; - - -class ir_swizzle : public ir_rvalue { -public: - ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w, - unsigned count); - - ir_swizzle(ir_rvalue *val, const unsigned *components, unsigned count); - - ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask); - - virtual ir_swizzle *clone(void *mem_ctx, struct hash_table *) const; - - virtual ir_constant *constant_expression_value(); - - virtual ir_swizzle *as_swizzle() - { - return this; - } - - /** - * Construct an ir_swizzle from the textual representation. Can fail. - */ - static ir_swizzle *create(ir_rvalue *, const char *, unsigned vector_length); - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - bool is_lvalue() const - { - return val->is_lvalue() && !mask.has_duplicates; - } - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() const; - - ir_rvalue *val; - ir_swizzle_mask mask; - -private: - /** - * Initialize the mask component of a swizzle - * - * This is used by the \c ir_swizzle constructors. - */ - void init_mask(const unsigned *components, unsigned count); -}; - - -class ir_dereference : public ir_rvalue { -public: - virtual ir_dereference *clone(void *mem_ctx, struct hash_table *) const = 0; - - virtual ir_dereference *as_dereference() - { - return this; - } - - bool is_lvalue() const; - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() const = 0; -}; - - -class ir_dereference_variable : public ir_dereference { -public: - ir_dereference_variable(ir_variable *var); - - virtual ir_dereference_variable *clone(void *mem_ctx, - struct hash_table *) const; - - virtual ir_constant *constant_expression_value(); - - virtual ir_dereference_variable *as_dereference_variable() - { - return this; - } - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() const - { - return this->var; - } - - virtual ir_variable *whole_variable_referenced() - { - /* ir_dereference_variable objects always dereference the entire - * variable. However, if this dereference is dereferenced by anything - * else, the complete deferefernce chain is not a whole-variable - * dereference. This method should only be called on the top most - * ir_rvalue in a dereference chain. - */ - return this->var; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Object being dereferenced. - */ - ir_variable *var; -}; - - -class ir_dereference_array : public ir_dereference { -public: - ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index); - - ir_dereference_array(ir_variable *var, ir_rvalue *array_index); - - virtual ir_dereference_array *clone(void *mem_ctx, - struct hash_table *) const; - - virtual ir_constant *constant_expression_value(); - - virtual ir_dereference_array *as_dereference_array() - { - return this; - } - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() const - { - return this->array->variable_referenced(); - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *array; - ir_rvalue *array_index; - -private: - void set_array(ir_rvalue *value); -}; - - -class ir_dereference_record : public ir_dereference { -public: - ir_dereference_record(ir_rvalue *value, const char *field); - - ir_dereference_record(ir_variable *var, const char *field); - - virtual ir_dereference_record *clone(void *mem_ctx, - struct hash_table *) const; - - virtual ir_constant *constant_expression_value(); - - /** - * Get the variable that is ultimately referenced by an r-value - */ - virtual ir_variable *variable_referenced() const - { - return this->record->variable_referenced(); - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - ir_rvalue *record; - const char *field; -}; - - -/** - * Data stored in an ir_constant - */ -union ir_constant_data { - unsigned u[16]; - int i[16]; - float f[16]; - bool b[16]; -}; - - -class ir_constant : public ir_rvalue { -public: - ir_constant(const struct glsl_type *type, const ir_constant_data *data); - ir_constant(bool b); - ir_constant(unsigned int u); - ir_constant(int i); - ir_constant(float f); - - /** - * Construct an ir_constant from a list of ir_constant values - */ - ir_constant(const struct glsl_type *type, exec_list *values); - - /** - * Construct an ir_constant from a scalar component of another ir_constant - * - * The new \c ir_constant inherits the type of the component from the - * source constant. - * - * \note - * In the case of a matrix constant, the new constant is a scalar, \b not - * a vector. - */ - ir_constant(const ir_constant *c, unsigned i); - - /** - * Return a new ir_constant of the specified type containing all zeros. - */ - static ir_constant *zero(void *mem_ctx, const glsl_type *type); - - virtual ir_constant *clone(void *mem_ctx, struct hash_table *) const; - - virtual ir_constant *constant_expression_value(); - - virtual ir_constant *as_constant() - { - return this; - } - - virtual void accept(ir_visitor *v) - { - v->visit(this); - } - - virtual ir_visitor_status accept(ir_hierarchical_visitor *); - - /** - * Get a particular component of a constant as a specific type - * - * This is useful, for example, to get a value from an integer constant - * as a float or bool. This appears frequently when constructors are - * called with all constant parameters. - */ - /*@{*/ - bool get_bool_component(unsigned i) const; - float get_float_component(unsigned i) const; - int get_int_component(unsigned i) const; - unsigned get_uint_component(unsigned i) const; - /*@}*/ - - ir_constant *get_array_element(unsigned i) const; - - ir_constant *get_record_field(const char *name); - - /** - * Determine whether a constant has the same value as another constant - * - * \sa ir_constant::is_zero, ir_constant::is_one, - * ir_constant::is_negative_one - */ - bool has_value(const ir_constant *) const; - - virtual bool is_zero() const; - virtual bool is_one() const; - virtual bool is_negative_one() const; - - /** - * Value of the constant. - * - * The field used to back the values supplied by the constant is determined - * by the type associated with the \c ir_instruction. Constants may be - * scalars, vectors, or matrices. - */ - union ir_constant_data value; - - /* Array elements */ - ir_constant **array_elements; - - /* Structure fields */ - exec_list components; - -private: - /** - * Parameterless constructor only used by the clone method - */ - ir_constant(void); -}; - -/*@}*/ - -/** - * Apply a visitor to each IR node in a list - */ -void -visit_exec_list(exec_list *list, ir_visitor *visitor); - -/** - * Validate invariants on each IR node in a list - */ -void validate_ir_tree(exec_list *instructions); - -struct _mesa_glsl_parse_state; -struct gl_shader_program; - -/** - * Detect whether an unlinked shader contains static recursion - * - * If the list of instructions is determined to contain static recursion, - * \c _mesa_glsl_error will be called to emit error messages for each function - * that is in the recursion cycle. - */ -void -detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, - exec_list *instructions); - -/** - * Detect whether a linked shader contains static recursion - * - * If the list of instructions is determined to contain static recursion, - * \c link_error_printf will be called to emit error messages for each function - * that is in the recursion cycle. In addition, - * \c gl_shader_program::LinkStatus will be set to false. - */ -void -detect_recursion_linked(struct gl_shader_program *prog, - exec_list *instructions); - -/** - * Make a clone of each IR instruction in a list - * - * \param in List of IR instructions that are to be cloned - * \param out List to hold the cloned instructions - */ -void -clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in); - -extern void -_mesa_glsl_initialize_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -extern void -_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state); - -extern void -_mesa_glsl_release_functions(void); - -extern void -reparent_ir(exec_list *list, void *mem_ctx); - -struct glsl_symbol_table; - -extern void -import_prototypes(const exec_list *source, exec_list *dest, - struct glsl_symbol_table *symbols, void *mem_ctx); - -extern bool -ir_has_call(ir_instruction *ir); - -extern void -do_set_program_inouts(exec_list *instructions, struct gl_program *prog, - bool is_fragment_shader); - -extern char * -prototype_string(const glsl_type *return_type, const char *name, - exec_list *parameters); - -#endif /* IR_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_basic_block.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_basic_block.cpp deleted file mode 100644 index a8338259620..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_basic_block.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_basic_block.cpp - * - * Basic block analysis of instruction streams. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_basic_block.h" -#include "glsl_types.h" - -class ir_has_call_visitor : public ir_hierarchical_visitor { -public: - ir_has_call_visitor() - { - has_call = false; - } - - virtual ir_visitor_status visit_enter(ir_call *ir) - { - (void) ir; - has_call = true; - return visit_stop; - } - - bool has_call; -}; - -bool -ir_has_call(ir_instruction *ir) -{ - ir_has_call_visitor v; - ir->accept(&v); - return v.has_call; -} - -/** - * Calls a user function for every basic block in the instruction stream. - * - * Basic block analysis is pretty easy in our IR thanks to the lack of - * unstructured control flow. We've got: - * - * ir_loop (for () {}, while () {}, do {} while ()) - * ir_loop_jump ( - * ir_if () {} - * ir_return - * ir_call() - * - * Note that the basic blocks returned by this don't encompass all - * operations performed by the program -- for example, if conditions - * don't get returned, nor do the assignments that will be generated - * for ir_call parameters. - */ -void call_for_basic_blocks(exec_list *instructions, - void (*callback)(ir_instruction *first, - ir_instruction *last, - void *data), - void *data) -{ - ir_instruction *leader = NULL; - ir_instruction *last = NULL; - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_if *ir_if; - ir_loop *ir_loop; - ir_function *ir_function; - - if (!leader) - leader = ir; - - if ((ir_if = ir->as_if())) { - callback(leader, ir, data); - leader = NULL; - - call_for_basic_blocks(&ir_if->then_instructions, callback, data); - call_for_basic_blocks(&ir_if->else_instructions, callback, data); - } else if ((ir_loop = ir->as_loop())) { - callback(leader, ir, data); - leader = NULL; - call_for_basic_blocks(&ir_loop->body_instructions, callback, data); - } else if (ir->as_return() || ir->as_call()) { - callback(leader, ir, data); - leader = NULL; - } else if ((ir_function = ir->as_function())) { - /* A function definition doesn't interrupt our basic block - * since execution doesn't go into it. We should process the - * bodies of its signatures for BBs, though. - * - * Note that we miss an opportunity for producing more - * maximal BBs between the instructions that precede main() - * and the body of main(). Perhaps those instructions ought - * to live inside of main(). - */ - foreach_iter(exec_list_iterator, fun_iter, *ir_function) { - ir_function_signature *ir_sig; - - ir_sig = (ir_function_signature *)fun_iter.get(); - - call_for_basic_blocks(&ir_sig->body, callback, data); - } - } else if (ir->as_assignment()) { - /* If there's a call in the expression tree being assigned, - * then that ends the BB too. - * - * The assumption is that any consumer of the basic block - * walker is fine with the fact that the call is somewhere in - * the tree even if portions of the tree may be evaluated - * after the call. - * - * A consumer that has an issue with this could not process - * the last instruction of the basic block. If doing so, - * expression flattener may be useful before using the basic - * block finder to get more maximal basic blocks out. - */ - if (ir_has_call(ir)) { - callback(leader, ir, data); - leader = NULL; - } - } - last = ir; - } - if (leader) { - callback(leader, last, data); - } -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_basic_block.h b/reactos/dll/opengl/mesa/src/glsl/ir_basic_block.h deleted file mode 100644 index dbd678b5c4f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_basic_block.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -void call_for_basic_blocks(exec_list *instructions, - void (*callback)(ir_instruction *first, - ir_instruction *last, - void *data), - void *data); diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_clone.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_clone.cpp deleted file mode 100644 index 16e4c5079f1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_clone.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include "main/compiler.h" -#include "ir.h" -#include "glsl_types.h" -#include "program/hash_table.h" - -/** - * Duplicate an IR variable - * - * \note - * This will probably be made \c virtual and moved to the base class - * eventually. - */ -ir_variable * -ir_variable::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_variable *var = new(mem_ctx) ir_variable(this->type, this->name, - (ir_variable_mode) this->mode); - - var->max_array_access = this->max_array_access; - var->read_only = this->read_only; - var->centroid = this->centroid; - var->invariant = this->invariant; - var->interpolation = this->interpolation; - var->location = this->location; - var->warn_extension = this->warn_extension; - var->has_initializer = this->has_initializer; - var->depth_layout = this->depth_layout; - - var->num_state_slots = this->num_state_slots; - if (this->state_slots) { - /* FINISHME: This really wants to use something like talloc_reference, but - * FINISHME: ralloc doesn't have any similar function. - */ - var->state_slots = ralloc_array(var, ir_state_slot, - this->num_state_slots); - memcpy(var->state_slots, this->state_slots, - sizeof(this->state_slots[0]) * var->num_state_slots); - } - - if (this->constant_value) - var->constant_value = this->constant_value->clone(mem_ctx, ht); - - if (this->constant_initializer) - var->constant_initializer = - this->constant_initializer->clone(mem_ctx, ht); - - if (ht) { - hash_table_insert(ht, var, (void *)const_cast(this)); - } - - return var; -} - -ir_swizzle * -ir_swizzle::clone(void *mem_ctx, struct hash_table *ht) const -{ - return new(mem_ctx) ir_swizzle(this->val->clone(mem_ctx, ht), this->mask); -} - -ir_return * -ir_return::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_rvalue *new_value = NULL; - - if (this->value) - new_value = this->value->clone(mem_ctx, ht); - - return new(mem_ctx) ir_return(new_value); -} - -ir_discard * -ir_discard::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_rvalue *new_condition = NULL; - - if (this->condition != NULL) - new_condition = this->condition->clone(mem_ctx, ht); - - return new(mem_ctx) ir_discard(new_condition); -} - -ir_loop_jump * -ir_loop_jump::clone(void *mem_ctx, struct hash_table *ht) const -{ - (void)ht; - - return new(mem_ctx) ir_loop_jump(this->mode); -} - -ir_if * -ir_if::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_if *new_if = new(mem_ctx) ir_if(this->condition->clone(mem_ctx, ht)); - - foreach_iter(exec_list_iterator, iter, this->then_instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_if->then_instructions.push_tail(ir->clone(mem_ctx, ht)); - } - - foreach_iter(exec_list_iterator, iter, this->else_instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_if->else_instructions.push_tail(ir->clone(mem_ctx, ht)); - } - - return new_if; -} - -ir_loop * -ir_loop::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_loop *new_loop = new(mem_ctx) ir_loop(); - - if (this->from) - new_loop->from = this->from->clone(mem_ctx, ht); - if (this->to) - new_loop->to = this->to->clone(mem_ctx, ht); - if (this->increment) - new_loop->increment = this->increment->clone(mem_ctx, ht); - new_loop->counter = counter; - - foreach_iter(exec_list_iterator, iter, this->body_instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht)); - } - - new_loop->cmp = this->cmp; - return new_loop; -} - -ir_call * -ir_call::clone(void *mem_ctx, struct hash_table *ht) const -{ - if (this->type == glsl_type::error_type) - return ir_call::get_error_instruction(mem_ctx); - - exec_list new_parameters; - - foreach_iter(exec_list_iterator, iter, this->actual_parameters) { - ir_instruction *ir = (ir_instruction *)iter.get(); - new_parameters.push_tail(ir->clone(mem_ctx, ht)); - } - - return new(mem_ctx) ir_call(this->callee, &new_parameters); -} - -ir_expression * -ir_expression::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_rvalue *op[Elements(this->operands)] = { NULL, }; - unsigned int i; - - for (i = 0; i < get_num_operands(); i++) { - op[i] = this->operands[i]->clone(mem_ctx, ht); - } - - return new(mem_ctx) ir_expression(this->operation, this->type, - op[0], op[1], op[2], op[3]); -} - -ir_dereference_variable * -ir_dereference_variable::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_variable *new_var; - - if (ht) { - new_var = (ir_variable *)hash_table_find(ht, this->var); - if (!new_var) - new_var = this->var; - } else { - new_var = this->var; - } - - return new(mem_ctx) ir_dereference_variable(new_var); -} - -ir_dereference_array * -ir_dereference_array::clone(void *mem_ctx, struct hash_table *ht) const -{ - return new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, ht), - this->array_index->clone(mem_ctx, - ht)); -} - -ir_dereference_record * -ir_dereference_record::clone(void *mem_ctx, struct hash_table *ht) const -{ - return new(mem_ctx) ir_dereference_record(this->record->clone(mem_ctx, ht), - this->field); -} - -ir_texture * -ir_texture::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_texture *new_tex = new(mem_ctx) ir_texture(this->op); - new_tex->type = this->type; - - new_tex->sampler = this->sampler->clone(mem_ctx, ht); - if (this->coordinate) - new_tex->coordinate = this->coordinate->clone(mem_ctx, ht); - if (this->projector) - new_tex->projector = this->projector->clone(mem_ctx, ht); - if (this->shadow_comparitor) { - new_tex->shadow_comparitor = this->shadow_comparitor->clone(mem_ctx, ht); - } - - if (this->offset != NULL) - new_tex->offset = this->offset->clone(mem_ctx, ht); - - switch (this->op) { - case ir_tex: - break; - case ir_txb: - new_tex->lod_info.bias = this->lod_info.bias->clone(mem_ctx, ht); - break; - case ir_txl: - case ir_txf: - case ir_txs: - new_tex->lod_info.lod = this->lod_info.lod->clone(mem_ctx, ht); - break; - case ir_txd: - new_tex->lod_info.grad.dPdx = this->lod_info.grad.dPdx->clone(mem_ctx, ht); - new_tex->lod_info.grad.dPdy = this->lod_info.grad.dPdy->clone(mem_ctx, ht); - break; - } - - return new_tex; -} - -ir_assignment * -ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_rvalue *new_condition = NULL; - - if (this->condition) - new_condition = this->condition->clone(mem_ctx, ht); - - return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), - this->rhs->clone(mem_ctx, ht), - new_condition, - this->write_mask); -} - -ir_function * -ir_function::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_function *copy = new(mem_ctx) ir_function(this->name); - - foreach_list_const(node, &this->signatures) { - const ir_function_signature *const sig = - (const ir_function_signature *const) node; - - ir_function_signature *sig_copy = sig->clone(mem_ctx, ht); - copy->add_signature(sig_copy); - - if (ht != NULL) - hash_table_insert(ht, sig_copy, - (void *)const_cast(sig)); - } - - return copy; -} - -ir_function_signature * -ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const -{ - ir_function_signature *copy = this->clone_prototype(mem_ctx, ht); - - copy->is_defined = this->is_defined; - - /* Clone the instruction list. - */ - foreach_list_const(node, &this->body) { - const ir_instruction *const inst = (const ir_instruction *) node; - - ir_instruction *const inst_copy = inst->clone(mem_ctx, ht); - copy->body.push_tail(inst_copy); - } - - return copy; -} - -ir_function_signature * -ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) const -{ - ir_function_signature *copy = - new(mem_ctx) ir_function_signature(this->return_type); - - copy->is_defined = false; - copy->is_builtin = this->is_builtin; - - /* Clone the parameter list, but NOT the body. - */ - foreach_list_const(node, &this->parameters) { - const ir_variable *const param = (const ir_variable *) node; - - assert(const_cast(param)->as_variable() != NULL); - - ir_variable *const param_copy = param->clone(mem_ctx, ht); - copy->parameters.push_tail(param_copy); - } - - return copy; -} - -ir_constant * -ir_constant::clone(void *mem_ctx, struct hash_table *ht) const -{ - (void)ht; - - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - return new(mem_ctx) ir_constant(this->type, &this->value); - - case GLSL_TYPE_STRUCT: { - ir_constant *c = new(mem_ctx) ir_constant; - - c->type = this->type; - for (exec_node *node = this->components.head - ; !node->is_tail_sentinel() - ; node = node->next) { - ir_constant *const orig = (ir_constant *) node; - - c->components.push_tail(orig->clone(mem_ctx, NULL)); - } - - return c; - } - - case GLSL_TYPE_ARRAY: { - ir_constant *c = new(mem_ctx) ir_constant; - - c->type = this->type; - c->array_elements = ralloc_array(c, ir_constant *, this->type->length); - for (unsigned i = 0; i < this->type->length; i++) { - c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL); - } - return c; - } - - default: - assert(!"Should not get here."); - return NULL; - } -} - - -class fixup_ir_call_visitor : public ir_hierarchical_visitor { -public: - fixup_ir_call_visitor(struct hash_table *ht) - { - this->ht = ht; - } - - virtual ir_visitor_status visit_enter(ir_call *ir) - { - /* Try to find the function signature referenced by the ir_call in the - * table. If it is found, replace it with the value from the table. - */ - ir_function_signature *sig = - (ir_function_signature *) hash_table_find(this->ht, ir->get_callee()); - if (sig != NULL) - ir->set_callee(sig); - - /* Since this may be used before function call parameters are flattened, - * the children also need to be processed. - */ - return visit_continue; - } - -private: - struct hash_table *ht; -}; - - -static void -fixup_function_calls(struct hash_table *ht, exec_list *instructions) -{ - fixup_ir_call_visitor v(ht); - v.run(instructions); -} - - -void -clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in) -{ - struct hash_table *ht = - hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); - - foreach_list_const(node, in) { - const ir_instruction *const original = (ir_instruction *) node; - ir_instruction *copy = original->clone(mem_ctx, ht); - - out->push_tail(copy); - } - - /* Make a pass over the cloned tree to fix up ir_call nodes to point to the - * cloned ir_function_signature nodes. This cannot be done automatically - * during cloning because the ir_call might be a forward reference (i.e., - * the function signature that it references may not have been cloned yet). - */ - fixup_function_calls(ht, out); - - hash_table_dtor(ht); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_constant_expression.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_constant_expression.cpp deleted file mode 100644 index fa027232b6a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_constant_expression.cpp +++ /dev/null @@ -1,1422 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_constant_expression.cpp - * Evaluate and process constant valued expressions - * - * In GLSL, constant valued expressions are used in several places. These - * must be processed and evaluated very early in the compilation process. - * - * * Sizes of arrays - * * Initializers for uniforms - * * Initializers for \c const variables - */ - -#include -#include "main/core.h" /* for MAX2, MIN2, CLAMP */ -#include "ir.h" -#include "ir_visitor.h" -#include "glsl_types.h" - -/* Using C99 rounding functions for roundToEven() implementation is - * difficult, because round(), rint, and nearbyint() are affected by - * fesetenv(), which the application may have done for its own - * purposes. Mesa's IROUND macro is close to what we want, but it - * rounds away from 0 on n + 0.5. - */ -static int -round_to_even(float val) -{ - int rounded = IROUND(val); - - if (val - floor(val) == 0.5) { - if (rounded % 2 != 0) - rounded += val > 0 ? -1 : 1; - } - - return rounded; -} - -static float -dot(ir_constant *op0, ir_constant *op1) -{ - assert(op0->type->is_float() && op1->type->is_float()); - - float result = 0; - for (unsigned c = 0; c < op0->type->components(); c++) - result += op0->value.f[c] * op1->value.f[c]; - - return result; -} - -ir_constant * -ir_expression::constant_expression_value() -{ - if (this->type->is_error()) - return NULL; - - ir_constant *op[Elements(this->operands)] = { NULL, }; - ir_constant_data data; - - memset(&data, 0, sizeof(data)); - - for (unsigned operand = 0; operand < this->get_num_operands(); operand++) { - op[operand] = this->operands[operand]->constant_expression_value(); - if (!op[operand]) - return NULL; - } - - if (op[1] != NULL) - assert(op[0]->type->base_type == op[1]->type->base_type || - this->operation == ir_binop_lshift || - this->operation == ir_binop_rshift); - - bool op0_scalar = op[0]->type->is_scalar(); - bool op1_scalar = op[1] != NULL && op[1]->type->is_scalar(); - - /* When iterating over a vector or matrix's components, we want to increase - * the loop counter. However, for scalars, we want to stay at 0. - */ - unsigned c0_inc = op0_scalar ? 0 : 1; - unsigned c1_inc = op1_scalar ? 0 : 1; - unsigned components; - if (op1_scalar || !op[1]) { - components = op[0]->type->components(); - } else { - components = op[1]->type->components(); - } - - void *ctx = ralloc_parent(this); - - /* Handle array operations here, rather than below. */ - if (op[0]->type->is_array()) { - assert(op[1] != NULL && op[1]->type->is_array()); - switch (this->operation) { - case ir_binop_all_equal: - return new(ctx) ir_constant(op[0]->has_value(op[1])); - case ir_binop_any_nequal: - return new(ctx) ir_constant(!op[0]->has_value(op[1])); - default: - break; - } - return NULL; - } - - switch (this->operation) { - case ir_unop_bit_not: - switch (op[0]->type->base_type) { - case GLSL_TYPE_INT: - for (unsigned c = 0; c < components; c++) - data.i[c] = ~ op[0]->value.i[c]; - break; - case GLSL_TYPE_UINT: - for (unsigned c = 0; c < components; c++) - data.u[c] = ~ op[0]->value.u[c]; - break; - default: - assert(0); - } - break; - - case ir_unop_logic_not: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.b[c] = !op[0]->value.b[c]; - break; - - case ir_unop_f2i: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.i[c] = (int) op[0]->value.f[c]; - } - break; - case ir_unop_i2f: - assert(op[0]->type->base_type == GLSL_TYPE_INT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = (float) op[0]->value.i[c]; - } - break; - case ir_unop_u2f: - assert(op[0]->type->base_type == GLSL_TYPE_UINT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = (float) op[0]->value.u[c]; - } - break; - case ir_unop_b2f: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = op[0]->value.b[c] ? 1.0F : 0.0F; - } - break; - case ir_unop_f2b: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.b[c] = op[0]->value.f[c] != 0.0F ? true : false; - } - break; - case ir_unop_b2i: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.u[c] = op[0]->value.b[c] ? 1 : 0; - } - break; - case ir_unop_i2b: - assert(op[0]->type->is_integer()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.b[c] = op[0]->value.u[c] ? true : false; - } - break; - case ir_unop_u2i: - assert(op[0]->type->base_type == GLSL_TYPE_UINT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.i[c] = op[0]->value.u[c]; - } - break; - case ir_unop_i2u: - assert(op[0]->type->base_type == GLSL_TYPE_INT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.u[c] = op[0]->value.i[c]; - } - break; - case ir_unop_any: - assert(op[0]->type->is_boolean()); - data.b[0] = false; - for (unsigned c = 0; c < op[0]->type->components(); c++) { - if (op[0]->value.b[c]) - data.b[0] = true; - } - break; - - case ir_unop_trunc: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = truncf(op[0]->value.f[c]); - } - break; - - case ir_unop_round_even: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = round_to_even(op[0]->value.f[c]); - } - break; - - case ir_unop_ceil: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = ceilf(op[0]->value.f[c]); - } - break; - - case ir_unop_floor: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = floorf(op[0]->value.f[c]); - } - break; - - case ir_unop_fract: - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = 0; - break; - case GLSL_TYPE_INT: - data.i[c] = 0; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]); - break; - default: - assert(0); - } - } - break; - - case ir_unop_sin: - case ir_unop_sin_reduced: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = sinf(op[0]->value.f[c]); - } - break; - - case ir_unop_cos: - case ir_unop_cos_reduced: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = cosf(op[0]->value.f[c]); - } - break; - - case ir_unop_neg: - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = -((int) op[0]->value.u[c]); - break; - case GLSL_TYPE_INT: - data.i[c] = -op[0]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = -op[0]->value.f[c]; - break; - default: - assert(0); - } - } - break; - - case ir_unop_abs: - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c]; - if (data.i[c] < 0) - data.i[c] = -data.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = fabs(op[0]->value.f[c]); - break; - default: - assert(0); - } - } - break; - - case ir_unop_sign: - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.i[c] > 0; - break; - case GLSL_TYPE_INT: - data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0); - break; - case GLSL_TYPE_FLOAT: - data.f[c] = float((op[0]->value.f[c] > 0)-(op[0]->value.f[c] < 0)); - break; - default: - assert(0); - } - } - break; - - case ir_unop_rcp: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (this->type->base_type) { - case GLSL_TYPE_UINT: - if (op[0]->value.u[c] != 0.0) - data.u[c] = 1 / op[0]->value.u[c]; - break; - case GLSL_TYPE_INT: - if (op[0]->value.i[c] != 0.0) - data.i[c] = 1 / op[0]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - if (op[0]->value.f[c] != 0.0) - data.f[c] = 1.0F / op[0]->value.f[c]; - break; - default: - assert(0); - } - } - break; - - case ir_unop_rsq: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = 1.0F / sqrtf(op[0]->value.f[c]); - } - break; - - case ir_unop_sqrt: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = sqrtf(op[0]->value.f[c]); - } - break; - - case ir_unop_exp: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = expf(op[0]->value.f[c]); - } - break; - - case ir_unop_exp2: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = exp2f(op[0]->value.f[c]); - } - break; - - case ir_unop_log: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = logf(op[0]->value.f[c]); - } - break; - - case ir_unop_log2: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = log2f(op[0]->value.f[c]); - } - break; - - case ir_unop_dFdx: - case ir_unop_dFdy: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = 0.0; - } - break; - - case ir_binop_pow: - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]); - } - break; - - case ir_binop_dot: - data.f[0] = dot(op[0], op[1]); - break; - - case ir_binop_min: - assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = MIN2(op[0]->value.u[c0], op[1]->value.u[c1]); - break; - case GLSL_TYPE_INT: - data.i[c] = MIN2(op[0]->value.i[c0], op[1]->value.i[c1]); - break; - case GLSL_TYPE_FLOAT: - data.f[c] = MIN2(op[0]->value.f[c0], op[1]->value.f[c1]); - break; - default: - assert(0); - } - } - - break; - case ir_binop_max: - assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = MAX2(op[0]->value.u[c0], op[1]->value.u[c1]); - break; - case GLSL_TYPE_INT: - data.i[c] = MAX2(op[0]->value.i[c0], op[1]->value.i[c1]); - break; - case GLSL_TYPE_FLOAT: - data.f[c] = MAX2(op[0]->value.f[c0], op[1]->value.f[c1]); - break; - default: - assert(0); - } - } - break; - - case ir_binop_add: - assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c0] + op[1]->value.i[c1]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c0] + op[1]->value.f[c1]; - break; - default: - assert(0); - } - } - - break; - case ir_binop_sub: - assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1]; - break; - default: - assert(0); - } - } - - break; - case ir_binop_mul: - /* Check for equal types, or unequal types involving scalars */ - if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix()) - || op0_scalar || op1_scalar) { - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1]; - break; - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c0] * op[1]->value.f[c1]; - break; - default: - assert(0); - } - } - } else { - assert(op[0]->type->is_matrix() || op[1]->type->is_matrix()); - - /* Multiply an N-by-M matrix with an M-by-P matrix. Since either - * matrix can be a GLSL vector, either N or P can be 1. - * - * For vec*mat, the vector is treated as a row vector. This - * means the vector is a 1-row x M-column matrix. - * - * For mat*vec, the vector is treated as a column vector. Since - * matrix_columns is 1 for vectors, this just works. - */ - const unsigned n = op[0]->type->is_vector() - ? 1 : op[0]->type->vector_elements; - const unsigned m = op[1]->type->vector_elements; - const unsigned p = op[1]->type->matrix_columns; - for (unsigned j = 0; j < p; j++) { - for (unsigned i = 0; i < n; i++) { - for (unsigned k = 0; k < m; k++) { - data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j]; - } - } - } - } - - break; - case ir_binop_div: - /* FINISHME: Emit warning when division-by-zero is detected. */ - assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - if (op[1]->value.u[c1] == 0) { - data.u[c] = 0; - } else { - data.u[c] = op[0]->value.u[c0] / op[1]->value.u[c1]; - } - break; - case GLSL_TYPE_INT: - if (op[1]->value.i[c1] == 0) { - data.i[c] = 0; - } else { - data.i[c] = op[0]->value.i[c0] / op[1]->value.i[c1]; - } - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[0]->value.f[c0] / op[1]->value.f[c1]; - break; - default: - assert(0); - } - } - - break; - case ir_binop_mod: - /* FINISHME: Emit warning when division-by-zero is detected. */ - assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar); - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - if (op[1]->value.u[c1] == 0) { - data.u[c] = 0; - } else { - data.u[c] = op[0]->value.u[c0] % op[1]->value.u[c1]; - } - break; - case GLSL_TYPE_INT: - if (op[1]->value.i[c1] == 0) { - data.i[c] = 0; - } else { - data.i[c] = op[0]->value.i[c0] % op[1]->value.i[c1]; - } - break; - case GLSL_TYPE_FLOAT: - /* We don't use fmod because it rounds toward zero; GLSL specifies - * the use of floor. - */ - data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1] - * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]); - break; - default: - assert(0); - } - } - - break; - - case ir_binop_logic_and: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.b[c] = op[0]->value.b[c] && op[1]->value.b[c]; - break; - case ir_binop_logic_xor: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c]; - break; - case ir_binop_logic_or: - assert(op[0]->type->base_type == GLSL_TYPE_BOOL); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.b[c] = op[0]->value.b[c] || op[1]->value.b[c]; - break; - - case ir_binop_less: - assert(op[0]->type == op[1]->type); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] < op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] < op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] < op[1]->value.f[c]; - break; - default: - assert(0); - } - } - break; - case ir_binop_greater: - assert(op[0]->type == op[1]->type); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] > op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] > op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] > op[1]->value.f[c]; - break; - default: - assert(0); - } - } - break; - case ir_binop_lequal: - assert(op[0]->type == op[1]->type); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c]; - break; - default: - assert(0); - } - } - break; - case ir_binop_gequal: - assert(op[0]->type == op[1]->type); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c]; - break; - default: - assert(0); - } - } - break; - case ir_binop_equal: - assert(op[0]->type == op[1]->type); - for (unsigned c = 0; c < components; c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] == op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] == op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] == op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[c] = op[0]->value.b[c] == op[1]->value.b[c]; - break; - default: - assert(0); - } - } - break; - case ir_binop_nequal: - assert(op[0]->type == op[1]->type); - for (unsigned c = 0; c < components; c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] != op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] != op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] != op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[c] = op[0]->value.b[c] != op[1]->value.b[c]; - break; - default: - assert(0); - } - } - break; - case ir_binop_all_equal: - data.b[0] = op[0]->has_value(op[1]); - break; - case ir_binop_any_nequal: - data.b[0] = !op[0]->has_value(op[1]); - break; - - case ir_binop_lshift: - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - if (op[0]->type->base_type == GLSL_TYPE_INT && - op[1]->type->base_type == GLSL_TYPE_INT) { - data.i[c] = op[0]->value.i[c0] << op[1]->value.i[c1]; - - } else if (op[0]->type->base_type == GLSL_TYPE_INT && - op[1]->type->base_type == GLSL_TYPE_UINT) { - data.i[c] = op[0]->value.i[c0] << op[1]->value.u[c1]; - - } else if (op[0]->type->base_type == GLSL_TYPE_UINT && - op[1]->type->base_type == GLSL_TYPE_INT) { - data.u[c] = op[0]->value.u[c0] << op[1]->value.i[c1]; - - } else if (op[0]->type->base_type == GLSL_TYPE_UINT && - op[1]->type->base_type == GLSL_TYPE_UINT) { - data.u[c] = op[0]->value.u[c0] << op[1]->value.u[c1]; - } - } - break; - - case ir_binop_rshift: - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - if (op[0]->type->base_type == GLSL_TYPE_INT && - op[1]->type->base_type == GLSL_TYPE_INT) { - data.i[c] = op[0]->value.i[c0] >> op[1]->value.i[c1]; - - } else if (op[0]->type->base_type == GLSL_TYPE_INT && - op[1]->type->base_type == GLSL_TYPE_UINT) { - data.i[c] = op[0]->value.i[c0] >> op[1]->value.u[c1]; - - } else if (op[0]->type->base_type == GLSL_TYPE_UINT && - op[1]->type->base_type == GLSL_TYPE_INT) { - data.u[c] = op[0]->value.u[c0] >> op[1]->value.i[c1]; - - } else if (op[0]->type->base_type == GLSL_TYPE_UINT && - op[1]->type->base_type == GLSL_TYPE_UINT) { - data.u[c] = op[0]->value.u[c0] >> op[1]->value.u[c1]; - } - } - break; - - case ir_binop_bit_and: - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c0] & op[1]->value.i[c1]; - break; - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c0] & op[1]->value.u[c1]; - break; - default: - assert(0); - } - } - break; - - case ir_binop_bit_or: - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c0] | op[1]->value.i[c1]; - break; - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c0] | op[1]->value.u[c1]; - break; - default: - assert(0); - } - } - break; - - case ir_binop_bit_xor: - for (unsigned c = 0, c0 = 0, c1 = 0; - c < components; - c0 += c0_inc, c1 += c1_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_INT: - data.i[c] = op[0]->value.i[c0] ^ op[1]->value.i[c1]; - break; - case GLSL_TYPE_UINT: - data.u[c] = op[0]->value.u[c0] ^ op[1]->value.u[c1]; - break; - default: - assert(0); - } - } - break; - - case ir_quadop_vector: - for (unsigned c = 0; c < this->type->vector_elements; c++) { - switch (this->type->base_type) { - case GLSL_TYPE_INT: - data.i[c] = op[c]->value.i[0]; - break; - case GLSL_TYPE_UINT: - data.u[c] = op[c]->value.u[0]; - break; - case GLSL_TYPE_FLOAT: - data.f[c] = op[c]->value.f[0]; - break; - default: - assert(0); - } - } - break; - - default: - /* FINISHME: Should handle all expression types. */ - return NULL; - } - - return new(ctx) ir_constant(this->type, &data); -} - - -ir_constant * -ir_texture::constant_expression_value() -{ - /* texture lookups aren't constant expressions */ - return NULL; -} - - -ir_constant * -ir_swizzle::constant_expression_value() -{ - ir_constant *v = this->val->constant_expression_value(); - - if (v != NULL) { - ir_constant_data data = { { 0 } }; - - const unsigned swiz_idx[4] = { - this->mask.x, this->mask.y, this->mask.z, this->mask.w - }; - - for (unsigned i = 0; i < this->mask.num_components; i++) { - switch (v->type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break; - case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break; - case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break; - default: assert(!"Should not get here."); break; - } - } - - void *ctx = ralloc_parent(this); - return new(ctx) ir_constant(this->type, &data); - } - return NULL; -} - - -ir_constant * -ir_dereference_variable::constant_expression_value() -{ - /* This may occur during compile and var->type is glsl_type::error_type */ - if (!var) - return NULL; - - /* The constant_value of a uniform variable is its initializer, - * not the lifetime constant value of the uniform. - */ - if (var->mode == ir_var_uniform) - return NULL; - - if (!var->constant_value) - return NULL; - - return var->constant_value->clone(ralloc_parent(var), NULL); -} - - -ir_constant * -ir_dereference_array::constant_expression_value() -{ - ir_constant *array = this->array->constant_expression_value(); - ir_constant *idx = this->array_index->constant_expression_value(); - - if ((array != NULL) && (idx != NULL)) { - void *ctx = ralloc_parent(this); - if (array->type->is_matrix()) { - /* Array access of a matrix results in a vector. - */ - const unsigned column = idx->value.u[0]; - - const glsl_type *const column_type = array->type->column_type(); - - /* Offset in the constant matrix to the first element of the column - * to be extracted. - */ - const unsigned mat_idx = column * column_type->vector_elements; - - ir_constant_data data = { { 0 } }; - - switch (column_type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - for (unsigned i = 0; i < column_type->vector_elements; i++) - data.u[i] = array->value.u[mat_idx + i]; - - break; - - case GLSL_TYPE_FLOAT: - for (unsigned i = 0; i < column_type->vector_elements; i++) - data.f[i] = array->value.f[mat_idx + i]; - - break; - - default: - assert(!"Should not get here."); - break; - } - - return new(ctx) ir_constant(column_type, &data); - } else if (array->type->is_vector()) { - const unsigned component = idx->value.u[0]; - - return new(ctx) ir_constant(array, component); - } else { - const unsigned index = idx->value.u[0]; - return array->get_array_element(index)->clone(ctx, NULL); - } - } - return NULL; -} - - -ir_constant * -ir_dereference_record::constant_expression_value() -{ - ir_constant *v = this->record->constant_expression_value(); - - return (v != NULL) ? v->get_record_field(this->field) : NULL; -} - - -ir_constant * -ir_assignment::constant_expression_value() -{ - /* FINISHME: Handle CEs involving assignment (return RHS) */ - return NULL; -} - - -ir_constant * -ir_constant::constant_expression_value() -{ - return this; -} - - -ir_constant * -ir_call::constant_expression_value() -{ - if (this->type == glsl_type::error_type) - return NULL; - - /* From the GLSL 1.20 spec, page 23: - * "Function calls to user-defined functions (non-built-in functions) - * cannot be used to form constant expressions." - */ - if (!this->callee->is_builtin) - return NULL; - - unsigned num_parameters = 0; - - /* Check if all parameters are constant */ - ir_constant *op[3]; - foreach_list(n, &this->actual_parameters) { - ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value(); - if (constant == NULL) - return NULL; - - op[num_parameters] = constant; - - assert(num_parameters < 3); - num_parameters++; - } - - /* Individual cases below can either: - * - Assign "expr" a new ir_expression to evaluate (for basic opcodes) - * - Fill "data" with appopriate constant data - * - Return an ir_constant directly. - */ - void *mem_ctx = ralloc_parent(this); - ir_expression *expr = NULL; - - ir_constant_data data; - memset(&data, 0, sizeof(data)); - - const char *callee = this->callee_name(); - if (strcmp(callee, "abs") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL); - } else if (strcmp(callee, "all") == 0) { - assert(op[0]->type->is_boolean()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - if (!op[0]->value.b[c]) - return new(mem_ctx) ir_constant(false); - } - return new(mem_ctx) ir_constant(true); - } else if (strcmp(callee, "any") == 0) { - assert(op[0]->type->is_boolean()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - if (op[0]->value.b[c]) - return new(mem_ctx) ir_constant(true); - } - return new(mem_ctx) ir_constant(false); - } else if (strcmp(callee, "acos") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = acosf(op[0]->value.f[c]); - } else if (strcmp(callee, "acosh") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = acoshf(op[0]->value.f[c]); - } else if (strcmp(callee, "asin") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = asinf(op[0]->value.f[c]); - } else if (strcmp(callee, "asinh") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = asinhf(op[0]->value.f[c]); - } else if (strcmp(callee, "atan") == 0) { - assert(op[0]->type->is_float()); - if (num_parameters == 2) { - assert(op[1]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = atan2f(op[0]->value.f[c], op[1]->value.f[c]); - } else { - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = atanf(op[0]->value.f[c]); - } - } else if (strcmp(callee, "atanh") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = atanhf(op[0]->value.f[c]); - } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) { - return ir_constant::zero(mem_ctx, this->type); - } else if (strcmp(callee, "ceil") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL); - } else if (strcmp(callee, "clamp") == 0) { - assert(num_parameters == 3); - unsigned c1_inc = op[1]->type->is_scalar() ? 0 : 1; - unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1; - for (unsigned c = 0, c1 = 0, c2 = 0; - c < op[0]->type->components(); - c1 += c1_inc, c2 += c2_inc, c++) { - - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.u[c] = CLAMP(op[0]->value.u[c], op[1]->value.u[c1], - op[2]->value.u[c2]); - break; - case GLSL_TYPE_INT: - data.i[c] = CLAMP(op[0]->value.i[c], op[1]->value.i[c1], - op[2]->value.i[c2]); - break; - case GLSL_TYPE_FLOAT: - data.f[c] = CLAMP(op[0]->value.f[c], op[1]->value.f[c1], - op[2]->value.f[c2]); - break; - default: - assert(!"Should not get here."); - } - } - } else if (strcmp(callee, "cos") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL); - } else if (strcmp(callee, "cosh") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = coshf(op[0]->value.f[c]); - } else if (strcmp(callee, "cross") == 0) { - assert(op[0]->type == glsl_type::vec3_type); - assert(op[1]->type == glsl_type::vec3_type); - data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] - - op[1]->value.f[1] * op[0]->value.f[2]); - data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] - - op[1]->value.f[2] * op[0]->value.f[0]); - data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] - - op[1]->value.f[0] * op[0]->value.f[1]); - } else if (strcmp(callee, "degrees") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = 180.0F / M_PI * op[0]->value.f[c]; - } else if (strcmp(callee, "distance") == 0) { - assert(op[0]->type->is_float() && op[1]->type->is_float()); - float length_squared = 0.0; - for (unsigned c = 0; c < op[0]->type->components(); c++) { - float t = op[0]->value.f[c] - op[1]->value.f[c]; - length_squared += t * t; - } - return new(mem_ctx) ir_constant(sqrtf(length_squared)); - } else if (strcmp(callee, "dot") == 0) { - return new(mem_ctx) ir_constant(dot(op[0], op[1])); - } else if (strcmp(callee, "equal") == 0) { - assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] == op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] == op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] == op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[c] = op[0]->value.b[c] == op[1]->value.b[c]; - break; - default: - assert(!"Should not get here."); - } - } - } else if (strcmp(callee, "exp") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL); - } else if (strcmp(callee, "exp2") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL); - } else if (strcmp(callee, "faceforward") == 0) { - if (dot(op[2], op[1]) < 0) - return op[0]; - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = -op[0]->value.f[c]; - } else if (strcmp(callee, "floor") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL); - } else if (strcmp(callee, "fract") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL); - } else if (strcmp(callee, "fwidth") == 0) { - return ir_constant::zero(mem_ctx, this->type); - } else if (strcmp(callee, "greaterThan") == 0) { - assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] > op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] > op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] > op[1]->value.f[c]; - break; - default: - assert(!"Should not get here."); - } - } - } else if (strcmp(callee, "greaterThanEqual") == 0) { - assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c]; - break; - default: - assert(!"Should not get here."); - } - } - } else if (strcmp(callee, "inversesqrt") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL); - } else if (strcmp(callee, "length") == 0) { - return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0]))); - } else if (strcmp(callee, "lessThan") == 0) { - assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] < op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] < op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] < op[1]->value.f[c]; - break; - default: - assert(!"Should not get here."); - } - } - } else if (strcmp(callee, "lessThanEqual") == 0) { - assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c]; - break; - default: - assert(!"Should not get here."); - } - } - } else if (strcmp(callee, "log") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL); - } else if (strcmp(callee, "log2") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL); - } else if (strcmp(callee, "matrixCompMult") == 0) { - assert(op[0]->type->is_float() && op[1]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = op[0]->value.f[c] * op[1]->value.f[c]; - } else if (strcmp(callee, "max") == 0) { - expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]); - } else if (strcmp(callee, "min") == 0) { - expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]); - } else if (strcmp(callee, "mix") == 0) { - assert(op[0]->type->is_float() && op[1]->type->is_float()); - if (op[2]->type->is_float()) { - unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1; - unsigned components = op[0]->type->components(); - for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) { - data.f[c] = op[0]->value.f[c] * (1 - op[2]->value.f[c2]) + - op[1]->value.f[c] * op[2]->value.f[c2]; - } - } else { - assert(op[2]->type->is_boolean()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = op[op[2]->value.b[c] ? 1 : 0]->value.f[c]; - } - } else if (strcmp(callee, "mod") == 0) { - expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]); - } else if (strcmp(callee, "normalize") == 0) { - assert(op[0]->type->is_float()); - float length = sqrtf(dot(op[0], op[0])); - - if (length == 0) - return ir_constant::zero(mem_ctx, this->type); - - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = op[0]->value.f[c] / length; - } else if (strcmp(callee, "not") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL); - } else if (strcmp(callee, "notEqual") == 0) { - assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector()); - for (unsigned c = 0; c < op[0]->type->components(); c++) { - switch (op[0]->type->base_type) { - case GLSL_TYPE_UINT: - data.b[c] = op[0]->value.u[c] != op[1]->value.u[c]; - break; - case GLSL_TYPE_INT: - data.b[c] = op[0]->value.i[c] != op[1]->value.i[c]; - break; - case GLSL_TYPE_FLOAT: - data.b[c] = op[0]->value.f[c] != op[1]->value.f[c]; - break; - case GLSL_TYPE_BOOL: - data.b[c] = op[0]->value.b[c] != op[1]->value.b[c]; - break; - default: - assert(!"Should not get here."); - } - } - } else if (strcmp(callee, "outerProduct") == 0) { - assert(op[0]->type->is_vector() && op[1]->type->is_vector()); - const unsigned m = op[0]->type->vector_elements; - const unsigned n = op[1]->type->vector_elements; - for (unsigned j = 0; j < n; j++) { - for (unsigned i = 0; i < m; i++) { - data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j]; - } - } - } else if (strcmp(callee, "pow") == 0) { - expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]); - } else if (strcmp(callee, "radians") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = M_PI / 180.0F * op[0]->value.f[c]; - } else if (strcmp(callee, "reflect") == 0) { - assert(op[0]->type->is_float()); - float dot_NI = dot(op[1], op[0]); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c]; - } else if (strcmp(callee, "refract") == 0) { - const float eta = op[2]->value.f[0]; - const float dot_NI = dot(op[1], op[0]); - const float k = 1.0F - eta * eta * (1.0F - dot_NI * dot_NI); - if (k < 0.0) { - return ir_constant::zero(mem_ctx, this->type); - } else { - for (unsigned c = 0; c < type->components(); c++) { - data.f[c] = eta * op[0]->value.f[c] - (eta * dot_NI + sqrtf(k)) - * op[1]->value.f[c]; - } - } - } else if (strcmp(callee, "round") == 0 || - strcmp(callee, "roundEven") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_round_even, op[0]); - } else if (strcmp(callee, "sign") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL); - } else if (strcmp(callee, "sin") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL); - } else if (strcmp(callee, "sinh") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = sinhf(op[0]->value.f[c]); - } else if (strcmp(callee, "smoothstep") == 0) { - assert(num_parameters == 3); - assert(op[1]->type == op[0]->type); - unsigned edge_inc = op[0]->type->is_scalar() ? 0 : 1; - for (unsigned c = 0, e = 0; c < type->components(); e += edge_inc, c++) { - const float edge0 = op[0]->value.f[e]; - const float edge1 = op[1]->value.f[e]; - if (edge0 == edge1) { - data.f[c] = 0.0; /* Avoid a crash - results are undefined anyway */ - } else { - const float numerator = op[2]->value.f[c] - edge0; - const float denominator = edge1 - edge0; - const float t = CLAMP(numerator/denominator, 0, 1); - data.f[c] = t * t * (3 - 2 * t); - } - } - } else if (strcmp(callee, "sqrt") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL); - } else if (strcmp(callee, "step") == 0) { - assert(op[0]->type->is_float() && op[1]->type->is_float()); - /* op[0] (edge) may be either a scalar or a vector */ - const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1; - for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++) - data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0F : 1.0F; - } else if (strcmp(callee, "tan") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = tanf(op[0]->value.f[c]); - } else if (strcmp(callee, "tanh") == 0) { - assert(op[0]->type->is_float()); - for (unsigned c = 0; c < op[0]->type->components(); c++) - data.f[c] = tanhf(op[0]->value.f[c]); - } else if (strcmp(callee, "transpose") == 0) { - assert(op[0]->type->is_matrix()); - const unsigned n = op[0]->type->vector_elements; - const unsigned m = op[0]->type->matrix_columns; - for (unsigned j = 0; j < m; j++) { - for (unsigned i = 0; i < n; i++) { - data.f[m*i+j] += op[0]->value.f[i+n*j]; - } - } - } else if (strcmp(callee, "trunc") == 0) { - expr = new(mem_ctx) ir_expression(ir_unop_trunc, op[0]); - } else { - /* Unsupported builtin - some are not allowed in constant expressions. */ - return NULL; - } - - if (expr != NULL) - return expr->constant_expression_value(); - - return new(mem_ctx) ir_constant(this->type, &data); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.cpp deleted file mode 100644 index 0b7c537bd8a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_expression_flattening.cpp - * - * Takes the leaves of expression trees and makes them dereferences of - * assignments of the leaves to temporaries, according to a predicate. - * - * This is used for automatic function inlining, where we want to take - * an expression containing a call and move the call out to its own - * assignment so that we can inline it at the appropriate place in the - * instruction stream. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_rvalue_visitor.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" - -class ir_expression_flattening_visitor : public ir_rvalue_visitor { -public: - ir_expression_flattening_visitor(bool (*predicate)(ir_instruction *ir)) - { - this->predicate = predicate; - } - - virtual ~ir_expression_flattening_visitor() - { - /* empty */ - } - - void handle_rvalue(ir_rvalue **rvalue); - bool (*predicate)(ir_instruction *ir); -}; - -void -do_expression_flattening(exec_list *instructions, - bool (*predicate)(ir_instruction *ir)) -{ - ir_expression_flattening_visitor v(predicate); - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - - ir->accept(&v); - } -} - -void -ir_expression_flattening_visitor::handle_rvalue(ir_rvalue **rvalue) -{ - ir_variable *var; - ir_assignment *assign; - ir_rvalue *ir = *rvalue; - - if (!ir || !this->predicate(ir)) - return; - - void *ctx = ralloc_parent(ir); - - var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary); - base_ir->insert_before(var); - - assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), - ir, - NULL); - base_ir->insert_before(assign); - - *rvalue = new(ctx) ir_dereference_variable(var); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.h b/reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.h deleted file mode 100644 index 2eda1590001..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_expression_flattening.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - - -/** - * \file ir_expression_flattening.h - * - * Takes the leaves of expression trees and makes them dereferences of - * assignments of the leaves to temporaries, according to a predicate. - * - * This is used for automatic function inlining, where we want to take - * an expression containing a call and move the call out to its own - * assignment so that we can inline it at the appropriate place in the - * instruction stream. - */ - -void do_expression_flattening(exec_list *instructions, - bool (*predicate)(ir_instruction *ir)); diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_function.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_function.cpp deleted file mode 100644 index b34a5008168..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_function.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "glsl_types.h" -#include "ir.h" - -typedef enum { - PARAMETER_LIST_NO_MATCH, - PARAMETER_LIST_EXACT_MATCH, - PARAMETER_LIST_INEXACT_MATCH /*< Match requires implicit conversion. */ -} parameter_list_match_t; - -/** - * \brief Check if two parameter lists match. - * - * \param list_a Parameters of the function definition. - * \param list_b Actual parameters passed to the function. - * \see matching_signature() - */ -static parameter_list_match_t -parameter_lists_match(const exec_list *list_a, const exec_list *list_b) -{ - const exec_node *node_a = list_a->head; - const exec_node *node_b = list_b->head; - - /* This is set to true if there is an inexact match requiring an implicit - * conversion. */ - bool inexact_match = false; - - for (/* empty */ - ; !node_a->is_tail_sentinel() - ; node_a = node_a->next, node_b = node_b->next) { - /* If all of the parameters from the other parameter list have been - * exhausted, the lists have different length and, by definition, - * do not match. - */ - if (node_b->is_tail_sentinel()) - return PARAMETER_LIST_NO_MATCH; - - - const ir_variable *const param = (ir_variable *) node_a; - const ir_instruction *const actual = (ir_instruction *) node_b; - - if (param->type == actual->type) - continue; - - /* Try to find an implicit conversion from actual to param. */ - inexact_match = true; - switch ((enum ir_variable_mode)(param->mode)) { - case ir_var_auto: - case ir_var_uniform: - case ir_var_temporary: - /* These are all error conditions. It is invalid for a parameter to - * a function to be declared as auto (not in, out, or inout) or - * as uniform. - */ - assert(0); - return PARAMETER_LIST_NO_MATCH; - - case ir_var_const_in: - case ir_var_in: - if (!actual->type->can_implicitly_convert_to(param->type)) - return PARAMETER_LIST_NO_MATCH; - break; - - case ir_var_out: - if (!param->type->can_implicitly_convert_to(actual->type)) - return PARAMETER_LIST_NO_MATCH; - break; - - case ir_var_inout: - /* Since there are no bi-directional automatic conversions (e.g., - * there is int -> float but no float -> int), inout parameters must - * be exact matches. - */ - return PARAMETER_LIST_NO_MATCH; - - default: - assert(false); - return PARAMETER_LIST_NO_MATCH; - } - } - - /* If all of the parameters from the other parameter list have been - * exhausted, the lists have different length and, by definition, do not - * match. - */ - if (!node_b->is_tail_sentinel()) - return PARAMETER_LIST_NO_MATCH; - - if (inexact_match) - return PARAMETER_LIST_INEXACT_MATCH; - else - return PARAMETER_LIST_EXACT_MATCH; -} - - -ir_function_signature * -ir_function::matching_signature(const exec_list *actual_parameters) -{ - bool is_exact; - return matching_signature(actual_parameters, &is_exact); -} - -ir_function_signature * -ir_function::matching_signature(const exec_list *actual_parameters, - bool *is_exact) -{ - ir_function_signature *match = NULL; - bool multiple_inexact_matches = false; - - /* From page 42 (page 49 of the PDF) of the GLSL 1.20 spec: - * - * "If an exact match is found, the other signatures are ignored, and - * the exact match is used. Otherwise, if no exact match is found, then - * the implicit conversions in Section 4.1.10 "Implicit Conversions" will - * be applied to the calling arguments if this can make their types match - * a signature. In this case, it is a semantic error if there are - * multiple ways to apply these conversions to the actual arguments of a - * call such that the call can be made to match multiple signatures." - */ - foreach_iter(exec_list_iterator, iter, signatures) { - ir_function_signature *const sig = - (ir_function_signature *) iter.get(); - - switch (parameter_lists_match(& sig->parameters, actual_parameters)) { - case PARAMETER_LIST_EXACT_MATCH: - *is_exact = true; - return sig; - case PARAMETER_LIST_INEXACT_MATCH: - if (match == NULL) - match = sig; - else - multiple_inexact_matches = true; - continue; - case PARAMETER_LIST_NO_MATCH: - continue; - default: - assert(false); - return NULL; - } - } - - /* There is no exact match (we would have returned it by now). If there - * are multiple inexact matches, the call is ambiguous, which is an error. - * - * FINISHME: Report a decent error. Returning NULL will likely result in - * FINISHME: a "no matching signature" error; it should report that the - * FINISHME: call is ambiguous. But reporting errors from here is hard. - */ - *is_exact = false; - - if (multiple_inexact_matches) - return NULL; - - return match; -} - - -static bool -parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b) -{ - const exec_node *node_a = list_a->head; - const exec_node *node_b = list_b->head; - - for (/* empty */ - ; !node_a->is_tail_sentinel() && !node_b->is_tail_sentinel() - ; node_a = node_a->next, node_b = node_b->next) { - ir_variable *a = (ir_variable *) node_a; - ir_variable *b = (ir_variable *) node_b; - - /* If the types of the parameters do not match, the parameters lists - * are different. - */ - if (a->type != b->type) - return false; - } - - /* Unless both lists are exhausted, they differ in length and, by - * definition, do not match. - */ - return (node_a->is_tail_sentinel() == node_b->is_tail_sentinel()); -} - -ir_function_signature * -ir_function::exact_matching_signature(const exec_list *actual_parameters) -{ - foreach_iter(exec_list_iterator, iter, signatures) { - ir_function_signature *const sig = - (ir_function_signature *) iter.get(); - - if (parameter_lists_match_exact(&sig->parameters, actual_parameters)) - return sig; - } - return NULL; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_function_can_inline.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_function_can_inline.cpp deleted file mode 100644 index c367c30e44f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_function_can_inline.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_function_can_inline.cpp - * - * Determines if we can inline a function call using ir_function_inlining.cpp. - * - * The primary restriction is that we can't return from the function - * other than as the last instruction. We could potentially work - * around this for some constructs by flattening control flow and - * moving the return to the end, or by using breaks from a do {} while - * (0) loop surrounding the function body. - */ - -#include "ir.h" - -class ir_function_can_inline_visitor : public ir_hierarchical_visitor { -public: - ir_function_can_inline_visitor() - { - this->num_returns = 0; - } - - virtual ir_visitor_status visit_enter(ir_return *); - - int num_returns; -}; - -ir_visitor_status -ir_function_can_inline_visitor::visit_enter(ir_return *ir) -{ - (void) ir; - this->num_returns++; - return visit_continue; -} - -bool -can_inline(ir_call *call) -{ - ir_function_can_inline_visitor v; - const ir_function_signature *callee = call->get_callee(); - if (!callee->is_defined) - return false; - - v.run((exec_list *) &callee->body); - - /* If the function is empty (no last instruction) or does not end with a - * return statement, we need to count the implicit return. - */ - ir_instruction *last = (ir_instruction *)callee->body.get_tail(); - if (last == NULL || !last->as_return()) - v.num_returns++; - - return v.num_returns == 1; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_function_detect_recursion.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_function_detect_recursion.cpp deleted file mode 100644 index 890bc455f44..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_function_detect_recursion.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_function_detect_recursion.cpp - * Determine whether a shader contains static recursion. - * - * Consider the (possibly disjoint) graph of function calls in a shader. If a - * program contains recursion, this graph will contain a cycle. If a function - * is part of a cycle, it will have a caller and it will have a callee (it - * calls another function). - * - * To detect recursion, the function call graph is constructed. The graph is - * repeatedly reduced by removing any function that either has no callees - * (leaf functions) or has no caller. Eventually the only functions that - * remain will be the functions in the cycles. - * - * The GLSL spec is a bit wishy-washy about recursion. - * - * From page 39 (page 45 of the PDF) of the GLSL 1.10 spec: - * - * "Behavior is undefined if recursion is used. Recursion means having any - * function appearing more than once at any one time in the run-time stack - * of function calls. That is, a function may not call itself either - * directly or indirectly. Compilers may give diagnostic messages when - * this is detectable at compile time, but not all such cases can be - * detected at compile time." - * - * From page 79 (page 85 of the PDF): - * - * "22) Should recursion be supported? - * - * DISCUSSION: Probably not necessary, but another example of limiting - * the language based on how it would directly map to hardware. One - * thought is that recursion would benefit ray tracing shaders. On the - * other hand, many recursion operations can also be implemented with the - * user managing the recursion through arrays. RenderMan doesn't support - * recursion. This could be added at a later date, if it proved to be - * necessary. - * - * RESOLVED on September 10, 2002: Implementations are not required to - * support recursion. - * - * CLOSED on September 10, 2002." - * - * From page 79 (page 85 of the PDF): - * - * "56) Is it an error for an implementation to support recursion if the - * specification says recursion is not supported? - * - * ADDED on September 10, 2002. - * - * DISCUSSION: This issues is related to Issue (22). If we say that - * recursion (or some other piece of functionality) is not supported, is - * it an error for an implementation to support it? Perhaps the - * specification should remain silent on these kind of things so that they - * could be gracefully added later as an extension or as part of the - * standard. - * - * RESOLUTION: Languages, in general, have programs that are not - * well-formed in ways a compiler cannot detect. Portability is only - * ensured for well-formed programs. Detecting recursion is an example of - * this. The language will say a well-formed program may not recurse, but - * compilers are not forced to detect that recursion may happen. - * - * CLOSED: November 29, 2002." - * - * In GLSL 1.10 the behavior of recursion is undefined. Compilers don't have - * to reject shaders (at compile-time or link-time) that contain recursion. - * Instead they could work, or crash, or kill a kitten. - * - * From page 44 (page 50 of the PDF) of the GLSL 1.20 spec: - * - * "Recursion is not allowed, not even statically. Static recursion is - * present if the static function call graph of the program contains - * cycles." - * - * This langauge clears things up a bit, but it still leaves a lot of - * questions unanswered. - * - * - Is the error generated at compile-time or link-time? - * - * - Is it an error to have a recursive function that is never statically - * called by main or any function called directly or indirectly by main? - * Technically speaking, such a function is not in the "static function - * call graph of the program" at all. - * - * \bug - * If a shader has multiple cycles, this algorithm may erroneously complain - * about functions that aren't in any cycle, but are in the part of the call - * tree that connects them. For example, if the call graph consists of a - * cycle between A and B, and a cycle between D and E, and B also calls C - * which calls D, then this algorithm will report C as a function which "has - * static recursion" even though it is not part of any cycle. - * - * A better algorithm for cycle detection that doesn't have this drawback can - * be found here: - * - * http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm - * - * \author Ian Romanick - */ -#include "main/core.h" -#include "ir.h" -#include "glsl_parser_extras.h" -#include "linker.h" -#include "program/hash_table.h" -#include "program.h" - -struct call_node : public exec_node { - class function *func; -}; - -class function { -public: - function(ir_function_signature *sig) - : sig(sig) - { - /* empty */ - } - - - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = ralloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *node) - { - ralloc_free(node); - } - - ir_function_signature *sig; - - /** List of functions called by this function. */ - exec_list callees; - - /** List of functions that call this function. */ - exec_list callers; -}; - -class has_recursion_visitor : public ir_hierarchical_visitor { -public: - has_recursion_visitor() - : current(NULL) - { - this->mem_ctx = ralloc_context(NULL); - this->function_hash = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - } - - ~has_recursion_visitor() - { - hash_table_dtor(this->function_hash); - ralloc_free(this->mem_ctx); - } - - function *get_function(ir_function_signature *sig) - { - function *f = (function *) hash_table_find(this->function_hash, sig); - if (f == NULL) { - f = new(mem_ctx) function(sig); - hash_table_insert(this->function_hash, f, sig); - } - - return f; - } - - virtual ir_visitor_status visit_enter(ir_function_signature *sig) - { - this->current = this->get_function(sig); - return visit_continue; - } - - virtual ir_visitor_status visit_leave(ir_function_signature *sig) - { - (void) sig; - this->current = NULL; - return visit_continue; - } - - virtual ir_visitor_status visit_enter(ir_call *call) - { - /* At global scope this->current will be NULL. Since there is no way to - * call global scope, it can never be part of a cycle. Don't bother - * adding calls from global scope to the graph. - */ - if (this->current == NULL) - return visit_continue; - - function *const target = this->get_function(call->get_callee()); - - /* Create a link from the caller to the callee. - */ - call_node *node = new(mem_ctx) call_node; - node->func = target; - this->current->callees.push_tail(node); - - /* Create a link from the callee to the caller. - */ - node = new(mem_ctx) call_node; - node->func = this->current; - target->callers.push_tail(node); - return visit_continue; - } - - function *current; - struct hash_table *function_hash; - void *mem_ctx; - bool progress; -}; - -static void -destroy_links(exec_list *list, function *f) -{ - foreach_list_safe(node, list) { - struct call_node *n = (struct call_node *) node; - - /* If this is the right function, remove it. Note that the loop cannot - * terminate now. There can be multiple links to a function if it is - * either called multiple times or calls multiple times. - */ - if (n->func == f) - n->remove(); - } -} - - -/** - * Remove a function if it has either no in or no out links - */ -static void -remove_unlinked_functions(const void *key, void *data, void *closure) -{ - has_recursion_visitor *visitor = (has_recursion_visitor *) closure; - function *f = (function *) data; - - if (f->callers.is_empty() || f->callees.is_empty()) { - while (!f->callers.is_empty()) { - struct call_node *n = (struct call_node *) f->callers.pop_head(); - destroy_links(& n->func->callees, f); - } - - while (!f->callees.is_empty()) { - struct call_node *n = (struct call_node *) f->callees.pop_head(); - destroy_links(& n->func->callers, f); - } - - hash_table_remove(visitor->function_hash, key); - visitor->progress = true; - } -} - - -static void -emit_errors_unlinked(const void *key, void *data, void *closure) -{ - struct _mesa_glsl_parse_state *state = - (struct _mesa_glsl_parse_state *) closure; - function *f = (function *) data; - YYLTYPE loc; - - (void) key; - - char *proto = prototype_string(f->sig->return_type, - f->sig->function_name(), - &f->sig->parameters); - - memset(&loc, 0, sizeof(loc)); - _mesa_glsl_error(&loc, state, - "function `%s' has static recursion.", - proto); - ralloc_free(proto); -} - - -static void -emit_errors_linked(const void *key, void *data, void *closure) -{ - struct gl_shader_program *prog = - (struct gl_shader_program *) closure; - function *f = (function *) data; - - (void) key; - - char *proto = prototype_string(f->sig->return_type, - f->sig->function_name(), - &f->sig->parameters); - - linker_error(prog, "function `%s' has static recursion.\n", proto); - ralloc_free(proto); - prog->LinkStatus = false; -} - - -void -detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, - exec_list *instructions) -{ - has_recursion_visitor v; - - /* Collect all of the information about which functions call which other - * functions. - */ - v.run(instructions); - - /* Remove from the set all of the functions that either have no caller or - * call no other functions. Repeat until no functions are removed. - */ - do { - v.progress = false; - hash_table_call_foreach(v.function_hash, remove_unlinked_functions, & v); - } while (v.progress); - - - /* At this point any functions still in the hash must be part of a cycle. - */ - hash_table_call_foreach(v.function_hash, emit_errors_unlinked, state); -} - - -void -detect_recursion_linked(struct gl_shader_program *prog, - exec_list *instructions) -{ - has_recursion_visitor v; - - /* Collect all of the information about which functions call which other - * functions. - */ - v.run(instructions); - - /* Remove from the set all of the functions that either have no caller or - * call no other functions. Repeat until no functions are removed. - */ - do { - v.progress = false; - hash_table_call_foreach(v.function_hash, remove_unlinked_functions, & v); - } while (v.progress); - - - /* At this point any functions still in the hash must be part of a cycle. - */ - hash_table_call_foreach(v.function_hash, emit_errors_linked, prog); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_function_inlining.h b/reactos/dll/opengl/mesa/src/glsl/ir_function_inlining.h deleted file mode 100644 index 6db011bbcae..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_function_inlining.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_function_inlining.h - * - * Replaces calls to functions with the body of the function. - */ - -bool can_inline(ir_call *call); diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.cpp deleted file mode 100644 index b5eacd6d2d4..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir.h" -#include "ir_hierarchical_visitor.h" - -ir_hierarchical_visitor::ir_hierarchical_visitor() -{ - this->base_ir = NULL; - this->callback = NULL; - this->data = NULL; - this->in_assignee = false; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_variable *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_constant *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_loop_jump *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit(ir_dereference_variable *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_loop *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_loop *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_function_signature *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_function *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_function *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_expression *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_expression *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_texture *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_texture *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_assignment *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_assignment *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_call *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_call *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_return *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_return *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_discard *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_discard *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_enter(ir_if *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_hierarchical_visitor::visit_leave(ir_if *ir) -{ - (void) ir; - return visit_continue; -} - -void -ir_hierarchical_visitor::run(exec_list *instructions) -{ - visit_list_elements(this, instructions); -} - - -void -visit_tree(ir_instruction *ir, - void (*callback)(class ir_instruction *ir, void *data), - void *data) -{ - ir_hierarchical_visitor v; - - v.callback = callback; - v.data = data; - - ir->accept(&v); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.h b/reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.h deleted file mode 100644 index bba046db424..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_hierarchical_visitor.h +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef IR_HIERARCHICAL_VISITOR_H -#define IR_HIERARCHICAL_VISITOR_H - -/** - * Enumeration values returned by visit methods to guide processing - */ -enum ir_visitor_status { - visit_continue, /**< Continue visiting as normal. */ - visit_continue_with_parent, /**< Don't visit siblings, continue w/parent. */ - visit_stop /**< Stop visiting immediately. */ -}; - - -/** - * Base class of hierarchical visitors of IR instruction trees - * - * Hierarchical visitors differ from traditional visitors in a couple of - * important ways. Rather than having a single \c visit method for each - * subclass in the composite, there are three kinds of visit methods. - * Leaf-node classes have a traditional \c visit method. Internal-node - * classes have a \c visit_enter method, which is invoked just before - * processing child nodes, and a \c visit_leave method which is invoked just - * after processing child nodes. - * - * In addition, each visit method and the \c accept methods in the composite - * have a return value which guides the navigation. Any of the visit methods - * can choose to continue visiting the tree as normal (by returning \c - * visit_continue), terminate visiting any further nodes immediately (by - * returning \c visit_stop), or stop visiting sibling nodes (by returning \c - * visit_continue_with_parent). - * - * These two changes combine to allow nagivation of children to be implemented - * in the composite's \c accept method. The \c accept method for a leaf-node - * class will simply call the \c visit method, as usual, and pass its return - * value on. The \c accept method for internal-node classes will call the \c - * visit_enter method, call the \c accpet method of each child node, and, - * finally, call the \c visit_leave method. If any of these return a value - * other that \c visit_continue, the correct action must be taken. - * - * The final benefit is that the hierarchical visitor base class need not be - * abstract. Default implementations of every \c visit, \c visit_enter, and - * \c visit_leave method can be provided. By default each of these methods - * simply returns \c visit_continue. This allows a significant reduction in - * derived class code. - * - * For more information about hierarchical visitors, see: - * - * http://c2.com/cgi/wiki?HierarchicalVisitorPattern - * http://c2.com/cgi/wiki?HierarchicalVisitorDiscussion - */ - -class ir_hierarchical_visitor { -public: - ir_hierarchical_visitor(); - - /** - * \name Visit methods for leaf-node classes - */ - /*@{*/ - virtual ir_visitor_status visit(class ir_variable *); - virtual ir_visitor_status visit(class ir_constant *); - virtual ir_visitor_status visit(class ir_loop_jump *); - - /** - * ir_dereference_variable isn't technically a leaf, but it is treated as a - * leaf here for a couple reasons. By not automatically visiting the one - * child ir_variable node from the ir_dereference_variable, ir_variable - * nodes can always be handled as variable declarations. Code that used - * non-hierarchical visitors had to set an "in a dereference" flag to - * determine how to handle an ir_variable. By forcing the visitor to - * handle the ir_variable within the ir_dereference_variable visitor, this - * kludge can be avoided. - * - * In addition, I can envision no use for having separate enter and leave - * methods. Anything that could be done in the enter and leave methods - * that couldn't just be done in the visit method. - */ - virtual ir_visitor_status visit(class ir_dereference_variable *); - /*@}*/ - - /** - * \name Visit methods for internal-node classes - */ - /*@{*/ - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_leave(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_leave(class ir_function_signature *); - virtual ir_visitor_status visit_enter(class ir_function *); - virtual ir_visitor_status visit_leave(class ir_function *); - virtual ir_visitor_status visit_enter(class ir_expression *); - virtual ir_visitor_status visit_leave(class ir_expression *); - virtual ir_visitor_status visit_enter(class ir_texture *); - virtual ir_visitor_status visit_leave(class ir_texture *); - virtual ir_visitor_status visit_enter(class ir_swizzle *); - virtual ir_visitor_status visit_leave(class ir_swizzle *); - virtual ir_visitor_status visit_enter(class ir_dereference_array *); - virtual ir_visitor_status visit_leave(class ir_dereference_array *); - virtual ir_visitor_status visit_enter(class ir_dereference_record *); - virtual ir_visitor_status visit_leave(class ir_dereference_record *); - virtual ir_visitor_status visit_enter(class ir_assignment *); - virtual ir_visitor_status visit_leave(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_leave(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_return *); - virtual ir_visitor_status visit_leave(class ir_return *); - virtual ir_visitor_status visit_enter(class ir_discard *); - virtual ir_visitor_status visit_leave(class ir_discard *); - virtual ir_visitor_status visit_enter(class ir_if *); - virtual ir_visitor_status visit_leave(class ir_if *); - /*@}*/ - - - /** - * Utility function to process a linked list of instructions with a visitor - */ - void run(struct exec_list *instructions); - - /* Some visitors may need to insert new variable declarations and - * assignments for portions of a subtree, which means they need a - * pointer to the current instruction in the stream, not just their - * node in the tree rooted at that instruction. - * - * This is implemented by visit_list_elements -- if the visitor is - * not called by it, nothing good will happen. - */ - class ir_instruction *base_ir; - - /** - * Callback function that is invoked on entry to each node visited. - * - * \warning - * Visitor classes derived from \c ir_hierarchical_visitor \b may \b not - * invoke this function. This can be used, for example, to cause the - * callback to be invoked on every node type execpt one. - */ - void (*callback)(class ir_instruction *ir, void *data); - - /** - * Extra data parameter passed to the per-node callback function - */ - void *data; - - /** - * Currently in the LHS of an assignment? - * - * This is set and cleared by the \c ir_assignment::accept method. - */ - bool in_assignee; -}; - -void visit_tree(ir_instruction *ir, - void (*callback)(class ir_instruction *ir, void *data), - void *data); - -ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l, - bool statement_list = true); - -#endif /* IR_HIERARCHICAL_VISITOR_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_hv_accept.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_hv_accept.cpp deleted file mode 100644 index 0e78fda81fd..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_hv_accept.cpp +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir.h" - -/** - * \file ir_hv_accept.cpp - * Implementations of all hierarchical visitor accept methods for IR - * instructions. - */ - -/** - * Process a list of nodes using a hierarchical vistor. - * - * If statement_list is true (the default), this is a list of statements, so - * v->base_ir will be set to point to each statement just before iterating - * over it, and restored after iteration is complete. If statement_list is - * false, this is a list that appears inside a statement (e.g. a parameter - * list), so v->base_ir will be left alone. - * - * \warning - * This function will operate correctly if a node being processed is removed - * from the list. However, if nodes are added to the list after the node being - * processed, some of the added nodes may not be processed. - */ -ir_visitor_status -visit_list_elements(ir_hierarchical_visitor *v, exec_list *l, - bool statement_list) -{ - ir_instruction *prev_base_ir = v->base_ir; - - foreach_list_safe(n, l) { - ir_instruction *const ir = (ir_instruction *) n; - if (statement_list) - v->base_ir = ir; - ir_visitor_status s = ir->accept(v); - - if (s != visit_continue) - return s; - } - if (statement_list) - v->base_ir = prev_base_ir; - - return visit_continue; -} - - -ir_visitor_status -ir_variable::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_loop::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->body_instructions); - if (s == visit_stop) - return s; - - if (s != visit_continue_with_parent) { - if (this->from) { - s = this->from->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->to) { - s = this->to->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->increment) { - s = this->increment->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - } - - return v->visit_leave(this); -} - - -ir_visitor_status -ir_loop_jump::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_function_signature::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->parameters); - if (s == visit_stop) - return s; - - s = visit_list_elements(v, &this->body); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_function::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->signatures, false); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_expression::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - for (unsigned i = 0; i < this->get_num_operands(); i++) { - switch (this->operands[i]->accept(v)) { - case visit_continue: - break; - - case visit_continue_with_parent: - // I wish for Java's labeled break-statement here. - goto done; - - case visit_stop: - return s; - } - } - -done: - return v->visit_leave(this); -} - -ir_visitor_status -ir_texture::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->sampler->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - if (this->coordinate) { - s = this->coordinate->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->projector) { - s = this->projector->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->shadow_comparitor) { - s = this->shadow_comparitor->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - if (this->offset) { - s = this->offset->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - switch (this->op) { - case ir_tex: - break; - case ir_txb: - s = this->lod_info.bias->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - break; - case ir_txl: - case ir_txf: - case ir_txs: - s = this->lod_info.lod->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - break; - case ir_txd: - s = this->lod_info.grad.dPdx->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->lod_info.grad.dPdy->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - break; - } - - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_swizzle::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->val->accept(v); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_dereference_variable::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_dereference_array::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - /* The array index is not the target of the assignment, so clear the - * 'in_assignee' flag. Restore it after returning from the array index. - */ - const bool was_in_assignee = v->in_assignee; - v->in_assignee = false; - s = this->array_index->accept(v); - v->in_assignee = was_in_assignee; - - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->array->accept(v); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_dereference_record::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->record->accept(v); - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_assignment::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - v->in_assignee = true; - s = this->lhs->accept(v); - v->in_assignee = false; - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->rhs->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - if (this->condition) - s = this->condition->accept(v); - - return (s == visit_stop) ? s : v->visit_leave(this); -} - - -ir_visitor_status -ir_constant::accept(ir_hierarchical_visitor *v) -{ - return v->visit(this); -} - - -ir_visitor_status -ir_call::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = visit_list_elements(v, &this->actual_parameters, false); - if (s == visit_stop) - return s; - - return v->visit_leave(this); -} - - -ir_visitor_status -ir_return::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - ir_rvalue *val = this->get_value(); - if (val) { - s = val->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - return v->visit_leave(this); -} - - -ir_visitor_status -ir_discard::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - if (this->condition != NULL) { - s = this->condition->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - } - - return v->visit_leave(this); -} - - -ir_visitor_status -ir_if::accept(ir_hierarchical_visitor *v) -{ - ir_visitor_status s = v->visit_enter(this); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - s = this->condition->accept(v); - if (s != visit_continue) - return (s == visit_continue_with_parent) ? visit_continue : s; - - if (s != visit_continue_with_parent) { - s = visit_list_elements(v, &this->then_instructions); - if (s == visit_stop) - return s; - } - - if (s != visit_continue_with_parent) { - s = visit_list_elements(v, &this->else_instructions); - if (s == visit_stop) - return s; - } - - return v->visit_leave(this); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_import_prototypes.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_import_prototypes.cpp deleted file mode 100644 index 3585bf6b24b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_import_prototypes.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_import_prototypes.cpp - * Import function prototypes from one IR tree into another. - * - * \author Ian Romanick - */ -#include "ir.h" -#include "glsl_symbol_table.h" - -/** - * Visitor used to import function prototypes - * - * Normally the \c clone method of either \c ir_function or - * \c ir_function_signature could be used. However, we don't want a complete - * clone of the \c ir_function_signature. We want everything \b except the - * body of the function. - */ -class import_prototype_visitor : public ir_hierarchical_visitor { -public: - /** - */ - import_prototype_visitor(exec_list *list, glsl_symbol_table *symbols, - void *mem_ctx) - { - this->mem_ctx = mem_ctx; - this->list = list; - this->symbols = symbols; - this->function = NULL; - } - - virtual ir_visitor_status visit_enter(ir_function *ir) - { - assert(this->function == NULL); - - this->function = this->symbols->get_function(ir->name); - if (!this->function) { - this->function = new(this->mem_ctx) ir_function(ir->name); - - list->push_tail(this->function); - - /* Add the new function to the symbol table. - */ - this->symbols->add_function(this->function); - } - return visit_continue; - } - - virtual ir_visitor_status visit_leave(ir_function *ir) - { - (void) ir; - assert(this->function != NULL); - - this->function = NULL; - return visit_continue; - } - - ir_visitor_status visit_enter(ir_function_signature *ir) - { - assert(this->function != NULL); - - ir_function_signature *copy = ir->clone_prototype(mem_ctx, NULL); - - this->function->add_signature(copy); - - /* Do not process child nodes of the ir_function_signature. There can - * never be any nodes inside the ir_function_signature that we care - * about. Instead continue with the next sibling. - */ - return visit_continue_with_parent; - } - -private: - exec_list *list; - ir_function *function; - glsl_symbol_table *symbols; - void *mem_ctx; -}; - - -/** - * Import function prototypes from one IR tree into another - * - * \param source Source instruction stream containing functions whose - * prototypes are to be imported - * \param dest Destination instruction stream where new \c ir_function and - * \c ir_function_signature nodes will be stored - * \param symbols Symbol table where new functions will be stored - * \param mem_ctx ralloc memory context used for new allocations - */ -void -import_prototypes(const exec_list *source, exec_list *dest, - glsl_symbol_table *symbols, void *mem_ctx) -{ - import_prototype_visitor v(dest, symbols, mem_ctx); - - /* Making source be const is just extra documentation. - */ - v.run(const_cast(source)); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_optimization.h b/reactos/dll/opengl/mesa/src/glsl/ir_optimization.h deleted file mode 100644 index 085b96903cb..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_optimization.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - - -/** - * \file ir_optimization.h - * - * Prototypes for optimization passes to be called by the compiler and drivers. - */ - -/* Operations for lower_instructions() */ -#define SUB_TO_ADD_NEG 0x01 -#define DIV_TO_MUL_RCP 0x02 -#define EXP_TO_EXP2 0x04 -#define POW_TO_EXP2 0x08 -#define LOG_TO_LOG2 0x10 -#define MOD_TO_FRACT 0x20 -#define INT_DIV_TO_MUL_RCP 0x40 - -bool do_common_optimization(exec_list *ir, bool linked, - bool uniform_locations_assigned, - unsigned max_unroll_iterations); - -bool do_algebraic(exec_list *instructions); -bool do_constant_folding(exec_list *instructions); -bool do_constant_variable(exec_list *instructions); -bool do_constant_variable_unlinked(exec_list *instructions); -bool do_copy_propagation(exec_list *instructions); -bool do_copy_propagation_elements(exec_list *instructions); -bool do_constant_propagation(exec_list *instructions); -bool do_dead_code(exec_list *instructions, bool uniform_locations_assigned); -bool do_dead_code_local(exec_list *instructions); -bool do_dead_code_unlinked(exec_list *instructions); -bool do_dead_functions(exec_list *instructions); -bool do_function_inlining(exec_list *instructions); -bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_sub_return = true, bool lower_main_return = false, bool lower_continue = false, bool lower_break = false); -bool do_lower_texture_projection(exec_list *instructions); -bool do_if_simplification(exec_list *instructions); -bool do_discard_simplification(exec_list *instructions); -bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0); -bool do_mat_op_to_vec(exec_list *instructions); -bool do_noop_swizzle(exec_list *instructions); -bool do_structure_splitting(exec_list *instructions); -bool do_swizzle_swizzle(exec_list *instructions); -bool do_tree_grafting(exec_list *instructions); -bool do_vec_index_to_cond_assign(exec_list *instructions); -bool do_vec_index_to_swizzle(exec_list *instructions); -bool lower_discard(exec_list *instructions); -bool lower_instructions(exec_list *instructions, unsigned what_to_lower); -bool lower_noise(exec_list *instructions); -bool lower_variable_index_to_cond_assign(exec_list *instructions, - bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform); -bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz); -bool lower_clip_distance(exec_list *instructions); -void lower_output_reads(exec_list *instructions); -bool optimize_redundant_jumps(exec_list *instructions); - -ir_rvalue * -compare_index_block(exec_list *instructions, ir_variable *index, - unsigned base, unsigned components, void *mem_ctx); diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.cpp deleted file mode 100644 index 1471355f381..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir_print_visitor.h" -#include "glsl_types.h" -#include "glsl_parser_extras.h" -#include "program/hash_table.h" - -static void print_type(const glsl_type *t); - -void -ir_instruction::print(void) const -{ - ir_instruction *deconsted = const_cast(this); - - ir_print_visitor v; - deconsted->accept(&v); -} - -void -_mesa_print_ir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (state) { - for (unsigned i = 0; i < state->num_user_structures; i++) { - const glsl_type *const s = state->user_structures[i]; - - printf("(structure (%s) (%s@%p) (%u) (\n", - s->name, s->name, (void *) s, s->length); - - for (unsigned j = 0; j < s->length; j++) { - printf("\t(("); - print_type(s->fields.structure[j].type); - printf(")(%s))\n", s->fields.structure[j].name); - } - - printf(")\n"); - } - } - - printf("(\n"); - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir->print(); - if (ir->ir_type != ir_type_function) - printf("\n"); - } - printf("\n)"); -} - -ir_print_visitor::ir_print_visitor() -{ - indentation = 0; - printable_names = - hash_table_ctor(32, hash_table_pointer_hash, hash_table_pointer_compare); - symbols = _mesa_symbol_table_ctor(); - mem_ctx = ralloc_context(NULL); -} - -ir_print_visitor::~ir_print_visitor() -{ - hash_table_dtor(printable_names); - _mesa_symbol_table_dtor(symbols); - ralloc_free(mem_ctx); -} - -void ir_print_visitor::indent(void) -{ - for (int i = 0; i < indentation; i++) - printf(" "); -} - -const char * -ir_print_visitor::unique_name(ir_variable *var) -{ - /* var->name can be NULL in function prototypes when a type is given for a - * parameter but no name is given. In that case, just return an empty - * string. Don't worry about tracking the generated name in the printable - * names hash because this is the only scope where it can ever appear. - */ - if (var->name == NULL) { - static unsigned arg = 1; - return ralloc_asprintf(this->mem_ctx, "parameter@%u", arg++); - } - - /* Do we already have a name for this variable? */ - const char *name = (const char *) hash_table_find(this->printable_names, var); - if (name != NULL) - return name; - - /* If there's no conflict, just use the original name */ - if (_mesa_symbol_table_find_symbol(this->symbols, -1, var->name) == NULL) { - name = var->name; - } else { - static unsigned i = 1; - name = ralloc_asprintf(this->mem_ctx, "%s@%u", var->name, ++i); - } - hash_table_insert(this->printable_names, (void *) name, var); - _mesa_symbol_table_add_symbol(this->symbols, -1, name, var); - return name; -} - -static void -print_type(const glsl_type *t) -{ - if (t->base_type == GLSL_TYPE_ARRAY) { - printf("(array "); - print_type(t->fields.array); - printf(" %u)", t->length); - } else if ((t->base_type == GLSL_TYPE_STRUCT) - && (strncmp("gl_", t->name, 3) != 0)) { - printf("%s@%p", t->name, (void *) t); - } else { - printf("%s", t->name); - } -} - - -void ir_print_visitor::visit(ir_variable *ir) -{ - printf("(declare "); - - const char *const cent = (ir->centroid) ? "centroid " : ""; - const char *const inv = (ir->invariant) ? "invariant " : ""; - const char *const mode[] = { "", "uniform ", "in ", "out ", "inout ", - "const_in ", "sys ", "temporary " }; - const char *const interp[] = { "", "flat", "noperspective" }; - - printf("(%s%s%s%s) ", - cent, inv, mode[ir->mode], interp[ir->interpolation]); - - print_type(ir->type); - printf(" %s)", unique_name(ir)); -} - - -void ir_print_visitor::visit(ir_function_signature *ir) -{ - _mesa_symbol_table_push_scope(symbols); - printf("(signature "); - indentation++; - - print_type(ir->return_type); - printf("\n"); - indent(); - - printf("(parameters\n"); - indentation++; - - foreach_iter(exec_list_iterator, iter, ir->parameters) { - ir_variable *const inst = (ir_variable *) iter.get(); - - indent(); - inst->accept(this); - printf("\n"); - } - indentation--; - - indent(); - printf(")\n"); - - indent(); - - printf("(\n"); - indentation++; - - foreach_iter(exec_list_iterator, iter, ir->body) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - indent(); - inst->accept(this); - printf("\n"); - } - indentation--; - indent(); - printf("))\n"); - indentation--; - _mesa_symbol_table_pop_scope(symbols); -} - - -void ir_print_visitor::visit(ir_function *ir) -{ - printf("(function %s\n", ir->name); - indentation++; - foreach_iter(exec_list_iterator, iter, *ir) { - ir_function_signature *const sig = (ir_function_signature *) iter.get(); - indent(); - sig->accept(this); - printf("\n"); - } - indentation--; - indent(); - printf(")\n\n"); -} - - -void ir_print_visitor::visit(ir_expression *ir) -{ - printf("(expression "); - - print_type(ir->type); - - printf(" %s ", ir->operator_string()); - - for (unsigned i = 0; i < ir->get_num_operands(); i++) { - ir->operands[i]->accept(this); - } - - printf(") "); -} - - -void ir_print_visitor::visit(ir_texture *ir) -{ - printf("(%s ", ir->opcode_string()); - - print_type(ir->type); - printf(" "); - - ir->sampler->accept(this); - printf(" "); - - if (ir->op != ir_txs) { - ir->coordinate->accept(this); - - printf(" "); - - if (ir->offset != NULL) { - ir->offset->accept(this); - } else { - printf("0"); - } - - printf(" "); - } - - if (ir->op != ir_txf && ir->op != ir_txs) { - if (ir->projector) - ir->projector->accept(this); - else - printf("1"); - - if (ir->shadow_comparitor) { - printf(" "); - ir->shadow_comparitor->accept(this); - } else { - printf(" ()"); - } - } - - printf(" "); - switch (ir->op) - { - case ir_tex: - break; - case ir_txb: - ir->lod_info.bias->accept(this); - break; - case ir_txl: - case ir_txf: - case ir_txs: - ir->lod_info.lod->accept(this); - break; - case ir_txd: - printf("("); - ir->lod_info.grad.dPdx->accept(this); - printf(" "); - ir->lod_info.grad.dPdy->accept(this); - printf(")"); - break; - }; - printf(")"); -} - - -void ir_print_visitor::visit(ir_swizzle *ir) -{ - const unsigned swiz[4] = { - ir->mask.x, - ir->mask.y, - ir->mask.z, - ir->mask.w, - }; - - printf("(swiz "); - for (unsigned i = 0; i < ir->mask.num_components; i++) { - printf("%c", "xyzw"[swiz[i]]); - } - printf(" "); - ir->val->accept(this); - printf(")"); -} - - -void ir_print_visitor::visit(ir_dereference_variable *ir) -{ - ir_variable *var = ir->variable_referenced(); - printf("(var_ref %s) ", unique_name(var)); -} - - -void ir_print_visitor::visit(ir_dereference_array *ir) -{ - printf("(array_ref "); - ir->array->accept(this); - ir->array_index->accept(this); - printf(") "); -} - - -void ir_print_visitor::visit(ir_dereference_record *ir) -{ - printf("(record_ref "); - ir->record->accept(this); - printf(" %s) ", ir->field); -} - - -void ir_print_visitor::visit(ir_assignment *ir) -{ - printf("(assign "); - - if (ir->condition) - ir->condition->accept(this); - - char mask[5]; - unsigned j = 0; - - for (unsigned i = 0; i < 4; i++) { - if ((ir->write_mask & (1 << i)) != 0) { - mask[j] = "xyzw"[i]; - j++; - } - } - mask[j] = '\0'; - - printf(" (%s) ", mask); - - ir->lhs->accept(this); - - printf(" "); - - ir->rhs->accept(this); - printf(") "); -} - - -void ir_print_visitor::visit(ir_constant *ir) -{ - printf("(constant "); - print_type(ir->type); - printf(" ("); - - if (ir->type->is_array()) { - for (unsigned i = 0; i < ir->type->length; i++) - ir->get_array_element(i)->accept(this); - } else if (ir->type->is_record()) { - ir_constant *value = (ir_constant *) ir->components.get_head(); - for (unsigned i = 0; i < ir->type->length; i++) { - printf("(%s ", ir->type->fields.structure[i].name); - value->accept(this); - printf(")"); - - value = (ir_constant *) value->next; - } - } else { - for (unsigned i = 0; i < ir->type->components(); i++) { - if (i != 0) - printf(" "); - switch (ir->type->base_type) { - case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break; - case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break; - case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break; - case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break; - default: assert(0); - } - } - } - printf(")) "); -} - - -void -ir_print_visitor::visit(ir_call *ir) -{ - printf("(call %s (", ir->callee_name()); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - inst->accept(this); - } - printf("))\n"); -} - - -void -ir_print_visitor::visit(ir_return *ir) -{ - printf("(return"); - - ir_rvalue *const value = ir->get_value(); - if (value) { - printf(" "); - value->accept(this); - } - - printf(")"); -} - - -void -ir_print_visitor::visit(ir_discard *ir) -{ - printf("(discard "); - - if (ir->condition != NULL) { - printf(" "); - ir->condition->accept(this); - } - - printf(")"); -} - - -void -ir_print_visitor::visit(ir_if *ir) -{ - printf("(if "); - ir->condition->accept(this); - - printf("(\n"); - indentation++; - - foreach_iter(exec_list_iterator, iter, ir->then_instructions) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - indent(); - inst->accept(this); - printf("\n"); - } - - indentation--; - indent(); - printf(")\n"); - - indent(); - if (!ir->else_instructions.is_empty()) { - printf("(\n"); - indentation++; - - foreach_iter(exec_list_iterator, iter, ir->else_instructions) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - indent(); - inst->accept(this); - printf("\n"); - } - indentation--; - indent(); - printf("))\n"); - } else { - printf("())\n"); - } -} - - -void -ir_print_visitor::visit(ir_loop *ir) -{ - printf("(loop ("); - if (ir->counter != NULL) - ir->counter->accept(this); - printf(") ("); - if (ir->from != NULL) - ir->from->accept(this); - printf(") ("); - if (ir->to != NULL) - ir->to->accept(this); - printf(") ("); - if (ir->increment != NULL) - ir->increment->accept(this); - printf(") (\n"); - indentation++; - - foreach_iter(exec_list_iterator, iter, ir->body_instructions) { - ir_instruction *const inst = (ir_instruction *) iter.get(); - - indent(); - inst->accept(this); - printf("\n"); - } - indentation--; - indent(); - printf("))\n"); -} - - -void -ir_print_visitor::visit(ir_loop_jump *ir) -{ - printf("%s", ir->is_break() ? "break" : "continue"); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.h b/reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.h deleted file mode 100644 index c7136f11a3b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_print_visitor.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef IR_PRINT_VISITOR_H -#define IR_PRINT_VISITOR_H - -#include "ir.h" -#include "ir_visitor.h" - -extern "C" { -#include "program/symbol_table.h" -} - -extern void _mesa_print_ir(exec_list *instructions, - struct _mesa_glsl_parse_state *state); - -/** - * Abstract base class of visitors of IR instruction trees - */ -class ir_print_visitor : public ir_visitor { -public: - ir_print_visitor(); - virtual ~ir_print_visitor(); - - void indent(void); - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_texture *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_discard *); - virtual void visit(ir_if *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - /*@}*/ - -private: - /** - * Fetch/generate a unique name for ir_variable. - * - * GLSL IR permits multiple ir_variables to share the same name. This works - * fine until we try to print it, when we really need a unique one. - */ - const char *unique_name(ir_variable *var); - - /** A mapping from ir_variable * -> unique printable names. */ - hash_table *printable_names; - _mesa_symbol_table *symbols; - - void *mem_ctx; - - int indentation; -}; - -#endif /* IR_PRINT_VISITOR_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_reader.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_reader.cpp deleted file mode 100644 index 6f50cc439b8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_reader.cpp +++ /dev/null @@ -1,1018 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir_reader.h" -#include "glsl_parser_extras.h" -#include "glsl_types.h" -#include "s_expression.h" - -const static bool debug = false; - -class ir_reader { -public: - ir_reader(_mesa_glsl_parse_state *); - - void read(exec_list *instructions, const char *src, bool scan_for_protos); - -private: - void *mem_ctx; - _mesa_glsl_parse_state *state; - - void ir_read_error(s_expression *, const char *fmt, ...); - - const glsl_type *read_type(s_expression *); - - void scan_for_prototypes(exec_list *, s_expression *); - ir_function *read_function(s_expression *, bool skip_body); - void read_function_sig(ir_function *, s_expression *, bool skip_body); - - void read_instructions(exec_list *, s_expression *, ir_loop *); - ir_instruction *read_instruction(s_expression *, ir_loop *); - ir_variable *read_declaration(s_expression *); - ir_if *read_if(s_expression *, ir_loop *); - ir_loop *read_loop(s_expression *); - ir_return *read_return(s_expression *); - ir_rvalue *read_rvalue(s_expression *); - ir_assignment *read_assignment(s_expression *); - ir_expression *read_expression(s_expression *); - ir_call *read_call(s_expression *); - ir_swizzle *read_swizzle(s_expression *); - ir_constant *read_constant(s_expression *); - ir_texture *read_texture(s_expression *); - - ir_dereference *read_dereference(s_expression *); -}; - -ir_reader::ir_reader(_mesa_glsl_parse_state *state) : state(state) -{ - this->mem_ctx = state; -} - -void -_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, - const char *src, bool scan_for_protos) -{ - ir_reader r(state); - r.read(instructions, src, scan_for_protos); -} - -void -ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos) -{ - void *sx_mem_ctx = ralloc_context(NULL); - s_expression *expr = s_expression::read_expression(sx_mem_ctx, src); - if (expr == NULL) { - ir_read_error(NULL, "couldn't parse S-Expression."); - return; - } - - if (scan_for_protos) { - scan_for_prototypes(instructions, expr); - if (state->error) - return; - } - - read_instructions(instructions, expr, NULL); - ralloc_free(sx_mem_ctx); - - if (debug) - validate_ir_tree(instructions); -} - -void -ir_reader::ir_read_error(s_expression *expr, const char *fmt, ...) -{ - va_list ap; - - state->error = true; - - if (state->current_function != NULL) - ralloc_asprintf_append(&state->info_log, "In function %s:\n", - state->current_function->function_name()); - ralloc_strcat(&state->info_log, "error: "); - - va_start(ap, fmt); - ralloc_vasprintf_append(&state->info_log, fmt, ap); - va_end(ap); - ralloc_strcat(&state->info_log, "\n"); - - if (expr != NULL) { - ralloc_strcat(&state->info_log, "...in this context:\n "); - expr->print(); - ralloc_strcat(&state->info_log, "\n\n"); - } -} - -const glsl_type * -ir_reader::read_type(s_expression *expr) -{ - s_expression *s_base_type; - s_int *s_size; - - s_pattern pat[] = { "array", s_base_type, s_size }; - if (MATCH(expr, pat)) { - const glsl_type *base_type = read_type(s_base_type); - if (base_type == NULL) { - ir_read_error(NULL, "when reading base type of array type"); - return NULL; - } - - return glsl_type::get_array_instance(base_type, s_size->value()); - } - - s_symbol *type_sym = SX_AS_SYMBOL(expr); - if (type_sym == NULL) { - ir_read_error(expr, "expected "); - return NULL; - } - - const glsl_type *type = state->symbols->get_type(type_sym->value()); - if (type == NULL) - ir_read_error(expr, "invalid type: %s", type_sym->value()); - - return type; -} - - -void -ir_reader::scan_for_prototypes(exec_list *instructions, s_expression *expr) -{ - s_list *list = SX_AS_LIST(expr); - if (list == NULL) { - ir_read_error(expr, "Expected ( ...); found an atom."); - return; - } - - foreach_iter(exec_list_iterator, it, list->subexpressions) { - s_list *sub = SX_AS_LIST(it.get()); - if (sub == NULL) - continue; // not a (function ...); ignore it. - - s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head()); - if (tag == NULL || strcmp(tag->value(), "function") != 0) - continue; // not a (function ...); ignore it. - - ir_function *f = read_function(sub, true); - if (f == NULL) - return; - instructions->push_tail(f); - } -} - -ir_function * -ir_reader::read_function(s_expression *expr, bool skip_body) -{ - bool added = false; - s_symbol *name; - - s_pattern pat[] = { "function", name }; - if (!PARTIAL_MATCH(expr, pat)) { - ir_read_error(expr, "Expected (function (signature ...) ...)"); - return NULL; - } - - ir_function *f = state->symbols->get_function(name->value()); - if (f == NULL) { - f = new(mem_ctx) ir_function(name->value()); - added = state->symbols->add_function(f); - assert(added); - } - - exec_list_iterator it = ((s_list *) expr)->subexpressions.iterator(); - it.next(); // skip "function" tag - it.next(); // skip function name - for (/* nothing */; it.has_next(); it.next()) { - s_expression *s_sig = (s_expression *) it.get(); - read_function_sig(f, s_sig, skip_body); - } - return added ? f : NULL; -} - -void -ir_reader::read_function_sig(ir_function *f, s_expression *expr, bool skip_body) -{ - s_expression *type_expr; - s_list *paramlist; - s_list *body_list; - - s_pattern pat[] = { "signature", type_expr, paramlist, body_list }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "Expected (signature (parameters ...) " - "( ...))"); - return; - } - - const glsl_type *return_type = read_type(type_expr); - if (return_type == NULL) - return; - - s_symbol *paramtag = SX_AS_SYMBOL(paramlist->subexpressions.get_head()); - if (paramtag == NULL || strcmp(paramtag->value(), "parameters") != 0) { - ir_read_error(paramlist, "Expected (parameters ...)"); - return; - } - - // Read the parameters list into a temporary place. - exec_list hir_parameters; - state->symbols->push_scope(); - - exec_list_iterator it = paramlist->subexpressions.iterator(); - for (it.next() /* skip "parameters" */; it.has_next(); it.next()) { - ir_variable *var = read_declaration((s_expression *) it.get()); - if (var == NULL) - return; - - hir_parameters.push_tail(var); - } - - ir_function_signature *sig = f->exact_matching_signature(&hir_parameters); - if (sig == NULL && skip_body) { - /* If scanning for prototypes, generate a new signature. */ - sig = new(mem_ctx) ir_function_signature(return_type); - sig->is_builtin = true; - f->add_signature(sig); - } else if (sig != NULL) { - const char *badvar = sig->qualifiers_match(&hir_parameters); - if (badvar != NULL) { - ir_read_error(expr, "function `%s' parameter `%s' qualifiers " - "don't match prototype", f->name, badvar); - return; - } - - if (sig->return_type != return_type) { - ir_read_error(expr, "function `%s' return type doesn't " - "match prototype", f->name); - return; - } - } else { - /* No prototype for this body exists - skip it. */ - state->symbols->pop_scope(); - return; - } - assert(sig != NULL); - - sig->replace_parameters(&hir_parameters); - - if (!skip_body && !body_list->subexpressions.is_empty()) { - if (sig->is_defined) { - ir_read_error(expr, "function %s redefined", f->name); - return; - } - state->current_function = sig; - read_instructions(&sig->body, body_list, NULL); - state->current_function = NULL; - sig->is_defined = true; - } - - state->symbols->pop_scope(); -} - -void -ir_reader::read_instructions(exec_list *instructions, s_expression *expr, - ir_loop *loop_ctx) -{ - // Read in a list of instructions - s_list *list = SX_AS_LIST(expr); - if (list == NULL) { - ir_read_error(expr, "Expected ( ...); found an atom."); - return; - } - - foreach_iter(exec_list_iterator, it, list->subexpressions) { - s_expression *sub = (s_expression*) it.get(); - ir_instruction *ir = read_instruction(sub, loop_ctx); - if (ir != NULL) { - /* Global variable declarations should be moved to the top, before - * any functions that might use them. Functions are added to the - * instruction stream when scanning for prototypes, so without this - * hack, they always appear before variable declarations. - */ - if (state->current_function == NULL && ir->as_variable() != NULL) - instructions->push_head(ir); - else - instructions->push_tail(ir); - } - } -} - - -ir_instruction * -ir_reader::read_instruction(s_expression *expr, ir_loop *loop_ctx) -{ - s_symbol *symbol = SX_AS_SYMBOL(expr); - if (symbol != NULL) { - if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL) - return new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_break); - if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL) - return new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_continue); - } - - s_list *list = SX_AS_LIST(expr); - if (list == NULL || list->subexpressions.is_empty()) { - ir_read_error(expr, "Invalid instruction.\n"); - return NULL; - } - - s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); - if (tag == NULL) { - ir_read_error(expr, "expected instruction tag"); - return NULL; - } - - ir_instruction *inst = NULL; - if (strcmp(tag->value(), "declare") == 0) { - inst = read_declaration(list); - } else if (strcmp(tag->value(), "assign") == 0) { - inst = read_assignment(list); - } else if (strcmp(tag->value(), "if") == 0) { - inst = read_if(list, loop_ctx); - } else if (strcmp(tag->value(), "loop") == 0) { - inst = read_loop(list); - } else if (strcmp(tag->value(), "return") == 0) { - inst = read_return(list); - } else if (strcmp(tag->value(), "function") == 0) { - inst = read_function(list, false); - } else { - inst = read_rvalue(list); - if (inst == NULL) - ir_read_error(NULL, "when reading instruction"); - } - return inst; -} - -ir_variable * -ir_reader::read_declaration(s_expression *expr) -{ - s_list *s_quals; - s_expression *s_type; - s_symbol *s_name; - - s_pattern pat[] = { "declare", s_quals, s_type, s_name }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (declare () )"); - return NULL; - } - - const glsl_type *type = read_type(s_type); - if (type == NULL) - return NULL; - - ir_variable *var = new(mem_ctx) ir_variable(type, s_name->value(), - ir_var_auto); - - foreach_iter(exec_list_iterator, it, s_quals->subexpressions) { - s_symbol *qualifier = SX_AS_SYMBOL(it.get()); - if (qualifier == NULL) { - ir_read_error(expr, "qualifier list must contain only symbols"); - return NULL; - } - - // FINISHME: Check for duplicate/conflicting qualifiers. - if (strcmp(qualifier->value(), "centroid") == 0) { - var->centroid = 1; - } else if (strcmp(qualifier->value(), "invariant") == 0) { - var->invariant = 1; - } else if (strcmp(qualifier->value(), "uniform") == 0) { - var->mode = ir_var_uniform; - } else if (strcmp(qualifier->value(), "auto") == 0) { - var->mode = ir_var_auto; - } else if (strcmp(qualifier->value(), "in") == 0) { - var->mode = ir_var_in; - } else if (strcmp(qualifier->value(), "const_in") == 0) { - var->mode = ir_var_const_in; - } else if (strcmp(qualifier->value(), "out") == 0) { - var->mode = ir_var_out; - } else if (strcmp(qualifier->value(), "inout") == 0) { - var->mode = ir_var_inout; - } else if (strcmp(qualifier->value(), "smooth") == 0) { - var->interpolation = INTERP_QUALIFIER_SMOOTH; - } else if (strcmp(qualifier->value(), "flat") == 0) { - var->interpolation = INTERP_QUALIFIER_FLAT; - } else if (strcmp(qualifier->value(), "noperspective") == 0) { - var->interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; - } else { - ir_read_error(expr, "unknown qualifier: %s", qualifier->value()); - return NULL; - } - } - - // Add the variable to the symbol table - state->symbols->add_variable(var); - - return var; -} - - -ir_if * -ir_reader::read_if(s_expression *expr, ir_loop *loop_ctx) -{ - s_expression *s_cond; - s_expression *s_then; - s_expression *s_else; - - s_pattern pat[] = { "if", s_cond, s_then, s_else }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (if (...) (...))"); - return NULL; - } - - ir_rvalue *condition = read_rvalue(s_cond); - if (condition == NULL) { - ir_read_error(NULL, "when reading condition of (if ...)"); - return NULL; - } - - ir_if *iff = new(mem_ctx) ir_if(condition); - - read_instructions(&iff->then_instructions, s_then, loop_ctx); - read_instructions(&iff->else_instructions, s_else, loop_ctx); - if (state->error) { - delete iff; - iff = NULL; - } - return iff; -} - - -ir_loop * -ir_reader::read_loop(s_expression *expr) -{ - s_expression *s_counter, *s_from, *s_to, *s_inc, *s_body; - - s_pattern pat[] = { "loop", s_counter, s_from, s_to, s_inc, s_body }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (loop " - " )"); - return NULL; - } - - // FINISHME: actually read the count/from/to fields. - - ir_loop *loop = new(mem_ctx) ir_loop; - read_instructions(&loop->body_instructions, s_body, loop); - if (state->error) { - delete loop; - loop = NULL; - } - return loop; -} - - -ir_return * -ir_reader::read_return(s_expression *expr) -{ - s_expression *s_retval; - - s_pattern return_value_pat[] = { "return", s_retval}; - s_pattern return_void_pat[] = { "return" }; - if (MATCH(expr, return_value_pat)) { - ir_rvalue *retval = read_rvalue(s_retval); - if (retval == NULL) { - ir_read_error(NULL, "when reading return value"); - return NULL; - } - return new(mem_ctx) ir_return(retval); - } else if (MATCH(expr, return_void_pat)) { - return new(mem_ctx) ir_return; - } else { - ir_read_error(expr, "expected (return ) or (return)"); - return NULL; - } -} - - -ir_rvalue * -ir_reader::read_rvalue(s_expression *expr) -{ - s_list *list = SX_AS_LIST(expr); - if (list == NULL || list->subexpressions.is_empty()) - return NULL; - - s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); - if (tag == NULL) { - ir_read_error(expr, "expected rvalue tag"); - return NULL; - } - - ir_rvalue *rvalue = read_dereference(list); - if (rvalue != NULL || state->error) - return rvalue; - else if (strcmp(tag->value(), "swiz") == 0) { - rvalue = read_swizzle(list); - } else if (strcmp(tag->value(), "expression") == 0) { - rvalue = read_expression(list); - } else if (strcmp(tag->value(), "call") == 0) { - rvalue = read_call(list); - } else if (strcmp(tag->value(), "constant") == 0) { - rvalue = read_constant(list); - } else { - rvalue = read_texture(list); - if (rvalue == NULL && !state->error) - ir_read_error(expr, "unrecognized rvalue tag: %s", tag->value()); - } - - return rvalue; -} - -ir_assignment * -ir_reader::read_assignment(s_expression *expr) -{ - s_expression *cond_expr = NULL; - s_expression *lhs_expr, *rhs_expr; - s_list *mask_list; - - s_pattern pat4[] = { "assign", mask_list, lhs_expr, rhs_expr }; - s_pattern pat5[] = { "assign", cond_expr, mask_list, lhs_expr, rhs_expr }; - if (!MATCH(expr, pat4) && !MATCH(expr, pat5)) { - ir_read_error(expr, "expected (assign [] () " - " )"); - return NULL; - } - - ir_rvalue *condition = NULL; - if (cond_expr != NULL) { - condition = read_rvalue(cond_expr); - if (condition == NULL) { - ir_read_error(NULL, "when reading condition of assignment"); - return NULL; - } - } - - unsigned mask = 0; - - s_symbol *mask_symbol; - s_pattern mask_pat[] = { mask_symbol }; - if (MATCH(mask_list, mask_pat)) { - const char *mask_str = mask_symbol->value(); - unsigned mask_length = strlen(mask_str); - if (mask_length > 4) { - ir_read_error(expr, "invalid write mask: %s", mask_str); - return NULL; - } - - const unsigned idx_map[] = { 3, 0, 1, 2 }; /* w=bit 3, x=0, y=1, z=2 */ - - for (unsigned i = 0; i < mask_length; i++) { - if (mask_str[i] < 'w' || mask_str[i] > 'z') { - ir_read_error(expr, "write mask contains invalid character: %c", - mask_str[i]); - return NULL; - } - mask |= 1 << idx_map[mask_str[i] - 'w']; - } - } else if (!mask_list->subexpressions.is_empty()) { - ir_read_error(mask_list, "expected () or ()"); - return NULL; - } - - ir_dereference *lhs = read_dereference(lhs_expr); - if (lhs == NULL) { - ir_read_error(NULL, "when reading left-hand side of assignment"); - return NULL; - } - - ir_rvalue *rhs = read_rvalue(rhs_expr); - if (rhs == NULL) { - ir_read_error(NULL, "when reading right-hand side of assignment"); - return NULL; - } - - if (mask == 0 && (lhs->type->is_vector() || lhs->type->is_scalar())) { - ir_read_error(expr, "non-zero write mask required."); - return NULL; - } - - return new(mem_ctx) ir_assignment(lhs, rhs, condition, mask); -} - -ir_call * -ir_reader::read_call(s_expression *expr) -{ - s_symbol *name; - s_list *params; - - s_pattern pat[] = { "call", name, params }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (call ( ...))"); - return NULL; - } - - exec_list parameters; - - foreach_iter(exec_list_iterator, it, params->subexpressions) { - s_expression *expr = (s_expression*) it.get(); - ir_rvalue *param = read_rvalue(expr); - if (param == NULL) { - ir_read_error(expr, "when reading parameter to function call"); - return NULL; - } - parameters.push_tail(param); - } - - ir_function *f = state->symbols->get_function(name->value()); - if (f == NULL) { - ir_read_error(expr, "found call to undefined function %s", - name->value()); - return NULL; - } - - ir_function_signature *callee = f->matching_signature(¶meters); - if (callee == NULL) { - ir_read_error(expr, "couldn't find matching signature for function " - "%s", name->value()); - return NULL; - } - - return new(mem_ctx) ir_call(callee, ¶meters); -} - -ir_expression * -ir_reader::read_expression(s_expression *expr) -{ - s_expression *s_type; - s_symbol *s_op; - s_expression *s_arg1; - - s_pattern pat[] = { "expression", s_type, s_op, s_arg1 }; - if (!PARTIAL_MATCH(expr, pat)) { - ir_read_error(expr, "expected (expression " - " [])"); - return NULL; - } - s_expression *s_arg2 = (s_expression *) s_arg1->next; // may be tail sentinel - - const glsl_type *type = read_type(s_type); - if (type == NULL) - return NULL; - - /* Read the operator */ - ir_expression_operation op = ir_expression::get_operator(s_op->value()); - if (op == (ir_expression_operation) -1) { - ir_read_error(expr, "invalid operator: %s", s_op->value()); - return NULL; - } - - unsigned num_operands = ir_expression::get_num_operands(op); - if (num_operands == 1 && !s_arg1->next->is_tail_sentinel()) { - ir_read_error(expr, "expected (expression %s )", - s_op->value()); - return NULL; - } - - ir_rvalue *arg1 = read_rvalue(s_arg1); - ir_rvalue *arg2 = NULL; - if (arg1 == NULL) { - ir_read_error(NULL, "when reading first operand of %s", s_op->value()); - return NULL; - } - - if (num_operands == 2) { - if (s_arg2->is_tail_sentinel() || !s_arg2->next->is_tail_sentinel()) { - ir_read_error(expr, "expected (expression %s " - ")", s_op->value()); - return NULL; - } - arg2 = read_rvalue(s_arg2); - if (arg2 == NULL) { - ir_read_error(NULL, "when reading second operand of %s", - s_op->value()); - return NULL; - } - } - - return new(mem_ctx) ir_expression(op, type, arg1, arg2); -} - -ir_swizzle * -ir_reader::read_swizzle(s_expression *expr) -{ - s_symbol *swiz; - s_expression *sub; - - s_pattern pat[] = { "swiz", swiz, sub }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (swiz )"); - return NULL; - } - - if (strlen(swiz->value()) > 4) { - ir_read_error(expr, "expected a valid swizzle; found %s", swiz->value()); - return NULL; - } - - ir_rvalue *rvalue = read_rvalue(sub); - if (rvalue == NULL) - return NULL; - - ir_swizzle *ir = ir_swizzle::create(rvalue, swiz->value(), - rvalue->type->vector_elements); - if (ir == NULL) - ir_read_error(expr, "invalid swizzle"); - - return ir; -} - -ir_constant * -ir_reader::read_constant(s_expression *expr) -{ - s_expression *type_expr; - s_list *values; - - s_pattern pat[] = { "constant", type_expr, values }; - if (!MATCH(expr, pat)) { - ir_read_error(expr, "expected (constant (...))"); - return NULL; - } - - const glsl_type *type = read_type(type_expr); - if (type == NULL) - return NULL; - - if (values == NULL) { - ir_read_error(expr, "expected (constant (...))"); - return NULL; - } - - if (type->is_array()) { - unsigned elements_supplied = 0; - exec_list elements; - foreach_iter(exec_list_iterator, it, values->subexpressions) { - s_expression *elt = (s_expression *) it.get(); - ir_constant *ir_elt = read_constant(elt); - if (ir_elt == NULL) - return NULL; - elements.push_tail(ir_elt); - elements_supplied++; - } - - if (elements_supplied != type->length) { - ir_read_error(values, "expected exactly %u array elements, " - "given %u", type->length, elements_supplied); - return NULL; - } - return new(mem_ctx) ir_constant(type, &elements); - } - - ir_constant_data data = { { 0 } }; - - // Read in list of values (at most 16). - unsigned k = 0; - foreach_iter(exec_list_iterator, it, values->subexpressions) { - if (k >= 16) { - ir_read_error(values, "expected at most 16 numbers"); - return NULL; - } - - s_expression *expr = (s_expression*) it.get(); - - if (type->base_type == GLSL_TYPE_FLOAT) { - s_number *value = SX_AS_NUMBER(expr); - if (value == NULL) { - ir_read_error(values, "expected numbers"); - return NULL; - } - data.f[k] = value->fvalue(); - } else { - s_int *value = SX_AS_INT(expr); - if (value == NULL) { - ir_read_error(values, "expected integers"); - return NULL; - } - - switch (type->base_type) { - case GLSL_TYPE_UINT: { - data.u[k] = value->value(); - break; - } - case GLSL_TYPE_INT: { - data.i[k] = value->value(); - break; - } - case GLSL_TYPE_BOOL: { - data.b[k] = value->value(); - break; - } - default: - ir_read_error(values, "unsupported constant type"); - return NULL; - } - } - ++k; - } - if (k != type->components()) { - ir_read_error(values, "expected %u constant values, found %u", - type->components(), k); - return NULL; - } - - return new(mem_ctx) ir_constant(type, &data); -} - -ir_dereference * -ir_reader::read_dereference(s_expression *expr) -{ - s_symbol *s_var; - s_expression *s_subject; - s_expression *s_index; - s_symbol *s_field; - - s_pattern var_pat[] = { "var_ref", s_var }; - s_pattern array_pat[] = { "array_ref", s_subject, s_index }; - s_pattern record_pat[] = { "record_ref", s_subject, s_field }; - - if (MATCH(expr, var_pat)) { - ir_variable *var = state->symbols->get_variable(s_var->value()); - if (var == NULL) { - ir_read_error(expr, "undeclared variable: %s", s_var->value()); - return NULL; - } - return new(mem_ctx) ir_dereference_variable(var); - } else if (MATCH(expr, array_pat)) { - ir_rvalue *subject = read_rvalue(s_subject); - if (subject == NULL) { - ir_read_error(NULL, "when reading the subject of an array_ref"); - return NULL; - } - - ir_rvalue *idx = read_rvalue(s_index); - if (subject == NULL) { - ir_read_error(NULL, "when reading the index of an array_ref"); - return NULL; - } - return new(mem_ctx) ir_dereference_array(subject, idx); - } else if (MATCH(expr, record_pat)) { - ir_rvalue *subject = read_rvalue(s_subject); - if (subject == NULL) { - ir_read_error(NULL, "when reading the subject of a record_ref"); - return NULL; - } - return new(mem_ctx) ir_dereference_record(subject, s_field->value()); - } - return NULL; -} - -ir_texture * -ir_reader::read_texture(s_expression *expr) -{ - s_symbol *tag = NULL; - s_expression *s_type = NULL; - s_expression *s_sampler = NULL; - s_expression *s_coord = NULL; - s_expression *s_offset = NULL; - s_expression *s_proj = NULL; - s_list *s_shadow = NULL; - s_expression *s_lod = NULL; - - ir_texture_opcode op = ir_tex; /* silence warning */ - - s_pattern tex_pattern[] = - { "tex", s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow }; - s_pattern txf_pattern[] = - { "txf", s_type, s_sampler, s_coord, s_offset, s_lod }; - s_pattern txs_pattern[] = - { "txs", s_type, s_sampler, s_lod }; - s_pattern other_pattern[] = - { tag, s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod }; - - if (MATCH(expr, tex_pattern)) { - op = ir_tex; - } else if (MATCH(expr, txf_pattern)) { - op = ir_txf; - } else if (MATCH(expr, txs_pattern)) { - op = ir_txs; - } else if (MATCH(expr, other_pattern)) { - op = ir_texture::get_opcode(tag->value()); - if (op == -1) - return NULL; - } else { - ir_read_error(NULL, "unexpected texture pattern"); - return NULL; - } - - ir_texture *tex = new(mem_ctx) ir_texture(op); - - // Read return type - const glsl_type *type = read_type(s_type); - if (type == NULL) { - ir_read_error(NULL, "when reading type in (%s ...)", - tex->opcode_string()); - return NULL; - } - - // Read sampler (must be a deref) - ir_dereference *sampler = read_dereference(s_sampler); - if (sampler == NULL) { - ir_read_error(NULL, "when reading sampler in (%s ...)", - tex->opcode_string()); - return NULL; - } - tex->set_sampler(sampler, type); - - if (op != ir_txs) { - // Read coordinate (any rvalue) - tex->coordinate = read_rvalue(s_coord); - if (tex->coordinate == NULL) { - ir_read_error(NULL, "when reading coordinate in (%s ...)", - tex->opcode_string()); - return NULL; - } - - // Read texel offset - either 0 or an rvalue. - s_int *si_offset = SX_AS_INT(s_offset); - if (si_offset == NULL || si_offset->value() != 0) { - tex->offset = read_rvalue(s_offset); - if (tex->offset == NULL) { - ir_read_error(s_offset, "expected 0 or an expression"); - return NULL; - } - } - } - - if (op != ir_txf && op != ir_txs) { - s_int *proj_as_int = SX_AS_INT(s_proj); - if (proj_as_int && proj_as_int->value() == 1) { - tex->projector = NULL; - } else { - tex->projector = read_rvalue(s_proj); - if (tex->projector == NULL) { - ir_read_error(NULL, "when reading projective divide in (%s ..)", - tex->opcode_string()); - return NULL; - } - } - - if (s_shadow->subexpressions.is_empty()) { - tex->shadow_comparitor = NULL; - } else { - tex->shadow_comparitor = read_rvalue(s_shadow); - if (tex->shadow_comparitor == NULL) { - ir_read_error(NULL, "when reading shadow comparitor in (%s ..)", - tex->opcode_string()); - return NULL; - } - } - } - - switch (op) { - case ir_txb: - tex->lod_info.bias = read_rvalue(s_lod); - if (tex->lod_info.bias == NULL) { - ir_read_error(NULL, "when reading LOD bias in (txb ...)"); - return NULL; - } - break; - case ir_txl: - case ir_txf: - case ir_txs: - tex->lod_info.lod = read_rvalue(s_lod); - if (tex->lod_info.lod == NULL) { - ir_read_error(NULL, "when reading LOD in (%s ...)", - tex->opcode_string()); - return NULL; - } - break; - case ir_txd: { - s_expression *s_dx, *s_dy; - s_pattern dxdy_pat[] = { s_dx, s_dy }; - if (!MATCH(s_lod, dxdy_pat)) { - ir_read_error(s_lod, "expected (dPdx dPdy) in (txd ...)"); - return NULL; - } - tex->lod_info.grad.dPdx = read_rvalue(s_dx); - if (tex->lod_info.grad.dPdx == NULL) { - ir_read_error(NULL, "when reading dPdx in (txd ...)"); - return NULL; - } - tex->lod_info.grad.dPdy = read_rvalue(s_dy); - if (tex->lod_info.grad.dPdy == NULL) { - ir_read_error(NULL, "when reading dPdy in (txd ...)"); - return NULL; - } - break; - } - default: - // tex doesn't have any extra parameters. - break; - }; - return tex; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_reader.h b/reactos/dll/opengl/mesa/src/glsl/ir_reader.h deleted file mode 100644 index aef2ca23bd2..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_reader.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef IR_READER_H -#define IR_READER_H - -#include "ir.h" - -void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions, - const char *src, bool scan_for_prototypes); - -#endif /* IR_READER_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.cpp deleted file mode 100644 index 193bcd2d7bd..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_rvalue_visitor.cpp - * - * Generic class to implement the common pattern we have of wanting to - * visit each ir_rvalue * and possibly change that node to a different - * class. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_rvalue_visitor.h" -#include "ir_print_visitor.h" -#include "glsl_types.h" - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_expression *ir) -{ - unsigned int operand; - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - handle_rvalue(&ir->operands[operand]); - } - - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_texture *ir) -{ - handle_rvalue(&ir->coordinate); - handle_rvalue(&ir->projector); - handle_rvalue(&ir->shadow_comparitor); - handle_rvalue(&ir->offset); - - switch (ir->op) { - case ir_tex: - break; - case ir_txb: - handle_rvalue(&ir->lod_info.bias); - break; - case ir_txf: - case ir_txl: - case ir_txs: - handle_rvalue(&ir->lod_info.lod); - break; - case ir_txd: - handle_rvalue(&ir->lod_info.grad.dPdx); - handle_rvalue(&ir->lod_info.grad.dPdy); - break; - } - - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_swizzle *ir) -{ - handle_rvalue(&ir->val); - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_dereference_array *ir) -{ - /* The array index is not the target of the assignment, so clear the - * 'in_assignee' flag. Restore it after returning from the array index. - */ - const bool was_in_assignee = this->in_assignee; - this->in_assignee = false; - handle_rvalue(&ir->array_index); - this->in_assignee = was_in_assignee; - - handle_rvalue(&ir->array); - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_dereference_record *ir) -{ - handle_rvalue(&ir->record); - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_assignment *ir) -{ - handle_rvalue(&ir->rhs); - handle_rvalue(&ir->condition); - - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = param; - handle_rvalue(&new_param); - - if (new_param != param) { - param->replace_with(new_param); - } - } - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_return *ir) -{ - handle_rvalue(&ir->value);; - return visit_continue; -} - -ir_visitor_status -ir_rvalue_visitor::visit_leave(ir_if *ir) -{ - handle_rvalue(&ir->condition); - return visit_continue; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.h b/reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.h deleted file mode 100644 index 31a56beb9b8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_rvalue_visitor.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_rvalue_visitor.h - * - * Generic class to implement the common pattern we have of wanting to - * visit each ir_rvalue * and possibly change that node to a different - * class. Just implement handle_rvalue() and you will be called with - * a pointer to each rvalue in the tree. - */ - -class ir_rvalue_visitor : public ir_hierarchical_visitor { -public: - - virtual ir_visitor_status visit_leave(ir_assignment *); - virtual ir_visitor_status visit_leave(ir_call *); - virtual ir_visitor_status visit_leave(ir_dereference_array *); - virtual ir_visitor_status visit_leave(ir_dereference_record *); - virtual ir_visitor_status visit_leave(ir_expression *); - virtual ir_visitor_status visit_leave(ir_if *); - virtual ir_visitor_status visit_leave(ir_return *); - virtual ir_visitor_status visit_leave(ir_swizzle *); - virtual ir_visitor_status visit_leave(ir_texture *); - - virtual void handle_rvalue(ir_rvalue **rvalue) = 0; -}; diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_set_program_inouts.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_set_program_inouts.cpp deleted file mode 100644 index 8c2bc30d614..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_set_program_inouts.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_set_program_inouts.cpp - * - * Sets the InputsRead and OutputsWritten of Mesa programs. - * - * Additionally, for fragment shaders, sets the InterpQualifier array. - * - * Mesa programs (gl_program, not gl_shader_program) have a set of - * flags indicating which varyings are read and written. Computing - * which are actually read from some sort of backend code can be - * tricky when variable array indexing involved. So this pass - * provides support for setting InputsRead and OutputsWritten right - * from the GLSL IR. - */ - -#include "main/core.h" /* for struct gl_program */ -#include "program/hash_table.h" -#include "ir.h" -#include "ir_visitor.h" -#include "glsl_types.h" - -class ir_set_program_inouts_visitor : public ir_hierarchical_visitor { -public: - ir_set_program_inouts_visitor(struct gl_program *prog, - bool is_fragment_shader) - { - this->prog = prog; - this->is_fragment_shader = is_fragment_shader; - this->ht = hash_table_ctor(0, - hash_table_pointer_hash, - hash_table_pointer_compare); - } - ~ir_set_program_inouts_visitor() - { - hash_table_dtor(this->ht); - } - - virtual ir_visitor_status visit_enter(ir_dereference_array *); - virtual ir_visitor_status visit_enter(ir_function_signature *); - virtual ir_visitor_status visit(ir_dereference_variable *); - virtual ir_visitor_status visit(ir_variable *); - - struct gl_program *prog; - struct hash_table *ht; - bool is_fragment_shader; -}; - -static void -mark(struct gl_program *prog, ir_variable *var, int offset, int len, - bool is_fragment_shader) -{ - /* As of GLSL 1.20, varyings can only be floats, floating-point - * vectors or matrices, or arrays of them. For Mesa programs using - * InputsRead/OutputsWritten, everything but matrices uses one - * slot, while matrices use a slot per column. Presumably - * something doing a more clever packing would use something other - * than InputsRead/OutputsWritten. - */ - - for (int i = 0; i < len; i++) { - GLbitfield64 bitfield = BITFIELD64_BIT(var->location + offset + i); - if (var->mode == ir_var_in) { - prog->InputsRead |= bitfield; - if (is_fragment_shader) { - gl_fragment_program *fprog = (gl_fragment_program *) prog; - fprog->InterpQualifier[var->location + offset + i] = - (glsl_interp_qualifier) var->interpolation; - } - } else if (var->mode == ir_var_system_value) { - prog->SystemValuesRead |= bitfield; - } else { - prog->OutputsWritten |= bitfield; - } - } -} - -/* Default handler: Mark all the locations in the variable as used. */ -ir_visitor_status -ir_set_program_inouts_visitor::visit(ir_dereference_variable *ir) -{ - if (hash_table_find(this->ht, ir->var) == NULL) - return visit_continue; - - if (ir->type->is_array()) { - mark(this->prog, ir->var, 0, - ir->type->length * ir->type->fields.array->matrix_columns, - this->is_fragment_shader); - } else { - mark(this->prog, ir->var, 0, ir->type->matrix_columns, - this->is_fragment_shader); - } - - return visit_continue; -} - -ir_visitor_status -ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir) -{ - ir_dereference_variable *deref_var; - ir_constant *index = ir->array_index->as_constant(); - deref_var = ir->array->as_dereference_variable(); - ir_variable *var = NULL; - - /* Check that we're dereferencing a shader in or out */ - if (deref_var) - var = (ir_variable *)hash_table_find(this->ht, deref_var->var); - - if (index && var) { - int width = 1; - - if (deref_var->type->is_array() && - deref_var->type->fields.array->is_matrix()) { - width = deref_var->type->fields.array->matrix_columns; - } - - mark(this->prog, var, index->value.i[0] * width, width, - this->is_fragment_shader); - return visit_continue_with_parent; - } - - return visit_continue; -} - -ir_visitor_status -ir_set_program_inouts_visitor::visit(ir_variable *ir) -{ - if (ir->mode == ir_var_in || - ir->mode == ir_var_out || - ir->mode == ir_var_system_value) { - hash_table_insert(this->ht, ir, ir); - } - - return visit_continue; -} - -ir_visitor_status -ir_set_program_inouts_visitor::visit_enter(ir_function_signature *ir) -{ - /* We don't want to descend into the function parameters and - * consider them as shader inputs or outputs. - */ - visit_list_elements(this, &ir->body); - return visit_continue_with_parent; -} - -void -do_set_program_inouts(exec_list *instructions, struct gl_program *prog, - bool is_fragment_shader) -{ - ir_set_program_inouts_visitor v(prog, is_fragment_shader); - - prog->InputsRead = 0; - prog->OutputsWritten = 0; - prog->SystemValuesRead = 0; - if (is_fragment_shader) { - memset(((gl_fragment_program *) prog)->InterpQualifier, 0, - sizeof(((gl_fragment_program *) prog)->InterpQualifier)); - } - visit_list_elements(&v, instructions); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_uniform.h b/reactos/dll/opengl/mesa/src/glsl/ir_uniform.h deleted file mode 100644 index 225da3fc5ef..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_uniform.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef IR_UNIFORM_H -#define IR_UNIFORM_H - - -/* stdbool.h is necessary because this file is included in both C and C++ code. - */ -#include - -#include "program/prog_parameter.h" /* For union gl_constant_value. */ - - -#ifdef __cplusplus -extern "C" { -#endif - -enum gl_uniform_driver_format { - uniform_native = 0, /**< Store data in the native format. */ - uniform_int_float, /**< Store integer data as floats. */ - uniform_bool_float, /**< Store boolean data as floats. */ - - /** - * Store boolean data as integer using 1 for \c true. - */ - uniform_bool_int_0_1, - - /** - * Store boolean data as integer using ~0 for \c true. - */ - uniform_bool_int_0_not0 -}; - -struct gl_uniform_driver_storage { - /** - * Number of bytes from one array element to the next. - */ - uint8_t element_stride; - - /** - * Number of bytes from one vector in a matrix to the next. - */ - uint8_t vector_stride; - - /** - * Base format of the stored data. - * - * This field must have a value from \c GLSL_TYPE_UINT through \c - * GLSL_TYPE_SAMPLER. - */ - uint8_t format; - - /** - * Pointer to the base of the data. - */ - void *data; -}; - -struct gl_uniform_storage { - char *name; - const struct glsl_type *type; - - /** - * The number of elements in this uniform. - * - * For non-arrays, this is always 0. For arrays, the value is the size of - * the array. - */ - unsigned array_elements; - - /** - * Has this uniform ever been set? - */ - bool initialized; - - /** - * Base sampler index - * - * If \c ::base_type is \c GLSL_TYPE_SAMPLER, this represents the index of - * this sampler. If \c ::array_elements is not zero, the array will use - * sampler indexes \c ::sampler through \c ::sampler + \c ::array_elements - * - 1, inclusive. - */ - uint8_t sampler; - - /** - * Storage used by the driver for the uniform - */ - unsigned num_driver_storage; - struct gl_uniform_driver_storage *driver_storage; - - /** - * Storage used by Mesa for the uniform - * - * This form of the uniform is used by Mesa's implementation of \c - * glGetUniform. It can also be used by drivers to obtain the value of the - * uniform if the \c ::driver_storage interface is not used. - */ - union gl_constant_value *storage; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* IR_UNIFORM_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_validate.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_validate.cpp deleted file mode 100644 index 20a0377d456..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_validate.cpp +++ /dev/null @@ -1,629 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_validate.cpp - * - * Attempts to verify that various invariants of the IR tree are true. - * - * In particular, at the moment it makes sure that no single - * ir_instruction node except for ir_variable appears multiple times - * in the ir tree. ir_variable does appear multiple times: Once as a - * declaration in an exec_list, and multiple times as the endpoint of - * a dereference chain. - */ - -#include "ir.h" -#include "ir_hierarchical_visitor.h" -#include "program/hash_table.h" -#include "glsl_types.h" - -class ir_validate : public ir_hierarchical_visitor { -public: - ir_validate() - { - this->ht = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - - this->current_function = NULL; - - this->callback = ir_validate::validate_ir; - this->data = ht; - } - - ~ir_validate() - { - hash_table_dtor(this->ht); - } - - virtual ir_visitor_status visit(ir_variable *v); - virtual ir_visitor_status visit(ir_dereference_variable *ir); - - virtual ir_visitor_status visit_enter(ir_if *ir); - - virtual ir_visitor_status visit_leave(ir_loop *ir); - virtual ir_visitor_status visit_enter(ir_function *ir); - virtual ir_visitor_status visit_leave(ir_function *ir); - virtual ir_visitor_status visit_enter(ir_function_signature *ir); - - virtual ir_visitor_status visit_leave(ir_expression *ir); - virtual ir_visitor_status visit_leave(ir_swizzle *ir); - - virtual ir_visitor_status visit_enter(ir_assignment *ir); - virtual ir_visitor_status visit_enter(ir_call *ir); - - static void validate_ir(ir_instruction *ir, void *data); - - ir_function *current_function; - - struct hash_table *ht; -}; - - -ir_visitor_status -ir_validate::visit(ir_dereference_variable *ir) -{ - if ((ir->var == NULL) || (ir->var->as_variable() == NULL)) { - printf("ir_dereference_variable @ %p does not specify a variable %p\n", - (void *) ir, (void *) ir->var); - abort(); - } - - if (hash_table_find(ht, ir->var) == NULL) { - printf("ir_dereference_variable @ %p specifies undeclared variable " - "`%s' @ %p\n", - (void *) ir, ir->var->name, (void *) ir->var); - abort(); - } - - this->validate_ir(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_if *ir) -{ - if (ir->condition->type != glsl_type::bool_type) { - printf("ir_if condition %s type instead of bool.\n", - ir->condition->type->name); - ir->print(); - printf("\n"); - abort(); - } - - return visit_continue; -} - - -ir_visitor_status -ir_validate::visit_leave(ir_loop *ir) -{ - if (ir->counter != NULL) { - if ((ir->from == NULL) || (ir->from == NULL) || (ir->increment == NULL)) { - printf("ir_loop has invalid loop controls:\n" - " counter: %p\n" - " from: %p\n" - " to: %p\n" - " increment: %p\n", - (void *) ir->counter, (void *) ir->from, (void *) ir->to, - (void *) ir->increment); - abort(); - } - - if ((ir->cmp < ir_binop_less) || (ir->cmp > ir_binop_nequal)) { - printf("ir_loop has invalid comparitor %d\n", ir->cmp); - abort(); - } - } else { - if ((ir->from != NULL) || (ir->from != NULL) || (ir->increment != NULL)) { - printf("ir_loop has invalid loop controls:\n" - " counter: %p\n" - " from: %p\n" - " to: %p\n" - " increment: %p\n", - (void *) ir->counter, (void *) ir->from, (void *) ir->to, - (void *) ir->increment); - abort(); - } - } - - return visit_continue; -} - - -ir_visitor_status -ir_validate::visit_enter(ir_function *ir) -{ - /* Function definitions cannot be nested. - */ - if (this->current_function != NULL) { - printf("Function definition nested inside another function " - "definition:\n"); - printf("%s %p inside %s %p\n", - ir->name, (void *) ir, - this->current_function->name, (void *) this->current_function); - abort(); - } - - /* Store the current function hierarchy being traversed. This is used - * by the function signature visitor to ensure that the signatures are - * linked with the correct functions. - */ - this->current_function = ir; - - this->validate_ir(ir, this->data); - - /* Verify that all of the things stored in the list of signatures are, - * in fact, function signatures. - */ - foreach_list(node, &ir->signatures) { - ir_instruction *sig = (ir_instruction *) node; - - if (sig->ir_type != ir_type_function_signature) { - printf("Non-signature in signature list of function `%s'\n", - ir->name); - abort(); - } - } - - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_leave(ir_function *ir) -{ - assert(ralloc_parent(ir->name) == ir); - - this->current_function = NULL; - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_function_signature *ir) -{ - if (this->current_function != ir->function()) { - printf("Function signature nested inside wrong function " - "definition:\n"); - printf("%p inside %s %p instead of %s %p\n", - (void *) ir, - this->current_function->name, (void *) this->current_function, - ir->function_name(), (void *) ir->function()); - abort(); - } - - if (ir->return_type == NULL) { - printf("Function signature %p for function %s has NULL return type.\n", - (void *) ir, ir->function_name()); - abort(); - } - - this->validate_ir(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_leave(ir_expression *ir) -{ - switch (ir->operation) { - case ir_unop_bit_not: - assert(ir->operands[0]->type == ir->type); - break; - case ir_unop_logic_not: - assert(ir->type->base_type == GLSL_TYPE_BOOL); - assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); - break; - - case ir_unop_neg: - case ir_unop_abs: - case ir_unop_sign: - case ir_unop_rcp: - case ir_unop_rsq: - case ir_unop_sqrt: - assert(ir->type == ir->operands[0]->type); - break; - - case ir_unop_exp: - case ir_unop_log: - case ir_unop_exp2: - case ir_unop_log2: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); - assert(ir->type == ir->operands[0]->type); - break; - - case ir_unop_f2i: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); - assert(ir->type->base_type == GLSL_TYPE_INT); - break; - case ir_unop_i2f: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); - break; - case ir_unop_f2b: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); - assert(ir->type->base_type == GLSL_TYPE_BOOL); - break; - case ir_unop_b2f: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); - break; - case ir_unop_i2b: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); - assert(ir->type->base_type == GLSL_TYPE_BOOL); - break; - case ir_unop_b2i: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); - assert(ir->type->base_type == GLSL_TYPE_INT); - break; - case ir_unop_u2f: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); - break; - case ir_unop_i2u: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); - assert(ir->type->base_type == GLSL_TYPE_UINT); - break; - case ir_unop_u2i: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); - assert(ir->type->base_type == GLSL_TYPE_INT); - break; - - case ir_unop_any: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL); - assert(ir->type == glsl_type::bool_type); - break; - - case ir_unop_trunc: - case ir_unop_round_even: - case ir_unop_ceil: - case ir_unop_floor: - case ir_unop_fract: - case ir_unop_sin: - case ir_unop_cos: - case ir_unop_sin_reduced: - case ir_unop_cos_reduced: - case ir_unop_dFdx: - case ir_unop_dFdy: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); - assert(ir->operands[0]->type == ir->type); - break; - - case ir_unop_noise: - /* XXX what can we assert here? */ - break; - - case ir_binop_add: - case ir_binop_sub: - case ir_binop_mul: - case ir_binop_div: - case ir_binop_mod: - case ir_binop_min: - case ir_binop_max: - case ir_binop_pow: - if (ir->operands[0]->type->is_scalar()) - assert(ir->operands[1]->type == ir->type); - else if (ir->operands[1]->type->is_scalar()) - assert(ir->operands[0]->type == ir->type); - else if (ir->operands[0]->type->is_vector() && - ir->operands[1]->type->is_vector()) { - assert(ir->operands[0]->type == ir->operands[1]->type); - assert(ir->operands[0]->type == ir->type); - } - break; - - case ir_binop_less: - case ir_binop_greater: - case ir_binop_lequal: - case ir_binop_gequal: - case ir_binop_equal: - case ir_binop_nequal: - /* The semantics of the IR operators differ from the GLSL <, >, <=, >=, - * ==, and != operators. The IR operators perform a component-wise - * comparison on scalar or vector types and return a boolean scalar or - * vector type of the same size. - */ - assert(ir->type->base_type == GLSL_TYPE_BOOL); - assert(ir->operands[0]->type == ir->operands[1]->type); - assert(ir->operands[0]->type->is_vector() - || ir->operands[0]->type->is_scalar()); - assert(ir->operands[0]->type->vector_elements - == ir->type->vector_elements); - break; - - case ir_binop_all_equal: - case ir_binop_any_nequal: - /* GLSL == and != operate on scalars, vectors, matrices and arrays, and - * return a scalar boolean. The IR matches that. - */ - assert(ir->type == glsl_type::bool_type); - assert(ir->operands[0]->type == ir->operands[1]->type); - break; - - case ir_binop_lshift: - case ir_binop_rshift: - assert(ir->operands[0]->type->is_integer() && - ir->operands[1]->type->is_integer()); - if (ir->operands[0]->type->is_scalar()) { - assert(ir->operands[1]->type->is_scalar()); - } - if (ir->operands[0]->type->is_vector() && - ir->operands[1]->type->is_vector()) { - assert(ir->operands[0]->type->components() == - ir->operands[1]->type->components()); - } - assert(ir->type == ir->operands[0]->type); - break; - - case ir_binop_bit_and: - case ir_binop_bit_xor: - case ir_binop_bit_or: - assert(ir->operands[0]->type->base_type == - ir->operands[1]->type->base_type); - assert(ir->type->is_integer()); - if (ir->operands[0]->type->is_vector() && - ir->operands[1]->type->is_vector()) { - assert(ir->operands[0]->type->vector_elements == - ir->operands[1]->type->vector_elements); - } - break; - - case ir_binop_logic_and: - case ir_binop_logic_xor: - case ir_binop_logic_or: - assert(ir->type == glsl_type::bool_type); - assert(ir->operands[0]->type == glsl_type::bool_type); - assert(ir->operands[1]->type == glsl_type::bool_type); - break; - - case ir_binop_dot: - assert(ir->type == glsl_type::float_type); - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); - assert(ir->operands[0]->type->is_vector()); - assert(ir->operands[0]->type == ir->operands[1]->type); - break; - - case ir_quadop_vector: - /* The vector operator collects some number of scalars and generates a - * vector from them. - * - * - All of the operands must be scalar. - * - Number of operands must matche the size of the resulting vector. - * - Base type of the operands must match the base type of the result. - */ - assert(ir->type->is_vector()); - switch (ir->type->vector_elements) { - case 2: - assert(ir->operands[0]->type->is_scalar()); - assert(ir->operands[0]->type->base_type == ir->type->base_type); - assert(ir->operands[1]->type->is_scalar()); - assert(ir->operands[1]->type->base_type == ir->type->base_type); - assert(ir->operands[2] == NULL); - assert(ir->operands[3] == NULL); - break; - case 3: - assert(ir->operands[0]->type->is_scalar()); - assert(ir->operands[0]->type->base_type == ir->type->base_type); - assert(ir->operands[1]->type->is_scalar()); - assert(ir->operands[1]->type->base_type == ir->type->base_type); - assert(ir->operands[2]->type->is_scalar()); - assert(ir->operands[2]->type->base_type == ir->type->base_type); - assert(ir->operands[3] == NULL); - break; - case 4: - assert(ir->operands[0]->type->is_scalar()); - assert(ir->operands[0]->type->base_type == ir->type->base_type); - assert(ir->operands[1]->type->is_scalar()); - assert(ir->operands[1]->type->base_type == ir->type->base_type); - assert(ir->operands[2]->type->is_scalar()); - assert(ir->operands[2]->type->base_type == ir->type->base_type); - assert(ir->operands[3]->type->is_scalar()); - assert(ir->operands[3]->type->base_type == ir->type->base_type); - break; - default: - /* The is_vector assertion above should prevent execution from ever - * getting here. - */ - assert(!"Should not get here."); - break; - } - } - - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_leave(ir_swizzle *ir) -{ - int chans[4] = {ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w}; - - for (unsigned int i = 0; i < ir->type->vector_elements; i++) { - if (chans[i] >= ir->val->type->vector_elements) { - printf("ir_swizzle @ %p specifies a channel not present " - "in the value.\n", (void *) ir); - ir->print(); - abort(); - } - } - - return visit_continue; -} - -ir_visitor_status -ir_validate::visit(ir_variable *ir) -{ - /* An ir_variable is the one thing that can (and will) appear multiple times - * in an IR tree. It is added to the hashtable so that it can be used - * in the ir_dereference_variable handler to ensure that a variable is - * declared before it is dereferenced. - */ - if (ir->name) - assert(ralloc_parent(ir->name) == ir); - - hash_table_insert(ht, ir, ir); - - - /* If a variable is an array, verify that the maximum array index is in - * bounds. There was once an error in AST-to-HIR conversion that set this - * to be out of bounds. - */ - if (ir->type->array_size() > 0) { - if (ir->max_array_access >= ir->type->length) { - printf("ir_variable has maximum access out of bounds (%d vs %d)\n", - ir->max_array_access, ir->type->length - 1); - ir->print(); - abort(); - } - } - - if (ir->constant_initializer != NULL && !ir->has_initializer) { - printf("ir_variable didn't have an initializer, but has a constant " - "initializer value.\n"); - ir->print(); - abort(); - } - - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_assignment *ir) -{ - const ir_dereference *const lhs = ir->lhs; - if (lhs->type->is_scalar() || lhs->type->is_vector()) { - if (ir->write_mask == 0) { - printf("Assignment LHS is %s, but write mask is 0:\n", - lhs->type->is_scalar() ? "scalar" : "vector"); - ir->print(); - abort(); - } - - int lhs_components = 0; - for (int i = 0; i < 4; i++) { - if (ir->write_mask & (1 << i)) - lhs_components++; - } - - if (lhs_components != ir->rhs->type->vector_elements) { - printf("Assignment count of LHS write mask channels enabled not\n" - "matching RHS vector size (%d LHS, %d RHS).\n", - lhs_components, ir->rhs->type->vector_elements); - ir->print(); - abort(); - } - } - - this->validate_ir(ir, this->data); - - return visit_continue; -} - -ir_visitor_status -ir_validate::visit_enter(ir_call *ir) -{ - ir_function_signature *const callee = ir->get_callee(); - - if (callee->ir_type != ir_type_function_signature) { - printf("IR called by ir_call is not ir_function_signature!\n"); - abort(); - } - - const exec_node *formal_param_node = callee->parameters.head; - const exec_node *actual_param_node = ir->actual_parameters.head; - while (true) { - if (formal_param_node->is_tail_sentinel() - != actual_param_node->is_tail_sentinel()) { - printf("ir_call has the wrong number of parameters:\n"); - goto dump_ir; - } - if (formal_param_node->is_tail_sentinel()) { - break; - } - const ir_variable *formal_param - = (const ir_variable *) formal_param_node; - const ir_rvalue *actual_param - = (const ir_rvalue *) actual_param_node; - if (formal_param->type != actual_param->type) { - printf("ir_call parameter type mismatch:\n"); - goto dump_ir; - } - if (formal_param->mode == ir_var_out - || formal_param->mode == ir_var_inout) { - if (!actual_param->is_lvalue()) { - printf("ir_call out/inout parameters must be lvalues:\n"); - goto dump_ir; - } - } - formal_param_node = formal_param_node->next; - actual_param_node = actual_param_node->next; - } - - return visit_continue; - -dump_ir: - ir->print(); - printf("callee:\n"); - callee->print(); - abort(); - return visit_stop; -} - -void -ir_validate::validate_ir(ir_instruction *ir, void *data) -{ - struct hash_table *ht = (struct hash_table *) data; - - if (hash_table_find(ht, ir)) { - printf("Instruction node present twice in ir tree:\n"); - ir->print(); - printf("\n"); - abort(); - } - hash_table_insert(ht, ir, ir); -} - -void -check_node_type(ir_instruction *ir, void *data) -{ - (void) data; - - if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) { - printf("Instruction node with unset type\n"); - ir->print(); printf("\n"); - } - assert(ir->type != glsl_type::error_type); -} - -void -validate_ir_tree(exec_list *instructions) -{ - ir_validate v; - - v.run(instructions); - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - - visit_tree(ir, check_node_type, NULL); - } -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.cpp b/reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.cpp deleted file mode 100644 index 7d39abb3682..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_variable_refcount.cpp - * - * Provides a visitor which produces a list of variables referenced, - * how many times they were referenced and assigned, and whether they - * were defined in the scope. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_variable_refcount.h" -#include "glsl_types.h" - - -// constructor -variable_entry::variable_entry(ir_variable *var) -{ - this->var = var; - assign = NULL; - assigned_count = 0; - declaration = false; - referenced_count = 0; -} - - -variable_entry * -ir_variable_refcount_visitor::get_variable_entry(ir_variable *var) -{ - assert(var); - foreach_iter(exec_list_iterator, iter, this->variable_list) { - variable_entry *entry = (variable_entry *)iter.get(); - if (entry->var == var) - return entry; - } - - variable_entry *entry = new(mem_ctx) variable_entry(var); - assert(entry->referenced_count == 0); - this->variable_list.push_tail(entry); - return entry; -} - - -ir_visitor_status -ir_variable_refcount_visitor::visit(ir_variable *ir) -{ - variable_entry *entry = this->get_variable_entry(ir); - if (entry) - entry->declaration = true; - - return visit_continue; -} - - -ir_visitor_status -ir_variable_refcount_visitor::visit(ir_dereference_variable *ir) -{ - ir_variable *const var = ir->variable_referenced(); - variable_entry *entry = this->get_variable_entry(var); - - if (entry) - entry->referenced_count++; - - return visit_continue; -} - - -ir_visitor_status -ir_variable_refcount_visitor::visit_enter(ir_function_signature *ir) -{ - /* We don't want to descend into the function parameters and - * dead-code eliminate them, so just accept the body here. - */ - visit_list_elements(this, &ir->body); - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_variable_refcount_visitor::visit_leave(ir_assignment *ir) -{ - variable_entry *entry; - entry = this->get_variable_entry(ir->lhs->variable_referenced()); - if (entry) { - entry->assigned_count++; - if (entry->assign == NULL) - entry->assign = ir; - } - - return visit_continue; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.h b/reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.h deleted file mode 100644 index 906135a9e1e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_variable_refcount.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_variable_refcount.h - * - * Provides a visitor which produces a list of variables referenced, - * how many times they were referenced and assigned, and whether they - * were defined in the scope. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "glsl_types.h" - -class variable_entry : public exec_node -{ -public: - variable_entry(ir_variable *var); - - ir_variable *var; /* The key: the variable's pointer. */ - ir_assignment *assign; /* An assignment to the variable, if any */ - - /** Number of times the variable is referenced, including assignments. */ - unsigned referenced_count; - - /** Number of times the variable is assigned. */ - unsigned assigned_count; - - bool declaration; /* If the variable had a decl in the instruction stream */ -}; - -class ir_variable_refcount_visitor : public ir_hierarchical_visitor { -public: - ir_variable_refcount_visitor(void) - { - this->mem_ctx = ralloc_context(NULL); - this->variable_list.make_empty(); - } - - ~ir_variable_refcount_visitor(void) - { - ralloc_free(this->mem_ctx); - } - - virtual ir_visitor_status visit(ir_variable *); - virtual ir_visitor_status visit(ir_dereference_variable *); - - virtual ir_visitor_status visit_enter(ir_function_signature *); - virtual ir_visitor_status visit_leave(ir_assignment *); - - variable_entry *get_variable_entry(ir_variable *var); - - /* List of variable_entry */ - exec_list variable_list; - - void *mem_ctx; -}; diff --git a/reactos/dll/opengl/mesa/src/glsl/ir_visitor.h b/reactos/dll/opengl/mesa/src/glsl/ir_visitor.h deleted file mode 100644 index 7dd35fe1dc3..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ir_visitor.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef IR_VISITOR_H -#define IR_VISITOR_H - -/** - * Abstract base class of visitors of IR instruction trees - */ -class ir_visitor { -public: - virtual ~ir_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(class ir_variable *) = 0; - virtual void visit(class ir_function_signature *) = 0; - virtual void visit(class ir_function *) = 0; - virtual void visit(class ir_expression *) = 0; - virtual void visit(class ir_texture *) = 0; - virtual void visit(class ir_swizzle *) = 0; - virtual void visit(class ir_dereference_variable *) = 0; - virtual void visit(class ir_dereference_array *) = 0; - virtual void visit(class ir_dereference_record *) = 0; - virtual void visit(class ir_assignment *) = 0; - virtual void visit(class ir_constant *) = 0; - virtual void visit(class ir_call *) = 0; - virtual void visit(class ir_return *) = 0; - virtual void visit(class ir_discard *) = 0; - virtual void visit(class ir_if *) = 0; - virtual void visit(class ir_loop *) = 0; - virtual void visit(class ir_loop_jump *) = 0; - /*@}*/ -}; - -/* NOTE: function calls may never return due to discards inside them - * This is usually not an issue, but if it is, keep it in mind - */ -class ir_control_flow_visitor : public ir_visitor { -public: - virtual void visit(class ir_variable *) {} - virtual void visit(class ir_expression *) {} - virtual void visit(class ir_texture *) {} - virtual void visit(class ir_swizzle *) {} - virtual void visit(class ir_dereference_variable *) {} - virtual void visit(class ir_dereference_array *) {} - virtual void visit(class ir_dereference_record *) {} - virtual void visit(class ir_assignment *) {} - virtual void visit(class ir_constant *) {} - virtual void visit(class ir_call *) {} -}; - -#endif /* IR_VISITOR_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/link_functions.cpp b/reactos/dll/opengl/mesa/src/glsl/link_functions.cpp deleted file mode 100644 index acee3271249..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/link_functions.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "main/core.h" -#include "glsl_symbol_table.h" -#include "glsl_parser_extras.h" -#include "ir.h" -#include "program.h" -#include "program/hash_table.h" -#include "linker.h" - -static ir_function_signature * -find_matching_signature(const char *name, const exec_list *actual_parameters, - gl_shader **shader_list, unsigned num_shaders, - bool use_builtin); - -class call_link_visitor : public ir_hierarchical_visitor { -public: - call_link_visitor(gl_shader_program *prog, gl_shader *linked, - gl_shader **shader_list, unsigned num_shaders) - { - this->prog = prog; - this->shader_list = shader_list; - this->num_shaders = num_shaders; - this->success = true; - this->linked = linked; - - this->locals = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - } - - ~call_link_visitor() - { - hash_table_dtor(this->locals); - } - - virtual ir_visitor_status visit(ir_variable *ir) - { - hash_table_insert(locals, ir, ir); - return visit_continue; - } - - virtual ir_visitor_status visit_enter(ir_call *ir) - { - /* If ir is an ir_call from a function that was imported from another - * shader callee will point to an ir_function_signature in the original - * shader. In this case the function signature MUST NOT BE MODIFIED. - * Doing so will modify the original shader. This may prevent that - * shader from being linkable in other programs. - */ - const ir_function_signature *const callee = ir->get_callee(); - assert(callee != NULL); - const char *const name = callee->function_name(); - - /* Determine if the requested function signature already exists in the - * final linked shader. If it does, use it as the target of the call. - */ - ir_function_signature *sig = - find_matching_signature(name, &callee->parameters, &linked, 1, - ir->use_builtin); - if (sig != NULL) { - ir->set_callee(sig); - return visit_continue; - } - - /* Try to find the signature in one of the other shaders that is being - * linked. If it's not found there, return an error. - */ - sig = find_matching_signature(name, &ir->actual_parameters, shader_list, - num_shaders, ir->use_builtin); - if (sig == NULL) { - /* FINISHME: Log the full signature of unresolved function. - */ - linker_error(this->prog, "unresolved reference to function `%s'\n", - name); - this->success = false; - return visit_stop; - } - - /* Find the prototype information in the linked shader. Generate any - * details that may be missing. - */ - ir_function *f = linked->symbols->get_function(name); - if (f == NULL) { - f = new(linked) ir_function(name); - - /* Add the new function to the linked IR. Put it at the end - * so that it comes after any global variable declarations - * that it refers to. - */ - linked->symbols->add_function(f); - linked->ir->push_tail(f); - } - - ir_function_signature *linked_sig = - f->exact_matching_signature(&callee->parameters); - if ((linked_sig == NULL) - || ((linked_sig != NULL) - && (linked_sig->is_builtin != ir->use_builtin))) { - linked_sig = new(linked) ir_function_signature(callee->return_type); - f->add_signature(linked_sig); - } - - /* At this point linked_sig and called may be the same. If ir is an - * ir_call from linked then linked_sig and callee will be - * ir_function_signatures that have no definitions (is_defined is false). - */ - assert(!linked_sig->is_defined); - assert(linked_sig->body.is_empty()); - - /* Create an in-place clone of the function definition. This multistep - * process introduces some complexity here, but it has some advantages. - * The parameter list and the and function body are cloned separately. - * The clone of the parameter list is used to prime the hashtable used - * to replace variable references in the cloned body. - * - * The big advantage is that the ir_function_signature does not change. - * This means that we don't have to process the rest of the IR tree to - * patch ir_call nodes. In addition, there is no way to remove or - * replace signature stored in a function. One could easily be added, - * but this avoids the need. - */ - struct hash_table *ht = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - exec_list formal_parameters; - foreach_list_const(node, &sig->parameters) { - const ir_instruction *const original = (ir_instruction *) node; - assert(const_cast(original)->as_variable()); - - ir_instruction *copy = original->clone(linked, ht); - formal_parameters.push_tail(copy); - } - - linked_sig->replace_parameters(&formal_parameters); - - foreach_list_const(node, &sig->body) { - const ir_instruction *const original = (ir_instruction *) node; - - ir_instruction *copy = original->clone(linked, ht); - linked_sig->body.push_tail(copy); - } - - linked_sig->is_defined = true; - hash_table_dtor(ht); - - /* Patch references inside the function to things outside the function - * (i.e., function calls and global variables). - */ - linked_sig->accept(this); - - ir->set_callee(linked_sig); - - return visit_continue; - } - - virtual ir_visitor_status visit(ir_dereference_variable *ir) - { - if (hash_table_find(locals, ir->var) == NULL) { - /* The non-function variable must be a global, so try to find the - * variable in the shader's symbol table. If the variable is not - * found, then it's a global that *MUST* be defined in the original - * shader. - */ - ir_variable *var = linked->symbols->get_variable(ir->var->name); - if (var == NULL) { - /* Clone the ir_variable that the dereference already has and add - * it to the linked shader. - */ - var = ir->var->clone(linked, NULL); - linked->symbols->add_variable(var); - linked->ir->push_head(var); - } else if (var->type->is_array()) { - /* It is possible to have a global array declared in multiple - * shaders without a size. The array is implicitly sized by the - * maximal access to it in *any* shader. Because of this, we - * need to track the maximal access to the array as linking pulls - * more functions in that access the array. - */ - var->max_array_access = - MAX2(var->max_array_access, ir->var->max_array_access); - - if (var->type->length == 0 && ir->var->type->length != 0) - var->type = ir->var->type; - } - - ir->var = var; - } - - return visit_continue; - } - - /** Was function linking successful? */ - bool success; - -private: - /** - * Shader program being linked - * - * This is only used for logging error messages. - */ - gl_shader_program *prog; - - /** List of shaders available for linking. */ - gl_shader **shader_list; - - /** Number of shaders available for linking. */ - unsigned num_shaders; - - /** - * Final linked shader - * - * This is used two ways. It is used to find global variables in the - * linked shader that are accessed by the function. It is also used to add - * global variables from the shader where the function originated. - */ - gl_shader *linked; - - /** - * Table of variables local to the function. - */ - hash_table *locals; -}; - - -/** - * Searches a list of shaders for a particular function definition - */ -ir_function_signature * -find_matching_signature(const char *name, const exec_list *actual_parameters, - gl_shader **shader_list, unsigned num_shaders, - bool use_builtin) -{ - for (unsigned i = 0; i < num_shaders; i++) { - ir_function *const f = shader_list[i]->symbols->get_function(name); - - if (f == NULL) - continue; - - ir_function_signature *sig = f->matching_signature(actual_parameters); - - if ((sig == NULL) || !sig->is_defined) - continue; - - /* If this function expects to bind to a built-in function and the - * signature that we found isn't a built-in, keep looking. Also keep - * looking if we expect a non-built-in but found a built-in. - */ - if (use_builtin != sig->is_builtin) - continue; - - return sig; - } - - return NULL; -} - - -bool -link_function_calls(gl_shader_program *prog, gl_shader *main, - gl_shader **shader_list, unsigned num_shaders) -{ - call_link_visitor v(prog, main, shader_list, num_shaders); - - v.run(main->ir); - return v.success; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/link_uniforms.cpp b/reactos/dll/opengl/mesa/src/glsl/link_uniforms.cpp deleted file mode 100644 index 588008a8b48..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/link_uniforms.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "main/core.h" -#include "ir.h" -#include "linker.h" -#include "ir_uniform.h" -#include "glsl_symbol_table.h" -#include "program/hash_table.h" - -/** - * \file link_uniforms.cpp - * Assign locations for GLSL uniforms. - * - * \author Ian Romanick - */ - -/** - * Count the backing storage requirements for a type - */ -static unsigned -values_for_type(const glsl_type *type) -{ - if (type->is_sampler()) { - return 1; - } else if (type->is_array() && type->fields.array->is_sampler()) { - return type->array_size(); - } else { - return type->component_slots(); - } -} - -void -uniform_field_visitor::process(ir_variable *var) -{ - const glsl_type *t = var->type; - - /* Only strdup the name if we actually will need to modify it. */ - if (t->is_record() || (t->is_array() && t->fields.array->is_record())) { - char *name = ralloc_strdup(NULL, var->name); - recursion(var->type, &name, strlen(name)); - ralloc_free(name); - } else { - this->visit_field(t, var->name); - } -} - -void -uniform_field_visitor::recursion(const glsl_type *t, char **name, - unsigned name_length) -{ - /* Records need to have each field processed individually. - * - * Arrays of records need to have each array element processed - * individually, then each field of the resulting array elements processed - * individually. - */ - if (t->is_record()) { - for (unsigned i = 0; i < t->length; i++) { - const char *field = t->fields.structure[i].name; - - /* Append '.field' to the current uniform name. */ - ralloc_asprintf_rewrite_tail(name, name_length, ".%s", field); - - recursion(t->fields.structure[i].type, name, - name_length + 1 + strlen(field)); - } - } else if (t->is_array() && t->fields.array->is_record()) { - for (unsigned i = 0; i < t->length; i++) { - char subscript[13]; - - /* Append the subscript to the current uniform name */ - const unsigned subscript_length = snprintf(subscript, 13, "[%u]", i); - ralloc_asprintf_rewrite_tail(name, name_length, "%s", subscript); - - recursion(t->fields.array, name, name_length + subscript_length); - } - } else { - this->visit_field(t, *name); - } -} - -/** - * Class to help calculate the storage requirements for a set of uniforms - * - * As uniforms are added to the active set the number of active uniforms and - * the storage requirements for those uniforms are accumulated. The active - * uniforms are added the the hash table supplied to the constructor. - * - * If the same uniform is added multiple times (i.e., once for each shader - * target), it will only be accounted once. - */ -class count_uniform_size : public uniform_field_visitor { -public: - count_uniform_size(struct string_to_uint_map *map) - : num_active_uniforms(0), num_values(0), num_shader_samplers(0), - num_shader_uniform_components(0), map(map) - { - /* empty */ - } - - void start_shader() - { - this->num_shader_samplers = 0; - this->num_shader_uniform_components = 0; - } - - /** - * Total number of active uniforms counted - */ - unsigned num_active_uniforms; - - /** - * Number of data values required to back the storage for the active uniforms - */ - unsigned num_values; - - /** - * Number of samplers used - */ - unsigned num_shader_samplers; - - /** - * Number of uniforms used in the current shader - */ - unsigned num_shader_uniform_components; - -private: - virtual void visit_field(const glsl_type *type, const char *name) - { - assert(!type->is_record()); - assert(!(type->is_array() && type->fields.array->is_record())); - - /* Count the number of samplers regardless of whether the uniform is - * already in the hash table. The hash table prevents adding the same - * uniform for multiple shader targets, but in this case we want to - * count it for each shader target. - */ - const unsigned values = values_for_type(type); - if (type->contains_sampler()) { - this->num_shader_samplers += - type->is_array() ? type->array_size() : 1; - } else { - /* Accumulate the total number of uniform slots used by this shader. - * Note that samplers do not count against this limit because they - * don't use any storage on current hardware. - */ - this->num_shader_uniform_components += values; - } - - /* If the uniform is already in the map, there's nothing more to do. - */ - unsigned id; - if (this->map->get(id, name)) - return; - - this->map->put(this->num_active_uniforms, name); - - /* Each leaf uniform occupies one entry in the list of active - * uniforms. - */ - this->num_active_uniforms++; - this->num_values += values; - } - - struct string_to_uint_map *map; -}; - -/** - * Class to help parcel out pieces of backing storage to uniforms - * - * Each uniform processed has some range of the \c gl_constant_value - * structures associated with it. The association is done by finding - * the uniform in the \c string_to_uint_map and using the value from - * the map to connect that slot in the \c gl_uniform_storage table - * with the next available slot in the \c gl_constant_value array. - * - * \warning - * This class assumes that every uniform that will be processed is - * already in the \c string_to_uint_map. In addition, it assumes that - * the \c gl_uniform_storage and \c gl_constant_value arrays are "big - * enough." - */ -class parcel_out_uniform_storage : public uniform_field_visitor { -public: - parcel_out_uniform_storage(struct string_to_uint_map *map, - struct gl_uniform_storage *uniforms, - union gl_constant_value *values) - : map(map), uniforms(uniforms), next_sampler(0), values(values) - { - memset(this->targets, 0, sizeof(this->targets)); - } - - void start_shader() - { - this->shader_samplers_used = 0; - this->shader_shadow_samplers = 0; - } - -private: - virtual void visit_field(const glsl_type *type, const char *name) - { - assert(!type->is_record()); - assert(!(type->is_array() && type->fields.array->is_record())); - - unsigned id; - bool found = this->map->get(id, name); - assert(found); - - if (!found) - return; - - /* If there is already storage associated with this uniform, it means - * that it was set while processing an earlier shader stage. For - * example, we may be processing the uniform in the fragment shader, but - * the uniform was already processed in the vertex shader. - */ - if (this->uniforms[id].storage != NULL) { - /* If the uniform already has storage set from another shader stage, - * mark the samplers used for this shader stage. - */ - if (type->contains_sampler()) { - const unsigned count = MAX2(1, this->uniforms[id].array_elements); - const unsigned shadow = (type->is_array()) - ? type->fields.array->sampler_shadow : type->sampler_shadow; - - for (unsigned i = 0; i < count; i++) { - const unsigned s = this->uniforms[id].sampler + i; - - this->shader_samplers_used |= 1U << s; - this->shader_shadow_samplers |= shadow << s; - } - } - - return; - } - - const glsl_type *base_type; - if (type->is_array()) { - this->uniforms[id].array_elements = type->length; - base_type = type->fields.array; - } else { - this->uniforms[id].array_elements = 0; - base_type = type; - } - - if (base_type->is_sampler()) { - this->uniforms[id].sampler = this->next_sampler; - - /* Increment the sampler by 1 for non-arrays and by the number of - * array elements for arrays. - */ - this->next_sampler += MAX2(1, this->uniforms[id].array_elements); - - const gl_texture_index target = base_type->sampler_index(); - const unsigned shadow = base_type->sampler_shadow; - for (unsigned i = this->uniforms[id].sampler - ; i < this->next_sampler - ; i++) { - this->targets[i] = target; - this->shader_samplers_used |= 1U << i; - this->shader_shadow_samplers |= shadow << i; - } - - } else { - this->uniforms[id].sampler = ~0; - } - - this->uniforms[id].name = ralloc_strdup(this->uniforms, name); - this->uniforms[id].type = base_type; - this->uniforms[id].initialized = 0; - this->uniforms[id].num_driver_storage = 0; - this->uniforms[id].driver_storage = NULL; - this->uniforms[id].storage = this->values; - - this->values += values_for_type(type); - } - - struct string_to_uint_map *map; - - struct gl_uniform_storage *uniforms; - unsigned next_sampler; - -public: - union gl_constant_value *values; - - gl_texture_index targets[MAX_SAMPLERS]; - - /** - * Mask of samplers used by the current shader stage. - */ - unsigned shader_samplers_used; - - /** - * Mask of samplers used by the current shader stage for shadows. - */ - unsigned shader_shadow_samplers; -}; - -void -link_assign_uniform_locations(struct gl_shader_program *prog) -{ - ralloc_free(prog->UniformStorage); - prog->UniformStorage = NULL; - prog->NumUserUniformStorage = 0; - - if (prog->UniformHash != NULL) { - prog->UniformHash->clear(); - } else { - prog->UniformHash = new string_to_uint_map; - } - - for (unsigned i = 0; i < Elements(prog->SamplerUnits); i++) { - prog->SamplerUnits[i] = i; - } - - /* First pass: Count the uniform resources used by the user-defined - * uniforms. While this happens, each active uniform will have an index - * assigned to it. - * - * Note: this is *NOT* the index that is returned to the application by - * glGetUniformLocation. - */ - count_uniform_size uniform_size(prog->UniformHash); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - /* Reset various per-shader target counts. - */ - uniform_size.start_shader(); - - foreach_list(node, prog->_LinkedShaders[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_uniform)) - continue; - - /* FINISHME: Update code to process built-in uniforms! - */ - if (strncmp("gl_", var->name, 3) == 0) - continue; - - uniform_size.process(var); - } - - prog->_LinkedShaders[i]->num_samplers = uniform_size.num_shader_samplers; - prog->_LinkedShaders[i]->num_uniform_components = - uniform_size.num_shader_uniform_components; - } - - const unsigned num_user_uniforms = uniform_size.num_active_uniforms; - const unsigned num_data_slots = uniform_size.num_values; - - /* On the outside chance that there were no uniforms, bail out. - */ - if (num_user_uniforms == 0) - return; - - struct gl_uniform_storage *uniforms = - rzalloc_array(prog, struct gl_uniform_storage, num_user_uniforms); - union gl_constant_value *data = - rzalloc_array(uniforms, union gl_constant_value, num_data_slots); -#ifndef NDEBUG - union gl_constant_value *data_end = &data[num_data_slots]; -#endif - - parcel_out_uniform_storage parcel(prog->UniformHash, uniforms, data); - - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - /* Reset various per-shader target counts. - */ - parcel.start_shader(); - - foreach_list(node, prog->_LinkedShaders[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_uniform)) - continue; - - /* FINISHME: Update code to process built-in uniforms! - */ - if (strncmp("gl_", var->name, 3) == 0) - continue; - - parcel.process(var); - } - - prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used; - prog->_LinkedShaders[i]->shadow_samplers = parcel.shader_shadow_samplers; - } - - assert(sizeof(prog->SamplerTargets) == sizeof(parcel.targets)); - memcpy(prog->SamplerTargets, parcel.targets, sizeof(prog->SamplerTargets)); - -#ifndef NDEBUG - for (unsigned i = 0; i < num_user_uniforms; i++) { - assert(uniforms[i].storage != NULL); - } - - assert(parcel.values == data_end); -#endif - - prog->NumUserUniformStorage = num_user_uniforms; - prog->UniformStorage = uniforms; - - return; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/linker.cpp b/reactos/dll/opengl/mesa/src/glsl/linker.cpp deleted file mode 100644 index bf04ea55622..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/linker.cpp +++ /dev/null @@ -1,1882 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file linker.cpp - * GLSL linker implementation - * - * Given a set of shaders that are to be linked to generate a final program, - * there are three distinct stages. - * - * In the first stage shaders are partitioned into groups based on the shader - * type. All shaders of a particular type (e.g., vertex shaders) are linked - * together. - * - * - Undefined references in each shader are resolve to definitions in - * another shader. - * - Types and qualifiers of uniforms, outputs, and global variables defined - * in multiple shaders with the same name are verified to be the same. - * - Initializers for uniforms and global variables defined - * in multiple shaders with the same name are verified to be the same. - * - * The result, in the terminology of the GLSL spec, is a set of shader - * executables for each processing unit. - * - * After the first stage is complete, a series of semantic checks are performed - * on each of the shader executables. - * - * - Each shader executable must define a \c main function. - * - Each vertex shader executable must write to \c gl_Position. - * - Each fragment shader executable must write to either \c gl_FragData or - * \c gl_FragColor. - * - * In the final stage individual shader executables are linked to create a - * complete exectuable. - * - * - Types of uniforms defined in multiple shader stages with the same name - * are verified to be the same. - * - Initializers for uniforms defined in multiple shader stages with the - * same name are verified to be the same. - * - Types and qualifiers of outputs defined in one stage are verified to - * be the same as the types and qualifiers of inputs defined with the same - * name in a later stage. - * - * \author Ian Romanick - */ - -#include "main/core.h" -#include "glsl_symbol_table.h" -#include "ir.h" -#include "program.h" -#include "program/hash_table.h" -#include "linker.h" -#include "ir_optimization.h" - -extern "C" { -#include "main/shaderobj.h" -} - -/** - * Visitor that determines whether or not a variable is ever written. - */ -class find_assignment_visitor : public ir_hierarchical_visitor { -public: - find_assignment_visitor(const char *name) - : name(name), found(false) - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_assignment *ir) - { - ir_variable *const var = ir->lhs->variable_referenced(); - - if (strcmp(name, var->name) == 0) { - found = true; - return visit_stop; - } - - return visit_continue_with_parent; - } - - virtual ir_visitor_status visit_enter(ir_call *ir) - { - exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param_rval = (ir_rvalue *)iter.get(); - ir_variable *sig_param = (ir_variable *)sig_iter.get(); - - if (sig_param->mode == ir_var_out || - sig_param->mode == ir_var_inout) { - ir_variable *var = param_rval->variable_referenced(); - if (var && strcmp(name, var->name) == 0) { - found = true; - return visit_stop; - } - } - sig_iter.next(); - } - - return visit_continue_with_parent; - } - - bool variable_found() - { - return found; - } - -private: - const char *name; /**< Find writes to a variable with this name. */ - bool found; /**< Was a write to the variable found? */ -}; - - -/** - * Visitor that determines whether or not a variable is ever read. - */ -class find_deref_visitor : public ir_hierarchical_visitor { -public: - find_deref_visitor(const char *name) - : name(name), found(false) - { - /* empty */ - } - - virtual ir_visitor_status visit(ir_dereference_variable *ir) - { - if (strcmp(this->name, ir->var->name) == 0) { - this->found = true; - return visit_stop; - } - - return visit_continue; - } - - bool variable_found() const - { - return this->found; - } - -private: - const char *name; /**< Find writes to a variable with this name. */ - bool found; /**< Was a write to the variable found? */ -}; - - -void -linker_error(gl_shader_program *prog, const char *fmt, ...) -{ - va_list ap; - - ralloc_strcat(&prog->InfoLog, "error: "); - va_start(ap, fmt); - ralloc_vasprintf_append(&prog->InfoLog, fmt, ap); - va_end(ap); - - prog->LinkStatus = false; -} - - -void -linker_warning(gl_shader_program *prog, const char *fmt, ...) -{ - va_list ap; - - ralloc_strcat(&prog->InfoLog, "error: "); - va_start(ap, fmt); - ralloc_vasprintf_append(&prog->InfoLog, fmt, ap); - va_end(ap); - -} - - -void -link_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode, - int generic_base) -{ - foreach_list(node, sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != (unsigned) mode)) - continue; - - /* Only assign locations for generic attributes / varyings / etc. - */ - if (var->location >= generic_base) - var->location = -1; - } -} - - -/** - * Determine the number of attribute slots required for a particular type - * - * This code is here because it implements the language rules of a specific - * GLSL version. Since it's a property of the language and not a property of - * types in general, it doesn't really belong in glsl_type. - */ -unsigned -count_attribute_slots(const glsl_type *t) -{ - /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec: - * - * "A scalar input counts the same amount against this limit as a vec4, - * so applications may want to consider packing groups of four - * unrelated float inputs together into a vector to better utilize the - * capabilities of the underlying hardware. A matrix input will use up - * multiple locations. The number of locations used will equal the - * number of columns in the matrix." - * - * The spec does not explicitly say how arrays are counted. However, it - * should be safe to assume the total number of slots consumed by an array - * is the number of entries in the array multiplied by the number of slots - * consumed by a single element of the array. - */ - - if (t->is_array()) - return t->array_size() * count_attribute_slots(t->element_type()); - - if (t->is_matrix()) - return t->matrix_columns; - - return 1; -} - - -/** - * Verify that a vertex shader executable meets all semantic requirements. - * - * Also sets prog->Vert.UsesClipDistance and prog->Vert.ClipDistanceArraySize - * as a side effect. - * - * \param shader Vertex shader executable to be verified - */ -bool -validate_vertex_shader_executable(struct gl_shader_program *prog, - struct gl_shader *shader) -{ - if (shader == NULL) - return true; - - find_assignment_visitor find("gl_Position"); - find.run(shader->ir); - if (!find.variable_found()) { - linker_error(prog, "vertex shader does not write to `gl_Position'\n"); - return false; - } - - prog->Vert.ClipDistanceArraySize = 0; - - if (prog->Version >= 130) { - /* From section 7.1 (Vertex Shader Special Variables) of the - * GLSL 1.30 spec: - * - * "It is an error for a shader to statically write both - * gl_ClipVertex and gl_ClipDistance." - */ - find_assignment_visitor clip_vertex("gl_ClipVertex"); - find_assignment_visitor clip_distance("gl_ClipDistance"); - - clip_vertex.run(shader->ir); - clip_distance.run(shader->ir); - if (clip_vertex.variable_found() && clip_distance.variable_found()) { - linker_error(prog, "vertex shader writes to both `gl_ClipVertex' " - "and `gl_ClipDistance'\n"); - return false; - } - prog->Vert.UsesClipDistance = clip_distance.variable_found(); - ir_variable *clip_distance_var = - shader->symbols->get_variable("gl_ClipDistance"); - if (clip_distance_var) - prog->Vert.ClipDistanceArraySize = clip_distance_var->type->length; - } - - return true; -} - - -/** - * Verify that a fragment shader executable meets all semantic requirements - * - * \param shader Fragment shader executable to be verified - */ -bool -validate_fragment_shader_executable(struct gl_shader_program *prog, - struct gl_shader *shader) -{ - if (shader == NULL) - return true; - - find_assignment_visitor frag_color("gl_FragColor"); - find_assignment_visitor frag_data("gl_FragData"); - - frag_color.run(shader->ir); - frag_data.run(shader->ir); - - if (frag_color.variable_found() && frag_data.variable_found()) { - linker_error(prog, "fragment shader writes to both " - "`gl_FragColor' and `gl_FragData'\n"); - return false; - } - - return true; -} - - -/** - * Generate a string describing the mode of a variable - */ -static const char * -mode_string(const ir_variable *var) -{ - switch (var->mode) { - case ir_var_auto: - return (var->read_only) ? "global constant" : "global variable"; - - case ir_var_uniform: return "uniform"; - case ir_var_in: return "shader input"; - case ir_var_out: return "shader output"; - case ir_var_inout: return "shader inout"; - - case ir_var_const_in: - case ir_var_temporary: - default: - assert(!"Should not get here."); - return "invalid variable"; - } -} - - -/** - * Perform validation of global variables used across multiple shaders - */ -bool -cross_validate_globals(struct gl_shader_program *prog, - struct gl_shader **shader_list, - unsigned num_shaders, - bool uniforms_only) -{ - /* Examine all of the uniforms in all of the shaders and cross validate - * them. - */ - glsl_symbol_table variables; - for (unsigned i = 0; i < num_shaders; i++) { - if (shader_list[i] == NULL) - continue; - - foreach_list(node, shader_list[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if (var == NULL) - continue; - - if (uniforms_only && (var->mode != ir_var_uniform)) - continue; - - /* Don't cross validate temporaries that are at global scope. These - * will eventually get pulled into the shaders 'main'. - */ - if (var->mode == ir_var_temporary) - continue; - - /* If a global with this name has already been seen, verify that the - * new instance has the same type. In addition, if the globals have - * initializers, the values of the initializers must be the same. - */ - ir_variable *const existing = variables.get_variable(var->name); - if (existing != NULL) { - if (var->type != existing->type) { - /* Consider the types to be "the same" if both types are arrays - * of the same type and one of the arrays is implicitly sized. - * In addition, set the type of the linked variable to the - * explicitly sized array. - */ - if (var->type->is_array() - && existing->type->is_array() - && (var->type->fields.array == existing->type->fields.array) - && ((var->type->length == 0) - || (existing->type->length == 0))) { - if (var->type->length != 0) { - existing->type = var->type; - } - } else { - linker_error(prog, "%s `%s' declared as type " - "`%s' and type `%s'\n", - mode_string(var), - var->name, var->type->name, - existing->type->name); - return false; - } - } - - /* Validate layout qualifiers for gl_FragDepth. - * - * From the AMD/ARB_conservative_depth specs: - * - * "If gl_FragDepth is redeclared in any fragment shader in a - * program, it must be redeclared in all fragment shaders in - * that program that have static assignments to - * gl_FragDepth. All redeclarations of gl_FragDepth in all - * fragment shaders in a single program must have the same set - * of qualifiers." - */ - if (strcmp(var->name, "gl_FragDepth") == 0) { - bool layout_declared = var->depth_layout != ir_depth_layout_none; - bool layout_differs = - var->depth_layout != existing->depth_layout; - - if (layout_declared && layout_differs) { - linker_error(prog, - "All redeclarations of gl_FragDepth in all " - "fragment shaders in a single program must have " - "the same set of qualifiers."); - } - - if (var->used && layout_differs) { - linker_error(prog, - "If gl_FragDepth is redeclared with a layout " - "qualifier in any fragment shader, it must be " - "redeclared with the same layout qualifier in " - "all fragment shaders that have assignments to " - "gl_FragDepth"); - } - } - - /* Page 35 (page 41 of the PDF) of the GLSL 4.20 spec says: - * - * "If a shared global has multiple initializers, the - * initializers must all be constant expressions, and they - * must all have the same value. Otherwise, a link error will - * result. (A shared global having only one initializer does - * not require that initializer to be a constant expression.)" - * - * Previous to 4.20 the GLSL spec simply said that initializers - * must have the same value. In this case of non-constant - * initializers, this was impossible to determine. As a result, - * no vendor actually implemented that behavior. The 4.20 - * behavior matches the implemented behavior of at least one other - * vendor, so we'll implement that for all GLSL versions. - */ - if (var->constant_initializer != NULL) { - if (existing->constant_initializer != NULL) { - if (!var->constant_initializer->has_value(existing->constant_initializer)) { - linker_error(prog, "initializers for %s " - "`%s' have differing values\n", - mode_string(var), var->name); - return false; - } - } else { - /* If the first-seen instance of a particular uniform did not - * have an initializer but a later instance does, copy the - * initializer to the version stored in the symbol table. - */ - /* FINISHME: This is wrong. The constant_value field should - * FINISHME: not be modified! Imagine a case where a shader - * FINISHME: without an initializer is linked in two different - * FINISHME: programs with shaders that have differing - * FINISHME: initializers. Linking with the first will - * FINISHME: modify the shader, and linking with the second - * FINISHME: will fail. - */ - existing->constant_initializer = - var->constant_initializer->clone(ralloc_parent(existing), - NULL); - } - } - - if (var->has_initializer) { - if (existing->has_initializer - && (var->constant_initializer == NULL - || existing->constant_initializer == NULL)) { - linker_error(prog, - "shared global variable `%s' has multiple " - "non-constant initializers.\n", - var->name); - return false; - } - - /* Some instance had an initializer, so keep track of that. In - * this location, all sorts of initializers (constant or - * otherwise) will propagate the existence to the variable - * stored in the symbol table. - */ - existing->has_initializer = true; - } - - if (existing->invariant != var->invariant) { - linker_error(prog, "declarations for %s `%s' have " - "mismatching invariant qualifiers\n", - mode_string(var), var->name); - return false; - } - if (existing->centroid != var->centroid) { - linker_error(prog, "declarations for %s `%s' have " - "mismatching centroid qualifiers\n", - mode_string(var), var->name); - return false; - } - } else - variables.add_variable(var); - } - } - - return true; -} - - -/** - * Perform validation of uniforms used across multiple shader stages - */ -bool -cross_validate_uniforms(struct gl_shader_program *prog) -{ - return cross_validate_globals(prog, prog->_LinkedShaders, - MESA_SHADER_TYPES, true); -} - - -/** - * Validate that outputs from one stage match inputs of another - */ -bool -cross_validate_outputs_to_inputs(struct gl_shader_program *prog, - gl_shader *producer, gl_shader *consumer) -{ - glsl_symbol_table parameters; - /* FINISHME: Figure these out dynamically. */ - const char *const producer_stage = "vertex"; - const char *const consumer_stage = "fragment"; - - /* Find all shader outputs in the "producer" stage. - */ - foreach_list(node, producer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - /* FINISHME: For geometry shaders, this should also look for inout - * FINISHME: variables. - */ - if ((var == NULL) || (var->mode != ir_var_out)) - continue; - - parameters.add_variable(var); - } - - - /* Find all shader inputs in the "consumer" stage. Any variables that have - * matching outputs already in the symbol table must have the same type and - * qualifiers. - */ - foreach_list(node, consumer->ir) { - ir_variable *const input = ((ir_instruction *) node)->as_variable(); - - /* FINISHME: For geometry shaders, this should also look for inout - * FINISHME: variables. - */ - if ((input == NULL) || (input->mode != ir_var_in)) - continue; - - ir_variable *const output = parameters.get_variable(input->name); - if (output != NULL) { - /* Check that the types match between stages. - */ - if (input->type != output->type) { - /* There is a bit of a special case for gl_TexCoord. This - * built-in is unsized by default. Applications that variable - * access it must redeclare it with a size. There is some - * language in the GLSL spec that implies the fragment shader - * and vertex shader do not have to agree on this size. Other - * driver behave this way, and one or two applications seem to - * rely on it. - * - * Neither declaration needs to be modified here because the array - * sizes are fixed later when update_array_sizes is called. - * - * From page 48 (page 54 of the PDF) of the GLSL 1.10 spec: - * - * "Unlike user-defined varying variables, the built-in - * varying variables don't have a strict one-to-one - * correspondence between the vertex language and the - * fragment language." - */ - if (!output->type->is_array() - || (strncmp("gl_", output->name, 3) != 0)) { - linker_error(prog, - "%s shader output `%s' declared as type `%s', " - "but %s shader input declared as type `%s'\n", - producer_stage, output->name, - output->type->name, - consumer_stage, input->type->name); - return false; - } - } - - /* Check that all of the qualifiers match between stages. - */ - if (input->centroid != output->centroid) { - linker_error(prog, - "%s shader output `%s' %s centroid qualifier, " - "but %s shader input %s centroid qualifier\n", - producer_stage, - output->name, - (output->centroid) ? "has" : "lacks", - consumer_stage, - (input->centroid) ? "has" : "lacks"); - return false; - } - - if (input->invariant != output->invariant) { - linker_error(prog, - "%s shader output `%s' %s invariant qualifier, " - "but %s shader input %s invariant qualifier\n", - producer_stage, - output->name, - (output->invariant) ? "has" : "lacks", - consumer_stage, - (input->invariant) ? "has" : "lacks"); - return false; - } - - if (input->interpolation != output->interpolation) { - linker_error(prog, - "%s shader output `%s' specifies %s " - "interpolation qualifier, " - "but %s shader input specifies %s " - "interpolation qualifier\n", - producer_stage, - output->name, - output->interpolation_string(), - consumer_stage, - input->interpolation_string()); - return false; - } - } - } - - return true; -} - - -/** - * Populates a shaders symbol table with all global declarations - */ -static void -populate_symbol_table(gl_shader *sh) -{ - sh->symbols = new(sh) glsl_symbol_table; - - foreach_list(node, sh->ir) { - ir_instruction *const inst = (ir_instruction *) node; - ir_variable *var; - ir_function *func; - - if ((func = inst->as_function()) != NULL) { - sh->symbols->add_function(func); - } else if ((var = inst->as_variable()) != NULL) { - sh->symbols->add_variable(var); - } - } -} - - -/** - * Remap variables referenced in an instruction tree - * - * This is used when instruction trees are cloned from one shader and placed in - * another. These trees will contain references to \c ir_variable nodes that - * do not exist in the target shader. This function finds these \c ir_variable - * references and replaces the references with matching variables in the target - * shader. - * - * If there is no matching variable in the target shader, a clone of the - * \c ir_variable is made and added to the target shader. The new variable is - * added to \b both the instruction stream and the symbol table. - * - * \param inst IR tree that is to be processed. - * \param symbols Symbol table containing global scope symbols in the - * linked shader. - * \param instructions Instruction stream where new variable declarations - * should be added. - */ -void -remap_variables(ir_instruction *inst, struct gl_shader *target, - hash_table *temps) -{ - class remap_visitor : public ir_hierarchical_visitor { - public: - remap_visitor(struct gl_shader *target, - hash_table *temps) - { - this->target = target; - this->symbols = target->symbols; - this->instructions = target->ir; - this->temps = temps; - } - - virtual ir_visitor_status visit(ir_dereference_variable *ir) - { - if (ir->var->mode == ir_var_temporary) { - ir_variable *var = (ir_variable *) hash_table_find(temps, ir->var); - - assert(var != NULL); - ir->var = var; - return visit_continue; - } - - ir_variable *const existing = - this->symbols->get_variable(ir->var->name); - if (existing != NULL) - ir->var = existing; - else { - ir_variable *copy = ir->var->clone(this->target, NULL); - - this->symbols->add_variable(copy); - this->instructions->push_head(copy); - ir->var = copy; - } - - return visit_continue; - } - - private: - struct gl_shader *target; - glsl_symbol_table *symbols; - exec_list *instructions; - hash_table *temps; - }; - - remap_visitor v(target, temps); - - inst->accept(&v); -} - - -/** - * Move non-declarations from one instruction stream to another - * - * The intended usage pattern of this function is to pass the pointer to the - * head sentinel of a list (i.e., a pointer to the list cast to an \c exec_node - * pointer) for \c last and \c false for \c make_copies on the first - * call. Successive calls pass the return value of the previous call for - * \c last and \c true for \c make_copies. - * - * \param instructions Source instruction stream - * \param last Instruction after which new instructions should be - * inserted in the target instruction stream - * \param make_copies Flag selecting whether instructions in \c instructions - * should be copied (via \c ir_instruction::clone) into the - * target list or moved. - * - * \return - * The new "last" instruction in the target instruction stream. This pointer - * is suitable for use as the \c last parameter of a later call to this - * function. - */ -exec_node * -move_non_declarations(exec_list *instructions, exec_node *last, - bool make_copies, gl_shader *target) -{ - hash_table *temps = NULL; - - if (make_copies) - temps = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - - foreach_list_safe(node, instructions) { - ir_instruction *inst = (ir_instruction *) node; - - if (inst->as_function()) - continue; - - ir_variable *var = inst->as_variable(); - if ((var != NULL) && (var->mode != ir_var_temporary)) - continue; - - assert(inst->as_assignment() - || ((var != NULL) && (var->mode == ir_var_temporary))); - - if (make_copies) { - inst = inst->clone(target, NULL); - - if (var != NULL) - hash_table_insert(temps, inst, var); - else - remap_variables(inst, target, temps); - } else { - inst->remove(); - } - - last->insert_after(inst); - last = inst; - } - - if (make_copies) - hash_table_dtor(temps); - - return last; -} - -/** - * Get the function signature for main from a shader - */ -static ir_function_signature * -get_main_function_signature(gl_shader *sh) -{ - ir_function *const f = sh->symbols->get_function("main"); - if (f != NULL) { - exec_list void_parameters; - - /* Look for the 'void main()' signature and ensure that it's defined. - * This keeps the linker from accidentally pick a shader that just - * contains a prototype for main. - * - * We don't have to check for multiple definitions of main (in multiple - * shaders) because that would have already been caught above. - */ - ir_function_signature *sig = f->matching_signature(&void_parameters); - if ((sig != NULL) && sig->is_defined) { - return sig; - } - } - - return NULL; -} - - -/** - * Combine a group of shaders for a single stage to generate a linked shader - * - * \note - * If this function is supplied a single shader, it is cloned, and the new - * shader is returned. - */ -static struct gl_shader * -link_intrastage_shaders(void *mem_ctx, - struct gl_context *ctx, - struct gl_shader_program *prog, - struct gl_shader **shader_list, - unsigned num_shaders) -{ - /* Check that global variables defined in multiple shaders are consistent. - */ - if (!cross_validate_globals(prog, shader_list, num_shaders, false)) - return NULL; - - /* Check that there is only a single definition of each function signature - * across all shaders. - */ - for (unsigned i = 0; i < (num_shaders - 1); i++) { - foreach_list(node, shader_list[i]->ir) { - ir_function *const f = ((ir_instruction *) node)->as_function(); - - if (f == NULL) - continue; - - for (unsigned j = i + 1; j < num_shaders; j++) { - ir_function *const other = - shader_list[j]->symbols->get_function(f->name); - - /* If the other shader has no function (and therefore no function - * signatures) with the same name, skip to the next shader. - */ - if (other == NULL) - continue; - - foreach_iter (exec_list_iterator, iter, *f) { - ir_function_signature *sig = - (ir_function_signature *) iter.get(); - - if (!sig->is_defined || sig->is_builtin) - continue; - - ir_function_signature *other_sig = - other->exact_matching_signature(& sig->parameters); - - if ((other_sig != NULL) && other_sig->is_defined - && !other_sig->is_builtin) { - linker_error(prog, "function `%s' is multiply defined", - f->name); - return NULL; - } - } - } - } - } - - /* Find the shader that defines main, and make a clone of it. - * - * Starting with the clone, search for undefined references. If one is - * found, find the shader that defines it. Clone the reference and add - * it to the shader. Repeat until there are no undefined references or - * until a reference cannot be resolved. - */ - gl_shader *main = NULL; - for (unsigned i = 0; i < num_shaders; i++) { - if (get_main_function_signature(shader_list[i]) != NULL) { - main = shader_list[i]; - break; - } - } - - if (main == NULL) { - linker_error(prog, "%s shader lacks `main'\n", - (shader_list[0]->Type == GL_VERTEX_SHADER) - ? "vertex" : "fragment"); - return NULL; - } - - gl_shader *linked = ctx->Driver.NewShader(NULL, 0, main->Type); - linked->ir = new(linked) exec_list; - clone_ir_list(mem_ctx, linked->ir, main->ir); - - populate_symbol_table(linked); - - /* The a pointer to the main function in the final linked shader (i.e., the - * copy of the original shader that contained the main function). - */ - ir_function_signature *const main_sig = get_main_function_signature(linked); - - /* Move any instructions other than variable declarations or function - * declarations into main. - */ - exec_node *insertion_point = - move_non_declarations(linked->ir, (exec_node *) &main_sig->body, false, - linked); - - for (unsigned i = 0; i < num_shaders; i++) { - if (shader_list[i] == main) - continue; - - insertion_point = move_non_declarations(shader_list[i]->ir, - insertion_point, true, linked); - } - - /* Resolve initializers for global variables in the linked shader. - */ - unsigned num_linking_shaders = num_shaders; - for (unsigned i = 0; i < num_shaders; i++) - num_linking_shaders += shader_list[i]->num_builtins_to_link; - - gl_shader **linking_shaders = - (gl_shader **) calloc(num_linking_shaders, sizeof(gl_shader *)); - - memcpy(linking_shaders, shader_list, - sizeof(linking_shaders[0]) * num_shaders); - - unsigned idx = num_shaders; - for (unsigned i = 0; i < num_shaders; i++) { - memcpy(&linking_shaders[idx], shader_list[i]->builtins_to_link, - sizeof(linking_shaders[0]) * shader_list[i]->num_builtins_to_link); - idx += shader_list[i]->num_builtins_to_link; - } - - assert(idx == num_linking_shaders); - - if (!link_function_calls(prog, linked, linking_shaders, - num_linking_shaders)) { - ctx->Driver.DeleteShader(ctx, linked); - linked = NULL; - } - - free(linking_shaders); - -#ifdef DEBUG - /* At this point linked should contain all of the linked IR, so - * validate it to make sure nothing went wrong. - */ - if (linked) - validate_ir_tree(linked->ir); -#endif - - /* Make a pass over all variable declarations to ensure that arrays with - * unspecified sizes have a size specified. The size is inferred from the - * max_array_access field. - */ - if (linked != NULL) { - class array_sizing_visitor : public ir_hierarchical_visitor { - public: - virtual ir_visitor_status visit(ir_variable *var) - { - if (var->type->is_array() && (var->type->length == 0)) { - const glsl_type *type = - glsl_type::get_array_instance(var->type->fields.array, - var->max_array_access + 1); - - assert(type != NULL); - var->type = type; - } - - return visit_continue; - } - } v; - - v.run(linked->ir); - } - - return linked; -} - -/** - * Update the sizes of linked shader uniform arrays to the maximum - * array index used. - * - * From page 81 (page 95 of the PDF) of the OpenGL 2.1 spec: - * - * If one or more elements of an array are active, - * GetActiveUniform will return the name of the array in name, - * subject to the restrictions listed above. The type of the array - * is returned in type. The size parameter contains the highest - * array element index used, plus one. The compiler or linker - * determines the highest index used. There will be only one - * active uniform reported by the GL per uniform array. - - */ -static void -update_array_sizes(struct gl_shader_program *prog) -{ - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - foreach_list(node, prog->_LinkedShaders[i]->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_uniform && - var->mode != ir_var_in && - var->mode != ir_var_out) || - !var->type->is_array()) - continue; - - unsigned int size = var->max_array_access; - for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) { - if (prog->_LinkedShaders[j] == NULL) - continue; - - foreach_list(node2, prog->_LinkedShaders[j]->ir) { - ir_variable *other_var = ((ir_instruction *) node2)->as_variable(); - if (!other_var) - continue; - - if (strcmp(var->name, other_var->name) == 0 && - other_var->max_array_access > size) { - size = other_var->max_array_access; - } - } - } - - if (size + 1 != var->type->fields.array->length) { - /* If this is a built-in uniform (i.e., it's backed by some - * fixed-function state), adjust the number of state slots to - * match the new array size. The number of slots per array entry - * is not known. It seems safe to assume that the total number of - * slots is an integer multiple of the number of array elements. - * Determine the number of slots per array element by dividing by - * the old (total) size. - */ - if (var->num_state_slots > 0) { - var->num_state_slots = (size + 1) - * (var->num_state_slots / var->type->length); - } - - var->type = glsl_type::get_array_instance(var->type->fields.array, - size + 1); - /* FINISHME: We should update the types of array - * dereferences of this variable now. - */ - } - } - } -} - -/** - * Find a contiguous set of available bits in a bitmask. - * - * \param used_mask Bits representing used (1) and unused (0) locations - * \param needed_count Number of contiguous bits needed. - * - * \return - * Base location of the available bits on success or -1 on failure. - */ -int -find_available_slots(unsigned used_mask, unsigned needed_count) -{ - unsigned needed_mask = (1 << needed_count) - 1; - const int max_bit_to_test = (8 * sizeof(used_mask)) - needed_count; - - /* The comparison to 32 is redundant, but without it GCC emits "warning: - * cannot optimize possibly infinite loops" for the loop below. - */ - if ((needed_count == 0) || (max_bit_to_test < 0) || (max_bit_to_test > 32)) - return -1; - - for (int i = 0; i <= max_bit_to_test; i++) { - if ((needed_mask & ~used_mask) == needed_mask) - return i; - - needed_mask <<= 1; - } - - return -1; -} - - -/** - * Assign locations for either VS inputs for FS outputs - * - * \param prog Shader program whose variables need locations assigned - * \param target_index Selector for the program target to receive location - * assignmnets. Must be either \c MESA_SHADER_VERTEX or - * \c MESA_SHADER_FRAGMENT. - * \param max_index Maximum number of generic locations. This corresponds - * to either the maximum number of draw buffers or the - * maximum number of generic attributes. - * - * \return - * If locations are successfully assigned, true is returned. Otherwise an - * error is emitted to the shader link log and false is returned. - */ -bool -assign_attribute_or_color_locations(gl_shader_program *prog, - unsigned target_index, - unsigned max_index) -{ - /* Mark invalid locations as being used. - */ - unsigned used_locations = (max_index >= 32) - ? ~0 : ~((1 << max_index) - 1); - - assert((target_index == MESA_SHADER_VERTEX) - || (target_index == MESA_SHADER_FRAGMENT)); - - gl_shader *const sh = prog->_LinkedShaders[target_index]; - if (sh == NULL) - return true; - - /* Operate in a total of four passes. - * - * 1. Invalidate the location assignments for all vertex shader inputs. - * - * 2. Assign locations for inputs that have user-defined (via - * glBindVertexAttribLocation) locations and outputs that have - * user-defined locations (via glBindFragDataLocation). - * - * 3. Sort the attributes without assigned locations by number of slots - * required in decreasing order. Fragmentation caused by attribute - * locations assigned by the application may prevent large attributes - * from having enough contiguous space. - * - * 4. Assign locations to any inputs without assigned locations. - */ - - const int generic_base = (target_index == MESA_SHADER_VERTEX) - ? (int) VERT_ATTRIB_GENERIC0 : (int) FRAG_RESULT_DATA0; - - const enum ir_variable_mode direction = - (target_index == MESA_SHADER_VERTEX) ? ir_var_in : ir_var_out; - - - link_invalidate_variable_locations(sh, direction, generic_base); - - /* Temporary storage for the set of attributes that need locations assigned. - */ - struct temp_attr { - unsigned slots; - ir_variable *var; - - /* Used below in the call to qsort. */ - static int compare(const void *a, const void *b) - { - const temp_attr *const l = (const temp_attr *) a; - const temp_attr *const r = (const temp_attr *) b; - - /* Reversed because we want a descending order sort below. */ - return r->slots - l->slots; - } - } to_assign[16]; - - unsigned num_attr = 0; - - foreach_list(node, sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != (unsigned) direction)) - continue; - - if (target_index == MESA_SHADER_VERTEX) { - unsigned binding; - - if (prog->AttributeBindings->get(binding, var->name)) { - assert(binding >= VERT_ATTRIB_GENERIC0); - var->location = binding; - } - } else if (target_index == MESA_SHADER_FRAGMENT) { - unsigned binding; - - if (prog->FragDataBindings->get(binding, var->name)) { - assert(binding >= FRAG_RESULT_DATA0); - var->location = binding; - } - } - - /* If the variable is not a built-in and has a location statically - * assigned in the shader (presumably via a layout qualifier), make sure - * that it doesn't collide with other assigned locations. Otherwise, - * add it to the list of variables that need linker-assigned locations. - */ - const unsigned slots = count_attribute_slots(var->type); - if (var->location != -1) { - if (var->location >= generic_base) { - /* From page 61 of the OpenGL 4.0 spec: - * - * "LinkProgram will fail if the attribute bindings assigned - * by BindAttribLocation do not leave not enough space to - * assign a location for an active matrix attribute or an - * active attribute array, both of which require multiple - * contiguous generic attributes." - * - * Previous versions of the spec contain similar language but omit - * the bit about attribute arrays. - * - * Page 61 of the OpenGL 4.0 spec also says: - * - * "It is possible for an application to bind more than one - * attribute name to the same location. This is referred to as - * aliasing. This will only work if only one of the aliased - * attributes is active in the executable program, or if no - * path through the shader consumes more than one attribute of - * a set of attributes aliased to the same location. A link - * error can occur if the linker determines that every path - * through the shader consumes multiple aliased attributes, - * but implementations are not required to generate an error - * in this case." - * - * These two paragraphs are either somewhat contradictory, or I - * don't fully understand one or both of them. - */ - /* FINISHME: The code as currently written does not support - * FINISHME: attribute location aliasing (see comment above). - */ - /* Mask representing the contiguous slots that will be used by - * this attribute. - */ - const unsigned attr = var->location - generic_base; - const unsigned use_mask = (1 << slots) - 1; - - /* Generate a link error if the set of bits requested for this - * attribute overlaps any previously allocated bits. - */ - if ((~(use_mask << attr) & used_locations) != used_locations) { - linker_error(prog, - "insufficient contiguous attribute locations " - "available for vertex shader input `%s'", - var->name); - return false; - } - - used_locations |= (use_mask << attr); - } - - continue; - } - - to_assign[num_attr].slots = slots; - to_assign[num_attr].var = var; - num_attr++; - } - - /* If all of the attributes were assigned locations by the application (or - * are built-in attributes with fixed locations), return early. This should - * be the common case. - */ - if (num_attr == 0) - return true; - - qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare); - - if (target_index == MESA_SHADER_VERTEX) { - /* VERT_ATTRIB_GENERIC0 is a pseudo-alias for VERT_ATTRIB_POS. It can - * only be explicitly assigned by via glBindAttribLocation. Mark it as - * reserved to prevent it from being automatically allocated below. - */ - find_deref_visitor find("gl_Vertex"); - find.run(sh->ir); - if (find.variable_found()) - used_locations |= (1 << 0); - } - - for (unsigned i = 0; i < num_attr; i++) { - /* Mask representing the contiguous slots that will be used by this - * attribute. - */ - const unsigned use_mask = (1 << to_assign[i].slots) - 1; - - int location = find_available_slots(used_locations, to_assign[i].slots); - - if (location < 0) { - const char *const string = (target_index == MESA_SHADER_VERTEX) - ? "vertex shader input" : "fragment shader output"; - - linker_error(prog, - "insufficient contiguous attribute locations " - "available for %s `%s'", - string, to_assign[i].var->name); - return false; - } - - to_assign[i].var->location = generic_base + location; - used_locations |= (use_mask << location); - } - - return true; -} - - -/** - * Demote shader inputs and outputs that are not used in other stages - */ -void -demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode) -{ - foreach_list(node, sh->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != int(mode))) - continue; - - /* A shader 'in' or 'out' variable is only really an input or output if - * its value is used by other shader stages. This will cause the variable - * to have a location assigned. - */ - if (var->location == -1) { - var->mode = ir_var_auto; - } - } -} - - -/** - * Assign a location for a variable that is produced in one pipeline stage - * (the "producer") and consumed in the next stage (the "consumer"). - * - * \param input_var is the input variable declaration in the consumer. - * - * \param output_var is the output variable declaration in the producer. - * - * \param input_index is the counter that keeps track of assigned input - * locations in the consumer. - * - * \param output_index is the counter that keeps track of assigned output - * locations in the producer. - * - * It is permissible for \c input_var to be NULL (this happens if a variable - * is output by the producer and consumed by transform feedback, but not - * consumed by the consumer). - * - * If the variable has already been assigned a location, this function has no - * effect. - */ -void -assign_varying_location(ir_variable *input_var, ir_variable *output_var, - unsigned *input_index, unsigned *output_index) -{ - if (output_var->location != -1) { - /* Location already assigned. */ - return; - } - - if (input_var) { - assert(input_var->location == -1); - input_var->location = *input_index; - } - - output_var->location = *output_index; - - /* FINISHME: Support for "varying" records in GLSL 1.50. */ - assert(!output_var->type->is_record()); - - if (output_var->type->is_array()) { - const unsigned slots = output_var->type->length - * output_var->type->fields.array->matrix_columns; - - *output_index += slots; - *input_index += slots; - } else { - const unsigned slots = output_var->type->matrix_columns; - - *output_index += slots; - *input_index += slots; - } -} - - -/** - * Assign locations for all variables that are produced in one pipeline stage - * (the "producer") and consumed in the next stage (the "consumer"). - * - * Variables produced by the producer may also be consumed by transform - * feedback. - * - * When num_tfeedback_decls is nonzero, it is permissible for the consumer to - * be NULL. In this case, varying locations are assigned solely based on the - * requirements of transform feedback. - */ -bool -assign_varying_locations(struct gl_context *ctx, - struct gl_shader_program *prog, - gl_shader *producer, gl_shader *consumer) -{ - /* FINISHME: Set dynamically when geometry shader support is added. */ - unsigned output_index = VERT_RESULT_VAR0; - unsigned input_index = FRAG_ATTRIB_VAR0; - - /* Operate in a total of three passes. - * - * 1. Assign locations for any matching inputs and outputs. - * - * 2. Mark output variables in the producer that do not have locations as - * not being outputs. This lets the optimizer eliminate them. - * - * 3. Mark input variables in the consumer that do not have locations as - * not being inputs. This lets the optimizer eliminate them. - */ - - link_invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0); - if (consumer) - link_invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0); - - foreach_list(node, producer->ir) { - ir_variable *const output_var = ((ir_instruction *) node)->as_variable(); - - if ((output_var == NULL) || (output_var->mode != ir_var_out)) - continue; - - ir_variable *input_var = - consumer ? consumer->symbols->get_variable(output_var->name) : NULL; - - if (input_var && input_var->mode != ir_var_in) - input_var = NULL; - - if (input_var) { - assign_varying_location(input_var, output_var, &input_index, - &output_index); - } - } - - unsigned varying_vectors = 0; - - if (consumer) { - foreach_list(node, consumer->ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_in)) - continue; - - if (var->location == -1) { - if (prog->Version <= 120) { - /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec: - * - * Only those varying variables used (i.e. read) in - * the fragment shader executable must be written to - * by the vertex shader executable; declaring - * superfluous varying variables in a vertex shader is - * permissible. - * - * We interpret this text as meaning that the VS must - * write the variable for the FS to read it. See - * "glsl1-varying read but not written" in piglit. - */ - - linker_error(prog, "fragment shader varying %s not written " - "by vertex shader\n.", var->name); - } - - /* An 'in' variable is only really a shader input if its - * value is written by the previous stage. - */ - var->mode = ir_var_auto; - } else { - /* The packing rules are used for vertex shader inputs are also - * used for fragment shader inputs. - */ - varying_vectors += count_attribute_slots(var->type); - } - } - } - - if (prog->Version == 100) { - if (varying_vectors > ctx->Const.MaxVarying) { - if (ctx->Const.GLSLSkipStrictMaxVaryingLimitCheck) { - linker_warning(prog, "shader uses too many varying vectors " - "(%u > %u), but the driver will try to optimize " - "them out; this is non-portable out-of-spec " - "behavior\n", - varying_vectors, ctx->Const.MaxVarying); - } else { - linker_error(prog, "shader uses too many varying vectors " - "(%u > %u)\n", - varying_vectors, ctx->Const.MaxVarying); - return false; - } - } - } else { - const unsigned float_components = varying_vectors * 4; - if (float_components > ctx->Const.MaxVarying * 4) { - if (ctx->Const.GLSLSkipStrictMaxVaryingLimitCheck) { - linker_warning(prog, "shader uses too many varying components " - "(%u > %u), but the driver will try to optimize " - "them out; this is non-portable out-of-spec " - "behavior\n", - float_components, ctx->Const.MaxVarying * 4); - } else { - linker_error(prog, "shader uses too many varying components " - "(%u > %u)\n", - float_components, ctx->Const.MaxVarying * 4); - return false; - } - } - } - - return true; -} - -/** - * Store the gl_FragDepth layout in the gl_shader_program struct. - */ -static void -store_fragdepth_layout(struct gl_shader_program *prog) -{ - if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) { - return; - } - - struct exec_list *ir = prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir; - - /* We don't look up the gl_FragDepth symbol directly because if - * gl_FragDepth is not used in the shader, it's removed from the IR. - * However, the symbol won't be removed from the symbol table. - * - * We're only interested in the cases where the variable is NOT removed - * from the IR. - */ - foreach_list(node, ir) { - ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if (var == NULL || var->mode != ir_var_out) { - continue; - } - - if (strcmp(var->name, "gl_FragDepth") == 0) { - switch (var->depth_layout) { - case ir_depth_layout_none: - prog->FragDepthLayout = FRAG_DEPTH_LAYOUT_NONE; - return; - case ir_depth_layout_any: - prog->FragDepthLayout = FRAG_DEPTH_LAYOUT_ANY; - return; - case ir_depth_layout_greater: - prog->FragDepthLayout = FRAG_DEPTH_LAYOUT_GREATER; - return; - case ir_depth_layout_less: - prog->FragDepthLayout = FRAG_DEPTH_LAYOUT_LESS; - return; - case ir_depth_layout_unchanged: - prog->FragDepthLayout = FRAG_DEPTH_LAYOUT_UNCHANGED; - return; - default: - assert(0); - return; - } - } - } -} - -/** - * Validate the resources used by a program versus the implementation limits - */ -static bool -check_resources(struct gl_context *ctx, struct gl_shader_program *prog) -{ - static const char *const shader_names[MESA_SHADER_TYPES] = { - "vertex", "fragment" - }; - - const unsigned max_samplers[MESA_SHADER_TYPES] = { - ctx->Const.MaxVertexTextureImageUnits, - ctx->Const.MaxTextureImageUnits - }; - - const unsigned max_uniform_components[MESA_SHADER_TYPES] = { - ctx->Const.VertexProgram.MaxUniformComponents, - ctx->Const.FragmentProgram.MaxUniformComponents - }; - - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - struct gl_shader *sh = prog->_LinkedShaders[i]; - - if (sh == NULL) - continue; - - if (sh->num_samplers > max_samplers[i]) { - linker_error(prog, "Too many %s shader texture samplers", - shader_names[i]); - } - - if (sh->num_uniform_components > max_uniform_components[i]) { - if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) { - linker_warning(prog, "Too many %s shader uniform components, " - "but the driver will try to optimize them out; " - "this is non-portable out-of-spec behavior\n", - shader_names[i]); - } else { - linker_error(prog, "Too many %s shader uniform components", - shader_names[i]); - } - } - } - - return prog->LinkStatus; -} - -void -link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) -{ - void *mem_ctx = ralloc_context(NULL); // temporary linker context - - prog->LinkStatus = false; - prog->Validated = false; - prog->_Used = false; - - if (prog->InfoLog != NULL) - ralloc_free(prog->InfoLog); - - prog->InfoLog = ralloc_strdup(NULL, ""); - - /* Separate the shaders into groups based on their type. - */ - struct gl_shader **vert_shader_list; - unsigned num_vert_shaders = 0; - struct gl_shader **frag_shader_list; - unsigned num_frag_shaders = 0; - - vert_shader_list = (struct gl_shader **) - calloc(2 * prog->NumShaders, sizeof(struct gl_shader *)); - frag_shader_list = &vert_shader_list[prog->NumShaders]; - - unsigned min_version = UINT_MAX; - unsigned max_version = 0; - for (unsigned i = 0; i < prog->NumShaders; i++) { - min_version = MIN2(min_version, prog->Shaders[i]->Version); - max_version = MAX2(max_version, prog->Shaders[i]->Version); - - switch (prog->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - vert_shader_list[num_vert_shaders] = prog->Shaders[i]; - num_vert_shaders++; - break; - case GL_FRAGMENT_SHADER: - frag_shader_list[num_frag_shaders] = prog->Shaders[i]; - num_frag_shaders++; - break; - } - } - - /* Previous to GLSL version 1.30, different compilation units could mix and - * match shading language versions. With GLSL 1.30 and later, the versions - * of all shaders must match. - */ - assert(min_version >= 100); - assert(max_version <= 130); - if ((max_version >= 130 || min_version == 100) - && min_version != max_version) { - linker_error(prog, "all shaders must use same shading " - "language version\n"); - goto done; - } - - prog->Version = max_version; - - for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] != NULL) - ctx->Driver.DeleteShader(ctx, prog->_LinkedShaders[i]); - - prog->_LinkedShaders[i] = NULL; - } - - /* Link all shaders for a particular stage and validate the result. - */ - if (num_vert_shaders > 0) { - gl_shader *const sh = - link_intrastage_shaders(mem_ctx, ctx, prog, vert_shader_list, - num_vert_shaders); - - if (sh == NULL) - goto done; - - if (!validate_vertex_shader_executable(prog, sh)) - goto done; - - _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_VERTEX], - sh); - } - - if (num_frag_shaders > 0) { - gl_shader *const sh = - link_intrastage_shaders(mem_ctx, ctx, prog, frag_shader_list, - num_frag_shaders); - - if (sh == NULL) - goto done; - - if (!validate_fragment_shader_executable(prog, sh)) - goto done; - - _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_FRAGMENT], - sh); - } - - /* Here begins the inter-stage linking phase. Some initial validation is - * performed, then locations are assigned for uniforms, attributes, and - * varyings. - */ - if (cross_validate_uniforms(prog)) { - unsigned prev; - - for (prev = 0; prev < MESA_SHADER_TYPES; prev++) { - if (prog->_LinkedShaders[prev] != NULL) - break; - } - - /* Validate the inputs of each stage with the output of the preceding - * stage. - */ - for (unsigned i = prev + 1; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - if (!cross_validate_outputs_to_inputs(prog, - prog->_LinkedShaders[prev], - prog->_LinkedShaders[i])) - goto done; - - prev = i; - } - - prog->LinkStatus = true; - } - - /* Do common optimization before assigning storage for attributes, - * uniforms, and varyings. Later optimization could possibly make - * some of that unused. - */ - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - detect_recursion_linked(prog, prog->_LinkedShaders[i]->ir); - if (!prog->LinkStatus) - goto done; - - if (ctx->ShaderCompilerOptions[i].LowerClipDistance) - lower_clip_distance(prog->_LinkedShaders[i]->ir); - - unsigned max_unroll = ctx->ShaderCompilerOptions[i].MaxUnrollIterations; - - while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false, max_unroll)) - ; - } - - /* FINISHME: The value of the max_attribute_index parameter is - * FINISHME: implementation dependent based on the value of - * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be - * FINISHME: at least 16, so hardcode 16 for now. - */ - if (!assign_attribute_or_color_locations(prog, MESA_SHADER_VERTEX, 16)) { - goto done; - } - - if (!assign_attribute_or_color_locations(prog, MESA_SHADER_FRAGMENT, 1)) { - goto done; - } - - unsigned prev; - for (prev = 0; prev < MESA_SHADER_TYPES; prev++) { - if (prog->_LinkedShaders[prev] != NULL) - break; - } - - for (unsigned i = prev + 1; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - if (!assign_varying_locations( - ctx, prog, prog->_LinkedShaders[prev], prog->_LinkedShaders[i])) - goto done; - - prev = i; - } - - if (prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL) { - demote_shader_inputs_and_outputs(prog->_LinkedShaders[MESA_SHADER_VERTEX], - ir_var_out); - - /* Eliminate code that is now dead due to unused vertex outputs being - * demoted. - */ - while (do_dead_code(prog->_LinkedShaders[MESA_SHADER_VERTEX]->ir, false)) - ; - } - - if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] != NULL) { - gl_shader *const sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; - - demote_shader_inputs_and_outputs(sh, ir_var_in); - - /* Eliminate code that is now dead due to unused fragment inputs being - * demoted. This shouldn't actually do anything other than remove - * declarations of the (now unused) global variables. - */ - while (do_dead_code(prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir, false)) - ; - } - - update_array_sizes(prog); - link_assign_uniform_locations(prog); - store_fragdepth_layout(prog); - - if (!check_resources(ctx, prog)) - goto done; - - /* OpenGL ES requires that a vertex shader and a fragment shader both be - * present in a linked program. By checking for use of shading language - * version 1.00, we also catch the GL_ARB_ES2_compatibility case. - */ - if (!prog->InternalSeparateShader && prog->Version == 100) { - if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) { - linker_error(prog, "program lacks a vertex shader\n"); - } else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) { - linker_error(prog, "program lacks a fragment shader\n"); - } - } - - /* FINISHME: Assign fragment shader output locations. */ - -done: - free(vert_shader_list); - - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - /* Retain any live IR, but trash the rest. */ - reparent_ir(prog->_LinkedShaders[i]->ir, prog->_LinkedShaders[i]->ir); - - /* The symbol table in the linked shaders may contain references to - * variables that were removed (e.g., unused uniforms). Since it may - * contain junk, there is no possible valid use. Delete it and set the - * pointer to NULL. - */ - delete prog->_LinkedShaders[i]->symbols; - prog->_LinkedShaders[i]->symbols = NULL; - } - - ralloc_free(mem_ctx); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/linker.h b/reactos/dll/opengl/mesa/src/glsl/linker.h deleted file mode 100644 index 433c63be246..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/linker.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef GLSL_LINKER_H -#define GLSL_LINKER_H - -extern bool -link_function_calls(gl_shader_program *prog, gl_shader *main, - gl_shader **shader_list, unsigned num_shaders); - -extern void -link_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode, - int generic_base); - -extern void -link_assign_uniform_locations(struct gl_shader_program *prog); - -/** - * Class for processing all of the leaf fields of an uniform - * - * Leaves are, roughly speaking, the parts of the uniform that the application - * could query with \c glGetUniformLocation (or that could be returned by - * \c glGetActiveUniforms). - * - * Classes my derive from this class to implement specific functionality. - * This class only provides the mechanism to iterate over the leaves. Derived - * classes must implement \c ::visit_field and may override \c ::process. - */ -class uniform_field_visitor { -public: - /** - * Begin processing a uniform - * - * Classes that overload this function should call \c ::process from the - * base class to start the recursive processing of the uniform. - * - * \param var The uniform variable that is to be processed - * - * Calls \c ::visit_field for each leaf of the uniform. - */ - void process(ir_variable *var); - -protected: - /** - * Method invoked for each leaf of the uniform - * - * \param type Type of the field. - * \param name Fully qualified name of the field. - */ - virtual void visit_field(const glsl_type *type, const char *name) = 0; - -private: - /** - * \param name_length Length of the current name \b not including the - * terminating \c NUL character. - */ - void recursion(const glsl_type *t, char **name, unsigned name_length); -}; - -#endif /* GLSL_LINKER_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/list.h b/reactos/dll/opengl/mesa/src/glsl/list.h deleted file mode 100644 index 1d46365faec..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/list.h +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright © 2008, 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file list.h - * \brief Doubly-linked list abstract container type. - * - * Each doubly-linked list has a sentinel head and tail node. These nodes - * contain no data. The head sentinel can be identified by its \c prev - * pointer being \c NULL. The tail sentinel can be identified by its - * \c next pointer being \c NULL. - * - * A list is empty if either the head sentinel's \c next pointer points to the - * tail sentinel or the tail sentinel's \c prev poiner points to the head - * sentinel. - * - * Instead of tracking two separate \c node structures and a \c list structure - * that points to them, the sentinel nodes are in a single structure. Noting - * that each sentinel node always has one \c NULL pointer, the \c NULL - * pointers occupy the same memory location. In the \c list structure - * contains a the following: - * - * - A \c head pointer that represents the \c next pointer of the - * head sentinel node. - * - A \c tail pointer that represents the \c prev pointer of the head - * sentinel node and the \c next pointer of the tail sentinel node. This - * pointer is \b always \c NULL. - * - A \c tail_prev pointer that represents the \c prev pointer of the - * tail sentinel node. - * - * Therefore, if \c head->next is \c NULL or \c tail_prev->prev is \c NULL, - * the list is empty. - * - * To anyone familiar with "exec lists" on the Amiga, this structure should - * be immediately recognizable. See the following link for the original Amiga - * operating system documentation on the subject. - * - * http://www.natami.net/dev/Libraries_Manual_guide/node02D7.html - * - * \author Ian Romanick - */ - -#pragma once -#ifndef LIST_CONTAINER_H -#define LIST_CONTAINER_H - -#ifndef __cplusplus -#include -#endif -#include - -#include "ralloc.h" - -struct exec_node { - struct exec_node *next; - struct exec_node *prev; - -#ifdef __cplusplus - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = ralloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *node) - { - ralloc_free(node); - } - - exec_node() : next(NULL), prev(NULL) - { - /* empty */ - } - - const exec_node *get_next() const - { - return next; - } - - exec_node *get_next() - { - return next; - } - - const exec_node *get_prev() const - { - return prev; - } - - exec_node *get_prev() - { - return prev; - } - - void remove() - { - next->prev = prev; - prev->next = next; - next = NULL; - prev = NULL; - } - - /** - * Link a node with itself - * - * This creates a sort of degenerate list that is occasionally useful. - */ - void self_link() - { - next = this; - prev = this; - } - - /** - * Insert a node in the list after the current node - */ - void insert_after(exec_node *after) - { - after->next = this->next; - after->prev = this; - - this->next->prev = after; - this->next = after; - } - /** - * Insert a node in the list before the current node - */ - void insert_before(exec_node *before) - { - before->next = this; - before->prev = this->prev; - - this->prev->next = before; - this->prev = before; - } - - /** - * Insert another list in the list before the current node - */ - void insert_before(struct exec_list *before); - - /** - * Replace the current node with the given node. - */ - void replace_with(exec_node *replacement) - { - replacement->prev = this->prev; - replacement->next = this->next; - - this->prev->next = replacement; - this->next->prev = replacement; - } - - /** - * Is this the sentinel at the tail of the list? - */ - bool is_tail_sentinel() const - { - return this->next == NULL; - } - - /** - * Is this the sentinel at the head of the list? - */ - bool is_head_sentinel() const - { - return this->prev == NULL; - } -#endif -}; - - -#ifdef __cplusplus -/* This macro will not work correctly if `t' uses virtual inheritance. If you - * are using virtual inheritance, you deserve a slow and painful death. Enjoy! - */ -#define exec_list_offsetof(t, f, p) \ - (((char *) &((t *) p)->f) - ((char *) p)) -#else -#define exec_list_offsetof(t, f, p) offsetof(t, f) -#endif - -/** - * Get a pointer to the structure containing an exec_node - * - * Given a pointer to an \c exec_node embedded in a structure, get a pointer to - * the containing structure. - * - * \param type Base type of the structure containing the node - * \param node Pointer to the \c exec_node - * \param field Name of the field in \c type that is the embedded \c exec_node - */ -#define exec_node_data(type, node, field) \ - ((type *) (((char *) node) - exec_list_offsetof(type, field, node))) - -#ifdef __cplusplus -struct exec_node; - -class iterator { -public: - void next() - { - } - - void *get() - { - return NULL; - } - - bool has_next() const - { - return false; - } -}; - -class exec_list_iterator : public iterator { -public: - exec_list_iterator(exec_node *n) : node(n), _next(n->next) - { - /* empty */ - } - - void next() - { - node = _next; - _next = node->next; - } - - void remove() - { - node->remove(); - } - - exec_node *get() - { - return node; - } - - bool has_next() const - { - return _next != NULL; - } - -private: - exec_node *node; - exec_node *_next; -}; - -#define foreach_iter(iter_type, iter, container) \ - for (iter_type iter = (container) . iterator(); iter.has_next(); iter.next()) -#endif - - -struct exec_list { - struct exec_node *head; - struct exec_node *tail; - struct exec_node *tail_pred; - -#ifdef __cplusplus - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = ralloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - /* If the user *does* call delete, that's OK, we will just - * ralloc_free in that case. */ - static void operator delete(void *node) - { - ralloc_free(node); - } - - exec_list() - { - make_empty(); - } - - void make_empty() - { - head = (exec_node *) & tail; - tail = NULL; - tail_pred = (exec_node *) & head; - } - - bool is_empty() const - { - /* There are three ways to test whether a list is empty or not. - * - * - Check to see if the \c head points to the \c tail. - * - Check to see if the \c tail_pred points to the \c head. - * - Check to see if the \c head is the sentinel node by test whether its - * \c next pointer is \c NULL. - * - * The first two methods tend to generate better code on modern systems - * because they save a pointer dereference. - */ - return head == (exec_node *) &tail; - } - - const exec_node *get_head() const - { - return !is_empty() ? head : NULL; - } - - exec_node *get_head() - { - return !is_empty() ? head : NULL; - } - - const exec_node *get_tail() const - { - return !is_empty() ? tail_pred : NULL; - } - - exec_node *get_tail() - { - return !is_empty() ? tail_pred : NULL; - } - - void push_head(exec_node *n) - { - n->next = head; - n->prev = (exec_node *) &head; - - n->next->prev = n; - head = n; - } - - void push_tail(exec_node *n) - { - n->next = (exec_node *) &tail; - n->prev = tail_pred; - - n->prev->next = n; - tail_pred = n; - } - - void push_degenerate_list_at_head(exec_node *n) - { - assert(n->prev->next == n); - - n->prev->next = head; - head->prev = n->prev; - n->prev = (exec_node *) &head; - head = n; - } - - /** - * Remove the first node from a list and return it - * - * \return - * The first node in the list or \c NULL if the list is empty. - * - * \sa exec_list::get_head - */ - exec_node *pop_head() - { - exec_node *const n = this->get_head(); - if (n != NULL) - n->remove(); - - return n; - } - - /** - * Move all of the nodes from this list to the target list - */ - void move_nodes_to(exec_list *target) - { - if (is_empty()) { - target->make_empty(); - } else { - target->head = head; - target->tail = NULL; - target->tail_pred = tail_pred; - - target->head->prev = (exec_node *) &target->head; - target->tail_pred->next = (exec_node *) &target->tail; - - make_empty(); - } - } - - /** - * Append all nodes from the source list to the target list - */ - void - append_list(exec_list *source) - { - if (source->is_empty()) - return; - - /* Link the first node of the source with the last node of the target list. - */ - this->tail_pred->next = source->head; - source->head->prev = this->tail_pred; - - /* Make the tail of the source list be the tail of the target list. - */ - this->tail_pred = source->tail_pred; - this->tail_pred->next = (exec_node *) &this->tail; - - /* Make the source list empty for good measure. - */ - source->make_empty(); - } - - exec_list_iterator iterator() - { - return exec_list_iterator(head); - } - - exec_list_iterator iterator() const - { - return exec_list_iterator((exec_node *) head); - } -#endif -}; - - -#ifdef __cplusplus -inline void exec_node::insert_before(exec_list *before) -{ - if (before->is_empty()) - return; - - before->tail_pred->next = this; - before->head->prev = this->prev; - - this->prev->next = before->head; - this->prev = before->tail_pred; - - before->make_empty(); -} -#endif - -/** - * This version is safe even if the current node is removed. - */ -#define foreach_list_safe(__node, __list) \ - for (exec_node * __node = (__list)->head, * __next = __node->next \ - ; __next != NULL \ - ; __node = __next, __next = __next->next) - -#define foreach_list(__node, __list) \ - for (exec_node * __node = (__list)->head \ - ; (__node)->next != NULL \ - ; (__node) = (__node)->next) - -#define foreach_list_const(__node, __list) \ - for (const exec_node * __node = (__list)->head \ - ; (__node)->next != NULL \ - ; (__node) = (__node)->next) - -#define foreach_list_typed(__type, __node, __field, __list) \ - for (__type * __node = \ - exec_node_data(__type, (__list)->head, __field); \ - (__node)->__field.next != NULL; \ - (__node) = exec_node_data(__type, (__node)->__field.next, __field)) - -#define foreach_list_typed_const(__type, __node, __field, __list) \ - for (const __type * __node = \ - exec_node_data(__type, (__list)->head, __field); \ - (__node)->__field.next != NULL; \ - (__node) = exec_node_data(__type, (__node)->__field.next, __field)) - -#endif /* LIST_CONTAINER_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/loop_analysis.cpp b/reactos/dll/opengl/mesa/src/glsl/loop_analysis.cpp deleted file mode 100644 index 6a0e4da5100..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/loop_analysis.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "glsl_types.h" -#include "loop_analysis.h" -#include "ir_hierarchical_visitor.h" - -static bool is_loop_terminator(ir_if *ir); - -static bool all_expression_operands_are_loop_constant(ir_rvalue *, - hash_table *); - -static ir_rvalue *get_basic_induction_increment(ir_assignment *, hash_table *); - - -loop_state::loop_state() -{ - this->ht = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - this->mem_ctx = ralloc_context(NULL); - this->loop_found = false; -} - - -loop_state::~loop_state() -{ - hash_table_dtor(this->ht); - ralloc_free(this->mem_ctx); -} - - -loop_variable_state * -loop_state::insert(ir_loop *ir) -{ - loop_variable_state *ls = new(this->mem_ctx) loop_variable_state; - - hash_table_insert(this->ht, ls, ir); - this->loop_found = true; - - return ls; -} - - -loop_variable_state * -loop_state::get(const ir_loop *ir) -{ - return (loop_variable_state *) hash_table_find(this->ht, ir); -} - - -loop_variable * -loop_variable_state::get(const ir_variable *ir) -{ - return (loop_variable *) hash_table_find(this->var_hash, ir); -} - - -loop_variable * -loop_variable_state::insert(ir_variable *var) -{ - void *mem_ctx = ralloc_parent(this); - loop_variable *lv = rzalloc(mem_ctx, loop_variable); - - lv->var = var; - - hash_table_insert(this->var_hash, lv, lv->var); - this->variables.push_tail(lv); - - return lv; -} - - -loop_terminator * -loop_variable_state::insert(ir_if *if_stmt) -{ - void *mem_ctx = ralloc_parent(this); - loop_terminator *t = rzalloc(mem_ctx, loop_terminator); - - t->ir = if_stmt; - this->terminators.push_tail(t); - - return t; -} - - -class loop_analysis : public ir_hierarchical_visitor { -public: - loop_analysis(); - - virtual ir_visitor_status visit(ir_loop_jump *); - virtual ir_visitor_status visit(ir_dereference_variable *); - - virtual ir_visitor_status visit_enter(ir_call *); - - virtual ir_visitor_status visit_enter(ir_loop *); - virtual ir_visitor_status visit_leave(ir_loop *); - virtual ir_visitor_status visit_enter(ir_assignment *); - virtual ir_visitor_status visit_leave(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_if *); - virtual ir_visitor_status visit_leave(ir_if *); - - loop_state *loops; - - int if_statement_depth; - - ir_assignment *current_assignment; - - exec_list state; -}; - - -loop_analysis::loop_analysis() -{ - this->loops = new loop_state; - - this->if_statement_depth = 0; - this->current_assignment = NULL; -} - - -ir_visitor_status -loop_analysis::visit(ir_loop_jump *ir) -{ - (void) ir; - - assert(!this->state.is_empty()); - - loop_variable_state *const ls = - (loop_variable_state *) this->state.get_head(); - - ls->num_loop_jumps++; - - return visit_continue; -} - - -ir_visitor_status -loop_analysis::visit_enter(ir_call *ir) -{ - /* If we're not somewhere inside a loop, there's nothing to do. */ - if (this->state.is_empty()) - return visit_continue; - - loop_variable_state *const ls = - (loop_variable_state *) this->state.get_head(); - - ls->contains_calls = true; - return visit_continue_with_parent; -} - - -ir_visitor_status -loop_analysis::visit(ir_dereference_variable *ir) -{ - /* If we're not somewhere inside a loop, there's nothing to do. - */ - if (this->state.is_empty()) - return visit_continue; - - loop_variable_state *const ls = - (loop_variable_state *) this->state.get_head(); - - ir_variable *var = ir->variable_referenced(); - loop_variable *lv = ls->get(var); - - if (lv == NULL) { - lv = ls->insert(var); - lv->read_before_write = !this->in_assignee; - } - - if (this->in_assignee) { - assert(this->current_assignment != NULL); - - lv->conditional_assignment = (this->if_statement_depth > 0) - || (this->current_assignment->condition != NULL); - - if (lv->first_assignment == NULL) { - assert(lv->num_assignments == 0); - - lv->first_assignment = this->current_assignment; - } - - lv->num_assignments++; - } else if (lv->first_assignment == this->current_assignment) { - /* This catches the case where the variable is used in the RHS of an - * assignment where it is also in the LHS. - */ - lv->read_before_write = true; - } - - return visit_continue; -} - -ir_visitor_status -loop_analysis::visit_enter(ir_loop *ir) -{ - loop_variable_state *ls = this->loops->insert(ir); - this->state.push_head(ls); - - return visit_continue; -} - -ir_visitor_status -loop_analysis::visit_leave(ir_loop *ir) -{ - loop_variable_state *const ls = - (loop_variable_state *) this->state.pop_head(); - - /* Function calls may contain side effects. These could alter any of our - * variables in ways that cannot be known, and may even terminate shader - * execution (say, calling discard in the fragment shader). So we can't - * rely on any of our analysis about assignments to variables. - * - * We could perform some conservative analysis (prove there's no statically - * possible assignment, etc.) but it isn't worth it for now; function - * inlining will allow us to unroll loops anyway. - */ - if (ls->contains_calls) - return visit_continue; - - foreach_list(node, &ir->body_instructions) { - /* Skip over declarations at the start of a loop. - */ - if (((ir_instruction *) node)->as_variable()) - continue; - - ir_if *if_stmt = ((ir_instruction *) node)->as_if(); - - if ((if_stmt != NULL) && is_loop_terminator(if_stmt)) - ls->insert(if_stmt); - else - break; - } - - - foreach_list_safe(node, &ls->variables) { - loop_variable *lv = (loop_variable *) node; - - /* Move variables that are already marked as being loop constant to - * a separate list. These trivially don't need to be tested. - */ - if (lv->is_loop_constant()) { - lv->remove(); - ls->constants.push_tail(lv); - } - } - - /* Each variable assigned in the loop that isn't already marked as being loop - * constant might still be loop constant. The requirements at this point - * are: - * - * - Variable is written before it is read. - * - * - Only one assignment to the variable. - * - * - All operands on the RHS of the assignment are also loop constants. - * - * The last requirement is the reason for the progress loop. A variable - * marked as a loop constant on one pass may allow other variables to be - * marked as loop constant on following passes. - */ - bool progress; - do { - progress = false; - - foreach_list_safe(node, &ls->variables) { - loop_variable *lv = (loop_variable *) node; - - if (lv->conditional_assignment || (lv->num_assignments > 1)) - continue; - - /* Process the RHS of the assignment. If all of the variables - * accessed there are loop constants, then add this - */ - ir_rvalue *const rhs = lv->first_assignment->rhs; - if (all_expression_operands_are_loop_constant(rhs, ls->var_hash)) { - lv->rhs_clean = true; - - if (lv->is_loop_constant()) { - progress = true; - - lv->remove(); - ls->constants.push_tail(lv); - } - } - } - } while (progress); - - /* The remaining variables that are not loop invariant might be loop - * induction variables. - */ - foreach_list_safe(node, &ls->variables) { - loop_variable *lv = (loop_variable *) node; - - /* If there is more than one assignment to a variable, it cannot be a - * loop induction variable. This isn't strictly true, but this is a - * very simple induction variable detector, and it can't handle more - * complex cases. - */ - if (lv->num_assignments > 1) - continue; - - /* All of the variables with zero assignments in the loop are loop - * invariant, and they should have already been filtered out. - */ - assert(lv->num_assignments == 1); - assert(lv->first_assignment != NULL); - - /* The assignmnet to the variable in the loop must be unconditional. - */ - if (lv->conditional_assignment) - continue; - - /* Basic loop induction variables have a single assignment in the loop - * that has the form 'VAR = VAR + i' or 'VAR = VAR - i' where i is a - * loop invariant. - */ - ir_rvalue *const inc = - get_basic_induction_increment(lv->first_assignment, ls->var_hash); - if (inc != NULL) { - lv->iv_scale = NULL; - lv->biv = lv->var; - lv->increment = inc; - - lv->remove(); - ls->induction_variables.push_tail(lv); - } - } - - return visit_continue; -} - -ir_visitor_status -loop_analysis::visit_enter(ir_if *ir) -{ - (void) ir; - - if (!this->state.is_empty()) - this->if_statement_depth++; - - return visit_continue; -} - -ir_visitor_status -loop_analysis::visit_leave(ir_if *ir) -{ - (void) ir; - - if (!this->state.is_empty()) - this->if_statement_depth--; - - return visit_continue; -} - -ir_visitor_status -loop_analysis::visit_enter(ir_assignment *ir) -{ - /* If we're not somewhere inside a loop, there's nothing to do. - */ - if (this->state.is_empty()) - return visit_continue_with_parent; - - this->current_assignment = ir; - - return visit_continue; -} - -ir_visitor_status -loop_analysis::visit_leave(ir_assignment *ir) -{ - /* Since the visit_enter exits with visit_continue_with_parent for this - * case, the loop state stack should never be empty here. - */ - assert(!this->state.is_empty()); - - assert(this->current_assignment == ir); - this->current_assignment = NULL; - - return visit_continue; -} - - -class examine_rhs : public ir_hierarchical_visitor { -public: - examine_rhs(hash_table *loop_variables) - { - this->only_uses_loop_constants = true; - this->loop_variables = loop_variables; - } - - virtual ir_visitor_status visit(ir_dereference_variable *ir) - { - loop_variable *lv = - (loop_variable *) hash_table_find(this->loop_variables, ir->var); - - assert(lv != NULL); - - if (lv->is_loop_constant()) { - return visit_continue; - } else { - this->only_uses_loop_constants = false; - return visit_stop; - } - } - - hash_table *loop_variables; - bool only_uses_loop_constants; -}; - - -bool -all_expression_operands_are_loop_constant(ir_rvalue *ir, hash_table *variables) -{ - examine_rhs v(variables); - - ir->accept(&v); - - return v.only_uses_loop_constants; -} - - -ir_rvalue * -get_basic_induction_increment(ir_assignment *ir, hash_table *var_hash) -{ - /* The RHS must be a binary expression. - */ - ir_expression *const rhs = ir->rhs->as_expression(); - if ((rhs == NULL) - || ((rhs->operation != ir_binop_add) - && (rhs->operation != ir_binop_sub))) - return NULL; - - /* One of the of operands of the expression must be the variable assigned. - * If the operation is subtraction, the variable in question must be the - * "left" operand. - */ - ir_variable *const var = ir->lhs->variable_referenced(); - - ir_variable *const op0 = rhs->operands[0]->variable_referenced(); - ir_variable *const op1 = rhs->operands[1]->variable_referenced(); - - if (((op0 != var) && (op1 != var)) - || ((op1 == var) && (rhs->operation == ir_binop_sub))) - return NULL; - - ir_rvalue *inc = (op0 == var) ? rhs->operands[1] : rhs->operands[0]; - - if (inc->as_constant() == NULL) { - ir_variable *const inc_var = inc->variable_referenced(); - if (inc_var != NULL) { - loop_variable *lv = - (loop_variable *) hash_table_find(var_hash, inc_var); - - if (!lv->is_loop_constant()) - inc = NULL; - } else - inc = NULL; - } - - if ((inc != NULL) && (rhs->operation == ir_binop_sub)) { - void *mem_ctx = ralloc_parent(ir); - - inc = new(mem_ctx) ir_expression(ir_unop_neg, - inc->type, - inc->clone(mem_ctx, NULL), - NULL); - } - - return inc; -} - - -/** - * Detect whether an if-statement is a loop terminating condition - * - * Detects if-statements of the form - * - * (if (expression bool ...) (break)) - */ -bool -is_loop_terminator(ir_if *ir) -{ - if (!ir->else_instructions.is_empty()) - return false; - - ir_instruction *const inst = - (ir_instruction *) ir->then_instructions.get_head(); - assert(inst != NULL); - - if (inst->ir_type != ir_type_loop_jump) - return false; - - ir_loop_jump *const jump = (ir_loop_jump *) inst; - if (jump->mode != ir_loop_jump::jump_break) - return false; - - return true; -} - - -loop_state * -analyze_loop_variables(exec_list *instructions) -{ - loop_analysis v; - - v.run(instructions); - return v.loops; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/loop_analysis.h b/reactos/dll/opengl/mesa/src/glsl/loop_analysis.h deleted file mode 100644 index 05c982fc164..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/loop_analysis.h +++ /dev/null @@ -1,255 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef LOOP_ANALYSIS_H -#define LOOP_ANALYSIS_H - -#include "ir.h" -#include "program/hash_table.h" - -/** - * Analyze and classify all variables used in all loops in the instruction list - */ -extern class loop_state * -analyze_loop_variables(exec_list *instructions); - - -/** - * Fill in loop control fields - * - * Based on analysis of loop variables, this function tries to remove sequences - * in the loop of the form - * - * (if (expression bool ...) (break)) - * - * and fill in the \c ir_loop::from, \c ir_loop::to, and \c ir_loop::counter - * fields of the \c ir_loop. - * - * In this process, some conditional break-statements may be eliminated - * altogether. For example, if it is provable that one loop exit condition will - * always be satisfied before another, the unnecessary exit condition will be - * removed. - */ -extern bool -set_loop_controls(exec_list *instructions, loop_state *ls); - - -extern bool -unroll_loops(exec_list *instructions, loop_state *ls, unsigned max_iterations); - - -/** - * Tracking for all variables used in a loop - */ -class loop_variable_state : public exec_node { -public: - class loop_variable *get(const ir_variable *); - class loop_variable *insert(ir_variable *); - class loop_terminator *insert(ir_if *); - - - /** - * Loop whose variable state is being tracked by this structure - */ - ir_loop *loop; - - /** - * Variables that have not yet been classified - */ - exec_list variables; - - /** - * Variables whose values are constant within the body of the loop - * - * This list contains \c loop_variable objects. - */ - exec_list constants; - - /** - * Induction variables for this loop - * - * This list contains \c loop_variable objects. - */ - exec_list induction_variables; - - /** - * Simple if-statements that lead to the termination of the loop - * - * This list contains \c loop_terminator objects. - * - * \sa is_loop_terminator - */ - exec_list terminators; - - /** - * Hash table containing all variables accessed in this loop - */ - hash_table *var_hash; - - /** - * Maximum number of loop iterations. - * - * If this value is negative, then the loop may be infinite. This actually - * means that analysis was unable to determine an upper bound on the number - * of loop iterations. - */ - int max_iterations; - - /** - * Number of ir_loop_jump instructions that operate on this loop - */ - unsigned num_loop_jumps; - - /** - * Whether this loop contains any function calls. - */ - bool contains_calls; - - loop_variable_state() - { - this->max_iterations = -1; - this->num_loop_jumps = 0; - this->contains_calls = false; - this->var_hash = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - } - - ~loop_variable_state() - { - hash_table_dtor(this->var_hash); - } - - static void* operator new(size_t size, void *ctx) - { - void *lvs = ralloc_size(ctx, size); - assert(lvs != NULL); - - ralloc_set_destructor(lvs, (void (*)(void*)) destructor); - - return lvs; - } - -private: - static void - destructor(loop_variable_state *lvs) - { - lvs->~loop_variable_state(); - } -}; - - -class loop_variable : public exec_node { -public: - /** The variable in question. */ - ir_variable *var; - - /** Is the variable read in the loop before it is written? */ - bool read_before_write; - - /** Are all variables in the RHS of the assignment loop constants? */ - bool rhs_clean; - - /** Is there an assignment to the variable that is conditional? */ - bool conditional_assignment; - - /** Reference to the first assignment to the variable in the loop body. */ - ir_assignment *first_assignment; - - /** Number of assignments to the variable in the loop body. */ - unsigned num_assignments; - - /** - * Increment values for loop induction variables - * - * Loop induction variables have a single increment of the form - * \c b * \c biv + \c c, where \c b and \c c are loop constants and \c i - * is a basic loop induction variable. - * - * If \c iv_scale is \c NULL, 1 is used. If \c biv is the same as \c var, - * then \c var is a basic loop induction variable. - */ - /*@{*/ - ir_rvalue *iv_scale; - ir_variable *biv; - ir_rvalue *increment; - /*@}*/ - - - inline bool is_loop_constant() const - { - const bool is_const = (this->num_assignments == 0) - || ((this->num_assignments == 1) - && !this->conditional_assignment - && !this->read_before_write - && this->rhs_clean); - - /* If the RHS of *the* assignment is clean, then there must be exactly - * one assignment of the variable. - */ - assert((this->rhs_clean && (this->num_assignments == 1)) - || !this->rhs_clean); - - /* Variables that are marked read-only *MUST* be loop constant. - */ - assert(!this->var->read_only || (this->var->read_only && is_const)); - - return is_const; - } -}; - - -class loop_terminator : public exec_node { -public: - ir_if *ir; -}; - - -class loop_state { -public: - ~loop_state(); - - /** - * Get the loop variable state data for a particular loop - */ - loop_variable_state *get(const ir_loop *); - - loop_variable_state *insert(ir_loop *ir); - - bool loop_found; - -private: - loop_state(); - - /** - * Hash table containing all loops that have been analyzed. - */ - hash_table *ht; - - void *mem_ctx; - - friend class loop_analysis; -}; - -#endif /* LOOP_ANALYSIS_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/loop_controls.cpp b/reactos/dll/opengl/mesa/src/glsl/loop_controls.cpp deleted file mode 100644 index 9acbadc50ea..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/loop_controls.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include "main/compiler.h" -#include "glsl_types.h" -#include "loop_analysis.h" -#include "ir_hierarchical_visitor.h" - -/** - * Find an initializer of a variable outside a loop - * - * Works backwards from the loop to find the pre-loop value of the variable. - * This is used, for example, to find the initial value of loop induction - * variables. - * - * \param loop Loop where \c var is an induction variable - * \param var Variable whose initializer is to be found - * - * \return - * The \c ir_rvalue assigned to the variable outside the loop. May return - * \c NULL if no initializer can be found. - */ -ir_rvalue * -find_initial_value(ir_loop *loop, ir_variable *var) -{ - for (exec_node *node = loop->prev; - !node->is_head_sentinel(); - node = node->prev) { - ir_instruction *ir = (ir_instruction *) node; - - switch (ir->ir_type) { - case ir_type_call: - case ir_type_loop: - case ir_type_loop_jump: - case ir_type_return: - case ir_type_if: - return NULL; - - case ir_type_function: - case ir_type_function_signature: - assert(!"Should not get here."); - return NULL; - - case ir_type_assignment: { - ir_assignment *assign = ir->as_assignment(); - ir_variable *assignee = assign->lhs->whole_variable_referenced(); - - if (assignee == var) - return (assign->condition != NULL) ? NULL : assign->rhs; - - break; - } - - default: - break; - } - } - - return NULL; -} - - -int -calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, - enum ir_expression_operation op) -{ - if (from == NULL || to == NULL || increment == NULL) - return -1; - - void *mem_ctx = ralloc_context(NULL); - - ir_expression *const sub = - new(mem_ctx) ir_expression(ir_binop_sub, from->type, to, from); - - ir_expression *const div = - new(mem_ctx) ir_expression(ir_binop_div, sub->type, sub, increment); - - ir_constant *iter = div->constant_expression_value(); - - if (iter == NULL) - return -1; - - if (!iter->type->is_integer()) { - ir_rvalue *cast = - new(mem_ctx) ir_expression(ir_unop_f2i, glsl_type::int_type, iter, - NULL); - - iter = cast->constant_expression_value(); - } - - int iter_value = iter->get_int_component(0); - - /* Make sure that the calculated number of iterations satisfies the exit - * condition. This is needed to catch off-by-one errors and some types of - * ill-formed loops. For example, we need to detect that the following - * loop does not have a maximum iteration count. - * - * for (float x = 0.0; x != 0.9; x += 0.2) - * ; - */ - const int bias[] = { -1, 0, 1 }; - bool valid_loop = false; - - for (unsigned i = 0; i < Elements(bias); i++) { - iter = (increment->type->is_integer()) - ? new(mem_ctx) ir_constant(iter_value + bias[i]) - : new(mem_ctx) ir_constant(float(iter_value + bias[i])); - - ir_expression *const mul = - new(mem_ctx) ir_expression(ir_binop_mul, increment->type, iter, - increment); - - ir_expression *const add = - new(mem_ctx) ir_expression(ir_binop_add, mul->type, mul, from); - - ir_expression *const cmp = - new(mem_ctx) ir_expression(op, glsl_type::bool_type, add, to); - - ir_constant *const cmp_result = cmp->constant_expression_value(); - - assert(cmp_result != NULL); - if (cmp_result->get_bool_component(0)) { - iter_value += bias[i]; - valid_loop = true; - break; - } - } - - ralloc_free(mem_ctx); - return (valid_loop) ? iter_value : -1; -} - - -class loop_control_visitor : public ir_hierarchical_visitor { -public: - loop_control_visitor(loop_state *state) - { - this->state = state; - this->progress = false; - } - - virtual ir_visitor_status visit_leave(ir_loop *ir); - - loop_state *state; - - bool progress; -}; - - -ir_visitor_status -loop_control_visitor::visit_leave(ir_loop *ir) -{ - loop_variable_state *const ls = this->state->get(ir); - - /* If we've entered a loop that hasn't been analyzed, something really, - * really bad has happened. - */ - if (ls == NULL) { - assert(ls != NULL); - return visit_continue; - } - - /* Search the loop terminating conditions for one of the form 'i < c' where - * i is a loop induction variable, c is a constant, and < is any relative - * operator. - */ - int max_iterations = ls->max_iterations; - - if(ir->from && ir->to && ir->increment) - max_iterations = calculate_iterations(ir->from, ir->to, ir->increment, (ir_expression_operation)ir->cmp); - - if(max_iterations < 0) - max_iterations = INT_MAX; - - foreach_list(node, &ls->terminators) { - loop_terminator *t = (loop_terminator *) node; - ir_if *if_stmt = t->ir; - - /* If-statements can be either 'if (expr)' or 'if (deref)'. We only care - * about the former here. - */ - ir_expression *cond = if_stmt->condition->as_expression(); - if (cond == NULL) - continue; - - switch (cond->operation) { - case ir_binop_less: - case ir_binop_greater: - case ir_binop_lequal: - case ir_binop_gequal: { - /* The expressions that we care about will either be of the form - * 'counter < limit' or 'limit < counter'. Figure out which is - * which. - */ - ir_rvalue *counter = cond->operands[0]->as_dereference_variable(); - ir_constant *limit = cond->operands[1]->as_constant(); - enum ir_expression_operation cmp = cond->operation; - - if (limit == NULL) { - counter = cond->operands[1]->as_dereference_variable(); - limit = cond->operands[0]->as_constant(); - - switch (cmp) { - case ir_binop_less: cmp = ir_binop_gequal; break; - case ir_binop_greater: cmp = ir_binop_lequal; break; - case ir_binop_lequal: cmp = ir_binop_greater; break; - case ir_binop_gequal: cmp = ir_binop_less; break; - default: assert(!"Should not get here."); - } - } - - if ((counter == NULL) || (limit == NULL)) - break; - - ir_variable *var = counter->variable_referenced(); - - ir_rvalue *init = find_initial_value(ir, var); - - foreach_list(iv_node, &ls->induction_variables) { - loop_variable *lv = (loop_variable *) iv_node; - - if (lv->var == var) { - const int iterations = calculate_iterations(init, limit, - lv->increment, - cmp); - if (iterations >= 0) { - /* If the new iteration count is lower than the previously - * believed iteration count, update the loop control values. - */ - if (iterations < max_iterations) { - ir->from = init->clone(ir, NULL); - ir->to = limit->clone(ir, NULL); - ir->increment = lv->increment->clone(ir, NULL); - ir->counter = lv->var; - ir->cmp = cmp; - - max_iterations = iterations; - } - - /* Remove the conditional break statement. The loop - * controls are now set such that the exit condition will be - * satisfied. - */ - if_stmt->remove(); - - assert(ls->num_loop_jumps > 0); - ls->num_loop_jumps--; - - this->progress = true; - } - - break; - } - } - break; - } - - default: - break; - } - } - - /* If we have proven the one of the loop exit conditions is satisifed before - * running the loop once, remove the loop. - */ - if (max_iterations == 0) - ir->remove(); - else - ls->max_iterations = max_iterations; - - return visit_continue; -} - - -bool -set_loop_controls(exec_list *instructions, loop_state *ls) -{ - loop_control_visitor v(ls); - - v.run(instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/loop_unroll.cpp b/reactos/dll/opengl/mesa/src/glsl/loop_unroll.cpp deleted file mode 100644 index d0bcaa6703d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/loop_unroll.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "glsl_types.h" -#include "loop_analysis.h" -#include "ir_hierarchical_visitor.h" - -class loop_unroll_visitor : public ir_hierarchical_visitor { -public: - loop_unroll_visitor(loop_state *state, unsigned max_iterations) - { - this->state = state; - this->progress = false; - this->max_iterations = max_iterations; - } - - virtual ir_visitor_status visit_leave(ir_loop *ir); - - loop_state *state; - - bool progress; - unsigned max_iterations; -}; - - -static bool -is_break(ir_instruction *ir) -{ - return ir != NULL && ir->ir_type == ir_type_loop_jump - && ((ir_loop_jump *) ir)->is_break(); -} - - -ir_visitor_status -loop_unroll_visitor::visit_leave(ir_loop *ir) -{ - loop_variable_state *const ls = this->state->get(ir); - int iterations; - unsigned ir_count; - - /* If we've entered a loop that hasn't been analyzed, something really, - * really bad has happened. - */ - if (ls == NULL) { - assert(ls != NULL); - return visit_continue; - } - - iterations = ls->max_iterations; - - /* Don't try to unroll loops where the number of iterations is not known - * at compile-time. - */ - if (iterations < 0) - return visit_continue; - - /* Don't try to unroll loops that have zillions of iterations either. - */ - if (iterations > (int) max_iterations) - return visit_continue; - - /* Don't try to unroll nested loops and loops with a huge body. - */ - ir_count = 0; - foreach_list(node, &ir->body_instructions) { - ++ir_count; - - /* If the loop body gets to huge, do not unroll. */ - if (5*max_iterations < ir_count*iterations) - return visit_continue; - /* Do not unroll loops with child loop nodes. */ - if (((ir_instruction *) node)->as_loop()) - return visit_continue; - } - - if (ls->num_loop_jumps > 1) - return visit_continue; - else if (ls->num_loop_jumps) { - ir_instruction *last_ir = (ir_instruction *) ir->body_instructions.get_tail(); - assert(last_ir != NULL); - - if (is_break(last_ir)) { - /* If the only loop-jump is a break at the end of the loop, the loop - * will execute exactly once. Remove the break, set the iteration - * count, and fall through to the normal unroller. - */ - last_ir->remove(); - iterations = 1; - - this->progress = true; - } else { - ir_if *ir_if = NULL; - ir_instruction *break_ir = NULL; - bool continue_from_then_branch = false; - - foreach_list(node, &ir->body_instructions) { - /* recognize loops in the form produced by ir_lower_jumps */ - ir_instruction *cur_ir = (ir_instruction *) node; - - ir_if = cur_ir->as_if(); - if (ir_if != NULL) { - /* Determine which if-statement branch, if any, ends with a - * break. The branch that did *not* have the break will get a - * temporary continue inserted in each iteration of the loop - * unroll. - * - * Note that since ls->num_loop_jumps is <= 1, it is impossible - * for both branches to end with a break. - */ - ir_instruction *ir_if_last = - (ir_instruction *) ir_if->then_instructions.get_tail(); - - if (is_break(ir_if_last)) { - continue_from_then_branch = false; - break_ir = ir_if_last; - break; - } else { - ir_if_last = - (ir_instruction *) ir_if->else_instructions.get_tail(); - - if (is_break(ir_if_last)) { - break_ir = ir_if_last; - continue_from_then_branch = true; - break; - } - } - } - } - - if (break_ir == NULL) - return visit_continue; - - /* move instructions after then if in the continue branch */ - while (!ir_if->get_next()->is_tail_sentinel()) { - ir_instruction *move_ir = (ir_instruction *) ir_if->get_next(); - - move_ir->remove(); - if (continue_from_then_branch) - ir_if->then_instructions.push_tail(move_ir); - else - ir_if->else_instructions.push_tail(move_ir); - } - - /* Remove the break from the if-statement. - */ - break_ir->remove(); - - void *const mem_ctx = ralloc_parent(ir); - ir_instruction *ir_to_replace = ir; - - for (int i = 0; i < iterations; i++) { - exec_list copy_list; - - copy_list.make_empty(); - clone_ir_list(mem_ctx, ©_list, &ir->body_instructions); - - ir_if = ((ir_instruction *) copy_list.get_tail())->as_if(); - assert(ir_if != NULL); - - ir_to_replace->insert_before(©_list); - ir_to_replace->remove(); - - /* placeholder that will be removed in the next iteration */ - ir_to_replace = - new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_continue); - - exec_list *const list = (continue_from_then_branch) - ? &ir_if->then_instructions : &ir_if->else_instructions; - - list->push_tail(ir_to_replace); - } - - ir_to_replace->remove(); - - this->progress = true; - return visit_continue; - } - } - - void *const mem_ctx = ralloc_parent(ir); - - for (int i = 0; i < iterations; i++) { - exec_list copy_list; - - copy_list.make_empty(); - clone_ir_list(mem_ctx, ©_list, &ir->body_instructions); - - ir->insert_before(©_list); - } - - /* The loop has been replaced by the unrolled copies. Remove the original - * loop from the IR sequence. - */ - ir->remove(); - - this->progress = true; - return visit_continue; -} - - -bool -unroll_loops(exec_list *instructions, loop_state *ls, unsigned max_iterations) -{ - loop_unroll_visitor v(ls, max_iterations); - - v.run(instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_clip_distance.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_clip_distance.cpp deleted file mode 100644 index 143e378f97b..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_clip_distance.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_clip_distance.cpp - * - * This pass accounts for the difference between the way - * gl_ClipDistance is declared in standard GLSL (as an array of - * floats), and the way it is frequently implemented in hardware (as - * a pair of vec4s, with four clip distances packed into each). - * - * The declaration of gl_ClipDistance is replaced with a declaration - * of gl_ClipDistanceMESA, and any references to gl_ClipDistance are - * translated to refer to gl_ClipDistanceMESA with the appropriate - * swizzling of array indices. For instance: - * - * gl_ClipDistance[i] - * - * is translated into: - * - * gl_ClipDistanceMESA[i>>2][i&3] - * - * Since some hardware may not internally represent gl_ClipDistance as a pair - * of vec4's, this lowering pass is optional. To enable it, set the - * LowerClipDistance flag in gl_shader_compiler_options to true. - */ - -#include "ir_hierarchical_visitor.h" -#include "ir.h" - -class lower_clip_distance_visitor : public ir_hierarchical_visitor { -public: - lower_clip_distance_visitor() - : progress(false), old_clip_distance_var(NULL), - new_clip_distance_var(NULL) - { - } - - virtual ir_visitor_status visit(ir_variable *); - void create_indices(ir_rvalue*, ir_rvalue *&, ir_rvalue *&); - virtual ir_visitor_status visit_leave(ir_dereference_array *); - virtual ir_visitor_status visit_leave(ir_assignment *); - void visit_new_assignment(ir_assignment *ir); - virtual ir_visitor_status visit_leave(ir_call *); - - bool progress; - - /** - * Pointer to the declaration of gl_ClipDistance, if found. - */ - ir_variable *old_clip_distance_var; - - /** - * Pointer to the newly-created gl_ClipDistanceMESA variable. - */ - ir_variable *new_clip_distance_var; -}; - - -/** - * Replace any declaration of gl_ClipDistance as an array of floats with a - * declaration of gl_ClipDistanceMESA as an array of vec4's. - */ -ir_visitor_status -lower_clip_distance_visitor::visit(ir_variable *ir) -{ - /* No point in looking for the declaration of gl_ClipDistance if - * we've already found it. - */ - if (this->old_clip_distance_var) - return visit_continue; - - if (ir->name && strcmp(ir->name, "gl_ClipDistance") == 0) { - this->progress = true; - this->old_clip_distance_var = ir; - assert (ir->type->is_array()); - assert (ir->type->element_type() == glsl_type::float_type); - unsigned new_size = (ir->type->array_size() + 3) / 4; - - /* Clone the old var so that we inherit all of its properties */ - this->new_clip_distance_var = ir->clone(ralloc_parent(ir), NULL); - - /* And change the properties that we need to change */ - this->new_clip_distance_var->name - = ralloc_strdup(this->new_clip_distance_var, "gl_ClipDistanceMESA"); - this->new_clip_distance_var->type - = glsl_type::get_array_instance(glsl_type::vec4_type, new_size); - this->new_clip_distance_var->max_array_access = ir->max_array_access / 4; - - ir->replace_with(this->new_clip_distance_var); - } - return visit_continue; -} - - -/** - * Create the necessary GLSL rvalues to index into gl_ClipDistanceMESA based - * on the rvalue previously used to index into gl_ClipDistance. - * - * \param array_index Selects one of the vec4's in gl_ClipDistanceMESA - * \param swizzle_index Selects a component within the vec4 selected by - * array_index. - */ -void -lower_clip_distance_visitor::create_indices(ir_rvalue *old_index, - ir_rvalue *&array_index, - ir_rvalue *&swizzle_index) -{ - void *ctx = ralloc_parent(old_index); - - /* Make sure old_index is a signed int so that the bitwise "shift" and - * "and" operations below type check properly. - */ - if (old_index->type != glsl_type::int_type) { - assert (old_index->type == glsl_type::uint_type); - old_index = new(ctx) ir_expression(ir_unop_u2i, old_index); - } - - ir_constant *old_index_constant = old_index->constant_expression_value(); - if (old_index_constant) { - /* gl_ClipDistance is being accessed via a constant index. Don't bother - * creating expressions to calculate the lowered indices. Just create - * constants. - */ - int const_val = old_index_constant->get_int_component(0); - array_index = new(ctx) ir_constant(const_val / 4); - swizzle_index = new(ctx) ir_constant(const_val % 4); - } else { - /* Create a variable to hold the value of old_index (so that we - * don't compute it twice). - */ - ir_variable *old_index_var = new(ctx) ir_variable( - glsl_type::int_type, "clip_distance_index", ir_var_temporary); - this->base_ir->insert_before(old_index_var); - this->base_ir->insert_before(new(ctx) ir_assignment( - new(ctx) ir_dereference_variable(old_index_var), old_index)); - - /* Create the expression clip_distance_index / 4. Do this as a bit - * shift because that's likely to be more efficient. - */ - array_index = new(ctx) ir_expression( - ir_binop_rshift, new(ctx) ir_dereference_variable(old_index_var), - new(ctx) ir_constant(2)); - - /* Create the expression clip_distance_index % 4. Do this as a bitwise - * AND because that's likely to be more efficient. - */ - swizzle_index = new(ctx) ir_expression( - ir_binop_bit_and, new(ctx) ir_dereference_variable(old_index_var), - new(ctx) ir_constant(3)); - } -} - - -/** - * Replace any expression that indexes into the gl_ClipDistance array with an - * expression that indexes into one of the vec4's in gl_ClipDistanceMESA and - * accesses the appropriate component. - */ -ir_visitor_status -lower_clip_distance_visitor::visit_leave(ir_dereference_array *ir) -{ - /* If the gl_ClipDistance var hasn't been declared yet, then - * there's no way this deref can refer to it. - */ - if (!this->old_clip_distance_var) - return visit_continue; - - ir_dereference_variable *old_var_ref = ir->array->as_dereference_variable(); - if (old_var_ref && old_var_ref->var == this->old_clip_distance_var) { - this->progress = true; - ir_rvalue *array_index; - ir_rvalue *swizzle_index; - this->create_indices(ir->array_index, array_index, swizzle_index); - void *mem_ctx = ralloc_parent(ir); - ir->array = new(mem_ctx) ir_dereference_array( - this->new_clip_distance_var, array_index); - ir->array_index = swizzle_index; - } - - return visit_continue; -} - - -/** - * Replace any assignment having gl_ClipDistance (undereferenced) as its LHS - * or RHS with a sequence of assignments, one for each component of the array. - * Each of these assignments is lowered to refer to gl_ClipDistanceMESA as - * appropriate. - */ -ir_visitor_status -lower_clip_distance_visitor::visit_leave(ir_assignment *ir) -{ - ir_dereference_variable *lhs_var = ir->lhs->as_dereference_variable(); - ir_dereference_variable *rhs_var = ir->rhs->as_dereference_variable(); - if ((lhs_var && lhs_var->var == this->old_clip_distance_var) - || (rhs_var && rhs_var->var == this->old_clip_distance_var)) { - /* LHS or RHS of the assignment is the entire gl_ClipDistance array. - * Since we are reshaping gl_ClipDistance from an array of floats to an - * array of vec4's, this isn't going to work as a bulk assignment - * anymore, so unroll it to element-by-element assignments and lower - * each of them. - * - * Note: to unroll into element-by-element assignments, we need to make - * clones of the LHS and RHS. This is only safe if the LHS and RHS are - * side-effect free. Fortunately, we know that they are, because the - * only kind of rvalue that can have side effects is an ir_call, and - * ir_calls only appear (a) as a statement on their own, or (b) as the - * RHS of an assignment that stores the result of the call in a - * temporary variable. - */ - void *ctx = ralloc_parent(ir); - int array_size = this->old_clip_distance_var->type->array_size(); - for (int i = 0; i < array_size; ++i) { - ir_dereference_array *new_lhs = new(ctx) ir_dereference_array( - ir->lhs->clone(ctx, NULL), new(ctx) ir_constant(i)); - new_lhs->accept(this); - ir_dereference_array *new_rhs = new(ctx) ir_dereference_array( - ir->rhs->clone(ctx, NULL), new(ctx) ir_constant(i)); - new_rhs->accept(this); - this->base_ir->insert_before( - new(ctx) ir_assignment(new_lhs, new_rhs)); - } - ir->remove(); - } - - return visit_continue; -} - - -/** - * Set up base_ir properly and call visit_leave() on a newly created - * ir_assignment node. This is used in cases where we have to insert an - * ir_assignment in a place where we know the hierarchical visitor won't see - * it. - */ -void -lower_clip_distance_visitor::visit_new_assignment(ir_assignment *ir) -{ - ir_instruction *old_base_ir = this->base_ir; - this->base_ir = ir; - ir->accept(this); - this->base_ir = old_base_ir; -} - - -/** - * If gl_ClipDistance appears as an argument in an ir_call expression, replace - * it with a temporary variable, and make sure the ir_call is preceded and/or - * followed by assignments that copy the contents of the temporary variable to - * and/or from gl_ClipDistance. Each of these assignments is then lowered to - * refer to gl_ClipDistanceMESA. - */ -ir_visitor_status -lower_clip_distance_visitor::visit_leave(ir_call *ir) -{ - void *ctx = ralloc_parent(ir); - - const exec_node *formal_param_node = ir->get_callee()->parameters.head; - const exec_node *actual_param_node = ir->actual_parameters.head; - while (!actual_param_node->is_tail_sentinel()) { - ir_variable *formal_param = (ir_variable *) formal_param_node; - ir_rvalue *actual_param = (ir_rvalue *) actual_param_node; - - /* Advance formal_param_node and actual_param_node now so that we can - * safely replace actual_param with another node, if necessary, below. - */ - formal_param_node = formal_param_node->next; - actual_param_node = actual_param_node->next; - - ir_dereference_variable *deref = actual_param->as_dereference_variable(); - if (deref && deref->var == this->old_clip_distance_var) { - /* User is trying to pass the whole gl_ClipDistance array to a - * function call. Since we are reshaping gl_ClipDistance from an - * array of floats to an array of vec4's, this isn't going to work - * anymore, so use a temporary array instead. - */ - ir_variable *temp_clip_distance = new(ctx) ir_variable( - actual_param->type, "temp_clip_distance", ir_var_temporary); - this->base_ir->insert_before(temp_clip_distance); - actual_param->replace_with( - new(ctx) ir_dereference_variable(temp_clip_distance)); - if (formal_param->mode == ir_var_in - || formal_param->mode == ir_var_inout) { - /* Copy from gl_ClipDistance to the temporary before the call. - * Since we are going to insert this copy before the current - * instruction, we need to visit it afterwards to make sure it - * gets lowered. - */ - ir_assignment *new_assignment = new(ctx) ir_assignment( - new(ctx) ir_dereference_variable(temp_clip_distance), - new(ctx) ir_dereference_variable(old_clip_distance_var)); - this->base_ir->insert_before(new_assignment); - this->visit_new_assignment(new_assignment); - } - if (formal_param->mode == ir_var_out - || formal_param->mode == ir_var_inout) { - /* Copy from the temporary to gl_ClipDistance after the call. - * Since visit_list_elements() has already decided which - * instruction it's going to visit next, we need to visit - * afterwards to make sure it gets lowered. - */ - ir_assignment *new_assignment = new(ctx) ir_assignment( - new(ctx) ir_dereference_variable(old_clip_distance_var), - new(ctx) ir_dereference_variable(temp_clip_distance)); - this->base_ir->insert_after(new_assignment); - this->visit_new_assignment(new_assignment); - } - } - } - - return visit_continue; -} - - -bool -lower_clip_distance(exec_list *instructions) -{ - lower_clip_distance_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_discard.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_discard.cpp deleted file mode 100644 index cafd2dd3b44..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_discard.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_discard.cpp - * - * This pass moves discards out of if-statements. - * - * Case 1: The "then" branch contains a conditional discard: - * --------------------------------------------------------- - * - * if (cond1) { - * s1; - * discard cond2; - * s2; - * } else { - * s3; - * } - * - * becomes: - * - * temp = false; - * if (cond1) { - * s1; - * temp = cond2; - * s2; - * } else { - * s3; - * } - * discard temp; - * - * Case 2: The "else" branch contains a conditional discard: - * --------------------------------------------------------- - * - * if (cond1) { - * s1; - * } else { - * s2; - * discard cond2; - * s3; - * } - * - * becomes: - * - * temp = false; - * if (cond1) { - * s1; - * } else { - * s2; - * temp = cond2; - * s3; - * } - * discard temp; - * - * Case 3: Both branches contain a conditional discard: - * ---------------------------------------------------- - * - * if (cond1) { - * s1; - * discard cond2; - * s2; - * } else { - * s3; - * discard cond3; - * s4; - * } - * - * becomes: - * - * temp = false; - * if (cond1) { - * s1; - * temp = cond2; - * s2; - * } else { - * s3; - * temp = cond3; - * s4; - * } - * discard temp; - * - * If there are multiple conditional discards, we need only deal with one of - * them. Repeatedly applying this pass will take care of the others. - * - * Unconditional discards are treated as having a condition of "true". - */ - -#include "glsl_types.h" -#include "ir.h" - -class lower_discard_visitor : public ir_hierarchical_visitor { -public: - lower_discard_visitor() - { - this->progress = false; - } - - ir_visitor_status visit_leave(ir_if *); - - bool progress; -}; - - -bool -lower_discard(exec_list *instructions) -{ - lower_discard_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} - - -static ir_discard * -find_discard(exec_list &instructions) -{ - foreach_list(n, &instructions) { - ir_discard *ir = ((ir_instruction *) n)->as_discard(); - if (ir != NULL) - return ir; - } - return NULL; -} - - -static void -replace_discard(void *mem_ctx, ir_variable *var, ir_discard *ir) -{ - ir_rvalue *condition = ir->condition; - - /* For unconditional discards, use "true" as the condition. */ - if (condition == NULL) - condition = new(mem_ctx) ir_constant(true); - - ir_assignment *assignment = - new(mem_ctx) ir_assignment(new(mem_ctx) ir_dereference_variable(var), - condition, NULL); - - ir->replace_with(assignment); -} - - -ir_visitor_status -lower_discard_visitor::visit_leave(ir_if *ir) -{ - ir_discard *then_discard = find_discard(ir->then_instructions); - ir_discard *else_discard = find_discard(ir->else_instructions); - - if (then_discard == NULL && else_discard == NULL) - return visit_continue; - - void *mem_ctx = ralloc_parent(ir); - - ir_variable *temp = new(mem_ctx) ir_variable(glsl_type::bool_type, - "discard_cond_temp", - ir_var_temporary); - ir_assignment *temp_initializer = - new(mem_ctx) ir_assignment(new(mem_ctx) ir_dereference_variable(temp), - new(mem_ctx) ir_constant(false), NULL); - - ir->insert_before(temp); - ir->insert_before(temp_initializer); - - if (then_discard != NULL) - replace_discard(mem_ctx, temp, then_discard); - - if (else_discard != NULL) - replace_discard(mem_ctx, temp, else_discard); - - ir_discard *discard = then_discard != NULL ? then_discard : else_discard; - discard->condition = new(mem_ctx) ir_dereference_variable(temp); - ir->insert_after(discard); - - this->progress = true; - - return visit_continue; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_if_to_cond_assign.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_if_to_cond_assign.cpp deleted file mode 100644 index 2c5d5612d0d..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_if_to_cond_assign.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_if_to_cond_assign.cpp - * - * This attempts to flatten if-statements to conditional assignments for - * GPUs with limited or no flow control support. - * - * It can't handle other control flow being inside of its block, such - * as calls or loops. Hopefully loop unrolling and inlining will take - * care of those. - * - * Drivers for GPUs with no control flow support should simply call - * - * lower_if_to_cond_assign(instructions) - * - * to attempt to flatten all if-statements. - * - * Some GPUs (such as i965 prior to gen6) do support control flow, but have a - * maximum nesting depth N. Drivers for such hardware can call - * - * lower_if_to_cond_assign(instructions, N) - * - * to attempt to flatten any if-statements appearing at depth > N. - */ - -#include "glsl_types.h" -#include "ir.h" -#include "program/hash_table.h" - -class ir_if_to_cond_assign_visitor : public ir_hierarchical_visitor { -public: - ir_if_to_cond_assign_visitor(unsigned max_depth) - { - this->progress = false; - this->max_depth = max_depth; - this->depth = 0; - - this->condition_variables = hash_table_ctor(0, hash_table_pointer_hash, - hash_table_pointer_compare); - } - - ~ir_if_to_cond_assign_visitor() - { - hash_table_dtor(this->condition_variables); - } - - ir_visitor_status visit_enter(ir_if *); - ir_visitor_status visit_leave(ir_if *); - - bool progress; - unsigned max_depth; - unsigned depth; - - struct hash_table *condition_variables; -}; - -bool -lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth) -{ - if (max_depth == UINT_MAX) - return false; - - ir_if_to_cond_assign_visitor v(max_depth); - - visit_list_elements(&v, instructions); - - return v.progress; -} - -void -check_control_flow(ir_instruction *ir, void *data) -{ - bool *found_control_flow = (bool *)data; - switch (ir->ir_type) { - case ir_type_call: - case ir_type_discard: - case ir_type_loop: - case ir_type_loop_jump: - case ir_type_return: - *found_control_flow = true; - break; - default: - break; - } -} - -void -move_block_to_cond_assign(void *mem_ctx, - ir_if *if_ir, ir_rvalue *cond_expr, - exec_list *instructions, - struct hash_table *ht) -{ - foreach_list_safe(node, instructions) { - ir_instruction *ir = (ir_instruction *) node; - - if (ir->ir_type == ir_type_assignment) { - ir_assignment *assign = (ir_assignment *)ir; - - if (hash_table_find(ht, assign) == NULL) { - hash_table_insert(ht, assign, assign); - - /* If the LHS of the assignment is a condition variable that was - * previously added, insert an additional assignment of false to - * the variable. - */ - const bool assign_to_cv = - hash_table_find(ht, assign->lhs->variable_referenced()) != NULL; - - if (!assign->condition) { - if (assign_to_cv) { - assign->rhs = - new(mem_ctx) ir_expression(ir_binop_logic_and, - glsl_type::bool_type, - cond_expr->clone(mem_ctx, NULL), - assign->rhs); - } else { - assign->condition = cond_expr->clone(mem_ctx, NULL); - } - } else { - assign->condition = - new(mem_ctx) ir_expression(ir_binop_logic_and, - glsl_type::bool_type, - cond_expr->clone(mem_ctx, NULL), - assign->condition); - } - } - } - - /* Now, move from the if block to the block surrounding it. */ - ir->remove(); - if_ir->insert_before(ir); - } -} - -ir_visitor_status -ir_if_to_cond_assign_visitor::visit_enter(ir_if *ir) -{ - (void) ir; - this->depth++; - - return visit_continue; -} - -ir_visitor_status -ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir) -{ - /* Only flatten when beyond the GPU's maximum supported nesting depth. */ - if (this->depth-- <= this->max_depth) - return visit_continue; - - bool found_control_flow = false; - ir_assignment *assign; - - /* Check that both blocks don't contain anything we can't support. */ - foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { - ir_instruction *then_ir = (ir_instruction *)then_iter.get(); - visit_tree(then_ir, check_control_flow, &found_control_flow); - } - foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { - ir_instruction *else_ir = (ir_instruction *)else_iter.get(); - visit_tree(else_ir, check_control_flow, &found_control_flow); - } - if (found_control_flow) - return visit_continue; - - void *mem_ctx = ralloc_parent(ir); - - /* Store the condition to a variable. Move all of the instructions from - * the then-clause of the if-statement. Use the condition variable as a - * condition for all assignments. - */ - ir_variable *const then_var = - new(mem_ctx) ir_variable(glsl_type::bool_type, - "if_to_cond_assign_then", - ir_var_temporary); - ir->insert_before(then_var); - - ir_dereference_variable *then_cond = - new(mem_ctx) ir_dereference_variable(then_var); - - assign = new(mem_ctx) ir_assignment(then_cond, ir->condition); - ir->insert_before(assign); - - move_block_to_cond_assign(mem_ctx, ir, then_cond, - &ir->then_instructions, - this->condition_variables); - - /* Add the new condition variable to the hash table. This allows us to - * find this variable when lowering other (enclosing) if-statements. - */ - hash_table_insert(this->condition_variables, then_var, then_var); - - /* If there are instructions in the else-clause, store the inverse of the - * condition to a variable. Move all of the instructions from the - * else-clause if the if-statement. Use the (inverse) condition variable - * as a condition for all assignments. - */ - if (!ir->else_instructions.is_empty()) { - ir_variable *const else_var = - new(mem_ctx) ir_variable(glsl_type::bool_type, - "if_to_cond_assign_else", - ir_var_temporary); - ir->insert_before(else_var); - - ir_dereference_variable *else_cond = - new(mem_ctx) ir_dereference_variable(else_var); - - ir_rvalue *inverse = - new(mem_ctx) ir_expression(ir_unop_logic_not, - then_cond->clone(mem_ctx, NULL)); - - assign = new(mem_ctx) ir_assignment(else_cond, inverse); - ir->insert_before(assign); - - move_block_to_cond_assign(mem_ctx, ir, else_cond, - &ir->else_instructions, - this->condition_variables); - - /* Add the new condition variable to the hash table. This allows us to - * find this variable when lowering other (enclosing) if-statements. - */ - hash_table_insert(this->condition_variables, else_var, else_var); - } - - ir->remove(); - - this->progress = true; - - return visit_continue; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_instructions.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_instructions.cpp deleted file mode 100644 index d79eb0a7ffb..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_instructions.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_instructions.cpp - * - * Many GPUs lack native instructions for certain expression operations, and - * must replace them with some other expression tree. This pass lowers some - * of the most common cases, allowing the lowering code to be implemented once - * rather than in each driver backend. - * - * Currently supported transformations: - * - SUB_TO_ADD_NEG - * - DIV_TO_MUL_RCP - * - INT_DIV_TO_MUL_RCP - * - EXP_TO_EXP2 - * - POW_TO_EXP2 - * - LOG_TO_LOG2 - * - MOD_TO_FRACT - * - * SUB_TO_ADD_NEG: - * --------------- - * Breaks an ir_binop_sub expression down to add(op0, neg(op1)) - * - * This simplifies expression reassociation, and for many backends - * there is no subtract operation separate from adding the negation. - * For backends with native subtract operations, they will probably - * want to recognize add(op0, neg(op1)) or the other way around to - * produce a subtract anyway. - * - * DIV_TO_MUL_RCP and INT_DIV_TO_MUL_RCP: - * -------------------------------------- - * Breaks an ir_unop_div expression down to op0 * (rcp(op1)). - * - * Many GPUs don't have a divide instruction (945 and 965 included), - * but they do have an RCP instruction to compute an approximate - * reciprocal. By breaking the operation down, constant reciprocals - * can get constant folded. - * - * DIV_TO_MUL_RCP only lowers floating point division; INT_DIV_TO_MUL_RCP - * handles the integer case, converting to and from floating point so that - * RCP is possible. - * - * EXP_TO_EXP2 and LOG_TO_LOG2: - * ---------------------------- - * Many GPUs don't have a base e log or exponent instruction, but they - * do have base 2 versions, so this pass converts exp and log to exp2 - * and log2 operations. - * - * POW_TO_EXP2: - * ----------- - * Many older GPUs don't have an x**y instruction. For these GPUs, convert - * x**y to 2**(y * log2(x)). - * - * MOD_TO_FRACT: - * ------------- - * Breaks an ir_unop_mod expression down to (op1 * fract(op0 / op1)) - * - * Many GPUs don't have a MOD instruction (945 and 965 included), and - * if we have to break it down like this anyway, it gives an - * opportunity to do things like constant fold the (1.0 / op1) easily. - */ - -#include "main/core.h" /* for M_LOG2E */ -#include "glsl_types.h" -#include "ir.h" -#include "ir_optimization.h" - -class lower_instructions_visitor : public ir_hierarchical_visitor { -public: - lower_instructions_visitor(unsigned lower) - : progress(false), lower(lower) { } - - ir_visitor_status visit_leave(ir_expression *); - - bool progress; - -private: - unsigned lower; /** Bitfield of which operations to lower */ - - void sub_to_add_neg(ir_expression *); - void div_to_mul_rcp(ir_expression *); - void int_div_to_mul_rcp(ir_expression *); - void mod_to_fract(ir_expression *); - void exp_to_exp2(ir_expression *); - void pow_to_exp2(ir_expression *); - void log_to_log2(ir_expression *); -}; - -/** - * Determine if a particular type of lowering should occur - */ -#define lowering(x) (this->lower & x) - -bool -lower_instructions(exec_list *instructions, unsigned what_to_lower) -{ - lower_instructions_visitor v(what_to_lower); - - visit_list_elements(&v, instructions); - return v.progress; -} - -void -lower_instructions_visitor::sub_to_add_neg(ir_expression *ir) -{ - ir->operation = ir_binop_add; - ir->operands[1] = new(ir) ir_expression(ir_unop_neg, ir->operands[1]->type, - ir->operands[1], NULL); - this->progress = true; -} - -void -lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir) -{ - assert(ir->operands[1]->type->is_float()); - - /* New expression for the 1.0 / op1 */ - ir_rvalue *expr; - expr = new(ir) ir_expression(ir_unop_rcp, - ir->operands[1]->type, - ir->operands[1]); - - /* op0 / op1 -> op0 * (1.0 / op1) */ - ir->operation = ir_binop_mul; - ir->operands[1] = expr; - - this->progress = true; -} - -void -lower_instructions_visitor::int_div_to_mul_rcp(ir_expression *ir) -{ - assert(ir->operands[1]->type->is_integer()); - - /* Be careful with integer division -- we need to do it as a - * float and re-truncate, since rcp(n > 1) of an integer would - * just be 0. - */ - ir_rvalue *op0, *op1; - const struct glsl_type *vec_type; - - vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, - ir->operands[1]->type->vector_elements, - ir->operands[1]->type->matrix_columns); - - if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) - op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL); - else - op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL); - - op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL); - - vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, - ir->operands[0]->type->vector_elements, - ir->operands[0]->type->matrix_columns); - - if (ir->operands[0]->type->base_type == GLSL_TYPE_INT) - op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL); - else - op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL); - - vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, - ir->type->vector_elements, - ir->type->matrix_columns); - - op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1); - - if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) { - ir->operation = ir_unop_f2i; - ir->operands[0] = op0; - } else { - ir->operation = ir_unop_i2u; - ir->operands[0] = new(ir) ir_expression(ir_unop_f2i, op0); - } - ir->operands[1] = NULL; - - this->progress = true; -} - -void -lower_instructions_visitor::exp_to_exp2(ir_expression *ir) -{ - ir_constant *log2_e = new(ir) ir_constant(float(M_LOG2E)); - - ir->operation = ir_unop_exp2; - ir->operands[0] = new(ir) ir_expression(ir_binop_mul, ir->operands[0]->type, - ir->operands[0], log2_e); - this->progress = true; -} - -void -lower_instructions_visitor::pow_to_exp2(ir_expression *ir) -{ - ir_expression *const log2_x = - new(ir) ir_expression(ir_unop_log2, ir->operands[0]->type, - ir->operands[0]); - - ir->operation = ir_unop_exp2; - ir->operands[0] = new(ir) ir_expression(ir_binop_mul, ir->operands[1]->type, - ir->operands[1], log2_x); - ir->operands[1] = NULL; - this->progress = true; -} - -void -lower_instructions_visitor::log_to_log2(ir_expression *ir) -{ - ir->operation = ir_binop_mul; - ir->operands[0] = new(ir) ir_expression(ir_unop_log2, ir->operands[0]->type, - ir->operands[0], NULL); - ir->operands[1] = new(ir) ir_constant(float(1.0 / M_LOG2E)); - this->progress = true; -} - -void -lower_instructions_visitor::mod_to_fract(ir_expression *ir) -{ - ir_variable *temp = new(ir) ir_variable(ir->operands[1]->type, "mod_b", - ir_var_temporary); - this->base_ir->insert_before(temp); - - ir_assignment *const assign = - new(ir) ir_assignment(new(ir) ir_dereference_variable(temp), - ir->operands[1], NULL); - - this->base_ir->insert_before(assign); - - ir_expression *const div_expr = - new(ir) ir_expression(ir_binop_div, ir->operands[0]->type, - ir->operands[0], - new(ir) ir_dereference_variable(temp)); - - /* Don't generate new IR that would need to be lowered in an additional - * pass. - */ - if (lowering(DIV_TO_MUL_RCP)) - div_to_mul_rcp(div_expr); - - ir_rvalue *expr = new(ir) ir_expression(ir_unop_fract, - ir->operands[0]->type, - div_expr, - NULL); - - ir->operation = ir_binop_mul; - ir->operands[0] = new(ir) ir_dereference_variable(temp); - ir->operands[1] = expr; - this->progress = true; -} - -ir_visitor_status -lower_instructions_visitor::visit_leave(ir_expression *ir) -{ - switch (ir->operation) { - case ir_binop_sub: - if (lowering(SUB_TO_ADD_NEG)) - sub_to_add_neg(ir); - break; - - case ir_binop_div: - if (ir->operands[1]->type->is_integer() && lowering(INT_DIV_TO_MUL_RCP)) - int_div_to_mul_rcp(ir); - else if (ir->operands[1]->type->is_float() && lowering(DIV_TO_MUL_RCP)) - div_to_mul_rcp(ir); - break; - - case ir_unop_exp: - if (lowering(EXP_TO_EXP2)) - exp_to_exp2(ir); - break; - - case ir_unop_log: - if (lowering(LOG_TO_LOG2)) - log_to_log2(ir); - break; - - case ir_binop_mod: - if (lowering(MOD_TO_FRACT) && ir->type->is_float()) - mod_to_fract(ir); - break; - - case ir_binop_pow: - if (lowering(POW_TO_EXP2)) - pow_to_exp2(ir); - break; - - default: - return visit_continue; - } - - return visit_continue; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_jumps.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_jumps.cpp deleted file mode 100644 index 92813f567f1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_jumps.cpp +++ /dev/null @@ -1,1011 +0,0 @@ -/* - * Copyright © 2010 Luca Barbieri - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_jumps.cpp - * - * This pass lowers jumps (break, continue, and return) to if/else structures. - * - * It can be asked to: - * 1. Pull jumps out of ifs where possible - * 2. Remove all "continue"s, replacing them with an "execute flag" - * 3. Replace all "break" with a single conditional one at the end of the loop - * 4. Replace all "return"s with a single return at the end of the function, - * for the main function and/or other functions - * - * Applying this pass gives several benefits: - * 1. All functions can be inlined. - * 2. nv40 and other pre-DX10 chips without "continue" can be supported - * 3. nv30 and other pre-DX10 chips with no control flow at all are better - * supported - * - * Continues are lowered by adding a per-loop "execute flag", initialized to - * true, that when cleared inhibits all execution until the end of the loop. - * - * Breaks are lowered to continues, plus setting a "break flag" that is checked - * at the end of the loop, and trigger the unique "break". - * - * Returns are lowered to breaks/continues, plus adding a "return flag" that - * causes loops to break again out of their enclosing loops until all the - * loops are exited: then the "execute flag" logic will ignore everything - * until the end of the function. - * - * Note that "continue" and "return" can also be implemented by adding - * a dummy loop and using break. - * However, this is bad for hardware with limited nesting depth, and - * prevents further optimization, and thus is not currently performed. - */ - -#include "glsl_types.h" -#include -#include "ir.h" - -/** - * Enum recording the result of analyzing how control flow might exit - * an IR node. - * - * Each possible value of jump_strength indicates a strictly stronger - * guarantee on control flow than the previous value. - * - * The ordering of strengths roughly reflects the way jumps are - * lowered: jumps with higher strength tend to be lowered to jumps of - * lower strength. Accordingly, strength is used as a heuristic to - * determine which lowering to perform first. - * - * This enum is also used by get_jump_strength() to categorize - * instructions as either break, continue, return, or other. When - * used in this fashion, strength_always_clears_execute_flag is not - * used. - * - * The control flow analysis made by this optimization pass makes two - * simplifying assumptions: - * - * - It ignores discard instructions, since they are lowered by a - * separate pass (lower_discard.cpp). - * - * - It assumes it is always possible for control to flow from a loop - * to the instruction immediately following it. Technically, this - * is not true (since all execution paths through the loop might - * jump back to the top, or return from the function). - * - * Both of these simplifying assumtions are safe, since they can never - * cause reachable code to be incorrectly classified as unreachable; - * they can only do the opposite. - */ -enum jump_strength -{ - /** - * Analysis has produced no guarantee on how control flow might - * exit this IR node. It might fall out the bottom (with or - * without clearing the execute flag, if present), or it might - * continue to the top of the innermost enclosing loop, break out - * of it, or return from the function. - */ - strength_none, - - /** - * The only way control can fall out the bottom of this node is - * through a code path that clears the execute flag. It might also - * continue to the top of the innermost enclosing loop, break out - * of it, or return from the function. - */ - strength_always_clears_execute_flag, - - /** - * Control cannot fall out the bottom of this node. It might - * continue to the top of the innermost enclosing loop, break out - * of it, or return from the function. - */ - strength_continue, - - /** - * Control cannot fall out the bottom of this node, or continue the - * top of the innermost enclosing loop. It can only break out of - * it or return from the function. - */ - strength_break, - - /** - * Control cannot fall out the bottom of this node, continue to the - * top of the innermost enclosing loop, or break out of it. It can - * only return from the function. - */ - strength_return -}; - -struct block_record -{ - /* minimum jump strength (of lowered IR, not pre-lowering IR) - * - * If the block ends with a jump, must be the strength of the jump. - * Otherwise, the jump would be dead and have been deleted before) - * - * If the block doesn't end with a jump, it can be different than strength_none if all paths before it lead to some jump - * (e.g. an if with a return in one branch, and a break in the other, while not lowering them) - * Note that identical jumps are usually unified though. - */ - jump_strength min_strength; - - /* can anything clear the execute flag? */ - bool may_clear_execute_flag; - - block_record() - { - this->min_strength = strength_none; - this->may_clear_execute_flag = false; - } -}; - -struct loop_record -{ - ir_function_signature* signature; - ir_loop* loop; - - /* used to avoid lowering the break used to represent lowered breaks */ - unsigned nesting_depth; - bool in_if_at_the_end_of_the_loop; - - bool may_set_return_flag; - - ir_variable* break_flag; - ir_variable* execute_flag; /* cleared to emulate continue */ - - loop_record(ir_function_signature* p_signature = 0, ir_loop* p_loop = 0) - { - this->signature = p_signature; - this->loop = p_loop; - this->nesting_depth = 0; - this->in_if_at_the_end_of_the_loop = false; - this->may_set_return_flag = false; - this->break_flag = 0; - this->execute_flag = 0; - } - - ir_variable* get_execute_flag() - { - /* also supported for the "function loop" */ - if(!this->execute_flag) { - exec_list& list = this->loop ? this->loop->body_instructions : signature->body; - this->execute_flag = new(this->signature) ir_variable(glsl_type::bool_type, "execute_flag", ir_var_temporary); - list.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(execute_flag), new(this->signature) ir_constant(true), 0)); - list.push_head(this->execute_flag); - } - return this->execute_flag; - } - - ir_variable* get_break_flag() - { - assert(this->loop); - if(!this->break_flag) { - this->break_flag = new(this->signature) ir_variable(glsl_type::bool_type, "break_flag", ir_var_temporary); - this->loop->insert_before(this->break_flag); - this->loop->insert_before(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(break_flag), new(this->signature) ir_constant(false), 0)); - } - return this->break_flag; - } -}; - -struct function_record -{ - ir_function_signature* signature; - ir_variable* return_flag; /* used to break out of all loops and then jump to the return instruction */ - ir_variable* return_value; - bool lower_return; - unsigned nesting_depth; - - function_record(ir_function_signature* p_signature = 0, - bool lower_return = false) - { - this->signature = p_signature; - this->return_flag = 0; - this->return_value = 0; - this->nesting_depth = 0; - this->lower_return = lower_return; - } - - ir_variable* get_return_flag() - { - if(!this->return_flag) { - this->return_flag = new(this->signature) ir_variable(glsl_type::bool_type, "return_flag", ir_var_temporary); - this->signature->body.push_head(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(return_flag), new(this->signature) ir_constant(false), 0)); - this->signature->body.push_head(this->return_flag); - } - return this->return_flag; - } - - ir_variable* get_return_value() - { - if(!this->return_value) { - assert(!this->signature->return_type->is_void()); - return_value = new(this->signature) ir_variable(this->signature->return_type, "return_value", ir_var_temporary); - this->signature->body.push_head(this->return_value); - } - return this->return_value; - } -}; - -struct ir_lower_jumps_visitor : public ir_control_flow_visitor { - /* Postconditions: on exit of any visit() function: - * - * ANALYSIS: this->block.min_strength, - * this->block.may_clear_execute_flag, and - * this->loop.may_set_return_flag are updated to reflect the - * characteristics of the visited statement. - * - * DEAD_CODE_ELIMINATION: If this->block.min_strength is not - * strength_none, the visited node is at the end of its exec_list. - * In other words, any unreachable statements that follow the - * visited statement in its exec_list have been removed. - * - * CONTAINED_JUMPS_LOWERED: If the visited statement contains other - * statements, then should_lower_jump() is false for all of the - * return, break, or continue statements it contains. - * - * Note that visiting a jump does not lower it. That is the - * responsibility of the statement (or function signature) that - * contains the jump. - */ - - bool progress; - - struct function_record function; - struct loop_record loop; - struct block_record block; - - bool pull_out_jumps; - bool lower_continue; - bool lower_break; - bool lower_sub_return; - bool lower_main_return; - - ir_lower_jumps_visitor() - { - this->progress = false; - } - - void truncate_after_instruction(exec_node *ir) - { - if (!ir) - return; - - while (!ir->get_next()->is_tail_sentinel()) { - ((ir_instruction *)ir->get_next())->remove(); - this->progress = true; - } - } - - void move_outer_block_inside(ir_instruction *ir, exec_list *inner_block) - { - while (!ir->get_next()->is_tail_sentinel()) { - ir_instruction *move_ir = (ir_instruction *)ir->get_next(); - - move_ir->remove(); - inner_block->push_tail(move_ir); - } - } - - /** - * Insert the instructions necessary to lower a return statement, - * before the given return instruction. - */ - void insert_lowered_return(ir_return *ir) - { - ir_variable* return_flag = this->function.get_return_flag(); - if(!this->function.signature->return_type->is_void()) { - ir_variable* return_value = this->function.get_return_value(); - ir->insert_before( - new(ir) ir_assignment( - new (ir) ir_dereference_variable(return_value), - ir->value)); - } - ir->insert_before( - new(ir) ir_assignment( - new (ir) ir_dereference_variable(return_flag), - new (ir) ir_constant(true))); - this->loop.may_set_return_flag = true; - } - - /** - * If the given instruction is a return, lower it to instructions - * that store the return value (if there is one), set the return - * flag, and then break. - * - * It is safe to pass NULL to this function. - */ - void lower_return_unconditionally(ir_instruction *ir) - { - if (get_jump_strength(ir) != strength_return) { - return; - } - insert_lowered_return((ir_return*)ir); - ir->replace_with(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); - } - - /** - * Create the necessary instruction to replace a break instruction. - */ - ir_instruction *create_lowered_break() - { - void *ctx = this->function.signature; - return new(ctx) ir_assignment( - new(ctx) ir_dereference_variable(this->loop.get_break_flag()), - new(ctx) ir_constant(true), - 0); - } - - /** - * If the given instruction is a break, lower it to an instruction - * that sets the break flag, without consulting - * should_lower_jump(). - * - * It is safe to pass NULL to this function. - */ - void lower_break_unconditionally(ir_instruction *ir) - { - if (get_jump_strength(ir) != strength_break) { - return; - } - ir->replace_with(create_lowered_break()); - } - - /** - * If the block ends in a conditional or unconditional break, lower - * it, even though should_lower_jump() says it needn't be lowered. - */ - void lower_final_breaks(exec_list *block) - { - ir_instruction *ir = (ir_instruction *) block->get_tail(); - lower_break_unconditionally(ir); - ir_if *ir_if = ir->as_if(); - if (ir_if) { - lower_break_unconditionally( - (ir_instruction *) ir_if->then_instructions.get_tail()); - lower_break_unconditionally( - (ir_instruction *) ir_if->else_instructions.get_tail()); - } - } - - virtual void visit(class ir_loop_jump * ir) - { - /* Eliminate all instructions after each one, since they are - * unreachable. This satisfies the DEAD_CODE_ELIMINATION - * postcondition. - */ - truncate_after_instruction(ir); - - /* Set this->block.min_strength based on this instruction. This - * satisfies the ANALYSIS postcondition. It is not necessary to - * update this->block.may_clear_execute_flag or - * this->loop.may_set_return_flag, because an unlowered jump - * instruction can't change any flags. - */ - this->block.min_strength = ir->is_break() ? strength_break : strength_continue; - - /* The CONTAINED_JUMPS_LOWERED postcondition is already - * satisfied, because jump statements can't contain other - * statements. - */ - } - - virtual void visit(class ir_return * ir) - { - /* Eliminate all instructions after each one, since they are - * unreachable. This satisfies the DEAD_CODE_ELIMINATION - * postcondition. - */ - truncate_after_instruction(ir); - - /* Set this->block.min_strength based on this instruction. This - * satisfies the ANALYSIS postcondition. It is not necessary to - * update this->block.may_clear_execute_flag or - * this->loop.may_set_return_flag, because an unlowered return - * instruction can't change any flags. - */ - this->block.min_strength = strength_return; - - /* The CONTAINED_JUMPS_LOWERED postcondition is already - * satisfied, because jump statements can't contain other - * statements. - */ - } - - virtual void visit(class ir_discard * ir) - { - /* Nothing needs to be done. The ANALYSIS and - * DEAD_CODE_ELIMINATION postconditions are already satisfied, - * because discard statements are ignored by this optimization - * pass. The CONTAINED_JUMPS_LOWERED postcondition is already - * satisfied, because discard statements can't contain other - * statements. - */ - (void) ir; - } - - enum jump_strength get_jump_strength(ir_instruction* ir) - { - if(!ir) - return strength_none; - else if(ir->ir_type == ir_type_loop_jump) { - if(((ir_loop_jump*)ir)->is_break()) - return strength_break; - else - return strength_continue; - } else if(ir->ir_type == ir_type_return) - return strength_return; - else - return strength_none; - } - - bool should_lower_jump(ir_jump* ir) - { - unsigned strength = get_jump_strength(ir); - bool lower; - switch(strength) - { - case strength_none: - lower = false; /* don't change this, code relies on it */ - break; - case strength_continue: - lower = lower_continue; - break; - case strength_break: - assert(this->loop.loop); - /* never lower "canonical break" */ - if(ir->get_next()->is_tail_sentinel() && (this->loop.nesting_depth == 0 - || (this->loop.nesting_depth == 1 && this->loop.in_if_at_the_end_of_the_loop))) - lower = false; - else - lower = lower_break; - break; - case strength_return: - /* never lower return at the end of a this->function */ - if(this->function.nesting_depth == 0 && ir->get_next()->is_tail_sentinel()) - lower = false; - else - lower = this->function.lower_return; - break; - } - return lower; - } - - block_record visit_block(exec_list* list) - { - /* Note: since visiting a node may change that node's next - * pointer, we can't use visit_exec_list(), because - * visit_exec_list() caches the node's next pointer before - * visiting it. So we use foreach_list() instead. - * - * foreach_list() isn't safe if the node being visited gets - * removed, but fortunately this visitor doesn't do that. - */ - - block_record saved_block = this->block; - this->block = block_record(); - foreach_list(node, list) { - ((ir_instruction *) node)->accept(this); - } - block_record ret = this->block; - this->block = saved_block; - return ret; - } - - virtual void visit(ir_if *ir) - { - if(this->loop.nesting_depth == 0 && ir->get_next()->is_tail_sentinel()) - this->loop.in_if_at_the_end_of_the_loop = true; - - ++this->function.nesting_depth; - ++this->loop.nesting_depth; - - block_record block_records[2]; - ir_jump* jumps[2]; - - /* Recursively lower nested jumps. This satisfies the - * CONTAINED_JUMPS_LOWERED postcondition, except in the case of - * unconditional jumps at the end of ir->then_instructions and - * ir->else_instructions, which are handled below. - */ - block_records[0] = visit_block(&ir->then_instructions); - block_records[1] = visit_block(&ir->else_instructions); - -retry: /* we get here if we put code after the if inside a branch */ - - /* Determine which of ir->then_instructions and - * ir->else_instructions end with an unconditional jump. - */ - for(unsigned i = 0; i < 2; ++i) { - exec_list& list = i ? ir->else_instructions : ir->then_instructions; - jumps[i] = 0; - if(!list.is_empty() && get_jump_strength((ir_instruction*)list.get_tail())) - jumps[i] = (ir_jump*)list.get_tail(); - } - - /* Loop until we have satisfied the CONTAINED_JUMPS_LOWERED - * postcondition by lowering jumps in both then_instructions and - * else_instructions. - */ - for(;;) { - /* Determine the types of the jumps that terminate - * ir->then_instructions and ir->else_instructions. - */ - jump_strength jump_strengths[2]; - - for(unsigned i = 0; i < 2; ++i) { - if(jumps[i]) { - jump_strengths[i] = block_records[i].min_strength; - assert(jump_strengths[i] == get_jump_strength(jumps[i])); - } else - jump_strengths[i] = strength_none; - } - - /* If both code paths end in a jump, and the jumps are the - * same, and we are pulling out jumps, replace them with a - * single jump that comes after the if instruction. The new - * jump will be visited next, and it will be lowered if - * necessary by the loop or conditional that encloses it. - */ - if(pull_out_jumps && jump_strengths[0] == jump_strengths[1]) { - bool unify = true; - if(jump_strengths[0] == strength_continue) - ir->insert_after(new(ir) ir_loop_jump(ir_loop_jump::jump_continue)); - else if(jump_strengths[0] == strength_break) - ir->insert_after(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); - /* FINISHME: unify returns with identical expressions */ - else if(jump_strengths[0] == strength_return && this->function.signature->return_type->is_void()) - ir->insert_after(new(ir) ir_return(NULL)); - else - unify = false; - - if(unify) { - jumps[0]->remove(); - jumps[1]->remove(); - this->progress = true; - - /* Update jumps[] to reflect the fact that the jumps - * are gone, and update block_records[] to reflect the - * fact that control can now flow to the next - * instruction. - */ - jumps[0] = 0; - jumps[1] = 0; - block_records[0].min_strength = strength_none; - block_records[1].min_strength = strength_none; - - /* The CONTAINED_JUMPS_LOWERED postcondition is now - * satisfied, so we can break out of the loop. - */ - break; - } - } - - /* lower a jump: if both need to lowered, start with the strongest one, so that - * we might later unify the lowered version with the other one - */ - bool should_lower[2]; - for(unsigned i = 0; i < 2; ++i) - should_lower[i] = should_lower_jump(jumps[i]); - - int lower; - if(should_lower[1] && should_lower[0]) - lower = jump_strengths[1] > jump_strengths[0]; - else if(should_lower[0]) - lower = 0; - else if(should_lower[1]) - lower = 1; - else - /* Neither code path ends in a jump that needs to be - * lowered, so the CONTAINED_JUMPS_LOWERED postcondition - * is satisfied and we can break out of the loop. - */ - break; - - if(jump_strengths[lower] == strength_return) { - /* To lower a return, we create a return flag (if the - * function doesn't have one already) and add instructions - * that: 1. store the return value (if this function has a - * non-void return) and 2. set the return flag - */ - insert_lowered_return((ir_return*)jumps[lower]); - if(this->loop.loop) { - /* If we are in a loop, replace the return instruction - * with a break instruction, and then loop so that the - * break instruction can be lowered if necessary. - */ - ir_loop_jump* lowered = 0; - lowered = new(ir) ir_loop_jump(ir_loop_jump::jump_break); - /* Note: we must update block_records and jumps to - * reflect the fact that the control path has been - * altered from a return to a break. - */ - block_records[lower].min_strength = strength_break; - jumps[lower]->replace_with(lowered); - jumps[lower] = lowered; - } else { - /* If we are not in a loop, we then proceed as we would - * for a continue statement (set the execute flag to - * false to prevent the rest of the function from - * executing). - */ - goto lower_continue; - } - this->progress = true; - } else if(jump_strengths[lower] == strength_break) { - /* To lower a break, we create a break flag (if the loop - * doesn't have one already) and add an instruction that - * sets it. - * - * Then we proceed as we would for a continue statement - * (set the execute flag to false to prevent the rest of - * the loop body from executing). - * - * The visit() function for the loop will ensure that the - * break flag is checked after executing the loop body. - */ - jumps[lower]->insert_before(create_lowered_break()); - goto lower_continue; - } else if(jump_strengths[lower] == strength_continue) { -lower_continue: - /* To lower a continue, we create an execute flag (if the - * loop doesn't have one already) and replace the continue - * with an instruction that clears it. - * - * Note that this code path gets exercised when lowering - * return statements that are not inside a loop, so - * this->loop must be initialized even outside of loops. - */ - ir_variable* execute_flag = this->loop.get_execute_flag(); - jumps[lower]->replace_with(new(ir) ir_assignment(new (ir) ir_dereference_variable(execute_flag), new (ir) ir_constant(false), 0)); - /* Note: we must update block_records and jumps to reflect - * the fact that the control path has been altered to an - * instruction that clears the execute flag. - */ - jumps[lower] = 0; - block_records[lower].min_strength = strength_always_clears_execute_flag; - block_records[lower].may_clear_execute_flag = true; - this->progress = true; - - /* Let the loop run again, in case the other branch of the - * if needs to be lowered too. - */ - } - } - - /* move out a jump out if possible */ - if(pull_out_jumps) { - /* If one of the branches ends in a jump, and control cannot - * fall out the bottom of the other branch, then we can move - * the jump after the if. - * - * Set move_out to the branch we are moving a jump out of. - */ - int move_out = -1; - if(jumps[0] && block_records[1].min_strength >= strength_continue) - move_out = 0; - else if(jumps[1] && block_records[0].min_strength >= strength_continue) - move_out = 1; - - if(move_out >= 0) - { - jumps[move_out]->remove(); - ir->insert_after(jumps[move_out]); - /* Note: we must update block_records and jumps to reflect - * the fact that the jump has been moved out of the if. - */ - jumps[move_out] = 0; - block_records[move_out].min_strength = strength_none; - this->progress = true; - } - } - - /* Now satisfy the ANALYSIS postcondition by setting - * this->block.min_strength and - * this->block.may_clear_execute_flag based on the - * characteristics of the two branches. - */ - if(block_records[0].min_strength < block_records[1].min_strength) - this->block.min_strength = block_records[0].min_strength; - else - this->block.min_strength = block_records[1].min_strength; - this->block.may_clear_execute_flag = this->block.may_clear_execute_flag || block_records[0].may_clear_execute_flag || block_records[1].may_clear_execute_flag; - - /* Now we need to clean up the instructions that follow the - * if. - * - * If those instructions are unreachable, then satisfy the - * DEAD_CODE_ELIMINATION postcondition by eliminating them. - * Otherwise that postcondition is already satisfied. - */ - if(this->block.min_strength) - truncate_after_instruction(ir); - else if(this->block.may_clear_execute_flag) - { - /* If the "if" instruction might clear the execute flag, then - * we need to guard any instructions that follow so that they - * are only executed if the execute flag is set. - * - * If one of the branches of the "if" always clears the - * execute flag, and the other branch never clears it, then - * this is easy: just move all the instructions following the - * "if" into the branch that never clears it. - */ - int move_into = -1; - if(block_records[0].min_strength && !block_records[1].may_clear_execute_flag) - move_into = 1; - else if(block_records[1].min_strength && !block_records[0].may_clear_execute_flag) - move_into = 0; - - if(move_into >= 0) { - assert(!block_records[move_into].min_strength && !block_records[move_into].may_clear_execute_flag); /* otherwise, we just truncated */ - - exec_list* list = move_into ? &ir->else_instructions : &ir->then_instructions; - exec_node* next = ir->get_next(); - if(!next->is_tail_sentinel()) { - move_outer_block_inside(ir, list); - - /* If any instructions moved, then we need to visit - * them (since they are now inside the "if"). Since - * block_records[move_into] is in its default state - * (see assertion above), we can safely replace - * block_records[move_into] with the result of this - * analysis. - */ - exec_list list; - list.head = next; - block_records[move_into] = visit_block(&list); - - /* - * Then we need to re-start our jump lowering, since one - * of the instructions we moved might be a jump that - * needs to be lowered. - */ - this->progress = true; - goto retry; - } - } else { - /* If we get here, then the simple case didn't apply; we - * need to actually guard the instructions that follow. - * - * To avoid creating unnecessarily-deep nesting, first - * look through the instructions that follow and unwrap - * any instructions that that are already wrapped in the - * appropriate guard. - */ - ir_instruction* ir_after; - for(ir_after = (ir_instruction*)ir->get_next(); !ir_after->is_tail_sentinel();) - { - ir_if* ir_if = ir_after->as_if(); - if(ir_if && ir_if->else_instructions.is_empty()) { - ir_dereference_variable* ir_if_cond_deref = ir_if->condition->as_dereference_variable(); - if(ir_if_cond_deref && ir_if_cond_deref->var == this->loop.execute_flag) { - ir_instruction* ir_next = (ir_instruction*)ir_after->get_next(); - ir_after->insert_before(&ir_if->then_instructions); - ir_after->remove(); - ir_after = ir_next; - continue; - } - } - ir_after = (ir_instruction*)ir_after->get_next(); - - /* only set this if we find any unprotected instruction */ - this->progress = true; - } - - /* Then, wrap all the instructions that follow in a single - * guard. - */ - if(!ir->get_next()->is_tail_sentinel()) { - assert(this->loop.execute_flag); - ir_if* if_execute = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.execute_flag)); - move_outer_block_inside(ir, &if_execute->then_instructions); - ir->insert_after(if_execute); - } - } - } - --this->loop.nesting_depth; - --this->function.nesting_depth; - } - - virtual void visit(ir_loop *ir) - { - /* Visit the body of the loop, with a fresh data structure in - * this->loop so that the analysis we do here won't bleed into - * enclosing loops. - * - * We assume that all code after a loop is reachable from the - * loop (see comments on enum jump_strength), so the - * DEAD_CODE_ELIMINATION postcondition is automatically - * satisfied, as is the block.min_strength portion of the - * ANALYSIS postcondition. - * - * The block.may_clear_execute_flag portion of the ANALYSIS - * postcondition is automatically satisfied because execute - * flags do not propagate outside of loops. - * - * The loop.may_set_return_flag portion of the ANALYSIS - * postcondition is handled below. - */ - ++this->function.nesting_depth; - loop_record saved_loop = this->loop; - this->loop = loop_record(this->function.signature, ir); - - /* Recursively lower nested jumps. This satisfies the - * CONTAINED_JUMPS_LOWERED postcondition, except in the case of - * an unconditional continue or return at the bottom of the - * loop, which are handled below. - */ - block_record body = visit_block(&ir->body_instructions); - - /* If the loop ends in an unconditional continue, eliminate it - * because it is redundant. - */ - ir_instruction *ir_last - = (ir_instruction *) ir->body_instructions.get_tail(); - if (get_jump_strength(ir_last) == strength_continue) { - ir_last->remove(); - } - - /* If the loop ends in an unconditional return, and we are - * lowering returns, lower it. - */ - if (this->function.lower_return) - lower_return_unconditionally(ir_last); - - if(body.min_strength >= strength_break) { - /* FINISHME: If the min_strength of the loop body is - * strength_break or strength_return, that means that it - * isn't a loop at all, since control flow always leaves the - * body of the loop via break or return. In principle the - * loop could be eliminated in this case. This optimization - * is not implemented yet. - */ - } - - if(this->loop.break_flag) { - /* We only get here if we are lowering breaks */ - assert (lower_break); - - /* If a break flag was generated while visiting the body of - * the loop, then at least one break was lowered, so we need - * to generate an if statement at the end of the loop that - * does a "break" if the break flag is set. The break we - * generate won't violate the CONTAINED_JUMPS_LOWERED - * postcondition, because should_lower_jump() always returns - * false for a break that happens at the end of a loop. - * - * However, if the loop already ends in a conditional or - * unconditional break, then we need to lower that break, - * because it won't be at the end of the loop anymore. - */ - lower_final_breaks(&ir->body_instructions); - - ir_if* break_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.break_flag)); - break_if->then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); - ir->body_instructions.push_tail(break_if); - } - - /* If the body of the loop may set the return flag, then at - * least one return was lowered to a break, so we need to ensure - * that the return flag is checked after the body of the loop is - * executed. - */ - if(this->loop.may_set_return_flag) { - assert(this->function.return_flag); - /* Generate the if statement to check the return flag */ - ir_if* return_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->function.return_flag)); - /* Note: we also need to propagate the knowledge that the - * return flag may get set to the outer context. This - * satisfies the loop.may_set_return_flag part of the - * ANALYSIS postcondition. - */ - saved_loop.may_set_return_flag = true; - if(saved_loop.loop) - /* If this loop is nested inside another one, then the if - * statement that we generated should break out of that - * loop if the return flag is set. Caller will lower that - * break statement if necessary. - */ - return_if->then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); - else - /* Otherwise, all we need to do is ensure that the - * instructions that follow are only executed if the - * return flag is clear. We can do that by moving those - * instructions into the else clause of the generated if - * statement. - */ - move_outer_block_inside(ir, &return_if->else_instructions); - ir->insert_after(return_if); - } - - this->loop = saved_loop; - --this->function.nesting_depth; - } - - virtual void visit(ir_function_signature *ir) - { - /* these are not strictly necessary */ - assert(!this->function.signature); - assert(!this->loop.loop); - - bool lower_return; - if (strcmp(ir->function_name(), "main") == 0) - lower_return = lower_main_return; - else - lower_return = lower_sub_return; - - function_record saved_function = this->function; - loop_record saved_loop = this->loop; - this->function = function_record(ir, lower_return); - this->loop = loop_record(ir); - - assert(!this->loop.loop); - - /* Visit the body of the function to lower any jumps that occur - * in it, except possibly an unconditional return statement at - * the end of it. - */ - visit_block(&ir->body); - - /* If the body ended in an unconditional return of non-void, - * then we don't need to lower it because it's the one canonical - * return. - * - * If the body ended in a return of void, eliminate it because - * it is redundant. - */ - if (ir->return_type->is_void() && - get_jump_strength((ir_instruction *) ir->body.get_tail())) { - ir_jump *jump = (ir_jump *) ir->body.get_tail(); - assert (jump->ir_type == ir_type_return); - jump->remove(); - } - - if(this->function.return_value) - ir->body.push_tail(new(ir) ir_return(new (ir) ir_dereference_variable(this->function.return_value))); - - this->loop = saved_loop; - this->function = saved_function; - } - - virtual void visit(class ir_function * ir) - { - visit_block(&ir->signatures); - } -}; - -bool -do_lower_jumps(exec_list *instructions, bool pull_out_jumps, bool lower_sub_return, bool lower_main_return, bool lower_continue, bool lower_break) -{ - ir_lower_jumps_visitor v; - v.pull_out_jumps = pull_out_jumps; - v.lower_continue = lower_continue; - v.lower_break = lower_break; - v.lower_sub_return = lower_sub_return; - v.lower_main_return = lower_main_return; - - do { - v.progress = false; - visit_exec_list(instructions, &v); - } while (v.progress); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_mat_op_to_vec.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_mat_op_to_vec.cpp deleted file mode 100644 index a371afc14c2..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_mat_op_to_vec.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_mat_op_to_vec.cpp - * - * Breaks matrix operation expressions down to a series of vector operations. - * - * Generally this is how we have to codegen matrix operations for a - * GPU, so this gives us the chance to constant fold operations on a - * column or row. - */ - -#include "ir.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" - -class ir_mat_op_to_vec_visitor : public ir_hierarchical_visitor { -public: - ir_mat_op_to_vec_visitor() - { - this->made_progress = false; - this->mem_ctx = NULL; - } - - ir_visitor_status visit_leave(ir_assignment *); - - ir_dereference *get_column(ir_dereference *val, int col); - ir_rvalue *get_element(ir_dereference *val, int col, int row); - - void do_mul_mat_mat(ir_dereference *result, - ir_dereference *a, ir_dereference *b); - void do_mul_mat_vec(ir_dereference *result, - ir_dereference *a, ir_dereference *b); - void do_mul_vec_mat(ir_dereference *result, - ir_dereference *a, ir_dereference *b); - void do_mul_mat_scalar(ir_dereference *result, - ir_dereference *a, ir_dereference *b); - void do_equal_mat_mat(ir_dereference *result, ir_dereference *a, - ir_dereference *b, bool test_equal); - - void *mem_ctx; - bool made_progress; -}; - -static bool -mat_op_to_vec_predicate(ir_instruction *ir) -{ - ir_expression *expr = ir->as_expression(); - unsigned int i; - - if (!expr) - return false; - - for (i = 0; i < expr->get_num_operands(); i++) { - if (expr->operands[i]->type->is_matrix()) - return true; - } - - return false; -} - -bool -do_mat_op_to_vec(exec_list *instructions) -{ - ir_mat_op_to_vec_visitor v; - - /* Pull out any matrix expression to a separate assignment to a - * temp. This will make our handling of the breakdown to - * operations on the matrix's vector components much easier. - */ - do_expression_flattening(instructions, mat_op_to_vec_predicate); - - visit_list_elements(&v, instructions); - - return v.made_progress; -} - -ir_rvalue * -ir_mat_op_to_vec_visitor::get_element(ir_dereference *val, int col, int row) -{ - val = get_column(val, col); - - return new(mem_ctx) ir_swizzle(val, row, 0, 0, 0, 1); -} - -ir_dereference * -ir_mat_op_to_vec_visitor::get_column(ir_dereference *val, int row) -{ - val = val->clone(mem_ctx, NULL); - - if (val->type->is_matrix()) { - val = new(mem_ctx) ir_dereference_array(val, - new(mem_ctx) ir_constant(row)); - } - - return val; -} - -void -ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_dereference *result, - ir_dereference *a, - ir_dereference *b) -{ - int b_col, i; - ir_assignment *assign; - ir_expression *expr; - - for (b_col = 0; b_col < b->type->matrix_columns; b_col++) { - /* first column */ - expr = new(mem_ctx) ir_expression(ir_binop_mul, - get_column(a, 0), - get_element(b, b_col, 0)); - - /* following columns */ - for (i = 1; i < a->type->matrix_columns; i++) { - ir_expression *mul_expr; - - mul_expr = new(mem_ctx) ir_expression(ir_binop_mul, - get_column(a, i), - get_element(b, b_col, i)); - expr = new(mem_ctx) ir_expression(ir_binop_add, - expr, - mul_expr); - } - - assign = new(mem_ctx) ir_assignment(get_column(result, b_col), expr); - base_ir->insert_before(assign); - } -} - -void -ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_dereference *result, - ir_dereference *a, - ir_dereference *b) -{ - int i; - ir_assignment *assign; - ir_expression *expr; - - /* first column */ - expr = new(mem_ctx) ir_expression(ir_binop_mul, - get_column(a, 0), - get_element(b, 0, 0)); - - /* following columns */ - for (i = 1; i < a->type->matrix_columns; i++) { - ir_expression *mul_expr; - - mul_expr = new(mem_ctx) ir_expression(ir_binop_mul, - get_column(a, i), - get_element(b, 0, i)); - expr = new(mem_ctx) ir_expression(ir_binop_add, expr, mul_expr); - } - - result = result->clone(mem_ctx, NULL); - assign = new(mem_ctx) ir_assignment(result, expr); - base_ir->insert_before(assign); -} - -void -ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_dereference *result, - ir_dereference *a, - ir_dereference *b) -{ - int i; - - for (i = 0; i < b->type->matrix_columns; i++) { - ir_rvalue *column_result; - ir_expression *column_expr; - ir_assignment *column_assign; - - column_result = result->clone(mem_ctx, NULL); - column_result = new(mem_ctx) ir_swizzle(column_result, i, 0, 0, 0, 1); - - column_expr = new(mem_ctx) ir_expression(ir_binop_dot, - a->clone(mem_ctx, NULL), - get_column(b, i)); - - column_assign = new(mem_ctx) ir_assignment(column_result, - column_expr); - base_ir->insert_before(column_assign); - } -} - -void -ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_dereference *result, - ir_dereference *a, - ir_dereference *b) -{ - int i; - - for (i = 0; i < a->type->matrix_columns; i++) { - ir_expression *column_expr; - ir_assignment *column_assign; - - column_expr = new(mem_ctx) ir_expression(ir_binop_mul, - get_column(a, i), - b->clone(mem_ctx, NULL)); - - column_assign = new(mem_ctx) ir_assignment(get_column(result, i), - column_expr); - base_ir->insert_before(column_assign); - } -} - -void -ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_dereference *result, - ir_dereference *a, - ir_dereference *b, - bool test_equal) -{ - /* This essentially implements the following GLSL: - * - * bool equal(mat4 a, mat4 b) - * { - * return !any(bvec4(a[0] != b[0], - * a[1] != b[1], - * a[2] != b[2], - * a[3] != b[3]); - * } - * - * bool nequal(mat4 a, mat4 b) - * { - * return any(bvec4(a[0] != b[0], - * a[1] != b[1], - * a[2] != b[2], - * a[3] != b[3]); - * } - */ - const unsigned columns = a->type->matrix_columns; - const glsl_type *const bvec_type = - glsl_type::get_instance(GLSL_TYPE_BOOL, columns, 1); - - ir_variable *const tmp_bvec = - new(this->mem_ctx) ir_variable(bvec_type, "mat_cmp_bvec", - ir_var_temporary); - this->base_ir->insert_before(tmp_bvec); - - for (unsigned i = 0; i < columns; i++) { - ir_expression *const cmp = - new(this->mem_ctx) ir_expression(ir_binop_any_nequal, - get_column(a, i), - get_column(b, i)); - - ir_dereference *const lhs = - new(this->mem_ctx) ir_dereference_variable(tmp_bvec); - - ir_assignment *const assign = - new(this->mem_ctx) ir_assignment(lhs, cmp, NULL, (1U << i)); - - this->base_ir->insert_before(assign); - } - - ir_rvalue *const val = new(this->mem_ctx) ir_dereference_variable(tmp_bvec); - ir_expression *any = new(this->mem_ctx) ir_expression(ir_unop_any, val); - - if (test_equal) - any = new(this->mem_ctx) ir_expression(ir_unop_logic_not, any); - - ir_assignment *const assign = - new(mem_ctx) ir_assignment(result->clone(mem_ctx, NULL), any); - base_ir->insert_before(assign); -} - -static bool -has_matrix_operand(const ir_expression *expr, unsigned &columns) -{ - for (unsigned i = 0; i < expr->get_num_operands(); i++) { - if (expr->operands[i]->type->is_matrix()) { - columns = expr->operands[i]->type->matrix_columns; - return true; - } - } - - return false; -} - - -ir_visitor_status -ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign) -{ - ir_expression *orig_expr = orig_assign->rhs->as_expression(); - unsigned int i, matrix_columns = 1; - ir_dereference *op[2]; - - if (!orig_expr) - return visit_continue; - - if (!has_matrix_operand(orig_expr, matrix_columns)) - return visit_continue; - - assert(orig_expr->get_num_operands() <= 2); - - mem_ctx = ralloc_parent(orig_assign); - - ir_dereference_variable *result = - orig_assign->lhs->as_dereference_variable(); - assert(result); - - /* Store the expression operands in temps so we can use them - * multiple times. - */ - for (i = 0; i < orig_expr->get_num_operands(); i++) { - ir_assignment *assign; - ir_dereference *deref = orig_expr->operands[i]->as_dereference(); - - /* Avoid making a temporary if we don't need to to avoid aliasing. */ - if (deref && - deref->variable_referenced() != result->variable_referenced()) { - op[i] = deref; - continue; - } - - /* Otherwise, store the operand in a temporary generally if it's - * not a dereference. - */ - ir_variable *var = new(mem_ctx) ir_variable(orig_expr->operands[i]->type, - "mat_op_to_vec", - ir_var_temporary); - base_ir->insert_before(var); - - /* Note that we use this dereference for the assignment. That means - * that others that want to use op[i] have to clone the deref. - */ - op[i] = new(mem_ctx) ir_dereference_variable(var); - assign = new(mem_ctx) ir_assignment(op[i], orig_expr->operands[i]); - base_ir->insert_before(assign); - } - - /* OK, time to break down this matrix operation. */ - switch (orig_expr->operation) { - case ir_unop_neg: { - /* Apply the operation to each column.*/ - for (i = 0; i < matrix_columns; i++) { - ir_expression *column_expr; - ir_assignment *column_assign; - - column_expr = new(mem_ctx) ir_expression(orig_expr->operation, - get_column(op[0], i)); - - column_assign = new(mem_ctx) ir_assignment(get_column(result, i), - column_expr); - assert(column_assign->write_mask != 0); - base_ir->insert_before(column_assign); - } - break; - } - case ir_binop_add: - case ir_binop_sub: - case ir_binop_div: - case ir_binop_mod: { - /* For most operations, the matrix version is just going - * column-wise through and applying the operation to each column - * if available. - */ - for (i = 0; i < matrix_columns; i++) { - ir_expression *column_expr; - ir_assignment *column_assign; - - column_expr = new(mem_ctx) ir_expression(orig_expr->operation, - get_column(op[0], i), - get_column(op[1], i)); - - column_assign = new(mem_ctx) ir_assignment(get_column(result, i), - column_expr); - assert(column_assign->write_mask != 0); - base_ir->insert_before(column_assign); - } - break; - } - case ir_binop_mul: - if (op[0]->type->is_matrix()) { - if (op[1]->type->is_matrix()) { - do_mul_mat_mat(result, op[0], op[1]); - } else if (op[1]->type->is_vector()) { - do_mul_mat_vec(result, op[0], op[1]); - } else { - assert(op[1]->type->is_scalar()); - do_mul_mat_scalar(result, op[0], op[1]); - } - } else { - assert(op[1]->type->is_matrix()); - if (op[0]->type->is_vector()) { - do_mul_vec_mat(result, op[0], op[1]); - } else { - assert(op[0]->type->is_scalar()); - do_mul_mat_scalar(result, op[1], op[0]); - } - } - break; - - case ir_binop_all_equal: - case ir_binop_any_nequal: - do_equal_mat_mat(result, op[1], op[0], - (orig_expr->operation == ir_binop_all_equal)); - break; - - default: - printf("FINISHME: Handle matrix operation for %s\n", - orig_expr->operator_string()); - abort(); - } - orig_assign->remove(); - this->made_progress = true; - - return visit_continue; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_noise.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_noise.cpp deleted file mode 100644 index 85f59b675e0..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_noise.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_noise.cpp - * IR lower pass to remove noise opcodes. - * - * \author Ian Romanick - */ - -#include "ir.h" -#include "ir_rvalue_visitor.h" - -class lower_noise_visitor : public ir_rvalue_visitor { -public: - lower_noise_visitor() : progress(false) - { - /* empty */ - } - - void handle_rvalue(ir_rvalue **rvalue) - { - if (!*rvalue) - return; - - ir_expression *expr = (*rvalue)->as_expression(); - if (!expr) - return; - - /* In the future, ir_unop_noise may be replaced by a call to a function - * that implements noise. No hardware has a noise instruction. - */ - if (expr->operation == ir_unop_noise) { - *rvalue = ir_constant::zero(ralloc_parent(expr), expr->type); - this->progress = true; - } - } - - bool progress; -}; - - -bool -lower_noise(exec_list *instructions) -{ - lower_noise_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_output_reads.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_output_reads.cpp deleted file mode 100644 index 415b541c3ef..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_output_reads.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright © 2012 Vincent Lejeune - * Copyright © 2012 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir.h" -#include "program/hash_table.h" - -/** - * \file lower_output_reads.cpp - * - * In GLSL, shader output variables (such as varyings) can be both read and - * written. However, on some hardware, reading an output register causes - * trouble. - * - * This pass creates temporary shadow copies of every (used) shader output, - * and replaces all accesses to use those instead. It also adds code to the - * main() function to copy the final values to the actual shader outputs. - */ - -class output_read_remover : public ir_hierarchical_visitor { -protected: - /** - * A hash table mapping from the original ir_variable shader outputs - * (ir_var_out mode) to the new temporaries to be used instead. - */ - hash_table *replacements; - - void *mem_ctx; -public: - output_read_remover(); - ~output_read_remover(); - virtual ir_visitor_status visit(class ir_dereference_variable *); - virtual ir_visitor_status visit_leave(class ir_return *); - virtual ir_visitor_status visit_leave(class ir_function_signature *); -}; - -output_read_remover::output_read_remover() -{ - mem_ctx = ralloc_context(NULL); - replacements = - hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); -} - -output_read_remover::~output_read_remover() -{ - hash_table_dtor(replacements); - ralloc_free(mem_ctx); -} - -ir_visitor_status -output_read_remover::visit(ir_dereference_variable *ir) -{ - if (ir->var->mode != ir_var_out) - return visit_continue; - - ir_variable *temp = (ir_variable *) hash_table_find(replacements, ir->var); - - /* If we don't have an existing temporary, create one. */ - if (temp == NULL) { - void *var_ctx = ralloc_parent(ir->var); - temp = new(var_ctx) ir_variable(ir->var->type, ir->var->name, - ir_var_temporary); - hash_table_insert(replacements, temp, ir->var); - } - - /* Update the dereference to use the temporary */ - ir->var = temp; - - return visit_continue; -} - -/** - * Create an assignment to copy a temporary value back to the actual output. - */ -static ir_assignment * -copy(void *ctx, ir_variable *output, ir_variable *temp) -{ - ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(output); - ir_dereference_variable *rhs = new(ctx) ir_dereference_variable(temp); - return new(ctx) ir_assignment(lhs, rhs); -} - -/** Insert a copy-back assignment before a "return" statement */ -static void -emit_return_copy(const void *key, void *data, void *closure) -{ - ir_return *ir = (ir_return *) closure; - ir->insert_before(copy(ir, (ir_variable *) key, (ir_variable *) data)); -} - -/** Insert a copy-back assignment at the end of the main() function */ -static void -emit_main_copy(const void *key, void *data, void *closure) -{ - ir_function_signature *sig = (ir_function_signature *) closure; - sig->body.push_tail(copy(sig, (ir_variable *) key, (ir_variable *) data)); -} - -ir_visitor_status -output_read_remover::visit_leave(ir_return *ir) -{ - hash_table_call_foreach(replacements, emit_return_copy, ir); - return visit_continue; -} - -ir_visitor_status -output_read_remover::visit_leave(ir_function_signature *sig) -{ - if (strcmp(sig->function_name(), "main") != 0) - return visit_continue; - - hash_table_call_foreach(replacements, emit_main_copy, sig); - return visit_continue; -} - -void -lower_output_reads(exec_list *instructions) -{ - output_read_remover v; - visit_list_elements(&v, instructions); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_texture_projection.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_texture_projection.cpp deleted file mode 100644 index 6e3aaecceee..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_texture_projection.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_texture_projection.cpp - * - * IR lower pass to perform the division of texture coordinates by the texture - * projector if present. - * - * Many GPUs have a texture sampling opcode that takes the projector - * and does the divide internally, thus the presence of the projector - * in the IR. For GPUs that don't, this saves the driver needing the - * logic for handling the divide. - * - * \author Eric Anholt - */ - -#include "ir.h" - -class lower_texture_projection_visitor : public ir_hierarchical_visitor { -public: - lower_texture_projection_visitor() - { - progress = false; - } - - ir_visitor_status visit_leave(ir_texture *ir); - - bool progress; -}; - -ir_visitor_status -lower_texture_projection_visitor::visit_leave(ir_texture *ir) -{ - if (!ir->projector) - return visit_continue; - - void *mem_ctx = ralloc_parent(ir); - - ir_variable *var = new(mem_ctx) ir_variable(ir->projector->type, - "projector", ir_var_auto); - base_ir->insert_before(var); - ir_dereference *deref = new(mem_ctx) ir_dereference_variable(var); - ir_expression *expr = new(mem_ctx) ir_expression(ir_unop_rcp, - ir->projector->type, - ir->projector, - NULL); - ir_assignment *assign = new(mem_ctx) ir_assignment(deref, expr, NULL); - base_ir->insert_before(assign); - - deref = new(mem_ctx) ir_dereference_variable(var); - ir->coordinate = new(mem_ctx) ir_expression(ir_binop_mul, - ir->coordinate->type, - ir->coordinate, - deref); - - if (ir->shadow_comparitor) { - deref = new(mem_ctx) ir_dereference_variable(var); - ir->shadow_comparitor = new(mem_ctx) ir_expression(ir_binop_mul, - ir->shadow_comparitor->type, - ir->shadow_comparitor, - deref); - } - - ir->projector = NULL; - - progress = true; - return visit_continue; -} - -bool -do_lower_texture_projection(exec_list *instructions) -{ - lower_texture_projection_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_variable_index_to_cond_assign.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_variable_index_to_cond_assign.cpp deleted file mode 100644 index f8e4a1de428..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_variable_index_to_cond_assign.cpp +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Copyright © 2010 Luca Barbieri - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_variable_index_to_cond_assign.cpp - * - * Turns non-constant indexing into array types to a series of - * conditional moves of each element into a temporary. - * - * Pre-DX10 GPUs often don't have a native way to do this operation, - * and this works around that. - * - * The lowering process proceeds as follows. Each non-constant index - * found in an r-value is converted to a canonical form \c array[i]. Each - * element of the array is conditionally assigned to a temporary by comparing - * \c i to a constant index. This is done by cloning the canonical form and - * replacing all occurances of \c i with a constant. Each remaining occurance - * of the canonical form in the IR is replaced with a dereference of the - * temporary variable. - * - * L-values with non-constant indices are handled similarly. In this case, - * the RHS of the assignment is assigned to a temporary. The non-constant - * index is replace with the canonical form (just like for r-values). The - * temporary is conditionally assigned to each element of the canonical form - * by comparing \c i with each index. The same clone-and-replace scheme is - * used. - */ - -#include "ir.h" -#include "ir_rvalue_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" -#include "main/macros.h" - -/** - * Generate a comparison value for a block of indices - * - * Lowering passes for non-constant indexing of arrays, matrices, or vectors - * can use this to generate blocks of index comparison values. - * - * \param instructions List where new instructions will be appended - * \param index \c ir_variable containing the desired index - * \param base Base value for this block of comparisons - * \param components Number of unique index values to compare. This must - * be on the range [1, 4]. - * \param mem_ctx ralloc memory context to be used for all allocations. - * - * \returns - * An \c ir_rvalue that \b must be cloned for each use in conditional - * assignments, etc. - */ -ir_rvalue * -compare_index_block(exec_list *instructions, ir_variable *index, - unsigned base, unsigned components, void *mem_ctx) -{ - ir_rvalue *broadcast_index = new(mem_ctx) ir_dereference_variable(index); - - assert(index->type->is_scalar()); - assert(index->type->base_type == GLSL_TYPE_INT); - assert(components >= 1 && components <= 4); - - if (components > 1) { - const ir_swizzle_mask m = { 0, 0, 0, 0, components, false }; - broadcast_index = new(mem_ctx) ir_swizzle(broadcast_index, m); - } - - /* Compare the desired index value with the next block of four indices. - */ - ir_constant_data test_indices_data; - memset(&test_indices_data, 0, sizeof(test_indices_data)); - test_indices_data.i[0] = base; - test_indices_data.i[1] = base + 1; - test_indices_data.i[2] = base + 2; - test_indices_data.i[3] = base + 3; - - ir_constant *const test_indices = - new(mem_ctx) ir_constant(broadcast_index->type, - &test_indices_data); - - ir_rvalue *const condition_val = - new(mem_ctx) ir_expression(ir_binop_equal, - &glsl_type::bool_type[components - 1], - broadcast_index, - test_indices); - - ir_variable *const condition = - new(mem_ctx) ir_variable(condition_val->type, - "dereference_condition", - ir_var_temporary); - instructions->push_tail(condition); - - ir_rvalue *const cond_deref = - new(mem_ctx) ir_dereference_variable(condition); - instructions->push_tail(new(mem_ctx) ir_assignment(cond_deref, condition_val, 0)); - - return cond_deref; -} - -static inline bool -is_array_or_matrix(const ir_instruction *ir) -{ - return (ir->type->is_array() || ir->type->is_matrix()); -} - -/** - * Replace a dereference of a variable with a specified r-value - * - * Each time a dereference of the specified value is replaced, the r-value - * tree is cloned. - */ -class deref_replacer : public ir_rvalue_visitor { -public: - deref_replacer(const ir_variable *variable_to_replace, ir_rvalue *value) - : variable_to_replace(variable_to_replace), value(value), - progress(false) - { - assert(this->variable_to_replace != NULL); - assert(this->value != NULL); - } - - virtual void handle_rvalue(ir_rvalue **rvalue) - { - ir_dereference_variable *const dv = (*rvalue)->as_dereference_variable(); - - if ((dv != NULL) && (dv->var == this->variable_to_replace)) { - this->progress = true; - *rvalue = this->value->clone(ralloc_parent(*rvalue), NULL); - } - } - - const ir_variable *variable_to_replace; - ir_rvalue *value; - bool progress; -}; - -/** - * Find a variable index dereference of an array in an rvalue tree - */ -class find_variable_index : public ir_hierarchical_visitor { -public: - find_variable_index() - : deref(NULL) - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_dereference_array *ir) - { - if (is_array_or_matrix(ir->array) - && (ir->array_index->as_constant() == NULL)) { - this->deref = ir; - return visit_stop; - } - - return visit_continue; - } - - /** - * First array dereference found in the tree that has a non-constant index. - */ - ir_dereference_array *deref; -}; - -struct assignment_generator -{ - ir_instruction* base_ir; - ir_dereference *rvalue; - ir_variable *old_index; - bool is_write; - unsigned int write_mask; - ir_variable* var; - - assignment_generator() - { - } - - void generate(unsigned i, ir_rvalue* condition, exec_list *list) const - { - /* Just clone the rest of the deref chain when trying to get at the - * underlying variable. - */ - void *mem_ctx = ralloc_parent(base_ir); - - /* Clone the old r-value in its entirety. Then replace any occurances of - * the old variable index with the new constant index. - */ - ir_dereference *element = this->rvalue->clone(mem_ctx, NULL); - ir_constant *const index = new(mem_ctx) ir_constant(i); - deref_replacer r(this->old_index, index); - element->accept(&r); - assert(r.progress); - - /* Generate a conditional assignment to (or from) the constant indexed - * array dereference. - */ - ir_rvalue *variable = new(mem_ctx) ir_dereference_variable(this->var); - ir_assignment *const assignment = (is_write) - ? new(mem_ctx) ir_assignment(element, variable, condition, write_mask) - : new(mem_ctx) ir_assignment(variable, element, condition); - - list->push_tail(assignment); - } -}; - -struct switch_generator -{ - /* make TFunction a template parameter if you need to use other generators */ - typedef assignment_generator TFunction; - const TFunction& generator; - - ir_variable* index; - unsigned linear_sequence_max_length; - unsigned condition_components; - - void *mem_ctx; - - switch_generator(const TFunction& generator, ir_variable *index, - unsigned linear_sequence_max_length, - unsigned condition_components) - : generator(generator), index(index), - linear_sequence_max_length(linear_sequence_max_length), - condition_components(condition_components) - { - this->mem_ctx = ralloc_parent(index); - } - - void linear_sequence(unsigned begin, unsigned end, exec_list *list) - { - if (begin == end) - return; - - /* If the array access is a read, read the first element of this subregion - * unconditionally. The remaining tests will possibly overwrite this - * value with one of the other array elements. - * - * This optimization cannot be done for writes because it will cause the - * first element of the subregion to be written possibly *in addition* to - * one of the other elements. - */ - unsigned first; - if (!this->generator.is_write) { - this->generator.generate(begin, 0, list); - first = begin + 1; - } else { - first = begin; - } - - for (unsigned i = first; i < end; i += 4) { - const unsigned comps = MIN2(condition_components, end - i); - - ir_rvalue *const cond_deref = - compare_index_block(list, index, i, comps, this->mem_ctx); - - if (comps == 1) { - this->generator.generate(i, cond_deref->clone(this->mem_ctx, NULL), - list); - } else { - for (unsigned j = 0; j < comps; j++) { - ir_rvalue *const cond_swiz = - new(this->mem_ctx) ir_swizzle(cond_deref->clone(this->mem_ctx, NULL), - j, 0, 0, 0, 1); - - this->generator.generate(i + j, cond_swiz, list); - } - } - } - } - - void bisect(unsigned begin, unsigned end, exec_list *list) - { - unsigned middle = (begin + end) >> 1; - - assert(index->type->is_integer()); - - ir_constant *const middle_c = (index->type->base_type == GLSL_TYPE_UINT) - ? new(this->mem_ctx) ir_constant((unsigned)middle) - : new(this->mem_ctx) ir_constant((int)middle); - - - ir_dereference_variable *deref = - new(this->mem_ctx) ir_dereference_variable(this->index); - - ir_expression *less = - new(this->mem_ctx) ir_expression(ir_binop_less, glsl_type::bool_type, - deref, middle_c); - - ir_if *if_less = new(this->mem_ctx) ir_if(less); - - generate(begin, middle, &if_less->then_instructions); - generate(middle, end, &if_less->else_instructions); - - list->push_tail(if_less); - } - - void generate(unsigned begin, unsigned end, exec_list *list) - { - unsigned length = end - begin; - if (length <= this->linear_sequence_max_length) - return linear_sequence(begin, end, list); - else - return bisect(begin, end, list); - } -}; - -/** - * Visitor class for replacing expressions with ir_constant values. - */ - -class variable_index_to_cond_assign_visitor : public ir_rvalue_visitor { -public: - variable_index_to_cond_assign_visitor(bool lower_input, - bool lower_output, - bool lower_temp, - bool lower_uniform) - { - this->progress = false; - this->lower_inputs = lower_input; - this->lower_outputs = lower_output; - this->lower_temps = lower_temp; - this->lower_uniforms = lower_uniform; - } - - bool progress; - bool lower_inputs; - bool lower_outputs; - bool lower_temps; - bool lower_uniforms; - - bool storage_type_needs_lowering(ir_dereference_array *deref) const - { - /* If a variable isn't eventually the target of this dereference, then - * it must be a constant or some sort of anonymous temporary storage. - * - * FINISHME: Is this correct? Most drivers treat arrays of constants as - * FINISHME: uniforms. It seems like this should do the same. - */ - const ir_variable *const var = deref->array->variable_referenced(); - if (var == NULL) - return this->lower_temps; - - switch (var->mode) { - case ir_var_auto: - case ir_var_temporary: - return this->lower_temps; - case ir_var_uniform: - return this->lower_uniforms; - case ir_var_in: - case ir_var_const_in: - return (var->location == -1) ? this->lower_temps : this->lower_inputs; - case ir_var_out: - return (var->location == -1) ? this->lower_temps : this->lower_outputs; - case ir_var_inout: - return this->lower_temps; - } - - assert(!"Should not get here."); - return false; - } - - bool needs_lowering(ir_dereference_array *deref) const - { - if (deref == NULL || deref->array_index->as_constant() - || !is_array_or_matrix(deref->array)) - return false; - - return this->storage_type_needs_lowering(deref); - } - - ir_variable *convert_dereference_array(ir_dereference_array *orig_deref, - ir_assignment* orig_assign, - ir_dereference *orig_base) - { - assert(is_array_or_matrix(orig_deref->array)); - - const unsigned length = (orig_deref->array->type->is_array()) - ? orig_deref->array->type->length - : orig_deref->array->type->matrix_columns; - - void *const mem_ctx = ralloc_parent(base_ir); - - /* Temporary storage for either the result of the dereference of - * the array, or the RHS that's being assigned into the - * dereference of the array. - */ - ir_variable *var; - - if (orig_assign) { - var = new(mem_ctx) ir_variable(orig_assign->rhs->type, - "dereference_array_value", - ir_var_temporary); - base_ir->insert_before(var); - - ir_dereference *lhs = new(mem_ctx) ir_dereference_variable(var); - ir_assignment *assign = new(mem_ctx) ir_assignment(lhs, - orig_assign->rhs, - NULL); - - base_ir->insert_before(assign); - } else { - var = new(mem_ctx) ir_variable(orig_deref->type, - "dereference_array_value", - ir_var_temporary); - base_ir->insert_before(var); - } - - /* Store the index to a temporary to avoid reusing its tree. */ - ir_variable *index = - new(mem_ctx) ir_variable(orig_deref->array_index->type, - "dereference_array_index", ir_var_temporary); - base_ir->insert_before(index); - - ir_dereference *lhs = new(mem_ctx) ir_dereference_variable(index); - ir_assignment *assign = - new(mem_ctx) ir_assignment(lhs, orig_deref->array_index, NULL); - base_ir->insert_before(assign); - - orig_deref->array_index = lhs->clone(mem_ctx, NULL); - - assignment_generator ag; - ag.rvalue = orig_base; - ag.base_ir = base_ir; - ag.old_index = index; - ag.var = var; - if (orig_assign) { - ag.is_write = true; - ag.write_mask = orig_assign->write_mask; - } else { - ag.is_write = false; - } - - switch_generator sg(ag, index, 4, 4); - - /* If the original assignment has a condition, respect that original - * condition! This is acomplished by wrapping the new conditional - * assignments in an if-statement that uses the original condition. - */ - if ((orig_assign != NULL) && (orig_assign->condition != NULL)) { - /* No need to clone the condition because the IR that it hangs on is - * going to be removed from the instruction sequence. - */ - ir_if *if_stmt = new(mem_ctx) ir_if(orig_assign->condition); - - sg.generate(0, length, &if_stmt->then_instructions); - base_ir->insert_before(if_stmt); - } else { - exec_list list; - - sg.generate(0, length, &list); - base_ir->insert_before(&list); - } - - return var; - } - - virtual void handle_rvalue(ir_rvalue **pir) - { - if (this->in_assignee) - return; - - if (!*pir) - return; - - ir_dereference_array* orig_deref = (*pir)->as_dereference_array(); - if (needs_lowering(orig_deref)) { - ir_variable *var = - convert_dereference_array(orig_deref, NULL, orig_deref); - assert(var); - *pir = new(ralloc_parent(base_ir)) ir_dereference_variable(var); - this->progress = true; - } - } - - ir_visitor_status - visit_leave(ir_assignment *ir) - { - ir_rvalue_visitor::visit_leave(ir); - - find_variable_index f; - ir->lhs->accept(&f); - - if ((f.deref != NULL) && storage_type_needs_lowering(f.deref)) { - convert_dereference_array(f.deref, ir, ir->lhs); - ir->remove(); - this->progress = true; - } - - return visit_continue; - } -}; - -bool -lower_variable_index_to_cond_assign(exec_list *instructions, - bool lower_input, - bool lower_output, - bool lower_temp, - bool lower_uniform) -{ - variable_index_to_cond_assign_visitor v(lower_input, - lower_output, - lower_temp, - lower_uniform); - - /* Continue lowering until no progress is made. If there are multiple - * levels of indirection (e.g., non-constant indexing of array elements and - * matrix columns of an array of matrix), each pass will only lower one - * level of indirection. - */ - bool progress_ever = false; - do { - v.progress = false; - visit_list_elements(&v, instructions); - progress_ever = v.progress || progress_ever; - } while (v.progress); - - return progress_ever; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_cond_assign.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_cond_assign.cpp deleted file mode 100644 index fce9c3424a1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_cond_assign.cpp +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_vec_index_to_cond_assign.cpp - * - * Turns indexing into vector types to a series of conditional moves - * of each channel's swizzle into a temporary. - * - * Most GPUs don't have a native way to do this operation, and this - * works around that. For drivers using both this pass and - * ir_vec_index_to_swizzle, there's a risk that this pass will happen - * before sufficient constant folding to find that the array index is - * constant. However, we hope that other optimization passes, - * particularly constant folding of assignment conditions and copy - * propagation, will result in the same code in the end. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -/** - * Visitor class for replacing expressions with ir_constant values. - */ - -class ir_vec_index_to_cond_assign_visitor : public ir_hierarchical_visitor { -public: - ir_vec_index_to_cond_assign_visitor() - { - progress = false; - } - - ir_rvalue *convert_vec_index_to_cond_assign(ir_rvalue *val); - - virtual ir_visitor_status visit_enter(ir_expression *); - virtual ir_visitor_status visit_enter(ir_swizzle *); - virtual ir_visitor_status visit_leave(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_call *); - virtual ir_visitor_status visit_enter(ir_if *); - - bool progress; -}; - -ir_rvalue * -ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue *ir) -{ - ir_dereference_array *orig_deref = ir->as_dereference_array(); - ir_assignment *assign; - ir_variable *index, *var; - ir_dereference *deref; - int i; - - if (!orig_deref) - return ir; - - if (orig_deref->array->type->is_matrix() || - orig_deref->array->type->is_array()) - return ir; - - void *mem_ctx = ralloc_parent(ir); - - assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); - - exec_list list; - - /* Store the index to a temporary to avoid reusing its tree. */ - index = new(base_ir) ir_variable(glsl_type::int_type, - "vec_index_tmp_i", - ir_var_temporary); - list.push_tail(index); - deref = new(base_ir) ir_dereference_variable(index); - assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL); - list.push_tail(assign); - - /* Temporary where we store whichever value we swizzle out. */ - var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v", - ir_var_temporary); - list.push_tail(var); - - /* Generate a single comparison condition "mask" for all of the components - * in the vector. - */ - ir_rvalue *const cond_deref = - compare_index_block(&list, index, 0, - orig_deref->array->type->vector_elements, - mem_ctx); - - /* Generate a conditional move of each vector element to the temp. */ - for (i = 0; i < orig_deref->array->type->vector_elements; i++) { - ir_rvalue *condition_swizzle = - new(base_ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1); - - /* Just clone the rest of the deref chain when trying to get at the - * underlying variable. - */ - ir_rvalue *swizzle = - new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), - i, 0, 0, 0, 1); - - deref = new(base_ir) ir_dereference_variable(var); - assign = new(base_ir) ir_assignment(deref, swizzle, condition_swizzle); - list.push_tail(assign); - } - - /* Put all of the new instructions in the IR stream before the old - * instruction. - */ - base_ir->insert_before(&list); - - this->progress = true; - return new(base_ir) ir_dereference_variable(var); -} - -ir_visitor_status -ir_vec_index_to_cond_assign_visitor::visit_enter(ir_expression *ir) -{ - unsigned int i; - - for (i = 0; i < ir->get_num_operands(); i++) { - ir->operands[i] = convert_vec_index_to_cond_assign(ir->operands[i]); - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_cond_assign_visitor::visit_enter(ir_swizzle *ir) -{ - /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which - * the result of indexing a vector is. But maybe at some point we'll end up - * using swizzling of scalars for vector construction. - */ - ir->val = convert_vec_index_to_cond_assign(ir->val); - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) -{ - ir_variable *index, *var; - ir_dereference_variable *deref; - ir_assignment *assign; - int i; - - ir->rhs = convert_vec_index_to_cond_assign(ir->rhs); - if (ir->condition) - ir->condition = convert_vec_index_to_cond_assign(ir->condition); - - /* Last, handle the LHS */ - ir_dereference_array *orig_deref = ir->lhs->as_dereference_array(); - - if (!orig_deref || - orig_deref->array->type->is_matrix() || - orig_deref->array->type->is_array()) - return visit_continue; - - void *mem_ctx = ralloc_parent(ir); - - assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); - - exec_list list; - - /* Store the index to a temporary to avoid reusing its tree. */ - index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i", - ir_var_temporary); - list.push_tail(index); - deref = new(ir) ir_dereference_variable(index); - assign = new(ir) ir_assignment(deref, orig_deref->array_index, NULL); - list.push_tail(assign); - - /* Store the RHS to a temporary to avoid reusing its tree. */ - var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v", - ir_var_temporary); - list.push_tail(var); - deref = new(ir) ir_dereference_variable(var); - assign = new(ir) ir_assignment(deref, ir->rhs, NULL); - list.push_tail(assign); - - /* Generate a single comparison condition "mask" for all of the components - * in the vector. - */ - ir_rvalue *const cond_deref = - compare_index_block(&list, index, 0, - orig_deref->array->type->vector_elements, - mem_ctx); - - /* Generate a conditional move of each vector element to the temp. */ - for (i = 0; i < orig_deref->array->type->vector_elements; i++) { - ir_rvalue *condition_swizzle = - new(ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1); - - - /* Just clone the rest of the deref chain when trying to get at the - * underlying variable. - */ - ir_rvalue *swizzle = - new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), - i, 0, 0, 0, 1); - - deref = new(ir) ir_dereference_variable(var); - assign = new(ir) ir_assignment(swizzle, deref, condition_swizzle); - list.push_tail(assign); - } - - /* If the original assignment has a condition, respect that original - * condition! This is acomplished by wrapping the new conditional - * assignments in an if-statement that uses the original condition. - */ - if (ir->condition != NULL) { - /* No need to clone the condition because the IR that it hangs on is - * going to be removed from the instruction sequence. - */ - ir_if *if_stmt = new(mem_ctx) ir_if(ir->condition); - - list.move_nodes_to(&if_stmt->then_instructions); - ir->insert_before(if_stmt); - } else { - ir->insert_before(&list); - } - - ir->remove(); - - this->progress = true; - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = convert_vec_index_to_cond_assign(param); - - if (new_param != param) { - param->replace_with(new_param); - } - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_cond_assign_visitor::visit_enter(ir_return *ir) -{ - if (ir->value) { - ir->value = convert_vec_index_to_cond_assign(ir->value); - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_cond_assign_visitor::visit_enter(ir_if *ir) -{ - ir->condition = convert_vec_index_to_cond_assign(ir->condition); - - return visit_continue; -} - -bool -do_vec_index_to_cond_assign(exec_list *instructions) -{ - ir_vec_index_to_cond_assign_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_swizzle.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_swizzle.cpp deleted file mode 100644 index 46fd6ace1b6..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_vec_index_to_swizzle.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_vec_index_to_swizzle.cpp - * - * Turns constant indexing into vector types to swizzles. This will - * let other swizzle-aware optimization passes catch these constructs, - * and codegen backends not have to worry about this case. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" -#include "main/macros.h" - -/** - * Visitor class for replacing expressions with ir_constant values. - */ - -class ir_vec_index_to_swizzle_visitor : public ir_hierarchical_visitor { -public: - ir_vec_index_to_swizzle_visitor() - { - progress = false; - } - - ir_rvalue *convert_vec_index_to_swizzle(ir_rvalue *val); - - virtual ir_visitor_status visit_enter(ir_expression *); - virtual ir_visitor_status visit_enter(ir_swizzle *); - virtual ir_visitor_status visit_enter(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_call *); - virtual ir_visitor_status visit_enter(ir_if *); - - bool progress; -}; - -ir_rvalue * -ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) -{ - ir_dereference_array *deref = ir->as_dereference_array(); - ir_constant *ir_constant; - - if (!deref) - return ir; - - if (deref->array->type->is_matrix() || deref->array->type->is_array()) - return ir; - - assert(deref->array_index->type->base_type == GLSL_TYPE_INT); - ir_constant = deref->array_index->constant_expression_value(); - if (!ir_constant) - return ir; - - void *ctx = ralloc_parent(ir); - this->progress = true; - - /* Page 40 of the GLSL 1.20 spec says: - * - * "When indexing with non-constant expressions, behavior is undefined - * if the index is negative, or greater than or equal to the size of - * the vector." - * - * The quoted spec text mentions non-constant expressions, but this code - * operates on constants. These constants are the result of non-constant - * expressions that have been optimized to constants. The common case here - * is a loop counter from an unrolled loop that is used to index a vector. - * - * The ir_swizzle constructor gets angry if the index is negative or too - * large. For simplicity sake, just clamp the index to [0, size-1]. - */ - const int i = MIN2(MAX2(ir_constant->value.i[0], 0), - (deref->array->type->vector_elements - 1)); - - return new(ctx) ir_swizzle(deref->array, i, 0, 0, 0, 1); -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_expression *ir) -{ - unsigned int i; - - for (i = 0; i < ir->get_num_operands(); i++) { - ir->operands[i] = convert_vec_index_to_swizzle(ir->operands[i]); - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) -{ - /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which - * the result of indexing a vector is. But maybe at some point we'll end up - * using swizzling of scalars for vector construction. - */ - ir->val = convert_vec_index_to_swizzle(ir->val); - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir) -{ - ir->set_lhs(convert_vec_index_to_swizzle(ir->lhs)); - ir->rhs = convert_vec_index_to_swizzle(ir->rhs); - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = convert_vec_index_to_swizzle(param); - - if (new_param != param) { - param->replace_with(new_param); - } - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir) -{ - if (ir->value) { - ir->value = convert_vec_index_to_swizzle(ir->value); - } - - return visit_continue; -} - -ir_visitor_status -ir_vec_index_to_swizzle_visitor::visit_enter(ir_if *ir) -{ - ir->condition = convert_vec_index_to_swizzle(ir->condition); - - return visit_continue; -} - -bool -do_vec_index_to_swizzle(exec_list *instructions) -{ - ir_vec_index_to_swizzle_visitor v; - - v.run(instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/lower_vector.cpp b/reactos/dll/opengl/mesa/src/glsl/lower_vector.cpp deleted file mode 100644 index 57963a121ad..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/lower_vector.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file lower_vector.cpp - * IR lowering pass to remove some types of ir_quadop_vector - * - * \author Ian Romanick - */ - -#include "ir.h" -#include "ir_rvalue_visitor.h" - -class lower_vector_visitor : public ir_rvalue_visitor { -public: - lower_vector_visitor() : progress(false) - { - /* empty */ - } - - void handle_rvalue(ir_rvalue **rvalue); - - /** - * Should SWZ-like expressions be lowered? - */ - bool dont_lower_swz; - - bool progress; -}; - -/** - * Determine if an IR expression tree looks like an extended swizzle - * - * Extended swizzles consist of access of a single vector source (with possible - * per component negation) and the constants -1, 0, or 1. - */ -bool -is_extended_swizzle(ir_expression *ir) -{ - /* Track any variables that are accessed by this expression. - */ - ir_variable *var = NULL; - - assert(ir->operation == ir_quadop_vector); - - for (unsigned i = 0; i < ir->type->vector_elements; i++) { - ir_rvalue *op = ir->operands[i]; - - while (op != NULL) { - switch (op->ir_type) { - case ir_type_constant: { - const ir_constant *const c = op->as_constant(); - - if (!c->is_one() && !c->is_zero() && !c->is_negative_one()) - return false; - - op = NULL; - break; - } - - case ir_type_dereference_variable: { - ir_dereference_variable *const d = (ir_dereference_variable *) op; - - if ((var != NULL) && (var != d->var)) - return false; - - var = d->var; - op = NULL; - break; - } - - case ir_type_expression: { - ir_expression *const ex = (ir_expression *) op; - - if (ex->operation != ir_unop_neg) - return false; - - op = ex->operands[0]; - break; - } - - case ir_type_swizzle: - op = ((ir_swizzle *) op)->val; - break; - - default: - return false; - } - } - } - - return true; -} - -void -lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue) -{ - if (!*rvalue) - return; - - ir_expression *expr = (*rvalue)->as_expression(); - if ((expr == NULL) || (expr->operation != ir_quadop_vector)) - return; - - if (this->dont_lower_swz && is_extended_swizzle(expr)) - return; - - /* FINISHME: Is this the right thing to use for the ralloc context? - */ - void *const mem_ctx = expr; - - assert(expr->type->vector_elements == expr->get_num_operands()); - - /* Generate a temporary with the same type as the ir_quadop_operation. - */ - ir_variable *const temp = - new(mem_ctx) ir_variable(expr->type, "vecop_tmp", ir_var_temporary); - - this->base_ir->insert_before(temp); - - /* Counter of the number of components collected so far. - */ - unsigned assigned; - - /* Write-mask in the destination that receives counted by 'assigned'. - */ - unsigned write_mask; - - - /* Generate upto four assignments to that variable. Try to group component - * assignments together: - * - * - All constant components can be assigned at once. - * - All assigments of components from a single variable with the same - * unary operator can be assigned at once. - */ - ir_constant_data d = { { 0 } }; - - assigned = 0; - write_mask = 0; - for (unsigned i = 0; i < expr->type->vector_elements; i++) { - const ir_constant *const c = expr->operands[i]->as_constant(); - - if (c == NULL) - continue; - - switch (expr->type->base_type) { - case GLSL_TYPE_UINT: d.u[assigned] = c->value.u[0]; break; - case GLSL_TYPE_INT: d.i[assigned] = c->value.i[0]; break; - case GLSL_TYPE_FLOAT: d.f[assigned] = c->value.f[0]; break; - case GLSL_TYPE_BOOL: d.b[assigned] = c->value.b[0]; break; - default: assert(!"Should not get here."); break; - } - - write_mask |= (1U << i); - assigned++; - } - - assert((write_mask == 0) == (assigned == 0)); - - /* If there were constant values, generate an assignment. - */ - if (assigned > 0) { - ir_constant *const c = - new(mem_ctx) ir_constant(glsl_type::get_instance(expr->type->base_type, - assigned, 0), - &d); - ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp); - ir_assignment *const assign = - new(mem_ctx) ir_assignment(lhs, c, NULL, write_mask); - - this->base_ir->insert_before(assign); - } - - /* FINISHME: This should try to coalesce assignments. - */ - for (unsigned i = 0; i < expr->type->vector_elements; i++) { - if (expr->operands[i]->ir_type == ir_type_constant) - continue; - - ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp); - ir_assignment *const assign = - new(mem_ctx) ir_assignment(lhs, expr->operands[i], NULL, (1U << i)); - - this->base_ir->insert_before(assign); - assigned++; - } - - assert(assigned == expr->type->vector_elements); - - *rvalue = new(mem_ctx) ir_dereference_variable(temp); - this->progress = true; -} - -bool -lower_quadop_vector(exec_list *instructions, bool dont_lower_swz) -{ - lower_vector_visitor v; - - v.dont_lower_swz = dont_lower_swz; - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/main.cpp b/reactos/dll/opengl/mesa/src/glsl/main.cpp deleted file mode 100644 index 8bc8639974c..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/main.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright © 2008, 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include - -#include "ast.h" -#include "glsl_parser_extras.h" -#include "ir_optimization.h" -#include "ir_print_visitor.h" -#include "program.h" -#include "loop_analysis.h" -#include "standalone_scaffolding.h" - -static void -initialize_context(struct gl_context *ctx, gl_api api) -{ - initialize_context_to_defaults(ctx, api); - - /* GLSL 1.30 isn't fully supported, but we need to advertise 1.30 so that - * the built-in functions for 1.30 can be built. - */ - ctx->Const.GLSLVersion = 130; - - ctx->Const.MaxClipPlanes = 8; - ctx->Const.MaxDrawBuffers = 2; - - /* More than the 1.10 minimum to appease parser tests taken from - * apps that (hopefully) already checked the number of coords. - */ - ctx->Const.MaxTextureCoordUnits = 4; - - ctx->Driver.NewShader = _mesa_new_shader; -} - -/* Returned string will have 'ctx' as its ralloc owner. */ -static char * -load_text_file(void *ctx, const char *file_name) -{ - char *text = NULL; - size_t size; - size_t total_read = 0; - FILE *fp = fopen(file_name, "rb"); - - if (!fp) { - return NULL; - } - - fseek(fp, 0L, SEEK_END); - size = ftell(fp); - fseek(fp, 0L, SEEK_SET); - - text = (char *) ralloc_size(ctx, size + 1); - if (text != NULL) { - do { - size_t bytes = fread(text + total_read, - 1, size - total_read, fp); - if (bytes < size - total_read) { - free(text); - text = NULL; - break; - } - - if (bytes == 0) { - break; - } - - total_read += bytes; - } while (total_read < size); - - text[total_read] = '\0'; - } - - fclose(fp); - - return text; -} - -int glsl_es = 0; -int dump_ast = 0; -int dump_hir = 0; -int dump_lir = 0; -int do_link = 0; - -const struct option compiler_opts[] = { - { "glsl-es", 0, &glsl_es, 1 }, - { "dump-ast", 0, &dump_ast, 1 }, - { "dump-hir", 0, &dump_hir, 1 }, - { "dump-lir", 0, &dump_lir, 1 }, - { "link", 0, &do_link, 1 }, - { NULL, 0, NULL, 0 } -}; - -/** - * \brief Print proper usage and exit with failure. - */ -void -usage_fail(const char *name) -{ - - const char *header = - "usage: %s [options] \n" - "\n" - "Possible options are:\n"; - printf(header, name, name); - for (const struct option *o = compiler_opts; o->name != 0; ++o) { - printf(" --%s\n", o->name); - } - exit(EXIT_FAILURE); -} - - -void -compile_shader(struct gl_context *ctx, struct gl_shader *shader) -{ - struct _mesa_glsl_parse_state *state = - new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader); - - const char *source = shader->Source; - state->error = preprocess(state, &source, &state->info_log, - state->extensions) != 0; - - if (!state->error) { - _mesa_glsl_lexer_ctor(state, source); - _mesa_glsl_parse(state); - _mesa_glsl_lexer_dtor(state); - } - - if (dump_ast) { - foreach_list_const(n, &state->translation_unit) { - ast_node *ast = exec_node_data(ast_node, n, link); - ast->print(); - } - printf("\n\n"); - } - - shader->ir = new(shader) exec_list; - if (!state->error && !state->translation_unit.is_empty()) - _mesa_ast_to_hir(shader->ir, state); - - /* Print out the unoptimized IR. */ - if (!state->error && dump_hir) { - validate_ir_tree(shader->ir); - _mesa_print_ir(shader->ir, state); - } - - /* Optimization passes */ - if (!state->error && !shader->ir->is_empty()) { - bool progress; - do { - progress = do_common_optimization(shader->ir, false, false, 32); - } while (progress); - - validate_ir_tree(shader->ir); - } - - - /* Print out the resulting IR */ - if (!state->error && dump_lir) { - _mesa_print_ir(shader->ir, state); - } - - shader->symbols = state->symbols; - shader->CompileStatus = !state->error; - shader->Version = state->language_version; - memcpy(shader->builtins_to_link, state->builtins_to_link, - sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); - shader->num_builtins_to_link = state->num_builtins_to_link; - - if (shader->InfoLog) - ralloc_free(shader->InfoLog); - - shader->InfoLog = state->info_log; - - /* Retain any live IR, but trash the rest. */ - reparent_ir(shader->ir, shader); - - ralloc_free(state); - - return; -} - -int -main(int argc, char **argv) -{ - int status = EXIT_SUCCESS; - struct gl_context local_ctx; - struct gl_context *ctx = &local_ctx; - - int c; - int idx = 0; - while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) - /* empty */ ; - - - if (argc <= optind) - usage_fail(argv[0]); - - initialize_context(ctx, (glsl_es) ? API_OPENGLES2 : API_OPENGL); - - struct gl_shader_program *whole_program; - - whole_program = rzalloc (NULL, struct gl_shader_program); - assert(whole_program != NULL); - whole_program->InfoLog = ralloc_strdup(whole_program, ""); - - for (/* empty */; argc > optind; optind++) { - whole_program->Shaders = - reralloc(whole_program, whole_program->Shaders, - struct gl_shader *, whole_program->NumShaders + 1); - assert(whole_program->Shaders != NULL); - - struct gl_shader *shader = rzalloc(whole_program, gl_shader); - - whole_program->Shaders[whole_program->NumShaders] = shader; - whole_program->NumShaders++; - - const unsigned len = strlen(argv[optind]); - if (len < 6) - usage_fail(argv[0]); - - const char *const ext = & argv[optind][len - 5]; - if (strncmp(".vert", ext, 5) == 0) - shader->Type = GL_VERTEX_SHADER; - else if (strncmp(".frag", ext, 5) == 0) - shader->Type = GL_FRAGMENT_SHADER; - else - usage_fail(argv[0]); - - shader->Source = load_text_file(whole_program, argv[optind]); - if (shader->Source == NULL) { - printf("File \"%s\" does not exist.\n", argv[optind]); - exit(EXIT_FAILURE); - } - - compile_shader(ctx, shader); - - if (!shader->CompileStatus) { - printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog); - status = EXIT_FAILURE; - break; - } - } - - if ((status == EXIT_SUCCESS) && do_link) { - link_shaders(ctx, whole_program); - status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE; - - if (strlen(whole_program->InfoLog) > 0) - printf("Info log for linking:\n%s\n", whole_program->InfoLog); - } - - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) - ralloc_free(whole_program->_LinkedShaders[i]); - - ralloc_free(whole_program); - _mesa_glsl_release_types(); - _mesa_glsl_release_functions(); - - return status; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_algebraic.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_algebraic.cpp deleted file mode 100644 index cade9611dbb..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_algebraic.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_algebraic.cpp - * - * Takes advantage of association, commutivity, and other algebraic - * properties to simplify expressions. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_rvalue_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -/** - * Visitor class for replacing expressions with ir_constant values. - */ - -class ir_algebraic_visitor : public ir_rvalue_visitor { -public: - ir_algebraic_visitor() - { - this->progress = false; - this->mem_ctx = NULL; - } - - virtual ~ir_algebraic_visitor() - { - } - - ir_rvalue *handle_expression(ir_expression *ir); - void handle_rvalue(ir_rvalue **rvalue); - bool reassociate_constant(ir_expression *ir1, - int const_index, - ir_constant *constant, - ir_expression *ir2); - void reassociate_operands(ir_expression *ir1, - int op1, - ir_expression *ir2, - int op2); - ir_rvalue *swizzle_if_required(ir_expression *expr, - ir_rvalue *operand); - - void *mem_ctx; - - bool progress; -}; - -static inline bool -is_vec_zero(ir_constant *ir) -{ - return (ir == NULL) ? false : ir->is_zero(); -} - -static inline bool -is_vec_one(ir_constant *ir) -{ - return (ir == NULL) ? false : ir->is_one(); -} - -static void -update_type(ir_expression *ir) -{ - if (ir->operands[0]->type->is_vector()) - ir->type = ir->operands[0]->type; - else - ir->type = ir->operands[1]->type; -} - -void -ir_algebraic_visitor::reassociate_operands(ir_expression *ir1, - int op1, - ir_expression *ir2, - int op2) -{ - ir_rvalue *temp = ir2->operands[op2]; - ir2->operands[op2] = ir1->operands[op1]; - ir1->operands[op1] = temp; - - /* Update the type of ir2. The type of ir1 won't have changed -- - * base types matched, and at least one of the operands of the 2 - * binops is still a vector if any of them were. - */ - update_type(ir2); - - this->progress = true; -} - -/** - * Reassociates a constant down a tree of adds or multiplies. - * - * Consider (2 * (a * (b * 0.5))). We want to send up with a * b. - */ -bool -ir_algebraic_visitor::reassociate_constant(ir_expression *ir1, int const_index, - ir_constant *constant, - ir_expression *ir2) -{ - if (!ir2 || ir1->operation != ir2->operation) - return false; - - /* Don't want to even think about matrices. */ - if (ir1->operands[0]->type->is_matrix() || - ir1->operands[1]->type->is_matrix() || - ir2->operands[0]->type->is_matrix() || - ir2->operands[1]->type->is_matrix()) - return false; - - ir_constant *ir2_const[2]; - ir2_const[0] = ir2->operands[0]->constant_expression_value(); - ir2_const[1] = ir2->operands[1]->constant_expression_value(); - - if (ir2_const[0] && ir2_const[1]) - return false; - - if (ir2_const[0]) { - reassociate_operands(ir1, const_index, ir2, 1); - return true; - } else if (ir2_const[1]) { - reassociate_operands(ir1, const_index, ir2, 0); - return true; - } - - if (reassociate_constant(ir1, const_index, constant, - ir2->operands[0]->as_expression())) { - update_type(ir2); - return true; - } - - if (reassociate_constant(ir1, const_index, constant, - ir2->operands[1]->as_expression())) { - update_type(ir2); - return true; - } - - return false; -} - -/* When eliminating an expression and just returning one of its operands, - * we may need to swizzle that operand out to a vector if the expression was - * vector type. - */ -ir_rvalue * -ir_algebraic_visitor::swizzle_if_required(ir_expression *expr, - ir_rvalue *operand) -{ - if (expr->type->is_vector() && operand->type->is_scalar()) { - return new(mem_ctx) ir_swizzle(operand, 0, 0, 0, 0, - expr->type->vector_elements); - } else - return operand; -} - -ir_rvalue * -ir_algebraic_visitor::handle_expression(ir_expression *ir) -{ - ir_constant *op_const[2] = {NULL, NULL}; - ir_expression *op_expr[2] = {NULL, NULL}; - ir_expression *temp; - unsigned int i; - - assert(ir->get_num_operands() <= 2); - for (i = 0; i < ir->get_num_operands(); i++) { - if (ir->operands[i]->type->is_matrix()) - return ir; - - op_const[i] = ir->operands[i]->constant_expression_value(); - op_expr[i] = ir->operands[i]->as_expression(); - } - - if (this->mem_ctx == NULL) - this->mem_ctx = ralloc_parent(ir); - - switch (ir->operation) { - case ir_unop_logic_not: { - enum ir_expression_operation new_op = ir_unop_logic_not; - - if (op_expr[0] == NULL) - break; - - switch (op_expr[0]->operation) { - case ir_binop_less: new_op = ir_binop_gequal; break; - case ir_binop_greater: new_op = ir_binop_lequal; break; - case ir_binop_lequal: new_op = ir_binop_greater; break; - case ir_binop_gequal: new_op = ir_binop_less; break; - case ir_binop_equal: new_op = ir_binop_nequal; break; - case ir_binop_nequal: new_op = ir_binop_equal; break; - case ir_binop_all_equal: new_op = ir_binop_any_nequal; break; - case ir_binop_any_nequal: new_op = ir_binop_all_equal; break; - - default: - /* The default case handler is here to silence a warning from GCC. - */ - break; - } - - if (new_op != ir_unop_logic_not) { - this->progress = true; - return new(mem_ctx) ir_expression(new_op, - ir->type, - op_expr[0]->operands[0], - op_expr[0]->operands[1]); - } - - break; - } - - case ir_binop_add: - if (is_vec_zero(op_const[0])) { - this->progress = true; - return swizzle_if_required(ir, ir->operands[1]); - } - if (is_vec_zero(op_const[1])) { - this->progress = true; - return swizzle_if_required(ir, ir->operands[0]); - } - - /* Reassociate addition of constants so that we can do constant - * folding. - */ - if (op_const[0] && !op_const[1]) - reassociate_constant(ir, 0, op_const[0], - ir->operands[1]->as_expression()); - if (op_const[1] && !op_const[0]) - reassociate_constant(ir, 1, op_const[1], - ir->operands[0]->as_expression()); - break; - - case ir_binop_sub: - if (is_vec_zero(op_const[0])) { - this->progress = true; - temp = new(mem_ctx) ir_expression(ir_unop_neg, - ir->operands[1]->type, - ir->operands[1], - NULL); - return swizzle_if_required(ir, temp); - } - if (is_vec_zero(op_const[1])) { - this->progress = true; - return swizzle_if_required(ir, ir->operands[0]); - } - break; - - case ir_binop_mul: - if (is_vec_one(op_const[0])) { - this->progress = true; - return swizzle_if_required(ir, ir->operands[1]); - } - if (is_vec_one(op_const[1])) { - this->progress = true; - return swizzle_if_required(ir, ir->operands[0]); - } - - if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) { - this->progress = true; - return ir_constant::zero(ir, ir->type); - } - - /* Reassociate multiplication of constants so that we can do - * constant folding. - */ - if (op_const[0] && !op_const[1]) - reassociate_constant(ir, 0, op_const[0], - ir->operands[1]->as_expression()); - if (op_const[1] && !op_const[0]) - reassociate_constant(ir, 1, op_const[1], - ir->operands[0]->as_expression()); - - break; - - case ir_binop_div: - if (is_vec_one(op_const[0]) && ir->type->base_type == GLSL_TYPE_FLOAT) { - this->progress = true; - temp = new(mem_ctx) ir_expression(ir_unop_rcp, - ir->operands[1]->type, - ir->operands[1], - NULL); - return swizzle_if_required(ir, temp); - } - if (is_vec_one(op_const[1])) { - this->progress = true; - return swizzle_if_required(ir, ir->operands[0]); - } - break; - - case ir_binop_logic_and: - /* FINISHME: Also simplify (a && a) to (a). */ - if (is_vec_one(op_const[0])) { - this->progress = true; - return ir->operands[1]; - } else if (is_vec_one(op_const[1])) { - this->progress = true; - return ir->operands[0]; - } else if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) { - this->progress = true; - return ir_constant::zero(mem_ctx, ir->type); - } - break; - - case ir_binop_logic_xor: - /* FINISHME: Also simplify (a ^^ a) to (false). */ - if (is_vec_zero(op_const[0])) { - this->progress = true; - return ir->operands[1]; - } else if (is_vec_zero(op_const[1])) { - this->progress = true; - return ir->operands[0]; - } else if (is_vec_one(op_const[0])) { - this->progress = true; - return new(mem_ctx) ir_expression(ir_unop_logic_not, ir->type, - ir->operands[1], NULL); - } else if (is_vec_one(op_const[1])) { - this->progress = true; - return new(mem_ctx) ir_expression(ir_unop_logic_not, ir->type, - ir->operands[0], NULL); - } - break; - - case ir_binop_logic_or: - /* FINISHME: Also simplify (a || a) to (a). */ - if (is_vec_zero(op_const[0])) { - this->progress = true; - return ir->operands[1]; - } else if (is_vec_zero(op_const[1])) { - this->progress = true; - return ir->operands[0]; - } else if (is_vec_one(op_const[0]) || is_vec_one(op_const[1])) { - ir_constant_data data; - - for (unsigned i = 0; i < 16; i++) - data.b[i] = true; - - this->progress = true; - return new(mem_ctx) ir_constant(ir->type, &data); - } - break; - - case ir_unop_rcp: - if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp) { - this->progress = true; - return op_expr[0]->operands[0]; - } - - /* FINISHME: We should do rcp(rsq(x)) -> sqrt(x) for some - * backends, except that some backends will have done sqrt -> - * rcp(rsq(x)) and we don't want to undo it for them. - */ - - /* As far as we know, all backends are OK with rsq. */ - if (op_expr[0] && op_expr[0]->operation == ir_unop_sqrt) { - this->progress = true; - temp = new(mem_ctx) ir_expression(ir_unop_rsq, - op_expr[0]->operands[0]->type, - op_expr[0]->operands[0], - NULL); - return swizzle_if_required(ir, temp); - } - - break; - - default: - break; - } - - return ir; -} - -void -ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue) -{ - if (!*rvalue) - return; - - ir_expression *expr = (*rvalue)->as_expression(); - if (!expr || expr->operation == ir_quadop_vector) - return; - - *rvalue = handle_expression(expr); -} - -bool -do_algebraic(exec_list *instructions) -{ - ir_algebraic_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_constant_folding.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_constant_folding.cpp deleted file mode 100644 index 599b21525de..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_constant_folding.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_constant_folding.cpp - * Replace constant-valued expressions with references to constant values. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_rvalue_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -/** - * Visitor class for replacing expressions with ir_constant values. - */ - -class ir_constant_folding_visitor : public ir_rvalue_visitor { -public: - ir_constant_folding_visitor() - { - this->progress = false; - } - - virtual ~ir_constant_folding_visitor() - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_assignment *ir); - virtual ir_visitor_status visit_enter(ir_call *ir); - - virtual void handle_rvalue(ir_rvalue **rvalue); - - bool progress; -}; - -void -ir_constant_folding_visitor::handle_rvalue(ir_rvalue **rvalue) -{ - if (*rvalue == NULL || (*rvalue)->ir_type == ir_type_constant) - return; - - /* Note that we do rvalue visitoring on leaving. So if an - * expression has a non-constant operand, no need to go looking - * down it to find if it's constant. This cuts the time of this - * pass down drastically. - */ - ir_expression *expr = (*rvalue)->as_expression(); - if (expr) { - for (unsigned int i = 0; i < expr->get_num_operands(); i++) { - if (!expr->operands[i]->as_constant()) - return; - } - } - - ir_constant *constant = (*rvalue)->constant_expression_value(); - if (constant) { - *rvalue = constant; - this->progress = true; - } else { - (*rvalue)->accept(this); - } -} - -ir_visitor_status -ir_constant_folding_visitor::visit_enter(ir_assignment *ir) -{ - ir->rhs->accept(this); - handle_rvalue(&ir->rhs); - - if (ir->condition) { - ir->condition->accept(this); - handle_rvalue(&ir->condition); - - ir_constant *const_val = ir->condition->as_constant(); - /* If the condition is constant, either remove the condition or - * remove the never-executed assignment. - */ - if (const_val) { - if (const_val->value.b[0]) - ir->condition = NULL; - else - ir->remove(); - this->progress = true; - } - } - - /* Don't descend into the LHS because we want it to stay as a - * variable dereference. FINISHME: We probably should to get array - * indices though. - */ - return visit_continue_with_parent; -} - -ir_visitor_status -ir_constant_folding_visitor::visit_enter(ir_call *ir) -{ - exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param_rval = (ir_rvalue *)iter.get(); - ir_variable *sig_param = (ir_variable *)sig_iter.get(); - - if (sig_param->mode == ir_var_in || sig_param->mode == ir_var_const_in) { - ir_rvalue *new_param = param_rval; - - handle_rvalue(&new_param); - if (new_param != param_rval) { - param_rval->replace_with(new_param); - } - } - sig_iter.next(); - } - - return visit_continue_with_parent; -} - -bool -do_constant_folding(exec_list *instructions) -{ - ir_constant_folding_visitor constant_folding; - - visit_list_elements(&constant_folding, instructions); - - return constant_folding.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_constant_propagation.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_constant_propagation.cpp deleted file mode 100644 index af77e490689..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_constant_propagation.cpp +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * constant of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, constant, 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 constantright notice and this permission notice (including the next - * paragraph) 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 - * THE AUTHORS OR CONSTANTRIGHT HOLDERS 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. - */ - -/** - * \file opt_constant_propagation.cpp - * - * Tracks assignments of constants to channels of variables, and - * usage of those constant channels with direct usage of the constants. - * - * This can lead to constant folding and algebraic optimizations in - * those later expressions, while causing no increase in instruction - * count (due to constants being generally free to load from a - * constant push buffer or as instruction immediate values) and - * possibly reducing register pressure. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_rvalue_visitor.h" -#include "ir_basic_block.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -class acp_entry : public exec_node -{ -public: - acp_entry(ir_variable *var, unsigned write_mask, ir_constant *constant) - { - assert(var); - assert(constant); - this->var = var; - this->write_mask = write_mask; - this->constant = constant; - this->initial_values = write_mask; - } - - acp_entry(const acp_entry *src) - { - this->var = src->var; - this->write_mask = src->write_mask; - this->constant = src->constant; - this->initial_values = src->initial_values; - } - - ir_variable *var; - ir_constant *constant; - unsigned write_mask; - - /** Mask of values initially available in the constant. */ - unsigned initial_values; -}; - - -class kill_entry : public exec_node -{ -public: - kill_entry(ir_variable *var, unsigned write_mask) - { - assert(var); - this->var = var; - this->write_mask = write_mask; - } - - ir_variable *var; - unsigned write_mask; -}; - -class ir_constant_propagation_visitor : public ir_rvalue_visitor { -public: - ir_constant_propagation_visitor() - { - progress = false; - mem_ctx = ralloc_context(0); - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - } - ~ir_constant_propagation_visitor() - { - ralloc_free(mem_ctx); - } - - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_enter(class ir_function *); - virtual ir_visitor_status visit_leave(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_if *); - - void add_constant(ir_assignment *ir); - void kill(ir_variable *ir, unsigned write_mask); - void handle_if_block(exec_list *instructions); - void handle_rvalue(ir_rvalue **rvalue); - - /** List of acp_entry: The available constants to propagate */ - exec_list *acp; - - /** - * List of kill_entry: The masks of variables whose values were - * killed in this block. - */ - exec_list *kills; - - bool progress; - - bool killed_all; - - void *mem_ctx; -}; - - -void -ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue) -{ - if (this->in_assignee || !*rvalue) - return; - - const glsl_type *type = (*rvalue)->type; - if (!type->is_scalar() && !type->is_vector()) - return; - - ir_swizzle *swiz = NULL; - ir_dereference_variable *deref = (*rvalue)->as_dereference_variable(); - if (!deref) { - swiz = (*rvalue)->as_swizzle(); - if (!swiz) - return; - - deref = swiz->val->as_dereference_variable(); - if (!deref) - return; - } - - ir_constant_data data; - memset(&data, 0, sizeof(data)); - - for (unsigned int i = 0; i < type->components(); i++) { - int channel; - acp_entry *found = NULL; - - if (swiz) { - switch (i) { - case 0: channel = swiz->mask.x; break; - case 1: channel = swiz->mask.y; break; - case 2: channel = swiz->mask.z; break; - case 3: channel = swiz->mask.w; break; - default: assert(!"shouldn't be reached"); channel = 0; break; - } - } else { - channel = i; - } - - foreach_iter(exec_list_iterator, iter, *this->acp) { - acp_entry *entry = (acp_entry *)iter.get(); - if (entry->var == deref->var && entry->write_mask & (1 << channel)) { - found = entry; - break; - } - } - - if (!found) - return; - - int rhs_channel = 0; - for (int j = 0; j < 4; j++) { - if (j == channel) - break; - if (found->initial_values & (1 << j)) - rhs_channel++; - } - - switch (type->base_type) { - case GLSL_TYPE_FLOAT: - data.f[i] = found->constant->value.f[rhs_channel]; - break; - case GLSL_TYPE_INT: - data.i[i] = found->constant->value.i[rhs_channel]; - break; - case GLSL_TYPE_UINT: - data.u[i] = found->constant->value.u[rhs_channel]; - break; - case GLSL_TYPE_BOOL: - data.b[i] = found->constant->value.b[rhs_channel]; - break; - default: - assert(!"not reached"); - break; - } - } - - *rvalue = new(ralloc_parent(deref)) ir_constant(type, &data); - this->progress = true; -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir) -{ - /* Treat entry into a function signature as a completely separate - * block. Any instructions at global scope will be shuffled into - * main() at link time, so they're irrelevant to us. - */ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - visit_list_elements(this, &ir->body); - - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = orig_killed_all; - - return visit_continue_with_parent; -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_leave(ir_assignment *ir) -{ - if (this->in_assignee) - return visit_continue; - - kill(ir->lhs->variable_referenced(), ir->write_mask); - - add_constant(ir); - - return visit_continue; -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_function *ir) -{ - (void) ir; - return visit_continue; -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_call *ir) -{ - /* Do constant propagation on call parameters, but skip any out params */ - exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { - ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); - ir_rvalue *param = (ir_rvalue *)iter.get(); - if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { - ir_rvalue *new_param = param; - handle_rvalue(&new_param); - if (new_param != param) - param->replace_with(new_param); - else - param->accept(this); - } - sig_param_iter.next(); - } - - /* Since we're unlinked, we don't (necssarily) know the side effects of - * this call. So kill all copies. - */ - acp->make_empty(); - this->killed_all = true; - - return visit_continue_with_parent; -} - -void -ir_constant_propagation_visitor::handle_if_block(exec_list *instructions) -{ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - /* Populate the initial acp with a constant of the original */ - foreach_iter(exec_list_iterator, iter, *orig_acp) { - acp_entry *a = (acp_entry *)iter.get(); - this->acp->push_tail(new(this->mem_ctx) acp_entry(a)); - } - - visit_list_elements(this, instructions); - - if (this->killed_all) { - orig_acp->make_empty(); - } - - exec_list *new_kills = this->kills; - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = this->killed_all || orig_killed_all; - - foreach_iter(exec_list_iterator, iter, *new_kills) { - kill_entry *k = (kill_entry *)iter.get(); - kill(k->var, k->write_mask); - } -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_if *ir) -{ - ir->condition->accept(this); - handle_rvalue(&ir->condition); - - handle_if_block(&ir->then_instructions); - handle_if_block(&ir->else_instructions); - - /* handle_if_block() already descended into the children. */ - return visit_continue_with_parent; -} - -ir_visitor_status -ir_constant_propagation_visitor::visit_enter(ir_loop *ir) -{ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - /* FINISHME: For now, the initial acp for loops is totally empty. - * We could go through once, then go through again with the acp - * cloned minus the killed entries after the first run through. - */ - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - visit_list_elements(this, &ir->body_instructions); - - if (this->killed_all) { - orig_acp->make_empty(); - } - - exec_list *new_kills = this->kills; - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = this->killed_all || orig_killed_all; - - foreach_iter(exec_list_iterator, iter, *new_kills) { - kill_entry *k = (kill_entry *)iter.get(); - kill(k->var, k->write_mask); - } - - /* already descended into the children. */ - return visit_continue_with_parent; -} - -void -ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask) -{ - assert(var != NULL); - - /* We don't track non-vectors. */ - if (!var->type->is_vector() && !var->type->is_scalar()) - return; - - /* Remove any entries currently in the ACP for this kill. */ - foreach_iter(exec_list_iterator, iter, *this->acp) { - acp_entry *entry = (acp_entry *)iter.get(); - - if (entry->var == var) { - entry->write_mask &= ~write_mask; - if (entry->write_mask == 0) - entry->remove(); - } - } - - /* Add this writemask of the variable to the list of killed - * variables in this block. - */ - foreach_iter(exec_list_iterator, iter, *this->kills) { - kill_entry *entry = (kill_entry *)iter.get(); - - if (entry->var == var) { - entry->write_mask |= write_mask; - return; - } - } - /* Not already in the list. Make new entry. */ - this->kills->push_tail(new(this->mem_ctx) kill_entry(var, write_mask)); -} - -/** - * Adds an entry to the available constant list if it's a plain assignment - * of a variable to a variable. - */ -void -ir_constant_propagation_visitor::add_constant(ir_assignment *ir) -{ - acp_entry *entry; - - if (ir->condition) - return; - - if (!ir->write_mask) - return; - - ir_dereference_variable *deref = ir->lhs->as_dereference_variable(); - ir_constant *constant = ir->rhs->as_constant(); - - if (!deref || !constant) - return; - - /* Only do constant propagation on vectors. Constant matrices, - * arrays, or structures would require more work elsewhere. - */ - if (!deref->var->type->is_vector() && !deref->var->type->is_scalar()) - return; - - entry = new(this->mem_ctx) acp_entry(deref->var, ir->write_mask, constant); - this->acp->push_tail(entry); -} - -/** - * Does a constant propagation pass on the code present in the instruction stream. - */ -bool -do_constant_propagation(exec_list *instructions) -{ - ir_constant_propagation_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_constant_variable.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_constant_variable.cpp deleted file mode 100644 index 3fa7c3badc8..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_constant_variable.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_constant_variable.cpp - * - * Marks variables assigned a single constant value over the course - * of the program as constant. - * - * The goal here is to trigger further constant folding and then dead - * code elimination. This is common with vector/matrix constructors - * and calls to builtin functions. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -struct assignment_entry { - exec_node link; - int assignment_count; - ir_variable *var; - ir_constant *constval; - bool our_scope; -}; - -class ir_constant_variable_visitor : public ir_hierarchical_visitor { -public: - virtual ir_visitor_status visit_enter(ir_dereference_variable *); - virtual ir_visitor_status visit(ir_variable *); - virtual ir_visitor_status visit_enter(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_call *); - - exec_list list; -}; - -static struct assignment_entry * -get_assignment_entry(ir_variable *var, exec_list *list) -{ - struct assignment_entry *entry; - - foreach_list_typed(struct assignment_entry, entry, link, list) { - if (entry->var == var) - return entry; - } - - entry = (struct assignment_entry *)calloc(1, sizeof(*entry)); - entry->var = var; - list->push_head(&entry->link); - return entry; -} - -ir_visitor_status -ir_constant_variable_visitor::visit(ir_variable *ir) -{ - struct assignment_entry *entry = get_assignment_entry(ir, &this->list); - entry->our_scope = true; - return visit_continue; -} - -/* Skip derefs of variables so that we can detect declarations. */ -ir_visitor_status -ir_constant_variable_visitor::visit_enter(ir_dereference_variable *ir) -{ - (void)ir; - return visit_continue_with_parent; -} - -ir_visitor_status -ir_constant_variable_visitor::visit_enter(ir_assignment *ir) -{ - ir_constant *constval; - struct assignment_entry *entry; - - entry = get_assignment_entry(ir->lhs->variable_referenced(), &this->list); - assert(entry); - entry->assignment_count++; - - /* If it's already constant, don't do the work. */ - if (entry->var->constant_value) - return visit_continue; - - /* OK, now find if we actually have all the right conditions for - * this to be a constant value assigned to the var. - */ - if (ir->condition) - return visit_continue; - - ir_variable *var = ir->whole_variable_written(); - if (!var) - return visit_continue; - - constval = ir->rhs->constant_expression_value(); - if (!constval) - return visit_continue; - - /* Mark this entry as having a constant assignment (if the - * assignment count doesn't go >1). do_constant_variable will fix - * up the variable with the constant value later. - */ - entry->constval = constval; - - return visit_continue; -} - -ir_visitor_status -ir_constant_variable_visitor::visit_enter(ir_call *ir) -{ - exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param_rval = (ir_rvalue *)iter.get(); - ir_variable *param = (ir_variable *)sig_iter.get(); - - if (param->mode == ir_var_out || - param->mode == ir_var_inout) { - ir_variable *var = param_rval->variable_referenced(); - struct assignment_entry *entry; - - assert(var); - entry = get_assignment_entry(var, &this->list); - entry->assignment_count++; - } - sig_iter.next(); - } - return visit_continue; -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_constant_variable(exec_list *instructions) -{ - bool progress = false; - ir_constant_variable_visitor v; - - v.run(instructions); - - while (!v.list.is_empty()) { - - struct assignment_entry *entry; - entry = exec_node_data(struct assignment_entry, v.list.head, link); - - if (entry->assignment_count == 1 && entry->constval && entry->our_scope) { - entry->var->constant_value = entry->constval; - progress = true; - } - entry->link.remove(); - free(entry); - } - - return progress; -} - -bool -do_constant_variable_unlinked(exec_list *instructions) -{ - bool progress = false; - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_function *f = ir->as_function(); - if (f) { - foreach_iter(exec_list_iterator, sigiter, *f) { - ir_function_signature *sig = - (ir_function_signature *) sigiter.get(); - if (do_constant_variable(&sig->body)) - progress = true; - } - } - } - - return progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation.cpp deleted file mode 100644 index efa3afda35a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_copy_propagation.cpp - * - * Moves usage of recently-copied variables to the previous copy of - * the variable. - * - * This should reduce the number of MOV instructions in the generated - * programs unless copy propagation is also done on the LIR, and may - * help anyway by triggering other optimizations that live in the HIR. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_basic_block.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -class acp_entry : public exec_node -{ -public: - acp_entry(ir_variable *lhs, ir_variable *rhs) - { - assert(lhs); - assert(rhs); - this->lhs = lhs; - this->rhs = rhs; - } - - ir_variable *lhs; - ir_variable *rhs; -}; - - -class kill_entry : public exec_node -{ -public: - kill_entry(ir_variable *var) - { - assert(var); - this->var = var; - } - - ir_variable *var; -}; - -class ir_copy_propagation_visitor : public ir_hierarchical_visitor { -public: - ir_copy_propagation_visitor() - { - progress = false; - mem_ctx = ralloc_context(0); - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - } - ~ir_copy_propagation_visitor() - { - ralloc_free(mem_ctx); - } - - virtual ir_visitor_status visit(class ir_dereference_variable *); - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_enter(class ir_function *); - virtual ir_visitor_status visit_leave(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_if *); - - void add_copy(ir_assignment *ir); - void kill(ir_variable *ir); - void handle_if_block(exec_list *instructions); - - /** List of acp_entry: The available copies to propagate */ - exec_list *acp; - /** - * List of kill_entry: The variables whose values were killed in this - * block. - */ - exec_list *kills; - - bool progress; - - bool killed_all; - - void *mem_ctx; -}; - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) -{ - /* Treat entry into a function signature as a completely separate - * block. Any instructions at global scope will be shuffled into - * main() at link time, so they're irrelevant to us. - */ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - visit_list_elements(this, &ir->body); - - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = orig_killed_all; - - return visit_continue_with_parent; -} - -ir_visitor_status -ir_copy_propagation_visitor::visit_leave(ir_assignment *ir) -{ - kill(ir->lhs->variable_referenced()); - - add_copy(ir); - - return visit_continue; -} - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_function *ir) -{ - (void) ir; - return visit_continue; -} - -/** - * Replaces dereferences of ACP RHS variables with ACP LHS variables. - * - * This is where the actual copy propagation occurs. Note that the - * rewriting of ir_dereference means that the ir_dereference instance - * must not be shared by multiple IR operations! - */ -ir_visitor_status -ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) -{ - if (this->in_assignee) - return visit_continue; - - ir_variable *var = ir->var; - - foreach_iter(exec_list_iterator, iter, *this->acp) { - acp_entry *entry = (acp_entry *)iter.get(); - - if (var == entry->lhs) { - ir->var = entry->rhs; - this->progress = true; - break; - } - } - - return visit_continue; -} - - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_call *ir) -{ - /* Do copy propagation on call parameters, but skip any out params */ - exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { - ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); - ir_instruction *ir = (ir_instruction *)iter.get(); - if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { - ir->accept(this); - } - sig_param_iter.next(); - } - - /* Since we're unlinked, we don't (necessarily) know the side effects of - * this call. So kill all copies. - */ - acp->make_empty(); - this->killed_all = true; - - return visit_continue_with_parent; -} - -void -ir_copy_propagation_visitor::handle_if_block(exec_list *instructions) -{ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - /* Populate the initial acp with a copy of the original */ - foreach_iter(exec_list_iterator, iter, *orig_acp) { - acp_entry *a = (acp_entry *)iter.get(); - this->acp->push_tail(new(this->mem_ctx) acp_entry(a->lhs, a->rhs)); - } - - visit_list_elements(this, instructions); - - if (this->killed_all) { - orig_acp->make_empty(); - } - - exec_list *new_kills = this->kills; - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = this->killed_all || orig_killed_all; - - foreach_iter(exec_list_iterator, iter, *new_kills) { - kill_entry *k = (kill_entry *)iter.get(); - kill(k->var); - } -} - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_if *ir) -{ - ir->condition->accept(this); - - handle_if_block(&ir->then_instructions); - handle_if_block(&ir->else_instructions); - - /* handle_if_block() already descended into the children. */ - return visit_continue_with_parent; -} - -ir_visitor_status -ir_copy_propagation_visitor::visit_enter(ir_loop *ir) -{ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - /* FINISHME: For now, the initial acp for loops is totally empty. - * We could go through once, then go through again with the acp - * cloned minus the killed entries after the first run through. - */ - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - visit_list_elements(this, &ir->body_instructions); - - if (this->killed_all) { - orig_acp->make_empty(); - } - - exec_list *new_kills = this->kills; - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = this->killed_all || orig_killed_all; - - foreach_iter(exec_list_iterator, iter, *new_kills) { - kill_entry *k = (kill_entry *)iter.get(); - kill(k->var); - } - - /* already descended into the children. */ - return visit_continue_with_parent; -} - -void -ir_copy_propagation_visitor::kill(ir_variable *var) -{ - assert(var != NULL); - - /* Remove any entries currently in the ACP for this kill. */ - foreach_iter(exec_list_iterator, iter, *acp) { - acp_entry *entry = (acp_entry *)iter.get(); - - if (entry->lhs == var || entry->rhs == var) { - entry->remove(); - } - } - - /* Add the LHS variable to the list of killed variables in this block. - */ - this->kills->push_tail(new(this->mem_ctx) kill_entry(var)); -} - -/** - * Adds an entry to the available copy list if it's a plain assignment - * of a variable to a variable. - */ -void -ir_copy_propagation_visitor::add_copy(ir_assignment *ir) -{ - acp_entry *entry; - - if (ir->condition) - return; - - ir_variable *lhs_var = ir->whole_variable_written(); - ir_variable *rhs_var = ir->rhs->whole_variable_referenced(); - - if ((lhs_var != NULL) && (rhs_var != NULL)) { - if (lhs_var == rhs_var) { - /* This is a dumb assignment, but we've conveniently noticed - * it here. Removing it now would mess up the loop iteration - * calling us. Just flag it to not execute, and someone else - * will clean up the mess. - */ - ir->condition = new(ralloc_parent(ir)) ir_constant(false); - this->progress = true; - } else { - entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var); - this->acp->push_tail(entry); - } - } -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_copy_propagation(exec_list *instructions) -{ - ir_copy_propagation_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation_elements.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation_elements.cpp deleted file mode 100644 index ebfd4fd3fe1..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_copy_propagation_elements.cpp +++ /dev/null @@ -1,490 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_copy_propagation_elements.cpp - * - * Replaces usage of recently-copied components of variables with the - * previous copy of the variable. - * - * This pass can be compared with opt_copy_propagation, which operands - * on arbitrary whole-variable copies. However, in order to handle - * the copy propagation of swizzled variables or writemasked writes, - * we want to track things on a channel-wise basis. I found that - * trying to mix the swizzled/writemasked support here with the - * whole-variable stuff in opt_copy_propagation.cpp just made a mess, - * so this is separate despite the ACP handling being somewhat - * similar. - * - * This should reduce the number of MOV instructions in the generated - * programs unless copy propagation is also done on the LIR, and may - * help anyway by triggering other optimizations that live in the HIR. - */ - -#include "ir.h" -#include "ir_rvalue_visitor.h" -#include "ir_basic_block.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -static bool debug = false; - -class acp_entry : public exec_node -{ -public: - acp_entry(ir_variable *lhs, ir_variable *rhs, int write_mask, int swizzle[4]) - { - this->lhs = lhs; - this->rhs = rhs; - this->write_mask = write_mask; - memcpy(this->swizzle, swizzle, sizeof(this->swizzle)); - } - - acp_entry(acp_entry *a) - { - this->lhs = a->lhs; - this->rhs = a->rhs; - this->write_mask = a->write_mask; - memcpy(this->swizzle, a->swizzle, sizeof(this->swizzle)); - } - - ir_variable *lhs; - ir_variable *rhs; - unsigned int write_mask; - int swizzle[4]; -}; - - -class kill_entry : public exec_node -{ -public: - kill_entry(ir_variable *var, int write_mask) - { - this->var = var; - this->write_mask = write_mask; - } - - ir_variable *var; - unsigned int write_mask; -}; - -class ir_copy_propagation_elements_visitor : public ir_rvalue_visitor { -public: - ir_copy_propagation_elements_visitor() - { - this->progress = false; - this->mem_ctx = ralloc_context(NULL); - this->shader_mem_ctx = NULL; - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - } - ~ir_copy_propagation_elements_visitor() - { - ralloc_free(mem_ctx); - } - - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_leave(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_if *); - virtual ir_visitor_status visit_leave(class ir_swizzle *); - - void handle_rvalue(ir_rvalue **rvalue); - - void add_copy(ir_assignment *ir); - void kill(kill_entry *k); - void handle_if_block(exec_list *instructions); - - /** List of acp_entry: The available copies to propagate */ - exec_list *acp; - /** - * List of kill_entry: The variables whose values were killed in this - * block. - */ - exec_list *kills; - - bool progress; - - bool killed_all; - - /* Context for our local data structures. */ - void *mem_ctx; - /* Context for allocating new shader nodes. */ - void *shader_mem_ctx; -}; - -ir_visitor_status -ir_copy_propagation_elements_visitor::visit_enter(ir_function_signature *ir) -{ - /* Treat entry into a function signature as a completely separate - * block. Any instructions at global scope will be shuffled into - * main() at link time, so they're irrelevant to us. - */ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - visit_list_elements(this, &ir->body); - - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = orig_killed_all; - - return visit_continue_with_parent; -} - -ir_visitor_status -ir_copy_propagation_elements_visitor::visit_leave(ir_assignment *ir) -{ - ir_dereference_variable *lhs = ir->lhs->as_dereference_variable(); - ir_variable *var = ir->lhs->variable_referenced(); - - if (var->type->is_scalar() || var->type->is_vector()) { - kill_entry *k; - - if (lhs) - k = new(mem_ctx) kill_entry(var, ir->write_mask); - else - k = new(mem_ctx) kill_entry(var, ~0); - - kill(k); - } - - add_copy(ir); - - return visit_continue; -} - -ir_visitor_status -ir_copy_propagation_elements_visitor::visit_leave(ir_swizzle *ir) -{ - /* Don't visit the values of swizzles since they are handled while - * visiting the swizzle itself. - */ - return visit_continue; -} - -/** - * Replaces dereferences of ACP RHS variables with ACP LHS variables. - * - * This is where the actual copy propagation occurs. Note that the - * rewriting of ir_dereference means that the ir_dereference instance - * must not be shared by multiple IR operations! - */ -void -ir_copy_propagation_elements_visitor::handle_rvalue(ir_rvalue **ir) -{ - int swizzle_chan[4]; - ir_dereference_variable *deref_var; - ir_variable *source[4] = {NULL, NULL, NULL, NULL}; - int source_chan[4]; - int chans; - - if (!*ir) - return; - - ir_swizzle *swizzle = (*ir)->as_swizzle(); - if (swizzle) { - deref_var = swizzle->val->as_dereference_variable(); - if (!deref_var) - return; - - swizzle_chan[0] = swizzle->mask.x; - swizzle_chan[1] = swizzle->mask.y; - swizzle_chan[2] = swizzle->mask.z; - swizzle_chan[3] = swizzle->mask.w; - chans = swizzle->type->vector_elements; - } else { - deref_var = (*ir)->as_dereference_variable(); - if (!deref_var) - return; - - swizzle_chan[0] = 0; - swizzle_chan[1] = 1; - swizzle_chan[2] = 2; - swizzle_chan[3] = 3; - chans = deref_var->type->vector_elements; - } - - if (this->in_assignee) - return; - - ir_variable *var = deref_var->var; - - /* Try to find ACP entries covering swizzle_chan[], hoping they're - * the same source variable. - */ - foreach_iter(exec_list_iterator, iter, *this->acp) { - acp_entry *entry = (acp_entry *)iter.get(); - - if (var == entry->lhs) { - for (int c = 0; c < chans; c++) { - if (entry->write_mask & (1 << swizzle_chan[c])) { - source[c] = entry->rhs; - source_chan[c] = entry->swizzle[swizzle_chan[c]]; - } - } - } - } - - /* Make sure all channels are copying from the same source variable. */ - if (!source[0]) - return; - for (int c = 1; c < chans; c++) { - if (source[c] != source[0]) - return; - } - - if (!shader_mem_ctx) - shader_mem_ctx = ralloc_parent(deref_var); - - if (debug) { - printf("Copy propagation from:\n"); - (*ir)->print(); - } - - deref_var = new(shader_mem_ctx) ir_dereference_variable(source[0]); - *ir = new(shader_mem_ctx) ir_swizzle(deref_var, - source_chan[0], - source_chan[1], - source_chan[2], - source_chan[3], - chans); - - if (debug) { - printf("to:\n"); - (*ir)->print(); - printf("\n"); - } -} - - -ir_visitor_status -ir_copy_propagation_elements_visitor::visit_enter(ir_call *ir) -{ - /* Do copy propagation on call parameters, but skip any out params */ - exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { - ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); - ir_instruction *ir = (ir_instruction *)iter.get(); - if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) { - ir->accept(this); - } - sig_param_iter.next(); - } - - /* Since we're unlinked, we don't (necessarily) know the side effects of - * this call. So kill all copies. - */ - acp->make_empty(); - this->killed_all = true; - - return visit_continue_with_parent; -} - -void -ir_copy_propagation_elements_visitor::handle_if_block(exec_list *instructions) -{ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - /* Populate the initial acp with a copy of the original */ - foreach_iter(exec_list_iterator, iter, *orig_acp) { - acp_entry *a = (acp_entry *)iter.get(); - this->acp->push_tail(new(this->mem_ctx) acp_entry(a)); - } - - visit_list_elements(this, instructions); - - if (this->killed_all) { - orig_acp->make_empty(); - } - - exec_list *new_kills = this->kills; - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = this->killed_all || orig_killed_all; - - /* Move the new kills into the parent block's list, removing them - * from the parent's ACP list in the process. - */ - foreach_list_safe(node, new_kills) { - kill_entry *k = (kill_entry *)node; - kill(k); - } -} - -ir_visitor_status -ir_copy_propagation_elements_visitor::visit_enter(ir_if *ir) -{ - ir->condition->accept(this); - - handle_if_block(&ir->then_instructions); - handle_if_block(&ir->else_instructions); - - /* handle_if_block() already descended into the children. */ - return visit_continue_with_parent; -} - -ir_visitor_status -ir_copy_propagation_elements_visitor::visit_enter(ir_loop *ir) -{ - exec_list *orig_acp = this->acp; - exec_list *orig_kills = this->kills; - bool orig_killed_all = this->killed_all; - - /* FINISHME: For now, the initial acp for loops is totally empty. - * We could go through once, then go through again with the acp - * cloned minus the killed entries after the first run through. - */ - this->acp = new(mem_ctx) exec_list; - this->kills = new(mem_ctx) exec_list; - this->killed_all = false; - - visit_list_elements(this, &ir->body_instructions); - - if (this->killed_all) { - orig_acp->make_empty(); - } - - exec_list *new_kills = this->kills; - this->kills = orig_kills; - this->acp = orig_acp; - this->killed_all = this->killed_all || orig_killed_all; - - foreach_list_safe(node, new_kills) { - kill_entry *k = (kill_entry *)node; - kill(k); - } - - /* already descended into the children. */ - return visit_continue_with_parent; -} - -/* Remove any entries currently in the ACP for this kill. */ -void -ir_copy_propagation_elements_visitor::kill(kill_entry *k) -{ - foreach_list_safe(node, acp) { - acp_entry *entry = (acp_entry *)node; - - if (entry->lhs == k->var) { - entry->write_mask = entry->write_mask & ~k->write_mask; - if (entry->write_mask == 0) { - entry->remove(); - continue; - } - } - if (entry->rhs == k->var) { - entry->remove(); - } - } - - /* If we were on a list, remove ourselves before inserting */ - if (k->next) - k->remove(); - - this->kills->push_tail(k); -} - -/** - * Adds directly-copied channels between vector variables to the available - * copy propagation list. - */ -void -ir_copy_propagation_elements_visitor::add_copy(ir_assignment *ir) -{ - acp_entry *entry; - int orig_swizzle[4] = {0, 1, 2, 3}; - int swizzle[4]; - - if (ir->condition) - return; - - ir_dereference_variable *lhs = ir->lhs->as_dereference_variable(); - if (!lhs || !(lhs->type->is_scalar() || lhs->type->is_vector())) - return; - - ir_dereference_variable *rhs = ir->rhs->as_dereference_variable(); - if (!rhs) { - ir_swizzle *swiz = ir->rhs->as_swizzle(); - if (!swiz) - return; - - rhs = swiz->val->as_dereference_variable(); - if (!rhs) - return; - - orig_swizzle[0] = swiz->mask.x; - orig_swizzle[1] = swiz->mask.y; - orig_swizzle[2] = swiz->mask.z; - orig_swizzle[3] = swiz->mask.w; - } - - /* Move the swizzle channels out to the positions they match in the - * destination. We don't want to have to rewrite the swizzle[] - * array every time we clear a bit of the write_mask. - */ - int j = 0; - for (int i = 0; i < 4; i++) { - if (ir->write_mask & (1 << i)) - swizzle[i] = orig_swizzle[j++]; - } - - int write_mask = ir->write_mask; - if (lhs->var == rhs->var) { - /* If this is a copy from the variable to itself, then we need - * to be sure not to include the updated channels from this - * instruction in the set of new source channels to be - * copy-propagated from. - */ - for (int i = 0; i < 4; i++) { - if (ir->write_mask & (1 << orig_swizzle[i])) - write_mask &= ~(1 << i); - } - } - - entry = new(this->mem_ctx) acp_entry(lhs->var, rhs->var, write_mask, - swizzle); - this->acp->push_tail(entry); -} - -bool -do_copy_propagation_elements(exec_list *instructions) -{ - ir_copy_propagation_elements_visitor v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_dead_code.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_dead_code.cpp deleted file mode 100644 index 5b9546ad409..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_dead_code.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_dead_code.cpp - * - * Eliminates dead assignments and variable declarations from the code. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_variable_refcount.h" -#include "glsl_types.h" - -static bool debug = false; - -/** - * Do a dead code pass over instructions and everything that instructions - * references. - * - * Note that this will remove assignments to globals, so it is not suitable - * for usage on an unlinked instruction stream. - */ -bool -do_dead_code(exec_list *instructions, bool uniform_locations_assigned) -{ - ir_variable_refcount_visitor v; - bool progress = false; - - v.run(instructions); - - foreach_iter(exec_list_iterator, iter, v.variable_list) { - variable_entry *entry = (variable_entry *)iter.get(); - - /* Since each assignment is a reference, the refereneced count must be - * greater than or equal to the assignment count. If they are equal, - * then all of the references are assignments, and the variable is - * dead. - * - * Note that if the variable is neither assigned nor referenced, both - * counts will be zero and will be caught by the equality test. - */ - assert(entry->referenced_count >= entry->assigned_count); - - if (debug) { - printf("%s@%p: %d refs, %d assigns, %sdeclared in our scope\n", - entry->var->name, (void *) entry->var, - entry->referenced_count, entry->assigned_count, - entry->declaration ? "" : "not "); - } - - if ((entry->referenced_count > entry->assigned_count) - || !entry->declaration) - continue; - - if (entry->assign) { - /* Remove a single dead assignment to the variable we found. - * Don't do so if it's a shader output, though. - */ - if (entry->var->mode != ir_var_out && - entry->var->mode != ir_var_inout && - !ir_has_call(entry->assign)) { - entry->assign->remove(); - progress = true; - - if (debug) { - printf("Removed assignment to %s@%p\n", - entry->var->name, (void *) entry->var); - } - } - } else { - /* If there are no assignments or references to the variable left, - * then we can remove its declaration. - */ - - /* uniform initializers are precious, and could get used by another - * stage. Also, once uniform locations have been assigned, the - * declaration cannot be deleted. - */ - if (entry->var->mode == ir_var_uniform && - (uniform_locations_assigned || entry->var->constant_value)) - continue; - - entry->var->remove(); - progress = true; - - if (debug) { - printf("Removed declaration of %s@%p\n", - entry->var->name, (void *) entry->var); - } - } - } - - return progress; -} - -/** - * Does a dead code pass on the functions present in the instruction stream. - * - * This is suitable for use while the program is not linked, as it will - * ignore variable declarations (and the assignments to them) for variables - * with global scope. - */ -bool -do_dead_code_unlinked(exec_list *instructions) -{ - bool progress = false; - - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_function *f = ir->as_function(); - if (f) { - foreach_iter(exec_list_iterator, sigiter, *f) { - ir_function_signature *sig = - (ir_function_signature *) sigiter.get(); - /* The setting of the uniform_locations_assigned flag here is - * irrelevent. If there is a uniform declaration encountered - * inside the body of the function, something has already gone - * terribly, terribly wrong. - */ - if (do_dead_code(&sig->body, false)) - progress = true; - } - } - } - - return progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_dead_code_local.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_dead_code_local.cpp deleted file mode 100644 index 39962bd602e..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_dead_code_local.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_dead_code_local.cpp - * - * Eliminates local dead assignments from the code. - * - * This operates on basic blocks, tracking assignments and finding if - * they're used before the variable is completely reassigned. - * - * Compare this to ir_dead_code.cpp, which operates globally looking - * for assignments to variables that are never read. - */ - -#include "ir.h" -#include "ir_basic_block.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -static bool debug = false; - -class assignment_entry : public exec_node -{ -public: - assignment_entry(ir_variable *lhs, ir_instruction *ir) - { - assert(lhs); - assert(ir); - this->lhs = lhs; - this->ir = ir; - } - - ir_variable *lhs; - ir_instruction *ir; -}; - -class kill_for_derefs_visitor : public ir_hierarchical_visitor { -public: - kill_for_derefs_visitor(exec_list *assignments) - { - this->assignments = assignments; - } - - virtual ir_visitor_status visit(ir_dereference_variable *ir) - { - ir_variable *const var = ir->variable_referenced(); - - foreach_iter(exec_list_iterator, iter, *this->assignments) { - assignment_entry *entry = (assignment_entry *)iter.get(); - - if (entry->lhs == var) { - if (debug) - printf("kill %s\n", entry->lhs->name); - entry->remove(); - } - } - - return visit_continue; - } - -private: - exec_list *assignments; -}; - -class array_index_visit : public ir_hierarchical_visitor { -public: - array_index_visit(ir_hierarchical_visitor *v) - { - this->visitor = v; - } - - virtual ir_visitor_status visit_enter(class ir_dereference_array *ir) - { - ir->array_index->accept(visitor); - return visit_continue; - } - - static void run(ir_instruction *ir, ir_hierarchical_visitor *v) - { - array_index_visit top_visit(v); - ir->accept(& top_visit); - } - - ir_hierarchical_visitor *visitor; -}; - - -/** - * Adds an entry to the available copy list if it's a plain assignment - * of a variable to a variable. - */ -static bool -process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments) -{ - ir_variable *var = NULL; - bool progress = false; - kill_for_derefs_visitor v(assignments); - - /* Kill assignment entries for things used to produce this assignment. */ - ir->rhs->accept(&v); - if (ir->condition) { - ir->condition->accept(&v); - } - - /* Kill assignment enties used as array indices. - */ - array_index_visit::run(ir->lhs, &v); - var = ir->lhs->variable_referenced(); - assert(var); - - /* Now, check if we did a whole-variable assignment. */ - if (!ir->condition && (ir->whole_variable_written() != NULL)) { - /* We did a whole-variable assignment. So, any instruction in - * the assignment list with the same LHS is dead. - */ - if (debug) - printf("looking for %s to remove\n", var->name); - foreach_iter(exec_list_iterator, iter, *assignments) { - assignment_entry *entry = (assignment_entry *)iter.get(); - - if (entry->lhs == var) { - if (debug) - printf("removing %s\n", var->name); - entry->ir->remove(); - entry->remove(); - progress = true; - } - } - } - - /* Add this instruction to the assignment list available to be removed. - * But not if the assignment has other side effects. - */ - if (ir_has_call(ir)) - return progress; - - assignment_entry *entry = new(ctx) assignment_entry(var, ir); - assignments->push_tail(entry); - - if (debug) { - printf("add %s\n", var->name); - - printf("current entries\n"); - foreach_iter(exec_list_iterator, iter, *assignments) { - assignment_entry *entry = (assignment_entry *)iter.get(); - - printf(" %s\n", entry->lhs->name); - } - } - - return progress; -} - -static void -dead_code_local_basic_block(ir_instruction *first, - ir_instruction *last, - void *data) -{ - ir_instruction *ir, *ir_next; - /* List of avaialble_copy */ - exec_list assignments; - bool *out_progress = (bool *)data; - bool progress = false; - - void *ctx = ralloc_context(NULL); - /* Safe looping, since process_assignment */ - for (ir = first, ir_next = (ir_instruction *)first->next;; - ir = ir_next, ir_next = (ir_instruction *)ir->next) { - ir_assignment *ir_assign = ir->as_assignment(); - - if (debug) { - ir->print(); - printf("\n"); - } - - if (ir_assign) { - progress = process_assignment(ctx, ir_assign, &assignments) || progress; - } else { - kill_for_derefs_visitor kill(&assignments); - ir->accept(&kill); - } - - if (ir == last) - break; - } - *out_progress = progress; - ralloc_free(ctx); -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_dead_code_local(exec_list *instructions) -{ - bool progress = false; - - call_for_basic_blocks(instructions, dead_code_local_basic_block, &progress); - - return progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_dead_functions.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_dead_functions.cpp deleted file mode 100644 index 51c77e3b947..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_dead_functions.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_dead_functions.cpp - * - * Eliminates unused functions from the linked program. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" - -class signature_entry : public exec_node -{ -public: - signature_entry(ir_function_signature *sig) - { - this->signature = sig; - this->used = false; - } - - ir_function_signature *signature; - bool used; -}; - -class ir_dead_functions_visitor : public ir_hierarchical_visitor { -public: - ir_dead_functions_visitor() - { - this->mem_ctx = ralloc_context(NULL); - } - - ~ir_dead_functions_visitor() - { - ralloc_free(this->mem_ctx); - } - - virtual ir_visitor_status visit_enter(ir_function_signature *); - virtual ir_visitor_status visit_enter(ir_call *); - - signature_entry *get_signature_entry(ir_function_signature *var); - - bool (*predicate)(ir_instruction *ir); - - /* List of signature_entry */ - exec_list signature_list; - void *mem_ctx; -}; - - -signature_entry * -ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig) -{ - foreach_iter(exec_list_iterator, iter, this->signature_list) { - signature_entry *entry = (signature_entry *)iter.get(); - if (entry->signature == sig) - return entry; - } - - signature_entry *entry = new(mem_ctx) signature_entry(sig); - this->signature_list.push_tail(entry); - return entry; -} - - -ir_visitor_status -ir_dead_functions_visitor::visit_enter(ir_function_signature *ir) -{ - signature_entry *entry = this->get_signature_entry(ir); - - if (strcmp(ir->function_name(), "main") == 0) { - entry->used = true; - } - - - - return visit_continue; -} - - -ir_visitor_status -ir_dead_functions_visitor::visit_enter(ir_call *ir) -{ - signature_entry *entry = this->get_signature_entry(ir->get_callee()); - - entry->used = true; - - return visit_continue; -} - -bool -do_dead_functions(exec_list *instructions) -{ - ir_dead_functions_visitor v; - bool progress = false; - - visit_list_elements(&v, instructions); - - /* Now that we've figured out which function signatures are used, remove - * the unused ones, and remove function definitions that have no more - * signatures. - */ - foreach_iter(exec_list_iterator, iter, v.signature_list) { - signature_entry *entry = (signature_entry *)iter.get(); - - if (!entry->used) { - entry->signature->remove(); - delete entry->signature; - progress = true; - } - delete(entry); - } - - /* We don't just do this above when we nuked a signature because of - * const pointers. - */ - foreach_iter(exec_list_iterator, iter, *instructions) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_function *func = ir->as_function(); - - if (func && func->signatures.is_empty()) { - /* At this point (post-linking), the symbol table is no - * longer in use, so not removing the function from the - * symbol table should be OK. - */ - func->remove(); - delete func; - progress = true; - } - } - - return progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_discard_simplification.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_discard_simplification.cpp deleted file mode 100644 index ba4981bae53..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_discard_simplification.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_discard_simplification.cpp - * - * This pass simplifies if-statements and loops containing unconditional - * discards. - * - * Case 1: Both branches contain unconditional discards: - * ----------------------------------------------------- - * - * if (cond) { - * s1; - * discard; - * s2; - * } else { - * s3; - * discard; - * s4; - * } - * - * becomes: - * - * discard - * - * Case 2: The "then" clause contains an unconditional discard: - * ------------------------------------------------------------ - * - * if (cond) { - * s1; - * discard; - * s2; - * } else { - * s3; - * } - * - * becomes: - * - * if (cond) { - * discard; - * } else { - * s3; - * } - * - * Case 3: The "else" clause contains an unconditional discard: - * ------------------------------------------------------------ - * - * if (cond) { - * s1; - * } else { - * s2; - * discard; - * s3; - * } - * - * becomes: - * - * if (cond) { - * s1; - * } else { - * discard; - * } - */ - -#include "glsl_types.h" -#include "ir.h" - -class discard_simplifier : public ir_hierarchical_visitor { -public: - discard_simplifier() - { - this->progress = false; - } - - ir_visitor_status visit_enter(ir_if *); - ir_visitor_status visit_enter(ir_loop *); - ir_visitor_status visit_enter(ir_assignment *); - - bool progress; -}; - -static ir_discard * -find_unconditional_discard(exec_list &instructions) -{ - foreach_list(n, &instructions) { - ir_instruction *ir = (ir_instruction *)n; - - if (ir->ir_type == ir_type_return || - ir->ir_type == ir_type_loop_jump) - return NULL; - - /* So far, this code doesn't know how to look inside of flow - * control to see if a discard later on at this level is - * unconditional. - */ - if (ir->ir_type == ir_type_if || - ir->ir_type == ir_type_loop) - return NULL; - - ir_discard *discard = ir->as_discard(); - if (discard != NULL && discard->condition == NULL) - return discard; - } - return NULL; -} - -static bool -is_only_instruction(ir_discard *discard) -{ - return (discard->prev->is_head_sentinel() && - discard->next->is_tail_sentinel()); -} - -/* We only care about the top level instructions, so don't descend - * into expressions. - */ -ir_visitor_status -discard_simplifier::visit_enter(ir_assignment *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - -ir_visitor_status -discard_simplifier::visit_enter(ir_if *ir) -{ - ir_discard *then_discard = find_unconditional_discard(ir->then_instructions); - ir_discard *else_discard = find_unconditional_discard(ir->else_instructions); - - if (then_discard == NULL && else_discard == NULL) - return visit_continue; - - /* If both branches result in discard, replace whole if with discard. */ - if (then_discard != NULL && else_discard != NULL) { - this->progress = true; - ir->replace_with(then_discard); - return visit_continue_with_parent; - } - - /* Otherwise, one branch has a discard. */ - if (then_discard != NULL && !is_only_instruction(then_discard)) { - this->progress = true; - ir->then_instructions.make_empty(); - ir->then_instructions.push_tail(then_discard); - } else if (else_discard != NULL && !is_only_instruction(else_discard)) { - this->progress = true; - ir->else_instructions.make_empty(); - ir->else_instructions.push_tail(else_discard); - } - - visit_list_elements(this, &ir->then_instructions); - return visit_continue_with_parent; -} - -ir_visitor_status -discard_simplifier::visit_enter(ir_loop *ir) -{ - ir_discard *discard = find_unconditional_discard(ir->body_instructions); - - if (discard) { - ir->replace_with(discard); - return visit_continue_with_parent; - } - - return visit_continue; -} - -bool -do_discard_simplification(exec_list *instructions) -{ - /* Look for a top-level unconditional discard */ - ir_discard *discard = find_unconditional_discard(*instructions); - if (discard != NULL) { - instructions->make_empty(); - instructions->push_tail(discard); - return true; - } - - discard_simplifier v; - - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_function_inlining.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_function_inlining.cpp deleted file mode 100644 index ec8b72c632f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_function_inlining.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_function_inlining.cpp - * - * Replaces calls to functions with the body of the function. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_function_inlining.h" -#include "ir_expression_flattening.h" -#include "glsl_types.h" -#include "program/hash_table.h" - -static void -do_sampler_replacement(exec_list *instructions, - ir_variable *sampler, - ir_dereference *deref); - -class ir_function_inlining_visitor : public ir_hierarchical_visitor { -public: - ir_function_inlining_visitor() - { - progress = false; - } - - virtual ~ir_function_inlining_visitor() - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_expression *); - virtual ir_visitor_status visit_enter(ir_call *); - virtual ir_visitor_status visit_enter(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_texture *); - virtual ir_visitor_status visit_enter(ir_swizzle *); - - bool progress; -}; - - -bool -automatic_inlining_predicate(ir_instruction *ir) -{ - ir_call *call = ir->as_call(); - - if (call && can_inline(call)) - return true; - - return false; -} - -bool -do_function_inlining(exec_list *instructions) -{ - ir_function_inlining_visitor v; - - do_expression_flattening(instructions, automatic_inlining_predicate); - - v.run(instructions); - - return v.progress; -} - -static void -replace_return_with_assignment(ir_instruction *ir, void *data) -{ - void *ctx = ralloc_parent(ir); - ir_variable *retval = (ir_variable *)data; - ir_return *ret = ir->as_return(); - - if (ret) { - if (ret->value) { - ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval); - ret->replace_with(new(ctx) ir_assignment(lhs, ret->value, NULL)); - } else { - /* un-valued return has to be the last return, or we shouldn't - * have reached here. (see can_inline()). - */ - assert(ret->next->is_tail_sentinel()); - ret->remove(); - } - } -} - -ir_rvalue * -ir_call::generate_inline(ir_instruction *next_ir) -{ - void *ctx = ralloc_parent(this); - ir_variable **parameters; - int num_parameters; - int i; - ir_variable *retval = NULL; - struct hash_table *ht; - - ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); - - num_parameters = 0; - foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters) - num_parameters++; - - parameters = new ir_variable *[num_parameters]; - - /* Generate storage for the return value. */ - if (!this->callee->return_type->is_void()) { - retval = new(ctx) ir_variable(this->callee->return_type, "_ret_val", - ir_var_auto); - next_ir->insert_before(retval); - } - - /* Generate the declarations for the parameters to our inlined code, - * and set up the mapping of real function body variables to ours. - */ - i = 0; - exec_list_iterator sig_param_iter = this->callee->parameters.iterator(); - exec_list_iterator param_iter = this->actual_parameters.iterator(); - for (i = 0; i < num_parameters; i++) { - ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); - ir_rvalue *param = (ir_rvalue *) param_iter.get(); - - /* Generate a new variable for the parameter. */ - if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { - /* For samplers, we want the inlined sampler references - * referencing the passed in sampler variable, since that - * will have the location information, which an assignment of - * a sampler wouldn't. Fix it up below. - */ - parameters[i] = NULL; - } else { - parameters[i] = sig_param->clone(ctx, ht); - parameters[i]->mode = ir_var_auto; - - /* Remove the read-only decoration becuase we're going to write - * directly to this variable. If the cloned variable is left - * read-only and the inlined function is inside a loop, the loop - * analysis code will get confused. - */ - parameters[i]->read_only = false; - next_ir->insert_before(parameters[i]); - } - - /* Move the actual param into our param variable if it's an 'in' type. */ - if (parameters[i] && (sig_param->mode == ir_var_in || - sig_param->mode == ir_var_const_in || - sig_param->mode == ir_var_inout)) { - ir_assignment *assign; - - assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), - param, NULL); - next_ir->insert_before(assign); - } - - sig_param_iter.next(); - param_iter.next(); - } - - exec_list new_instructions; - - /* Generate the inlined body of the function to a new list */ - foreach_iter(exec_list_iterator, iter, callee->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_instruction *new_ir = ir->clone(ctx, ht); - - new_instructions.push_tail(new_ir); - visit_tree(new_ir, replace_return_with_assignment, retval); - } - - /* If any samplers were passed in, replace any deref of the sampler - * with a deref of the sampler argument. - */ - param_iter = this->actual_parameters.iterator(); - sig_param_iter = this->callee->parameters.iterator(); - for (i = 0; i < num_parameters; i++) { - ir_instruction *const param = (ir_instruction *) param_iter.get(); - ir_variable *sig_param = (ir_variable *) sig_param_iter.get(); - - if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) { - ir_dereference *deref = param->as_dereference(); - - assert(deref); - do_sampler_replacement(&new_instructions, sig_param, deref); - } - param_iter.next(); - sig_param_iter.next(); - } - - /* Now push those new instructions in. */ - next_ir->insert_before(&new_instructions); - - /* Copy back the value of any 'out' parameters from the function body - * variables to our own. - */ - i = 0; - param_iter = this->actual_parameters.iterator(); - sig_param_iter = this->callee->parameters.iterator(); - for (i = 0; i < num_parameters; i++) { - ir_instruction *const param = (ir_instruction *) param_iter.get(); - const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get(); - - /* Move our param variable into the actual param if it's an 'out' type. */ - if (parameters[i] && (sig_param->mode == ir_var_out || - sig_param->mode == ir_var_inout)) { - ir_assignment *assign; - - assign = new(ctx) ir_assignment(param->clone(ctx, NULL)->as_rvalue(), - new(ctx) ir_dereference_variable(parameters[i]), - NULL); - next_ir->insert_before(assign); - } - - param_iter.next(); - sig_param_iter.next(); - } - - delete [] parameters; - - hash_table_dtor(ht); - - if (retval) - return new(ctx) ir_dereference_variable(retval); - else - return NULL; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_expression *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_return *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_texture *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_swizzle *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_call *ir) -{ - if (can_inline(ir)) { - /* If the call was part of some tree, then it should have been - * flattened out or we shouldn't have seen it because of a - * visit_continue_with_parent in this visitor. - */ - assert(ir == base_ir); - - (void) ir->generate_inline(ir); - ir->remove(); - this->progress = true; - } - - return visit_continue; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_assignment *ir) -{ - ir_call *call = ir->rhs->as_call(); - if (!call || !can_inline(call)) - return visit_continue; - - /* generates the parameter setup, function body, and returns the return - * value of the function - */ - ir_rvalue *rhs = call->generate_inline(ir); - assert(rhs); - - ir->rhs = rhs; - this->progress = true; - - return visit_continue; -} - -/** - * Replaces references to the "sampler" variable with a clone of "deref." - * - * From the spec, samplers can appear in the tree as function - * (non-out) parameters and as the result of array indexing and - * structure field selection. In our builtin implementation, they - * also appear in the sampler field of an ir_tex instruction. - */ - -class ir_sampler_replacement_visitor : public ir_hierarchical_visitor { -public: - ir_sampler_replacement_visitor(ir_variable *sampler, ir_dereference *deref) - { - this->sampler = sampler; - this->deref = deref; - } - - virtual ~ir_sampler_replacement_visitor() - { - } - - virtual ir_visitor_status visit_leave(ir_call *); - virtual ir_visitor_status visit_leave(ir_dereference_array *); - virtual ir_visitor_status visit_leave(ir_dereference_record *); - virtual ir_visitor_status visit_leave(ir_texture *); - - void replace_deref(ir_dereference **deref); - void replace_rvalue(ir_rvalue **rvalue); - - ir_variable *sampler; - ir_dereference *deref; -}; - -void -ir_sampler_replacement_visitor::replace_deref(ir_dereference **deref) -{ - ir_dereference_variable *deref_var = (*deref)->as_dereference_variable(); - if (deref_var && deref_var->var == this->sampler) { - *deref = this->deref->clone(ralloc_parent(*deref), NULL); - } -} - -void -ir_sampler_replacement_visitor::replace_rvalue(ir_rvalue **rvalue) -{ - if (!*rvalue) - return; - - ir_dereference *deref = (*rvalue)->as_dereference(); - - if (!deref) - return; - - replace_deref(&deref); - *rvalue = deref; -} - -ir_visitor_status -ir_sampler_replacement_visitor::visit_leave(ir_texture *ir) -{ - replace_deref(&ir->sampler); - - return visit_continue; -} - -ir_visitor_status -ir_sampler_replacement_visitor::visit_leave(ir_dereference_array *ir) -{ - replace_rvalue(&ir->array); - return visit_continue; -} - -ir_visitor_status -ir_sampler_replacement_visitor::visit_leave(ir_dereference_record *ir) -{ - replace_rvalue(&ir->record); - return visit_continue; -} - -ir_visitor_status -ir_sampler_replacement_visitor::visit_leave(ir_call *ir) -{ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = param; - replace_rvalue(&new_param); - - if (new_param != param) { - param->replace_with(new_param); - } - } - return visit_continue; -} - -static void -do_sampler_replacement(exec_list *instructions, - ir_variable *sampler, - ir_dereference *deref) -{ - ir_sampler_replacement_visitor v(sampler, deref); - - visit_list_elements(&v, instructions); -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_if_simplification.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_if_simplification.cpp deleted file mode 100644 index 940dd08d576..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_if_simplification.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_if_simplification.cpp - * - * Moves constant branches of if statements out to the surrounding - * instruction stream. - */ - -#include "ir.h" - -class ir_if_simplification_visitor : public ir_hierarchical_visitor { -public: - ir_if_simplification_visitor() - { - this->made_progress = false; - } - - ir_visitor_status visit_leave(ir_if *); - ir_visitor_status visit_enter(ir_assignment *); - - bool made_progress; -}; - -/* We only care about the top level "if" instructions, so don't - * descend into expressions. - */ -ir_visitor_status -ir_if_simplification_visitor::visit_enter(ir_assignment *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - -bool -do_if_simplification(exec_list *instructions) -{ - ir_if_simplification_visitor v; - - v.run(instructions); - return v.made_progress; -} - - -ir_visitor_status -ir_if_simplification_visitor::visit_leave(ir_if *ir) -{ - /* FINISHME: Ideally there would be a way to note that the condition results - * FINISHME: in a constant before processing both of the other subtrees. - * FINISHME: This can probably be done with some flags, but it would take - * FINISHME: some work to get right. - */ - ir_constant *condition_constant = ir->condition->constant_expression_value(); - if (condition_constant) { - /* Move the contents of the one branch of the conditional - * that matters out. - */ - if (condition_constant->value.b[0]) { - foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { - ir_instruction *then_ir = (ir_instruction *)then_iter.get(); - ir->insert_before(then_ir); - } - } else { - foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { - ir_instruction *else_ir = (ir_instruction *)else_iter.get(); - ir->insert_before(else_ir); - } - } - ir->remove(); - this->made_progress = true; - } - - return visit_continue; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_noop_swizzle.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_noop_swizzle.cpp deleted file mode 100644 index 0a906aaf1da..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_noop_swizzle.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_noop_swizzle.cpp - * - * If a swizzle doesn't change the order or count of components, then - * remove the swizzle so that other optimization passes see the value - * behind it. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_rvalue_visitor.h" -#include "ir_print_visitor.h" -#include "glsl_types.h" - -class ir_noop_swizzle_visitor : public ir_rvalue_visitor { -public: - ir_noop_swizzle_visitor() - { - this->progress = false; - } - - void handle_rvalue(ir_rvalue **rvalue); - bool progress; -}; - -void -ir_noop_swizzle_visitor::handle_rvalue(ir_rvalue **rvalue) -{ - if (!*rvalue) - return; - - ir_swizzle *swiz = (*rvalue)->as_swizzle(); - if (!swiz || swiz->type != swiz->val->type) - return; - - int elems = swiz->val->type->vector_elements; - if (swiz->mask.x != 0) - return; - if (elems >= 2 && swiz->mask.y != 1) - return; - if (elems >= 3 && swiz->mask.z != 2) - return; - if (elems >= 4 && swiz->mask.w != 3) - return; - - this->progress = true; - *rvalue = swiz->val; -} - -bool -do_noop_swizzle(exec_list *instructions) -{ - ir_noop_swizzle_visitor v; - visit_list_elements(&v, instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_redundant_jumps.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_redundant_jumps.cpp deleted file mode 100644 index f350fa947c9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_redundant_jumps.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_redundant_jumps.cpp - * Remove certain types of redundant jumps - */ - -#include "ir.h" - -class redundant_jumps_visitor : public ir_hierarchical_visitor { -public: - redundant_jumps_visitor() - { - this->progress = false; - } - - virtual ir_visitor_status visit_leave(ir_if *); - virtual ir_visitor_status visit_leave(ir_loop *); - virtual ir_visitor_status visit_enter(ir_assignment *); - - bool progress; -}; - -/* We only care about the top level instructions, so don't descend - * into expressions. - */ -ir_visitor_status -redundant_jumps_visitor::visit_enter(ir_assignment *ir) -{ - return visit_continue_with_parent; -} - -ir_visitor_status -redundant_jumps_visitor::visit_leave(ir_if *ir) -{ - /* If the last instruction in both branches is a 'break' or a 'continue', - * pull it out of the branches and insert it after the if-statment. Note - * that both must be the same type (either 'break' or 'continue'). - */ - ir_instruction *const last_then = - (ir_instruction *) ir->then_instructions.get_tail(); - ir_instruction *const last_else = - (ir_instruction *) ir->else_instructions.get_tail(); - - if ((last_then == NULL) || (last_else == NULL)) - return visit_continue; - - if ((last_then->ir_type != ir_type_loop_jump) - || (last_else->ir_type != ir_type_loop_jump)) - return visit_continue; - - ir_loop_jump *const then_jump = (ir_loop_jump *) last_then; - ir_loop_jump *const else_jump = (ir_loop_jump *) last_else; - - if (then_jump->mode != else_jump->mode) - return visit_continue; - - then_jump->remove(); - else_jump->remove(); - this->progress = true; - - ir->insert_after(then_jump); - - /* If both branchs of the if-statement are now empty, remove the - * if-statement. - */ - if (ir->then_instructions.is_empty() && ir->else_instructions.is_empty()) - ir->remove(); - - return visit_continue; -} - - -ir_visitor_status -redundant_jumps_visitor::visit_leave(ir_loop *ir) -{ - /* If the last instruction of a loop body is a 'continue', remove it. - */ - ir_instruction *const last = - (ir_instruction *) ir->body_instructions.get_tail(); - - if (last && (last->ir_type == ir_type_loop_jump) - && (((ir_loop_jump *) last)->mode == ir_loop_jump::jump_continue)) { - last->remove(); - this->progress = true; - } - - return visit_continue; -} - - -bool -optimize_redundant_jumps(exec_list *instructions) -{ - redundant_jumps_visitor v; - - v.run(instructions); - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_structure_splitting.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_structure_splitting.cpp deleted file mode 100644 index 2c1f6bb227a..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_structure_splitting.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_structure_splitting.cpp - * - * If a structure is only ever referenced by its components, then - * split those components out to individual variables so they can be - * handled normally by other optimization passes. - * - * This skips structures like uniforms, which need to be accessible as - * structures for their access by the GL. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_print_visitor.h" -#include "ir_rvalue_visitor.h" -#include "glsl_types.h" - -static bool debug = false; - -// XXX using variable_entry2 here to avoid collision (MSVC multiply-defined -// function) with the variable_entry class seen in ir_variable_refcount.h -// Perhaps we can use the one in ir_variable_refcount.h and make this class -// here go away? -class variable_entry2 : public exec_node -{ -public: - variable_entry2(ir_variable *var) - { - this->var = var; - this->whole_structure_access = 0; - this->declaration = false; - this->components = NULL; - this->mem_ctx = NULL; - } - - ir_variable *var; /* The key: the variable's pointer. */ - - /** Number of times the variable is referenced, including assignments. */ - unsigned whole_structure_access; - - bool declaration; /* If the variable had a decl in the instruction stream */ - - ir_variable **components; - - /** ralloc_parent(this->var) -- the shader's ralloc context. */ - void *mem_ctx; -}; - - -class ir_structure_reference_visitor : public ir_hierarchical_visitor { -public: - ir_structure_reference_visitor(void) - { - this->mem_ctx = ralloc_context(NULL); - this->variable_list.make_empty(); - } - - ~ir_structure_reference_visitor(void) - { - ralloc_free(mem_ctx); - } - - virtual ir_visitor_status visit(ir_variable *); - virtual ir_visitor_status visit(ir_dereference_variable *); - virtual ir_visitor_status visit_enter(ir_dereference_record *); - virtual ir_visitor_status visit_enter(ir_assignment *); - virtual ir_visitor_status visit_enter(ir_function_signature *); - - variable_entry2 *get_variable_entry2(ir_variable *var); - - /* List of variable_entry */ - exec_list variable_list; - - void *mem_ctx; -}; - -variable_entry2 * -ir_structure_reference_visitor::get_variable_entry2(ir_variable *var) -{ - assert(var); - - if (!var->type->is_record() || var->mode == ir_var_uniform) - return NULL; - - foreach_iter(exec_list_iterator, iter, this->variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); - if (entry->var == var) - return entry; - } - - variable_entry2 *entry = new(mem_ctx) variable_entry2(var); - this->variable_list.push_tail(entry); - return entry; -} - - -ir_visitor_status -ir_structure_reference_visitor::visit(ir_variable *ir) -{ - variable_entry2 *entry = this->get_variable_entry2(ir); - - if (entry) - entry->declaration = true; - - return visit_continue; -} - -ir_visitor_status -ir_structure_reference_visitor::visit(ir_dereference_variable *ir) -{ - ir_variable *const var = ir->variable_referenced(); - variable_entry2 *entry = this->get_variable_entry2(var); - - if (entry) - entry->whole_structure_access++; - - return visit_continue; -} - -ir_visitor_status -ir_structure_reference_visitor::visit_enter(ir_dereference_record *ir) -{ - (void) ir; - /* Don't descend into the ir_dereference_variable below. */ - return visit_continue_with_parent; -} - -ir_visitor_status -ir_structure_reference_visitor::visit_enter(ir_assignment *ir) -{ - /* If there are no structure references yet, no need to bother with - * processing the expression tree. - */ - if (this->variable_list.is_empty()) - return visit_continue_with_parent; - - if (ir->lhs->as_dereference_variable() && - ir->rhs->as_dereference_variable() && - !ir->condition) { - /* We'll split copies of a structure to copies of components, so don't - * descend to the ir_dereference_variables. - */ - return visit_continue_with_parent; - } - return visit_continue; -} - -ir_visitor_status -ir_structure_reference_visitor::visit_enter(ir_function_signature *ir) -{ - /* We don't want to descend into the function parameters and - * dead-code eliminate them, so just accept the body here. - */ - visit_list_elements(this, &ir->body); - return visit_continue_with_parent; -} - -class ir_structure_splitting_visitor : public ir_rvalue_visitor { -public: - ir_structure_splitting_visitor(exec_list *vars) - { - this->variable_list = vars; - } - - virtual ~ir_structure_splitting_visitor() - { - } - - virtual ir_visitor_status visit_leave(ir_assignment *); - - void split_deref(ir_dereference **deref); - void handle_rvalue(ir_rvalue **rvalue); - variable_entry2 *get_splitting_entry(ir_variable *var); - - exec_list *variable_list; - void *mem_ctx; -}; - -variable_entry2 * -ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var) -{ - assert(var); - - if (!var->type->is_record()) - return NULL; - - foreach_iter(exec_list_iterator, iter, *this->variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); - if (entry->var == var) { - return entry; - } - } - - return NULL; -} - -void -ir_structure_splitting_visitor::split_deref(ir_dereference **deref) -{ - if ((*deref)->ir_type != ir_type_dereference_record) - return; - - ir_dereference_record *deref_record = (ir_dereference_record *)*deref; - ir_dereference_variable *deref_var = deref_record->record->as_dereference_variable(); - if (!deref_var) - return; - - variable_entry2 *entry = get_splitting_entry(deref_var->var); - if (!entry) - return; - - unsigned int i; - for (i = 0; i < entry->var->type->length; i++) { - if (strcmp(deref_record->field, - entry->var->type->fields.structure[i].name) == 0) - break; - } - assert(i != entry->var->type->length); - - *deref = new(entry->mem_ctx) ir_dereference_variable(entry->components[i]); -} - -void -ir_structure_splitting_visitor::handle_rvalue(ir_rvalue **rvalue) -{ - if (!*rvalue) - return; - - ir_dereference *deref = (*rvalue)->as_dereference(); - - if (!deref) - return; - - split_deref(&deref); - *rvalue = deref; -} - -ir_visitor_status -ir_structure_splitting_visitor::visit_leave(ir_assignment *ir) -{ - ir_dereference_variable *lhs_deref = ir->lhs->as_dereference_variable(); - ir_dereference_variable *rhs_deref = ir->rhs->as_dereference_variable(); - variable_entry2 *lhs_entry = lhs_deref ? get_splitting_entry(lhs_deref->var) : NULL; - variable_entry2 *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL; - const glsl_type *type = ir->rhs->type; - - if ((lhs_entry || rhs_entry) && !ir->condition) { - for (unsigned int i = 0; i < type->length; i++) { - ir_dereference *new_lhs, *new_rhs; - void *mem_ctx = lhs_entry ? lhs_entry->mem_ctx : rhs_entry->mem_ctx; - - if (lhs_entry) { - new_lhs = new(mem_ctx) ir_dereference_variable(lhs_entry->components[i]); - } else { - new_lhs = new(mem_ctx) - ir_dereference_record(ir->lhs->clone(mem_ctx, NULL), - type->fields.structure[i].name); - } - - if (rhs_entry) { - new_rhs = new(mem_ctx) ir_dereference_variable(rhs_entry->components[i]); - } else { - new_rhs = new(mem_ctx) - ir_dereference_record(ir->rhs->clone(mem_ctx, NULL), - type->fields.structure[i].name); - } - - ir->insert_before(new(mem_ctx) ir_assignment(new_lhs, - new_rhs, - NULL)); - } - ir->remove(); - } else { - handle_rvalue(&ir->rhs); - split_deref(&ir->lhs); - } - - handle_rvalue(&ir->condition); - - return visit_continue; -} - -bool -do_structure_splitting(exec_list *instructions) -{ - ir_structure_reference_visitor refs; - - visit_list_elements(&refs, instructions); - - /* Trim out variables we can't split. */ - foreach_iter(exec_list_iterator, iter, refs.variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); - - if (debug) { - printf("structure %s@%p: decl %d, whole_access %d\n", - entry->var->name, (void *) entry->var, entry->declaration, - entry->whole_structure_access); - } - - if (!entry->declaration || entry->whole_structure_access) { - entry->remove(); - } - } - - if (refs.variable_list.is_empty()) - return false; - - void *mem_ctx = ralloc_context(NULL); - - /* Replace the decls of the structures to be split with their split - * components. - */ - foreach_iter(exec_list_iterator, iter, refs.variable_list) { - variable_entry2 *entry = (variable_entry2 *)iter.get(); - const struct glsl_type *type = entry->var->type; - - entry->mem_ctx = ralloc_parent(entry->var); - - entry->components = ralloc_array(mem_ctx, - ir_variable *, - type->length); - - for (unsigned int i = 0; i < entry->var->type->length; i++) { - const char *name = ralloc_asprintf(mem_ctx, "%s_%s", - entry->var->name, - type->fields.structure[i].name); - - entry->components[i] = - new(entry->mem_ctx) ir_variable(type->fields.structure[i].type, - name, - ir_var_temporary); - entry->var->insert_before(entry->components[i]); - } - - entry->var->remove(); - } - - ir_structure_splitting_visitor split(&refs.variable_list); - visit_list_elements(&split, instructions); - - ralloc_free(mem_ctx); - - return true; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_swizzle_swizzle.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_swizzle_swizzle.cpp deleted file mode 100644 index bc442fa8693..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_swizzle_swizzle.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_swizzle_swizzle.cpp - * - * Eliminates the second swizzle in a swizzle chain. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor { -public: - ir_swizzle_swizzle_visitor() - { - progress = false; - } - - virtual ir_visitor_status visit_enter(ir_swizzle *); - - bool progress; -}; - -ir_visitor_status -ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir) -{ - int mask2[4]; - - ir_swizzle *swiz2 = ir->val->as_swizzle(); - if (!swiz2) - return visit_continue; - - memset(&mask2, 0, sizeof(mask2)); - if (swiz2->mask.num_components >= 1) - mask2[0] = swiz2->mask.x; - if (swiz2->mask.num_components >= 2) - mask2[1] = swiz2->mask.y; - if (swiz2->mask.num_components >= 3) - mask2[2] = swiz2->mask.z; - if (swiz2->mask.num_components >= 4) - mask2[3] = swiz2->mask.w; - - if (ir->mask.num_components >= 1) - ir->mask.x = mask2[ir->mask.x]; - if (ir->mask.num_components >= 2) - ir->mask.y = mask2[ir->mask.y]; - if (ir->mask.num_components >= 3) - ir->mask.z = mask2[ir->mask.z]; - if (ir->mask.num_components >= 4) - ir->mask.w = mask2[ir->mask.w]; - - ir->val = swiz2->val; - - this->progress = true; - - return visit_continue; -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_swizzle_swizzle(exec_list *instructions) -{ - ir_swizzle_swizzle_visitor v; - - v.run(instructions); - - return v.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/opt_tree_grafting.cpp b/reactos/dll/opengl/mesa/src/glsl/opt_tree_grafting.cpp deleted file mode 100644 index d32d14e88a9..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/opt_tree_grafting.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file opt_tree_grafting.cpp - * - * Takes assignments to variables that are dereferenced only once and - * pastes the RHS expression into where the variable is dereferenced. - * - * In the process of various operations like function inlining and - * tertiary op handling, we'll end up with our expression trees having - * been chopped up into a series of assignments of short expressions - * to temps. Other passes like ir_algebraic.cpp would prefer to see - * the deepest expression trees they can to try to optimize them. - * - * This is a lot like copy propagaton. In comparison, copy - * propagation only acts on plain copies, not arbitrary expressions on - * the RHS. Generally, we wouldn't want to go pasting some - * complicated expression everywhere it got used, though, so we don't - * handle expressions in that pass. - * - * The hard part is making sure we don't move an expression across - * some other assignments that would change the value of the - * expression. So we split this into two passes: First, find the - * variables in our scope which are written to once and read once, and - * then go through basic blocks seeing if we find an opportunity to - * move those expressions safely. - */ - -#include "ir.h" -#include "ir_visitor.h" -#include "ir_variable_refcount.h" -#include "ir_basic_block.h" -#include "ir_optimization.h" -#include "glsl_types.h" - -static bool debug = false; - -class ir_tree_grafting_visitor : public ir_hierarchical_visitor { -public: - ir_tree_grafting_visitor(ir_assignment *graft_assign, - ir_variable *graft_var) - { - this->progress = false; - this->graft_assign = graft_assign; - this->graft_var = graft_var; - } - - virtual ir_visitor_status visit_leave(class ir_assignment *); - virtual ir_visitor_status visit_enter(class ir_call *); - virtual ir_visitor_status visit_enter(class ir_expression *); - virtual ir_visitor_status visit_enter(class ir_function *); - virtual ir_visitor_status visit_enter(class ir_function_signature *); - virtual ir_visitor_status visit_enter(class ir_if *); - virtual ir_visitor_status visit_enter(class ir_loop *); - virtual ir_visitor_status visit_enter(class ir_swizzle *); - virtual ir_visitor_status visit_enter(class ir_texture *); - - ir_visitor_status check_graft(ir_instruction *ir, ir_variable *var); - - bool do_graft(ir_rvalue **rvalue); - - bool progress; - ir_variable *graft_var; - ir_assignment *graft_assign; -}; - -struct find_deref_info { - ir_variable *var; - bool found; -}; - -void -dereferences_variable_callback(ir_instruction *ir, void *data) -{ - struct find_deref_info *info = (struct find_deref_info *)data; - ir_dereference_variable *deref = ir->as_dereference_variable(); - - if (deref && deref->var == info->var) - info->found = true; -} - -static bool -dereferences_variable(ir_instruction *ir, ir_variable *var) -{ - struct find_deref_info info; - - info.var = var; - info.found = false; - - visit_tree(ir, dereferences_variable_callback, &info); - - return info.found; -} - -bool -ir_tree_grafting_visitor::do_graft(ir_rvalue **rvalue) -{ - if (!*rvalue) - return false; - - ir_dereference_variable *deref = (*rvalue)->as_dereference_variable(); - - if (!deref || deref->var != this->graft_var) - return false; - - if (debug) { - printf("GRAFTING:\n"); - this->graft_assign->print(); - printf("\n"); - printf("TO:\n"); - (*rvalue)->print(); - printf("\n"); - } - - this->graft_assign->remove(); - *rvalue = this->graft_assign->rhs; - - this->progress = true; - return true; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_loop *ir) -{ - (void)ir; - /* Do not traverse into the body of the loop since that is a - * different basic block. - */ - return visit_stop; -} - -/** - * Check if we can continue grafting after writing to a variable. If the - * expression we're trying to graft references the variable, we must stop. - * - * \param ir An instruction that writes to a variable. - * \param var The variable being updated. - */ -ir_visitor_status -ir_tree_grafting_visitor::check_graft(ir_instruction *ir, ir_variable *var) -{ - if (dereferences_variable(this->graft_assign->rhs, var)) { - if (debug) { - printf("graft killed by: "); - ir->print(); - printf("\n"); - } - return visit_stop; - } - - return visit_continue; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_leave(ir_assignment *ir) -{ - if (do_graft(&ir->rhs) || - do_graft(&ir->condition)) - return visit_stop; - - /* If this assignment updates a variable used in the assignment - * we're trying to graft, then we're done. - */ - return check_graft(ir, ir->lhs->variable_referenced()); -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_function *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_function_signature *ir) -{ - (void)ir; - return visit_continue_with_parent; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_call *ir) -{ - exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); - /* Reminder: iterating ir_call iterates its parameters. */ - foreach_iter(exec_list_iterator, iter, *ir) { - ir_variable *sig_param = (ir_variable *)sig_iter.get(); - ir_rvalue *ir = (ir_rvalue *)iter.get(); - ir_rvalue *new_ir = ir; - - if (sig_param->mode != ir_var_in && sig_param->mode != ir_var_const_in) { - if (check_graft(ir, sig_param) == visit_stop) - return visit_stop; - continue; - } - - if (do_graft(&new_ir)) { - ir->replace_with(new_ir); - return visit_stop; - } - sig_iter.next(); - } - - return visit_continue; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_expression *ir) -{ - for (unsigned int i = 0; i < ir->get_num_operands(); i++) { - if (do_graft(&ir->operands[i])) - return visit_stop; - } - - return visit_continue; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_if *ir) -{ - if (do_graft(&ir->condition)) - return visit_stop; - - /* Do not traverse into the body of the if-statement since that is a - * different basic block. - */ - return visit_continue_with_parent; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_swizzle *ir) -{ - if (do_graft(&ir->val)) - return visit_stop; - - return visit_continue; -} - -ir_visitor_status -ir_tree_grafting_visitor::visit_enter(ir_texture *ir) -{ - if (do_graft(&ir->coordinate) || - do_graft(&ir->projector) || - do_graft(&ir->offset) || - do_graft(&ir->shadow_comparitor)) - return visit_stop; - - switch (ir->op) { - case ir_tex: - break; - case ir_txb: - if (do_graft(&ir->lod_info.bias)) - return visit_stop; - break; - case ir_txf: - case ir_txl: - case ir_txs: - if (do_graft(&ir->lod_info.lod)) - return visit_stop; - break; - case ir_txd: - if (do_graft(&ir->lod_info.grad.dPdx) || - do_graft(&ir->lod_info.grad.dPdy)) - return visit_stop; - break; - } - - return visit_continue; -} - -struct tree_grafting_info { - ir_variable_refcount_visitor *refs; - bool progress; -}; - -static bool -try_tree_grafting(ir_assignment *start, - ir_variable *lhs_var, - ir_instruction *bb_last) -{ - ir_tree_grafting_visitor v(start, lhs_var); - - if (debug) { - printf("trying to graft: "); - lhs_var->print(); - printf("\n"); - } - - for (ir_instruction *ir = (ir_instruction *)start->next; - ir != bb_last->next; - ir = (ir_instruction *)ir->next) { - - if (debug) { - printf("- "); - ir->print(); - printf("\n"); - } - - ir_visitor_status s = ir->accept(&v); - if (s == visit_stop) - return v.progress; - } - - return false; -} - -static void -tree_grafting_basic_block(ir_instruction *bb_first, - ir_instruction *bb_last, - void *data) -{ - struct tree_grafting_info *info = (struct tree_grafting_info *)data; - ir_instruction *ir, *next; - - for (ir = bb_first, next = (ir_instruction *)ir->next; - ir != bb_last->next; - ir = next, next = (ir_instruction *)ir->next) { - ir_assignment *assign = ir->as_assignment(); - - if (!assign) - continue; - - ir_variable *lhs_var = assign->whole_variable_written(); - if (!lhs_var) - continue; - - if (lhs_var->mode == ir_var_out || - lhs_var->mode == ir_var_inout) - continue; - - variable_entry *entry = info->refs->get_variable_entry(lhs_var); - - if (!entry->declaration || - entry->assigned_count != 1 || - entry->referenced_count != 2) - continue; - - assert(assign == entry->assign); - - /* Found a possibly graftable assignment. Now, walk through the - * rest of the BB seeing if the deref is here, and if nothing interfered with - * pasting its expression's values in between. - */ - info->progress |= try_tree_grafting(assign, lhs_var, bb_last); - } -} - -/** - * Does a copy propagation pass on the code present in the instruction stream. - */ -bool -do_tree_grafting(exec_list *instructions) -{ - ir_variable_refcount_visitor refs; - struct tree_grafting_info info; - - info.progress = false; - info.refs = &refs; - - visit_list_elements(info.refs, instructions); - - call_for_basic_blocks(instructions, tree_grafting_basic_block, &info); - - return info.progress; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/program.h b/reactos/dll/opengl/mesa/src/glsl/program.h deleted file mode 100644 index 437ca1462fa..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/program.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * Copyright © 2010 Intel Corporation - * - * 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. - */ - -#include "main/core.h" - -extern void -link_shaders(struct gl_context *ctx, struct gl_shader_program *prog); - -extern void -linker_error(gl_shader_program *prog, const char *fmt, ...) - PRINTFLIKE(2, 3); - -extern void -linker_warning(gl_shader_program *prog, const char *fmt, ...) - PRINTFLIKE(2, 3); diff --git a/reactos/dll/opengl/mesa/src/glsl/ralloc.c b/reactos/dll/opengl/mesa/src/glsl/ralloc.c deleted file mode 100644 index 51a92fc1f69..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ralloc.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include -#include -#include -#include - -/* Android defines SIZE_MAX in limits.h, instead of the standard stdint.h */ -#ifdef ANDROID -#include -#endif - -/* Some versions of MinGW are missing _vscprintf's declaration, although they - * still provide the symbol in the import library. */ -#ifdef __MINGW32__ -_CRTIMP int _vscprintf(const char *format, va_list argptr); -#endif - -#include "ralloc.h" - -#ifdef __GNUC__ -#define likely(x) __builtin_expect(!!(x),1) -#define unlikely(x) __builtin_expect(!!(x),0) -#else -#define likely(x) !!(x) -#define unlikely(x) !!(x) -#endif - -#ifndef va_copy -#ifdef __va_copy -#define va_copy(dest, src) __va_copy((dest), (src)) -#else -#define va_copy(dest, src) (dest) = (src) -#endif -#endif - -#define CANARY 0x5A1106 - -struct ralloc_header -{ - /* A canary value used to determine whether a pointer is ralloc'd. */ - unsigned canary; - - struct ralloc_header *parent; - - /* The first child (head of a linked list) */ - struct ralloc_header *child; - - /* Linked list of siblings */ - struct ralloc_header *prev; - struct ralloc_header *next; - - void (*destructor)(void *); -}; - -typedef struct ralloc_header ralloc_header; - -static void unlink_block(ralloc_header *info); -static void unsafe_free(ralloc_header *info); - -static ralloc_header * -get_header(const void *ptr) -{ - ralloc_header *info = (ralloc_header *) (((char *) ptr) - - sizeof(ralloc_header)); - assert(info->canary == CANARY); - return info; -} - -#define PTR_FROM_HEADER(info) (((char *) info) + sizeof(ralloc_header)) - -static void -add_child(ralloc_header *parent, ralloc_header *info) -{ - if (parent != NULL) { - info->parent = parent; - info->next = parent->child; - parent->child = info; - - if (info->next != NULL) - info->next->prev = info; - } -} - -void * -ralloc_context(const void *ctx) -{ - return ralloc_size(ctx, 0); -} - -void * -ralloc_size(const void *ctx, size_t size) -{ - void *block = calloc(1, size + sizeof(ralloc_header)); - - ralloc_header *info = (ralloc_header *) block; - ralloc_header *parent = ctx != NULL ? get_header(ctx) : NULL; - - add_child(parent, info); - - info->canary = CANARY; - - return PTR_FROM_HEADER(info); -} - -void * -rzalloc_size(const void *ctx, size_t size) -{ - void *ptr = ralloc_size(ctx, size); - if (likely(ptr != NULL)) - memset(ptr, 0, size); - return ptr; -} - -/* helper function - assumes ptr != NULL */ -static void * -resize(void *ptr, size_t size) -{ - ralloc_header *child, *old, *info; - - old = get_header(ptr); - info = realloc(old, size + sizeof(ralloc_header)); - - if (info == NULL) - return NULL; - - /* Update parent and sibling's links to the reallocated node. */ - if (info != old && info->parent != NULL) { - if (info->parent->child == old) - info->parent->child = info; - - if (info->prev != NULL) - info->prev->next = info; - - if (info->next != NULL) - info->next->prev = info; - } - - /* Update child->parent links for all children */ - for (child = info->child; child != NULL; child = child->next) - child->parent = info; - - return PTR_FROM_HEADER(info); -} - -void * -reralloc_size(const void *ctx, void *ptr, size_t size) -{ - if (unlikely(ptr == NULL)) - return ralloc_size(ctx, size); - - assert(ralloc_parent(ptr) == ctx); - return resize(ptr, size); -} - -void * -ralloc_array_size(const void *ctx, size_t size, unsigned count) -{ - if (count > SIZE_MAX/size) - return NULL; - - return ralloc_size(ctx, size * count); -} - -void * -rzalloc_array_size(const void *ctx, size_t size, unsigned count) -{ - if (count > SIZE_MAX/size) - return NULL; - - return rzalloc_size(ctx, size * count); -} - -void * -reralloc_array_size(const void *ctx, void *ptr, size_t size, unsigned count) -{ - if (count > SIZE_MAX/size) - return NULL; - - return reralloc_size(ctx, ptr, size * count); -} - -void -ralloc_free(void *ptr) -{ - ralloc_header *info; - - if (ptr == NULL) - return; - - info = get_header(ptr); - unlink_block(info); - unsafe_free(info); -} - -static void -unlink_block(ralloc_header *info) -{ - /* Unlink from parent & siblings */ - if (info->parent != NULL) { - if (info->parent->child == info) - info->parent->child = info->next; - - if (info->prev != NULL) - info->prev->next = info->next; - - if (info->next != NULL) - info->next->prev = info->prev; - } - info->parent = NULL; - info->prev = NULL; - info->next = NULL; -} - -static void -unsafe_free(ralloc_header *info) -{ - /* Recursively free any children...don't waste time unlinking them. */ - ralloc_header *temp; - while (info->child != NULL) { - temp = info->child; - info->child = temp->next; - unsafe_free(temp); - } - - /* Free the block itself. Call the destructor first, if any. */ - if (info->destructor != NULL) - info->destructor(PTR_FROM_HEADER(info)); - - free(info); -} - -void -ralloc_steal(const void *new_ctx, void *ptr) -{ - ralloc_header *info, *parent; - - if (unlikely(ptr == NULL)) - return; - - info = get_header(ptr); - parent = get_header(new_ctx); - - unlink_block(info); - - add_child(parent, info); -} - -void * -ralloc_parent(const void *ptr) -{ - ralloc_header *info; - - if (unlikely(ptr == NULL)) - return NULL; - - info = get_header(ptr); - return info->parent ? PTR_FROM_HEADER(info->parent) : NULL; -} - -static void *autofree_context = NULL; - -static void -autofree(void) -{ - ralloc_free(autofree_context); -} - -void * -ralloc_autofree_context(void) -{ - if (unlikely(autofree_context == NULL)) { - autofree_context = ralloc_context(NULL); - atexit(autofree); - } - return autofree_context; -} - -void -ralloc_set_destructor(const void *ptr, void(*destructor)(void *)) -{ - ralloc_header *info = get_header(ptr); - info->destructor = destructor; -} - -char * -ralloc_strdup(const void *ctx, const char *str) -{ - size_t n; - char *ptr; - - if (unlikely(str == NULL)) - return NULL; - - n = strlen(str); - ptr = ralloc_array(ctx, char, n + 1); - memcpy(ptr, str, n); - ptr[n] = '\0'; - return ptr; -} - -char * -ralloc_strndup(const void *ctx, const char *str, size_t max) -{ - size_t n; - char *ptr; - - if (unlikely(str == NULL)) - return NULL; - - n = strlen(str); - if (n > max) - n = max; - - ptr = ralloc_array(ctx, char, n + 1); - memcpy(ptr, str, n); - ptr[n] = '\0'; - return ptr; -} - -/* helper routine for strcat/strncat - n is the exact amount to copy */ -static bool -cat(char **dest, const char *str, size_t n) -{ - char *both; - size_t existing_length; - assert(dest != NULL && *dest != NULL); - - existing_length = strlen(*dest); - both = resize(*dest, existing_length + n + 1); - if (unlikely(both == NULL)) - return false; - - memcpy(both + existing_length, str, n); - both[existing_length + n] = '\0'; - - *dest = both; - return true; -} - - -bool -ralloc_strcat(char **dest, const char *str) -{ - return cat(dest, str, strlen(str)); -} - -bool -ralloc_strncat(char **dest, const char *str, size_t n) -{ - /* Clamp n to the string length */ - size_t str_length = strlen(str); - if (str_length < n) - n = str_length; - - return cat(dest, str, n); -} - -char * -ralloc_asprintf(const void *ctx, const char *fmt, ...) -{ - char *ptr; - va_list args; - va_start(args, fmt); - ptr = ralloc_vasprintf(ctx, fmt, args); - va_end(args); - return ptr; -} - -/* Return the length of the string that would be generated by a printf-style - * format and argument list, not including the \0 byte. - */ -static size_t -printf_length(const char *fmt, va_list untouched_args) -{ - int size; - char junk; - - /* Make a copy of the va_list so the original caller can still use it */ - va_list args; - va_copy(args, untouched_args); - -#ifdef _WIN32 - /* We need to use _vcsprintf to calculate the size as vsnprintf returns -1 - * if the number of characters to write is greater than count. - */ - size = _vscprintf(fmt, args); - (void)junk; -#else - size = vsnprintf(&junk, 1, fmt, args); -#endif - assert(size >= 0); - - va_end(args); - - return size; -} - -char * -ralloc_vasprintf(const void *ctx, const char *fmt, va_list args) -{ - size_t size = printf_length(fmt, args) + 1; - - char *ptr = ralloc_size(ctx, size); - if (ptr != NULL) - vsnprintf(ptr, size, fmt, args); - - return ptr; -} - -bool -ralloc_asprintf_append(char **str, const char *fmt, ...) -{ - bool success; - va_list args; - va_start(args, fmt); - success = ralloc_vasprintf_append(str, fmt, args); - va_end(args); - return success; -} - -bool -ralloc_vasprintf_append(char **str, const char *fmt, va_list args) -{ - size_t existing_length; - assert(str != NULL); - existing_length = *str ? strlen(*str) : 0; - return ralloc_vasprintf_rewrite_tail(str, existing_length, fmt, args); -} - -bool -ralloc_asprintf_rewrite_tail(char **str, size_t start, const char *fmt, ...) -{ - bool success; - va_list args; - va_start(args, fmt); - success = ralloc_vasprintf_rewrite_tail(str, start, fmt, args); - va_end(args); - return success; -} - -bool -ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt, - va_list args) -{ - size_t new_length; - char *ptr; - - assert(str != NULL); - - if (unlikely(*str == NULL)) { - // Assuming a NULL context is probably bad, but it's expected behavior. - *str = ralloc_vasprintf(NULL, fmt, args); - return true; - } - - new_length = printf_length(fmt, args); - - ptr = resize(*str, start + new_length + 1); - if (unlikely(ptr == NULL)) - return false; - - vsnprintf(ptr + start, new_length + 1, fmt, args); - *str = ptr; - return true; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/ralloc.h b/reactos/dll/opengl/mesa/src/glsl/ralloc.h deleted file mode 100644 index 1324f3466bb..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/ralloc.h +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ralloc.h - * - * ralloc: a recursive memory allocator - * - * The ralloc memory allocator creates a hierarchy of allocated - * objects. Every allocation is in reference to some parent, and - * every allocated object can in turn be used as the parent of a - * subsequent allocation. This allows for extremely convenient - * discarding of an entire tree/sub-tree of allocations by calling - * ralloc_free on any particular object to free it and all of its - * children. - * - * The conceptual working of ralloc was directly inspired by Andrew - * Tridgell's talloc, but ralloc is an independent implementation - * released under the MIT license and tuned for Mesa. - * - * The talloc implementation is available under the GNU Lesser - * General Public License (GNU LGPL), version 3 or later. It is - * more sophisticated than ralloc in that it includes reference - * counting and debugging features. See: http://talloc.samba.org/ - */ - -#ifndef RALLOC_H -#define RALLOC_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -/** - * \def ralloc(ctx, type) - * Allocate a new object chained off of the given context. - * - * This is equivalent to: - * \code - * ((type *) ralloc_size(ctx, sizeof(type)) - * \endcode - */ -#define ralloc(ctx, type) ((type *) ralloc_size(ctx, sizeof(type))) - -/** - * \def rzalloc(ctx, type) - * Allocate a new object out of the given context and initialize it to zero. - * - * This is equivalent to: - * \code - * ((type *) rzalloc_size(ctx, sizeof(type)) - * \endcode - */ -#define rzalloc(ctx, type) ((type *) rzalloc_size(ctx, sizeof(type))) - -/** - * Allocate a new ralloc context. - * - * While any ralloc'd pointer can be used as a context, sometimes it is useful - * to simply allocate a context with no associated memory. - * - * It is equivalent to: - * \code - * ((type *) ralloc_size(ctx, 0) - * \endcode - */ -void *ralloc_context(const void *ctx); - -/** - * Allocate memory chained off of the given context. - * - * This is the core allocation routine which is used by all others. It - * simply allocates storage for \p size bytes and returns the pointer, - * similar to \c malloc. - */ -void *ralloc_size(const void *ctx, size_t size); - -/** - * Allocate zero-initialized memory chained off of the given context. - * - * This is similar to \c calloc with a size of 1. - */ -void *rzalloc_size(const void *ctx, size_t size); - -/** - * Resize a piece of ralloc-managed memory, preserving data. - * - * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the - * memory. Instead, it resizes it to a 0-byte ralloc context, just like - * calling ralloc_size(ctx, 0). This is different from talloc. - * - * \param ctx The context to use for new allocation. If \p ptr != NULL, - * it must be the same as ralloc_parent(\p ptr). - * \param ptr Pointer to the memory to be resized. May be NULL. - * \param size The amount of memory to allocate, in bytes. - */ -void *reralloc_size(const void *ctx, void *ptr, size_t size); - -/// \defgroup array Array Allocators @{ - -/** - * \def ralloc_array(ctx, type, count) - * Allocate an array of objects chained off the given context. - * - * Similar to \c calloc, but does not initialize the memory to zero. - * - * More than a convenience function, this also checks for integer overflow when - * multiplying \c sizeof(type) and \p count. This is necessary for security. - * - * This is equivalent to: - * \code - * ((type *) ralloc_array_size(ctx, sizeof(type), count) - * \endcode - */ -#define ralloc_array(ctx, type, count) \ - ((type *) ralloc_array_size(ctx, sizeof(type), count)) - -/** - * \def rzalloc_array(ctx, type, count) - * Allocate a zero-initialized array chained off the given context. - * - * Similar to \c calloc. - * - * More than a convenience function, this also checks for integer overflow when - * multiplying \c sizeof(type) and \p count. This is necessary for security. - * - * This is equivalent to: - * \code - * ((type *) rzalloc_array_size(ctx, sizeof(type), count) - * \endcode - */ -#define rzalloc_array(ctx, type, count) \ - ((type *) rzalloc_array_size(ctx, sizeof(type), count)) - -/** - * \def reralloc(ctx, ptr, type, count) - * Resize a ralloc-managed array, preserving data. - * - * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the - * memory. Instead, it resizes it to a 0-byte ralloc context, just like - * calling ralloc_size(ctx, 0). This is different from talloc. - * - * More than a convenience function, this also checks for integer overflow when - * multiplying \c sizeof(type) and \p count. This is necessary for security. - * - * \param ctx The context to use for new allocation. If \p ptr != NULL, - * it must be the same as ralloc_parent(\p ptr). - * \param ptr Pointer to the array to be resized. May be NULL. - * \param type The element type. - * \param count The number of elements to allocate. - */ -#define reralloc(ctx, ptr, type, count) \ - ((type *) reralloc_array_size(ctx, ptr, sizeof(type), count)) - -/** - * Allocate memory for an array chained off the given context. - * - * Similar to \c calloc, but does not initialize the memory to zero. - * - * More than a convenience function, this also checks for integer overflow when - * multiplying \p size and \p count. This is necessary for security. - */ -void *ralloc_array_size(const void *ctx, size_t size, unsigned count); - -/** - * Allocate a zero-initialized array chained off the given context. - * - * Similar to \c calloc. - * - * More than a convenience function, this also checks for integer overflow when - * multiplying \p size and \p count. This is necessary for security. - */ -void *rzalloc_array_size(const void *ctx, size_t size, unsigned count); - -/** - * Resize a ralloc-managed array, preserving data. - * - * Similar to \c realloc. Unlike C89, passing 0 for \p size does not free the - * memory. Instead, it resizes it to a 0-byte ralloc context, just like - * calling ralloc_size(ctx, 0). This is different from talloc. - * - * More than a convenience function, this also checks for integer overflow when - * multiplying \c sizeof(type) and \p count. This is necessary for security. - * - * \param ctx The context to use for new allocation. If \p ptr != NULL, - * it must be the same as ralloc_parent(\p ptr). - * \param ptr Pointer to the array to be resized. May be NULL. - * \param size The size of an individual element. - * \param count The number of elements to allocate. - * - * \return True unless allocation failed. - */ -void *reralloc_array_size(const void *ctx, void *ptr, size_t size, - unsigned count); -/// @} - -/** - * Free a piece of ralloc-managed memory. - * - * This will also free the memory of any children allocated this context. - */ -void ralloc_free(void *ptr); - -/** - * "Steal" memory from one context, changing it to another. - * - * This changes \p ptr's context to \p new_ctx. This is quite useful if - * memory is allocated out of a temporary context. - */ -void ralloc_steal(const void *new_ctx, void *ptr); - -/** - * Return the given pointer's ralloc context. - */ -void *ralloc_parent(const void *ptr); - -/** - * Return a context whose memory will be automatically freed at program exit. - * - * The first call to this function creates a context and registers a handler - * to free it using \c atexit. This may cause trouble if used in a library - * loaded with \c dlopen. - */ -void *ralloc_autofree_context(void); - -/** - * Set a callback to occur just before an object is freed. - */ -void ralloc_set_destructor(const void *ptr, void(*destructor)(void *)); - -/// \defgroup array String Functions @{ -/** - * Duplicate a string, allocating the memory from the given context. - */ -char *ralloc_strdup(const void *ctx, const char *str); - -/** - * Duplicate a string, allocating the memory from the given context. - * - * Like \c strndup, at most \p n characters are copied. If \p str is longer - * than \p n characters, \p n are copied, and a termining \c '\0' byte is added. - */ -char *ralloc_strndup(const void *ctx, const char *str, size_t n); - -/** - * Concatenate two strings, allocating the necessary space. - * - * This appends \p str to \p *dest, similar to \c strcat, using ralloc_resize - * to expand \p *dest to the appropriate size. \p dest will be updated to the - * new pointer unless allocation fails. - * - * The result will always be null-terminated. - * - * \return True unless allocation failed. - */ -bool ralloc_strcat(char **dest, const char *str); - -/** - * Concatenate two strings, allocating the necessary space. - * - * This appends at most \p n bytes of \p str to \p *dest, using ralloc_resize - * to expand \p *dest to the appropriate size. \p dest will be updated to the - * new pointer unless allocation fails. - * - * The result will always be null-terminated; \p str does not need to be null - * terminated if it is longer than \p n. - * - * \return True unless allocation failed. - */ -bool ralloc_strncat(char **dest, const char *str, size_t n); - -/** - * Print to a string. - * - * This is analogous to \c sprintf, but allocates enough space (using \p ctx - * as the context) for the resulting string. - * - * \return The newly allocated string. - */ -char *ralloc_asprintf (const void *ctx, const char *fmt, ...); - -/** - * Print to a string, given a va_list. - * - * This is analogous to \c vsprintf, but allocates enough space (using \p ctx - * as the context) for the resulting string. - * - * \return The newly allocated string. - */ -char *ralloc_vasprintf(const void *ctx, const char *fmt, va_list args); - -/** - * Rewrite the tail of an existing string, starting at a given index. - * - * Overwrites the contents of *str starting at \p start with newly formatted - * text, including a new null-terminator. Allocates more memory as necessary. - * - * This can be used to append formatted text when the length of the existing - * string is already known, saving a strlen() call. - * - * \sa ralloc_asprintf_append - * - * \param str The string to be updated. - * \param start The index to start appending new data at. - * \param fmt A printf-style formatting string - * - * \p str will be updated to the new pointer unless allocation fails. - * - * \return True unless allocation failed. - */ -bool ralloc_asprintf_rewrite_tail(char **str, size_t start, - const char *fmt, ...); - -/** - * Rewrite the tail of an existing string, starting at a given index. - * - * Overwrites the contents of *str starting at \p start with newly formatted - * text, including a new null-terminator. Allocates more memory as necessary. - * - * This can be used to append formatted text when the length of the existing - * string is already known, saving a strlen() call. - * - * \sa ralloc_vasprintf_append - * - * \param str The string to be updated. - * \param start The index to start appending new data at. - * \param fmt A printf-style formatting string - * \param args A va_list containing the data to be formatted - * - * \p str will be updated to the new pointer unless allocation fails. - * - * \return True unless allocation failed. - */ -bool ralloc_vasprintf_rewrite_tail(char **str, size_t start, const char *fmt, - va_list args); - -/** - * Append formatted text to the supplied string. - * - * This is equivalent to - * \code - * ralloc_asprintf_rewrite_tail(str, strlen(*str), fmt, ...) - * \endcode - * - * \sa ralloc_asprintf - * \sa ralloc_asprintf_rewrite_tail - * \sa ralloc_strcat - * - * \p str will be updated to the new pointer unless allocation fails. - * - * \return True unless allocation failed. - */ -bool ralloc_asprintf_append (char **str, const char *fmt, ...); - -/** - * Append formatted text to the supplied string, given a va_list. - * - * This is equivalent to - * \code - * ralloc_vasprintf_rewrite_tail(str, strlen(*str), fmt, args) - * \endcode - * - * \sa ralloc_vasprintf - * \sa ralloc_vasprintf_rewrite_tail - * \sa ralloc_strcat - * - * \p str will be updated to the new pointer unless allocation fails. - * - * \return True unless allocation failed. - */ -bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args); -/// @} - -#ifdef __cplusplus -} /* end of extern "C" */ -#endif - -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/s_expression.cpp b/reactos/dll/opengl/mesa/src/glsl/s_expression.cpp deleted file mode 100644 index 57de9d334a2..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/s_expression.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include -#include "s_expression.h" - -s_symbol::s_symbol(const char *str, size_t n) -{ - /* Assume the given string is already nul-terminated and in memory that - * will live as long as this node. - */ - assert(str[n] == '\0'); - this->str = str; -} - -s_list::s_list() -{ -} - -static void -skip_whitespace(const char *&src, char *&symbol_buffer) -{ - size_t n = strspn(src, " \v\t\r\n"); - src += n; - symbol_buffer += n; - /* Also skip Scheme-style comments: semi-colon 'til end of line */ - if (src[0] == ';') { - n = strcspn(src, "\n"); - src += n; - symbol_buffer += n; - skip_whitespace(src, symbol_buffer); - } -} - -static s_expression * -read_atom(void *ctx, const char *&src, char *&symbol_buffer) -{ - s_expression *expr = NULL; - - skip_whitespace(src, symbol_buffer); - - size_t n = strcspn(src, "( \v\t\r\n);"); - if (n == 0) - return NULL; // no atom - - // Check for the special symbol '+INF', which means +Infinity. Note: C99 - // requires strtod to parse '+INF' as +Infinity, but we still support some - // non-C99-compliant compilers (e.g. MSVC). - if (n == 4 && strncmp(src, "+INF", 4) == 0) { - expr = new(ctx) s_float(std::numeric_limits::infinity()); - } else { - // Check if the atom is a number. - char *float_end = NULL; - double f = glsl_strtod(src, &float_end); - if (float_end != src) { - char *int_end = NULL; - int i = strtol(src, &int_end, 10); - // If strtod matched more characters, it must have a decimal part - if (float_end > int_end) - expr = new(ctx) s_float(f); - else - expr = new(ctx) s_int(i); - } else { - // Not a number; return a symbol. - symbol_buffer[n] = '\0'; - expr = new(ctx) s_symbol(symbol_buffer, n); - } - } - - src += n; - symbol_buffer += n; - - return expr; -} - -static s_expression * -__read_expression(void *ctx, const char *&src, char *&symbol_buffer) -{ - s_expression *atom = read_atom(ctx, src, symbol_buffer); - if (atom != NULL) - return atom; - - skip_whitespace(src, symbol_buffer); - if (src[0] == '(') { - ++src; - ++symbol_buffer; - - s_list *list = new(ctx) s_list; - s_expression *expr; - - while ((expr = __read_expression(ctx, src, symbol_buffer)) != NULL) { - list->subexpressions.push_tail(expr); - } - skip_whitespace(src, symbol_buffer); - if (src[0] != ')') { - printf("Unclosed expression (check your parenthesis).\n"); - return NULL; - } - ++src; - ++symbol_buffer; - return list; - } - return NULL; -} - -s_expression * -s_expression::read_expression(void *ctx, const char *&src) -{ - assert(src != NULL); - - /* When we encounter a Symbol, we need to save a nul-terminated copy of - * the string. However, ralloc_strndup'ing every individual Symbol is - * extremely expensive. We could avoid this by simply overwriting the - * next character (guaranteed to be whitespace, parens, or semicolon) with - * a nul-byte. But overwriting non-whitespace would mess up parsing. - * - * So, just copy the whole buffer ahead of time. Walk both, leaving the - * original source string unmodified, and altering the copy to contain the - * necessary nul-bytes whenever we encounter a symbol. - */ - char *symbol_buffer = ralloc_strdup(ctx, src); - return __read_expression(ctx, src, symbol_buffer); -} - -void s_int::print() -{ - printf("%d", this->val); -} - -void s_float::print() -{ - printf("%f", this->val); -} - -void s_symbol::print() -{ - printf("%s", this->str); -} - -void s_list::print() -{ - printf("("); - foreach_iter(exec_list_iterator, it, this->subexpressions) { - s_expression *expr = (s_expression*) it.get(); - expr->print(); - if (!expr->next->is_tail_sentinel()) - printf(" "); - } - printf(")"); -} - -// -------------------------------------------------- - -bool -s_pattern::match(s_expression *expr) -{ - switch (type) - { - case EXPR: *p_expr = expr; break; - case LIST: if (expr->is_list()) *p_list = (s_list *) expr; break; - case SYMBOL: if (expr->is_symbol()) *p_symbol = (s_symbol *) expr; break; - case NUMBER: if (expr->is_number()) *p_number = (s_number *) expr; break; - case INT: if (expr->is_int()) *p_int = (s_int *) expr; break; - case STRING: - s_symbol *sym = SX_AS_SYMBOL(expr); - if (sym != NULL && strcmp(sym->value(), literal) == 0) - return true; - return false; - }; - - return *p_expr == expr; -} - -bool -s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial) -{ - s_list *list = SX_AS_LIST(top); - if (list == NULL) - return false; - - unsigned i = 0; - foreach_iter(exec_list_iterator, it, list->subexpressions) { - if (i >= n) - return partial; /* More actual items than the pattern expected */ - - s_expression *expr = (s_expression *) it.get(); - if (expr == NULL || !pattern[i].match(expr)) - return false; - - i++; - } - - if (i < n) - return false; /* Less actual items than the pattern expected */ - - return true; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/s_expression.h b/reactos/dll/opengl/mesa/src/glsl/s_expression.h deleted file mode 100644 index 642af19b439..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/s_expression.h +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef S_EXPRESSION_H -#define S_EXPRESSION_H - -#include "main/core.h" /* for Elements */ -#include "strtod.h" -#include "list.h" - -/* Type-safe downcasting macros (also safe to pass NULL) */ -#define SX_AS_(t,x) ((x) && ((s_expression*) x)->is_##t()) ? ((s_##t*) (x)) \ - : NULL -#define SX_AS_LIST(x) SX_AS_(list, x) -#define SX_AS_SYMBOL(x) SX_AS_(symbol, x) -#define SX_AS_NUMBER(x) SX_AS_(number, x) -#define SX_AS_INT(x) SX_AS_(int, x) - -/* Pattern matching macros */ -#define MATCH(list, pat) s_match(list, Elements(pat), pat, false) -#define PARTIAL_MATCH(list, pat) s_match(list, Elements(pat), pat, true) - -/* For our purposes, S-Expressions are: - * - - * - - * - symbol - * - (expr1 expr2 ... exprN) where exprN is an S-Expression - * - * Unlike LISP/Scheme, we do not support (foo . bar) pairs. - */ -class s_expression : public exec_node -{ -public: - /** - * Read an S-Expression from the given string. - * Advances the supplied pointer to just after the expression read. - * - * Any allocation will be performed with 'ctx' as the ralloc owner. - */ - static s_expression *read_expression(void *ctx, const char *&src); - - /** - * Print out an S-Expression. Useful for debugging. - */ - virtual void print() = 0; - - virtual bool is_list() const { return false; } - virtual bool is_symbol() const { return false; } - virtual bool is_number() const { return false; } - virtual bool is_int() const { return false; } - -protected: - s_expression() { } -}; - -/* Atoms */ - -class s_number : public s_expression -{ -public: - bool is_number() const { return true; } - - virtual float fvalue() = 0; - -protected: - s_number() { } -}; - -class s_int : public s_number -{ -public: - s_int(int x) : val(x) { } - - bool is_int() const { return true; } - - float fvalue() { return float(this->val); } - int value() { return this->val; } - - void print(); - -private: - int val; -}; - -class s_float : public s_number -{ -public: - s_float(float x) : val(x) { } - - float fvalue() { return this->val; } - - void print(); - -private: - float val; -}; - -class s_symbol : public s_expression -{ -public: - s_symbol(const char *, size_t); - - bool is_symbol() const { return true; } - - const char *value() { return this->str; } - - void print(); - -private: - const char *str; -}; - -/* Lists of expressions: (expr1 ... exprN) */ -class s_list : public s_expression -{ -public: - s_list(); - - virtual bool is_list() const { return true; } - - void print(); - - exec_list subexpressions; -}; - -// ------------------------------------------------------------ - -/** - * Part of a pattern to match - essentially a record holding a pointer to the - * storage for the component to match, along with the appropriate type. - */ -class s_pattern { -public: - s_pattern(s_expression *&s) : p_expr(&s), type(EXPR) { } - s_pattern(s_list *&s) : p_list(&s), type(LIST) { } - s_pattern(s_symbol *&s) : p_symbol(&s), type(SYMBOL) { } - s_pattern(s_number *&s) : p_number(&s), type(NUMBER) { } - s_pattern(s_int *&s) : p_int(&s), type(INT) { } - s_pattern(const char *str) : literal(str), type(STRING) { } - - bool match(s_expression *expr); - -private: - union { - s_expression **p_expr; - s_list **p_list; - s_symbol **p_symbol; - s_number **p_number; - s_int **p_int; - const char *literal; - }; - enum { EXPR, LIST, SYMBOL, NUMBER, INT, STRING } type; -}; - -bool -s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial); - -#endif /* S_EXPRESSION_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.cpp b/reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.cpp deleted file mode 100644 index ede838c4fbc..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* This file declares stripped-down versions of functions that - * normally exist outside of the glsl folder, so that they can be used - * when running the GLSL compiler standalone (for unit testing or - * compiling builtins). - */ - -#include "standalone_scaffolding.h" - -#include -#include -#include "ralloc.h" - -void -_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, - struct gl_shader *sh) -{ - (void) ctx; - *ptr = sh; -} - -struct gl_shader * -_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) -{ - struct gl_shader *shader; - - (void) ctx; - - assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER); - shader = rzalloc(NULL, struct gl_shader); - if (shader) { - shader->Type = type; - shader->Name = name; - shader->RefCount = 1; - } - return shader; -} - -void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) -{ - memset(ctx, 0, sizeof(*ctx)); - - ctx->API = api; - - ctx->Extensions.dummy_false = false; - ctx->Extensions.dummy_true = true; - ctx->Extensions.EXT_texture3D = true; - - ctx->Const.GLSLVersion = 120; - - /* 1.20 minimums. */ - ctx->Const.MaxLights = 8; - ctx->Const.MaxClipPlanes = 6; - ctx->Const.MaxTextureUnits = 2; - ctx->Const.MaxTextureCoordUnits = 2; - ctx->Const.VertexProgram.MaxAttribs = 16; - - ctx->Const.VertexProgram.MaxUniformComponents = 512; - ctx->Const.MaxVarying = 8; /* == gl_MaxVaryingFloats / 4 */ - ctx->Const.MaxVertexTextureImageUnits = 0; - ctx->Const.MaxCombinedTextureImageUnits = 2; - ctx->Const.MaxTextureImageUnits = 2; - ctx->Const.FragmentProgram.MaxUniformComponents = 64; - - ctx->Const.MaxDrawBuffers = 1; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.h b/reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.h deleted file mode 100644 index 87733200670..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/standalone_scaffolding.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* This file declares stripped-down versions of functions that - * normally exist outside of the glsl folder, so that they can be used - * when running the GLSL compiler standalone (for unit testing or - * compiling builtins). - */ - -#pragma once -#ifndef STANDALONE_SCAFFOLDING_H -#define STANDALONE_SCAFFOLDING_H - -#include "main/mtypes.h" - -extern "C" void -_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, - struct gl_shader *sh); - -extern "C" struct gl_shader * -_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); - -/** - * Initialize the given gl_context structure to a reasonable set of - * defaults representing the minimum capabilities required by the - * OpenGL spec. - * - * This is used when compiling builtin functions and in testing, when - * we don't have a connection to an actual driver. - */ -void initialize_context_to_defaults(struct gl_context *ctx, gl_api api); - - -#endif /* STANDALONE_SCAFFOLDING_H */ diff --git a/reactos/dll/opengl/mesa/src/glsl/strtod.c b/reactos/dll/opengl/mesa/src/glsl/strtod.c deleted file mode 100644 index a876e138b70..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/strtod.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2010 VMware, Inc. - * 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. - */ - - -#include - -#ifdef _GNU_SOURCE -#include -#ifdef __APPLE__ -#include -#endif -#endif - -#include "strtod.h" - - - -/** - * Wrapper around strtod which uses the "C" locale so the decimal - * point is always '.' - */ -double -glsl_strtod(const char *s, char **end) -{ -#if defined(_GNU_SOURCE) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && \ - !defined(__HAIKU__) - static locale_t loc = NULL; - if (!loc) { - loc = newlocale(LC_CTYPE_MASK, "C", NULL); - } - return strtod_l(s, end, loc); -#else - return strtod(s, end); -#endif -} diff --git a/reactos/dll/opengl/mesa/src/glsl/strtod.h b/reactos/dll/opengl/mesa/src/glsl/strtod.h deleted file mode 100644 index 0cf6409d425..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/strtod.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2010 VMware, Inc. - * 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 STRTOD_H -#define STRTOD_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern double -glsl_strtod(const char *s, char **end); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/reactos/dll/opengl/mesa/src/glsl/test.cpp b/reactos/dll/opengl/mesa/src/glsl/test.cpp deleted file mode 100644 index b1ff92ed1d4..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/test.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file test.cpp - * - * Standalone tests for the GLSL compiler. - * - * This file provides a standalone executable which can be used to - * test components of the GLSL. - * - * Each test is a function with the same signature as main(). The - * main function interprets its first argument as the name of the test - * to run, strips out that argument, and then calls the test function. - */ - -#include -#include -#include - -#include "test_optpass.h" - -/** - * Print proper usage and exit with failure. - */ -static void -usage_fail(const char *name) -{ - printf("*** usage: %s \n", name); - printf("\n"); - printf("Possible commands are:\n"); - printf(" optpass: test an optimization pass in isolation\n"); - exit(EXIT_FAILURE); -} - -static const char *extract_command_from_argv(int *argc, char **argv) -{ - if (*argc < 2) { - usage_fail(argv[0]); - } - const char *command = argv[1]; - --*argc; - memmove(&argv[1], &argv[2], (*argc) * sizeof(argv[1])); - return command; -} - -int main(int argc, char **argv) -{ - const char *command = extract_command_from_argv(&argc, argv); - if (strcmp(command, "optpass") == 0) { - return test_optpass(argc, argv); - } else { - usage_fail(argv[0]); - } - - /* Execution should never reach here. */ - return EXIT_FAILURE; -} diff --git a/reactos/dll/opengl/mesa/src/glsl/test_optpass.cpp b/reactos/dll/opengl/mesa/src/glsl/test_optpass.cpp deleted file mode 100644 index 0462e4d053f..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/test_optpass.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file test_optpass.cpp - * - * Standalone test for optimization passes. - * - * This file provides the "optpass" command for the standalone - * glsl_test app. It accepts either GLSL or high-level IR as input, - * and performs the optimiation passes specified on the command line. - * It outputs the IR, both before and after optimiations. - */ - -#include -#include -#include -#include - -#include "ast.h" -#include "ir_optimization.h" -#include "ir_print_visitor.h" -#include "program.h" -#include "ir_reader.h" -#include "standalone_scaffolding.h" - -using namespace std; - -static string read_stdin_to_eof() -{ - stringbuf sb; - cin.get(sb, '\0'); - return sb.str(); -} - -static GLboolean -do_optimization(struct exec_list *ir, const char *optimization) -{ - int int_0; - int int_1; - int int_2; - int int_3; - int int_4; - - if (sscanf(optimization, "do_common_optimization ( %d , %d ) ", - &int_0, &int_1) == 2) { - return do_common_optimization(ir, int_0 != 0, false, int_1); - } else if (strcmp(optimization, "do_algebraic") == 0) { - return do_algebraic(ir); - } else if (strcmp(optimization, "do_constant_folding") == 0) { - return do_constant_folding(ir); - } else if (strcmp(optimization, "do_constant_variable") == 0) { - return do_constant_variable(ir); - } else if (strcmp(optimization, "do_constant_variable_unlinked") == 0) { - return do_constant_variable_unlinked(ir); - } else if (strcmp(optimization, "do_copy_propagation") == 0) { - return do_copy_propagation(ir); - } else if (strcmp(optimization, "do_copy_propagation_elements") == 0) { - return do_copy_propagation_elements(ir); - } else if (strcmp(optimization, "do_constant_propagation") == 0) { - return do_constant_propagation(ir); - } else if (strcmp(optimization, "do_dead_code") == 0) { - return do_dead_code(ir, false); - } else if (strcmp(optimization, "do_dead_code_local") == 0) { - return do_dead_code_local(ir); - } else if (strcmp(optimization, "do_dead_code_unlinked") == 0) { - return do_dead_code_unlinked(ir); - } else if (strcmp(optimization, "do_dead_functions") == 0) { - return do_dead_functions(ir); - } else if (strcmp(optimization, "do_function_inlining") == 0) { - return do_function_inlining(ir); - } else if (sscanf(optimization, - "do_lower_jumps ( %d , %d , %d , %d , %d ) ", - &int_0, &int_1, &int_2, &int_3, &int_4) == 5) { - return do_lower_jumps(ir, int_0 != 0, int_1 != 0, int_2 != 0, - int_3 != 0, int_4 != 0); - } else if (strcmp(optimization, "do_lower_texture_projection") == 0) { - return do_lower_texture_projection(ir); - } else if (strcmp(optimization, "do_if_simplification") == 0) { - return do_if_simplification(ir); - } else if (strcmp(optimization, "do_discard_simplification") == 0) { - return do_discard_simplification(ir); - } else if (sscanf(optimization, "lower_if_to_cond_assign ( %d ) ", - &int_0) == 1) { - return lower_if_to_cond_assign(ir, int_0); - } else if (strcmp(optimization, "do_mat_op_to_vec") == 0) { - return do_mat_op_to_vec(ir); - } else if (strcmp(optimization, "do_noop_swizzle") == 0) { - return do_noop_swizzle(ir); - } else if (strcmp(optimization, "do_structure_splitting") == 0) { - return do_structure_splitting(ir); - } else if (strcmp(optimization, "do_swizzle_swizzle") == 0) { - return do_swizzle_swizzle(ir); - } else if (strcmp(optimization, "do_tree_grafting") == 0) { - return do_tree_grafting(ir); - } else if (strcmp(optimization, "do_vec_index_to_cond_assign") == 0) { - return do_vec_index_to_cond_assign(ir); - } else if (strcmp(optimization, "do_vec_index_to_swizzle") == 0) { - return do_vec_index_to_swizzle(ir); - } else if (strcmp(optimization, "lower_discard") == 0) { - return lower_discard(ir); - } else if (sscanf(optimization, "lower_instructions ( %d ) ", - &int_0) == 1) { - return lower_instructions(ir, int_0); - } else if (strcmp(optimization, "lower_noise") == 0) { - return lower_noise(ir); - } else if (sscanf(optimization, "lower_variable_index_to_cond_assign " - "( %d , %d , %d , %d ) ", &int_0, &int_1, &int_2, - &int_3) == 4) { - return lower_variable_index_to_cond_assign(ir, int_0 != 0, int_1 != 0, - int_2 != 0, int_3 != 0); - } else if (sscanf(optimization, "lower_quadop_vector ( %d ) ", - &int_0) == 1) { - return lower_quadop_vector(ir, int_0 != 0); - } else if (strcmp(optimization, "optimize_redundant_jumps") == 0) { - return optimize_redundant_jumps(ir); - } else { - printf("Unrecognized optimization %s\n", optimization); - exit(EXIT_FAILURE); - return false; - } -} - -static GLboolean -do_optimization_passes(struct exec_list *ir, char **optimizations, - int num_optimizations, bool quiet) -{ - GLboolean overall_progress = false; - - for (int i = 0; i < num_optimizations; ++i) { - const char *optimization = optimizations[i]; - if (!quiet) { - printf("*** Running optimization %s...", optimization); - } - GLboolean progress = do_optimization(ir, optimization); - if (!quiet) { - printf("%s\n", progress ? "progress" : "no progress"); - } - validate_ir_tree(ir); - - overall_progress = overall_progress || progress; - } - - return overall_progress; -} - -int test_optpass(int argc, char **argv) -{ - int input_format_ir = 0; /* 0=glsl, 1=ir */ - int loop = 0; - int shader_type = GL_VERTEX_SHADER; - int quiet = 0; - - const struct option optpass_opts[] = { - { "input-ir", no_argument, &input_format_ir, 1 }, - { "input-glsl", no_argument, &input_format_ir, 0 }, - { "loop", no_argument, &loop, 1 }, - { "vertex-shader", no_argument, &shader_type, GL_VERTEX_SHADER }, - { "fragment-shader", no_argument, &shader_type, GL_FRAGMENT_SHADER }, - { "quiet", no_argument, &quiet, 1 }, - { NULL, 0, NULL, 0 } - }; - - int idx = 0; - int c; - while ((c = getopt_long(argc, argv, "", optpass_opts, &idx)) != -1) { - if (c != 0) { - printf("*** usage: %s optpass \n", argv[0]); - printf("\n"); - printf("Possible options are:\n"); - printf(" --input-ir: input format is IR\n"); - printf(" --input-glsl: input format is GLSL (the default)\n"); - printf(" --loop: run optimizations repeatedly until no progress\n"); - printf(" --vertex-shader: test with a vertex shader (the default)\n"); - printf(" --fragment-shader: test with a fragment shader\n"); - exit(EXIT_FAILURE); - } - } - - struct gl_context local_ctx; - struct gl_context *ctx = &local_ctx; - initialize_context_to_defaults(ctx, API_OPENGL); - - ctx->Driver.NewShader = _mesa_new_shader; - - struct gl_shader *shader = rzalloc(NULL, struct gl_shader); - shader->Type = shader_type; - - string input = read_stdin_to_eof(); - - struct _mesa_glsl_parse_state *state - = new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader); - - if (input_format_ir) { - shader->ir = new(shader) exec_list; - _mesa_glsl_initialize_types(state); - _mesa_glsl_read_ir(state, shader->ir, input.c_str(), true); - } else { - shader->Source = input.c_str(); - const char *source = shader->Source; - state->error = preprocess(state, &source, &state->info_log, - state->extensions) != 0; - - if (!state->error) { - _mesa_glsl_lexer_ctor(state, source); - _mesa_glsl_parse(state); - _mesa_glsl_lexer_dtor(state); - } - - shader->ir = new(shader) exec_list; - if (!state->error && !state->translation_unit.is_empty()) - _mesa_ast_to_hir(shader->ir, state); - } - - /* Print out the initial IR */ - if (!state->error && !quiet) { - printf("*** pre-optimization IR:\n"); - _mesa_print_ir(shader->ir, state); - printf("\n--\n"); - } - - /* Optimization passes */ - if (!state->error) { - GLboolean progress; - do { - progress = do_optimization_passes(shader->ir, &argv[optind], - argc - optind, quiet != 0); - } while (loop && progress); - } - - /* Print out the resulting IR */ - if (!state->error) { - if (!quiet) { - printf("*** resulting IR:\n"); - } - _mesa_print_ir(shader->ir, state); - if (!quiet) { - printf("\n--\n"); - } - } - - if (state->error) { - printf("*** error(s) occurred:\n"); - printf("%s\n", state->info_log); - printf("--\n"); - } - - ralloc_free(state); - ralloc_free(shader); - - return state->error; -} - diff --git a/reactos/dll/opengl/mesa/src/glsl/test_optpass.h b/reactos/dll/opengl/mesa/src/glsl/test_optpass.h deleted file mode 100644 index 923ccf3dece..00000000000 --- a/reactos/dll/opengl/mesa/src/glsl/test_optpass.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once -#ifndef TEST_OPTPASS_H -#define TEST_OPTPASS_H - -int test_optpass(int argc, char **argv); - -#endif /* TEST_OPTPASS_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/CMakeLists.txt b/reactos/dll/opengl/mesa/src/mesa/CMakeLists.txt index f9802728cc5..f4a8f9ede10 100644 --- a/reactos/dll/opengl/mesa/src/mesa/CMakeLists.txt +++ b/reactos/dll/opengl/mesa/src/mesa/CMakeLists.txt @@ -1,9 +1,6 @@ -set_cpp(WITH_STL) - include_directories( ../mapi - ../glsl . ) @@ -27,7 +24,6 @@ endif() add_subdirectory(drivers/common) add_subdirectory(main) add_subdirectory(math) -add_subdirectory(program) add_subdirectory(swrast) add_subdirectory(swrast_setup) add_subdirectory(tnl) diff --git a/reactos/dll/opengl/mesa/src/mesa/drivers/common/driverfuncs.c b/reactos/dll/opengl/mesa/src/mesa/drivers/common/driverfuncs.c index 80c71e3bd12..bb273bf0b5c 100644 --- a/reactos/dll/opengl/mesa/src/mesa/drivers/common/driverfuncs.c +++ b/reactos/dll/opengl/mesa/src/mesa/drivers/common/driverfuncs.c @@ -31,7 +31,6 @@ #include "main/framebuffer.h" #include "main/readpix.h" #include "main/renderbuffer.h" -#include "main/shaderobj.h" #include "main/texformat.h" #include "main/texgetimage.h" #include "main/teximage.h" @@ -40,7 +39,6 @@ #include "main/bufferobj.h" #include "main/texturebarrier.h" -#include "program/program.h" #include "tnl/tnl.h" #include "swrast/swrast.h" #include "swrast/s_renderbuffer.h" @@ -105,11 +103,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->MapTextureImage = _swrast_map_teximage; driver->UnmapTextureImage = _swrast_unmap_teximage; - /* Vertex/fragment programs */ - driver->BindProgram = NULL; - driver->NewProgram = _mesa_new_program; - driver->DeleteProgram = _mesa_delete_program; - /* simple state commands */ driver->AlphaFunc = NULL; driver->BlendColor = NULL; @@ -165,8 +158,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->DeleteArrayObject = _mesa_delete_array_object; driver->BindArrayObject = NULL; - _mesa_init_shader_object_functions(driver); - /* T&L stuff */ driver->CurrentExecPrimitive = 0; driver->CurrentSavePrimitive = 0; diff --git a/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.c b/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.c index e227f5d15d3..7ddc03cd021 100644 --- a/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.c +++ b/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.c @@ -34,7 +34,6 @@ #include "main/glheader.h" #include "main/mtypes.h" #include "main/imports.h" -#include "main/arbprogram.h" #include "main/arrayobj.h" #include "main/blend.h" #include "main/bufferobj.h" @@ -53,8 +52,6 @@ #include "main/polygon.h" #include "main/readpix.h" #include "main/scissor.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" #include "main/state.h" #include "main/stencil.h" #include "main/texobj.h" @@ -63,10 +60,8 @@ #include "main/teximage.h" #include "main/texparam.h" #include "main/texstate.h" -#include "main/uniforms.h" #include "main/varray.h" #include "main/viewport.h" -#include "program/program.h" #include "swrast/swrast.h" #include "drivers/common/meta.h" @@ -121,15 +116,6 @@ struct save_state /** MESA_META_SCISSOR */ struct gl_scissor_attrib Scissor; - /** MESA_META_SHADER */ - GLboolean VertexProgramEnabled; - struct gl_vertex_program *VertexProgram; - GLboolean FragmentProgramEnabled; - struct gl_fragment_program *FragmentProgram; - struct gl_shader_program *VertexShader; - struct gl_shader_program *FragmentShader; - struct gl_shader_program *ActiveShader; - /** MESA_META_STENCIL_TEST */ struct gl_stencil_attrib Stencil; @@ -143,13 +129,10 @@ struct save_state GLbitfield ClipPlanesEnabled; /** MESA_META_TEXTURE */ - GLuint ActiveUnit; - GLuint ClientActiveUnit; - /** for unit[0] only */ struct gl_texture_object *CurrentTexture[NUM_TEXTURE_TARGETS]; /** mask of TEXTURE_2D_BIT, etc */ - GLbitfield TexEnabled[MAX_TEXTURE_UNITS]; - GLbitfield TexGenEnabled[MAX_TEXTURE_UNITS]; + GLbitfield TexEnabled; + GLbitfield TexGenEnabled; GLuint EnvMode; /* unit[0] only */ /** MESA_META_VERTEX */ @@ -381,33 +364,6 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) _mesa_set_enable(ctx, GL_SCISSOR_TEST, GL_FALSE); } - if (state & MESA_META_SHADER) { - if (ctx->Extensions.ARB_vertex_program) { - save->VertexProgramEnabled = ctx->VertexProgram.Enabled; - _mesa_reference_vertprog(ctx, &save->VertexProgram, - ctx->VertexProgram.Current); - _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE); - } - - if (ctx->Extensions.ARB_fragment_program) { - save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled; - _mesa_reference_fragprog(ctx, &save->FragmentProgram, - ctx->FragmentProgram.Current); - _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE); - } - - if (ctx->Extensions.ARB_shader_objects) { - _mesa_reference_shader_program(ctx, &save->VertexShader, - ctx->Shader.CurrentVertexProgram); - _mesa_reference_shader_program(ctx, &save->FragmentShader, - ctx->Shader.CurrentFragmentProgram); - _mesa_reference_shader_program(ctx, &save->ActiveShader, - ctx->Shader.ActiveProgram); - - _mesa_UseProgramObjectARB(0); - } - } - if (state & MESA_META_STENCIL_TEST) { save->Stencil = ctx->Stencil; /* struct copy */ if (ctx->Stencil.Enabled) @@ -416,57 +372,45 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) } if (state & MESA_META_TEXTURE) { - GLuint u, tgt; + GLuint tgt; - save->ActiveUnit = ctx->Texture.CurrentUnit; - save->ClientActiveUnit = ctx->Array.ActiveTexture; - save->EnvMode = ctx->Texture.Unit[0].EnvMode; + save->EnvMode = ctx->Texture.Unit.EnvMode; /* Disable all texture units */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled; - save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled; - if (ctx->Texture.Unit[u].Enabled || - ctx->Texture.Unit[u].TexGenEnabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + u); - _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE); - if (ctx->Extensions.ARB_texture_cube_map) - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE); - } + save->TexEnabled = ctx->Texture.Unit.Enabled; + save->TexGenEnabled = ctx->Texture.Unit.TexGenEnabled; + if (ctx->Texture.Unit.Enabled || + ctx->Texture.Unit.TexGenEnabled) { + _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE); + if (ctx->Extensions.ARB_texture_cube_map) + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE); } /* save current texture objects for unit[0] only */ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { _mesa_reference_texobj(&save->CurrentTexture[tgt], - ctx->Texture.Unit[0].CurrentTex[tgt]); + ctx->Texture.Unit.CurrentTex[tgt]); } - - /* set defaults for unit[0] */ - _mesa_ActiveTextureARB(GL_TEXTURE0); - _mesa_ClientActiveTextureARB(GL_TEXTURE0); _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } if (state & MESA_META_TRANSFORM) { - GLuint activeTexture = ctx->Texture.CurrentUnit; memcpy(save->ModelviewMatrix, ctx->ModelviewMatrixStack.Top->m, 16 * sizeof(GLfloat)); memcpy(save->ProjectionMatrix, ctx->ProjectionMatrixStack.Top->m, 16 * sizeof(GLfloat)); - memcpy(save->TextureMatrix, ctx->TextureMatrixStack[0].Top->m, + memcpy(save->TextureMatrix, ctx->TextureMatrixStack.Top->m, 16 * sizeof(GLfloat)); save->MatrixMode = ctx->Transform.MatrixMode; /* set 1:1 vertex:pixel coordinate transform */ - _mesa_ActiveTextureARB(GL_TEXTURE0); _mesa_MatrixMode(GL_TEXTURE); _mesa_LoadIdentity(); - _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture); _mesa_MatrixMode(GL_MODELVIEW); _mesa_LoadIdentity(); _mesa_MatrixMode(GL_PROJECTION); @@ -614,38 +558,6 @@ _mesa_meta_end(struct gl_context *ctx) save->Scissor.Width, save->Scissor.Height); } - if (state & MESA_META_SHADER) { - if (ctx->Extensions.ARB_vertex_program) { - _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, - save->VertexProgramEnabled); - _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, - save->VertexProgram); - _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL); - } - - if (ctx->Extensions.ARB_fragment_program) { - _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, - save->FragmentProgramEnabled); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - save->FragmentProgram); - _mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL); - } - - if (ctx->Extensions.ARB_vertex_shader) - _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, save->VertexShader); - - if (ctx->Extensions.ARB_fragment_shader) - _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER, - save->FragmentShader); - - _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, - save->ActiveShader); - - _mesa_reference_shader_program(ctx, &save->VertexShader, NULL); - _mesa_reference_shader_program(ctx, &save->FragmentShader, NULL); - _mesa_reference_shader_program(ctx, &save->ActiveShader, NULL); - } - if (state & MESA_META_STENCIL_TEST) { const struct gl_stencil_attrib *stencil = &save->Stencil; @@ -678,47 +590,36 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_TEXTURE) { - GLuint u, tgt; - - ASSERT(ctx->Texture.CurrentUnit == 0); + GLuint tgt; /* restore texenv for unit[0] */ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); /* restore texture objects for unit[0] only */ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - if (ctx->Texture.Unit[0].CurrentTex[tgt] != save->CurrentTexture[tgt]) { + if (ctx->Texture.Unit.CurrentTex[tgt] != save->CurrentTexture[tgt]) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); - _mesa_reference_texobj(&ctx->Texture.Unit[0].CurrentTex[tgt], + _mesa_reference_texobj(&ctx->Texture.Unit.CurrentTex[tgt], save->CurrentTexture[tgt]); } _mesa_reference_texobj(&save->CurrentTexture[tgt], NULL); } /* Restore fixed function texture enables, texgen */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) { + if (ctx->Texture.Unit.Enabled != save->TexEnabled) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.Unit[u].Enabled = save->TexEnabled[u]; + ctx->Texture.Unit.Enabled = save->TexEnabled; } - if (ctx->Texture.Unit[u].TexGenEnabled != save->TexGenEnabled[u]) { + if (ctx->Texture.Unit.TexGenEnabled != save->TexGenEnabled) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.Unit[u].TexGenEnabled = save->TexGenEnabled[u]; + ctx->Texture.Unit.TexGenEnabled = save->TexGenEnabled; } - } - - /* restore current unit state */ - _mesa_ActiveTextureARB(GL_TEXTURE0 + save->ActiveUnit); - _mesa_ClientActiveTextureARB(GL_TEXTURE0 + save->ClientActiveUnit); } if (state & MESA_META_TRANSFORM) { - GLuint activeTexture = ctx->Texture.CurrentUnit; - _mesa_ActiveTextureARB(GL_TEXTURE0); _mesa_MatrixMode(GL_TEXTURE); _mesa_LoadMatrixf(save->TextureMatrix); - _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture); _mesa_MatrixMode(GL_MODELVIEW); _mesa_LoadMatrixf(save->ModelviewMatrix); @@ -965,7 +866,6 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY, * we need to override: */ _mesa_meta_begin(ctx, (MESA_META_RASTERIZATION | - MESA_META_SHADER | MESA_META_TEXTURE | MESA_META_TRANSFORM | MESA_META_CLIP | diff --git a/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.h b/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.h index dd012ecc857..1e2656af014 100644 --- a/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.h +++ b/reactos/dll/opengl/mesa/src/mesa/drivers/common/meta.h @@ -44,7 +44,6 @@ #define MESA_META_PIXEL_TRANSFER 0x40 #define MESA_META_RASTERIZATION 0x80 #define MESA_META_SCISSOR 0x100 -#define MESA_META_SHADER 0x200 #define MESA_META_STENCIL_TEST 0x400 #define MESA_META_TRANSFORM 0x800 /**< modelview/projection matrix state */ #define MESA_META_TEXTURE 0x1000 diff --git a/reactos/dll/opengl/mesa/src/mesa/main/CMakeLists.txt b/reactos/dll/opengl/mesa/src/mesa/main/CMakeLists.txt index 47563db0819..2f973131897 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/CMakeLists.txt +++ b/reactos/dll/opengl/mesa/src/mesa/main/CMakeLists.txt @@ -5,7 +5,6 @@ list(APPEND SOURCE api_loopback.c api_validate.c accum.c - arbprogram.c attrib.c arrayobj.c blend.c @@ -56,9 +55,6 @@ list(APPEND SOURCE readpix.c renderbuffer.c scissor.c - shaderapi.c - shaderobj.c - shader_query.cpp shared.c state.c stencil.c @@ -74,8 +70,6 @@ list(APPEND SOURCE texstorage.c texstore.c texturebarrier.c - uniform_query.cpp - uniforms.c varray.c version.c viewport.c diff --git a/reactos/dll/opengl/mesa/src/mesa/main/api_arrayelt.c b/reactos/dll/opengl/mesa/src/mesa/main/api_arrayelt.c index a189e480970..5ed52c4e54c 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/api_arrayelt.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/api_arrayelt.c @@ -673,732 +673,6 @@ static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = { } }; - -/** - ** GL_ARB_vertex_program - **/ - -/* GL_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NbvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), - BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), - BYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4bvARB(GLuint index, const GLbyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_BYTE attributes */ - -static void GLAPIENTRY -VertexAttrib1NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, - UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, - (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, - UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]))); -} -static void GLAPIENTRY -VertexAttrib3ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, - (GLfloat)v[0], - (GLfloat)v[1], - (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), - (index, - UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), - UBYTE_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ubvARB(GLuint index, const GLubyte *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), - (index, - (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), - (index, SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), - (index, (GLfloat)v[0], (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), - (index, - SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), - (index, - (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NsvARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), - (index, - SHORT_TO_FLOAT(v[0]), - SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), - SHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4svARB(GLuint index, const GLshort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_SHORT attributes */ - -static void GLAPIENTRY -VertexAttrib1NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NusvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]), - USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), - USHORT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4usvARB(GLuint index, const GLushort *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]), - INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), - INT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4ivARB(GLuint index, const GLint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_UNSIGNED_INT attributes */ - -static void GLAPIENTRY -VertexAttrib1NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]))); -} - -static void GLAPIENTRY -VertexAttrib1uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0])); -} - -static void GLAPIENTRY -VertexAttrib2NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]))); -} - -static void GLAPIENTRY -VertexAttrib2uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1])); -} - -static void GLAPIENTRY -VertexAttrib3NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]))); -} - -static void GLAPIENTRY -VertexAttrib3uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], - (GLfloat)v[1], (GLfloat)v[2])); -} - -static void GLAPIENTRY -VertexAttrib4NuivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]), - UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), - UINT_TO_FLOAT(v[3]))); -} - -static void GLAPIENTRY -VertexAttrib4uivARB(GLuint index, const GLuint *v) -{ - CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3])); -} - -/* GL_FLOAT attributes */ - -static void GLAPIENTRY -VertexAttrib1fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4fvARB(GLuint index, const GLfloat *v) -{ - CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v)); -} - -/* GL_DOUBLE attributes */ - -static void GLAPIENTRY -VertexAttrib1dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib2dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib3dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v)); -} - -static void GLAPIENTRY -VertexAttrib4dvARB(GLuint index, const GLdouble *v) -{ - CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v)); -} - - -/** - * Integer-valued attributes - */ -static void GLAPIENTRY -VertexAttribI1bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4bv(GLuint index, const GLbyte *v) -{ - CALL_VertexAttribI4bvEXT(GET_DISPATCH(), (index, v)); -} - - -static void GLAPIENTRY -VertexAttribI1ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4ubv(GLuint index, const GLubyte *v) -{ - CALL_VertexAttribI4ubvEXT(GET_DISPATCH(), (index, v)); -} - - - -static void GLAPIENTRY -VertexAttribI1sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4sv(GLuint index, const GLshort *v) -{ - CALL_VertexAttribI4svEXT(GET_DISPATCH(), (index, v)); -} - - -static void GLAPIENTRY -VertexAttribI1usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4usv(GLuint index, const GLushort *v) -{ - CALL_VertexAttribI4usvEXT(GET_DISPATCH(), (index, v)); -} - - - -static void GLAPIENTRY -VertexAttribI1iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4iv(GLuint index, const GLint *v) -{ - CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index, v)); -} - - -static void GLAPIENTRY -VertexAttribI1uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0])); -} - -static void GLAPIENTRY -VertexAttribI2uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1])); -} - -static void GLAPIENTRY -VertexAttribI3uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2])); -} - -static void GLAPIENTRY -VertexAttribI4uiv(GLuint index, const GLuint *v) -{ - CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index, v)); -} - - - - -/* - * Array [unnormalized/normalized/integer][size][type] of VertexAttrib - * functions - */ -static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = { - { - /* non-normalized */ - { - /* size 1 */ - (attrib_func) VertexAttrib1bvARB, - (attrib_func) VertexAttrib1ubvARB, - (attrib_func) VertexAttrib1svARB, - (attrib_func) VertexAttrib1usvARB, - (attrib_func) VertexAttrib1ivARB, - (attrib_func) VertexAttrib1uivARB, - (attrib_func) VertexAttrib1fvARB, - (attrib_func) VertexAttrib1dvARB - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2bvARB, - (attrib_func) VertexAttrib2ubvARB, - (attrib_func) VertexAttrib2svARB, - (attrib_func) VertexAttrib2usvARB, - (attrib_func) VertexAttrib2ivARB, - (attrib_func) VertexAttrib2uivARB, - (attrib_func) VertexAttrib2fvARB, - (attrib_func) VertexAttrib2dvARB - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3bvARB, - (attrib_func) VertexAttrib3ubvARB, - (attrib_func) VertexAttrib3svARB, - (attrib_func) VertexAttrib3usvARB, - (attrib_func) VertexAttrib3ivARB, - (attrib_func) VertexAttrib3uivARB, - (attrib_func) VertexAttrib3fvARB, - (attrib_func) VertexAttrib3dvARB - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4bvARB, - (attrib_func) VertexAttrib4ubvARB, - (attrib_func) VertexAttrib4svARB, - (attrib_func) VertexAttrib4usvARB, - (attrib_func) VertexAttrib4ivARB, - (attrib_func) VertexAttrib4uivARB, - (attrib_func) VertexAttrib4fvARB, - (attrib_func) VertexAttrib4dvARB - } - }, - { - /* normalized (except for float/double) */ - { - /* size 1 */ - (attrib_func) VertexAttrib1NbvARB, - (attrib_func) VertexAttrib1NubvARB, - (attrib_func) VertexAttrib1NsvARB, - (attrib_func) VertexAttrib1NusvARB, - (attrib_func) VertexAttrib1NivARB, - (attrib_func) VertexAttrib1NuivARB, - (attrib_func) VertexAttrib1fvARB, - (attrib_func) VertexAttrib1dvARB - }, - { - /* size 2 */ - (attrib_func) VertexAttrib2NbvARB, - (attrib_func) VertexAttrib2NubvARB, - (attrib_func) VertexAttrib2NsvARB, - (attrib_func) VertexAttrib2NusvARB, - (attrib_func) VertexAttrib2NivARB, - (attrib_func) VertexAttrib2NuivARB, - (attrib_func) VertexAttrib2fvARB, - (attrib_func) VertexAttrib2dvARB - }, - { - /* size 3 */ - (attrib_func) VertexAttrib3NbvARB, - (attrib_func) VertexAttrib3NubvARB, - (attrib_func) VertexAttrib3NsvARB, - (attrib_func) VertexAttrib3NusvARB, - (attrib_func) VertexAttrib3NivARB, - (attrib_func) VertexAttrib3NuivARB, - (attrib_func) VertexAttrib3fvARB, - (attrib_func) VertexAttrib3dvARB - }, - { - /* size 4 */ - (attrib_func) VertexAttrib4NbvARB, - (attrib_func) VertexAttrib4NubvARB, - (attrib_func) VertexAttrib4NsvARB, - (attrib_func) VertexAttrib4NusvARB, - (attrib_func) VertexAttrib4NivARB, - (attrib_func) VertexAttrib4NuivARB, - (attrib_func) VertexAttrib4fvARB, - (attrib_func) VertexAttrib4dvARB - } - }, - - { - /* integer-valued */ - { - /* size 1 */ - (attrib_func) VertexAttribI1bv, - (attrib_func) VertexAttribI1ubv, - (attrib_func) VertexAttribI1sv, - (attrib_func) VertexAttribI1usv, - (attrib_func) VertexAttribI1iv, - (attrib_func) VertexAttribI1uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - }, - { - /* size 2 */ - (attrib_func) VertexAttribI2bv, - (attrib_func) VertexAttribI2ubv, - (attrib_func) VertexAttribI2sv, - (attrib_func) VertexAttribI2usv, - (attrib_func) VertexAttribI2iv, - (attrib_func) VertexAttribI2uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - }, - { - /* size 3 */ - (attrib_func) VertexAttribI3bv, - (attrib_func) VertexAttribI3ubv, - (attrib_func) VertexAttribI3sv, - (attrib_func) VertexAttribI3usv, - (attrib_func) VertexAttribI3iv, - (attrib_func) VertexAttribI3uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - }, - { - /* size 4 */ - (attrib_func) VertexAttribI4bv, - (attrib_func) VertexAttribI4ubv, - (attrib_func) VertexAttribI4sv, - (attrib_func) VertexAttribI4usv, - (attrib_func) VertexAttribI4iv, - (attrib_func) VertexAttribI4uiv, - NULL, /* GL_FLOAT */ - NULL /* GL_DOUBLE */ - } - } -}; - /**********************************************************************/ @@ -1468,7 +742,6 @@ static void _ae_update_state( struct gl_context *ctx ) AEcontext *actx = AE_CONTEXT(ctx); AEarray *aa = actx->arrays; AEattrib *at = actx->attribs; - GLuint i; struct gl_array_object *arrayObj = ctx->Array.ArrayObj; actx->nr_vbos = 0; @@ -1510,8 +783,8 @@ static void _ae_update_state( struct gl_context *ctx ) check_vbo(actx, aa->array->BufferObj); aa++; } - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]; + { + struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX]; if (attribArray->Enabled) { /* NOTE: we use generic glVertexAttribNV functions here. * If we ever remove GL_NV_vertex_program this will have to change. @@ -1521,59 +794,14 @@ static void _ae_update_state( struct gl_context *ctx ) at->func = AttribFuncsNV[at->array->Normalized] [at->array->Size-1] [TYPE_IDX(at->array->Type)]; - at->index = VERT_ATTRIB_TEX0 + i; - check_vbo(actx, at->array->BufferObj); - at++; - } - } - - /* generic vertex attribute arrays */ - for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */ - struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]; - if (attribArray->Enabled) { - at->array = attribArray; - /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV - * function pointer here (for float arrays) since the pointer may - * change from one execution of _ae_ArrayElement() to - * the next. Doing so caused UT to break. - */ - if (ctx->VertexProgram._Enabled - && ctx->VertexProgram.Current->IsNVProgram) { - at->func = AttribFuncsNV[at->array->Normalized] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - } - else { - GLint intOrNorm; - if (at->array->Integer) - intOrNorm = 2; - else if (at->array->Normalized) - intOrNorm = 1; - else - intOrNorm = 0; - - at->func = AttribFuncsARB[intOrNorm] - [at->array->Size-1] - [TYPE_IDX(at->array->Type)]; - } - at->index = i; - check_vbo(actx, at->array->BufferObj); + at->index = VERT_ATTRIB_TEX; + check_vbo(actx, at->array->BufferObj); at++; } } /* finally, vertex position */ - if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) { - /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's - * issued as the last (provoking) attribute). - */ - aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]; - assert(aa->array->Size >= 2); /* XXX fix someday? */ - aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; - check_vbo(actx, aa->array->BufferObj); - aa++; - } - else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_POS]; aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)]; check_vbo(actx, aa->array->BufferObj); @@ -1690,7 +918,7 @@ void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state ) * Luckily, neither the drivers nor tnl muck with the state that * concerns us here: */ - new_state &= _NEW_ARRAY | _NEW_PROGRAM; + new_state &= _NEW_ARRAY; if (new_state) { assert(!actx->mapped_vbos); actx->NewState |= new_state; diff --git a/reactos/dll/opengl/mesa/src/mesa/main/api_exec.c b/reactos/dll/opengl/mesa/src/mesa/main/api_exec.c index 98a6d10dfa6..9fa7d4fbe58 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/api_exec.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/api_exec.c @@ -33,9 +33,6 @@ #include "accum.h" #include "api_loopback.h" #include "api_exec.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#endif #include "attrib.h" #include "blend.h" #include "bufferobj.h" @@ -84,13 +81,6 @@ #include "mtypes.h" #include "varray.h" #include "viewport.h" -#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "nvprogram.h" -#endif -#if FEATURE_ARB_shader_objects -#include "shaderapi.h" -#include "uniforms.h" -#endif #include "main/dispatch.h" @@ -291,11 +281,6 @@ _mesa_create_exec_table(void) SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate); SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate); -#if FEATURE_ARB_shader_objects - _mesa_init_shader_dispatch(exec); - _mesa_init_shader_uniform_dispatch(exec); -#endif - /* 2. GL_EXT_blend_color */ #if 0 /* SET_BlendColorEXT(exec, _mesa_BlendColorEXT); */ @@ -380,8 +365,6 @@ _mesa_create_exec_table(void) /* 233. GL_NV_vertex_program */ #if FEATURE_NV_vertex_program - SET_BindProgramNV(exec, _mesa_BindProgram); - SET_DeleteProgramsNV(exec, _mesa_DeletePrograms); SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV); SET_GenProgramsNV(exec, _mesa_GenPrograms); SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV); @@ -389,13 +372,7 @@ _mesa_create_exec_table(void) SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV); SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV); SET_GetProgramivNV(exec, _mesa_GetProgramivNV); - SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV); SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(exec, _mesa_IsProgramARB); SET_LoadProgramNV(exec, _mesa_LoadProgramNV); SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ @@ -404,7 +381,6 @@ _mesa_create_exec_table(void) SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); - SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV); /* glVertexAttrib*NV functions handled in api_loopback.c */ #endif @@ -422,12 +398,6 @@ _mesa_create_exec_table(void) SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV); SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV); SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); #endif /* 262. GL_NV_point_sprite */ @@ -444,12 +414,6 @@ _mesa_create_exec_table(void) /* ???. GL_EXT_depth_bounds_test */ SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT); - /* ARB 1. GL_ARB_multitexture */ -#if _HAVE_FULL_GL - SET_ActiveTextureARB(exec, _mesa_ActiveTextureARB); - SET_ClientActiveTextureARB(exec, _mesa_ClientActiveTextureARB); -#endif - /* ARB 3. GL_ARB_transpose_matrix */ #if _HAVE_FULL_GL SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB); @@ -466,73 +430,6 @@ _mesa_create_exec_table(void) /* ARB 14. GL_ARB_point_parameters */ /* reuse EXT_point_parameters functions */ - /* ARB 26. GL_ARB_vertex_program */ - /* ARB 27. GL_ARB_fragment_program */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */ - /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */ - /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */ - /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */ - /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */ - /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */ - /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */ - /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */ - /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */ - /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */ - /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */ - /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */ - /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */ - /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */ - /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */ - /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */ - /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */ - /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */ - /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */ - /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */ - /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */ - /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */ - /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */ - /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */ - /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */ - /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */ - /* glVertexAttrib4bvARB handled in api_loopback.c */ - /* glVertexAttrib4ivARB handled in api_loopback.c */ - /* glVertexAttrib4ubvARB handled in api_loopback.c */ - /* glVertexAttrib4usvARB handled in api_loopback.c */ - /* glVertexAttrib4uivARB handled in api_loopback.c */ - /* glVertexAttrib4NbvARB handled in api_loopback.c */ - /* glVertexAttrib4NsvARB handled in api_loopback.c */ - /* glVertexAttrib4NivARB handled in api_loopback.c */ - /* glVertexAttrib4NusvARB handled in api_loopback.c */ - /* glVertexAttrib4NuivARB handled in api_loopback.c */ - SET_VertexAttribPointerARB(exec, _mesa_VertexAttribPointerARB); - SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB); - SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB); - SET_ProgramStringARB(exec, _mesa_ProgramStringARB); - /* glBindProgramARB aliases glBindProgramNV */ - /* glDeleteProgramsARB aliases glDeleteProgramsNV */ - /* glGenProgramsARB aliases glGenProgramsNV */ - /* glIsProgramARB aliases glIsProgramNV */ - SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB); - SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB); - SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB); - /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */ - SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); - SET_GetProgramivARB(exec, _mesa_GetProgramivARB); - SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); -#endif - /* ARB 28. GL_ARB_vertex_buffer_object */ SET_BindBufferARB(exec, _mesa_BindBufferARB); SET_BufferDataARB(exec, _mesa_BufferDataARB); @@ -552,18 +449,6 @@ _mesa_create_exec_table(void) SET_GetnTexImageARB(exec, _mesa_GetnTexImageARB); SET_ReadnPixelsARB(exec, _mesa_ReadnPixelsARB); - /* GL_ATI_envmap_bumpmap */ - SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); - SET_GetTexBumpParameterfvATI(exec, _mesa_GetTexBumpParameterfvATI); - SET_TexBumpParameterivATI(exec, _mesa_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(exec, _mesa_TexBumpParameterfvATI); - - /* GL_EXT_gpu_program_parameters */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT); -#endif - /* GL_ATI_separate_stencil */ SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI); @@ -590,11 +475,6 @@ _mesa_create_exec_table(void) SET_TexParameterIivEXT(exec, _mesa_TexParameterIiv); SET_TexParameterIuivEXT(exec, _mesa_TexParameterIuiv); - /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ - SET_GetVertexAttribIivEXT(exec, _mesa_GetVertexAttribIiv); - SET_GetVertexAttribIuivEXT(exec, _mesa_GetVertexAttribIuiv); - SET_VertexAttribIPointerEXT(exec, _mesa_VertexAttribIPointer); - /* GL 3.0 (functions not covered by other extensions) */ SET_GetStringi(exec, _mesa_GetStringi); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/api_loopback.c b/reactos/dll/opengl/mesa/src/mesa/main/api_loopback.c index c438307d84c..c8b2db8ef08 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/api_loopback.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/api_loopback.c @@ -57,10 +57,6 @@ #define TEXCOORD3(s,t,u) CALL_TexCoord3f(GET_DISPATCH(), (s,t,u)) #define TEXCOORD4(s,t,u,v) CALL_TexCoord4f(GET_DISPATCH(), (s,t,u,v)) #define INDEX(c) CALL_Indexf(GET_DISPATCH(), (c)) -#define MULTI_TEXCOORD1(z,s) CALL_MultiTexCoord1fARB(GET_DISPATCH(), (z,s)) -#define MULTI_TEXCOORD2(z,s,t) CALL_MultiTexCoord2fARB(GET_DISPATCH(), (z,s,t)) -#define MULTI_TEXCOORD3(z,s,t,u) CALL_MultiTexCoord3fARB(GET_DISPATCH(), (z,s,t,u)) -#define MULTI_TEXCOORD4(z,s,t,u,v) CALL_MultiTexCoord4fARB(GET_DISPATCH(), (z,s,t,u,v)) #define EVALCOORD1(x) CALL_EvalCoord1f(GET_DISPATCH(), (x)) #define EVALCOORD2(x,y) CALL_EvalCoord2f(GET_DISPATCH(), (x,y)) #define MATERIALFV(a,b,c) CALL_Materialfv(GET_DISPATCH(), (a,b,c)) @@ -74,17 +70,6 @@ #define ATTRIB3NV(index,x,y,z) CALL_VertexAttrib3fNV(GET_DISPATCH(), (index,x,y,z)) #define ATTRIB4NV(index,x,y,z,w) CALL_VertexAttrib4fNV(GET_DISPATCH(), (index,x,y,z,w)) -#define ATTRIB1ARB(index,x) CALL_VertexAttrib1fARB(GET_DISPATCH(), (index,x)) -#define ATTRIB2ARB(index,x,y) CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,x,y)) -#define ATTRIB3ARB(index,x,y,z) CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,x,y,z)) -#define ATTRIB4ARB(index,x,y,z,w) CALL_VertexAttrib4fARB(GET_DISPATCH(), (index,x,y,z,w)) - -#define ATTRIBI_1I(index,x) CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index,x)) -#define ATTRIBI_1UI(index,x) CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index,x)) -#define ATTRIBI_4I(index,x,y,z,w) CALL_VertexAttribI4iEXT(GET_DISPATCH(), (index,x,y,z,w)) - -#define ATTRIBI_4UI(index,x,y,z,w) CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index,x,y,z,w)) - #if FEATURE_beginend @@ -665,156 +650,6 @@ loopback_Vertex4sv( const GLshort *v ) (GLfloat) v[2], (GLfloat) v[3] ); } -static void GLAPIENTRY -loopback_MultiTexCoord1dARB(GLenum target, GLdouble s) -{ - MULTI_TEXCOORD1( target, (GLfloat) s ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD1( target, (GLfloat) v[0] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1iARB(GLenum target, GLint s) -{ - MULTI_TEXCOORD1( target, (GLfloat) s ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD1( target, (GLfloat) v[0] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1sARB(GLenum target, GLshort s) -{ - MULTI_TEXCOORD1( target, (GLfloat) s ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord1svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD1( target, (GLfloat) v[0] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t) -{ - MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2iARB(GLenum target, GLint s, GLint t) -{ - MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2sARB(GLenum target, GLshort s, GLshort t) -{ - MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord2svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r) -{ - MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r) -{ - MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r) -{ - MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord3svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) -{ - MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, - (GLfloat) r, (GLfloat) q ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4dvARB(GLenum target, const GLdouble *v) -{ - MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q) -{ - MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, - (GLfloat) r, (GLfloat) q ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4ivARB(GLenum target, const GLint *v) -{ - MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) -{ - MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t, - (GLfloat) r, (GLfloat) q ); -} - -static void GLAPIENTRY -loopback_MultiTexCoord4svARB(GLenum target, const GLshort *v) -{ - MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1], - (GLfloat) v[2], (GLfloat) v[3] ); -} - static void GLAPIENTRY loopback_EvalCoord2dv( const GLdouble *u ) { @@ -1269,232 +1104,6 @@ loopback_VertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v) } -/* - * GL_ARB_vertex_program - * Always loop-back to one of the VertexAttrib[1234]f[v]ARB functions. - * Note that attribute indexes do NOT alias conventional attributes. - */ - -static void GLAPIENTRY -loopback_VertexAttrib1sARB(GLuint index, GLshort x) -{ - ATTRIB1ARB(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dARB(GLuint index, GLdouble x) -{ - ATTRIB1ARB(index, (GLfloat) x); -} - -static void GLAPIENTRY -loopback_VertexAttrib2sARB(GLuint index, GLshort x, GLshort y) -{ - ATTRIB2ARB(index, (GLfloat) x, y); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y) -{ - ATTRIB2ARB(index, (GLfloat) x, (GLfloat) y); -} - -static void GLAPIENTRY -loopback_VertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z) -{ - ATTRIB3ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F); -} - -static void GLAPIENTRY -loopback_VertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - -static void GLAPIENTRY -loopback_VertexAttrib1svARB(GLuint index, const GLshort *v) -{ - ATTRIB1ARB(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib1dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB1ARB(index, (GLfloat) v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2svARB(GLuint index, const GLshort *v) -{ - ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib2dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3svARB(GLuint index, const GLshort *v) -{ - ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib3dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4svARB(GLuint index, const GLshort *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], - (GLfloat)v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4dvARB(GLuint index, const GLdouble *v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4bvARB(GLuint index, const GLbyte * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ivARB(GLuint index, const GLint * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4ubvARB(GLuint index, const GLubyte * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4usvARB(GLuint index, const GLushort * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4uivARB(GLuint index, const GLuint * v) -{ - ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NbvARB(GLuint index, const GLbyte * v) -{ - ATTRIB4ARB(index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NsvARB(GLuint index, const GLshort * v) -{ - ATTRIB4ARB(index, SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NivARB(GLuint index, const GLint * v) -{ - ATTRIB4ARB(index, INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) -{ - ATTRIB4ARB(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y), - UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w)); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NubvARB(GLuint index, const GLubyte * v) -{ - ATTRIB4ARB(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NusvARB(GLuint index, const GLushort * v) -{ - ATTRIB4ARB(index, USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3])); -} - -static void GLAPIENTRY -loopback_VertexAttrib4NuivARB(GLuint index, const GLuint * v) -{ - ATTRIB4ARB(index, UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3])); -} - - - -/** - * GL_EXT_gpu_shader / GL 3.0 signed/unsigned integer-valued attributes. - * Note that attribute indexes do NOT alias conventional attributes. - */ - -static void GLAPIENTRY -loopback_VertexAttribI1iv(GLuint index, const GLint *v) -{ - ATTRIBI_1I(index, v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttribI1uiv(GLuint index, const GLuint *v) -{ - ATTRIBI_1UI(index, v[0]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4bv(GLuint index, const GLbyte *v) -{ - ATTRIBI_4I(index, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4sv(GLuint index, const GLshort *v) -{ - ATTRIBI_4I(index, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4ubv(GLuint index, const GLubyte *v) -{ - ATTRIBI_4UI(index, v[0], v[1], v[2], v[3]); -} - -static void GLAPIENTRY -loopback_VertexAttribI4usv(GLuint index, const GLushort *v) -{ - ATTRIBI_4UI(index, v[0], v[1], v[2], v[3]); -} - - /* @@ -1608,30 +1217,6 @@ _mesa_loopback_init_api_table( struct _glapi_table *dest ) SET_Vertex4dv(dest, loopback_Vertex4dv); SET_Vertex4iv(dest, loopback_Vertex4iv); SET_Vertex4sv(dest, loopback_Vertex4sv); - SET_MultiTexCoord1dARB(dest, loopback_MultiTexCoord1dARB); - SET_MultiTexCoord1dvARB(dest, loopback_MultiTexCoord1dvARB); - SET_MultiTexCoord1iARB(dest, loopback_MultiTexCoord1iARB); - SET_MultiTexCoord1ivARB(dest, loopback_MultiTexCoord1ivARB); - SET_MultiTexCoord1sARB(dest, loopback_MultiTexCoord1sARB); - SET_MultiTexCoord1svARB(dest, loopback_MultiTexCoord1svARB); - SET_MultiTexCoord2dARB(dest, loopback_MultiTexCoord2dARB); - SET_MultiTexCoord2dvARB(dest, loopback_MultiTexCoord2dvARB); - SET_MultiTexCoord2iARB(dest, loopback_MultiTexCoord2iARB); - SET_MultiTexCoord2ivARB(dest, loopback_MultiTexCoord2ivARB); - SET_MultiTexCoord2sARB(dest, loopback_MultiTexCoord2sARB); - SET_MultiTexCoord2svARB(dest, loopback_MultiTexCoord2svARB); - SET_MultiTexCoord3dARB(dest, loopback_MultiTexCoord3dARB); - SET_MultiTexCoord3dvARB(dest, loopback_MultiTexCoord3dvARB); - SET_MultiTexCoord3iARB(dest, loopback_MultiTexCoord3iARB); - SET_MultiTexCoord3ivARB(dest, loopback_MultiTexCoord3ivARB); - SET_MultiTexCoord3sARB(dest, loopback_MultiTexCoord3sARB); - SET_MultiTexCoord3svARB(dest, loopback_MultiTexCoord3svARB); - SET_MultiTexCoord4dARB(dest, loopback_MultiTexCoord4dARB); - SET_MultiTexCoord4dvARB(dest, loopback_MultiTexCoord4dvARB); - SET_MultiTexCoord4iARB(dest, loopback_MultiTexCoord4iARB); - SET_MultiTexCoord4ivARB(dest, loopback_MultiTexCoord4ivARB); - SET_MultiTexCoord4sARB(dest, loopback_MultiTexCoord4sARB); - SET_MultiTexCoord4svARB(dest, loopback_MultiTexCoord4svARB); SET_EvalCoord2dv(dest, loopback_EvalCoord2dv); SET_EvalCoord2fv(dest, loopback_EvalCoord2fv); SET_EvalCoord2d(dest, loopback_EvalCoord2d); @@ -1682,43 +1267,6 @@ _mesa_loopback_init_api_table( struct _glapi_table *dest ) SET_VertexAttribs4fvNV(dest, loopback_VertexAttribs4fvNV); SET_VertexAttribs4dvNV(dest, loopback_VertexAttribs4dvNV); SET_VertexAttribs4ubvNV(dest, loopback_VertexAttribs4ubvNV); - - SET_VertexAttrib1sARB(dest, loopback_VertexAttrib1sARB); - SET_VertexAttrib1dARB(dest, loopback_VertexAttrib1dARB); - SET_VertexAttrib2sARB(dest, loopback_VertexAttrib2sARB); - SET_VertexAttrib2dARB(dest, loopback_VertexAttrib2dARB); - SET_VertexAttrib3sARB(dest, loopback_VertexAttrib3sARB); - SET_VertexAttrib3dARB(dest, loopback_VertexAttrib3dARB); - SET_VertexAttrib4sARB(dest, loopback_VertexAttrib4sARB); - SET_VertexAttrib4dARB(dest, loopback_VertexAttrib4dARB); - SET_VertexAttrib1svARB(dest, loopback_VertexAttrib1svARB); - SET_VertexAttrib1dvARB(dest, loopback_VertexAttrib1dvARB); - SET_VertexAttrib2svARB(dest, loopback_VertexAttrib2svARB); - SET_VertexAttrib2dvARB(dest, loopback_VertexAttrib2dvARB); - SET_VertexAttrib3svARB(dest, loopback_VertexAttrib3svARB); - SET_VertexAttrib3dvARB(dest, loopback_VertexAttrib3dvARB); - SET_VertexAttrib4svARB(dest, loopback_VertexAttrib4svARB); - SET_VertexAttrib4dvARB(dest, loopback_VertexAttrib4dvARB); - SET_VertexAttrib4NubARB(dest, loopback_VertexAttrib4NubARB); - SET_VertexAttrib4NubvARB(dest, loopback_VertexAttrib4NubvARB); - SET_VertexAttrib4bvARB(dest, loopback_VertexAttrib4bvARB); - SET_VertexAttrib4ivARB(dest, loopback_VertexAttrib4ivARB); - SET_VertexAttrib4ubvARB(dest, loopback_VertexAttrib4ubvARB); - SET_VertexAttrib4usvARB(dest, loopback_VertexAttrib4usvARB); - SET_VertexAttrib4uivARB(dest, loopback_VertexAttrib4uivARB); - SET_VertexAttrib4NbvARB(dest, loopback_VertexAttrib4NbvARB); - SET_VertexAttrib4NsvARB(dest, loopback_VertexAttrib4NsvARB); - SET_VertexAttrib4NivARB(dest, loopback_VertexAttrib4NivARB); - SET_VertexAttrib4NusvARB(dest, loopback_VertexAttrib4NusvARB); - SET_VertexAttrib4NuivARB(dest, loopback_VertexAttrib4NuivARB); - - /* GL_EXT_gpu_shader4, GL 3.0 */ - SET_VertexAttribI1ivEXT(dest, loopback_VertexAttribI1iv); - SET_VertexAttribI1uivEXT(dest, loopback_VertexAttribI1uiv); - SET_VertexAttribI4bvEXT(dest, loopback_VertexAttribI4bv); - SET_VertexAttribI4svEXT(dest, loopback_VertexAttribI4sv); - SET_VertexAttribI4ubvEXT(dest, loopback_VertexAttribI4ubv); - SET_VertexAttribI4usvEXT(dest, loopback_VertexAttribI4usv); } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/api_validate.c b/reactos/dll/opengl/mesa/src/mesa/main/api_validate.c index d7a867dd3ca..d1ac93b647e 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/api_validate.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/api_validate.c @@ -106,26 +106,10 @@ check_valid_to_render(struct gl_context *ctx, const char *function) return GL_FALSE; } - { - const struct gl_shader_program *vsProg = - ctx->Shader.CurrentVertexProgram; - GLboolean haveVertexShader = (vsProg && vsProg->LinkStatus); - GLboolean haveVertexProgram = ctx->VertexProgram._Enabled; - if (haveVertexShader || haveVertexProgram) { - /* Draw regardless of whether or not we have any vertex arrays. - * (Ex: could draw a point using a constant vertex pos) - */ - return GL_TRUE; - } - else { - /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic - * array [0]). - */ - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled || - ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled); - } - } - return GL_TRUE; + /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic + * array [0]). + */ + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled; } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/arbprogram.c b/reactos/dll/opengl/mesa/src/mesa/main/arbprogram.c deleted file mode 100644 index 739961d7b9a..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/arbprogram.c +++ /dev/null @@ -1,905 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 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. - */ - -/** - * \file arbprogram.c - * ARB_vertex/fragment_program state management functions. - * \author Brian Paul - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/hash.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/arbprogram.h" -#include "program/arbprogparse.h" -#include "program/nvfragparse.h" -#include "program/nvvertparse.h" -#include "program/program.h" - - - -/** - * Mixing ARB and NV vertex/fragment programs can be tricky. - * Note: GL_VERTEX_PROGRAM_ARB == GL_VERTEX_PROGRAM_NV - * but, GL_FRAGMENT_PROGRAM_ARB != GL_FRAGMENT_PROGRAM_NV - * The two different fragment program targets are supposed to be compatible - * to some extent (see GL_ARB_fragment_program spec). - * This function does the compatibility check. - */ -static GLboolean -compatible_program_targets(GLenum t1, GLenum t2) -{ - if (t1 == t2) - return GL_TRUE; - if (t1 == GL_FRAGMENT_PROGRAM_ARB && t2 == GL_FRAGMENT_PROGRAM_NV) - return GL_TRUE; - if (t1 == GL_FRAGMENT_PROGRAM_NV && t2 == GL_FRAGMENT_PROGRAM_ARB) - return GL_TRUE; - return GL_FALSE; -} - - -/** - * Bind a program (make it current) - * \note Called from the GL API dispatcher by both glBindProgramNV - * and glBindProgramARB. - */ -void GLAPIENTRY -_mesa_BindProgram(GLenum target, GLuint id) -{ - struct gl_program *curProg, *newProg; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - /* Error-check target and get curProg */ - if ((target == GL_VERTEX_PROGRAM_ARB) && /* == GL_VERTEX_PROGRAM_NV */ - (ctx->Extensions.NV_vertex_program || - ctx->Extensions.ARB_vertex_program)) { - curProg = &ctx->VertexProgram.Current->Base; - } - else if ((target == GL_FRAGMENT_PROGRAM_NV - && ctx->Extensions.NV_fragment_program) || - (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program)) { - curProg = &ctx->FragmentProgram.Current->Base; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glBindProgramNV/ARB(target)"); - return; - } - - /* - * Get pointer to new program to bind. - * NOTE: binding to a non-existant program is not an error. - * That's supposed to be caught in glBegin. - */ - if (id == 0) { - /* Bind a default program */ - newProg = NULL; - if (target == GL_VERTEX_PROGRAM_ARB) /* == GL_VERTEX_PROGRAM_NV */ - newProg = &ctx->Shared->DefaultVertexProgram->Base; - else - newProg = &ctx->Shared->DefaultFragmentProgram->Base; - } - else { - /* Bind a user program */ - newProg = _mesa_lookup_program(ctx, id); - if (!newProg || newProg == &_mesa_DummyProgram) { - /* allocate a new program now */ - newProg = ctx->Driver.NewProgram(ctx, target, id); - if (!newProg) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV/ARB"); - return; - } - _mesa_HashInsert(ctx->Shared->Programs, id, newProg); - } - else if (!compatible_program_targets(newProg->Target, target)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindProgramNV/ARB(target mismatch)"); - return; - } - } - - /** All error checking is complete now **/ - - if (curProg->Id == id) { - /* binding same program - no change */ - return; - } - - /* signal new program (and its new constants) */ - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); - - /* bind newProg */ - if (target == GL_VERTEX_PROGRAM_ARB) { /* == GL_VERTEX_PROGRAM_NV */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, - (struct gl_vertex_program *) newProg); - } - else if (target == GL_FRAGMENT_PROGRAM_NV || - target == GL_FRAGMENT_PROGRAM_ARB) { - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - (struct gl_fragment_program *) newProg); - } - - /* Never null pointers */ - ASSERT(ctx->VertexProgram.Current); - ASSERT(ctx->FragmentProgram.Current); - - if (ctx->Driver.BindProgram) - ctx->Driver.BindProgram(ctx, target, newProg); -} - - -/** - * Delete a list of programs. - * \note Not compiled into display lists. - * \note Called by both glDeleteProgramsNV and glDeleteProgramsARB. - */ -void GLAPIENTRY -_mesa_DeletePrograms(GLsizei n, const GLuint *ids) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (n < 0) { - _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteProgramsNV" ); - return; - } - - for (i = 0; i < n; i++) { - if (ids[i] != 0) { - struct gl_program *prog = _mesa_lookup_program(ctx, ids[i]); - if (prog == &_mesa_DummyProgram) { - _mesa_HashRemove(ctx->Shared->Programs, ids[i]); - } - else if (prog) { - /* Unbind program if necessary */ - switch (prog->Target) { - case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */ - case GL_VERTEX_STATE_PROGRAM_NV: - if (ctx->VertexProgram.Current && - ctx->VertexProgram.Current->Base.Id == ids[i]) { - /* unbind this currently bound program */ - _mesa_BindProgram(prog->Target, 0); - } - break; - case GL_FRAGMENT_PROGRAM_NV: - case GL_FRAGMENT_PROGRAM_ARB: - if (ctx->FragmentProgram.Current && - ctx->FragmentProgram.Current->Base.Id == ids[i]) { - /* unbind this currently bound program */ - _mesa_BindProgram(prog->Target, 0); - } - break; - default: - _mesa_problem(ctx, "bad target in glDeleteProgramsNV"); - return; - } - /* The ID is immediately available for re-use now */ - _mesa_HashRemove(ctx->Shared->Programs, ids[i]); - _mesa_reference_program(ctx, &prog, NULL); - } - } - } -} - - -/** - * Generate a list of new program identifiers. - * \note Not compiled into display lists. - * \note Called by both glGenProgramsNV and glGenProgramsARB. - */ -void GLAPIENTRY -_mesa_GenPrograms(GLsizei n, GLuint *ids) -{ - GLuint first; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGenPrograms"); - return; - } - - if (!ids) - return; - - first = _mesa_HashFindFreeKeyBlock(ctx->Shared->Programs, n); - - /* Insert pointer to dummy program as placeholder */ - for (i = 0; i < (GLuint) n; i++) { - _mesa_HashInsert(ctx->Shared->Programs, first + i, &_mesa_DummyProgram); - } - - /* Return the program names */ - for (i = 0; i < (GLuint) n; i++) { - ids[i] = first + i; - } -} - - -/** - * Determine if id names a vertex or fragment program. - * \note Not compiled into display lists. - * \note Called from both glIsProgramNV and glIsProgramARB. - * \param id is the program identifier - * \return GL_TRUE if id is a program, else GL_FALSE. - */ -GLboolean GLAPIENTRY -_mesa_IsProgramARB(GLuint id) -{ - struct gl_program *prog = NULL; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (id == 0) - return GL_FALSE; - - prog = _mesa_lookup_program(ctx, id); - if (prog && (prog != &_mesa_DummyProgram)) - return GL_TRUE; - else - return GL_FALSE; -} - -static GLboolean -get_local_param_pointer(struct gl_context *ctx, const char *func, - GLenum target, GLuint index, GLfloat **param) -{ - struct gl_program *prog; - GLuint maxParams; - - if (target == GL_VERTEX_PROGRAM_ARB - && ctx->Extensions.ARB_vertex_program) { - prog = &(ctx->VertexProgram.Current->Base); - maxParams = ctx->Const.VertexProgram.MaxLocalParams; - } - else if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - prog = &(ctx->FragmentProgram.Current->Base); - maxParams = ctx->Const.FragmentProgram.MaxLocalParams; - } - else if (target == GL_FRAGMENT_PROGRAM_NV - && ctx->Extensions.NV_fragment_program) { - prog = &(ctx->FragmentProgram.Current->Base); - maxParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "%s(target)", func); - return GL_FALSE; - } - - if (index >= maxParams) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func); - return GL_FALSE; - } - - *param = prog->LocalParams[index]; - return GL_TRUE; -} - - -static GLboolean -get_env_param_pointer(struct gl_context *ctx, const char *func, - GLenum target, GLuint index, GLfloat **param) -{ - if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - if (index >= ctx->Const.FragmentProgram.MaxEnvParams) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func); - return GL_FALSE; - } - *param = ctx->FragmentProgram.Parameters[index]; - return GL_TRUE; - } - else if (target == GL_VERTEX_PROGRAM_ARB && - (ctx->Extensions.ARB_vertex_program || - ctx->Extensions.NV_vertex_program)) { - if (index >= ctx->Const.VertexProgram.MaxEnvParams) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func); - return GL_FALSE; - } - *param = ctx->VertexProgram.Parameters[index]; - return GL_TRUE; - } else { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func); - return GL_FALSE; - } -} - -void GLAPIENTRY -_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, - const GLvoid *string) -{ - struct gl_program *base; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - if (!ctx->Extensions.ARB_vertex_program - && !ctx->Extensions.ARB_fragment_program) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramStringARB()"); - return; - } - - if (format != GL_PROGRAM_FORMAT_ASCII_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)"); - return; - } - - /* The first couple cases are complicated. The same enum value is used for - * ARB and NV vertex programs. If the target is a vertex program, parse it - * using the ARB grammar if the string starts with "!!ARB" or if - * NV_vertex_program is not supported. - */ - if (target == GL_VERTEX_PROGRAM_ARB - && ctx->Extensions.ARB_vertex_program - && ((strncmp(string, "!!ARB", 5) == 0) - || !ctx->Extensions.NV_vertex_program)) { - struct gl_vertex_program *prog = ctx->VertexProgram.Current; - _mesa_parse_arb_vertex_program(ctx, target, string, len, prog); - - base = & prog->Base; - } -#if FEATURE_NV_vertex_program - else if ((target == GL_VERTEX_PROGRAM_ARB - || target == GL_VERTEX_STATE_PROGRAM_NV) - && ctx->Extensions.NV_vertex_program) { - struct gl_vertex_program *prog = ctx->VertexProgram.Current; - _mesa_parse_nv_vertex_program(ctx, target, string, len, prog); - - base = & prog->Base; - } -#endif - else if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - struct gl_fragment_program *prog = ctx->FragmentProgram.Current; - _mesa_parse_arb_fragment_program(ctx, target, string, len, prog); - - base = & prog->Base; - } -#if FEATURE_NV_fragment_program - else if (target == GL_FRAGMENT_PROGRAM_NV - && ctx->Extensions.NV_fragment_program) { - struct gl_fragment_program *prog = ctx->FragmentProgram.Current; - _mesa_parse_nv_fragment_program(ctx, target, string, len, prog); - - base = & prog->Base; - } -#endif - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(target)"); - return; - } -} - - -/** - * Set a program env parameter register. - * \note Called from the GL API dispatcher. - * Note, this function is also used by the GL_NV_vertex_program extension - * (alias to ProgramParameterdNV) - */ -void GLAPIENTRY -_mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - _mesa_ProgramEnvParameter4fARB(target, index, (GLfloat) x, (GLfloat) y, - (GLfloat) z, (GLfloat) w); -} - - -/** - * Set a program env parameter register. - * \note Called from the GL API dispatcher. - * Note, this function is also used by the GL_NV_vertex_program extension - * (alias to ProgramParameterdvNV) - */ -void GLAPIENTRY -_mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - _mesa_ProgramEnvParameter4fARB(target, index, (GLfloat) params[0], - (GLfloat) params[1], (GLfloat) params[2], - (GLfloat) params[3]); -} - - -/** - * Set a program env parameter register. - * \note Called from the GL API dispatcher. - * Note, this function is also used by the GL_NV_vertex_program extension - * (alias to ProgramParameterfNV) - */ -void GLAPIENTRY -_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GLfloat *param; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - if (get_env_param_pointer(ctx, "glProgramEnvParameter", - target, index, ¶m)) { - ASSIGN_4V(param, x, y, z, w); - } -} - - - -/** - * Set a program env parameter register. - * \note Called from the GL API dispatcher. - * Note, this function is also used by the GL_NV_vertex_program extension - * (alias to ProgramParameterfvNV) - */ -void GLAPIENTRY -_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - GLfloat *param; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - if (get_env_param_pointer(ctx, "glProgramEnvParameter4fv", - target, index, ¶m)) { - memcpy(param, params, 4 * sizeof(GLfloat)); - } -} - - -void GLAPIENTRY -_mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat * dest; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - if (count <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(count)"); - } - - if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - if ((index + count) > ctx->Const.FragmentProgram.MaxEnvParams) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(index + count)"); - return; - } - dest = ctx->FragmentProgram.Parameters[index]; - } - else if (target == GL_VERTEX_PROGRAM_ARB - && ctx->Extensions.ARB_vertex_program) { - if ((index + count) > ctx->Const.VertexProgram.MaxEnvParams) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(index + count)"); - return; - } - dest = ctx->VertexProgram.Parameters[index]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameters4fv(target)"); - return; - } - - memcpy(dest, params, count * 4 * sizeof(GLfloat)); -} - - -void GLAPIENTRY -_mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index, - GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *fparam; - - if (get_env_param_pointer(ctx, "glGetProgramEnvParameterdv", - target, index, &fparam)) { - COPY_4V(params, fparam); - } -} - - -void GLAPIENTRY -_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, - GLfloat *params) -{ - GLfloat *param; - - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (get_env_param_pointer(ctx, "glGetProgramEnvParameterfv", - target, index, ¶m)) { - COPY_4V(params, param); - } -} - - -/** - * Note, this function is also used by the GL_NV_fragment_program extension. - */ -void GLAPIENTRY -_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *param; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - if (get_local_param_pointer(ctx, "glProgramLocalParameterARB", - target, index, ¶m)) { - ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS); - ASSIGN_4V(param, x, y, z, w); - } -} - - -/** - * Note, this function is also used by the GL_NV_fragment_program extension. - */ -void GLAPIENTRY -_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - _mesa_ProgramLocalParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); -} - - -void GLAPIENTRY -_mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - if (count <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fv(count)"); - } - - if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - if ((index + count) > ctx->Const.FragmentProgram.MaxLocalParams) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)"); - return; - } - dest = ctx->FragmentProgram.Current->Base.LocalParams[index]; - } - else if (target == GL_VERTEX_PROGRAM_ARB - && ctx->Extensions.ARB_vertex_program) { - if ((index + count) > ctx->Const.VertexProgram.MaxLocalParams) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)"); - return; - } - dest = ctx->VertexProgram.Current->Base.LocalParams[index]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameters4fvEXT(target)"); - return; - } - - memcpy(dest, params, count * 4 * sizeof(GLfloat)); -} - - -/** - * Note, this function is also used by the GL_NV_fragment_program extension. - */ -void GLAPIENTRY -_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, - GLdouble z, GLdouble w) -{ - _mesa_ProgramLocalParameter4fARB(target, index, (GLfloat) x, (GLfloat) y, - (GLfloat) z, (GLfloat) w); -} - - -/** - * Note, this function is also used by the GL_NV_fragment_program extension. - */ -void GLAPIENTRY -_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - _mesa_ProgramLocalParameter4fARB(target, index, - (GLfloat) params[0], (GLfloat) params[1], - (GLfloat) params[2], (GLfloat) params[3]); -} - - -/** - * Note, this function is also used by the GL_NV_fragment_program extension. - */ -void GLAPIENTRY -_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, - GLfloat *params) -{ - GLfloat *param; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT", - target, index, ¶m)) { - COPY_4V(params, param); - } -} - - -/** - * Note, this function is also used by the GL_NV_fragment_program extension. - */ -void GLAPIENTRY -_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index, - GLdouble *params) -{ - GLfloat *param; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT", - target, index, ¶m)) { - COPY_4V(params, param); - } -} - - -void GLAPIENTRY -_mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params) -{ - const struct gl_program_constants *limits; - struct gl_program *prog; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_ARB - && ctx->Extensions.ARB_vertex_program) { - prog = &(ctx->VertexProgram.Current->Base); - limits = &ctx->Const.VertexProgram; - } - else if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - prog = &(ctx->FragmentProgram.Current->Base); - limits = &ctx->Const.FragmentProgram; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)"); - return; - } - - ASSERT(prog); - ASSERT(limits); - - /* Queries supported for both vertex and fragment programs */ - switch (pname) { - case GL_PROGRAM_LENGTH_ARB: - *params - = prog->String ? (GLint) strlen((char *) prog->String) : 0; - return; - case GL_PROGRAM_FORMAT_ARB: - *params = prog->Format; - return; - case GL_PROGRAM_BINDING_ARB: - *params = prog->Id; - return; - case GL_PROGRAM_INSTRUCTIONS_ARB: - *params = prog->NumInstructions; - return; - case GL_MAX_PROGRAM_INSTRUCTIONS_ARB: - *params = limits->MaxInstructions; - return; - case GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB: - *params = prog->NumNativeInstructions; - return; - case GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB: - *params = limits->MaxNativeInstructions; - return; - case GL_PROGRAM_TEMPORARIES_ARB: - *params = prog->NumTemporaries; - return; - case GL_MAX_PROGRAM_TEMPORARIES_ARB: - *params = limits->MaxTemps; - return; - case GL_PROGRAM_NATIVE_TEMPORARIES_ARB: - *params = prog->NumNativeTemporaries; - return; - case GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB: - *params = limits->MaxNativeTemps; - return; - case GL_PROGRAM_PARAMETERS_ARB: - *params = prog->NumParameters; - return; - case GL_MAX_PROGRAM_PARAMETERS_ARB: - *params = limits->MaxParameters; - return; - case GL_PROGRAM_NATIVE_PARAMETERS_ARB: - *params = prog->NumNativeParameters; - return; - case GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB: - *params = limits->MaxNativeParameters; - return; - case GL_PROGRAM_ATTRIBS_ARB: - *params = prog->NumAttributes; - return; - case GL_MAX_PROGRAM_ATTRIBS_ARB: - *params = limits->MaxAttribs; - return; - case GL_PROGRAM_NATIVE_ATTRIBS_ARB: - *params = prog->NumNativeAttributes; - return; - case GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB: - *params = limits->MaxNativeAttribs; - return; - case GL_PROGRAM_ADDRESS_REGISTERS_ARB: - *params = prog->NumAddressRegs; - return; - case GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB: - *params = limits->MaxAddressRegs; - return; - case GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB: - *params = prog->NumNativeAddressRegs; - return; - case GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB: - *params = limits->MaxNativeAddressRegs; - return; - case GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB: - *params = limits->MaxLocalParams; - return; - case GL_MAX_PROGRAM_ENV_PARAMETERS_ARB: - *params = limits->MaxEnvParams; - return; - case GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB: - /* - * XXX we may not really need a driver callback here. - * If the number of native instructions, registers, etc. used - * are all below the maximums, we could return true. - * The spec says that even if this query returns true, there's - * no guarantee that the program will run in hardware. - */ - if (prog->Id == 0) { - /* default/null program */ - *params = GL_FALSE; - } - else if (ctx->Driver.IsProgramNative) { - /* ask the driver */ - *params = ctx->Driver.IsProgramNative( ctx, target, prog ); - } - else { - /* probably running in software */ - *params = GL_TRUE; - } - return; - default: - /* continue with fragment-program only queries below */ - break; - } - - /* - * The following apply to fragment programs only (at this time) - */ - if (target == GL_FRAGMENT_PROGRAM_ARB) { - const struct gl_fragment_program *fp = ctx->FragmentProgram.Current; - switch (pname) { - case GL_PROGRAM_ALU_INSTRUCTIONS_ARB: - *params = fp->Base.NumNativeAluInstructions; - return; - case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: - *params = fp->Base.NumAluInstructions; - return; - case GL_PROGRAM_TEX_INSTRUCTIONS_ARB: - *params = fp->Base.NumTexInstructions; - return; - case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB: - *params = fp->Base.NumNativeTexInstructions; - return; - case GL_PROGRAM_TEX_INDIRECTIONS_ARB: - *params = fp->Base.NumTexIndirections; - return; - case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: - *params = fp->Base.NumNativeTexIndirections; - return; - case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB: - *params = limits->MaxAluInstructions; - return; - case GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: - *params = limits->MaxNativeAluInstructions; - return; - case GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB: - *params = limits->MaxTexInstructions; - return; - case GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB: - *params = limits->MaxNativeTexInstructions; - return; - case GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB: - *params = limits->MaxTexIndirections; - return; - case GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: - *params = limits->MaxNativeTexIndirections; - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)"); - return; - } - } else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)"); - return; - } -} - - -void GLAPIENTRY -_mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string) -{ - const struct gl_program *prog; - char *dst = (char *) string; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_ARB) { - prog = &(ctx->VertexProgram.Current->Base); - } - else if (target == GL_FRAGMENT_PROGRAM_ARB) { - prog = &(ctx->FragmentProgram.Current->Base); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(target)"); - return; - } - - ASSERT(prog); - - if (pname != GL_PROGRAM_STRING_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(pname)"); - return; - } - - if (prog->String) - memcpy(dst, prog->String, strlen((char *) prog->String)); - else - *dst = '\0'; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/arbprogram.h b/reactos/dll/opengl/mesa/src/mesa/main/arbprogram.h deleted file mode 100644 index e2e535e911e..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/arbprogram.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-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 ARBPROGRAM_H -#define ARBPROGRAM_H - - -#include "glheader.h" - - -extern void GLAPIENTRY -_mesa_BindProgram(GLenum target, GLuint id); - -extern void GLAPIENTRY -_mesa_DeletePrograms(GLsizei n, const GLuint *ids); - -extern void GLAPIENTRY -_mesa_GenPrograms(GLsizei n, GLuint *ids); - - -extern GLboolean GLAPIENTRY -_mesa_IsProgramARB(GLuint id); - - -extern void GLAPIENTRY -_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, - const GLvoid *string); - - -extern void GLAPIENTRY -_mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w); - - -extern void GLAPIENTRY -_mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params); - - -extern void GLAPIENTRY -_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w); - - -extern void GLAPIENTRY -_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params); - - -extern void GLAPIENTRY -_mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params); - - -extern void GLAPIENTRY -_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, - GLdouble z, GLdouble w); - - -extern void GLAPIENTRY -_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params); - - -extern void GLAPIENTRY -_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w); - - -extern void GLAPIENTRY -_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params); - - -extern void GLAPIENTRY -_mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params); - - -extern void GLAPIENTRY -_mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index, - GLdouble *params); - - -extern void GLAPIENTRY -_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, - GLfloat *params); - - -extern void GLAPIENTRY -_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index, - GLdouble *params); - - -extern void GLAPIENTRY -_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, - GLfloat *params); - - -extern void GLAPIENTRY -_mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params); - - -extern void GLAPIENTRY -_mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string); - - -#endif diff --git a/reactos/dll/opengl/mesa/src/mesa/main/attrib.c b/reactos/dll/opengl/mesa/src/mesa/main/attrib.c index 04e874f3ce5..07213291161 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/attrib.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/attrib.c @@ -93,7 +93,6 @@ struct gl_enable_attrib GLboolean Map1TextureCoord4; GLboolean Map1Vertex3; GLboolean Map1Vertex4; - GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ GLboolean Map2Color4; GLboolean Map2Index; GLboolean Map2Normal; @@ -103,7 +102,6 @@ struct gl_enable_attrib GLboolean Map2TextureCoord4; GLboolean Map2Vertex3; GLboolean Map2Vertex4; - GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ GLboolean Normalize; GLboolean PixelTexture; @@ -123,13 +121,8 @@ struct gl_enable_attrib GLboolean SampleCoverage; /* GL_ARB_multisample */ GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ - GLbitfield Texture[MAX_TEXTURE_UNITS]; - GLbitfield TexGen[MAX_TEXTURE_UNITS]; - - /* GL_ARB_vertex_program / GL_NV_vertex_program */ - GLboolean VertexProgram; - GLboolean VertexProgramPointSize; - GLboolean VertexProgramTwoSide; + GLbitfield Texture; + GLbitfield TexGen; /* GL_ARB_point_sprite / GL_NV_point_sprite */ GLboolean PointSprite; @@ -156,13 +149,13 @@ struct texture_state struct gl_texture_attrib Texture; /**< The usual context state */ /** to save per texture object state (wrap modes, filters, etc): */ - struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; + struct gl_texture_object SavedObj[NUM_TEXTURE_TARGETS]; /** * To save references to texture objects (so they don't get accidentally * deleted while saved in the attribute stack). */ - struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; + struct gl_texture_object *SavedTexRef[NUM_TEXTURE_TARGETS]; /* We need to keep a reference to the shared state. That's where the * default texture objects are kept. We don't want that state to be @@ -280,7 +273,6 @@ _mesa_PushAttrib(GLbitfield mask) attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; - memcpy(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib)); attr->Map2Color4 = ctx->Eval.Map2Color4; attr->Map2Index = ctx->Eval.Map2Index; attr->Map2Normal = ctx->Eval.Map2Normal; @@ -290,7 +282,6 @@ _mesa_PushAttrib(GLbitfield mask) attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; - memcpy(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib)); attr->Normalize = ctx->Transform.Normalize; attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; attr->PointSmooth = ctx->Point.SmoothFlag; @@ -308,14 +299,8 @@ _mesa_PushAttrib(GLbitfield mask) attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage; attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; attr->SampleCoverage = ctx->Multisample.SampleCoverage; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - attr->Texture[i] = ctx->Texture.Unit[i].Enabled; - attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; - } - /* GL_NV_vertex_program */ - attr->VertexProgram = ctx->VertexProgram.Enabled; - attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled; - attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled; + attr->Texture = ctx->Texture.Unit.Enabled; + attr->TexGen = ctx->Texture.Unit.TexGenEnabled; save_attrib_data(&head, GL_ENABLE_BIT, attr); } @@ -408,7 +393,7 @@ _mesa_PushAttrib(GLbitfield mask) if (mask & GL_TEXTURE_BIT) { struct texture_state *texstate = CALLOC_STRUCT(texture_state); - GLuint u, tex; + GLuint tex; if (!texstate) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); @@ -423,19 +408,15 @@ _mesa_PushAttrib(GLbitfield mask) /* Save references to the currently bound texture objects so they don't * accidentally get deleted while referenced in the attribute stack. */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tex], - ctx->Texture.Unit[u].CurrentTex[tex]); - } + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texstate->SavedTexRef[tex], + ctx->Texture.Unit.CurrentTex[tex]); } /* copy state/contents of the currently bound texture objects */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_copy_texture_object(&texstate->SavedObj[u][tex], - ctx->Texture.Unit[u].CurrentTex[tex]); - } + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_copy_texture_object(&texstate->SavedObj[tex], + ctx->Texture.Unit.CurrentTex[tex]); } _mesa_reference_shared_state(ctx, &texstate->SharedRef, ctx->Shared); @@ -477,7 +458,6 @@ end: static void pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) { - const GLuint curTexUnitSave = ctx->Texture.CurrentUnit; GLuint i; #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ @@ -527,10 +507,6 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) GL_MAP1_VERTEX_3); TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, GL_MAP1_VERTEX_4); - for (i = 0; i < 16; i++) { - TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i], - GL_MAP1_VERTEX_ATTRIB0_4_NV + i); - } TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); @@ -547,10 +523,6 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) GL_MAP2_VERTEX_3); TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, GL_MAP2_VERTEX_4); - for (i = 0; i < 16; i++) { - TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i], - GL_MAP2_VERTEX_ATTRIB0_4_NV + i); - } TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); @@ -591,25 +563,13 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) TEST_AND_UPDATE(ctx->Multisample.SampleCoverage, enable->SampleCoverage, GL_SAMPLE_COVERAGE_ARB); - /* GL_ARB_vertex_program, GL_NV_vertex_program */ - TEST_AND_UPDATE(ctx->VertexProgram.Enabled, - enable->VertexProgram, - GL_VERTEX_PROGRAM_ARB); - TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled, - enable->VertexProgramPointSize, - GL_VERTEX_PROGRAM_POINT_SIZE_ARB); - TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled, - enable->VertexProgramTwoSide, - GL_VERTEX_PROGRAM_TWO_SIDE_ARB); /* texture unit enables */ - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - const GLbitfield enabled = enable->Texture[i]; - const GLbitfield genEnabled = enable->TexGen[i]; - - if (ctx->Texture.Unit[i].Enabled != enabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + { + const GLbitfield enabled = enable->Texture; + const GLbitfield genEnabled = enable->TexGen; + if (ctx->Texture.Unit.Enabled != enabled) { _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(enabled & TEXTURE_1D_BIT)); _mesa_set_enable(ctx, GL_TEXTURE_2D, !!(enabled & TEXTURE_2D_BIT)); _mesa_set_enable(ctx, GL_TEXTURE_3D, !!(enabled & TEXTURE_3D_BIT)); @@ -619,16 +579,13 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) } } - if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + i); + if (ctx->Texture.Unit.TexGenEnabled != genEnabled) { _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(genEnabled & S_BIT)); _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(genEnabled & T_BIT)); _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(genEnabled & R_BIT)); _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(genEnabled & Q_BIT)); } } - - _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave); } @@ -638,118 +595,107 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable) static void pop_texture_group(struct gl_context *ctx, struct texture_state *texstate) { - GLuint u; + const struct gl_texture_unit *unit; + GLuint tgt; _mesa_lock_context_textures(ctx); - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - const struct gl_texture_unit *unit = &texstate->Texture.Unit[u]; - GLuint tgt; + unit = &texstate->Texture.Unit; - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); - _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(unit->Enabled & TEXTURE_1D_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_2D, !!(unit->Enabled & TEXTURE_2D_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_3D, !!(unit->Enabled & TEXTURE_3D_BIT)); - if (ctx->Extensions.ARB_texture_cube_map) { - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB, - !!(unit->Enabled & TEXTURE_CUBE_BIT)); + _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(unit->Enabled & TEXTURE_1D_BIT)); + _mesa_set_enable(ctx, GL_TEXTURE_2D, !!(unit->Enabled & TEXTURE_2D_BIT)); + _mesa_set_enable(ctx, GL_TEXTURE_3D, !!(unit->Enabled & TEXTURE_3D_BIT)); + + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); + _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); + _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); + _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); + _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); + _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); + _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); + _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); + _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); + _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); + /* Eye plane done differently to avoid re-transformation */ + { + struct gl_texture_unit *destUnit = &ctx->Texture.Unit; + COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); + COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); + COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); + COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); + if (ctx->Driver.TexGen) { + ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); + ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); + ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); + ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); + } + } + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(unit->TexGenEnabled & S_BIT)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(unit->TexGenEnabled & T_BIT)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(unit->TexGenEnabled & R_BIT)); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(unit->TexGenEnabled & Q_BIT)); + _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, + unit->LodBias); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, + unit->Combine.ModeRGB); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, + unit->Combine.ModeA); + { + const GLuint n = ctx->Extensions.NV_texture_env_combine4 ? 4 : 3; + GLuint i; + for (i = 0; i < n; i++) { + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB + i, + unit->Combine.SourceRGB[i]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA + i, + unit->Combine.SourceA[i]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB + i, + unit->Combine.OperandRGB[i]); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA + i, + unit->Combine.OperandA[i]); + } + } + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 1 << unit->Combine.ScaleShiftRGB); + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 << unit->Combine.ScaleShiftA); + + /* Restore texture object state for each target */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + const struct gl_texture_object *obj = NULL; + const struct gl_sampler_object *samp; + GLenum target; + + obj = &texstate->SavedObj[tgt]; + + /* don't restore state for unsupported targets to prevent + * raising GL errors. + */ + if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && + !ctx->Extensions.ARB_texture_cube_map) { + continue; } - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); - _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); - _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); - _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); - _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); - _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); - _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); - _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); - _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); - _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); - /* Eye plane done differently to avoid re-transformation */ - { - struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u]; - COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); - COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); - COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); - COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); - if (ctx->Driver.TexGen) { - ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); - ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); - ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); - ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); - } - } - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(unit->TexGenEnabled & S_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(unit->TexGenEnabled & T_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(unit->TexGenEnabled & R_BIT)); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(unit->TexGenEnabled & Q_BIT)); - _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, - unit->LodBias); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, - unit->Combine.ModeRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, - unit->Combine.ModeA); - { - const GLuint n = ctx->Extensions.NV_texture_env_combine4 ? 4 : 3; - GLuint i; - for (i = 0; i < n; i++) { - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB + i, - unit->Combine.SourceRGB[i]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA + i, - unit->Combine.SourceA[i]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB + i, - unit->Combine.OperandRGB[i]); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA + i, - unit->Combine.OperandA[i]); - } - } - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, - 1 << unit->Combine.ScaleShiftRGB); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, - 1 << unit->Combine.ScaleShiftA); + target = obj->Target; - /* Restore texture object state for each target */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - const struct gl_texture_object *obj = NULL; - const struct gl_sampler_object *samp; - GLenum target; + _mesa_BindTexture(target, obj->Name); - obj = &texstate->SavedObj[u][tgt]; + samp = &obj->Sampler; - /* don't restore state for unsupported targets to prevent - * raising GL errors. - */ - if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && - !ctx->Extensions.ARB_texture_cube_map) { - continue; - } - - target = obj->Target; - - _mesa_BindTexture(target, obj->Name); - - samp = &obj->Sampler; - - _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, samp->BorderColor.f); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, samp->WrapS); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, samp->WrapT); - _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, samp->WrapR); - _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, samp->MinFilter); - _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, samp->MagFilter); - _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); - if (ctx->Extensions.EXT_texture_filter_anisotropic) { - _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, - samp->MaxAnisotropy); - } - } - - /* remove saved references to the texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); + _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, samp->BorderColor.f); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, samp->WrapS); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, samp->WrapT); + _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, samp->WrapR); + _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, samp->MinFilter); + _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, samp->MagFilter); + _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); + if (ctx->Extensions.EXT_texture_filter_anisotropic) { + _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, + samp->MaxAnisotropy); } } - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); + /* remove saved references to the texture objects */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[tgt], NULL); + } _mesa_reference_shared_state(ctx, &texstate->SharedRef, NULL); @@ -994,30 +940,6 @@ _mesa_PopAttrib(void) point = (const struct gl_point_attrib *) attr->data; _mesa_PointSize(point->Size); _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag); - if (ctx->Extensions.EXT_point_parameters) { - _mesa_PointParameterfv(GL_DISTANCE_ATTENUATION_EXT, - point->Params); - _mesa_PointParameterf(GL_POINT_SIZE_MIN_EXT, - point->MinSize); - _mesa_PointParameterf(GL_POINT_SIZE_MAX_EXT, - point->MaxSize); - _mesa_PointParameterf(GL_POINT_FADE_THRESHOLD_SIZE_EXT, - point->Threshold); - } - if (ctx->Extensions.NV_point_sprite - || ctx->Extensions.ARB_point_sprite) { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, - (GLint) point->CoordReplace[u]); - } - _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite); - if (ctx->Extensions.NV_point_sprite) - _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV, - ctx->Point.SpriteRMode); - _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, - (GLfloat)ctx->Point.SpriteOrigin); - } } break; case GL_POLYGON_BIT: @@ -1234,7 +1156,6 @@ copy_array_attrib(struct gl_context *ctx, { /* skip ArrayObj */ /* skip DefaultArrayObj, Objects */ - dest->ActiveTexture = src->ActiveTexture; dest->LockFirst = src->LockFirst; dest->LockCount = src->LockCount; /* skip NewState */ @@ -1486,12 +1407,10 @@ _mesa_free_attrib_data(struct gl_context *ctx) while (attr) { if (attr->kind == GL_TEXTURE_BIT) { struct texture_state *texstate = (struct texture_state*)attr->data; - GLuint u, tgt; + GLuint tgt; /* clear references to the saved texture objects */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); - } + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[tgt], NULL); } _mesa_reference_shared_state(ctx, &texstate->SharedRef, NULL); } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/config.h b/reactos/dll/opengl/mesa/src/mesa/main/config.h index 80b9bf017c0..c88dfc941ed 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/config.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/config.h @@ -112,28 +112,6 @@ /** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */ #define MAX_CUBE_TEXTURE_LEVELS 15 -/** - * Max number of texture coordinate units. This mainly just applies to - * the fixed-function vertex code. This will be difficult to raise above - * eight because of various vertex attribute bitvectors. - */ -#define MAX_TEXTURE_COORD_UNITS 8 - -/** - * Max number of texture image units. Also determines number of texture - * samplers in shaders. - */ -#define MAX_TEXTURE_IMAGE_UNITS 16 - -/** - * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS. - * This value is only used for dimensioning arrays. - * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the - * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be - * used almost everywhere else. - */ -#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS) - /** * Maximum viewport/image width. Must accomodate all texture sizes too. @@ -183,82 +161,7 @@ /** For GL_EXT_texture_filter_anisotropic */ #define MAX_TEXTURE_MAX_ANISOTROPY 16.0 -/** For any program target/extension */ -/*@{*/ -#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024) - -/** - * Per-program constants (power of two) - * - * \c MAX_PROGRAM_LOCAL_PARAMS and \c MAX_UNIFORMS are just the assembly shader - * and GLSL shader names for the same thing. They should \b always have the - * same value. Each refers to the number of vec4 values supplied as - * per-program parameters. - */ -/*@{*/ -#define MAX_PROGRAM_LOCAL_PARAMS 4096 -#define MAX_UNIFORMS 4096 -/*@}*/ - -/** - * Per-context constants (power of two) - * - * \note - * This value should always be less than or equal to \c MAX_PROGRAM_LOCAL_PARAMS - * and \c MAX_VERTEX_PROGRAM_PARAMS. Otherwise some applications will make - * incorrect assumptions. - */ -#define MAX_PROGRAM_ENV_PARAMS 256 - -#define MAX_PROGRAM_MATRICES 8 -#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4 -#define MAX_PROGRAM_CALL_DEPTH 8 -#define MAX_PROGRAM_TEMPS 256 -#define MAX_PROGRAM_ADDRESS_REGS 2 -#define MAX_VARYING 16 /**< number of float[4] vectors */ -#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS -#define MAX_PROGRAM_INPUTS 32 -#define MAX_PROGRAM_OUTPUTS 64 -/*@}*/ - -/** For GL_ARB_vertex_program */ -/*@{*/ -#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1 -#define MAX_VERTEX_PROGRAM_PARAMS MAX_UNIFORMS -/*@}*/ - -/** For GL_ARB_fragment_program */ -/*@{*/ -#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0 -/*@}*/ - -/** For GL_NV_vertex_program */ -/*@{*/ -#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128 -#define MAX_NV_VERTEX_PROGRAM_TEMPS 12 -#define MAX_NV_VERTEX_PROGRAM_PARAMS 96 -#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 -#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15 -/*@}*/ - -/** For GL_NV_fragment_program */ -/*@{*/ -#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */ -#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96 -#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64 -#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12 -#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3 -#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2 -/*@}*/ - - -/** For GL_ARB_vertex_shader */ -/*@{*/ -#define MAX_VERTEX_GENERIC_ATTRIBS 16 -#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS -#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_VERTEX_TEXTURE_IMAGE_UNITS + \ - MAX_TEXTURE_IMAGE_UNITS) -/*@}*/ +#define MAX_NV_VERTEX_PROGRAM_INPUTS 16 /** For GL_EXT_framebuffer_object */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/context.c b/reactos/dll/opengl/mesa/src/mesa/main/context.c index ca1315bfa30..482ddb7e55c 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/context.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/context.c @@ -110,7 +110,6 @@ #include "rastpos.h" #include "scissor.h" #include "shared.h" -#include "shaderobj.h" #include "simple_list.h" #include "state.h" #include "stencil.h" @@ -120,8 +119,6 @@ #include "version.h" #include "viewport.h" #include "vtxfmt.h" -#include "program/program.h" -#include "program/prog_print.h" #if _HAVE_FULL_GL #include "math/m_matrix.h" #endif @@ -131,7 +128,6 @@ #include "sparc/sparc.h" #endif -#include "glsl_parser_extras.h" #include @@ -333,16 +329,12 @@ dummy_enum_func(void) gl_buffer_index bi = BUFFER_FRONT_LEFT; gl_face_index fi = FACE_POS_X; gl_frag_attrib fa = FRAG_ATTRIB_WPOS; - gl_frag_result fr = FRAG_RESULT_DEPTH; gl_vert_attrib va = VERT_ATTRIB_POS; - gl_vert_result vr = VERT_RESULT_HPOS; (void) bi; (void) fi; (void) fa; - (void) fr; (void) va; - (void) vr; } @@ -410,11 +402,6 @@ one_time_init( struct gl_context *ctx ) _glthread_UNLOCK_MUTEX(OneTimeLock); - /* Hopefully atexit() is widely available. If not, we may need some - * #ifdef tests here. - */ - atexit(_mesa_destroy_shader_compiler); - dummy_enum_func(); } @@ -441,54 +428,6 @@ _mesa_init_current(struct gl_context *ctx) ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 ); } - -/** - * Init vertex/fragment/geometry program limits. - * Important: drivers should override these with actual limits. - */ -static void -init_program_limits(GLenum type, struct gl_program_constants *prog) -{ - prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxAluInstructions = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxTexInstructions = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxTexIndirections = MAX_PROGRAM_INSTRUCTIONS; - prog->MaxTemps = MAX_PROGRAM_TEMPS; - prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS; - prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS; - prog->MaxAddressOffset = MAX_PROGRAM_LOCAL_PARAMS; - - switch (type) { - case GL_VERTEX_PROGRAM_ARB: - prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS; - prog->MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS; - prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS; - prog->MaxUniformComponents = 4 * MAX_UNIFORMS; - break; - case GL_FRAGMENT_PROGRAM_ARB: - prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS; - prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS; - prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS; - prog->MaxUniformComponents = 4 * MAX_UNIFORMS; - break; - default: - assert(0 && "Bad program type in init_program_limits()"); - } - - /* Set the native limits to zero. This implies that there is no native - * support for shaders. Let the drivers fill in the actual values. - */ - prog->MaxNativeInstructions = 0; - prog->MaxNativeAluInstructions = 0; - prog->MaxNativeTexInstructions = 0; - prog->MaxNativeTexIndirections = 0; - prog->MaxNativeAttribs = 0; - prog->MaxNativeTemps = 0; - prog->MaxNativeAddressRegs = 0; - prog->MaxNativeParameters = 0; -} - - /** * Initialize fields of gl_constants (aka ctx->Const.*). * Use defaults from config.h. The device drivers will often override @@ -504,10 +443,6 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS; ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS; ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS; - ctx->Const.MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS; - ctx->Const.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits, - ctx->Const.MaxTextureImageUnits); ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY; ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE; ctx->Const.SubPixelBits = SUB_PIXEL_BITS; @@ -528,37 +463,13 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.MaxSpotExponent = 128.0; ctx->Const.MaxViewportWidth = MAX_WIDTH; ctx->Const.MaxViewportHeight = MAX_HEIGHT; -#if FEATURE_ARB_vertex_program - init_program_limits(GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram); -#endif -#if FEATURE_ARB_fragment_program - init_program_limits(GL_FRAGMENT_PROGRAM_ARB, &ctx->Const.FragmentProgram); -#endif - ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES; - ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; /* CheckArrayBounds is overriden by drivers/x11 for X server */ ctx->Const.CheckArrayBounds = GL_FALSE; -#if FEATURE_ARB_vertex_shader - ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS; - ctx->Const.MaxVarying = MAX_VARYING; -#endif - - ctx->Const.GLSLVersion = 120; - _mesa_override_glsl_version(ctx); - - /* GL_ATI_envmap_bumpmap */ - ctx->Const.SupportedBumpUnits = SUPPORTED_ATI_BUMP_UNITS; - /* GL 3.2: hard-coded for now: */ ctx->Const.ProfileMask = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; - /** GL_EXT_gpu_shader4 */ - ctx->Const.MinProgramTexelOffset = -8; - ctx->Const.MaxProgramTexelOffset = 7; - /* GL_ARB_robustness */ ctx->Const.ResetStrategy = GL_NO_RESET_NOTIFICATION_ARB; } @@ -571,40 +482,6 @@ _mesa_init_constants(struct gl_context *ctx) static void check_context_limits(struct gl_context *ctx) { - /* check that we don't exceed the size of various bitfields */ - assert(VERT_RESULT_MAX <= - (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten))); - assert(FRAG_ATTRIB_MAX <= - (8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead))); - - assert(MAX_COMBINED_TEXTURE_IMAGE_UNITS <= 8 * sizeof(GLbitfield)); - - /* shader-related checks */ - assert(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS); - assert(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS); - - assert(MAX_NV_FRAGMENT_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS); - assert(MAX_NV_VERTEX_PROGRAM_TEMPS <= MAX_PROGRAM_TEMPS); - assert(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX); - assert(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX); - - /* Texture unit checks */ - assert(ctx->Const.MaxTextureImageUnits > 0); - assert(ctx->Const.MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS); - assert(ctx->Const.MaxTextureCoordUnits > 0); - assert(ctx->Const.MaxTextureCoordUnits <= MAX_TEXTURE_COORD_UNITS); - assert(ctx->Const.MaxTextureUnits > 0); - assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS); - assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS); - assert(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.MaxTextureImageUnits, - ctx->Const.MaxTextureCoordUnits)); - assert(ctx->Const.MaxCombinedTextureImageUnits > 0); - assert(ctx->Const.MaxCombinedTextureImageUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS); - assert(ctx->Const.MaxTextureCoordUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS); - /* number of coord units cannot be greater than number of image units */ - assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.MaxTextureImageUnits); - - /* Texture size checks */ assert(ctx->Const.MaxTextureLevels <= MAX_TEXTURE_LEVELS); assert(ctx->Const.Max3DTextureLevels <= MAX_3D_TEXTURE_LEVELS); @@ -666,10 +543,8 @@ init_attrib_groups(struct gl_context *ctx) _mesa_init_pixelstore( ctx ); _mesa_init_point( ctx ); _mesa_init_polygon( ctx ); - _mesa_init_program( ctx ); _mesa_init_rastpos( ctx ); _mesa_init_scissor( ctx ); - _mesa_init_shader_state( ctx ); _mesa_init_stencil( ctx ); _mesa_init_transform( ctx ); _mesa_init_varray( ctx ); @@ -702,7 +577,6 @@ update_default_objects(struct gl_context *ctx) { assert(ctx); - _mesa_update_default_objects_program(ctx); _mesa_update_default_objects_texture(ctx); _mesa_update_default_objects_buffer_objects(ctx); @@ -922,12 +796,6 @@ _mesa_free_context_data( struct gl_context *ctx ) _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL); _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL); - _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL); - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); - - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); - _mesa_free_attrib_data(ctx); _mesa_free_buffer_objects(ctx); _mesa_free_lighting_data( ctx ); @@ -935,8 +803,6 @@ _mesa_free_context_data( struct gl_context *ctx ) _mesa_free_texture_data( ctx ); _mesa_free_matrix_data( ctx ); _mesa_free_viewport_data( ctx ); - _mesa_free_program_data(ctx); - _mesa_free_shader_state(ctx); _mesa_free_varray_data(ctx); _mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj); @@ -1511,113 +1377,10 @@ _mesa_set_mvp_with_dp4( struct gl_context *ctx, GLboolean _mesa_valid_to_render(struct gl_context *ctx, const char *where) { - bool vert_from_glsl_shader = false; - bool frag_from_glsl_shader = false; - /* This depends on having up to date derived state (shaders) */ if (ctx->NewState) _mesa_update_state(ctx); - if (ctx->Shader.CurrentVertexProgram) { - vert_from_glsl_shader = true; - - if (!ctx->Shader.CurrentVertexProgram->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(shader not linked)", where); - return GL_FALSE; - } -#if 0 /* not normally enabled */ - { - char errMsg[100]; - if (!_mesa_validate_shader_program(ctx, - ctx->Shader.CurrentVertexProgram, - errMsg)) { - _mesa_warning(ctx, "Shader program %u is invalid: %s", - ctx->Shader.CurrentVertexProgram->Name, errMsg); - } - } -#endif - } - - if (ctx->Shader.CurrentFragmentProgram) { - frag_from_glsl_shader = true; - - if (!ctx->Shader.CurrentFragmentProgram->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(shader not linked)", where); - return GL_FALSE; - } -#if 0 /* not normally enabled */ - { - char errMsg[100]; - if (!_mesa_validate_shader_program(ctx, - ctx->Shader.CurrentFragmentProgram, - errMsg)) { - _mesa_warning(ctx, "Shader program %u is invalid: %s", - ctx->Shader.CurrentFragmentProgram->Name, errMsg); - } - } -#endif - } - - /* Any shader stages that are not supplied by the GLSL shader and have - * assembly shaders enabled must now be validated. - */ - if (!vert_from_glsl_shader - && ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(vertex program not valid)", where); - return GL_FALSE; - } - - if (!frag_from_glsl_shader) { - if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(fragment program not valid)", where); - return GL_FALSE; - } - - /* If drawing to integer-valued color buffers, there must be an - * active fragment shader (GL_EXT_texture_integer). - */ - if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerColor) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(integer format but no fragment shader)", where); - return GL_FALSE; - } - } - -#ifdef DEBUG - if (ctx->Shader.Flags & GLSL_LOG) { - struct gl_shader_program *shProg[MESA_SHADER_TYPES]; - gl_shader_type i; - - shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram; - shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram; - - for (i = 0; i < MESA_SHADER_TYPES; i++) { - if (shProg[i] == NULL || shProg[i]->_Used - || shProg[i]->_LinkedShaders[i] == NULL) - continue; - - /* This is the first time this shader is being used. - * Append shader's constants/uniforms to log file. - * - * Only log data for the program target that matches the shader - * target. It's possible to have a program bound to the vertex - * shader target that also supplied a fragment shader. If that - * program isn't also bound to the fragment shader target we don't - * want to log its fragment data. - */ - _mesa_append_uniforms_to_file(shProg[i]->_LinkedShaders[i]); - } - - for (i = 0; i < MESA_SHADER_TYPES; i++) { - if (shProg[i] != NULL) - shProg[i]->_Used = GL_TRUE; - } - } -#endif return GL_TRUE; } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/dd.h b/reactos/dll/opengl/mesa/src/mesa/main/dd.h index ace4ef9d0e2..547b64d51bb 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/dd.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/dd.h @@ -40,11 +40,8 @@ struct gl_context; struct gl_display_list; struct gl_framebuffer; struct gl_pixelstore_attrib; -struct gl_program; struct gl_renderbuffer; struct gl_renderbuffer_attachment; -struct gl_shader; -struct gl_shader_program; struct gl_texture_image; struct gl_texture_object; @@ -391,13 +388,6 @@ struct dd_function_table { GLsizei width, GLint height, GLint depth, GLenum format, GLsizei imageSize, const GLvoid *data); - - /** - * Called by glGetCompressedTexImage. - */ - void (*GetCompressedTexImage)(struct gl_context *ctx, - struct gl_texture_image *texImage, - GLvoid *data); /*@}*/ /** @@ -488,37 +478,6 @@ struct dd_function_table { /*@}*/ - - /** - * \name Vertex/fragment program functions - */ - /*@{*/ - /** Bind a vertex/fragment program */ - void (*BindProgram)(struct gl_context *ctx, GLenum target, struct gl_program *prog); - /** Allocate a new program */ - struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target, GLuint id); - /** Delete a program */ - void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog); - - /** Query if program can be loaded onto hardware */ - GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target, - struct gl_program *prog); - - /*@}*/ - - /** - * \name GLSL shader/program functions. - */ - /*@{*/ - /** - * Called when a shader program is linked. - * - * This gives drivers an opportunity to clone the IR and make their - * own transformations on it for the purposes of code generation. - */ - GLboolean (*LinkShader)(struct gl_context *ctx, struct gl_shader_program *shader); - /*@}*/ - /** * \name State-changing functions. * @@ -694,18 +653,6 @@ struct dd_function_table { void (*BindArrayObject)(struct gl_context *ctx, struct gl_array_object *obj); /*@}*/ - /** - * \name GLSL-related functions (ARB extensions and OpenGL 2.x) - */ - /*@{*/ - struct gl_shader *(*NewShader)(struct gl_context *ctx, GLuint name, GLenum type); - void (*DeleteShader)(struct gl_context *ctx, struct gl_shader *shader); - struct gl_shader_program *(*NewShaderProgram)(struct gl_context *ctx, GLuint name); - void (*DeleteShaderProgram)(struct gl_context *ctx, - struct gl_shader_program *shProg); - void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg); - /*@}*/ - /** * \name Support for multiple T&L engines @@ -896,32 +843,6 @@ typedef struct { void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v ); void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v ); - /* GL_ARB_vertex_program */ - void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x ); - void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y ); - void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z ); - void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v ); - void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); - void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v ); - - /* GL_EXT_gpu_shader4 / GL 3.0 */ - void (GLAPIENTRYP VertexAttribI1i)( GLuint index, GLint x); - void (GLAPIENTRYP VertexAttribI2i)( GLuint index, GLint x, GLint y); - void (GLAPIENTRYP VertexAttribI3i)( GLuint index, GLint x, GLint y, GLint z); - void (GLAPIENTRYP VertexAttribI4i)( GLuint index, GLint x, GLint y, GLint z, GLint w); - void (GLAPIENTRYP VertexAttribI2iv)( GLuint index, const GLint *v); - void (GLAPIENTRYP VertexAttribI3iv)( GLuint index, const GLint *v); - void (GLAPIENTRYP VertexAttribI4iv)( GLuint index, const GLint *v); - - void (GLAPIENTRYP VertexAttribI1ui)( GLuint index, GLuint x); - void (GLAPIENTRYP VertexAttribI2ui)( GLuint index, GLuint x, GLuint y); - void (GLAPIENTRYP VertexAttribI3ui)( GLuint index, GLuint x, GLuint y, GLuint z); - void (GLAPIENTRYP VertexAttribI4ui)( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); - void (GLAPIENTRYP VertexAttribI2uiv)( GLuint index, const GLuint *v); - void (GLAPIENTRYP VertexAttribI3uiv)( GLuint index, const GLuint *v); - void (GLAPIENTRYP VertexAttribI4uiv)( GLuint index, const GLuint *v); /*@}*/ @@ -937,10 +858,6 @@ typedef struct { void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); - void (GLAPIENTRYP MultiDrawElementsEXT)( GLenum mode, const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount); /*@}*/ /** diff --git a/reactos/dll/opengl/mesa/src/mesa/main/dispatch.h b/reactos/dll/opengl/mesa/src/mesa/main/dispatch.h index 11f52ed3a3a..c2e64581332 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/dispatch.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/dispatch.h @@ -439,65 +439,12 @@ #define _gloffset_TexImage3D 371 #define _gloffset_TexSubImage3D 372 #define _gloffset_CopyTexSubImage3D 373 -#define _gloffset_ActiveTextureARB 374 -#define _gloffset_ClientActiveTextureARB 375 -#define _gloffset_MultiTexCoord1dARB 376 -#define _gloffset_MultiTexCoord1dvARB 377 -#define _gloffset_MultiTexCoord1fARB 378 -#define _gloffset_MultiTexCoord1fvARB 379 -#define _gloffset_MultiTexCoord1iARB 380 -#define _gloffset_MultiTexCoord1ivARB 381 -#define _gloffset_MultiTexCoord1sARB 382 -#define _gloffset_MultiTexCoord1svARB 383 -#define _gloffset_MultiTexCoord2dARB 384 -#define _gloffset_MultiTexCoord2dvARB 385 -#define _gloffset_MultiTexCoord2fARB 386 -#define _gloffset_MultiTexCoord2fvARB 387 -#define _gloffset_MultiTexCoord2iARB 388 -#define _gloffset_MultiTexCoord2ivARB 389 -#define _gloffset_MultiTexCoord2sARB 390 -#define _gloffset_MultiTexCoord2svARB 391 -#define _gloffset_MultiTexCoord3dARB 392 -#define _gloffset_MultiTexCoord3dvARB 393 -#define _gloffset_MultiTexCoord3fARB 394 -#define _gloffset_MultiTexCoord3fvARB 395 -#define _gloffset_MultiTexCoord3iARB 396 -#define _gloffset_MultiTexCoord3ivARB 397 -#define _gloffset_MultiTexCoord3sARB 398 -#define _gloffset_MultiTexCoord3svARB 399 -#define _gloffset_MultiTexCoord4dARB 400 -#define _gloffset_MultiTexCoord4dvARB 401 -#define _gloffset_MultiTexCoord4fARB 402 -#define _gloffset_MultiTexCoord4fvARB 403 -#define _gloffset_MultiTexCoord4iARB 404 -#define _gloffset_MultiTexCoord4ivARB 405 -#define _gloffset_MultiTexCoord4sARB 406 -#define _gloffset_MultiTexCoord4svARB 407 #if !FEATURE_remap_table -#define _gloffset_AttachShader 408 -#define _gloffset_CreateProgram 409 -#define _gloffset_CreateShader 410 -#define _gloffset_DeleteProgram 411 -#define _gloffset_DeleteShader 412 -#define _gloffset_DetachShader 413 -#define _gloffset_GetAttachedShaders 414 -#define _gloffset_GetProgramInfoLog 415 -#define _gloffset_GetProgramiv 416 -#define _gloffset_GetShaderInfoLog 417 -#define _gloffset_GetShaderiv 418 -#define _gloffset_IsProgram 419 -#define _gloffset_IsShader 420 #define _gloffset_StencilFuncSeparate 421 #define _gloffset_StencilMaskSeparate 422 #define _gloffset_StencilOpSeparate 423 -#define _gloffset_UniformMatrix2x3fv 424 -#define _gloffset_UniformMatrix2x4fv 425 -#define _gloffset_UniformMatrix3x2fv 426 -#define _gloffset_UniformMatrix3x4fv 427 -#define _gloffset_UniformMatrix4x2fv 428 -#define _gloffset_UniformMatrix4x3fv 429 #define _gloffset_GetStringi 435 #define _gloffset_GetBufferParameteri64v 438 #define _gloffset_GetInteger64i_v 439 @@ -506,63 +453,6 @@ #define _gloffset_MultTransposeMatrixdARB 443 #define _gloffset_MultTransposeMatrixfARB 444 #define _gloffset_SampleCoverageARB 445 -#define _gloffset_DisableVertexAttribArrayARB 453 -#define _gloffset_EnableVertexAttribArrayARB 454 -#define _gloffset_GetProgramEnvParameterdvARB 455 -#define _gloffset_GetProgramEnvParameterfvARB 456 -#define _gloffset_GetProgramLocalParameterdvARB 457 -#define _gloffset_GetProgramLocalParameterfvARB 458 -#define _gloffset_GetProgramStringARB 459 -#define _gloffset_GetProgramivARB 460 -#define _gloffset_GetVertexAttribdvARB 461 -#define _gloffset_GetVertexAttribfvARB 462 -#define _gloffset_GetVertexAttribivARB 463 -#define _gloffset_ProgramEnvParameter4dARB 464 -#define _gloffset_ProgramEnvParameter4dvARB 465 -#define _gloffset_ProgramEnvParameter4fARB 466 -#define _gloffset_ProgramEnvParameter4fvARB 467 -#define _gloffset_ProgramLocalParameter4dARB 468 -#define _gloffset_ProgramLocalParameter4dvARB 469 -#define _gloffset_ProgramLocalParameter4fARB 470 -#define _gloffset_ProgramLocalParameter4fvARB 471 -#define _gloffset_ProgramStringARB 472 -#define _gloffset_VertexAttrib1dARB 473 -#define _gloffset_VertexAttrib1dvARB 474 -#define _gloffset_VertexAttrib1fARB 475 -#define _gloffset_VertexAttrib1fvARB 476 -#define _gloffset_VertexAttrib1sARB 477 -#define _gloffset_VertexAttrib1svARB 478 -#define _gloffset_VertexAttrib2dARB 479 -#define _gloffset_VertexAttrib2dvARB 480 -#define _gloffset_VertexAttrib2fARB 481 -#define _gloffset_VertexAttrib2fvARB 482 -#define _gloffset_VertexAttrib2sARB 483 -#define _gloffset_VertexAttrib2svARB 484 -#define _gloffset_VertexAttrib3dARB 485 -#define _gloffset_VertexAttrib3dvARB 486 -#define _gloffset_VertexAttrib3fARB 487 -#define _gloffset_VertexAttrib3fvARB 488 -#define _gloffset_VertexAttrib3sARB 489 -#define _gloffset_VertexAttrib3svARB 490 -#define _gloffset_VertexAttrib4NbvARB 491 -#define _gloffset_VertexAttrib4NivARB 492 -#define _gloffset_VertexAttrib4NsvARB 493 -#define _gloffset_VertexAttrib4NubARB 494 -#define _gloffset_VertexAttrib4NubvARB 495 -#define _gloffset_VertexAttrib4NuivARB 496 -#define _gloffset_VertexAttrib4NusvARB 497 -#define _gloffset_VertexAttrib4bvARB 498 -#define _gloffset_VertexAttrib4dARB 499 -#define _gloffset_VertexAttrib4dvARB 500 -#define _gloffset_VertexAttrib4fARB 501 -#define _gloffset_VertexAttrib4fvARB 502 -#define _gloffset_VertexAttrib4ivARB 503 -#define _gloffset_VertexAttrib4sARB 504 -#define _gloffset_VertexAttrib4svARB 505 -#define _gloffset_VertexAttrib4ubvARB 506 -#define _gloffset_VertexAttrib4uivARB 507 -#define _gloffset_VertexAttrib4usvARB 508 -#define _gloffset_VertexAttribPointerARB 509 #define _gloffset_BindBufferARB 510 #define _gloffset_BufferDataARB 511 #define _gloffset_BufferSubDataARB 512 @@ -580,42 +470,16 @@ #define _gloffset_CreateShaderObjectARB 532 #define _gloffset_DeleteObjectARB 533 #define _gloffset_DetachObjectARB 534 -#define _gloffset_GetActiveUniformARB 535 #define _gloffset_GetAttachedObjectsARB 536 #define _gloffset_GetHandleARB 537 #define _gloffset_GetInfoLogARB 538 #define _gloffset_GetObjectParameterfvARB 539 #define _gloffset_GetObjectParameterivARB 540 #define _gloffset_GetShaderSourceARB 541 -#define _gloffset_GetUniformLocationARB 542 -#define _gloffset_GetUniformfvARB 543 -#define _gloffset_GetUniformivARB 544 #define _gloffset_LinkProgramARB 545 #define _gloffset_ShaderSourceARB 546 -#define _gloffset_Uniform1fARB 547 -#define _gloffset_Uniform1fvARB 548 -#define _gloffset_Uniform1iARB 549 -#define _gloffset_Uniform1ivARB 550 -#define _gloffset_Uniform2fARB 551 -#define _gloffset_Uniform2fvARB 552 -#define _gloffset_Uniform2iARB 553 -#define _gloffset_Uniform2ivARB 554 -#define _gloffset_Uniform3fARB 555 -#define _gloffset_Uniform3fvARB 556 -#define _gloffset_Uniform3iARB 557 -#define _gloffset_Uniform3ivARB 558 -#define _gloffset_Uniform4fARB 559 -#define _gloffset_Uniform4fvARB 560 -#define _gloffset_Uniform4iARB 561 -#define _gloffset_Uniform4ivARB 562 -#define _gloffset_UniformMatrix2fvARB 563 -#define _gloffset_UniformMatrix3fvARB 564 -#define _gloffset_UniformMatrix4fvARB 565 -#define _gloffset_UseProgramObjectARB 566 #define _gloffset_ValidateProgramARB 567 -#define _gloffset_BindAttribLocationARB 568 #define _gloffset_GetActiveAttribARB 569 -#define _gloffset_GetAttribLocationARB 570 #define _gloffset_FlushMappedBufferRange 580 #define _gloffset_MapBufferRange 581 #define _gloffset_BindVertexArray 583 @@ -634,10 +498,6 @@ #define _gloffset_GetnPolygonStippleARB 677 #define _gloffset_GetnSeparableFilterARB 678 #define _gloffset_GetnTexImageARB 679 -#define _gloffset_GetnUniformdvARB 680 -#define _gloffset_GetnUniformfvARB 681 -#define _gloffset_GetnUniformivARB 682 -#define _gloffset_GetnUniformuivARB 683 #define _gloffset_ReadnPixelsARB 684 #define _gloffset_TexStorage1D 685 #define _gloffset_TexStorage2D 686 @@ -646,12 +506,6 @@ #define _gloffset_TextureStorage2DEXT 689 #define _gloffset_TextureStorage3DEXT 690 #define _gloffset_PolygonOffsetEXT 691 -#define _gloffset_GetPixelTexGenParameterfvSGIS 692 -#define _gloffset_GetPixelTexGenParameterivSGIS 693 -#define _gloffset_PixelTexGenParameterfSGIS 694 -#define _gloffset_PixelTexGenParameterfvSGIS 695 -#define _gloffset_PixelTexGenParameteriSGIS 696 -#define _gloffset_PixelTexGenParameterivSGIS 697 #define _gloffset_SampleMaskSGIS 698 #define _gloffset_SamplePatternSGIS 699 #define _gloffset_ColorPointerEXT 700 @@ -682,7 +536,6 @@ #define _gloffset_SecondaryColor3usvEXT 725 #define _gloffset_SecondaryColorPointerEXT 726 #define _gloffset_MultiDrawArraysEXT 727 -#define _gloffset_MultiDrawElementsEXT 728 #define _gloffset_FogCoordPointerEXT 729 #define _gloffset_FogCoorddEXT 730 #define _gloffset_FogCoorddvEXT 731 @@ -739,20 +592,10 @@ #define _gloffset_SetFenceNV 783 #define _gloffset_TestFenceNV 784 #define _gloffset_AreProgramsResidentNV 785 -#define _gloffset_BindProgramNV 786 -#define _gloffset_DeleteProgramsNV 787 #define _gloffset_ExecuteProgramNV 788 -#define _gloffset_GenProgramsNV 789 #define _gloffset_GetProgramParameterdvNV 790 #define _gloffset_GetProgramParameterfvNV 791 -#define _gloffset_GetProgramStringNV 792 -#define _gloffset_GetProgramivNV 793 #define _gloffset_GetTrackMatrixivNV 794 -#define _gloffset_GetVertexAttribPointervNV 795 -#define _gloffset_GetVertexAttribdvNV 796 -#define _gloffset_GetVertexAttribfvNV 797 -#define _gloffset_GetVertexAttribivNV 798 -#define _gloffset_IsProgramNV 799 #define _gloffset_LoadProgramNV 800 #define _gloffset_ProgramParameters4dvNV 801 #define _gloffset_ProgramParameters4fvNV 802 @@ -784,7 +627,6 @@ #define _gloffset_VertexAttrib4svNV 828 #define _gloffset_VertexAttrib4ubNV 829 #define _gloffset_VertexAttrib4ubvNV 830 -#define _gloffset_VertexAttribPointerNV 831 #define _gloffset_VertexAttribs1dvNV 832 #define _gloffset_VertexAttribs1fvNV 833 #define _gloffset_VertexAttribs1svNV 834 @@ -798,10 +640,6 @@ #define _gloffset_VertexAttribs4fvNV 842 #define _gloffset_VertexAttribs4svNV 843 #define _gloffset_VertexAttribs4ubvNV 844 -#define _gloffset_GetTexBumpParameterfvATI 845 -#define _gloffset_GetTexBumpParameterivATI 846 -#define _gloffset_TexBumpParameterfvATI 847 -#define _gloffset_TexBumpParameterivATI 848 #define _gloffset_PointParameteriNV 863 #define _gloffset_PointParameterivNV 864 #define _gloffset_ActiveStencilFaceEXT 865 @@ -821,38 +659,6 @@ #define _gloffset_FlushMappedBufferRangeAPPLE 899 #define _gloffset_BindFragDataLocationEXT 900 #define _gloffset_GetFragDataLocationEXT 901 -#define _gloffset_GetUniformuivEXT 902 -#define _gloffset_GetVertexAttribIivEXT 903 -#define _gloffset_GetVertexAttribIuivEXT 904 -#define _gloffset_Uniform1uiEXT 905 -#define _gloffset_Uniform1uivEXT 906 -#define _gloffset_Uniform2uiEXT 907 -#define _gloffset_Uniform2uivEXT 908 -#define _gloffset_Uniform3uiEXT 909 -#define _gloffset_Uniform3uivEXT 910 -#define _gloffset_Uniform4uiEXT 911 -#define _gloffset_Uniform4uivEXT 912 -#define _gloffset_VertexAttribI1iEXT 913 -#define _gloffset_VertexAttribI1ivEXT 914 -#define _gloffset_VertexAttribI1uiEXT 915 -#define _gloffset_VertexAttribI1uivEXT 916 -#define _gloffset_VertexAttribI2iEXT 917 -#define _gloffset_VertexAttribI2ivEXT 918 -#define _gloffset_VertexAttribI2uiEXT 919 -#define _gloffset_VertexAttribI2uivEXT 920 -#define _gloffset_VertexAttribI3iEXT 921 -#define _gloffset_VertexAttribI3ivEXT 922 -#define _gloffset_VertexAttribI3uiEXT 923 -#define _gloffset_VertexAttribI3uivEXT 924 -#define _gloffset_VertexAttribI4bvEXT 925 -#define _gloffset_VertexAttribI4iEXT 926 -#define _gloffset_VertexAttribI4ivEXT 927 -#define _gloffset_VertexAttribI4svEXT 928 -#define _gloffset_VertexAttribI4ubvEXT 929 -#define _gloffset_VertexAttribI4uiEXT 930 -#define _gloffset_VertexAttribI4uivEXT 931 -#define _gloffset_VertexAttribI4usvEXT 932 -#define _gloffset_VertexAttribIPointerEXT 933 #define _gloffset_ClearColorIiEXT 941 #define _gloffset_ClearColorIuiEXT 942 #define _gloffset_GetTexParameterIivEXT 943 @@ -864,41 +670,18 @@ #define _gloffset_GetObjectParameterivAPPLE 959 #define _gloffset_ObjectPurgeableAPPLE 960 #define _gloffset_ObjectUnpurgeableAPPLE 961 -#define _gloffset_ActiveProgramEXT 962 #define _gloffset_CreateShaderProgramEXT 963 -#define _gloffset_UseShaderProgramEXT 964 #define _gloffset_TextureBarrierNV 965 #define _gloffset_StencilFuncSeparateATI 966 -#define _gloffset_ProgramEnvParameters4fvEXT 967 -#define _gloffset_ProgramLocalParameters4fvEXT 968 #else /* !FEATURE_remap_table */ #define driDispatchRemapTable_size 565 extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; -#define AttachShader_remap_index 0 -#define CreateProgram_remap_index 1 -#define CreateShader_remap_index 2 -#define DeleteProgram_remap_index 3 -#define DeleteShader_remap_index 4 -#define DetachShader_remap_index 5 -#define GetAttachedShaders_remap_index 6 -#define GetProgramInfoLog_remap_index 7 -#define GetProgramiv_remap_index 8 -#define GetShaderInfoLog_remap_index 9 -#define GetShaderiv_remap_index 10 -#define IsProgram_remap_index 11 -#define IsShader_remap_index 12 #define StencilFuncSeparate_remap_index 13 #define StencilMaskSeparate_remap_index 14 #define StencilOpSeparate_remap_index 15 -#define UniformMatrix2x3fv_remap_index 16 -#define UniformMatrix2x4fv_remap_index 17 -#define UniformMatrix3x2fv_remap_index 18 -#define UniformMatrix3x4fv_remap_index 19 -#define UniformMatrix4x2fv_remap_index 20 -#define UniformMatrix4x3fv_remap_index 21 #define GetStringi_remap_index 27 #define TexBuffer_remap_index 28 #define GetBufferParameteri64v_remap_index 30 @@ -909,63 +692,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define MultTransposeMatrixdARB_remap_index 35 #define MultTransposeMatrixfARB_remap_index 36 #define SampleCoverageARB_remap_index 37 -#define DisableVertexAttribArrayARB_remap_index 45 -#define EnableVertexAttribArrayARB_remap_index 46 -#define GetProgramEnvParameterdvARB_remap_index 47 -#define GetProgramEnvParameterfvARB_remap_index 48 -#define GetProgramLocalParameterdvARB_remap_index 49 -#define GetProgramLocalParameterfvARB_remap_index 50 -#define GetProgramStringARB_remap_index 51 -#define GetProgramivARB_remap_index 52 -#define GetVertexAttribdvARB_remap_index 53 -#define GetVertexAttribfvARB_remap_index 54 -#define GetVertexAttribivARB_remap_index 55 -#define ProgramEnvParameter4dARB_remap_index 56 -#define ProgramEnvParameter4dvARB_remap_index 57 -#define ProgramEnvParameter4fARB_remap_index 58 -#define ProgramEnvParameter4fvARB_remap_index 59 -#define ProgramLocalParameter4dARB_remap_index 60 -#define ProgramLocalParameter4dvARB_remap_index 61 -#define ProgramLocalParameter4fARB_remap_index 62 -#define ProgramLocalParameter4fvARB_remap_index 63 -#define ProgramStringARB_remap_index 64 -#define VertexAttrib1dARB_remap_index 65 -#define VertexAttrib1dvARB_remap_index 66 -#define VertexAttrib1fARB_remap_index 67 -#define VertexAttrib1fvARB_remap_index 68 -#define VertexAttrib1sARB_remap_index 69 -#define VertexAttrib1svARB_remap_index 70 -#define VertexAttrib2dARB_remap_index 71 -#define VertexAttrib2dvARB_remap_index 72 -#define VertexAttrib2fARB_remap_index 73 -#define VertexAttrib2fvARB_remap_index 74 -#define VertexAttrib2sARB_remap_index 75 -#define VertexAttrib2svARB_remap_index 76 -#define VertexAttrib3dARB_remap_index 77 -#define VertexAttrib3dvARB_remap_index 78 -#define VertexAttrib3fARB_remap_index 79 -#define VertexAttrib3fvARB_remap_index 80 -#define VertexAttrib3sARB_remap_index 81 -#define VertexAttrib3svARB_remap_index 82 -#define VertexAttrib4NbvARB_remap_index 83 -#define VertexAttrib4NivARB_remap_index 84 -#define VertexAttrib4NsvARB_remap_index 85 -#define VertexAttrib4NubARB_remap_index 86 -#define VertexAttrib4NubvARB_remap_index 87 -#define VertexAttrib4NuivARB_remap_index 88 -#define VertexAttrib4NusvARB_remap_index 89 -#define VertexAttrib4bvARB_remap_index 90 -#define VertexAttrib4dARB_remap_index 91 -#define VertexAttrib4dvARB_remap_index 92 -#define VertexAttrib4fARB_remap_index 93 -#define VertexAttrib4fvARB_remap_index 94 -#define VertexAttrib4ivARB_remap_index 95 -#define VertexAttrib4sARB_remap_index 96 -#define VertexAttrib4svARB_remap_index 97 -#define VertexAttrib4ubvARB_remap_index 98 -#define VertexAttrib4uivARB_remap_index 99 -#define VertexAttrib4usvARB_remap_index 100 -#define VertexAttribPointerARB_remap_index 101 #define BindBufferARB_remap_index 102 #define BufferDataARB_remap_index 103 #define BufferSubDataARB_remap_index 104 @@ -983,42 +709,16 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define CreateShaderObjectARB_remap_index 124 #define DeleteObjectARB_remap_index 125 #define DetachObjectARB_remap_index 126 -#define GetActiveUniformARB_remap_index 127 #define GetAttachedObjectsARB_remap_index 128 #define GetHandleARB_remap_index 129 #define GetInfoLogARB_remap_index 130 #define GetObjectParameterfvARB_remap_index 131 #define GetObjectParameterivARB_remap_index 132 #define GetShaderSourceARB_remap_index 133 -#define GetUniformLocationARB_remap_index 134 -#define GetUniformfvARB_remap_index 135 -#define GetUniformivARB_remap_index 136 #define LinkProgramARB_remap_index 137 #define ShaderSourceARB_remap_index 138 -#define Uniform1fARB_remap_index 139 -#define Uniform1fvARB_remap_index 140 -#define Uniform1iARB_remap_index 141 -#define Uniform1ivARB_remap_index 142 -#define Uniform2fARB_remap_index 143 -#define Uniform2fvARB_remap_index 144 -#define Uniform2iARB_remap_index 145 -#define Uniform2ivARB_remap_index 146 -#define Uniform3fARB_remap_index 147 -#define Uniform3fvARB_remap_index 148 -#define Uniform3iARB_remap_index 149 -#define Uniform3ivARB_remap_index 150 -#define Uniform4fARB_remap_index 151 -#define Uniform4fvARB_remap_index 152 -#define Uniform4iARB_remap_index 153 -#define Uniform4ivARB_remap_index 154 -#define UniformMatrix2fvARB_remap_index 155 -#define UniformMatrix3fvARB_remap_index 156 -#define UniformMatrix4fvARB_remap_index 157 -#define UseProgramObjectARB_remap_index 158 #define ValidateProgramARB_remap_index 159 -#define BindAttribLocationARB_remap_index 160 #define GetActiveAttribARB_remap_index 161 -#define GetAttribLocationARB_remap_index 162 #define VertexAttribDivisorARB_remap_index 171 #define FlushMappedBufferRange_remap_index 172 #define MapBufferRange_remap_index 173 @@ -1038,10 +738,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define GetnPolygonStippleARB_remap_index 269 #define GetnSeparableFilterARB_remap_index 270 #define GetnTexImageARB_remap_index 271 -#define GetnUniformdvARB_remap_index 272 -#define GetnUniformfvARB_remap_index 273 -#define GetnUniformivARB_remap_index 274 -#define GetnUniformuivARB_remap_index 275 #define ReadnPixelsARB_remap_index 276 #define TexStorage1D_remap_index 277 #define TexStorage2D_remap_index 278 @@ -1050,12 +746,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define TextureStorage2DEXT_remap_index 281 #define TextureStorage3DEXT_remap_index 282 #define PolygonOffsetEXT_remap_index 283 -#define GetPixelTexGenParameterfvSGIS_remap_index 284 -#define GetPixelTexGenParameterivSGIS_remap_index 285 -#define PixelTexGenParameterfSGIS_remap_index 286 -#define PixelTexGenParameterfvSGIS_remap_index 287 -#define PixelTexGenParameteriSGIS_remap_index 288 -#define PixelTexGenParameterivSGIS_remap_index 289 #define SampleMaskSGIS_remap_index 290 #define SamplePatternSGIS_remap_index 291 #define ColorPointerEXT_remap_index 292 @@ -1086,7 +776,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define SecondaryColor3usvEXT_remap_index 317 #define SecondaryColorPointerEXT_remap_index 318 #define MultiDrawArraysEXT_remap_index 319 -#define MultiDrawElementsEXT_remap_index 320 #define FogCoordPointerEXT_remap_index 321 #define FogCoorddEXT_remap_index 322 #define FogCoorddvEXT_remap_index 323 @@ -1143,20 +832,10 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define SetFenceNV_remap_index 375 #define TestFenceNV_remap_index 376 #define AreProgramsResidentNV_remap_index 377 -#define BindProgramNV_remap_index 378 -#define DeleteProgramsNV_remap_index 379 #define ExecuteProgramNV_remap_index 380 -#define GenProgramsNV_remap_index 381 #define GetProgramParameterdvNV_remap_index 382 #define GetProgramParameterfvNV_remap_index 383 -#define GetProgramStringNV_remap_index 384 -#define GetProgramivNV_remap_index 385 #define GetTrackMatrixivNV_remap_index 386 -#define GetVertexAttribPointervNV_remap_index 387 -#define GetVertexAttribdvNV_remap_index 388 -#define GetVertexAttribfvNV_remap_index 389 -#define GetVertexAttribivNV_remap_index 390 -#define IsProgramNV_remap_index 391 #define LoadProgramNV_remap_index 392 #define ProgramParameters4dvNV_remap_index 393 #define ProgramParameters4fvNV_remap_index 394 @@ -1188,7 +867,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define VertexAttrib4svNV_remap_index 420 #define VertexAttrib4ubNV_remap_index 421 #define VertexAttrib4ubvNV_remap_index 422 -#define VertexAttribPointerNV_remap_index 423 #define VertexAttribs1dvNV_remap_index 424 #define VertexAttribs1fvNV_remap_index 425 #define VertexAttribs1svNV_remap_index 426 @@ -1202,10 +880,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define VertexAttribs4fvNV_remap_index 434 #define VertexAttribs4svNV_remap_index 435 #define VertexAttribs4ubvNV_remap_index 436 -#define GetTexBumpParameterfvATI_remap_index 437 -#define GetTexBumpParameterivATI_remap_index 438 -#define TexBumpParameterfvATI_remap_index 439 -#define TexBumpParameterivATI_remap_index 440 #define PointParameteriNV_remap_index 455 #define PointParameterivNV_remap_index 456 #define ActiveStencilFaceEXT_remap_index 457 @@ -1225,38 +899,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define FlushMappedBufferRangeAPPLE_remap_index 491 #define BindFragDataLocationEXT_remap_index 492 #define GetFragDataLocationEXT_remap_index 493 -#define GetUniformuivEXT_remap_index 494 -#define GetVertexAttribIivEXT_remap_index 495 -#define GetVertexAttribIuivEXT_remap_index 496 -#define Uniform1uiEXT_remap_index 497 -#define Uniform1uivEXT_remap_index 498 -#define Uniform2uiEXT_remap_index 499 -#define Uniform2uivEXT_remap_index 500 -#define Uniform3uiEXT_remap_index 501 -#define Uniform3uivEXT_remap_index 502 -#define Uniform4uiEXT_remap_index 503 -#define Uniform4uivEXT_remap_index 504 -#define VertexAttribI1iEXT_remap_index 505 -#define VertexAttribI1ivEXT_remap_index 506 -#define VertexAttribI1uiEXT_remap_index 507 -#define VertexAttribI1uivEXT_remap_index 508 -#define VertexAttribI2iEXT_remap_index 509 -#define VertexAttribI2ivEXT_remap_index 510 -#define VertexAttribI2uiEXT_remap_index 511 -#define VertexAttribI2uivEXT_remap_index 512 -#define VertexAttribI3iEXT_remap_index 513 -#define VertexAttribI3ivEXT_remap_index 514 -#define VertexAttribI3uiEXT_remap_index 515 -#define VertexAttribI3uivEXT_remap_index 516 -#define VertexAttribI4bvEXT_remap_index 517 -#define VertexAttribI4iEXT_remap_index 518 -#define VertexAttribI4ivEXT_remap_index 519 -#define VertexAttribI4svEXT_remap_index 520 -#define VertexAttribI4ubvEXT_remap_index 521 -#define VertexAttribI4uiEXT_remap_index 522 -#define VertexAttribI4uivEXT_remap_index 523 -#define VertexAttribI4usvEXT_remap_index 524 -#define VertexAttribIPointerEXT_remap_index 525 #define ClearColorIiEXT_remap_index 533 #define ClearColorIuiEXT_remap_index 534 #define GetTexParameterIivEXT_remap_index 535 @@ -1268,36 +910,13 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define GetObjectParameterivAPPLE_remap_index 551 #define ObjectPurgeableAPPLE_remap_index 552 #define ObjectUnpurgeableAPPLE_remap_index 553 -#define ActiveProgramEXT_remap_index 554 #define CreateShaderProgramEXT_remap_index 555 -#define UseShaderProgramEXT_remap_index 556 #define TextureBarrierNV_remap_index 557 #define StencilFuncSeparateATI_remap_index 558 -#define ProgramEnvParameters4fvEXT_remap_index 559 -#define ProgramLocalParameters4fvEXT_remap_index 560 -#define _gloffset_AttachShader driDispatchRemapTable[AttachShader_remap_index] -#define _gloffset_CreateProgram driDispatchRemapTable[CreateProgram_remap_index] -#define _gloffset_CreateShader driDispatchRemapTable[CreateShader_remap_index] -#define _gloffset_DeleteProgram driDispatchRemapTable[DeleteProgram_remap_index] -#define _gloffset_DeleteShader driDispatchRemapTable[DeleteShader_remap_index] -#define _gloffset_DetachShader driDispatchRemapTable[DetachShader_remap_index] -#define _gloffset_GetAttachedShaders driDispatchRemapTable[GetAttachedShaders_remap_index] -#define _gloffset_GetProgramInfoLog driDispatchRemapTable[GetProgramInfoLog_remap_index] -#define _gloffset_GetProgramiv driDispatchRemapTable[GetProgramiv_remap_index] -#define _gloffset_GetShaderInfoLog driDispatchRemapTable[GetShaderInfoLog_remap_index] -#define _gloffset_GetShaderiv driDispatchRemapTable[GetShaderiv_remap_index] -#define _gloffset_IsProgram driDispatchRemapTable[IsProgram_remap_index] -#define _gloffset_IsShader driDispatchRemapTable[IsShader_remap_index] #define _gloffset_StencilFuncSeparate driDispatchRemapTable[StencilFuncSeparate_remap_index] #define _gloffset_StencilMaskSeparate driDispatchRemapTable[StencilMaskSeparate_remap_index] #define _gloffset_StencilOpSeparate driDispatchRemapTable[StencilOpSeparate_remap_index] -#define _gloffset_UniformMatrix2x3fv driDispatchRemapTable[UniformMatrix2x3fv_remap_index] -#define _gloffset_UniformMatrix2x4fv driDispatchRemapTable[UniformMatrix2x4fv_remap_index] -#define _gloffset_UniformMatrix3x2fv driDispatchRemapTable[UniformMatrix3x2fv_remap_index] -#define _gloffset_UniformMatrix3x4fv driDispatchRemapTable[UniformMatrix3x4fv_remap_index] -#define _gloffset_UniformMatrix4x2fv driDispatchRemapTable[UniformMatrix4x2fv_remap_index] -#define _gloffset_UniformMatrix4x3fv driDispatchRemapTable[UniformMatrix4x3fv_remap_index] #define _gloffset_GetStringi driDispatchRemapTable[GetStringi_remap_index] #define _gloffset_GetBufferParameteri64v driDispatchRemapTable[GetBufferParameteri64v_remap_index] #define _gloffset_GetInteger64i_v driDispatchRemapTable[GetInteger64i_v_remap_index] @@ -1306,63 +925,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_MultTransposeMatrixdARB driDispatchRemapTable[MultTransposeMatrixdARB_remap_index] #define _gloffset_MultTransposeMatrixfARB driDispatchRemapTable[MultTransposeMatrixfARB_remap_index] #define _gloffset_SampleCoverageARB driDispatchRemapTable[SampleCoverageARB_remap_index] -#define _gloffset_DisableVertexAttribArrayARB driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index] -#define _gloffset_EnableVertexAttribArrayARB driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index] -#define _gloffset_GetProgramEnvParameterdvARB driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index] -#define _gloffset_GetProgramEnvParameterfvARB driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index] -#define _gloffset_GetProgramLocalParameterdvARB driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index] -#define _gloffset_GetProgramLocalParameterfvARB driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index] -#define _gloffset_GetProgramStringARB driDispatchRemapTable[GetProgramStringARB_remap_index] -#define _gloffset_GetProgramivARB driDispatchRemapTable[GetProgramivARB_remap_index] -#define _gloffset_GetVertexAttribdvARB driDispatchRemapTable[GetVertexAttribdvARB_remap_index] -#define _gloffset_GetVertexAttribfvARB driDispatchRemapTable[GetVertexAttribfvARB_remap_index] -#define _gloffset_GetVertexAttribivARB driDispatchRemapTable[GetVertexAttribivARB_remap_index] -#define _gloffset_ProgramEnvParameter4dARB driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index] -#define _gloffset_ProgramEnvParameter4dvARB driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index] -#define _gloffset_ProgramEnvParameter4fARB driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index] -#define _gloffset_ProgramEnvParameter4fvARB driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index] -#define _gloffset_ProgramLocalParameter4dARB driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index] -#define _gloffset_ProgramLocalParameter4dvARB driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index] -#define _gloffset_ProgramLocalParameter4fARB driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index] -#define _gloffset_ProgramLocalParameter4fvARB driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index] -#define _gloffset_ProgramStringARB driDispatchRemapTable[ProgramStringARB_remap_index] -#define _gloffset_VertexAttrib1dARB driDispatchRemapTable[VertexAttrib1dARB_remap_index] -#define _gloffset_VertexAttrib1dvARB driDispatchRemapTable[VertexAttrib1dvARB_remap_index] -#define _gloffset_VertexAttrib1fARB driDispatchRemapTable[VertexAttrib1fARB_remap_index] -#define _gloffset_VertexAttrib1fvARB driDispatchRemapTable[VertexAttrib1fvARB_remap_index] -#define _gloffset_VertexAttrib1sARB driDispatchRemapTable[VertexAttrib1sARB_remap_index] -#define _gloffset_VertexAttrib1svARB driDispatchRemapTable[VertexAttrib1svARB_remap_index] -#define _gloffset_VertexAttrib2dARB driDispatchRemapTable[VertexAttrib2dARB_remap_index] -#define _gloffset_VertexAttrib2dvARB driDispatchRemapTable[VertexAttrib2dvARB_remap_index] -#define _gloffset_VertexAttrib2fARB driDispatchRemapTable[VertexAttrib2fARB_remap_index] -#define _gloffset_VertexAttrib2fvARB driDispatchRemapTable[VertexAttrib2fvARB_remap_index] -#define _gloffset_VertexAttrib2sARB driDispatchRemapTable[VertexAttrib2sARB_remap_index] -#define _gloffset_VertexAttrib2svARB driDispatchRemapTable[VertexAttrib2svARB_remap_index] -#define _gloffset_VertexAttrib3dARB driDispatchRemapTable[VertexAttrib3dARB_remap_index] -#define _gloffset_VertexAttrib3dvARB driDispatchRemapTable[VertexAttrib3dvARB_remap_index] -#define _gloffset_VertexAttrib3fARB driDispatchRemapTable[VertexAttrib3fARB_remap_index] -#define _gloffset_VertexAttrib3fvARB driDispatchRemapTable[VertexAttrib3fvARB_remap_index] -#define _gloffset_VertexAttrib3sARB driDispatchRemapTable[VertexAttrib3sARB_remap_index] -#define _gloffset_VertexAttrib3svARB driDispatchRemapTable[VertexAttrib3svARB_remap_index] -#define _gloffset_VertexAttrib4NbvARB driDispatchRemapTable[VertexAttrib4NbvARB_remap_index] -#define _gloffset_VertexAttrib4NivARB driDispatchRemapTable[VertexAttrib4NivARB_remap_index] -#define _gloffset_VertexAttrib4NsvARB driDispatchRemapTable[VertexAttrib4NsvARB_remap_index] -#define _gloffset_VertexAttrib4NubARB driDispatchRemapTable[VertexAttrib4NubARB_remap_index] -#define _gloffset_VertexAttrib4NubvARB driDispatchRemapTable[VertexAttrib4NubvARB_remap_index] -#define _gloffset_VertexAttrib4NuivARB driDispatchRemapTable[VertexAttrib4NuivARB_remap_index] -#define _gloffset_VertexAttrib4NusvARB driDispatchRemapTable[VertexAttrib4NusvARB_remap_index] -#define _gloffset_VertexAttrib4bvARB driDispatchRemapTable[VertexAttrib4bvARB_remap_index] -#define _gloffset_VertexAttrib4dARB driDispatchRemapTable[VertexAttrib4dARB_remap_index] -#define _gloffset_VertexAttrib4dvARB driDispatchRemapTable[VertexAttrib4dvARB_remap_index] -#define _gloffset_VertexAttrib4fARB driDispatchRemapTable[VertexAttrib4fARB_remap_index] -#define _gloffset_VertexAttrib4fvARB driDispatchRemapTable[VertexAttrib4fvARB_remap_index] -#define _gloffset_VertexAttrib4ivARB driDispatchRemapTable[VertexAttrib4ivARB_remap_index] -#define _gloffset_VertexAttrib4sARB driDispatchRemapTable[VertexAttrib4sARB_remap_index] -#define _gloffset_VertexAttrib4svARB driDispatchRemapTable[VertexAttrib4svARB_remap_index] -#define _gloffset_VertexAttrib4ubvARB driDispatchRemapTable[VertexAttrib4ubvARB_remap_index] -#define _gloffset_VertexAttrib4uivARB driDispatchRemapTable[VertexAttrib4uivARB_remap_index] -#define _gloffset_VertexAttrib4usvARB driDispatchRemapTable[VertexAttrib4usvARB_remap_index] -#define _gloffset_VertexAttribPointerARB driDispatchRemapTable[VertexAttribPointerARB_remap_index] #define _gloffset_BindBufferARB driDispatchRemapTable[BindBufferARB_remap_index] #define _gloffset_BufferDataARB driDispatchRemapTable[BufferDataARB_remap_index] #define _gloffset_BufferSubDataARB driDispatchRemapTable[BufferSubDataARB_remap_index] @@ -1380,40 +942,15 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_CreateShaderObjectARB driDispatchRemapTable[CreateShaderObjectARB_remap_index] #define _gloffset_DeleteObjectARB driDispatchRemapTable[DeleteObjectARB_remap_index] #define _gloffset_DetachObjectARB driDispatchRemapTable[DetachObjectARB_remap_index] -#define _gloffset_GetActiveUniformARB driDispatchRemapTable[GetActiveUniformARB_remap_index] #define _gloffset_GetAttachedObjectsARB driDispatchRemapTable[GetAttachedObjectsARB_remap_index] #define _gloffset_GetHandleARB driDispatchRemapTable[GetHandleARB_remap_index] #define _gloffset_GetInfoLogARB driDispatchRemapTable[GetInfoLogARB_remap_index] #define _gloffset_GetObjectParameterfvARB driDispatchRemapTable[GetObjectParameterfvARB_remap_index] #define _gloffset_GetObjectParameterivARB driDispatchRemapTable[GetObjectParameterivARB_remap_index] #define _gloffset_GetShaderSourceARB driDispatchRemapTable[GetShaderSourceARB_remap_index] -#define _gloffset_GetUniformLocationARB driDispatchRemapTable[GetUniformLocationARB_remap_index] -#define _gloffset_GetUniformfvARB driDispatchRemapTable[GetUniformfvARB_remap_index] -#define _gloffset_GetUniformivARB driDispatchRemapTable[GetUniformivARB_remap_index] #define _gloffset_LinkProgramARB driDispatchRemapTable[LinkProgramARB_remap_index] #define _gloffset_ShaderSourceARB driDispatchRemapTable[ShaderSourceARB_remap_index] -#define _gloffset_Uniform1fARB driDispatchRemapTable[Uniform1fARB_remap_index] -#define _gloffset_Uniform1fvARB driDispatchRemapTable[Uniform1fvARB_remap_index] -#define _gloffset_Uniform1iARB driDispatchRemapTable[Uniform1iARB_remap_index] -#define _gloffset_Uniform1ivARB driDispatchRemapTable[Uniform1ivARB_remap_index] -#define _gloffset_Uniform2fARB driDispatchRemapTable[Uniform2fARB_remap_index] -#define _gloffset_Uniform2fvARB driDispatchRemapTable[Uniform2fvARB_remap_index] -#define _gloffset_Uniform2iARB driDispatchRemapTable[Uniform2iARB_remap_index] -#define _gloffset_Uniform2ivARB driDispatchRemapTable[Uniform2ivARB_remap_index] -#define _gloffset_Uniform3fARB driDispatchRemapTable[Uniform3fARB_remap_index] -#define _gloffset_Uniform3fvARB driDispatchRemapTable[Uniform3fvARB_remap_index] -#define _gloffset_Uniform3iARB driDispatchRemapTable[Uniform3iARB_remap_index] -#define _gloffset_Uniform3ivARB driDispatchRemapTable[Uniform3ivARB_remap_index] -#define _gloffset_Uniform4fARB driDispatchRemapTable[Uniform4fARB_remap_index] -#define _gloffset_Uniform4fvARB driDispatchRemapTable[Uniform4fvARB_remap_index] -#define _gloffset_Uniform4iARB driDispatchRemapTable[Uniform4iARB_remap_index] -#define _gloffset_Uniform4ivARB driDispatchRemapTable[Uniform4ivARB_remap_index] -#define _gloffset_UniformMatrix2fvARB driDispatchRemapTable[UniformMatrix2fvARB_remap_index] -#define _gloffset_UniformMatrix3fvARB driDispatchRemapTable[UniformMatrix3fvARB_remap_index] -#define _gloffset_UniformMatrix4fvARB driDispatchRemapTable[UniformMatrix4fvARB_remap_index] -#define _gloffset_UseProgramObjectARB driDispatchRemapTable[UseProgramObjectARB_remap_index] #define _gloffset_ValidateProgramARB driDispatchRemapTable[ValidateProgramARB_remap_index] -#define _gloffset_BindAttribLocationARB driDispatchRemapTable[BindAttribLocationARB_remap_index] #define _gloffset_GetActiveAttribARB driDispatchRemapTable[GetActiveAttribARB_remap_index] #define _gloffset_GetAttribLocationARB driDispatchRemapTable[GetAttribLocationARB_remap_index] #define _gloffset_FlushMappedBufferRange driDispatchRemapTable[FlushMappedBufferRange_remap_index] @@ -1434,10 +971,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_GetnPolygonStippleARB driDispatchRemapTable[GetnPolygonStippleARB_remap_index] #define _gloffset_GetnSeparableFilterARB driDispatchRemapTable[GetnSeparableFilterARB_remap_index] #define _gloffset_GetnTexImageARB driDispatchRemapTable[GetnTexImageARB_remap_index] -#define _gloffset_GetnUniformdvARB driDispatchRemapTable[GetnUniformdvARB_remap_index] -#define _gloffset_GetnUniformfvARB driDispatchRemapTable[GetnUniformfvARB_remap_index] -#define _gloffset_GetnUniformivARB driDispatchRemapTable[GetnUniformivARB_remap_index] -#define _gloffset_GetnUniformuivARB driDispatchRemapTable[GetnUniformuivARB_remap_index] #define _gloffset_ReadnPixelsARB driDispatchRemapTable[ReadnPixelsARB_remap_index] #define _gloffset_TexStorage1D driDispatchRemapTable[TexStorage1D_remap_index] #define _gloffset_TexStorage2D driDispatchRemapTable[TexStorage2D_remap_index] @@ -1446,12 +979,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_TextureStorage2DEXT driDispatchRemapTable[TextureStorage2DEXT_remap_index] #define _gloffset_TextureStorage3DEXT driDispatchRemapTable[TextureStorage3DEXT_remap_index] #define _gloffset_PolygonOffsetEXT driDispatchRemapTable[PolygonOffsetEXT_remap_index] -#define _gloffset_GetPixelTexGenParameterfvSGIS driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index] -#define _gloffset_GetPixelTexGenParameterivSGIS driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index] -#define _gloffset_PixelTexGenParameterfSGIS driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index] -#define _gloffset_PixelTexGenParameterfvSGIS driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index] -#define _gloffset_PixelTexGenParameteriSGIS driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index] -#define _gloffset_PixelTexGenParameterivSGIS driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index] #define _gloffset_SampleMaskSGIS driDispatchRemapTable[SampleMaskSGIS_remap_index] #define _gloffset_SamplePatternSGIS driDispatchRemapTable[SamplePatternSGIS_remap_index] #define _gloffset_ColorPointerEXT driDispatchRemapTable[ColorPointerEXT_remap_index] @@ -1482,7 +1009,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_SecondaryColor3usvEXT driDispatchRemapTable[SecondaryColor3usvEXT_remap_index] #define _gloffset_SecondaryColorPointerEXT driDispatchRemapTable[SecondaryColorPointerEXT_remap_index] #define _gloffset_MultiDrawArraysEXT driDispatchRemapTable[MultiDrawArraysEXT_remap_index] -#define _gloffset_MultiDrawElementsEXT driDispatchRemapTable[MultiDrawElementsEXT_remap_index] #define _gloffset_FogCoordPointerEXT driDispatchRemapTable[FogCoordPointerEXT_remap_index] #define _gloffset_FogCoorddEXT driDispatchRemapTable[FogCoorddEXT_remap_index] #define _gloffset_FogCoorddvEXT driDispatchRemapTable[FogCoorddvEXT_remap_index] @@ -1539,20 +1065,10 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_SetFenceNV driDispatchRemapTable[SetFenceNV_remap_index] #define _gloffset_TestFenceNV driDispatchRemapTable[TestFenceNV_remap_index] #define _gloffset_AreProgramsResidentNV driDispatchRemapTable[AreProgramsResidentNV_remap_index] -#define _gloffset_BindProgramNV driDispatchRemapTable[BindProgramNV_remap_index] -#define _gloffset_DeleteProgramsNV driDispatchRemapTable[DeleteProgramsNV_remap_index] #define _gloffset_ExecuteProgramNV driDispatchRemapTable[ExecuteProgramNV_remap_index] -#define _gloffset_GenProgramsNV driDispatchRemapTable[GenProgramsNV_remap_index] #define _gloffset_GetProgramParameterdvNV driDispatchRemapTable[GetProgramParameterdvNV_remap_index] #define _gloffset_GetProgramParameterfvNV driDispatchRemapTable[GetProgramParameterfvNV_remap_index] -#define _gloffset_GetProgramStringNV driDispatchRemapTable[GetProgramStringNV_remap_index] -#define _gloffset_GetProgramivNV driDispatchRemapTable[GetProgramivNV_remap_index] #define _gloffset_GetTrackMatrixivNV driDispatchRemapTable[GetTrackMatrixivNV_remap_index] -#define _gloffset_GetVertexAttribPointervNV driDispatchRemapTable[GetVertexAttribPointervNV_remap_index] -#define _gloffset_GetVertexAttribdvNV driDispatchRemapTable[GetVertexAttribdvNV_remap_index] -#define _gloffset_GetVertexAttribfvNV driDispatchRemapTable[GetVertexAttribfvNV_remap_index] -#define _gloffset_GetVertexAttribivNV driDispatchRemapTable[GetVertexAttribivNV_remap_index] -#define _gloffset_IsProgramNV driDispatchRemapTable[IsProgramNV_remap_index] #define _gloffset_LoadProgramNV driDispatchRemapTable[LoadProgramNV_remap_index] #define _gloffset_ProgramParameters4dvNV driDispatchRemapTable[ProgramParameters4dvNV_remap_index] #define _gloffset_ProgramParameters4fvNV driDispatchRemapTable[ProgramParameters4fvNV_remap_index] @@ -1584,7 +1100,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_VertexAttrib4svNV driDispatchRemapTable[VertexAttrib4svNV_remap_index] #define _gloffset_VertexAttrib4ubNV driDispatchRemapTable[VertexAttrib4ubNV_remap_index] #define _gloffset_VertexAttrib4ubvNV driDispatchRemapTable[VertexAttrib4ubvNV_remap_index] -#define _gloffset_VertexAttribPointerNV driDispatchRemapTable[VertexAttribPointerNV_remap_index] #define _gloffset_VertexAttribs1dvNV driDispatchRemapTable[VertexAttribs1dvNV_remap_index] #define _gloffset_VertexAttribs1fvNV driDispatchRemapTable[VertexAttribs1fvNV_remap_index] #define _gloffset_VertexAttribs1svNV driDispatchRemapTable[VertexAttribs1svNV_remap_index] @@ -1598,10 +1113,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_VertexAttribs4fvNV driDispatchRemapTable[VertexAttribs4fvNV_remap_index] #define _gloffset_VertexAttribs4svNV driDispatchRemapTable[VertexAttribs4svNV_remap_index] #define _gloffset_VertexAttribs4ubvNV driDispatchRemapTable[VertexAttribs4ubvNV_remap_index] -#define _gloffset_GetTexBumpParameterfvATI driDispatchRemapTable[GetTexBumpParameterfvATI_remap_index] -#define _gloffset_GetTexBumpParameterivATI driDispatchRemapTable[GetTexBumpParameterivATI_remap_index] -#define _gloffset_TexBumpParameterfvATI driDispatchRemapTable[TexBumpParameterfvATI_remap_index] -#define _gloffset_TexBumpParameterivATI driDispatchRemapTable[TexBumpParameterivATI_remap_index] #define _gloffset_PointParameteriNV driDispatchRemapTable[PointParameteriNV_remap_index] #define _gloffset_PointParameterivNV driDispatchRemapTable[PointParameterivNV_remap_index] #define _gloffset_ActiveStencilFaceEXT driDispatchRemapTable[ActiveStencilFaceEXT_remap_index] @@ -1621,38 +1132,6 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_FlushMappedBufferRangeAPPLE driDispatchRemapTable[FlushMappedBufferRangeAPPLE_remap_index] #define _gloffset_BindFragDataLocationEXT driDispatchRemapTable[BindFragDataLocationEXT_remap_index] #define _gloffset_GetFragDataLocationEXT driDispatchRemapTable[GetFragDataLocationEXT_remap_index] -#define _gloffset_GetUniformuivEXT driDispatchRemapTable[GetUniformuivEXT_remap_index] -#define _gloffset_GetVertexAttribIivEXT driDispatchRemapTable[GetVertexAttribIivEXT_remap_index] -#define _gloffset_GetVertexAttribIuivEXT driDispatchRemapTable[GetVertexAttribIuivEXT_remap_index] -#define _gloffset_Uniform1uiEXT driDispatchRemapTable[Uniform1uiEXT_remap_index] -#define _gloffset_Uniform1uivEXT driDispatchRemapTable[Uniform1uivEXT_remap_index] -#define _gloffset_Uniform2uiEXT driDispatchRemapTable[Uniform2uiEXT_remap_index] -#define _gloffset_Uniform2uivEXT driDispatchRemapTable[Uniform2uivEXT_remap_index] -#define _gloffset_Uniform3uiEXT driDispatchRemapTable[Uniform3uiEXT_remap_index] -#define _gloffset_Uniform3uivEXT driDispatchRemapTable[Uniform3uivEXT_remap_index] -#define _gloffset_Uniform4uiEXT driDispatchRemapTable[Uniform4uiEXT_remap_index] -#define _gloffset_Uniform4uivEXT driDispatchRemapTable[Uniform4uivEXT_remap_index] -#define _gloffset_VertexAttribI1iEXT driDispatchRemapTable[VertexAttribI1iEXT_remap_index] -#define _gloffset_VertexAttribI1ivEXT driDispatchRemapTable[VertexAttribI1ivEXT_remap_index] -#define _gloffset_VertexAttribI1uiEXT driDispatchRemapTable[VertexAttribI1uiEXT_remap_index] -#define _gloffset_VertexAttribI1uivEXT driDispatchRemapTable[VertexAttribI1uivEXT_remap_index] -#define _gloffset_VertexAttribI2iEXT driDispatchRemapTable[VertexAttribI2iEXT_remap_index] -#define _gloffset_VertexAttribI2ivEXT driDispatchRemapTable[VertexAttribI2ivEXT_remap_index] -#define _gloffset_VertexAttribI2uiEXT driDispatchRemapTable[VertexAttribI2uiEXT_remap_index] -#define _gloffset_VertexAttribI2uivEXT driDispatchRemapTable[VertexAttribI2uivEXT_remap_index] -#define _gloffset_VertexAttribI3iEXT driDispatchRemapTable[VertexAttribI3iEXT_remap_index] -#define _gloffset_VertexAttribI3ivEXT driDispatchRemapTable[VertexAttribI3ivEXT_remap_index] -#define _gloffset_VertexAttribI3uiEXT driDispatchRemapTable[VertexAttribI3uiEXT_remap_index] -#define _gloffset_VertexAttribI3uivEXT driDispatchRemapTable[VertexAttribI3uivEXT_remap_index] -#define _gloffset_VertexAttribI4bvEXT driDispatchRemapTable[VertexAttribI4bvEXT_remap_index] -#define _gloffset_VertexAttribI4iEXT driDispatchRemapTable[VertexAttribI4iEXT_remap_index] -#define _gloffset_VertexAttribI4ivEXT driDispatchRemapTable[VertexAttribI4ivEXT_remap_index] -#define _gloffset_VertexAttribI4svEXT driDispatchRemapTable[VertexAttribI4svEXT_remap_index] -#define _gloffset_VertexAttribI4ubvEXT driDispatchRemapTable[VertexAttribI4ubvEXT_remap_index] -#define _gloffset_VertexAttribI4uiEXT driDispatchRemapTable[VertexAttribI4uiEXT_remap_index] -#define _gloffset_VertexAttribI4uivEXT driDispatchRemapTable[VertexAttribI4uivEXT_remap_index] -#define _gloffset_VertexAttribI4usvEXT driDispatchRemapTable[VertexAttribI4usvEXT_remap_index] -#define _gloffset_VertexAttribIPointerEXT driDispatchRemapTable[VertexAttribIPointerEXT_remap_index] #define _gloffset_ClearColorIiEXT driDispatchRemapTable[ClearColorIiEXT_remap_index] #define _gloffset_ClearColorIuiEXT driDispatchRemapTable[ClearColorIuiEXT_remap_index] #define _gloffset_GetTexParameterIivEXT driDispatchRemapTable[GetTexParameterIivEXT_remap_index] @@ -1664,13 +1143,9 @@ extern int driDispatchRemapTable[ driDispatchRemapTable_size ]; #define _gloffset_GetObjectParameterivAPPLE driDispatchRemapTable[GetObjectParameterivAPPLE_remap_index] #define _gloffset_ObjectPurgeableAPPLE driDispatchRemapTable[ObjectPurgeableAPPLE_remap_index] #define _gloffset_ObjectUnpurgeableAPPLE driDispatchRemapTable[ObjectUnpurgeableAPPLE_remap_index] -#define _gloffset_ActiveProgramEXT driDispatchRemapTable[ActiveProgramEXT_remap_index] #define _gloffset_CreateShaderProgramEXT driDispatchRemapTable[CreateShaderProgramEXT_remap_index] -#define _gloffset_UseShaderProgramEXT driDispatchRemapTable[UseShaderProgramEXT_remap_index] #define _gloffset_TextureBarrierNV driDispatchRemapTable[TextureBarrierNV_remap_index] #define _gloffset_StencilFuncSeparateATI driDispatchRemapTable[StencilFuncSeparateATI_remap_index] -#define _gloffset_ProgramEnvParameters4fvEXT driDispatchRemapTable[ProgramEnvParameters4fvEXT_remap_index] -#define _gloffset_ProgramLocalParameters4fvEXT driDispatchRemapTable[ProgramLocalParameters4fvEXT_remap_index] #endif /* !FEATURE_remap_table */ @@ -5788,523 +5263,6 @@ static inline void SET_CopyTexSubImage3D(struct _glapi_table *disp, void (GLAPIE SET_by_offset(disp, _gloffset_CopyTexSubImage3D, fn); } -typedef void (GLAPIENTRYP _glptr_ActiveTextureARB)(GLenum); -#define CALL_ActiveTextureARB(disp, parameters) \ - (* GET_ActiveTextureARB(disp)) parameters -static inline _glptr_ActiveTextureARB GET_ActiveTextureARB(struct _glapi_table *disp) { - return (_glptr_ActiveTextureARB) (GET_by_offset(disp, _gloffset_ActiveTextureARB)); -} - -static inline void SET_ActiveTextureARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_ActiveTextureARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ClientActiveTextureARB)(GLenum); -#define CALL_ClientActiveTextureARB(disp, parameters) \ - (* GET_ClientActiveTextureARB(disp)) parameters -static inline _glptr_ClientActiveTextureARB GET_ClientActiveTextureARB(struct _glapi_table *disp) { - return (_glptr_ClientActiveTextureARB) (GET_by_offset(disp, _gloffset_ClientActiveTextureARB)); -} - -static inline void SET_ClientActiveTextureARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_ClientActiveTextureARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1dARB)(GLenum, GLdouble); -#define CALL_MultiTexCoord1dARB(disp, parameters) \ - (* GET_MultiTexCoord1dARB(disp)) parameters -static inline _glptr_MultiTexCoord1dARB GET_MultiTexCoord1dARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1dARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1dARB)); -} - -static inline void SET_MultiTexCoord1dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1dvARB)(GLenum, const GLdouble *); -#define CALL_MultiTexCoord1dvARB(disp, parameters) \ - (* GET_MultiTexCoord1dvARB(disp)) parameters -static inline _glptr_MultiTexCoord1dvARB GET_MultiTexCoord1dvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1dvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1dvARB)); -} - -static inline void SET_MultiTexCoord1dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLdouble *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1fARB)(GLenum, GLfloat); -#define CALL_MultiTexCoord1fARB(disp, parameters) \ - (* GET_MultiTexCoord1fARB(disp)) parameters -static inline _glptr_MultiTexCoord1fARB GET_MultiTexCoord1fARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1fARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1fARB)); -} - -static inline void SET_MultiTexCoord1fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1fvARB)(GLenum, const GLfloat *); -#define CALL_MultiTexCoord1fvARB(disp, parameters) \ - (* GET_MultiTexCoord1fvARB(disp)) parameters -static inline _glptr_MultiTexCoord1fvARB GET_MultiTexCoord1fvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1fvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1fvARB)); -} - -static inline void SET_MultiTexCoord1fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1iARB)(GLenum, GLint); -#define CALL_MultiTexCoord1iARB(disp, parameters) \ - (* GET_MultiTexCoord1iARB(disp)) parameters -static inline _glptr_MultiTexCoord1iARB GET_MultiTexCoord1iARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1iARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1iARB)); -} - -static inline void SET_MultiTexCoord1iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1ivARB)(GLenum, const GLint *); -#define CALL_MultiTexCoord1ivARB(disp, parameters) \ - (* GET_MultiTexCoord1ivARB(disp)) parameters -static inline _glptr_MultiTexCoord1ivARB GET_MultiTexCoord1ivARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1ivARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1ivARB)); -} - -static inline void SET_MultiTexCoord1ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1sARB)(GLenum, GLshort); -#define CALL_MultiTexCoord1sARB(disp, parameters) \ - (* GET_MultiTexCoord1sARB(disp)) parameters -static inline _glptr_MultiTexCoord1sARB GET_MultiTexCoord1sARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1sARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1sARB)); -} - -static inline void SET_MultiTexCoord1sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLshort)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord1svARB)(GLenum, const GLshort *); -#define CALL_MultiTexCoord1svARB(disp, parameters) \ - (* GET_MultiTexCoord1svARB(disp)) parameters -static inline _glptr_MultiTexCoord1svARB GET_MultiTexCoord1svARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord1svARB) (GET_by_offset(disp, _gloffset_MultiTexCoord1svARB)); -} - -static inline void SET_MultiTexCoord1svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLshort *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord1svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2dARB)(GLenum, GLdouble, GLdouble); -#define CALL_MultiTexCoord2dARB(disp, parameters) \ - (* GET_MultiTexCoord2dARB(disp)) parameters -static inline _glptr_MultiTexCoord2dARB GET_MultiTexCoord2dARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2dARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2dARB)); -} - -static inline void SET_MultiTexCoord2dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2dvARB)(GLenum, const GLdouble *); -#define CALL_MultiTexCoord2dvARB(disp, parameters) \ - (* GET_MultiTexCoord2dvARB(disp)) parameters -static inline _glptr_MultiTexCoord2dvARB GET_MultiTexCoord2dvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2dvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2dvARB)); -} - -static inline void SET_MultiTexCoord2dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLdouble *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2fARB)(GLenum, GLfloat, GLfloat); -#define CALL_MultiTexCoord2fARB(disp, parameters) \ - (* GET_MultiTexCoord2fARB(disp)) parameters -static inline _glptr_MultiTexCoord2fARB GET_MultiTexCoord2fARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2fARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2fARB)); -} - -static inline void SET_MultiTexCoord2fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2fvARB)(GLenum, const GLfloat *); -#define CALL_MultiTexCoord2fvARB(disp, parameters) \ - (* GET_MultiTexCoord2fvARB(disp)) parameters -static inline _glptr_MultiTexCoord2fvARB GET_MultiTexCoord2fvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2fvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2fvARB)); -} - -static inline void SET_MultiTexCoord2fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2iARB)(GLenum, GLint, GLint); -#define CALL_MultiTexCoord2iARB(disp, parameters) \ - (* GET_MultiTexCoord2iARB(disp)) parameters -static inline _glptr_MultiTexCoord2iARB GET_MultiTexCoord2iARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2iARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2iARB)); -} - -static inline void SET_MultiTexCoord2iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2ivARB)(GLenum, const GLint *); -#define CALL_MultiTexCoord2ivARB(disp, parameters) \ - (* GET_MultiTexCoord2ivARB(disp)) parameters -static inline _glptr_MultiTexCoord2ivARB GET_MultiTexCoord2ivARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2ivARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2ivARB)); -} - -static inline void SET_MultiTexCoord2ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2sARB)(GLenum, GLshort, GLshort); -#define CALL_MultiTexCoord2sARB(disp, parameters) \ - (* GET_MultiTexCoord2sARB(disp)) parameters -static inline _glptr_MultiTexCoord2sARB GET_MultiTexCoord2sARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2sARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2sARB)); -} - -static inline void SET_MultiTexCoord2sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord2svARB)(GLenum, const GLshort *); -#define CALL_MultiTexCoord2svARB(disp, parameters) \ - (* GET_MultiTexCoord2svARB(disp)) parameters -static inline _glptr_MultiTexCoord2svARB GET_MultiTexCoord2svARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord2svARB) (GET_by_offset(disp, _gloffset_MultiTexCoord2svARB)); -} - -static inline void SET_MultiTexCoord2svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLshort *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord2svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3dARB)(GLenum, GLdouble, GLdouble, GLdouble); -#define CALL_MultiTexCoord3dARB(disp, parameters) \ - (* GET_MultiTexCoord3dARB(disp)) parameters -static inline _glptr_MultiTexCoord3dARB GET_MultiTexCoord3dARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3dARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3dARB)); -} - -static inline void SET_MultiTexCoord3dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3dvARB)(GLenum, const GLdouble *); -#define CALL_MultiTexCoord3dvARB(disp, parameters) \ - (* GET_MultiTexCoord3dvARB(disp)) parameters -static inline _glptr_MultiTexCoord3dvARB GET_MultiTexCoord3dvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3dvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3dvARB)); -} - -static inline void SET_MultiTexCoord3dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLdouble *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3fARB)(GLenum, GLfloat, GLfloat, GLfloat); -#define CALL_MultiTexCoord3fARB(disp, parameters) \ - (* GET_MultiTexCoord3fARB(disp)) parameters -static inline _glptr_MultiTexCoord3fARB GET_MultiTexCoord3fARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3fARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3fARB)); -} - -static inline void SET_MultiTexCoord3fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3fvARB)(GLenum, const GLfloat *); -#define CALL_MultiTexCoord3fvARB(disp, parameters) \ - (* GET_MultiTexCoord3fvARB(disp)) parameters -static inline _glptr_MultiTexCoord3fvARB GET_MultiTexCoord3fvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3fvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3fvARB)); -} - -static inline void SET_MultiTexCoord3fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3iARB)(GLenum, GLint, GLint, GLint); -#define CALL_MultiTexCoord3iARB(disp, parameters) \ - (* GET_MultiTexCoord3iARB(disp)) parameters -static inline _glptr_MultiTexCoord3iARB GET_MultiTexCoord3iARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3iARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3iARB)); -} - -static inline void SET_MultiTexCoord3iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3ivARB)(GLenum, const GLint *); -#define CALL_MultiTexCoord3ivARB(disp, parameters) \ - (* GET_MultiTexCoord3ivARB(disp)) parameters -static inline _glptr_MultiTexCoord3ivARB GET_MultiTexCoord3ivARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3ivARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3ivARB)); -} - -static inline void SET_MultiTexCoord3ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3sARB)(GLenum, GLshort, GLshort, GLshort); -#define CALL_MultiTexCoord3sARB(disp, parameters) \ - (* GET_MultiTexCoord3sARB(disp)) parameters -static inline _glptr_MultiTexCoord3sARB GET_MultiTexCoord3sARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3sARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3sARB)); -} - -static inline void SET_MultiTexCoord3sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord3svARB)(GLenum, const GLshort *); -#define CALL_MultiTexCoord3svARB(disp, parameters) \ - (* GET_MultiTexCoord3svARB(disp)) parameters -static inline _glptr_MultiTexCoord3svARB GET_MultiTexCoord3svARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord3svARB) (GET_by_offset(disp, _gloffset_MultiTexCoord3svARB)); -} - -static inline void SET_MultiTexCoord3svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLshort *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord3svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4dARB)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_MultiTexCoord4dARB(disp, parameters) \ - (* GET_MultiTexCoord4dARB(disp)) parameters -static inline _glptr_MultiTexCoord4dARB GET_MultiTexCoord4dARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4dARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4dARB)); -} - -static inline void SET_MultiTexCoord4dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4dvARB)(GLenum, const GLdouble *); -#define CALL_MultiTexCoord4dvARB(disp, parameters) \ - (* GET_MultiTexCoord4dvARB(disp)) parameters -static inline _glptr_MultiTexCoord4dvARB GET_MultiTexCoord4dvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4dvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4dvARB)); -} - -static inline void SET_MultiTexCoord4dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLdouble *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4fARB)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_MultiTexCoord4fARB(disp, parameters) \ - (* GET_MultiTexCoord4fARB(disp)) parameters -static inline _glptr_MultiTexCoord4fARB GET_MultiTexCoord4fARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4fARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4fARB)); -} - -static inline void SET_MultiTexCoord4fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4fvARB)(GLenum, const GLfloat *); -#define CALL_MultiTexCoord4fvARB(disp, parameters) \ - (* GET_MultiTexCoord4fvARB(disp)) parameters -static inline _glptr_MultiTexCoord4fvARB GET_MultiTexCoord4fvARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4fvARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4fvARB)); -} - -static inline void SET_MultiTexCoord4fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4iARB)(GLenum, GLint, GLint, GLint, GLint); -#define CALL_MultiTexCoord4iARB(disp, parameters) \ - (* GET_MultiTexCoord4iARB(disp)) parameters -static inline _glptr_MultiTexCoord4iARB GET_MultiTexCoord4iARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4iARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4iARB)); -} - -static inline void SET_MultiTexCoord4iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4ivARB)(GLenum, const GLint *); -#define CALL_MultiTexCoord4ivARB(disp, parameters) \ - (* GET_MultiTexCoord4ivARB(disp)) parameters -static inline _glptr_MultiTexCoord4ivARB GET_MultiTexCoord4ivARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4ivARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4ivARB)); -} - -static inline void SET_MultiTexCoord4ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4sARB)(GLenum, GLshort, GLshort, GLshort, GLshort); -#define CALL_MultiTexCoord4sARB(disp, parameters) \ - (* GET_MultiTexCoord4sARB(disp)) parameters -static inline _glptr_MultiTexCoord4sARB GET_MultiTexCoord4sARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4sARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4sARB)); -} - -static inline void SET_MultiTexCoord4sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_MultiTexCoord4svARB)(GLenum, const GLshort *); -#define CALL_MultiTexCoord4svARB(disp, parameters) \ - (* GET_MultiTexCoord4svARB(disp)) parameters -static inline _glptr_MultiTexCoord4svARB GET_MultiTexCoord4svARB(struct _glapi_table *disp) { - return (_glptr_MultiTexCoord4svARB) (GET_by_offset(disp, _gloffset_MultiTexCoord4svARB)); -} - -static inline void SET_MultiTexCoord4svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLshort *)) { - SET_by_offset(disp, _gloffset_MultiTexCoord4svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_AttachShader)(GLuint, GLuint); -#define CALL_AttachShader(disp, parameters) \ - (* GET_AttachShader(disp)) parameters -static inline _glptr_AttachShader GET_AttachShader(struct _glapi_table *disp) { - return (_glptr_AttachShader) (GET_by_offset(disp, _gloffset_AttachShader)); -} - -static inline void SET_AttachShader(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_AttachShader, fn); -} - -typedef GLuint (GLAPIENTRYP _glptr_CreateProgram)(void); -#define CALL_CreateProgram(disp, parameters) \ - (* GET_CreateProgram(disp)) parameters -static inline _glptr_CreateProgram GET_CreateProgram(struct _glapi_table *disp) { - return (_glptr_CreateProgram) (GET_by_offset(disp, _gloffset_CreateProgram)); -} - -static inline void SET_CreateProgram(struct _glapi_table *disp, GLuint (GLAPIENTRYP fn)(void)) { - SET_by_offset(disp, _gloffset_CreateProgram, fn); -} - -typedef GLuint (GLAPIENTRYP _glptr_CreateShader)(GLenum); -#define CALL_CreateShader(disp, parameters) \ - (* GET_CreateShader(disp)) parameters -static inline _glptr_CreateShader GET_CreateShader(struct _glapi_table *disp) { - return (_glptr_CreateShader) (GET_by_offset(disp, _gloffset_CreateShader)); -} - -static inline void SET_CreateShader(struct _glapi_table *disp, GLuint (GLAPIENTRYP fn)(GLenum)) { - SET_by_offset(disp, _gloffset_CreateShader, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteProgram)(GLuint); -#define CALL_DeleteProgram(disp, parameters) \ - (* GET_DeleteProgram(disp)) parameters -static inline _glptr_DeleteProgram GET_DeleteProgram(struct _glapi_table *disp) { - return (_glptr_DeleteProgram) (GET_by_offset(disp, _gloffset_DeleteProgram)); -} - -static inline void SET_DeleteProgram(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_DeleteProgram, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteShader)(GLuint); -#define CALL_DeleteShader(disp, parameters) \ - (* GET_DeleteShader(disp)) parameters -static inline _glptr_DeleteShader GET_DeleteShader(struct _glapi_table *disp) { - return (_glptr_DeleteShader) (GET_by_offset(disp, _gloffset_DeleteShader)); -} - -static inline void SET_DeleteShader(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_DeleteShader, fn); -} - -typedef void (GLAPIENTRYP _glptr_DetachShader)(GLuint, GLuint); -#define CALL_DetachShader(disp, parameters) \ - (* GET_DetachShader(disp)) parameters -static inline _glptr_DetachShader GET_DetachShader(struct _glapi_table *disp) { - return (_glptr_DetachShader) (GET_by_offset(disp, _gloffset_DetachShader)); -} - -static inline void SET_DetachShader(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_DetachShader, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *); -#define CALL_GetAttachedShaders(disp, parameters) \ - (* GET_GetAttachedShaders(disp)) parameters -static inline _glptr_GetAttachedShaders GET_GetAttachedShaders(struct _glapi_table *disp) { - return (_glptr_GetAttachedShaders) (GET_by_offset(disp, _gloffset_GetAttachedShaders)); -} - -static inline void SET_GetAttachedShaders(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLsizei, GLsizei *, GLuint *)) { - SET_by_offset(disp, _gloffset_GetAttachedShaders, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); -#define CALL_GetProgramInfoLog(disp, parameters) \ - (* GET_GetProgramInfoLog(disp)) parameters -static inline _glptr_GetProgramInfoLog GET_GetProgramInfoLog(struct _glapi_table *disp) { - return (_glptr_GetProgramInfoLog) (GET_by_offset(disp, _gloffset_GetProgramInfoLog)); -} - -static inline void SET_GetProgramInfoLog(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLsizei, GLsizei *, GLchar *)) { - SET_by_offset(disp, _gloffset_GetProgramInfoLog, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramiv)(GLuint, GLenum, GLint *); -#define CALL_GetProgramiv(disp, parameters) \ - (* GET_GetProgramiv(disp)) parameters -static inline _glptr_GetProgramiv GET_GetProgramiv(struct _glapi_table *disp) { - return (_glptr_GetProgramiv) (GET_by_offset(disp, _gloffset_GetProgramiv)); -} - -static inline void SET_GetProgramiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetProgramiv, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); -#define CALL_GetShaderInfoLog(disp, parameters) \ - (* GET_GetShaderInfoLog(disp)) parameters -static inline _glptr_GetShaderInfoLog GET_GetShaderInfoLog(struct _glapi_table *disp) { - return (_glptr_GetShaderInfoLog) (GET_by_offset(disp, _gloffset_GetShaderInfoLog)); -} - -static inline void SET_GetShaderInfoLog(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLsizei, GLsizei *, GLchar *)) { - SET_by_offset(disp, _gloffset_GetShaderInfoLog, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetShaderiv)(GLuint, GLenum, GLint *); -#define CALL_GetShaderiv(disp, parameters) \ - (* GET_GetShaderiv(disp)) parameters -static inline _glptr_GetShaderiv GET_GetShaderiv(struct _glapi_table *disp) { - return (_glptr_GetShaderiv) (GET_by_offset(disp, _gloffset_GetShaderiv)); -} - -static inline void SET_GetShaderiv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetShaderiv, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsProgram)(GLuint); -#define CALL_IsProgram(disp, parameters) \ - (* GET_IsProgram(disp)) parameters -static inline _glptr_IsProgram GET_IsProgram(struct _glapi_table *disp) { - return (_glptr_IsProgram) (GET_by_offset(disp, _gloffset_IsProgram)); -} - -static inline void SET_IsProgram(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IsProgram, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsShader)(GLuint); -#define CALL_IsShader(disp, parameters) \ - (* GET_IsShader(disp)) parameters -static inline _glptr_IsShader GET_IsShader(struct _glapi_table *disp) { - return (_glptr_IsShader) (GET_by_offset(disp, _gloffset_IsShader)); -} - -static inline void SET_IsShader(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IsShader, fn); -} - typedef void (GLAPIENTRYP _glptr_StencilFuncSeparate)(GLenum, GLenum, GLint, GLuint); #define CALL_StencilFuncSeparate(disp, parameters) \ (* GET_StencilFuncSeparate(disp)) parameters @@ -6338,72 +5296,6 @@ static inline void SET_StencilOpSeparate(struct _glapi_table *disp, void (GLAPIE SET_by_offset(disp, _gloffset_StencilOpSeparate, fn); } -typedef void (GLAPIENTRYP _glptr_UniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix2x3fv(disp, parameters) \ - (* GET_UniformMatrix2x3fv(disp)) parameters -static inline _glptr_UniformMatrix2x3fv GET_UniformMatrix2x3fv(struct _glapi_table *disp) { - return (_glptr_UniformMatrix2x3fv) (GET_by_offset(disp, _gloffset_UniformMatrix2x3fv)); -} - -static inline void SET_UniformMatrix2x3fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix2x3fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix2x4fv(disp, parameters) \ - (* GET_UniformMatrix2x4fv(disp)) parameters -static inline _glptr_UniformMatrix2x4fv GET_UniformMatrix2x4fv(struct _glapi_table *disp) { - return (_glptr_UniformMatrix2x4fv) (GET_by_offset(disp, _gloffset_UniformMatrix2x4fv)); -} - -static inline void SET_UniformMatrix2x4fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix2x4fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix3x2fv(disp, parameters) \ - (* GET_UniformMatrix3x2fv(disp)) parameters -static inline _glptr_UniformMatrix3x2fv GET_UniformMatrix3x2fv(struct _glapi_table *disp) { - return (_glptr_UniformMatrix3x2fv) (GET_by_offset(disp, _gloffset_UniformMatrix3x2fv)); -} - -static inline void SET_UniformMatrix3x2fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix3x2fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix3x4fv(disp, parameters) \ - (* GET_UniformMatrix3x4fv(disp)) parameters -static inline _glptr_UniformMatrix3x4fv GET_UniformMatrix3x4fv(struct _glapi_table *disp) { - return (_glptr_UniformMatrix3x4fv) (GET_by_offset(disp, _gloffset_UniformMatrix3x4fv)); -} - -static inline void SET_UniformMatrix3x4fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix3x4fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix4x2fv(disp, parameters) \ - (* GET_UniformMatrix4x2fv(disp)) parameters -static inline _glptr_UniformMatrix4x2fv GET_UniformMatrix4x2fv(struct _glapi_table *disp) { - return (_glptr_UniformMatrix4x2fv) (GET_by_offset(disp, _gloffset_UniformMatrix4x2fv)); -} - -static inline void SET_UniformMatrix4x2fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix4x2fv, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix4x3fv(disp, parameters) \ - (* GET_UniformMatrix4x3fv(disp)) parameters -static inline _glptr_UniformMatrix4x3fv GET_UniformMatrix4x3fv(struct _glapi_table *disp) { - return (_glptr_UniformMatrix4x3fv) (GET_by_offset(disp, _gloffset_UniformMatrix4x3fv)); -} - -static inline void SET_UniformMatrix4x3fv(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix4x3fv, fn); -} - typedef const GLubyte * (GLAPIENTRYP _glptr_GetStringi)(GLenum, GLuint); #define CALL_GetStringi(disp, parameters) \ (* GET_GetStringi(disp)) parameters @@ -6492,633 +5384,6 @@ static inline void SET_SampleCoverageARB(struct _glapi_table *disp, void (GLAPIE SET_by_offset(disp, _gloffset_SampleCoverageARB, fn); } -typedef void (GLAPIENTRYP _glptr_DisableVertexAttribArrayARB)(GLuint); -#define CALL_DisableVertexAttribArrayARB(disp, parameters) \ - (* GET_DisableVertexAttribArrayARB(disp)) parameters -static inline _glptr_DisableVertexAttribArrayARB GET_DisableVertexAttribArrayARB(struct _glapi_table *disp) { - return (_glptr_DisableVertexAttribArrayARB) (GET_by_offset(disp, _gloffset_DisableVertexAttribArrayARB)); -} - -static inline void SET_DisableVertexAttribArrayARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_DisableVertexAttribArrayARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_EnableVertexAttribArrayARB)(GLuint); -#define CALL_EnableVertexAttribArrayARB(disp, parameters) \ - (* GET_EnableVertexAttribArrayARB(disp)) parameters -static inline _glptr_EnableVertexAttribArrayARB GET_EnableVertexAttribArrayARB(struct _glapi_table *disp) { - return (_glptr_EnableVertexAttribArrayARB) (GET_by_offset(disp, _gloffset_EnableVertexAttribArrayARB)); -} - -static inline void SET_EnableVertexAttribArrayARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_EnableVertexAttribArrayARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramEnvParameterdvARB)(GLenum, GLuint, GLdouble *); -#define CALL_GetProgramEnvParameterdvARB(disp, parameters) \ - (* GET_GetProgramEnvParameterdvARB(disp)) parameters -static inline _glptr_GetProgramEnvParameterdvARB GET_GetProgramEnvParameterdvARB(struct _glapi_table *disp) { - return (_glptr_GetProgramEnvParameterdvARB) (GET_by_offset(disp, _gloffset_GetProgramEnvParameterdvARB)); -} - -static inline void SET_GetProgramEnvParameterdvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetProgramEnvParameterdvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramEnvParameterfvARB)(GLenum, GLuint, GLfloat *); -#define CALL_GetProgramEnvParameterfvARB(disp, parameters) \ - (* GET_GetProgramEnvParameterfvARB(disp)) parameters -static inline _glptr_GetProgramEnvParameterfvARB GET_GetProgramEnvParameterfvARB(struct _glapi_table *disp) { - return (_glptr_GetProgramEnvParameterfvARB) (GET_by_offset(disp, _gloffset_GetProgramEnvParameterfvARB)); -} - -static inline void SET_GetProgramEnvParameterfvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetProgramEnvParameterfvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramLocalParameterdvARB)(GLenum, GLuint, GLdouble *); -#define CALL_GetProgramLocalParameterdvARB(disp, parameters) \ - (* GET_GetProgramLocalParameterdvARB(disp)) parameters -static inline _glptr_GetProgramLocalParameterdvARB GET_GetProgramLocalParameterdvARB(struct _glapi_table *disp) { - return (_glptr_GetProgramLocalParameterdvARB) (GET_by_offset(disp, _gloffset_GetProgramLocalParameterdvARB)); -} - -static inline void SET_GetProgramLocalParameterdvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetProgramLocalParameterdvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramLocalParameterfvARB)(GLenum, GLuint, GLfloat *); -#define CALL_GetProgramLocalParameterfvARB(disp, parameters) \ - (* GET_GetProgramLocalParameterfvARB(disp)) parameters -static inline _glptr_GetProgramLocalParameterfvARB GET_GetProgramLocalParameterfvARB(struct _glapi_table *disp) { - return (_glptr_GetProgramLocalParameterfvARB) (GET_by_offset(disp, _gloffset_GetProgramLocalParameterfvARB)); -} - -static inline void SET_GetProgramLocalParameterfvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetProgramLocalParameterfvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramStringARB)(GLenum, GLenum, GLvoid *); -#define CALL_GetProgramStringARB(disp, parameters) \ - (* GET_GetProgramStringARB(disp)) parameters -static inline _glptr_GetProgramStringARB GET_GetProgramStringARB(struct _glapi_table *disp) { - return (_glptr_GetProgramStringARB) (GET_by_offset(disp, _gloffset_GetProgramStringARB)); -} - -static inline void SET_GetProgramStringARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLvoid *)) { - SET_by_offset(disp, _gloffset_GetProgramStringARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramivARB)(GLenum, GLenum, GLint *); -#define CALL_GetProgramivARB(disp, parameters) \ - (* GET_GetProgramivARB(disp)) parameters -static inline _glptr_GetProgramivARB GET_GetProgramivARB(struct _glapi_table *disp) { - return (_glptr_GetProgramivARB) (GET_by_offset(disp, _gloffset_GetProgramivARB)); -} - -static inline void SET_GetProgramivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetProgramivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribdvARB)(GLuint, GLenum, GLdouble *); -#define CALL_GetVertexAttribdvARB(disp, parameters) \ - (* GET_GetVertexAttribdvARB(disp)) parameters -static inline _glptr_GetVertexAttribdvARB GET_GetVertexAttribdvARB(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribdvARB) (GET_by_offset(disp, _gloffset_GetVertexAttribdvARB)); -} - -static inline void SET_GetVertexAttribdvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribdvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribfvARB)(GLuint, GLenum, GLfloat *); -#define CALL_GetVertexAttribfvARB(disp, parameters) \ - (* GET_GetVertexAttribfvARB(disp)) parameters -static inline _glptr_GetVertexAttribfvARB GET_GetVertexAttribfvARB(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribfvARB) (GET_by_offset(disp, _gloffset_GetVertexAttribfvARB)); -} - -static inline void SET_GetVertexAttribfvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribfvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribivARB)(GLuint, GLenum, GLint *); -#define CALL_GetVertexAttribivARB(disp, parameters) \ - (* GET_GetVertexAttribivARB(disp)) parameters -static inline _glptr_GetVertexAttribivARB GET_GetVertexAttribivARB(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribivARB) (GET_by_offset(disp, _gloffset_GetVertexAttribivARB)); -} - -static inline void SET_GetVertexAttribivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramEnvParameter4dARB)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_ProgramEnvParameter4dARB(disp, parameters) \ - (* GET_ProgramEnvParameter4dARB(disp)) parameters -static inline _glptr_ProgramEnvParameter4dARB GET_ProgramEnvParameter4dARB(struct _glapi_table *disp) { - return (_glptr_ProgramEnvParameter4dARB) (GET_by_offset(disp, _gloffset_ProgramEnvParameter4dARB)); -} - -static inline void SET_ProgramEnvParameter4dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_ProgramEnvParameter4dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramEnvParameter4dvARB)(GLenum, GLuint, const GLdouble *); -#define CALL_ProgramEnvParameter4dvARB(disp, parameters) \ - (* GET_ProgramEnvParameter4dvARB(disp)) parameters -static inline _glptr_ProgramEnvParameter4dvARB GET_ProgramEnvParameter4dvARB(struct _glapi_table *disp) { - return (_glptr_ProgramEnvParameter4dvARB) (GET_by_offset(disp, _gloffset_ProgramEnvParameter4dvARB)); -} - -static inline void SET_ProgramEnvParameter4dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_ProgramEnvParameter4dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramEnvParameter4fARB)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_ProgramEnvParameter4fARB(disp, parameters) \ - (* GET_ProgramEnvParameter4fARB(disp)) parameters -static inline _glptr_ProgramEnvParameter4fARB GET_ProgramEnvParameter4fARB(struct _glapi_table *disp) { - return (_glptr_ProgramEnvParameter4fARB) (GET_by_offset(disp, _gloffset_ProgramEnvParameter4fARB)); -} - -static inline void SET_ProgramEnvParameter4fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_ProgramEnvParameter4fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramEnvParameter4fvARB)(GLenum, GLuint, const GLfloat *); -#define CALL_ProgramEnvParameter4fvARB(disp, parameters) \ - (* GET_ProgramEnvParameter4fvARB(disp)) parameters -static inline _glptr_ProgramEnvParameter4fvARB GET_ProgramEnvParameter4fvARB(struct _glapi_table *disp) { - return (_glptr_ProgramEnvParameter4fvARB) (GET_by_offset(disp, _gloffset_ProgramEnvParameter4fvARB)); -} - -static inline void SET_ProgramEnvParameter4fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_ProgramEnvParameter4fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramLocalParameter4dARB)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_ProgramLocalParameter4dARB(disp, parameters) \ - (* GET_ProgramLocalParameter4dARB(disp)) parameters -static inline _glptr_ProgramLocalParameter4dARB GET_ProgramLocalParameter4dARB(struct _glapi_table *disp) { - return (_glptr_ProgramLocalParameter4dARB) (GET_by_offset(disp, _gloffset_ProgramLocalParameter4dARB)); -} - -static inline void SET_ProgramLocalParameter4dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_ProgramLocalParameter4dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramLocalParameter4dvARB)(GLenum, GLuint, const GLdouble *); -#define CALL_ProgramLocalParameter4dvARB(disp, parameters) \ - (* GET_ProgramLocalParameter4dvARB(disp)) parameters -static inline _glptr_ProgramLocalParameter4dvARB GET_ProgramLocalParameter4dvARB(struct _glapi_table *disp) { - return (_glptr_ProgramLocalParameter4dvARB) (GET_by_offset(disp, _gloffset_ProgramLocalParameter4dvARB)); -} - -static inline void SET_ProgramLocalParameter4dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_ProgramLocalParameter4dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramLocalParameter4fARB)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_ProgramLocalParameter4fARB(disp, parameters) \ - (* GET_ProgramLocalParameter4fARB(disp)) parameters -static inline _glptr_ProgramLocalParameter4fARB GET_ProgramLocalParameter4fARB(struct _glapi_table *disp) { - return (_glptr_ProgramLocalParameter4fARB) (GET_by_offset(disp, _gloffset_ProgramLocalParameter4fARB)); -} - -static inline void SET_ProgramLocalParameter4fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_ProgramLocalParameter4fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramLocalParameter4fvARB)(GLenum, GLuint, const GLfloat *); -#define CALL_ProgramLocalParameter4fvARB(disp, parameters) \ - (* GET_ProgramLocalParameter4fvARB(disp)) parameters -static inline _glptr_ProgramLocalParameter4fvARB GET_ProgramLocalParameter4fvARB(struct _glapi_table *disp) { - return (_glptr_ProgramLocalParameter4fvARB) (GET_by_offset(disp, _gloffset_ProgramLocalParameter4fvARB)); -} - -static inline void SET_ProgramLocalParameter4fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_ProgramLocalParameter4fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramStringARB)(GLenum, GLenum, GLsizei, const GLvoid *); -#define CALL_ProgramStringARB(disp, parameters) \ - (* GET_ProgramStringARB(disp)) parameters -static inline _glptr_ProgramStringARB GET_ProgramStringARB(struct _glapi_table *disp) { - return (_glptr_ProgramStringARB) (GET_by_offset(disp, _gloffset_ProgramStringARB)); -} - -static inline void SET_ProgramStringARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_ProgramStringARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1dARB)(GLuint, GLdouble); -#define CALL_VertexAttrib1dARB(disp, parameters) \ - (* GET_VertexAttrib1dARB(disp)) parameters -static inline _glptr_VertexAttrib1dARB GET_VertexAttrib1dARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1dARB) (GET_by_offset(disp, _gloffset_VertexAttrib1dARB)); -} - -static inline void SET_VertexAttrib1dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib1dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1dvARB)(GLuint, const GLdouble *); -#define CALL_VertexAttrib1dvARB(disp, parameters) \ - (* GET_VertexAttrib1dvARB(disp)) parameters -static inline _glptr_VertexAttrib1dvARB GET_VertexAttrib1dvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1dvARB) (GET_by_offset(disp, _gloffset_VertexAttrib1dvARB)); -} - -static inline void SET_VertexAttrib1dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib1dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1fARB)(GLuint, GLfloat); -#define CALL_VertexAttrib1fARB(disp, parameters) \ - (* GET_VertexAttrib1fARB(disp)) parameters -static inline _glptr_VertexAttrib1fARB GET_VertexAttrib1fARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1fARB) (GET_by_offset(disp, _gloffset_VertexAttrib1fARB)); -} - -static inline void SET_VertexAttrib1fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib1fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1fvARB)(GLuint, const GLfloat *); -#define CALL_VertexAttrib1fvARB(disp, parameters) \ - (* GET_VertexAttrib1fvARB(disp)) parameters -static inline _glptr_VertexAttrib1fvARB GET_VertexAttrib1fvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1fvARB) (GET_by_offset(disp, _gloffset_VertexAttrib1fvARB)); -} - -static inline void SET_VertexAttrib1fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib1fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1sARB)(GLuint, GLshort); -#define CALL_VertexAttrib1sARB(disp, parameters) \ - (* GET_VertexAttrib1sARB(disp)) parameters -static inline _glptr_VertexAttrib1sARB GET_VertexAttrib1sARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1sARB) (GET_by_offset(disp, _gloffset_VertexAttrib1sARB)); -} - -static inline void SET_VertexAttrib1sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib1sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib1svARB)(GLuint, const GLshort *); -#define CALL_VertexAttrib1svARB(disp, parameters) \ - (* GET_VertexAttrib1svARB(disp)) parameters -static inline _glptr_VertexAttrib1svARB GET_VertexAttrib1svARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib1svARB) (GET_by_offset(disp, _gloffset_VertexAttrib1svARB)); -} - -static inline void SET_VertexAttrib1svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib1svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2dARB)(GLuint, GLdouble, GLdouble); -#define CALL_VertexAttrib2dARB(disp, parameters) \ - (* GET_VertexAttrib2dARB(disp)) parameters -static inline _glptr_VertexAttrib2dARB GET_VertexAttrib2dARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2dARB) (GET_by_offset(disp, _gloffset_VertexAttrib2dARB)); -} - -static inline void SET_VertexAttrib2dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib2dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2dvARB)(GLuint, const GLdouble *); -#define CALL_VertexAttrib2dvARB(disp, parameters) \ - (* GET_VertexAttrib2dvARB(disp)) parameters -static inline _glptr_VertexAttrib2dvARB GET_VertexAttrib2dvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2dvARB) (GET_by_offset(disp, _gloffset_VertexAttrib2dvARB)); -} - -static inline void SET_VertexAttrib2dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib2dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2fARB)(GLuint, GLfloat, GLfloat); -#define CALL_VertexAttrib2fARB(disp, parameters) \ - (* GET_VertexAttrib2fARB(disp)) parameters -static inline _glptr_VertexAttrib2fARB GET_VertexAttrib2fARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2fARB) (GET_by_offset(disp, _gloffset_VertexAttrib2fARB)); -} - -static inline void SET_VertexAttrib2fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib2fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2fvARB)(GLuint, const GLfloat *); -#define CALL_VertexAttrib2fvARB(disp, parameters) \ - (* GET_VertexAttrib2fvARB(disp)) parameters -static inline _glptr_VertexAttrib2fvARB GET_VertexAttrib2fvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2fvARB) (GET_by_offset(disp, _gloffset_VertexAttrib2fvARB)); -} - -static inline void SET_VertexAttrib2fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib2fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2sARB)(GLuint, GLshort, GLshort); -#define CALL_VertexAttrib2sARB(disp, parameters) \ - (* GET_VertexAttrib2sARB(disp)) parameters -static inline _glptr_VertexAttrib2sARB GET_VertexAttrib2sARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2sARB) (GET_by_offset(disp, _gloffset_VertexAttrib2sARB)); -} - -static inline void SET_VertexAttrib2sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib2sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib2svARB)(GLuint, const GLshort *); -#define CALL_VertexAttrib2svARB(disp, parameters) \ - (* GET_VertexAttrib2svARB(disp)) parameters -static inline _glptr_VertexAttrib2svARB GET_VertexAttrib2svARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib2svARB) (GET_by_offset(disp, _gloffset_VertexAttrib2svARB)); -} - -static inline void SET_VertexAttrib2svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib2svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3dARB)(GLuint, GLdouble, GLdouble, GLdouble); -#define CALL_VertexAttrib3dARB(disp, parameters) \ - (* GET_VertexAttrib3dARB(disp)) parameters -static inline _glptr_VertexAttrib3dARB GET_VertexAttrib3dARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3dARB) (GET_by_offset(disp, _gloffset_VertexAttrib3dARB)); -} - -static inline void SET_VertexAttrib3dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib3dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3dvARB)(GLuint, const GLdouble *); -#define CALL_VertexAttrib3dvARB(disp, parameters) \ - (* GET_VertexAttrib3dvARB(disp)) parameters -static inline _glptr_VertexAttrib3dvARB GET_VertexAttrib3dvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3dvARB) (GET_by_offset(disp, _gloffset_VertexAttrib3dvARB)); -} - -static inline void SET_VertexAttrib3dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib3dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3fARB)(GLuint, GLfloat, GLfloat, GLfloat); -#define CALL_VertexAttrib3fARB(disp, parameters) \ - (* GET_VertexAttrib3fARB(disp)) parameters -static inline _glptr_VertexAttrib3fARB GET_VertexAttrib3fARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3fARB) (GET_by_offset(disp, _gloffset_VertexAttrib3fARB)); -} - -static inline void SET_VertexAttrib3fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib3fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3fvARB)(GLuint, const GLfloat *); -#define CALL_VertexAttrib3fvARB(disp, parameters) \ - (* GET_VertexAttrib3fvARB(disp)) parameters -static inline _glptr_VertexAttrib3fvARB GET_VertexAttrib3fvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3fvARB) (GET_by_offset(disp, _gloffset_VertexAttrib3fvARB)); -} - -static inline void SET_VertexAttrib3fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib3fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3sARB)(GLuint, GLshort, GLshort, GLshort); -#define CALL_VertexAttrib3sARB(disp, parameters) \ - (* GET_VertexAttrib3sARB(disp)) parameters -static inline _glptr_VertexAttrib3sARB GET_VertexAttrib3sARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3sARB) (GET_by_offset(disp, _gloffset_VertexAttrib3sARB)); -} - -static inline void SET_VertexAttrib3sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib3sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib3svARB)(GLuint, const GLshort *); -#define CALL_VertexAttrib3svARB(disp, parameters) \ - (* GET_VertexAttrib3svARB(disp)) parameters -static inline _glptr_VertexAttrib3svARB GET_VertexAttrib3svARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib3svARB) (GET_by_offset(disp, _gloffset_VertexAttrib3svARB)); -} - -static inline void SET_VertexAttrib3svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib3svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4NbvARB)(GLuint, const GLbyte *); -#define CALL_VertexAttrib4NbvARB(disp, parameters) \ - (* GET_VertexAttrib4NbvARB(disp)) parameters -static inline _glptr_VertexAttrib4NbvARB GET_VertexAttrib4NbvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4NbvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4NbvARB)); -} - -static inline void SET_VertexAttrib4NbvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLbyte *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4NbvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4NivARB)(GLuint, const GLint *); -#define CALL_VertexAttrib4NivARB(disp, parameters) \ - (* GET_VertexAttrib4NivARB(disp)) parameters -static inline _glptr_VertexAttrib4NivARB GET_VertexAttrib4NivARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4NivARB) (GET_by_offset(disp, _gloffset_VertexAttrib4NivARB)); -} - -static inline void SET_VertexAttrib4NivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLint *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4NivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4NsvARB)(GLuint, const GLshort *); -#define CALL_VertexAttrib4NsvARB(disp, parameters) \ - (* GET_VertexAttrib4NsvARB(disp)) parameters -static inline _glptr_VertexAttrib4NsvARB GET_VertexAttrib4NsvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4NsvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4NsvARB)); -} - -static inline void SET_VertexAttrib4NsvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4NsvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4NubARB)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -#define CALL_VertexAttrib4NubARB(disp, parameters) \ - (* GET_VertexAttrib4NubARB(disp)) parameters -static inline _glptr_VertexAttrib4NubARB GET_VertexAttrib4NubARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4NubARB) (GET_by_offset(disp, _gloffset_VertexAttrib4NubARB)); -} - -static inline void SET_VertexAttrib4NubARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)) { - SET_by_offset(disp, _gloffset_VertexAttrib4NubARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4NubvARB)(GLuint, const GLubyte *); -#define CALL_VertexAttrib4NubvARB(disp, parameters) \ - (* GET_VertexAttrib4NubvARB(disp)) parameters -static inline _glptr_VertexAttrib4NubvARB GET_VertexAttrib4NubvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4NubvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4NubvARB)); -} - -static inline void SET_VertexAttrib4NubvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLubyte *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4NubvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4NuivARB)(GLuint, const GLuint *); -#define CALL_VertexAttrib4NuivARB(disp, parameters) \ - (* GET_VertexAttrib4NuivARB(disp)) parameters -static inline _glptr_VertexAttrib4NuivARB GET_VertexAttrib4NuivARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4NuivARB) (GET_by_offset(disp, _gloffset_VertexAttrib4NuivARB)); -} - -static inline void SET_VertexAttrib4NuivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLuint *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4NuivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4NusvARB)(GLuint, const GLushort *); -#define CALL_VertexAttrib4NusvARB(disp, parameters) \ - (* GET_VertexAttrib4NusvARB(disp)) parameters -static inline _glptr_VertexAttrib4NusvARB GET_VertexAttrib4NusvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4NusvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4NusvARB)); -} - -static inline void SET_VertexAttrib4NusvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLushort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4NusvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4bvARB)(GLuint, const GLbyte *); -#define CALL_VertexAttrib4bvARB(disp, parameters) \ - (* GET_VertexAttrib4bvARB(disp)) parameters -static inline _glptr_VertexAttrib4bvARB GET_VertexAttrib4bvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4bvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4bvARB)); -} - -static inline void SET_VertexAttrib4bvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLbyte *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4bvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4dARB)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -#define CALL_VertexAttrib4dARB(disp, parameters) \ - (* GET_VertexAttrib4dARB(disp)) parameters -static inline _glptr_VertexAttrib4dARB GET_VertexAttrib4dARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4dARB) (GET_by_offset(disp, _gloffset_VertexAttrib4dARB)); -} - -static inline void SET_VertexAttrib4dARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)) { - SET_by_offset(disp, _gloffset_VertexAttrib4dARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4dvARB)(GLuint, const GLdouble *); -#define CALL_VertexAttrib4dvARB(disp, parameters) \ - (* GET_VertexAttrib4dvARB(disp)) parameters -static inline _glptr_VertexAttrib4dvARB GET_VertexAttrib4dvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4dvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4dvARB)); -} - -static inline void SET_VertexAttrib4dvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLdouble *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4dvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4fARB)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_VertexAttrib4fARB(disp, parameters) \ - (* GET_VertexAttrib4fARB(disp)) parameters -static inline _glptr_VertexAttrib4fARB GET_VertexAttrib4fARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4fARB) (GET_by_offset(disp, _gloffset_VertexAttrib4fARB)); -} - -static inline void SET_VertexAttrib4fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_VertexAttrib4fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4fvARB)(GLuint, const GLfloat *); -#define CALL_VertexAttrib4fvARB(disp, parameters) \ - (* GET_VertexAttrib4fvARB(disp)) parameters -static inline _glptr_VertexAttrib4fvARB GET_VertexAttrib4fvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4fvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4fvARB)); -} - -static inline void SET_VertexAttrib4fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLfloat *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4ivARB)(GLuint, const GLint *); -#define CALL_VertexAttrib4ivARB(disp, parameters) \ - (* GET_VertexAttrib4ivARB(disp)) parameters -static inline _glptr_VertexAttrib4ivARB GET_VertexAttrib4ivARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4ivARB) (GET_by_offset(disp, _gloffset_VertexAttrib4ivARB)); -} - -static inline void SET_VertexAttrib4ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLint *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4sARB)(GLuint, GLshort, GLshort, GLshort, GLshort); -#define CALL_VertexAttrib4sARB(disp, parameters) \ - (* GET_VertexAttrib4sARB(disp)) parameters -static inline _glptr_VertexAttrib4sARB GET_VertexAttrib4sARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4sARB) (GET_by_offset(disp, _gloffset_VertexAttrib4sARB)); -} - -static inline void SET_VertexAttrib4sARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLshort, GLshort, GLshort, GLshort)) { - SET_by_offset(disp, _gloffset_VertexAttrib4sARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4svARB)(GLuint, const GLshort *); -#define CALL_VertexAttrib4svARB(disp, parameters) \ - (* GET_VertexAttrib4svARB(disp)) parameters -static inline _glptr_VertexAttrib4svARB GET_VertexAttrib4svARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4svARB) (GET_by_offset(disp, _gloffset_VertexAttrib4svARB)); -} - -static inline void SET_VertexAttrib4svARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4svARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4ubvARB)(GLuint, const GLubyte *); -#define CALL_VertexAttrib4ubvARB(disp, parameters) \ - (* GET_VertexAttrib4ubvARB(disp)) parameters -static inline _glptr_VertexAttrib4ubvARB GET_VertexAttrib4ubvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4ubvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4ubvARB)); -} - -static inline void SET_VertexAttrib4ubvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLubyte *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4ubvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4uivARB)(GLuint, const GLuint *); -#define CALL_VertexAttrib4uivARB(disp, parameters) \ - (* GET_VertexAttrib4uivARB(disp)) parameters -static inline _glptr_VertexAttrib4uivARB GET_VertexAttrib4uivARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4uivARB) (GET_by_offset(disp, _gloffset_VertexAttrib4uivARB)); -} - -static inline void SET_VertexAttrib4uivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLuint *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4uivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttrib4usvARB)(GLuint, const GLushort *); -#define CALL_VertexAttrib4usvARB(disp, parameters) \ - (* GET_VertexAttrib4usvARB(disp)) parameters -static inline _glptr_VertexAttrib4usvARB GET_VertexAttrib4usvARB(struct _glapi_table *disp) { - return (_glptr_VertexAttrib4usvARB) (GET_by_offset(disp, _gloffset_VertexAttrib4usvARB)); -} - -static inline void SET_VertexAttrib4usvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLushort *)) { - SET_by_offset(disp, _gloffset_VertexAttrib4usvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribPointerARB)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#define CALL_VertexAttribPointerARB(disp, parameters) \ - (* GET_VertexAttribPointerARB(disp)) parameters -static inline _glptr_VertexAttribPointerARB GET_VertexAttribPointerARB(struct _glapi_table *disp) { - return (_glptr_VertexAttribPointerARB) (GET_by_offset(disp, _gloffset_VertexAttribPointerARB)); -} - -static inline void SET_VertexAttribPointerARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_VertexAttribPointerARB, fn); -} - typedef void (GLAPIENTRYP _glptr_BindBufferARB)(GLenum, GLuint); #define CALL_BindBufferARB(disp, parameters) \ (* GET_BindBufferARB(disp)) parameters @@ -7306,17 +5571,6 @@ static inline void SET_DetachObjectARB(struct _glapi_table *disp, void (GLAPIENT SET_by_offset(disp, _gloffset_DetachObjectARB, fn); } -typedef void (GLAPIENTRYP _glptr_GetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -#define CALL_GetActiveUniformARB(disp, parameters) \ - (* GET_GetActiveUniformARB(disp)) parameters -static inline _glptr_GetActiveUniformARB GET_GetActiveUniformARB(struct _glapi_table *disp) { - return (_glptr_GetActiveUniformARB) (GET_by_offset(disp, _gloffset_GetActiveUniformARB)); -} - -static inline void SET_GetActiveUniformARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)) { - SET_by_offset(disp, _gloffset_GetActiveUniformARB, fn); -} - typedef void (GLAPIENTRYP _glptr_GetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); #define CALL_GetAttachedObjectsARB(disp, parameters) \ (* GET_GetAttachedObjectsARB(disp)) parameters @@ -7383,39 +5637,6 @@ static inline void SET_GetShaderSourceARB(struct _glapi_table *disp, void (GLAPI SET_by_offset(disp, _gloffset_GetShaderSourceARB, fn); } -typedef GLint (GLAPIENTRYP _glptr_GetUniformLocationARB)(GLhandleARB, const GLcharARB *); -#define CALL_GetUniformLocationARB(disp, parameters) \ - (* GET_GetUniformLocationARB(disp)) parameters -static inline _glptr_GetUniformLocationARB GET_GetUniformLocationARB(struct _glapi_table *disp) { - return (_glptr_GetUniformLocationARB) (GET_by_offset(disp, _gloffset_GetUniformLocationARB)); -} - -static inline void SET_GetUniformLocationARB(struct _glapi_table *disp, GLint (GLAPIENTRYP fn)(GLhandleARB, const GLcharARB *)) { - SET_by_offset(disp, _gloffset_GetUniformLocationARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetUniformfvARB)(GLhandleARB, GLint, GLfloat *); -#define CALL_GetUniformfvARB(disp, parameters) \ - (* GET_GetUniformfvARB(disp)) parameters -static inline _glptr_GetUniformfvARB GET_GetUniformfvARB(struct _glapi_table *disp) { - return (_glptr_GetUniformfvARB) (GET_by_offset(disp, _gloffset_GetUniformfvARB)); -} - -static inline void SET_GetUniformfvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLint, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetUniformfvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetUniformivARB)(GLhandleARB, GLint, GLint *); -#define CALL_GetUniformivARB(disp, parameters) \ - (* GET_GetUniformivARB(disp)) parameters -static inline _glptr_GetUniformivARB GET_GetUniformivARB(struct _glapi_table *disp) { - return (_glptr_GetUniformivARB) (GET_by_offset(disp, _gloffset_GetUniformivARB)); -} - -static inline void SET_GetUniformivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLint, GLint *)) { - SET_by_offset(disp, _gloffset_GetUniformivARB, fn); -} - typedef void (GLAPIENTRYP _glptr_LinkProgramARB)(GLhandleARB); #define CALL_LinkProgramARB(disp, parameters) \ (* GET_LinkProgramARB(disp)) parameters @@ -7438,226 +5659,6 @@ static inline void SET_ShaderSourceARB(struct _glapi_table *disp, void (GLAPIENT SET_by_offset(disp, _gloffset_ShaderSourceARB, fn); } -typedef void (GLAPIENTRYP _glptr_Uniform1fARB)(GLint, GLfloat); -#define CALL_Uniform1fARB(disp, parameters) \ - (* GET_Uniform1fARB(disp)) parameters -static inline _glptr_Uniform1fARB GET_Uniform1fARB(struct _glapi_table *disp) { - return (_glptr_Uniform1fARB) (GET_by_offset(disp, _gloffset_Uniform1fARB)); -} - -static inline void SET_Uniform1fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLfloat)) { - SET_by_offset(disp, _gloffset_Uniform1fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform1fvARB)(GLint, GLsizei, const GLfloat *); -#define CALL_Uniform1fvARB(disp, parameters) \ - (* GET_Uniform1fvARB(disp)) parameters -static inline _glptr_Uniform1fvARB GET_Uniform1fvARB(struct _glapi_table *disp) { - return (_glptr_Uniform1fvARB) (GET_by_offset(disp, _gloffset_Uniform1fvARB)); -} - -static inline void SET_Uniform1fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Uniform1fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform1iARB)(GLint, GLint); -#define CALL_Uniform1iARB(disp, parameters) \ - (* GET_Uniform1iARB(disp)) parameters -static inline _glptr_Uniform1iARB GET_Uniform1iARB(struct _glapi_table *disp) { - return (_glptr_Uniform1iARB) (GET_by_offset(disp, _gloffset_Uniform1iARB)); -} - -static inline void SET_Uniform1iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint)) { - SET_by_offset(disp, _gloffset_Uniform1iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform1ivARB)(GLint, GLsizei, const GLint *); -#define CALL_Uniform1ivARB(disp, parameters) \ - (* GET_Uniform1ivARB(disp)) parameters -static inline _glptr_Uniform1ivARB GET_Uniform1ivARB(struct _glapi_table *disp) { - return (_glptr_Uniform1ivARB) (GET_by_offset(disp, _gloffset_Uniform1ivARB)); -} - -static inline void SET_Uniform1ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLint *)) { - SET_by_offset(disp, _gloffset_Uniform1ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform2fARB)(GLint, GLfloat, GLfloat); -#define CALL_Uniform2fARB(disp, parameters) \ - (* GET_Uniform2fARB(disp)) parameters -static inline _glptr_Uniform2fARB GET_Uniform2fARB(struct _glapi_table *disp) { - return (_glptr_Uniform2fARB) (GET_by_offset(disp, _gloffset_Uniform2fARB)); -} - -static inline void SET_Uniform2fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Uniform2fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform2fvARB)(GLint, GLsizei, const GLfloat *); -#define CALL_Uniform2fvARB(disp, parameters) \ - (* GET_Uniform2fvARB(disp)) parameters -static inline _glptr_Uniform2fvARB GET_Uniform2fvARB(struct _glapi_table *disp) { - return (_glptr_Uniform2fvARB) (GET_by_offset(disp, _gloffset_Uniform2fvARB)); -} - -static inline void SET_Uniform2fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Uniform2fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform2iARB)(GLint, GLint, GLint); -#define CALL_Uniform2iARB(disp, parameters) \ - (* GET_Uniform2iARB(disp)) parameters -static inline _glptr_Uniform2iARB GET_Uniform2iARB(struct _glapi_table *disp) { - return (_glptr_Uniform2iARB) (GET_by_offset(disp, _gloffset_Uniform2iARB)); -} - -static inline void SET_Uniform2iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Uniform2iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform2ivARB)(GLint, GLsizei, const GLint *); -#define CALL_Uniform2ivARB(disp, parameters) \ - (* GET_Uniform2ivARB(disp)) parameters -static inline _glptr_Uniform2ivARB GET_Uniform2ivARB(struct _glapi_table *disp) { - return (_glptr_Uniform2ivARB) (GET_by_offset(disp, _gloffset_Uniform2ivARB)); -} - -static inline void SET_Uniform2ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLint *)) { - SET_by_offset(disp, _gloffset_Uniform2ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform3fARB)(GLint, GLfloat, GLfloat, GLfloat); -#define CALL_Uniform3fARB(disp, parameters) \ - (* GET_Uniform3fARB(disp)) parameters -static inline _glptr_Uniform3fARB GET_Uniform3fARB(struct _glapi_table *disp) { - return (_glptr_Uniform3fARB) (GET_by_offset(disp, _gloffset_Uniform3fARB)); -} - -static inline void SET_Uniform3fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Uniform3fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform3fvARB)(GLint, GLsizei, const GLfloat *); -#define CALL_Uniform3fvARB(disp, parameters) \ - (* GET_Uniform3fvARB(disp)) parameters -static inline _glptr_Uniform3fvARB GET_Uniform3fvARB(struct _glapi_table *disp) { - return (_glptr_Uniform3fvARB) (GET_by_offset(disp, _gloffset_Uniform3fvARB)); -} - -static inline void SET_Uniform3fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Uniform3fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform3iARB)(GLint, GLint, GLint, GLint); -#define CALL_Uniform3iARB(disp, parameters) \ - (* GET_Uniform3iARB(disp)) parameters -static inline _glptr_Uniform3iARB GET_Uniform3iARB(struct _glapi_table *disp) { - return (_glptr_Uniform3iARB) (GET_by_offset(disp, _gloffset_Uniform3iARB)); -} - -static inline void SET_Uniform3iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Uniform3iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform3ivARB)(GLint, GLsizei, const GLint *); -#define CALL_Uniform3ivARB(disp, parameters) \ - (* GET_Uniform3ivARB(disp)) parameters -static inline _glptr_Uniform3ivARB GET_Uniform3ivARB(struct _glapi_table *disp) { - return (_glptr_Uniform3ivARB) (GET_by_offset(disp, _gloffset_Uniform3ivARB)); -} - -static inline void SET_Uniform3ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLint *)) { - SET_by_offset(disp, _gloffset_Uniform3ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); -#define CALL_Uniform4fARB(disp, parameters) \ - (* GET_Uniform4fARB(disp)) parameters -static inline _glptr_Uniform4fARB GET_Uniform4fARB(struct _glapi_table *disp) { - return (_glptr_Uniform4fARB) (GET_by_offset(disp, _gloffset_Uniform4fARB)); -} - -static inline void SET_Uniform4fARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLfloat, GLfloat, GLfloat, GLfloat)) { - SET_by_offset(disp, _gloffset_Uniform4fARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform4fvARB)(GLint, GLsizei, const GLfloat *); -#define CALL_Uniform4fvARB(disp, parameters) \ - (* GET_Uniform4fvARB(disp)) parameters -static inline _glptr_Uniform4fvARB GET_Uniform4fvARB(struct _glapi_table *disp) { - return (_glptr_Uniform4fvARB) (GET_by_offset(disp, _gloffset_Uniform4fvARB)); -} - -static inline void SET_Uniform4fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLfloat *)) { - SET_by_offset(disp, _gloffset_Uniform4fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform4iARB)(GLint, GLint, GLint, GLint, GLint); -#define CALL_Uniform4iARB(disp, parameters) \ - (* GET_Uniform4iARB(disp)) parameters -static inline _glptr_Uniform4iARB GET_Uniform4iARB(struct _glapi_table *disp) { - return (_glptr_Uniform4iARB) (GET_by_offset(disp, _gloffset_Uniform4iARB)); -} - -static inline void SET_Uniform4iARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_Uniform4iARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform4ivARB)(GLint, GLsizei, const GLint *); -#define CALL_Uniform4ivARB(disp, parameters) \ - (* GET_Uniform4ivARB(disp)) parameters -static inline _glptr_Uniform4ivARB GET_Uniform4ivARB(struct _glapi_table *disp) { - return (_glptr_Uniform4ivARB) (GET_by_offset(disp, _gloffset_Uniform4ivARB)); -} - -static inline void SET_Uniform4ivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLint *)) { - SET_by_offset(disp, _gloffset_Uniform4ivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix2fvARB(disp, parameters) \ - (* GET_UniformMatrix2fvARB(disp)) parameters -static inline _glptr_UniformMatrix2fvARB GET_UniformMatrix2fvARB(struct _glapi_table *disp) { - return (_glptr_UniformMatrix2fvARB) (GET_by_offset(disp, _gloffset_UniformMatrix2fvARB)); -} - -static inline void SET_UniformMatrix2fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix2fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix3fvARB(disp, parameters) \ - (* GET_UniformMatrix3fvARB(disp)) parameters -static inline _glptr_UniformMatrix3fvARB GET_UniformMatrix3fvARB(struct _glapi_table *disp) { - return (_glptr_UniformMatrix3fvARB) (GET_by_offset(disp, _gloffset_UniformMatrix3fvARB)); -} - -static inline void SET_UniformMatrix3fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix3fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_UniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat *); -#define CALL_UniformMatrix4fvARB(disp, parameters) \ - (* GET_UniformMatrix4fvARB(disp)) parameters -static inline _glptr_UniformMatrix4fvARB GET_UniformMatrix4fvARB(struct _glapi_table *disp) { - return (_glptr_UniformMatrix4fvARB) (GET_by_offset(disp, _gloffset_UniformMatrix4fvARB)); -} - -static inline void SET_UniformMatrix4fvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, GLboolean, const GLfloat *)) { - SET_by_offset(disp, _gloffset_UniformMatrix4fvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_UseProgramObjectARB)(GLhandleARB); -#define CALL_UseProgramObjectARB(disp, parameters) \ - (* GET_UseProgramObjectARB(disp)) parameters -static inline _glptr_UseProgramObjectARB GET_UseProgramObjectARB(struct _glapi_table *disp) { - return (_glptr_UseProgramObjectARB) (GET_by_offset(disp, _gloffset_UseProgramObjectARB)); -} - -static inline void SET_UseProgramObjectARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB)) { - SET_by_offset(disp, _gloffset_UseProgramObjectARB, fn); -} - typedef void (GLAPIENTRYP _glptr_ValidateProgramARB)(GLhandleARB); #define CALL_ValidateProgramARB(disp, parameters) \ (* GET_ValidateProgramARB(disp)) parameters @@ -7669,17 +5670,6 @@ static inline void SET_ValidateProgramARB(struct _glapi_table *disp, void (GLAPI SET_by_offset(disp, _gloffset_ValidateProgramARB, fn); } -typedef void (GLAPIENTRYP _glptr_BindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB *); -#define CALL_BindAttribLocationARB(disp, parameters) \ - (* GET_BindAttribLocationARB(disp)) parameters -static inline _glptr_BindAttribLocationARB GET_BindAttribLocationARB(struct _glapi_table *disp) { - return (_glptr_BindAttribLocationARB) (GET_by_offset(disp, _gloffset_BindAttribLocationARB)); -} - -static inline void SET_BindAttribLocationARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLuint, const GLcharARB *)) { - SET_by_offset(disp, _gloffset_BindAttribLocationARB, fn); -} - typedef void (GLAPIENTRYP _glptr_GetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); #define CALL_GetActiveAttribARB(disp, parameters) \ (* GET_GetActiveAttribARB(disp)) parameters @@ -7691,17 +5681,6 @@ static inline void SET_GetActiveAttribARB(struct _glapi_table *disp, void (GLAPI SET_by_offset(disp, _gloffset_GetActiveAttribARB, fn); } -typedef GLint (GLAPIENTRYP _glptr_GetAttribLocationARB)(GLhandleARB, const GLcharARB *); -#define CALL_GetAttribLocationARB(disp, parameters) \ - (* GET_GetAttribLocationARB(disp)) parameters -static inline _glptr_GetAttribLocationARB GET_GetAttribLocationARB(struct _glapi_table *disp) { - return (_glptr_GetAttribLocationARB) (GET_by_offset(disp, _gloffset_GetAttribLocationARB)); -} - -static inline void SET_GetAttribLocationARB(struct _glapi_table *disp, GLint (GLAPIENTRYP fn)(GLhandleARB, const GLcharARB *)) { - SET_by_offset(disp, _gloffset_GetAttribLocationARB, fn); -} - typedef void (GLAPIENTRYP _glptr_FlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr); #define CALL_FlushMappedBufferRange(disp, parameters) \ (* GET_FlushMappedBufferRange(disp)) parameters @@ -7900,50 +5879,6 @@ static inline void SET_GetnTexImageARB(struct _glapi_table *disp, void (GLAPIENT SET_by_offset(disp, _gloffset_GetnTexImageARB, fn); } -typedef void (GLAPIENTRYP _glptr_GetnUniformdvARB)(GLhandleARB, GLint, GLsizei, GLdouble *); -#define CALL_GetnUniformdvARB(disp, parameters) \ - (* GET_GetnUniformdvARB(disp)) parameters -static inline _glptr_GetnUniformdvARB GET_GetnUniformdvARB(struct _glapi_table *disp) { - return (_glptr_GetnUniformdvARB) (GET_by_offset(disp, _gloffset_GetnUniformdvARB)); -} - -static inline void SET_GetnUniformdvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLint, GLsizei, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetnUniformdvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetnUniformfvARB)(GLhandleARB, GLint, GLsizei, GLfloat *); -#define CALL_GetnUniformfvARB(disp, parameters) \ - (* GET_GetnUniformfvARB(disp)) parameters -static inline _glptr_GetnUniformfvARB GET_GetnUniformfvARB(struct _glapi_table *disp) { - return (_glptr_GetnUniformfvARB) (GET_by_offset(disp, _gloffset_GetnUniformfvARB)); -} - -static inline void SET_GetnUniformfvARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLint, GLsizei, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetnUniformfvARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetnUniformivARB)(GLhandleARB, GLint, GLsizei, GLint *); -#define CALL_GetnUniformivARB(disp, parameters) \ - (* GET_GetnUniformivARB(disp)) parameters -static inline _glptr_GetnUniformivARB GET_GetnUniformivARB(struct _glapi_table *disp) { - return (_glptr_GetnUniformivARB) (GET_by_offset(disp, _gloffset_GetnUniformivARB)); -} - -static inline void SET_GetnUniformivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLint, GLsizei, GLint *)) { - SET_by_offset(disp, _gloffset_GetnUniformivARB, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetnUniformuivARB)(GLhandleARB, GLint, GLsizei, GLuint *); -#define CALL_GetnUniformuivARB(disp, parameters) \ - (* GET_GetnUniformuivARB(disp)) parameters -static inline _glptr_GetnUniformuivARB GET_GetnUniformuivARB(struct _glapi_table *disp) { - return (_glptr_GetnUniformuivARB) (GET_by_offset(disp, _gloffset_GetnUniformuivARB)); -} - -static inline void SET_GetnUniformuivARB(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLhandleARB, GLint, GLsizei, GLuint *)) { - SET_by_offset(disp, _gloffset_GetnUniformuivARB, fn); -} - typedef void (GLAPIENTRYP _glptr_ReadnPixelsARB)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLsizei, GLvoid *); #define CALL_ReadnPixelsARB(disp, parameters) \ (* GET_ReadnPixelsARB(disp)) parameters @@ -8032,72 +5967,6 @@ static inline void SET_PolygonOffsetEXT(struct _glapi_table *disp, void (GLAPIEN SET_by_offset(disp, _gloffset_PolygonOffsetEXT, fn); } -typedef void (GLAPIENTRYP _glptr_GetPixelTexGenParameterfvSGIS)(GLenum, GLfloat *); -#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) \ - (* GET_GetPixelTexGenParameterfvSGIS(disp)) parameters -static inline _glptr_GetPixelTexGenParameterfvSGIS GET_GetPixelTexGenParameterfvSGIS(struct _glapi_table *disp) { - return (_glptr_GetPixelTexGenParameterfvSGIS) (GET_by_offset(disp, _gloffset_GetPixelTexGenParameterfvSGIS)); -} - -static inline void SET_GetPixelTexGenParameterfvSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetPixelTexGenParameterfvSGIS, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetPixelTexGenParameterivSGIS)(GLenum, GLint *); -#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) \ - (* GET_GetPixelTexGenParameterivSGIS(disp)) parameters -static inline _glptr_GetPixelTexGenParameterivSGIS GET_GetPixelTexGenParameterivSGIS(struct _glapi_table *disp) { - return (_glptr_GetPixelTexGenParameterivSGIS) (GET_by_offset(disp, _gloffset_GetPixelTexGenParameterivSGIS)); -} - -static inline void SET_GetPixelTexGenParameterivSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetPixelTexGenParameterivSGIS, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelTexGenParameterfSGIS)(GLenum, GLfloat); -#define CALL_PixelTexGenParameterfSGIS(disp, parameters) \ - (* GET_PixelTexGenParameterfSGIS(disp)) parameters -static inline _glptr_PixelTexGenParameterfSGIS GET_PixelTexGenParameterfSGIS(struct _glapi_table *disp) { - return (_glptr_PixelTexGenParameterfSGIS) (GET_by_offset(disp, _gloffset_PixelTexGenParameterfSGIS)); -} - -static inline void SET_PixelTexGenParameterfSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat)) { - SET_by_offset(disp, _gloffset_PixelTexGenParameterfSGIS, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelTexGenParameterfvSGIS)(GLenum, const GLfloat *); -#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) \ - (* GET_PixelTexGenParameterfvSGIS(disp)) parameters -static inline _glptr_PixelTexGenParameterfvSGIS GET_PixelTexGenParameterfvSGIS(struct _glapi_table *disp) { - return (_glptr_PixelTexGenParameterfvSGIS) (GET_by_offset(disp, _gloffset_PixelTexGenParameterfvSGIS)); -} - -static inline void SET_PixelTexGenParameterfvSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_PixelTexGenParameterfvSGIS, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelTexGenParameteriSGIS)(GLenum, GLint); -#define CALL_PixelTexGenParameteriSGIS(disp, parameters) \ - (* GET_PixelTexGenParameteriSGIS(disp)) parameters -static inline _glptr_PixelTexGenParameteriSGIS GET_PixelTexGenParameteriSGIS(struct _glapi_table *disp) { - return (_glptr_PixelTexGenParameteriSGIS) (GET_by_offset(disp, _gloffset_PixelTexGenParameteriSGIS)); -} - -static inline void SET_PixelTexGenParameteriSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint)) { - SET_by_offset(disp, _gloffset_PixelTexGenParameteriSGIS, fn); -} - -typedef void (GLAPIENTRYP _glptr_PixelTexGenParameterivSGIS)(GLenum, const GLint *); -#define CALL_PixelTexGenParameterivSGIS(disp, parameters) \ - (* GET_PixelTexGenParameterivSGIS(disp)) parameters -static inline _glptr_PixelTexGenParameterivSGIS GET_PixelTexGenParameterivSGIS(struct _glapi_table *disp) { - return (_glptr_PixelTexGenParameterivSGIS) (GET_by_offset(disp, _gloffset_PixelTexGenParameterivSGIS)); -} - -static inline void SET_PixelTexGenParameterivSGIS(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_PixelTexGenParameterivSGIS, fn); -} - typedef void (GLAPIENTRYP _glptr_SampleMaskSGIS)(GLclampf, GLboolean); #define CALL_SampleMaskSGIS(disp, parameters) \ (* GET_SampleMaskSGIS(disp)) parameters @@ -8428,17 +6297,6 @@ static inline void SET_MultiDrawArraysEXT(struct _glapi_table *disp, void (GLAPI SET_by_offset(disp, _gloffset_MultiDrawArraysEXT, fn); } -typedef void (GLAPIENTRYP _glptr_MultiDrawElementsEXT)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei); -#define CALL_MultiDrawElementsEXT(disp, parameters) \ - (* GET_MultiDrawElementsEXT(disp)) parameters -static inline _glptr_MultiDrawElementsEXT GET_MultiDrawElementsEXT(struct _glapi_table *disp) { - return (_glptr_MultiDrawElementsEXT) (GET_by_offset(disp, _gloffset_MultiDrawElementsEXT)); -} - -static inline void SET_MultiDrawElementsEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei)) { - SET_by_offset(disp, _gloffset_MultiDrawElementsEXT, fn); -} - typedef void (GLAPIENTRYP _glptr_FogCoordPointerEXT)(GLenum, GLsizei, const GLvoid *); #define CALL_FogCoordPointerEXT(disp, parameters) \ (* GET_FogCoordPointerEXT(disp)) parameters @@ -9055,28 +6913,6 @@ static inline void SET_AreProgramsResidentNV(struct _glapi_table *disp, GLboolea SET_by_offset(disp, _gloffset_AreProgramsResidentNV, fn); } -typedef void (GLAPIENTRYP _glptr_BindProgramNV)(GLenum, GLuint); -#define CALL_BindProgramNV(disp, parameters) \ - (* GET_BindProgramNV(disp)) parameters -static inline _glptr_BindProgramNV GET_BindProgramNV(struct _glapi_table *disp) { - return (_glptr_BindProgramNV) (GET_by_offset(disp, _gloffset_BindProgramNV)); -} - -static inline void SET_BindProgramNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint)) { - SET_by_offset(disp, _gloffset_BindProgramNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_DeleteProgramsNV)(GLsizei, const GLuint *); -#define CALL_DeleteProgramsNV(disp, parameters) \ - (* GET_DeleteProgramsNV(disp)) parameters -static inline _glptr_DeleteProgramsNV GET_DeleteProgramsNV(struct _glapi_table *disp) { - return (_glptr_DeleteProgramsNV) (GET_by_offset(disp, _gloffset_DeleteProgramsNV)); -} - -static inline void SET_DeleteProgramsNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_DeleteProgramsNV, fn); -} - typedef void (GLAPIENTRYP _glptr_ExecuteProgramNV)(GLenum, GLuint, const GLfloat *); #define CALL_ExecuteProgramNV(disp, parameters) \ (* GET_ExecuteProgramNV(disp)) parameters @@ -9088,17 +6924,6 @@ static inline void SET_ExecuteProgramNV(struct _glapi_table *disp, void (GLAPIEN SET_by_offset(disp, _gloffset_ExecuteProgramNV, fn); } -typedef void (GLAPIENTRYP _glptr_GenProgramsNV)(GLsizei, GLuint *); -#define CALL_GenProgramsNV(disp, parameters) \ - (* GET_GenProgramsNV(disp)) parameters -static inline _glptr_GenProgramsNV GET_GenProgramsNV(struct _glapi_table *disp) { - return (_glptr_GenProgramsNV) (GET_by_offset(disp, _gloffset_GenProgramsNV)); -} - -static inline void SET_GenProgramsNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLsizei, GLuint *)) { - SET_by_offset(disp, _gloffset_GenProgramsNV, fn); -} - typedef void (GLAPIENTRYP _glptr_GetProgramParameterdvNV)(GLenum, GLuint, GLenum, GLdouble *); #define CALL_GetProgramParameterdvNV(disp, parameters) \ (* GET_GetProgramParameterdvNV(disp)) parameters @@ -9121,28 +6946,6 @@ static inline void SET_GetProgramParameterfvNV(struct _glapi_table *disp, void ( SET_by_offset(disp, _gloffset_GetProgramParameterfvNV, fn); } -typedef void (GLAPIENTRYP _glptr_GetProgramStringNV)(GLuint, GLenum, GLubyte *); -#define CALL_GetProgramStringNV(disp, parameters) \ - (* GET_GetProgramStringNV(disp)) parameters -static inline _glptr_GetProgramStringNV GET_GetProgramStringNV(struct _glapi_table *disp) { - return (_glptr_GetProgramStringNV) (GET_by_offset(disp, _gloffset_GetProgramStringNV)); -} - -static inline void SET_GetProgramStringNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLubyte *)) { - SET_by_offset(disp, _gloffset_GetProgramStringNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetProgramivNV)(GLuint, GLenum, GLint *); -#define CALL_GetProgramivNV(disp, parameters) \ - (* GET_GetProgramivNV(disp)) parameters -static inline _glptr_GetProgramivNV GET_GetProgramivNV(struct _glapi_table *disp) { - return (_glptr_GetProgramivNV) (GET_by_offset(disp, _gloffset_GetProgramivNV)); -} - -static inline void SET_GetProgramivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetProgramivNV, fn); -} - typedef void (GLAPIENTRYP _glptr_GetTrackMatrixivNV)(GLenum, GLuint, GLenum, GLint *); #define CALL_GetTrackMatrixivNV(disp, parameters) \ (* GET_GetTrackMatrixivNV(disp)) parameters @@ -9154,61 +6957,6 @@ static inline void SET_GetTrackMatrixivNV(struct _glapi_table *disp, void (GLAPI SET_by_offset(disp, _gloffset_GetTrackMatrixivNV, fn); } -typedef void (GLAPIENTRYP _glptr_GetVertexAttribPointervNV)(GLuint, GLenum, GLvoid **); -#define CALL_GetVertexAttribPointervNV(disp, parameters) \ - (* GET_GetVertexAttribPointervNV(disp)) parameters -static inline _glptr_GetVertexAttribPointervNV GET_GetVertexAttribPointervNV(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribPointervNV) (GET_by_offset(disp, _gloffset_GetVertexAttribPointervNV)); -} - -static inline void SET_GetVertexAttribPointervNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLvoid **)) { - SET_by_offset(disp, _gloffset_GetVertexAttribPointervNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribdvNV)(GLuint, GLenum, GLdouble *); -#define CALL_GetVertexAttribdvNV(disp, parameters) \ - (* GET_GetVertexAttribdvNV(disp)) parameters -static inline _glptr_GetVertexAttribdvNV GET_GetVertexAttribdvNV(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribdvNV) (GET_by_offset(disp, _gloffset_GetVertexAttribdvNV)); -} - -static inline void SET_GetVertexAttribdvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLdouble *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribdvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribfvNV)(GLuint, GLenum, GLfloat *); -#define CALL_GetVertexAttribfvNV(disp, parameters) \ - (* GET_GetVertexAttribfvNV(disp)) parameters -static inline _glptr_GetVertexAttribfvNV GET_GetVertexAttribfvNV(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribfvNV) (GET_by_offset(disp, _gloffset_GetVertexAttribfvNV)); -} - -static inline void SET_GetVertexAttribfvNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribfvNV, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribivNV)(GLuint, GLenum, GLint *); -#define CALL_GetVertexAttribivNV(disp, parameters) \ - (* GET_GetVertexAttribivNV(disp)) parameters -static inline _glptr_GetVertexAttribivNV GET_GetVertexAttribivNV(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribivNV) (GET_by_offset(disp, _gloffset_GetVertexAttribivNV)); -} - -static inline void SET_GetVertexAttribivNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribivNV, fn); -} - -typedef GLboolean (GLAPIENTRYP _glptr_IsProgramNV)(GLuint); -#define CALL_IsProgramNV(disp, parameters) \ - (* GET_IsProgramNV(disp)) parameters -static inline _glptr_IsProgramNV GET_IsProgramNV(struct _glapi_table *disp) { - return (_glptr_IsProgramNV) (GET_by_offset(disp, _gloffset_IsProgramNV)); -} - -static inline void SET_IsProgramNV(struct _glapi_table *disp, GLboolean (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_IsProgramNV, fn); -} - typedef void (GLAPIENTRYP _glptr_LoadProgramNV)(GLenum, GLuint, GLsizei, const GLubyte *); #define CALL_LoadProgramNV(disp, parameters) \ (* GET_LoadProgramNV(disp)) parameters @@ -9550,17 +7298,6 @@ static inline void SET_VertexAttrib4ubvNV(struct _glapi_table *disp, void (GLAPI SET_by_offset(disp, _gloffset_VertexAttrib4ubvNV, fn); } -typedef void (GLAPIENTRYP _glptr_VertexAttribPointerNV)(GLuint, GLint, GLenum, GLsizei, const GLvoid *); -#define CALL_VertexAttribPointerNV(disp, parameters) \ - (* GET_VertexAttribPointerNV(disp)) parameters -static inline _glptr_VertexAttribPointerNV GET_VertexAttribPointerNV(struct _glapi_table *disp) { - return (_glptr_VertexAttribPointerNV) (GET_by_offset(disp, _gloffset_VertexAttribPointerNV)); -} - -static inline void SET_VertexAttribPointerNV(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint, GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_VertexAttribPointerNV, fn); -} - typedef void (GLAPIENTRYP _glptr_VertexAttribs1dvNV)(GLuint, GLsizei, const GLdouble *); #define CALL_VertexAttribs1dvNV(disp, parameters) \ (* GET_VertexAttribs1dvNV(disp)) parameters @@ -9704,50 +7441,6 @@ static inline void SET_VertexAttribs4ubvNV(struct _glapi_table *disp, void (GLAP SET_by_offset(disp, _gloffset_VertexAttribs4ubvNV, fn); } -typedef void (GLAPIENTRYP _glptr_GetTexBumpParameterfvATI)(GLenum, GLfloat *); -#define CALL_GetTexBumpParameterfvATI(disp, parameters) \ - (* GET_GetTexBumpParameterfvATI(disp)) parameters -static inline _glptr_GetTexBumpParameterfvATI GET_GetTexBumpParameterfvATI(struct _glapi_table *disp) { - return (_glptr_GetTexBumpParameterfvATI) (GET_by_offset(disp, _gloffset_GetTexBumpParameterfvATI)); -} - -static inline void SET_GetTexBumpParameterfvATI(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLfloat *)) { - SET_by_offset(disp, _gloffset_GetTexBumpParameterfvATI, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetTexBumpParameterivATI)(GLenum, GLint *); -#define CALL_GetTexBumpParameterivATI(disp, parameters) \ - (* GET_GetTexBumpParameterivATI(disp)) parameters -static inline _glptr_GetTexBumpParameterivATI GET_GetTexBumpParameterivATI(struct _glapi_table *disp) { - return (_glptr_GetTexBumpParameterivATI) (GET_by_offset(disp, _gloffset_GetTexBumpParameterivATI)); -} - -static inline void SET_GetTexBumpParameterivATI(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetTexBumpParameterivATI, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexBumpParameterfvATI)(GLenum, const GLfloat *); -#define CALL_TexBumpParameterfvATI(disp, parameters) \ - (* GET_TexBumpParameterfvATI(disp)) parameters -static inline _glptr_TexBumpParameterfvATI GET_TexBumpParameterfvATI(struct _glapi_table *disp) { - return (_glptr_TexBumpParameterfvATI) (GET_by_offset(disp, _gloffset_TexBumpParameterfvATI)); -} - -static inline void SET_TexBumpParameterfvATI(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLfloat *)) { - SET_by_offset(disp, _gloffset_TexBumpParameterfvATI, fn); -} - -typedef void (GLAPIENTRYP _glptr_TexBumpParameterivATI)(GLenum, const GLint *); -#define CALL_TexBumpParameterivATI(disp, parameters) \ - (* GET_TexBumpParameterivATI(disp)) parameters -static inline _glptr_TexBumpParameterivATI GET_TexBumpParameterivATI(struct _glapi_table *disp) { - return (_glptr_TexBumpParameterivATI) (GET_by_offset(disp, _gloffset_TexBumpParameterivATI)); -} - -static inline void SET_TexBumpParameterivATI(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, const GLint *)) { - SET_by_offset(disp, _gloffset_TexBumpParameterivATI, fn); -} - typedef void (GLAPIENTRYP _glptr_PointParameteriNV)(GLenum, GLint); #define CALL_PointParameteriNV(disp, parameters) \ (* GET_PointParameteriNV(disp)) parameters @@ -9957,358 +7650,6 @@ static inline void SET_GetFragDataLocationEXT(struct _glapi_table *disp, GLint ( SET_by_offset(disp, _gloffset_GetFragDataLocationEXT, fn); } -typedef void (GLAPIENTRYP _glptr_GetUniformuivEXT)(GLuint, GLint, GLuint *); -#define CALL_GetUniformuivEXT(disp, parameters) \ - (* GET_GetUniformuivEXT(disp)) parameters -static inline _glptr_GetUniformuivEXT GET_GetUniformuivEXT(struct _glapi_table *disp) { - return (_glptr_GetUniformuivEXT) (GET_by_offset(disp, _gloffset_GetUniformuivEXT)); -} - -static inline void SET_GetUniformuivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint, GLuint *)) { - SET_by_offset(disp, _gloffset_GetUniformuivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribIivEXT)(GLuint, GLenum, GLint *); -#define CALL_GetVertexAttribIivEXT(disp, parameters) \ - (* GET_GetVertexAttribIivEXT(disp)) parameters -static inline _glptr_GetVertexAttribIivEXT GET_GetVertexAttribIivEXT(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribIivEXT) (GET_by_offset(disp, _gloffset_GetVertexAttribIivEXT)); -} - -static inline void SET_GetVertexAttribIivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLint *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribIivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_GetVertexAttribIuivEXT)(GLuint, GLenum, GLuint *); -#define CALL_GetVertexAttribIuivEXT(disp, parameters) \ - (* GET_GetVertexAttribIuivEXT(disp)) parameters -static inline _glptr_GetVertexAttribIuivEXT GET_GetVertexAttribIuivEXT(struct _glapi_table *disp) { - return (_glptr_GetVertexAttribIuivEXT) (GET_by_offset(disp, _gloffset_GetVertexAttribIuivEXT)); -} - -static inline void SET_GetVertexAttribIuivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLenum, GLuint *)) { - SET_by_offset(disp, _gloffset_GetVertexAttribIuivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform1uiEXT)(GLint, GLuint); -#define CALL_Uniform1uiEXT(disp, parameters) \ - (* GET_Uniform1uiEXT(disp)) parameters -static inline _glptr_Uniform1uiEXT GET_Uniform1uiEXT(struct _glapi_table *disp) { - return (_glptr_Uniform1uiEXT) (GET_by_offset(disp, _gloffset_Uniform1uiEXT)); -} - -static inline void SET_Uniform1uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLuint)) { - SET_by_offset(disp, _gloffset_Uniform1uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform1uivEXT)(GLint, GLsizei, const GLuint *); -#define CALL_Uniform1uivEXT(disp, parameters) \ - (* GET_Uniform1uivEXT(disp)) parameters -static inline _glptr_Uniform1uivEXT GET_Uniform1uivEXT(struct _glapi_table *disp) { - return (_glptr_Uniform1uivEXT) (GET_by_offset(disp, _gloffset_Uniform1uivEXT)); -} - -static inline void SET_Uniform1uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_Uniform1uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform2uiEXT)(GLint, GLuint, GLuint); -#define CALL_Uniform2uiEXT(disp, parameters) \ - (* GET_Uniform2uiEXT(disp)) parameters -static inline _glptr_Uniform2uiEXT GET_Uniform2uiEXT(struct _glapi_table *disp) { - return (_glptr_Uniform2uiEXT) (GET_by_offset(disp, _gloffset_Uniform2uiEXT)); -} - -static inline void SET_Uniform2uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_Uniform2uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform2uivEXT)(GLint, GLsizei, const GLuint *); -#define CALL_Uniform2uivEXT(disp, parameters) \ - (* GET_Uniform2uivEXT(disp)) parameters -static inline _glptr_Uniform2uivEXT GET_Uniform2uivEXT(struct _glapi_table *disp) { - return (_glptr_Uniform2uivEXT) (GET_by_offset(disp, _gloffset_Uniform2uivEXT)); -} - -static inline void SET_Uniform2uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_Uniform2uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform3uiEXT)(GLint, GLuint, GLuint, GLuint); -#define CALL_Uniform3uiEXT(disp, parameters) \ - (* GET_Uniform3uiEXT(disp)) parameters -static inline _glptr_Uniform3uiEXT GET_Uniform3uiEXT(struct _glapi_table *disp) { - return (_glptr_Uniform3uiEXT) (GET_by_offset(disp, _gloffset_Uniform3uiEXT)); -} - -static inline void SET_Uniform3uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_Uniform3uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform3uivEXT)(GLint, GLsizei, const GLuint *); -#define CALL_Uniform3uivEXT(disp, parameters) \ - (* GET_Uniform3uivEXT(disp)) parameters -static inline _glptr_Uniform3uivEXT GET_Uniform3uivEXT(struct _glapi_table *disp) { - return (_glptr_Uniform3uivEXT) (GET_by_offset(disp, _gloffset_Uniform3uivEXT)); -} - -static inline void SET_Uniform3uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_Uniform3uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform4uiEXT)(GLint, GLuint, GLuint, GLuint, GLuint); -#define CALL_Uniform4uiEXT(disp, parameters) \ - (* GET_Uniform4uiEXT(disp)) parameters -static inline _glptr_Uniform4uiEXT GET_Uniform4uiEXT(struct _glapi_table *disp) { - return (_glptr_Uniform4uiEXT) (GET_by_offset(disp, _gloffset_Uniform4uiEXT)); -} - -static inline void SET_Uniform4uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLuint, GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_Uniform4uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_Uniform4uivEXT)(GLint, GLsizei, const GLuint *); -#define CALL_Uniform4uivEXT(disp, parameters) \ - (* GET_Uniform4uivEXT(disp)) parameters -static inline _glptr_Uniform4uivEXT GET_Uniform4uivEXT(struct _glapi_table *disp) { - return (_glptr_Uniform4uivEXT) (GET_by_offset(disp, _gloffset_Uniform4uivEXT)); -} - -static inline void SET_Uniform4uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLint, GLsizei, const GLuint *)) { - SET_by_offset(disp, _gloffset_Uniform4uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI1iEXT)(GLuint, GLint); -#define CALL_VertexAttribI1iEXT(disp, parameters) \ - (* GET_VertexAttribI1iEXT(disp)) parameters -static inline _glptr_VertexAttribI1iEXT GET_VertexAttribI1iEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI1iEXT) (GET_by_offset(disp, _gloffset_VertexAttribI1iEXT)); -} - -static inline void SET_VertexAttribI1iEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint)) { - SET_by_offset(disp, _gloffset_VertexAttribI1iEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI1ivEXT)(GLuint, const GLint *); -#define CALL_VertexAttribI1ivEXT(disp, parameters) \ - (* GET_VertexAttribI1ivEXT(disp)) parameters -static inline _glptr_VertexAttribI1ivEXT GET_VertexAttribI1ivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI1ivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI1ivEXT)); -} - -static inline void SET_VertexAttribI1ivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI1ivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI1uiEXT)(GLuint, GLuint); -#define CALL_VertexAttribI1uiEXT(disp, parameters) \ - (* GET_VertexAttribI1uiEXT(disp)) parameters -static inline _glptr_VertexAttribI1uiEXT GET_VertexAttribI1uiEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI1uiEXT) (GET_by_offset(disp, _gloffset_VertexAttribI1uiEXT)); -} - -static inline void SET_VertexAttribI1uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_VertexAttribI1uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI1uivEXT)(GLuint, const GLuint *); -#define CALL_VertexAttribI1uivEXT(disp, parameters) \ - (* GET_VertexAttribI1uivEXT(disp)) parameters -static inline _glptr_VertexAttribI1uivEXT GET_VertexAttribI1uivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI1uivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI1uivEXT)); -} - -static inline void SET_VertexAttribI1uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLuint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI1uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI2iEXT)(GLuint, GLint, GLint); -#define CALL_VertexAttribI2iEXT(disp, parameters) \ - (* GET_VertexAttribI2iEXT(disp)) parameters -static inline _glptr_VertexAttribI2iEXT GET_VertexAttribI2iEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI2iEXT) (GET_by_offset(disp, _gloffset_VertexAttribI2iEXT)); -} - -static inline void SET_VertexAttribI2iEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_VertexAttribI2iEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI2ivEXT)(GLuint, const GLint *); -#define CALL_VertexAttribI2ivEXT(disp, parameters) \ - (* GET_VertexAttribI2ivEXT(disp)) parameters -static inline _glptr_VertexAttribI2ivEXT GET_VertexAttribI2ivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI2ivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI2ivEXT)); -} - -static inline void SET_VertexAttribI2ivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI2ivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI2uiEXT)(GLuint, GLuint, GLuint); -#define CALL_VertexAttribI2uiEXT(disp, parameters) \ - (* GET_VertexAttribI2uiEXT(disp)) parameters -static inline _glptr_VertexAttribI2uiEXT GET_VertexAttribI2uiEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI2uiEXT) (GET_by_offset(disp, _gloffset_VertexAttribI2uiEXT)); -} - -static inline void SET_VertexAttribI2uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_VertexAttribI2uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI2uivEXT)(GLuint, const GLuint *); -#define CALL_VertexAttribI2uivEXT(disp, parameters) \ - (* GET_VertexAttribI2uivEXT(disp)) parameters -static inline _glptr_VertexAttribI2uivEXT GET_VertexAttribI2uivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI2uivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI2uivEXT)); -} - -static inline void SET_VertexAttribI2uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLuint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI2uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI3iEXT)(GLuint, GLint, GLint, GLint); -#define CALL_VertexAttribI3iEXT(disp, parameters) \ - (* GET_VertexAttribI3iEXT(disp)) parameters -static inline _glptr_VertexAttribI3iEXT GET_VertexAttribI3iEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI3iEXT) (GET_by_offset(disp, _gloffset_VertexAttribI3iEXT)); -} - -static inline void SET_VertexAttribI3iEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_VertexAttribI3iEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI3ivEXT)(GLuint, const GLint *); -#define CALL_VertexAttribI3ivEXT(disp, parameters) \ - (* GET_VertexAttribI3ivEXT(disp)) parameters -static inline _glptr_VertexAttribI3ivEXT GET_VertexAttribI3ivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI3ivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI3ivEXT)); -} - -static inline void SET_VertexAttribI3ivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI3ivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI3uiEXT)(GLuint, GLuint, GLuint, GLuint); -#define CALL_VertexAttribI3uiEXT(disp, parameters) \ - (* GET_VertexAttribI3uiEXT(disp)) parameters -static inline _glptr_VertexAttribI3uiEXT GET_VertexAttribI3uiEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI3uiEXT) (GET_by_offset(disp, _gloffset_VertexAttribI3uiEXT)); -} - -static inline void SET_VertexAttribI3uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_VertexAttribI3uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI3uivEXT)(GLuint, const GLuint *); -#define CALL_VertexAttribI3uivEXT(disp, parameters) \ - (* GET_VertexAttribI3uivEXT(disp)) parameters -static inline _glptr_VertexAttribI3uivEXT GET_VertexAttribI3uivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI3uivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI3uivEXT)); -} - -static inline void SET_VertexAttribI3uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLuint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI3uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4bvEXT)(GLuint, const GLbyte *); -#define CALL_VertexAttribI4bvEXT(disp, parameters) \ - (* GET_VertexAttribI4bvEXT(disp)) parameters -static inline _glptr_VertexAttribI4bvEXT GET_VertexAttribI4bvEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4bvEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4bvEXT)); -} - -static inline void SET_VertexAttribI4bvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLbyte *)) { - SET_by_offset(disp, _gloffset_VertexAttribI4bvEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4iEXT)(GLuint, GLint, GLint, GLint, GLint); -#define CALL_VertexAttribI4iEXT(disp, parameters) \ - (* GET_VertexAttribI4iEXT(disp)) parameters -static inline _glptr_VertexAttribI4iEXT GET_VertexAttribI4iEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4iEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4iEXT)); -} - -static inline void SET_VertexAttribI4iEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint, GLint, GLint, GLint)) { - SET_by_offset(disp, _gloffset_VertexAttribI4iEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4ivEXT)(GLuint, const GLint *); -#define CALL_VertexAttribI4ivEXT(disp, parameters) \ - (* GET_VertexAttribI4ivEXT(disp)) parameters -static inline _glptr_VertexAttribI4ivEXT GET_VertexAttribI4ivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4ivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4ivEXT)); -} - -static inline void SET_VertexAttribI4ivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI4ivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4svEXT)(GLuint, const GLshort *); -#define CALL_VertexAttribI4svEXT(disp, parameters) \ - (* GET_VertexAttribI4svEXT(disp)) parameters -static inline _glptr_VertexAttribI4svEXT GET_VertexAttribI4svEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4svEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4svEXT)); -} - -static inline void SET_VertexAttribI4svEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLshort *)) { - SET_by_offset(disp, _gloffset_VertexAttribI4svEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4ubvEXT)(GLuint, const GLubyte *); -#define CALL_VertexAttribI4ubvEXT(disp, parameters) \ - (* GET_VertexAttribI4ubvEXT(disp)) parameters -static inline _glptr_VertexAttribI4ubvEXT GET_VertexAttribI4ubvEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4ubvEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4ubvEXT)); -} - -static inline void SET_VertexAttribI4ubvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLubyte *)) { - SET_by_offset(disp, _gloffset_VertexAttribI4ubvEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4uiEXT)(GLuint, GLuint, GLuint, GLuint, GLuint); -#define CALL_VertexAttribI4uiEXT(disp, parameters) \ - (* GET_VertexAttribI4uiEXT(disp)) parameters -static inline _glptr_VertexAttribI4uiEXT GET_VertexAttribI4uiEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4uiEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4uiEXT)); -} - -static inline void SET_VertexAttribI4uiEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLuint, GLuint, GLuint, GLuint)) { - SET_by_offset(disp, _gloffset_VertexAttribI4uiEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4uivEXT)(GLuint, const GLuint *); -#define CALL_VertexAttribI4uivEXT(disp, parameters) \ - (* GET_VertexAttribI4uivEXT(disp)) parameters -static inline _glptr_VertexAttribI4uivEXT GET_VertexAttribI4uivEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4uivEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4uivEXT)); -} - -static inline void SET_VertexAttribI4uivEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLuint *)) { - SET_by_offset(disp, _gloffset_VertexAttribI4uivEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribI4usvEXT)(GLuint, const GLushort *); -#define CALL_VertexAttribI4usvEXT(disp, parameters) \ - (* GET_VertexAttribI4usvEXT(disp)) parameters -static inline _glptr_VertexAttribI4usvEXT GET_VertexAttribI4usvEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribI4usvEXT) (GET_by_offset(disp, _gloffset_VertexAttribI4usvEXT)); -} - -static inline void SET_VertexAttribI4usvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, const GLushort *)) { - SET_by_offset(disp, _gloffset_VertexAttribI4usvEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_VertexAttribIPointerEXT)(GLuint, GLint, GLenum, GLsizei, const GLvoid *); -#define CALL_VertexAttribIPointerEXT(disp, parameters) \ - (* GET_VertexAttribIPointerEXT(disp)) parameters -static inline _glptr_VertexAttribIPointerEXT GET_VertexAttribIPointerEXT(struct _glapi_table *disp) { - return (_glptr_VertexAttribIPointerEXT) (GET_by_offset(disp, _gloffset_VertexAttribIPointerEXT)); -} - -static inline void SET_VertexAttribIPointerEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint, GLint, GLenum, GLsizei, const GLvoid *)) { - SET_by_offset(disp, _gloffset_VertexAttribIPointerEXT, fn); -} - typedef void (GLAPIENTRYP _glptr_ClearColorIiEXT)(GLint, GLint, GLint, GLint); #define CALL_ClearColorIiEXT(disp, parameters) \ (* GET_ClearColorIiEXT(disp)) parameters @@ -10430,17 +7771,6 @@ static inline void SET_ObjectUnpurgeableAPPLE(struct _glapi_table *disp, GLenum SET_by_offset(disp, _gloffset_ObjectUnpurgeableAPPLE, fn); } -typedef void (GLAPIENTRYP _glptr_ActiveProgramEXT)(GLuint); -#define CALL_ActiveProgramEXT(disp, parameters) \ - (* GET_ActiveProgramEXT(disp)) parameters -static inline _glptr_ActiveProgramEXT GET_ActiveProgramEXT(struct _glapi_table *disp) { - return (_glptr_ActiveProgramEXT) (GET_by_offset(disp, _gloffset_ActiveProgramEXT)); -} - -static inline void SET_ActiveProgramEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLuint)) { - SET_by_offset(disp, _gloffset_ActiveProgramEXT, fn); -} - typedef GLuint (GLAPIENTRYP _glptr_CreateShaderProgramEXT)(GLenum, const GLchar *); #define CALL_CreateShaderProgramEXT(disp, parameters) \ (* GET_CreateShaderProgramEXT(disp)) parameters @@ -10452,17 +7782,6 @@ static inline void SET_CreateShaderProgramEXT(struct _glapi_table *disp, GLuint SET_by_offset(disp, _gloffset_CreateShaderProgramEXT, fn); } -typedef void (GLAPIENTRYP _glptr_UseShaderProgramEXT)(GLenum, GLuint); -#define CALL_UseShaderProgramEXT(disp, parameters) \ - (* GET_UseShaderProgramEXT(disp)) parameters -static inline _glptr_UseShaderProgramEXT GET_UseShaderProgramEXT(struct _glapi_table *disp) { - return (_glptr_UseShaderProgramEXT) (GET_by_offset(disp, _gloffset_UseShaderProgramEXT)); -} - -static inline void SET_UseShaderProgramEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint)) { - SET_by_offset(disp, _gloffset_UseShaderProgramEXT, fn); -} - typedef void (GLAPIENTRYP _glptr_TextureBarrierNV)(void); #define CALL_TextureBarrierNV(disp, parameters) \ (* GET_TextureBarrierNV(disp)) parameters @@ -10485,27 +7804,5 @@ static inline void SET_StencilFuncSeparateATI(struct _glapi_table *disp, void (G SET_by_offset(disp, _gloffset_StencilFuncSeparateATI, fn); } -typedef void (GLAPIENTRYP _glptr_ProgramEnvParameters4fvEXT)(GLenum, GLuint, GLsizei, const GLfloat *); -#define CALL_ProgramEnvParameters4fvEXT(disp, parameters) \ - (* GET_ProgramEnvParameters4fvEXT(disp)) parameters -static inline _glptr_ProgramEnvParameters4fvEXT GET_ProgramEnvParameters4fvEXT(struct _glapi_table *disp) { - return (_glptr_ProgramEnvParameters4fvEXT) (GET_by_offset(disp, _gloffset_ProgramEnvParameters4fvEXT)); -} - -static inline void SET_ProgramEnvParameters4fvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLsizei, const GLfloat *)) { - SET_by_offset(disp, _gloffset_ProgramEnvParameters4fvEXT, fn); -} - -typedef void (GLAPIENTRYP _glptr_ProgramLocalParameters4fvEXT)(GLenum, GLuint, GLsizei, const GLfloat *); -#define CALL_ProgramLocalParameters4fvEXT(disp, parameters) \ - (* GET_ProgramLocalParameters4fvEXT(disp)) parameters -static inline _glptr_ProgramLocalParameters4fvEXT GET_ProgramLocalParameters4fvEXT(struct _glapi_table *disp) { - return (_glptr_ProgramLocalParameters4fvEXT) (GET_by_offset(disp, _gloffset_ProgramLocalParameters4fvEXT)); -} - -static inline void SET_ProgramLocalParameters4fvEXT(struct _glapi_table *disp, void (GLAPIENTRYP fn)(GLenum, GLuint, GLsizei, const GLfloat *)) { - SET_by_offset(disp, _gloffset_ProgramLocalParameters4fvEXT, fn); -} - #endif /* !defined( _DISPATCH_H_ ) */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/dlist.c b/reactos/dll/opengl/mesa/src/mesa/main/dlist.c index 443abdac748..4fdf5044484 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/dlist.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/dlist.c @@ -51,17 +51,10 @@ #include "macros.h" #include "pack.h" #include "pbo.h" -#include "shaderapi.h" #include "teximage.h" #include "texstorage.h" #include "mtypes.h" #include "varray.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#endif -#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "nvprogram.h" -#endif #include "math/m_matrix.h" @@ -291,73 +284,19 @@ typedef enum OPCODE_TRANSLATE, OPCODE_VIEWPORT, OPCODE_WINDOW_POS, - /* GL_ARB_multitexture */ - OPCODE_ACTIVE_TEXTURE, /* GL_ARB_multisample */ OPCODE_SAMPLE_COVERAGE, /* GL_ARB_window_pos */ OPCODE_WINDOW_POS_ARB, - /* GL_NV_vertex_program */ - OPCODE_BIND_PROGRAM_NV, - OPCODE_EXECUTE_PROGRAM_NV, - OPCODE_REQUEST_RESIDENT_PROGRAMS_NV, - OPCODE_LOAD_PROGRAM_NV, - OPCODE_TRACK_MATRIX_NV, - /* GL_NV_fragment_program */ - OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, - OPCODE_PROGRAM_NAMED_PARAMETER_NV, /* GL_EXT_stencil_two_side */ OPCODE_ACTIVE_STENCIL_FACE_EXT, /* GL_EXT_depth_bounds_test */ OPCODE_DEPTH_BOUNDS_EXT, - /* GL_ARB_vertex/fragment_program */ - OPCODE_PROGRAM_STRING_ARB, - OPCODE_PROGRAM_ENV_PARAMETER_ARB, - /* GL_ATI_fragment_shader */ - OPCODE_TEX_BUMP_PARAMETER_ATI, /* OpenGL 2.0 */ OPCODE_STENCIL_FUNC_SEPARATE, OPCODE_STENCIL_OP_SEPARATE, OPCODE_STENCIL_MASK_SEPARATE, - /* GL_ARB_shader_objects */ - OPCODE_USE_PROGRAM, - OPCODE_UNIFORM_1F, - OPCODE_UNIFORM_2F, - OPCODE_UNIFORM_3F, - OPCODE_UNIFORM_4F, - OPCODE_UNIFORM_1FV, - OPCODE_UNIFORM_2FV, - OPCODE_UNIFORM_3FV, - OPCODE_UNIFORM_4FV, - OPCODE_UNIFORM_1I, - OPCODE_UNIFORM_2I, - OPCODE_UNIFORM_3I, - OPCODE_UNIFORM_4I, - OPCODE_UNIFORM_1IV, - OPCODE_UNIFORM_2IV, - OPCODE_UNIFORM_3IV, - OPCODE_UNIFORM_4IV, - OPCODE_UNIFORM_MATRIX22, - OPCODE_UNIFORM_MATRIX33, - OPCODE_UNIFORM_MATRIX44, - OPCODE_UNIFORM_MATRIX23, - OPCODE_UNIFORM_MATRIX32, - OPCODE_UNIFORM_MATRIX24, - OPCODE_UNIFORM_MATRIX42, - OPCODE_UNIFORM_MATRIX34, - OPCODE_UNIFORM_MATRIX43, - - /* OpenGL 3.0 */ - OPCODE_UNIFORM_1UI, - OPCODE_UNIFORM_2UI, - OPCODE_UNIFORM_3UI, - OPCODE_UNIFORM_4UI, - OPCODE_UNIFORM_1UIV, - OPCODE_UNIFORM_2UIV, - OPCODE_UNIFORM_3UIV, - OPCODE_UNIFORM_4UIV, - /* Vertex attributes -- fallback for when optimized display * list build isn't active. */ @@ -365,10 +304,6 @@ typedef enum OPCODE_ATTR_2F_NV, OPCODE_ATTR_3F_NV, OPCODE_ATTR_4F_NV, - OPCODE_ATTR_1F_ARB, - OPCODE_ATTR_2F_ARB, - OPCODE_ATTR_3F_ARB, - OPCODE_ATTR_4F_ARB, OPCODE_MATERIAL, OPCODE_BEGIN, OPCODE_END, @@ -384,10 +319,6 @@ typedef enum OPCODE_TEXPARAMETER_I, OPCODE_TEXPARAMETER_UI, - /* GL_EXT_separate_shader_objects */ - OPCODE_ACTIVE_PROGRAM_EXT, - OPCODE_USE_SHADER_PROGRAM_EXT, - /* GL_NV_texture_barrier */ OPCODE_TEXTURE_BARRIER_NV, @@ -622,56 +553,6 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist) free(n[11].data); n += InstSize[n[0].opcode]; break; -#if FEATURE_NV_vertex_program - case OPCODE_LOAD_PROGRAM_NV: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; - case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - free(n[2].data); /* array of program ids */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_NV_fragment_program - case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - free(n[3].data); /* parameter name */ - n += InstSize[n[0].opcode]; - break; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_PROGRAM_STRING_ARB: - free(n[4].data); /* program string */ - n += InstSize[n[0].opcode]; - break; -#endif - case OPCODE_UNIFORM_1FV: - case OPCODE_UNIFORM_2FV: - case OPCODE_UNIFORM_3FV: - case OPCODE_UNIFORM_4FV: - case OPCODE_UNIFORM_1IV: - case OPCODE_UNIFORM_2IV: - case OPCODE_UNIFORM_3IV: - case OPCODE_UNIFORM_4IV: - case OPCODE_UNIFORM_1UIV: - case OPCODE_UNIFORM_2UIV: - case OPCODE_UNIFORM_3UIV: - case OPCODE_UNIFORM_4UIV: - free(n[3].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_UNIFORM_MATRIX22: - case OPCODE_UNIFORM_MATRIX33: - case OPCODE_UNIFORM_MATRIX44: - case OPCODE_UNIFORM_MATRIX24: - case OPCODE_UNIFORM_MATRIX42: - case OPCODE_UNIFORM_MATRIX23: - case OPCODE_UNIFORM_MATRIX32: - case OPCODE_UNIFORM_MATRIX34: - case OPCODE_UNIFORM_MATRIX43: - free(n[4].data); - n += InstSize[n[0].opcode]; - break; - case OPCODE_CONTINUE: n = (Node *) n[1].next; free(block); @@ -4131,24 +4012,6 @@ save_WindowPos4svMESA(const GLshort * v) } - -/* GL_ARB_multitexture */ -static void GLAPIENTRY -save_ActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_TEXTURE, 1); - if (n) { - n[1].e = target; - } - if (ctx->ExecuteFlag) { - CALL_ActiveTextureARB(ctx->Exec, (target)); - } -} - - /* GL_ARB_transpose_matrix */ static void GLAPIENTRY @@ -4208,349 +4071,6 @@ save_SampleCoverageARB(GLclampf value, GLboolean invert) /* * GL_NV_vertex_program */ -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -static void GLAPIENTRY -save_BindProgramNV(GLenum target, GLuint id) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_BIND_PROGRAM_NV, 2); - if (n) { - n[1].e = target; - n[2].ui = id; - } - if (ctx->ExecuteFlag) { - CALL_BindProgramNV(ctx->Exec, (target, id)); - } -} - -static void GLAPIENTRY -save_ProgramEnvParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - save_ProgramEnvParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); -} - - -static void GLAPIENTRY -save_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat * params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramEnvParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) x, - (GLfloat) y, (GLfloat) z, (GLfloat) w); -} - - -static void GLAPIENTRY -save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - save_ProgramEnvParameter4fARB(target, index, - (GLfloat) params[0], - (GLfloat) params[1], - (GLfloat) params[2], (GLfloat) params[3]); -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program */ - -#if FEATURE_NV_vertex_program -static void GLAPIENTRY -save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_EXECUTE_PROGRAM_NV, 6); - if (n) { - n[1].e = target; - n[2].ui = id; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ExecuteProgramNV(ctx->Exec, (target, id, params)); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4dvNV(GLenum target, GLuint index, - GLsizei num, const GLdouble *params) -{ - GLint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4dvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_ProgramParameters4fvNV(GLenum target, GLuint index, - GLsizei num, const GLfloat *params) -{ - GLint i; - for (i = 0; i < num; i++) { - save_ProgramEnvParameter4fvARB(target, index + i, params + 4 * i); - } -} - - -static void GLAPIENTRY -save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, - const GLubyte * program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - memcpy(programCopy, program, len); - n[1].e = target; - n[2].ui = id; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_LoadProgramNV(ctx->Exec, (target, id, len, program)); - } -} - - -static void GLAPIENTRY -save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); - if (n) { - GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); - if (!idCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); - return; - } - memcpy(idCopy, ids, num * sizeof(GLuint)); - n[1].i = num; - n[2].data = idCopy; - } - if (ctx->ExecuteFlag) { - CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids)); - } -} - - -static void GLAPIENTRY -save_TrackMatrixNV(GLenum target, GLuint address, - GLenum matrix, GLenum transform) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4); - if (n) { - n[1].e = target; - n[2].ui = address; - n[3].e = matrix; - n[4].e = transform; - } - if (ctx->ExecuteFlag) { - CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform)); - } -} -#endif /* FEATURE_NV_vertex_program */ - - -/* - * GL_NV_fragment_program - */ -#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program -static void GLAPIENTRY -save_ProgramLocalParameter4fARB(GLenum target, GLuint index, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = x; - n[4].f = y; - n[5].f = z; - n[6].f = w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = params[0]; - n[4].f = params[1]; - n[5].f = params[2]; - n[6].f = params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, - const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - if (count > 0) { - GLint i; - const GLfloat * p = params; - - for (i = 0 ; i < count ; i++) { - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = p[0]; - n[4].f = p[1]; - n[5].f = p[2]; - n[6].f = p[3]; - p += 4; - } - } - } - - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameters4fvEXT(ctx->Exec, (target, index, count, params)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dARB(GLenum target, GLuint index, - GLdouble x, GLdouble y, - GLdouble z, GLdouble w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) x; - n[4].f = (GLfloat) y; - n[5].f = (GLfloat) z; - n[6].f = (GLfloat) w; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w)); - } -} - - -static void GLAPIENTRY -save_ProgramLocalParameter4dvARB(GLenum target, GLuint index, - const GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6); - if (n) { - n[1].e = target; - n[2].ui = index; - n[3].f = (GLfloat) params[0]; - n[4].f = (GLfloat) params[1]; - n[5].f = (GLfloat) params[2]; - n[6].f = (GLfloat) params[3]; - } - if (ctx->ExecuteFlag) { - CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params)); - } -} #if FEATURE_NV_fragment_program static void GLAPIENTRY @@ -4609,7 +4129,6 @@ save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, (GLfloat) v[3]); } #endif -#endif /* FEATURE_NV_fragment_program */ @@ -4647,69 +4166,6 @@ save_DepthBoundsEXT(GLclampd zmin, GLclampd zmax) } } - - -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - -static void GLAPIENTRY -save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, - const GLvoid * string) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - - n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); - if (n) { - GLubyte *programCopy = (GLubyte *) malloc(len); - if (!programCopy) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); - return; - } - memcpy(programCopy, string, len); - n[1].e = target; - n[2].e = format; - n[3].i = len; - n[4].data = programCopy; - } - if (ctx->ExecuteFlag) { - CALL_ProgramStringARB(ctx->Exec, (target, format, len, string)); - } -} - -#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ - -static void GLAPIENTRY -save_TexBumpParameterfvATI(GLenum pname, const GLfloat *param) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - - n = alloc_instruction(ctx, OPCODE_TEX_BUMP_PARAMETER_ATI, 5); - if (n) { - n[1].ui = pname; - n[2].f = param[0]; - n[3].f = param[1]; - n[4].f = param[2]; - n[5].f = param[3]; - } - if (ctx->ExecuteFlag) { - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, param)); - } -} - -static void GLAPIENTRY -save_TexBumpParameterivATI(GLenum pname, const GLint *param) -{ - GLfloat p[4]; - p[0] = INT_TO_FLOAT(param[0]); - p[1] = INT_TO_FLOAT(param[1]); - p[2] = INT_TO_FLOAT(param[2]); - p[3] = INT_TO_FLOAT(param[3]); - save_TexBumpParameterfvATI(pname, p); -} - static void GLAPIENTRY save_Attr1fNV(GLenum attr, GLfloat x) { @@ -4800,98 +4256,6 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) } } - -static void GLAPIENTRY -save_Attr1fARB(GLenum attr, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_1F_ARB, 2); - if (n) { - n[1].e = attr; - n[2].f = x; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 1; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib1fARB(ctx->Exec, (attr, x)); - } -} - -static void GLAPIENTRY -save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_2F_ARB, 3); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 2; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib2fARB(ctx->Exec, (attr, x, y)); - } -} - -static void GLAPIENTRY -save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_3F_ARB, 4); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 3; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib3fARB(ctx->Exec, (attr, x, y, z)); - } -} - -static void GLAPIENTRY -save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - SAVE_FLUSH_VERTICES(ctx); - n = alloc_instruction(ctx, OPCODE_ATTR_4F_ARB, 5); - if (n) { - n[1].e = attr; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); - ctx->ListState.ActiveAttribSize[attr] = 4; - ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); - - if (ctx->ExecuteFlag) { - CALL_VertexAttrib4fARB(ctx->Exec, (attr, x, y, z, w)); - } -} - - static void GLAPIENTRY save_EvalCoord1f(GLfloat x) { @@ -5184,49 +4548,49 @@ save_Vertex4fv(const GLfloat * v) static void GLAPIENTRY save_TexCoord1f(GLfloat x) { - save_Attr1fNV(VERT_ATTRIB_TEX0, x); + save_Attr1fNV(VERT_ATTRIB_TEX, x); } static void GLAPIENTRY save_TexCoord1fv(const GLfloat * v) { - save_Attr1fNV(VERT_ATTRIB_TEX0, v[0]); + save_Attr1fNV(VERT_ATTRIB_TEX, v[0]); } static void GLAPIENTRY save_TexCoord2f(GLfloat x, GLfloat y) { - save_Attr2fNV(VERT_ATTRIB_TEX0, x, y); + save_Attr2fNV(VERT_ATTRIB_TEX, x, y); } static void GLAPIENTRY save_TexCoord2fv(const GLfloat * v) { - save_Attr2fNV(VERT_ATTRIB_TEX0, v[0], v[1]); + save_Attr2fNV(VERT_ATTRIB_TEX, v[0], v[1]); } static void GLAPIENTRY save_TexCoord3f(GLfloat x, GLfloat y, GLfloat z) { - save_Attr3fNV(VERT_ATTRIB_TEX0, x, y, z); + save_Attr3fNV(VERT_ATTRIB_TEX, x, y, z); } static void GLAPIENTRY save_TexCoord3fv(const GLfloat * v) { - save_Attr3fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2]); + save_Attr3fNV(VERT_ATTRIB_TEX, v[0], v[1], v[2]); } static void GLAPIENTRY save_TexCoord4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - save_Attr4fNV(VERT_ATTRIB_TEX0, x, y, z, w); + save_Attr4fNV(VERT_ATTRIB_TEX, x, y, z, w); } static void GLAPIENTRY save_TexCoord4fv(const GLfloat * v) { - save_Attr4fNV(VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3]); + save_Attr4fNV(VERT_ATTRIB_TEX, v[0], v[1], v[2], v[3]); } static void GLAPIENTRY @@ -5290,66 +4654,6 @@ save_SecondaryColor3fvEXT(const GLfloat * v) } -/* Just call the respective ATTR for texcoord - */ -static void GLAPIENTRY -save_MultiTexCoord1f(GLenum target, GLfloat x) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, x); -} - -static void GLAPIENTRY -save_MultiTexCoord1fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr1fNV(attr, v[0]); -} - -static void GLAPIENTRY -save_MultiTexCoord2f(GLenum target, GLfloat x, GLfloat y) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, x, y); -} - -static void GLAPIENTRY -save_MultiTexCoord2fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr2fNV(attr, v[0], v[1]); -} - -static void GLAPIENTRY -save_MultiTexCoord3f(GLenum target, GLfloat x, GLfloat y, GLfloat z) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, x, y, z); -} - -static void GLAPIENTRY -save_MultiTexCoord3fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr3fNV(attr, v[0], v[1], v[2]); -} - -static void GLAPIENTRY -save_MultiTexCoord4f(GLenum target, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, x, y, z, w); -} - -static void GLAPIENTRY -save_MultiTexCoord4fv(GLenum target, const GLfloat * v) -{ - GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; - save_Attr4fNV(attr, v[0], v[1], v[2], v[3]); -} - - /** * Record a GL_INVALID_VALUE error when a invalid vertex attribute * index is found. @@ -5440,770 +4744,6 @@ save_VertexAttrib4fvNV(GLuint index, const GLfloat * v) } - - -static void GLAPIENTRY -save_VertexAttrib1fARB(GLuint index, GLfloat x) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, x); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib1fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr1fARB(index, v[0]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, x, y); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib2fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr2fARB(index, v[0], v[1]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, x, y, z); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib3fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr3fARB(index, v[0], v[1], v[2]); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, - GLfloat w) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, x, y, z, w); - else - index_error(); -} - -static void GLAPIENTRY -save_VertexAttrib4fvARB(GLuint index, const GLfloat * v) -{ - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - save_Attr4fARB(index, v[0], v[1], v[2], v[3]); - else - index_error(); -} - - -/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - -static void GLAPIENTRY -exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_BindAttribLocationARB(ctx->Exec, (program, index, name)); -} - -static GLint GLAPIENTRY -exec_GetAttribLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetAttribLocationARB(ctx->Exec, (program, name)); -} - -static GLint GLAPIENTRY -exec_GetUniformLocationARB(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - return CALL_GetUniformLocationARB(ctx->Exec, (program, name)); -} -/* XXX more shader functions needed here */ - - -/* aka UseProgram() */ -static void GLAPIENTRY -save_UseProgramObjectARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_USE_PROGRAM, 1); - if (n) { - n[1].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_UseProgramObjectARB(ctx->Exec, (program)); - } -} - - -static void GLAPIENTRY -save_Uniform1fARB(GLint location, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1F, 2); - if (n) { - n[1].i = location; - n[2].f = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fARB(ctx->Exec, (location, x)); - } -} - - -static void GLAPIENTRY -save_Uniform2fARB(GLint location, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2F, 3); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fARB(ctx->Exec, (location, x, y)); - } -} - - -static void GLAPIENTRY -save_Uniform3fARB(GLint location, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3F, 4); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fARB(ctx->Exec, (location, x, y, z)); - } -} - - -static void GLAPIENTRY -save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4F, 5); - if (n) { - n[1].i = location; - n[2].f = x; - n[3].f = y; - n[4].f = z; - n[5].f = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fARB(ctx->Exec, (location, x, y, z, w)); - } -} - - -/** Return copy of memory */ -static void * -memdup(const void *src, GLsizei bytes) -{ - void *b = bytes >= 0 ? malloc(bytes) : NULL; - if (b) - memcpy(b, src, bytes); - return b; -} - - -static void GLAPIENTRY -save_Uniform1fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3fvARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4fvARB(GLint location, GLsizei count, const GLfloat *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4FV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4fvARB(ctx->Exec, (location, count, v)); - } -} - - -static void GLAPIENTRY -save_Uniform1iARB(GLint location, GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1I, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - CALL_Uniform1iARB(ctx->Exec, (location, x)); - } -} - -static void GLAPIENTRY -save_Uniform2iARB(GLint location, GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2I, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - CALL_Uniform2iARB(ctx->Exec, (location, x, y)); - } -} - -static void GLAPIENTRY -save_Uniform3iARB(GLint location, GLint x, GLint y, GLint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3I, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - CALL_Uniform3iARB(ctx->Exec, (location, x, y, z)); - } -} - -static void GLAPIENTRY -save_Uniform4iARB(GLint location, GLint x, GLint y, GLint z, GLint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4I, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - CALL_Uniform4iARB(ctx->Exec, (location, x, y, z, w)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform1ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform2ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform2ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform3ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(GLint)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform3ivARB(ctx->Exec, (location, count, v)); - } -} - -static void GLAPIENTRY -save_Uniform4ivARB(GLint location, GLsizei count, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4IV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_Uniform4ivARB(ctx->Exec, (location, count, v)); - } -} - - - -static void GLAPIENTRY -save_Uniform1ui(GLint location, GLuint x) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UI, 2); - if (n) { - n[1].i = location; - n[2].i = x; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1ui(ctx->Exec, (location, x));*/ - } -} - -static void GLAPIENTRY -save_Uniform2ui(GLint location, GLuint x, GLuint y) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UI, 3); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2ui(ctx->Exec, (location, x, y));*/ - } -} - -static void GLAPIENTRY -save_Uniform3ui(GLint location, GLuint x, GLuint y, GLuint z) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UI, 4); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3ui(ctx->Exec, (location, x, y, z));*/ - } -} - -static void GLAPIENTRY -save_Uniform4ui(GLint location, GLuint x, GLuint y, GLuint z, GLuint w) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UI, 5); - if (n) { - n[1].i = location; - n[2].i = x; - n[3].i = y; - n[4].i = z; - n[5].i = w; - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4ui(ctx->Exec, (location, x, y, z, w));*/ - } -} - - - -static void GLAPIENTRY -save_Uniform1uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_1UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 1 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform1uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform2uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_2UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 2 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform2uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform3uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_3UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 3 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform3uiv(ctx->Exec, (location, count, v));*/ - } -} - -static void GLAPIENTRY -save_Uniform4uiv(GLint location, GLsizei count, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_4UIV, 3); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].data = memdup(v, count * 4 * sizeof(*v)); - } - if (ctx->ExecuteFlag) { - /*CALL_Uniform4uiv(ctx->Exec, (location, count, v));*/ - } -} - - - -static void GLAPIENTRY -save_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX22, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX33, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX44, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4fvARB(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX23, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX32, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX24, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 2 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix2x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX42, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 2 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x2fv(ctx->Exec, (location, count, transpose, m)); - } -} - - -static void GLAPIENTRY -save_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX34, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 3 * 4 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix3x4fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *m) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_UNIFORM_MATRIX43, 4); - if (n) { - n[1].i = location; - n[2].i = count; - n[3].b = transpose; - n[4].data = memdup(m, count * 4 * 3 * sizeof(GLfloat)); - } - if (ctx->ExecuteFlag) { - CALL_UniformMatrix4x3fv(ctx->Exec, (location, count, transpose, m)); - } -} - -static void GLAPIENTRY -save_UseShaderProgramEXT(GLenum type, GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_USE_SHADER_PROGRAM_EXT, 2); - if (n) { - n[1].ui = type; - n[2].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_UseShaderProgramEXT(ctx->Exec, (type, program)); - } -} - -static void GLAPIENTRY -save_ActiveProgramEXT(GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - Node *n; - ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); - n = alloc_instruction(ctx, OPCODE_ACTIVE_PROGRAM_EXT, 1); - if (n) { - n[1].ui = program; - } - if (ctx->ExecuteFlag) { - CALL_ActiveProgramEXT(ctx->Exec, (program)); - } -} - /** GL_EXT_texture_integer */ static void GLAPIENTRY save_ClearColorIi(GLint red, GLint green, GLint blue, GLint alpha) @@ -7017,20 +5557,12 @@ execute_list(struct gl_context *ctx, GLuint list) case OPCODE_WINDOW_POS: CALL_WindowPos4fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f)); break; - case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ - CALL_ActiveTextureARB(ctx->Exec, (n[1].e)); - break; case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */ CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b)); break; case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */ CALL_WindowPos3fMESA(ctx->Exec, (n[1].f, n[2].f, n[3].f)); break; -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */ - CALL_BindProgramNV(ctx->Exec, (n[1].e, n[2].ui)); - break; -#endif #if FEATURE_NV_vertex_program case OPCODE_EXECUTE_PROGRAM_NV: { @@ -7056,11 +5588,6 @@ execute_list(struct gl_context *ctx, GLuint list) #endif #if FEATURE_NV_fragment_program - case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB: - CALL_ProgramLocalParameter4fARB(ctx->Exec, - (n[1].e, n[2].ui, n[3].f, n[4].f, - n[5].f, n[6].f)); - break; case OPCODE_PROGRAM_NAMED_PARAMETER_NV: CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i, (const GLubyte *) n[3]. @@ -7075,152 +5602,7 @@ execute_list(struct gl_context *ctx, GLuint list) case OPCODE_DEPTH_BOUNDS_EXT: CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f)); break; -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - case OPCODE_PROGRAM_STRING_ARB: - CALL_ProgramStringARB(ctx->Exec, - (n[1].e, n[2].e, n[3].i, n[4].data)); - break; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program || FEATURE_NV_vertex_program - case OPCODE_PROGRAM_ENV_PARAMETER_ARB: - CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f, - n[4].f, n[5].f, - n[6].f)); - break; -#endif - case OPCODE_USE_PROGRAM: - CALL_UseProgramObjectARB(ctx->Exec, (n[1].ui)); - break; - case OPCODE_USE_SHADER_PROGRAM_EXT: - CALL_UseShaderProgramEXT(ctx->Exec, (n[1].ui, n[2].ui)); - break; - case OPCODE_ACTIVE_PROGRAM_EXT: - CALL_ActiveProgramEXT(ctx->Exec, (n[1].ui)); - break; - case OPCODE_UNIFORM_1F: - CALL_Uniform1fARB(ctx->Exec, (n[1].i, n[2].f)); - break; - case OPCODE_UNIFORM_2F: - CALL_Uniform2fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f)); - break; - case OPCODE_UNIFORM_3F: - CALL_Uniform3fARB(ctx->Exec, (n[1].i, n[2].f, n[3].f, n[4].f)); - break; - case OPCODE_UNIFORM_4F: - CALL_Uniform4fARB(ctx->Exec, - (n[1].i, n[2].f, n[3].f, n[4].f, n[5].f)); - break; - case OPCODE_UNIFORM_1FV: - CALL_Uniform1fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2FV: - CALL_Uniform2fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3FV: - CALL_Uniform3fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4FV: - CALL_Uniform4fvARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1I: - CALL_Uniform1iARB(ctx->Exec, (n[1].i, n[2].i)); - break; - case OPCODE_UNIFORM_2I: - CALL_Uniform2iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i)); - break; - case OPCODE_UNIFORM_3I: - CALL_Uniform3iARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i)); - break; - case OPCODE_UNIFORM_4I: - CALL_Uniform4iARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - break; - case OPCODE_UNIFORM_1IV: - CALL_Uniform1ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_2IV: - CALL_Uniform2ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_3IV: - CALL_Uniform3ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_4IV: - CALL_Uniform4ivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data)); - break; - case OPCODE_UNIFORM_1UI: - /*CALL_Uniform1uiARB(ctx->Exec, (n[1].i, n[2].i));*/ - break; - case OPCODE_UNIFORM_2UI: - /*CALL_Uniform2uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i));*/ - break; - case OPCODE_UNIFORM_3UI: - /*CALL_Uniform3uiARB(ctx->Exec, (n[1].i, n[2].i, n[3].i, n[4].i));*/ - break; - case OPCODE_UNIFORM_4UI: - /*CALL_Uniform4uiARB(ctx->Exec, - (n[1].i, n[2].i, n[3].i, n[4].i, n[5].i)); - */ - break; - case OPCODE_UNIFORM_1UIV: - /*CALL_Uniform1uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_2UIV: - /*CALL_Uniform2uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_3UIV: - /*CALL_Uniform3uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_4UIV: - /*CALL_Uniform4uivARB(ctx->Exec, (n[1].i, n[2].i, n[3].data));*/ - break; - case OPCODE_UNIFORM_MATRIX22: - CALL_UniformMatrix2fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX33: - CALL_UniformMatrix3fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX44: - CALL_UniformMatrix4fvARB(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX23: - CALL_UniformMatrix2x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX32: - CALL_UniformMatrix3x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX24: - CALL_UniformMatrix2x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX42: - CALL_UniformMatrix4x2fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX34: - CALL_UniformMatrix3x4fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - case OPCODE_UNIFORM_MATRIX43: - CALL_UniformMatrix4x3fv(ctx->Exec, - (n[1].i, n[2].i, n[3].b, n[4].data)); - break; - - case OPCODE_TEX_BUMP_PARAMETER_ATI: - { - GLfloat values[4]; - GLuint i, pname = n[1].ui; - - for (i = 0; i < 4; i++) - values[i] = n[1 + i].f; - CALL_TexBumpParameterfvATI(ctx->Exec, (pname, values)); - } - break; case OPCODE_ATTR_1F_NV: CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f)); break; @@ -7250,39 +5632,8 @@ execute_list(struct gl_context *ctx, GLuint list) CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f, n[4].f, n[5].f)); break; - case OPCODE_ATTR_1F_ARB: - CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f)); - break; - case OPCODE_ATTR_2F_ARB: - /* Really shouldn't have to do this - the Node structure - * is convenient, but it would be better to store the data - * packed appropriately so that it can be sent directly - * on. With x86_64 becoming common, this will start to - * matter more. - */ - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f)); - break; - case OPCODE_ATTR_3F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f)); - break; - case OPCODE_ATTR_4F_ARB: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f)); - else - CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f, - n[4].f, n[5].f)); - break; case OPCODE_MATERIAL: - if (sizeof(Node) == sizeof(GLfloat)) - CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f)); - else { + { GLfloat f[4]; f[0] = n[3].f; f[1] = n[4].f; @@ -8299,14 +6650,6 @@ exec_UnlockArraysEXT(void) CALL_UnlockArraysEXT(ctx->Exec, ()); } -static void GLAPIENTRY -exec_ClientActiveTextureARB(GLenum target) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - CALL_ClientActiveTextureARB(ctx->Exec, (target)); -} - static void GLAPIENTRY exec_SecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) @@ -8726,37 +7069,18 @@ _mesa_create_save_table(void) * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV, * VertexAttribPointerNV, GetProgram*, GetVertexAttrib* */ - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); SET_ExecuteProgramNV(table, save_ExecuteProgramNV); - SET_GenProgramsNV(table, _mesa_GenPrograms); SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV); SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV); SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV); SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV); - SET_GetProgramivNV(table, _mesa_GetProgramivNV); - SET_GetProgramStringNV(table, _mesa_GetProgramStringNV); SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(table, _mesa_IsProgramARB); SET_LoadProgramNV(table, save_LoadProgramNV); - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV); SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV); SET_TrackMatrixNV(table, save_TrackMatrixNV); - SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV); #endif - /* 244. GL_ATI_envmap_bumpmap */ - SET_TexBumpParameterivATI(table, save_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(table, save_TexBumpParameterfvATI); - /* 282. GL_NV_fragment_program */ #if FEATURE_NV_fragment_program SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV); @@ -8767,14 +7091,6 @@ _mesa_create_save_table(void) _mesa_GetProgramNamedParameterfvNV); SET_GetProgramNamedParameterdvNV(table, _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); #endif /* 262. GL_NV_point_sprite */ @@ -8797,10 +7113,6 @@ _mesa_create_save_table(void) /* ???. GL_EXT_depth_bounds_test */ SET_DepthBoundsEXT(table, save_DepthBoundsEXT); - /* ARB 1. GL_ARB_multitexture */ - SET_ActiveTextureARB(table, save_ActiveTextureARB); - SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB); - /* ARB 3. GL_ARB_transpose_matrix */ SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB); SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB); @@ -8810,48 +7122,6 @@ _mesa_create_save_table(void) /* ARB 5. GL_ARB_multisample */ SET_SampleCoverageARB(table, save_SampleCoverageARB); - /* ARB 14. GL_ARB_point_parameters */ - /* aliased with EXT_point_parameters functions */ - - /* ARB 25. GL_ARB_window_pos */ - /* aliased with MESA_window_pos functions */ - - /* ARB 26. GL_ARB_vertex_program */ - /* ARB 27. GL_ARB_fragment_program */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - /* glVertexAttrib* functions alias the NV ones, handled elsewhere */ - SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB); - SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB); - SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB); - SET_ProgramStringARB(table, save_ProgramStringARB); - SET_BindProgramNV(table, save_BindProgramNV); - SET_DeleteProgramsNV(table, _mesa_DeletePrograms); - SET_GenProgramsNV(table, _mesa_GenPrograms); - SET_IsProgramNV(table, _mesa_IsProgramARB); - SET_GetVertexAttribdvARB(table, _mesa_GetVertexAttribdvARB); - SET_GetVertexAttribfvARB(table, _mesa_GetVertexAttribfvARB); - SET_GetVertexAttribivARB(table, _mesa_GetVertexAttribivARB); -#if FEATURE_NV_vertex_program - SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV); -#endif - SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(table, - _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(table, - _mesa_GetProgramLocalParameterfvARB); - SET_GetProgramivARB(table, _mesa_GetProgramivARB); - SET_GetProgramStringARB(table, _mesa_GetProgramStringARB); -#endif - /* ARB 28. GL_ARB_vertex_buffer_object */ /* None of the extension's functions get compiled */ SET_BindBufferARB(table, _mesa_BindBufferARB); @@ -8866,50 +7136,9 @@ _mesa_create_save_table(void) SET_MapBufferARB(table, _mesa_MapBufferARB); SET_UnmapBufferARB(table, _mesa_UnmapBufferARB); - /* GL_ARB_shader_objects */ - _mesa_init_shader_dispatch(table); /* Plug in glCreate/Delete/Get, etc */ - SET_UseProgramObjectARB(table, save_UseProgramObjectARB); - SET_Uniform1fARB(table, save_Uniform1fARB); - SET_Uniform2fARB(table, save_Uniform2fARB); - SET_Uniform3fARB(table, save_Uniform3fARB); - SET_Uniform4fARB(table, save_Uniform4fARB); - SET_Uniform1fvARB(table, save_Uniform1fvARB); - SET_Uniform2fvARB(table, save_Uniform2fvARB); - SET_Uniform3fvARB(table, save_Uniform3fvARB); - SET_Uniform4fvARB(table, save_Uniform4fvARB); - SET_Uniform1iARB(table, save_Uniform1iARB); - SET_Uniform2iARB(table, save_Uniform2iARB); - SET_Uniform3iARB(table, save_Uniform3iARB); - SET_Uniform4iARB(table, save_Uniform4iARB); - SET_Uniform1ivARB(table, save_Uniform1ivARB); - SET_Uniform2ivARB(table, save_Uniform2ivARB); - SET_Uniform3ivARB(table, save_Uniform3ivARB); - SET_Uniform4ivARB(table, save_Uniform4ivARB); - SET_UniformMatrix2fvARB(table, save_UniformMatrix2fvARB); - SET_UniformMatrix3fvARB(table, save_UniformMatrix3fvARB); - SET_UniformMatrix4fvARB(table, save_UniformMatrix4fvARB); - SET_UniformMatrix2x3fv(table, save_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(table, save_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(table, save_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(table, save_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(table, save_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(table, save_UniformMatrix4x3fv); - - /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */ - SET_BindAttribLocationARB(table, exec_BindAttribLocationARB); - SET_GetAttribLocationARB(table, exec_GetAttribLocationARB); - SET_GetUniformLocationARB(table, exec_GetUniformLocationARB); - /* XXX additional functions need to be implemented here! */ - /* 299. GL_EXT_blend_equation_separate */ SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT); - /* GL_EXT_gpu_program_parameters */ -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(table, save_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(table, save_ProgramLocalParameters4fvEXT); -#endif - /* ARB 50. GL_ARB_map_buffer_range */ #if FEATURE_ARB_map_buffer_range SET_MapBufferRange(table, _mesa_MapBufferRange); /* no dlist save */ @@ -8931,30 +7160,6 @@ _mesa_create_save_table(void) SET_GetTexParameterIivEXT(table, exec_GetTexParameterIiv); SET_GetTexParameterIuivEXT(table, exec_GetTexParameterIuiv); - /* 377. GL_EXT_separate_shader_objects */ - SET_UseShaderProgramEXT(table, save_UseShaderProgramEXT); - SET_ActiveProgramEXT(table, save_ActiveProgramEXT); - -#if 0 - SET_Uniform1ui(table, save_Uniform1ui); - SET_Uniform2ui(table, save_Uniform2ui); - SET_Uniform3ui(table, save_Uniform3ui); - SET_Uniform4ui(table, save_Uniform4ui); - SET_Uniform1uiv(table, save_Uniform1uiv); - SET_Uniform2uiv(table, save_Uniform2uiv); - SET_Uniform3uiv(table, save_Uniform3uiv); - SET_Uniform4uiv(table, save_Uniform4uiv); -#else - (void) save_Uniform1ui; - (void) save_Uniform2ui; - (void) save_Uniform3ui; - (void) save_Uniform4ui; - (void) save_Uniform1uiv; - (void) save_Uniform2uiv; - (void) save_Uniform3uiv; - (void) save_Uniform4uiv; -#endif - /* GL_NV_texture_barrier */ SET_TextureBarrierNV(table, save_TextureBarrierNV); @@ -9157,21 +7362,6 @@ print_list(struct gl_context *ctx, GLuint list) printf("ATTR_4F_NV attr %d: %f %f %f %f\n", n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); break; - case OPCODE_ATTR_1F_ARB: - printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); - break; - case OPCODE_ATTR_2F_ARB: - printf("ATTR_2F_ARB attr %d: %f %f\n", - n[1].i, n[2].f, n[3].f); - break; - case OPCODE_ATTR_3F_ARB: - printf("ATTR_3F_ARB attr %d: %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f); - break; - case OPCODE_ATTR_4F_ARB: - printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", - n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); - break; case OPCODE_MATERIAL: printf("MATERIAL %x %x: %f %f %f %f\n", @@ -9277,14 +7467,6 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) vfmt->Indexf = save_Indexf; vfmt->Indexfv = save_Indexfv; vfmt->Materialfv = save_Materialfv; - vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv; - vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv; - vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv; - vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv; vfmt->Normal3f = save_Normal3f; vfmt->Normal3fv = save_Normal3fv; vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT; @@ -9311,14 +7493,6 @@ _mesa_save_vtxfmt_init(GLvertexformat * vfmt) vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV; vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV; vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB; vfmt->Rectf = save_Rectf; diff --git a/reactos/dll/opengl/mesa/src/mesa/main/drawpix.c b/reactos/dll/opengl/mesa/src/mesa/main/drawpix.c index 13930456777..13bf07bb11f 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/drawpix.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/drawpix.c @@ -67,14 +67,9 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, return; } - /* We're not using the current vertex program, and the driver may install - * its own. Note: this may dirty some state. - */ - _mesa_set_vp_override(ctx, GL_TRUE); - /* Note: this call does state validation */ if (!_mesa_valid_to_render(ctx, "glDrawPixels")) { - goto end; /* the error code was recorded */ + return; /* the error code was recorded */ } /* GL 3.0 introduced a new restriction on glDrawPixels() over what was in @@ -91,19 +86,19 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, */ if (_mesa_is_integer_format(format)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(integer format)"); - goto end; + return; } if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) { - goto end; /* the error code was recorded */ + return; /* the error code was recorded */ } if (ctx->RasterDiscard) { - goto end; + return; } if (!ctx->Current.RasterPosValid) { - goto end; /* no-op, not an error */ + return; /* no-op, not an error */ } if (ctx->RenderMode == GL_RENDER) { @@ -118,13 +113,13 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, 1, format, type, INT_MAX, pixels)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(invalid PBO access)"); - goto end; + return; } if (_mesa_bufferobj_mapped(ctx->Unpack.BufferObj)) { /* buffer is mapped - that's an error */ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(PBO is mapped)"); - goto end; + return; } } @@ -139,15 +134,12 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, _mesa_feedback_vertex( ctx, ctx->Current.RasterPos, ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); + ctx->Current.RasterTexCoords ); } else { ASSERT(ctx->RenderMode == GL_SELECT); /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ } - -end: - _mesa_set_vp_override(ctx, GL_FALSE); } @@ -185,29 +177,24 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, return; } - /* We're not using the current vertex program, and the driver may install - * it's own. Note: this may dirty some state. - */ - _mesa_set_vp_override(ctx, GL_TRUE); - /* Note: this call does state validation */ if (!_mesa_valid_to_render(ctx, "glCopyPixels")) { - goto end; /* the error code was recorded */ + return; /* the error code was recorded */ } if (!_mesa_source_buffer_exists(ctx, type) || !_mesa_dest_buffer_exists(ctx, type)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyPixels(missing source or dest buffer)"); - goto end; + return; } if (ctx->RasterDiscard) { - goto end; + return; } if (!ctx->Current.RasterPosValid || width == 0 || height == 0) { - goto end; /* no-op, not an error */ + return; /* no-op, not an error */ } if (ctx->RenderMode == GL_RENDER) { @@ -225,15 +212,12 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, _mesa_feedback_vertex( ctx, ctx->Current.RasterPos, ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); + ctx->Current.RasterTexCoords ); } else { ASSERT(ctx->RenderMode == GL_SELECT); /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ } - -end: - _mesa_set_vp_override(ctx, GL_FALSE); } @@ -297,7 +281,7 @@ _mesa_Bitmap( GLsizei width, GLsizei height, _mesa_feedback_vertex( ctx, ctx->Current.RasterPos, ctx->Current.RasterColor, - ctx->Current.RasterTexCoords[0] ); + ctx->Current.RasterTexCoords ); } else { ASSERT(ctx->RenderMode == GL_SELECT); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/enable.c b/reactos/dll/opengl/mesa/src/mesa/main/enable.c index c20d2a00c7a..43678922d67 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/enable.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/enable.c @@ -75,8 +75,8 @@ client_state(struct gl_context *ctx, GLenum cap, GLboolean state) flag = VERT_BIT_COLOR_INDEX; break; case GL_TEXTURE_COORD_ARRAY: - var = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled; - flag = VERT_BIT_TEX(ctx->Array.ActiveTexture); + var = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX].Enabled; + flag = VERT_BIT_TEX; break; case GL_EDGE_FLAG_ARRAY: var = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled; @@ -207,16 +207,10 @@ _mesa_DisableClientState( GLenum cap ) * Note that we'll set GL_INVALID_OPERATION and return NULL if the active * texture unit is higher than the number of supported coordinate units. */ -static struct gl_texture_unit * +static inline struct gl_texture_unit * get_texcoord_unit(struct gl_context *ctx) { - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); - return NULL; - } - else { - return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - } + return &ctx->Texture.Unit; } @@ -228,7 +222,7 @@ get_texcoord_unit(struct gl_context *ctx) static GLboolean enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit) { - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; const GLbitfield newenabled = state ? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit); @@ -650,15 +644,6 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) } break; - /* GL_EXT_secondary_color */ - case GL_COLOR_SUM_EXT: - CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); - if (ctx->Fog.ColorSumEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_FOG); - ctx->Fog.ColorSumEnabled = state; - break; - /* GL_ARB_multisample */ case GL_MULTISAMPLE_ARB: if (ctx->Multisample.Enabled == state) @@ -709,88 +694,6 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Point.PointSprite = state; break; -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.Enabled = state; - break; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.PointSizeEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.PointSizeEnabled = state; - break; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); - if (ctx->VertexProgram.TwoSideEnabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->VertexProgram.TwoSideEnabled = state; - break; -#endif -#if FEATURE_NV_vertex_program - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map1Attrib[map] = state; - } - break; - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program, cap); - { - const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); - FLUSH_VERTICES(ctx, _NEW_EVAL); - ctx->Eval.Map2Attrib[map] = state; - } - break; -#endif /* FEATURE_NV_vertex_program */ - -#if FEATURE_NV_fragment_program - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXTENSION(NV_fragment_program, cap); - if (ctx->FragmentProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->FragmentProgram.Enabled = state; - break; -#endif /* FEATURE_NV_fragment_program */ - /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: CHECK_EXTENSION(EXT_stencil_two_side, cap); @@ -807,16 +710,6 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) } break; -#if FEATURE_ARB_fragment_program - case GL_FRAGMENT_PROGRAM_ARB: - CHECK_EXTENSION(ARB_fragment_program, cap); - if (ctx->FragmentProgram.Enabled == state) - return; - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - ctx->FragmentProgram.Enabled = state; - break; -#endif /* FEATURE_ARB_fragment_program */ - /* GL_EXT_depth_bounds_test */ case GL_DEPTH_BOUNDS_TEST_EXT: CHECK_EXTENSION(EXT_depth_bounds_test, cap); @@ -890,7 +783,7 @@ static GLboolean is_texture_enabled(struct gl_context *ctx, GLbitfield bit) { const struct gl_texture_unit *const texUnit = - &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + &ctx->Texture.Unit; return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE; } @@ -1056,7 +949,7 @@ _mesa_IsEnabled( GLenum cap ) case GL_INDEX_ARRAY: return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled != 0); case GL_TEXTURE_COORD_ARRAY: - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)] + return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX] .Enabled != 0); case GL_EDGE_FLAG_ARRAY: return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled != 0); @@ -1076,11 +969,6 @@ _mesa_IsEnabled( GLenum cap ) CHECK_EXTENSION(ARB_texture_cube_map); return is_texture_enabled(ctx, TEXTURE_CUBE_BIT); - /* GL_EXT_secondary_color */ - case GL_COLOR_SUM_EXT: - CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); - return ctx->Fog.ColorSumEnabled; - /* GL_ARB_multisample */ case GL_MULTISAMPLE_ARB: return ctx->Multisample.Enabled; @@ -1103,100 +991,11 @@ _mesa_IsEnabled( GLenum cap ) CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) return ctx->Point.PointSprite; -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.Enabled; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.PointSizeEnabled; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program); - return ctx->VertexProgram.TwoSideEnabled; -#endif -#if FEATURE_NV_vertex_program - case GL_VERTEX_ATTRIB_ARRAY0_NV: - case GL_VERTEX_ATTRIB_ARRAY1_NV: - case GL_VERTEX_ATTRIB_ARRAY2_NV: - case GL_VERTEX_ATTRIB_ARRAY3_NV: - case GL_VERTEX_ATTRIB_ARRAY4_NV: - case GL_VERTEX_ATTRIB_ARRAY5_NV: - case GL_VERTEX_ATTRIB_ARRAY6_NV: - case GL_VERTEX_ATTRIB_ARRAY7_NV: - case GL_VERTEX_ATTRIB_ARRAY8_NV: - case GL_VERTEX_ATTRIB_ARRAY9_NV: - case GL_VERTEX_ATTRIB_ARRAY10_NV: - case GL_VERTEX_ATTRIB_ARRAY11_NV: - case GL_VERTEX_ATTRIB_ARRAY12_NV: - case GL_VERTEX_ATTRIB_ARRAY13_NV: - case GL_VERTEX_ATTRIB_ARRAY14_NV: - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXTENSION(NV_vertex_program); - { - GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV; - ASSERT(VERT_ATTRIB_GENERIC(n) < Elements(ctx->Array.ArrayObj->VertexAttrib)); - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(n)].Enabled != 0); - } - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program); - { - const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); - return ctx->Eval.Map1Attrib[map]; - } - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - CHECK_EXTENSION(NV_vertex_program); - { - const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); - return ctx->Eval.Map2Attrib[map]; - } -#endif /* FEATURE_NV_vertex_program */ - -#if FEATURE_NV_fragment_program - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXTENSION(NV_fragment_program); - return ctx->FragmentProgram.Enabled; -#endif /* FEATURE_NV_fragment_program */ - /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: CHECK_EXTENSION(EXT_stencil_two_side); return ctx->Stencil.TestTwoSide; -#if FEATURE_ARB_fragment_program - case GL_FRAGMENT_PROGRAM_ARB: - return ctx->FragmentProgram.Enabled; -#endif /* FEATURE_ARB_fragment_program */ - /* GL_EXT_depth_bounds_test */ case GL_DEPTH_BOUNDS_TEST_EXT: CHECK_EXTENSION(EXT_depth_bounds_test); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/eval.c b/reactos/dll/opengl/mesa/src/mesa/main/eval.c index e651715f788..add35877260 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/eval.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/eval.c @@ -122,25 +122,6 @@ get_1d_map( struct gl_context *ctx, GLenum target ) return &ctx->EvalMap.Map1Texture3; case GL_MAP1_TEXTURE_COORD_4: return &ctx->EvalMap.Map1Texture4; - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - if (!ctx->Extensions.NV_vertex_program) - return NULL; - return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV]; default: return NULL; } @@ -172,25 +153,6 @@ get_2d_map( struct gl_context *ctx, GLenum target ) return &ctx->EvalMap.Map2Texture3; case GL_MAP2_TEXTURE_COORD_4: return &ctx->EvalMap.Map2Texture4; - case GL_MAP2_VERTEX_ATTRIB0_4_NV: - case GL_MAP2_VERTEX_ATTRIB1_4_NV: - case GL_MAP2_VERTEX_ATTRIB2_4_NV: - case GL_MAP2_VERTEX_ATTRIB3_4_NV: - case GL_MAP2_VERTEX_ATTRIB4_4_NV: - case GL_MAP2_VERTEX_ATTRIB5_4_NV: - case GL_MAP2_VERTEX_ATTRIB6_4_NV: - case GL_MAP2_VERTEX_ATTRIB7_4_NV: - case GL_MAP2_VERTEX_ATTRIB8_4_NV: - case GL_MAP2_VERTEX_ATTRIB9_4_NV: - case GL_MAP2_VERTEX_ATTRIB10_4_NV: - case GL_MAP2_VERTEX_ATTRIB11_4_NV: - case GL_MAP2_VERTEX_ATTRIB12_4_NV: - case GL_MAP2_VERTEX_ATTRIB13_4_NV: - case GL_MAP2_VERTEX_ATTRIB14_4_NV: - case GL_MAP2_VERTEX_ATTRIB15_4_NV: - if (!ctx->Extensions.NV_vertex_program) - return NULL; - return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV]; default: return NULL; } @@ -391,12 +353,6 @@ map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, return; } - if (ctx->Texture.CurrentUnit != 0) { - /* See OpenGL 1.2.1 spec, section F.2.13 */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); - return; - } - map = get_1d_map(ctx, target); if (!map) { _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); @@ -485,12 +441,6 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, return; } - if (ctx->Texture.CurrentUnit != 0) { - /* See OpenGL 1.2.1 spec, section F.2.13 */ - _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); - return; - } - map = get_2d_map(ctx, target); if (!map) { _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); @@ -972,7 +922,6 @@ init_2d_map( struct gl_2d_map *map, int n, const float *initial ) void _mesa_init_eval( struct gl_context *ctx ) { - int i; /* Evaluators group */ ctx->Eval.Map1Color4 = GL_FALSE; @@ -984,7 +933,6 @@ void _mesa_init_eval( struct gl_context *ctx ) ctx->Eval.Map1TextureCoord4 = GL_FALSE; ctx->Eval.Map1Vertex3 = GL_FALSE; ctx->Eval.Map1Vertex4 = GL_FALSE; - memset(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib)); ctx->Eval.Map2Color4 = GL_FALSE; ctx->Eval.Map2Index = GL_FALSE; ctx->Eval.Map2Normal = GL_FALSE; @@ -994,7 +942,6 @@ void _mesa_init_eval( struct gl_context *ctx ) ctx->Eval.Map2TextureCoord4 = GL_FALSE; ctx->Eval.Map2Vertex3 = GL_FALSE; ctx->Eval.Map2Vertex4 = GL_FALSE; - memset(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib)); ctx->Eval.AutoNormal = GL_FALSE; ctx->Eval.MapGrid1un = 1; ctx->Eval.MapGrid1u1 = 0.0; @@ -1013,7 +960,6 @@ void _mesa_init_eval( struct gl_context *ctx ) static GLfloat index[1] = { 1.0 }; static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; - static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 }; init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); @@ -1024,8 +970,6 @@ void _mesa_init_eval( struct gl_context *ctx ) init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); - for (i = 0; i < 16; i++) - init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib ); init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); @@ -1036,16 +980,12 @@ void _mesa_init_eval( struct gl_context *ctx ) init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); - for (i = 0; i < 16; i++) - init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib ); } } void _mesa_free_eval_data( struct gl_context *ctx ) { - int i; - /* Free evaluator data */ if (ctx->EvalMap.Map1Vertex3.Points) FREE( ctx->EvalMap.Map1Vertex3.Points ); @@ -1065,8 +1005,6 @@ void _mesa_free_eval_data( struct gl_context *ctx ) FREE( ctx->EvalMap.Map1Texture3.Points ); if (ctx->EvalMap.Map1Texture4.Points) FREE( ctx->EvalMap.Map1Texture4.Points ); - for (i = 0; i < 16; i++) - FREE((ctx->EvalMap.Map1Attrib[i].Points)); if (ctx->EvalMap.Map2Vertex3.Points) FREE( ctx->EvalMap.Map2Vertex3.Points ); @@ -1086,6 +1024,4 @@ void _mesa_free_eval_data( struct gl_context *ctx ) FREE( ctx->EvalMap.Map2Texture3.Points ); if (ctx->EvalMap.Map2Texture4.Points) FREE( ctx->EvalMap.Map2Texture4.Points ); - for (i = 0; i < 16; i++) - FREE((ctx->EvalMap.Map2Attrib[i].Points)); } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/extensions.c b/reactos/dll/opengl/mesa/src/mesa/main/extensions.c index 7ffb2643f36..6224ae818d0 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/extensions.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/extensions.c @@ -67,10 +67,6 @@ struct extension { */ static const struct extension extension_table[] = { /* ARB Extensions */ - { "GL_ARB_conservative_depth", o(ARB_conservative_depth), 2011 }, - { "GL_ARB_fragment_program", o(ARB_fragment_program), 2002 }, - { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), 2003 }, - { "GL_ARB_fragment_shader", o(ARB_fragment_shader), 2002 }, { "GL_ARB_half_float_pixel", o(ARB_half_float_pixel), 2003 }, { "GL_ARB_half_float_vertex", o(ARB_half_float_vertex), 2008 }, { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), 2008 }, @@ -80,10 +76,6 @@ static const struct extension extension_table[] = { { "GL_ARB_point_parameters", o(EXT_point_parameters), 1997 }, { "GL_ARB_point_sprite", o(ARB_point_sprite), 2003 }, { "GL_ARB_robustness", o(dummy_true), 2010 }, - { "GL_ARB_shader_objects", o(ARB_shader_objects), 2002 }, - { "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), 2009 }, - { "GL_ARB_shader_texture_lod", o(ARB_shader_texture_lod), 2009 }, - { "GL_ARB_shading_language_100", o(ARB_shading_language_100), 2003 }, { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), 2000 }, { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), 1999 }, { "GL_ARB_texture_env_add", o(dummy_true), 1999 }, @@ -97,8 +89,6 @@ static const struct extension extension_table[] = { { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), 1999 }, { "GL_ARB_vertex_array_object", o(ARB_vertex_array_object), 2006 }, { "GL_ARB_vertex_buffer_object", o(dummy_true), 2003 }, - { "GL_ARB_vertex_program", o(ARB_vertex_program), 2002 }, - { "GL_ARB_vertex_shader", o(ARB_vertex_shader), 2002 }, { "GL_ARB_window_pos", o(ARB_window_pos), 2001 }, /* EXT extensions */ { "GL_EXT_abgr", o(dummy_true), 1995 }, @@ -114,8 +104,6 @@ static const struct extension extension_table[] = { { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), 2002 }, { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), 1997 }, { "GL_EXT_fog_coord", o(EXT_fog_coord), 1999 }, - { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), 2006 }, - { "GL_EXT_gpu_shader4", o(EXT_gpu_shader4), 2006 }, { "GL_EXT_multi_draw_arrays", o(dummy_true), 1999 }, { "GL_EXT_packed_pixels", o(EXT_packed_pixels), 1997 }, { "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), 2004 }, @@ -143,13 +131,10 @@ static const struct extension extension_table[] = { { "GL_EXT_vertex_array", o(dummy_true), 1995 }, /* Vendor extensions */ - { "GL_AMD_conservative_depth", o(ARB_conservative_depth), 2009 }, - { "GL_AMD_shader_stencil_export", o(ARB_shader_stencil_export), 2009 }, { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), 2006 }, { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), 2002 }, { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), 2002 }, { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), 2003 }, - { "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), 2001 }, { "GL_ATI_separate_stencil", o(ATI_separate_stencil), 2006 }, { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), 2002 }, { "GL_ATI_texture_float", o(ARB_texture_float), 2002 }, @@ -164,15 +149,11 @@ static const struct extension extension_table[] = { { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), 2002 }, { "GL_NV_blend_square", o(NV_blend_square), 1999 }, { "GL_NV_fog_distance", o(NV_fog_distance), 2001 }, - { "GL_NV_fragment_program", o(NV_fragment_program), 2001 }, - { "GL_NV_fragment_program_option", o(NV_fragment_program_option), 2005 }, { "GL_NV_light_max_exponent", o(NV_light_max_exponent), 1999 }, { "GL_NV_point_sprite", o(NV_point_sprite), 2001 }, { "GL_NV_texgen_reflection", o(NV_texgen_reflection), 1999 }, { "GL_NV_texture_barrier", o(NV_texture_barrier), 2009 }, { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), 1999 }, - { "GL_NV_vertex_program1_1", o(NV_vertex_program1_1), 2001 }, - { "GL_NV_vertex_program", o(NV_vertex_program), 2000 }, { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), 1997 }, { "GL_SGIS_texture_edge_clamp", o(dummy_true), 1997 }, { "GL_SUN_multi_draw_arrays", o(dummy_true), 1999 }, @@ -242,24 +223,10 @@ static const size_t default_extensions[] = { void _mesa_enable_sw_extensions(struct gl_context *ctx) { -#if FEATURE_ARB_fragment_program - ctx->Extensions.ARB_fragment_program = GL_TRUE; - ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; -#endif -#if FEATURE_ARB_fragment_shader - ctx->Extensions.ARB_fragment_shader = GL_TRUE; -#endif ctx->Extensions.ARB_half_float_pixel = GL_TRUE; ctx->Extensions.ARB_half_float_vertex = GL_TRUE; ctx->Extensions.ARB_map_buffer_range = GL_TRUE; ctx->Extensions.ARB_point_sprite = GL_TRUE; -#if FEATURE_ARB_shader_objects - ctx->Extensions.ARB_shader_objects = GL_TRUE; - ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; -#endif -#if FEATURE_ARB_shading_language_100 - ctx->Extensions.ARB_shading_language_100 = GL_TRUE; -#endif ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; ctx->Extensions.ARB_texture_cube_map = GL_TRUE; ctx->Extensions.ARB_texture_env_combine = GL_TRUE; @@ -269,17 +236,10 @@ _mesa_enable_sw_extensions(struct gl_context *ctx) ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; ctx->Extensions.ARB_texture_storage = GL_TRUE; ctx->Extensions.ARB_vertex_array_object = GL_TRUE; -#if FEATURE_ARB_vertex_program - ctx->Extensions.ARB_vertex_program = GL_TRUE; -#endif -#if FEATURE_ARB_vertex_shader - ctx->Extensions.ARB_vertex_shader = GL_TRUE; -#endif ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; #if FEATURE_APPLE_object_purgeable ctx->Extensions.APPLE_object_purgeable = GL_TRUE; #endif - ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; ctx->Extensions.ATI_separate_stencil = GL_TRUE; @@ -308,28 +268,9 @@ _mesa_enable_sw_extensions(struct gl_context *ctx) ctx->Extensions.NV_point_sprite = GL_TRUE; ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ -#if FEATURE_NV_vertex_program - ctx->Extensions.NV_vertex_program = GL_TRUE; - ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; -#endif -#if FEATURE_NV_fragment_program - ctx->Extensions.NV_fragment_program = GL_TRUE; -#endif -#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program - ctx->Extensions.NV_fragment_program_option = GL_TRUE; -#endif -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; -#endif #if FEATURE_texture_fxt1 _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); #endif -#if FEATURE_texture_s3tc - if (ctx->Mesa_DXTn) { - _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); - _mesa_enable_extension(ctx, "GL_S3_s3tc"); - } -#endif } @@ -385,22 +326,10 @@ _mesa_enable_1_5_extensions(struct gl_context *ctx) void _mesa_enable_2_0_extensions(struct gl_context *ctx) { -#if FEATURE_ARB_fragment_shader - ctx->Extensions.ARB_fragment_shader = GL_TRUE; -#endif ctx->Extensions.ARB_point_sprite = GL_TRUE; ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; -#if FEATURE_ARB_shader_objects - ctx->Extensions.ARB_shader_objects = GL_TRUE; -#endif -#if FEATURE_ARB_shading_language_100 - ctx->Extensions.ARB_shading_language_100 = GL_TRUE; -#endif ctx->Extensions.EXT_stencil_two_side = GL_TRUE; -#if FEATURE_ARB_vertex_shader - ctx->Extensions.ARB_vertex_shader = GL_TRUE; -#endif } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/format_pack.c b/reactos/dll/opengl/mesa/src/mesa/main/format_pack.c index 64e7191432c..67ae9cfb671 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/format_pack.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/format_pack.c @@ -1008,27 +1008,6 @@ pack_float_LUMINANCE_ALPHA_FLOAT16(const GLfloat src[4], void *dst) } -/* MESA_FORMAT_DUDV8 */ - -static void -pack_ubyte_DUDV8(const GLubyte src[4], void *dst) -{ - /* XXX is this ever used? */ - GLushort *d = ((GLushort *) dst); - *d = PACK_COLOR_88(src[0], src[1]); -} - -static void -pack_float_DUDV8(const GLfloat src[4], void *dst) -{ - GLushort *d = ((GLushort *) dst); - GLbyte du, dv; - du = FLOAT_TO_BYTE(CLAMP(src[0], 0.0F, 1.0F)); - dv = FLOAT_TO_BYTE(CLAMP(src[1], 0.0F, 1.0F)); - *d = PACK_COLOR_88(du, dv); -} - - /* MESA_FORMAT_RGBA_16 */ static void @@ -1141,8 +1120,6 @@ _mesa_get_pack_ubyte_rgba_function(gl_format format) table[MESA_FORMAT_RGBA_UINT16] = NULL; /* pack_ubyte_RGBA_UINT16 */ table[MESA_FORMAT_RGBA_UINT32] = NULL; /* pack_ubyte_RGBA_UINT32 */ - table[MESA_FORMAT_DUDV8] = pack_ubyte_DUDV8; - table[MESA_FORMAT_RGBA_16] = pack_ubyte_RGBA_16; table[MESA_FORMAT_SIGNED_RGBA_16] = NULL; @@ -1234,8 +1211,6 @@ _mesa_get_pack_float_rgba_function(gl_format format) table[MESA_FORMAT_RGBA_UINT16] = NULL; table[MESA_FORMAT_RGBA_UINT32] = NULL; - table[MESA_FORMAT_DUDV8] = pack_float_DUDV8; - table[MESA_FORMAT_RGBA_16] = pack_float_RGBA_16; table[MESA_FORMAT_SIGNED_RGBA_16] = pack_float_SIGNED_RGBA_16; diff --git a/reactos/dll/opengl/mesa/src/mesa/main/format_unpack.c b/reactos/dll/opengl/mesa/src/mesa/main/format_unpack.c index 394fc37a39b..efe33a80955 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/format_unpack.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/format_unpack.c @@ -829,19 +829,6 @@ unpack_RGBA_UINT32(const void *src, GLfloat dst[][4], GLuint n) } } -static void -unpack_DUDV8(const void *src, GLfloat dst[][4], GLuint n) -{ - const GLbyte *s = (const GLbyte *) src; - GLuint i; - for (i = 0; i < n; i++) { - dst[i][RCOMP] = BYTE_TO_FLOAT(s[i*2+0]); - dst[i][GCOMP] = BYTE_TO_FLOAT(s[i*2+1]); - dst[i][BCOMP] = 0; - dst[i][ACOMP] = 0; - } -} - static void unpack_SIGNED_RGBA_16(const void *src, GLfloat dst[][4], GLuint n) { @@ -938,7 +925,6 @@ get_unpack_rgba_function(gl_format format) table[MESA_FORMAT_RGBA_UINT16] = unpack_RGBA_UINT16; table[MESA_FORMAT_RGBA_UINT32] = unpack_RGBA_UINT32; - table[MESA_FORMAT_DUDV8] = unpack_DUDV8; table[MESA_FORMAT_SIGNED_RGBA_16] = unpack_SIGNED_RGBA_16; table[MESA_FORMAT_RGBA_16] = unpack_RGBA_16; diff --git a/reactos/dll/opengl/mesa/src/mesa/main/formats.c b/reactos/dll/opengl/mesa/src/mesa/main/formats.c index 7c7a9fd9ee1..c060b7f4726 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/formats.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/formats.c @@ -43,7 +43,7 @@ struct gl_format_info /** * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, - * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL, GL_DUDV_ATI. + * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL. */ GLenum BaseFormat; @@ -848,15 +848,6 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = }, - { - MESA_FORMAT_DUDV8, - "MESA_FORMAT_DUDV8", - GL_DUDV_ATI, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, { MESA_FORMAT_SIGNED_RGBA_16, "MESA_FORMAT_SIGNED_RGBA_16", @@ -1359,11 +1350,6 @@ _mesa_format_to_type_and_comps(gl_format format, *comps = 1; return; - case MESA_FORMAT_DUDV8: - *datatype = GL_BYTE; - *comps = 2; - return; - case MESA_FORMAT_RGBA_16: *datatype = GL_UNSIGNED_SHORT; *comps = 4; @@ -1752,7 +1738,6 @@ _mesa_format_matches_format_and_type(gl_format gl_format, case MESA_FORMAT_RGBA_UINT32: return GL_FALSE; - case MESA_FORMAT_DUDV8: case MESA_FORMAT_SIGNED_RGBA_16: case MESA_FORMAT_RGBA_16: /* FINISHME: SNORM */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/formats.h b/reactos/dll/opengl/mesa/src/mesa/main/formats.h index 4c31030df2f..2ff4af1fa59 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/formats.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/formats.h @@ -179,7 +179,6 @@ typedef enum * \name Signed fixed point texture formats. */ /*@{*/ - MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ MESA_FORMAT_SIGNED_RGBA_16, /* ... */ MESA_FORMAT_RGBA_16, /* ... */ /*@}*/ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/get.c b/reactos/dll/opengl/mesa/src/mesa/main/get.c index 1554404b642..1cd04aa4b00 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/get.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/get.c @@ -133,7 +133,6 @@ enum value_extra { EXTRA_VALID_TEXTURE_UNIT, EXTRA_VALID_CLIP_DISTANCE, EXTRA_FLUSH_CURRENT, - EXTRA_GLSL_130, }; #define NO_EXTRA NULL @@ -263,54 +262,21 @@ static const int extra_EXT_texture_integer[] = { EXTRA_END }; -static const int extra_GLSL_130[] = { - EXTRA_GLSL_130, - EXTRA_END -}; - EXTRA_EXT(ARB_texture_cube_map); -EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program); EXTRA_EXT(EXT_secondary_color); EXTRA_EXT(EXT_fog_coord); EXTRA_EXT(NV_fog_distance); EXTRA_EXT(EXT_texture_filter_anisotropic); EXTRA_EXT(IBM_rasterpos_clip); EXTRA_EXT(NV_point_sprite); -EXTRA_EXT(NV_vertex_program); -EXTRA_EXT(NV_fragment_program); EXTRA_EXT(EXT_stencil_two_side); EXTRA_EXT(NV_light_max_exponent); EXTRA_EXT(EXT_depth_bounds_test); -EXTRA_EXT(ARB_shader_objects); -EXTRA_EXT(ARB_fragment_shader); -EXTRA_EXT(ARB_fragment_program); EXTRA_EXT(APPLE_vertex_array_object); EXTRA_EXT(EXT_compiled_vertex_array); -EXTRA_EXT(ARB_vertex_shader); EXTRA_EXT(EXT_pixel_buffer_object); -EXTRA_EXT(ARB_vertex_program); EXTRA_EXT2(NV_point_sprite, ARB_point_sprite); -EXTRA_EXT2(ARB_fragment_program, NV_fragment_program); -EXTRA_EXT2(ARB_vertex_program, NV_vertex_program); -EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); - -static const int -extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { - EXT(ARB_vertex_program), - EXT(ARB_fragment_program), - EXT(NV_vertex_program), - EXTRA_END -}; - -static const int -extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { - EXT(NV_vertex_program), - EXT(ARB_vertex_program), - EXT(ARB_fragment_program), - EXT(NV_vertex_program), - EXTRA_END -}; static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; @@ -527,10 +493,6 @@ static const struct value_desc values[] = { { GL_TEXTURE_COORD_ARRAY_STRIDE, LOC_CUSTOM, TYPE_INT, offsetof(struct gl_client_array, Stride), NO_EXTRA }, - /* GL_ARB_multitexture */ - { GL_MAX_TEXTURE_UNITS, CONTEXT_INT(Const.MaxTextureUnits), NO_EXTRA }, - { GL_CLIENT_ACTIVE_TEXTURE, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, - /* GL_ARB_texture_cube_map */ { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, /* S, T, and R are always set at the same time */ @@ -555,42 +517,12 @@ static const struct value_desc values[] = { CONTEXT_BOOL(Point.PointSprite), extra_NV_point_sprite_ARB_point_sprite }, - /* GL_ARB_fragment_shader */ - { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, - CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents), - extra_ARB_fragment_shader }, - - /* GL_ARB_vertex_shader */ - { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, - CONTEXT_INT(Const.VertexProgram.MaxUniformComponents), - extra_ARB_vertex_shader }, - { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_vertex_shader }, - /* GL_EXT_texture_filter_anisotropic */ { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), extra_EXT_texture_filter_anisotropic }, - { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */ - CONTEXT_INT(Const.MaxTextureCoordUnits), - extra_ARB_fragment_program_NV_fragment_program }, - { GL_BLEND_COLOR_EXT, LOC_CUSTOM, TYPE_FLOATN_4, 0, NO_EXTRA }, - /* GL_ARB_fragment_program */ - { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */ - CONTEXT_INT(Const.MaxTextureImageUnits), - extra_ARB_fragment_program_NV_fragment_program }, - { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, - CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader }, - { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, - CONTEXT_INT(Const.MaxCombinedTextureImageUnits), - extra_ARB_vertex_shader }, - - /* GL_ARB_shader_objects - * Actually, this token isn't part of GL_ARB_shader_objects, but is - * close enough for now. */ - { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects }, /* OpenGL 2.0 */ { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA }, @@ -606,10 +538,6 @@ static const struct value_desc values[] = { { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, offsetof(struct gl_context, Const.Max3DTextureLevels), NO_EXTRA }, - /* GL_ARB_fragment_program/OES_standard_derivatives */ - { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, - CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader }, - { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits), NO_EXTRA }, { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits), NO_EXTRA }, { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits), NO_EXTRA }, @@ -780,8 +708,6 @@ static const struct value_desc values[] = { { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA }, /* GL_EXT_secondary_color */ - { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled), - extra_EXT_secondary_color_ARB_vertex_program }, { GL_CURRENT_SECONDARY_COLOR_EXT, CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4), extra_EXT_secondary_color_flush_current }, @@ -822,83 +748,6 @@ static const struct value_desc values[] = { { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin), extra_NV_point_sprite_ARB_point_sprite }, - /* GL_NV_vertex_program */ - { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(0)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(1)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(2)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(3)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(4)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(5)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(6)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(7)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(8)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(9)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(10)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(11)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(12)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(13)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(14)].Enabled), - extra_NV_vertex_program }, - { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(15)].Enabled), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]), - extra_NV_vertex_program }, - { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]), - extra_NV_vertex_program }, - - /* GL_NV_fragment_program */ - { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled), - extra_NV_fragment_program }, - { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, - extra_NV_fragment_program }, - { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV, - CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS), - extra_NV_fragment_program }, - /* GL_EXT_stencil_two_side */ { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide), extra_EXT_stencil_two_side }, @@ -926,41 +775,6 @@ static const struct value_desc values[] = { { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, extra_EXT_pixel_buffer_object }, - /* GL_ARB_vertex_program */ - { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */ - CONTEXT_BOOL(VertexProgram.Enabled), - extra_ARB_vertex_program_NV_vertex_program }, - { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/ - CONTEXT_BOOL(VertexProgram.PointSizeEnabled), - extra_ARB_vertex_program_NV_vertex_program }, - { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */ - CONTEXT_BOOL(VertexProgram.TwoSideEnabled), - extra_ARB_vertex_program_NV_vertex_program }, - { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ - CONTEXT_INT(Const.MaxProgramMatrixStackDepth), - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */ - CONTEXT_INT(Const.MaxProgramMatrices), - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */ - LOC_CUSTOM, TYPE_INT, 0, - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - - { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ - LOC_CUSTOM, TYPE_MATRIX, 0, - extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ - LOC_CUSTOM, TYPE_MATRIX, 0, - extra_ARB_vertex_program_ARB_fragment_program }, - - { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */ - CONTEXT_INT(Program.ErrorPos), - extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, - - /* GL_ARB_fragment_program */ - { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled), - extra_ARB_fragment_program }, - /* GL_EXT_depth_bounds_test */ { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest), extra_EXT_depth_bounds_test }, @@ -975,14 +789,6 @@ static const struct value_desc values[] = { { GL_RGBA_INTEGER_MODE_EXT, BUFFER_BOOL(_IntegerColor), extra_EXT_texture_integer }, - /* GL_EXT_gpu_shader4 / GLSL 1.30 */ - { GL_MIN_PROGRAM_TEXEL_OFFSET, - CONTEXT_INT(Const.MinProgramTexelOffset), - extra_GLSL_130 }, - { GL_MAX_PROGRAM_TEXEL_OFFSET, - CONTEXT_INT(Const.MaxProgramTexelOffset), - extra_GLSL_130 }, - /* GL 3.0 */ { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 }, { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 }, @@ -1106,7 +912,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu { struct gl_buffer_object **buffer_obj; struct gl_client_array *array; - GLuint unit, *p; + GLuint *p; switch (d->pname) { case GL_TEXTURE_1D: @@ -1123,19 +929,17 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; case GL_CURRENT_RASTER_TEXTURE_COORDS: - unit = ctx->Texture.CurrentUnit; - v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; - v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; - v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; - v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; + v->value_float_4[0] = ctx->Current.RasterTexCoords[0]; + v->value_float_4[1] = ctx->Current.RasterTexCoords[1]; + v->value_float_4[2] = ctx->Current.RasterTexCoords[2]; + v->value_float_4[3] = ctx->Current.RasterTexCoords[3]; break; case GL_CURRENT_TEXTURE_COORDS: - unit = ctx->Texture.CurrentUnit; - v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; - v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; - v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; - v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; + v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX][0]; + v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX][1]; + v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX][2]; + v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX][3]; break; case GL_COLOR_WRITEMASK: @@ -1161,29 +965,20 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; case GL_TEXTURE_STACK_DEPTH: - unit = ctx->Texture.CurrentUnit; - v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; + v->value_int = ctx->TextureMatrixStack.Depth + 1; break; case GL_TEXTURE_MATRIX: - unit = ctx->Texture.CurrentUnit; - v->value_matrix = ctx->TextureMatrixStack[unit].Top; + v->value_matrix = ctx->TextureMatrixStack.Top; break; case GL_TEXTURE_COORD_ARRAY: case GL_TEXTURE_COORD_ARRAY_SIZE: case GL_TEXTURE_COORD_ARRAY_TYPE: case GL_TEXTURE_COORD_ARRAY_STRIDE: - array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]; + array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX]; v->value_int = *(GLuint *) ((char *) array + d->offset); break; - case GL_ACTIVE_TEXTURE_ARB: - v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; - break; - case GL_CLIENT_ACTIVE_TEXTURE_ARB: - v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; - break; - case GL_MODELVIEW_STACK_DEPTH: case GL_PROJECTION_STACK_DEPTH: v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; @@ -1268,19 +1063,14 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu v->value_matrix = ctx->CurrentStack->Top; break; - case GL_MAX_VARYING_FLOATS_ARB: - v->value_int = ctx->Const.MaxVarying * 4; - break; - /* Various object names */ case GL_TEXTURE_BINDING_1D: case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_3D: case GL_TEXTURE_BINDING_CUBE_MAP_ARB: - unit = ctx->Texture.CurrentUnit; v->value_int = - ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; + ctx->Texture.Unit.CurrentTex[d->offset]->Name; break; /* GL_ARB_vertex_buffer_object */ @@ -1300,30 +1090,18 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: v->value_int = - ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj->Name; + ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX].BufferObj->Name; break; case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: v->value_int = ctx->Array.ArrayObj->ElementArrayBufferObj->Name; break; - case GL_FRAGMENT_PROGRAM_BINDING_NV: - v->value_int = - ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0; - break; - case GL_VERTEX_PROGRAM_BINDING_NV: - v->value_int = - ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0; - break; case GL_PIXEL_PACK_BUFFER_BINDING_EXT: v->value_int = ctx->Pack.BufferObj->Name; break; case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: v->value_int = ctx->Unpack.BufferObj->Name; break; - case GL_CURRENT_PROGRAM: - v->value_int = - ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0; - break; case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: v->value_int = ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].BufferObj->Name; break; @@ -1332,10 +1110,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu COPY_4FV(v->value_float_4, ctx->Fog.Color); break; case GL_COLOR_CLEAR_VALUE: - v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F); - v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F); - v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F); - v->value_float_4[3] = CLAMP(ctx->Color.ClearColor.f[3], 0.0F, 1.0F); + v->value_float_4[0] = ctx->Color.ClearColor.f[0], 0.0F, 1.0F; + v->value_float_4[1] = ctx->Color.ClearColor.f[1], 0.0F, 1.0F; + v->value_float_4[2] = ctx->Color.ClearColor.f[2], 0.0F, 1.0F; + v->value_float_4[3] = ctx->Color.ClearColor.f[3], 0.0F, 1.0F; break; case GL_BLEND_COLOR_EXT: COPY_4FV(v->value_float_4, ctx->Color.BlendColor); @@ -1343,13 +1121,6 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu case GL_ALPHA_TEST_REF: v->value_float = ctx->Color.AlphaRef; break; - case GL_MAX_VERTEX_UNIFORM_VECTORS: - v->value_int = ctx->Const.VertexProgram.MaxUniformComponents / 4; - break; - - case GL_MAX_FRAGMENT_UNIFORM_VECTORS: - v->value_int = ctx->Const.FragmentProgram.MaxUniformComponents / 4; - break; } } @@ -1404,13 +1175,6 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d case EXTRA_FLUSH_CURRENT: FLUSH_CURRENT(ctx, 0); break; - case EXTRA_VALID_TEXTURE_UNIT: - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", - func, ctx->Texture.CurrentUnit); - return GL_FALSE; - } - break; case EXTRA_VALID_CLIP_DISTANCE: if (d->pname - GL_CLIP_DISTANCE0 >= ctx->Const.MaxClipPlanes) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(clip distance %u)", @@ -1418,12 +1182,6 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d return GL_FALSE; } break; - case EXTRA_GLSL_130: - if (ctx->Const.GLSLVersion >= 130) { - total++; - enabled++; - } - break; case EXTRA_END: break; default: /* *e is a offset into the extension struct */ @@ -1500,7 +1258,7 @@ find_value(const char *func, GLenum pname, void **p, union value *v) *p = ((char *) ctx->Array.ArrayObj + d->offset); return d; case LOC_TEXUNIT: - unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + unit = &ctx->Texture.Unit; *p = ((char *) unit + d->offset); return d; case LOC_CUSTOM: diff --git a/reactos/dll/opengl/mesa/src/mesa/main/getstring.c b/reactos/dll/opengl/mesa/src/mesa/main/getstring.c index 9e1526e0cb3..f69fe2aafad 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/getstring.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/getstring.c @@ -33,32 +33,6 @@ #include "mtypes.h" -/** - * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query. - */ -static const GLubyte * -shading_language_version(struct gl_context *ctx) -{ - if (!ctx->Extensions.ARB_shader_objects) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetString"); - return (const GLubyte *) 0; - } - - switch (ctx->Const.GLSLVersion) { - case 110: - return (const GLubyte *) "1.10"; - case 120: - return (const GLubyte *) "1.20"; - case 130: - return (const GLubyte *) "1.30"; - default: - _mesa_problem(ctx, - "Invalid GLSL version in shading_language_version()"); - return (const GLubyte *) 0; - } -} - - /** * Query string-valued state. The return value should _not_ be freed by * the caller. @@ -100,21 +74,6 @@ _mesa_GetString( GLenum name ) return (const GLubyte *) ctx->VersionString; case GL_EXTENSIONS: return (const GLubyte *) ctx->Extensions.String; -#if FEATURE_ARB_shading_language_100 || FEATURE_ES2 - case GL_SHADING_LANGUAGE_VERSION: - return shading_language_version(ctx); -#endif -#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \ - FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - case GL_PROGRAM_ERROR_STRING_NV: - if (ctx->Extensions.NV_fragment_program || - ctx->Extensions.ARB_fragment_program || - ctx->Extensions.NV_vertex_program || - ctx->Extensions.ARB_vertex_program) { - return (const GLubyte *) ctx->Program.ErrorString; - } - /* FALL-THROUGH */ -#endif default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" ); return (const GLubyte *) 0; @@ -165,7 +124,6 @@ void GLAPIENTRY _mesa_GetPointerv( GLenum pname, GLvoid **params ) { GET_CURRENT_CONTEXT(ctx); - const GLuint clientUnit = ctx->Array.ActiveTexture; ASSERT_OUTSIDE_BEGIN_END(ctx); if (!params) @@ -194,7 +152,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr; break; case GL_TEXTURE_COORD_ARRAY_POINTER: - *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(clientUnit)].Ptr; + *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX].Ptr; break; case GL_EDGE_FLAG_ARRAY_POINTER: *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr; diff --git a/reactos/dll/opengl/mesa/src/mesa/main/hint.c b/reactos/dll/opengl/mesa/src/mesa/main/hint.c index 500a933ed7c..869c4125408 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/hint.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/hint.c @@ -89,18 +89,6 @@ _mesa_Hint( GLenum target, GLenum mode ) ctx->Hint.ClipVolumeClipping = mode; break; - /* GL_ARB_fragment_shader */ - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: - if (!ctx->Extensions.ARB_fragment_shader) { - _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); - return; - } - if (ctx->Hint.FragmentShaderDerivative == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.FragmentShaderDerivative = mode; - break; - default: _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); return; @@ -125,5 +113,4 @@ void _mesa_init_hint( struct gl_context * ctx ) ctx->Hint.PolygonSmooth = GL_DONT_CARE; ctx->Hint.Fog = GL_DONT_CARE; ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; - ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/image.c b/reactos/dll/opengl/mesa/src/mesa/main/image.c index 70b63fce04e..48f0fb472b0 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/image.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/image.c @@ -226,8 +226,6 @@ _mesa_components_in_format( GLenum format ) case GL_LUMINANCE_ALPHA_INTEGER_EXT: case GL_RG: case GL_YCBCR_MESA: - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: case GL_RG_INTEGER: return 2; @@ -504,23 +502,6 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx, else return GL_INVALID_OPERATION; - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - if (!ctx->Extensions.ATI_envmap_bumpmap) - return GL_INVALID_ENUM; - switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_FLOAT: - return GL_NO_ERROR; - default: - return GL_INVALID_ENUM; - } - /* integer-valued formats */ case GL_RED_INTEGER_EXT: case GL_GREEN_INTEGER_EXT: @@ -820,22 +801,6 @@ _mesa_is_depth_or_stencil_format(GLenum format) } -/** - * Test if the given image format is a dudv format. - */ -GLboolean -_mesa_is_dudv_format(GLenum format) -{ - switch (format) { - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - /** * Test if the given format is an integer (non-normalized) format. */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/image.h b/reactos/dll/opengl/mesa/src/mesa/main/image.h index 8b557cc16e9..6cd7b08dce4 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/image.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/image.h @@ -72,9 +72,6 @@ _mesa_is_ycbcr_format(GLenum format); extern GLboolean _mesa_is_depth_or_stencil_format(GLenum format); -extern GLboolean -_mesa_is_dudv_format(GLenum format); - extern GLboolean _mesa_is_integer_format(GLenum format); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/matrix.c b/reactos/dll/opengl/mesa/src/mesa/main/matrix.c index f479a22b073..c614f0fa712 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/matrix.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/matrix.c @@ -161,62 +161,7 @@ _mesa_MatrixMode( GLenum mode ) ctx->CurrentStack = &ctx->ProjectionMatrixStack; break; case GL_TEXTURE: - /* This error check is disabled because if we're called from - * glPopAttrib() when the active texture unit is >= MaxTextureCoordUnits - * we'll generate an unexpected error. - * From the GL_ARB_vertex_shader spec it sounds like we should instead - * do error checking in other places when we actually try to access - * texture matrices beyond MaxTextureCoordUnits. - */ -#if 0 - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glMatrixMode(invalid tex unit %d)", - ctx->Texture.CurrentUnit); - return; - } -#endif - ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack)); - ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit]; - break; - case GL_MATRIX0_NV: - case GL_MATRIX1_NV: - case GL_MATRIX2_NV: - case GL_MATRIX3_NV: - case GL_MATRIX4_NV: - case GL_MATRIX5_NV: - case GL_MATRIX6_NV: - case GL_MATRIX7_NV: - if (ctx->Extensions.NV_vertex_program) { - ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); - return; - } - break; - case GL_MATRIX0_ARB: - case GL_MATRIX1_ARB: - case GL_MATRIX2_ARB: - case GL_MATRIX3_ARB: - case GL_MATRIX4_ARB: - case GL_MATRIX5_ARB: - case GL_MATRIX6_ARB: - case GL_MATRIX7_ARB: - if (ctx->Extensions.ARB_vertex_program || - ctx->Extensions.ARB_fragment_program) { - const GLuint m = mode - GL_MATRIX0_ARB; - if (m > ctx->Const.MaxProgramMatrices) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glMatrixMode(GL_MATRIX%d_ARB)", m); - return; - } - ctx->CurrentStack = &ctx->ProgramMatrixStack[m]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); - return; - } + ctx->CurrentStack = &ctx->TextureMatrixStack; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); @@ -250,8 +195,7 @@ _mesa_PushMatrix( void ) if (stack->Depth + 1 >= stack->MaxDepth) { if (ctx->Transform.MatrixMode == GL_TEXTURE) { _mesa_error(ctx, GL_STACK_OVERFLOW, - "glPushMatrix(mode=GL_TEXTURE, unit=%d)", - ctx->Texture.CurrentUnit); + "glPushMatrix(mode=GL_TEXTURE)"); } else { _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)", @@ -290,8 +234,7 @@ _mesa_PopMatrix( void ) if (stack->Depth == 0) { if (ctx->Transform.MatrixMode == GL_TEXTURE) { _mesa_error(ctx, GL_STACK_UNDERFLOW, - "glPopMatrix(mode=GL_TEXTURE, unit=%d)", - ctx->Texture.CurrentUnit); + "glPopMatrix(mode=GL_TEXTURE)"); } else { _mesa_error(ctx, GL_STACK_UNDERFLOW, "glPopMatrix(mode=%s)", @@ -716,19 +659,13 @@ free_matrix_stack( struct gl_matrix_stack *stack ) */ void _mesa_init_matrix( struct gl_context * ctx ) { - GLint i; - /* Initialize matrix stacks */ init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH, _NEW_MODELVIEW); init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH, _NEW_PROJECTION); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) - init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH, - _NEW_TEXTURE_MATRIX); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) - init_matrix_stack(&ctx->ProgramMatrixStack[i], - MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX); + init_matrix_stack(&ctx->TextureMatrixStack, MAX_TEXTURE_STACK_DEPTH, + _NEW_TEXTURE_MATRIX); ctx->CurrentStack = &ctx->ModelviewMatrixStack; /* Init combined Modelview*Projection matrix */ @@ -746,14 +683,9 @@ void _mesa_init_matrix( struct gl_context * ctx ) */ void _mesa_free_matrix_data( struct gl_context *ctx ) { - GLint i; - free_matrix_stack(&ctx->ModelviewMatrixStack); free_matrix_stack(&ctx->ProjectionMatrixStack); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) - free_matrix_stack(&ctx->TextureMatrixStack[i]); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) - free_matrix_stack(&ctx->ProgramMatrixStack[i]); + free_matrix_stack(&ctx->TextureMatrixStack); /* combined Modelview*Projection matrix */ _math_matrix_dtr( &ctx->_ModelProjectMatrix ); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/mtypes.h b/reactos/dll/opengl/mesa/src/mesa/main/mtypes.h index 1ec0e9b0a57..aef6fc3c3fe 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/mtypes.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/mtypes.h @@ -72,11 +72,9 @@ struct _mesa_HashTable; struct gl_attrib_node; struct gl_list_extensions; struct gl_meta_state; -struct gl_program_cache; struct gl_texture_object; struct gl_context; struct st_context; -struct gl_uniform_storage; /*@}*/ @@ -86,18 +84,6 @@ struct gl_uniform_storage; #define PRIM_UNKNOWN (GL_POLYGON+3) -/** - * Shader stages. Note that these will become 5 with tessellation. - * These MUST have the same values as gallium's PIPE_SHADER_* - */ -typedef enum -{ - MESA_SHADER_VERTEX = 0, - MESA_SHADER_FRAGMENT = 1, - MESA_SHADER_TYPES = 2 -} gl_shader_type; - - /** * Indexes for vertex program attributes. @@ -116,62 +102,17 @@ typedef enum VERT_ATTRIB_FOG = 5, VERT_ATTRIB_COLOR_INDEX = 6, VERT_ATTRIB_EDGEFLAG = 7, - VERT_ATTRIB_TEX0 = 8, - VERT_ATTRIB_TEX1 = 9, - VERT_ATTRIB_TEX2 = 10, - VERT_ATTRIB_TEX3 = 11, - VERT_ATTRIB_TEX4 = 12, - VERT_ATTRIB_TEX5 = 13, - VERT_ATTRIB_TEX6 = 14, - VERT_ATTRIB_TEX7 = 15, - VERT_ATTRIB_POINT_SIZE = 16, - VERT_ATTRIB_GENERIC0 = 17, - VERT_ATTRIB_GENERIC1 = 18, - VERT_ATTRIB_GENERIC2 = 19, - VERT_ATTRIB_GENERIC3 = 20, - VERT_ATTRIB_GENERIC4 = 21, - VERT_ATTRIB_GENERIC5 = 22, - VERT_ATTRIB_GENERIC6 = 23, - VERT_ATTRIB_GENERIC7 = 24, - VERT_ATTRIB_GENERIC8 = 25, - VERT_ATTRIB_GENERIC9 = 26, - VERT_ATTRIB_GENERIC10 = 27, - VERT_ATTRIB_GENERIC11 = 28, - VERT_ATTRIB_GENERIC12 = 29, - VERT_ATTRIB_GENERIC13 = 30, - VERT_ATTRIB_GENERIC14 = 31, - VERT_ATTRIB_GENERIC15 = 32, - VERT_ATTRIB_MAX = 33 + VERT_ATTRIB_TEX = 8, + VERT_ATTRIB_POINT_SIZE = 9, + VERT_ATTRIB_MAX = 10 } gl_vert_attrib; /** * Symbolic constats to help iterating over * specific blocks of vertex attributes. * - * VERT_ATTRIB_FF - * includes all fixed function attributes as well as - * the aliased GL_NV_vertex_program shader attributes. - * VERT_ATTRIB_TEX - * include the classic texture coordinate attributes. - * Is a subset of VERT_ATTRIB_FF. - * VERT_ATTRIB_GENERIC_NV - * include the NV shader attributes. - * Is a subset of VERT_ATTRIB_FF. - * VERT_ATTRIB_GENERIC - * include the OpenGL 2.0+ GLSL generic shader attributes. - * These alias the generic GL_ARB_vertex_shader attributes. */ -#define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i)) -#define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0 - -#define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i)) -#define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS - -#define VERT_ATTRIB_GENERIC_NV(i) (VERT_ATTRIB_POS + (i)) -#define VERT_ATTRIB_GENERIC_NV_MAX MAX_VERTEX_GENERIC_ATTRIBS - -#define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i)) -#define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS +#define VERT_ATTRIB(i) (VERT_ATTRIB_POS + (i)) /** * Bitflags for vertex attributes. @@ -186,67 +127,15 @@ typedef enum #define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG) #define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX) #define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7) +#define VERT_BIT_TEX BITFIELD64_BIT(VERT_ATTRIB_TEX) #define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE) -#define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0) #define VERT_BIT(i) BITFIELD64_BIT(i) #define VERT_BIT_ALL (BITFIELD64_BIT(VERT_ATTRIB_MAX) - 1) -#define VERT_BIT_FF(i) VERT_BIT(i) -#define VERT_BIT_FF_ALL (BITFIELD64_BIT(VERT_ATTRIB_FF_MAX) - 1) -#define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i)) -#define VERT_BIT_TEX_ALL \ - ((BITFIELD64_BIT(VERT_ATTRIB_TEX_MAX) - 1) << VERT_ATTRIB_TEX(0)) -#define VERT_BIT_GENERIC_NV(i) VERT_BIT(VERT_ATTRIB_GENERIC_NV(i)) -#define VERT_BIT_GENERIC_NV_ALL \ - ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_NV_MAX) - 1) << (VERT_ATTRIB_GENERIC_NV(0))) -#define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i)) -#define VERT_BIT_GENERIC_ALL \ - ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_MAX) - 1) << (VERT_ATTRIB_GENERIC(0))) /*@}*/ -/** - * Indexes for vertex program result attributes. Note that - * _mesa_vert_result_to_frag_attrib() and _mesa_frag_attrib_to_vert_result() make - * assumptions about the layout of this enum. - */ -typedef enum -{ - VERT_RESULT_HPOS = 0, - VERT_RESULT_COL0 = 1, - VERT_RESULT_COL1 = 2, - VERT_RESULT_FOGC = 3, - VERT_RESULT_TEX0 = 4, - VERT_RESULT_TEX1 = 5, - VERT_RESULT_TEX2 = 6, - VERT_RESULT_TEX3 = 7, - VERT_RESULT_TEX4 = 8, - VERT_RESULT_TEX5 = 9, - VERT_RESULT_TEX6 = 10, - VERT_RESULT_TEX7 = 11, - VERT_RESULT_PSIZ = 12, - VERT_RESULT_BFC0 = 13, - VERT_RESULT_BFC1 = 14, - VERT_RESULT_EDGE = 15, - VERT_RESULT_CLIP_VERTEX = 16, - VERT_RESULT_CLIP_DIST0 = 17, - VERT_RESULT_CLIP_DIST1 = 18, - VERT_RESULT_VAR0 = 19, /**< shader varying */ - VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) -} gl_vert_result; - - -/*********************************************/ - /** * Indexes for fragment program input attributes. Note that * _mesa_vert_result_to_frag_attrib() and frag_attrib_to_vert_result() make @@ -258,118 +147,19 @@ typedef enum FRAG_ATTRIB_COL0 = 1, FRAG_ATTRIB_COL1 = 2, FRAG_ATTRIB_FOGC = 3, - FRAG_ATTRIB_TEX0 = 4, - FRAG_ATTRIB_TEX1 = 5, - FRAG_ATTRIB_TEX2 = 6, - FRAG_ATTRIB_TEX3 = 7, - FRAG_ATTRIB_TEX4 = 8, - FRAG_ATTRIB_TEX5 = 9, - FRAG_ATTRIB_TEX6 = 10, - FRAG_ATTRIB_TEX7 = 11, - FRAG_ATTRIB_FACE = 12, /**< front/back face */ - FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ - FRAG_ATTRIB_CLIP_DIST0 = 14, - FRAG_ATTRIB_CLIP_DIST1 = 15, - FRAG_ATTRIB_VAR0 = 16, /**< shader varying */ - FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) + FRAG_ATTRIB_TEX = 4, + FRAG_ATTRIB_FACE = 5, /**< front/back face */ + FRAG_ATTRIB_PNTC = 6, /**< sprite/point coord */ + FRAG_ATTRIB_CLIP_DIST0 = 7, + FRAG_ATTRIB_CLIP_DIST1 = 8, + FRAG_ATTRIB_MAX = 9 } gl_frag_attrib; -/** - * Convert from a gl_vert_result value to the corresponding gl_frag_attrib. - * - * VERT_RESULT_HPOS is converted to FRAG_ATTRIB_WPOS. - * - * gl_vert_result values which have no corresponding gl_frag_attrib - * (VERT_RESULT_PSIZ, VERT_RESULT_BFC0, VERT_RESULT_BFC1, and - * VERT_RESULT_EDGE) are converted to a value of -1. - */ -static inline int -_mesa_vert_result_to_frag_attrib(gl_vert_result vert_result) -{ - if (vert_result >= VERT_RESULT_CLIP_DIST0) - return vert_result - VERT_RESULT_CLIP_DIST0 + FRAG_ATTRIB_CLIP_DIST0; - else if (vert_result <= VERT_RESULT_TEX7) - return vert_result; - else - return -1; -} - - -/** - * Convert from a gl_frag_attrib value to the corresponding gl_vert_result. - * - * FRAG_ATTRIB_WPOS is converted to VERT_RESULT_HPOS. - * - * gl_frag_attrib values which have no corresponding gl_vert_result - * (FRAG_ATTRIB_FACE and FRAG_ATTRIB_PNTC) are converted to a value of -1. - */ -static inline int -_mesa_frag_attrib_to_vert_result(gl_frag_attrib frag_attrib) -{ - if (frag_attrib <= FRAG_ATTRIB_TEX7) - return frag_attrib; - else if (frag_attrib >= FRAG_ATTRIB_CLIP_DIST0) - return frag_attrib - FRAG_ATTRIB_CLIP_DIST0 + VERT_RESULT_CLIP_DIST0; - else - return -1; -} - - -/** - * Bitflags for fragment program input attributes. - */ -/*@{*/ -#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS) #define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0) #define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1) #define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC) -#define FRAG_BIT_FACE (1 << FRAG_ATTRIB_FACE) -#define FRAG_BIT_PNTC (1 << FRAG_ATTRIB_PNTC) -#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0) -#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1) -#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2) -#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3) -#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4) -#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5) -#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6) -#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7) -#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0) - -#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U)) -#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V)) - -#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \ - FRAG_BIT_TEX1| \ - FRAG_BIT_TEX2| \ - FRAG_BIT_TEX3| \ - FRAG_BIT_TEX4| \ - FRAG_BIT_TEX5| \ - FRAG_BIT_TEX6| \ - FRAG_BIT_TEX7) -/*@}*/ - - -/** - * Fragment program results - */ -typedef enum -{ - FRAG_RESULT_DEPTH = 0, - FRAG_RESULT_STENCIL = 1, - /* If a single color should be written to all render targets, this - * register is written. No FRAG_RESULT_DATAn will be written. - */ - FRAG_RESULT_COLOR = 2, - - /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n] - * or ARB_fragment_program fragment.color[n]) color results. If - * any are written, FRAG_RESULT_COLOR will not be written. - */ - FRAG_RESULT_DATA0 = 3, - FRAG_RESULT_MAX = (FRAG_RESULT_DATA0) -} gl_frag_result; - +#define FRAG_BIT_TEX (1 << FRAG_ATTRIB_TEX) /** * Indexes for all renderbuffers @@ -708,7 +498,7 @@ struct gl_current_attrib GLfloat RasterDistance; GLfloat RasterColor[4]; GLfloat RasterSecondaryColor[4]; - GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; + GLfloat RasterTexCoords[4]; GLboolean RasterPosValid; /*@}*/ }; @@ -746,7 +536,6 @@ struct gl_eval_attrib GLboolean Map1TextureCoord4; GLboolean Map1Vertex3; GLboolean Map1Vertex4; - GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ GLboolean Map2Color4; GLboolean Map2Index; GLboolean Map2Normal; @@ -756,7 +545,6 @@ struct gl_eval_attrib GLboolean Map2TextureCoord4; GLboolean Map2Vertex3; GLboolean Map2Vertex4; - GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ GLboolean AutoNormal; /*@}*/ @@ -822,7 +610,6 @@ struct gl_hint_attrib GLenum PolygonSmooth; GLenum Fog; GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ - GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ }; /** @@ -982,7 +769,7 @@ struct gl_point_attrib GLfloat Threshold; /**< GL_EXT_point_parameters */ GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ - GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/ + GLboolean CoordReplace; /**< GL_ARB_point_sprite*/ GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ }; @@ -1273,8 +1060,6 @@ struct gl_texture_unit GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ GLfloat LodBias; /**< for biasing mipmap levels */ - GLenum BumpTarget; - GLfloat RotMatrix[4]; /* 2x2 matrix */ /** * \name GL_EXT_texture_env_combine @@ -1306,22 +1091,20 @@ struct gl_texture_unit */ struct gl_texture_attrib { - GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ - struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + struct gl_texture_unit Unit; struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; - - /** Texture units/samplers used by vertex or fragment texturing */ - GLbitfield _EnabledUnits; + + GLboolean _Enabled; /** Texture coord units/sets used for fragment texturing */ - GLbitfield _EnabledCoordUnits; + GLboolean _EnabledCoord; /** Texture coord units that have texgen enabled */ - GLbitfield _TexGenEnabled; + GLboolean _TexGenEnabled; /** Texture coord units that have non-identity matrices */ - GLbitfield _TexMatEnabled; + GLboolean _TexMatEnabled; /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ GLbitfield _GenFlags; @@ -1490,7 +1273,6 @@ struct gl_array_attrib /** Array objects (GL_ARB/APPLE_vertex_array_object) */ struct _mesa_HashTable *Objects; - GLint ActiveTexture; /**< Client Active Texture */ GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */ GLuint LockCount; /**< GL_EXT_compiled_vertex_array */ @@ -1574,7 +1356,6 @@ struct gl_evaluators struct gl_1d_map Map1Texture2; struct gl_1d_map Map1Texture3; struct gl_1d_map Map1Texture4; - struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */ /*@}*/ /** @@ -1590,448 +1371,10 @@ struct gl_evaluators struct gl_2d_map Map2Texture2; struct gl_2d_map Map2Texture3; struct gl_2d_map Map2Texture4; - struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */ /*@}*/ }; -/** - * Names of the various vertex/fragment program register files, etc. - * - * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) - * All values should fit in a 4-bit field. - * - * NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM, - * PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to - * be "uniform" variables since they can only be set outside glBegin/End. - * They're also all stored in the same Parameters array. - */ -typedef enum -{ - PROGRAM_TEMPORARY, /**< machine->Temporary[] */ - PROGRAM_INPUT, /**< machine->Inputs[] */ - PROGRAM_OUTPUT, /**< machine->Outputs[] */ - PROGRAM_VARYING, /**< machine->Inputs[]/Outputs[] */ - PROGRAM_LOCAL_PARAM, /**< gl_program->LocalParams[] */ - PROGRAM_ENV_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */ - PROGRAM_NAMED_PARAM, /**< gl_program->Parameters[] */ - PROGRAM_CONSTANT, /**< gl_program->Parameters[] */ - PROGRAM_UNIFORM, /**< gl_program->Parameters[] */ - PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */ - PROGRAM_ADDRESS, /**< machine->AddressReg */ - PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */ - PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */ - PROGRAM_UNDEFINED, /**< Invalid/TBD value */ - PROGRAM_FILE_MAX -} gl_register_file; - - -/** - * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be - * one of these values. - */ -typedef enum -{ - SYSTEM_VALUE_FRONT_FACE, /**< Fragment shader only (not done yet) */ - SYSTEM_VALUE_VERTEX_ID, /**< Vertex shader only */ - SYSTEM_VALUE_INSTANCE_ID, /**< Vertex shader only */ - SYSTEM_VALUE_MAX /**< Number of values */ -} gl_system_value; - - -/** - * The possible interpolation qualifiers that can be applied to a fragment - * shader input in GLSL. - * - * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the - * gl_fragment_program data structure to 0 causes the default behavior. - */ -enum glsl_interp_qualifier -{ - INTERP_QUALIFIER_NONE = 0, - INTERP_QUALIFIER_SMOOTH, - INTERP_QUALIFIER_FLAT, - INTERP_QUALIFIER_NOPERSPECTIVE -}; - - -/** Vertex and fragment instructions */ -struct prog_instruction; -struct gl_program_parameter_list; -struct gl_uniform_list; - -/** - * Base class for any kind of program object - */ -struct gl_program -{ - GLuint Id; - GLubyte *String; /**< Null-terminated program text */ - GLint RefCount; - GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */ - GLenum Format; /**< String encoding format */ - GLboolean Resident; - - struct prog_instruction *Instructions; - - GLbitfield64 InputsRead; /**< Bitmask of which input regs are read */ - GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ - GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */ - GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ - GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ - GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */ - GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ - GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ - - - /** Named parameters, constants, etc. from program text */ - struct gl_program_parameter_list *Parameters; - /** Numbered local parameters */ - GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4]; - - /** Map from sampler unit to texture unit (set by glUniform1i()) */ - GLubyte SamplerUnits[MAX_SAMPLERS]; - - /** Bitmask of which register files are read/written with indirect - * addressing. Mask of (1 << PROGRAM_x) bits. - */ - GLbitfield IndirectRegisterFiles; - - /** Logical counts */ - /*@{*/ - GLuint NumInstructions; - GLuint NumTemporaries; - GLuint NumParameters; - GLuint NumAttributes; - GLuint NumAddressRegs; - GLuint NumAluInstructions; - GLuint NumTexInstructions; - GLuint NumTexIndirections; - /*@}*/ - /** Native, actual h/w counts */ - /*@{*/ - GLuint NumNativeInstructions; - GLuint NumNativeTemporaries; - GLuint NumNativeParameters; - GLuint NumNativeAttributes; - GLuint NumNativeAddressRegs; - GLuint NumNativeAluInstructions; - GLuint NumNativeTexInstructions; - GLuint NumNativeTexIndirections; - /*@}*/ -}; - - -/** Vertex program object */ -struct gl_vertex_program -{ - struct gl_program Base; /**< base class */ - GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */ - GLboolean IsPositionInvariant; - GLboolean UsesClipDistance; -}; - - -/** Fragment program object */ -struct gl_fragment_program -{ - struct gl_program Base; /**< base class */ - GLboolean UsesKill; /**< shader uses KIL instruction */ - enum gl_frag_depth_layout FragDepthLayout; - - /** - * GLSL interpolation qualifier associated with each fragment shader input. - * For inputs that do not have an interpolation qualifier specified in - * GLSL, the value is INTERP_QUALIFIER_NONE. - */ - enum glsl_interp_qualifier InterpQualifier[FRAG_ATTRIB_MAX]; -}; - - -/** - * State common to vertex and fragment programs. - */ -struct gl_program_state -{ - GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */ - const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */ -}; - - -/** - * Context state for vertex programs. - */ -struct gl_vertex_program_state -{ - GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */ - GLboolean _Enabled; /**< Enabled and _valid_ user program? */ - GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */ - GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */ - /** Computed two sided lighting for fixed function/programs. */ - GLboolean _TwoSideEnabled; - struct gl_vertex_program *Current; /**< User-bound vertex program */ - - /** Currently enabled and valid vertex program (including internal - * programs, user-defined vertex programs and GLSL vertex shaders). - * This is the program we must use when rendering. - */ - struct gl_vertex_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /* For GL_NV_vertex_program only: */ - GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4]; - GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4]; - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; - - GLboolean _Overriden; -}; - - -/** - * Context state for fragment programs. - */ -struct gl_fragment_program_state -{ - GLboolean Enabled; /**< User-set fragment program enable flag */ - GLboolean _Enabled; /**< Enabled and _valid_ user program? */ - struct gl_fragment_program *Current; /**< User-bound fragment program */ - - /** Currently enabled and valid fragment program (including internal - * programs, user-defined fragment programs and GLSL fragment shaders). - * This is the program we must use when rendering. - */ - struct gl_fragment_program *_Current; - - GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ - - /** Cache of fixed-function programs */ - struct gl_program_cache *Cache; -}; - -/** Set by #pragma directives */ -struct gl_sl_pragmas -{ - GLboolean IgnoreOptimize; /**< ignore #pragma optimize(on/off) ? */ - GLboolean IgnoreDebug; /**< ignore #pragma debug(on/off) ? */ - GLboolean Optimize; /**< defaults on */ - GLboolean Debug; /**< defaults off */ -}; - - -/** - * A GLSL vertex or fragment shader object. - */ -struct gl_shader -{ - GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */ - GLuint Name; /**< AKA the handle */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - GLboolean CompileStatus; - const GLchar *Source; /**< Source code string */ - GLuint SourceChecksum; /**< for debug/logging purposes */ - struct gl_program *Program; /**< Post-compile assembly code */ - GLchar *InfoLog; - struct gl_sl_pragmas Pragmas; - - unsigned Version; /**< GLSL version used for linking */ - - /** - * \name Sampler tracking - * - * \note Each of these fields is only set post-linking. - */ - /*@{*/ - unsigned num_samplers; /**< Number of samplers used by this shader. */ - GLbitfield active_samplers; /**< Bitfield of which samplers are used */ - GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */ - /*@}*/ - - /** - * Number of uniform components used by this shader. - * - * This field is only set post-linking. - */ - unsigned num_uniform_components; - - struct exec_list *ir; - struct glsl_symbol_table *symbols; - - /** Shaders containing built-in functions that are used for linking. */ - struct gl_shader *builtins_to_link[16]; - unsigned num_builtins_to_link; -}; - - -/** - * A GLSL program object. - * Basically a linked collection of vertex and fragment shaders. - */ -struct gl_shader_program -{ - GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */ - GLuint Name; /**< aka handle or ID */ - GLint RefCount; /**< Reference count */ - GLboolean DeletePending; - - /** - * Flags that the linker should not reject the program if it lacks - * a vertex or fragment shader. GLES2 doesn't allow separate - * shader objects, and would reject them. However, we internally - * build separate shader objects for fixed function programs, which - * we use for drivers/common/meta.c and for handling - * _mesa_update_state with no program bound (for example in - * glClear()). - */ - GLboolean InternalSeparateShader; - - GLuint NumShaders; /**< number of attached shaders */ - struct gl_shader **Shaders; /**< List of attached the shaders */ - - /** - * User-defined attribute bindings - * - * These are set via \c glBindAttribLocation and are used to direct the - * GLSL linker. These are \b not the values used in the compiled shader, - * and they are \b not the values returned by \c glGetAttribLocation. - */ - struct string_to_uint_map *AttributeBindings; - - /** - * User-defined fragment data bindings - * - * These are set via \c glBindFragDataLocation and are used to direct the - * GLSL linker. These are \b not the values used in the compiled shader, - * and they are \b not the values returned by \c glGetFragDataLocation. - */ - struct string_to_uint_map *FragDataBindings; - - /** Post-link gl_FragDepth layout for ARB_conservative_depth. */ - enum gl_frag_depth_layout FragDepthLayout; - - /** Vertex shader state - copied into gl_vertex_program at link time */ - struct { - GLboolean UsesClipDistance; /**< True if gl_ClipDistance is written to. */ - GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or - 0 if not present. */ - } Vert; - - /* post-link info: */ - unsigned NumUserUniformStorage; - struct gl_uniform_storage *UniformStorage; - - /** - * Map of active uniform names to locations - * - * Maps any active uniform that is not an array element to a location. - * Each active uniform, including individual structure members will appear - * in this map. This roughly corresponds to the set of names that would be - * enumerated by \c glGetActiveUniform. - */ - struct string_to_uint_map *UniformHash; - - /** - * Map from sampler unit to texture unit (set by glUniform1i()) - * - * A sampler unit is associated with each sampler uniform by the linker. - * The sampler unit associated with each uniform is stored in the - * \c gl_uniform_storage::sampler field. - */ - GLubyte SamplerUnits[MAX_SAMPLERS]; - /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ - gl_texture_index SamplerTargets[MAX_SAMPLERS]; - - GLboolean LinkStatus; /**< GL_LINK_STATUS */ - GLboolean Validated; - GLboolean _Used; /**< Ever used for drawing? */ - GLchar *InfoLog; - - unsigned Version; /**< GLSL version used for linking */ - - /** - * Per-stage shaders resulting from the first stage of linking. - * - * Set of linked shaders for this program. The array is accessed using the - * \c MESA_SHADER_* defines. Entries for non-existent stages will be - * \c NULL. - */ - struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES]; -}; - - -#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */ -#define GLSL_LOG 0x2 /**< Write shaders to files */ -#define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */ -#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */ -#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */ -#define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */ -#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */ -#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */ - - -/** - * Context state for GLSL vertex/fragment shaders. - */ -struct gl_shader_state -{ - /** - * Programs used for rendering - * - * There is a separate program set for each shader stage. If - * GL_EXT_separate_shader_objects is not supported, each of these must point - * to \c NULL or to the same program. - */ - struct gl_shader_program *CurrentVertexProgram; - struct gl_shader_program *CurrentFragmentProgram; - - struct gl_shader_program *_CurrentFragmentProgram; - - /** - * Program used by glUniform calls. - * - * Explicitly set by \c glUseProgram and \c glActiveProgramEXT. - */ - struct gl_shader_program *ActiveProgram; - - GLbitfield Flags; /**< Mask of GLSL_x flags */ -}; - -/** - * Compiler options for a single GLSL shaders type - */ -struct gl_shader_compiler_options -{ - /** Driver-selectable options: */ - GLboolean EmitCondCodes; /**< Use condition codes? */ - GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ - GLboolean EmitNoLoops; - GLboolean EmitNoFunctions; - GLboolean EmitNoCont; /**< Emit CONT opcode? */ - GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ - GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ - GLboolean EmitNoPow; /**< Emit POW opcodes? */ - GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to vec4[2]? */ - - /** - * \name Forms of indirect addressing the driver cannot do. - */ - /*@{*/ - GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */ - GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */ - GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */ - GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */ - /*@}*/ - - GLuint MaxIfDepth; /**< Maximum nested IF blocks */ - GLuint MaxUnrollIterations; - - struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ -}; - /** * State which can be shared by multiple contexts: */ @@ -2062,24 +1405,8 @@ struct gl_shared_state /** Default buffer object for vertex arrays that aren't in VBOs */ struct gl_buffer_object *NullBufferObj; - /** - * \name Vertex/geometry/fragment programs - */ - /*@{*/ - struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ - struct gl_vertex_program *DefaultVertexProgram; - struct gl_fragment_program *DefaultFragmentProgram; - /*@}*/ - struct _mesa_HashTable *BufferObjects; - /** Table of both gl_shader and gl_shader_program objects */ - struct _mesa_HashTable *ShaderObjects; - - /* GL_EXT_framebuffer_object */ - struct _mesa_HashTable *RenderBuffers; - struct _mesa_HashTable *FrameBuffers; - void *DriverData; /**< Device driver shared state */ }; @@ -2196,38 +1523,6 @@ struct gl_precision GLushort Precision; /**< number of mantissa bits */ }; - -/** - * Limits for vertex, geometry and fragment programs/shaders. - */ -struct gl_program_constants -{ - /* logical limits */ - GLuint MaxInstructions; - GLuint MaxAluInstructions; - GLuint MaxTexInstructions; - GLuint MaxTexIndirections; - GLuint MaxAttribs; - GLuint MaxTemps; - GLuint MaxAddressRegs; - GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */ - GLuint MaxParameters; - GLuint MaxLocalParams; - GLuint MaxEnvParams; - /* native/hardware limits */ - GLuint MaxNativeInstructions; - GLuint MaxNativeAluInstructions; - GLuint MaxNativeTexInstructions; - GLuint MaxNativeTexIndirections; - GLuint MaxNativeAttribs; - GLuint MaxNativeTemps; - GLuint MaxNativeAddressRegs; - GLuint MaxNativeParameters; - /* For shaders */ - GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */ -}; - - /** * Constants which may be overridden by device driver during context creation * but are never changed after that. @@ -2238,11 +1533,6 @@ struct gl_constants GLint MaxTextureLevels; /**< Max mipmap levels. */ GLint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ GLint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ - GLuint MaxTextureCoordUnits; - GLuint MaxTextureImageUnits; - GLuint MaxVertexTextureImageUnits; - GLuint MaxCombinedTextureImageUnits; - GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ GLuint MaxArrayLockSize; @@ -2265,49 +1555,21 @@ struct gl_constants GLuint MaxViewportWidth, MaxViewportHeight; - struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */ - struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */ - GLuint MaxProgramMatrices; - GLuint MaxProgramMatrixStackDepth; - /** vertex array / buffer object bounds checking */ GLboolean CheckArrayBounds; - /** Number of varying vectors between vertex and fragment shaders */ - GLuint MaxVarying; - - GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */ - - /** - * Changes default GLSL extension behavior from "error" to "warn". It's out - * of spec, but it can make some apps work that otherwise wouldn't. - */ - GLboolean ForceGLSLExtensionsWarn; - /** * Does the driver support real 32-bit integers? (Otherwise, integers are * simulated via floats.) */ GLboolean NativeIntegers; - /** - * If the driver supports real 32-bit integers, what integer value should be - * used for boolean true in uniform uploads? (Usually 1 or ~0.) - */ - GLuint UniformBooleanTrue; - - /** Which texture units support GL_ATI_envmap_bumpmap as targets */ - GLbitfield SupportedBumpUnits; - /** OpenGL version 3.0 */ GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */ /** OpenGL version 3.2 */ GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ - /** GL_EXT_gpu_shader4 */ - GLint MinProgramTexelOffset, MaxProgramTexelOffset; - /* GL_ARB_robustness */ GLenum ResetStrategy; @@ -2324,15 +1586,6 @@ struct gl_constants * Texture borders are deprecated in GL 3.0. **/ GLboolean StripTextureBorder; - - /** - * For drivers which can do a better job at eliminating unused varyings - * and uniforms than the GLSL compiler. - * - * XXX Remove these as soon as a better solution is available. - */ - GLboolean GLSLSkipStrictMaxVaryingLimitCheck; - GLboolean GLSLSkipStrictMaxUniformLimitCheck; }; @@ -2345,18 +1598,10 @@ struct gl_extensions GLboolean dummy; /* don't remove this! */ GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ - GLboolean ARB_conservative_depth; - GLboolean ARB_fragment_program; - GLboolean ARB_fragment_program_shadow; - GLboolean ARB_fragment_shader; GLboolean ARB_half_float_pixel; GLboolean ARB_half_float_vertex; GLboolean ARB_map_buffer_range; GLboolean ARB_point_sprite; - GLboolean ARB_shader_objects; - GLboolean ARB_shader_stencil_export; - GLboolean ARB_shader_texture_lod; - GLboolean ARB_shading_language_100; GLboolean ARB_texture_border_clamp; GLboolean ARB_texture_cube_map; GLboolean ARB_texture_env_combine; @@ -2367,8 +1612,6 @@ struct gl_extensions GLboolean ARB_texture_storage; GLboolean ARB_transpose_matrix; GLboolean ARB_vertex_array_object; - GLboolean ARB_vertex_program; - GLboolean ARB_vertex_shader; GLboolean ARB_window_pos; GLboolean EXT_blend_color; GLboolean EXT_blend_equation_separate; @@ -2379,8 +1622,6 @@ struct gl_extensions GLboolean EXT_depth_bounds_test; GLboolean EXT_draw_range_elements; GLboolean EXT_fog_coord; - GLboolean EXT_gpu_program_parameters; - GLboolean EXT_gpu_shader4; GLboolean EXT_packed_pixels; GLboolean EXT_pixel_buffer_object; GLboolean EXT_point_parameters; @@ -2399,7 +1640,6 @@ struct gl_extensions GLboolean APPLE_packed_pixels; GLboolean APPLE_vertex_array_object; GLboolean APPLE_object_purgeable; - GLboolean ATI_envmap_bumpmap; GLboolean ATI_texture_mirror_once; GLboolean ATI_texture_env_combine3; GLboolean ATI_separate_stencil; @@ -2410,15 +1650,11 @@ struct gl_extensions GLboolean MESA_ycbcr_texture; GLboolean NV_blend_square; GLboolean NV_fog_distance; - GLboolean NV_fragment_program; - GLboolean NV_fragment_program_option; GLboolean NV_light_max_exponent; GLboolean NV_point_sprite; GLboolean NV_texture_barrier; GLboolean NV_texgen_reflection; GLboolean NV_texture_env_combine4; - GLboolean NV_vertex_program; - GLboolean NV_vertex_program1_1; GLboolean extension_sentinel; /** The extension string */ const GLubyte *String; @@ -2486,9 +1722,7 @@ struct gl_matrix_stack #define _NEW_CURRENT_ATTRIB (1 << 23) /**< gl_context::Current */ #define _NEW_MULTISAMPLE (1 << 24) /**< gl_context::Multisample */ #define _NEW_TRACK_MATRIX (1 << 25) /**< gl_context::VertexProgram */ -#define _NEW_PROGRAM (1 << 26) /**< New program/shader state */ -#define _NEW_PROGRAM_CONSTANTS (1 << 27) -#define _NEW_BUFFER_OBJECT (1 << 28) +#define _NEW_BUFFER_OBJECT (1 << 26) #define _NEW_ALL ~0 /** @@ -2526,7 +1760,7 @@ struct gl_matrix_stack */ /*@{*/ #define _DD_NEW_FLATSHADE _NEW_LIGHT -#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM) +#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG) #define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON #define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT #define _DD_NEW_TRI_UNFILLED _NEW_POLYGON @@ -2549,7 +1783,6 @@ struct gl_matrix_stack #define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ _NEW_TEXTURE | \ _NEW_POINT | \ - _NEW_PROGRAM | \ _NEW_MODELVIEW) /*@}*/ @@ -2663,8 +1896,7 @@ struct gl_context /*@{*/ struct gl_matrix_stack ModelviewMatrixStack; struct gl_matrix_stack ProjectionMatrixStack; - struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; - struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; + struct gl_matrix_stack TextureMatrixStack; struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ /*@}*/ @@ -2739,13 +1971,6 @@ struct gl_context struct gl_evaluators EvalMap; /**< All evaluators */ struct gl_feedback Feedback; /**< Feedback */ struct gl_selection Select; /**< Selection */ - - struct gl_program_state Program; /**< general program state */ - struct gl_vertex_program_state VertexProgram; - struct gl_fragment_program_state FragmentProgram; - - struct gl_shader_state Shader; /**< GLSL shader object state */ - struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES]; /*@}*/ struct gl_meta_state *Meta; /**< for "meta" operations */ @@ -2796,9 +2021,6 @@ struct gl_context GLboolean FirstTimeCurrent; /*@}*/ - /** software compression/decompression supported or not */ - GLboolean Mesa_DXTn; - GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; /** diff --git a/reactos/dll/opengl/mesa/src/mesa/main/nvprogram.c b/reactos/dll/opengl/mesa/src/mesa/main/nvprogram.c deleted file mode 100644 index dae11566e39..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/nvprogram.c +++ /dev/null @@ -1,920 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-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. - */ - -/** - * \file nvprogram.c - * NVIDIA vertex/fragment program state management functions. - * \author Brian Paul - */ - -/* - * Regarding GL_NV_fragment/vertex_program, GL_NV_vertex_program1_1, etc: - * - * Portions of this software may use or implement intellectual - * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims - * any and all warranties with respect to such intellectual property, - * including any use thereof or modifications thereto. - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/hash.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/nvprogram.h" -#include "program/arbprogparse.h" -#include "program/nvfragparse.h" -#include "program/nvvertparse.h" -#include "program/program.h" -#include "program/prog_instruction.h" -#include "program/prog_parameter.h" - - - -/** - * Execute a vertex state program. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) -{ - struct gl_vertex_program *vprog; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target != GL_VERTEX_STATE_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_ENUM, "glExecuteProgramNV"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - vprog = (struct gl_vertex_program *) _mesa_lookup_program(ctx, id); - - if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV"); - return; - } - - _mesa_problem(ctx, "glExecuteProgramNV() not supported"); -} - - -/** - * Determine if a set of programs is resident in hardware. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -GLboolean GLAPIENTRY -_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids, - GLboolean *residences) -{ - GLint i, j; - GLboolean allResident = GL_TRUE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV(n)"); - return GL_FALSE; - } - - for (i = 0; i < n; i++) { - const struct gl_program *prog; - if (ids[i] == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV"); - return GL_FALSE; - } - prog = _mesa_lookup_program(ctx, ids[i]); - if (!prog) { - _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV"); - return GL_FALSE; - } - if (prog->Resident) { - if (!allResident) - residences[i] = GL_TRUE; - } - else { - if (allResident) { - allResident = GL_FALSE; - for (j = 0; j < i; j++) - residences[j] = GL_TRUE; - } - residences[i] = GL_FALSE; - } - } - - return allResident; -} - - -/** - * Request that a set of programs be resident in hardware. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids) -{ - GLint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (n < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(n)"); - return; - } - - /* just error checking for now */ - for (i = 0; i < n; i++) { - struct gl_program *prog; - - if (ids[i] == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)"); - return; - } - - prog = _mesa_lookup_program(ctx, ids[i]); - if (!prog) { - _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)"); - return; - } - - /* XXX this is really a hardware thing we should hook out */ - prog->Resident = GL_TRUE; - } -} - - -/** - * Get a program parameter register. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramParameterfvNV(GLenum target, GLuint index, - GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV) { - if (pname == GL_PROGRAM_PARAMETER_NV) { - if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { - COPY_4V(params, ctx->VertexProgram.Parameters[index]); - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetProgramParameterfvNV(index)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(pname)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(target)"); - return; - } -} - - -/** - * Get a program parameter register. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramParameterdvNV(GLenum target, GLuint index, - GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV) { - if (pname == GL_PROGRAM_PARAMETER_NV) { - if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) { - COPY_4V(params, ctx->VertexProgram.Parameters[index]); - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetProgramParameterdvNV(index)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(pname)"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(target)"); - return; - } -} - - -/** - * Get a program attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params) -{ - struct gl_program *prog; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - prog = _mesa_lookup_program(ctx, id); - if (!prog) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramivNV"); - return; - } - - switch (pname) { - case GL_PROGRAM_TARGET_NV: - *params = prog->Target; - return; - case GL_PROGRAM_LENGTH_NV: - *params = prog->String ?(GLint) strlen((char *) prog->String) : 0; - return; - case GL_PROGRAM_RESIDENT_NV: - *params = prog->Resident; - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivNV(pname)"); - return; - } -} - - -/** - * Get the program source code. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program) -{ - struct gl_program *prog; - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname != GL_PROGRAM_STRING_NV) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringNV(pname)"); - return; - } - - prog = _mesa_lookup_program(ctx, id); - if (!prog) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramStringNV"); - return; - } - - if (prog->String) { - memcpy(program, prog->String, strlen((char *) prog->String)); - } - else { - program[0] = 0; - } -} - - -/** - * Get matrix tracking information. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, - GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV - && ctx->Extensions.NV_vertex_program) { - GLuint i; - - if ((address & 0x3) || address >= MAX_NV_VERTEX_PROGRAM_PARAMS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetTrackMatrixivNV(address)"); - return; - } - - i = address / 4; - - switch (pname) { - case GL_TRACK_MATRIX_NV: - params[0] = (GLint) ctx->VertexProgram.TrackMatrix[i]; - return; - case GL_TRACK_MATRIX_TRANSFORM_NV: - params[0] = (GLint) ctx->VertexProgram.TrackMatrixTransform[i]; - return; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV"); - return; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV"); - return; - } -} - - -/** - * Get a vertex (or vertex array) attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params) -{ - const struct gl_client_array *array; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); - return; - } - - array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; - - switch (pname) { - case GL_ATTRIB_ARRAY_SIZE_NV: - params[0] = array->Size; - break; - case GL_ATTRIB_ARRAY_STRIDE_NV: - params[0] = array->Stride; - break; - case GL_ATTRIB_ARRAY_TYPE_NV: - params[0] = array->Type; - break; - case GL_CURRENT_ATTRIB_NV: - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribdvNV(index == 0)"); - return; - } - FLUSH_CURRENT(ctx, 0); - COPY_4V(params, ctx->Current.Attrib[index]); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); - return; - } -} - -/** - * Get a vertex (or vertex array) attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params) -{ - const struct gl_client_array *array; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); - return; - } - - array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; - - switch (pname) { - case GL_ATTRIB_ARRAY_SIZE_NV: - params[0] = (GLfloat) array->Size; - break; - case GL_ATTRIB_ARRAY_STRIDE_NV: - params[0] = (GLfloat) array->Stride; - break; - case GL_ATTRIB_ARRAY_TYPE_NV: - params[0] = (GLfloat) array->Type; - break; - case GL_CURRENT_ATTRIB_NV: - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribfvNV(index == 0)"); - return; - } - FLUSH_CURRENT(ctx, 0); - COPY_4V(params, ctx->Current.Attrib[index]); - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); - return; - } -} - -/** - * Get a vertex (or vertex array) attribute. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params) -{ - const struct gl_client_array *array; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)"); - return; - } - - array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; - - switch (pname) { - case GL_ATTRIB_ARRAY_SIZE_NV: - params[0] = array->Size; - break; - case GL_ATTRIB_ARRAY_STRIDE_NV: - params[0] = array->Stride; - break; - case GL_ATTRIB_ARRAY_TYPE_NV: - params[0] = array->Type; - break; - case GL_CURRENT_ATTRIB_NV: - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetVertexAttribivNV(index == 0)"); - return; - } - FLUSH_CURRENT(ctx, 0); - params[0] = (GLint) ctx->Current.Attrib[index][0]; - params[1] = (GLint) ctx->Current.Attrib[index][1]; - params[2] = (GLint) ctx->Current.Attrib[index][2]; - params[3] = (GLint) ctx->Current.Attrib[index][3]; - break; - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: - params[0] = array->BufferObj->Name; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); - return; - } -} - - -/** - * Get a vertex array attribute pointer. - * \note Not compiled into display lists. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerNV(index)"); - return; - } - - if (pname != GL_ATTRIB_ARRAY_POINTER_NV) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerNV(pname)"); - return; - } - - *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr; -} - -void -_mesa_emit_nv_temp_initialization(struct gl_context *ctx, - struct gl_program *program) -{ - struct prog_instruction *inst; - GLuint i; - struct gl_shader_compiler_options* options = - &ctx->ShaderCompilerOptions[_mesa_program_target_to_index(program->Target)]; - - if (!options->EmitNVTempInitialization) - return; - - /* We'll swizzle up a zero temporary so we can use it for the - * ARL. - */ - if (program->NumTemporaries == 0) - program->NumTemporaries = 1; - - _mesa_insert_instructions(program, 0, program->NumTemporaries + 1); - - for (i = 0; i < program->NumTemporaries; i++) { - struct prog_instruction *inst = &program->Instructions[i]; - - inst->Opcode = OPCODE_SWZ; - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = i; - inst->DstReg.WriteMask = WRITEMASK_XYZW; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = 0; - inst->SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_ZERO, - SWIZZLE_ZERO, - SWIZZLE_ZERO, - SWIZZLE_ZERO); - } - - inst = &program->Instructions[i]; - inst->Opcode = OPCODE_ARL; - inst->DstReg.File = PROGRAM_ADDRESS; - inst->DstReg.Index = 0; - inst->DstReg.WriteMask = WRITEMASK_XYZW; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = 0; - inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; - - if (program->NumAddressRegs == 0) - program->NumAddressRegs = 1; -} - -void -_mesa_setup_nv_temporary_count(struct gl_program *program) -{ - GLuint i; - - program->NumTemporaries = 0; - for (i = 0; i < program->NumInstructions; i++) { - struct prog_instruction *inst = &program->Instructions[i]; - - if (inst->DstReg.File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2(program->NumTemporaries, - inst->DstReg.Index + 1); - } - if (inst->SrcReg[0].File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2((GLint)program->NumTemporaries, - inst->SrcReg[0].Index + 1); - } - if (inst->SrcReg[1].File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2((GLint)program->NumTemporaries, - inst->SrcReg[1].Index + 1); - } - if (inst->SrcReg[2].File == PROGRAM_TEMPORARY) { - program->NumTemporaries = MAX2((GLint)program->NumTemporaries, - inst->SrcReg[2].Index + 1); - } - } -} - -/** - * Load/parse/compile a program. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, - const GLubyte *program) -{ - struct gl_program *prog; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.NV_vertex_program - && !ctx->Extensions.NV_fragment_program) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV()"); - return; - } - - if (id == 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(id)"); - return; - } - - if (len < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(len)"); - return; - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - prog = _mesa_lookup_program(ctx, id); - - if (prog && prog->Target != 0 && prog->Target != target) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(target)"); - return; - } - - if ((target == GL_VERTEX_PROGRAM_NV || - target == GL_VERTEX_STATE_PROGRAM_NV) - && ctx->Extensions.NV_vertex_program) { - struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog; - if (!vprog || prog == &_mesa_DummyProgram) { - vprog = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, target, id); - if (!vprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - _mesa_HashInsert(ctx->Shared->Programs, id, vprog); - } - - if (ctx->Extensions.ARB_vertex_program - && (strncmp((char *) program, "!!ARB", 5) == 0)) { - _mesa_parse_arb_vertex_program(ctx, target, program, len, vprog); - } else { - _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog); - } - } - else if (target == GL_FRAGMENT_PROGRAM_NV - && ctx->Extensions.NV_fragment_program) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; - if (!fprog || prog == &_mesa_DummyProgram) { - fprog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, target, id); - if (!fprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - _mesa_HashInsert(ctx->Shared->Programs, id, fprog); - } - _mesa_parse_nv_fragment_program(ctx, target, program, len, fprog); - } - else if (target == GL_FRAGMENT_PROGRAM_ARB - && ctx->Extensions.ARB_fragment_program) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; - if (!fprog || prog == &_mesa_DummyProgram) { - fprog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, target, id); - if (!fprog) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - _mesa_HashInsert(ctx->Shared->Programs, id, fprog); - } - _mesa_parse_arb_fragment_program(ctx, target, program, len, fprog); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glLoadProgramNV(target)"); - } -} - - - -/** - * Set a sequence of program parameter registers. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameters4dvNV(GLenum target, GLuint index, - GLsizei num, const GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { - GLint i; - if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4dvNV"); - return; - } - for (i = 0; i < num; i++) { - ctx->VertexProgram.Parameters[index + i][0] = (GLfloat) params[0]; - ctx->VertexProgram.Parameters[index + i][1] = (GLfloat) params[1]; - ctx->VertexProgram.Parameters[index + i][2] = (GLfloat) params[2]; - ctx->VertexProgram.Parameters[index + i][3] = (GLfloat) params[3]; - params += 4; - }; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4dvNV"); - return; - } -} - - -/** - * Set a sequence of program parameter registers. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, - GLsizei num, const GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { - GLint i; - if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4fvNV"); - return; - } - for (i = 0; i < num; i++) { - COPY_4V(ctx->VertexProgram.Parameters[index + i], params); - params += 4; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4fvNV"); - return; - } -} - - - -/** - * Setup tracking of matrices into program parameter registers. - * \note Called from the GL API dispatcher. - */ -void GLAPIENTRY -_mesa_TrackMatrixNV(GLenum target, GLuint address, - GLenum matrix, GLenum transform) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) { - if (address & 0x3) { - /* addr must be multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, "glTrackMatrixNV(address)"); - return; - } - - switch (matrix) { - case GL_NONE: - case GL_MODELVIEW: - case GL_PROJECTION: - case GL_TEXTURE: - case GL_COLOR: - case GL_MODELVIEW_PROJECTION_NV: - case GL_MATRIX0_NV: - case GL_MATRIX1_NV: - case GL_MATRIX2_NV: - case GL_MATRIX3_NV: - case GL_MATRIX4_NV: - case GL_MATRIX5_NV: - case GL_MATRIX6_NV: - case GL_MATRIX7_NV: - /* OK, fallthrough */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(matrix)"); - return; - } - - switch (transform) { - case GL_IDENTITY_NV: - case GL_INVERSE_NV: - case GL_TRANSPOSE_NV: - case GL_INVERSE_TRANSPOSE_NV: - /* OK, fallthrough */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(transform)"); - return; - } - - ctx->VertexProgram.TrackMatrix[address / 4] = matrix; - ctx->VertexProgram.TrackMatrixTransform[address / 4] = transform; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(target)"); - return; - } -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - struct gl_program *prog; - struct gl_fragment_program *fragProg; - gl_constant_value *v; - - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - prog = _mesa_lookup_program(ctx, id); - if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramNamedParameterNV"); - return; - } - - if (len <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(len)"); - return; - } - - fragProg = (struct gl_fragment_program *) prog; - v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len, - (char *) name); - if (v) { - v[0].f = x; - v[1].f = y; - v[2].f = z; - v[3].f = w; - return; - } - - _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(name)"); -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, - const float v[]) -{ - _mesa_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble x, GLdouble y, GLdouble z, GLdouble w) -{ - _mesa_ProgramNamedParameter4fNV(id, len, name, (GLfloat)x, (GLfloat)y, - (GLfloat)z, (GLfloat)w); -} - - -void GLAPIENTRY -_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, - const double v[]) -{ - _mesa_ProgramNamedParameter4fNV(id, len, name, - (GLfloat)v[0], (GLfloat)v[1], - (GLfloat)v[2], (GLfloat)v[3]); -} - - -void GLAPIENTRY -_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat *params) -{ - struct gl_program *prog; - struct gl_fragment_program *fragProg; - const gl_constant_value *v; - - GET_CURRENT_CONTEXT(ctx); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - prog = _mesa_lookup_program(ctx, id); - if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramNamedParameterNV"); - return; - } - - if (len <= 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV"); - return; - } - - fragProg = (struct gl_fragment_program *) prog; - v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, - len, (char *) name); - if (v) { - params[0] = v[0].f; - params[1] = v[1].f; - params[2] = v[2].f; - params[3] = v[3].f; - return; - } - - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV"); -} - - -void GLAPIENTRY -_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble *params) -{ - GLfloat floatParams[4]; - _mesa_GetProgramNamedParameterfvNV(id, len, name, floatParams); - COPY_4V(params, floatParams); -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/nvprogram.h b/reactos/dll/opengl/mesa/src/mesa/main/nvprogram.h deleted file mode 100644 index fc579a9fe76..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/nvprogram.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 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. - * - * Authors: - * Brian Paul - */ - - -#ifndef NVPROGRAM_H -#define NVPROGRAM_H - -#include "glheader.h" - -struct gl_context; -struct gl_program; - -extern void GLAPIENTRY -_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params); - -extern GLboolean GLAPIENTRY -_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids, GLboolean *residences); - -extern void GLAPIENTRY -_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids); - -extern void GLAPIENTRY -_mesa_GetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat *params); - -extern void GLAPIENTRY -_mesa_GetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble *params); - -extern void GLAPIENTRY -_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program); - -extern void GLAPIENTRY -_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer); - -extern void GLAPIENTRY -_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program); - -extern void GLAPIENTRY -_mesa_ProgramParameters4dvNV(GLenum target, GLuint index, GLsizei num, - const GLdouble *params); - -extern void GLAPIENTRY -_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, GLsizei num, - const GLfloat *params); - -extern void GLAPIENTRY -_mesa_TrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform); - - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat x, GLfloat y, GLfloat z, GLfloat w); - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, - const float v[]); - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble x, GLdouble y, GLdouble z, GLdouble w); - -extern void GLAPIENTRY -_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, - const double v[]); - -extern void GLAPIENTRY -_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, - GLfloat *params); - -extern void GLAPIENTRY -_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, - GLdouble *params); - -extern void -_mesa_setup_nv_temporary_count(struct gl_program *program); - -extern void -_mesa_emit_nv_temp_initialization(struct gl_context *ctx, - struct gl_program *program); - -#endif diff --git a/reactos/dll/opengl/mesa/src/mesa/main/pack.c b/reactos/dll/opengl/mesa/src/mesa/main/pack.c index 87db56a9158..d681f4e12ed 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/pack.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/pack.c @@ -404,11 +404,6 @@ get_component_indexes(GLenum format, *blueIndex = 1; *alphaIndex = 0; break; - case GL_DU8DV8_ATI: - case GL_DUDV_ATI: - *redIndex = 0; - *greenIndex = 1; - break; default: assert(0 && "bad format in get_component_indexes()"); } @@ -751,13 +746,6 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], rgba[i][BCOMP]); } break; - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - for (i=0;i 0); - - /* - * Extract image data and convert to RGBA floats - */ - extract_float_rgba(n, rgba, srcFormat, srcType, source, - srcPacking->SwapBytes); - - - /* Now determine which color channels we need to produce. - * And determine the dest index (offset) within each color tuple. - */ - - /* Now pack results in the requested dstFormat */ - for (i = 0; i < n; i++) { - /* not sure - need clamp[-1,1] here? */ - dst[0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst += dstComponents; - } - - free(rgba); - } -} - /* * Unpack a row of color index data from a client buffer according to * the pixel unpacking parameters. diff --git a/reactos/dll/opengl/mesa/src/mesa/main/pack.h b/reactos/dll/opengl/mesa/src/mesa/main/pack.h index 61d0fe4403d..c5ccc9f493a 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/pack.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/pack.h @@ -81,14 +81,6 @@ _mesa_unpack_color_span_uint(struct gl_context *ctx, const GLvoid *source, const struct gl_pixelstore_attrib *srcPacking); -extern void -_mesa_unpack_dudv_span_byte(struct gl_context *ctx, - GLuint n, GLenum dstFormat, GLbyte dest[], - GLenum srcFormat, GLenum srcType, - const GLvoid *source, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps); - extern void _mesa_unpack_index_span(struct gl_context *ctx, GLuint n, GLenum dstType, GLvoid *dest, diff --git a/reactos/dll/opengl/mesa/src/mesa/main/points.c b/reactos/dll/opengl/mesa/src/mesa/main/points.c index 87bfae27eba..f9870c72e46 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/points.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/points.c @@ -251,8 +251,6 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params) void _mesa_init_point(struct gl_context *ctx) { - GLuint i; - ctx->Point.SmoothFlag = GL_FALSE; ctx->Point.Size = 1.0; ctx->Point.Params[0] = 1.0; @@ -266,7 +264,5 @@ _mesa_init_point(struct gl_context *ctx) ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */ ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ - for (i = 0; i < Elements(ctx->Point.CoordReplace); i++) { - ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */ - } + ctx->Point.CoordReplace = GL_FALSE; /* GL_ARB/NV_point_sprite */ } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/rastpos.c b/reactos/dll/opengl/mesa/src/mesa/main/rastpos.c index a1f6f423416..0cf4e4e95f7 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/rastpos.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/rastpos.c @@ -266,14 +266,7 @@ window_pos3f(GLfloat x, GLfloat y, GLfloat z) = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3], 0.0F, 1.0F); /* raster texcoord = current texcoord */ - { - GLuint texSet; - for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) { - assert(texSet < Elements(ctx->Current.RasterTexCoords)); - COPY_4FV( ctx->Current.RasterTexCoords[texSet], - ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); - } - } + COPY_4FV( ctx->Current.RasterTexCoords, ctx->Current.Attrib[VERT_ATTRIB_TEX] ); if (ctx->RenderMode==GL_SELECT) { _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); @@ -552,14 +545,11 @@ _mesa_init_rastpos_dispatch(struct _glapi_table *disp) */ void _mesa_init_rastpos( struct gl_context * ctx ) { - int i; - ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 ); ctx->Current.RasterDistance = 0.0; ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 ); - for (i = 0; i < Elements(ctx->Current.RasterTexCoords); i++) - ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 ); + ASSIGN_4V( ctx->Current.RasterTexCoords, 0.0, 0.0, 0.0, 1.0 ); ctx->Current.RasterPosValid = GL_TRUE; } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/shader_query.cpp b/reactos/dll/opengl/mesa/src/mesa/main/shader_query.cpp deleted file mode 100644 index 5985cd2c8bc..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/shader_query.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file shader_query.cpp - * C-to-C++ bridge functions to query GLSL shader data - * - * \author Ian Romanick - */ - -#include "main/core.h" -#include "glsl_symbol_table.h" -#include "ir.h" -#include "shaderobj.h" -#include "program/hash_table.h" -#include "../glsl/program.h" - -extern "C" { -#include "shaderapi.h" -} - -void GLAPIENTRY -_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index, - const GLcharARB *name) -{ - GET_CURRENT_CONTEXT(ctx); - - struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glBindAttribLocation"); - if (!shProg) - return; - - if (!name) - return; - - if (strncmp(name, "gl_", 3) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindAttribLocation(illegal name)"); - return; - } - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(index)"); - return; - } - - /* Replace the current value if it's already in the list. Add - * VERT_ATTRIB_GENERIC0 because that's how the linker differentiates - * between built-in attributes and user-defined attributes. - */ - shProg->AttributeBindings->put(index + VERT_ATTRIB_GENERIC0, name); - - /* - * Note that this attribute binding won't go into effect until - * glLinkProgram is called again. - */ -} - -void GLAPIENTRY -_mesa_GetActiveAttribARB(GLhandleARB program, GLuint desired_index, - GLsizei maxLength, GLsizei * length, GLint * size, - GLenum * type, GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); - if (!shProg) - return; - - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glGetActiveAttrib(program not linked)"); - return; - } - - if (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(no vertex shader)"); - return; - } - - exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir; - unsigned current_index = 0; - - foreach_list(node, ir) { - const ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if (var == NULL - || var->mode != ir_var_in - || var->location == -1) - continue; - - if (current_index == desired_index) { - _mesa_copy_string(name, maxLength, length, var->name); - - if (size) - *size = (var->type->is_array()) ? var->type->length : 1; - - if (type) - *type = var->type->gl_type; - - return; - } - - current_index++; - } - - /* If the loop did not return early, the caller must have asked for - * an index that did not exit. Set an error. - */ - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)"); -} - -GLint GLAPIENTRY -_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation"); - - if (!shProg) { - return -1; - } - - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetAttribLocation(program not linked)"); - return -1; - } - - if (!name) - return -1; - - /* Not having a vertex shader is not an error. - */ - if (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) - return -1; - - exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir; - foreach_list(node, ir) { - const ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - /* The extra check against VERT_ATTRIB_GENERIC0 is because - * glGetAttribLocation cannot be used on "conventional" attributes. - * - * From page 95 of the OpenGL 3.0 spec: - * - * "If name is not an active attribute, if name is a conventional - * attribute, or if an error occurs, -1 will be returned." - */ - if (var == NULL - || var->mode != ir_var_in - || var->location == -1 - || var->location < VERT_ATTRIB_GENERIC0) - continue; - - if (strcmp(var->name, name) == 0) - return var->location - VERT_ATTRIB_GENERIC0; - } - - return -1; -} - - -unsigned -_mesa_count_active_attribs(struct gl_shader_program *shProg) -{ - if (!shProg->LinkStatus - || shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) { - return 0; - } - - exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir; - unsigned i = 0; - - foreach_list(node, ir) { - const ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if (var == NULL - || var->mode != ir_var_in - || var->location == -1) - continue; - - i++; - } - - return i; -} - - -size_t -_mesa_longest_attribute_name_length(struct gl_shader_program *shProg) -{ - if (!shProg->LinkStatus - || shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) { - return 0; - } - - exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir; - size_t longest = 0; - - foreach_list(node, ir) { - const ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - if (var == NULL - || var->mode != ir_var_in - || var->location == -1) - continue; - - const size_t len = strlen(var->name); - if (len >= longest) - longest = len + 1; - } - - return longest; -} - -void GLAPIENTRY -_mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, - const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - - struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glBindFragDataLocation"); - if (!shProg) - return; - - if (!name) - return; - - if (strncmp(name, "gl_", 3) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindFragDataLocation(illegal name)"); - return; - } - - if (colorNumber > 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindFragDataLocation(index)"); - return; - } - - /* Replace the current value if it's already in the list. Add - * FRAG_RESULT_DATA0 because that's how the linker differentiates - * between built-in attributes and user-defined attributes. - */ - shProg->FragDataBindings->put(colorNumber + FRAG_RESULT_DATA0, name); - - /* - * Note that this binding won't go into effect until - * glLinkProgram is called again. - */ -} - -GLint GLAPIENTRY -_mesa_GetFragDataLocation(GLuint program, const GLchar *name) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetFragDataLocation"); - - if (!shProg) { - return -1; - } - - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetFragDataLocation(program not linked)"); - return -1; - } - - if (!name) - return -1; - - if (strncmp(name, "gl_", 3) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetFragDataLocation(illegal name)"); - return -1; - } - - /* Not having a fragment shader is not an error. - */ - if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) - return -1; - - exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir; - foreach_list(node, ir) { - const ir_variable *const var = ((ir_instruction *) node)->as_variable(); - - /* The extra check against FRAG_RESULT_DATA0 is because - * glGetFragDataLocation cannot be used on "conventional" attributes. - * - * From page 95 of the OpenGL 3.0 spec: - * - * "If name is not an active attribute, if name is a conventional - * attribute, or if an error occurs, -1 will be returned." - */ - if (var == NULL - || var->mode != ir_var_out - || var->location == -1 - || var->location < FRAG_RESULT_DATA0) - continue; - - if (strcmp(var->name, name) == 0) - return var->location - FRAG_RESULT_DATA0; - } - - return -1; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/shaderapi.c b/reactos/dll/opengl/mesa/src/mesa/main/shaderapi.c deleted file mode 100644 index 5ee0d9a4c88..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/shaderapi.c +++ /dev/null @@ -1,1501 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. 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. - */ - -/** - * \file shaderapi.c - * \author Brian Paul - * - * Implementation of GLSL-related API functions. - * The glUniform* functions are in uniforms.c - * - * - * XXX things to do: - * 1. Check that the right error code is generated for all _mesa_error() calls. - * 2. Insert FLUSH_VERTICES calls in various places - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/dispatch.h" -#include "main/enums.h" -#include "main/hash.h" -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" -#include "main/uniforms.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "ralloc.h" -#include -#include "../glsl/glsl_parser_extras.h" -#include "../glsl/ir_uniform.h" - -/** Define this to enable shader substitution (see below) */ -#define SHADER_SUBST 0 - - -/** - * Return mask of GLSL_x flags by examining the MESA_GLSL env var. - */ -static GLbitfield -get_shader_flags(void) -{ - GLbitfield flags = 0x0; - const char *env = _mesa_getenv("MESA_GLSL"); - - if (env) { - if (strstr(env, "dump")) - flags |= GLSL_DUMP; - if (strstr(env, "log")) - flags |= GLSL_LOG; - if (strstr(env, "nopvert")) - flags |= GLSL_NOP_VERT; - if (strstr(env, "nopfrag")) - flags |= GLSL_NOP_FRAG; - if (strstr(env, "nopt")) - flags |= GLSL_NO_OPT; - else if (strstr(env, "opt")) - flags |= GLSL_OPT; - if (strstr(env, "uniform")) - flags |= GLSL_UNIFORMS; - if (strstr(env, "useprog")) - flags |= GLSL_USE_PROG; - } - - return flags; -} - - -/** - * Initialize context's shader state. - */ -void -_mesa_init_shader_state(struct gl_context *ctx) -{ - /* Device drivers may override these to control what kind of instructions - * are generated by the GLSL compiler. - */ - struct gl_shader_compiler_options options; - gl_shader_type sh; - - memset(&options, 0, sizeof(options)); - options.MaxUnrollIterations = 32; - - /* Default pragma settings */ - options.DefaultPragmas.Optimize = GL_TRUE; - - for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) - memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); - - ctx->Shader.Flags = get_shader_flags(); -} - - -/** - * Free the per-context shader-related state. - */ -void -_mesa_free_shader_state(struct gl_context *ctx) -{ - _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentVertexProgram, NULL); - _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentFragmentProgram, - NULL); - _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram, - NULL); - _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL); -} - - -/** - * Return the size of the given GLSL datatype, in floats (components). - */ -GLint -_mesa_sizeof_glsl_type(GLenum type) -{ - switch (type) { - case GL_FLOAT: - case GL_INT: - case GL_UNSIGNED_INT: - case GL_BOOL: - case GL_SAMPLER_1D: - case GL_SAMPLER_2D: - case GL_SAMPLER_3D: - case GL_SAMPLER_CUBE: - case GL_SAMPLER_1D_SHADOW: - case GL_SAMPLER_2D_SHADOW: - case GL_SAMPLER_CUBE_SHADOW_EXT: - return 1; - case GL_FLOAT_VEC2: - case GL_INT_VEC2: - case GL_UNSIGNED_INT_VEC2: - case GL_BOOL_VEC2: - return 2; - case GL_FLOAT_VEC3: - case GL_INT_VEC3: - case GL_UNSIGNED_INT_VEC3: - case GL_BOOL_VEC3: - return 3; - case GL_FLOAT_VEC4: - case GL_INT_VEC4: - case GL_UNSIGNED_INT_VEC4: - case GL_BOOL_VEC4: - return 4; - case GL_FLOAT_MAT2: - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - return 8; /* two float[4] vectors */ - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3x4: - return 12; /* three float[4] vectors */ - case GL_FLOAT_MAT4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: - return 16; /* four float[4] vectors */ - default: - _mesa_problem(NULL, "Invalid type in _mesa_sizeof_glsl_type()"); - return 1; - } -} - - -/** - * Copy string from to , up to maxLength characters, returning - * length of in . - * \param src the strings source - * \param maxLength max chars to copy - * \param length returns number of chars copied - * \param dst the string destination - */ -void -_mesa_copy_string(GLchar *dst, GLsizei maxLength, - GLsizei *length, const GLchar *src) -{ - GLsizei len; - for (len = 0; len < maxLength - 1 && src && src[len]; len++) - dst[len] = src[len]; - if (maxLength > 0) - dst[len] = 0; - if (length) - *length = len; -} - - - -/** - * Confirm that the a shader type is valid and supported by the implementation - * - * \param ctx Current GL context - * \param type Shader target - * - */ -static bool -validate_shader_target(const struct gl_context *ctx, GLenum type) -{ - switch (type) { -#if FEATURE_ARB_fragment_shader - case GL_FRAGMENT_SHADER: - return ctx->Extensions.ARB_fragment_shader; -#endif -#if FEATURE_ARB_vertex_shader - case GL_VERTEX_SHADER: - return ctx->Extensions.ARB_vertex_shader; -#endif - default: - return false; - } -} - -static GLboolean -is_program(struct gl_context *ctx, GLuint name) -{ - struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name); - return shProg ? GL_TRUE : GL_FALSE; -} - - -static GLboolean -is_shader(struct gl_context *ctx, GLuint name) -{ - struct gl_shader *shader = _mesa_lookup_shader(ctx, name); - return shader ? GL_TRUE : GL_FALSE; -} - - -/** - * Attach shader to a shader program. - */ -static void -attach_shader(struct gl_context *ctx, GLuint program, GLuint shader) -{ - struct gl_shader_program *shProg; - struct gl_shader *sh; - GLuint i, n; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glAttachShader"); - if (!shProg) - return; - - sh = _mesa_lookup_shader_err(ctx, shader, "glAttachShader"); - if (!sh) { - return; - } - - n = shProg->NumShaders; - for (i = 0; i < n; i++) { - if (shProg->Shaders[i] == sh) { - /* The shader is already attched to this program. The - * GL_ARB_shader_objects spec says: - * - * "The error INVALID_OPERATION is generated by AttachObjectARB - * if is already attached to ." - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader"); - return; - } - } - - /* grow list */ - shProg->Shaders = (struct gl_shader **) - _mesa_realloc(shProg->Shaders, - n * sizeof(struct gl_shader *), - (n + 1) * sizeof(struct gl_shader *)); - if (!shProg->Shaders) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAttachShader"); - return; - } - - /* append */ - shProg->Shaders[n] = NULL; /* since realloc() didn't zero the new space */ - _mesa_reference_shader(ctx, &shProg->Shaders[n], sh); - shProg->NumShaders++; -} - - -static GLuint -create_shader(struct gl_context *ctx, GLenum type) -{ - struct gl_shader *sh; - GLuint name; - - if (!validate_shader_target(ctx, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, "CreateShader(type)"); - return 0; - } - - name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); - sh = ctx->Driver.NewShader(ctx, name, type); - _mesa_HashInsert(ctx->Shared->ShaderObjects, name, sh); - - return name; -} - - -static GLuint -create_shader_program(struct gl_context *ctx) -{ - GLuint name; - struct gl_shader_program *shProg; - - name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1); - - shProg = ctx->Driver.NewShaderProgram(ctx, name); - - _mesa_HashInsert(ctx->Shared->ShaderObjects, name, shProg); - - assert(shProg->RefCount == 1); - - return name; -} - - -/** - * Named w/ "2" to indicate OpenGL 2.x vs GL_ARB_fragment_programs's - * DeleteProgramARB. - */ -static void -delete_shader_program(struct gl_context *ctx, GLuint name) -{ - /* - * NOTE: deleting shaders/programs works a bit differently than - * texture objects (and buffer objects, etc). Shader/program - * handles/IDs exist in the hash table until the object is really - * deleted (refcount==0). With texture objects, the handle/ID is - * removed from the hash table in glDeleteTextures() while the tex - * object itself might linger until its refcount goes to zero. - */ - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, name, "glDeleteProgram"); - if (!shProg) - return; - - if (!shProg->DeletePending) { - shProg->DeletePending = GL_TRUE; - - /* effectively, decr shProg's refcount */ - _mesa_reference_shader_program(ctx, &shProg, NULL); - } -} - - -static void -delete_shader(struct gl_context *ctx, GLuint shader) -{ - struct gl_shader *sh; - - sh = _mesa_lookup_shader_err(ctx, shader, "glDeleteShader"); - if (!sh) - return; - - sh->DeletePending = GL_TRUE; - - /* effectively, decr sh's refcount */ - _mesa_reference_shader(ctx, &sh, NULL); -} - - -static void -detach_shader(struct gl_context *ctx, GLuint program, GLuint shader) -{ - struct gl_shader_program *shProg; - GLuint n; - GLuint i, j; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader"); - if (!shProg) - return; - - n = shProg->NumShaders; - - for (i = 0; i < n; i++) { - if (shProg->Shaders[i]->Name == shader) { - /* found it */ - struct gl_shader **newList; - - /* release */ - _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); - - /* alloc new, smaller array */ - newList = (struct gl_shader **) - malloc((n - 1) * sizeof(struct gl_shader *)); - if (!newList) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader"); - return; - } - for (j = 0; j < i; j++) { - newList[j] = shProg->Shaders[j]; - } - while (++i < n) - newList[j++] = shProg->Shaders[i]; - free(shProg->Shaders); - - shProg->Shaders = newList; - shProg->NumShaders = n - 1; - -#ifdef DEBUG - /* sanity check */ - { - for (j = 0; j < shProg->NumShaders; j++) { - assert(shProg->Shaders[j]->Type == GL_VERTEX_SHADER || - shProg->Shaders[j]->Type == GL_FRAGMENT_SHADER); - assert(shProg->Shaders[j]->RefCount > 0); - } - } -#endif - - return; - } - } - - /* not found */ - { - GLenum err; - if (is_shader(ctx, shader)) - err = GL_INVALID_OPERATION; - else if (is_program(ctx, shader)) - err = GL_INVALID_OPERATION; - else - err = GL_INVALID_VALUE; - _mesa_error(ctx, err, "glDetachProgram(shader)"); - return; - } -} - - -/** - * Return list of shaders attached to shader program. - */ -static void -get_attached_shaders(struct gl_context *ctx, GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj) -{ - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetAttachedShaders"); - if (shProg) { - GLuint i; - for (i = 0; i < (GLuint) maxCount && i < shProg->NumShaders; i++) { - obj[i] = shProg->Shaders[i]->Name; - } - if (count) - *count = i; - } -} - - -/** - * glGetHandleARB() - return ID/name of currently bound shader program. - */ -static GLuint -get_handle(struct gl_context *ctx, GLenum pname) -{ - if (pname == GL_PROGRAM_OBJECT_ARB) { - if (ctx->Shader.ActiveProgram) - return ctx->Shader.ActiveProgram->Name; - else - return 0; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB"); - return 0; - } -} - - -/** - * glGetProgramiv() - get shader program state. - * Note that this is for GLSL shader programs, not ARB vertex/fragment - * programs (see glGetProgramivARB). - */ -static void -get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *params) -{ - struct gl_shader_program *shProg - = _mesa_lookup_shader_program(ctx, program); - - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)"); - return; - } - - switch (pname) { - case GL_DELETE_STATUS: - *params = shProg->DeletePending; - break; - case GL_LINK_STATUS: - *params = shProg->LinkStatus; - break; - case GL_VALIDATE_STATUS: - *params = shProg->Validated; - break; - case GL_INFO_LOG_LENGTH: - *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0; - break; - case GL_ATTACHED_SHADERS: - *params = shProg->NumShaders; - break; - case GL_ACTIVE_ATTRIBUTES: - *params = _mesa_count_active_attribs(shProg); - break; - case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: - *params = _mesa_longest_attribute_name_length(shProg); - break; - case GL_ACTIVE_UNIFORMS: - *params = shProg->NumUserUniformStorage; - break; - case GL_ACTIVE_UNIFORM_MAX_LENGTH: { - unsigned i; - GLint max_len = 0; - - for (i = 0; i < shProg->NumUserUniformStorage; i++) { - /* Add one for the terminating NUL character. - */ - const GLint len = strlen(shProg->UniformStorage[i].name) + 1; - - if (len > max_len) - max_len = len; - } - - *params = max_len; - break; - } - case GL_PROGRAM_BINARY_LENGTH_OES: - *params = 0; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); - return; - } -} - - -/** - * glGetShaderiv() - get GLSL shader state - */ -static void -get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params) -{ - struct gl_shader *shader = - _mesa_lookup_shader_err(ctx, name, "glGetShaderiv"); - - if (!shader) { - return; - } - - switch (pname) { - case GL_SHADER_TYPE: - *params = shader->Type; - break; - case GL_DELETE_STATUS: - *params = shader->DeletePending; - break; - case GL_COMPILE_STATUS: - *params = shader->CompileStatus; - break; - case GL_INFO_LOG_LENGTH: - *params = shader->InfoLog ? strlen(shader->InfoLog) + 1 : 0; - break; - case GL_SHADER_SOURCE_LENGTH: - *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)"); - return; - } -} - - -static void -get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - struct gl_shader_program *shProg - = _mesa_lookup_shader_program(ctx, program); - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); - return; - } - _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); -} - - -static void -get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); - if (!sh) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); - return; - } - _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); -} - - -/** - * Return shader source code. - */ -static void -get_shader_source(struct gl_context *ctx, GLuint shader, GLsizei maxLength, - GLsizei *length, GLchar *sourceOut) -{ - struct gl_shader *sh; - sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderSource"); - if (!sh) { - return; - } - _mesa_copy_string(sourceOut, maxLength, length, sh->Source); -} - - -/** - * Set/replace shader source code. - */ -static void -shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source) -{ - struct gl_shader *sh; - - sh = _mesa_lookup_shader_err(ctx, shader, "glShaderSource"); - if (!sh) - return; - - /* free old shader source string and install new one */ - if (sh->Source) { - free((void *) sh->Source); - } - sh->Source = source; - sh->CompileStatus = GL_FALSE; -#ifdef DEBUG - sh->SourceChecksum = _mesa_str_checksum(sh->Source); -#endif -} - - -/** - * Compile a shader. - */ -static void -compile_shader(struct gl_context *ctx, GLuint shaderObj) -{ - struct gl_shader *sh; - struct gl_shader_compiler_options *options; - - sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); - if (!sh) - return; - - options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; - - /* set default pragma state for shader */ - sh->Pragmas = options->DefaultPragmas; - - /* this call will set the sh->CompileStatus field to indicate if - * compilation was successful. - */ - _mesa_glsl_compile_shader(ctx, sh); -} - - -/** - * Link a program's shaders. - */ -static void -link_program(struct gl_context *ctx, GLuint program) -{ - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram"); - if (!shProg) - return; - - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - - _mesa_glsl_link_shader(ctx, shProg); - - /* debug code */ - if (0) { - GLuint i; - - printf("Link %u shaders in program %u: %s\n", - shProg->NumShaders, shProg->Name, - shProg->LinkStatus ? "Success" : "Failed"); - - for (i = 0; i < shProg->NumShaders; i++) { - printf(" shader %u, type 0x%x\n", - shProg->Shaders[i]->Name, - shProg->Shaders[i]->Type); - } - } -} - - -/** - * Print basic shader info (for debug). - */ -static void -print_shader_info(const struct gl_shader_program *shProg) -{ - GLuint i; - - printf("Mesa: glUseProgram(%u)\n", shProg->Name); - for (i = 0; i < shProg->NumShaders; i++) { - const char *s; - switch (shProg->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - s = "vertex"; - break; - case GL_FRAGMENT_SHADER: - s = "fragment"; - break; - default: - s = ""; - } - printf(" %s shader %u, checksum %u\n", s, - shProg->Shaders[i]->Name, - shProg->Shaders[i]->SourceChecksum); - } - if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) - printf(" vert prog %u\n", - shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Id); - if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) - printf(" frag prog %u\n", - shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Id); -} - - -/** - * Use the named shader program for subsequent glUniform calls - */ -void -_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, - const char *caller) -{ - if ((shProg != NULL) && !shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(program %u not linked)", caller, shProg->Name); - return; - } - - if (ctx->Shader.ActiveProgram != shProg) { - _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, shProg); - } -} - -/** - */ -static bool -use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg) -{ - struct gl_shader_program **target; - - switch (type) { -#if FEATURE_ARB_vertex_shader - case GL_VERTEX_SHADER: - target = &ctx->Shader.CurrentVertexProgram; - if ((shProg == NULL) - || (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL)) { - shProg = NULL; - } - break; -#endif -#if FEATURE_ARB_fragment_shader - case GL_FRAGMENT_SHADER: - target = &ctx->Shader.CurrentFragmentProgram; - if ((shProg == NULL) - || (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)) { - shProg = NULL; - } - break; -#endif - default: - return false; - } - - if (*target != shProg) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); - - /* If the shader is also bound as the current rendering shader, unbind - * it from that binding point as well. This ensures that the correct - * semantics of glDeleteProgram are maintained. - */ - switch (type) { -#if FEATURE_ARB_vertex_shader - case GL_VERTEX_SHADER: - /* Empty for now. */ - break; -#endif -#if FEATURE_ARB_fragment_shader - case GL_FRAGMENT_SHADER: - if (*target == ctx->Shader._CurrentFragmentProgram) { - _mesa_reference_shader_program(ctx, - &ctx->Shader._CurrentFragmentProgram, - NULL); - } - break; -#endif - } - - _mesa_reference_shader_program(ctx, target, shProg); - return true; - } - - return false; -} - -/** - * Use the named shader program for subsequent rendering. - */ -void -_mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) -{ - use_shader_program(ctx, GL_VERTEX_SHADER, shProg); - use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); - _mesa_active_program(ctx, shProg, "glUseProgram"); - - if (ctx->Driver.UseProgram) - ctx->Driver.UseProgram(ctx, shProg); -} - -/** - * Do validation of the given shader program. - * \param errMsg returns error message if validation fails. - * \return GL_TRUE if valid, GL_FALSE if invalid (and set errMsg) - */ -static GLboolean -validate_shader_program(const struct gl_shader_program *shProg, - char *errMsg) -{ - if (!shProg->LinkStatus) { - return GL_FALSE; - } - - /* From the GL spec, a program is invalid if any of these are true: - - any two active samplers in the current program object are of - different types, but refer to the same texture image unit, - - any active sampler in the current program object refers to a texture - image unit where fixed-function fragment processing accesses a - texture target that does not match the sampler type, or - - the sum of the number of active samplers in the program and the - number of texture image units enabled for fixed-function fragment - processing exceeds the combined limit on the total number of texture - image units allowed. - */ - - - /* - * Check: any two active samplers in the current program object are of - * different types, but refer to the same texture image unit, - */ - if (!_mesa_sampler_uniforms_are_valid(shProg, errMsg, 100)) - return GL_FALSE; - - return GL_TRUE; -} - - -/** - * Called via glValidateProgram() - */ -static void -validate_program(struct gl_context *ctx, GLuint program) -{ - struct gl_shader_program *shProg; - char errMsg[100] = ""; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glValidateProgram"); - if (!shProg) { - return; - } - - shProg->Validated = validate_shader_program(shProg, errMsg); - if (!shProg->Validated) { - /* update info log */ - if (shProg->InfoLog) { - ralloc_free(shProg->InfoLog); - } - shProg->InfoLog = ralloc_strdup(shProg, errMsg); - } -} - - - -void GLAPIENTRY -_mesa_AttachObjectARB(GLhandleARB program, GLhandleARB shader) -{ - GET_CURRENT_CONTEXT(ctx); - attach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_AttachShader(GLuint program, GLuint shader) -{ - GET_CURRENT_CONTEXT(ctx); - attach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_CompileShaderARB(GLhandleARB shaderObj) -{ - GET_CURRENT_CONTEXT(ctx); - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCompileShader %u\n", shaderObj); - compile_shader(ctx, shaderObj); -} - - -GLuint GLAPIENTRY -_mesa_CreateShader(GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCreateShader %s\n", _mesa_lookup_enum_by_nr(type)); - return create_shader(ctx, type); -} - - -GLhandleARB GLAPIENTRY -_mesa_CreateShaderObjectARB(GLenum type) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader(ctx, type); -} - - -GLuint GLAPIENTRY -_mesa_CreateProgram(void) -{ - GET_CURRENT_CONTEXT(ctx); - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glCreateProgram\n"); - return create_shader_program(ctx); -} - - -GLhandleARB GLAPIENTRY -_mesa_CreateProgramObjectARB(void) -{ - GET_CURRENT_CONTEXT(ctx); - return create_shader_program(ctx); -} - - -void GLAPIENTRY -_mesa_DeleteObjectARB(GLhandleARB obj) -{ - if (MESA_VERBOSE & VERBOSE_API) { - GET_CURRENT_CONTEXT(ctx); - _mesa_debug(ctx, "glDeleteObjectARB(%u)\n", obj); - } - - if (obj) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - if (is_program(ctx, obj)) { - delete_shader_program(ctx, obj); - } - else if (is_shader(ctx, obj)) { - delete_shader(ctx, obj); - } - else { - /* error? */ - } - } -} - - -void GLAPIENTRY -_mesa_DeleteProgram(GLuint name) -{ - if (name) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - delete_shader_program(ctx, name); - } -} - - -void GLAPIENTRY -_mesa_DeleteShader(GLuint name) -{ - if (name) { - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - delete_shader(ctx, name); - } -} - - -void GLAPIENTRY -_mesa_DetachObjectARB(GLhandleARB program, GLhandleARB shader) -{ - GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_DetachShader(GLuint program, GLuint shader) -{ - GET_CURRENT_CONTEXT(ctx); - detach_shader(ctx, program, shader); -} - - -void GLAPIENTRY -_mesa_GetAttachedObjectsARB(GLhandleARB container, GLsizei maxCount, - GLsizei * count, GLhandleARB * obj) -{ - GET_CURRENT_CONTEXT(ctx); - get_attached_shaders(ctx, container, maxCount, count, obj); -} - - -void GLAPIENTRY -_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj) -{ - GET_CURRENT_CONTEXT(ctx); - get_attached_shaders(ctx, program, maxCount, count, obj); -} - - -void GLAPIENTRY -_mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length, - GLcharARB * infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - if (is_program(ctx, object)) { - get_program_info_log(ctx, object, maxLength, length, infoLog); - } - else if (is_shader(ctx, object)) { - get_shader_info_log(ctx, object, maxLength, length, infoLog); - } - else { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB"); - } -} - - -void GLAPIENTRY -_mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - /* Implement in terms of GetProgramiv, GetShaderiv */ - if (is_program(ctx, object)) { - if (pname == GL_OBJECT_TYPE_ARB) { - *params = GL_PROGRAM_OBJECT_ARB; - } - else { - get_programiv(ctx, object, pname, params); - } - } - else if (is_shader(ctx, object)) { - if (pname == GL_OBJECT_TYPE_ARB) { - *params = GL_SHADER_OBJECT_ARB; - } - else { - get_shaderiv(ctx, object, pname, params); - } - } - else { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB"); - } -} - - -void GLAPIENTRY -_mesa_GetObjectParameterfvARB(GLhandleARB object, GLenum pname, - GLfloat *params) -{ - GLint iparams[1]; /* XXX is one element enough? */ - _mesa_GetObjectParameterivARB(object, pname, iparams); - params[0] = (GLfloat) iparams[0]; -} - - -void GLAPIENTRY -_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_programiv(ctx, program, pname, params); -} - - -void GLAPIENTRY -_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - get_shaderiv(ctx, shader, pname, params); -} - - -void GLAPIENTRY -_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - get_program_info_log(ctx, program, bufSize, length, infoLog); -} - - -void GLAPIENTRY -_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog) -{ - GET_CURRENT_CONTEXT(ctx); - get_shader_info_log(ctx, shader, bufSize, length, infoLog); -} - - -void GLAPIENTRY -_mesa_GetShaderSourceARB(GLhandleARB shader, GLsizei maxLength, - GLsizei *length, GLcharARB *sourceOut) -{ - GET_CURRENT_CONTEXT(ctx); - get_shader_source(ctx, shader, maxLength, length, sourceOut); -} - - -GLhandleARB GLAPIENTRY -_mesa_GetHandleARB(GLenum pname) -{ - GET_CURRENT_CONTEXT(ctx); - return get_handle(ctx, pname); -} - - -GLboolean GLAPIENTRY -_mesa_IsProgram(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - return is_program(ctx, name); -} - - -GLboolean GLAPIENTRY -_mesa_IsShader(GLuint name) -{ - GET_CURRENT_CONTEXT(ctx); - return is_shader(ctx, name); -} - - -void GLAPIENTRY -_mesa_LinkProgramARB(GLhandleARB programObj) -{ - GET_CURRENT_CONTEXT(ctx); - link_program(ctx, programObj); -} - - - -/** - * Read shader source code from a file. - * Useful for debugging to override an app's shader. - */ -static GLcharARB * -read_shader(const char *fname) -{ - const int max = 50*1000; - FILE *f = fopen(fname, "r"); - GLcharARB *buffer, *shader; - int len; - - if (!f) { - return NULL; - } - - buffer = (char *) malloc(max); - len = fread(buffer, 1, max, f); - buffer[len] = 0; - - fclose(f); - - shader = _mesa_strdup(buffer); - free(buffer); - - return shader; -} - - -/** - * Called via glShaderSource() and glShaderSourceARB() API functions. - * Basically, concatenate the source code strings into one long string - * and pass it to _mesa_shader_source(). - */ -void GLAPIENTRY -_mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, - const GLcharARB ** string, const GLint * length) -{ - GET_CURRENT_CONTEXT(ctx); - GLint *offsets; - GLsizei i, totalLength; - GLcharARB *source; - GLuint checksum; - - if (!shaderObj || string == NULL) { - _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB"); - return; - } - - /* - * This array holds offsets of where the appropriate string ends, thus the - * last element will be set to the total length of the source code. - */ - offsets = (GLint *) malloc(count * sizeof(GLint)); - if (offsets == NULL) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); - return; - } - - for (i = 0; i < count; i++) { - if (string[i] == NULL) { - free((GLvoid *) offsets); - _mesa_error(ctx, GL_INVALID_OPERATION, - "glShaderSourceARB(null string)"); - return; - } - if (length == NULL || length[i] < 0) - offsets[i] = strlen(string[i]); - else - offsets[i] = length[i]; - /* accumulate string lengths */ - if (i > 0) - offsets[i] += offsets[i - 1]; - } - - /* Total length of source string is sum off all strings plus two. - * One extra byte for terminating zero, another extra byte to silence - * valgrind warnings in the parser/grammer code. - */ - totalLength = offsets[count - 1] + 2; - source = (GLcharARB *) malloc(totalLength * sizeof(GLcharARB)); - if (source == NULL) { - free((GLvoid *) offsets); - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); - return; - } - - for (i = 0; i < count; i++) { - GLint start = (i > 0) ? offsets[i - 1] : 0; - memcpy(source + start, string[i], - (offsets[i] - start) * sizeof(GLcharARB)); - } - source[totalLength - 1] = '\0'; - source[totalLength - 2] = '\0'; - - if (SHADER_SUBST) { - /* Compute the shader's source code checksum then try to open a file - * named newshader_. If it exists, use it in place of the - * original shader source code. For debugging. - */ - char filename[100]; - GLcharARB *newSource; - - checksum = _mesa_str_checksum(source); - - _mesa_snprintf(filename, sizeof(filename), "newshader_%d", checksum); - - newSource = read_shader(filename); - if (newSource) { - fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", - shaderObj, checksum, filename); - free(source); - source = newSource; - } - } - - shader_source(ctx, shaderObj, source); - - if (SHADER_SUBST) { - struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj); - if (sh) - sh->SourceChecksum = checksum; /* save original checksum */ - } - - free(offsets); -} - - -void GLAPIENTRY -_mesa_UseProgramObjectARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (program) { - shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); - if (!shProg) { - return; - } - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(program %u not linked)", program); - return; - } - - /* debug code */ - if (ctx->Shader.Flags & GLSL_USE_PROG) { - print_shader_info(shProg); - } - } - else { - shProg = NULL; - } - - _mesa_use_program(ctx, shProg); -} - - -void GLAPIENTRY -_mesa_ValidateProgramARB(GLhandleARB program) -{ - GET_CURRENT_CONTEXT(ctx); - validate_program(ctx, program); -} - - -void -_mesa_use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg) -{ - use_shader_program(ctx, type, shProg); - - if (ctx->Driver.UseProgram) - ctx->Driver.UseProgram(ctx, shProg); -} - -void GLAPIENTRY -_mesa_UseShaderProgramEXT(GLenum type, GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg = NULL; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_shader_target(ctx, type)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glUseShaderProgramEXT(type)"); - return; - } - - if (program) { - shProg = _mesa_lookup_shader_program_err(ctx, program, - "glUseShaderProgramEXT"); - if (shProg == NULL) - return; - - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseShaderProgramEXT(program not linked)"); - return; - } - } - - _mesa_use_shader_program(ctx, type, shProg); -} - -void GLAPIENTRY -_mesa_ActiveProgramEXT(GLuint program) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg = (program != 0) - ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT") - : NULL; - - _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); - return; -} - -GLuint GLAPIENTRY -_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string) -{ - GET_CURRENT_CONTEXT(ctx); - const GLuint shader = create_shader(ctx, type); - GLuint program = 0; - - if (shader) { - shader_source(ctx, shader, _mesa_strdup(string)); - compile_shader(ctx, shader); - - program = create_shader_program(ctx); - if (program) { - struct gl_shader_program *shProg; - struct gl_shader *sh; - GLint compiled = GL_FALSE; - - shProg = _mesa_lookup_shader_program(ctx, program); - sh = _mesa_lookup_shader(ctx, shader); - - get_shaderiv(ctx, shader, GL_COMPILE_STATUS, &compiled); - if (compiled) { - attach_shader(ctx, program, shader); - link_program(ctx, program); - detach_shader(ctx, program, shader); - -#if 0 - /* Possibly... */ - if (active-user-defined-varyings-in-linked-program) { - append-error-to-info-log; - shProg->LinkStatus = GL_FALSE; - } -#endif - } - - ralloc_strcat(&shProg->InfoLog, sh->InfoLog); - } - - delete_shader(ctx, shader); - } - - return program; -} - -/** - * Plug in shader-related functions into API dispatch table. - */ -void -_mesa_init_shader_dispatch(struct _glapi_table *exec) -{ -#if FEATURE_GL - /* GL_ARB_vertex/fragment_shader */ - SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB); - SET_GetHandleARB(exec, _mesa_GetHandleARB); - SET_DetachObjectARB(exec, _mesa_DetachObjectARB); - SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB); - SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB); - SET_CompileShaderARB(exec, _mesa_CompileShaderARB); - SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB); - SET_AttachObjectARB(exec, _mesa_AttachObjectARB); - SET_LinkProgramARB(exec, _mesa_LinkProgramARB); - SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB); - SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB); - SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB); - SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB); - SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB); - SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB); - SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB); - - /* OpenGL 2.0 */ - SET_AttachShader(exec, _mesa_AttachShader); - SET_CreateProgram(exec, _mesa_CreateProgram); - SET_CreateShader(exec, _mesa_CreateShader); - SET_DeleteProgram(exec, _mesa_DeleteProgram); - SET_DeleteShader(exec, _mesa_DeleteShader); - SET_DetachShader(exec, _mesa_DetachShader); - SET_GetAttachedShaders(exec, _mesa_GetAttachedShaders); - SET_GetProgramiv(exec, _mesa_GetProgramiv); - SET_GetProgramInfoLog(exec, _mesa_GetProgramInfoLog); - SET_GetShaderiv(exec, _mesa_GetShaderiv); - SET_GetShaderInfoLog(exec, _mesa_GetShaderInfoLog); - SET_IsProgram(exec, _mesa_IsProgram); - SET_IsShader(exec, _mesa_IsShader); - -#if FEATURE_ARB_vertex_shader - SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB); - SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB); - SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB); -#endif - - SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); - SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); - SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); - - /* GL_EXT_gpu_shader4 / GL 3.0 */ - SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation); - SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation); - -#endif /* FEATURE_GL */ -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/main/shaderapi.h b/reactos/dll/opengl/mesa/src/mesa/main/shaderapi.h deleted file mode 100644 index ce305618e01..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/shaderapi.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2010 VMware, Inc. 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 - * THE AUTHORS 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 SHADERAPI_H -#define SHADERAPI_H - - -#include "glheader.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -struct _glapi_table; -struct gl_context; -struct gl_shader_program; - -extern GLint -_mesa_sizeof_glsl_type(GLenum type); - -extern void -_mesa_copy_string(GLchar *dst, GLsizei maxLength, - GLsizei *length, const GLchar *src); - -extern void -_mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg); - -extern void -_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, - const char *caller); - -extern void -_mesa_init_shader_dispatch(struct _glapi_table *exec); - -extern unsigned -_mesa_count_active_attribs(struct gl_shader_program *shProg); - -extern size_t -_mesa_longest_attribute_name_length(struct gl_shader_program *shProg); - -extern void GLAPIENTRY -_mesa_AttachObjectARB(GLhandleARB, GLhandleARB); - -extern void GLAPIENTRY -_mesa_CompileShaderARB(GLhandleARB); - -extern GLhandleARB GLAPIENTRY -_mesa_CreateProgramObjectARB(void); - -extern GLhandleARB GLAPIENTRY -_mesa_CreateShaderObjectARB(GLenum type); - -extern void GLAPIENTRY -_mesa_DeleteObjectARB(GLhandleARB obj); - -extern void GLAPIENTRY -_mesa_DetachObjectARB(GLhandleARB, GLhandleARB); - -extern void GLAPIENTRY -_mesa_GetAttachedObjectsARB(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); - -extern GLint GLAPIENTRY -_mesa_GetFragDataLocation(GLuint program, const GLchar *name); - -extern GLhandleARB GLAPIENTRY -_mesa_GetHandleARB(GLenum pname); - -extern void GLAPIENTRY -_mesa_GetInfoLogARB(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); - -extern void GLAPIENTRY -_mesa_GetObjectParameterfvARB(GLhandleARB, GLenum, GLfloat *); - -extern void GLAPIENTRY -_mesa_GetObjectParameterivARB(GLhandleARB, GLenum, GLint *); - -extern void GLAPIENTRY -_mesa_GetShaderSourceARB(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); - -extern GLboolean GLAPIENTRY -_mesa_IsProgram(GLuint name); - -extern GLboolean GLAPIENTRY -_mesa_IsShader(GLuint name); - -extern void GLAPIENTRY -_mesa_LinkProgramARB(GLhandleARB programObj); - -extern void GLAPIENTRY -_mesa_ShaderSourceARB(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); - -extern void GLAPIENTRY -_mesa_UseProgramObjectARB(GLhandleARB); - -extern void GLAPIENTRY -_mesa_ValidateProgramARB(GLhandleARB); - - -extern void GLAPIENTRY -_mesa_BindAttribLocationARB(GLhandleARB, GLuint, const GLcharARB *); - -extern void GLAPIENTRY -_mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, - const GLchar *name); - -extern void GLAPIENTRY -_mesa_GetActiveAttribARB(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, - GLenum *, GLcharARB *); - -extern GLint GLAPIENTRY -_mesa_GetAttribLocationARB(GLhandleARB, const GLcharARB *); - - - -extern void GLAPIENTRY -_mesa_AttachShader(GLuint program, GLuint shader); - -extern GLuint GLAPIENTRY -_mesa_CreateShader(GLenum); - -extern GLuint GLAPIENTRY -_mesa_CreateProgram(void); - -extern void GLAPIENTRY -_mesa_DeleteProgram(GLuint program); - -extern void GLAPIENTRY -_mesa_DeleteShader(GLuint shader); - -extern void GLAPIENTRY -_mesa_DetachShader(GLuint program, GLuint shader); - -extern void GLAPIENTRY -_mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, - GLsizei *count, GLuint *obj); - -extern void GLAPIENTRY -_mesa_GetProgramiv(GLuint program, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, - GLsizei *length, GLchar *infoLog); - -extern void GLAPIENTRY -_mesa_GetShaderiv(GLuint shader, GLenum pname, GLint *params); - -extern void GLAPIENTRY -_mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, - GLsizei *length, GLchar *infoLog); - -extern void GLAPIENTRY -_mesa_ProgramParameteriARB(GLuint program, GLenum pname, - GLint value); -void -_mesa_use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg); - -extern void GLAPIENTRY -_mesa_UseShaderProgramEXT(GLenum type, GLuint program); - -extern void GLAPIENTRY -_mesa_ActiveProgramEXT(GLuint program); - -extern GLuint GLAPIENTRY -_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string); - - -#ifdef __cplusplus -} -#endif - -#endif /* SHADERAPI_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/shaderobj.c b/reactos/dll/opengl/mesa/src/mesa/main/shaderobj.c deleted file mode 100644 index 7bfb45f9833..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/shaderobj.c +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. 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. - */ - -/** - * \file shaderobj.c - * \author Brian Paul - * - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/hash.h" -#include "main/mfeatures.h" -#include "main/mtypes.h" -#include "main/shaderobj.h" -#include "main/uniforms.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/hash_table.h" -#include "ralloc.h" - -/**********************************************************************/ -/*** Shader object functions ***/ -/**********************************************************************/ - - -/** - * Set ptr to point to sh. - * If ptr is pointing to another shader, decrement its refcount (and delete - * if refcount hits zero). - * Then set ptr to point to sh, incrementing its refcount. - */ -void -_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, - struct gl_shader *sh) -{ - assert(ptr); - if (*ptr == sh) { - /* no-op */ - return; - } - if (*ptr) { - /* Unreference the old shader */ - GLboolean deleteFlag = GL_FALSE; - struct gl_shader *old = *ptr; - - ASSERT(old->RefCount > 0); - old->RefCount--; - /*printf("SHADER DECR %p (%d) to %d\n", - (void*) old, old->Name, old->RefCount);*/ - deleteFlag = (old->RefCount == 0); - - if (deleteFlag) { - if (old->Name != 0) - _mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name); - ctx->Driver.DeleteShader(ctx, old); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (sh) { - /* reference new */ - sh->RefCount++; - /*printf("SHADER INCR %p (%d) to %d\n", - (void*) sh, sh->Name, sh->RefCount);*/ - *ptr = sh; - } -} - -void -_mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader) -{ - shader->RefCount = 1; -} - -/** - * Allocate a new gl_shader object, initialize it. - * Called via ctx->Driver.NewShader() - */ -struct gl_shader * -_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) -{ - struct gl_shader *shader; - assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER); - shader = rzalloc(NULL, struct gl_shader); - if (shader) { - shader->Type = type; - shader->Name = name; - _mesa_init_shader(ctx, shader); - } - return shader; -} - - -/** - * Delete a shader object. - * Called via ctx->Driver.DeleteShader(). - */ -static void -_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh) -{ - if (sh->Source) - free((void *) sh->Source); - _mesa_reference_program(ctx, &sh->Program, NULL); - ralloc_free(sh); -} - - -/** - * Lookup a GLSL shader object. - */ -struct gl_shader * -_mesa_lookup_shader(struct gl_context *ctx, GLuint name) -{ - if (name) { - struct gl_shader *sh = (struct gl_shader *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - /* Note that both gl_shader and gl_shader_program objects are kept - * in the same hash table. Check the object's type to be sure it's - * what we're expecting. - */ - if (sh && sh->Type == GL_SHADER_PROGRAM_MESA) { - return NULL; - } - return sh; - } - return NULL; -} - - -/** - * As above, but record an error if shader is not found. - */ -struct gl_shader * -_mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller) -{ - if (!name) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - else { - struct gl_shader *sh = (struct gl_shader *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - if (!sh) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - if (sh->Type == GL_SHADER_PROGRAM_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; - } - return sh; - } -} - - - -/**********************************************************************/ -/*** Shader Program object functions ***/ -/**********************************************************************/ - - -/** - * Set ptr to point to shProg. - * If ptr is pointing to another object, decrement its refcount (and delete - * if refcount hits zero). - * Then set ptr to point to shProg, incrementing its refcount. - */ -void -_mesa_reference_shader_program(struct gl_context *ctx, - struct gl_shader_program **ptr, - struct gl_shader_program *shProg) -{ - assert(ptr); - if (*ptr == shProg) { - /* no-op */ - return; - } - if (*ptr) { - /* Unreference the old shader program */ - GLboolean deleteFlag = GL_FALSE; - struct gl_shader_program *old = *ptr; - - ASSERT(old->RefCount > 0); - old->RefCount--; -#if 0 - printf("ShaderProgram %p ID=%u RefCount-- to %d\n", - (void *) old, old->Name, old->RefCount); -#endif - deleteFlag = (old->RefCount == 0); - - if (deleteFlag) { - if (old->Name != 0) - _mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name); - ctx->Driver.DeleteShaderProgram(ctx, old); - } - - *ptr = NULL; - } - assert(!*ptr); - - if (shProg) { - shProg->RefCount++; -#if 0 - printf("ShaderProgram %p ID=%u RefCount++ to %d\n", - (void *) shProg, shProg->Name, shProg->RefCount); -#endif - *ptr = shProg; - } -} - -void -_mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog) -{ - prog->Type = GL_SHADER_PROGRAM_MESA; - prog->RefCount = 1; - - prog->AttributeBindings = string_to_uint_map_ctor(); - prog->FragDataBindings = string_to_uint_map_ctor(); - - prog->InfoLog = ralloc_strdup(prog, ""); -} - -/** - * Allocate a new gl_shader_program object, initialize it. - * Called via ctx->Driver.NewShaderProgram() - */ -static struct gl_shader_program * -_mesa_new_shader_program(struct gl_context *ctx, GLuint name) -{ - struct gl_shader_program *shProg; - shProg = rzalloc(NULL, struct gl_shader_program); - if (shProg) { - shProg->Name = name; - _mesa_init_shader_program(ctx, shProg); - } - return shProg; -} - - -/** - * Clear (free) the shader program state that gets produced by linking. - */ -void -_mesa_clear_shader_program_data(struct gl_context *ctx, - struct gl_shader_program *shProg) -{ - if (shProg->UniformStorage) { - unsigned i; - for (i = 0; i < shProg->NumUserUniformStorage; ++i) - _mesa_uniform_detach_all_driver_storage(&shProg->UniformStorage[i]); - ralloc_free(shProg->UniformStorage); - shProg->NumUserUniformStorage = 0; - shProg->UniformStorage = NULL; - } - - if (shProg->UniformHash) { - string_to_uint_map_dtor(shProg->UniformHash); - shProg->UniformHash = NULL; - } - - assert(shProg->InfoLog != NULL); - ralloc_free(shProg->InfoLog); - shProg->InfoLog = ralloc_strdup(shProg, ""); -} - - -/** - * Free all the data that hangs off a shader program object, but not the - * object itself. - */ -void -_mesa_free_shader_program_data(struct gl_context *ctx, - struct gl_shader_program *shProg) -{ - GLuint i; - gl_shader_type sh; - - assert(shProg->Type == GL_SHADER_PROGRAM_MESA); - - _mesa_clear_shader_program_data(ctx, shProg); - - if (shProg->AttributeBindings) { - string_to_uint_map_dtor(shProg->AttributeBindings); - shProg->AttributeBindings = NULL; - } - - if (shProg->FragDataBindings) { - string_to_uint_map_dtor(shProg->FragDataBindings); - shProg->FragDataBindings = NULL; - } - - /* detach shaders */ - for (i = 0; i < shProg->NumShaders; i++) { - _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL); - } - shProg->NumShaders = 0; - - if (shProg->Shaders) { - free(shProg->Shaders); - shProg->Shaders = NULL; - } - - - for (sh = 0; sh < MESA_SHADER_TYPES; sh++) { - if (shProg->_LinkedShaders[sh] != NULL) { - ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[sh]); - shProg->_LinkedShaders[sh] = NULL; - } - } -} - - -/** - * Free/delete a shader program object. - * Called via ctx->Driver.DeleteShaderProgram(). - */ -static void -_mesa_delete_shader_program(struct gl_context *ctx, struct gl_shader_program *shProg) -{ - _mesa_free_shader_program_data(ctx, shProg); - - ralloc_free(shProg); -} - - -/** - * Lookup a GLSL program object. - */ -struct gl_shader_program * -_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name) -{ - struct gl_shader_program *shProg; - if (name) { - shProg = (struct gl_shader_program *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - /* Note that both gl_shader and gl_shader_program objects are kept - * in the same hash table. Check the object's type to be sure it's - * what we're expecting. - */ - if (shProg && shProg->Type != GL_SHADER_PROGRAM_MESA) { - return NULL; - } - return shProg; - } - return NULL; -} - - -/** - * As above, but record an error if program is not found. - */ -struct gl_shader_program * -_mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name, - const char *caller) -{ - if (!name) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - else { - struct gl_shader_program *shProg = (struct gl_shader_program *) - _mesa_HashLookup(ctx->Shared->ShaderObjects, name); - if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s", caller); - return NULL; - } - if (shProg->Type != GL_SHADER_PROGRAM_MESA) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller); - return NULL; - } - return shProg; - } -} - - -void -_mesa_init_shader_object_functions(struct dd_function_table *driver) -{ - driver->NewShader = _mesa_new_shader; - driver->DeleteShader = _mesa_delete_shader; - driver->NewShaderProgram = _mesa_new_shader_program; - driver->DeleteShaderProgram = _mesa_delete_shader_program; - driver->LinkShader = _mesa_ir_link_shader; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/shaderobj.h b/reactos/dll/opengl/mesa/src/mesa/main/shaderobj.h deleted file mode 100644 index c0cbea6198e..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/shaderobj.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 2004-2007 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 SHADEROBJ_H -#define SHADEROBJ_H - - -#include "main/compiler.h" -#include "main/glheader.h" -#include "main/mtypes.h" -#include "program/ir_to_mesa.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Internal functions - */ - -extern void -_mesa_init_shader_state(struct gl_context * ctx); - -extern void -_mesa_free_shader_state(struct gl_context *ctx); - - -extern void -_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, - struct gl_shader *sh); - -extern struct gl_shader * -_mesa_lookup_shader(struct gl_context *ctx, GLuint name); - -extern struct gl_shader * -_mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller); - - - -extern void -_mesa_reference_shader_program(struct gl_context *ctx, - struct gl_shader_program **ptr, - struct gl_shader_program *shProg); -extern void -_mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader); - -extern struct gl_shader * -_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); - -extern void -_mesa_init_shader_program(struct gl_context *ctx, struct gl_shader_program *prog); - -extern struct gl_shader_program * -_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name); - -extern struct gl_shader_program * -_mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name, - const char *caller); - -extern void -_mesa_clear_shader_program_data(struct gl_context *ctx, - struct gl_shader_program *shProg); - -extern void -_mesa_free_shader_program_data(struct gl_context *ctx, - struct gl_shader_program *shProg); - - - -extern void -_mesa_init_shader_object_functions(struct dd_function_table *driver); - -extern void -_mesa_init_shader_state(struct gl_context *ctx); - -extern void -_mesa_free_shader_state(struct gl_context *ctx); - - -static inline gl_shader_type -_mesa_shader_type_to_index(GLenum v) -{ - switch (v) { - case GL_VERTEX_SHADER: - return MESA_SHADER_VERTEX; - case GL_FRAGMENT_SHADER: - return MESA_SHADER_FRAGMENT; - default: - ASSERT(0 && "bad value in _mesa_shader_type_to_index()"); - return MESA_SHADER_TYPES; - } -} - - -static inline GLenum -_mesa_shader_index_to_type(GLuint i) -{ - static const GLenum enums[MESA_SHADER_TYPES] = { - GL_VERTEX_SHADER, - GL_FRAGMENT_SHADER, - }; - if (i >= MESA_SHADER_TYPES) - return 0; - else - return enums[i]; -} - - -#ifdef __cplusplus -} -#endif - -#endif /* SHADEROBJ_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/shared.c b/reactos/dll/opengl/mesa/src/mesa/main/shared.c index ede7970646a..bcf2c3a8d14 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/shared.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/shared.c @@ -33,9 +33,7 @@ #include "hash.h" #include "bufferobj.h" #include "shared.h" -#include "program/program.h" #include "dlist.h" -#include "shaderobj.h" /** @@ -61,21 +59,6 @@ _mesa_alloc_shared_state(struct gl_context *ctx) shared->DisplayList = _mesa_NewHashTable(); shared->TexObjects = _mesa_NewHashTable(); - shared->Programs = _mesa_NewHashTable(); - -#if FEATURE_ARB_vertex_program - shared->DefaultVertexProgram = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); -#endif - -#if FEATURE_ARB_fragment_program - shared->DefaultFragmentProgram = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); -#endif - -#if FEATURE_ARB_shader_objects - shared->ShaderObjects = _mesa_NewHashTable(); -#endif shared->BufferObjects = _mesa_NewHashTable(); @@ -102,11 +85,6 @@ _mesa_alloc_shared_state(struct gl_context *ctx) _glthread_INIT_MUTEX(shared->TexMutex); shared->TextureStateStamp = 0; -#if FEATURE_EXT_framebuffer_object - shared->FrameBuffers = _mesa_NewHashTable(); - shared->RenderBuffers = _mesa_NewHashTable(); -#endif - return shared; } @@ -135,22 +113,6 @@ delete_texture_cb(GLuint id, void *data, void *userData) } -/** - * Callback for deleting a program object. Called by _mesa_HashDeleteAll(). - */ -static void -delete_program_cb(GLuint id, void *data, void *userData) -{ - struct gl_program *prog = (struct gl_program *) data; - struct gl_context *ctx = (struct gl_context *) userData; - if(prog != &_mesa_DummyProgram) { - ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */ - prog->RefCount = 0; /* now going away */ - ctx->Driver.DeleteProgram(ctx, prog); - } -} - - /** * Callback for deleting a buffer object. Called by _mesa_HashDeleteAll(). */ @@ -167,76 +129,6 @@ delete_bufferobj_cb(GLuint id, void *data, void *userData) } -/** - * Callback for freeing shader program data. Call it before delete_shader_cb - * to avoid memory access error. - */ -static void -free_shader_program_data_cb(GLuint id, void *data, void *userData) -{ - struct gl_context *ctx = (struct gl_context *) userData; - struct gl_shader_program *shProg = (struct gl_shader_program *) data; - - if (shProg->Type == GL_SHADER_PROGRAM_MESA) { - _mesa_free_shader_program_data(ctx, shProg); - } -} - - -/** - * Callback for deleting shader and shader programs objects. - * Called by _mesa_HashDeleteAll(). - */ -static void -delete_shader_cb(GLuint id, void *data, void *userData) -{ - struct gl_context *ctx = (struct gl_context *) userData; - struct gl_shader *sh = (struct gl_shader *) data; - if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) { - ctx->Driver.DeleteShader(ctx, sh); - } - else { - struct gl_shader_program *shProg = (struct gl_shader_program *) data; - ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA); - ctx->Driver.DeleteShaderProgram(ctx, shProg); - } -} - - -/** - * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll() - */ -static void -delete_framebuffer_cb(GLuint id, void *data, void *userData) -{ - struct gl_framebuffer *fb = (struct gl_framebuffer *) data; - /* The fact that the framebuffer is in the hashtable means its refcount - * is one, but we're removing from the hashtable now. So clear refcount. - */ - /*assert(fb->RefCount == 1);*/ - fb->RefCount = 0; - - /* NOTE: Delete should always be defined but there are two reports - * of it being NULL (bugs 13507, 14293). Work-around for now. - */ - if (fb->Delete) - fb->Delete(fb); -} - - -/** - * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll() - */ -static void -delete_renderbuffer_cb(GLuint id, void *data, void *userData) -{ - struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; - rb->RefCount = 0; /* see comment for FBOs above */ - if (rb->Delete) - rb->Delete(rb); -} - - /** * Deallocate a shared state object and all children structures. * @@ -264,33 +156,9 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) _mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx); _mesa_DeleteHashTable(shared->DisplayList); -#if FEATURE_ARB_shader_objects - _mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx); - _mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx); - _mesa_DeleteHashTable(shared->ShaderObjects); -#endif - - _mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx); - _mesa_DeleteHashTable(shared->Programs); - -#if FEATURE_ARB_vertex_program - _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL); -#endif - -#if FEATURE_ARB_fragment_program - _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL); -#endif - _mesa_HashDeleteAll(shared->BufferObjects, delete_bufferobj_cb, ctx); _mesa_DeleteHashTable(shared->BufferObjects); -#if FEATURE_EXT_framebuffer_object - _mesa_HashDeleteAll(shared->FrameBuffers, delete_framebuffer_cb, ctx); - _mesa_DeleteHashTable(shared->FrameBuffers); - _mesa_HashDeleteAll(shared->RenderBuffers, delete_renderbuffer_cb, ctx); - _mesa_DeleteHashTable(shared->RenderBuffers); -#endif - _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL); /* diff --git a/reactos/dll/opengl/mesa/src/mesa/main/state.c b/reactos/dll/opengl/mesa/src/mesa/main/state.c index d646cb61fa7..bce7c677c1d 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/state.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/state.c @@ -39,9 +39,6 @@ #include "light.h" #include "matrix.h" #include "pixel.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "shaderobj.h" #include "state.h" #include "stencil.h" #include "texobj.h" @@ -79,7 +76,7 @@ static void update_arrays( struct gl_context *ctx ) { struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint i, min = ~0; + GLuint min = ~0; /* find min of _MaxElement values for all enabled arrays. * Note that the generic arrays always take precedence over @@ -87,91 +84,38 @@ update_arrays( struct gl_context *ctx ) */ /* 0 */ - if (ctx->VertexProgram._Current - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]); - } - else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); } - /* 1 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1]); - } - /* no conventional vertex weight array */ - /* 2 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2]); - } - else if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); } /* 3 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3]); - } - else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); } /* 4 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4]); - } - else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]); } /* 5 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5]); - } - else if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]); } /* 6 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6]); - } - else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); } - /* 7 */ - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7]); - } - - /* 8..15 */ - for (i = 0; i < VERT_ATTRIB_TEX_MAX; i++) { - if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i]); - } - else if (i < ctx->Const.MaxTextureCoordUnits - && arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]); - } - } - - /* 16..31 */ - if (ctx->VertexProgram._Current) { - for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) { - if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]); - } - } + /* 8 */ + if (arrayObj->VertexAttrib[VERT_ATTRIB_TEX].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX]); } if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { @@ -182,163 +126,6 @@ update_arrays( struct gl_context *ctx ) arrayObj->_MaxElement = min; } - -/** - * Update the following fields: - * ctx->VertexProgram._Enabled - * ctx->FragmentProgram._Enabled - * ctx->ATIFragmentShader._Enabled - * This needs to be done before texture state validation. - */ -static void -update_program_enables(struct gl_context *ctx) -{ - /* These _Enabled flags indicate if the user-defined ARB/NV vertex/fragment - * program is enabled AND valid. Similarly for ATI fragment shaders. - * GLSL shaders not relevant here. - */ - ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled - && ctx->VertexProgram.Current->Base.Instructions; - ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled - && ctx->FragmentProgram.Current->Base.Instructions; -} - - -/** - * Update the ctx->Vertex/Geometry/FragmentProgram._Current pointers to point - * to the current/active programs. Then call ctx->Driver.BindProgram() to - * tell the driver which programs to use. - * - * Programs may come from 3 sources: GLSL shaders, ARB/NV_vertex/fragment - * programs or programs derived from fixed-function state. - * - * This function needs to be called after texture state validation in case - * we're generating a fragment program from fixed-function texture state. - * - * \return bitfield which will indicate _NEW_PROGRAM state if a new vertex - * or fragment program is being used. - */ -static GLbitfield -update_program(struct gl_context *ctx) -{ - const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram; - struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram; - const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; - const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; - GLbitfield new_state = 0x0; - - /* - * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current - * pointers to the programs that should be used for rendering. If either - * is NULL, use fixed-function code paths. - * - * These programs may come from several sources. The priority is as - * follows: - * 1. OpenGL 2.0/ARB vertex/fragment shaders - * 2. ARB/NV vertex/fragment programs - * 3. Programs derived from fixed-function state. - * - * Note: it's possible for a vertex shader to get used with a fragment - * program (and vice versa) here, but in practice that shouldn't ever - * come up, or matter. - */ - - if (fsProg && fsProg->LinkStatus - && fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) { - /* Use GLSL fragment shader */ - _mesa_reference_shader_program(ctx, - &ctx->Shader._CurrentFragmentProgram, - fsProg); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - (struct gl_fragment_program *) - fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); - } - else if (ctx->FragmentProgram._Enabled) { - /* Use user-defined fragment program */ - _mesa_reference_shader_program(ctx, - &ctx->Shader._CurrentFragmentProgram, - NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - ctx->FragmentProgram.Current); - } - else { - /* No fragment program */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); - } - - /* Examine vertex program after fragment program as - * _mesa_get_fixed_func_vertex_program() needs to know active - * fragprog inputs. - */ - if (vsProg && vsProg->LinkStatus - && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) { - /* Use GLSL vertex shader */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - (struct gl_vertex_program *) - vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program); - } - else if (ctx->VertexProgram._Enabled) { - /* Use user-defined vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - ctx->VertexProgram.Current); - } - else { - /* no vertex program */ - _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); - } - - /* Let the driver know what's happening: - */ - if (ctx->FragmentProgram._Current != prevFP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, - (struct gl_program *) ctx->FragmentProgram._Current); - } - } - - if (ctx->VertexProgram._Current != prevVP) { - new_state |= _NEW_PROGRAM; - if (ctx->Driver.BindProgram) { - ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB, - (struct gl_program *) ctx->VertexProgram._Current); - } - } - - return new_state; -} - - -/** - * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0. - */ -static GLbitfield -update_program_constants(struct gl_context *ctx) -{ - GLbitfield new_state = 0x0; - - if (ctx->FragmentProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->FragmentProgram._Current->Base.Parameters; - if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - if (ctx->VertexProgram._Current) { - const struct gl_program_parameter_list *params = - ctx->VertexProgram._Current->Base.Parameters; - if (params && params->StateFlags & ctx->NewState) { - new_state |= _NEW_PROGRAM_CONSTANTS; - } - } - - return new_state; -} - - - - static void update_viewport_matrix(struct gl_context *ctx) { @@ -358,22 +145,6 @@ update_viewport_matrix(struct gl_context *ctx) } -/** - * Update the ctx->VertexProgram._TwoSideEnabled flag. - */ -static void -update_twoside(struct gl_context *ctx) -{ - if (ctx->Shader.CurrentVertexProgram || - ctx->VertexProgram._Enabled) { - ctx->VertexProgram._TwoSideEnabled = ctx->VertexProgram.TwoSideEnabled; - } else { - ctx->VertexProgram._TwoSideEnabled = (ctx->Light.Enabled && - ctx->Light.Model.TwoSide); - } -} - - /* * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET * in ctx->_TriangleCaps if needed. @@ -480,8 +251,6 @@ void _mesa_update_state_locked( struct gl_context *ctx ) { GLbitfield new_state = ctx->NewState; - GLbitfield prog_flags = _NEW_PROGRAM; - GLbitfield new_prog_state = 0x0; if (new_state == _NEW_CURRENT_ATTRIB) goto out; @@ -490,13 +259,10 @@ _mesa_update_state_locked( struct gl_context *ctx ) * Now update derived state info */ - if (new_state & prog_flags) - update_program_enables( ctx ); - if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) _mesa_update_modelview_project( ctx, new_state ); - if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) + if (new_state & (_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) _mesa_update_texture( ctx, new_state ); if (new_state & _NEW_BUFFERS) @@ -511,9 +277,6 @@ _mesa_update_state_locked( struct gl_context *ctx ) if (new_state & _NEW_LIGHT) _mesa_update_lighting( ctx ); - if (new_state & (_NEW_LIGHT | _NEW_PROGRAM)) - update_twoside( ctx ); - if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) _mesa_update_stencil( ctx ); @@ -544,19 +307,10 @@ _mesa_update_state_locked( struct gl_context *ctx ) if (new_state & _MESA_NEW_NEED_EYE_COORDS) _mesa_update_tnl_spaces( ctx, new_state ); - if (new_state & prog_flags) { - /* When we generate programs from fixed-function vertex/fragment state - * this call may generate/bind a new program. If so, we need to - * propogate the _NEW_PROGRAM flag to the driver. - */ - new_prog_state |= update_program( ctx ); - } - - if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) + if (new_state & (_NEW_ARRAY | _NEW_BUFFER_OBJECT)) update_arrays( ctx ); out: - new_prog_state |= update_program_constants(ctx); /* * Give the driver a chance to act upon the new_state flags. @@ -567,12 +321,12 @@ _mesa_update_state_locked( struct gl_context *ctx ) * Set ctx->NewState to zero to avoid recursion if * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?) */ - new_state = ctx->NewState | new_prog_state; + new_state = ctx->NewState; ctx->NewState = 0; ctx->Driver.UpdateState(ctx, new_state); ctx->Array.NewState = 0; if (!ctx->Array.RebindArrays) - ctx->Array.RebindArrays = (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) != 0; + ctx->Array.RebindArrays = (new_state & _NEW_ARRAY) != 0; } @@ -621,23 +375,3 @@ _mesa_set_varying_vp_inputs( struct gl_context *ctx, /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/ } } - - -/** - * Used by drivers to tell core Mesa that the driver is going to - * install/ use its own vertex program. In particular, this will - * prevent generated fragment programs from using state vars instead - * of ordinary varyings/inputs. - */ -void -_mesa_set_vp_override(struct gl_context *ctx, GLboolean flag) -{ - if (ctx->VertexProgram._Overriden != flag) { - ctx->VertexProgram._Overriden = flag; - - /* Set one of the bits which will trigger fragment program - * regeneration: - */ - ctx->NewState |= _NEW_PROGRAM; - } -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/state.h b/reactos/dll/opengl/mesa/src/mesa/main/state.h index 5ab7d0e0ff5..3ab5aee0832 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/state.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/state.h @@ -42,10 +42,6 @@ extern void _mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield64 varying_inputs); -extern void -_mesa_set_vp_override(struct gl_context *ctx, GLboolean flag); - - /** * Is the secondary color needed? */ @@ -59,14 +55,6 @@ _mesa_need_secondary_color(const struct gl_context *ctx) if (ctx->Fog.ColorSumEnabled) return GL_TRUE; - if (ctx->VertexProgram._Current && - (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) - return GL_TRUE; - - if (ctx->FragmentProgram._Current && - (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) - return GL_TRUE; - return GL_FALSE; } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texenv.c b/reactos/dll/opengl/mesa/src/mesa/main/texenv.c index 23b32fd6896..9b8c9bdd780 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texenv.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texenv.c @@ -131,10 +131,6 @@ set_combiner_mode(struct gl_context *ctx, case GL_MODULATE_SUBTRACT_ATI: legal = ctx->Extensions.ATI_texture_env_combine3; break; - case GL_BUMP_ENVMAP_ATI: - legal = (ctx->Extensions.ATI_envmap_bumpmap && - pname == GL_COMBINE_RGB); - break; default: legal = GL_FALSE; } @@ -216,17 +212,6 @@ set_combiner_source(struct gl_context *ctx, case GL_PREVIOUS: legal = GL_TRUE; break; - case GL_TEXTURE0: - case GL_TEXTURE1: - case GL_TEXTURE2: - case GL_TEXTURE3: - case GL_TEXTURE4: - case GL_TEXTURE5: - case GL_TEXTURE6: - case GL_TEXTURE7: - legal = (ctx->Extensions.ARB_texture_env_crossbar && - param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits); - break; case GL_ZERO: legal = (ctx->Extensions.ATI_texture_env_combine3 || ctx->Extensions.NV_texture_env_combine4); @@ -380,19 +365,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) { const GLint iparam0 = (GLint) param[0]; struct gl_texture_unit *texUnit; - GLuint maxUnit; - GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = &ctx->Texture.Unit; if (target == GL_TEXTURE_ENV) { switch (pname) { @@ -430,26 +406,6 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) case GL_ALPHA_SCALE: set_combiner_scale(ctx, texUnit, pname, param[0]); break; - case GL_BUMP_TARGET_ATI: - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); - return; - } - if ((iparam0 < GL_TEXTURE0) || - (iparam0 > GL_TEXTURE31)) { - /* spec doesn't say this but it seems logical */ - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(param=0x%x)", iparam0); - return; - } - if (!((1 << (iparam0 - GL_TEXTURE0)) & ctx->Const.SupportedBumpUnits)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); - return; - } - else { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->BumpTarget = iparam0; - } - break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); return; @@ -467,34 +423,6 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) return; } } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - if (iparam0 == GL_TRUE || iparam0 == GL_FALSE) { - /* It's kind of weird to set point state via glTexEnv, - * but that's what the spec calls for. - */ - const GLboolean state = (GLboolean) iparam0; - if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state) - return; - FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state; - } - else { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); - return; - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); - return; - } - } else { _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)",target ); return; @@ -630,15 +558,6 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, return 1 << texUnit->Combine.ScaleShiftRGB; case GL_ALPHA_SCALE: return 1 << texUnit->Combine.ScaleShiftA; - case GL_BUMP_TARGET_ATI: - /* spec doesn't say so, but I think this should be queryable */ - if (ctx->Extensions.ATI_envmap_bumpmap) { - return texUnit->BumpTarget; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); @@ -653,20 +572,10 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, void GLAPIENTRY _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) { - GLuint maxUnit; - const struct gl_texture_unit *texUnit; GET_CURRENT_CONTEXT(ctx); + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; ASSERT_OUTSIDE_BEGIN_END(ctx); - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - if (target == GL_TEXTURE_ENV) { if (pname == GL_TEXTURE_ENV_COLOR) { if(ctx->NewState & _NEW_BUFFERS) @@ -689,21 +598,6 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) return; } } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); - return; - } - } else { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); return; @@ -714,20 +608,10 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) void GLAPIENTRY _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) { - GLuint maxUnit; - const struct gl_texture_unit *texUnit; GET_CURRENT_CONTEXT(ctx); + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit;; ASSERT_OUTSIDE_BEGIN_END(ctx); - maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) - ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - if (target == GL_TEXTURE_ENV) { if (pname == GL_TEXTURE_ENV_COLOR) { params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] ); @@ -751,21 +635,6 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) return; } } - else if (target == GL_POINT_SPRITE_NV) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - if (!ctx->Extensions.NV_point_sprite - && !ctx->Extensions.ARB_point_sprite) { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); - return; - } - if (pname == GL_COORD_REPLACE_NV) { - *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); - return; - } - } else { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); return; @@ -773,169 +642,3 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) } -/** - * Why does ATI_envmap_bumpmap require new entrypoints? Should just - * reuse TexEnv ones... - */ -void GLAPIENTRY -_mesa_TexBumpParameterivATI( GLenum pname, const GLint *param ) -{ - GLfloat p[4]; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - /* This isn't an "official" error case, but let's tell the user - * that something's wrong. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterivATI"); - return; - } - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - p[0] = INT_TO_FLOAT( param[0] ); - p[1] = INT_TO_FLOAT( param[1] ); - p[2] = INT_TO_FLOAT( param[2] ); - p[3] = INT_TO_FLOAT( param[3] ); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; /* init to zero, just to be safe */ - } - _mesa_TexBumpParameterfvATI( pname, p ); -} - - -void GLAPIENTRY -_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param ) -{ - struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - if (TEST_EQ_4V(param, texUnit->RotMatrix)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->RotMatrix, param); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexBumpParameter(pname)" ); - return; - } - /* Drivers might want to know about this, instead of dedicated function - just shove it into TexEnv where it really belongs anyway */ - if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, 0, pname, param ); - } -} - - -void GLAPIENTRY -_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ) -{ - const struct gl_texture_unit *texUnit; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterivATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps almost certainly would not understand it and - thus fail to submit matrices correctly) so hardcode this. */ - *param = 4; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - param[0] = FLOAT_TO_INT(texUnit->RotMatrix[0]); - param[1] = FLOAT_TO_INT(texUnit->RotMatrix[1]); - param[2] = FLOAT_TO_INT(texUnit->RotMatrix[2]); - param[3] = FLOAT_TO_INT(texUnit->RotMatrix[3]); - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = i + GL_TEXTURE0; - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } -} - - -void GLAPIENTRY -_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ) -{ - const struct gl_texture_unit *texUnit; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps might not understand it) so hardcode this. */ - *param = 4.0F; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - param[0] = texUnit->RotMatrix[0]; - param[1] = texUnit->RotMatrix[1]; - param[2] = texUnit->RotMatrix[2]; - param[3] = texUnit->RotMatrix[3]; - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = (GLfloat) count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = (GLfloat) (i + GL_TEXTURE0); - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texenv.h b/reactos/dll/opengl/mesa/src/mesa/main/texenv.h index 1e9c5faed79..d967f5d4219 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texenv.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/texenv.h @@ -48,16 +48,4 @@ _mesa_TexEnvi( GLenum target, GLenum pname, GLint param ); extern void GLAPIENTRY _mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ); -extern void GLAPIENTRY -_mesa_TexBumpParameterivATI( GLenum pname, const GLint *param ); - -extern void GLAPIENTRY -_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param ); - -extern void GLAPIENTRY -_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ); - -extern void GLAPIENTRY -_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ); - #endif /* TEXENV_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texformat.c b/reactos/dll/opengl/mesa/src/mesa/main/texformat.c index a7708f7688d..2c75c570569 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texformat.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texformat.c @@ -286,17 +286,6 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, } } - if (ctx->Extensions.ATI_envmap_bumpmap) { - switch (internalFormat) { - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - RETURN_IF_SUPPORTED(MESA_FORMAT_DUDV8); - break; - default: - ; /* fallthrough */ - } - } - if (ctx->Extensions.EXT_texture_integer) { switch (internalFormat) { case GL_ALPHA8UI_EXT: diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texgen.c b/reactos/dll/opengl/mesa/src/mesa/main/texgen.c index 0ace0b9364d..5c4889da9eb 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texgen.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texgen.c @@ -80,12 +80,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) *params, _mesa_lookup_enum_by_nr((GLenum) (GLint) *params)); - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexGen(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = &ctx->Texture.Unit; texgen = get_texgen(texUnit, coord); if (!texgen) { @@ -272,12 +267,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGendv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = &ctx->Texture.Unit; texgen = get_texgen(texUnit, coord); if (!texgen) { @@ -310,12 +300,7 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGenfv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = &ctx->Texture.Unit; texgen = get_texgen(texUnit, coord); if (!texgen) { @@ -348,12 +333,7 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGeniv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = &ctx->Texture.Unit; texgen = get_texgen(texUnit, coord); if (!texgen) { diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texgetimage.c b/reactos/dll/opengl/mesa/src/mesa/main/texgetimage.c index 297f3510ed4..b916b2980f9 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texgetimage.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texgetimage.c @@ -508,19 +508,13 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, return GL_TRUE; } - if (!ctx->Extensions.ATI_envmap_bumpmap - && _mesa_is_dudv_format(format)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); - return GL_TRUE; - } - err = _mesa_error_check_format_and_type(ctx, format, type); if (err != GL_NO_ERROR) { _mesa_error(ctx, err, "glGetTexImage(format/type)"); return GL_TRUE; } - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); if (!texObj || _mesa_is_proxy_texture(target)) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); @@ -553,11 +547,6 @@ getteximage_error_check(struct gl_context *ctx, GLenum target, GLint level, _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); return GL_TRUE; } - else if (_mesa_is_dudv_format(format) - && !_mesa_is_dudv_format(baseFormat)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); - return GL_TRUE; - } if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width, texImage->Height, texImage->Depth, @@ -616,7 +605,7 @@ _mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format, return; } - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); texImage = _mesa_select_tex_image(ctx, texObj, target, level); if (_mesa_is_zero_size_texture(texImage)) diff --git a/reactos/dll/opengl/mesa/src/mesa/main/teximage.c b/reactos/dll/opengl/mesa/src/mesa/main/teximage.c index 764ecc9fc40..e9b83b538ea 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/teximage.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/teximage.c @@ -156,16 +156,6 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) } } - if (ctx->Extensions.ATI_envmap_bumpmap) { - switch (internalFormat) { - case GL_DUDV_ATI: - case GL_DU8DV8_ATI: - return GL_DUDV_ATI; - default: - ; /* fallthrough */ - } - } - if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_integer) { switch (internalFormat) { @@ -379,34 +369,21 @@ get_proxy_target(GLenum target) */ struct gl_texture_object * _mesa_select_tex_object(struct gl_context *ctx, - const struct gl_texture_unit *texUnit, GLenum target) { switch (target) { case GL_TEXTURE_1D: - return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + return ctx->Texture.Unit.CurrentTex[TEXTURE_1D_INDEX]; case GL_PROXY_TEXTURE_1D: return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; case GL_TEXTURE_2D: - return texUnit->CurrentTex[TEXTURE_2D_INDEX]; + return ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; case GL_PROXY_TEXTURE_2D: return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; case GL_TEXTURE_3D: - return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + return ctx->Texture.Unit.CurrentTex[TEXTURE_3D_INDEX]; case GL_PROXY_TEXTURE_3D: return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: - case GL_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? texUnit->CurrentTex[TEXTURE_CUBE_INDEX] : NULL; - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - return ctx->Extensions.ARB_texture_cube_map - ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL; default: _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); return NULL; @@ -414,17 +391,6 @@ _mesa_select_tex_object(struct gl_context *ctx, } -/** - * Return pointer to texture object for given target on current texture unit. - */ -struct gl_texture_object * -_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - return _mesa_select_tex_object(ctx, texUnit, target); -} - - /** * Get a texture image pointer from a texture object, given a texture * target and mipmap level. The target and level parameters should @@ -1013,7 +979,7 @@ mutable_tex_object(struct gl_context *ctx, GLenum target) { if (ctx->Extensions.ARB_texture_storage) { struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); + _mesa_select_tex_object(ctx, target); return !texObj->Immutable; } return GL_TRUE; @@ -1135,8 +1101,7 @@ texture_error_check( struct gl_context *ctx, colorFormat = _mesa_is_color_format(format); if ((_mesa_is_color_format(internalFormat) && !colorFormat && !indexFormat) || (_mesa_is_depth_format(internalFormat) != _mesa_is_depth_format(format)) || - (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || - (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { + (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format))) { if (!isProxy) _mesa_error(ctx, GL_INVALID_OPERATION, "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", @@ -1182,7 +1147,7 @@ texture_error_check( struct gl_context *ctx, target != GL_TEXTURE_2D && target != GL_PROXY_TEXTURE_2D && !((_mesa_is_cube_face(target) || target == GL_PROXY_TEXTURE_CUBE_MAP) && - (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_gpu_shader4))) { + (ctx->VersionMajor >= 3))) { if (!isProxy) _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target/internalFormat)"); @@ -1775,7 +1740,7 @@ teximage(struct gl_context *ctx, GLuint dims, else { /* no error, set the tex image parameters */ struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); + _mesa_select_tex_object(ctx, target); gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, internalFormat, @@ -1813,7 +1778,7 @@ teximage(struct gl_context *ctx, GLuint dims, if (ctx->NewState & _NEW_PIXEL) _mesa_update_state(ctx); - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); _mesa_lock_texture(ctx, texObj); { @@ -1962,7 +1927,7 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, return; /* error was detected */ } - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); _mesa_lock_texture(ctx, texObj); { @@ -2107,7 +2072,7 @@ copyteximage(struct gl_context *ctx, GLuint dims, width, height, border)) return; - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); if (border && ctx->Const.StripTextureBorder) { x += border; @@ -2232,7 +2197,7 @@ copytexsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, if (copytexsubimage_error_check1(ctx, dims, target, level)) return; - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); _mesa_lock_texture(ctx, texObj); { diff --git a/reactos/dll/opengl/mesa/src/mesa/main/teximage.h b/reactos/dll/opengl/mesa/src/mesa/main/teximage.h index eec6e3eaf05..776e3b80478 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/teximage.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/teximage.h @@ -94,12 +94,8 @@ _mesa_clear_texture_image(struct gl_context *ctx, extern struct gl_texture_object * _mesa_select_tex_object(struct gl_context *ctx, - const struct gl_texture_unit *texUnit, GLenum target); -extern struct gl_texture_object * -_mesa_get_current_tex_object(struct gl_context *ctx, GLenum target); - extern struct gl_texture_image * _mesa_select_tex_image(struct gl_context *ctx, diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texobj.c b/reactos/dll/opengl/mesa/src/mesa/main/texobj.c index 9cc76428ae9..ec0abacaf90 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texobj.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texobj.c @@ -41,7 +41,6 @@ #include "texobj.h" #include "texstate.h" #include "mtypes.h" -#include "program/prog_instruction.h" @@ -582,7 +581,7 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx, return; } /* Don't support GL_DEPTH_COMPONENT for cube maps */ - if (ctx->VersionMajor < 3 && !ctx->Extensions.EXT_gpu_shader4) { + if (ctx->VersionMajor < 3) { if (t->Image[face][i]->_BaseFormat == GL_DEPTH_COMPONENT) { incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex"); return; @@ -794,17 +793,14 @@ static void unbind_texobj_from_texunits(struct gl_context *ctx, struct gl_texture_object *texObj) { - GLuint u, tex; - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - if (texObj == unit->CurrentTex[tex]) { - _mesa_reference_texobj(&unit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - ASSERT(unit->CurrentTex[tex]); - break; - } + GLuint tex; + struct gl_texture_unit *unit = &ctx->Texture.Unit; + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + if (texObj == unit->CurrentTex[tex]) { + _mesa_reference_texobj(&unit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); + ASSERT(unit->CurrentTex[tex]); + break; } } } @@ -911,7 +907,7 @@ void GLAPIENTRY _mesa_BindTexture( GLenum target, GLuint texName ) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; struct gl_texture_object *newTexObj = NULL; GLint targetIndex; ASSERT_OUTSIDE_BEGIN_END(ctx); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texparam.c b/reactos/dll/opengl/mesa/src/mesa/main/texparam.c index df3fad6ab5e..5c430b5c254 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texparam.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texparam.c @@ -43,7 +43,6 @@ #include "main/texparam.h" #include "main/teximage.h" #include "main/texstate.h" -#include "program/prog_instruction.h" /** @@ -95,13 +94,7 @@ get_texobj(struct gl_context *ctx, GLenum target, GLboolean get) { struct gl_texture_unit *texUnit; - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "gl%sTexParameter(current unit)", get ? "Get" : ""); - return NULL; - } - - texUnit = _mesa_get_current_tex_unit(ctx); + texUnit = &ctx->Texture.Unit; switch (target) { case GL_TEXTURE_1D: @@ -595,7 +588,6 @@ void GLAPIENTRY _mesa_GetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ) { - const struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; const struct gl_texture_image *img = NULL; GLint maxLevels; @@ -603,14 +595,6 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); - if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetTexLevelParameteriv(current unit)"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - /* this will catch bad target values */ maxLevels = _mesa_max_texture_levels(ctx, target); if (maxLevels == 0) { @@ -624,7 +608,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, return; } - texObj = _mesa_select_tex_object(ctx, texUnit, target); + texObj = _mesa_select_tex_object(ctx, target); img = _mesa_select_tex_image(ctx, texObj, target, level); if (!img || img->TexFormat == MESA_FORMAT_NONE) { diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texstate.c b/reactos/dll/opengl/mesa/src/mesa/main/texstate.c index adf22ec0cf3..7f0dc1b8493 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texstate.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texstate.c @@ -66,51 +66,43 @@ static const struct gl_tex_env_combine_state default_combine_state = { void _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ) { - GLuint u, tex; + GLuint tex; ASSERT(src); ASSERT(dst); - dst->Texture.CurrentUnit = src->Texture.CurrentUnit; dst->Texture._GenFlags = src->Texture._GenFlags; dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled; dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled; - /* per-unit state */ - for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) { - dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled; - dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode; - COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor); - dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled; - dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS; - dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT; - dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR; - dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ; - dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias; + dst->Texture.Unit.Enabled = src->Texture.Unit.Enabled; + dst->Texture.Unit.EnvMode = src->Texture.Unit.EnvMode; + COPY_4V(dst->Texture.Unit.EnvColor, src->Texture.Unit.EnvColor); + dst->Texture.Unit.TexGenEnabled = src->Texture.Unit.TexGenEnabled; + dst->Texture.Unit.GenS = src->Texture.Unit.GenS; + dst->Texture.Unit.GenT = src->Texture.Unit.GenT; + dst->Texture.Unit.GenR = src->Texture.Unit.GenR; + dst->Texture.Unit.GenQ = src->Texture.Unit.GenQ; + dst->Texture.Unit.LodBias = src->Texture.Unit.LodBias; - /* GL_EXT_texture_env_combine */ - dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine; + /* GL_EXT_texture_env_combine */ + dst->Texture.Unit.Combine = src->Texture.Unit.Combine; - /* GL_ATI_envmap_bumpmap - need this? */ - dst->Texture.Unit[u].BumpTarget = src->Texture.Unit[u].BumpTarget; - COPY_4V(dst->Texture.Unit[u].RotMatrix, src->Texture.Unit[u].RotMatrix); + /* + * XXX strictly speaking, we should compare texture names/ids and + * bind textures in the dest context according to id. For now, only + * copy bindings if the contexts share the same pool of textures to + * avoid refcounting bugs. + */ + if (dst->Shared == src->Shared) { + /* copy texture object bindings, not contents of texture objects */ + _mesa_lock_context_textures(dst); - /* - * XXX strictly speaking, we should compare texture names/ids and - * bind textures in the dest context according to id. For now, only - * copy bindings if the contexts share the same pool of textures to - * avoid refcounting bugs. - */ - if (dst->Shared == src->Shared) { - /* copy texture object bindings, not contents of texture objects */ - _mesa_lock_context_textures(dst); - - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex], - src->Texture.Unit[u].CurrentTex[tex]); - } - _mesa_unlock_context_textures(dst); + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&dst->Texture.Unit.CurrentTex[tex], + src->Texture.Unit.CurrentTex[tex]); } + _mesa_unlock_context_textures(dst); } } @@ -119,10 +111,10 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ) * For debugging */ void -_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ) +_mesa_print_texunit_state( struct gl_context *ctx ) { - const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit; - printf("Texture Unit %d\n", unit); + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; + printf("Texture Unit\n"); printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); @@ -183,7 +175,6 @@ calculate_derived_texenv( struct gl_tex_env_combine_state *state, case GL_RG: case GL_RGB: case GL_YCBCR_MESA: - case GL_DUDV_ATI: state->SourceA[0] = GL_PREVIOUS; break; @@ -225,7 +216,6 @@ calculate_derived_texenv( struct gl_tex_env_combine_state *state, case GL_RG: case GL_RGB: case GL_YCBCR_MESA: - case GL_DUDV_ATI: mode_rgb = GL_REPLACE; break; case GL_RGBA: @@ -254,7 +244,6 @@ calculate_derived_texenv( struct gl_tex_env_combine_state *state, case GL_LUMINANCE_ALPHA: case GL_RGBA: case GL_YCBCR_MESA: - case GL_DUDV_ATI: state->SourceRGB[2] = GL_TEXTURE; state->SourceA[2] = GL_TEXTURE; state->SourceRGB[0] = GL_CONSTANT; @@ -281,74 +270,6 @@ calculate_derived_texenv( struct gl_tex_env_combine_state *state, ? mode_a : GL_REPLACE; } - - - -/* GL_ARB_multitexture */ -void GLAPIENTRY -_mesa_ActiveTextureARB(GLenum texture) -{ - const GLuint texUnit = texture - GL_TEXTURE0; - GLuint k; - GET_CURRENT_CONTEXT(ctx); - - /* See OpenGL spec for glActiveTexture: */ - k = MAX2(ctx->Const.MaxCombinedTextureImageUnits, - ctx->Const.MaxTextureCoordUnits); - - ASSERT(k <= Elements(ctx->Texture.Unit)); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glActiveTexture %s\n", - _mesa_lookup_enum_by_nr(texture)); - - if (texUnit >= k) { - _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", - _mesa_lookup_enum_by_nr(texture)); - return; - } - - if (ctx->Texture.CurrentUnit == texUnit) - return; - - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - - ctx->Texture.CurrentUnit = texUnit; - if (ctx->Transform.MatrixMode == GL_TEXTURE) { - /* update current stack pointer */ - ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit]; - } -} - - -/* GL_ARB_multitexture */ -void GLAPIENTRY -_mesa_ClientActiveTextureARB(GLenum texture) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint texUnit = texture - GL_TEXTURE0; - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glClientActiveTexture %s\n", - _mesa_lookup_enum_by_nr(texture)); - - if (texUnit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(texture)"); - return; - } - - if (ctx->Array.ActiveTexture == texUnit) - return; - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.ActiveTexture = texUnit; -} - - - /**********************************************************************/ /***** State management *****/ /**********************************************************************/ @@ -365,19 +286,14 @@ _mesa_ClientActiveTextureARB(GLenum texture) static void update_texture_matrices( struct gl_context *ctx ) { - GLuint u; - ctx->Texture._TexMatEnabled = 0x0; - for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { - ASSERT(u < Elements(ctx->TextureMatrixStack)); - if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) { - _math_matrix_analyse( ctx->TextureMatrixStack[u].Top ); + if (_math_matrix_is_dirty(ctx->TextureMatrixStack.Top)) { + _math_matrix_analyse( ctx->TextureMatrixStack.Top ); - if (ctx->Texture.Unit[u]._ReallyEnabled && - ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u); - } + if (ctx->Texture.Unit._ReallyEnabled && + ctx->TextureMatrixStack.Top->type != MATRIX_IDENTITY) + ctx->Texture._TexMatEnabled = GL_TRUE; } } @@ -434,10 +350,6 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit) case GL_MODULATE_SUBTRACT_ATI: combine->_NumArgsRGB = 3; break; - case GL_BUMP_ENVMAP_ATI: - /* no real arguments for this case */ - combine->_NumArgsRGB = 0; - break; default: combine->_NumArgsRGB = 0; _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state"); @@ -485,144 +397,64 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit) static void update_texture_state( struct gl_context *ctx ) { - GLuint unit; - struct gl_program *fprog = NULL; - struct gl_program *vprog = NULL; - GLbitfield enabledFragUnits = 0x0; - - if (ctx->Shader.CurrentVertexProgram && - ctx->Shader.CurrentVertexProgram->LinkStatus) { - vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program; - } else if (ctx->VertexProgram._Enabled) { - /* XXX enable this if/when non-shader vertex programs get - * texture fetches: - vprog = &ctx->VertexProgram.Current->Base; - */ - } - - if (ctx->Shader.CurrentFragmentProgram && - ctx->Shader.CurrentFragmentProgram->LinkStatus) { - fprog = ctx->Shader.CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program; - } - else if (ctx->FragmentProgram._Enabled) { - fprog = &ctx->FragmentProgram.Current->Base; - } - - /* FINISHME: Geometry shader texture accesses should also be considered - * FINISHME: here. - */ - /* TODO: only set this if there are actual changes */ ctx->NewState |= _NEW_TEXTURE; - ctx->Texture._EnabledUnits = 0x0; + ctx->Texture._Enabled = GL_FALSE; ctx->Texture._GenFlags = 0x0; - ctx->Texture._TexMatEnabled = 0x0; - ctx->Texture._TexGenEnabled = 0x0; + ctx->Texture._TexMatEnabled = GL_FALSE; + ctx->Texture._TexGenEnabled = GL_FALSE; /* * Update texture unit state. */ - for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLbitfield enabledVertTargets = 0x0; - GLbitfield enabledFragTargets = 0x0; - GLbitfield enabledTargets = 0x0; - GLuint texIndex; - - /* Get the bitmask of texture target enables. - * enableBits will be a mask of the TEXTURE_*_BIT flags indicating - * which texture targets are enabled (fixed function) or referenced - * by a fragment program/program. When multiple flags are set, we'll - * settle on the one with highest priority (see below). - */ - if (vprog) { - enabledVertTargets |= vprog->TexturesUsed[unit]; - } - - if (fprog) { - enabledFragTargets |= fprog->TexturesUsed[unit]; - } - else { - /* fixed-function fragment program */ - enabledFragTargets |= texUnit->Enabled; - } - - enabledTargets = enabledVertTargets | enabledFragTargets; + { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; + GLbitfield enabledTargets = texUnit->Enabled; texUnit->_ReallyEnabled = 0x0; - if (enabledTargets == 0x0) { - /* neither vertex nor fragment processing uses this unit */ - continue; - } - - /* Look for the highest priority texture target that's enabled (or used - * by the vert/frag shaders) and "complete". That's the one we'll use - * for texturing. If we're using vert/frag program we're guaranteed - * that bitcount(enabledBits) <= 1. - * Note that the TEXTURE_x_INDEX values are in high to low priority. - */ - for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { - if (enabledTargets & (1 << texIndex)) { - struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; - if (!texObj->_Complete) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (texObj->_Complete) { - texUnit->_ReallyEnabled = 1 << texIndex; - _mesa_reference_texobj(&texUnit->_Current, texObj); - break; + if (enabledTargets) { + GLuint texIndex; + /* Look for the highest priority texture target that's enabled (or used + * by the vert/frag shaders) and "complete". That's the one we'll use + * for texturing. If we're using vert/frag program we're guaranteed + * that bitcount(enabledBits) <= 1. + * Note that the TEXTURE_x_INDEX values are in high to low priority. + */ + for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { + if (enabledTargets & (1 << texIndex)) { + struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; + if (!texObj->_Complete) { + _mesa_test_texobj_completeness(ctx, texObj); + } + if (texObj->_Complete) { + texUnit->_ReallyEnabled = 1 << texIndex; + _mesa_reference_texobj(&texUnit->_Current, texObj); + break; + } } } - } - if (!texUnit->_ReallyEnabled) { - if (fprog) { - /* If we get here it means the shader is expecting a texture - * object, but there isn't one (or it's incomplete). Use the - * fallback texture. - */ - struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx); - texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX; - _mesa_reference_texobj(&texUnit->_Current, texObj); - } - else { - /* fixed-function: texture unit is really disabled */ - continue; + if (texUnit->_ReallyEnabled) { + /* if we get here, we know this texture unit is enabled */ + ctx->Texture._Enabled = GL_TRUE; + update_tex_combine(ctx, texUnit); } } - - /* if we get here, we know this texture unit is enabled */ - - ctx->Texture._EnabledUnits |= (1 << unit); - - if (enabledFragTargets) - enabledFragUnits |= (1 << unit); - - update_tex_combine(ctx, texUnit); } - /* Determine which texture coordinate sets are actually needed */ - if (fprog) { - const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1; - ctx->Texture._EnabledCoordUnits - = (fprog->InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; - } - else { - ctx->Texture._EnabledCoordUnits = enabledFragUnits; - } + /* Determine if texture coordinates are actually needed */ + ctx->Texture._EnabledCoord = ctx->Texture._Enabled; /* Setup texgen for those texture coordinate sets that are in use */ - for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + if(ctx->Texture._EnabledCoord) + { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; texUnit->_GenFlags = 0x0; - if (!(ctx->Texture._EnabledCoordUnits & (1 << unit))) - continue; - if (texUnit->TexGenEnabled) { if (texUnit->TexGenEnabled & S_BIT) { texUnit->_GenFlags |= texUnit->GenS._ModeBit; @@ -637,13 +469,12 @@ update_texture_state( struct gl_context *ctx ) texUnit->_GenFlags |= texUnit->GenQ._ModeBit; } - ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); + ctx->Texture._TexGenEnabled = GL_TRUE; ctx->Texture._GenFlags |= texUnit->_GenFlags; } - ASSERT(unit < Elements(ctx->TextureMatrixStack)); - if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) - ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); + if (ctx->TextureMatrixStack.Top->type != MATRIX_IDENTITY) + ctx->Texture._TexMatEnabled = GL_TRUE; } } @@ -657,7 +488,7 @@ _mesa_update_texture( struct gl_context *ctx, GLuint new_state ) if (new_state & _NEW_TEXTURE_MATRIX) update_texture_matrices( ctx ); - if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM)) + if (new_state & _NEW_TEXTURE) update_texture_state( ctx ); } @@ -717,9 +548,9 @@ alloc_proxy_textures( struct gl_context *ctx ) * \param unit texture unit number to be initialized. */ static void -init_texture_unit( struct gl_context *ctx, GLuint unit ) +init_texture_unit( struct gl_context *ctx) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; GLuint tex; texUnit->EnvMode = GL_MODULATE; @@ -728,7 +559,6 @@ init_texture_unit( struct gl_context *ctx, GLuint unit ) texUnit->Combine = default_combine_state; texUnit->_EnvMode = default_combine_state; texUnit->_CurrentCombine = & texUnit->_EnvMode; - texUnit->BumpTarget = GL_TEXTURE0; texUnit->TexGenEnabled = 0x0; texUnit->GenS.Mode = GL_EYE_LINEAR; @@ -750,9 +580,6 @@ init_texture_unit( struct gl_context *ctx, GLuint unit ) ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); - /* no mention of this in spec, but maybe id matrix expected? */ - ASSIGN_4V( texUnit->RotMatrix, 1.0, 0.0, 0.0, 1.0 ); - /* initialize current texture object ptrs to the shared default objects */ for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { _mesa_reference_texobj(&texUnit->CurrentTex[tex], @@ -767,21 +594,10 @@ init_texture_unit( struct gl_context *ctx, GLuint unit ) GLboolean _mesa_init_texture(struct gl_context *ctx) { - GLuint u; - /* Texture group */ - ctx->Texture.CurrentUnit = 0; /* multitexture */ - ctx->Texture._EnabledUnits = 0x0; + ctx->Texture._Enabled = GL_FALSE; - for (u = 0; u < Elements(ctx->Texture.Unit); u++) - init_texture_unit(ctx, u); - - /* After we're done initializing the context's texture state the default - * texture objects' refcounts should be at least - * MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1. - */ - assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount - >= MAX_COMBINED_TEXTURE_IMAGE_UNITS + 1); + init_texture_unit(ctx); /* Allocate proxy textures */ if (!alloc_proxy_textures( ctx )) @@ -797,16 +613,14 @@ _mesa_init_texture(struct gl_context *ctx) void _mesa_free_texture_data(struct gl_context *ctx) { - GLuint u, tgt; + GLuint tgt; /* unreference current textures */ - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - /* The _Current texture could account for another reference */ - _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); + /* The _Current texture could account for another reference */ + _mesa_reference_texobj(&ctx->Texture.Unit._Current, NULL); - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL); - } + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&ctx->Texture.Unit.CurrentTex[tgt], NULL); } /* Free proxy texture objects */ @@ -814,9 +628,7 @@ _mesa_free_texture_data(struct gl_context *ctx) ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); #if FEATURE_sampler_objects - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL); - } + _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit.Sampler, NULL); #endif } @@ -829,13 +641,10 @@ _mesa_free_texture_data(struct gl_context *ctx) void _mesa_update_default_objects_texture(struct gl_context *ctx) { - GLuint u, tex; - - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&texUnit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - } + GLuint tex; + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; + for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { + _mesa_reference_texobj(&texUnit->CurrentTex[tex], + ctx->Shared->DefaultTex[tex]); } } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texstate.h b/reactos/dll/opengl/mesa/src/mesa/main/texstate.h index 7dc6dc6a2cd..2183589d98b 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texstate.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/texstate.h @@ -36,38 +36,11 @@ #include "mtypes.h" -/** - * Return pointer to current texture unit. - * This the texture unit set by glActiveTexture(), not glClientActiveTexture(). - */ -static inline struct gl_texture_unit * -_mesa_get_current_tex_unit(struct gl_context *ctx) -{ - ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->Texture.Unit)); - return &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]); -} - - extern void _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ); extern void -_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit ); - - - -/** - * \name Called from API - */ -/*@{*/ - -extern void GLAPIENTRY -_mesa_ActiveTextureARB( GLenum target ); - -extern void GLAPIENTRY -_mesa_ClientActiveTextureARB( GLenum target ); - -/*@}*/ +_mesa_print_texunit_state( struct gl_context *ctx ); /** diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texstorage.c b/reactos/dll/opengl/mesa/src/mesa/main/texstorage.c index 6e0d165a9b5..a70305db38d 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texstorage.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texstorage.c @@ -281,7 +281,7 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target, } /* non-default texture object check */ - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); if (!texObj || (texObj->Name == 0 && !isProxy)) { if (!isProxy) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -315,7 +315,7 @@ texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat, GET_CURRENT_CONTEXT(ctx); - texObj = _mesa_get_current_tex_object(ctx, target); + texObj = _mesa_select_tex_object(ctx, target); error = tex_storage_error_check(ctx, dims, target, levels, internalformat, width, height, depth); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/texstore.c b/reactos/dll/opengl/mesa/src/mesa/main/texstore.c index c1d5588859a..9d6ebb41a3b 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/texstore.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/texstore.c @@ -2520,92 +2520,6 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS) return GL_TRUE; } -static GLboolean -_mesa_texstore_dudv8(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_DUDV8); - ASSERT(texelBytes == 2); - ASSERT(ctx->Extensions.ATI_envmap_bumpmap); - ASSERT((srcFormat == GL_DU8DV8_ATI) || - (srcFormat == GL_DUDV_ATI)); - ASSERT(baseInternalFormat == GL_DUDV_ATI); - - if (!srcPacking->SwapBytes && srcType == GL_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (srcType == GL_BYTE) { - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (littleEndian) { - dstmap[0] = 0; - dstmap[1] = 3; - } - else { - dstmap[0] = 3; - dstmap[1] = 0; - } - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - GL_LUMINANCE_ALPHA, /* hack */ - GL_UNSIGNED_BYTE, /* hack */ - GL_LUMINANCE_ALPHA, /* hack */ - dstmap, 2, - dstRowStride, dstSlices, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path - note this is defined for 2d textures only */ - const GLint components = _mesa_components_in_format(baseInternalFormat); - const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); - GLbyte *tempImage, *dst, *src; - GLint row; - - tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLbyte)); - if (!tempImage) - return GL_FALSE; - - src = (GLbyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - 0, 0, 0); - - dst = tempImage; - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_dudv_span_byte(ctx, srcWidth, baseInternalFormat, - dst, srcFormat, srcType, src, - srcPacking, 0); - dst += srcWidth * components; - src += srcStride; - } - - src = tempImage; - dst = (GLbyte *) dstSlices[0]; - for (row = 0; row < srcHeight; row++) { - memcpy(dst, src, srcWidth * texelBytes); - dst += dstRowStride; - src += srcWidth * texelBytes; - } - free((void *) tempImage); - } - return GL_TRUE; -} - /** * Store simple 8-bit/value stencil texture data. */ @@ -3298,7 +3212,6 @@ _mesa_get_texstore_func(gl_format format) table[MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = _mesa_texstore_rgba_float16; table[MESA_FORMAT_INTENSITY_FLOAT32] = _mesa_texstore_rgba_float32; table[MESA_FORMAT_INTENSITY_FLOAT16] = _mesa_texstore_rgba_float16; - table[MESA_FORMAT_DUDV8] = _mesa_texstore_dudv8; table[MESA_FORMAT_SIGNED_RGBA_16] = _mesa_texstore_signed_rgba_16; table[MESA_FORMAT_RGBA_16] = _mesa_texstore_rgba_16; diff --git a/reactos/dll/opengl/mesa/src/mesa/main/uniform_query.cpp b/reactos/dll/opengl/mesa/src/mesa/main/uniform_query.cpp deleted file mode 100644 index 78041c5aef0..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/uniform_query.cpp +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * Copyright © 2010, 2011 Intel Corporation - * - * 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. - */ - -#include - -#include "main/core.h" -#include "main/context.h" -#include "ir.h" -#include "ir_uniform.h" -#include "program/hash_table.h" -#include "../glsl/program.h" -#include "../glsl/ir_uniform.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" -#include "uniforms.h" - - -extern "C" void GLAPIENTRY -_mesa_GetActiveUniformARB(GLhandleARB program, GLuint index, - GLsizei maxLength, GLsizei *length, GLint *size, - GLenum *type, GLcharARB *nameOut) -{ - GET_CURRENT_CONTEXT(ctx); - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniform"); - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!shProg) - return; - - if (index >= shProg->NumUserUniformStorage) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)"); - return; - } - - const struct gl_uniform_storage *const uni = &shProg->UniformStorage[index]; - - if (nameOut) { - _mesa_copy_string(nameOut, maxLength, length, uni->name); - } - - if (size) { - /* array_elements is zero for non-arrays, but the API requires that 1 be - * returned. - */ - *size = MAX2(1, uni->array_elements); - } - - if (type) { - *type = uni->type->gl_type; - } -} - -static bool -validate_uniform_parameters(struct gl_context *ctx, - struct gl_shader_program *shProg, - GLint location, GLsizei count, - unsigned *loc, - unsigned *array_index, - const char *caller, - bool negative_one_is_not_valid) -{ - if (!shProg || !shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)", caller); - return false; - } - - if (location == -1) { - /* For glGetUniform, page 264 (page 278 of the PDF) of the OpenGL 2.1 - * spec says: - * - * "The error INVALID_OPERATION is generated if program has not been - * linked successfully, or if location is not a valid location for - * program." - * - * For glUniform, page 82 (page 96 of the PDF) of the OpenGL 2.1 spec - * says: - * - * "If the value of location is -1, the Uniform* commands will - * silently ignore the data passed in, and the current uniform - * values will not be changed." - * - * Allowing -1 for the location parameter of glUniform allows - * applications to avoid error paths in the case that, for example, some - * uniform variable is removed by the compiler / linker after - * optimization. In this case, the new value of the uniform is dropped - * on the floor. For the case of glGetUniform, there is nothing - * sensible to do for a location of -1. - * - * The negative_one_is_not_valid flag selects between the two behaviors. - */ - if (negative_one_is_not_valid) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); - } - - return false; - } - - /* From page 12 (page 26 of the PDF) of the OpenGL 2.1 spec: - * - * "If a negative number is provided where an argument of type sizei or - * sizeiptr is specified, the error INVALID_VALUE is generated." - */ - if (count < 0) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(count < 0)", caller); - return false; - } - - /* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says: - * - * "If any of the following conditions occur, an INVALID_OPERATION - * error is generated by the Uniform* commands, and no uniform values - * are changed: - * - * ... - * - * - if no variable with a location of location exists in the - * program object currently in use and location is not -1, - * - if count is greater than one, and the uniform declared in the - * shader is not an array variable, - */ - if (location < -1) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); - return false; - } - - _mesa_uniform_split_location_offset(location, loc, array_index); - - if (*loc >= shProg->NumUserUniformStorage) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); - return false; - } - - if (shProg->UniformStorage[*loc].array_elements == 0 && count > 1) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(count > 1 for non-array, location=%d)", - caller, location); - return false; - } - - /* This case should be impossible. The implication is that a call like - * glGetUniformLocation(prog, "foo[8]") was successful but "foo" is not an - * array. - */ - if (*array_index != 0 && shProg->UniformStorage[*loc].array_elements == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); - return false; - } - return true; -} - -/** - * Called via glGetUniform[fiui]v() to get the current value of a uniform. - */ -extern "C" void -_mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, - GLsizei bufSize, enum glsl_base_type returnType, - GLvoid *paramsOut) -{ - struct gl_shader_program *shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetUniformfv"); - struct gl_uniform_storage *uni; - unsigned loc, offset; - - if (!validate_uniform_parameters(ctx, shProg, location, 1, - &loc, &offset, "glGetUniform", true)) - return; - - uni = &shProg->UniformStorage[loc]; - - { - unsigned elements = (uni->type->is_sampler()) - ? 1 : uni->type->components(); - - /* Calculate the source base address *BEFORE* modifying elements to - * account for the size of the user's buffer. - */ - const union gl_constant_value *const src = - &uni->storage[offset * elements]; - - assert(returnType == GLSL_TYPE_FLOAT || returnType == GLSL_TYPE_INT || - returnType == GLSL_TYPE_UINT); - /* The three (currently) supported types all have the same size, - * which is of course the same as their union. That'll change - * with glGetUniformdv()... - */ - unsigned bytes = sizeof(src[0]) * elements; - if (bufSize < 0 || bytes > (unsigned) bufSize) { - _mesa_error( ctx, GL_INVALID_OPERATION, - "glGetnUniform*vARB(out of bounds: bufSize is %d," - " but %u bytes are required)", bufSize, bytes ); - return; - } - - /* If the return type and the uniform's native type are "compatible," - * just memcpy the data. If the types are not compatible, perform a - * slower convert-and-copy process. - */ - if (returnType == uni->type->base_type - || ((returnType == GLSL_TYPE_INT - || returnType == GLSL_TYPE_UINT - || returnType == GLSL_TYPE_SAMPLER) - && - (uni->type->base_type == GLSL_TYPE_INT - || uni->type->base_type == GLSL_TYPE_UINT - || uni->type->base_type == GLSL_TYPE_SAMPLER))) { - memcpy(paramsOut, src, bytes); - } else { - union gl_constant_value *const dst = - (union gl_constant_value *) paramsOut; - - /* This code could be optimized by putting the loop inside the switch - * statements. However, this is not expected to be - * performance-critical code. - */ - for (unsigned i = 0; i < elements; i++) { - switch (returnType) { - case GLSL_TYPE_FLOAT: - switch (uni->type->base_type) { - case GLSL_TYPE_UINT: - dst[i].f = (float) src[i].u; - break; - case GLSL_TYPE_INT: - case GLSL_TYPE_SAMPLER: - dst[i].f = (float) src[i].i; - break; - case GLSL_TYPE_BOOL: - dst[i].f = src[i].i ? 1.0f : 0.0f; - break; - default: - assert(!"Should not get here."); - break; - } - break; - - case GLSL_TYPE_INT: - case GLSL_TYPE_UINT: - switch (uni->type->base_type) { - case GLSL_TYPE_FLOAT: - /* While the GL 3.2 core spec doesn't explicitly - * state how conversion of float uniforms to integer - * values works, in section 6.2 "State Tables" on - * page 267 it says: - * - * "Unless otherwise specified, when floating - * point state is returned as integer values or - * integer state is returned as floating-point - * values it is converted in the fashion - * described in section 6.1.2" - * - * That section, on page 248, says: - * - * "If GetIntegerv or GetInteger64v are called, - * a floating-point value is rounded to the - * nearest integer..." - */ - dst[i].i = IROUND(src[i].f); - break; - case GLSL_TYPE_BOOL: - dst[i].i = src[i].i ? 1 : 0; - break; - default: - assert(!"Should not get here."); - break; - } - break; - - default: - assert(!"Should not get here."); - break; - } - } - } - } -} - -static void -log_uniform(const void *values, enum glsl_base_type basicType, - unsigned rows, unsigned cols, unsigned count, - bool transpose, - const struct gl_shader_program *shProg, - GLint location, - const struct gl_uniform_storage *uni) -{ - - const union gl_constant_value *v = (const union gl_constant_value *) values; - const unsigned elems = rows * cols * count; - const char *const extra = (cols == 1) ? "uniform" : "uniform matrix"; - - printf("Mesa: set program %u %s \"%s\" (loc %d, type \"%s\", " - "transpose = %s) to: ", - shProg->Name, extra, uni->name, location, uni->type->name, - transpose ? "true" : "false"); - for (unsigned i = 0; i < elems; i++) { - if (i != 0 && ((i % rows) == 0)) - printf(", "); - - switch (basicType) { - case GLSL_TYPE_UINT: - printf("%u ", v[i].u); - break; - case GLSL_TYPE_INT: - printf("%d ", v[i].i); - break; - case GLSL_TYPE_FLOAT: - printf("%g ", v[i].f); - break; - default: - assert(!"Should not get here."); - break; - } - } - printf("\n"); - fflush(stdout); -} - -#if 0 -static void -log_program_parameters(const struct gl_shader_program *shProg) -{ - static const char *stages[] = { - "vertex", "fragment" - }; - - assert(Elements(stages) == MESA_SHADER_TYPES); - - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (shProg->_LinkedShaders[i] == NULL) - continue; - - const struct gl_program *const prog = shProg->_LinkedShaders[i]->Program; - - printf("Program %d %s shader parameters:\n", - shProg->Name, stages[i]); - for (unsigned j = 0; j < prog->Parameters->NumParameters; j++) { - printf("%s: %p %f %f %f %f\n", - prog->Parameters->Parameters[j].Name, - prog->Parameters->ParameterValues[j], - prog->Parameters->ParameterValues[j][0].f, - prog->Parameters->ParameterValues[j][1].f, - prog->Parameters->ParameterValues[j][2].f, - prog->Parameters->ParameterValues[j][3].f); - } - } - fflush(stdout); -} -#endif - -/** - * Propagate some values from uniform backing storage to driver storage - * - * Values propagated from uniform backing storage to driver storage - * have all format / type conversions previously requested by the - * driver applied. This function is most often called by the - * implementations of \c glUniform1f, etc. and \c glUniformMatrix2f, - * etc. - * - * \param uni Uniform whose data is to be propagated to driver storage - * \param array_index If \c uni is an array, this is the element of - * the array to be propagated. - * \param count Number of array elements to propagate. - */ -extern "C" void -_mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni, - unsigned array_index, - unsigned count) -{ - unsigned i; - - /* vector_elements and matrix_columns can be 0 for samplers. - */ - const unsigned components = MAX2(1, uni->type->vector_elements); - const unsigned vectors = MAX2(1, uni->type->matrix_columns); - - /* Store the data in the driver's requested type in the driver's storage - * areas. - */ - unsigned src_vector_byte_stride = components * 4; - - for (i = 0; i < uni->num_driver_storage; i++) { - struct gl_uniform_driver_storage *const store = &uni->driver_storage[i]; - uint8_t *dst = (uint8_t *) store->data; - const unsigned extra_stride = - store->element_stride - (vectors * store->vector_stride); - const uint8_t *src = - (uint8_t *) (&uni->storage[array_index * (components * vectors)].i); - -#if 0 - printf("%s: %p[%d] components=%u vectors=%u count=%u vector_stride=%u " - "extra_stride=%u\n", - __func__, dst, array_index, components, - vectors, count, store->vector_stride, extra_stride); -#endif - - dst += array_index * store->element_stride; - - switch (store->format) { - case uniform_native: - case uniform_bool_int_0_1: { - unsigned j; - unsigned v; - - for (j = 0; j < count; j++) { - for (v = 0; v < vectors; v++) { - memcpy(dst, src, src_vector_byte_stride); - src += src_vector_byte_stride; - dst += store->vector_stride; - } - - dst += extra_stride; - } - break; - } - - case uniform_int_float: - case uniform_bool_float: { - const int *isrc = (const int *) src; - unsigned j; - unsigned v; - unsigned c; - - for (j = 0; j < count; j++) { - for (v = 0; v < vectors; v++) { - for (c = 0; c < components; c++) { - ((float *) dst)[c] = (float) *isrc; - isrc++; - } - - dst += store->vector_stride; - } - - dst += extra_stride; - } - break; - } - - case uniform_bool_int_0_not0: { - const int *isrc = (const int *) src; - unsigned j; - unsigned v; - unsigned c; - - for (j = 0; j < count; j++) { - for (v = 0; v < vectors; v++) { - for (c = 0; c < components; c++) { - ((int *) dst)[c] = *isrc == 0 ? 0 : ~0; - isrc++; - } - - dst += store->vector_stride; - } - - dst += extra_stride; - } - break; - } - - default: - assert(!"Should not get here."); - break; - } - } -} - -/** - * Called via glUniform*() functions. - */ -extern "C" void -_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, - GLint location, GLsizei count, - const GLvoid *values, GLenum type) -{ - unsigned loc, offset; - unsigned components; - unsigned src_components; - enum glsl_base_type basicType; - struct gl_uniform_storage *uni; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_uniform_parameters(ctx, shProg, location, count, - &loc, &offset, "glUniform", false)) - return; - - uni = &shProg->UniformStorage[loc]; - - /* Verify that the types are compatible. - */ - switch (type) { - case GL_FLOAT: - basicType = GLSL_TYPE_FLOAT; - src_components = 1; - break; - case GL_FLOAT_VEC2: - basicType = GLSL_TYPE_FLOAT; - src_components = 2; - break; - case GL_FLOAT_VEC3: - basicType = GLSL_TYPE_FLOAT; - src_components = 3; - break; - case GL_FLOAT_VEC4: - basicType = GLSL_TYPE_FLOAT; - src_components = 4; - break; - case GL_UNSIGNED_INT: - basicType = GLSL_TYPE_UINT; - src_components = 1; - break; - case GL_UNSIGNED_INT_VEC2: - basicType = GLSL_TYPE_UINT; - src_components = 2; - break; - case GL_UNSIGNED_INT_VEC3: - basicType = GLSL_TYPE_UINT; - src_components = 3; - break; - case GL_UNSIGNED_INT_VEC4: - basicType = GLSL_TYPE_UINT; - src_components = 4; - break; - case GL_INT: - basicType = GLSL_TYPE_INT; - src_components = 1; - break; - case GL_INT_VEC2: - basicType = GLSL_TYPE_INT; - src_components = 2; - break; - case GL_INT_VEC3: - basicType = GLSL_TYPE_INT; - src_components = 3; - break; - case GL_INT_VEC4: - basicType = GLSL_TYPE_INT; - src_components = 4; - break; - case GL_BOOL: - case GL_BOOL_VEC2: - case GL_BOOL_VEC3: - case GL_BOOL_VEC4: - case GL_FLOAT_MAT2: - case GL_FLOAT_MAT2x3: - case GL_FLOAT_MAT2x4: - case GL_FLOAT_MAT3x2: - case GL_FLOAT_MAT3: - case GL_FLOAT_MAT3x4: - case GL_FLOAT_MAT4x2: - case GL_FLOAT_MAT4x3: - case GL_FLOAT_MAT4: - default: - _mesa_problem(NULL, "Invalid type in %s", __func__); - return; - } - - if (uni->type->is_sampler()) { - components = 1; - } else { - components = uni->type->vector_elements; - } - - bool match; - switch (uni->type->base_type) { - case GLSL_TYPE_BOOL: - match = true; - break; - case GLSL_TYPE_SAMPLER: - match = (basicType == GLSL_TYPE_INT); - break; - default: - match = (basicType == uni->type->base_type); - break; - } - - if (uni->type->is_matrix() || components != src_components || !match) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)"); - return; - } - - if (ctx->Shader.Flags & GLSL_UNIFORMS) { - log_uniform(values, basicType, components, 1, count, - false, shProg, location, uni); - } - - /* Page 100 (page 116 of the PDF) of the OpenGL 3.0 spec says: - * - * "Setting a sampler's value to i selects texture image unit number - * i. The values of i range from zero to the implementation- dependent - * maximum supported number of texture image units." - * - * In addition, table 2.3, "Summary of GL errors," on page 17 (page 33 of - * the PDF) says: - * - * "Error Description Offending command - * ignored? - * ... - * INVALID_VALUE Numeric argument out of range Yes" - * - * Based on that, when an invalid sampler is specified, we generate a - * GL_INVALID_VALUE error and ignore the command. - */ - if (uni->type->is_sampler()) { - int i; - - for (i = 0; i < count; i++) { - const unsigned texUnit = ((unsigned *) values)[i]; - - /* check that the sampler (tex unit index) is legal */ - if (texUnit >= ctx->Const.MaxCombinedTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glUniform1i(invalid sampler/tex unit index for " - "uniform %d)", - location); - return; - } - } - } - - /* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says: - * - * "When loading N elements starting at an arbitrary position k in a - * uniform declared as an array, elements k through k + N - 1 in the - * array will be replaced with the new values. Values for any array - * element that exceeds the highest array element index used, as - * reported by GetActiveUniform, will be ignored by the GL." - * - * Clamp 'count' to a valid value. Note that for non-arrays a count > 1 - * will have already generated an error. - */ - if (uni->array_elements != 0) { - if (offset >= uni->array_elements) - return; - - count = MIN2(count, (int) (uni->array_elements - offset)); - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - /* Store the data in the "actual type" backing storage for the uniform. - */ - if (!uni->type->is_boolean()) { - memcpy(&uni->storage[components * offset], values, - sizeof(uni->storage[0]) * components * count); - } else { - const union gl_constant_value *src = - (const union gl_constant_value *) values; - union gl_constant_value *dst = &uni->storage[components * offset]; - const unsigned elems = components * count; - unsigned i; - - for (i = 0; i < elems; i++) { - if (basicType == GLSL_TYPE_FLOAT) { - dst[i].i = src[i].f != 0.0f ? 1 : 0; - } else { - dst[i].i = src[i].i != 0 ? 1 : 0; - } - } - } - - uni->initialized = true; - - _mesa_propagate_uniforms_to_driver_storage(uni, offset, count); - - /* If the uniform is a sampler, do the extra magic necessary to propagate - * the changes through. - */ - if (uni->type->is_sampler()) { - int i; - - for (i = 0; i < count; i++) { - shProg->SamplerUnits[uni->sampler + offset + i] = - ((unsigned *) values)[i]; - } - - bool flushed = false; - for (i = 0; i < MESA_SHADER_TYPES; i++) { - struct gl_shader *const sh = shProg->_LinkedShaders[i]; - - /* If the shader stage doesn't use any samplers, don't bother - * checking if any samplers have changed. - */ - if (sh == NULL || sh->active_samplers == 0) - continue; - - struct gl_program *const prog = sh->Program; - - assert(sizeof(prog->SamplerUnits) == sizeof(shProg->SamplerUnits)); - - /* Determine if any of the samplers used by this shader stage have - * been modified. - */ - bool changed = false; - for (unsigned j = 0; j < Elements(prog->SamplerUnits); j++) { - if ((sh->active_samplers & (1U << j)) != 0 - && (prog->SamplerUnits[j] != shProg->SamplerUnits[j])) { - changed = true; - break; - } - } - - if (changed) { - if (!flushed) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM); - flushed = true; - } - - memcpy(prog->SamplerUnits, - shProg->SamplerUnits, - sizeof(shProg->SamplerUnits)); - - _mesa_update_shader_textures_used(shProg, prog); - } - } - } -} - -/** - * Called by glUniformMatrix*() functions. - * Note: cols=2, rows=4 ==> array[2] of vec4 - */ -extern "C" void -_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, - GLuint cols, GLuint rows, - GLint location, GLsizei count, - GLboolean transpose, const GLfloat *values) -{ - unsigned loc, offset; - unsigned vectors; - unsigned components; - unsigned elements; - struct gl_uniform_storage *uni; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (!validate_uniform_parameters(ctx, shProg, location, count, - &loc, &offset, "glUniformMatrix", false)) - return; - - uni = &shProg->UniformStorage[loc]; - if (!uni->type->is_matrix()) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(non-matrix uniform)"); - return; - } - - assert(!uni->type->is_sampler()); - vectors = uni->type->matrix_columns; - components = uni->type->vector_elements; - - /* Verify that the types are compatible. This is greatly simplified for - * matrices because they can only have a float base type. - */ - if (vectors != cols || components != rows) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniformMatrix(matrix size mismatch)"); - return; - } - - if (ctx->Shader.Flags & GLSL_UNIFORMS) { - log_uniform(values, GLSL_TYPE_FLOAT, components, vectors, count, - bool(transpose), shProg, location, uni); - } - - /* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says: - * - * "When loading N elements starting at an arbitrary position k in a - * uniform declared as an array, elements k through k + N - 1 in the - * array will be replaced with the new values. Values for any array - * element that exceeds the highest array element index used, as - * reported by GetActiveUniform, will be ignored by the GL." - * - * Clamp 'count' to a valid value. Note that for non-arrays a count > 1 - * will have already generated an error. - */ - if (uni->array_elements != 0) { - if (offset >= uni->array_elements) - return; - - count = MIN2(count, (int) (uni->array_elements - offset)); - } - - FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); - - /* Store the data in the "actual type" backing storage for the uniform. - */ - elements = components * vectors; - - if (!transpose) { - memcpy(&uni->storage[elements * offset], values, - sizeof(uni->storage[0]) * elements * count); - } else { - /* Copy and transpose the matrix. - */ - const float *src = values; - float *dst = &uni->storage[elements * offset].f; - - for (int i = 0; i < count; i++) { - for (unsigned r = 0; r < rows; r++) { - for (unsigned c = 0; c < cols; c++) { - dst[(c * components) + r] = src[c + (r * vectors)]; - } - } - - dst += elements; - src += elements; - } - } - - uni->initialized = true; - - _mesa_propagate_uniforms_to_driver_storage(uni, offset, count); -} - -/** - * Called via glGetUniformLocation(). - * - * The return value will encode two values, the uniform location and an - * offset (used for arrays, structs). - */ -extern "C" GLint -_mesa_get_uniform_location(struct gl_context *ctx, - struct gl_shader_program *shProg, - const GLchar *name) -{ - const size_t len = strlen(name); - long offset; - bool array_lookup; - char *name_copy; - - /* If the name ends with a ']', assume that it refers to some element of an - * array. Malformed array references will fail the hash table look up - * below, so it doesn't matter that they are not caught here. This code - * only wants to catch the "leaf" array references so that arrays of - * structures containing arrays will be handled correctly. - */ - if (name[len-1] == ']') { - unsigned i; - - /* Walk backwards over the string looking for a non-digit character. - * This had better be the opening bracket for an array index. - * - * Initially, i specifies the location of the ']'. Since the string may - * contain only the ']' charcater, walk backwards very carefully. - */ - for (i = len - 1; (i > 0) && isdigit(name[i-1]); --i) - /* empty */ ; - - /* Page 80 (page 94 of the PDF) of the OpenGL 2.1 spec says: - * - * "The first element of a uniform array is identified using the - * name of the uniform array appended with "[0]". Except if the last - * part of the string name indicates a uniform array, then the - * location of the first element of that array can be retrieved by - * either using the name of the uniform array, or the name of the - * uniform array appended with "[0]"." - * - * Page 79 (page 93 of the PDF) of the OpenGL 2.1 spec says: - * - * "name must be a null terminated string, without white space." - * - * Return an error if there is no opening '[' to match the closing ']'. - * An error will also be returned if there is intervening white space - * (or other non-digit characters) before the opening '['. - */ - if ((i == 0) || name[i-1] != '[') - return -1; - - /* Return an error if there are no digits between the opening '[' to - * match the closing ']'. - */ - if (i == (len - 1)) - return -1; - - /* Make a new string that is a copy of the old string up to (but not - * including) the '[' character. - */ - name_copy = (char *) malloc(i); - memcpy(name_copy, name, i - 1); - name_copy[i-1] = '\0'; - - offset = strtol(&name[i], NULL, 10); - if (offset < 0) { - free(name_copy); - return -1; - } - - array_lookup = true; - } else { - name_copy = (char *) name; - offset = 0; - array_lookup = false; - } - - unsigned location = 0; - const bool found = shProg->UniformHash->get(location, name_copy); - - assert(!found - || strcmp(name_copy, shProg->UniformStorage[location].name) == 0); - - /* Free the temporary buffer *before* possibly returning an error. - */ - if (name_copy != name) - free(name_copy); - - if (!found) - return -1; - - /* Since array_elements is 0 for non-arrays, this causes look-ups of 'a[0]' - * to (correctly) fail if 'a' is not an array. - */ - if (array_lookup && shProg->UniformStorage[location].array_elements == 0) { - return -1; - } - - return _mesa_uniform_merge_location_offset(location, offset); -} - -extern "C" bool -_mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg, - char *errMsg, size_t errMsgLength) -{ - const glsl_type *unit_types[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; - - memset(unit_types, 0, sizeof(unit_types)); - - for (unsigned i = 0; i < shProg->NumUserUniformStorage; i++) { - const struct gl_uniform_storage *const storage = - &shProg->UniformStorage[i]; - const glsl_type *const t = (storage->type->is_array()) - ? storage->type->fields.array : storage->type; - - if (!t->is_sampler()) - continue; - - const unsigned count = MAX2(1, storage->type->array_size()); - for (unsigned j = 0; j < count; j++) { - const unsigned unit = storage->storage[j].i; - - /* The types of the samplers associated with a particular texture - * unit must be an exact match. Page 74 (page 89 of the PDF) of the - * OpenGL 3.3 core spec says: - * - * "It is not allowed to have variables of different sampler - * types pointing to the same texture image unit within a program - * object." - */ - if (unit_types[unit] == NULL) { - unit_types[unit] = t; - } else if (unit_types[unit] != t) { - _mesa_snprintf(errMsg, errMsgLength, - "Texture unit %d is accessed both as %s and %s", - unit, unit_types[unit]->name, t->name); - return false; - } - } - } - - return true; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/uniforms.c b/reactos/dll/opengl/mesa/src/mesa/main/uniforms.c deleted file mode 100644 index be1e1728d30..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/uniforms.c +++ /dev/null @@ -1,580 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2004-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved. - * Copyright © 2010 Intel Corporation - * - * 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. - */ - -/** - * \file uniforms.c - * Functions related to GLSL uniform variables. - * \author Brian Paul - */ - -/** - * XXX things to do: - * 1. Check that the right error code is generated for all _mesa_error() calls. - * 2. Insert FLUSH_VERTICES calls in various places - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/dispatch.h" -#include "main/shaderapi.h" -#include "main/shaderobj.h" -#include "main/uniforms.h" -#include "ir_uniform.h" -#include "glsl_types.h" - -/** - * Update the vertex/fragment program's TexturesUsed array. - * - * This needs to be called after glUniform(set sampler var) is called. - * A call to glUniform(samplerVar, value) causes a sampler to point to a - * particular texture unit. We know the sampler's texture target - * (1D/2D/3D/etc) from compile time but the sampler's texture unit is - * set by glUniform() calls. - * - * So, scan the program->SamplerUnits[] and program->SamplerTargets[] - * information to update the prog->TexturesUsed[] values. - * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX, - * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc. - * We'll use that info for state validation before rendering. - */ -void -_mesa_update_shader_textures_used(struct gl_shader_program *shProg, - struct gl_program *prog) -{ - GLuint s; - - memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed)); - - for (s = 0; s < MAX_SAMPLERS; s++) { - if (prog->SamplersUsed & (1 << s)) { - GLuint unit = shProg->SamplerUnits[s]; - GLuint tgt = shProg->SamplerTargets[s]; - assert(unit < Elements(prog->TexturesUsed)); - assert(tgt < NUM_TEXTURE_TARGETS); - prog->TexturesUsed[unit] |= (1 << tgt); - } - } -} - -/** - * Connect a piece of driver storage with a part of a uniform - * - * \param uni The uniform with which the storage will be associated - * \param element_stride Byte-stride between array elements. - * \sa gl_uniform_driver_storage::element_stride. - * \param vector_stride Byte-stride between vectors (in a matrix). - * \sa gl_uniform_driver_storage::vector_stride. - * \param format Conversion from native format to driver format - * required by the driver. - * \param data Location to dump the data. - */ -void -_mesa_uniform_attach_driver_storage(struct gl_uniform_storage *uni, - unsigned element_stride, - unsigned vector_stride, - enum gl_uniform_driver_format format, - void *data) -{ - uni->driver_storage = (struct gl_uniform_driver_storage*) - realloc(uni->driver_storage, - sizeof(struct gl_uniform_driver_storage) - * (uni->num_driver_storage + 1)); - - uni->driver_storage[uni->num_driver_storage].element_stride = element_stride; - uni->driver_storage[uni->num_driver_storage].vector_stride = vector_stride; - uni->driver_storage[uni->num_driver_storage].format = (uint8_t) format; - uni->driver_storage[uni->num_driver_storage].data = data; - - uni->num_driver_storage++; -} - -/** - * Sever all connections with all pieces of driver storage for all uniforms - * - * \warning - * This function does \b not release any of the \c data pointers - * previously passed in to \c _mesa_uniform_attach_driver_stoarge. - */ -void -_mesa_uniform_detach_all_driver_storage(struct gl_uniform_storage *uni) -{ - free(uni->driver_storage); - uni->driver_storage = NULL; - uni->num_driver_storage = 0; -} - -void GLAPIENTRY -_mesa_Uniform1fARB(GLint location, GLfloat v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_FLOAT); -} - -void GLAPIENTRY -_mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, - GLfloat v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1iARB(GLint location, GLint v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_INT); -} - -void GLAPIENTRY -_mesa_Uniform2iARB(GLint location, GLint v0, GLint v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLint v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT); -} - -void GLAPIENTRY -_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT); -} - -void GLAPIENTRY -_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC4); -} - - -/** OpenGL 3.0 GLuint-valued functions **/ -void GLAPIENTRY -_mesa_Uniform1ui(GLint location, GLuint v0) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT); -} - -void GLAPIENTRY -_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[2]; - v[0] = v0; - v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[3]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint v[4]; - v[0] = v0; - v[1] = v1; - v[2] = v2; - v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); -} - -void GLAPIENTRY -_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT); -} - -void GLAPIENTRY -_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2); -} - -void GLAPIENTRY -_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3); -} - -void GLAPIENTRY -_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4); -} - - - -void GLAPIENTRY -_mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 2, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 3, 3, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, - const GLfloat * value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 4, 4, location, count, transpose, value); -} - - -/** - * Non-square UniformMatrix are OpenGL 2.1 - */ -void GLAPIENTRY -_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 2, 3, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 3, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 2, 4, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 4, 2, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 3, 4, location, count, transpose, value); -} - -void GLAPIENTRY -_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, - 4, 3, location, count, transpose, value); -} - - -void GLAPIENTRY -_mesa_GetnUniformfvARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_FLOAT, params); -} - -void GLAPIENTRY -_mesa_GetUniformfvARB(GLhandleARB program, GLint location, GLfloat *params) -{ - _mesa_GetnUniformfvARB(program, location, INT_MAX, params); -} - - -void GLAPIENTRY -_mesa_GetnUniformivARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_INT, params); -} - -void GLAPIENTRY -_mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint *params) -{ - _mesa_GetnUniformivARB(program, location, INT_MAX, params); -} - - -/* GL3 */ -void GLAPIENTRY -_mesa_GetnUniformuivARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_UINT, params); -} - -void GLAPIENTRY -_mesa_GetUniformuiv(GLhandleARB program, GLint location, GLuint *params) -{ - _mesa_GetnUniformuivARB(program, location, INT_MAX, params); -} - - -/* GL4 */ -void GLAPIENTRY -_mesa_GetnUniformdvARB(GLhandleARB program, GLint location, - GLsizei bufSize, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - - (void) program; - (void) location; - (void) bufSize; - (void) params; - - /* - _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_DOUBLE, params); - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformdvARB" - "(GL_ARB_gpu_shader_fp64 not implemented)"); -} - -void GLAPIENTRY -_mesa_GetUniformdv(GLhandleARB program, GLint location, GLdouble *params) -{ - _mesa_GetnUniformdvARB(program, location, INT_MAX, params); -} - - -GLint GLAPIENTRY -_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) -{ - struct gl_shader_program *shProg; - - GET_CURRENT_CONTEXT(ctx); - - shProg = _mesa_lookup_shader_program_err(ctx, programObj, - "glGetUniformLocation"); - if (!shProg) - return -1; - - /* Page 80 (page 94 of the PDF) of the OpenGL 2.1 spec says: - * - * "If program has not been successfully linked, the error - * INVALID_OPERATION is generated." - */ - if (shProg->LinkStatus == GL_FALSE) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetUniformLocation(program not linked)"); - return -1; - } - - return _mesa_get_uniform_location(ctx, shProg, name); -} - - -/** - * Plug in shader uniform-related functions into API dispatch table. - */ -void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec) -{ -#if FEATURE_GL - SET_Uniform1fARB(exec, _mesa_Uniform1fARB); - SET_Uniform2fARB(exec, _mesa_Uniform2fARB); - SET_Uniform3fARB(exec, _mesa_Uniform3fARB); - SET_Uniform4fARB(exec, _mesa_Uniform4fARB); - SET_Uniform1iARB(exec, _mesa_Uniform1iARB); - SET_Uniform2iARB(exec, _mesa_Uniform2iARB); - SET_Uniform3iARB(exec, _mesa_Uniform3iARB); - SET_Uniform4iARB(exec, _mesa_Uniform4iARB); - SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB); - SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB); - SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB); - SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB); - SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB); - SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB); - SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB); - SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB); - SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB); - SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB); - SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB); - - SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB); - SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB); - SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB); - SET_GetUniformivARB(exec, _mesa_GetUniformivARB); - - /* OpenGL 2.1 */ - SET_UniformMatrix2x3fv(exec, _mesa_UniformMatrix2x3fv); - SET_UniformMatrix3x2fv(exec, _mesa_UniformMatrix3x2fv); - SET_UniformMatrix2x4fv(exec, _mesa_UniformMatrix2x4fv); - SET_UniformMatrix4x2fv(exec, _mesa_UniformMatrix4x2fv); - SET_UniformMatrix3x4fv(exec, _mesa_UniformMatrix3x4fv); - SET_UniformMatrix4x3fv(exec, _mesa_UniformMatrix4x3fv); - - /* OpenGL 3.0 */ - SET_Uniform1uiEXT(exec, _mesa_Uniform1ui); - SET_Uniform2uiEXT(exec, _mesa_Uniform2ui); - SET_Uniform3uiEXT(exec, _mesa_Uniform3ui); - SET_Uniform4uiEXT(exec, _mesa_Uniform4ui); - SET_Uniform1uivEXT(exec, _mesa_Uniform1uiv); - SET_Uniform2uivEXT(exec, _mesa_Uniform2uiv); - SET_Uniform3uivEXT(exec, _mesa_Uniform3uiv); - SET_Uniform4uivEXT(exec, _mesa_Uniform4uiv); - SET_GetUniformuivEXT(exec, _mesa_GetUniformuiv); - - /* GL_ARB_robustness */ - SET_GetnUniformfvARB(exec, _mesa_GetnUniformfvARB); - SET_GetnUniformivARB(exec, _mesa_GetnUniformivARB); - SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB); - SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */ - -#endif /* FEATURE_GL */ -} diff --git a/reactos/dll/opengl/mesa/src/mesa/main/uniforms.h b/reactos/dll/opengl/mesa/src/mesa/main/uniforms.h deleted file mode 100644 index 7b512a52759..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/main/uniforms.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 2010 VMware, Inc. 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 - * THE AUTHORS 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 UNIFORMS_H -#define UNIFORMS_H - -#include "glheader.h" -#include "program/prog_parameter.h" -#include "../glsl/glsl_types.h" -#include "../glsl/ir_uniform.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -struct gl_program; -struct _glapi_table; - -extern void GLAPIENTRY -_mesa_Uniform1fARB(GLint, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform2fARB(GLint, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform3fARB(GLint, GLfloat, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform4fARB(GLint, GLfloat, GLfloat, GLfloat, GLfloat); - -extern void GLAPIENTRY -_mesa_Uniform1iARB(GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform2iARB(GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform3iARB(GLint, GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform4iARB(GLint, GLint, GLint, GLint, GLint); - -extern void GLAPIENTRY -_mesa_Uniform1fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform2fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform3fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform4fvARB(GLint, GLsizei, const GLfloat *); - -extern void GLAPIENTRY -_mesa_Uniform1ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform2ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform3ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform4ivARB(GLint, GLsizei, const GLint *); - -extern void GLAPIENTRY -_mesa_Uniform1ui(GLint location, GLuint v0); - -extern void GLAPIENTRY -_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1); - -extern void GLAPIENTRY -_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); - -extern void GLAPIENTRY -_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); - -extern void GLAPIENTRY -_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value); - -extern void GLAPIENTRY -_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value); - - -extern void GLAPIENTRY -_mesa_UniformMatrix2fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix3fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix4fvARB(GLint, GLsizei, GLboolean, const GLfloat *); - -extern void GLAPIENTRY -_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - -extern void GLAPIENTRY -_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); - - -extern void GLAPIENTRY -_mesa_GetActiveUniformARB(GLhandleARB, GLuint, GLsizei, GLsizei *, - GLint *, GLenum *, GLcharARB *); - -extern void GLAPIENTRY -_mesa_GetUniformfvARB(GLhandleARB, GLint, GLfloat *); - -extern void GLAPIENTRY -_mesa_GetnUniformfvARB(GLhandleARB, GLint, GLsizei, GLfloat *); - -extern void GLAPIENTRY -_mesa_GetUniformivARB(GLhandleARB, GLint, GLint *); - -extern void GLAPIENTRY -_mesa_GetnUniformivARB(GLhandleARB, GLint, GLsizei, GLint *); - -extern void GLAPIENTRY -_mesa_GetUniformuiv(GLhandleARB, GLint, GLuint *); - -extern void GLAPIENTRY -_mesa_GetnUniformuivARB(GLhandleARB, GLint, GLsizei, GLuint *); - -extern void GLAPIENTRY -_mesa_GetUniformdv(GLhandleARB, GLint, GLdouble *); - -extern void GLAPIENTRY -_mesa_GetnUniformdvARB(GLhandleARB, GLint, GLsizei, GLdouble *); - -extern GLint GLAPIENTRY -_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *); - -GLint -_mesa_get_uniform_location(struct gl_context *ctx, struct gl_shader_program *shProg, - const GLchar *name); - -void -_mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shader_program, - GLint location, GLsizei count, - const GLvoid *values, GLenum type); - -void -_mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, - GLuint cols, GLuint rows, - GLint location, GLsizei count, - GLboolean transpose, const GLfloat *values); - -void -_mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, - GLsizei bufSize, enum glsl_base_type returnType, - GLvoid *paramsOut); - -extern void -_mesa_uniform_attach_driver_storage(struct gl_uniform_storage *, - unsigned element_stride, - unsigned vector_stride, - enum gl_uniform_driver_format format, - void *data); - -extern void -_mesa_uniform_detach_all_driver_storage(struct gl_uniform_storage *uni); - -extern void -_mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni, - unsigned array_index, - unsigned count); - -extern void -_mesa_update_shader_textures_used(struct gl_shader_program *shProg, - struct gl_program *prog); - -extern bool -_mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg, - char *errMsg, size_t errMsgLength); - -extern void -_mesa_init_shader_uniform_dispatch(struct _glapi_table *exec); - -extern const struct gl_program_parameter * -get_uniform_parameter(struct gl_shader_program *shProg, GLint index); - -struct gl_builtin_uniform_element { - const char *field; - int tokens[STATE_LENGTH]; - int swizzle; -}; - -struct gl_builtin_uniform_desc { - const char *name; - struct gl_builtin_uniform_element *elements; - unsigned int num_elements; -}; - -extern const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[]; - -/** - * \name GLSL uniform arrays and structs require special handling. - * - * The GL_ARB_shader_objects spec says that if you use - * glGetUniformLocation to get the location of an array, you CANNOT - * access other elements of the array by adding an offset to the - * returned location. For example, you must call - * glGetUniformLocation("foo[16]") if you want to set the 16th element - * of the array with glUniform(). - * - * HOWEVER, some other OpenGL drivers allow accessing array elements - * by adding an offset to the returned array location. And some apps - * seem to depend on that behaviour. - * - * Mesa's gl_uniform_list doesn't directly support this since each - * entry in the list describes one uniform variable, not one uniform - * element. We could insert dummy entries in the list for each array - * element after [0] but that causes complications elsewhere. - * - * We solve this problem by encoding two values in the location that's - * returned by glGetUniformLocation(): - * a) index into gl_uniform_list::Uniforms[] for the uniform - * b) an array/field offset (0 for simple types) - * - * These two values are encoded in the high and low halves of a GLint. - * By putting the uniform number in the high part and the offset in the - * low part, we can support the unofficial ability to index into arrays - * by adding offsets to the location value. - */ -/*@{*/ -/** - * Combine the uniform's base location and the offset - */ -static inline GLint -_mesa_uniform_merge_location_offset(unsigned base_location, unsigned offset) -{ - return (base_location << 16) | offset; -} - -/** - * Separate the uniform base location and parameter offset - */ -static inline void -_mesa_uniform_split_location_offset(GLint location, unsigned *base_location, - unsigned *offset) -{ - *offset = location & 0xffff; - *base_location = location >> 16; -} -/*@}*/ - - -#ifdef __cplusplus -} -#endif - - -#endif /* UNIFORMS_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/varray.c b/reactos/dll/opengl/mesa/src/mesa/main/varray.c index 0ae8607e401..74c72432408 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/varray.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/varray.c @@ -262,10 +262,9 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, GLbitfield legalTypes = (SHORT_BIT | INT_BIT | HALF_BIT | FLOAT_BIT | DOUBLE_BIT); GET_CURRENT_CONTEXT(ctx); - const GLuint unit = ctx->Array.ActiveTexture; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX(unit), + update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX, legalTypes, 1, 4, size, type, stride, GL_FALSE, GL_FALSE, ptr); @@ -286,346 +285,6 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, integer, ptr); } - -#if FEATURE_NV_vertex_program -/** - * Set a vertex attribute array. - * Note that these arrays DO alias the conventional GL vertex arrays - * (position, normal, color, fog, texcoord, etc). - * The generic attribute slots at #16 and above are not touched. - */ -void GLAPIENTRY -_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) -{ - const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | - FLOAT_BIT | DOUBLE_BIT); - GLboolean normalized = GL_FALSE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); - return; - } - - if (type == GL_UNSIGNED_BYTE && size != 4) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); - return; - } - - update_array(ctx, "glVertexAttribPointerNV", VERT_ATTRIB_GENERIC(index), - legalTypes, 1, 4, - size, type, stride, normalized, GL_FALSE, ptr); -} -#endif - - -#if FEATURE_ARB_vertex_program -/** - * Set a generic vertex attribute array. - * Note that these arrays DO NOT alias the conventional GL vertex arrays - * (position, normal, color, fog, texcoord, etc). - */ -void GLAPIENTRY -_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, - GLboolean normalized, - GLsizei stride, const GLvoid *ptr) -{ - const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | - SHORT_BIT | UNSIGNED_SHORT_BIT | - INT_BIT | UNSIGNED_INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT); - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); - return; - } - - update_array(ctx, "glVertexAttribPointer", VERT_ATTRIB_GENERIC(index), - legalTypes, 1, 4, - size, type, stride, normalized, GL_FALSE, ptr); -} -#endif - - -/** - * GL_EXT_gpu_shader4 / GL 3.0. - * Set an integer-valued vertex attribute array. - * Note that these arrays DO NOT alias the conventional GL vertex arrays - * (position, normal, color, fog, texcoord, etc). - */ -void GLAPIENTRY -_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr) -{ - const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | - SHORT_BIT | UNSIGNED_SHORT_BIT | - INT_BIT | UNSIGNED_INT_BIT); - const GLboolean normalized = GL_FALSE; - const GLboolean integer = GL_TRUE; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(index)"); - return; - } - - update_array(ctx, "glVertexAttribIPointer", VERT_ATTRIB_GENERIC(index), - legalTypes, 1, 4, - size, type, stride, normalized, integer, ptr); -} - - - -void GLAPIENTRY -_mesa_EnableVertexAttribArrayARB(GLuint index) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glEnableVertexAttribArrayARB(index)"); - return; - } - - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE; - ctx->Array.ArrayObj->_Enabled |= VERT_BIT_GENERIC(index); - ctx->Array.NewState |= VERT_BIT_GENERIC(index); -} - - -void GLAPIENTRY -_mesa_DisableVertexAttribArrayARB(GLuint index) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glDisableVertexAttribArrayARB(index)"); - return; - } - - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - FLUSH_VERTICES(ctx, _NEW_ARRAY); - ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE; - ctx->Array.ArrayObj->_Enabled &= ~VERT_BIT_GENERIC(index); - ctx->Array.NewState |= VERT_BIT_GENERIC(index); -} - - -/** - * Return info for a vertex attribute array (no alias with legacy - * vertex attributes (pos, normal, color, etc)). This function does - * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query. - */ -static GLuint -get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname, - const char *caller) -{ - const struct gl_client_array *array; - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index); - return 0; - } - - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; - - switch (pname) { - case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB: - return array->Enabled; - case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB: - return array->Size; - case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB: - return array->Stride; - case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB: - return array->Type; - case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB: - return array->Normalized; - case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: - return array->BufferObj->Name; - case GL_VERTEX_ATTRIB_ARRAY_INTEGER: - if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_gpu_shader4) { - return array->Integer; - } - goto error; - default: - ; /* fall-through */ - } - -error: - _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", caller, pname); - return 0; -} - - -static const GLfloat * -get_current_attrib(struct gl_context *ctx, GLuint index, const char *function) -{ - if (index == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(index==0)", function); - return NULL; - } - else if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, - "%s(index>=GL_MAX_VERTEX_ATTRIBS)", function); - return NULL; - } - - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - FLUSH_CURRENT(ctx, 0); - return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)]; -} - -void GLAPIENTRY -_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribfv"); - if (v != NULL) { - COPY_4V(params, v); - } - } - else { - params[0] = (GLfloat) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribfv"); - } -} - - -void GLAPIENTRY -_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribdv"); - if (v != NULL) { - params[0] = (GLdouble) v[0]; - params[1] = (GLdouble) v[1]; - params[2] = (GLdouble) v[2]; - params[3] = (GLdouble) v[3]; - } - } - else { - params[0] = (GLdouble) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribdv"); - } -} - - -void GLAPIENTRY -_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - const GLfloat *v = get_current_attrib(ctx, index, "glGetVertexAttribiv"); - if (v != NULL) { - /* XXX should floats in[0,1] be scaled to full int range? */ - params[0] = (GLint) v[0]; - params[1] = (GLint) v[1]; - params[2] = (GLint) v[2]; - params[3] = (GLint) v[3]; - } - } - else { - params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribiv"); - } -} - - -/** GL 3.0 */ -void GLAPIENTRY -_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - const GLfloat *v = - get_current_attrib(ctx, index, "glGetVertexAttribIiv"); - if (v != NULL) { - /* XXX we don't have true integer-valued vertex attribs yet */ - params[0] = (GLint) v[0]; - params[1] = (GLint) v[1]; - params[2] = (GLint) v[2]; - params[3] = (GLint) v[3]; - } - } - else { - params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribIiv"); - } -} - - -/** GL 3.0 */ -void GLAPIENTRY -_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { - const GLfloat *v = - get_current_attrib(ctx, index, "glGetVertexAttribIuiv"); - if (v != NULL) { - /* XXX we don't have true integer-valued vertex attribs yet */ - params[0] = (GLuint) v[0]; - params[1] = (GLuint) v[1]; - params[2] = (GLuint) v[2]; - params[3] = (GLuint) v[3]; - } - } - else { - params[0] = get_vertex_array_attrib(ctx, index, pname, - "glGetVertexAttribIuiv"); - } -} - - -void GLAPIENTRY -_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer) -{ - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - - if (index >= ctx->Const.VertexProgram.MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)"); - return; - } - - if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerARB(pname)"); - return; - } - - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib)); - - *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr; -} - - void GLAPIENTRY _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr) @@ -1016,7 +675,6 @@ void _mesa_print_arrays(struct gl_context *ctx) { struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint i; _mesa_update_array_object_max_element(ctx, arrayObj); @@ -1027,12 +685,8 @@ _mesa_print_arrays(struct gl_context *ctx) print_array("Normal", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) print_array("Color", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) - if (arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled) - print_array("TexCoord", i, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]); - for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) - if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) - print_array("Attrib", i, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]); + if (arrayObj->VertexAttrib[VERT_ATTRIB_TEX].Enabled) + print_array("TexCoord", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX]); printf(" _MaxElement = %u\n", arrayObj->_MaxElement); } @@ -1046,7 +700,6 @@ _mesa_init_varray(struct gl_context *ctx) ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0); _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, ctx->Array.DefaultArrayObj); - ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */ ctx->Array.Objects = _mesa_NewHashTable(); } diff --git a/reactos/dll/opengl/mesa/src/mesa/main/varray.h b/reactos/dll/opengl/mesa/src/mesa/main/varray.h index 523151c7633..f2fc41fa516 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/varray.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/varray.h @@ -137,53 +137,6 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); -extern void GLAPIENTRY -_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *pointer); - - -extern void GLAPIENTRY -_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, - GLboolean normalized, GLsizei stride, - const GLvoid *pointer); - -void GLAPIENTRY -_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr); - - -extern void GLAPIENTRY -_mesa_EnableVertexAttribArrayARB(GLuint index); - - -extern void GLAPIENTRY -_mesa_DisableVertexAttribArrayARB(GLuint index); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params); - - -extern void GLAPIENTRY -_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer); - - extern void GLAPIENTRY _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); @@ -192,10 +145,6 @@ extern void GLAPIENTRY _mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount ); -extern void GLAPIENTRY -_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount ); - extern void GLAPIENTRY _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, const GLsizei * count, diff --git a/reactos/dll/opengl/mesa/src/mesa/main/version.c b/reactos/dll/opengl/mesa/src/mesa/main/version.c index ad4584ff042..531814e9081 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/version.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/version.c @@ -51,30 +51,6 @@ override_version(struct gl_context *ctx, GLuint *major, GLuint *minor) } } -/** - * Override the context's GLSL version if the environment variable - * MESA_GLSL_VERSION_OVERRIDE is set. Valid values for - * MESA_GLSL_VERSION_OVERRIDE are integers, such as "130". - */ -void -_mesa_override_glsl_version(struct gl_context *ctx) -{ - const char *env_var = "MESA_GLSL_VERSION_OVERRIDE"; - const char *version; - int n; - - version = getenv(env_var); - if (!version) { - return; - } - - n = sscanf(version, "%u", &ctx->Const.GLSLVersion); - if (n != 1) { - fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version); - return; - } -} - /** * Examine enabled GL extensions to determine GL version. * Return major and minor version numbers. @@ -102,9 +78,6 @@ compute_version(struct gl_context *ctx) ctx->Extensions.EXT_shadow_funcs); const GLboolean ver_2_0 = (ver_1_5 && ctx->Extensions.ARB_point_sprite && - ctx->Extensions.ARB_shader_objects && - ctx->Extensions.ARB_vertex_shader && - ctx->Extensions.ARB_fragment_shader && ctx->Extensions.ARB_texture_non_power_of_two && ctx->Extensions.EXT_blend_equation_separate && @@ -117,14 +90,11 @@ compute_version(struct gl_context *ctx) (ctx->Extensions.EXT_stencil_two_side || ctx->Extensions.ATI_separate_stencil)); const GLboolean ver_2_1 = (ver_2_0 && - ctx->Const.GLSLVersion >= 120 && ctx->Extensions.EXT_pixel_buffer_object); const GLboolean ver_3_0 = (ver_2_1 && - ctx->Const.GLSLVersion >= 130 && ctx->Extensions.ARB_half_float_pixel && ctx->Extensions.ARB_half_float_vertex && ctx->Extensions.ARB_map_buffer_range && - ctx->Extensions.ARB_shader_texture_lod && ctx->Extensions.ARB_texture_float && ctx->Extensions.APPLE_vertex_array_object); diff --git a/reactos/dll/opengl/mesa/src/mesa/main/version.h b/reactos/dll/opengl/mesa/src/mesa/main/version.h index 6afeff4ea83..a34cc52000a 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/version.h +++ b/reactos/dll/opengl/mesa/src/mesa/main/version.h @@ -45,7 +45,4 @@ struct gl_context; extern void _mesa_compute_version(struct gl_context *ctx); -extern void -_mesa_override_glsl_version(struct gl_context *ctx); - #endif /* VERSION_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/main/vtxfmt.c b/reactos/dll/opengl/mesa/src/mesa/main/vtxfmt.c index 0c63bc3975d..ba3bf93d3c4 100644 --- a/reactos/dll/opengl/mesa/src/mesa/main/vtxfmt.c +++ b/reactos/dll/opengl/mesa/src/mesa/main/vtxfmt.c @@ -62,14 +62,6 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) SET_Indexf(tab, vfmt->Indexf); SET_Indexfv(tab, vfmt->Indexfv); SET_Materialfv(tab, vfmt->Materialfv); - SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB); - SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB); - SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB); - SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB); - SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB); - SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB); - SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB); - SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB); SET_Normal3f(tab, vfmt->Normal3f); SET_Normal3fv(tab, vfmt->Normal3fv); SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT); @@ -99,7 +91,6 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) SET_DrawArrays(tab, vfmt->DrawArrays); SET_DrawElements(tab, vfmt->DrawElements); SET_DrawRangeElements(tab, vfmt->DrawRangeElements); - SET_MultiDrawElementsEXT(tab, vfmt->MultiDrawElementsEXT); /* GL_NV_vertex_program */ SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); @@ -110,33 +101,6 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt ) SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV); SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV); SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV); -#if FEATURE_ARB_vertex_program - SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB); - SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB); - SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB); - SET_VertexAttrib2fvARB(tab, vfmt->VertexAttrib2fvARB); - SET_VertexAttrib3fARB(tab, vfmt->VertexAttrib3fARB); - SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB); - SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB); - SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB); -#endif - - /* GL_EXT_gpu_shader4 / OpenGL 3.0 */ - SET_VertexAttribI1iEXT(tab, vfmt->VertexAttribI1i); - SET_VertexAttribI2iEXT(tab, vfmt->VertexAttribI2i); - SET_VertexAttribI3iEXT(tab, vfmt->VertexAttribI3i); - SET_VertexAttribI4iEXT(tab, vfmt->VertexAttribI4i); - SET_VertexAttribI2ivEXT(tab, vfmt->VertexAttribI2iv); - SET_VertexAttribI3ivEXT(tab, vfmt->VertexAttribI3iv); - SET_VertexAttribI4ivEXT(tab, vfmt->VertexAttribI4iv); - - SET_VertexAttribI1uiEXT(tab, vfmt->VertexAttribI1ui); - SET_VertexAttribI2uiEXT(tab, vfmt->VertexAttribI2ui); - SET_VertexAttribI3uiEXT(tab, vfmt->VertexAttribI3ui); - SET_VertexAttribI4uiEXT(tab, vfmt->VertexAttribI4ui); - SET_VertexAttribI2uivEXT(tab, vfmt->VertexAttribI2uiv); - SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv); - SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv); } diff --git a/reactos/dll/opengl/mesa/src/mesa/program/CMakeLists.txt b/reactos/dll/opengl/mesa/src/mesa/program/CMakeLists.txt deleted file mode 100644 index 6d9334dfe40..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ - -list(APPEND SOURCE - ../../../generated/mesa/program/lex.yy.c - ../../../generated/mesa/program/program_parse.tab.c - arbprogparse.c - hash_table.c - ir_to_mesa.cpp - # nvfragparse.c - # nvvertparse.c - program.c - program_parse_extra.c - prog_cache.c - prog_execute.c - prog_instruction.c - prog_noise.c - prog_optimize.c - prog_opt_constant_fold.c - prog_parameter.c - prog_parameter_layout.c - prog_print.c - prog_statevars.c - programopt.c - sampler.cpp - symbol_table.c - string_to_uint_map.cpp -) - -if(NOT MSVC) - add_compile_flags("-Wno-format") -endif() - -add_library(mesa_program STATIC ${SOURCE}) \ No newline at end of file diff --git a/reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.c b/reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.c deleted file mode 100644 index 2f6b8db5d62..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 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. - */ - -#define DEBUG_PARSING 0 - -/** - * \file arbprogparse.c - * ARB_*_program parser core - * \author Karl Rasche - */ - -/** -Notes on program parameters, etc. - -The instructions we emit will use six kinds of source registers: - - PROGRAM_INPUT - input registers - PROGRAM_TEMPORARY - temp registers - PROGRAM_ADDRESS - address/indirect register - PROGRAM_SAMPLER - texture sampler - PROGRAM_CONSTANT - indexes into program->Parameters, a known constant/literal - PROGRAM_STATE_VAR - indexes into program->Parameters, and may actually be: - + a state variable, like "state.fog.color", or - + a pointer to a "program.local[k]" parameter, or - + a pointer to a "program.env[k]" parameter - -Basically, all the program.local[] and program.env[] values will get mapped -into the unified gl_program->Parameters array. This solves the problem of -having three separate program parameter arrays. -*/ - - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/context.h" -#include "main/mtypes.h" -#include "arbprogparse.h" -#include "programopt.h" -#include "prog_parameter.h" -#include "prog_statevars.h" -#include "prog_instruction.h" -#include "program_parser.h" - - -void -_mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, - const GLvoid *str, GLsizei len, - struct gl_fragment_program *program) -{ - struct gl_program prog; - struct asm_parser_state state; - GLuint i; - - ASSERT(target == GL_FRAGMENT_PROGRAM_ARB); - - memset(&prog, 0, sizeof(prog)); - memset(&state, 0, sizeof(state)); - state.prog = &prog; - - if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, - &state)) { - /* Error in the program. Just return. */ - return; - } - - if (program->Base.String != NULL) - free(program->Base.String); - - /* Copy the relevant contents of the arb_program struct into the - * fragment_program struct. - */ - program->Base.String = prog.String; - program->Base.NumInstructions = prog.NumInstructions; - program->Base.NumTemporaries = prog.NumTemporaries; - program->Base.NumParameters = prog.NumParameters; - program->Base.NumAttributes = prog.NumAttributes; - program->Base.NumAddressRegs = prog.NumAddressRegs; - program->Base.NumNativeInstructions = prog.NumNativeInstructions; - program->Base.NumNativeTemporaries = prog.NumNativeTemporaries; - program->Base.NumNativeParameters = prog.NumNativeParameters; - program->Base.NumNativeAttributes = prog.NumNativeAttributes; - program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs; - program->Base.NumAluInstructions = prog.NumAluInstructions; - program->Base.NumTexInstructions = prog.NumTexInstructions; - program->Base.NumTexIndirections = prog.NumTexIndirections; - program->Base.NumNativeAluInstructions = prog.NumAluInstructions; - program->Base.NumNativeTexInstructions = prog.NumTexInstructions; - program->Base.NumNativeTexIndirections = prog.NumTexIndirections; - program->Base.InputsRead = prog.InputsRead; - program->Base.OutputsWritten = prog.OutputsWritten; - program->Base.IndirectRegisterFiles = prog.IndirectRegisterFiles; - for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) { - program->Base.TexturesUsed[i] = prog.TexturesUsed[i]; - if (prog.TexturesUsed[i]) - program->Base.SamplersUsed |= (1 << i); - } - program->Base.ShadowSamplers = prog.ShadowSamplers; - - program->UsesKill = state.fragment.UsesKill; - - if (program->Base.Instructions) - free(program->Base.Instructions); - program->Base.Instructions = prog.Instructions; - - if (program->Base.Parameters) - _mesa_free_parameter_list(program->Base.Parameters); - program->Base.Parameters = prog.Parameters; - - /* Append fog instructions now if the program has "OPTION ARB_fog_exp" - * or similar. We used to leave this up to drivers, but it appears - * there's no hardware that wants to do fog in a discrete stage separate - * from the fragment shader. - */ - if (state.option.Fog != OPTION_NONE) { - static const GLenum fog_modes[4] = { - GL_NONE, GL_EXP, GL_EXP2, GL_LINEAR - }; - - /* XXX: we should somehow recompile this to remove clamping if disabled - * On the ATI driver, this is unclampled if fragment clamping is disabled - */ - _mesa_append_fog_code(ctx, program, fog_modes[state.option.Fog], GL_TRUE); - } - -#if DEBUG_FP - printf("____________Fragment program %u ________\n", program->Base.Id); - _mesa_print_program(&program->Base); -#endif -} - - - -/** - * Parse the vertex program string. If success, update the given - * vertex_program object with the new program. Else, leave the vertex_program - * object unchanged. - */ -void -_mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, - const GLvoid *str, GLsizei len, - struct gl_vertex_program *program) -{ - struct gl_program prog; - struct asm_parser_state state; - - ASSERT(target == GL_VERTEX_PROGRAM_ARB); - - memset(&prog, 0, sizeof(prog)); - memset(&state, 0, sizeof(state)); - state.prog = &prog; - - if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, - &state)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramString(bad program)"); - return; - } - - if (program->Base.String != NULL) - free(program->Base.String); - - /* Copy the relevant contents of the arb_program struct into the - * vertex_program struct. - */ - program->Base.String = prog.String; - program->Base.NumInstructions = prog.NumInstructions; - program->Base.NumTemporaries = prog.NumTemporaries; - program->Base.NumParameters = prog.NumParameters; - program->Base.NumAttributes = prog.NumAttributes; - program->Base.NumAddressRegs = prog.NumAddressRegs; - program->Base.NumNativeInstructions = prog.NumNativeInstructions; - program->Base.NumNativeTemporaries = prog.NumNativeTemporaries; - program->Base.NumNativeParameters = prog.NumNativeParameters; - program->Base.NumNativeAttributes = prog.NumNativeAttributes; - program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs; - program->Base.InputsRead = prog.InputsRead; - program->Base.OutputsWritten = prog.OutputsWritten; - program->Base.IndirectRegisterFiles = prog.IndirectRegisterFiles; - program->IsPositionInvariant = (state.option.PositionInvariant) - ? GL_TRUE : GL_FALSE; - - if (program->Base.Instructions) - free(program->Base.Instructions); - program->Base.Instructions = prog.Instructions; - - if (program->Base.Parameters) - _mesa_free_parameter_list(program->Base.Parameters); - program->Base.Parameters = prog.Parameters; - -#if DEBUG_VP - printf("____________Vertex program %u __________\n", program->Base.Id); - _mesa_print_program(&program->Base); -#endif -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.h b/reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.h deleted file mode 100644 index 4c0c3007205..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/arbprogparse.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 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 ARBPROGPARSE_H -#define ARBPROGPARSE_H - -#include "main/glheader.h" - -struct gl_context; -struct gl_fragment_program; -struct gl_vertex_program; - -extern void -_mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, - const GLvoid *str, GLsizei len, - struct gl_vertex_program *program); - -extern void -_mesa_parse_arb_fragment_program(struct gl_context *ctx, GLenum target, - const GLvoid *str, GLsizei len, - struct gl_fragment_program *program); - -#endif diff --git a/reactos/dll/opengl/mesa/src/mesa/program/hash_table.c b/reactos/dll/opengl/mesa/src/mesa/program/hash_table.c deleted file mode 100644 index dc8563a330f..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/hash_table.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file hash_table.c - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#include "main/imports.h" -#include "main/simple_list.h" -#include "hash_table.h" - -struct node { - struct node *next; - struct node *prev; -}; - -struct hash_table { - hash_func_t hash; - hash_compare_func_t compare; - - unsigned num_buckets; - struct node buckets[1]; -}; - - -struct hash_node { - struct node link; - const void *key; - void *data; -}; - - -struct hash_table * -hash_table_ctor(unsigned num_buckets, hash_func_t hash, - hash_compare_func_t compare) -{ - struct hash_table *ht; - unsigned i; - - - if (num_buckets < 16) { - num_buckets = 16; - } - - ht = malloc(sizeof(*ht) + ((num_buckets - 1) - * sizeof(ht->buckets[0]))); - if (ht != NULL) { - ht->hash = hash; - ht->compare = compare; - ht->num_buckets = num_buckets; - - for (i = 0; i < num_buckets; i++) { - make_empty_list(& ht->buckets[i]); - } - } - - return ht; -} - - -void -hash_table_dtor(struct hash_table *ht) -{ - hash_table_clear(ht); - free(ht); -} - - -void -hash_table_clear(struct hash_table *ht) -{ - struct node *node; - struct node *temp; - unsigned i; - - - for (i = 0; i < ht->num_buckets; i++) { - foreach_s(node, temp, & ht->buckets[i]) { - remove_from_list(node); - free(node); - } - - assert(is_empty_list(& ht->buckets[i])); - } -} - - -static struct hash_node * -get_node(struct hash_table *ht, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct node *node; - - foreach(node, & ht->buckets[bucket]) { - struct hash_node *hn = (struct hash_node *) node; - - if ((*ht->compare)(hn->key, key) == 0) { - return hn; - } - } - - return NULL; -} - -void * -hash_table_find(struct hash_table *ht, const void *key) -{ - struct hash_node *hn = get_node(ht, key); - - return (hn == NULL) ? NULL : hn->data; -} - -void -hash_table_insert(struct hash_table *ht, void *data, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct hash_node *node; - - node = calloc(1, sizeof(*node)); - - node->data = data; - node->key = key; - - insert_at_head(& ht->buckets[bucket], & node->link); -} - -void -hash_table_replace(struct hash_table *ht, void *data, const void *key) -{ - const unsigned hash_value = (*ht->hash)(key); - const unsigned bucket = hash_value % ht->num_buckets; - struct node *node; - struct hash_node *hn; - - foreach(node, & ht->buckets[bucket]) { - hn = (struct hash_node *) node; - - if ((*ht->compare)(hn->key, key) == 0) { - hn->data = data; - return; - } - } - - hn = calloc(1, sizeof(*hn)); - - hn->data = data; - hn->key = key; - - insert_at_head(& ht->buckets[bucket], & hn->link); -} - -void -hash_table_remove(struct hash_table *ht, const void *key) -{ - struct node *node = (struct node *) get_node(ht, key); - if (node != NULL) { - remove_from_list(node); - free(node); - return; - } -} - -void -hash_table_call_foreach(struct hash_table *ht, - void (*callback)(const void *key, - void *data, - void *closure), - void *closure) -{ - int bucket; - - for (bucket = 0; bucket < ht->num_buckets; bucket++) { - struct node *node, *temp; - foreach_s(node, temp, &ht->buckets[bucket]) { - struct hash_node *hn = (struct hash_node *) node; - - callback(hn->key, hn->data, closure); - } - } -} - -unsigned -hash_table_string_hash(const void *key) -{ - const char *str = (const char *) key; - unsigned hash = 5381; - - - while (*str != '\0') { - hash = (hash * 33) + *str; - str++; - } - - return hash; -} - - -unsigned -hash_table_pointer_hash(const void *key) -{ - return (unsigned)((uintptr_t) key / sizeof(void *)); -} - - -int -hash_table_pointer_compare(const void *key1, const void *key2) -{ - return key1 == key2 ? 0 : 1; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/hash_table.h b/reactos/dll/opengl/mesa/src/mesa/program/hash_table.h deleted file mode 100644 index bcf65df7d89..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/hash_table.h +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file hash_table.h - * \brief Implementation of a generic, opaque hash table data type. - * - * \author Ian Romanick - */ - -#ifndef HASH_TABLE_H -#define HASH_TABLE_H - -#include -#include -#include -#include -#include - -struct string_to_uint_map; - -#ifdef __cplusplus -extern "C" { -#endif - -struct hash_table; - -typedef unsigned (*hash_func_t)(const void *key); -typedef int (*hash_compare_func_t)(const void *key1, const void *key2); - -/** - * Hash table constructor - * - * Creates a hash table with the specified number of buckets. The supplied - * \c hash and \c compare routines are used when adding elements to the table - * and when searching for elements in the table. - * - * \param num_buckets Number of buckets (bins) in the hash table. - * \param hash Function used to compute hash value of input keys. - * \param compare Function used to compare keys. - */ -extern struct hash_table *hash_table_ctor(unsigned num_buckets, - hash_func_t hash, hash_compare_func_t compare); - - -/** - * Release all memory associated with a hash table - * - * \warning - * This function cannot release memory occupied either by keys or data. - */ -extern void hash_table_dtor(struct hash_table *ht); - - -/** - * Flush all entries from a hash table - * - * \param ht Table to be cleared of its entries. - */ -extern void hash_table_clear(struct hash_table *ht); - - -/** - * Search a hash table for a specific element - * - * \param ht Table to be searched - * \param key Key of the desired element - * - * \return - * The \c data value supplied to \c hash_table_insert when the element with - * the matching key was added. If no matching key exists in the table, - * \c NULL is returned. - */ -extern void *hash_table_find(struct hash_table *ht, const void *key); - - -/** - * Add an element to a hash table - * - * \warning - * If \c key is already in the hash table, it will be added again. Future - * calls to \c hash_table_find and \c hash_table_remove will return or remove, - * repsectively, the most recently added instance of \c key. - * - * \warning - * The value passed by \c key is kept in the hash table and is used by later - * calls to \c hash_table_find. - * - * \sa hash_table_replace - */ -extern void hash_table_insert(struct hash_table *ht, void *data, - const void *key); - -/** - * Add an element to a hash table with replacement - * - * \warning - * If \c key is already in the hash table, \c data will \b replace the most - * recently inserted \c data (see the warning in \c hash_table_insert) for - * that key. - * - * \sa hash_table_insert - */ -extern void hash_table_replace(struct hash_table *ht, void *data, - const void *key); - -/** - * Remove a specific element from a hash table. - */ -extern void hash_table_remove(struct hash_table *ht, const void *key); - -/** - * Compute hash value of a string - * - * Computes the hash value of a string using the DJB2 algorithm developed by - * Professor Daniel J. Bernstein. It was published on comp.lang.c once upon - * a time. I was unable to find the original posting in the archives. - * - * \param key Pointer to a NUL terminated string to be hashed. - * - * \sa hash_table_string_compare - */ -extern unsigned hash_table_string_hash(const void *key); - - -/** - * Compare two strings used as keys - * - * This is just a macro wrapper around \c strcmp. - * - * \sa hash_table_string_hash - */ -#define hash_table_string_compare ((hash_compare_func_t) strcmp) - - -/** - * Compute hash value of a pointer - * - * \param key Pointer to be used as a hash key - * - * \note - * The memory pointed to by \c key is \b never accessed. The value of \c key - * itself is used as the hash key - * - * \sa hash_table_pointer_compare - */ -unsigned -hash_table_pointer_hash(const void *key); - - -/** - * Compare two pointers used as keys - * - * \sa hash_table_pointer_hash - */ -int -hash_table_pointer_compare(const void *key1, const void *key2); - -void -hash_table_call_foreach(struct hash_table *ht, - void (*callback)(const void *key, - void *data, - void *closure), - void *closure); - -struct string_to_uint_map * -string_to_uint_map_ctor(); - -void -string_to_uint_map_dtor(struct string_to_uint_map *); - - -#ifdef __cplusplus -} - -/** - * Map from a string (name) to an unsigned integer value - * - * \note - * Because of the way this class interacts with the \c hash_table - * implementation, values of \c UINT_MAX cannot be stored in the map. - */ -struct string_to_uint_map { -public: - string_to_uint_map() - { - this->ht = hash_table_ctor(0, hash_table_string_hash, - hash_table_string_compare); - } - - ~string_to_uint_map() - { - hash_table_call_foreach(this->ht, delete_key, NULL); - hash_table_dtor(this->ht); - } - - /** - * Remove all mappings from this map. - */ - void clear() - { - hash_table_clear(this->ht); - } - - /** - * Get the value associated with a particular key - * - * \return - * If \c key is found in the map, \c true is returned. Otherwise \c false - * is returned. - * - * \note - * If \c key is not found in the table, \c value is not modified. - */ - bool get(unsigned &value, const char *key) - { - const intptr_t v = - (intptr_t) hash_table_find(this->ht, (const void *) key); - - if (v == 0) - return false; - - value = (unsigned)(v - 1); - return true; - } - - void put(unsigned value, const char *key) - { - /* The low-level hash table structure returns NULL if key is not in the - * hash table. However, users of this map might want to store zero as a - * valid value in the table. Bias the value by +1 so that a - * user-specified zero is stored as 1. This enables ::get to tell the - * difference between a user-specified zero (returned as 1 by - * hash_table_find) and the key not in the table (returned as 0 by - * hash_table_find). - * - * The net effect is that we can't store UINT_MAX in the table. This is - * because UINT_MAX+1 = 0. - */ - assert(value != UINT_MAX); - hash_table_replace(this->ht, - (void *) (intptr_t) (value + 1), - strdup(key)); - } - -private: - static void delete_key(const void *key, void *data, void *closure) - { - (void) data; - (void) closure; - - free((char *)key); - } - - struct hash_table *ht; -}; - -#endif /* __cplusplus */ -#endif /* HASH_TABLE_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.cpp b/reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.cpp deleted file mode 100644 index 375b0941e70..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.cpp +++ /dev/null @@ -1,3397 +0,0 @@ -/* - * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file ir_to_mesa.cpp - * - * Translate GLSL IR to Mesa's gl_program representation. - */ - -#include -#include "main/compiler.h" -#include "ir.h" -#include "ir_visitor.h" -#include "ir_print_visitor.h" -#include "ir_expression_flattening.h" -#include "ir_uniform.h" -#include "glsl_types.h" -#include "glsl_parser_extras.h" -#include "../glsl/program.h" -#include "ir_optimization.h" -#include "ast.h" -#include "linker.h" - -#include "main/mtypes.h" -#include "main/shaderobj.h" -#include "program/hash_table.h" - -extern "C" { -#include "main/shaderapi.h" -#include "main/uniforms.h" -#include "program/prog_instruction.h" -#include "program/prog_optimize.h" -#include "program/prog_print.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/sampler.h" -} - -class src_reg; -class dst_reg; - -static int swizzle_for_size(int size); - -/** - * This struct is a corresponding struct to Mesa prog_src_register, with - * wider fields. - */ -class src_reg { -public: - src_reg(gl_register_file file, int index, const glsl_type *type) - { - this->file = file; - this->index = index; - if (type && (type->is_scalar() || type->is_vector() || type->is_matrix())) - this->swizzle = swizzle_for_size(type->vector_elements); - else - this->swizzle = SWIZZLE_XYZW; - this->negate = 0; - this->reladdr = NULL; - } - - src_reg() - { - this->file = PROGRAM_UNDEFINED; - this->index = 0; - this->swizzle = 0; - this->negate = 0; - this->reladdr = NULL; - } - - explicit src_reg(dst_reg reg); - - gl_register_file file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - GLuint swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */ - int negate; /**< NEGATE_XYZW mask from mesa */ - /** Register index should be offset by the integer in this reg. */ - src_reg *reladdr; -}; - -class dst_reg { -public: - dst_reg(gl_register_file file, int writemask) - { - this->file = file; - this->index = 0; - this->writemask = writemask; - this->cond_mask = COND_TR; - this->reladdr = NULL; - } - - dst_reg() - { - this->file = PROGRAM_UNDEFINED; - this->index = 0; - this->writemask = 0; - this->cond_mask = COND_TR; - this->reladdr = NULL; - } - - explicit dst_reg(src_reg reg); - - gl_register_file file; /**< PROGRAM_* from Mesa */ - int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */ - int writemask; /**< Bitfield of WRITEMASK_[XYZW] */ - GLuint cond_mask:4; - /** Register index should be offset by the integer in this reg. */ - src_reg *reladdr; -}; - -src_reg::src_reg(dst_reg reg) -{ - this->file = reg.file; - this->index = reg.index; - this->swizzle = SWIZZLE_XYZW; - this->negate = 0; - this->reladdr = reg.reladdr; -} - -dst_reg::dst_reg(src_reg reg) -{ - this->file = reg.file; - this->index = reg.index; - this->writemask = WRITEMASK_XYZW; - this->cond_mask = COND_TR; - this->reladdr = reg.reladdr; -} - -class ir_to_mesa_instruction : public exec_node { -public: - /* Callers of this ralloc-based new need not call delete. It's - * easier to just ralloc_free 'ctx' (or any of its ancestors). */ - static void* operator new(size_t size, void *ctx) - { - void *node; - - node = rzalloc_size(ctx, size); - assert(node != NULL); - - return node; - } - - enum prog_opcode op; - dst_reg dst; - src_reg src[3]; - /** Pointer to the ir source this tree came from for debugging */ - ir_instruction *ir; - GLboolean cond_update; - bool saturate; - int sampler; /**< sampler index */ - int tex_target; /**< One of TEXTURE_*_INDEX */ - GLboolean tex_shadow; - - class function_entry *function; /* Set on OPCODE_CAL or OPCODE_BGNSUB */ -}; - -class variable_storage : public exec_node { -public: - variable_storage(ir_variable *var, gl_register_file file, int index) - : file(file), index(index), var(var) - { - /* empty */ - } - - gl_register_file file; - int index; - ir_variable *var; /* variable that maps to this, if any */ -}; - -class function_entry : public exec_node { -public: - ir_function_signature *sig; - - /** - * identifier of this function signature used by the program. - * - * At the point that Mesa instructions for function calls are - * generated, we don't know the address of the first instruction of - * the function body. So we make the BranchTarget that is called a - * small integer and rewrite them during set_branchtargets(). - */ - int sig_id; - - /** - * Pointer to first instruction of the function body. - * - * Set during function body emits after main() is processed. - */ - ir_to_mesa_instruction *bgn_inst; - - /** - * Index of the first instruction of the function body in actual - * Mesa IR. - * - * Set after convertion from ir_to_mesa_instruction to prog_instruction. - */ - int inst; - - /** Storage for the return value. */ - src_reg return_reg; -}; - -class ir_to_mesa_visitor : public ir_visitor { -public: - ir_to_mesa_visitor(); - ~ir_to_mesa_visitor(); - - function_entry *current_function; - - struct gl_context *ctx; - struct gl_program *prog; - struct gl_shader_program *shader_program; - struct gl_shader_compiler_options *options; - - int next_temp; - - variable_storage *find_variable_storage(ir_variable *var); - - function_entry *get_function_signature(ir_function_signature *sig); - - src_reg get_temp(const glsl_type *type); - void reladdr_to_temp(ir_instruction *ir, src_reg *reg, int *num_reladdr); - - src_reg src_reg_for_float(float val); - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference_variable *); - virtual void visit(ir_dereference_array *); - virtual void visit(ir_dereference_record *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_discard *); - virtual void visit(ir_texture *); - virtual void visit(ir_if *); - /*@}*/ - - src_reg result; - - /** List of variable_storage */ - exec_list variables; - - /** List of function_entry */ - exec_list function_signatures; - int next_signature_id; - - /** List of ir_to_mesa_instruction */ - exec_list instructions; - - ir_to_mesa_instruction *emit(ir_instruction *ir, enum prog_opcode op); - - ir_to_mesa_instruction *emit(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, src_reg src0); - - ir_to_mesa_instruction *emit(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, src_reg src0, src_reg src1); - - ir_to_mesa_instruction *emit(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, - src_reg src0, src_reg src1, src_reg src2); - - /** - * Emit the correct dot-product instruction for the type of arguments - */ - ir_to_mesa_instruction * emit_dp(ir_instruction *ir, - dst_reg dst, - src_reg src0, - src_reg src1, - unsigned elements); - - void emit_scalar(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, src_reg src0); - - void emit_scalar(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, src_reg src0, src_reg src1); - - void emit_scs(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, const src_reg &src); - - bool try_emit_mad(ir_expression *ir, - int mul_operand); - bool try_emit_mad_for_and_not(ir_expression *ir, - int mul_operand); - bool try_emit_sat(ir_expression *ir); - - void emit_swz(ir_expression *ir); - - bool process_move_condition(ir_rvalue *ir); - - void copy_propagate(void); - - void *mem_ctx; -}; - -src_reg undef_src = src_reg(PROGRAM_UNDEFINED, 0, NULL); - -dst_reg undef_dst = dst_reg(PROGRAM_UNDEFINED, SWIZZLE_NOOP); - -dst_reg address_reg = dst_reg(PROGRAM_ADDRESS, WRITEMASK_X); - -static int -swizzle_for_size(int size) -{ - int size_swizzles[4] = { - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z), - MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W), - }; - - assert((size >= 1) && (size <= 4)); - return size_swizzles[size - 1]; -} - -ir_to_mesa_instruction * -ir_to_mesa_visitor::emit(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, - src_reg src0, src_reg src1, src_reg src2) -{ - ir_to_mesa_instruction *inst = new(mem_ctx) ir_to_mesa_instruction(); - int num_reladdr = 0; - - /* If we have to do relative addressing, we want to load the ARL - * reg directly for one of the regs, and preload the other reladdr - * sources into temps. - */ - num_reladdr += dst.reladdr != NULL; - num_reladdr += src0.reladdr != NULL; - num_reladdr += src1.reladdr != NULL; - num_reladdr += src2.reladdr != NULL; - - reladdr_to_temp(ir, &src2, &num_reladdr); - reladdr_to_temp(ir, &src1, &num_reladdr); - reladdr_to_temp(ir, &src0, &num_reladdr); - - if (dst.reladdr) { - emit(ir, OPCODE_ARL, address_reg, *dst.reladdr); - num_reladdr--; - } - assert(num_reladdr == 0); - - inst->op = op; - inst->dst = dst; - inst->src[0] = src0; - inst->src[1] = src1; - inst->src[2] = src2; - inst->ir = ir; - - inst->function = NULL; - - this->instructions.push_tail(inst); - - return inst; -} - - -ir_to_mesa_instruction * -ir_to_mesa_visitor::emit(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, src_reg src0, src_reg src1) -{ - return emit(ir, op, dst, src0, src1, undef_src); -} - -ir_to_mesa_instruction * -ir_to_mesa_visitor::emit(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, src_reg src0) -{ - assert(dst.writemask != 0); - return emit(ir, op, dst, src0, undef_src, undef_src); -} - -ir_to_mesa_instruction * -ir_to_mesa_visitor::emit(ir_instruction *ir, enum prog_opcode op) -{ - return emit(ir, op, undef_dst, undef_src, undef_src, undef_src); -} - -ir_to_mesa_instruction * -ir_to_mesa_visitor::emit_dp(ir_instruction *ir, - dst_reg dst, src_reg src0, src_reg src1, - unsigned elements) -{ - static const gl_inst_opcode dot_opcodes[] = { - OPCODE_DP2, OPCODE_DP3, OPCODE_DP4 - }; - - return emit(ir, dot_opcodes[elements - 2], dst, src0, src1); -} - -/** - * Emits Mesa scalar opcodes to produce unique answers across channels. - * - * Some Mesa opcodes are scalar-only, like ARB_fp/vp. The src X - * channel determines the result across all channels. So to do a vec4 - * of this operation, we want to emit a scalar per source channel used - * to produce dest channels. - */ -void -ir_to_mesa_visitor::emit_scalar(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, - src_reg orig_src0, src_reg orig_src1) -{ - int i, j; - int done_mask = ~dst.writemask; - - /* Mesa RCP is a scalar operation splatting results to all channels, - * like ARB_fp/vp. So emit as many RCPs as necessary to cover our - * dst channels. - */ - for (i = 0; i < 4; i++) { - GLuint this_mask = (1 << i); - ir_to_mesa_instruction *inst; - src_reg src0 = orig_src0; - src_reg src1 = orig_src1; - - if (done_mask & this_mask) - continue; - - GLuint src0_swiz = GET_SWZ(src0.swizzle, i); - GLuint src1_swiz = GET_SWZ(src1.swizzle, i); - for (j = i + 1; j < 4; j++) { - /* If there is another enabled component in the destination that is - * derived from the same inputs, generate its value on this pass as - * well. - */ - if (!(done_mask & (1 << j)) && - GET_SWZ(src0.swizzle, j) == src0_swiz && - GET_SWZ(src1.swizzle, j) == src1_swiz) { - this_mask |= (1 << j); - } - } - src0.swizzle = MAKE_SWIZZLE4(src0_swiz, src0_swiz, - src0_swiz, src0_swiz); - src1.swizzle = MAKE_SWIZZLE4(src1_swiz, src1_swiz, - src1_swiz, src1_swiz); - - inst = emit(ir, op, dst, src0, src1); - inst->dst.writemask = this_mask; - done_mask |= this_mask; - } -} - -void -ir_to_mesa_visitor::emit_scalar(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, src_reg src0) -{ - src_reg undef = undef_src; - - undef.swizzle = SWIZZLE_XXXX; - - emit_scalar(ir, op, dst, src0, undef); -} - -/** - * Emit an OPCODE_SCS instruction - * - * The \c SCS opcode functions a bit differently than the other Mesa (or - * ARB_fragment_program) opcodes. Instead of splatting its result across all - * four components of the destination, it writes one value to the \c x - * component and another value to the \c y component. - * - * \param ir IR instruction being processed - * \param op Either \c OPCODE_SIN or \c OPCODE_COS depending on which - * value is desired. - * \param dst Destination register - * \param src Source register - */ -void -ir_to_mesa_visitor::emit_scs(ir_instruction *ir, enum prog_opcode op, - dst_reg dst, - const src_reg &src) -{ - /* Vertex programs cannot use the SCS opcode. - */ - if (this->prog->Target == GL_VERTEX_PROGRAM_ARB) { - emit_scalar(ir, op, dst, src); - return; - } - - const unsigned component = (op == OPCODE_SIN) ? 0 : 1; - const unsigned scs_mask = (1U << component); - int done_mask = ~dst.writemask; - src_reg tmp; - - assert(op == OPCODE_SIN || op == OPCODE_COS); - - /* If there are compnents in the destination that differ from the component - * that will be written by the SCS instrution, we'll need a temporary. - */ - if (scs_mask != unsigned(dst.writemask)) { - tmp = get_temp(glsl_type::vec4_type); - } - - for (unsigned i = 0; i < 4; i++) { - unsigned this_mask = (1U << i); - src_reg src0 = src; - - if ((done_mask & this_mask) != 0) - continue; - - /* The source swizzle specified which component of the source generates - * sine / cosine for the current component in the destination. The SCS - * instruction requires that this value be swizzle to the X component. - * Replace the current swizzle with a swizzle that puts the source in - * the X component. - */ - unsigned src0_swiz = GET_SWZ(src.swizzle, i); - - src0.swizzle = MAKE_SWIZZLE4(src0_swiz, src0_swiz, - src0_swiz, src0_swiz); - for (unsigned j = i + 1; j < 4; j++) { - /* If there is another enabled component in the destination that is - * derived from the same inputs, generate its value on this pass as - * well. - */ - if (!(done_mask & (1 << j)) && - GET_SWZ(src0.swizzle, j) == src0_swiz) { - this_mask |= (1 << j); - } - } - - if (this_mask != scs_mask) { - ir_to_mesa_instruction *inst; - dst_reg tmp_dst = dst_reg(tmp); - - /* Emit the SCS instruction. - */ - inst = emit(ir, OPCODE_SCS, tmp_dst, src0); - inst->dst.writemask = scs_mask; - - /* Move the result of the SCS instruction to the desired location in - * the destination. - */ - tmp.swizzle = MAKE_SWIZZLE4(component, component, - component, component); - inst = emit(ir, OPCODE_SCS, dst, tmp); - inst->dst.writemask = this_mask; - } else { - /* Emit the SCS instruction to write directly to the destination. - */ - ir_to_mesa_instruction *inst = emit(ir, OPCODE_SCS, dst, src0); - inst->dst.writemask = scs_mask; - } - - done_mask |= this_mask; - } -} - -src_reg -ir_to_mesa_visitor::src_reg_for_float(float val) -{ - src_reg src(PROGRAM_CONSTANT, -1, NULL); - - src.index = _mesa_add_unnamed_constant(this->prog->Parameters, - (const gl_constant_value *)&val, 1, &src.swizzle); - - return src; -} - -static int -type_size(const struct glsl_type *type) -{ - unsigned int i; - int size; - - switch (type->base_type) { - case GLSL_TYPE_UINT: - case GLSL_TYPE_INT: - case GLSL_TYPE_FLOAT: - case GLSL_TYPE_BOOL: - if (type->is_matrix()) { - return type->matrix_columns; - } else { - /* Regardless of size of vector, it gets a vec4. This is bad - * packing for things like floats, but otherwise arrays become a - * mess. Hopefully a later pass over the code can pack scalars - * down if appropriate. - */ - return 1; - } - case GLSL_TYPE_ARRAY: - assert(type->length > 0); - return type_size(type->fields.array) * type->length; - case GLSL_TYPE_STRUCT: - size = 0; - for (i = 0; i < type->length; i++) { - size += type_size(type->fields.structure[i].type); - } - return size; - case GLSL_TYPE_SAMPLER: - /* Samplers take up one slot in UNIFORMS[], but they're baked in - * at link time. - */ - return 1; - default: - assert(0); - return 0; - } -} - -/** - * In the initial pass of codegen, we assign temporary numbers to - * intermediate results. (not SSA -- variable assignments will reuse - * storage). Actual register allocation for the Mesa VM occurs in a - * pass over the Mesa IR later. - */ -src_reg -ir_to_mesa_visitor::get_temp(const glsl_type *type) -{ - src_reg src; - - src.file = PROGRAM_TEMPORARY; - src.index = next_temp; - src.reladdr = NULL; - next_temp += type_size(type); - - if (type->is_array() || type->is_record()) { - src.swizzle = SWIZZLE_NOOP; - } else { - src.swizzle = swizzle_for_size(type->vector_elements); - } - src.negate = 0; - - return src; -} - -variable_storage * -ir_to_mesa_visitor::find_variable_storage(ir_variable *var) -{ - - variable_storage *entry; - - foreach_iter(exec_list_iterator, iter, this->variables) { - entry = (variable_storage *)iter.get(); - - if (entry->var == var) - return entry; - } - - return NULL; -} - -void -ir_to_mesa_visitor::visit(ir_variable *ir) -{ - if (ir->mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) { - unsigned int i; - const ir_state_slot *const slots = ir->state_slots; - assert(ir->state_slots != NULL); - - /* Check if this statevar's setup in the STATE file exactly - * matches how we'll want to reference it as a - * struct/array/whatever. If not, then we need to move it into - * temporary storage and hope that it'll get copy-propagated - * out. - */ - for (i = 0; i < ir->num_state_slots; i++) { - if (slots[i].swizzle != SWIZZLE_XYZW) { - break; - } - } - - variable_storage *storage; - dst_reg dst; - if (i == ir->num_state_slots) { - /* We'll set the index later. */ - storage = new(mem_ctx) variable_storage(ir, PROGRAM_STATE_VAR, -1); - this->variables.push_tail(storage); - - dst = undef_dst; - } else { - /* The variable_storage constructor allocates slots based on the size - * of the type. However, this had better match the number of state - * elements that we're going to copy into the new temporary. - */ - assert((int) ir->num_state_slots == type_size(ir->type)); - - storage = new(mem_ctx) variable_storage(ir, PROGRAM_TEMPORARY, - this->next_temp); - this->variables.push_tail(storage); - this->next_temp += type_size(ir->type); - - dst = dst_reg(src_reg(PROGRAM_TEMPORARY, storage->index, NULL)); - } - - - for (unsigned int i = 0; i < ir->num_state_slots; i++) { - int index = _mesa_add_state_reference(this->prog->Parameters, - (gl_state_index *)slots[i].tokens); - - if (storage->file == PROGRAM_STATE_VAR) { - if (storage->index == -1) { - storage->index = index; - } else { - assert(index == storage->index + (int)i); - } - } else { - src_reg src(PROGRAM_STATE_VAR, index, NULL); - src.swizzle = slots[i].swizzle; - emit(ir, OPCODE_MOV, dst, src); - /* even a float takes up a whole vec4 reg in a struct/array. */ - dst.index++; - } - } - - if (storage->file == PROGRAM_TEMPORARY && - dst.index != storage->index + (int) ir->num_state_slots) { - linker_error(this->shader_program, - "failed to load builtin uniform `%s' " - "(%d/%d regs loaded)\n", - ir->name, dst.index - storage->index, - type_size(ir->type)); - } - } -} - -void -ir_to_mesa_visitor::visit(ir_loop *ir) -{ - ir_dereference_variable *counter = NULL; - - if (ir->counter != NULL) - counter = new(mem_ctx) ir_dereference_variable(ir->counter); - - if (ir->from != NULL) { - assert(ir->counter != NULL); - - ir_assignment *a = - new(mem_ctx) ir_assignment(counter, ir->from, NULL); - - a->accept(this); - } - - emit(NULL, OPCODE_BGNLOOP); - - if (ir->to) { - ir_expression *e = - new(mem_ctx) ir_expression(ir->cmp, glsl_type::bool_type, - counter, ir->to); - ir_if *if_stmt = new(mem_ctx) ir_if(e); - - ir_loop_jump *brk = - new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_break); - - if_stmt->then_instructions.push_tail(brk); - - if_stmt->accept(this); - } - - visit_exec_list(&ir->body_instructions, this); - - if (ir->increment) { - ir_expression *e = - new(mem_ctx) ir_expression(ir_binop_add, counter->type, - counter, ir->increment); - - ir_assignment *a = - new(mem_ctx) ir_assignment(counter, e, NULL); - - a->accept(this); - } - - emit(NULL, OPCODE_ENDLOOP); -} - -void -ir_to_mesa_visitor::visit(ir_loop_jump *ir) -{ - switch (ir->mode) { - case ir_loop_jump::jump_break: - emit(NULL, OPCODE_BRK); - break; - case ir_loop_jump::jump_continue: - emit(NULL, OPCODE_CONT); - break; - } -} - - -void -ir_to_mesa_visitor::visit(ir_function_signature *ir) -{ - assert(0); - (void)ir; -} - -void -ir_to_mesa_visitor::visit(ir_function *ir) -{ - /* Ignore function bodies other than main() -- we shouldn't see calls to - * them since they should all be inlined before we get to ir_to_mesa. - */ - if (strcmp(ir->name, "main") == 0) { - const ir_function_signature *sig; - exec_list empty; - - sig = ir->matching_signature(&empty); - - assert(sig); - - foreach_iter(exec_list_iterator, iter, sig->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); - - ir->accept(this); - } - } -} - -bool -ir_to_mesa_visitor::try_emit_mad(ir_expression *ir, int mul_operand) -{ - int nonmul_operand = 1 - mul_operand; - src_reg a, b, c; - - ir_expression *expr = ir->operands[mul_operand]->as_expression(); - if (!expr || expr->operation != ir_binop_mul) - return false; - - expr->operands[0]->accept(this); - a = this->result; - expr->operands[1]->accept(this); - b = this->result; - ir->operands[nonmul_operand]->accept(this); - c = this->result; - - this->result = get_temp(ir->type); - emit(ir, OPCODE_MAD, dst_reg(this->result), a, b, c); - - return true; -} - -/** - * Emit OPCODE_MAD(a, -b, a) instead of AND(a, NOT(b)) - * - * The logic values are 1.0 for true and 0.0 for false. Logical-and is - * implemented using multiplication, and logical-or is implemented using - * addition. Logical-not can be implemented as (true - x), or (1.0 - x). - * As result, the logical expression (a & !b) can be rewritten as: - * - * - a * !b - * - a * (1 - b) - * - (a * 1) - (a * b) - * - a + -(a * b) - * - a + (a * -b) - * - * This final expression can be implemented as a single MAD(a, -b, a) - * instruction. - */ -bool -ir_to_mesa_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operand) -{ - const int other_operand = 1 - try_operand; - src_reg a, b; - - ir_expression *expr = ir->operands[try_operand]->as_expression(); - if (!expr || expr->operation != ir_unop_logic_not) - return false; - - ir->operands[other_operand]->accept(this); - a = this->result; - expr->operands[0]->accept(this); - b = this->result; - - b.negate = ~b.negate; - - this->result = get_temp(ir->type); - emit(ir, OPCODE_MAD, dst_reg(this->result), a, b, a); - - return true; -} - -bool -ir_to_mesa_visitor::try_emit_sat(ir_expression *ir) -{ - /* Saturates were only introduced to vertex programs in - * NV_vertex_program3, so don't give them to drivers in the VP. - */ - if (this->prog->Target == GL_VERTEX_PROGRAM_ARB) - return false; - - ir_rvalue *sat_src = ir->as_rvalue_to_saturate(); - if (!sat_src) - return false; - - sat_src->accept(this); - src_reg src = this->result; - - /* If we generated an expression instruction into a temporary in - * processing the saturate's operand, apply the saturate to that - * instruction. Otherwise, generate a MOV to do the saturate. - * - * Note that we have to be careful to only do this optimization if - * the instruction in question was what generated src->result. For - * example, ir_dereference_array might generate a MUL instruction - * to create the reladdr, and return us a src reg using that - * reladdr. That MUL result is not the value we're trying to - * saturate. - */ - ir_expression *sat_src_expr = sat_src->as_expression(); - ir_to_mesa_instruction *new_inst; - new_inst = (ir_to_mesa_instruction *)this->instructions.get_tail(); - if (sat_src_expr && (sat_src_expr->operation == ir_binop_mul || - sat_src_expr->operation == ir_binop_add || - sat_src_expr->operation == ir_binop_dot)) { - new_inst->saturate = true; - } else { - this->result = get_temp(ir->type); - ir_to_mesa_instruction *inst; - inst = emit(ir, OPCODE_MOV, dst_reg(this->result), src); - inst->saturate = true; - } - - return true; -} - -void -ir_to_mesa_visitor::reladdr_to_temp(ir_instruction *ir, - src_reg *reg, int *num_reladdr) -{ - if (!reg->reladdr) - return; - - emit(ir, OPCODE_ARL, address_reg, *reg->reladdr); - - if (*num_reladdr != 1) { - src_reg temp = get_temp(glsl_type::vec4_type); - - emit(ir, OPCODE_MOV, dst_reg(temp), *reg); - *reg = temp; - } - - (*num_reladdr)--; -} - -void -ir_to_mesa_visitor::emit_swz(ir_expression *ir) -{ - /* Assume that the vector operator is in a form compatible with OPCODE_SWZ. - * This means that each of the operands is either an immediate value of -1, - * 0, or 1, or is a component from one source register (possibly with - * negation). - */ - uint8_t components[4] = { 0 }; - bool negate[4] = { false }; - ir_variable *var = NULL; - - for (unsigned i = 0; i < ir->type->vector_elements; i++) { - ir_rvalue *op = ir->operands[i]; - - assert(op->type->is_scalar()); - - while (op != NULL) { - switch (op->ir_type) { - case ir_type_constant: { - - assert(op->type->is_scalar()); - - const ir_constant *const c = op->as_constant(); - if (c->is_one()) { - components[i] = SWIZZLE_ONE; - } else if (c->is_zero()) { - components[i] = SWIZZLE_ZERO; - } else if (c->is_negative_one()) { - components[i] = SWIZZLE_ONE; - negate[i] = true; - } else { - assert(!"SWZ constant must be 0.0 or 1.0."); - } - - op = NULL; - break; - } - - case ir_type_dereference_variable: { - ir_dereference_variable *const deref = - (ir_dereference_variable *) op; - - assert((var == NULL) || (deref->var == var)); - components[i] = SWIZZLE_X; - var = deref->var; - op = NULL; - break; - } - - case ir_type_expression: { - ir_expression *const expr = (ir_expression *) op; - - assert(expr->operation == ir_unop_neg); - negate[i] = true; - - op = expr->operands[0]; - break; - } - - case ir_type_swizzle: { - ir_swizzle *const swiz = (ir_swizzle *) op; - - components[i] = swiz->mask.x; - op = swiz->val; - break; - } - - default: - assert(!"Should not get here."); - return; - } - } - } - - assert(var != NULL); - - ir_dereference_variable *const deref = - new(mem_ctx) ir_dereference_variable(var); - - this->result.file = PROGRAM_UNDEFINED; - deref->accept(this); - if (this->result.file == PROGRAM_UNDEFINED) { - ir_print_visitor v; - printf("Failed to get tree for expression operand:\n"); - deref->accept(&v); - exit(1); - } - - src_reg src; - - src = this->result; - src.swizzle = MAKE_SWIZZLE4(components[0], - components[1], - components[2], - components[3]); - src.negate = ((unsigned(negate[0]) << 0) - | (unsigned(negate[1]) << 1) - | (unsigned(negate[2]) << 2) - | (unsigned(negate[3]) << 3)); - - /* Storage for our result. Ideally for an assignment we'd be using the - * actual storage for the result here, instead. - */ - const src_reg result_src = get_temp(ir->type); - dst_reg result_dst = dst_reg(result_src); - - /* Limit writes to the channels that will be used by result_src later. - * This does limit this temp's use as a temporary for multi-instruction - * sequences. - */ - result_dst.writemask = (1 << ir->type->vector_elements) - 1; - - emit(ir, OPCODE_SWZ, result_dst, src); - this->result = result_src; -} - -void -ir_to_mesa_visitor::visit(ir_expression *ir) -{ - unsigned int operand; - src_reg op[Elements(ir->operands)]; - src_reg result_src; - dst_reg result_dst; - - /* Quick peephole: Emit OPCODE_MAD(a, b, c) instead of ADD(MUL(a, b), c) - */ - if (ir->operation == ir_binop_add) { - if (try_emit_mad(ir, 1)) - return; - if (try_emit_mad(ir, 0)) - return; - } - - /* Quick peephole: Emit OPCODE_MAD(-a, -b, a) instead of AND(a, NOT(b)) - */ - if (ir->operation == ir_binop_logic_and) { - if (try_emit_mad_for_and_not(ir, 1)) - return; - if (try_emit_mad_for_and_not(ir, 0)) - return; - } - - if (try_emit_sat(ir)) - return; - - if (ir->operation == ir_quadop_vector) { - this->emit_swz(ir); - return; - } - - for (operand = 0; operand < ir->get_num_operands(); operand++) { - this->result.file = PROGRAM_UNDEFINED; - ir->operands[operand]->accept(this); - if (this->result.file == PROGRAM_UNDEFINED) { - ir_print_visitor v; - printf("Failed to get tree for expression operand:\n"); - ir->operands[operand]->accept(&v); - exit(1); - } - op[operand] = this->result; - - /* Matrix expression operands should have been broken down to vector - * operations already. - */ - assert(!ir->operands[operand]->type->is_matrix()); - } - - int vector_elements = ir->operands[0]->type->vector_elements; - if (ir->operands[1]) { - vector_elements = MAX2(vector_elements, - ir->operands[1]->type->vector_elements); - } - - this->result.file = PROGRAM_UNDEFINED; - - /* Storage for our result. Ideally for an assignment we'd be using - * the actual storage for the result here, instead. - */ - result_src = get_temp(ir->type); - /* convenience for the emit functions below. */ - result_dst = dst_reg(result_src); - /* Limit writes to the channels that will be used by result_src later. - * This does limit this temp's use as a temporary for multi-instruction - * sequences. - */ - result_dst.writemask = (1 << ir->type->vector_elements) - 1; - - switch (ir->operation) { - case ir_unop_logic_not: - /* Previously 'SEQ dst, src, 0.0' was used for this. However, many - * older GPUs implement SEQ using multiple instructions (i915 uses two - * SGE instructions and a MUL instruction). Since our logic values are - * 0.0 and 1.0, 1-x also implements !x. - */ - op[0].negate = ~op[0].negate; - emit(ir, OPCODE_ADD, result_dst, op[0], src_reg_for_float(1.0)); - break; - case ir_unop_neg: - op[0].negate = ~op[0].negate; - result_src = op[0]; - break; - case ir_unop_abs: - emit(ir, OPCODE_ABS, result_dst, op[0]); - break; - case ir_unop_sign: - emit(ir, OPCODE_SSG, result_dst, op[0]); - break; - case ir_unop_rcp: - emit_scalar(ir, OPCODE_RCP, result_dst, op[0]); - break; - - case ir_unop_exp2: - emit_scalar(ir, OPCODE_EX2, result_dst, op[0]); - break; - case ir_unop_exp: - case ir_unop_log: - assert(!"not reached: should be handled by ir_explog_to_explog2"); - break; - case ir_unop_log2: - emit_scalar(ir, OPCODE_LG2, result_dst, op[0]); - break; - case ir_unop_sin: - emit_scalar(ir, OPCODE_SIN, result_dst, op[0]); - break; - case ir_unop_cos: - emit_scalar(ir, OPCODE_COS, result_dst, op[0]); - break; - case ir_unop_sin_reduced: - emit_scs(ir, OPCODE_SIN, result_dst, op[0]); - break; - case ir_unop_cos_reduced: - emit_scs(ir, OPCODE_COS, result_dst, op[0]); - break; - - case ir_unop_dFdx: - emit(ir, OPCODE_DDX, result_dst, op[0]); - break; - case ir_unop_dFdy: - emit(ir, OPCODE_DDY, result_dst, op[0]); - break; - - case ir_unop_noise: { - const enum prog_opcode opcode = - prog_opcode(OPCODE_NOISE1 - + (ir->operands[0]->type->vector_elements) - 1); - assert((opcode >= OPCODE_NOISE1) && (opcode <= OPCODE_NOISE4)); - - emit(ir, opcode, result_dst, op[0]); - break; - } - - case ir_binop_add: - emit(ir, OPCODE_ADD, result_dst, op[0], op[1]); - break; - case ir_binop_sub: - emit(ir, OPCODE_SUB, result_dst, op[0], op[1]); - break; - - case ir_binop_mul: - emit(ir, OPCODE_MUL, result_dst, op[0], op[1]); - break; - case ir_binop_div: - assert(!"not reached: should be handled by ir_div_to_mul_rcp"); - break; - case ir_binop_mod: - /* Floating point should be lowered by MOD_TO_FRACT in the compiler. */ - assert(ir->type->is_integer()); - emit(ir, OPCODE_MUL, result_dst, op[0], op[1]); - break; - - case ir_binop_less: - emit(ir, OPCODE_SLT, result_dst, op[0], op[1]); - break; - case ir_binop_greater: - emit(ir, OPCODE_SGT, result_dst, op[0], op[1]); - break; - case ir_binop_lequal: - emit(ir, OPCODE_SLE, result_dst, op[0], op[1]); - break; - case ir_binop_gequal: - emit(ir, OPCODE_SGE, result_dst, op[0], op[1]); - break; - case ir_binop_equal: - emit(ir, OPCODE_SEQ, result_dst, op[0], op[1]); - break; - case ir_binop_nequal: - emit(ir, OPCODE_SNE, result_dst, op[0], op[1]); - break; - case ir_binop_all_equal: - /* "==" operator producing a scalar boolean. */ - if (ir->operands[0]->type->is_vector() || - ir->operands[1]->type->is_vector()) { - src_reg temp = get_temp(glsl_type::vec4_type); - emit(ir, OPCODE_SNE, dst_reg(temp), op[0], op[1]); - - /* After the dot-product, the value will be an integer on the - * range [0,4]. Zero becomes 1.0, and positive values become zero. - */ - emit_dp(ir, result_dst, temp, temp, vector_elements); - - /* Negating the result of the dot-product gives values on the range - * [-4, 0]. Zero becomes 1.0, and negative values become zero. This - * achieved using SGE. - */ - src_reg sge_src = result_src; - sge_src.negate = ~sge_src.negate; - emit(ir, OPCODE_SGE, result_dst, sge_src, src_reg_for_float(0.0)); - } else { - emit(ir, OPCODE_SEQ, result_dst, op[0], op[1]); - } - break; - case ir_binop_any_nequal: - /* "!=" operator producing a scalar boolean. */ - if (ir->operands[0]->type->is_vector() || - ir->operands[1]->type->is_vector()) { - src_reg temp = get_temp(glsl_type::vec4_type); - emit(ir, OPCODE_SNE, dst_reg(temp), op[0], op[1]); - - /* After the dot-product, the value will be an integer on the - * range [0,4]. Zero stays zero, and positive values become 1.0. - */ - ir_to_mesa_instruction *const dp = - emit_dp(ir, result_dst, temp, temp, vector_elements); - if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB) { - /* The clamping to [0,1] can be done for free in the fragment - * shader with a saturate. - */ - dp->saturate = true; - } else { - /* Negating the result of the dot-product gives values on the range - * [-4, 0]. Zero stays zero, and negative values become 1.0. This - * achieved using SLT. - */ - src_reg slt_src = result_src; - slt_src.negate = ~slt_src.negate; - emit(ir, OPCODE_SLT, result_dst, slt_src, src_reg_for_float(0.0)); - } - } else { - emit(ir, OPCODE_SNE, result_dst, op[0], op[1]); - } - break; - - case ir_unop_any: { - assert(ir->operands[0]->type->is_vector()); - - /* After the dot-product, the value will be an integer on the - * range [0,4]. Zero stays zero, and positive values become 1.0. - */ - ir_to_mesa_instruction *const dp = - emit_dp(ir, result_dst, op[0], op[0], - ir->operands[0]->type->vector_elements); - if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB) { - /* The clamping to [0,1] can be done for free in the fragment - * shader with a saturate. - */ - dp->saturate = true; - } else { - /* Negating the result of the dot-product gives values on the range - * [-4, 0]. Zero stays zero, and negative values become 1.0. This - * is achieved using SLT. - */ - src_reg slt_src = result_src; - slt_src.negate = ~slt_src.negate; - emit(ir, OPCODE_SLT, result_dst, slt_src, src_reg_for_float(0.0)); - } - break; - } - - case ir_binop_logic_xor: - emit(ir, OPCODE_SNE, result_dst, op[0], op[1]); - break; - - case ir_binop_logic_or: { - /* After the addition, the value will be an integer on the - * range [0,2]. Zero stays zero, and positive values become 1.0. - */ - ir_to_mesa_instruction *add = - emit(ir, OPCODE_ADD, result_dst, op[0], op[1]); - if (this->prog->Target == GL_FRAGMENT_PROGRAM_ARB) { - /* The clamping to [0,1] can be done for free in the fragment - * shader with a saturate. - */ - add->saturate = true; - } else { - /* Negating the result of the addition gives values on the range - * [-2, 0]. Zero stays zero, and negative values become 1.0. This - * is achieved using SLT. - */ - src_reg slt_src = result_src; - slt_src.negate = ~slt_src.negate; - emit(ir, OPCODE_SLT, result_dst, slt_src, src_reg_for_float(0.0)); - } - break; - } - - case ir_binop_logic_and: - /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */ - emit(ir, OPCODE_MUL, result_dst, op[0], op[1]); - break; - - case ir_binop_dot: - assert(ir->operands[0]->type->is_vector()); - assert(ir->operands[0]->type == ir->operands[1]->type); - emit_dp(ir, result_dst, op[0], op[1], - ir->operands[0]->type->vector_elements); - break; - - case ir_unop_sqrt: - /* sqrt(x) = x * rsq(x). */ - emit_scalar(ir, OPCODE_RSQ, result_dst, op[0]); - emit(ir, OPCODE_MUL, result_dst, result_src, op[0]); - /* For incoming channels <= 0, set the result to 0. */ - op[0].negate = ~op[0].negate; - emit(ir, OPCODE_CMP, result_dst, - op[0], result_src, src_reg_for_float(0.0)); - break; - case ir_unop_rsq: - emit_scalar(ir, OPCODE_RSQ, result_dst, op[0]); - break; - case ir_unop_i2f: - case ir_unop_u2f: - case ir_unop_b2f: - case ir_unop_b2i: - case ir_unop_i2u: - case ir_unop_u2i: - /* Mesa IR lacks types, ints are stored as truncated floats. */ - result_src = op[0]; - break; - case ir_unop_f2i: - emit(ir, OPCODE_TRUNC, result_dst, op[0]); - break; - case ir_unop_f2b: - case ir_unop_i2b: - emit(ir, OPCODE_SNE, result_dst, - op[0], src_reg_for_float(0.0)); - break; - case ir_unop_trunc: - emit(ir, OPCODE_TRUNC, result_dst, op[0]); - break; - case ir_unop_ceil: - op[0].negate = ~op[0].negate; - emit(ir, OPCODE_FLR, result_dst, op[0]); - result_src.negate = ~result_src.negate; - break; - case ir_unop_floor: - emit(ir, OPCODE_FLR, result_dst, op[0]); - break; - case ir_unop_fract: - emit(ir, OPCODE_FRC, result_dst, op[0]); - break; - - case ir_binop_min: - emit(ir, OPCODE_MIN, result_dst, op[0], op[1]); - break; - case ir_binop_max: - emit(ir, OPCODE_MAX, result_dst, op[0], op[1]); - break; - case ir_binop_pow: - emit_scalar(ir, OPCODE_POW, result_dst, op[0], op[1]); - break; - - /* GLSL 1.30 integer ops are unsupported in Mesa IR, but since - * hardware backends have no way to avoid Mesa IR generation - * even if they don't use it, we need to emit "something" and - * continue. - */ - case ir_binop_lshift: - case ir_binop_rshift: - case ir_binop_bit_and: - case ir_binop_bit_xor: - case ir_binop_bit_or: - emit(ir, OPCODE_ADD, result_dst, op[0], op[1]); - break; - - case ir_unop_bit_not: - case ir_unop_round_even: - emit(ir, OPCODE_MOV, result_dst, op[0]); - break; - - case ir_quadop_vector: - /* This operation should have already been handled. - */ - assert(!"Should not get here."); - break; - } - - this->result = result_src; -} - - -void -ir_to_mesa_visitor::visit(ir_swizzle *ir) -{ - src_reg src; - int i; - int swizzle[4]; - - /* Note that this is only swizzles in expressions, not those on the left - * hand side of an assignment, which do write masking. See ir_assignment - * for that. - */ - - ir->val->accept(this); - src = this->result; - assert(src.file != PROGRAM_UNDEFINED); - - for (i = 0; i < 4; i++) { - if (i < ir->type->vector_elements) { - switch (i) { - case 0: - swizzle[i] = GET_SWZ(src.swizzle, ir->mask.x); - break; - case 1: - swizzle[i] = GET_SWZ(src.swizzle, ir->mask.y); - break; - case 2: - swizzle[i] = GET_SWZ(src.swizzle, ir->mask.z); - break; - case 3: - swizzle[i] = GET_SWZ(src.swizzle, ir->mask.w); - break; - } - } else { - /* If the type is smaller than a vec4, replicate the last - * channel out. - */ - swizzle[i] = swizzle[ir->type->vector_elements - 1]; - } - } - - src.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1], swizzle[2], swizzle[3]); - - this->result = src; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_variable *ir) -{ - variable_storage *entry = find_variable_storage(ir->var); - ir_variable *var = ir->var; - - if (!entry) { - switch (var->mode) { - case ir_var_uniform: - entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM, - var->location); - this->variables.push_tail(entry); - break; - case ir_var_in: - case ir_var_inout: - /* The linker assigns locations for varyings and attributes, - * including deprecated builtins (like gl_Color), - * user-assigned generic attributes (glBindVertexLocation), - * and user-defined varyings. - * - * FINISHME: We would hit this path for function arguments. Fix! - */ - assert(var->location != -1); - entry = new(mem_ctx) variable_storage(var, - PROGRAM_INPUT, - var->location); - break; - case ir_var_out: - assert(var->location != -1); - entry = new(mem_ctx) variable_storage(var, - PROGRAM_OUTPUT, - var->location); - break; - case ir_var_system_value: - entry = new(mem_ctx) variable_storage(var, - PROGRAM_SYSTEM_VALUE, - var->location); - break; - case ir_var_auto: - case ir_var_temporary: - entry = new(mem_ctx) variable_storage(var, PROGRAM_TEMPORARY, - this->next_temp); - this->variables.push_tail(entry); - - next_temp += type_size(var->type); - break; - } - - if (!entry) { - printf("Failed to make storage for %s\n", var->name); - exit(1); - } - } - - this->result = src_reg(entry->file, entry->index, var->type); -} - -void -ir_to_mesa_visitor::visit(ir_dereference_array *ir) -{ - ir_constant *index; - src_reg src; - int element_size = type_size(ir->type); - - index = ir->array_index->constant_expression_value(); - - ir->array->accept(this); - src = this->result; - - if (index) { - src.index += index->value.i[0] * element_size; - } else { - /* Variable index array dereference. It eats the "vec4" of the - * base of the array and an index that offsets the Mesa register - * index. - */ - ir->array_index->accept(this); - - src_reg index_reg; - - if (element_size == 1) { - index_reg = this->result; - } else { - index_reg = get_temp(glsl_type::float_type); - - emit(ir, OPCODE_MUL, dst_reg(index_reg), - this->result, src_reg_for_float(element_size)); - } - - /* If there was already a relative address register involved, add the - * new and the old together to get the new offset. - */ - if (src.reladdr != NULL) { - src_reg accum_reg = get_temp(glsl_type::float_type); - - emit(ir, OPCODE_ADD, dst_reg(accum_reg), - index_reg, *src.reladdr); - - index_reg = accum_reg; - } - - src.reladdr = ralloc(mem_ctx, src_reg); - memcpy(src.reladdr, &index_reg, sizeof(index_reg)); - } - - /* If the type is smaller than a vec4, replicate the last channel out. */ - if (ir->type->is_scalar() || ir->type->is_vector()) - src.swizzle = swizzle_for_size(ir->type->vector_elements); - else - src.swizzle = SWIZZLE_NOOP; - - this->result = src; -} - -void -ir_to_mesa_visitor::visit(ir_dereference_record *ir) -{ - unsigned int i; - const glsl_type *struct_type = ir->record->type; - int offset = 0; - - ir->record->accept(this); - - for (i = 0; i < struct_type->length; i++) { - if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0) - break; - offset += type_size(struct_type->fields.structure[i].type); - } - - /* If the type is smaller than a vec4, replicate the last channel out. */ - if (ir->type->is_scalar() || ir->type->is_vector()) - this->result.swizzle = swizzle_for_size(ir->type->vector_elements); - else - this->result.swizzle = SWIZZLE_NOOP; - - this->result.index += offset; -} - -/** - * We want to be careful in assignment setup to hit the actual storage - * instead of potentially using a temporary like we might with the - * ir_dereference handler. - */ -static dst_reg -get_assignment_lhs(ir_dereference *ir, ir_to_mesa_visitor *v) -{ - /* The LHS must be a dereference. If the LHS is a variable indexed array - * access of a vector, it must be separated into a series conditional moves - * before reaching this point (see ir_vec_index_to_cond_assign). - */ - assert(ir->as_dereference()); - ir_dereference_array *deref_array = ir->as_dereference_array(); - if (deref_array) { - assert(!deref_array->array->type->is_vector()); - } - - /* Use the rvalue deref handler for the most part. We'll ignore - * swizzles in it and write swizzles using writemask, though. - */ - ir->accept(v); - return dst_reg(v->result); -} - -/** - * Process the condition of a conditional assignment - * - * Examines the condition of a conditional assignment to generate the optimal - * first operand of a \c CMP instruction. If the condition is a relational - * operator with 0 (e.g., \c ir_binop_less), the value being compared will be - * used as the source for the \c CMP instruction. Otherwise the comparison - * is processed to a boolean result, and the boolean result is used as the - * operand to the CMP instruction. - */ -bool -ir_to_mesa_visitor::process_move_condition(ir_rvalue *ir) -{ - ir_rvalue *src_ir = ir; - bool negate = true; - bool switch_order = false; - - ir_expression *const expr = ir->as_expression(); - if ((expr != NULL) && (expr->get_num_operands() == 2)) { - bool zero_on_left = false; - - if (expr->operands[0]->is_zero()) { - src_ir = expr->operands[1]; - zero_on_left = true; - } else if (expr->operands[1]->is_zero()) { - src_ir = expr->operands[0]; - zero_on_left = false; - } - - /* a is - 0 + - 0 + - * (a < 0) T F F ( a < 0) T F F - * (0 < a) F F T (-a < 0) F F T - * (a <= 0) T T F (-a < 0) F F T (swap order of other operands) - * (0 <= a) F T T ( a < 0) T F F (swap order of other operands) - * (a > 0) F F T (-a < 0) F F T - * (0 > a) T F F ( a < 0) T F F - * (a >= 0) F T T ( a < 0) T F F (swap order of other operands) - * (0 >= a) T T F (-a < 0) F F T (swap order of other operands) - * - * Note that exchanging the order of 0 and 'a' in the comparison simply - * means that the value of 'a' should be negated. - */ - if (src_ir != ir) { - switch (expr->operation) { - case ir_binop_less: - switch_order = false; - negate = zero_on_left; - break; - - case ir_binop_greater: - switch_order = false; - negate = !zero_on_left; - break; - - case ir_binop_lequal: - switch_order = true; - negate = !zero_on_left; - break; - - case ir_binop_gequal: - switch_order = true; - negate = zero_on_left; - break; - - default: - /* This isn't the right kind of comparison afterall, so make sure - * the whole condition is visited. - */ - src_ir = ir; - break; - } - } - } - - src_ir->accept(this); - - /* We use the OPCODE_CMP (a < 0 ? b : c) for conditional moves, and the - * condition we produced is 0.0 or 1.0. By flipping the sign, we can - * choose which value OPCODE_CMP produces without an extra instruction - * computing the condition. - */ - if (negate) - this->result.negate = ~this->result.negate; - - return switch_order; -} - -void -ir_to_mesa_visitor::visit(ir_assignment *ir) -{ - dst_reg l; - src_reg r; - int i; - - ir->rhs->accept(this); - r = this->result; - - l = get_assignment_lhs(ir->lhs, this); - - /* FINISHME: This should really set to the correct maximal writemask for each - * FINISHME: component written (in the loops below). This case can only - * FINISHME: occur for matrices, arrays, and structures. - */ - if (ir->write_mask == 0) { - assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector()); - l.writemask = WRITEMASK_XYZW; - } else if (ir->lhs->type->is_scalar()) { - /* FINISHME: This hack makes writing to gl_FragDepth, which lives in the - * FINISHME: W component of fragment shader output zero, work correctly. - */ - l.writemask = WRITEMASK_XYZW; - } else { - int swizzles[4]; - int first_enabled_chan = 0; - int rhs_chan = 0; - - assert(ir->lhs->type->is_vector()); - l.writemask = ir->write_mask; - - for (int i = 0; i < 4; i++) { - if (l.writemask & (1 << i)) { - first_enabled_chan = GET_SWZ(r.swizzle, i); - break; - } - } - - /* Swizzle a small RHS vector into the channels being written. - * - * glsl ir treats write_mask as dictating how many channels are - * present on the RHS while Mesa IR treats write_mask as just - * showing which channels of the vec4 RHS get written. - */ - for (int i = 0; i < 4; i++) { - if (l.writemask & (1 << i)) - swizzles[i] = GET_SWZ(r.swizzle, rhs_chan++); - else - swizzles[i] = first_enabled_chan; - } - r.swizzle = MAKE_SWIZZLE4(swizzles[0], swizzles[1], - swizzles[2], swizzles[3]); - } - - assert(l.file != PROGRAM_UNDEFINED); - assert(r.file != PROGRAM_UNDEFINED); - - if (ir->condition) { - const bool switch_order = this->process_move_condition(ir->condition); - src_reg condition = this->result; - - for (i = 0; i < type_size(ir->lhs->type); i++) { - if (switch_order) { - emit(ir, OPCODE_CMP, l, condition, src_reg(l), r); - } else { - emit(ir, OPCODE_CMP, l, condition, r, src_reg(l)); - } - - l.index++; - r.index++; - } - } else { - for (i = 0; i < type_size(ir->lhs->type); i++) { - emit(ir, OPCODE_MOV, l, r); - l.index++; - r.index++; - } - } -} - - -void -ir_to_mesa_visitor::visit(ir_constant *ir) -{ - src_reg src; - GLfloat stack_vals[4] = { 0 }; - GLfloat *values = stack_vals; - unsigned int i; - - /* Unfortunately, 4 floats is all we can get into - * _mesa_add_unnamed_constant. So, make a temp to store an - * aggregate constant and move each constant value into it. If we - * get lucky, copy propagation will eliminate the extra moves. - */ - - if (ir->type->base_type == GLSL_TYPE_STRUCT) { - src_reg temp_base = get_temp(ir->type); - dst_reg temp = dst_reg(temp_base); - - foreach_iter(exec_list_iterator, iter, ir->components) { - ir_constant *field_value = (ir_constant *)iter.get(); - int size = type_size(field_value->type); - - assert(size > 0); - - field_value->accept(this); - src = this->result; - - for (i = 0; i < (unsigned int)size; i++) { - emit(ir, OPCODE_MOV, temp, src); - - src.index++; - temp.index++; - } - } - this->result = temp_base; - return; - } - - if (ir->type->is_array()) { - src_reg temp_base = get_temp(ir->type); - dst_reg temp = dst_reg(temp_base); - int size = type_size(ir->type->fields.array); - - assert(size > 0); - - for (i = 0; i < ir->type->length; i++) { - ir->array_elements[i]->accept(this); - src = this->result; - for (int j = 0; j < size; j++) { - emit(ir, OPCODE_MOV, temp, src); - - src.index++; - temp.index++; - } - } - this->result = temp_base; - return; - } - - if (ir->type->is_matrix()) { - src_reg mat = get_temp(ir->type); - dst_reg mat_column = dst_reg(mat); - - for (i = 0; i < ir->type->matrix_columns; i++) { - assert(ir->type->base_type == GLSL_TYPE_FLOAT); - values = &ir->value.f[i * ir->type->vector_elements]; - - src = src_reg(PROGRAM_CONSTANT, -1, NULL); - src.index = _mesa_add_unnamed_constant(this->prog->Parameters, - (gl_constant_value *) values, - ir->type->vector_elements, - &src.swizzle); - emit(ir, OPCODE_MOV, mat_column, src); - - mat_column.index++; - } - - this->result = mat; - return; - } - - src.file = PROGRAM_CONSTANT; - switch (ir->type->base_type) { - case GLSL_TYPE_FLOAT: - values = &ir->value.f[0]; - break; - case GLSL_TYPE_UINT: - for (i = 0; i < ir->type->vector_elements; i++) { - values[i] = ir->value.u[i]; - } - break; - case GLSL_TYPE_INT: - for (i = 0; i < ir->type->vector_elements; i++) { - values[i] = ir->value.i[i]; - } - break; - case GLSL_TYPE_BOOL: - for (i = 0; i < ir->type->vector_elements; i++) { - values[i] = ir->value.b[i]; - } - break; - default: - assert(!"Non-float/uint/int/bool constant"); - } - - this->result = src_reg(PROGRAM_CONSTANT, -1, ir->type); - this->result.index = _mesa_add_unnamed_constant(this->prog->Parameters, - (gl_constant_value *) values, - ir->type->vector_elements, - &this->result.swizzle); -} - -function_entry * -ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig) -{ - function_entry *entry; - - foreach_iter(exec_list_iterator, iter, this->function_signatures) { - entry = (function_entry *)iter.get(); - - if (entry->sig == sig) - return entry; - } - - entry = ralloc(mem_ctx, function_entry); - entry->sig = sig; - entry->sig_id = this->next_signature_id++; - entry->bgn_inst = NULL; - - /* Allocate storage for all the parameters. */ - foreach_iter(exec_list_iterator, iter, sig->parameters) { - ir_variable *param = (ir_variable *)iter.get(); - variable_storage *storage; - - storage = find_variable_storage(param); - assert(!storage); - - storage = new(mem_ctx) variable_storage(param, PROGRAM_TEMPORARY, - this->next_temp); - this->variables.push_tail(storage); - - this->next_temp += type_size(param->type); - } - - if (!sig->return_type->is_void()) { - entry->return_reg = get_temp(sig->return_type); - } else { - entry->return_reg = undef_src; - } - - this->function_signatures.push_tail(entry); - return entry; -} - -void -ir_to_mesa_visitor::visit(ir_call *ir) -{ - ir_to_mesa_instruction *call_inst; - ir_function_signature *sig = ir->get_callee(); - function_entry *entry = get_function_signature(sig); - int i; - - /* Process in parameters. */ - exec_list_iterator sig_iter = sig->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param_rval = (ir_rvalue *)iter.get(); - ir_variable *param = (ir_variable *)sig_iter.get(); - - if (param->mode == ir_var_in || - param->mode == ir_var_inout) { - variable_storage *storage = find_variable_storage(param); - assert(storage); - - param_rval->accept(this); - src_reg r = this->result; - - dst_reg l; - l.file = storage->file; - l.index = storage->index; - l.reladdr = NULL; - l.writemask = WRITEMASK_XYZW; - l.cond_mask = COND_TR; - - for (i = 0; i < type_size(param->type); i++) { - emit(ir, OPCODE_MOV, l, r); - l.index++; - r.index++; - } - } - - sig_iter.next(); - } - assert(!sig_iter.has_next()); - - /* Emit call instruction */ - call_inst = emit(ir, OPCODE_CAL); - call_inst->function = entry; - - /* Process out parameters. */ - sig_iter = sig->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param_rval = (ir_rvalue *)iter.get(); - ir_variable *param = (ir_variable *)sig_iter.get(); - - if (param->mode == ir_var_out || - param->mode == ir_var_inout) { - variable_storage *storage = find_variable_storage(param); - assert(storage); - - src_reg r; - r.file = storage->file; - r.index = storage->index; - r.reladdr = NULL; - r.swizzle = SWIZZLE_NOOP; - r.negate = 0; - - param_rval->accept(this); - dst_reg l = dst_reg(this->result); - - for (i = 0; i < type_size(param->type); i++) { - emit(ir, OPCODE_MOV, l, r); - l.index++; - r.index++; - } - } - - sig_iter.next(); - } - assert(!sig_iter.has_next()); - - /* Process return value. */ - this->result = entry->return_reg; -} - -void -ir_to_mesa_visitor::visit(ir_texture *ir) -{ - src_reg result_src, coord, lod_info, projector, dx, dy; - dst_reg result_dst, coord_dst; - ir_to_mesa_instruction *inst = NULL; - prog_opcode opcode = OPCODE_NOP; - - if (ir->op == ir_txs) - this->result = src_reg_for_float(0.0); - else - ir->coordinate->accept(this); - - /* Put our coords in a temp. We'll need to modify them for shadow, - * projection, or LOD, so the only case we'd use it as is is if - * we're doing plain old texturing. Mesa IR optimization should - * handle cleaning up our mess in that case. - */ - coord = get_temp(glsl_type::vec4_type); - coord_dst = dst_reg(coord); - emit(ir, OPCODE_MOV, coord_dst, this->result); - - if (ir->projector) { - ir->projector->accept(this); - projector = this->result; - } - - /* Storage for our result. Ideally for an assignment we'd be using - * the actual storage for the result here, instead. - */ - result_src = get_temp(glsl_type::vec4_type); - result_dst = dst_reg(result_src); - - switch (ir->op) { - case ir_tex: - case ir_txs: - opcode = OPCODE_TEX; - break; - case ir_txb: - opcode = OPCODE_TXB; - ir->lod_info.bias->accept(this); - lod_info = this->result; - break; - case ir_txf: - /* Pretend to be TXL so the sampler, coordinate, lod are available */ - case ir_txl: - opcode = OPCODE_TXL; - ir->lod_info.lod->accept(this); - lod_info = this->result; - break; - case ir_txd: - opcode = OPCODE_TXD; - ir->lod_info.grad.dPdx->accept(this); - dx = this->result; - ir->lod_info.grad.dPdy->accept(this); - dy = this->result; - break; - } - - const glsl_type *sampler_type = ir->sampler->type; - - if (ir->projector) { - if (opcode == OPCODE_TEX) { - /* Slot the projector in as the last component of the coord. */ - coord_dst.writemask = WRITEMASK_W; - emit(ir, OPCODE_MOV, coord_dst, projector); - coord_dst.writemask = WRITEMASK_XYZW; - opcode = OPCODE_TXP; - } else { - src_reg coord_w = coord; - coord_w.swizzle = SWIZZLE_WWWW; - - /* For the other TEX opcodes there's no projective version - * since the last slot is taken up by lod info. Do the - * projective divide now. - */ - coord_dst.writemask = WRITEMASK_W; - emit(ir, OPCODE_RCP, coord_dst, projector); - - /* In the case where we have to project the coordinates "by hand," - * the shadow comparitor value must also be projected. - */ - src_reg tmp_src = coord; - if (ir->shadow_comparitor) { - /* Slot the shadow value in as the second to last component of the - * coord. - */ - ir->shadow_comparitor->accept(this); - - tmp_src = get_temp(glsl_type::vec4_type); - dst_reg tmp_dst = dst_reg(tmp_src); - - tmp_dst.writemask = WRITEMASK_Z; - emit(ir, OPCODE_MOV, tmp_dst, this->result); - - tmp_dst.writemask = WRITEMASK_XY; - emit(ir, OPCODE_MOV, tmp_dst, coord); - } - - coord_dst.writemask = WRITEMASK_XYZ; - emit(ir, OPCODE_MUL, coord_dst, tmp_src, coord_w); - - coord_dst.writemask = WRITEMASK_XYZW; - coord.swizzle = SWIZZLE_XYZW; - } - } - - /* If projection is done and the opcode is not OPCODE_TXP, then the shadow - * comparitor was put in the correct place (and projected) by the code, - * above, that handles by-hand projection. - */ - if (ir->shadow_comparitor && (!ir->projector || opcode == OPCODE_TXP)) { - /* Slot the shadow value in as the second to last component of the - * coord. - */ - ir->shadow_comparitor->accept(this); - - /* XXX This will need to be updated for cubemap array samplers. */ - coord_dst.writemask = WRITEMASK_Z; - - emit(ir, OPCODE_MOV, coord_dst, this->result); - coord_dst.writemask = WRITEMASK_XYZW; - } - - if (opcode == OPCODE_TXL || opcode == OPCODE_TXB) { - /* Mesa IR stores lod or lod bias in the last channel of the coords. */ - coord_dst.writemask = WRITEMASK_W; - emit(ir, OPCODE_MOV, coord_dst, lod_info); - coord_dst.writemask = WRITEMASK_XYZW; - } - - if (opcode == OPCODE_TXD) - inst = emit(ir, opcode, result_dst, coord, dx, dy); - else - inst = emit(ir, opcode, result_dst, coord); - - if (ir->shadow_comparitor) - inst->tex_shadow = GL_TRUE; - - inst->sampler = _mesa_get_sampler_uniform_value(ir->sampler, - this->shader_program, - this->prog); - - switch (sampler_type->sampler_dimensionality) { - case GLSL_SAMPLER_DIM_1D: - inst->tex_target = TEXTURE_1D_INDEX; - break; - case GLSL_SAMPLER_DIM_2D: - inst->tex_target = TEXTURE_2D_INDEX; - break; - case GLSL_SAMPLER_DIM_3D: - inst->tex_target = TEXTURE_3D_INDEX; - break; - case GLSL_SAMPLER_DIM_CUBE: - inst->tex_target = TEXTURE_CUBE_INDEX; - break; - default: - assert(!"Should not get here."); - } - - this->result = result_src; -} - -void -ir_to_mesa_visitor::visit(ir_return *ir) -{ - if (ir->get_value()) { - dst_reg l; - int i; - - assert(current_function); - - ir->get_value()->accept(this); - src_reg r = this->result; - - l = dst_reg(current_function->return_reg); - - for (i = 0; i < type_size(current_function->sig->return_type); i++) { - emit(ir, OPCODE_MOV, l, r); - l.index++; - r.index++; - } - } - - emit(ir, OPCODE_RET); -} - -void -ir_to_mesa_visitor::visit(ir_discard *ir) -{ - struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog; - - if (ir->condition) { - ir->condition->accept(this); - this->result.negate = ~this->result.negate; - emit(ir, OPCODE_KIL, undef_dst, this->result); - } else { - emit(ir, OPCODE_KIL_NV); - } - - fp->UsesKill = GL_TRUE; -} - -void -ir_to_mesa_visitor::visit(ir_if *ir) -{ - ir_to_mesa_instruction *cond_inst, *if_inst; - ir_to_mesa_instruction *prev_inst; - - prev_inst = (ir_to_mesa_instruction *)this->instructions.get_tail(); - - ir->condition->accept(this); - assert(this->result.file != PROGRAM_UNDEFINED); - - if (this->options->EmitCondCodes) { - cond_inst = (ir_to_mesa_instruction *)this->instructions.get_tail(); - - /* See if we actually generated any instruction for generating - * the condition. If not, then cook up a move to a temp so we - * have something to set cond_update on. - */ - if (cond_inst == prev_inst) { - src_reg temp = get_temp(glsl_type::bool_type); - cond_inst = emit(ir->condition, OPCODE_MOV, dst_reg(temp), result); - } - cond_inst->cond_update = GL_TRUE; - - if_inst = emit(ir->condition, OPCODE_IF); - if_inst->dst.cond_mask = COND_NE; - } else { - if_inst = emit(ir->condition, OPCODE_IF, undef_dst, this->result); - } - - this->instructions.push_tail(if_inst); - - visit_exec_list(&ir->then_instructions, this); - - if (!ir->else_instructions.is_empty()) { - emit(ir->condition, OPCODE_ELSE); - visit_exec_list(&ir->else_instructions, this); - } - - if_inst = emit(ir->condition, OPCODE_ENDIF); -} - -ir_to_mesa_visitor::ir_to_mesa_visitor() -{ - result.file = PROGRAM_UNDEFINED; - next_temp = 1; - next_signature_id = 1; - current_function = NULL; - mem_ctx = ralloc_context(NULL); -} - -ir_to_mesa_visitor::~ir_to_mesa_visitor() -{ - ralloc_free(mem_ctx); -} - -static struct prog_src_register -mesa_src_reg_from_ir_src_reg(src_reg reg) -{ - struct prog_src_register mesa_reg; - - mesa_reg.File = reg.file; - assert(reg.index < (1 << INST_INDEX_BITS)); - mesa_reg.Index = reg.index; - mesa_reg.Swizzle = reg.swizzle; - mesa_reg.RelAddr = reg.reladdr != NULL; - mesa_reg.Negate = reg.negate; - mesa_reg.Abs = 0; - mesa_reg.HasIndex2 = GL_FALSE; - mesa_reg.RelAddr2 = 0; - mesa_reg.Index2 = 0; - - return mesa_reg; -} - -static void -set_branchtargets(ir_to_mesa_visitor *v, - struct prog_instruction *mesa_instructions, - int num_instructions) -{ - int if_count = 0, loop_count = 0; - int *if_stack, *loop_stack; - int if_stack_pos = 0, loop_stack_pos = 0; - int i, j; - - for (i = 0; i < num_instructions; i++) { - switch (mesa_instructions[i].Opcode) { - case OPCODE_IF: - if_count++; - break; - case OPCODE_BGNLOOP: - loop_count++; - break; - case OPCODE_BRK: - case OPCODE_CONT: - mesa_instructions[i].BranchTarget = -1; - break; - default: - break; - } - } - - if_stack = rzalloc_array(v->mem_ctx, int, if_count); - loop_stack = rzalloc_array(v->mem_ctx, int, loop_count); - - for (i = 0; i < num_instructions; i++) { - switch (mesa_instructions[i].Opcode) { - case OPCODE_IF: - if_stack[if_stack_pos] = i; - if_stack_pos++; - break; - case OPCODE_ELSE: - mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; - if_stack[if_stack_pos - 1] = i; - break; - case OPCODE_ENDIF: - mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i; - if_stack_pos--; - break; - case OPCODE_BGNLOOP: - loop_stack[loop_stack_pos] = i; - loop_stack_pos++; - break; - case OPCODE_ENDLOOP: - loop_stack_pos--; - /* Rewrite any breaks/conts at this nesting level (haven't - * already had a BranchTarget assigned) to point to the end - * of the loop. - */ - for (j = loop_stack[loop_stack_pos]; j < i; j++) { - if (mesa_instructions[j].Opcode == OPCODE_BRK || - mesa_instructions[j].Opcode == OPCODE_CONT) { - if (mesa_instructions[j].BranchTarget == -1) { - mesa_instructions[j].BranchTarget = i; - } - } - } - /* The loop ends point at each other. */ - mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos]; - mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i; - break; - case OPCODE_CAL: - foreach_iter(exec_list_iterator, iter, v->function_signatures) { - function_entry *entry = (function_entry *)iter.get(); - - if (entry->sig_id == mesa_instructions[i].BranchTarget) { - mesa_instructions[i].BranchTarget = entry->inst; - break; - } - } - break; - default: - break; - } - } -} - -static void -print_program(struct prog_instruction *mesa_instructions, - ir_instruction **mesa_instruction_annotation, - int num_instructions) -{ - ir_instruction *last_ir = NULL; - int i; - int indent = 0; - - for (i = 0; i < num_instructions; i++) { - struct prog_instruction *mesa_inst = mesa_instructions + i; - ir_instruction *ir = mesa_instruction_annotation[i]; - - fprintf(stdout, "%3d: ", i); - - if (last_ir != ir && ir) { - int j; - - for (j = 0; j < indent; j++) { - fprintf(stdout, " "); - } - ir->print(); - printf("\n"); - last_ir = ir; - - fprintf(stdout, " "); /* line number spacing. */ - } - - indent = _mesa_fprint_instruction_opt(stdout, mesa_inst, indent, - PROG_PRINT_DEBUG, NULL); - } -} - -class add_uniform_to_shader : public uniform_field_visitor { -public: - add_uniform_to_shader(struct gl_shader_program *shader_program, - struct gl_program_parameter_list *params) - : shader_program(shader_program), params(params), idx(-1) - { - /* empty */ - } - - void process(ir_variable *var) - { - this->idx = -1; - this->uniform_field_visitor::process(var); - - var->location = this->idx; - } - -private: - virtual void visit_field(const glsl_type *type, const char *name); - - struct gl_shader_program *shader_program; - struct gl_program_parameter_list *params; - int idx; -}; - -void -add_uniform_to_shader::visit_field(const glsl_type *type, const char *name) -{ - unsigned int size; - - if (type->is_vector() || type->is_scalar()) { - size = type->vector_elements; - } else { - size = type_size(type) * 4; - } - - gl_register_file file; - if (type->is_sampler() || - (type->is_array() && type->fields.array->is_sampler())) { - file = PROGRAM_SAMPLER; - } else { - file = PROGRAM_UNIFORM; - } - - int index = _mesa_lookup_parameter_index(params, -1, name); - if (index < 0) { - index = _mesa_add_parameter(params, file, name, size, type->gl_type, - NULL, NULL, 0x0); - - /* Sampler uniform values are stored in prog->SamplerUnits, - * and the entry in that array is selected by this index we - * store in ParameterValues[]. - */ - if (file == PROGRAM_SAMPLER) { - unsigned location; - const bool found = - this->shader_program->UniformHash->get(location, - params->Parameters[index].Name); - assert(found); - - if (!found) - return; - - struct gl_uniform_storage *storage = - &this->shader_program->UniformStorage[location]; - - for (unsigned int j = 0; j < size / 4; j++) - params->ParameterValues[index + j][0].f = storage->sampler + j; - } - } - - /* The first part of the uniform that's processed determines the base - * location of the whole uniform (for structures). - */ - if (this->idx < 0) - this->idx = index; -} - -/** - * Generate the program parameters list for the user uniforms in a shader - * - * \param shader_program Linked shader program. This is only used to - * emit possible link errors to the info log. - * \param sh Shader whose uniforms are to be processed. - * \param params Parameter list to be filled in. - */ -void -_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program - *shader_program, - struct gl_shader *sh, - struct gl_program_parameter_list - *params) -{ - add_uniform_to_shader add(shader_program, params); - - foreach_list(node, sh->ir) { - ir_variable *var = ((ir_instruction *) node)->as_variable(); - - if ((var == NULL) || (var->mode != ir_var_uniform) - || (strncmp(var->name, "gl_", 3) == 0)) - continue; - - add.process(var); - } -} - -void -_mesa_associate_uniform_storage(struct gl_context *ctx, - struct gl_shader_program *shader_program, - struct gl_program_parameter_list *params) -{ - /* After adding each uniform to the parameter list, connect the storage for - * the parameter with the tracking structure used by the API for the - * uniform. - */ - unsigned last_location = unsigned(~0); - for (unsigned i = 0; i < params->NumParameters; i++) { - if (params->Parameters[i].Type != PROGRAM_UNIFORM) - continue; - - unsigned location; - const bool found = - shader_program->UniformHash->get(location, params->Parameters[i].Name); - assert(found); - - if (!found) - continue; - - if (location != last_location) { - struct gl_uniform_storage *storage = - &shader_program->UniformStorage[location]; - enum gl_uniform_driver_format format = uniform_native; - - unsigned columns = 0; - switch (storage->type->base_type) { - case GLSL_TYPE_UINT: - assert(ctx->Const.NativeIntegers); - format = uniform_native; - columns = 1; - break; - case GLSL_TYPE_INT: - format = - (ctx->Const.NativeIntegers) ? uniform_native : uniform_int_float; - columns = 1; - break; - case GLSL_TYPE_FLOAT: - format = uniform_native; - columns = storage->type->matrix_columns; - break; - case GLSL_TYPE_BOOL: - if (ctx->Const.NativeIntegers) { - format = (ctx->Const.UniformBooleanTrue == 1) - ? uniform_bool_int_0_1 : uniform_bool_int_0_not0; - } else { - format = uniform_bool_float; - } - columns = 1; - break; - case GLSL_TYPE_SAMPLER: - format = uniform_native; - columns = 1; - break; - default: - assert(!"Should not get here."); - break; - } - - _mesa_uniform_attach_driver_storage(storage, - 4 * sizeof(float) * columns, - 4 * sizeof(float), - format, - ¶ms->ParameterValues[i]); - last_location = location; - } - } -} - -static void -set_uniform_initializer(struct gl_context *ctx, void *mem_ctx, - struct gl_shader_program *shader_program, - const char *name, const glsl_type *type, - ir_constant *val) -{ - if (type->is_record()) { - ir_constant *field_constant; - - field_constant = (ir_constant *)val->components.get_head(); - - for (unsigned int i = 0; i < type->length; i++) { - const glsl_type *field_type = type->fields.structure[i].type; - const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name, - type->fields.structure[i].name); - set_uniform_initializer(ctx, mem_ctx, shader_program, field_name, - field_type, field_constant); - field_constant = (ir_constant *)field_constant->next; - } - return; - } - - int loc = _mesa_get_uniform_location(ctx, shader_program, name); - - if (loc == -1) { - linker_error(shader_program, - "Couldn't find uniform for initializer %s\n", name); - return; - } - - for (unsigned int i = 0; i < (type->is_array() ? type->length : 1); i++) { - ir_constant *element; - const glsl_type *element_type; - if (type->is_array()) { - element = val->array_elements[i]; - element_type = type->fields.array; - } else { - element = val; - element_type = type; - } - - void *values; - - if (element_type->base_type == GLSL_TYPE_BOOL) { - int *conv = ralloc_array(mem_ctx, int, element_type->components()); - for (unsigned int j = 0; j < element_type->components(); j++) { - conv[j] = element->value.b[j]; - } - values = (void *)conv; - element_type = glsl_type::get_instance(GLSL_TYPE_INT, - element_type->vector_elements, - 1); - } else { - values = &element->value; - } - - if (element_type->is_matrix()) { - _mesa_uniform_matrix(ctx, shader_program, - element_type->matrix_columns, - element_type->vector_elements, - loc, 1, GL_FALSE, (GLfloat *)values); - } else { - _mesa_uniform(ctx, shader_program, loc, element_type->matrix_columns, - values, element_type->gl_type); - } - - loc++; - } -} - -static void -set_uniform_initializers(struct gl_context *ctx, - struct gl_shader_program *shader_program) -{ - void *mem_ctx = NULL; - - for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) { - struct gl_shader *shader = shader_program->_LinkedShaders[i]; - - if (shader == NULL) - continue; - - foreach_iter(exec_list_iterator, iter, *shader->ir) { - ir_instruction *ir = (ir_instruction *)iter.get(); - ir_variable *var = ir->as_variable(); - - if (!var || var->mode != ir_var_uniform || !var->constant_value) - continue; - - if (!mem_ctx) - mem_ctx = ralloc_context(NULL); - - set_uniform_initializer(ctx, mem_ctx, shader_program, var->name, - var->type, var->constant_value); - } - } - - ralloc_free(mem_ctx); -} - -/* - * On a basic block basis, tracks available PROGRAM_TEMPORARY register - * channels for copy propagation and updates following instructions to - * use the original versions. - * - * The ir_to_mesa_visitor lazily produces code assuming that this pass - * will occur. As an example, a TXP production before this pass: - * - * 0: MOV TEMP[1], INPUT[4].xyyy; - * 1: MOV TEMP[1].w, INPUT[4].wwww; - * 2: TXP TEMP[2], TEMP[1], texture[0], 2D; - * - * and after: - * - * 0: MOV TEMP[1], INPUT[4].xyyy; - * 1: MOV TEMP[1].w, INPUT[4].wwww; - * 2: TXP TEMP[2], INPUT[4].xyyw, texture[0], 2D; - * - * which allows for dead code elimination on TEMP[1]'s writes. - */ -void -ir_to_mesa_visitor::copy_propagate(void) -{ - ir_to_mesa_instruction **acp = rzalloc_array(mem_ctx, - ir_to_mesa_instruction *, - this->next_temp * 4); - int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4); - int level = 0; - - foreach_iter(exec_list_iterator, iter, this->instructions) { - ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); - - assert(inst->dst.file != PROGRAM_TEMPORARY - || inst->dst.index < this->next_temp); - - /* First, do any copy propagation possible into the src regs. */ - for (int r = 0; r < 3; r++) { - ir_to_mesa_instruction *first = NULL; - bool good = true; - int acp_base = inst->src[r].index * 4; - - if (inst->src[r].file != PROGRAM_TEMPORARY || - inst->src[r].reladdr) - continue; - - /* See if we can find entries in the ACP consisting of MOVs - * from the same src register for all the swizzled channels - * of this src register reference. - */ - for (int i = 0; i < 4; i++) { - int src_chan = GET_SWZ(inst->src[r].swizzle, i); - ir_to_mesa_instruction *copy_chan = acp[acp_base + src_chan]; - - if (!copy_chan) { - good = false; - break; - } - - assert(acp_level[acp_base + src_chan] <= level); - - if (!first) { - first = copy_chan; - } else { - if (first->src[0].file != copy_chan->src[0].file || - first->src[0].index != copy_chan->src[0].index) { - good = false; - break; - } - } - } - - if (good) { - /* We've now validated that we can copy-propagate to - * replace this src register reference. Do it. - */ - inst->src[r].file = first->src[0].file; - inst->src[r].index = first->src[0].index; - - int swizzle = 0; - for (int i = 0; i < 4; i++) { - int src_chan = GET_SWZ(inst->src[r].swizzle, i); - ir_to_mesa_instruction *copy_inst = acp[acp_base + src_chan]; - swizzle |= (GET_SWZ(copy_inst->src[0].swizzle, src_chan) << - (3 * i)); - } - inst->src[r].swizzle = swizzle; - } - } - - switch (inst->op) { - case OPCODE_BGNLOOP: - case OPCODE_ENDLOOP: - /* End of a basic block, clear the ACP entirely. */ - memset(acp, 0, sizeof(*acp) * this->next_temp * 4); - break; - - case OPCODE_IF: - ++level; - break; - - case OPCODE_ENDIF: - case OPCODE_ELSE: - /* Clear all channels written inside the block from the ACP, but - * leaving those that were not touched. - */ - for (int r = 0; r < this->next_temp; r++) { - for (int c = 0; c < 4; c++) { - if (!acp[4 * r + c]) - continue; - - if (acp_level[4 * r + c] >= level) - acp[4 * r + c] = NULL; - } - } - if (inst->op == OPCODE_ENDIF) - --level; - break; - - default: - /* Continuing the block, clear any written channels from - * the ACP. - */ - if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.reladdr) { - /* Any temporary might be written, so no copy propagation - * across this instruction. - */ - memset(acp, 0, sizeof(*acp) * this->next_temp * 4); - } else if (inst->dst.file == PROGRAM_OUTPUT && - inst->dst.reladdr) { - /* Any output might be written, so no copy propagation - * from outputs across this instruction. - */ - for (int r = 0; r < this->next_temp; r++) { - for (int c = 0; c < 4; c++) { - if (!acp[4 * r + c]) - continue; - - if (acp[4 * r + c]->src[0].file == PROGRAM_OUTPUT) - acp[4 * r + c] = NULL; - } - } - } else if (inst->dst.file == PROGRAM_TEMPORARY || - inst->dst.file == PROGRAM_OUTPUT) { - /* Clear where it's used as dst. */ - if (inst->dst.file == PROGRAM_TEMPORARY) { - for (int c = 0; c < 4; c++) { - if (inst->dst.writemask & (1 << c)) { - acp[4 * inst->dst.index + c] = NULL; - } - } - } - - /* Clear where it's used as src. */ - for (int r = 0; r < this->next_temp; r++) { - for (int c = 0; c < 4; c++) { - if (!acp[4 * r + c]) - continue; - - int src_chan = GET_SWZ(acp[4 * r + c]->src[0].swizzle, c); - - if (acp[4 * r + c]->src[0].file == inst->dst.file && - acp[4 * r + c]->src[0].index == inst->dst.index && - inst->dst.writemask & (1 << src_chan)) - { - acp[4 * r + c] = NULL; - } - } - } - } - break; - } - - /* If this is a copy, add it to the ACP. */ - if (inst->op == OPCODE_MOV && - inst->dst.file == PROGRAM_TEMPORARY && - !inst->dst.reladdr && - !inst->saturate && - !inst->src[0].reladdr && - !inst->src[0].negate) { - for (int i = 0; i < 4; i++) { - if (inst->dst.writemask & (1 << i)) { - acp[4 * inst->dst.index + i] = inst; - acp_level[4 * inst->dst.index + i] = level; - } - } - } - } - - ralloc_free(acp_level); - ralloc_free(acp); -} - - -/** - * Convert a shader's GLSL IR into a Mesa gl_program. - */ -static struct gl_program * -get_mesa_program(struct gl_context *ctx, - struct gl_shader_program *shader_program, - struct gl_shader *shader) -{ - ir_to_mesa_visitor v; - struct prog_instruction *mesa_instructions, *mesa_inst; - ir_instruction **mesa_instruction_annotation; - int i; - struct gl_program *prog; - GLenum target; - const char *target_string; - GLboolean progress; - struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; - - switch (shader->Type) { - case GL_VERTEX_SHADER: - target = GL_VERTEX_PROGRAM_ARB; - target_string = "vertex"; - break; - case GL_FRAGMENT_SHADER: - target = GL_FRAGMENT_PROGRAM_ARB; - target_string = "fragment"; - break; - default: - assert(!"should not be reached"); - return NULL; - } - - validate_ir_tree(shader->ir); - - prog = ctx->Driver.NewProgram(ctx, target, shader_program->Name); - if (!prog) - return NULL; - prog->Parameters = _mesa_new_parameter_list(); - v.ctx = ctx; - v.prog = prog; - v.shader_program = shader_program; - v.options = options; - - _mesa_generate_parameters_list_for_uniforms(shader_program, shader, - prog->Parameters); - - /* Emit Mesa IR for main(). */ - visit_exec_list(shader->ir, &v); - v.emit(NULL, OPCODE_END); - - /* Now emit bodies for any functions that were used. */ - do { - progress = GL_FALSE; - - foreach_iter(exec_list_iterator, iter, v.function_signatures) { - function_entry *entry = (function_entry *)iter.get(); - - if (!entry->bgn_inst) { - v.current_function = entry; - - entry->bgn_inst = v.emit(NULL, OPCODE_BGNSUB); - entry->bgn_inst->function = entry; - - visit_exec_list(&entry->sig->body, &v); - - ir_to_mesa_instruction *last; - last = (ir_to_mesa_instruction *)v.instructions.get_tail(); - if (last->op != OPCODE_RET) - v.emit(NULL, OPCODE_RET); - - ir_to_mesa_instruction *end; - end = v.emit(NULL, OPCODE_ENDSUB); - end->function = entry; - - progress = GL_TRUE; - } - } - } while (progress); - - prog->NumTemporaries = v.next_temp; - - int num_instructions = 0; - foreach_iter(exec_list_iterator, iter, v.instructions) { - num_instructions++; - } - - mesa_instructions = - (struct prog_instruction *)calloc(num_instructions, - sizeof(*mesa_instructions)); - mesa_instruction_annotation = ralloc_array(v.mem_ctx, ir_instruction *, - num_instructions); - - v.copy_propagate(); - - /* Convert ir_mesa_instructions into prog_instructions. - */ - mesa_inst = mesa_instructions; - i = 0; - foreach_iter(exec_list_iterator, iter, v.instructions) { - const ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); - - mesa_inst->Opcode = inst->op; - mesa_inst->CondUpdate = inst->cond_update; - if (inst->saturate) - mesa_inst->SaturateMode = SATURATE_ZERO_ONE; - mesa_inst->DstReg.File = inst->dst.file; - mesa_inst->DstReg.Index = inst->dst.index; - mesa_inst->DstReg.CondMask = inst->dst.cond_mask; - mesa_inst->DstReg.WriteMask = inst->dst.writemask; - mesa_inst->DstReg.RelAddr = inst->dst.reladdr != NULL; - mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src[0]); - mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src[1]); - mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src[2]); - mesa_inst->TexSrcUnit = inst->sampler; - mesa_inst->TexSrcTarget = inst->tex_target; - mesa_inst->TexShadow = inst->tex_shadow; - mesa_instruction_annotation[i] = inst->ir; - - /* Set IndirectRegisterFiles. */ - if (mesa_inst->DstReg.RelAddr) - prog->IndirectRegisterFiles |= 1 << mesa_inst->DstReg.File; - - /* Update program's bitmask of indirectly accessed register files */ - for (unsigned src = 0; src < 3; src++) - if (mesa_inst->SrcReg[src].RelAddr) - prog->IndirectRegisterFiles |= 1 << mesa_inst->SrcReg[src].File; - - switch (mesa_inst->Opcode) { - case OPCODE_IF: - if (options->MaxIfDepth == 0) { - linker_warning(shader_program, - "Couldn't flatten if-statement. " - "This will likely result in software " - "rasterization.\n"); - } - break; - case OPCODE_BGNLOOP: - if (options->EmitNoLoops) { - linker_warning(shader_program, - "Couldn't unroll loop. " - "This will likely result in software " - "rasterization.\n"); - } - break; - case OPCODE_CONT: - if (options->EmitNoCont) { - linker_warning(shader_program, - "Couldn't lower continue-statement. " - "This will likely result in software " - "rasterization.\n"); - } - break; - case OPCODE_BGNSUB: - inst->function->inst = i; - mesa_inst->Comment = strdup(inst->function->sig->function_name()); - break; - case OPCODE_ENDSUB: - mesa_inst->Comment = strdup(inst->function->sig->function_name()); - break; - case OPCODE_CAL: - mesa_inst->BranchTarget = inst->function->sig_id; /* rewritten later */ - break; - case OPCODE_ARL: - prog->NumAddressRegs = 1; - break; - default: - break; - } - - mesa_inst++; - i++; - - if (!shader_program->LinkStatus) - break; - } - - if (!shader_program->LinkStatus) { - goto fail_exit; - } - - set_branchtargets(&v, mesa_instructions, num_instructions); - - if (ctx->Shader.Flags & GLSL_DUMP) { - printf("\n"); - printf("GLSL IR for linked %s program %d:\n", target_string, - shader_program->Name); - _mesa_print_ir(shader->ir, NULL); - printf("\n"); - printf("\n"); - printf("Mesa IR for linked %s program %d:\n", target_string, - shader_program->Name); - print_program(mesa_instructions, mesa_instruction_annotation, - num_instructions); - } - - prog->Instructions = mesa_instructions; - prog->NumInstructions = num_instructions; - - /* Setting this to NULL prevents a possible double free in the fail_exit - * path (far below). - */ - mesa_instructions = NULL; - - do_set_program_inouts(shader->ir, prog, shader->Type == GL_FRAGMENT_SHADER); - - prog->SamplersUsed = shader->active_samplers; - prog->ShadowSamplers = shader->shadow_samplers; - _mesa_update_shader_textures_used(shader_program, prog); - - /* Set the gl_FragDepth layout. */ - if (target == GL_FRAGMENT_PROGRAM_ARB) { - struct gl_fragment_program *fp = (struct gl_fragment_program *)prog; - fp->FragDepthLayout = shader_program->FragDepthLayout; - } - - _mesa_reference_program(ctx, &shader->Program, prog); - - if ((ctx->Shader.Flags & GLSL_NO_OPT) == 0) { - _mesa_optimize_program(ctx, prog); - } - - /* This has to be done last. Any operation that can cause - * prog->ParameterValues to get reallocated (e.g., anything that adds a - * program constant) has to happen before creating this linkage. - */ - _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters); - if (!shader_program->LinkStatus) { - goto fail_exit; - } - - return prog; - -fail_exit: - free(mesa_instructions); - _mesa_reference_program(ctx, &shader->Program, NULL); - return NULL; -} - -extern "C" { - -/** - * Link a shader. - * Called via ctx->Driver.LinkShader() - * This actually involves converting GLSL IR into Mesa gl_programs with - * code lowering and other optimizations. - */ -GLboolean -_mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) -{ - assert(prog->LinkStatus); - - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - if (prog->_LinkedShaders[i] == NULL) - continue; - - bool progress; - exec_list *ir = prog->_LinkedShaders[i]->ir; - const struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)]; - - do { - progress = false; - - /* Lowering */ - do_mat_op_to_vec(ir); - lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2 - | LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP - | ((options->EmitNoPow) ? POW_TO_EXP2 : 0))); - - progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress; - - progress = do_common_optimization(ir, true, true, - options->MaxUnrollIterations) - || progress; - - progress = lower_quadop_vector(ir, true) || progress; - - if (options->MaxIfDepth == 0) - progress = lower_discard(ir) || progress; - - progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress; - - if (options->EmitNoNoise) - progress = lower_noise(ir) || progress; - - /* If there are forms of indirect addressing that the driver - * cannot handle, perform the lowering pass. - */ - if (options->EmitNoIndirectInput || options->EmitNoIndirectOutput - || options->EmitNoIndirectTemp || options->EmitNoIndirectUniform) - progress = - lower_variable_index_to_cond_assign(ir, - options->EmitNoIndirectInput, - options->EmitNoIndirectOutput, - options->EmitNoIndirectTemp, - options->EmitNoIndirectUniform) - || progress; - - progress = do_vec_index_to_cond_assign(ir) || progress; - } while (progress); - - validate_ir_tree(ir); - } - - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { - struct gl_program *linked_prog; - - if (prog->_LinkedShaders[i] == NULL) - continue; - - linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); - - if (linked_prog) { - - if (i == MESA_SHADER_VERTEX) { - ((struct gl_vertex_program *)linked_prog)->UsesClipDistance - = prog->Vert.UsesClipDistance; - } - - _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, - linked_prog); - } - - _mesa_reference_program(ctx, &linked_prog, NULL); - } - - return prog->LinkStatus; -} - - -/** - * Compile a GLSL shader. Called via glCompileShader(). - */ -void -_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader) -{ - struct _mesa_glsl_parse_state *state = - new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader); - - const char *source = shader->Source; - /* Check if the user called glCompileShader without first calling - * glShaderSource. This should fail to compile, but not raise a GL_ERROR. - */ - if (source == NULL) { - shader->CompileStatus = GL_FALSE; - return; - } - - state->error = preprocess(state, &source, &state->info_log, - &ctx->Extensions); - - if (ctx->Shader.Flags & GLSL_DUMP) { - printf("GLSL source for %s shader %d:\n", - _mesa_glsl_shader_target_name(state->target), shader->Name); - printf("%s\n", shader->Source); - } - - if (!state->error) { - _mesa_glsl_lexer_ctor(state, source); - _mesa_glsl_parse(state); - _mesa_glsl_lexer_dtor(state); - } - - ralloc_free(shader->ir); - shader->ir = new(shader) exec_list; - if (!state->error && !state->translation_unit.is_empty()) - _mesa_ast_to_hir(shader->ir, state); - - if (!state->error && !shader->ir->is_empty()) { - validate_ir_tree(shader->ir); - - /* Do some optimization at compile time to reduce shader IR size - * and reduce later work if the same shader is linked multiple times - */ - while (do_common_optimization(shader->ir, false, false, 32)) - ; - - validate_ir_tree(shader->ir); - } - - shader->symbols = state->symbols; - - shader->CompileStatus = !state->error; - shader->InfoLog = state->info_log; - shader->Version = state->language_version; - memcpy(shader->builtins_to_link, state->builtins_to_link, - sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); - shader->num_builtins_to_link = state->num_builtins_to_link; - - if (ctx->Shader.Flags & GLSL_LOG) { - _mesa_write_shader_to_file(shader); - } - - if (ctx->Shader.Flags & GLSL_DUMP) { - if (shader->CompileStatus) { - printf("GLSL IR for shader %d:\n", shader->Name); - _mesa_print_ir(shader->ir, NULL); - printf("\n\n"); - } else { - printf("GLSL shader %d failed to compile.\n", shader->Name); - } - if (shader->InfoLog && shader->InfoLog[0] != 0) { - printf("GLSL shader %d info log:\n", shader->Name); - printf("%s\n", shader->InfoLog); - } - } - - /* Retain any live IR, but trash the rest. */ - reparent_ir(shader->ir, shader->ir); - - ralloc_free(state); -} - - -/** - * Link a GLSL shader program. Called via glLinkProgram(). - */ -void -_mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) -{ - unsigned int i; - - _mesa_clear_shader_program_data(ctx, prog); - - prog->LinkStatus = GL_TRUE; - - for (i = 0; i < prog->NumShaders; i++) { - if (!prog->Shaders[i]->CompileStatus) { - linker_error(prog, "linking with uncompiled shader"); - prog->LinkStatus = GL_FALSE; - } - } - - if (prog->LinkStatus) { - link_shaders(ctx, prog); - } - - if (prog->LinkStatus) { - if (!ctx->Driver.LinkShader(ctx, prog)) { - prog->LinkStatus = GL_FALSE; - } - } - - if (prog->LinkStatus) { - set_uniform_initializers(ctx, prog); - } - - if (ctx->Shader.Flags & GLSL_DUMP) { - if (!prog->LinkStatus) { - printf("GLSL shader program %d failed to link\n", prog->Name); - } - - if (prog->InfoLog && prog->InfoLog[0] != 0) { - printf("GLSL shader program %d info log:\n", prog->Name); - printf("%s\n", prog->InfoLog); - } - } -} - -} /* extern "C" */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.h b/reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.h deleted file mode 100644 index aa053d9c8e3..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/ir_to_mesa.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#pragma once - -#include "main/glheader.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct gl_context; -struct gl_shader; -struct gl_shader_program; - -void _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *sh); -void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); -GLboolean _mesa_ir_compile_shader(struct gl_context *ctx, struct gl_shader *shader); -GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); - -void -_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program - *shader_program, - struct gl_shader *sh, - struct gl_program_parameter_list - *params); -void -_mesa_associate_uniform_storage(struct gl_context *ctx, - struct gl_shader_program *shader_program, - struct gl_program_parameter_list *params); - -#ifdef __cplusplus -} -#endif diff --git a/reactos/dll/opengl/mesa/src/mesa/program/lex.yy.c b/reactos/dll/opengl/mesa/src/mesa/program/lex.yy.c deleted file mode 100644 index 83775a0e274..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/lex.yy.c +++ /dev/null @@ -1,3671 +0,0 @@ -#line 2 "program/lex.yy.c" - -#line 4 "program/lex.yy.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ,yyscanner ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -void yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void yypop_buffer_state (yyscan_t yyscanner ); - -static void yyensure_buffer_stack (yyscan_t yyscanner ); -static void yy_load_buffer_state (yyscan_t yyscanner ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -void *yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define yywrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 170 -#define YY_END_OF_BUFFER 171 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[850] = - { 0, - 0, 0, 171, 169, 167, 166, 169, 169, 139, 165, - 141, 141, 141, 141, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 167, 0, 0, 168, 139, - 0, 140, 142, 162, 162, 0, 0, 0, 0, 162, - 0, 0, 0, 0, 0, 0, 0, 119, 163, 120, - 121, 153, 153, 153, 153, 0, 141, 0, 127, 128, - 129, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 161, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 160, 160, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 159, 159, 159, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 150, 150, 150, 151, 151, 152, 143, - 142, 143, 0, 144, 11, 12, 139, 13, 139, 139, - 14, 15, 139, 16, 17, 18, 19, 20, 21, 6, - - 22, 23, 24, 25, 26, 28, 27, 29, 30, 31, - 32, 33, 34, 35, 139, 139, 139, 139, 139, 40, - 41, 139, 42, 43, 44, 45, 46, 47, 48, 139, - 49, 50, 51, 52, 53, 54, 55, 139, 56, 57, - 58, 59, 139, 139, 64, 65, 139, 139, 139, 139, - 139, 139, 0, 0, 0, 0, 142, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 80, 81, 83, - 0, 158, 0, 0, 0, 0, 0, 0, 97, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 157, - 156, 156, 109, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 147, 147, 148, 149, 0, 145, 11, - 11, 139, 12, 12, 12, 139, 139, 139, 139, 139, - 15, 15, 139, 130, 16, 16, 139, 17, 17, 139, - 18, 18, 139, 19, 19, 139, 20, 20, 139, 21, - 21, 139, 22, 22, 139, 24, 24, 139, 25, 25, - 139, 28, 28, 139, 27, 27, 139, 30, 30, 139, - 31, 31, 139, 32, 32, 139, 33, 33, 139, 34, - 34, 139, 35, 35, 139, 139, 139, 139, 36, 139, - 38, 139, 40, 40, 139, 41, 41, 139, 131, 42, - 42, 139, 43, 43, 139, 139, 45, 45, 139, 46, - - 46, 139, 47, 47, 139, 48, 48, 139, 139, 49, - 49, 139, 50, 50, 139, 51, 51, 139, 52, 52, - 139, 53, 53, 139, 54, 54, 139, 139, 10, 56, - 139, 57, 139, 58, 139, 59, 139, 60, 139, 62, - 139, 64, 64, 139, 139, 139, 139, 139, 139, 139, - 139, 0, 164, 0, 0, 0, 73, 74, 0, 0, - 0, 0, 0, 0, 0, 85, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 155, 0, 0, 0, 113, 0, - 115, 0, 0, 0, 0, 0, 0, 154, 146, 139, - - 139, 139, 4, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 9, 37, 39, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 60, 139, 61, 62, 139, 63, 139, 139, 139, 139, - 139, 69, 139, 139, 0, 0, 0, 0, 0, 75, - 76, 0, 0, 0, 0, 84, 0, 0, 88, 91, - 0, 0, 0, 0, 0, 0, 0, 102, 103, 0, - 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 139, 139, 139, 139, 139, 139, - 5, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 7, 8, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 61, 139, 139, 63, 139, 139, - 139, 139, 139, 70, 139, 66, 0, 0, 0, 0, - 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 94, 0, 98, 99, 0, 101, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 117, 118, 0, 0, - - 125, 11, 3, 12, 135, 136, 139, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 24, 25, 28, 27, - 30, 31, 32, 33, 34, 35, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 139, 139, 139, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 139, - 139, 139, 139, 64, 65, 139, 68, 126, 0, 0, - 71, 0, 77, 0, 0, 0, 86, 0, 0, 0, - 0, 0, 0, 100, 0, 0, 106, 93, 0, 0, - 0, 0, 0, 0, 122, 0, 139, 132, 133, 139, - 60, 139, 62, 139, 67, 0, 0, 0, 0, 79, - - 82, 87, 0, 0, 92, 0, 0, 0, 105, 0, - 0, 0, 0, 114, 116, 0, 139, 139, 61, 63, - 2, 1, 0, 78, 0, 90, 0, 96, 104, 0, - 0, 111, 112, 123, 139, 134, 0, 89, 0, 107, - 110, 139, 72, 95, 139, 139, 137, 138, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 5, 1, 6, 7, 1, 1, 1, 1, - 1, 1, 8, 1, 8, 9, 1, 10, 11, 12, - 13, 14, 15, 15, 15, 15, 15, 1, 1, 1, - 1, 1, 1, 1, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 7, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 1, 1, 1, 1, 41, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[68] = - { 0, - 1, 1, 1, 1, 1, 1, 2, 1, 3, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2 - } ; - -static yyconst flex_int16_t yy_base[853] = - { 0, - 0, 0, 1299, 1300, 66, 1300, 1293, 1294, 0, 69, - 85, 128, 140, 152, 151, 58, 56, 63, 76, 1272, - 158, 160, 39, 163, 173, 189, 52, 1265, 76, 1235, - 1234, 1246, 1230, 1244, 1243, 105, 1272, 1284, 1300, 0, - 225, 1300, 218, 160, 157, 20, 123, 66, 119, 192, - 1244, 1230, 54, 162, 1228, 1240, 194, 1300, 200, 195, - 98, 227, 196, 231, 235, 293, 305, 316, 1300, 1300, - 1300, 1249, 1262, 1256, 223, 1245, 1248, 1244, 1259, 107, - 298, 1241, 1255, 246, 1241, 1254, 1245, 1258, 1235, 1246, - 1237, 182, 1238, 1229, 1238, 1229, 1228, 1229, 144, 1223, - - 1229, 1240, 1231, 1225, 1222, 1223, 1227, 289, 1236, 1223, - 302, 1230, 1217, 1231, 1207, 65, 315, 276, 1227, 1226, - 1202, 1187, 1182, 1199, 1175, 1180, 1206, 279, 1195, 293, - 1190, 342, 299, 1192, 1173, 317, 1183, 1179, 1174, 207, - 1180, 1166, 1182, 1179, 1170, 320, 324, 1172, 1161, 1175, - 1178, 1160, 1175, 1162, 1159, 1166, 284, 1174, 227, 288, - 327, 342, 345, 1151, 1168, 1169, 1162, 1144, 318, 1145, - 1167, 1158, 330, 341, 345, 349, 353, 357, 361, 1300, - 419, 430, 436, 442, 440, 441, 1191, 0, 1190, 1173, - 1163, 443, 1183, 444, 451, 468, 470, 472, 471, 0, - - 496, 0, 497, 498, 0, 499, 500, 0, 524, 525, - 526, 536, 537, 553, 1178, 1171, 1184, 354, 356, 561, - 563, 1165, 564, 565, 1157, 580, 590, 591, 592, 1178, - 593, 617, 618, 619, 629, 630, 1155, 1165, 330, 362, - 419, 483, 445, 364, 646, 1153, 1145, 1144, 1129, 1129, - 1128, 1127, 1170, 1142, 1130, 662, 669, 643, 1134, 487, - 1131, 1125, 1125, 1119, 1132, 1132, 1117, 1300, 1300, 1132, - 1120, 646, 1127, 135, 1124, 1130, 561, 1125, 1300, 1116, - 1123, 1122, 1125, 1111, 1110, 1114, 1109, 448, 1114, 650, - 653, 665, 1300, 1106, 1104, 1104, 1112, 1113, 1095, 670, - - 1100, 1106, 486, 579, 655, 661, 668, 726, 732, 1112, - 682, 1119, 1110, 688, 730, 1117, 1116, 1109, 1123, 1113, - 1104, 712, 1111, 0, 1102, 731, 1109, 1100, 733, 1107, - 1098, 734, 1105, 1096, 736, 1103, 1094, 737, 1101, 1092, - 738, 1099, 1090, 739, 1097, 1088, 740, 1095, 1086, 741, - 1093, 1084, 742, 1091, 1082, 743, 1089, 1080, 744, 1087, - 1078, 745, 1085, 1076, 746, 1083, 1074, 747, 1081, 1072, - 748, 1079, 1070, 749, 1077, 1080, 1073, 1080, 0, 1073, - 0, 1088, 1063, 750, 1070, 1061, 751, 1068, 0, 1059, - 752, 1066, 1057, 755, 1064, 1063, 1054, 758, 1061, 1052, - - 776, 1059, 1050, 777, 1057, 1048, 779, 1055, 1058, 1045, - 780, 1052, 1043, 782, 1050, 1041, 783, 1048, 1039, 784, - 1046, 1037, 785, 1044, 1035, 786, 1042, 1041, 0, 1032, - 1039, 1030, 1037, 1028, 1035, 1026, 1033, 787, 1032, 788, - 1047, 1022, 789, 1029, 1028, 1006, 1000, 1005, 1011, 994, - 1009, 424, 1300, 1008, 998, 1002, 1300, 1300, 992, 1001, - 987, 1004, 987, 990, 984, 1300, 985, 984, 981, 988, - 981, 989, 985, 995, 992, 974, 980, 987, 971, 970, - 988, 970, 982, 981, 1300, 980, 970, 974, 1300, 961, - 1300, 966, 966, 974, 957, 958, 968, 1300, 1300, 1000, - - 982, 998, 0, 798, 996, 996, 995, 994, 993, 992, - 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, - 981, 980, 979, 978, 965, 958, 0, 0, 0, 975, - 974, 973, 972, 971, 970, 969, 968, 967, 945, 965, - 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, - 929, 936, 793, 927, 934, 794, 950, 949, 918, 921, - 901, 0, 902, 895, 902, 901, 902, 894, 912, 1300, - 1300, 894, 892, 902, 895, 1300, 890, 907, 516, 1300, - 898, 882, 883, 892, 883, 882, 882, 1300, 881, 890, - 880, 896, 893, 1300, 892, 890, 879, 880, 876, 868, - - 875, 870, 871, 866, 892, 892, 890, 904, 903, 898, - 0, 886, 885, 884, 883, 882, 881, 880, 879, 878, - 877, 876, 875, 874, 873, 872, 871, 870, 869, 868, - 0, 0, 867, 866, 865, 864, 863, 862, 861, 860, - 859, 804, 858, 857, 856, 855, 854, 853, 852, 851, - 850, 849, 848, 865, 839, 846, 862, 836, 843, 841, - 840, 818, 818, 0, 825, 0, 859, 858, 807, 825, - 1300, 820, 815, 808, 804, 816, 806, 804, 800, 816, - 807, 806, 1300, 1300, 809, 1300, 804, 797, 786, 797, - 789, 793, 806, 801, 804, 786, 1300, 1300, 798, 787, - - 1300, 0, 0, 0, 0, 0, 826, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 814, 813, 802, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 785, - 798, 779, 792, 0, 0, 656, 0, 0, 706, 702, - 1300, 649, 1300, 648, 648, 654, 1300, 637, 645, 610, - 612, 608, 608, 1300, 572, 583, 1300, 1300, 577, 573, - 560, 557, 542, 555, 1300, 539, 573, 0, 0, 572, - 0, 555, 0, 546, 0, 562, 551, 495, 479, 1300, - - 1300, 1300, 481, 481, 1300, 480, 443, 31, 1300, 141, - 166, 171, 186, 1300, 1300, 211, 236, 276, 0, 0, - 1300, 1300, 290, 1300, 325, 1300, 346, 1300, 1300, 343, - 341, 1300, 1300, 1300, 365, 0, 380, 1300, 371, 1300, - 1300, 486, 1300, 1300, 451, 458, 0, 0, 1300, 836, - 503, 839 - } ; - -static yyconst flex_int16_t yy_def[853] = - { 0, - 849, 1, 849, 849, 849, 849, 849, 850, 851, 849, - 849, 849, 849, 849, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 849, 849, 850, 849, 851, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 852, 849, 849, 849, 849, - 849, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - - 849, 849, 849, 849, 849, 849, 849, 849, 849, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 851, - - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - - 849, 849, 849, 849, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - - 849, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 851, 851, 851, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 851, 851, 851, 851, - 851, 851, 851, 851, 851, 849, 849, 849, 849, 849, - - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 851, 851, 851, 851, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 851, 851, 849, 849, 849, 849, - 849, 851, 849, 849, 851, 851, 851, 851, 0, 849, - 849, 849 - } ; - -static yyconst flex_int16_t yy_nxt[1368] = - { 0, - 4, 5, 6, 5, 7, 8, 9, 4, 10, 11, - 12, 13, 14, 11, 11, 15, 9, 16, 17, 18, - 19, 9, 9, 9, 20, 21, 22, 9, 23, 24, - 9, 25, 26, 27, 28, 9, 9, 29, 9, 9, - 9, 9, 9, 9, 9, 9, 30, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 31, 9, 32, 33, - 34, 9, 35, 9, 9, 9, 9, 36, 96, 36, - 41, 116, 137, 97, 80, 138, 829, 42, 43, 43, - 43, 43, 43, 43, 77, 81, 78, 119, 82, 117, - 83, 238, 79, 66, 67, 67, 67, 67, 67, 67, - - 84, 85, 239, 150, 68, 120, 36, 86, 36, 151, - 44, 45, 46, 47, 48, 49, 50, 51, 52, 141, - 142, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 68, 143, 62, 63, 64, 65, 66, 67, 67, 67, - 67, 67, 67, 170, 194, 195, 69, 68, 66, 67, - 67, 67, 67, 67, 67, 218, 171, 219, 70, 68, - 66, 67, 67, 67, 67, 67, 67, 72, 139, 73, - 71, 68, 140, 68, 144, 92, 74, 145, 98, 88, - 467, 89, 75, 93, 76, 68, 90, 99, 94, 91, - 101, 100, 102, 103, 95, 468, 830, 68, 136, 133, - - 210, 133, 133, 152, 133, 104, 105, 133, 106, 107, - 108, 109, 110, 134, 111, 133, 112, 153, 133, 211, - 135, 831, 113, 114, 154, 115, 41, 43, 43, 43, - 43, 43, 43, 146, 147, 157, 832, 132, 165, 133, - 166, 161, 162, 167, 168, 833, 158, 163, 188, 159, - 133, 169, 160, 265, 189, 164, 834, 201, 133, 174, - 173, 175, 176, 132, 835, 266, 128, 129, 46, 47, - 48, 49, 172, 51, 52, 202, 285, 53, 54, 55, - 56, 57, 58, 130, 60, 61, 286, 243, 131, 244, - 173, 173, 173, 173, 177, 173, 173, 178, 179, 173, - - 173, 173, 181, 181, 181, 181, 181, 181, 228, 836, - 196, 197, 182, 66, 67, 67, 67, 67, 67, 67, - 198, 232, 229, 183, 68, 184, 184, 184, 184, 184, - 184, 240, 134, 241, 255, 233, 282, 287, 182, 135, - 258, 258, 283, 288, 242, 837, 258, 430, 164, 256, - 68, 257, 257, 257, 257, 257, 257, 258, 258, 258, - 261, 258, 258, 298, 258, 272, 258, 258, 258, 258, - 431, 258, 381, 299, 258, 258, 379, 838, 258, 432, - 440, 289, 258, 290, 258, 258, 291, 292, 380, 258, - 382, 839, 258, 303, 303, 303, 303, 840, 441, 841, - - 258, 842, 433, 258, 303, 303, 303, 303, 304, 303, - 303, 305, 306, 303, 303, 303, 303, 303, 303, 303, - 307, 303, 303, 303, 303, 303, 303, 303, 43, 43, - 43, 43, 43, 43, 843, 844, 434, 308, 132, 309, - 309, 309, 309, 309, 309, 184, 184, 184, 184, 184, - 184, 184, 184, 184, 184, 184, 184, 310, 313, 435, - 321, 325, 311, 314, 132, 322, 326, 438, 328, 847, - 565, 311, 315, 329, 322, 326, 848, 311, 314, 439, - 312, 316, 329, 323, 327, 331, 566, 334, 340, 337, - 332, 330, 335, 341, 338, 482, 845, 846, 483, 332, - - 436, 335, 341, 338, 40, 332, 828, 335, 333, 338, - 336, 342, 339, 343, 346, 349, 352, 355, 344, 347, - 350, 353, 356, 437, 827, 826, 825, 344, 347, 350, - 353, 356, 455, 824, 347, 350, 345, 348, 351, 354, - 357, 358, 361, 364, 823, 456, 359, 362, 365, 498, - 498, 498, 498, 367, 370, 359, 362, 365, 368, 371, - 822, 359, 362, 365, 360, 363, 366, 368, 371, 678, - 373, 821, 679, 368, 371, 374, 369, 372, 383, 820, - 386, 390, 393, 384, 374, 387, 391, 394, 819, 818, - 374, 817, 384, 375, 387, 391, 394, 397, 816, 815, - - 814, 385, 398, 388, 392, 395, 471, 400, 403, 406, - 410, 398, 401, 404, 407, 411, 813, 398, 812, 472, - 399, 401, 404, 407, 411, 811, 810, 401, 404, 407, - 402, 405, 408, 412, 413, 416, 419, 809, 808, 414, - 417, 420, 498, 498, 498, 498, 422, 425, 414, 417, - 420, 423, 426, 807, 414, 417, 420, 415, 418, 421, - 423, 426, 806, 442, 805, 804, 423, 426, 443, 424, - 427, 257, 257, 257, 257, 257, 257, 443, 257, 257, - 257, 257, 257, 257, 453, 453, 444, 453, 453, 803, - 453, 453, 453, 453, 453, 453, 802, 453, 801, 310, - - 453, 453, 800, 799, 453, 313, 485, 453, 453, 798, - 797, 453, 453, 492, 796, 493, 795, 494, 499, 498, - 498, 498, 312, 453, 498, 498, 498, 498, 316, 321, - 495, 498, 498, 498, 498, 309, 309, 309, 309, 309, - 309, 309, 309, 309, 309, 309, 309, 313, 325, 501, - 328, 331, 323, 334, 337, 340, 343, 346, 349, 352, - 355, 358, 361, 364, 367, 370, 373, 383, 386, 390, - 316, 327, 393, 330, 333, 397, 336, 339, 342, 345, - 348, 351, 354, 357, 360, 363, 366, 369, 372, 375, - 385, 388, 392, 400, 403, 395, 406, 410, 399, 413, - - 416, 419, 422, 425, 551, 554, 442, 794, 608, 609, - 655, 658, 793, 792, 736, 737, 402, 405, 791, 408, - 412, 790, 415, 418, 421, 424, 427, 552, 555, 444, - 610, 789, 788, 656, 659, 738, 38, 38, 38, 180, - 180, 787, 786, 785, 784, 783, 782, 781, 780, 779, - 778, 777, 776, 775, 774, 773, 772, 771, 770, 769, - 768, 767, 766, 765, 764, 763, 762, 761, 760, 759, - 758, 757, 756, 755, 754, 753, 659, 752, 751, 656, - 750, 749, 748, 747, 746, 745, 744, 743, 742, 741, - 740, 739, 735, 734, 733, 732, 731, 730, 729, 728, - - 727, 726, 725, 724, 723, 722, 721, 720, 719, 718, - 717, 716, 715, 714, 713, 712, 711, 710, 709, 708, - 707, 706, 705, 704, 703, 702, 701, 700, 699, 698, - 697, 696, 695, 694, 693, 692, 691, 690, 689, 688, - 687, 686, 685, 684, 683, 682, 681, 680, 677, 676, - 675, 674, 673, 672, 671, 670, 669, 668, 667, 666, - 665, 664, 663, 662, 661, 660, 657, 555, 654, 552, - 653, 652, 651, 650, 649, 648, 647, 646, 645, 644, - 643, 642, 641, 640, 639, 638, 637, 636, 635, 634, - 633, 632, 631, 630, 629, 628, 627, 626, 625, 624, - - 623, 622, 621, 620, 619, 618, 617, 616, 615, 614, - 613, 612, 611, 607, 606, 605, 604, 603, 602, 601, - 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, - 590, 589, 588, 587, 586, 585, 584, 583, 582, 581, - 580, 579, 578, 577, 576, 575, 574, 573, 572, 571, - 570, 569, 568, 567, 564, 563, 562, 561, 560, 559, - 558, 557, 444, 556, 553, 550, 437, 549, 435, 548, - 433, 547, 431, 546, 545, 427, 544, 424, 543, 421, - 542, 418, 541, 415, 540, 412, 539, 538, 408, 537, - 405, 536, 402, 535, 399, 534, 533, 395, 532, 392, - - 531, 388, 530, 385, 529, 528, 527, 526, 525, 524, - 375, 523, 372, 522, 369, 521, 366, 520, 363, 519, - 360, 518, 357, 517, 354, 516, 351, 515, 348, 514, - 345, 513, 342, 512, 339, 511, 336, 510, 333, 509, - 330, 508, 327, 507, 323, 506, 505, 504, 503, 502, - 316, 500, 312, 497, 496, 491, 490, 489, 488, 487, - 486, 484, 481, 480, 479, 478, 477, 476, 475, 474, - 473, 470, 469, 466, 465, 464, 463, 462, 461, 460, - 459, 458, 457, 454, 289, 261, 452, 451, 450, 449, - 448, 447, 446, 445, 429, 428, 409, 396, 389, 378, - - 377, 376, 324, 320, 319, 318, 317, 302, 301, 300, - 297, 296, 295, 294, 293, 284, 281, 280, 279, 278, - 277, 276, 275, 274, 273, 271, 270, 269, 268, 267, - 264, 263, 262, 260, 259, 172, 254, 253, 252, 251, - 250, 249, 248, 247, 246, 245, 237, 236, 235, 234, - 231, 230, 227, 226, 225, 224, 223, 222, 221, 220, - 217, 216, 215, 214, 213, 212, 209, 208, 207, 206, - 205, 204, 203, 200, 199, 193, 192, 191, 190, 187, - 186, 185, 156, 155, 149, 148, 39, 127, 126, 125, - 124, 123, 122, 121, 118, 87, 39, 37, 849, 3, - - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849 - } ; - -static yyconst flex_int16_t yy_chk[1368] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 5, 23, 5, - 10, 27, 46, 23, 17, 46, 808, 10, 10, 10, - 10, 10, 10, 10, 16, 17, 16, 29, 17, 27, - 18, 116, 16, 11, 11, 11, 11, 11, 11, 11, - - 18, 19, 116, 53, 11, 29, 36, 19, 36, 53, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 48, - 48, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 11, 48, 10, 10, 10, 10, 12, 12, 12, 12, - 12, 12, 12, 61, 80, 80, 12, 12, 13, 13, - 13, 13, 13, 13, 13, 99, 61, 99, 13, 13, - 14, 14, 14, 14, 14, 14, 14, 15, 47, 15, - 14, 14, 47, 12, 49, 22, 15, 49, 24, 21, - 274, 21, 15, 22, 15, 13, 21, 24, 22, 21, - 25, 24, 25, 25, 22, 274, 810, 14, 45, 45, - - 92, 44, 44, 54, 45, 25, 26, 44, 26, 26, - 26, 26, 26, 44, 26, 45, 26, 54, 44, 92, - 44, 811, 26, 26, 54, 26, 41, 43, 43, 43, - 43, 43, 43, 50, 50, 57, 812, 43, 60, 50, - 60, 59, 59, 60, 60, 813, 57, 59, 75, 57, - 50, 60, 57, 140, 75, 59, 816, 84, 59, 63, - 63, 63, 63, 43, 817, 140, 41, 41, 41, 41, - 41, 41, 62, 41, 41, 84, 159, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 159, 118, 41, 118, - 62, 62, 62, 62, 64, 64, 64, 64, 65, 65, - - 65, 65, 66, 66, 66, 66, 66, 66, 108, 818, - 81, 81, 66, 67, 67, 67, 67, 67, 67, 67, - 81, 111, 108, 68, 67, 68, 68, 68, 68, 68, - 68, 117, 128, 117, 130, 111, 157, 160, 66, 128, - 133, 133, 157, 160, 117, 823, 133, 239, 130, 132, - 67, 132, 132, 132, 132, 132, 132, 133, 136, 136, - 136, 146, 146, 169, 136, 147, 147, 146, 161, 161, - 239, 147, 219, 169, 161, 136, 218, 825, 146, 240, - 244, 161, 147, 162, 162, 161, 163, 163, 218, 162, - 219, 827, 163, 173, 173, 173, 173, 830, 244, 831, - - 162, 835, 240, 163, 174, 174, 174, 174, 175, 175, - 175, 175, 176, 176, 176, 176, 177, 177, 177, 177, - 178, 178, 178, 178, 179, 179, 179, 179, 181, 181, - 181, 181, 181, 181, 837, 839, 241, 182, 181, 182, - 182, 182, 182, 182, 182, 183, 183, 183, 183, 183, - 183, 184, 184, 184, 184, 184, 184, 185, 186, 241, - 192, 194, 185, 186, 181, 192, 194, 243, 195, 845, - 452, 185, 186, 195, 192, 194, 846, 185, 186, 243, - 185, 186, 195, 192, 194, 196, 452, 197, 199, 198, - 196, 195, 197, 199, 198, 288, 842, 842, 288, 196, - - 242, 197, 199, 198, 851, 196, 807, 197, 196, 198, - 197, 199, 198, 201, 203, 204, 206, 207, 201, 203, - 204, 206, 207, 242, 806, 804, 803, 201, 203, 204, - 206, 207, 260, 799, 203, 204, 201, 203, 204, 206, - 207, 209, 210, 211, 798, 260, 209, 210, 211, 303, - 303, 303, 303, 212, 213, 209, 210, 211, 212, 213, - 797, 209, 210, 211, 209, 210, 211, 212, 213, 579, - 214, 796, 579, 212, 213, 214, 212, 213, 220, 794, - 221, 223, 224, 220, 214, 221, 223, 224, 792, 790, - 214, 787, 220, 214, 221, 223, 224, 226, 786, 784, - - 783, 220, 226, 221, 223, 224, 277, 227, 228, 229, - 231, 226, 227, 228, 229, 231, 782, 226, 781, 277, - 226, 227, 228, 229, 231, 780, 779, 227, 228, 229, - 227, 228, 229, 231, 232, 233, 234, 776, 775, 232, - 233, 234, 304, 304, 304, 304, 235, 236, 232, 233, - 234, 235, 236, 773, 232, 233, 234, 232, 233, 234, - 235, 236, 772, 245, 771, 770, 235, 236, 245, 235, - 236, 256, 256, 256, 256, 256, 256, 245, 257, 257, - 257, 257, 257, 257, 258, 258, 245, 272, 272, 769, - 258, 290, 290, 272, 291, 291, 768, 290, 766, 311, - - 291, 258, 765, 764, 272, 314, 292, 292, 290, 762, - 760, 291, 292, 300, 759, 300, 756, 300, 305, 305, - 305, 305, 311, 292, 306, 306, 306, 306, 314, 322, - 300, 307, 307, 307, 307, 308, 308, 308, 308, 308, - 308, 309, 309, 309, 309, 309, 309, 315, 326, 315, - 329, 332, 322, 335, 338, 341, 344, 347, 350, 353, - 356, 359, 362, 365, 368, 371, 374, 384, 387, 391, - 315, 326, 394, 329, 332, 398, 335, 338, 341, 344, - 347, 350, 353, 356, 359, 362, 365, 368, 371, 374, - 384, 387, 391, 401, 404, 394, 407, 411, 398, 414, - - 417, 420, 423, 426, 438, 440, 443, 753, 504, 504, - 553, 556, 752, 751, 642, 642, 401, 404, 750, 407, - 411, 738, 414, 417, 420, 423, 426, 438, 440, 443, - 504, 737, 736, 553, 556, 642, 850, 850, 850, 852, - 852, 707, 700, 699, 696, 695, 694, 693, 692, 691, - 690, 689, 688, 687, 685, 682, 681, 680, 679, 678, - 677, 676, 675, 674, 673, 672, 670, 669, 668, 667, - 665, 663, 662, 661, 660, 659, 658, 657, 656, 655, - 654, 653, 652, 651, 650, 649, 648, 647, 646, 645, - 644, 643, 641, 640, 639, 638, 637, 636, 635, 634, - - 633, 630, 629, 628, 627, 626, 625, 624, 623, 622, - 621, 620, 619, 618, 617, 616, 615, 614, 613, 612, - 610, 609, 608, 607, 606, 605, 604, 603, 602, 601, - 600, 599, 598, 597, 596, 595, 593, 592, 591, 590, - 589, 587, 586, 585, 584, 583, 582, 581, 578, 577, - 575, 574, 573, 572, 569, 568, 567, 566, 565, 564, - 563, 561, 560, 559, 558, 557, 555, 554, 552, 551, - 550, 549, 548, 547, 546, 545, 544, 543, 542, 541, - 540, 539, 538, 537, 536, 535, 534, 533, 532, 531, - 530, 526, 525, 524, 523, 522, 521, 520, 519, 518, - - 517, 516, 515, 514, 513, 512, 511, 510, 509, 508, - 507, 506, 505, 502, 501, 500, 497, 496, 495, 494, - 493, 492, 490, 488, 487, 486, 484, 483, 482, 481, - 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, - 470, 469, 468, 467, 465, 464, 463, 462, 461, 460, - 459, 456, 455, 454, 451, 450, 449, 448, 447, 446, - 445, 444, 442, 441, 439, 437, 436, 435, 434, 433, - 432, 431, 430, 428, 427, 425, 424, 422, 421, 419, - 418, 416, 415, 413, 412, 410, 409, 408, 406, 405, - 403, 402, 400, 399, 397, 396, 395, 393, 392, 390, - - 388, 386, 385, 383, 382, 380, 378, 377, 376, 375, - 373, 372, 370, 369, 367, 366, 364, 363, 361, 360, - 358, 357, 355, 354, 352, 351, 349, 348, 346, 345, - 343, 342, 340, 339, 337, 336, 334, 333, 331, 330, - 328, 327, 325, 323, 321, 320, 319, 318, 317, 316, - 313, 312, 310, 302, 301, 299, 298, 297, 296, 295, - 294, 289, 287, 286, 285, 284, 283, 282, 281, 280, - 278, 276, 275, 273, 271, 270, 267, 266, 265, 264, - 263, 262, 261, 259, 255, 254, 253, 252, 251, 250, - 249, 248, 247, 246, 238, 237, 230, 225, 222, 217, - - 216, 215, 193, 191, 190, 189, 187, 172, 171, 170, - 168, 167, 166, 165, 164, 158, 156, 155, 154, 153, - 152, 151, 150, 149, 148, 145, 144, 143, 142, 141, - 139, 138, 137, 135, 134, 131, 129, 127, 126, 125, - 124, 123, 122, 121, 120, 119, 115, 114, 113, 112, - 110, 109, 107, 106, 105, 104, 103, 102, 101, 100, - 98, 97, 96, 95, 94, 93, 91, 90, 89, 88, - 87, 86, 85, 83, 82, 79, 78, 77, 76, 74, - 73, 72, 56, 55, 52, 51, 38, 37, 35, 34, - 33, 32, 31, 30, 28, 20, 8, 7, 3, 849, - - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849, 849, 849, 849, - 849, 849, 849, 849, 849, 849, 849 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "program/program_lexer.l" -#line 2 "program/program_lexer.l" -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include "main/glheader.h" -#include "main/imports.h" -#include "program/prog_instruction.h" -#include "program/prog_statevars.h" -#include "program/symbol_table.h" -#include "program/program_parser.h" -#include "program/program_parse.tab.h" - -#define require_ARB_vp (yyextra->mode == ARB_vertex) -#define require_ARB_fp (yyextra->mode == ARB_fragment) -#define require_NV_fp (yyextra->option.NV_fragment) -#define require_shadow (yyextra->option.Shadow) -#define require_texarray (yyextra->option.TexArray) - -#ifndef HAVE_UNISTD_H -#define YY_NO_UNISTD_H -#endif - -#define return_token_or_IDENTIFIER(condition, token) \ - do { \ - if (condition) { \ - return token; \ - } else { \ - return handle_ident(yyextra, yytext, yylval); \ - } \ - } while (0) - -#define return_token_or_DOT(condition, token) \ - do { \ - if (condition) { \ - return token; \ - } else { \ - yyless(1); \ - return DOT; \ - } \ - } while (0) - - -#define return_opcode(condition, token, opcode, len) \ - do { \ - if (condition && \ - _mesa_parse_instruction_suffix(yyextra, \ - yytext + len, \ - & yylval->temp_inst)) { \ - yylval->temp_inst.Opcode = OPCODE_ ## opcode; \ - return token; \ - } else { \ - return handle_ident(yyextra, yytext, yylval); \ - } \ - } while (0) - -#define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ - SWIZZLE_NIL, SWIZZLE_NIL) - -static unsigned -mask_from_char(char c) -{ - switch (c) { - case 'x': - case 'r': - return WRITEMASK_X; - case 'y': - case 'g': - return WRITEMASK_Y; - case 'z': - case 'b': - return WRITEMASK_Z; - case 'w': - case 'a': - return WRITEMASK_W; - } - - return 0; -} - -static unsigned -swiz_from_char(char c) -{ - switch (c) { - case 'x': - case 'r': - return SWIZZLE_X; - case 'y': - case 'g': - return SWIZZLE_Y; - case 'z': - case 'b': - return SWIZZLE_Z; - case 'w': - case 'a': - return SWIZZLE_W; - } - - return 0; -} - -static int -handle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval) -{ - lval->string = strdup(text); - - return (_mesa_symbol_table_find_symbol(state->st, 0, text) == NULL) - ? IDENTIFIER : USED_IDENTIFIER; -} - -#define YY_USER_ACTION \ - do { \ - yylloc->first_column = yylloc->last_column; \ - yylloc->last_column += yyleng; \ - if ((yylloc->first_line == 1) \ - && (yylloc->first_column == 1)) { \ - yylloc->position = 1; \ - } else { \ - yylloc->position += yylloc->last_column - yylloc->first_column; \ - } \ - } while(0); - -#define YY_NO_INPUT - -/* Yes, this is intentionally doing nothing. We have this line of code -here only to avoid the compiler complaining about an unput function -that is defined, but never called. */ -#define YY_USER_INIT while (0) { unput(0); } - -#define YY_EXTRA_TYPE struct asm_parser_state * - -/* Flex defines a couple of functions with no declarations nor the -static keyword. Declare them here to avoid a compiler warning. */ -int yyget_column (yyscan_t yyscanner); -void yyset_column (int column_no , yyscan_t yyscanner); - -#line 1169 "program/lex.yy.c" - -#define INITIAL 0 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - YYSTYPE * yylval_r; - - YYLTYPE * yylloc_r; - - }; /* end struct yyguts_t */ - -static int yy_init_globals (yyscan_t yyscanner ); - - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval yyg->yylval_r - - # define yylloc yyg->yylloc_r - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (yyscan_t yyscanner ); - -int yyget_debug (yyscan_t yyscanner ); - -void yyset_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *yyget_in (yyscan_t yyscanner ); - -void yyset_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *yyget_out (yyscan_t yyscanner ); - -void yyset_out (FILE * out_str ,yyscan_t yyscanner ); - -int yyget_leng (yyscan_t yyscanner ); - -char *yyget_text (yyscan_t yyscanner ); - -int yyget_lineno (yyscan_t yyscanner ); - -void yyset_lineno (int line_number ,yyscan_t yyscanner ); - -int yyget_column (yyscan_t yyscanner ); - -void yyset_column (int column_no ,yyscan_t yyscanner ); - -YYSTYPE * yyget_lval (yyscan_t yyscanner ); - -void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - - YYLTYPE *yyget_lloc (yyscan_t yyscanner ); - - void yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (yyscan_t yyscanner ); -#else -extern int yywrap (yyscan_t yyscanner ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); -#else -static int input (yyscan_t yyscanner ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - unsigned n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int yylex \ - (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); - -#define YY_DECL int yylex \ - (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -#line 169 "program/program_lexer.l" - - -#line 1417 "program/lex.yy.c" - - yylval = yylval_param; - - yylloc = yylloc_param; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - yy_load_buffer_state(yyscanner ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yyg->yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 850 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 1300 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 171 "program/program_lexer.l" -{ return ARBvp_10; } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 172 "program/program_lexer.l" -{ return ARBfp_10; } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 173 "program/program_lexer.l" -{ - yylval->integer = at_address; - return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS); -} - YY_BREAK -case 4: -YY_RULE_SETUP -#line 177 "program/program_lexer.l" -{ return ALIAS; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 178 "program/program_lexer.l" -{ return ATTRIB; } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 179 "program/program_lexer.l" -{ return END; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 180 "program/program_lexer.l" -{ return OPTION; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 181 "program/program_lexer.l" -{ return OUTPUT; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 182 "program/program_lexer.l" -{ return PARAM; } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 183 "program/program_lexer.l" -{ yylval->integer = at_temp; return TEMP; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 185 "program/program_lexer.l" -{ return_opcode( 1, VECTOR_OP, ABS, 3); } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 186 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, ADD, 3); } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 187 "program/program_lexer.l" -{ return_opcode(require_ARB_vp, ARL, ARL, 3); } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 189 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, TRI_OP, CMP, 3); } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 190 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, SCALAR_OP, COS, 3); } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 192 "program/program_lexer.l" -{ return_opcode(require_NV_fp, VECTOR_OP, DDX, 3); } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 193 "program/program_lexer.l" -{ return_opcode(require_NV_fp, VECTOR_OP, DDY, 3); } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 194 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, DP3, 3); } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 195 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, DP4, 3); } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 196 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, DPH, 3); } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 197 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, DST, 3); } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 199 "program/program_lexer.l" -{ return_opcode( 1, SCALAR_OP, EX2, 3); } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 200 "program/program_lexer.l" -{ return_opcode(require_ARB_vp, SCALAR_OP, EXP, 3); } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 202 "program/program_lexer.l" -{ return_opcode( 1, VECTOR_OP, FLR, 3); } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 203 "program/program_lexer.l" -{ return_opcode( 1, VECTOR_OP, FRC, 3); } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 205 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, KIL, KIL, 3); } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 207 "program/program_lexer.l" -{ return_opcode( 1, VECTOR_OP, LIT, 3); } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 208 "program/program_lexer.l" -{ return_opcode( 1, SCALAR_OP, LG2, 3); } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 209 "program/program_lexer.l" -{ return_opcode(require_ARB_vp, SCALAR_OP, LOG, 3); } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 210 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, TRI_OP, LRP, 3); } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 212 "program/program_lexer.l" -{ return_opcode( 1, TRI_OP, MAD, 3); } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 213 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, MAX, 3); } - YY_BREAK -case 33: -YY_RULE_SETUP -#line 214 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, MIN, 3); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 215 "program/program_lexer.l" -{ return_opcode( 1, VECTOR_OP, MOV, 3); } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 216 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, MUL, 3); } - YY_BREAK -case 36: -YY_RULE_SETUP -#line 218 "program/program_lexer.l" -{ return_opcode(require_NV_fp, VECTOR_OP, PK2H, 4); } - YY_BREAK -case 37: -YY_RULE_SETUP -#line 219 "program/program_lexer.l" -{ return_opcode(require_NV_fp, VECTOR_OP, PK2US, 5); } - YY_BREAK -case 38: -YY_RULE_SETUP -#line 220 "program/program_lexer.l" -{ return_opcode(require_NV_fp, VECTOR_OP, PK4B, 4); } - YY_BREAK -case 39: -YY_RULE_SETUP -#line 221 "program/program_lexer.l" -{ return_opcode(require_NV_fp, VECTOR_OP, PK4UB, 5); } - YY_BREAK -case 40: -YY_RULE_SETUP -#line 222 "program/program_lexer.l" -{ return_opcode( 1, BINSC_OP, POW, 3); } - YY_BREAK -case 41: -YY_RULE_SETUP -#line 224 "program/program_lexer.l" -{ return_opcode( 1, SCALAR_OP, RCP, 3); } - YY_BREAK -case 42: -YY_RULE_SETUP -#line 225 "program/program_lexer.l" -{ return_opcode(require_NV_fp, BIN_OP, RFL, 3); } - YY_BREAK -case 43: -YY_RULE_SETUP -#line 226 "program/program_lexer.l" -{ return_opcode( 1, SCALAR_OP, RSQ, 3); } - YY_BREAK -case 44: -YY_RULE_SETUP -#line 228 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); } - YY_BREAK -case 45: -YY_RULE_SETUP -#line 229 "program/program_lexer.l" -{ return_opcode(require_NV_fp, BIN_OP, SEQ, 3); } - YY_BREAK -case 46: -YY_RULE_SETUP -#line 230 "program/program_lexer.l" -{ return_opcode(require_NV_fp, BIN_OP, SFL, 3); } - YY_BREAK -case 47: -YY_RULE_SETUP -#line 231 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, SGE, 3); } - YY_BREAK -case 48: -YY_RULE_SETUP -#line 232 "program/program_lexer.l" -{ return_opcode(require_NV_fp, BIN_OP, SGT, 3); } - YY_BREAK -case 49: -YY_RULE_SETUP -#line 233 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); } - YY_BREAK -case 50: -YY_RULE_SETUP -#line 234 "program/program_lexer.l" -{ return_opcode(require_NV_fp, BIN_OP, SLE, 3); } - YY_BREAK -case 51: -YY_RULE_SETUP -#line 235 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, SLT, 3); } - YY_BREAK -case 52: -YY_RULE_SETUP -#line 236 "program/program_lexer.l" -{ return_opcode(require_NV_fp, BIN_OP, SNE, 3); } - YY_BREAK -case 53: -YY_RULE_SETUP -#line 237 "program/program_lexer.l" -{ return_opcode(require_NV_fp, BIN_OP, STR, 3); } - YY_BREAK -case 54: -YY_RULE_SETUP -#line 238 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, SUB, 3); } - YY_BREAK -case 55: -YY_RULE_SETUP -#line 239 "program/program_lexer.l" -{ return_opcode( 1, SWZ, SWZ, 3); } - YY_BREAK -case 56: -YY_RULE_SETUP -#line 241 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, SAMPLE_OP, TEX, 3); } - YY_BREAK -case 57: -YY_RULE_SETUP -#line 242 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); } - YY_BREAK -case 58: -YY_RULE_SETUP -#line 243 "program/program_lexer.l" -{ return_opcode(require_NV_fp, TXD_OP, TXD, 3); } - YY_BREAK -case 59: -YY_RULE_SETUP -#line 244 "program/program_lexer.l" -{ return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); } - YY_BREAK -case 60: -YY_RULE_SETUP -#line 246 "program/program_lexer.l" -{ return_opcode(require_NV_fp, SCALAR_OP, UP2H, 4); } - YY_BREAK -case 61: -YY_RULE_SETUP -#line 247 "program/program_lexer.l" -{ return_opcode(require_NV_fp, SCALAR_OP, UP2US, 5); } - YY_BREAK -case 62: -YY_RULE_SETUP -#line 248 "program/program_lexer.l" -{ return_opcode(require_NV_fp, SCALAR_OP, UP4B, 4); } - YY_BREAK -case 63: -YY_RULE_SETUP -#line 249 "program/program_lexer.l" -{ return_opcode(require_NV_fp, SCALAR_OP, UP4UB, 5); } - YY_BREAK -case 64: -YY_RULE_SETUP -#line 251 "program/program_lexer.l" -{ return_opcode(require_NV_fp, TRI_OP, X2D, 3); } - YY_BREAK -case 65: -YY_RULE_SETUP -#line 252 "program/program_lexer.l" -{ return_opcode( 1, BIN_OP, XPD, 3); } - YY_BREAK -case 66: -YY_RULE_SETUP -#line 254 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); } - YY_BREAK -case 67: -YY_RULE_SETUP -#line 255 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); } - YY_BREAK -case 68: -YY_RULE_SETUP -#line 256 "program/program_lexer.l" -{ return PROGRAM; } - YY_BREAK -case 69: -YY_RULE_SETUP -#line 257 "program/program_lexer.l" -{ return STATE; } - YY_BREAK -case 70: -YY_RULE_SETUP -#line 258 "program/program_lexer.l" -{ return RESULT; } - YY_BREAK -case 71: -YY_RULE_SETUP -#line 260 "program/program_lexer.l" -{ return AMBIENT; } - YY_BREAK -case 72: -YY_RULE_SETUP -#line 261 "program/program_lexer.l" -{ return ATTENUATION; } - YY_BREAK -case 73: -YY_RULE_SETUP -#line 262 "program/program_lexer.l" -{ return BACK; } - YY_BREAK -case 74: -YY_RULE_SETUP -#line 263 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, CLIP); } - YY_BREAK -case 75: -YY_RULE_SETUP -#line 264 "program/program_lexer.l" -{ return COLOR; } - YY_BREAK -case 76: -YY_RULE_SETUP -#line 265 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_fp, DEPTH); } - YY_BREAK -case 77: -YY_RULE_SETUP -#line 266 "program/program_lexer.l" -{ return DIFFUSE; } - YY_BREAK -case 78: -YY_RULE_SETUP -#line 267 "program/program_lexer.l" -{ return DIRECTION; } - YY_BREAK -case 79: -YY_RULE_SETUP -#line 268 "program/program_lexer.l" -{ return EMISSION; } - YY_BREAK -case 80: -YY_RULE_SETUP -#line 269 "program/program_lexer.l" -{ return ENV; } - YY_BREAK -case 81: -YY_RULE_SETUP -#line 270 "program/program_lexer.l" -{ return EYE; } - YY_BREAK -case 82: -YY_RULE_SETUP -#line 271 "program/program_lexer.l" -{ return FOGCOORD; } - YY_BREAK -case 83: -YY_RULE_SETUP -#line 272 "program/program_lexer.l" -{ return FOG; } - YY_BREAK -case 84: -YY_RULE_SETUP -#line 273 "program/program_lexer.l" -{ return FRONT; } - YY_BREAK -case 85: -YY_RULE_SETUP -#line 274 "program/program_lexer.l" -{ return HALF; } - YY_BREAK -case 86: -YY_RULE_SETUP -#line 275 "program/program_lexer.l" -{ return INVERSE; } - YY_BREAK -case 87: -YY_RULE_SETUP -#line 276 "program/program_lexer.l" -{ return INVTRANS; } - YY_BREAK -case 88: -YY_RULE_SETUP -#line 277 "program/program_lexer.l" -{ return LIGHT; } - YY_BREAK -case 89: -YY_RULE_SETUP -#line 278 "program/program_lexer.l" -{ return LIGHTMODEL; } - YY_BREAK -case 90: -YY_RULE_SETUP -#line 279 "program/program_lexer.l" -{ return LIGHTPROD; } - YY_BREAK -case 91: -YY_RULE_SETUP -#line 280 "program/program_lexer.l" -{ return LOCAL; } - YY_BREAK -case 92: -YY_RULE_SETUP -#line 281 "program/program_lexer.l" -{ return MATERIAL; } - YY_BREAK -case 93: -YY_RULE_SETUP -#line 282 "program/program_lexer.l" -{ return MAT_PROGRAM; } - YY_BREAK -case 94: -YY_RULE_SETUP -#line 283 "program/program_lexer.l" -{ return MATRIX; } - YY_BREAK -case 95: -YY_RULE_SETUP -#line 284 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, MATRIXINDEX); } - YY_BREAK -case 96: -YY_RULE_SETUP -#line 285 "program/program_lexer.l" -{ return MODELVIEW; } - YY_BREAK -case 97: -YY_RULE_SETUP -#line 286 "program/program_lexer.l" -{ return MVP; } - YY_BREAK -case 98: -YY_RULE_SETUP -#line 287 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, NORMAL); } - YY_BREAK -case 99: -YY_RULE_SETUP -#line 288 "program/program_lexer.l" -{ return OBJECT; } - YY_BREAK -case 100: -YY_RULE_SETUP -#line 289 "program/program_lexer.l" -{ return PALETTE; } - YY_BREAK -case 101: -YY_RULE_SETUP -#line 290 "program/program_lexer.l" -{ return PARAMS; } - YY_BREAK -case 102: -YY_RULE_SETUP -#line 291 "program/program_lexer.l" -{ return PLANE; } - YY_BREAK -case 103: -YY_RULE_SETUP -#line 292 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, POINT_TOK); } - YY_BREAK -case 104: -YY_RULE_SETUP -#line 293 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, POINTSIZE); } - YY_BREAK -case 105: -YY_RULE_SETUP -#line 294 "program/program_lexer.l" -{ return POSITION; } - YY_BREAK -case 106: -YY_RULE_SETUP -#line 295 "program/program_lexer.l" -{ return PRIMARY; } - YY_BREAK -case 107: -YY_RULE_SETUP -#line 296 "program/program_lexer.l" -{ return PROJECTION; } - YY_BREAK -case 108: -YY_RULE_SETUP -#line 297 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_fp, RANGE); } - YY_BREAK -case 109: -YY_RULE_SETUP -#line 298 "program/program_lexer.l" -{ return ROW; } - YY_BREAK -case 110: -YY_RULE_SETUP -#line 299 "program/program_lexer.l" -{ return SCENECOLOR; } - YY_BREAK -case 111: -YY_RULE_SETUP -#line 300 "program/program_lexer.l" -{ return SECONDARY; } - YY_BREAK -case 112: -YY_RULE_SETUP -#line 301 "program/program_lexer.l" -{ return SHININESS; } - YY_BREAK -case 113: -YY_RULE_SETUP -#line 302 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, SIZE_TOK); } - YY_BREAK -case 114: -YY_RULE_SETUP -#line 303 "program/program_lexer.l" -{ return SPECULAR; } - YY_BREAK -case 115: -YY_RULE_SETUP -#line 304 "program/program_lexer.l" -{ return SPOT; } - YY_BREAK -case 116: -YY_RULE_SETUP -#line 305 "program/program_lexer.l" -{ return TEXCOORD; } - YY_BREAK -case 117: -YY_RULE_SETUP -#line 306 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_fp, TEXENV); } - YY_BREAK -case 118: -YY_RULE_SETUP -#line 307 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, TEXGEN); } - YY_BREAK -case 119: -YY_RULE_SETUP -#line 308 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, TEXGEN_Q); } - YY_BREAK -case 120: -YY_RULE_SETUP -#line 309 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, TEXGEN_S); } - YY_BREAK -case 121: -YY_RULE_SETUP -#line 310 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, TEXGEN_T); } - YY_BREAK -case 122: -YY_RULE_SETUP -#line 311 "program/program_lexer.l" -{ return TEXTURE; } - YY_BREAK -case 123: -YY_RULE_SETUP -#line 312 "program/program_lexer.l" -{ return TRANSPOSE; } - YY_BREAK -case 124: -YY_RULE_SETUP -#line 313 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, VTXATTRIB); } - YY_BREAK -case 125: -YY_RULE_SETUP -#line 314 "program/program_lexer.l" -{ return_token_or_DOT(require_ARB_vp, WEIGHT); } - YY_BREAK -case 126: -YY_RULE_SETUP -#line 316 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); } - YY_BREAK -case 127: -YY_RULE_SETUP -#line 317 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); } - YY_BREAK -case 128: -YY_RULE_SETUP -#line 318 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); } - YY_BREAK -case 129: -YY_RULE_SETUP -#line 319 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); } - YY_BREAK -case 130: -YY_RULE_SETUP -#line 320 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); } - YY_BREAK -case 131: -YY_RULE_SETUP -#line 321 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(GL_FALSE, TEX_RECT); } - YY_BREAK -case 132: -YY_RULE_SETUP -#line 322 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); } - YY_BREAK -case 133: -YY_RULE_SETUP -#line 323 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); } - YY_BREAK -case 134: -YY_RULE_SETUP -#line 324 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(GL_FALSE, TEX_SHADOWRECT); } - YY_BREAK -case 135: -YY_RULE_SETUP -#line 325 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); } - YY_BREAK -case 136: -YY_RULE_SETUP -#line 326 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); } - YY_BREAK -case 137: -YY_RULE_SETUP -#line 327 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); } - YY_BREAK -case 138: -YY_RULE_SETUP -#line 328 "program/program_lexer.l" -{ return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } - YY_BREAK -case 139: -YY_RULE_SETUP -#line 330 "program/program_lexer.l" -{ return handle_ident(yyextra, yytext, yylval); } - YY_BREAK -case 140: -YY_RULE_SETUP -#line 332 "program/program_lexer.l" -{ return DOT_DOT; } - YY_BREAK -case 141: -YY_RULE_SETUP -#line 334 "program/program_lexer.l" -{ - yylval->integer = strtol(yytext, NULL, 10); - return INTEGER; -} - YY_BREAK -case 142: -YY_RULE_SETUP -#line 338 "program/program_lexer.l" -{ - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} - YY_BREAK -case 143: -/* rule 143 can match eol */ -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 342 "program/program_lexer.l" -{ - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} - YY_BREAK -case 144: -YY_RULE_SETUP -#line 346 "program/program_lexer.l" -{ - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} - YY_BREAK -case 145: -YY_RULE_SETUP -#line 350 "program/program_lexer.l" -{ - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} - YY_BREAK -case 146: -YY_RULE_SETUP -#line 355 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_NOOP; - yylval->swiz_mask.mask = WRITEMASK_XYZW; - return MASK4; -} - YY_BREAK -case 147: -YY_RULE_SETUP -#line 361 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XY - | mask_from_char(yytext[3]); - return MASK3; -} - YY_BREAK -case 148: -YY_RULE_SETUP -#line 367 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XZW; - return MASK3; -} - YY_BREAK -case 149: -YY_RULE_SETUP -#line 372 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_YZW; - return MASK3; -} - YY_BREAK -case 150: -YY_RULE_SETUP -#line 378 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_X - | mask_from_char(yytext[2]); - return MASK2; -} - YY_BREAK -case 151: -YY_RULE_SETUP -#line 384 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_Y - | mask_from_char(yytext[2]); - return MASK2; -} - YY_BREAK -case 152: -YY_RULE_SETUP -#line 390 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_ZW; - return MASK2; -} - YY_BREAK -case 153: -YY_RULE_SETUP -#line 396 "program/program_lexer.l" -{ - const unsigned s = swiz_from_char(yytext[1]); - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); - yylval->swiz_mask.mask = mask_from_char(yytext[1]); - return MASK1; -} - YY_BREAK -case 154: -YY_RULE_SETUP -#line 403 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), - swiz_from_char(yytext[2]), - swiz_from_char(yytext[3]), - swiz_from_char(yytext[4])); - yylval->swiz_mask.mask = 0; - return SWIZZLE; -} - YY_BREAK -case 155: -YY_RULE_SETUP -#line 412 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_NOOP; - yylval->swiz_mask.mask = WRITEMASK_XYZW; - return_token_or_DOT(require_ARB_fp, MASK4); -} - YY_BREAK -case 156: -YY_RULE_SETUP -#line 418 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XY - | mask_from_char(yytext[3]); - return_token_or_DOT(require_ARB_fp, MASK3); -} - YY_BREAK -case 157: -YY_RULE_SETUP -#line 424 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XZW; - return_token_or_DOT(require_ARB_fp, MASK3); -} - YY_BREAK -case 158: -YY_RULE_SETUP -#line 429 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_YZW; - return_token_or_DOT(require_ARB_fp, MASK3); -} - YY_BREAK -case 159: -YY_RULE_SETUP -#line 435 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_X - | mask_from_char(yytext[2]); - return_token_or_DOT(require_ARB_fp, MASK2); -} - YY_BREAK -case 160: -YY_RULE_SETUP -#line 441 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_Y - | mask_from_char(yytext[2]); - return_token_or_DOT(require_ARB_fp, MASK2); -} - YY_BREAK -case 161: -YY_RULE_SETUP -#line 447 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_ZW; - return_token_or_DOT(require_ARB_fp, MASK2); -} - YY_BREAK -case 162: -YY_RULE_SETUP -#line 453 "program/program_lexer.l" -{ - const unsigned s = swiz_from_char(yytext[1]); - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); - yylval->swiz_mask.mask = mask_from_char(yytext[1]); - return_token_or_DOT(require_ARB_fp, MASK1); -} - YY_BREAK -case 163: -YY_RULE_SETUP -#line 461 "program/program_lexer.l" -{ - if (require_ARB_vp) { - return TEXGEN_R; - } else { - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, - SWIZZLE_X, SWIZZLE_X); - yylval->swiz_mask.mask = WRITEMASK_X; - return MASK1; - } -} - YY_BREAK -case 164: -YY_RULE_SETUP -#line 472 "program/program_lexer.l" -{ - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), - swiz_from_char(yytext[2]), - swiz_from_char(yytext[3]), - swiz_from_char(yytext[4])); - yylval->swiz_mask.mask = 0; - return_token_or_DOT(require_ARB_fp, SWIZZLE); -} - YY_BREAK -case 165: -YY_RULE_SETUP -#line 481 "program/program_lexer.l" -{ return DOT; } - YY_BREAK -case 166: -/* rule 166 can match eol */ -YY_RULE_SETUP -#line 483 "program/program_lexer.l" -{ - yylloc->first_line++; - yylloc->first_column = 1; - yylloc->last_line++; - yylloc->last_column = 1; - yylloc->position++; -} - YY_BREAK -case 167: -YY_RULE_SETUP -#line 490 "program/program_lexer.l" -/* eat whitespace */ ; - YY_BREAK -case 168: -*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ -yyg->yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 491 "program/program_lexer.l" -/* eat comments */ ; - YY_BREAK -case 169: -YY_RULE_SETUP -#line 492 "program/program_lexer.l" -{ return yytext[0]; } - YY_BREAK -case 170: -YY_RULE_SETUP -#line 493 "program/program_lexer.l" -ECHO; - YY_BREAK -#line 2481 "program/lex.yy.c" -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yyg->yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 850 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -{ - register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 850 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 849); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) -{ - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_cp = yyg->yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yyg->yy_hold_char; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yyg->yy_n_chars + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - yyg->yytext_ptr = yy_bp; - yyg->yy_hold_char = *yy_cp; - yyg->yy_c_buf_p = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - yy_load_buffer_state(yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; -} - -static void yy_load_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ,yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ,yyscanner ); - - yyfree((void *) b ,yyscanner ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) - -{ - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_flush_buffer(b ,yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state(yyscanner ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -void yypop_buffer_state (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -{ - int num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ,yyscanner ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); -} - -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/** Set the current line number. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "yyset_lineno called with no buffer" , yyscanner); - - yylineno = line_number; -} - -/** Set the current column. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_column (int column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "yyset_column called with no buffer" , yyscanner); - - yycolumn = column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; -} - -void yyset_out (FILE * out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; -} - -/* Accessor methods for yylval and yylloc */ - -YYSTYPE * yyget_lval (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylval; -} - -void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylval = yylval_param; -} - -YYLTYPE *yyget_lloc (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylloc; -} - -void yyset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylloc = yylloc_param; -} - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ - -int yylex_init(yyscan_t* ptr_yy_globals) - -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ - -int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - -{ - struct yyguts_t dummy_yyguts; - - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} - -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 493 "program/program_lexer.l" - - - -void -_mesa_program_lexer_ctor(void **scanner, struct asm_parser_state *state, - const char *string, size_t len) -{ - yylex_init_extra(state,scanner); - yy_scan_bytes(string,len,*scanner); -} - -void -_mesa_program_lexer_dtor(void *scanner) -{ - yylex_destroy(scanner); -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.c b/reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.c deleted file mode 100644 index f3caa399ca6..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.c +++ /dev/null @@ -1,1592 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 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. - */ - -/** - * \file nvfragparse.c - * NVIDIA fragment program parser. - * \author Brian Paul - */ - -/* - * Regarding GL_NV_fragment_program: - * - * Portions of this software may use or implement intellectual - * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims - * any and all warranties with respect to such intellectual property, - * including any use thereof or modifications thereto. - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/imports.h" -#include "main/macros.h" -#include "program.h" -#include "prog_parameter.h" -#include "prog_print.h" -#include "prog_instruction.h" -#include "nvfragparse.h" - - -#define INPUT_1V 1 -#define INPUT_2V 2 -#define INPUT_3V 3 -#define INPUT_1S 4 -#define INPUT_2S 5 -#define INPUT_CC 6 -#define INPUT_1V_T 7 /* one source vector, plus textureId */ -#define INPUT_3V_T 8 /* one source vector, plus textureId */ -#define INPUT_NONE 9 -#define INPUT_1V_S 10 /* a string and a vector register */ -#define OUTPUT_V 20 -#define OUTPUT_S 21 -#define OUTPUT_NONE 22 - -/* IRIX defines some of these */ -#undef _R -#undef _H -#undef _X -#undef _C -#undef _S - -/* Optional suffixes */ -#define _R FLOAT32 /* float */ -#define _H FLOAT16 /* half-float */ -#define _X FIXED12 /* fixed */ -#define _C 0x08 /* set cond codes */ -#define _S 0x10 /* saturate, clamp result to [0,1] */ - -struct instruction_pattern { - const char *name; - enum prog_opcode opcode; - GLuint inputs; - GLuint outputs; - GLuint suffixes; -}; - -static const struct instruction_pattern Instructions[] = { - { "ADD", OPCODE_ADD, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "COS", OPCODE_COS, INPUT_1S, OUTPUT_S, _R | _H | _C | _S }, - { "DDX", OPCODE_DDX, INPUT_1V, OUTPUT_V, _R | _H | _C | _S }, - { "DDY", OPCODE_DDY, INPUT_1V, OUTPUT_V, _R | _H | _C | _S }, - { "DP3", OPCODE_DP3, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S }, - { "DP4", OPCODE_DP4, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S }, - { "DST", OPCODE_DP4, INPUT_2V, OUTPUT_V, _R | _H | _C | _S }, - { "EX2", OPCODE_DP4, INPUT_1S, OUTPUT_S, _R | _H | _C | _S }, - { "FLR", OPCODE_FLR, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "FRC", OPCODE_FRC, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "KIL", OPCODE_KIL_NV, INPUT_CC, OUTPUT_NONE, 0 }, - { "LG2", OPCODE_LG2, INPUT_1S, OUTPUT_S, _R | _H | _C | _S }, - { "LIT", OPCODE_LIT, INPUT_1V, OUTPUT_V, _R | _H | _C | _S }, - { "LRP", OPCODE_LRP, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "MAD", OPCODE_MAD, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "MAX", OPCODE_MAX, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "MIN", OPCODE_MIN, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "MOV", OPCODE_MOV, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "MUL", OPCODE_MUL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "PK2H", OPCODE_PK2H, INPUT_1V, OUTPUT_S, 0 }, - { "PK2US", OPCODE_PK2US, INPUT_1V, OUTPUT_S, 0 }, - { "PK4B", OPCODE_PK4B, INPUT_1V, OUTPUT_S, 0 }, - { "PK4UB", OPCODE_PK4UB, INPUT_1V, OUTPUT_S, 0 }, - { "POW", OPCODE_POW, INPUT_2S, OUTPUT_S, _R | _H | _C | _S }, - { "RCP", OPCODE_RCP, INPUT_1S, OUTPUT_S, _R | _H | _C | _S }, - { "RFL", OPCODE_RFL, INPUT_2V, OUTPUT_V, _R | _H | _C | _S }, - { "RSQ", OPCODE_RSQ, INPUT_1S, OUTPUT_S, _R | _H | _C | _S }, - { "SEQ", OPCODE_SEQ, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "SFL", OPCODE_SFL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "SGE", OPCODE_SGE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "SGT", OPCODE_SGT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "SIN", OPCODE_SIN, INPUT_1S, OUTPUT_S, _R | _H | _C | _S }, - { "SLE", OPCODE_SLE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "SLT", OPCODE_SLT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "SNE", OPCODE_SNE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "STR", OPCODE_STR, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "SUB", OPCODE_SUB, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S }, - { "TEX", OPCODE_TEX, INPUT_1V_T, OUTPUT_V, _C | _S }, - { "TXD", OPCODE_TXD, INPUT_3V_T, OUTPUT_V, _C | _S }, - { "TXP", OPCODE_TXP_NV, INPUT_1V_T, OUTPUT_V, _C | _S }, - { "UP2H", OPCODE_UP2H, INPUT_1S, OUTPUT_V, _C | _S }, - { "UP2US", OPCODE_UP2US, INPUT_1S, OUTPUT_V, _C | _S }, - { "UP4B", OPCODE_UP4B, INPUT_1S, OUTPUT_V, _C | _S }, - { "UP4UB", OPCODE_UP4UB, INPUT_1S, OUTPUT_V, _C | _S }, - { "X2D", OPCODE_X2D, INPUT_3V, OUTPUT_V, _R | _H | _C | _S }, - { "PRINT", OPCODE_PRINT, INPUT_1V_S, OUTPUT_NONE, 0 }, - { NULL, (enum prog_opcode) -1, 0, 0, 0 } -}; - - -/* - * Information needed or computed during parsing. - * Remember, we can't modify the target program object until we've - * _successfully_ parsed the program text. - */ -struct parse_state { - struct gl_context *ctx; - const GLubyte *start; /* start of program string */ - const GLubyte *pos; /* current position */ - const GLubyte *curLine; - struct gl_fragment_program *program; /* current program */ - - struct gl_program_parameter_list *parameters; - - GLuint numInst; /* number of instructions parsed */ - GLuint inputsRead; /* bitmask of input registers used */ - GLuint outputsWritten; /* bitmask of 1 << FRAG_OUTPUT_* bits */ - GLuint texturesUsed[MAX_TEXTURE_IMAGE_UNITS]; -}; - - - -/* - * Called whenever we find an error during parsing. - */ -static void -record_error(struct parse_state *parseState, const char *msg, int lineNo) -{ -#ifdef DEBUG - GLint line, column; - const GLubyte *lineStr; - lineStr = _mesa_find_line_column(parseState->start, - parseState->pos, &line, &column); - _mesa_debug(parseState->ctx, - "nvfragparse.c(%d): line %d, column %d:%s (%s)\n", - lineNo, line, column, (char *) lineStr, msg); - free((void *) lineStr); -#else - (void) lineNo; -#endif - - /* Check that no error was already recorded. Only record the first one. */ - if (parseState->ctx->Program.ErrorString[0] == 0) { - _mesa_set_program_error(parseState->ctx, - parseState->pos - parseState->start, - msg); - } -} - - -#define RETURN_ERROR \ -do { \ - record_error(parseState, "Unexpected end of input.", __LINE__); \ - return GL_FALSE; \ -} while(0) - -#define RETURN_ERROR1(msg) \ -do { \ - record_error(parseState, msg, __LINE__); \ - return GL_FALSE; \ -} while(0) - -#define RETURN_ERROR2(msg1, msg2) \ -do { \ - char err[1000]; \ - sprintf(err, "%s %s", msg1, msg2); \ - record_error(parseState, err, __LINE__); \ - return GL_FALSE; \ -} while(0) - - - - -/* - * Search a list of instruction structures for a match. - */ -static struct instruction_pattern -MatchInstruction(const GLubyte *token) -{ - const struct instruction_pattern *inst; - struct instruction_pattern result; - - result.name = NULL; - result.opcode = MAX_OPCODE; /* i.e. invalid instruction */ - result.inputs = 0; - result.outputs = 0; - result.suffixes = 0; - - for (inst = Instructions; inst->name; inst++) { - if (strncmp((const char *) token, inst->name, 3) == 0) { - /* matched! */ - int i = 3; - result = *inst; - result.suffixes = 0; - /* look at suffix */ - if (token[i] == 'R') { - result.suffixes |= _R; - i++; - } - else if (token[i] == 'H') { - result.suffixes |= _H; - i++; - } - else if (token[i] == 'X') { - result.suffixes |= _X; - i++; - } - if (token[i] == 'C') { - result.suffixes |= _C; - i++; - } - if (token[i] == '_' && token[i+1] == 'S' && - token[i+2] == 'A' && token[i+3] == 'T') { - result.suffixes |= _S; - } - return result; - } - } - - return result; -} - - - - -/**********************************************************************/ - - -static GLboolean IsLetter(GLubyte b) -{ - return (b >= 'a' && b <= 'z') || - (b >= 'A' && b <= 'Z') || - (b == '_') || - (b == '$'); -} - - -static GLboolean IsDigit(GLubyte b) -{ - return b >= '0' && b <= '9'; -} - - -static GLboolean IsWhitespace(GLubyte b) -{ - return b == ' ' || b == '\t' || b == '\n' || b == '\r'; -} - - -/** - * Starting at 'str' find the next token. A token can be an integer, - * an identifier or punctuation symbol. - * \return <= 0 we found an error, else, return number of characters parsed. - */ -static GLint -GetToken(struct parse_state *parseState, GLubyte *token) -{ - const GLubyte *str = parseState->pos; - GLint i = 0, j = 0; - - token[0] = 0; - - /* skip whitespace and comments */ - while (str[i] && (IsWhitespace(str[i]) || str[i] == '#')) { - if (str[i] == '#') { - /* skip comment */ - while (str[i] && (str[i] != '\n' && str[i] != '\r')) { - i++; - } - if (str[i] == '\n' || str[i] == '\r') - parseState->curLine = str + i + 1; - } - else { - /* skip whitespace */ - if (str[i] == '\n' || str[i] == '\r') - parseState->curLine = str + i + 1; - i++; - } - } - - if (str[i] == 0) - return -i; - - /* try matching an integer */ - while (str[i] && IsDigit(str[i])) { - token[j++] = str[i++]; - } - if (j > 0 || !str[i]) { - token[j] = 0; - return i; - } - - /* try matching an identifier */ - if (IsLetter(str[i])) { - while (str[i] && (IsLetter(str[i]) || IsDigit(str[i]))) { - token[j++] = str[i++]; - } - token[j] = 0; - return i; - } - - /* punctuation character */ - if (str[i]) { - token[0] = str[i++]; - token[1] = 0; - return i; - } - - /* end of input */ - token[0] = 0; - return i; -} - - -/** - * Get next token from input stream and increment stream pointer past token. - */ -static GLboolean -Parse_Token(struct parse_state *parseState, GLubyte *token) -{ - GLint i; - i = GetToken(parseState, token); - if (i <= 0) { - parseState->pos += (-i); - return GL_FALSE; - } - parseState->pos += i; - return GL_TRUE; -} - - -/** - * Get next token from input stream but don't increment stream pointer. - */ -static GLboolean -Peek_Token(struct parse_state *parseState, GLubyte *token) -{ - GLint i, len; - i = GetToken(parseState, token); - if (i <= 0) { - parseState->pos += (-i); - return GL_FALSE; - } - len = (GLint) strlen((const char *) token); - parseState->pos += (i - len); - return GL_TRUE; -} - - -/**********************************************************************/ - -static const char *InputRegisters[MAX_NV_FRAGMENT_PROGRAM_INPUTS + 1] = { - "WPOS", "COL0", "COL1", "FOGC", - "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", NULL -}; - - - -/**********************************************************************/ - -/** - * Try to match 'pattern' as the next token after any whitespace/comments. - */ -static GLboolean -Parse_String(struct parse_state *parseState, const char *pattern) -{ - const GLubyte *m; - GLint i; - - /* skip whitespace and comments */ - while (IsWhitespace(*parseState->pos) || *parseState->pos == '#') { - if (*parseState->pos == '#') { - while (*parseState->pos && (*parseState->pos != '\n' && *parseState->pos != '\r')) { - parseState->pos += 1; - } - if (*parseState->pos == '\n' || *parseState->pos == '\r') - parseState->curLine = parseState->pos + 1; - } - else { - /* skip whitespace */ - if (*parseState->pos == '\n' || *parseState->pos == '\r') - parseState->curLine = parseState->pos + 1; - parseState->pos += 1; - } - } - - /* Try to match the pattern */ - m = parseState->pos; - for (i = 0; pattern[i]; i++) { - if (*m != (GLubyte) pattern[i]) - return GL_FALSE; - m += 1; - } - parseState->pos = m; - - return GL_TRUE; /* success */ -} - - -static GLboolean -Parse_Identifier(struct parse_state *parseState, GLubyte *ident) -{ - if (!Parse_Token(parseState, ident)) - RETURN_ERROR; - if (IsLetter(ident[0])) - return GL_TRUE; - else - RETURN_ERROR1("Expected an identfier"); -} - - -/** - * Parse a floating point constant, or a defined symbol name. - * [+/-]N[.N[eN]] - * Output: number[0 .. 3] will get the value. - */ -static GLboolean -Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number) -{ - char *end = NULL; - - *number = (GLfloat) _mesa_strtof((const char *) parseState->pos, &end); - - if (end && end > (char *) parseState->pos) { - /* got a number */ - parseState->pos = (GLubyte *) end; - number[1] = *number; - number[2] = *number; - number[3] = *number; - return GL_TRUE; - } - else { - /* should be an identifier */ - GLubyte ident[100]; - const GLfloat *constant; - if (!Parse_Identifier(parseState, ident)) - RETURN_ERROR1("Expected an identifier"); - constant = (GLfloat *)_mesa_lookup_parameter_value(parseState->parameters, - -1, - (const char *) ident); - /* XXX Check that it's a constant and not a parameter */ - if (!constant) { - RETURN_ERROR1("Undefined symbol"); - } - else { - COPY_4V(number, constant); - return GL_TRUE; - } - } -} - - - -/** - * Parse a vector constant, one of: - * { float } - * { float, float } - * { float, float, float } - * { float, float, float, float } - */ -static GLboolean -Parse_VectorConstant(struct parse_state *parseState, GLfloat *vec) -{ - /* "{" was already consumed */ - - ASSIGN_4V(vec, 0.0, 0.0, 0.0, 1.0); - - if (!Parse_ScalarConstant(parseState, vec+0)) /* X */ - return GL_FALSE; - - if (Parse_String(parseState, "}")) { - return GL_TRUE; - } - - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected comma in vector constant"); - - if (!Parse_ScalarConstant(parseState, vec+1)) /* Y */ - return GL_FALSE; - - if (Parse_String(parseState, "}")) { - return GL_TRUE; - } - - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected comma in vector constant"); - - if (!Parse_ScalarConstant(parseState, vec+2)) /* Z */ - return GL_FALSE; - - if (Parse_String(parseState, "}")) { - return GL_TRUE; - } - - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected comma in vector constant"); - - if (!Parse_ScalarConstant(parseState, vec+3)) /* W */ - return GL_FALSE; - - if (!Parse_String(parseState, "}")) - RETURN_ERROR1("Expected closing brace in vector constant"); - - return GL_TRUE; -} - - -/** - * Parse , or {a, b, c, d}. - * Return number of values in the vector or scalar, or zero if parse error. - */ -static GLuint -Parse_VectorOrScalarConstant(struct parse_state *parseState, GLfloat *vec) -{ - if (Parse_String(parseState, "{")) { - return Parse_VectorConstant(parseState, vec); - } - else { - GLboolean b = Parse_ScalarConstant(parseState, vec); - if (b) { - vec[1] = vec[2] = vec[3] = vec[0]; - } - return b; - } -} - - -/** - * Parse a texture image source: - * [TEX0 | TEX1 | .. | TEX15] , [1D | 2D | 3D | CUBE | RECT] - */ -static GLboolean -Parse_TextureImageId(struct parse_state *parseState, - GLubyte *texUnit, GLubyte *texTarget) -{ - GLubyte imageSrc[100]; - GLint unit; - - if (!Parse_Token(parseState, imageSrc)) - RETURN_ERROR; - - if (imageSrc[0] != 'T' || - imageSrc[1] != 'E' || - imageSrc[2] != 'X') { - RETURN_ERROR1("Expected TEX# source"); - } - unit = atoi((const char *) imageSrc + 3); - if ((unit < 0 || unit > MAX_TEXTURE_IMAGE_UNITS) || - (unit == 0 && (imageSrc[3] != '0' || imageSrc[4] != 0))) { - RETURN_ERROR1("Invalied TEX# source index"); - } - *texUnit = unit; - - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - - if (Parse_String(parseState, "1D")) { - *texTarget = TEXTURE_1D_INDEX; - } - else if (Parse_String(parseState, "2D")) { - *texTarget = TEXTURE_2D_INDEX; - } - else if (Parse_String(parseState, "3D")) { - *texTarget = TEXTURE_3D_INDEX; - } - else if (Parse_String(parseState, "CUBE")) { - *texTarget = TEXTURE_CUBE_INDEX; - } - else { - RETURN_ERROR1("Invalid texture target token"); - } - - /* update record of referenced texture units */ - parseState->texturesUsed[*texUnit] |= (1 << *texTarget); - if (_mesa_bitcount(parseState->texturesUsed[*texUnit]) > 1) { - RETURN_ERROR1("Only one texture target can be used per texture unit."); - } - - return GL_TRUE; -} - - -/** - * Parse a scalar suffix like .x, .y, .z or .w or parse a swizzle suffix - * like .wxyz, .xxyy, etc and return the swizzle indexes. - */ -static GLboolean -Parse_SwizzleSuffix(const GLubyte *token, GLuint swizzle[4]) -{ - if (token[1] == 0) { - /* single letter swizzle (scalar) */ - if (token[0] == 'x') - ASSIGN_4V(swizzle, 0, 0, 0, 0); - else if (token[0] == 'y') - ASSIGN_4V(swizzle, 1, 1, 1, 1); - else if (token[0] == 'z') - ASSIGN_4V(swizzle, 2, 2, 2, 2); - else if (token[0] == 'w') - ASSIGN_4V(swizzle, 3, 3, 3, 3); - else - return GL_FALSE; - } - else { - /* 4-component swizzle (vector) */ - GLint k; - for (k = 0; k < 4 && token[k]; k++) { - if (token[k] == 'x') - swizzle[k] = 0; - else if (token[k] == 'y') - swizzle[k] = 1; - else if (token[k] == 'z') - swizzle[k] = 2; - else if (token[k] == 'w') - swizzle[k] = 3; - else - return GL_FALSE; - } - if (k != 4) - return GL_FALSE; - } - return GL_TRUE; -} - - -static GLboolean -Parse_CondCodeMask(struct parse_state *parseState, - struct prog_dst_register *dstReg) -{ - if (Parse_String(parseState, "EQ")) - dstReg->CondMask = COND_EQ; - else if (Parse_String(parseState, "GE")) - dstReg->CondMask = COND_GE; - else if (Parse_String(parseState, "GT")) - dstReg->CondMask = COND_GT; - else if (Parse_String(parseState, "LE")) - dstReg->CondMask = COND_LE; - else if (Parse_String(parseState, "LT")) - dstReg->CondMask = COND_LT; - else if (Parse_String(parseState, "NE")) - dstReg->CondMask = COND_NE; - else if (Parse_String(parseState, "TR")) - dstReg->CondMask = COND_TR; - else if (Parse_String(parseState, "FL")) - dstReg->CondMask = COND_FL; - else - RETURN_ERROR1("Invalid condition code mask"); - - /* look for optional .xyzw swizzle */ - if (Parse_String(parseState, ".")) { - GLubyte token[100]; - GLuint swz[4]; - - if (!Parse_Token(parseState, token)) /* get xyzw suffix */ - RETURN_ERROR; - - if (!Parse_SwizzleSuffix(token, swz)) - RETURN_ERROR1("Invalid swizzle suffix"); - - dstReg->CondSwizzle = MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]); - } - - return GL_TRUE; -} - - -/** - * Parse a temporary register: Rnn or Hnn - */ -static GLboolean -Parse_TempReg(struct parse_state *parseState, GLint *tempRegNum) -{ - GLubyte token[100]; - - /* Should be 'R##' or 'H##' */ - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - if (token[0] != 'R' && token[0] != 'H') - RETURN_ERROR1("Expected R## or H##"); - - if (IsDigit(token[1])) { - GLint reg = atoi((const char *) (token + 1)); - if (token[0] == 'H') - reg += 32; - if (reg >= MAX_NV_FRAGMENT_PROGRAM_TEMPS) - RETURN_ERROR1("Invalid temporary register name"); - *tempRegNum = reg; - } - else { - RETURN_ERROR1("Invalid temporary register name"); - } - - return GL_TRUE; -} - - -/** - * Parse a write-only dummy register: RC or HC. - */ -static GLboolean -Parse_DummyReg(struct parse_state *parseState, GLint *regNum) -{ - if (Parse_String(parseState, "RC")) { - *regNum = 0; - } - else if (Parse_String(parseState, "HC")) { - *regNum = 1; - } - else { - RETURN_ERROR1("Invalid write-only register name"); - } - - return GL_TRUE; -} - - -/** - * Parse a program local parameter register "p[##]" - */ -static GLboolean -Parse_ProgramParamReg(struct parse_state *parseState, GLint *regNum) -{ - GLubyte token[100]; - - if (!Parse_String(parseState, "p[")) - RETURN_ERROR1("Expected p["); - - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (IsDigit(token[0])) { - /* a numbered program parameter register */ - GLint reg = atoi((const char *) token); - if (reg >= MAX_NV_FRAGMENT_PROGRAM_PARAMS) - RETURN_ERROR1("Invalid constant program number"); - *regNum = reg; - } - else { - RETURN_ERROR; - } - - if (!Parse_String(parseState, "]")) - RETURN_ERROR1("Expected ]"); - - return GL_TRUE; -} - - -/** - * Parse f[name] - fragment input register - */ -static GLboolean -Parse_FragReg(struct parse_state *parseState, GLint *tempRegNum) -{ - GLubyte token[100]; - GLint j; - - /* Match 'f[' */ - if (!Parse_String(parseState, "f[")) - RETURN_ERROR1("Expected f["); - - /* get and look for match */ - if (!Parse_Token(parseState, token)) { - RETURN_ERROR; - } - for (j = 0; InputRegisters[j]; j++) { - if (strcmp((const char *) token, InputRegisters[j]) == 0) { - *tempRegNum = j; - parseState->inputsRead |= (1 << j); - break; - } - } - if (!InputRegisters[j]) { - /* unknown input register label */ - RETURN_ERROR2("Invalid register name", token); - } - - /* Match '[' */ - if (!Parse_String(parseState, "]")) - RETURN_ERROR1("Expected ]"); - - return GL_TRUE; -} - - -static GLboolean -Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum) -{ - GLubyte token[100]; - - /* Match "o[" */ - if (!Parse_String(parseState, "o[")) - RETURN_ERROR1("Expected o["); - - /* Get output reg name */ - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - /* try to match an output register name */ - if (strcmp((char *) token, "COLR") == 0 || - strcmp((char *) token, "COLH") == 0) { - /* note that we don't distinguish between COLR and COLH */ - *outputRegNum = FRAG_RESULT_COLOR; - parseState->outputsWritten |= (1 << FRAG_RESULT_COLOR); - } - else if (strcmp((char *) token, "DEPR") == 0) { - *outputRegNum = FRAG_RESULT_DEPTH; - parseState->outputsWritten |= (1 << FRAG_RESULT_DEPTH); - } - else { - RETURN_ERROR1("Invalid output register name"); - } - - /* Match ']' */ - if (!Parse_String(parseState, "]")) - RETURN_ERROR1("Expected ]"); - - return GL_TRUE; -} - - -static GLboolean -Parse_MaskedDstReg(struct parse_state *parseState, - struct prog_dst_register *dstReg) -{ - GLubyte token[100]; - GLint idx; - - /* Dst reg can be R, H, o[n], RC or HC */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - if (strcmp((const char *) token, "RC") == 0 || - strcmp((const char *) token, "HC") == 0) { - /* a write-only register */ - dstReg->File = PROGRAM_WRITE_ONLY; - if (!Parse_DummyReg(parseState, &idx)) - RETURN_ERROR; - dstReg->Index = idx; - } - else if (token[0] == 'R' || token[0] == 'H') { - /* a temporary register */ - dstReg->File = PROGRAM_TEMPORARY; - if (!Parse_TempReg(parseState, &idx)) - RETURN_ERROR; - dstReg->Index = idx; - } - else if (token[0] == 'o') { - /* an output register */ - dstReg->File = PROGRAM_OUTPUT; - if (!Parse_OutputReg(parseState, &idx)) - RETURN_ERROR; - dstReg->Index = idx; - } - else { - RETURN_ERROR1("Invalid destination register name"); - } - - /* Parse optional write mask */ - if (Parse_String(parseState, ".")) { - /* got a mask */ - GLint k = 0; - - if (!Parse_Token(parseState, token)) /* get xyzw writemask */ - RETURN_ERROR; - - dstReg->WriteMask = 0; - - if (token[k] == 'x') { - dstReg->WriteMask |= WRITEMASK_X; - k++; - } - if (token[k] == 'y') { - dstReg->WriteMask |= WRITEMASK_Y; - k++; - } - if (token[k] == 'z') { - dstReg->WriteMask |= WRITEMASK_Z; - k++; - } - if (token[k] == 'w') { - dstReg->WriteMask |= WRITEMASK_W; - k++; - } - if (k == 0) { - RETURN_ERROR1("Invalid writemask character"); - } - - } - else { - dstReg->WriteMask = WRITEMASK_XYZW; - } - - /* optional condition code mask */ - if (Parse_String(parseState, "(")) { - /* ("EQ" | "GE" | "GT" | "LE" | "LT" | "NE" | "TR" | "FL".x|y|z|w) */ - /* ("EQ" | "GE" | "GT" | "LE" | "LT" | "NE" | "TR" | "FL".[xyzw]) */ - if (!Parse_CondCodeMask(parseState, dstReg)) - RETURN_ERROR; - - if (!Parse_String(parseState, ")")) /* consume ")" */ - RETURN_ERROR1("Expected )"); - - return GL_TRUE; - } - else { - /* no cond code mask */ - dstReg->CondMask = COND_TR; - dstReg->CondSwizzle = SWIZZLE_NOOP; - return GL_TRUE; - } -} - - -/** - * Parse a vector source (register, constant, etc): - * ::= - * | - * ::= "|" "|" - */ -static GLboolean -Parse_VectorSrc(struct parse_state *parseState, - struct prog_src_register *srcReg) -{ - GLfloat sign = 1.0F; - GLubyte token[100]; - GLint idx; - GLuint negateBase, negateAbs; - - /* - * First, take care of +/- and absolute value stuff. - */ - if (Parse_String(parseState, "-")) - sign = -1.0F; - else if (Parse_String(parseState, "+")) - sign = +1.0F; - - if (Parse_String(parseState, "|")) { - srcReg->Abs = GL_TRUE; - negateAbs = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE; - - if (Parse_String(parseState, "-")) - negateBase = NEGATE_XYZW; - else if (Parse_String(parseState, "+")) - negateBase = NEGATE_NONE; - else - negateBase = NEGATE_NONE; - } - else { - srcReg->Abs = GL_FALSE; - negateAbs = NEGATE_NONE; - negateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE; - } - - srcReg->Negate = srcReg->Abs ? negateAbs : negateBase; - - /* This should be the real src vector/register name */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - /* Src reg can be Rn, Hn, f[n], p[n], a named parameter, a scalar - * literal or vector literal. - */ - if (token[0] == 'R' || token[0] == 'H') { - srcReg->File = PROGRAM_TEMPORARY; - if (!Parse_TempReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == 'f') { - /* XXX this might be an identifier! */ - srcReg->File = PROGRAM_INPUT; - if (!Parse_FragReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == 'p') { - /* XXX this might be an identifier! */ - srcReg->File = PROGRAM_LOCAL_PARAM; - if (!Parse_ProgramParamReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (IsLetter(token[0])){ - GLubyte ident[100]; - GLint paramIndex; - if (!Parse_Identifier(parseState, ident)) - RETURN_ERROR; - paramIndex = _mesa_lookup_parameter_index(parseState->parameters, - -1, (const char *) ident); - if (paramIndex < 0) { - RETURN_ERROR2("Undefined constant or parameter: ", ident); - } - srcReg->File = PROGRAM_NAMED_PARAM; - srcReg->Index = paramIndex; - } - else if (IsDigit(token[0]) || token[0] == '-' || token[0] == '+' || token[0] == '.'){ - /* literal scalar constant */ - GLfloat values[4]; - GLuint paramIndex; - if (!Parse_ScalarConstant(parseState, values)) - RETURN_ERROR; - paramIndex = _mesa_add_unnamed_constant(parseState->parameters, - (gl_constant_value *) values, - 4, NULL); - srcReg->File = PROGRAM_NAMED_PARAM; - srcReg->Index = paramIndex; - } - else if (token[0] == '{'){ - /* literal vector constant */ - GLfloat values[4]; - GLuint paramIndex; - (void) Parse_String(parseState, "{"); - if (!Parse_VectorConstant(parseState, values)) - RETURN_ERROR; - paramIndex = _mesa_add_unnamed_constant(parseState->parameters, - (gl_constant_value *) values, - 4, NULL); - srcReg->File = PROGRAM_NAMED_PARAM; - srcReg->Index = paramIndex; - } - else { - RETURN_ERROR2("Invalid source register name", token); - } - - /* init swizzle fields */ - srcReg->Swizzle = SWIZZLE_NOOP; - - /* Look for optional swizzle suffix */ - if (Parse_String(parseState, ".")) { - GLuint swz[4]; - - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (!Parse_SwizzleSuffix(token, swz)) - RETURN_ERROR1("Invalid swizzle suffix"); - - srcReg->Swizzle = MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]); - } - - /* Finish absolute value */ - if (srcReg->Abs && !Parse_String(parseState, "|")) { - RETURN_ERROR1("Expected |"); - } - - return GL_TRUE; -} - - -static GLboolean -Parse_ScalarSrcReg(struct parse_state *parseState, - struct prog_src_register *srcReg) -{ - GLubyte token[100]; - GLfloat sign = 1.0F; - GLboolean needSuffix = GL_TRUE; - GLint idx; - GLuint negateBase, negateAbs; - - /* - * First, take care of +/- and absolute value stuff. - */ - if (Parse_String(parseState, "-")) - sign = -1.0F; - else if (Parse_String(parseState, "+")) - sign = +1.0F; - - if (Parse_String(parseState, "|")) { - srcReg->Abs = GL_TRUE; - negateAbs = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE; - - if (Parse_String(parseState, "-")) - negateBase = NEGATE_XYZW; - else if (Parse_String(parseState, "+")) - negateBase = NEGATE_NONE; - else - negateBase = NEGATE_NONE; - } - else { - srcReg->Abs = GL_FALSE; - negateAbs = NEGATE_NONE; - negateBase = (sign < 0.0F) ? NEGATE_XYZW : NEGATE_NONE; - } - - srcReg->Negate = srcReg->Abs ? negateAbs : negateBase; - - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - /* Src reg can be R, H or a named fragment attrib */ - if (token[0] == 'R' || token[0] == 'H') { - srcReg->File = PROGRAM_TEMPORARY; - if (!Parse_TempReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == 'f') { - srcReg->File = PROGRAM_INPUT; - if (!Parse_FragReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == '{') { - /* vector literal */ - GLfloat values[4]; - GLuint paramIndex; - (void) Parse_String(parseState, "{"); - if (!Parse_VectorConstant(parseState, values)) - RETURN_ERROR; - paramIndex = _mesa_add_unnamed_constant(parseState->parameters, - (gl_constant_value *) values, - 4, NULL); - srcReg->File = PROGRAM_NAMED_PARAM; - srcReg->Index = paramIndex; - } - else if (IsLetter(token[0])){ - /* named param/constant */ - GLubyte ident[100]; - GLint paramIndex; - if (!Parse_Identifier(parseState, ident)) - RETURN_ERROR; - paramIndex = _mesa_lookup_parameter_index(parseState->parameters, - -1, (const char *) ident); - if (paramIndex < 0) { - RETURN_ERROR2("Undefined constant or parameter: ", ident); - } - srcReg->File = PROGRAM_NAMED_PARAM; - srcReg->Index = paramIndex; - } - else if (IsDigit(token[0])) { - /* scalar literal */ - GLfloat values[4]; - GLuint paramIndex; - if (!Parse_ScalarConstant(parseState, values)) - RETURN_ERROR; - paramIndex = _mesa_add_unnamed_constant(parseState->parameters, - (gl_constant_value *) values, - 4, NULL); - srcReg->Index = paramIndex; - srcReg->File = PROGRAM_NAMED_PARAM; - needSuffix = GL_FALSE; - } - else { - RETURN_ERROR2("Invalid scalar source argument", token); - } - - srcReg->Swizzle = 0; - if (needSuffix) { - /* parse .[xyzw] suffix */ - if (!Parse_String(parseState, ".")) - RETURN_ERROR1("Expected ."); - - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (token[0] == 'x' && token[1] == 0) { - srcReg->Swizzle = 0; - } - else if (token[0] == 'y' && token[1] == 0) { - srcReg->Swizzle = 1; - } - else if (token[0] == 'z' && token[1] == 0) { - srcReg->Swizzle = 2; - } - else if (token[0] == 'w' && token[1] == 0) { - srcReg->Swizzle = 3; - } - else { - RETURN_ERROR1("Invalid scalar source suffix"); - } - } - - /* Finish absolute value */ - if (srcReg->Abs && !Parse_String(parseState, "|")) { - RETURN_ERROR1("Expected |"); - } - - return GL_TRUE; -} - - -static GLboolean -Parse_PrintInstruction(struct parse_state *parseState, - struct prog_instruction *inst) -{ - const GLubyte *str; - GLubyte *msg; - GLuint len; - GLint idx; - - /* The first argument is a literal string 'just like this' */ - if (!Parse_String(parseState, "'")) - RETURN_ERROR1("Expected '"); - - str = parseState->pos; - for (len = 0; str[len] != '\''; len++) /* find closing quote */ - ; - parseState->pos += len + 1; - msg = (GLubyte*) malloc(len + 1); - - memcpy(msg, str, len); - msg[len] = 0; - inst->Data = msg; - - if (Parse_String(parseState, ",")) { - /* got an optional register to print */ - GLubyte token[100]; - GetToken(parseState, token); - if (token[0] == 'o') { - /* dst reg */ - if (!Parse_OutputReg(parseState, &idx)) - RETURN_ERROR; - inst->SrcReg[0].Index = idx; - inst->SrcReg[0].File = PROGRAM_OUTPUT; - } - else { - /* src reg */ - if (!Parse_VectorSrc(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - } - } - else { - inst->SrcReg[0].File = PROGRAM_UNDEFINED; - } - - inst->SrcReg[0].Swizzle = SWIZZLE_NOOP; - inst->SrcReg[0].Abs = GL_FALSE; - inst->SrcReg[0].Negate = NEGATE_NONE; - - return GL_TRUE; -} - - -static GLboolean -Parse_InstructionSequence(struct parse_state *parseState, - struct prog_instruction program[]) -{ - while (1) { - struct prog_instruction *inst = program + parseState->numInst; - struct instruction_pattern instMatch; - GLubyte token[100]; - - /* Initialize the instruction */ - _mesa_init_instructions(inst, 1); - - /* special instructions */ - if (Parse_String(parseState, "DEFINE")) { - GLubyte id[100]; - GLfloat value[7]; /* yes, 7 to be safe */ - if (!Parse_Identifier(parseState, id)) - RETURN_ERROR; - /* XXX make sure id is not a reserved identifer, like R9 */ - if (!Parse_String(parseState, "=")) - RETURN_ERROR1("Expected ="); - if (!Parse_VectorOrScalarConstant(parseState, value)) - RETURN_ERROR; - if (!Parse_String(parseState, ";")) - RETURN_ERROR1("Expected ;"); - if (_mesa_lookup_parameter_index(parseState->parameters, - -1, (const char *) id) >= 0) { - RETURN_ERROR2(id, "already defined"); - } - _mesa_add_named_parameter(parseState->parameters, - (const char *) id, - (gl_constant_value *) value); - } - else if (Parse_String(parseState, "DECLARE")) { - GLubyte id[100]; - GLfloat value[7] = {0, 0, 0, 0, 0, 0, 0}; /* yes, to be safe */ - if (!Parse_Identifier(parseState, id)) - RETURN_ERROR; - /* XXX make sure id is not a reserved identifer, like R9 */ - if (Parse_String(parseState, "=")) { - if (!Parse_VectorOrScalarConstant(parseState, value)) - RETURN_ERROR; - } - if (!Parse_String(parseState, ";")) - RETURN_ERROR1("Expected ;"); - if (_mesa_lookup_parameter_index(parseState->parameters, - -1, (const char *) id) >= 0) { - RETURN_ERROR2(id, "already declared"); - } - _mesa_add_named_parameter(parseState->parameters, - (const char *) id, - (gl_constant_value *) value); - } - else if (Parse_String(parseState, "END")) { - inst->Opcode = OPCODE_END; - parseState->numInst++; - if (Parse_Token(parseState, token)) { - RETURN_ERROR1("Code after END opcode."); - } - break; - } - else { - /* general/arithmetic instruction */ - - /* get token */ - if (!Parse_Token(parseState, token)) { - RETURN_ERROR1("Missing END instruction."); - } - - /* try to find matching instuction */ - instMatch = MatchInstruction(token); - if (instMatch.opcode >= MAX_OPCODE) { - /* bad instruction name */ - RETURN_ERROR2("Unexpected token: ", token); - } - - inst->Opcode = instMatch.opcode; - inst->Precision = instMatch.suffixes & (_R | _H | _X); - inst->SaturateMode = (instMatch.suffixes & (_S)) - ? SATURATE_ZERO_ONE : SATURATE_OFF; - inst->CondUpdate = (instMatch.suffixes & (_C)) ? GL_TRUE : GL_FALSE; - - /* - * parse the input and output operands - */ - if (instMatch.outputs == OUTPUT_S || instMatch.outputs == OUTPUT_V) { - if (!Parse_MaskedDstReg(parseState, &inst->DstReg)) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - } - else if (instMatch.outputs == OUTPUT_NONE) { - if (instMatch.opcode == OPCODE_KIL_NV) { - /* This is a little weird, the cond code info is in - * the dest register. - */ - if (!Parse_CondCodeMask(parseState, &inst->DstReg)) - RETURN_ERROR; - } - else { - ASSERT(instMatch.opcode == OPCODE_PRINT); - } - } - - if (instMatch.inputs == INPUT_1V) { - if (!Parse_VectorSrc(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - } - else if (instMatch.inputs == INPUT_2V) { - if (!Parse_VectorSrc(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_VectorSrc(parseState, &inst->SrcReg[1])) - RETURN_ERROR; - } - else if (instMatch.inputs == INPUT_3V) { - if (!Parse_VectorSrc(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_VectorSrc(parseState, &inst->SrcReg[1])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_VectorSrc(parseState, &inst->SrcReg[2])) - RETURN_ERROR; - } - else if (instMatch.inputs == INPUT_1S) { - if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - } - else if (instMatch.inputs == INPUT_2S) { - if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[1])) - RETURN_ERROR; - } - else if (instMatch.inputs == INPUT_CC) { - /* XXX to-do */ - } - else if (instMatch.inputs == INPUT_1V_T) { - GLubyte unit, idx; - if (!Parse_VectorSrc(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_TextureImageId(parseState, &unit, &idx)) - RETURN_ERROR; - inst->TexSrcUnit = unit; - inst->TexSrcTarget = idx; - } - else if (instMatch.inputs == INPUT_3V_T) { - GLubyte unit, idx; - if (!Parse_VectorSrc(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_VectorSrc(parseState, &inst->SrcReg[1])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_VectorSrc(parseState, &inst->SrcReg[2])) - RETURN_ERROR; - if (!Parse_String(parseState, ",")) - RETURN_ERROR1("Expected ,"); - if (!Parse_TextureImageId(parseState, &unit, &idx)) - RETURN_ERROR; - inst->TexSrcUnit = unit; - inst->TexSrcTarget = idx; - } - else if (instMatch.inputs == INPUT_1V_S) { - if (!Parse_PrintInstruction(parseState, inst)) - RETURN_ERROR; - } - - /* end of statement semicolon */ - if (!Parse_String(parseState, ";")) - RETURN_ERROR1("Expected ;"); - - parseState->numInst++; - - if (parseState->numInst >= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS) - RETURN_ERROR1("Program too long"); - } - } - return GL_TRUE; -} - - - -/** - * Parse/compile the 'str' returning the compiled 'program'. - * ctx->Program.ErrorPos will be -1 if successful. Otherwise, ErrorPos - * indicates the position of the error in 'str'. - */ -void -_mesa_parse_nv_fragment_program(struct gl_context *ctx, GLenum dstTarget, - const GLubyte *str, GLsizei len, - struct gl_fragment_program *program) -{ - struct parse_state parseState; - struct prog_instruction instBuffer[MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS]; - struct prog_instruction *newInst; - GLenum target; - GLubyte *programString; - - /* Make a null-terminated copy of the program string */ - programString = (GLubyte *) MALLOC(len + 1); - if (!programString) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - memcpy(programString, str, len); - programString[len] = 0; - - /* Get ready to parse */ - memset(&parseState, 0, sizeof(struct parse_state)); - parseState.ctx = ctx; - parseState.start = programString; - parseState.program = program; - parseState.numInst = 0; - parseState.curLine = programString; - parseState.parameters = _mesa_new_parameter_list(); - - /* Reset error state */ - _mesa_set_program_error(ctx, -1, NULL); - - /* check the program header */ - if (strncmp((const char *) programString, "!!FP1.0", 7) == 0) { - target = GL_FRAGMENT_PROGRAM_NV; - parseState.pos = programString + 7; - } - else if (strncmp((const char *) programString, "!!FCP1.0", 8) == 0) { - /* fragment / register combiner program - not supported */ - _mesa_set_program_error(ctx, 0, "Invalid fragment program header"); - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(bad header)"); - return; - } - else { - /* invalid header */ - _mesa_set_program_error(ctx, 0, "Invalid fragment program header"); - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(bad header)"); - return; - } - - /* make sure target and header match */ - if (target != dstTarget) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glLoadProgramNV(target mismatch 0x%x != 0x%x)", - target, dstTarget); - return; - } - - if (Parse_InstructionSequence(&parseState, instBuffer)) { - GLuint u; - /* successful parse! */ - - if (parseState.outputsWritten == 0) { - /* must write at least one output! */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "Invalid fragment program - no outputs written."); - return; - } - - /* copy the compiled instructions */ - assert(parseState.numInst <= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS); - newInst = _mesa_alloc_instructions(parseState.numInst); - if (!newInst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; /* out of memory */ - } - _mesa_copy_instructions(newInst, instBuffer, parseState.numInst); - - /* install the program */ - program->Base.Target = target; - if (program->Base.String) { - FREE(program->Base.String); - } - program->Base.String = programString; - program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; - if (program->Base.Instructions) { - free(program->Base.Instructions); - } - program->Base.Instructions = newInst; - program->Base.NumInstructions = parseState.numInst; - program->Base.InputsRead = parseState.inputsRead; - program->Base.OutputsWritten = parseState.outputsWritten; - for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) - program->Base.TexturesUsed[u] = parseState.texturesUsed[u]; - - /* save program parameters */ - program->Base.Parameters = parseState.parameters; - - /* allocate registers for declared program parameters */ -#if 00 - _mesa_assign_program_registers(&(program->SymbolTable)); -#endif - -#ifdef DEBUG_foo - printf("--- glLoadProgramNV(%d) result ---\n", program->Base.Id); - _mesa_fprint_program_opt(stdout, &program->Base, PROG_PRINT_NV, 0); - printf("----------------------------------\n"); -#endif - } - else { - /* Error! */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV"); - /* NOTE: _mesa_set_program_error would have been called already */ - } -} - - -const char * -_mesa_nv_fragment_input_register_name(GLuint i) -{ - ASSERT(i < MAX_NV_FRAGMENT_PROGRAM_INPUTS); - return InputRegisters[i]; -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.h b/reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.h deleted file mode 100644 index 088e7527d5b..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/nvfragparse.h +++ /dev/null @@ -1,47 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2002 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. - * - * Authors: - * Brian Paul - */ - - -#ifndef NVFRAGPARSE_H -#define NVFRAGPARSE_H - -#include "main/glheader.h" - -struct gl_context; -struct gl_fragment_program; - -extern void -_mesa_parse_nv_fragment_program(struct gl_context *ctx, GLenum target, - const GLubyte *str, GLsizei len, - struct gl_fragment_program *program); - - -extern const char * -_mesa_nv_fragment_input_register_name(GLuint i); - -#endif diff --git a/reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.c b/reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.c deleted file mode 100644 index 7b46bef91b0..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.c +++ /dev/null @@ -1,1460 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-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. - */ - -/** - * \file nvvertparse.c - * NVIDIA vertex program parser. - * \author Brian Paul - */ - -/* - * Regarding GL_NV_vertex_program, GL_NV_vertex_program1_1: - * - * Portions of this software may use or implement intellectual - * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims - * any and all warranties with respect to such intellectual property, - * including any use thereof or modifications thereto. - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/imports.h" -#include "main/nvprogram.h" -#include "nvvertparse.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_print.h" -#include "program.h" - - -/** - * Current parsing state. This structure is passed among the parsing - * functions and keeps track of the current parser position and various - * program attributes. - */ -struct parse_state { - struct gl_context *ctx; - const GLubyte *start; - const GLubyte *pos; - const GLubyte *curLine; - GLboolean isStateProgram; - GLboolean isPositionInvariant; - GLboolean isVersion1_1; - GLbitfield inputsRead; - GLbitfield outputsWritten; - GLboolean anyProgRegsWritten; - GLboolean indirectRegisterFiles; - GLuint numInst; /* number of instructions parsed */ -}; - - -/* - * Called whenever we find an error during parsing. - */ -static void -record_error(struct parse_state *parseState, const char *msg, int lineNo) -{ -#ifdef DEBUG - GLint line, column; - const GLubyte *lineStr; - lineStr = _mesa_find_line_column(parseState->start, - parseState->pos, &line, &column); - _mesa_debug(parseState->ctx, - "nvfragparse.c(%d): line %d, column %d:%s (%s)\n", - lineNo, line, column, (char *) lineStr, msg); - free((void *) lineStr); -#else - (void) lineNo; -#endif - - /* Check that no error was already recorded. Only record the first one. */ - if (parseState->ctx->Program.ErrorString[0] == 0) { - _mesa_set_program_error(parseState->ctx, - parseState->pos - parseState->start, - msg); - } -} - - -#define RETURN_ERROR \ -do { \ - record_error(parseState, "Unexpected end of input.", __LINE__); \ - return GL_FALSE; \ -} while(0) - -#define RETURN_ERROR1(msg) \ -do { \ - record_error(parseState, msg, __LINE__); \ - return GL_FALSE; \ -} while(0) - -#define RETURN_ERROR2(msg1, msg2) \ -do { \ - char err[1000]; \ - sprintf(err, "%s %s", msg1, msg2); \ - record_error(parseState, err, __LINE__); \ - return GL_FALSE; \ -} while(0) - - - - - -static GLboolean IsLetter(GLubyte b) -{ - return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z'); -} - - -static GLboolean IsDigit(GLubyte b) -{ - return b >= '0' && b <= '9'; -} - - -static GLboolean IsWhitespace(GLubyte b) -{ - return b == ' ' || b == '\t' || b == '\n' || b == '\r'; -} - - -/** - * Starting at 'str' find the next token. A token can be an integer, - * an identifier or punctuation symbol. - * \return <= 0 we found an error, else, return number of characters parsed. - */ -static GLint -GetToken(struct parse_state *parseState, GLubyte *token) -{ - const GLubyte *str = parseState->pos; - GLint i = 0, j = 0; - - token[0] = 0; - - /* skip whitespace and comments */ - while (str[i] && (IsWhitespace(str[i]) || str[i] == '#')) { - if (str[i] == '#') { - /* skip comment */ - while (str[i] && (str[i] != '\n' && str[i] != '\r')) { - i++; - } - if (str[i] == '\n' || str[i] == '\r') - parseState->curLine = str + i + 1; - } - else { - /* skip whitespace */ - if (str[i] == '\n' || str[i] == '\r') - parseState->curLine = str + i + 1; - i++; - } - } - - if (str[i] == 0) - return -i; - - /* try matching an integer */ - while (str[i] && IsDigit(str[i])) { - token[j++] = str[i++]; - } - if (j > 0 || !str[i]) { - token[j] = 0; - return i; - } - - /* try matching an identifier */ - if (IsLetter(str[i])) { - while (str[i] && (IsLetter(str[i]) || IsDigit(str[i]))) { - token[j++] = str[i++]; - } - token[j] = 0; - return i; - } - - /* punctuation character */ - if (str[i]) { - token[0] = str[i++]; - token[1] = 0; - return i; - } - - /* end of input */ - token[0] = 0; - return i; -} - - -/** - * Get next token from input stream and increment stream pointer past token. - */ -static GLboolean -Parse_Token(struct parse_state *parseState, GLubyte *token) -{ - GLint i; - i = GetToken(parseState, token); - if (i <= 0) { - parseState->pos += (-i); - return GL_FALSE; - } - parseState->pos += i; - return GL_TRUE; -} - - -/** - * Get next token from input stream but don't increment stream pointer. - */ -static GLboolean -Peek_Token(struct parse_state *parseState, GLubyte *token) -{ - GLint i, len; - i = GetToken(parseState, token); - if (i <= 0) { - parseState->pos += (-i); - return GL_FALSE; - } - len = (GLint) strlen((const char *) token); - parseState->pos += (i - len); - return GL_TRUE; -} - - -/** - * Try to match 'pattern' as the next token after any whitespace/comments. - * Advance the current parsing position only if we match the pattern. - * \return GL_TRUE if pattern is matched, GL_FALSE otherwise. - */ -static GLboolean -Parse_String(struct parse_state *parseState, const char *pattern) -{ - const GLubyte *m; - GLint i; - - /* skip whitespace and comments */ - while (IsWhitespace(*parseState->pos) || *parseState->pos == '#') { - if (*parseState->pos == '#') { - while (*parseState->pos && (*parseState->pos != '\n' && *parseState->pos != '\r')) { - parseState->pos += 1; - } - if (*parseState->pos == '\n' || *parseState->pos == '\r') - parseState->curLine = parseState->pos + 1; - } - else { - /* skip whitespace */ - if (*parseState->pos == '\n' || *parseState->pos == '\r') - parseState->curLine = parseState->pos + 1; - parseState->pos += 1; - } - } - - /* Try to match the pattern */ - m = parseState->pos; - for (i = 0; pattern[i]; i++) { - if (*m != (GLubyte) pattern[i]) - return GL_FALSE; - m += 1; - } - parseState->pos = m; - - return GL_TRUE; /* success */ -} - - -/**********************************************************************/ - -static const char *InputRegisters[MAX_NV_VERTEX_PROGRAM_INPUTS + 1] = { - "OPOS", "WGHT", "NRML", "COL0", "COL1", "FOGC", "6", "7", - "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", NULL -}; - -static const char *OutputRegisters[MAX_NV_VERTEX_PROGRAM_OUTPUTS + 1] = { - "HPOS", "COL0", "COL1", "FOGC", - "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", - "PSIZ", "BFC0", "BFC1", NULL -}; - - - -/** - * Parse a temporary register: Rnn - */ -static GLboolean -Parse_TempReg(struct parse_state *parseState, GLint *tempRegNum) -{ - GLubyte token[100]; - - /* Should be 'R##' */ - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - if (token[0] != 'R') - RETURN_ERROR1("Expected R##"); - - if (IsDigit(token[1])) { - GLint reg = atoi((char *) (token + 1)); - if (reg >= MAX_NV_VERTEX_PROGRAM_TEMPS) - RETURN_ERROR1("Bad temporary register name"); - *tempRegNum = reg; - } - else { - RETURN_ERROR1("Bad temporary register name"); - } - - return GL_TRUE; -} - - -/** - * Parse address register "A0.x" - */ -static GLboolean -Parse_AddrReg(struct parse_state *parseState) -{ - /* match 'A0' */ - if (!Parse_String(parseState, "A0")) - RETURN_ERROR; - - /* match '.' */ - if (!Parse_String(parseState, ".")) - RETURN_ERROR; - - /* match 'x' */ - if (!Parse_String(parseState, "x")) - RETURN_ERROR; - - return GL_TRUE; -} - - -/** - * Parse absolute program parameter register "c[##]" - */ -static GLboolean -Parse_AbsParamReg(struct parse_state *parseState, GLint *regNum) -{ - GLubyte token[100]; - - if (!Parse_String(parseState, "c")) - RETURN_ERROR; - - if (!Parse_String(parseState, "[")) - RETURN_ERROR; - - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (IsDigit(token[0])) { - /* a numbered program parameter register */ - GLint reg = atoi((char *) token); - if (reg >= MAX_NV_VERTEX_PROGRAM_PARAMS) - RETURN_ERROR1("Bad program parameter number"); - *regNum = reg; - } - else { - RETURN_ERROR; - } - - if (!Parse_String(parseState, "]")) - RETURN_ERROR; - - return GL_TRUE; -} - - -static GLboolean -Parse_ParamReg(struct parse_state *parseState, struct prog_src_register *srcReg) -{ - GLubyte token[100]; - - if (!Parse_String(parseState, "c")) - RETURN_ERROR; - - if (!Parse_String(parseState, "[")) - RETURN_ERROR; - - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - if (IsDigit(token[0])) { - /* a numbered program parameter register */ - GLint reg; - (void) Parse_Token(parseState, token); - reg = atoi((char *) token); - if (reg >= MAX_NV_VERTEX_PROGRAM_PARAMS) - RETURN_ERROR1("Bad program parameter number"); - srcReg->File = PROGRAM_ENV_PARAM; - srcReg->Index = reg; - } - else if (strcmp((const char *) token, "A0") == 0) { - /* address register "A0.x" */ - if (!Parse_AddrReg(parseState)) - RETURN_ERROR; - - srcReg->RelAddr = GL_TRUE; - srcReg->File = PROGRAM_ENV_PARAM; - parseState->indirectRegisterFiles |= (1 << srcReg->File); - /* Look for +/-N offset */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - if (token[0] == '-' || token[0] == '+') { - const GLubyte sign = token[0]; - (void) Parse_Token(parseState, token); /* consume +/- */ - - /* an integer should be next */ - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (IsDigit(token[0])) { - const GLint k = atoi((char *) token); - if (sign == '-') { - if (k > 64) - RETURN_ERROR1("Bad address offset"); - srcReg->Index = -k; - } - else { - if (k > 63) - RETURN_ERROR1("Bad address offset"); - srcReg->Index = k; - } - } - else { - RETURN_ERROR; - } - } - else { - /* probably got a ']', catch it below */ - } - } - else { - RETURN_ERROR; - } - - /* Match closing ']' */ - if (!Parse_String(parseState, "]")) - RETURN_ERROR; - - return GL_TRUE; -} - - -/** - * Parse v[#] or v[] - */ -static GLboolean -Parse_AttribReg(struct parse_state *parseState, GLint *tempRegNum) -{ - GLubyte token[100]; - GLint j; - - /* Match 'v' */ - if (!Parse_String(parseState, "v")) - RETURN_ERROR; - - /* Match '[' */ - if (!Parse_String(parseState, "[")) - RETURN_ERROR; - - /* match number or named register */ - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (parseState->isStateProgram && token[0] != '0') - RETURN_ERROR1("Only v[0] accessible in vertex state programs"); - - if (IsDigit(token[0])) { - GLint reg = atoi((char *) token); - if (reg >= MAX_NV_VERTEX_PROGRAM_INPUTS) - RETURN_ERROR1("Bad vertex attribute register name"); - *tempRegNum = reg; - } - else { - for (j = 0; InputRegisters[j]; j++) { - if (strcmp((const char *) token, InputRegisters[j]) == 0) { - *tempRegNum = j; - break; - } - } - if (!InputRegisters[j]) { - /* unknown input register label */ - RETURN_ERROR2("Bad register name", token); - } - } - - /* Match '[' */ - if (!Parse_String(parseState, "]")) - RETURN_ERROR; - - return GL_TRUE; -} - - -static GLboolean -Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum) -{ - GLubyte token[100]; - GLint start, j; - - /* Match 'o' */ - if (!Parse_String(parseState, "o")) - RETURN_ERROR; - - /* Match '[' */ - if (!Parse_String(parseState, "[")) - RETURN_ERROR; - - /* Get output reg name */ - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (parseState->isPositionInvariant) - start = 1; /* skip HPOS register name */ - else - start = 0; - - /* try to match an output register name */ - for (j = start; OutputRegisters[j]; j++) { - if (strcmp((const char *) token, OutputRegisters[j]) == 0) { - *outputRegNum = j; - break; - } - } - if (!OutputRegisters[j]) - RETURN_ERROR1("Unrecognized output register name"); - - /* Match ']' */ - if (!Parse_String(parseState, "]")) - RETURN_ERROR1("Expected ]"); - - return GL_TRUE; -} - - -static GLboolean -Parse_MaskedDstReg(struct parse_state *parseState, struct prog_dst_register *dstReg) -{ - GLubyte token[100]; - GLint idx; - - /* Dst reg can be R or o[n] */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - if (token[0] == 'R') { - /* a temporary register */ - dstReg->File = PROGRAM_TEMPORARY; - if (!Parse_TempReg(parseState, &idx)) - RETURN_ERROR; - dstReg->Index = idx; - } - else if (!parseState->isStateProgram && token[0] == 'o') { - /* an output register */ - dstReg->File = PROGRAM_OUTPUT; - if (!Parse_OutputReg(parseState, &idx)) - RETURN_ERROR; - dstReg->Index = idx; - } - else if (parseState->isStateProgram && token[0] == 'c' && - parseState->isStateProgram) { - /* absolute program parameter register */ - /* Only valid for vertex state programs */ - dstReg->File = PROGRAM_ENV_PARAM; - if (!Parse_AbsParamReg(parseState, &idx)) - RETURN_ERROR; - dstReg->Index = idx; - } - else { - RETURN_ERROR1("Bad destination register name"); - } - - /* Parse optional write mask */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - if (token[0] == '.') { - /* got a mask */ - GLint k = 0; - - if (!Parse_String(parseState, ".")) - RETURN_ERROR; - - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - dstReg->WriteMask = 0; - - if (token[k] == 'x') { - dstReg->WriteMask |= WRITEMASK_X; - k++; - } - if (token[k] == 'y') { - dstReg->WriteMask |= WRITEMASK_Y; - k++; - } - if (token[k] == 'z') { - dstReg->WriteMask |= WRITEMASK_Z; - k++; - } - if (token[k] == 'w') { - dstReg->WriteMask |= WRITEMASK_W; - k++; - } - if (k == 0) { - RETURN_ERROR1("Bad writemask character"); - } - return GL_TRUE; - } - else { - dstReg->WriteMask = WRITEMASK_XYZW; - return GL_TRUE; - } -} - - -static GLboolean -Parse_SwizzleSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg) -{ - GLubyte token[100]; - GLint idx; - - srcReg->RelAddr = GL_FALSE; - - /* check for '-' */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - if (token[0] == '-') { - (void) Parse_String(parseState, "-"); - srcReg->Negate = NEGATE_XYZW; - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - } - else { - srcReg->Negate = NEGATE_NONE; - } - - /* Src reg can be R, c[n], c[n +/- offset], or a named vertex attrib */ - if (token[0] == 'R') { - srcReg->File = PROGRAM_TEMPORARY; - if (!Parse_TempReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == 'c') { - if (!Parse_ParamReg(parseState, srcReg)) - RETURN_ERROR; - } - else if (token[0] == 'v') { - srcReg->File = PROGRAM_INPUT; - if (!Parse_AttribReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else { - RETURN_ERROR2("Bad source register name", token); - } - - /* init swizzle fields */ - srcReg->Swizzle = SWIZZLE_NOOP; - - /* Look for optional swizzle suffix */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - if (token[0] == '.') { - (void) Parse_String(parseState, "."); /* consume . */ - - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (token[1] == 0) { - /* single letter swizzle */ - if (token[0] == 'x') - srcReg->Swizzle = SWIZZLE_XXXX; - else if (token[0] == 'y') - srcReg->Swizzle = SWIZZLE_YYYY; - else if (token[0] == 'z') - srcReg->Swizzle = SWIZZLE_ZZZZ; - else if (token[0] == 'w') - srcReg->Swizzle = SWIZZLE_WWWW; - else - RETURN_ERROR1("Expected x, y, z, or w"); - } - else { - /* 2, 3 or 4-component swizzle */ - GLint k; - - srcReg->Swizzle = 0; - - for (k = 0; token[k] && k < 5; k++) { - if (token[k] == 'x') - srcReg->Swizzle |= 0 << (k*3); - else if (token[k] == 'y') - srcReg->Swizzle |= 1 << (k*3); - else if (token[k] == 'z') - srcReg->Swizzle |= 2 << (k*3); - else if (token[k] == 'w') - srcReg->Swizzle |= 3 << (k*3); - else - RETURN_ERROR; - } - if (k >= 5) - RETURN_ERROR; - } - } - - return GL_TRUE; -} - - -static GLboolean -Parse_ScalarSrcReg(struct parse_state *parseState, struct prog_src_register *srcReg) -{ - GLubyte token[100]; - GLint idx; - - srcReg->RelAddr = GL_FALSE; - - /* check for '-' */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - if (token[0] == '-') { - srcReg->Negate = NEGATE_XYZW; - (void) Parse_String(parseState, "-"); /* consume '-' */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - } - else { - srcReg->Negate = NEGATE_NONE; - } - - /* Src reg can be R, c[n], c[n +/- offset], or a named vertex attrib */ - if (token[0] == 'R') { - srcReg->File = PROGRAM_TEMPORARY; - if (!Parse_TempReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == 'c') { - if (!Parse_ParamReg(parseState, srcReg)) - RETURN_ERROR; - } - else if (token[0] == 'v') { - srcReg->File = PROGRAM_INPUT; - if (!Parse_AttribReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else { - RETURN_ERROR2("Bad source register name", token); - } - - /* Look for .[xyzw] suffix */ - if (!Parse_String(parseState, ".")) - RETURN_ERROR; - - if (!Parse_Token(parseState, token)) - RETURN_ERROR; - - if (token[0] == 'x' && token[1] == 0) { - srcReg->Swizzle = 0; - } - else if (token[0] == 'y' && token[1] == 0) { - srcReg->Swizzle = 1; - } - else if (token[0] == 'z' && token[1] == 0) { - srcReg->Swizzle = 2; - } - else if (token[0] == 'w' && token[1] == 0) { - srcReg->Swizzle = 3; - } - else { - RETURN_ERROR1("Bad scalar source suffix"); - } - - return GL_TRUE; -} - - -static GLint -Parse_UnaryOpInstruction(struct parse_state *parseState, - struct prog_instruction *inst, - enum prog_opcode opcode) -{ - if (opcode == OPCODE_ABS && !parseState->isVersion1_1) - RETURN_ERROR1("ABS illegal for vertex program 1.0"); - - inst->Opcode = opcode; - - /* dest reg */ - if (!Parse_MaskedDstReg(parseState, &inst->DstReg)) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* src arg */ - if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - - /* semicolon */ - if (!Parse_String(parseState, ";")) - RETURN_ERROR; - - return GL_TRUE; -} - - -static GLboolean -Parse_BiOpInstruction(struct parse_state *parseState, - struct prog_instruction *inst, - enum prog_opcode opcode) -{ - if (opcode == OPCODE_DPH && !parseState->isVersion1_1) - RETURN_ERROR1("DPH illegal for vertex program 1.0"); - if (opcode == OPCODE_SUB && !parseState->isVersion1_1) - RETURN_ERROR1("SUB illegal for vertex program 1.0"); - - inst->Opcode = opcode; - - /* dest reg */ - if (!Parse_MaskedDstReg(parseState, &inst->DstReg)) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* first src arg */ - if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* second src arg */ - if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[1])) - RETURN_ERROR; - - /* semicolon */ - if (!Parse_String(parseState, ";")) - RETURN_ERROR; - - /* make sure we don't reference more than one program parameter register */ - if (inst->SrcReg[0].File == PROGRAM_ENV_PARAM && - inst->SrcReg[1].File == PROGRAM_ENV_PARAM && - inst->SrcReg[0].Index != inst->SrcReg[1].Index) - RETURN_ERROR1("Can't reference two program parameter registers"); - - /* make sure we don't reference more than one vertex attribute register */ - if (inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[1].File == PROGRAM_INPUT && - inst->SrcReg[0].Index != inst->SrcReg[1].Index) - RETURN_ERROR1("Can't reference two vertex attribute registers"); - - return GL_TRUE; -} - - -static GLboolean -Parse_TriOpInstruction(struct parse_state *parseState, - struct prog_instruction *inst, - enum prog_opcode opcode) -{ - inst->Opcode = opcode; - - /* dest reg */ - if (!Parse_MaskedDstReg(parseState, &inst->DstReg)) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* first src arg */ - if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* second src arg */ - if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[1])) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* third src arg */ - if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[2])) - RETURN_ERROR; - - /* semicolon */ - if (!Parse_String(parseState, ";")) - RETURN_ERROR; - - /* make sure we don't reference more than one program parameter register */ - if ((inst->SrcReg[0].File == PROGRAM_ENV_PARAM && - inst->SrcReg[1].File == PROGRAM_ENV_PARAM && - inst->SrcReg[0].Index != inst->SrcReg[1].Index) || - (inst->SrcReg[0].File == PROGRAM_ENV_PARAM && - inst->SrcReg[2].File == PROGRAM_ENV_PARAM && - inst->SrcReg[0].Index != inst->SrcReg[2].Index) || - (inst->SrcReg[1].File == PROGRAM_ENV_PARAM && - inst->SrcReg[2].File == PROGRAM_ENV_PARAM && - inst->SrcReg[1].Index != inst->SrcReg[2].Index)) - RETURN_ERROR1("Can only reference one program register"); - - /* make sure we don't reference more than one vertex attribute register */ - if ((inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[1].File == PROGRAM_INPUT && - inst->SrcReg[0].Index != inst->SrcReg[1].Index) || - (inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[2].File == PROGRAM_INPUT && - inst->SrcReg[0].Index != inst->SrcReg[2].Index) || - (inst->SrcReg[1].File == PROGRAM_INPUT && - inst->SrcReg[2].File == PROGRAM_INPUT && - inst->SrcReg[1].Index != inst->SrcReg[2].Index)) - RETURN_ERROR1("Can only reference one input register"); - - return GL_TRUE; -} - - -static GLboolean -Parse_ScalarInstruction(struct parse_state *parseState, - struct prog_instruction *inst, - enum prog_opcode opcode) -{ - if (opcode == OPCODE_RCC && !parseState->isVersion1_1) - RETURN_ERROR1("RCC illegal for vertex program 1.0"); - - inst->Opcode = opcode; - - /* dest reg */ - if (!Parse_MaskedDstReg(parseState, &inst->DstReg)) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* first src arg */ - if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - - /* semicolon */ - if (!Parse_String(parseState, ";")) - RETURN_ERROR; - - return GL_TRUE; -} - - -static GLboolean -Parse_AddressInstruction(struct parse_state *parseState, struct prog_instruction *inst) -{ - inst->Opcode = OPCODE_ARL; - - /* Make ARB_vp backends happy */ - inst->DstReg.File = PROGRAM_ADDRESS; - inst->DstReg.WriteMask = WRITEMASK_X; - inst->DstReg.Index = 0; - - /* dest A0 reg */ - if (!Parse_AddrReg(parseState)) - RETURN_ERROR; - - /* comma */ - if (!Parse_String(parseState, ",")) - RETURN_ERROR; - - /* parse src reg */ - if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0])) - RETURN_ERROR; - - /* semicolon */ - if (!Parse_String(parseState, ";")) - RETURN_ERROR; - - return GL_TRUE; -} - - -static GLboolean -Parse_EndInstruction(struct parse_state *parseState, struct prog_instruction *inst) -{ - GLubyte token[100]; - - inst->Opcode = OPCODE_END; - - /* this should fail! */ - if (Parse_Token(parseState, token)) - RETURN_ERROR2("Unexpected token after END:", token); - else - return GL_TRUE; -} - - -/** - * The PRINT instruction is Mesa-specific and is meant as a debugging aid for - * the vertex program developer. - * The NV_vertex_program extension grammar is modified as follows: - * - * ::= - * | ... - * | - * - * ::= "PRINT" - * | "PRINT" "," - * | "PRINT" "," - */ -static GLboolean -Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction *inst) -{ - const GLubyte *str; - GLubyte *msg; - GLuint len; - GLubyte token[100]; - struct prog_src_register *srcReg = &inst->SrcReg[0]; - GLint idx; - - inst->Opcode = OPCODE_PRINT; - - /* The first argument is a literal string 'just like this' */ - if (!Parse_String(parseState, "'")) - RETURN_ERROR; - - str = parseState->pos; - for (len = 0; str[len] != '\''; len++) /* find closing quote */ - ; - parseState->pos += len + 1; - msg = (GLubyte*) malloc(len + 1); - - memcpy(msg, str, len); - msg[len] = 0; - inst->Data = msg; - - /* comma */ - if (Parse_String(parseState, ",")) { - - /* The second argument is a register name */ - if (!Peek_Token(parseState, token)) - RETURN_ERROR; - - srcReg->RelAddr = GL_FALSE; - srcReg->Negate = NEGATE_NONE; - srcReg->Swizzle = SWIZZLE_NOOP; - - /* Register can be R, c[n], c[n +/- offset], a named vertex attrib, - * or an o[n] output register. - */ - if (token[0] == 'R') { - srcReg->File = PROGRAM_TEMPORARY; - if (!Parse_TempReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == 'c') { - srcReg->File = PROGRAM_ENV_PARAM; - if (!Parse_ParamReg(parseState, srcReg)) - RETURN_ERROR; - } - else if (token[0] == 'v') { - srcReg->File = PROGRAM_INPUT; - if (!Parse_AttribReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else if (token[0] == 'o') { - srcReg->File = PROGRAM_OUTPUT; - if (!Parse_OutputReg(parseState, &idx)) - RETURN_ERROR; - srcReg->Index = idx; - } - else { - RETURN_ERROR2("Bad source register name", token); - } - } - else { - srcReg->File = PROGRAM_UNDEFINED; - } - - /* semicolon */ - if (!Parse_String(parseState, ";")) - RETURN_ERROR; - - return GL_TRUE; -} - - -static GLboolean -Parse_OptionSequence(struct parse_state *parseState, - struct prog_instruction program[]) -{ - (void) program; - while (1) { - if (!Parse_String(parseState, "OPTION")) - return GL_TRUE; /* ok, not an OPTION statement */ - if (Parse_String(parseState, "NV_position_invariant")) { - parseState->isPositionInvariant = GL_TRUE; - } - else { - RETURN_ERROR1("unexpected OPTION statement"); - } - if (!Parse_String(parseState, ";")) - return GL_FALSE; - } -} - - -static GLboolean -Parse_InstructionSequence(struct parse_state *parseState, - struct prog_instruction program[]) -{ - while (1) { - struct prog_instruction *inst = program + parseState->numInst; - - /* Initialize the instruction */ - _mesa_init_instructions(inst, 1); - - if (Parse_String(parseState, "MOV")) { - if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_MOV)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "LIT")) { - if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_LIT)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "ABS")) { - if (!Parse_UnaryOpInstruction(parseState, inst, OPCODE_ABS)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "MUL")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MUL)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "ADD")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_ADD)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "DP3")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP3)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "DP4")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DP4)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "DST")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DST)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "MIN")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MIN)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "MAX")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_MAX)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "SLT")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SLT)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "SGE")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SGE)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "DPH")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_DPH)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "SUB")) { - if (!Parse_BiOpInstruction(parseState, inst, OPCODE_SUB)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "MAD")) { - if (!Parse_TriOpInstruction(parseState, inst, OPCODE_MAD)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "RCP")) { - if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCP)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "RSQ")) { - if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RSQ)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "EXP")) { - if (!Parse_ScalarInstruction(parseState, inst, OPCODE_EXP)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "LOG")) { - if (!Parse_ScalarInstruction(parseState, inst, OPCODE_LOG)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "RCC")) { - if (!Parse_ScalarInstruction(parseState, inst, OPCODE_RCC)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "ARL")) { - if (!Parse_AddressInstruction(parseState, inst)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "PRINT")) { - if (!Parse_PrintInstruction(parseState, inst)) - RETURN_ERROR; - } - else if (Parse_String(parseState, "END")) { - if (!Parse_EndInstruction(parseState, inst)) - RETURN_ERROR; - else { - parseState->numInst++; - return GL_TRUE; /* all done */ - } - } - else { - /* bad instruction name */ - RETURN_ERROR1("Unexpected token"); - } - - /* examine input/output registers */ - if (inst->DstReg.File == PROGRAM_OUTPUT) - parseState->outputsWritten |= (1 << inst->DstReg.Index); - else if (inst->DstReg.File == PROGRAM_ENV_PARAM) - parseState->anyProgRegsWritten = GL_TRUE; - - if (inst->SrcReg[0].File == PROGRAM_INPUT) - parseState->inputsRead |= (1 << inst->SrcReg[0].Index); - if (inst->SrcReg[1].File == PROGRAM_INPUT) - parseState->inputsRead |= (1 << inst->SrcReg[1].Index); - if (inst->SrcReg[2].File == PROGRAM_INPUT) - parseState->inputsRead |= (1 << inst->SrcReg[2].Index); - - parseState->numInst++; - - if (parseState->numInst >= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS) - RETURN_ERROR1("Program too long"); - } - - RETURN_ERROR; -} - - -static GLboolean -Parse_Program(struct parse_state *parseState, - struct prog_instruction instBuffer[]) -{ - if (parseState->isVersion1_1) { - if (!Parse_OptionSequence(parseState, instBuffer)) { - return GL_FALSE; - } - } - return Parse_InstructionSequence(parseState, instBuffer); -} - - -/** - * Parse/compile the 'str' returning the compiled 'program'. - * ctx->Program.ErrorPos will be -1 if successful. Otherwise, ErrorPos - * indicates the position of the error in 'str'. - */ -void -_mesa_parse_nv_vertex_program(struct gl_context *ctx, GLenum dstTarget, - const GLubyte *str, GLsizei len, - struct gl_vertex_program *program) -{ - struct parse_state parseState; - struct prog_instruction instBuffer[MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS]; - struct prog_instruction *newInst; - GLenum target; - GLubyte *programString; - - /* Make a null-terminated copy of the program string */ - programString = (GLubyte *) MALLOC(len + 1); - if (!programString) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - return; - } - memcpy(programString, str, len); - programString[len] = 0; - - /* Get ready to parse */ - parseState.ctx = ctx; - parseState.start = programString; - parseState.isPositionInvariant = GL_FALSE; - parseState.isVersion1_1 = GL_FALSE; - parseState.numInst = 0; - parseState.inputsRead = 0; - parseState.outputsWritten = 0; - parseState.anyProgRegsWritten = GL_FALSE; - parseState.indirectRegisterFiles = 0x0; - - /* Reset error state */ - _mesa_set_program_error(ctx, -1, NULL); - - /* check the program header */ - if (strncmp((const char *) programString, "!!VP1.0", 7) == 0) { - target = GL_VERTEX_PROGRAM_NV; - parseState.pos = programString + 7; - parseState.isStateProgram = GL_FALSE; - } - else if (strncmp((const char *) programString, "!!VP1.1", 7) == 0) { - target = GL_VERTEX_PROGRAM_NV; - parseState.pos = programString + 7; - parseState.isStateProgram = GL_FALSE; - parseState.isVersion1_1 = GL_TRUE; - } - else if (strncmp((const char *) programString, "!!VSP1.0", 8) == 0) { - target = GL_VERTEX_STATE_PROGRAM_NV; - parseState.pos = programString + 8; - parseState.isStateProgram = GL_TRUE; - } - else { - /* invalid header */ - ctx->Program.ErrorPos = 0; - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(bad header)"); - return; - } - - /* make sure target and header match */ - if (target != dstTarget) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glLoadProgramNV(target mismatch)"); - return; - } - - - if (Parse_Program(&parseState, instBuffer)) { - gl_state_index state_tokens[STATE_LENGTH] = {0, 0, 0, 0, 0}; - int i; - - /* successful parse! */ - - if (parseState.isStateProgram) { - if (!parseState.anyProgRegsWritten) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glLoadProgramNV(c[#] not written)"); - return; - } - } - else { - if (!parseState.isPositionInvariant && - !(parseState.outputsWritten & (1 << VERT_RESULT_HPOS))) { - /* bit 1 = HPOS register */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glLoadProgramNV(HPOS not written)"); - return; - } - } - - /* copy the compiled instructions */ - assert(parseState.numInst <= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS); - newInst = _mesa_alloc_instructions(parseState.numInst); - if (!newInst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - free(programString); - return; /* out of memory */ - } - _mesa_copy_instructions(newInst, instBuffer, parseState.numInst); - - /* install the program */ - program->Base.Target = target; - if (program->Base.String) { - free(program->Base.String); - } - program->Base.String = programString; - program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; - if (program->Base.Instructions) { - free(program->Base.Instructions); - } - program->Base.Instructions = newInst; - program->Base.InputsRead = parseState.inputsRead; - if (parseState.isPositionInvariant) - program->Base.InputsRead |= VERT_BIT_POS; - program->Base.NumInstructions = parseState.numInst; - program->Base.OutputsWritten = parseState.outputsWritten; - program->IsPositionInvariant = parseState.isPositionInvariant; - program->IsNVProgram = GL_TRUE; - -#ifdef DEBUG_foo - printf("--- glLoadProgramNV result ---\n"); - _mesa_fprint_program_opt(stdout, &program->Base, PROG_PRINT_NV, 0); - printf("------------------------------\n"); -#endif - - if (program->Base.Parameters) - _mesa_free_parameter_list(program->Base.Parameters); - - program->Base.Parameters = _mesa_new_parameter_list (); - program->Base.NumParameters = 0; - - program->Base.IndirectRegisterFiles = parseState.indirectRegisterFiles; - - state_tokens[0] = STATE_VERTEX_PROGRAM; - state_tokens[1] = STATE_ENV; - /* Add refs to all of the potential params, in order. If we want to not - * upload everything, _mesa_layout_parameters is the answer. - */ - for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS; i++) { - GLint index; - state_tokens[2] = i; - index = _mesa_add_state_reference(program->Base.Parameters, - state_tokens); - assert(index == i); - (void)index; - } - program->Base.NumParameters = program->Base.Parameters->NumParameters; - - _mesa_setup_nv_temporary_count(&program->Base); - _mesa_emit_nv_temp_initialization(ctx, &program->Base); - } - else { - /* Error! */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV"); - /* NOTE: _mesa_set_program_error would have been called already */ - /* GL_NV_vertex_program isn't supposed to set the error string - * so we reset it here. - */ - _mesa_set_program_error(ctx, ctx->Program.ErrorPos, NULL); - } -} - - -const char * -_mesa_nv_vertex_input_register_name(GLuint i) -{ - ASSERT(i < MAX_NV_VERTEX_PROGRAM_INPUTS); - return InputRegisters[i]; -} - - -const char * -_mesa_nv_vertex_output_register_name(GLuint i) -{ - ASSERT(i < MAX_NV_VERTEX_PROGRAM_OUTPUTS); - return OutputRegisters[i]; -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.h b/reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.h deleted file mode 100644 index 7318e149416..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/nvvertparse.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 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. - * - * Authors: - * Brian Paul - */ - - -#ifndef NVVERTPARSE_H -#define NVVERTPARSE_H - -#include "main/glheader.h" - -struct gl_context; -struct gl_vertex_program; - -extern void -_mesa_parse_nv_vertex_program(struct gl_context *ctx, GLenum target, - const GLubyte *str, GLsizei len, - struct gl_vertex_program *program); - - -extern const char * -_mesa_nv_vertex_input_register_name(GLuint i); - -extern const char * -_mesa_nv_vertex_output_register_name(GLuint i); - -#endif diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_cache.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_cache.c deleted file mode 100644 index 2ccedb5d7d0..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_cache.c +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/imports.h" -#include "main/shaderobj.h" -#include "program/prog_cache.h" -#include "program/program.h" - - -struct cache_item -{ - GLuint hash; - void *key; - struct gl_program *program; - struct cache_item *next; -}; - -struct gl_program_cache -{ - struct cache_item **items; - struct cache_item *last; - GLuint size, n_items; -}; - - - -/** - * Compute hash index from state key. - */ -static GLuint -hash_key(const void *key, GLuint key_size) -{ - const GLuint *ikey = (const GLuint *) key; - GLuint hash = 0, i; - - assert(key_size >= 4); - - /* Make a slightly better attempt at a hash function: - */ - for (i = 0; i < key_size / sizeof(*ikey); i++) - { - hash += ikey[i]; - hash += (hash << 10); - hash ^= (hash >> 6); - } - - return hash; -} - - -/** - * Rebuild/expand the hash table to accomodate more entries - */ -static void -rehash(struct gl_program_cache *cache) -{ - struct cache_item **items; - struct cache_item *c, *next; - GLuint size, i; - - cache->last = NULL; - - size = cache->size * 3; - items = (struct cache_item**) malloc(size * sizeof(*items)); - memset(items, 0, size * sizeof(*items)); - - for (i = 0; i < cache->size; i++) - for (c = cache->items[i]; c; c = next) { - next = c->next; - c->next = items[c->hash % size]; - items[c->hash % size] = c; - } - - free(cache->items); - cache->items = items; - cache->size = size; -} - - -static void -clear_cache(struct gl_context *ctx, struct gl_program_cache *cache, - GLboolean shader) -{ - struct cache_item *c, *next; - GLuint i; - - cache->last = NULL; - - for (i = 0; i < cache->size; i++) { - for (c = cache->items[i]; c; c = next) { - next = c->next; - free(c->key); - if (shader) { - _mesa_reference_shader_program(ctx, - (struct gl_shader_program **)&c->program, - NULL); - } else { - _mesa_reference_program(ctx, &c->program, NULL); - } - free(c); - } - cache->items[i] = NULL; - } - - - cache->n_items = 0; -} - - - -struct gl_program_cache * -_mesa_new_program_cache(void) -{ - struct gl_program_cache *cache = CALLOC_STRUCT(gl_program_cache); - if (cache) { - cache->size = 17; - cache->items = (struct cache_item **) - calloc(1, cache->size * sizeof(struct cache_item)); - if (!cache->items) { - free(cache); - return NULL; - } - } - return cache; -} - - -void -_mesa_delete_program_cache(struct gl_context *ctx, struct gl_program_cache *cache) -{ - clear_cache(ctx, cache, GL_FALSE); - free(cache->items); - free(cache); -} - -void -_mesa_delete_shader_cache(struct gl_context *ctx, - struct gl_program_cache *cache) -{ - clear_cache(ctx, cache, GL_TRUE); - free(cache->items); - free(cache); -} - - -struct gl_program * -_mesa_search_program_cache(struct gl_program_cache *cache, - const void *key, GLuint keysize) -{ - if (cache->last && - memcmp(cache->last->key, key, keysize) == 0) { - return cache->last->program; - } - else { - const GLuint hash = hash_key(key, keysize); - struct cache_item *c; - - for (c = cache->items[hash % cache->size]; c; c = c->next) { - if (c->hash == hash && memcmp(c->key, key, keysize) == 0) { - cache->last = c; - return c->program; - } - } - - return NULL; - } -} - - -void -_mesa_program_cache_insert(struct gl_context *ctx, - struct gl_program_cache *cache, - const void *key, GLuint keysize, - struct gl_program *program) -{ - const GLuint hash = hash_key(key, keysize); - struct cache_item *c = CALLOC_STRUCT(cache_item); - - c->hash = hash; - - c->key = malloc(keysize); - memcpy(c->key, key, keysize); - - c->program = program; /* no refcount change */ - - if (cache->n_items > cache->size * 1.5) { - if (cache->size < 1000) - rehash(cache); - else - clear_cache(ctx, cache, GL_FALSE); - } - - cache->n_items++; - c->next = cache->items[hash % cache->size]; - cache->items[hash % cache->size] = c; -} - -void -_mesa_shader_cache_insert(struct gl_context *ctx, - struct gl_program_cache *cache, - const void *key, GLuint keysize, - struct gl_shader_program *program) -{ - const GLuint hash = hash_key(key, keysize); - struct cache_item *c = CALLOC_STRUCT(cache_item); - - c->hash = hash; - - c->key = malloc(keysize); - memcpy(c->key, key, keysize); - - c->program = (struct gl_program *)program; /* no refcount change */ - - if (cache->n_items > cache->size * 1.5) { - if (cache->size < 1000) - rehash(cache); - else - clear_cache(ctx, cache, GL_TRUE); - } - - cache->n_items++; - c->next = cache->items[hash % cache->size]; - cache->items[hash % cache->size] = c; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_cache.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_cache.h deleted file mode 100644 index 5d46bfc5cc9..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_cache.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * 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, sub license, 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 (including the - * next paragraph) 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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 PROG_CACHE_H -#define PROG_CACHE_H - - -#include "main/glheader.h" - -struct gl_context; - -/** Opaque type */ -struct gl_program_cache; - - -extern struct gl_program_cache * -_mesa_new_program_cache(void); - -extern void -_mesa_delete_program_cache(struct gl_context *ctx, struct gl_program_cache *pc); - -extern void -_mesa_delete_shader_cache(struct gl_context *ctx, - struct gl_program_cache *cache); - -extern struct gl_program * -_mesa_search_program_cache(struct gl_program_cache *cache, - const void *key, GLuint keysize); - -extern void -_mesa_program_cache_insert(struct gl_context *ctx, - struct gl_program_cache *cache, - const void *key, GLuint keysize, - struct gl_program *program); - -void -_mesa_shader_cache_insert(struct gl_context *ctx, - struct gl_program_cache *cache, - const void *key, GLuint keysize, - struct gl_shader_program *program); - - -#endif /* PROG_CACHE_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_execute.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_execute.c deleted file mode 100644 index 848c2fec105..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_execute.c +++ /dev/null @@ -1,1903 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 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. - */ - -/** - * \file prog_execute.c - * Software interpreter for vertex/fragment programs. - * \author Brian Paul - */ - -/* - * NOTE: we do everything in single-precision floating point; we don't - * currently observe the single/half/fixed-precision qualifiers. - * - */ - - -#include "main/glheader.h" -#include "main/colormac.h" -#include "main/macros.h" -#include "prog_execute.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_print.h" -#include "prog_noise.h" - - -/* debug predicate */ -#define DEBUG_PROG 0 - - -/** - * Set x to positive or negative infinity. - */ -#if defined(USE_IEEE) || defined(_WIN32) -#define SET_POS_INFINITY(x) \ - do { \ - fi_type fi; \ - fi.i = 0x7F800000; \ - x = fi.f; \ - } while (0) -#define SET_NEG_INFINITY(x) \ - do { \ - fi_type fi; \ - fi.i = 0xFF800000; \ - x = fi.f; \ - } while (0) -#elif defined(VMS) -#define SET_POS_INFINITY(x) x = __MAXFLOAT -#define SET_NEG_INFINITY(x) x = -__MAXFLOAT -#else -#define SET_POS_INFINITY(x) x = (GLfloat) HUGE_VAL -#define SET_NEG_INFINITY(x) x = (GLfloat) -HUGE_VAL -#endif - -#define SET_FLOAT_BITS(x, bits) ((fi_type *) (void *) &(x))->i = bits - - -static const GLfloat ZeroVec[4] = { 0.0F, 0.0F, 0.0F, 0.0F }; - - - -/** - * Return TRUE for +0 and other positive values, FALSE otherwise. - * Used for RCC opcode. - */ -static inline GLboolean -positive(float x) -{ - fi_type fi; - fi.f = x; - if (fi.i & 0x80000000) - return GL_FALSE; - return GL_TRUE; -} - - - -/** - * Return a pointer to the 4-element float vector specified by the given - * source register. - */ -static inline const GLfloat * -get_src_register_pointer(const struct prog_src_register *source, - const struct gl_program_machine *machine) -{ - const struct gl_program *prog = machine->CurProgram; - GLint reg = source->Index; - - if (source->RelAddr) { - /* add address register value to src index/offset */ - reg += machine->AddressReg[0][0]; - if (reg < 0) { - return ZeroVec; - } - } - - switch (source->File) { - case PROGRAM_TEMPORARY: - if (reg >= MAX_PROGRAM_TEMPS) - return ZeroVec; - return machine->Temporaries[reg]; - - case PROGRAM_INPUT: - if (prog->Target == GL_VERTEX_PROGRAM_ARB) { - if (reg >= VERT_ATTRIB_MAX) - return ZeroVec; - return machine->VertAttribs[reg]; - } - else { - if (reg >= FRAG_ATTRIB_MAX) - return ZeroVec; - return machine->Attribs[reg][machine->CurElement]; - } - - case PROGRAM_OUTPUT: - if (reg >= MAX_PROGRAM_OUTPUTS) - return ZeroVec; - return machine->Outputs[reg]; - - case PROGRAM_LOCAL_PARAM: - if (reg >= MAX_PROGRAM_LOCAL_PARAMS) - return ZeroVec; - return machine->CurProgram->LocalParams[reg]; - - case PROGRAM_ENV_PARAM: - if (reg >= MAX_PROGRAM_ENV_PARAMS) - return ZeroVec; - return machine->EnvParams[reg]; - - case PROGRAM_STATE_VAR: - /* Fallthrough */ - case PROGRAM_CONSTANT: - /* Fallthrough */ - case PROGRAM_UNIFORM: - /* Fallthrough */ - case PROGRAM_NAMED_PARAM: - if (reg >= (GLint) prog->Parameters->NumParameters) - return ZeroVec; - return (GLfloat *) prog->Parameters->ParameterValues[reg]; - - case PROGRAM_SYSTEM_VALUE: - assert(reg < Elements(machine->SystemValues)); - return machine->SystemValues[reg]; - - default: - _mesa_problem(NULL, - "Invalid src register file %d in get_src_register_pointer()", - source->File); - return NULL; - } -} - - -/** - * Return a pointer to the 4-element float vector specified by the given - * destination register. - */ -static inline GLfloat * -get_dst_register_pointer(const struct prog_dst_register *dest, - struct gl_program_machine *machine) -{ - static GLfloat dummyReg[4]; - GLint reg = dest->Index; - - if (dest->RelAddr) { - /* add address register value to src index/offset */ - reg += machine->AddressReg[0][0]; - if (reg < 0) { - return dummyReg; - } - } - - switch (dest->File) { - case PROGRAM_TEMPORARY: - if (reg >= MAX_PROGRAM_TEMPS) - return dummyReg; - return machine->Temporaries[reg]; - - case PROGRAM_OUTPUT: - if (reg >= MAX_PROGRAM_OUTPUTS) - return dummyReg; - return machine->Outputs[reg]; - - case PROGRAM_WRITE_ONLY: - return dummyReg; - - default: - _mesa_problem(NULL, - "Invalid dest register file %d in get_dst_register_pointer()", - dest->File); - return NULL; - } -} - - - -/** - * Fetch a 4-element float vector from the given source register. - * Apply swizzling and negating as needed. - */ -static void -fetch_vector4(const struct prog_src_register *source, - const struct gl_program_machine *machine, GLfloat result[4]) -{ - const GLfloat *src = get_src_register_pointer(source, machine); - ASSERT(src); - - if (source->Swizzle == SWIZZLE_NOOP) { - /* no swizzling */ - COPY_4V(result, src); - } - else { - ASSERT(GET_SWZ(source->Swizzle, 0) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 1) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 2) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 3) <= 3); - result[0] = src[GET_SWZ(source->Swizzle, 0)]; - result[1] = src[GET_SWZ(source->Swizzle, 1)]; - result[2] = src[GET_SWZ(source->Swizzle, 2)]; - result[3] = src[GET_SWZ(source->Swizzle, 3)]; - } - - if (source->Abs) { - result[0] = FABSF(result[0]); - result[1] = FABSF(result[1]); - result[2] = FABSF(result[2]); - result[3] = FABSF(result[3]); - } - if (source->Negate) { - ASSERT(source->Negate == NEGATE_XYZW); - result[0] = -result[0]; - result[1] = -result[1]; - result[2] = -result[2]; - result[3] = -result[3]; - } - -#ifdef NAN_CHECK - assert(!IS_INF_OR_NAN(result[0])); - assert(!IS_INF_OR_NAN(result[0])); - assert(!IS_INF_OR_NAN(result[0])); - assert(!IS_INF_OR_NAN(result[0])); -#endif -} - - -/** - * Fetch a 4-element uint vector from the given source register. - * Apply swizzling but not negation/abs. - */ -static void -fetch_vector4ui(const struct prog_src_register *source, - const struct gl_program_machine *machine, GLuint result[4]) -{ - const GLuint *src = (GLuint *) get_src_register_pointer(source, machine); - ASSERT(src); - - if (source->Swizzle == SWIZZLE_NOOP) { - /* no swizzling */ - COPY_4V(result, src); - } - else { - ASSERT(GET_SWZ(source->Swizzle, 0) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 1) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 2) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 3) <= 3); - result[0] = src[GET_SWZ(source->Swizzle, 0)]; - result[1] = src[GET_SWZ(source->Swizzle, 1)]; - result[2] = src[GET_SWZ(source->Swizzle, 2)]; - result[3] = src[GET_SWZ(source->Swizzle, 3)]; - } - - /* Note: no Negate or Abs here */ -} - - - -/** - * Fetch the derivative with respect to X or Y for the given register. - * XXX this currently only works for fragment program input attribs. - */ -static void -fetch_vector4_deriv(struct gl_context * ctx, - const struct prog_src_register *source, - const struct gl_program_machine *machine, - char xOrY, GLfloat result[4]) -{ - if (source->File == PROGRAM_INPUT && - source->Index < (GLint) machine->NumDeriv) { - const GLint col = machine->CurElement; - const GLfloat w = machine->Attribs[FRAG_ATTRIB_WPOS][col][3]; - const GLfloat invQ = 1.0f / w; - GLfloat deriv[4]; - - if (xOrY == 'X') { - deriv[0] = machine->DerivX[source->Index][0] * invQ; - deriv[1] = machine->DerivX[source->Index][1] * invQ; - deriv[2] = machine->DerivX[source->Index][2] * invQ; - deriv[3] = machine->DerivX[source->Index][3] * invQ; - } - else { - deriv[0] = machine->DerivY[source->Index][0] * invQ; - deriv[1] = machine->DerivY[source->Index][1] * invQ; - deriv[2] = machine->DerivY[source->Index][2] * invQ; - deriv[3] = machine->DerivY[source->Index][3] * invQ; - } - - result[0] = deriv[GET_SWZ(source->Swizzle, 0)]; - result[1] = deriv[GET_SWZ(source->Swizzle, 1)]; - result[2] = deriv[GET_SWZ(source->Swizzle, 2)]; - result[3] = deriv[GET_SWZ(source->Swizzle, 3)]; - - if (source->Abs) { - result[0] = FABSF(result[0]); - result[1] = FABSF(result[1]); - result[2] = FABSF(result[2]); - result[3] = FABSF(result[3]); - } - if (source->Negate) { - ASSERT(source->Negate == NEGATE_XYZW); - result[0] = -result[0]; - result[1] = -result[1]; - result[2] = -result[2]; - result[3] = -result[3]; - } - } - else { - ASSIGN_4V(result, 0.0, 0.0, 0.0, 0.0); - } -} - - -/** - * As above, but only return result[0] element. - */ -static void -fetch_vector1(const struct prog_src_register *source, - const struct gl_program_machine *machine, GLfloat result[4]) -{ - const GLfloat *src = get_src_register_pointer(source, machine); - ASSERT(src); - - result[0] = src[GET_SWZ(source->Swizzle, 0)]; - - if (source->Abs) { - result[0] = FABSF(result[0]); - } - if (source->Negate) { - result[0] = -result[0]; - } -} - - -static GLuint -fetch_vector1ui(const struct prog_src_register *source, - const struct gl_program_machine *machine) -{ - const GLuint *src = (GLuint *) get_src_register_pointer(source, machine); - return src[GET_SWZ(source->Swizzle, 0)]; -} - - -/** - * Fetch texel from texture. Use partial derivatives when possible. - */ -static inline void -fetch_texel(struct gl_context *ctx, - const struct gl_program_machine *machine, - const struct prog_instruction *inst, - const GLfloat texcoord[4], GLfloat lodBias, - GLfloat color[4]) -{ - const GLuint unit = machine->Samplers[inst->TexSrcUnit]; - - /* Note: we only have the right derivatives for fragment input attribs. - */ - if (machine->NumDeriv > 0 && - inst->SrcReg[0].File == PROGRAM_INPUT && - inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit) { - /* simple texture fetch for which we should have derivatives */ - GLuint attr = inst->SrcReg[0].Index; - machine->FetchTexelDeriv(ctx, texcoord, - machine->DerivX[attr], - machine->DerivY[attr], - lodBias, unit, color); - } - else { - machine->FetchTexelLod(ctx, texcoord, lodBias, unit, color); - } -} - - -/** - * Test value against zero and return GT, LT, EQ or UN if NaN. - */ -static inline GLuint -generate_cc(float value) -{ - if (value != value) - return COND_UN; /* NaN */ - if (value > 0.0F) - return COND_GT; - if (value < 0.0F) - return COND_LT; - return COND_EQ; -} - - -/** - * Test if the ccMaskRule is satisfied by the given condition code. - * Used to mask destination writes according to the current condition code. - */ -static inline GLboolean -test_cc(GLuint condCode, GLuint ccMaskRule) -{ - switch (ccMaskRule) { - case COND_EQ: return (condCode == COND_EQ); - case COND_NE: return (condCode != COND_EQ); - case COND_LT: return (condCode == COND_LT); - case COND_GE: return (condCode == COND_GT || condCode == COND_EQ); - case COND_LE: return (condCode == COND_LT || condCode == COND_EQ); - case COND_GT: return (condCode == COND_GT); - case COND_TR: return GL_TRUE; - case COND_FL: return GL_FALSE; - default: return GL_TRUE; - } -} - - -/** - * Evaluate the 4 condition codes against a predicate and return GL_TRUE - * or GL_FALSE to indicate result. - */ -static inline GLboolean -eval_condition(const struct gl_program_machine *machine, - const struct prog_instruction *inst) -{ - const GLuint swizzle = inst->DstReg.CondSwizzle; - const GLuint condMask = inst->DstReg.CondMask; - if (test_cc(machine->CondCodes[GET_SWZ(swizzle, 0)], condMask) || - test_cc(machine->CondCodes[GET_SWZ(swizzle, 1)], condMask) || - test_cc(machine->CondCodes[GET_SWZ(swizzle, 2)], condMask) || - test_cc(machine->CondCodes[GET_SWZ(swizzle, 3)], condMask)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/** - * Store 4 floats into a register. Observe the instructions saturate and - * set-condition-code flags. - */ -static void -store_vector4(const struct prog_instruction *inst, - struct gl_program_machine *machine, const GLfloat value[4]) -{ - const struct prog_dst_register *dstReg = &(inst->DstReg); - const GLboolean clamp = inst->SaturateMode == SATURATE_ZERO_ONE; - GLuint writeMask = dstReg->WriteMask; - GLfloat clampedValue[4]; - GLfloat *dst = get_dst_register_pointer(dstReg, machine); - -#if 0 - if (value[0] > 1.0e10 || - IS_INF_OR_NAN(value[0]) || - IS_INF_OR_NAN(value[1]) || - IS_INF_OR_NAN(value[2]) || IS_INF_OR_NAN(value[3])) - printf("store %g %g %g %g\n", value[0], value[1], value[2], value[3]); -#endif - - if (clamp) { - clampedValue[0] = CLAMP(value[0], 0.0F, 1.0F); - clampedValue[1] = CLAMP(value[1], 0.0F, 1.0F); - clampedValue[2] = CLAMP(value[2], 0.0F, 1.0F); - clampedValue[3] = CLAMP(value[3], 0.0F, 1.0F); - value = clampedValue; - } - - if (dstReg->CondMask != COND_TR) { - /* condition codes may turn off some writes */ - if (writeMask & WRITEMASK_X) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 0)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_X; - } - if (writeMask & WRITEMASK_Y) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 1)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_Y; - } - if (writeMask & WRITEMASK_Z) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 2)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_Z; - } - if (writeMask & WRITEMASK_W) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 3)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_W; - } - } - -#ifdef NAN_CHECK - assert(!IS_INF_OR_NAN(value[0])); - assert(!IS_INF_OR_NAN(value[0])); - assert(!IS_INF_OR_NAN(value[0])); - assert(!IS_INF_OR_NAN(value[0])); -#endif - - if (writeMask & WRITEMASK_X) - dst[0] = value[0]; - if (writeMask & WRITEMASK_Y) - dst[1] = value[1]; - if (writeMask & WRITEMASK_Z) - dst[2] = value[2]; - if (writeMask & WRITEMASK_W) - dst[3] = value[3]; - - if (inst->CondUpdate) { - if (writeMask & WRITEMASK_X) - machine->CondCodes[0] = generate_cc(value[0]); - if (writeMask & WRITEMASK_Y) - machine->CondCodes[1] = generate_cc(value[1]); - if (writeMask & WRITEMASK_Z) - machine->CondCodes[2] = generate_cc(value[2]); - if (writeMask & WRITEMASK_W) - machine->CondCodes[3] = generate_cc(value[3]); -#if DEBUG_PROG - printf("CondCodes=(%s,%s,%s,%s) for:\n", - _mesa_condcode_string(machine->CondCodes[0]), - _mesa_condcode_string(machine->CondCodes[1]), - _mesa_condcode_string(machine->CondCodes[2]), - _mesa_condcode_string(machine->CondCodes[3])); -#endif - } -} - - -/** - * Store 4 uints into a register. Observe the set-condition-code flags. - */ -static void -store_vector4ui(const struct prog_instruction *inst, - struct gl_program_machine *machine, const GLuint value[4]) -{ - const struct prog_dst_register *dstReg = &(inst->DstReg); - GLuint writeMask = dstReg->WriteMask; - GLuint *dst = (GLuint *) get_dst_register_pointer(dstReg, machine); - - if (dstReg->CondMask != COND_TR) { - /* condition codes may turn off some writes */ - if (writeMask & WRITEMASK_X) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 0)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_X; - } - if (writeMask & WRITEMASK_Y) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 1)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_Y; - } - if (writeMask & WRITEMASK_Z) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 2)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_Z; - } - if (writeMask & WRITEMASK_W) { - if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 3)], - dstReg->CondMask)) - writeMask &= ~WRITEMASK_W; - } - } - - if (writeMask & WRITEMASK_X) - dst[0] = value[0]; - if (writeMask & WRITEMASK_Y) - dst[1] = value[1]; - if (writeMask & WRITEMASK_Z) - dst[2] = value[2]; - if (writeMask & WRITEMASK_W) - dst[3] = value[3]; - - if (inst->CondUpdate) { - if (writeMask & WRITEMASK_X) - machine->CondCodes[0] = generate_cc((float)value[0]); - if (writeMask & WRITEMASK_Y) - machine->CondCodes[1] = generate_cc((float)value[1]); - if (writeMask & WRITEMASK_Z) - machine->CondCodes[2] = generate_cc((float)value[2]); - if (writeMask & WRITEMASK_W) - machine->CondCodes[3] = generate_cc((float)value[3]); -#if DEBUG_PROG - printf("CondCodes=(%s,%s,%s,%s) for:\n", - _mesa_condcode_string(machine->CondCodes[0]), - _mesa_condcode_string(machine->CondCodes[1]), - _mesa_condcode_string(machine->CondCodes[2]), - _mesa_condcode_string(machine->CondCodes[3])); -#endif - } -} - - - -/** - * Execute the given vertex/fragment program. - * - * \param ctx rendering context - * \param program the program to execute - * \param machine machine state (must be initialized) - * \return GL_TRUE if program completed or GL_FALSE if program executed KIL. - */ -GLboolean -_mesa_execute_program(struct gl_context * ctx, - const struct gl_program *program, - struct gl_program_machine *machine) -{ - const GLuint numInst = program->NumInstructions; - const GLuint maxExec = 65536; - GLuint pc, numExec = 0; - - machine->CurProgram = program; - - if (DEBUG_PROG) { - printf("execute program %u --------------------\n", program->Id); - } - - if (program->Target == GL_VERTEX_PROGRAM_ARB) { - machine->EnvParams = ctx->VertexProgram.Parameters; - } - else { - machine->EnvParams = ctx->FragmentProgram.Parameters; - } - - for (pc = 0; pc < numInst; pc++) { - const struct prog_instruction *inst = program->Instructions + pc; - - if (DEBUG_PROG) { - _mesa_print_instruction(inst); - } - - switch (inst->Opcode) { - case OPCODE_ABS: - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = FABSF(a[0]); - result[1] = FABSF(a[1]); - result[2] = FABSF(a[2]); - result[3] = FABSF(a[3]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_ADD: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = a[0] + b[0]; - result[1] = a[1] + b[1]; - result[2] = a[2] + b[2]; - result[3] = a[3] + b[3]; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("ADD (%g %g %g %g) = (%g %g %g %g) + (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_AND: /* bitwise AND */ - { - GLuint a[4], b[4], result[4]; - fetch_vector4ui(&inst->SrcReg[0], machine, a); - fetch_vector4ui(&inst->SrcReg[1], machine, b); - result[0] = a[0] & b[0]; - result[1] = a[1] & b[1]; - result[2] = a[2] & b[2]; - result[3] = a[3] & b[3]; - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_ARL: - { - GLfloat t[4]; - fetch_vector4(&inst->SrcReg[0], machine, t); - machine->AddressReg[0][0] = IFLOOR(t[0]); - if (DEBUG_PROG) { - printf("ARL %d\n", machine->AddressReg[0][0]); - } - } - break; - case OPCODE_BGNLOOP: - /* no-op */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode - == OPCODE_ENDLOOP); - break; - case OPCODE_ENDLOOP: - /* subtract 1 here since pc is incremented by for(pc) loop */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode - == OPCODE_BGNLOOP); - pc = inst->BranchTarget - 1; /* go to matching BNGLOOP */ - break; - case OPCODE_BGNSUB: /* begin subroutine */ - break; - case OPCODE_ENDSUB: /* end subroutine */ - break; - case OPCODE_BRA: /* branch (conditional) */ - if (eval_condition(machine, inst)) { - /* take branch */ - /* Subtract 1 here since we'll do pc++ below */ - pc = inst->BranchTarget - 1; - } - break; - case OPCODE_BRK: /* break out of loop (conditional) */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode - == OPCODE_ENDLOOP); - if (eval_condition(machine, inst)) { - /* break out of loop */ - /* pc++ at end of for-loop will put us after the ENDLOOP inst */ - pc = inst->BranchTarget; - } - break; - case OPCODE_CONT: /* continue loop (conditional) */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode - == OPCODE_ENDLOOP); - if (eval_condition(machine, inst)) { - /* continue at ENDLOOP */ - /* Subtract 1 here since we'll do pc++ at end of for-loop */ - pc = inst->BranchTarget - 1; - } - break; - case OPCODE_CAL: /* Call subroutine (conditional) */ - if (eval_condition(machine, inst)) { - /* call the subroutine */ - if (machine->StackDepth >= MAX_PROGRAM_CALL_DEPTH) { - return GL_TRUE; /* Per GL_NV_vertex_program2 spec */ - } - machine->CallStack[machine->StackDepth++] = pc + 1; /* next inst */ - /* Subtract 1 here since we'll do pc++ at end of for-loop */ - pc = inst->BranchTarget - 1; - } - break; - case OPCODE_CMP: - { - GLfloat a[4], b[4], c[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - fetch_vector4(&inst->SrcReg[2], machine, c); - result[0] = a[0] < 0.0F ? b[0] : c[0]; - result[1] = a[1] < 0.0F ? b[1] : c[1]; - result[2] = a[2] < 0.0F ? b[2] : c[2]; - result[3] = a[3] < 0.0F ? b[3] : c[3]; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("CMP (%g %g %g %g) = (%g %g %g %g) < 0 ? (%g %g %g %g) : (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3], - c[0], c[1], c[2], c[3]); - } - } - break; - case OPCODE_COS: - { - GLfloat a[4], result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = result[1] = result[2] = result[3] - = (GLfloat) cos(a[0]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_DDX: /* Partial derivative with respect to X */ - { - GLfloat result[4]; - fetch_vector4_deriv(ctx, &inst->SrcReg[0], machine, - 'X', result); - store_vector4(inst, machine, result); - } - break; - case OPCODE_DDY: /* Partial derivative with respect to Y */ - { - GLfloat result[4]; - fetch_vector4_deriv(ctx, &inst->SrcReg[0], machine, - 'Y', result); - store_vector4(inst, machine, result); - } - break; - case OPCODE_DP2: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = result[1] = result[2] = result[3] = DOT2(a, b); - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("DP2 %g = (%g %g) . (%g %g)\n", - result[0], a[0], a[1], b[0], b[1]); - } - } - break; - case OPCODE_DP2A: - { - GLfloat a[4], b[4], c, result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - fetch_vector1(&inst->SrcReg[1], machine, &c); - result[0] = result[1] = result[2] = result[3] = DOT2(a, b) + c; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("DP2A %g = (%g %g) . (%g %g) + %g\n", - result[0], a[0], a[1], b[0], b[1], c); - } - } - break; - case OPCODE_DP3: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = result[1] = result[2] = result[3] = DOT3(a, b); - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("DP3 %g = (%g %g %g) . (%g %g %g)\n", - result[0], a[0], a[1], a[2], b[0], b[1], b[2]); - } - } - break; - case OPCODE_DP4: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = result[1] = result[2] = result[3] = DOT4(a, b); - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("DP4 %g = (%g, %g %g %g) . (%g, %g %g %g)\n", - result[0], a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_DPH: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = result[1] = result[2] = result[3] = DOT3(a, b) + b[3]; - store_vector4(inst, machine, result); - } - break; - case OPCODE_DST: /* Distance vector */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = 1.0F; - result[1] = a[1] * b[1]; - result[2] = a[2]; - result[3] = b[3]; - store_vector4(inst, machine, result); - } - break; - case OPCODE_EXP: - { - GLfloat t[4], q[4], floor_t0; - fetch_vector1(&inst->SrcReg[0], machine, t); - floor_t0 = FLOORF(t[0]); - if (floor_t0 > FLT_MAX_EXP) { - SET_POS_INFINITY(q[0]); - SET_POS_INFINITY(q[2]); - } - else if (floor_t0 < FLT_MIN_EXP) { - q[0] = 0.0F; - q[2] = 0.0F; - } - else { - q[0] = LDEXPF(1.0, (int) floor_t0); - /* Note: GL_NV_vertex_program expects - * result.z = result.x * APPX(result.y) - * We do what the ARB extension says. - */ - q[2] = (GLfloat) pow(2.0, t[0]); - } - q[1] = t[0] - floor_t0; - q[3] = 1.0F; - store_vector4( inst, machine, q ); - } - break; - case OPCODE_EX2: /* Exponential base 2 */ - { - GLfloat a[4], result[4], val; - fetch_vector1(&inst->SrcReg[0], machine, a); - val = (GLfloat) pow(2.0, a[0]); - /* - if (IS_INF_OR_NAN(val)) - val = 1.0e10; - */ - result[0] = result[1] = result[2] = result[3] = val; - store_vector4(inst, machine, result); - } - break; - case OPCODE_FLR: - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = FLOORF(a[0]); - result[1] = FLOORF(a[1]); - result[2] = FLOORF(a[2]); - result[3] = FLOORF(a[3]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_FRC: - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = a[0] - FLOORF(a[0]); - result[1] = a[1] - FLOORF(a[1]); - result[2] = a[2] - FLOORF(a[2]); - result[3] = a[3] - FLOORF(a[3]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_IF: - { - GLboolean cond; - ASSERT(program->Instructions[inst->BranchTarget].Opcode - == OPCODE_ELSE || - program->Instructions[inst->BranchTarget].Opcode - == OPCODE_ENDIF); - /* eval condition */ - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - GLfloat a[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - cond = (a[0] != 0.0); - } - else { - cond = eval_condition(machine, inst); - } - if (DEBUG_PROG) { - printf("IF: %d\n", cond); - } - /* do if/else */ - if (cond) { - /* do if-clause (just continue execution) */ - } - else { - /* go to the instruction after ELSE or ENDIF */ - assert(inst->BranchTarget >= 0); - pc = inst->BranchTarget; - } - } - break; - case OPCODE_ELSE: - /* goto ENDIF */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode - == OPCODE_ENDIF); - assert(inst->BranchTarget >= 0); - pc = inst->BranchTarget; - break; - case OPCODE_ENDIF: - /* nothing */ - break; - case OPCODE_KIL_NV: /* NV_f_p only (conditional) */ - if (eval_condition(machine, inst)) { - return GL_FALSE; - } - break; - case OPCODE_KIL: /* ARB_f_p only */ - { - GLfloat a[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - if (DEBUG_PROG) { - printf("KIL if (%g %g %g %g) <= 0.0\n", - a[0], a[1], a[2], a[3]); - } - - if (a[0] < 0.0F || a[1] < 0.0F || a[2] < 0.0F || a[3] < 0.0F) { - return GL_FALSE; - } - } - break; - case OPCODE_LG2: /* log base 2 */ - { - GLfloat a[4], result[4], val; - fetch_vector1(&inst->SrcReg[0], machine, a); - /* The fast LOG2 macro doesn't meet the precision requirements. - */ - if (a[0] == 0.0F) { - val = -FLT_MAX; - } - else { - val = (float)(log(a[0]) * 1.442695F); - } - result[0] = result[1] = result[2] = result[3] = val; - store_vector4(inst, machine, result); - } - break; - case OPCODE_LIT: - { - const GLfloat epsilon = 1.0F / 256.0F; /* from NV VP spec */ - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - a[0] = MAX2(a[0], 0.0F); - a[1] = MAX2(a[1], 0.0F); - /* XXX ARB version clamps a[3], NV version doesn't */ - a[3] = CLAMP(a[3], -(128.0F - epsilon), (128.0F - epsilon)); - result[0] = 1.0F; - result[1] = a[0]; - /* XXX we could probably just use pow() here */ - if (a[0] > 0.0F) { - if (a[1] == 0.0 && a[3] == 0.0) - result[2] = 1.0F; - else - result[2] = (GLfloat) pow(a[1], a[3]); - } - else { - result[2] = 0.0F; - } - result[3] = 1.0F; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("LIT (%g %g %g %g) : (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3]); - } - } - break; - case OPCODE_LOG: - { - GLfloat t[4], q[4], abs_t0; - fetch_vector1(&inst->SrcReg[0], machine, t); - abs_t0 = FABSF(t[0]); - if (abs_t0 != 0.0F) { - /* Since we really can't handle infinite values on VMS - * like other OSes we'll use __MAXFLOAT to represent - * infinity. This may need some tweaking. - */ -#ifdef VMS - if (abs_t0 == __MAXFLOAT) -#else - if (IS_INF_OR_NAN(abs_t0)) -#endif - { - SET_POS_INFINITY(q[0]); - q[1] = 1.0F; - SET_POS_INFINITY(q[2]); - } - else { - int exponent; - GLfloat mantissa = FREXPF(t[0], &exponent); - q[0] = (GLfloat) (exponent - 1); - q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */ - - /* The fast LOG2 macro doesn't meet the precision - * requirements. - */ - q[2] = (float)(log(t[0]) * 1.442695F); - } - } - else { - SET_NEG_INFINITY(q[0]); - q[1] = 1.0F; - SET_NEG_INFINITY(q[2]); - } - q[3] = 1.0; - store_vector4(inst, machine, q); - } - break; - case OPCODE_LRP: - { - GLfloat a[4], b[4], c[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - fetch_vector4(&inst->SrcReg[2], machine, c); - result[0] = a[0] * b[0] + (1.0F - a[0]) * c[0]; - result[1] = a[1] * b[1] + (1.0F - a[1]) * c[1]; - result[2] = a[2] * b[2] + (1.0F - a[2]) * c[2]; - result[3] = a[3] * b[3] + (1.0F - a[3]) * c[3]; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("LRP (%g %g %g %g) = (%g %g %g %g), " - "(%g %g %g %g), (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3], c[0], c[1], c[2], c[3]); - } - } - break; - case OPCODE_MAD: - { - GLfloat a[4], b[4], c[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - fetch_vector4(&inst->SrcReg[2], machine, c); - result[0] = a[0] * b[0] + c[0]; - result[1] = a[1] * b[1] + c[1]; - result[2] = a[2] * b[2] + c[2]; - result[3] = a[3] * b[3] + c[3]; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("MAD (%g %g %g %g) = (%g %g %g %g) * " - "(%g %g %g %g) + (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3], c[0], c[1], c[2], c[3]); - } - } - break; - case OPCODE_MAX: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = MAX2(a[0], b[0]); - result[1] = MAX2(a[1], b[1]); - result[2] = MAX2(a[2], b[2]); - result[3] = MAX2(a[3], b[3]); - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("MAX (%g %g %g %g) = (%g %g %g %g), (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_MIN: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = MIN2(a[0], b[0]); - result[1] = MIN2(a[1], b[1]); - result[2] = MIN2(a[2], b[2]); - result[3] = MIN2(a[3], b[3]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_MOV: - { - GLfloat result[4]; - fetch_vector4(&inst->SrcReg[0], machine, result); - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("MOV (%g %g %g %g)\n", - result[0], result[1], result[2], result[3]); - } - } - break; - case OPCODE_MUL: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = a[0] * b[0]; - result[1] = a[1] * b[1]; - result[2] = a[2] * b[2]; - result[3] = a[3] * b[3]; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("MUL (%g %g %g %g) = (%g %g %g %g) * (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_NOISE1: - { - GLfloat a[4], result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = - result[1] = - result[2] = - result[3] = _mesa_noise1(a[0]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_NOISE2: - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = - result[1] = - result[2] = result[3] = _mesa_noise2(a[0], a[1]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_NOISE3: - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = - result[1] = - result[2] = - result[3] = _mesa_noise3(a[0], a[1], a[2]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_NOISE4: - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = - result[1] = - result[2] = - result[3] = _mesa_noise4(a[0], a[1], a[2], a[3]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_NOP: - break; - case OPCODE_NOT: /* bitwise NOT */ - { - GLuint a[4], result[4]; - fetch_vector4ui(&inst->SrcReg[0], machine, a); - result[0] = ~a[0]; - result[1] = ~a[1]; - result[2] = ~a[2]; - result[3] = ~a[3]; - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_NRM3: /* 3-component normalization */ - { - GLfloat a[4], result[4]; - GLfloat tmp; - fetch_vector4(&inst->SrcReg[0], machine, a); - tmp = a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; - if (tmp != 0.0F) - tmp = INV_SQRTF(tmp); - result[0] = tmp * a[0]; - result[1] = tmp * a[1]; - result[2] = tmp * a[2]; - result[3] = 0.0; /* undefined, but prevent valgrind warnings */ - store_vector4(inst, machine, result); - } - break; - case OPCODE_NRM4: /* 4-component normalization */ - { - GLfloat a[4], result[4]; - GLfloat tmp; - fetch_vector4(&inst->SrcReg[0], machine, a); - tmp = a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3]; - if (tmp != 0.0F) - tmp = INV_SQRTF(tmp); - result[0] = tmp * a[0]; - result[1] = tmp * a[1]; - result[2] = tmp * a[2]; - result[3] = tmp * a[3]; - store_vector4(inst, machine, result); - } - break; - case OPCODE_OR: /* bitwise OR */ - { - GLuint a[4], b[4], result[4]; - fetch_vector4ui(&inst->SrcReg[0], machine, a); - fetch_vector4ui(&inst->SrcReg[1], machine, b); - result[0] = a[0] | b[0]; - result[1] = a[1] | b[1]; - result[2] = a[2] | b[2]; - result[3] = a[3] | b[3]; - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_PK2H: /* pack two 16-bit floats in one 32-bit float */ - { - GLfloat a[4]; - GLuint result[4]; - GLhalfNV hx, hy; - fetch_vector4(&inst->SrcReg[0], machine, a); - hx = _mesa_float_to_half(a[0]); - hy = _mesa_float_to_half(a[1]); - result[0] = - result[1] = - result[2] = - result[3] = hx | (hy << 16); - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_PK2US: /* pack two GLushorts into one 32-bit float */ - { - GLfloat a[4]; - GLuint result[4], usx, usy; - fetch_vector4(&inst->SrcReg[0], machine, a); - a[0] = CLAMP(a[0], 0.0F, 1.0F); - a[1] = CLAMP(a[1], 0.0F, 1.0F); - usx = IROUND(a[0] * 65535.0F); - usy = IROUND(a[1] * 65535.0F); - result[0] = - result[1] = - result[2] = - result[3] = usx | (usy << 16); - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_PK4B: /* pack four GLbytes into one 32-bit float */ - { - GLfloat a[4]; - GLuint result[4], ubx, uby, ubz, ubw; - fetch_vector4(&inst->SrcReg[0], machine, a); - a[0] = CLAMP(a[0], -128.0F / 127.0F, 1.0F); - a[1] = CLAMP(a[1], -128.0F / 127.0F, 1.0F); - a[2] = CLAMP(a[2], -128.0F / 127.0F, 1.0F); - a[3] = CLAMP(a[3], -128.0F / 127.0F, 1.0F); - ubx = IROUND(127.0F * a[0] + 128.0F); - uby = IROUND(127.0F * a[1] + 128.0F); - ubz = IROUND(127.0F * a[2] + 128.0F); - ubw = IROUND(127.0F * a[3] + 128.0F); - result[0] = - result[1] = - result[2] = - result[3] = ubx | (uby << 8) | (ubz << 16) | (ubw << 24); - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_PK4UB: /* pack four GLubytes into one 32-bit float */ - { - GLfloat a[4]; - GLuint result[4], ubx, uby, ubz, ubw; - fetch_vector4(&inst->SrcReg[0], machine, a); - a[0] = CLAMP(a[0], 0.0F, 1.0F); - a[1] = CLAMP(a[1], 0.0F, 1.0F); - a[2] = CLAMP(a[2], 0.0F, 1.0F); - a[3] = CLAMP(a[3], 0.0F, 1.0F); - ubx = IROUND(255.0F * a[0]); - uby = IROUND(255.0F * a[1]); - ubz = IROUND(255.0F * a[2]); - ubw = IROUND(255.0F * a[3]); - result[0] = - result[1] = - result[2] = - result[3] = ubx | (uby << 8) | (ubz << 16) | (ubw << 24); - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_POW: - { - GLfloat a[4], b[4], result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - fetch_vector1(&inst->SrcReg[1], machine, b); - result[0] = result[1] = result[2] = result[3] - = (GLfloat) pow(a[0], b[0]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_RCC: /* clamped riciprocal */ - { - const float largest = 1.884467e+19, smallest = 5.42101e-20; - GLfloat a[4], r, result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - if (DEBUG_PROG) { - if (a[0] == 0) - printf("RCC(0)\n"); - else if (IS_INF_OR_NAN(a[0])) - printf("RCC(inf)\n"); - } - if (a[0] == 1.0F) { - r = 1.0F; - } - else { - r = 1.0F / a[0]; - } - if (positive(r)) { - if (r > largest) { - r = largest; - } - else if (r < smallest) { - r = smallest; - } - } - else { - if (r < -largest) { - r = -largest; - } - else if (r > -smallest) { - r = -smallest; - } - } - result[0] = result[1] = result[2] = result[3] = r; - store_vector4(inst, machine, result); - } - break; - - case OPCODE_RCP: - { - GLfloat a[4], result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - if (DEBUG_PROG) { - if (a[0] == 0) - printf("RCP(0)\n"); - else if (IS_INF_OR_NAN(a[0])) - printf("RCP(inf)\n"); - } - result[0] = result[1] = result[2] = result[3] = 1.0F / a[0]; - store_vector4(inst, machine, result); - } - break; - case OPCODE_RET: /* return from subroutine (conditional) */ - if (eval_condition(machine, inst)) { - if (machine->StackDepth == 0) { - return GL_TRUE; /* Per GL_NV_vertex_program2 spec */ - } - /* subtract one because of pc++ in the for loop */ - pc = machine->CallStack[--machine->StackDepth] - 1; - } - break; - case OPCODE_RFL: /* reflection vector */ - { - GLfloat axis[4], dir[4], result[4], tmpX, tmpW; - fetch_vector4(&inst->SrcReg[0], machine, axis); - fetch_vector4(&inst->SrcReg[1], machine, dir); - tmpW = DOT3(axis, axis); - tmpX = (2.0F * DOT3(axis, dir)) / tmpW; - result[0] = tmpX * axis[0] - dir[0]; - result[1] = tmpX * axis[1] - dir[1]; - result[2] = tmpX * axis[2] - dir[2]; - /* result[3] is never written! XXX enforce in parser! */ - store_vector4(inst, machine, result); - } - break; - case OPCODE_RSQ: /* 1 / sqrt() */ - { - GLfloat a[4], result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - a[0] = FABSF(a[0]); - result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]); - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("RSQ %g = 1/sqrt(|%g|)\n", result[0], a[0]); - } - } - break; - case OPCODE_SCS: /* sine and cos */ - { - GLfloat a[4], result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = (GLfloat) cos(a[0]); - result[1] = (GLfloat) sin(a[0]); - result[2] = 0.0; /* undefined! */ - result[3] = 0.0; /* undefined! */ - store_vector4(inst, machine, result); - } - break; - case OPCODE_SEQ: /* set on equal */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = (a[0] == b[0]) ? 1.0F : 0.0F; - result[1] = (a[1] == b[1]) ? 1.0F : 0.0F; - result[2] = (a[2] == b[2]) ? 1.0F : 0.0F; - result[3] = (a[3] == b[3]) ? 1.0F : 0.0F; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("SEQ (%g %g %g %g) = (%g %g %g %g) == (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_SFL: /* set false, operands ignored */ - { - static const GLfloat result[4] = { 0.0F, 0.0F, 0.0F, 0.0F }; - store_vector4(inst, machine, result); - } - break; - case OPCODE_SGE: /* set on greater or equal */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = (a[0] >= b[0]) ? 1.0F : 0.0F; - result[1] = (a[1] >= b[1]) ? 1.0F : 0.0F; - result[2] = (a[2] >= b[2]) ? 1.0F : 0.0F; - result[3] = (a[3] >= b[3]) ? 1.0F : 0.0F; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("SGE (%g %g %g %g) = (%g %g %g %g) >= (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_SGT: /* set on greater */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = (a[0] > b[0]) ? 1.0F : 0.0F; - result[1] = (a[1] > b[1]) ? 1.0F : 0.0F; - result[2] = (a[2] > b[2]) ? 1.0F : 0.0F; - result[3] = (a[3] > b[3]) ? 1.0F : 0.0F; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("SGT (%g %g %g %g) = (%g %g %g %g) > (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_SIN: - { - GLfloat a[4], result[4]; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = result[1] = result[2] = result[3] - = (GLfloat) sin(a[0]); - store_vector4(inst, machine, result); - } - break; - case OPCODE_SLE: /* set on less or equal */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = (a[0] <= b[0]) ? 1.0F : 0.0F; - result[1] = (a[1] <= b[1]) ? 1.0F : 0.0F; - result[2] = (a[2] <= b[2]) ? 1.0F : 0.0F; - result[3] = (a[3] <= b[3]) ? 1.0F : 0.0F; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("SLE (%g %g %g %g) = (%g %g %g %g) <= (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_SLT: /* set on less */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = (a[0] < b[0]) ? 1.0F : 0.0F; - result[1] = (a[1] < b[1]) ? 1.0F : 0.0F; - result[2] = (a[2] < b[2]) ? 1.0F : 0.0F; - result[3] = (a[3] < b[3]) ? 1.0F : 0.0F; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("SLT (%g %g %g %g) = (%g %g %g %g) < (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_SNE: /* set on not equal */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = (a[0] != b[0]) ? 1.0F : 0.0F; - result[1] = (a[1] != b[1]) ? 1.0F : 0.0F; - result[2] = (a[2] != b[2]) ? 1.0F : 0.0F; - result[3] = (a[3] != b[3]) ? 1.0F : 0.0F; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("SNE (%g %g %g %g) = (%g %g %g %g) != (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_SSG: /* set sign (-1, 0 or +1) */ - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = (GLfloat) ((a[0] > 0.0F) - (a[0] < 0.0F)); - result[1] = (GLfloat) ((a[1] > 0.0F) - (a[1] < 0.0F)); - result[2] = (GLfloat) ((a[2] > 0.0F) - (a[2] < 0.0F)); - result[3] = (GLfloat) ((a[3] > 0.0F) - (a[3] < 0.0F)); - store_vector4(inst, machine, result); - } - break; - case OPCODE_STR: /* set true, operands ignored */ - { - static const GLfloat result[4] = { 1.0F, 1.0F, 1.0F, 1.0F }; - store_vector4(inst, machine, result); - } - break; - case OPCODE_SUB: - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = a[0] - b[0]; - result[1] = a[1] - b[1]; - result[2] = a[2] - b[2]; - result[3] = a[3] - b[3]; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("SUB (%g %g %g %g) = (%g %g %g %g) - (%g %g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]); - } - } - break; - case OPCODE_SWZ: /* extended swizzle */ - { - const struct prog_src_register *source = &inst->SrcReg[0]; - const GLfloat *src = get_src_register_pointer(source, machine); - GLfloat result[4]; - GLuint i; - for (i = 0; i < 4; i++) { - const GLuint swz = GET_SWZ(source->Swizzle, i); - if (swz == SWIZZLE_ZERO) - result[i] = 0.0; - else if (swz == SWIZZLE_ONE) - result[i] = 1.0; - else { - ASSERT(swz >= 0); - ASSERT(swz <= 3); - result[i] = src[swz]; - } - if (source->Negate & (1 << i)) - result[i] = -result[i]; - } - store_vector4(inst, machine, result); - } - break; - case OPCODE_TEX: /* Both ARB and NV frag prog */ - /* Simple texel lookup */ - { - GLfloat texcoord[4], color[4]; - fetch_vector4(&inst->SrcReg[0], machine, texcoord); - - /* For TEX, texcoord.Q should not be used and its value should not - * matter (at most, we pass coord.xyz to texture3D() in GLSL). - * Set Q=1 so that FetchTexelDeriv() doesn't get a garbage value - * which is effectively what happens when the texcoord swizzle - * is .xyzz - */ - texcoord[3] = 1.0f; - - fetch_texel(ctx, machine, inst, texcoord, 0.0, color); - - if (DEBUG_PROG) { - printf("TEX (%g, %g, %g, %g) = texture[%d][%g, %g, %g, %g]\n", - color[0], color[1], color[2], color[3], - inst->TexSrcUnit, - texcoord[0], texcoord[1], texcoord[2], texcoord[3]); - } - store_vector4(inst, machine, color); - } - break; - case OPCODE_TXB: /* GL_ARB_fragment_program only */ - /* Texel lookup with LOD bias */ - { - GLfloat texcoord[4], color[4], lodBias; - - fetch_vector4(&inst->SrcReg[0], machine, texcoord); - - /* texcoord[3] is the bias to add to lambda */ - lodBias = texcoord[3]; - - fetch_texel(ctx, machine, inst, texcoord, lodBias, color); - - if (DEBUG_PROG) { - printf("TXB (%g, %g, %g, %g) = texture[%d][%g %g %g %g]" - " bias %g\n", - color[0], color[1], color[2], color[3], - inst->TexSrcUnit, - texcoord[0], - texcoord[1], - texcoord[2], - texcoord[3], - lodBias); - } - - store_vector4(inst, machine, color); - } - break; - case OPCODE_TXD: /* GL_NV_fragment_program only */ - /* Texture lookup w/ partial derivatives for LOD */ - { - GLfloat texcoord[4], dtdx[4], dtdy[4], color[4]; - fetch_vector4(&inst->SrcReg[0], machine, texcoord); - fetch_vector4(&inst->SrcReg[1], machine, dtdx); - fetch_vector4(&inst->SrcReg[2], machine, dtdy); - machine->FetchTexelDeriv(ctx, texcoord, dtdx, dtdy, - 0.0, /* lodBias */ - inst->TexSrcUnit, color); - store_vector4(inst, machine, color); - } - break; - case OPCODE_TXL: - /* Texel lookup with explicit LOD */ - { - GLfloat texcoord[4], color[4], lod; - - fetch_vector4(&inst->SrcReg[0], machine, texcoord); - - /* texcoord[3] is the LOD */ - lod = texcoord[3]; - - machine->FetchTexelLod(ctx, texcoord, lod, - machine->Samplers[inst->TexSrcUnit], color); - - store_vector4(inst, machine, color); - } - break; - case OPCODE_TXP: /* GL_ARB_fragment_program only */ - /* Texture lookup w/ projective divide */ - { - GLfloat texcoord[4], color[4]; - - fetch_vector4(&inst->SrcReg[0], machine, texcoord); - /* Not so sure about this test - if texcoord[3] is - * zero, we'd probably be fine except for an ASSERT in - * IROUND_POS() which gets triggered by the inf values created. - */ - if (texcoord[3] != 0.0) { - texcoord[0] /= texcoord[3]; - texcoord[1] /= texcoord[3]; - texcoord[2] /= texcoord[3]; - } - - fetch_texel(ctx, machine, inst, texcoord, 0.0, color); - - store_vector4(inst, machine, color); - } - break; - case OPCODE_TXP_NV: /* GL_NV_fragment_program only */ - /* Texture lookup w/ projective divide, as above, but do not - * do the divide by w if sampling from a cube map. - */ - { - GLfloat texcoord[4], color[4]; - - fetch_vector4(&inst->SrcReg[0], machine, texcoord); - if (inst->TexSrcTarget != TEXTURE_CUBE_INDEX && - texcoord[3] != 0.0) { - texcoord[0] /= texcoord[3]; - texcoord[1] /= texcoord[3]; - texcoord[2] /= texcoord[3]; - } - - fetch_texel(ctx, machine, inst, texcoord, 0.0, color); - - store_vector4(inst, machine, color); - } - break; - case OPCODE_TRUNC: /* truncate toward zero */ - { - GLfloat a[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = (GLfloat) (GLint) a[0]; - result[1] = (GLfloat) (GLint) a[1]; - result[2] = (GLfloat) (GLint) a[2]; - result[3] = (GLfloat) (GLint) a[3]; - store_vector4(inst, machine, result); - } - break; - case OPCODE_UP2H: /* unpack two 16-bit floats */ - { - const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); - GLfloat result[4]; - GLushort hx, hy; - hx = raw & 0xffff; - hy = raw >> 16; - result[0] = result[2] = _mesa_half_to_float(hx); - result[1] = result[3] = _mesa_half_to_float(hy); - store_vector4(inst, machine, result); - } - break; - case OPCODE_UP2US: /* unpack two GLushorts */ - { - const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); - GLfloat result[4]; - GLushort usx, usy; - usx = raw & 0xffff; - usy = raw >> 16; - result[0] = result[2] = usx * (1.0f / 65535.0f); - result[1] = result[3] = usy * (1.0f / 65535.0f); - store_vector4(inst, machine, result); - } - break; - case OPCODE_UP4B: /* unpack four GLbytes */ - { - const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); - GLfloat result[4]; - result[0] = (((raw >> 0) & 0xff) - 128) / 127.0F; - result[1] = (((raw >> 8) & 0xff) - 128) / 127.0F; - result[2] = (((raw >> 16) & 0xff) - 128) / 127.0F; - result[3] = (((raw >> 24) & 0xff) - 128) / 127.0F; - store_vector4(inst, machine, result); - } - break; - case OPCODE_UP4UB: /* unpack four GLubytes */ - { - const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); - GLfloat result[4]; - result[0] = ((raw >> 0) & 0xff) / 255.0F; - result[1] = ((raw >> 8) & 0xff) / 255.0F; - result[2] = ((raw >> 16) & 0xff) / 255.0F; - result[3] = ((raw >> 24) & 0xff) / 255.0F; - store_vector4(inst, machine, result); - } - break; - case OPCODE_XOR: /* bitwise XOR */ - { - GLuint a[4], b[4], result[4]; - fetch_vector4ui(&inst->SrcReg[0], machine, a); - fetch_vector4ui(&inst->SrcReg[1], machine, b); - result[0] = a[0] ^ b[0]; - result[1] = a[1] ^ b[1]; - result[2] = a[2] ^ b[2]; - result[3] = a[3] ^ b[3]; - store_vector4ui(inst, machine, result); - } - break; - case OPCODE_XPD: /* cross product */ - { - GLfloat a[4], b[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - result[0] = a[1] * b[2] - a[2] * b[1]; - result[1] = a[2] * b[0] - a[0] * b[2]; - result[2] = a[0] * b[1] - a[1] * b[0]; - result[3] = 1.0; - store_vector4(inst, machine, result); - if (DEBUG_PROG) { - printf("XPD (%g %g %g %g) = (%g %g %g) X (%g %g %g)\n", - result[0], result[1], result[2], result[3], - a[0], a[1], a[2], b[0], b[1], b[2]); - } - } - break; - case OPCODE_X2D: /* 2-D matrix transform */ - { - GLfloat a[4], b[4], c[4], result[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - fetch_vector4(&inst->SrcReg[1], machine, b); - fetch_vector4(&inst->SrcReg[2], machine, c); - result[0] = a[0] + b[0] * c[0] + b[1] * c[1]; - result[1] = a[1] + b[0] * c[2] + b[1] * c[3]; - result[2] = a[2] + b[0] * c[0] + b[1] * c[1]; - result[3] = a[3] + b[0] * c[2] + b[1] * c[3]; - store_vector4(inst, machine, result); - } - break; - case OPCODE_PRINT: - { - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - GLfloat a[4]; - fetch_vector4(&inst->SrcReg[0], machine, a); - printf("%s%g, %g, %g, %g\n", (const char *) inst->Data, - a[0], a[1], a[2], a[3]); - } - else { - printf("%s\n", (const char *) inst->Data); - } - } - break; - case OPCODE_END: - return GL_TRUE; - default: - _mesa_problem(ctx, "Bad opcode %d in _mesa_execute_program", - inst->Opcode); - return GL_TRUE; /* return value doesn't matter */ - } - - numExec++; - if (numExec > maxExec) { - static GLboolean reported = GL_FALSE; - if (!reported) { - _mesa_problem(ctx, "Infinite loop detected in fragment program"); - reported = GL_TRUE; - } - return GL_TRUE; - } - - } /* for pc */ - - return GL_TRUE; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_execute.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_execute.h deleted file mode 100644 index cdf37082a00..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_execute.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.0.3 - * - * Copyright (C) 1999-2007 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 PROG_EXECUTE_H -#define PROG_EXECUTE_H - -#include "main/config.h" -#include "main/mtypes.h" - - -typedef void (*FetchTexelLodFunc)(struct gl_context *ctx, const GLfloat texcoord[4], - GLfloat lambda, GLuint unit, GLfloat color[4]); - -typedef void (*FetchTexelDerivFunc)(struct gl_context *ctx, const GLfloat texcoord[4], - const GLfloat texdx[4], - const GLfloat texdy[4], - GLfloat lodBias, - GLuint unit, GLfloat color[4]); - - -/** - * Virtual machine state used during execution of vertex/fragment programs. - */ -struct gl_program_machine -{ - const struct gl_program *CurProgram; - - /** Fragment Input attributes */ - GLfloat (*Attribs)[MAX_WIDTH][4]; - GLfloat (*DerivX)[4]; - GLfloat (*DerivY)[4]; - GLuint NumDeriv; /**< Max index into DerivX/Y arrays */ - GLuint CurElement; /**< Index into Attribs arrays */ - - /** Vertex Input attribs */ - GLfloat VertAttribs[VERT_ATTRIB_MAX][4]; - - GLfloat Temporaries[MAX_PROGRAM_TEMPS][4]; - GLfloat Outputs[MAX_PROGRAM_OUTPUTS][4]; - GLfloat (*EnvParams)[4]; /**< Vertex or Fragment env parameters */ - GLuint CondCodes[4]; /**< COND_* value for x/y/z/w */ - GLint AddressReg[MAX_PROGRAM_ADDRESS_REGS][4]; - GLfloat SystemValues[SYSTEM_VALUE_MAX][4]; - - const GLubyte *Samplers; /** Array mapping sampler var to tex unit */ - - GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */ - GLuint StackDepth; /**< Index/ptr to top of CallStack[] */ - - /** Texture fetch functions */ - FetchTexelLodFunc FetchTexelLod; - FetchTexelDerivFunc FetchTexelDeriv; -}; - - -extern void -_mesa_get_program_register(struct gl_context *ctx, gl_register_file file, - GLuint index, GLfloat val[4]); - -extern GLboolean -_mesa_execute_program(struct gl_context *ctx, - const struct gl_program *program, - struct gl_program_machine *machine); - - -#endif /* PROG_EXECUTE_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.c deleted file mode 100644 index 5d6cb476c1d..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 1999-2009 VMware, Inc. 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. - */ - - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/mtypes.h" -#include "prog_instruction.h" - - -/** - * Initialize program instruction fields to defaults. - * \param inst first instruction to initialize - * \param count number of instructions to initialize - */ -void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count) -{ - GLuint i; - - memset(inst, 0, count * sizeof(struct prog_instruction)); - - for (i = 0; i < count; i++) { - inst[i].SrcReg[0].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; - inst[i].SrcReg[1].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; - inst[i].SrcReg[2].File = PROGRAM_UNDEFINED; - inst[i].SrcReg[2].Swizzle = SWIZZLE_NOOP; - - inst[i].DstReg.File = PROGRAM_UNDEFINED; - inst[i].DstReg.WriteMask = WRITEMASK_XYZW; - inst[i].DstReg.CondMask = COND_TR; - inst[i].DstReg.CondSwizzle = SWIZZLE_NOOP; - - inst[i].SaturateMode = SATURATE_OFF; - inst[i].Precision = FLOAT32; - } -} - - -/** - * Allocate an array of program instructions. - * \param numInst number of instructions - * \return pointer to instruction memory - */ -struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst) -{ - return (struct prog_instruction *) - calloc(1, numInst * sizeof(struct prog_instruction)); -} - - -/** - * Reallocate memory storing an array of program instructions. - * This is used when we need to append additional instructions onto an - * program. - * \param oldInst pointer to first of old/src instructions - * \param numOldInst number of instructions at - * \param numNewInst desired size of new instruction array. - * \return pointer to start of new instruction array. - */ -struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, - GLuint numOldInst, GLuint numNewInst) -{ - struct prog_instruction *newInst; - - newInst = (struct prog_instruction *) - _mesa_realloc(oldInst, - numOldInst * sizeof(struct prog_instruction), - numNewInst * sizeof(struct prog_instruction)); - - return newInst; -} - - -/** - * Copy an array of program instructions. - * \param dest pointer to destination. - * \param src pointer to source. - * \param n number of instructions to copy. - * \return pointer to destination. - */ -struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, - const struct prog_instruction *src, GLuint n) -{ - GLuint i; - memcpy(dest, src, n * sizeof(struct prog_instruction)); - for (i = 0; i < n; i++) { - if (src[i].Comment) - dest[i].Comment = _mesa_strdup(src[i].Comment); - } - return dest; -} - - -/** - * Free an array of instructions - */ -void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count) -{ - GLuint i; - for (i = 0; i < count; i++) { - if (inst[i].Data) - free(inst[i].Data); - if (inst[i].Comment) - free((char *) inst[i].Comment); - } - free(inst); -} - - -/** - * Basic info about each instruction - */ -struct instruction_info -{ - gl_inst_opcode Opcode; - const char *Name; - GLuint NumSrcRegs; - GLuint NumDstRegs; -}; - -/** - * Instruction info - * \note Opcode should equal array index! - */ -static const struct instruction_info InstInfo[MAX_OPCODE] = { - { OPCODE_NOP, "NOP", 0, 0 }, - { OPCODE_ABS, "ABS", 1, 1 }, - { OPCODE_ADD, "ADD", 2, 1 }, - { OPCODE_AND, "AND", 2, 1 }, - { OPCODE_ARA, "ARA", 1, 1 }, - { OPCODE_ARL, "ARL", 1, 1 }, - { OPCODE_ARL_NV, "ARL_NV", 1, 1 }, - { OPCODE_ARR, "ARL", 1, 1 }, - { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, - { OPCODE_BGNSUB, "BGNSUB", 0, 0 }, - { OPCODE_BRA, "BRA", 0, 0 }, - { OPCODE_BRK, "BRK", 0, 0 }, - { OPCODE_CAL, "CAL", 0, 0 }, - { OPCODE_CMP, "CMP", 3, 1 }, - { OPCODE_CONT, "CONT", 0, 0 }, - { OPCODE_COS, "COS", 1, 1 }, - { OPCODE_DDX, "DDX", 1, 1 }, - { OPCODE_DDY, "DDY", 1, 1 }, - { OPCODE_DP2, "DP2", 2, 1 }, - { OPCODE_DP2A, "DP2A", 3, 1 }, - { OPCODE_DP3, "DP3", 2, 1 }, - { OPCODE_DP4, "DP4", 2, 1 }, - { OPCODE_DPH, "DPH", 2, 1 }, - { OPCODE_DST, "DST", 2, 1 }, - { OPCODE_ELSE, "ELSE", 0, 0 }, - { OPCODE_EMIT_VERTEX, "EMIT_VERTEX", 0, 0 }, - { OPCODE_END, "END", 0, 0 }, - { OPCODE_END_PRIMITIVE, "END_PRIMITIVE", 0, 0 }, - { OPCODE_ENDIF, "ENDIF", 0, 0 }, - { OPCODE_ENDLOOP,"ENDLOOP", 0, 0 }, - { OPCODE_ENDSUB, "ENDSUB", 0, 0 }, - { OPCODE_EX2, "EX2", 1, 1 }, - { OPCODE_EXP, "EXP", 1, 1 }, - { OPCODE_FLR, "FLR", 1, 1 }, - { OPCODE_FRC, "FRC", 1, 1 }, - { OPCODE_IF, "IF", 1, 0 }, - { OPCODE_KIL, "KIL", 1, 0 }, - { OPCODE_KIL_NV, "KIL_NV", 0, 0 }, - { OPCODE_LG2, "LG2", 1, 1 }, - { OPCODE_LIT, "LIT", 1, 1 }, - { OPCODE_LOG, "LOG", 1, 1 }, - { OPCODE_LRP, "LRP", 3, 1 }, - { OPCODE_MAD, "MAD", 3, 1 }, - { OPCODE_MAX, "MAX", 2, 1 }, - { OPCODE_MIN, "MIN", 2, 1 }, - { OPCODE_MOV, "MOV", 1, 1 }, - { OPCODE_MUL, "MUL", 2, 1 }, - { OPCODE_NOISE1, "NOISE1", 1, 1 }, - { OPCODE_NOISE2, "NOISE2", 1, 1 }, - { OPCODE_NOISE3, "NOISE3", 1, 1 }, - { OPCODE_NOISE4, "NOISE4", 1, 1 }, - { OPCODE_NOT, "NOT", 1, 1 }, - { OPCODE_NRM3, "NRM3", 1, 1 }, - { OPCODE_NRM4, "NRM4", 1, 1 }, - { OPCODE_OR, "OR", 2, 1 }, - { OPCODE_PK2H, "PK2H", 1, 1 }, - { OPCODE_PK2US, "PK2US", 1, 1 }, - { OPCODE_PK4B, "PK4B", 1, 1 }, - { OPCODE_PK4UB, "PK4UB", 1, 1 }, - { OPCODE_POW, "POW", 2, 1 }, - { OPCODE_POPA, "POPA", 0, 0 }, - { OPCODE_PRINT, "PRINT", 1, 0 }, - { OPCODE_PUSHA, "PUSHA", 0, 0 }, - { OPCODE_RCC, "RCC", 1, 1 }, - { OPCODE_RCP, "RCP", 1, 1 }, - { OPCODE_RET, "RET", 0, 0 }, - { OPCODE_RFL, "RFL", 1, 1 }, - { OPCODE_RSQ, "RSQ", 1, 1 }, - { OPCODE_SCS, "SCS", 1, 1 }, - { OPCODE_SEQ, "SEQ", 2, 1 }, - { OPCODE_SFL, "SFL", 0, 1 }, - { OPCODE_SGE, "SGE", 2, 1 }, - { OPCODE_SGT, "SGT", 2, 1 }, - { OPCODE_SIN, "SIN", 1, 1 }, - { OPCODE_SLE, "SLE", 2, 1 }, - { OPCODE_SLT, "SLT", 2, 1 }, - { OPCODE_SNE, "SNE", 2, 1 }, - { OPCODE_SSG, "SSG", 1, 1 }, - { OPCODE_STR, "STR", 0, 1 }, - { OPCODE_SUB, "SUB", 2, 1 }, - { OPCODE_SWZ, "SWZ", 1, 1 }, - { OPCODE_TEX, "TEX", 1, 1 }, - { OPCODE_TXB, "TXB", 1, 1 }, - { OPCODE_TXD, "TXD", 3, 1 }, - { OPCODE_TXL, "TXL", 1, 1 }, - { OPCODE_TXP, "TXP", 1, 1 }, - { OPCODE_TXP_NV, "TXP_NV", 1, 1 }, - { OPCODE_TRUNC, "TRUNC", 1, 1 }, - { OPCODE_UP2H, "UP2H", 1, 1 }, - { OPCODE_UP2US, "UP2US", 1, 1 }, - { OPCODE_UP4B, "UP4B", 1, 1 }, - { OPCODE_UP4UB, "UP4UB", 1, 1 }, - { OPCODE_X2D, "X2D", 3, 1 }, - { OPCODE_XOR, "XOR", 2, 1 }, - { OPCODE_XPD, "XPD", 2, 1 } -}; - - -/** - * Return the number of src registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode) -{ - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); - return InstInfo[opcode].NumSrcRegs; -} - - -/** - * Return the number of dst registers for the given instruction/opcode. - */ -GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode) -{ - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); - return InstInfo[opcode].NumDstRegs; -} - - -GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode) -{ - return (opcode == OPCODE_TEX || - opcode == OPCODE_TXB || - opcode == OPCODE_TXD || - opcode == OPCODE_TXL || - opcode == OPCODE_TXP); -} - - -/** - * Check if there's a potential src/dst register data dependency when - * using SOA execution. - * Example: - * MOV T, T.yxwz; - * This would expand into: - * MOV t0, t1; - * MOV t1, t0; - * MOV t2, t3; - * MOV t3, t2; - * The second instruction will have the wrong value for t0 if executed as-is. - */ -GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst) -{ - GLuint i, chan; - - if (inst->DstReg.WriteMask == WRITEMASK_X || - inst->DstReg.WriteMask == WRITEMASK_Y || - inst->DstReg.WriteMask == WRITEMASK_Z || - inst->DstReg.WriteMask == WRITEMASK_W || - inst->DstReg.WriteMask == 0x0) { - /* no chance of data dependency */ - return GL_FALSE; - } - - /* loop over src regs */ - for (i = 0; i < 3; i++) { - if (inst->SrcReg[i].File == inst->DstReg.File && - inst->SrcReg[i].Index == inst->DstReg.Index) { - /* loop over dest channels */ - GLuint channelsWritten = 0x0; - for (chan = 0; chan < 4; chan++) { - if (inst->DstReg.WriteMask & (1 << chan)) { - /* check if we're reading a channel that's been written */ - GLuint swizzle = GET_SWZ(inst->SrcReg[i].Swizzle, chan); - if (swizzle <= SWIZZLE_W && - (channelsWritten & (1 << swizzle))) { - return GL_TRUE; - } - - channelsWritten |= (1 << chan); - } - } - } - } - return GL_FALSE; -} - - -/** - * Return string name for given program opcode. - */ -const char * -_mesa_opcode_string(gl_inst_opcode opcode) -{ - if (opcode < MAX_OPCODE) - return InstInfo[opcode].Name; - else { - static char s[20]; - _mesa_snprintf(s, sizeof(s), "OP%u", opcode); - return s; - } -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.h deleted file mode 100644 index 09659ce9c7c..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_instruction.h +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 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. - */ - - -/** - * \file prog_instruction.h - * - * Vertex/fragment program instruction datatypes and constants. - * - * \author Brian Paul - * \author Keith Whitwell - * \author Ian Romanick - */ - - -#ifndef PROG_INSTRUCTION_H -#define PROG_INSTRUCTION_H - - -#include "main/glheader.h" - - -/** - * Swizzle indexes. - * Do not change! - */ -/*@{*/ -#define SWIZZLE_X 0 -#define SWIZZLE_Y 1 -#define SWIZZLE_Z 2 -#define SWIZZLE_W 3 -#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */ -#define SWIZZLE_ONE 5 /**< For SWZ instruction only */ -#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */ -/*@}*/ - -#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9)) -#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3) -#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7) -#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1) - -#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) -#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X) -#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y) -#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z) -#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W) - - -/** - * Writemask values, 1 bit per component. - */ -/*@{*/ -#define WRITEMASK_X 0x1 -#define WRITEMASK_Y 0x2 -#define WRITEMASK_XY 0x3 -#define WRITEMASK_Z 0x4 -#define WRITEMASK_XZ 0x5 -#define WRITEMASK_YZ 0x6 -#define WRITEMASK_XYZ 0x7 -#define WRITEMASK_W 0x8 -#define WRITEMASK_XW 0x9 -#define WRITEMASK_YW 0xa -#define WRITEMASK_XYW 0xb -#define WRITEMASK_ZW 0xc -#define WRITEMASK_XZW 0xd -#define WRITEMASK_YZW 0xe -#define WRITEMASK_XYZW 0xf -/*@}*/ - - -/** - * Condition codes - */ -/*@{*/ -#define COND_GT 1 /**< greater than zero */ -#define COND_EQ 2 /**< equal to zero */ -#define COND_LT 3 /**< less than zero */ -#define COND_UN 4 /**< unordered (NaN) */ -#define COND_GE 5 /**< greater than or equal to zero */ -#define COND_LE 6 /**< less than or equal to zero */ -#define COND_NE 7 /**< not equal to zero */ -#define COND_TR 8 /**< always true */ -#define COND_FL 9 /**< always false */ -/*@}*/ - - -/** - * Instruction precision for GL_NV_fragment_program - */ -/*@{*/ -#define FLOAT32 0x1 -#define FLOAT16 0x2 -#define FIXED12 0x4 -/*@}*/ - - -/** - * Saturation modes when storing values. - */ -/*@{*/ -#define SATURATE_OFF 0 -#define SATURATE_ZERO_ONE 1 -/*@}*/ - - -/** - * Per-component negation masks - */ -/*@{*/ -#define NEGATE_X 0x1 -#define NEGATE_Y 0x2 -#define NEGATE_Z 0x4 -#define NEGATE_W 0x8 -#define NEGATE_XYZ 0x7 -#define NEGATE_XYZW 0xf -#define NEGATE_NONE 0x0 -/*@}*/ - - -/** - * Program instruction opcodes for vertex, fragment and geometry programs. - */ -typedef enum prog_opcode { - /* ARB_vp ARB_fp NV_vp NV_fp GLSL */ - /*------------------------------------------*/ - OPCODE_NOP = 0, /* X */ - OPCODE_ABS, /* X X 1.1 X */ - OPCODE_ADD, /* X X X X X */ - OPCODE_AND, /* */ - OPCODE_ARA, /* 2 */ - OPCODE_ARL, /* X X X */ - OPCODE_ARL_NV, /* 2 */ - OPCODE_ARR, /* 2 */ - OPCODE_BGNLOOP, /* opt */ - OPCODE_BGNSUB, /* opt */ - OPCODE_BRA, /* 2 */ - OPCODE_BRK, /* 2 opt */ - OPCODE_CAL, /* 2 2 opt */ - OPCODE_CMP, /* X X */ - OPCODE_CONT, /* opt */ - OPCODE_COS, /* X 2 X X */ - OPCODE_DDX, /* X X */ - OPCODE_DDY, /* X X */ - OPCODE_DP2, /* 2 X */ - OPCODE_DP2A, /* 2 */ - OPCODE_DP3, /* X X X X X */ - OPCODE_DP4, /* X X X X X */ - OPCODE_DPH, /* X X 1.1 */ - OPCODE_DST, /* X X X X */ - OPCODE_ELSE, /* opt */ - OPCODE_EMIT_VERTEX,/* X */ - OPCODE_END, /* X X X X opt */ - OPCODE_END_PRIMITIVE,/* X */ - OPCODE_ENDIF, /* opt */ - OPCODE_ENDLOOP, /* opt */ - OPCODE_ENDSUB, /* opt */ - OPCODE_EX2, /* X X 2 X X */ - OPCODE_EXP, /* X X */ - OPCODE_FLR, /* X X 2 X X */ - OPCODE_FRC, /* X X 2 X X */ - OPCODE_IF, /* opt */ - OPCODE_KIL, /* X X */ - OPCODE_KIL_NV, /* X X */ - OPCODE_LG2, /* X X 2 X X */ - OPCODE_LIT, /* X X X X */ - OPCODE_LOG, /* X X */ - OPCODE_LRP, /* X X */ - OPCODE_MAD, /* X X X X X */ - OPCODE_MAX, /* X X X X X */ - OPCODE_MIN, /* X X X X X */ - OPCODE_MOV, /* X X X X X */ - OPCODE_MUL, /* X X X X X */ - OPCODE_NOISE1, /* X */ - OPCODE_NOISE2, /* X */ - OPCODE_NOISE3, /* X */ - OPCODE_NOISE4, /* X */ - OPCODE_NOT, /* */ - OPCODE_NRM3, /* */ - OPCODE_NRM4, /* */ - OPCODE_OR, /* */ - OPCODE_PK2H, /* X */ - OPCODE_PK2US, /* X */ - OPCODE_PK4B, /* X */ - OPCODE_PK4UB, /* X */ - OPCODE_POW, /* X X X X */ - OPCODE_POPA, /* 3 */ - OPCODE_PRINT, /* X X */ - OPCODE_PUSHA, /* 3 */ - OPCODE_RCC, /* 1.1 */ - OPCODE_RCP, /* X X X X X */ - OPCODE_RET, /* 2 2 opt */ - OPCODE_RFL, /* X X */ - OPCODE_RSQ, /* X X X X X */ - OPCODE_SCS, /* X X */ - OPCODE_SEQ, /* 2 X X */ - OPCODE_SFL, /* 2 X */ - OPCODE_SGE, /* X X X X X */ - OPCODE_SGT, /* 2 X X */ - OPCODE_SIN, /* X 2 X X */ - OPCODE_SLE, /* 2 X X */ - OPCODE_SLT, /* X X X X X */ - OPCODE_SNE, /* 2 X X */ - OPCODE_SSG, /* 2 X */ - OPCODE_STR, /* 2 X */ - OPCODE_SUB, /* X X 1.1 X X */ - OPCODE_SWZ, /* X X X */ - OPCODE_TEX, /* X 3 X X */ - OPCODE_TXB, /* X 3 X */ - OPCODE_TXD, /* X X */ - OPCODE_TXL, /* 3 2 X */ - OPCODE_TXP, /* X X */ - OPCODE_TXP_NV, /* 3 X */ - OPCODE_TRUNC, /* X */ - OPCODE_UP2H, /* X */ - OPCODE_UP2US, /* X */ - OPCODE_UP4B, /* X */ - OPCODE_UP4UB, /* X */ - OPCODE_X2D, /* X */ - OPCODE_XOR, /* */ - OPCODE_XPD, /* X X */ - MAX_OPCODE -} gl_inst_opcode; - - -/** - * Number of bits for the src/dst register Index field. - * This limits the size of temp/uniform register files. - */ -#define INST_INDEX_BITS 12 - - -/** - * Instruction source register. - */ -struct prog_src_register -{ - GLuint File:4; /**< One of the PROGRAM_* register file values. */ - GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. - * May be negative for relative addressing. - */ - GLuint Swizzle:12; - GLuint RelAddr:1; - - /** Take the component-wise absolute value */ - GLuint Abs:1; - - /** - * Post-Abs negation. - * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ - * instruction which allows per-component negation. - */ - GLuint Negate:4; - - /** - * Is the register two-dimensional. - * Two dimensional registers are of the - * REGISTER[index][index2] format. - * They are used by the geometry shaders where - * the first index is the index within an array - * and the second index is the semantic of the - * array, e.g. gl_PositionIn[index] would become - * INPUT[index][gl_PositionIn] - */ - GLuint HasIndex2:1; - GLuint RelAddr2:1; - GLint Index2:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. - * May be negative for relative - * addressing. */ -}; - - -/** - * Instruction destination register. - */ -struct prog_dst_register -{ - GLuint File:4; /**< One of the PROGRAM_* register file values */ - GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */ - GLuint WriteMask:4; - GLuint RelAddr:1; - - /** - * \name Conditional destination update control. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - /*@{*/ - /** - * Takes one of the 9 possible condition values (EQ, FL, GT, GE, LE, LT, - * NE, TR, or UN). Dest reg is only written to if the matching - * (swizzled) condition code value passes. When a conditional update mask - * is not specified, this will be \c COND_TR. - */ - GLuint CondMask:4; - - /** - * Condition code swizzle value. - */ - GLuint CondSwizzle:12; - - /** - * Selects the condition code register to use for conditional destination - * update masking. In NV_fragmnet_program or NV_vertex_program2 mode, only - * condition code register 0 is available. In NV_vertex_program3 mode, - * condition code registers 0 and 1 are available. - */ - GLuint CondSrc:1; - /*@}*/ -}; - - -/** - * Vertex/fragment program instruction. - */ -struct prog_instruction -{ - gl_inst_opcode Opcode; - struct prog_src_register SrcReg[3]; - struct prog_dst_register DstReg; - - /** - * Indicates that the instruction should update the condition code - * register. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - GLuint CondUpdate:1; - - /** - * If prog_instruction::CondUpdate is \c GL_TRUE, this value selects the - * condition code register that is to be updated. - * - * In GL_NV_fragment_program or GL_NV_vertex_program2 mode, only condition - * code register 0 is available. In GL_NV_vertex_program3 mode, condition - * code registers 0 and 1 are available. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program2, - * NV_vertex_program2_option. - */ - GLuint CondDst:1; - - /** - * Saturate each value of the vectored result to the range [0,1] or the - * range [-1,1]. \c SSAT mode (i.e., saturation to the range [-1,1]) is - * only available in NV_fragment_program2 mode. - * Value is one of the SATURATE_* tokens. - * - * \since - * NV_fragment_program, NV_fragment_program_option, NV_vertex_program3. - */ - GLuint SaturateMode:2; - - /** - * Per-instruction selectable precision: FLOAT32, FLOAT16, FIXED12. - * - * \since - * NV_fragment_program, NV_fragment_program_option. - */ - GLuint Precision:3; - - /** - * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions. - */ - /*@{*/ - /** Source texture unit. */ - GLuint TexSrcUnit:5; - - /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */ - GLuint TexSrcTarget:4; - - /** True if tex instruction should do shadow comparison */ - GLuint TexShadow:1; - /*@}*/ - - /** - * For BRA and CAL instructions, the location to jump to. - * For BGNLOOP, points to ENDLOOP (and vice-versa). - * For BRK, points to ENDLOOP - * For IF, points to ELSE or ENDIF. - * For ELSE, points to ENDIF. - */ - GLint BranchTarget; - - /** for debugging purposes */ - const char *Comment; - - /** Arbitrary data. Used for OPCODE_PRINT and some drivers */ - void *Data; - - /** for driver use (try to remove someday) */ - GLint Aux; -}; - - -extern void -_mesa_init_instructions(struct prog_instruction *inst, GLuint count); - -extern struct prog_instruction * -_mesa_alloc_instructions(GLuint numInst); - -extern struct prog_instruction * -_mesa_realloc_instructions(struct prog_instruction *oldInst, - GLuint numOldInst, GLuint numNewInst); - -extern struct prog_instruction * -_mesa_copy_instructions(struct prog_instruction *dest, - const struct prog_instruction *src, GLuint n); - -extern void -_mesa_free_instructions(struct prog_instruction *inst, GLuint count); - -extern GLuint -_mesa_num_inst_src_regs(gl_inst_opcode opcode); - -extern GLuint -_mesa_num_inst_dst_regs(gl_inst_opcode opcode); - -extern GLboolean -_mesa_is_tex_instruction(gl_inst_opcode opcode); - -extern GLboolean -_mesa_check_soa_dependencies(const struct prog_instruction *inst); - -extern const char * -_mesa_opcode_string(gl_inst_opcode opcode); - - -#endif /* PROG_INSTRUCTION_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_noise.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_noise.c deleted file mode 100644 index 1713ddb5f34..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_noise.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 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. - */ - -/* - * SimplexNoise1234 - * Copyright (c) 2003-2005, Stefan Gustavson - * - * Contact: stegu@itn.liu.se - */ - -/** - * \file - * \brief C implementation of Perlin Simplex Noise over 1, 2, 3 and 4 dims. - * \author Stefan Gustavson (stegu@itn.liu.se) - * - * - * This implementation is "Simplex Noise" as presented by - * Ken Perlin at a relatively obscure and not often cited course - * session "Real-Time Shading" at Siggraph 2001 (before real - * time shading actually took on), under the title "hardware noise". - * The 3D function is numerically equivalent to his Java reference - * code available in the PDF course notes, although I re-implemented - * it from scratch to get more readable code. The 1D, 2D and 4D cases - * were implemented from scratch by me from Ken Perlin's text. - * - * This file has no dependencies on any other file, not even its own - * header file. The header file is made for use by external code only. - */ - - -#include "main/imports.h" -#include "prog_noise.h" - -#define FASTFLOOR(x) ( ((x)>0) ? ((int)x) : (((int)x)-1) ) - -/* - * --------------------------------------------------------------------- - * Static data - */ - -/** - * Permutation table. This is just a random jumble of all numbers 0-255, - * repeated twice to avoid wrapping the index at 255 for each lookup. - * This needs to be exactly the same for all instances on all platforms, - * so it's easiest to just keep it as static explicit data. - * This also removes the need for any initialisation of this class. - * - * Note that making this an int[] instead of a char[] might make the - * code run faster on platforms with a high penalty for unaligned single - * byte addressing. Intel x86 is generally single-byte-friendly, but - * some other CPUs are faster with 4-aligned reads. - * However, a char[] is smaller, which avoids cache trashing, and that - * is probably the most important aspect on most architectures. - * This array is accessed a *lot* by the noise functions. - * A vector-valued noise over 3D accesses it 96 times, and a - * float-valued 4D noise 64 times. We want this to fit in the cache! - */ -unsigned char perm[512] = { 151, 160, 137, 91, 90, 15, - 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, - 99, 37, 240, 21, 10, 23, - 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, - 11, 32, 57, 177, 33, - 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, - 134, 139, 48, 27, 166, - 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, - 55, 46, 245, 40, 244, - 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, - 18, 169, 200, 196, - 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, - 226, 250, 124, 123, - 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, - 17, 182, 189, 28, 42, - 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, - 167, 43, 172, 9, - 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, - 218, 246, 97, 228, - 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, - 249, 14, 239, 107, - 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, - 127, 4, 150, 254, - 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, - 215, 61, 156, 180, - 151, 160, 137, 91, 90, 15, - 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, - 99, 37, 240, 21, 10, 23, - 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, - 11, 32, 57, 177, 33, - 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, - 134, 139, 48, 27, 166, - 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, - 55, 46, 245, 40, 244, - 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, - 18, 169, 200, 196, - 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, - 226, 250, 124, 123, - 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, - 17, 182, 189, 28, 42, - 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, - 167, 43, 172, 9, - 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, - 218, 246, 97, 228, - 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, - 249, 14, 239, 107, - 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, - 127, 4, 150, 254, - 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, - 215, 61, 156, 180 -}; - -/* - * --------------------------------------------------------------------- - */ - -/* - * Helper functions to compute gradients-dot-residualvectors (1D to 4D) - * Note that these generate gradients of more than unit length. To make - * a close match with the value range of classic Perlin noise, the final - * noise values need to be rescaled to fit nicely within [-1,1]. - * (The simplex noise functions as such also have different scaling.) - * Note also that these noise functions are the most practical and useful - * signed version of Perlin noise. To return values according to the - * RenderMan specification from the SL noise() and pnoise() functions, - * the noise values need to be scaled and offset to [0,1], like this: - * float SLnoise = (SimplexNoise1234::noise(x,y,z) + 1.0) * 0.5; - */ - -static float -grad1(int hash, float x) -{ - int h = hash & 15; - float grad = 1.0f + (h & 7); /* Gradient value 1.0, 2.0, ..., 8.0 */ - if (h & 8) - grad = -grad; /* Set a random sign for the gradient */ - return (grad * x); /* Multiply the gradient with the distance */ -} - -static float -grad2(int hash, float x, float y) -{ - int h = hash & 7; /* Convert low 3 bits of hash code */ - float u = h < 4 ? x : y; /* into 8 simple gradient directions, */ - float v = h < 4 ? y : x; /* and compute the dot product with (x,y). */ - return ((h & 1) ? -u : u) + ((h & 2) ? -2.0f * v : 2.0f * v); -} - -static float -grad3(int hash, float x, float y, float z) -{ - int h = hash & 15; /* Convert low 4 bits of hash code into 12 simple */ - float u = h < 8 ? x : y; /* gradient directions, and compute dot product. */ - float v = h < 4 ? y : h == 12 || h == 14 ? x : z; /* Fix repeats at h = 12 to 15 */ - return ((h & 1) ? -u : u) + ((h & 2) ? -v : v); -} - -static float -grad4(int hash, float x, float y, float z, float t) -{ - int h = hash & 31; /* Convert low 5 bits of hash code into 32 simple */ - float u = h < 24 ? x : y; /* gradient directions, and compute dot product. */ - float v = h < 16 ? y : z; - float w = h < 8 ? z : t; - return ((h & 1) ? -u : u) + ((h & 2) ? -v : v) + ((h & 4) ? -w : w); -} - -/** - * A lookup table to traverse the simplex around a given point in 4D. - * Details can be found where this table is used, in the 4D noise method. - * TODO: This should not be required, backport it from Bill's GLSL code! - */ -static unsigned char simplex[64][4] = { - {0, 1, 2, 3}, {0, 1, 3, 2}, {0, 0, 0, 0}, {0, 2, 3, 1}, - {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 2, 3, 0}, - {0, 2, 1, 3}, {0, 0, 0, 0}, {0, 3, 1, 2}, {0, 3, 2, 1}, - {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {1, 3, 2, 0}, - {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, - {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, - {1, 2, 0, 3}, {0, 0, 0, 0}, {1, 3, 0, 2}, {0, 0, 0, 0}, - {0, 0, 0, 0}, {0, 0, 0, 0}, {2, 3, 0, 1}, {2, 3, 1, 0}, - {1, 0, 2, 3}, {1, 0, 3, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, - {0, 0, 0, 0}, {2, 0, 3, 1}, {0, 0, 0, 0}, {2, 1, 3, 0}, - {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, - {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, - {2, 0, 1, 3}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, - {3, 0, 1, 2}, {3, 0, 2, 1}, {0, 0, 0, 0}, {3, 1, 2, 0}, - {2, 1, 0, 3}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, - {3, 1, 0, 2}, {0, 0, 0, 0}, {3, 2, 0, 1}, {3, 2, 1, 0} -}; - - -/** 1D simplex noise */ -GLfloat -_mesa_noise1(GLfloat x) -{ - int i0 = FASTFLOOR(x); - int i1 = i0 + 1; - float x0 = x - i0; - float x1 = x0 - 1.0f; - float t1 = 1.0f - x1 * x1; - float n0, n1; - - float t0 = 1.0f - x0 * x0; -/* if(t0 < 0.0f) t0 = 0.0f; // this never happens for the 1D case */ - t0 *= t0; - n0 = t0 * t0 * grad1(perm[i0 & 0xff], x0); - -/* if(t1 < 0.0f) t1 = 0.0f; // this never happens for the 1D case */ - t1 *= t1; - n1 = t1 * t1 * grad1(perm[i1 & 0xff], x1); - /* The maximum value of this noise is 8*(3/4)^4 = 2.53125 */ - /* A factor of 0.395 would scale to fit exactly within [-1,1], but */ - /* we want to match PRMan's 1D noise, so we scale it down some more. */ - return 0.25f * (n0 + n1); -} - - -/** 2D simplex noise */ -GLfloat -_mesa_noise2(GLfloat x, GLfloat y) -{ -#define F2 0.366025403f /* F2 = 0.5*(sqrt(3.0)-1.0) */ -#define G2 0.211324865f /* G2 = (3.0-Math.sqrt(3.0))/6.0 */ - - float n0, n1, n2; /* Noise contributions from the three corners */ - - /* Skew the input space to determine which simplex cell we're in */ - float s = (x + y) * F2; /* Hairy factor for 2D */ - float xs = x + s; - float ys = y + s; - int i = FASTFLOOR(xs); - int j = FASTFLOOR(ys); - - float t = (float) (i + j) * G2; - float X0 = i - t; /* Unskew the cell origin back to (x,y) space */ - float Y0 = j - t; - float x0 = x - X0; /* The x,y distances from the cell origin */ - float y0 = y - Y0; - - float x1, y1, x2, y2; - int ii, jj; - float t0, t1, t2; - - /* For the 2D case, the simplex shape is an equilateral triangle. */ - /* Determine which simplex we are in. */ - int i1, j1; /* Offsets for second (middle) corner of simplex in (i,j) coords */ - if (x0 > y0) { - i1 = 1; - j1 = 0; - } /* lower triangle, XY order: (0,0)->(1,0)->(1,1) */ - else { - i1 = 0; - j1 = 1; - } /* upper triangle, YX order: (0,0)->(0,1)->(1,1) */ - - /* A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and */ - /* a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where */ - /* c = (3-sqrt(3))/6 */ - - x1 = x0 - i1 + G2; /* Offsets for middle corner in (x,y) unskewed coords */ - y1 = y0 - j1 + G2; - x2 = x0 - 1.0f + 2.0f * G2; /* Offsets for last corner in (x,y) unskewed coords */ - y2 = y0 - 1.0f + 2.0f * G2; - - /* Wrap the integer indices at 256, to avoid indexing perm[] out of bounds */ - ii = i % 256; - jj = j % 256; - - /* Calculate the contribution from the three corners */ - t0 = 0.5f - x0 * x0 - y0 * y0; - if (t0 < 0.0f) - n0 = 0.0f; - else { - t0 *= t0; - n0 = t0 * t0 * grad2(perm[ii + perm[jj]], x0, y0); - } - - t1 = 0.5f - x1 * x1 - y1 * y1; - if (t1 < 0.0f) - n1 = 0.0f; - else { - t1 *= t1; - n1 = t1 * t1 * grad2(perm[ii + i1 + perm[jj + j1]], x1, y1); - } - - t2 = 0.5f - x2 * x2 - y2 * y2; - if (t2 < 0.0f) - n2 = 0.0f; - else { - t2 *= t2; - n2 = t2 * t2 * grad2(perm[ii + 1 + perm[jj + 1]], x2, y2); - } - - /* Add contributions from each corner to get the final noise value. */ - /* The result is scaled to return values in the interval [-1,1]. */ - return 40.0f * (n0 + n1 + n2); /* TODO: The scale factor is preliminary! */ -} - - -/** 3D simplex noise */ -GLfloat -_mesa_noise3(GLfloat x, GLfloat y, GLfloat z) -{ -/* Simple skewing factors for the 3D case */ -#define F3 0.333333333f -#define G3 0.166666667f - - float n0, n1, n2, n3; /* Noise contributions from the four corners */ - - /* Skew the input space to determine which simplex cell we're in */ - float s = (x + y + z) * F3; /* Very nice and simple skew factor for 3D */ - float xs = x + s; - float ys = y + s; - float zs = z + s; - int i = FASTFLOOR(xs); - int j = FASTFLOOR(ys); - int k = FASTFLOOR(zs); - - float t = (float) (i + j + k) * G3; - float X0 = i - t; /* Unskew the cell origin back to (x,y,z) space */ - float Y0 = j - t; - float Z0 = k - t; - float x0 = x - X0; /* The x,y,z distances from the cell origin */ - float y0 = y - Y0; - float z0 = z - Z0; - - float x1, y1, z1, x2, y2, z2, x3, y3, z3; - int ii, jj, kk; - float t0, t1, t2, t3; - - /* For the 3D case, the simplex shape is a slightly irregular tetrahedron. */ - /* Determine which simplex we are in. */ - int i1, j1, k1; /* Offsets for second corner of simplex in (i,j,k) coords */ - int i2, j2, k2; /* Offsets for third corner of simplex in (i,j,k) coords */ - -/* This code would benefit from a backport from the GLSL version! */ - if (x0 >= y0) { - if (y0 >= z0) { - i1 = 1; - j1 = 0; - k1 = 0; - i2 = 1; - j2 = 1; - k2 = 0; - } /* X Y Z order */ - else if (x0 >= z0) { - i1 = 1; - j1 = 0; - k1 = 0; - i2 = 1; - j2 = 0; - k2 = 1; - } /* X Z Y order */ - else { - i1 = 0; - j1 = 0; - k1 = 1; - i2 = 1; - j2 = 0; - k2 = 1; - } /* Z X Y order */ - } - else { /* x0 y0) ? 32 : 0; - int c2 = (x0 > z0) ? 16 : 0; - int c3 = (y0 > z0) ? 8 : 0; - int c4 = (x0 > w0) ? 4 : 0; - int c5 = (y0 > w0) ? 2 : 0; - int c6 = (z0 > w0) ? 1 : 0; - int c = c1 + c2 + c3 + c4 + c5 + c6; - - int i1, j1, k1, l1; /* The integer offsets for the second simplex corner */ - int i2, j2, k2, l2; /* The integer offsets for the third simplex corner */ - int i3, j3, k3, l3; /* The integer offsets for the fourth simplex corner */ - - float x1, y1, z1, w1, x2, y2, z2, w2, x3, y3, z3, w3, x4, y4, z4, w4; - int ii, jj, kk, ll; - float t0, t1, t2, t3, t4; - - /* - * simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some - * order. Many values of c will never occur, since e.g. x>y>z>w - * makes x= 3 ? 1 : 0; - j1 = simplex[c][1] >= 3 ? 1 : 0; - k1 = simplex[c][2] >= 3 ? 1 : 0; - l1 = simplex[c][3] >= 3 ? 1 : 0; - /* The number 2 in the "simplex" array is at the second largest coordinate. */ - i2 = simplex[c][0] >= 2 ? 1 : 0; - j2 = simplex[c][1] >= 2 ? 1 : 0; - k2 = simplex[c][2] >= 2 ? 1 : 0; - l2 = simplex[c][3] >= 2 ? 1 : 0; - /* The number 1 in the "simplex" array is at the second smallest coordinate. */ - i3 = simplex[c][0] >= 1 ? 1 : 0; - j3 = simplex[c][1] >= 1 ? 1 : 0; - k3 = simplex[c][2] >= 1 ? 1 : 0; - l3 = simplex[c][3] >= 1 ? 1 : 0; - /* The fifth corner has all coordinate offsets = 1, so no need to look that up. */ - - x1 = x0 - i1 + G4; /* Offsets for second corner in (x,y,z,w) coords */ - y1 = y0 - j1 + G4; - z1 = z0 - k1 + G4; - w1 = w0 - l1 + G4; - x2 = x0 - i2 + 2.0f * G4; /* Offsets for third corner in (x,y,z,w) coords */ - y2 = y0 - j2 + 2.0f * G4; - z2 = z0 - k2 + 2.0f * G4; - w2 = w0 - l2 + 2.0f * G4; - x3 = x0 - i3 + 3.0f * G4; /* Offsets for fourth corner in (x,y,z,w) coords */ - y3 = y0 - j3 + 3.0f * G4; - z3 = z0 - k3 + 3.0f * G4; - w3 = w0 - l3 + 3.0f * G4; - x4 = x0 - 1.0f + 4.0f * G4; /* Offsets for last corner in (x,y,z,w) coords */ - y4 = y0 - 1.0f + 4.0f * G4; - z4 = z0 - 1.0f + 4.0f * G4; - w4 = w0 - 1.0f + 4.0f * G4; - - /* Wrap the integer indices at 256, to avoid indexing perm[] out of bounds */ - ii = i % 256; - jj = j % 256; - kk = k % 256; - ll = l % 256; - - /* Calculate the contribution from the five corners */ - t0 = 0.6f - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; - if (t0 < 0.0f) - n0 = 0.0f; - else { - t0 *= t0; - n0 = - t0 * t0 * grad4(perm[ii + perm[jj + perm[kk + perm[ll]]]], x0, y0, - z0, w0); - } - - t1 = 0.6f - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; - if (t1 < 0.0f) - n1 = 0.0f; - else { - t1 *= t1; - n1 = - t1 * t1 * - grad4(perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]], - x1, y1, z1, w1); - } - - t2 = 0.6f - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; - if (t2 < 0.0f) - n2 = 0.0f; - else { - t2 *= t2; - n2 = - t2 * t2 * - grad4(perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]], - x2, y2, z2, w2); - } - - t3 = 0.6f - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; - if (t3 < 0.0f) - n3 = 0.0f; - else { - t3 *= t3; - n3 = - t3 * t3 * - grad4(perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]], - x3, y3, z3, w3); - } - - t4 = 0.6f - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; - if (t4 < 0.0f) - n4 = 0.0f; - else { - t4 *= t4; - n4 = - t4 * t4 * - grad4(perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]], x4, - y4, z4, w4); - } - - /* Sum up and scale the result to cover the range [-1,1] */ - return 27.0f * (n0 + n1 + n2 + n3 + n4); /* TODO: The scale factor is preliminary! */ -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_noise.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_noise.h deleted file mode 100644 index dd7986efcdb..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_noise.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 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 PROG_NOISE -#define PROG_NOISE - -#include "main/glheader.h" - -extern GLfloat _mesa_noise1(GLfloat); -extern GLfloat _mesa_noise2(GLfloat, GLfloat); -extern GLfloat _mesa_noise3(GLfloat, GLfloat, GLfloat); -extern GLfloat _mesa_noise4(GLfloat, GLfloat, GLfloat, GLfloat); - -#endif - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_opt_constant_fold.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_opt_constant_fold.c deleted file mode 100644 index e2418b55451..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_opt_constant_fold.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "program.h" -#include "prog_instruction.h" -#include "prog_optimize.h" -#include "prog_parameter.h" -#include - -static bool -src_regs_are_constant(const struct prog_instruction *inst, unsigned num_srcs) -{ - unsigned i; - - for (i = 0; i < num_srcs; i++) { - if (inst->SrcReg[i].File != PROGRAM_CONSTANT) - return false; - } - - return true; -} - -static struct prog_src_register -src_reg_for_float(struct gl_program *prog, float val) -{ - struct prog_src_register src; - unsigned swiz; - - memset(&src, 0, sizeof(src)); - - src.File = PROGRAM_CONSTANT; - src.Index = _mesa_add_unnamed_constant(prog->Parameters, - (gl_constant_value *) &val, 1, &swiz); - src.Swizzle = swiz; - return src; -} - -static struct prog_src_register -src_reg_for_vec4(struct gl_program *prog, const float *val) -{ - struct prog_src_register src; - unsigned swiz; - - memset(&src, 0, sizeof(src)); - - src.File = PROGRAM_CONSTANT; - src.Index = _mesa_add_unnamed_constant(prog->Parameters, - (gl_constant_value *) val, 4, &swiz); - src.Swizzle = swiz; - return src; -} - -static bool -src_regs_are_same(const struct prog_src_register *a, - const struct prog_src_register *b) -{ - return (a->File == b->File) - && (a->Index == b->Index) - && (a->Swizzle == b->Swizzle) - && (a->Abs == b->Abs) - && (a->Negate == b->Negate) - && (a->RelAddr == 0) - && (b->RelAddr == 0); -} - -static void -get_value(struct gl_program *prog, struct prog_src_register *r, float *data) -{ - const gl_constant_value *const value = - prog->Parameters->ParameterValues[r->Index]; - - data[0] = value[GET_SWZ(r->Swizzle, 0)].f; - data[1] = value[GET_SWZ(r->Swizzle, 1)].f; - data[2] = value[GET_SWZ(r->Swizzle, 2)].f; - data[3] = value[GET_SWZ(r->Swizzle, 3)].f; - - if (r->Abs) { - data[0] = fabsf(data[0]); - data[1] = fabsf(data[1]); - data[2] = fabsf(data[2]); - data[3] = fabsf(data[3]); - } - - if (r->Negate & 0x01) { - data[0] = -data[0]; - } - - if (r->Negate & 0x02) { - data[1] = -data[1]; - } - - if (r->Negate & 0x04) { - data[2] = -data[2]; - } - - if (r->Negate & 0x08) { - data[3] = -data[3]; - } -} - -/** - * Try to replace instructions that produce a constant result with simple moves - * - * The hope is that a following copy propagation pass will eliminate the - * unnecessary move instructions. - */ -GLboolean -_mesa_constant_fold(struct gl_program *prog) -{ - bool progress = false; - unsigned i; - - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *const inst = &prog->Instructions[i]; - - switch (inst->Opcode) { - case OPCODE_ADD: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = a[0] + b[0]; - result[1] = a[1] + b[1]; - result[2] = a[2] + b[2]; - result[3] = a[3] + b[3]; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_CMP: - /* FINISHME: We could also optimize CMP instructions where the first - * FINISHME: source is a constant that is either all < 0.0 or all - * FINISHME: >= 0.0. - */ - if (src_regs_are_constant(inst, 3)) { - float a[4]; - float b[4]; - float c[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - get_value(prog, &inst->SrcReg[2], c); - - result[0] = a[0] < 0.0f ? b[0] : c[0]; - result[1] = a[1] < 0.0f ? b[1] : c[1]; - result[2] = a[2] < 0.0f ? b[2] : c[2]; - result[3] = a[3] < 0.0f ? b[3] : c[3]; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - inst->SrcReg[2].File = PROGRAM_UNDEFINED; - inst->SrcReg[2].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_DP2: - case OPCODE_DP3: - case OPCODE_DP4: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - /* It seems like a loop could be used here, but we cleverly put - * DP2A between DP2 and DP3. Subtracting DP2 (or similar) from - * the opcode results in various failures of the loop control. - */ - result = (a[0] * b[0]) + (a[1] * b[1]); - - if (inst->Opcode >= OPCODE_DP3) - result += a[2] * b[2]; - - if (inst->Opcode == OPCODE_DP4) - result += a[3] * b[3]; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_float(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_MUL: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = a[0] * b[0]; - result[1] = a[1] * b[1]; - result[2] = a[2] * b[2]; - result[3] = a[3] * b[3]; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_SEQ: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = (a[0] == b[0]) ? 1.0f : 0.0f; - result[1] = (a[1] == b[1]) ? 1.0f : 0.0f; - result[2] = (a[2] == b[2]) ? 1.0f : 0.0f; - result[3] = (a[3] == b[3]) ? 1.0f : 0.0f; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) { - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_float(prog, 1.0f); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_SGE: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = (a[0] >= b[0]) ? 1.0f : 0.0f; - result[1] = (a[1] >= b[1]) ? 1.0f : 0.0f; - result[2] = (a[2] >= b[2]) ? 1.0f : 0.0f; - result[3] = (a[3] >= b[3]) ? 1.0f : 0.0f; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) { - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_float(prog, 1.0f); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_SGT: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = (a[0] > b[0]) ? 1.0f : 0.0f; - result[1] = (a[1] > b[1]) ? 1.0f : 0.0f; - result[2] = (a[2] > b[2]) ? 1.0f : 0.0f; - result[3] = (a[3] > b[3]) ? 1.0f : 0.0f; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) { - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_float(prog, 0.0f); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_SLE: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = (a[0] <= b[0]) ? 1.0f : 0.0f; - result[1] = (a[1] <= b[1]) ? 1.0f : 0.0f; - result[2] = (a[2] <= b[2]) ? 1.0f : 0.0f; - result[3] = (a[3] <= b[3]) ? 1.0f : 0.0f; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) { - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_float(prog, 1.0f); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_SLT: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = (a[0] < b[0]) ? 1.0f : 0.0f; - result[1] = (a[1] < b[1]) ? 1.0f : 0.0f; - result[2] = (a[2] < b[2]) ? 1.0f : 0.0f; - result[3] = (a[3] < b[3]) ? 1.0f : 0.0f; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) { - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_float(prog, 0.0f); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - case OPCODE_SNE: - if (src_regs_are_constant(inst, 2)) { - float a[4]; - float b[4]; - float result[4]; - - get_value(prog, &inst->SrcReg[0], a); - get_value(prog, &inst->SrcReg[1], b); - - result[0] = (a[0] != b[0]) ? 1.0f : 0.0f; - result[1] = (a[1] != b[1]) ? 1.0f : 0.0f; - result[2] = (a[2] != b[2]) ? 1.0f : 0.0f; - result[3] = (a[3] != b[3]) ? 1.0f : 0.0f; - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_vec4(prog, result); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) { - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = src_reg_for_float(prog, 0.0f); - - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - - progress = true; - } - break; - - default: - break; - } - } - - return progress; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.c deleted file mode 100644 index 25d9684b137..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.c +++ /dev/null @@ -1,1366 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. 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 - * VMWARE 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. - */ - - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "program.h" -#include "prog_instruction.h" -#include "prog_optimize.h" -#include "prog_print.h" - - -#define MAX_LOOP_NESTING 50 -/* MAX_PROGRAM_TEMPS is a low number (256), and we want to be able to - * register allocate many temporary values into that small number of - * temps. So allow large temporary indices coming into the register - * allocator. - */ -#define REG_ALLOCATE_MAX_PROGRAM_TEMPS ((1 << INST_INDEX_BITS) - 1) - -static GLboolean dbg = GL_FALSE; - -#define NO_MASK 0xf - -/** - * Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which - * are read from the given src in this instruction, We also provide - * one optional masks which may mask other components in the dst - * register - */ -static GLuint -get_src_arg_mask(const struct prog_instruction *inst, - GLuint arg, GLuint dst_mask) -{ - GLuint read_mask, channel_mask; - GLuint comp; - - ASSERT(arg < _mesa_num_inst_src_regs(inst->Opcode)); - - /* Form the dst register, find the written channels */ - if (inst->CondUpdate) { - channel_mask = WRITEMASK_XYZW; - } - else { - switch (inst->Opcode) { - case OPCODE_MOV: - case OPCODE_MIN: - case OPCODE_MAX: - case OPCODE_ABS: - case OPCODE_ADD: - case OPCODE_MAD: - case OPCODE_MUL: - case OPCODE_SUB: - case OPCODE_CMP: - case OPCODE_FLR: - case OPCODE_FRC: - case OPCODE_LRP: - case OPCODE_SEQ: - case OPCODE_SGE: - case OPCODE_SGT: - case OPCODE_SLE: - case OPCODE_SLT: - case OPCODE_SNE: - case OPCODE_SSG: - channel_mask = inst->DstReg.WriteMask & dst_mask; - break; - case OPCODE_RCP: - case OPCODE_SIN: - case OPCODE_COS: - case OPCODE_RSQ: - case OPCODE_POW: - case OPCODE_EX2: - case OPCODE_LOG: - channel_mask = WRITEMASK_X; - break; - case OPCODE_DP2: - channel_mask = WRITEMASK_XY; - break; - case OPCODE_DP3: - case OPCODE_XPD: - channel_mask = WRITEMASK_XYZ; - break; - default: - channel_mask = WRITEMASK_XYZW; - break; - } - } - - /* Now, given the src swizzle and the written channels, find which - * components are actually read - */ - read_mask = 0x0; - for (comp = 0; comp < 4; ++comp) { - const GLuint coord = GET_SWZ(inst->SrcReg[arg].Swizzle, comp); - ASSERT(coord < 4); - if (channel_mask & (1 << comp) && coord <= SWIZZLE_W) - read_mask |= 1 << coord; - } - - return read_mask; -} - - -/** - * For a MOV instruction, compute a write mask when src register also has - * a mask - */ -static GLuint -get_dst_mask_for_mov(const struct prog_instruction *mov, GLuint src_mask) -{ - const GLuint mask = mov->DstReg.WriteMask; - GLuint comp; - GLuint updated_mask = 0x0; - - ASSERT(mov->Opcode == OPCODE_MOV); - - for (comp = 0; comp < 4; ++comp) { - GLuint src_comp; - if ((mask & (1 << comp)) == 0) - continue; - src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, comp); - if ((src_mask & (1 << src_comp)) == 0) - continue; - updated_mask |= 1 << comp; - } - - return updated_mask; -} - - -/** - * Ensure that the swizzle is regular. That is, all of the swizzle - * terms are SWIZZLE_X,Y,Z,W and not SWIZZLE_ZERO or SWIZZLE_ONE. - */ -static GLboolean -is_swizzle_regular(GLuint swz) -{ - return GET_SWZ(swz,0) <= SWIZZLE_W && - GET_SWZ(swz,1) <= SWIZZLE_W && - GET_SWZ(swz,2) <= SWIZZLE_W && - GET_SWZ(swz,3) <= SWIZZLE_W; -} - - -/** - * In 'prog' remove instruction[i] if removeFlags[i] == TRUE. - * \return number of instructions removed - */ -static GLuint -remove_instructions(struct gl_program *prog, const GLboolean *removeFlags) -{ - GLint i, removeEnd = 0, removeCount = 0; - GLuint totalRemoved = 0; - - /* go backward */ - for (i = prog->NumInstructions - 1; i >= 0; i--) { - if (removeFlags[i]) { - totalRemoved++; - if (removeCount == 0) { - /* begin a run of instructions to remove */ - removeEnd = i; - removeCount = 1; - } - else { - /* extend the run of instructions to remove */ - removeCount++; - } - } - else { - /* don't remove this instruction, but check if the preceeding - * instructions are to be removed. - */ - if (removeCount > 0) { - GLint removeStart = removeEnd - removeCount + 1; - _mesa_delete_instructions(prog, removeStart, removeCount); - removeStart = removeCount = 0; /* reset removal info */ - } - } - } - /* Finish removing if the first instruction was to be removed. */ - if (removeCount > 0) { - GLint removeStart = removeEnd - removeCount + 1; - _mesa_delete_instructions(prog, removeStart, removeCount); - } - return totalRemoved; -} - - -/** - * Remap register indexes according to map. - * \param prog the program to search/replace - * \param file the type of register file to search/replace - * \param map maps old register indexes to new indexes - */ -static void -replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[]) -{ - GLuint i; - - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode); - GLuint j; - for (j = 0; j < numSrc; j++) { - if (inst->SrcReg[j].File == file) { - GLuint index = inst->SrcReg[j].Index; - ASSERT(map[index] >= 0); - inst->SrcReg[j].Index = map[index]; - } - } - if (inst->DstReg.File == file) { - const GLuint index = inst->DstReg.Index; - ASSERT(map[index] >= 0); - inst->DstReg.Index = map[index]; - } - } -} - - -/** - * Remove dead instructions from the given program. - * This is very primitive for now. Basically look for temp registers - * that are written to but never read. Remove any instructions that - * write to such registers. Be careful with condition code setters. - */ -static GLboolean -_mesa_remove_dead_code_global(struct gl_program *prog) -{ - GLboolean tempRead[REG_ALLOCATE_MAX_PROGRAM_TEMPS][4]; - GLboolean *removeInst; /* per-instruction removal flag */ - GLuint i, rem = 0, comp; - - memset(tempRead, 0, sizeof(tempRead)); - - if (dbg) { - printf("Optimize: Begin dead code removal\n"); - /*_mesa_print_program(prog);*/ - } - - removeInst = (GLboolean *) - calloc(1, prog->NumInstructions * sizeof(GLboolean)); - - /* Determine which temps are read and written */ - for (i = 0; i < prog->NumInstructions; i++) { - const struct prog_instruction *inst = prog->Instructions + i; - const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode); - GLuint j; - - /* check src regs */ - for (j = 0; j < numSrc; j++) { - if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) { - const GLuint index = inst->SrcReg[j].Index; - GLuint read_mask; - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); - read_mask = get_src_arg_mask(inst, j, NO_MASK); - - if (inst->SrcReg[j].RelAddr) { - if (dbg) - printf("abort remove dead code (indirect temp)\n"); - goto done; - } - - for (comp = 0; comp < 4; comp++) { - const GLuint swz = GET_SWZ(inst->SrcReg[j].Swizzle, comp); - ASSERT(swz < 4); - if ((read_mask & (1 << swz)) == 0) - continue; - if (swz <= SWIZZLE_W) - tempRead[index][swz] = GL_TRUE; - } - } - } - - /* check dst reg */ - if (inst->DstReg.File == PROGRAM_TEMPORARY) { - const GLuint index = inst->DstReg.Index; - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); - - if (inst->DstReg.RelAddr) { - if (dbg) - printf("abort remove dead code (indirect temp)\n"); - goto done; - } - - if (inst->CondUpdate) { - /* If we're writing to this register and setting condition - * codes we cannot remove the instruction. Prevent removal - * by setting the 'read' flag. - */ - tempRead[index][0] = GL_TRUE; - tempRead[index][1] = GL_TRUE; - tempRead[index][2] = GL_TRUE; - tempRead[index][3] = GL_TRUE; - } - } - } - - /* find instructions that write to dead registers, flag for removal */ - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - const GLuint numDst = _mesa_num_inst_dst_regs(inst->Opcode); - - if (numDst != 0 && inst->DstReg.File == PROGRAM_TEMPORARY) { - GLint chan, index = inst->DstReg.Index; - - for (chan = 0; chan < 4; chan++) { - if (!tempRead[index][chan] && - inst->DstReg.WriteMask & (1 << chan)) { - if (dbg) { - printf("Remove writemask on %u.%c\n", i, - chan == 3 ? 'w' : 'x' + chan); - } - inst->DstReg.WriteMask &= ~(1 << chan); - rem++; - } - } - - if (inst->DstReg.WriteMask == 0) { - /* If we cleared all writes, the instruction can be removed. */ - if (dbg) - printf("Remove instruction %u: \n", i); - removeInst[i] = GL_TRUE; - } - } - } - - /* now remove the instructions which aren't needed */ - rem = remove_instructions(prog, removeInst); - - if (dbg) { - printf("Optimize: End dead code removal.\n"); - printf(" %u channel writes removed\n", rem); - printf(" %u instructions removed\n", rem); - /*_mesa_print_program(prog);*/ - } - -done: - free(removeInst); - return rem != 0; -} - - -enum inst_use -{ - READ, - WRITE, - FLOW, - END -}; - - -/** - * Scan forward in program from 'start' for the next occurances of TEMP[index]. - * We look if an instruction reads the component given by the masks and if they - * are overwritten. - * Return READ, WRITE, FLOW or END to indicate the next usage or an indicator - * that we can't look further. - */ -static enum inst_use -find_next_use(const struct gl_program *prog, - GLuint start, - GLuint index, - GLuint mask) -{ - GLuint i; - - for (i = start; i < prog->NumInstructions; i++) { - const struct prog_instruction *inst = prog->Instructions + i; - switch (inst->Opcode) { - case OPCODE_BGNLOOP: - case OPCODE_BGNSUB: - case OPCODE_BRA: - case OPCODE_CAL: - case OPCODE_CONT: - case OPCODE_IF: - case OPCODE_ELSE: - case OPCODE_ENDIF: - case OPCODE_ENDLOOP: - case OPCODE_ENDSUB: - case OPCODE_RET: - return FLOW; - case OPCODE_END: - return END; - default: - { - const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode); - GLuint j; - for (j = 0; j < numSrc; j++) { - if (inst->SrcReg[j].RelAddr || - (inst->SrcReg[j].File == PROGRAM_TEMPORARY && - inst->SrcReg[j].Index == index && - (get_src_arg_mask(inst,j,NO_MASK) & mask))) - return READ; - } - if (_mesa_num_inst_dst_regs(inst->Opcode) == 1 && - inst->DstReg.File == PROGRAM_TEMPORARY && - inst->DstReg.Index == index) { - mask &= ~inst->DstReg.WriteMask; - if (mask == 0) - return WRITE; - } - } - } - } - return END; -} - - -/** - * Is the given instruction opcode a flow-control opcode? - * XXX maybe move this into prog_instruction.[ch] - */ -static GLboolean -_mesa_is_flow_control_opcode(enum prog_opcode opcode) -{ - switch (opcode) { - case OPCODE_BGNLOOP: - case OPCODE_BGNSUB: - case OPCODE_BRA: - case OPCODE_CAL: - case OPCODE_CONT: - case OPCODE_IF: - case OPCODE_ELSE: - case OPCODE_END: - case OPCODE_ENDIF: - case OPCODE_ENDLOOP: - case OPCODE_ENDSUB: - case OPCODE_RET: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Test if the given instruction is a simple MOV (no conditional updating, - * not relative addressing, no negation/abs, etc). - */ -static GLboolean -can_downward_mov_be_modifed(const struct prog_instruction *mov) -{ - return - mov->Opcode == OPCODE_MOV && - mov->CondUpdate == GL_FALSE && - mov->SrcReg[0].RelAddr == 0 && - mov->SrcReg[0].Negate == 0 && - mov->SrcReg[0].Abs == 0 && - mov->SrcReg[0].HasIndex2 == 0 && - mov->SrcReg[0].RelAddr2 == 0 && - mov->DstReg.RelAddr == 0 && - mov->DstReg.CondMask == COND_TR; -} - - -static GLboolean -can_upward_mov_be_modifed(const struct prog_instruction *mov) -{ - return - can_downward_mov_be_modifed(mov) && - mov->DstReg.File == PROGRAM_TEMPORARY && - mov->SaturateMode == SATURATE_OFF; -} - - -/** - * Try to remove use of extraneous MOV instructions, to free them up for dead - * code removal. - */ -static void -_mesa_remove_extra_move_use(struct gl_program *prog) -{ - GLuint i, j; - - if (dbg) { - printf("Optimize: Begin remove extra move use\n"); - _mesa_print_program(prog); - } - - /* - * Look for sequences such as this: - * MOV tmpX, arg0; - * ... - * FOO tmpY, tmpX, arg1; - * and convert into: - * MOV tmpX, arg0; - * ... - * FOO tmpY, arg0, arg1; - */ - - for (i = 0; i + 1 < prog->NumInstructions; i++) { - const struct prog_instruction *mov = prog->Instructions + i; - GLuint dst_mask, src_mask; - if (can_upward_mov_be_modifed(mov) == GL_FALSE) - continue; - - /* Scanning the code, we maintain the components which are still active in - * these two masks - */ - dst_mask = mov->DstReg.WriteMask; - src_mask = get_src_arg_mask(mov, 0, NO_MASK); - - /* Walk through remaining instructions until the or src reg gets - * rewritten or we get into some flow-control, eliminating the use of - * this MOV. - */ - for (j = i + 1; j < prog->NumInstructions; j++) { - struct prog_instruction *inst2 = prog->Instructions + j; - GLuint arg; - - if (_mesa_is_flow_control_opcode(inst2->Opcode)) - break; - - /* First rewrite this instruction's args if appropriate. */ - for (arg = 0; arg < _mesa_num_inst_src_regs(inst2->Opcode); arg++) { - GLuint comp, read_mask; - - if (inst2->SrcReg[arg].File != mov->DstReg.File || - inst2->SrcReg[arg].Index != mov->DstReg.Index || - inst2->SrcReg[arg].RelAddr || - inst2->SrcReg[arg].Abs) - continue; - read_mask = get_src_arg_mask(inst2, arg, NO_MASK); - - /* Adjust the swizzles of inst2 to point at MOV's source if ALL the - * components read still come from the mov instructions - */ - if (is_swizzle_regular(inst2->SrcReg[arg].Swizzle) && - (read_mask & dst_mask) == read_mask) { - for (comp = 0; comp < 4; comp++) { - const GLuint inst2_swz = - GET_SWZ(inst2->SrcReg[arg].Swizzle, comp); - const GLuint s = GET_SWZ(mov->SrcReg[0].Swizzle, inst2_swz); - inst2->SrcReg[arg].Swizzle &= ~(7 << (3 * comp)); - inst2->SrcReg[arg].Swizzle |= s << (3 * comp); - inst2->SrcReg[arg].Negate ^= (((mov->SrcReg[0].Negate >> - inst2_swz) & 0x1) << comp); - } - inst2->SrcReg[arg].File = mov->SrcReg[0].File; - inst2->SrcReg[arg].Index = mov->SrcReg[0].Index; - } - } - - /* The source of MOV is written. This potentially deactivates some - * components from the src and dst of the MOV instruction - */ - if (inst2->DstReg.File == mov->DstReg.File && - (inst2->DstReg.RelAddr || - inst2->DstReg.Index == mov->DstReg.Index)) { - dst_mask &= ~inst2->DstReg.WriteMask; - src_mask = get_src_arg_mask(mov, 0, dst_mask); - } - - /* Idem when the destination of mov is written */ - if (inst2->DstReg.File == mov->SrcReg[0].File && - (inst2->DstReg.RelAddr || - inst2->DstReg.Index == mov->SrcReg[0].Index)) { - src_mask &= ~inst2->DstReg.WriteMask; - dst_mask &= get_dst_mask_for_mov(mov, src_mask); - } - if (dst_mask == 0) - break; - } - } - - if (dbg) { - printf("Optimize: End remove extra move use.\n"); - /*_mesa_print_program(prog);*/ - } -} - - -/** - * Complements dead_code_global. Try to remove code in block of code by - * carefully monitoring the swizzles. Both functions should be merged into one - * with a proper control flow graph - */ -static GLboolean -_mesa_remove_dead_code_local(struct gl_program *prog) -{ - GLboolean *removeInst; - GLuint i, arg, rem = 0; - - removeInst = (GLboolean *) - calloc(1, prog->NumInstructions * sizeof(GLboolean)); - - for (i = 0; i < prog->NumInstructions; i++) { - const struct prog_instruction *inst = prog->Instructions + i; - const GLuint index = inst->DstReg.Index; - const GLuint mask = inst->DstReg.WriteMask; - enum inst_use use; - - /* We must deactivate the pass as soon as some indirection is used */ - if (inst->DstReg.RelAddr) - goto done; - for (arg = 0; arg < _mesa_num_inst_src_regs(inst->Opcode); arg++) - if (inst->SrcReg[arg].RelAddr) - goto done; - - if (_mesa_is_flow_control_opcode(inst->Opcode) || - _mesa_num_inst_dst_regs(inst->Opcode) == 0 || - inst->DstReg.File != PROGRAM_TEMPORARY || - inst->DstReg.RelAddr) - continue; - - use = find_next_use(prog, i+1, index, mask); - if (use == WRITE || use == END) - removeInst[i] = GL_TRUE; - } - - rem = remove_instructions(prog, removeInst); - -done: - free(removeInst); - return rem != 0; -} - - -/** - * Try to inject the destination of mov as the destination of inst and recompute - * the swizzles operators for the sources of inst if required. Return GL_TRUE - * of the substitution was possible, GL_FALSE otherwise - */ -static GLboolean -_mesa_merge_mov_into_inst(struct prog_instruction *inst, - const struct prog_instruction *mov) -{ - /* Indirection table which associates destination and source components for - * the mov instruction - */ - const GLuint mask = get_src_arg_mask(mov, 0, NO_MASK); - - /* Some components are not written by inst. We cannot remove the mov */ - if (mask != (inst->DstReg.WriteMask & mask)) - return GL_FALSE; - - inst->SaturateMode |= mov->SaturateMode; - - /* Depending on the instruction, we may need to recompute the swizzles. - * Also, some other instructions (like TEX) are not linear. We will only - * consider completely active sources and destinations - */ - switch (inst->Opcode) { - - /* Carstesian instructions: we compute the swizzle */ - case OPCODE_MOV: - case OPCODE_MIN: - case OPCODE_MAX: - case OPCODE_ABS: - case OPCODE_ADD: - case OPCODE_MAD: - case OPCODE_MUL: - case OPCODE_SUB: - { - GLuint dst_to_src_comp[4] = {0,0,0,0}; - GLuint dst_comp, arg; - for (dst_comp = 0; dst_comp < 4; ++dst_comp) { - if (mov->DstReg.WriteMask & (1 << dst_comp)) { - const GLuint src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, dst_comp); - ASSERT(src_comp < 4); - dst_to_src_comp[dst_comp] = src_comp; - } - } - - /* Patch each source of the instruction */ - for (arg = 0; arg < _mesa_num_inst_src_regs(inst->Opcode); arg++) { - const GLuint arg_swz = inst->SrcReg[arg].Swizzle; - inst->SrcReg[arg].Swizzle = 0; - - /* Reset each active component of the swizzle */ - for (dst_comp = 0; dst_comp < 4; ++dst_comp) { - GLuint src_comp, arg_comp; - if ((mov->DstReg.WriteMask & (1 << dst_comp)) == 0) - continue; - src_comp = dst_to_src_comp[dst_comp]; - ASSERT(src_comp < 4); - arg_comp = GET_SWZ(arg_swz, src_comp); - ASSERT(arg_comp < 4); - inst->SrcReg[arg].Swizzle |= arg_comp << (3*dst_comp); - } - } - inst->DstReg = mov->DstReg; - return GL_TRUE; - } - - /* Dot products and scalar instructions: we only change the destination */ - case OPCODE_RCP: - case OPCODE_SIN: - case OPCODE_COS: - case OPCODE_RSQ: - case OPCODE_POW: - case OPCODE_EX2: - case OPCODE_LOG: - case OPCODE_DP2: - case OPCODE_DP3: - case OPCODE_DP4: - inst->DstReg = mov->DstReg; - return GL_TRUE; - - /* All other instructions require fully active components with no swizzle */ - default: - if (mov->SrcReg[0].Swizzle != SWIZZLE_XYZW || - inst->DstReg.WriteMask != WRITEMASK_XYZW) - return GL_FALSE; - inst->DstReg = mov->DstReg; - return GL_TRUE; - } -} - - -/** - * Try to remove extraneous MOV instructions from the given program. - */ -static GLboolean -_mesa_remove_extra_moves(struct gl_program *prog) -{ - GLboolean *removeInst; /* per-instruction removal flag */ - GLuint i, rem = 0, nesting = 0; - - if (dbg) { - printf("Optimize: Begin remove extra moves\n"); - _mesa_print_program(prog); - } - - removeInst = (GLboolean *) - calloc(1, prog->NumInstructions * sizeof(GLboolean)); - - /* - * Look for sequences such as this: - * FOO tmpX, arg0, arg1; - * MOV tmpY, tmpX; - * and convert into: - * FOO tmpY, arg0, arg1; - */ - - for (i = 0; i < prog->NumInstructions; i++) { - const struct prog_instruction *mov = prog->Instructions + i; - - switch (mov->Opcode) { - case OPCODE_BGNLOOP: - case OPCODE_BGNSUB: - case OPCODE_IF: - nesting++; - break; - case OPCODE_ENDLOOP: - case OPCODE_ENDSUB: - case OPCODE_ENDIF: - nesting--; - break; - case OPCODE_MOV: - if (i > 0 && - can_downward_mov_be_modifed(mov) && - mov->SrcReg[0].File == PROGRAM_TEMPORARY && - nesting == 0) - { - - /* see if this MOV can be removed */ - const GLuint id = mov->SrcReg[0].Index; - struct prog_instruction *prevInst; - GLuint prevI; - - /* get pointer to previous instruction */ - prevI = i - 1; - while (prevI > 0 && removeInst[prevI]) - prevI--; - prevInst = prog->Instructions + prevI; - - if (prevInst->DstReg.File == PROGRAM_TEMPORARY && - prevInst->DstReg.Index == id && - prevInst->DstReg.RelAddr == 0 && - prevInst->DstReg.CondSrc == 0 && - prevInst->DstReg.CondMask == COND_TR) { - - const GLuint dst_mask = prevInst->DstReg.WriteMask; - enum inst_use next_use = find_next_use(prog, i+1, id, dst_mask); - - if (next_use == WRITE || next_use == END) { - /* OK, we can safely remove this MOV instruction. - * Transform: - * prevI: FOO tempIndex, x, y; - * i: MOV z, tempIndex; - * Into: - * prevI: FOO z, x, y; - */ - if (_mesa_merge_mov_into_inst(prevInst, mov)) { - removeInst[i] = GL_TRUE; - if (dbg) { - printf("Remove MOV at %u\n", i); - printf("new prev inst %u: ", prevI); - _mesa_print_instruction(prevInst); - } - } - } - } - } - break; - default: - ; /* nothing */ - } - } - - /* now remove the instructions which aren't needed */ - rem = remove_instructions(prog, removeInst); - - free(removeInst); - - if (dbg) { - printf("Optimize: End remove extra moves. %u instructions removed\n", rem); - /*_mesa_print_program(prog);*/ - } - - return rem != 0; -} - - -/** A live register interval */ -struct interval -{ - GLuint Reg; /** The temporary register index */ - GLuint Start, End; /** Start/end instruction numbers */ -}; - - -/** A list of register intervals */ -struct interval_list -{ - GLuint Num; - struct interval Intervals[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; -}; - - -static void -append_interval(struct interval_list *list, const struct interval *inv) -{ - list->Intervals[list->Num++] = *inv; -} - - -/** Insert interval inv into list, sorted by interval end */ -static void -insert_interval_by_end(struct interval_list *list, const struct interval *inv) -{ - /* XXX we could do a binary search insertion here since list is sorted */ - GLint i = list->Num - 1; - while (i >= 0 && list->Intervals[i].End > inv->End) { - list->Intervals[i + 1] = list->Intervals[i]; - i--; - } - list->Intervals[i + 1] = *inv; - list->Num++; - -#ifdef DEBUG - { - GLuint i; - for (i = 0; i + 1 < list->Num; i++) { - ASSERT(list->Intervals[i].End <= list->Intervals[i + 1].End); - } - } -#endif -} - - -/** Remove the given interval from the interval list */ -static void -remove_interval(struct interval_list *list, const struct interval *inv) -{ - /* XXX we could binary search since list is sorted */ - GLuint k; - for (k = 0; k < list->Num; k++) { - if (list->Intervals[k].Reg == inv->Reg) { - /* found, remove it */ - ASSERT(list->Intervals[k].Start == inv->Start); - ASSERT(list->Intervals[k].End == inv->End); - while (k < list->Num - 1) { - list->Intervals[k] = list->Intervals[k + 1]; - k++; - } - list->Num--; - return; - } - } -} - - -/** called by qsort() */ -static int -compare_start(const void *a, const void *b) -{ - const struct interval *ia = (const struct interval *) a; - const struct interval *ib = (const struct interval *) b; - if (ia->Start < ib->Start) - return -1; - else if (ia->Start > ib->Start) - return +1; - else - return 0; -} - - -/** sort the interval list according to interval starts */ -static void -sort_interval_list_by_start(struct interval_list *list) -{ - qsort(list->Intervals, list->Num, sizeof(struct interval), compare_start); -#ifdef DEBUG - { - GLuint i; - for (i = 0; i + 1 < list->Num; i++) { - ASSERT(list->Intervals[i].Start <= list->Intervals[i + 1].Start); - } - } -#endif -} - -struct loop_info -{ - GLuint Start, End; /**< Start, end instructions of loop */ -}; - -/** - * Update the intermediate interval info for register 'index' and - * instruction 'ic'. - */ -static void -update_interval(GLint intBegin[], GLint intEnd[], - struct loop_info *loopStack, GLuint loopStackDepth, - GLuint index, GLuint ic) -{ - int i; - GLuint begin = ic; - GLuint end = ic; - - /* If the register is used in a loop, extend its lifetime through the end - * of the outermost loop that doesn't contain its definition. - */ - for (i = 0; i < loopStackDepth; i++) { - if (intBegin[index] < loopStack[i].Start) { - end = loopStack[i].End; - break; - } - } - - /* Variables that are live at the end of a loop will also be live at the - * beginning, so an instruction inside of a loop should have its live - * interval begin at the start of the outermost loop. - */ - if (loopStackDepth > 0 && ic > loopStack[0].Start && ic < loopStack[0].End) { - begin = loopStack[0].Start; - } - - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); - if (intBegin[index] == -1) { - ASSERT(intEnd[index] == -1); - intBegin[index] = begin; - intEnd[index] = end; - } - else { - intEnd[index] = end; - } -} - - -/** - * Find first/last instruction that references each temporary register. - */ -GLboolean -_mesa_find_temp_intervals(const struct prog_instruction *instructions, - GLuint numInstructions, - GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS], - GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS]) -{ - struct loop_info loopStack[MAX_LOOP_NESTING]; - GLuint loopStackDepth = 0; - GLuint i; - - for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){ - intBegin[i] = intEnd[i] = -1; - } - - /* Scan instructions looking for temporary registers */ - for (i = 0; i < numInstructions; i++) { - const struct prog_instruction *inst = instructions + i; - if (inst->Opcode == OPCODE_BGNLOOP) { - loopStack[loopStackDepth].Start = i; - loopStack[loopStackDepth].End = inst->BranchTarget; - loopStackDepth++; - } - else if (inst->Opcode == OPCODE_ENDLOOP) { - loopStackDepth--; - } - else if (inst->Opcode == OPCODE_CAL) { - return GL_FALSE; - } - else { - const GLuint numSrc = 3;/*_mesa_num_inst_src_regs(inst->Opcode);*/ - GLuint j; - for (j = 0; j < numSrc; j++) { - if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) { - const GLuint index = inst->SrcReg[j].Index; - if (inst->SrcReg[j].RelAddr) - return GL_FALSE; - update_interval(intBegin, intEnd, loopStack, loopStackDepth, - index, i); - } - } - if (inst->DstReg.File == PROGRAM_TEMPORARY) { - const GLuint index = inst->DstReg.Index; - if (inst->DstReg.RelAddr) - return GL_FALSE; - update_interval(intBegin, intEnd, loopStack, loopStackDepth, - index, i); - } - } - } - - return GL_TRUE; -} - - -/** - * Find the live intervals for each temporary register in the program. - * For register R, the interval [A,B] indicates that R is referenced - * from instruction A through instruction B. - * Special consideration is needed for loops and subroutines. - * \return GL_TRUE if success, GL_FALSE if we cannot proceed for some reason - */ -static GLboolean -find_live_intervals(struct gl_program *prog, - struct interval_list *liveIntervals) -{ - GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; - GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; - GLuint i; - - /* - * Note: we'll return GL_FALSE below if we find relative indexing - * into the TEMP register file. We can't handle that yet. - * We also give up on subroutines for now. - */ - - if (dbg) { - printf("Optimize: Begin find intervals\n"); - } - - /* build intermediate arrays */ - if (!_mesa_find_temp_intervals(prog->Instructions, prog->NumInstructions, - intBegin, intEnd)) - return GL_FALSE; - - /* Build live intervals list from intermediate arrays */ - liveIntervals->Num = 0; - for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) { - if (intBegin[i] >= 0) { - struct interval inv; - inv.Reg = i; - inv.Start = intBegin[i]; - inv.End = intEnd[i]; - append_interval(liveIntervals, &inv); - } - } - - /* Sort the list according to interval starts */ - sort_interval_list_by_start(liveIntervals); - - if (dbg) { - /* print interval info */ - for (i = 0; i < liveIntervals->Num; i++) { - const struct interval *inv = liveIntervals->Intervals + i; - printf("Reg[%d] live [%d, %d]:", - inv->Reg, inv->Start, inv->End); - if (1) { - GLuint j; - for (j = 0; j < inv->Start; j++) - printf(" "); - for (j = inv->Start; j <= inv->End; j++) - printf("x"); - } - printf("\n"); - } - } - - return GL_TRUE; -} - - -/** Scan the array of used register flags to find free entry */ -static GLint -alloc_register(GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS]) -{ - GLuint k; - for (k = 0; k < REG_ALLOCATE_MAX_PROGRAM_TEMPS; k++) { - if (!usedRegs[k]) { - usedRegs[k] = GL_TRUE; - return k; - } - } - return -1; -} - - -/** - * This function implements "Linear Scan Register Allocation" to reduce - * the number of temporary registers used by the program. - * - * We compute the "live interval" for all temporary registers then - * examine the overlap of the intervals to allocate new registers. - * Basically, if two intervals do not overlap, they can use the same register. - */ -static void -_mesa_reallocate_registers(struct gl_program *prog) -{ - struct interval_list liveIntervals; - GLint registerMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; - GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; - GLuint i; - GLint maxTemp = -1; - - if (dbg) { - printf("Optimize: Begin live-interval register reallocation\n"); - _mesa_print_program(prog); - } - - for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){ - registerMap[i] = -1; - usedRegs[i] = GL_FALSE; - } - - if (!find_live_intervals(prog, &liveIntervals)) { - if (dbg) - printf("Aborting register reallocation\n"); - return; - } - - { - struct interval_list activeIntervals; - activeIntervals.Num = 0; - - /* loop over live intervals, allocating a new register for each */ - for (i = 0; i < liveIntervals.Num; i++) { - const struct interval *live = liveIntervals.Intervals + i; - - if (dbg) - printf("Consider register %u\n", live->Reg); - - /* Expire old intervals. Intervals which have ended with respect - * to the live interval can have their remapped registers freed. - */ - { - GLint j; - for (j = 0; j < (GLint) activeIntervals.Num; j++) { - const struct interval *inv = activeIntervals.Intervals + j; - if (inv->End >= live->Start) { - /* Stop now. Since the activeInterval list is sorted - * we know we don't have to go further. - */ - break; - } - else { - /* Interval 'inv' has expired */ - const GLint regNew = registerMap[inv->Reg]; - ASSERT(regNew >= 0); - - if (dbg) - printf(" expire interval for reg %u\n", inv->Reg); - - /* remove interval j from active list */ - remove_interval(&activeIntervals, inv); - j--; /* counter-act j++ in for-loop above */ - - /* return register regNew to the free pool */ - if (dbg) - printf(" free reg %d\n", regNew); - ASSERT(usedRegs[regNew] == GL_TRUE); - usedRegs[regNew] = GL_FALSE; - } - } - } - - /* find a free register for this live interval */ - { - const GLint k = alloc_register(usedRegs); - if (k < 0) { - /* out of registers, give up */ - return; - } - registerMap[live->Reg] = k; - maxTemp = MAX2(maxTemp, k); - if (dbg) - printf(" remap register %u -> %d\n", live->Reg, k); - } - - /* Insert this live interval into the active list which is sorted - * by increasing end points. - */ - insert_interval_by_end(&activeIntervals, live); - } - } - - if (maxTemp + 1 < (GLint) liveIntervals.Num) { - /* OK, we've reduced the number of registers needed. - * Scan the program and replace all the old temporary register - * indexes with the new indexes. - */ - replace_regs(prog, PROGRAM_TEMPORARY, registerMap); - - prog->NumTemporaries = maxTemp + 1; - } - - if (dbg) { - printf("Optimize: End live-interval register reallocation\n"); - printf("Num temp regs before: %u after: %u\n", - liveIntervals.Num, maxTemp + 1); - _mesa_print_program(prog); - } -} - - -#if 0 -static void -print_it(struct gl_context *ctx, struct gl_program *program, const char *txt) { - fprintf(stderr, "%s (%u inst):\n", txt, program->NumInstructions); - _mesa_print_program(program); - _mesa_print_program_parameters(ctx, program); - fprintf(stderr, "\n\n"); -} -#endif - -/** - * This pass replaces CMP T0, T1 T2 T0 with MOV T0, T2 when the CMP - * instruction is the first instruction to write to register T0. The are - * several lowering passes done in GLSL IR (e.g. branches and - * relative addressing) that create a large number of conditional assignments - * that ir_to_mesa converts to CMP instructions like the one mentioned above. - * - * Here is why this conversion is safe: - * CMP T0, T1 T2 T0 can be expanded to: - * if (T1 < 0.0) - * MOV T0, T2; - * else - * MOV T0, T0; - * - * If (T1 < 0.0) evaluates to true then our replacement MOV T0, T2 is the same - * as the original program. If (T1 < 0.0) evaluates to false, executing - * MOV T0, T0 will store a garbage value in T0 since T0 is uninitialized. - * Therefore, it doesn't matter that we are replacing MOV T0, T0 with MOV T0, T2 - * because any instruction that was going to read from T0 after this was going - * to read a garbage value anyway. - */ -static void -_mesa_simplify_cmp(struct gl_program * program) -{ - GLuint tempWrites[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; - GLuint outputWrites[MAX_PROGRAM_OUTPUTS]; - GLuint i; - - if (dbg) { - printf("Optimize: Begin reads without writes\n"); - _mesa_print_program(program); - } - - for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) { - tempWrites[i] = 0; - } - - for (i = 0; i < MAX_PROGRAM_OUTPUTS; i++) { - outputWrites[i] = 0; - } - - for (i = 0; i < program->NumInstructions; i++) { - struct prog_instruction *inst = program->Instructions + i; - GLuint prevWriteMask; - - /* Give up if we encounter relative addressing or flow control. */ - if (_mesa_is_flow_control_opcode(inst->Opcode) || inst->DstReg.RelAddr) { - return; - } - - if (inst->DstReg.File == PROGRAM_OUTPUT) { - assert(inst->DstReg.Index < MAX_PROGRAM_OUTPUTS); - prevWriteMask = outputWrites[inst->DstReg.Index]; - outputWrites[inst->DstReg.Index] |= inst->DstReg.WriteMask; - } else if (inst->DstReg.File == PROGRAM_TEMPORARY) { - assert(inst->DstReg.Index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); - prevWriteMask = tempWrites[inst->DstReg.Index]; - tempWrites[inst->DstReg.Index] |= inst->DstReg.WriteMask; - } else { - /* No other register type can be a destination register. */ - continue; - } - - /* For a CMP to be considered a conditional write, the destination - * register and source register two must be the same. */ - if (inst->Opcode == OPCODE_CMP - && !(inst->DstReg.WriteMask & prevWriteMask) - && inst->SrcReg[2].File == inst->DstReg.File - && inst->SrcReg[2].Index == inst->DstReg.Index - && inst->DstReg.WriteMask == get_src_arg_mask(inst, 2, NO_MASK)) { - - inst->Opcode = OPCODE_MOV; - inst->SrcReg[0] = inst->SrcReg[1]; - - /* Unused operands are expected to have the file set to - * PROGRAM_UNDEFINED. This is how _mesa_init_instructions initializes - * all of the sources. - */ - inst->SrcReg[1].File = PROGRAM_UNDEFINED; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - inst->SrcReg[2].File = PROGRAM_UNDEFINED; - inst->SrcReg[2].Swizzle = SWIZZLE_NOOP; - } - } - if (dbg) { - printf("Optimize: End reads without writes\n"); - _mesa_print_program(program); - } -} - -/** - * Apply optimizations to the given program to eliminate unnecessary - * instructions, temp regs, etc. - */ -void -_mesa_optimize_program(struct gl_context *ctx, struct gl_program *program) -{ - GLboolean any_change; - - _mesa_simplify_cmp(program); - /* Stop when no modifications were output */ - do { - any_change = GL_FALSE; - _mesa_remove_extra_move_use(program); - if (_mesa_remove_dead_code_global(program)) - any_change = GL_TRUE; - if (_mesa_remove_extra_moves(program)) - any_change = GL_TRUE; - if (_mesa_remove_dead_code_local(program)) - any_change = GL_TRUE; - - any_change = _mesa_constant_fold(program) || any_change; - _mesa_reallocate_registers(program); - } while (any_change); -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.h deleted file mode 100644 index 9854fb7a491..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_optimize.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 2009 VMware, Inc. 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 - * VMWARE 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 PROG_OPT_H -#define PROG_OPT_H - - -#include "main/config.h" -#include "main/glheader.h" - - -struct gl_context; -struct gl_program; -struct prog_instruction; - - -extern GLboolean -_mesa_find_temp_intervals(const struct prog_instruction *instructions, - GLuint numInstructions, - GLint intBegin[MAX_PROGRAM_TEMPS], - GLint intEnd[MAX_PROGRAM_TEMPS]); - -extern void -_mesa_optimize_program(struct gl_context *ctx, struct gl_program *program); - -extern GLboolean -_mesa_constant_fold(struct gl_program *prog); - -#endif diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.c deleted file mode 100644 index 2018fa52071..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.c +++ /dev/null @@ -1,658 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 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. - */ - -/** - * \file prog_parameter.c - * Program parameter lists and functions. - * \author Brian Paul - */ - - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/macros.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_statevars.h" - - -struct gl_program_parameter_list * -_mesa_new_parameter_list(void) -{ - return CALLOC_STRUCT(gl_program_parameter_list); -} - - -struct gl_program_parameter_list * -_mesa_new_parameter_list_sized(unsigned size) -{ - struct gl_program_parameter_list *p = _mesa_new_parameter_list(); - - if ((p != NULL) && (size != 0)) { - p->Size = size; - - /* alloc arrays */ - p->Parameters = (struct gl_program_parameter *) - calloc(1, size * sizeof(struct gl_program_parameter)); - - p->ParameterValues = (gl_constant_value (*)[4]) - _mesa_align_malloc(size * 4 *sizeof(gl_constant_value), 16); - - - if ((p->Parameters == NULL) || (p->ParameterValues == NULL)) { - free(p->Parameters); - _mesa_align_free(p->ParameterValues); - free(p); - p = NULL; - } - } - - return p; -} - - -/** - * Free a parameter list and all its parameters - */ -void -_mesa_free_parameter_list(struct gl_program_parameter_list *paramList) -{ - GLuint i; - for (i = 0; i < paramList->NumParameters; i++) { - if (paramList->Parameters[i].Name) - free((void *) paramList->Parameters[i].Name); - } - free(paramList->Parameters); - if (paramList->ParameterValues) - _mesa_align_free(paramList->ParameterValues); - free(paramList); -} - - -/** - * Add a new parameter to a parameter list. - * Note that parameter values are usually 4-element GLfloat vectors. - * When size > 4 we'll allocate a sequential block of parameters to - * store all the values (in blocks of 4). - * - * \param paramList the list to add the parameter to - * \param type type of parameter, such as - * \param name the parameter name, will be duplicated/copied! - * \param size number of elements in 'values' vector (1..4, or more) - * \param datatype GL_FLOAT, GL_FLOAT_VECx, GL_INT, GL_INT_VECx or GL_NONE. - * \param values initial parameter value, up to 4 gl_constant_values, or NULL - * \param state state indexes, or NULL - * \return index of new parameter in the list, or -1 if error (out of mem) - */ -GLint -_mesa_add_parameter(struct gl_program_parameter_list *paramList, - gl_register_file type, const char *name, - GLuint size, GLenum datatype, - const gl_constant_value *values, - const gl_state_index state[STATE_LENGTH], - GLbitfield flags) -{ - const GLuint oldNum = paramList->NumParameters; - const GLuint sz4 = (size + 3) / 4; /* no. of new param slots needed */ - - assert(size > 0); - - if (oldNum + sz4 > paramList->Size) { - /* Need to grow the parameter list array (alloc some extra) */ - paramList->Size = paramList->Size + 4 * sz4; - - /* realloc arrays */ - paramList->Parameters = (struct gl_program_parameter *) - _mesa_realloc(paramList->Parameters, - oldNum * sizeof(struct gl_program_parameter), - paramList->Size * sizeof(struct gl_program_parameter)); - - paramList->ParameterValues = (gl_constant_value (*)[4]) - _mesa_align_realloc(paramList->ParameterValues, /* old buf */ - oldNum * 4 * sizeof(gl_constant_value),/* old sz */ - paramList->Size*4*sizeof(gl_constant_value),/*new*/ - 16); - } - - if (!paramList->Parameters || - !paramList->ParameterValues) { - /* out of memory */ - paramList->NumParameters = 0; - paramList->Size = 0; - return -1; - } - else { - GLuint i, j; - - paramList->NumParameters = oldNum + sz4; - - memset(¶mList->Parameters[oldNum], 0, - sz4 * sizeof(struct gl_program_parameter)); - - for (i = 0; i < sz4; i++) { - struct gl_program_parameter *p = paramList->Parameters + oldNum + i; - p->Name = name ? _mesa_strdup(name) : NULL; - p->Type = type; - p->Size = size; - p->DataType = datatype; - p->Flags = flags; - if (values) { - COPY_4V(paramList->ParameterValues[oldNum + i], values); - values += 4; - p->Initialized = GL_TRUE; - } - else { - /* silence valgrind */ - for (j = 0; j < 4; j++) - paramList->ParameterValues[oldNum + i][j].f = 0; - } - size -= 4; - } - - if (state) { - for (i = 0; i < STATE_LENGTH; i++) - paramList->Parameters[oldNum].StateIndexes[i] = state[i]; - } - - return (GLint) oldNum; - } -} - - -/** - * Add a new named program parameter (Ex: NV_fragment_program DEFINE statement) - * \return index of the new entry in the parameter list - */ -GLint -_mesa_add_named_parameter(struct gl_program_parameter_list *paramList, - const char *name, const gl_constant_value values[4]) -{ - return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name, - 4, GL_NONE, values, NULL, 0x0); - -} - - -/** - * Add a new named constant to the parameter list. - * This will be used when the program contains something like this: - * PARAM myVals = { 0, 1, 2, 3 }; - * - * \param paramList the parameter list - * \param name the name for the constant - * \param values four float values - * \return index/position of the new parameter in the parameter list - */ -GLint -_mesa_add_named_constant(struct gl_program_parameter_list *paramList, - const char *name, const gl_constant_value values[4], - GLuint size) -{ - /* first check if this is a duplicate constant */ - GLint pos; - for (pos = 0; pos < (GLint)paramList->NumParameters; pos++) { - const gl_constant_value *pvals = paramList->ParameterValues[pos]; - if (pvals[0].u == values[0].u && - pvals[1].u == values[1].u && - pvals[2].u == values[2].u && - pvals[3].u == values[3].u && - strcmp(paramList->Parameters[pos].Name, name) == 0) { - /* Same name and value is already in the param list - reuse it */ - return pos; - } - } - /* not found, add new parameter */ - return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, name, - size, GL_NONE, values, NULL, 0x0); -} - - -/** - * Add a new unnamed constant to the parameter list. This will be used - * when a fragment/vertex program contains something like this: - * MOV r, { 0, 1, 2, 3 }; - * If swizzleOut is non-null we'll search the parameter list for an - * existing instance of the constant which matches with a swizzle. - * - * \param paramList the parameter list - * \param values four float values - * \param swizzleOut returns swizzle mask for accessing the constant - * \return index/position of the new parameter in the parameter list. - */ -GLint -_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList, - const gl_constant_value values[4], GLuint size, - GLenum datatype, GLuint *swizzleOut) -{ - GLint pos; - ASSERT(size >= 1); - ASSERT(size <= 4); - - if (swizzleOut && - _mesa_lookup_parameter_constant(paramList, values, - size, &pos, swizzleOut)) { - return pos; - } - - /* Look for empty space in an already unnamed constant parameter - * to add this constant. This will only work for single-element - * constants because we rely on smearing (i.e. .yyyy or .zzzz). - */ - if (size == 1 && swizzleOut) { - for (pos = 0; pos < (GLint) paramList->NumParameters; pos++) { - struct gl_program_parameter *p = paramList->Parameters + pos; - if (p->Type == PROGRAM_CONSTANT && p->Size + size <= 4) { - /* ok, found room */ - gl_constant_value *pVal = paramList->ParameterValues[pos]; - GLuint swz = p->Size; /* 1, 2 or 3 for Y, Z, W */ - pVal[p->Size] = values[0]; - p->Size++; - *swizzleOut = MAKE_SWIZZLE4(swz, swz, swz, swz); - return pos; - } - } - } - - /* add a new parameter to store this constant */ - pos = _mesa_add_parameter(paramList, PROGRAM_CONSTANT, NULL, - size, datatype, values, NULL, 0x0); - if (pos >= 0 && swizzleOut) { - if (size == 1) - *swizzleOut = SWIZZLE_XXXX; - else - *swizzleOut = SWIZZLE_NOOP; - } - return pos; -} - -/** - * Add a new unnamed constant to the parameter list. This will be used - * when a fragment/vertex program contains something like this: - * MOV r, { 0, 1, 2, 3 }; - * If swizzleOut is non-null we'll search the parameter list for an - * existing instance of the constant which matches with a swizzle. - * - * \param paramList the parameter list - * \param values four float values - * \param swizzleOut returns swizzle mask for accessing the constant - * \return index/position of the new parameter in the parameter list. - * \sa _mesa_add_typed_unnamed_constant - */ -GLint -_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, - const gl_constant_value values[4], GLuint size, - GLuint *swizzleOut) -{ - return _mesa_add_typed_unnamed_constant(paramList, values, size, GL_NONE, - swizzleOut); -} - -/** - * Add parameter representing a varying variable. - */ -GLint -_mesa_add_varying(struct gl_program_parameter_list *paramList, - const char *name, GLuint size, GLenum datatype, - GLbitfield flags) -{ - GLint i = _mesa_lookup_parameter_index(paramList, -1, name); - if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_VARYING) { - /* already in list */ - return i; - } - else { - /*assert(size == 4);*/ - i = _mesa_add_parameter(paramList, PROGRAM_VARYING, name, - size, datatype, NULL, NULL, flags); - return i; - } -} - - -/** - * Add parameter representing a vertex program attribute. - * \param size size of attribute (in floats), may be -1 if unknown - * \param attrib the attribute index, or -1 if unknown - */ -GLint -_mesa_add_attribute(struct gl_program_parameter_list *paramList, - const char *name, GLint size, GLenum datatype, GLint attrib) -{ - GLint i = _mesa_lookup_parameter_index(paramList, -1, name); - if (i >= 0) { - /* replace */ - if (attrib < 0) - attrib = i; - paramList->Parameters[i].StateIndexes[0] = attrib; - } - else { - /* add */ - gl_state_index state[STATE_LENGTH]; - state[0] = (gl_state_index) attrib; - if (size < 0) - size = 4; - i = _mesa_add_parameter(paramList, PROGRAM_INPUT, name, - size, datatype, NULL, state, 0x0); - } - return i; -} - - - -#if 0 /* not used yet */ -/** - * Returns the number of 4-component registers needed to store a piece - * of GL state. For matrices this may be as many as 4 registers, - * everything else needs - * just 1 register. - */ -static GLuint -sizeof_state_reference(const GLint *stateTokens) -{ - if (stateTokens[0] == STATE_MATRIX) { - GLuint rows = stateTokens[4] - stateTokens[3] + 1; - assert(rows >= 1); - assert(rows <= 4); - return rows; - } - else { - return 1; - } -} -#endif - - -/** - * Add a new state reference to the parameter list. - * This will be used when the program contains something like this: - * PARAM ambient = state.material.front.ambient; - * - * \param paramList the parameter list - * \param stateTokens an array of 5 (STATE_LENGTH) state tokens - * \return index of the new parameter. - */ -GLint -_mesa_add_state_reference(struct gl_program_parameter_list *paramList, - const gl_state_index stateTokens[STATE_LENGTH]) -{ - const GLuint size = 4; /* XXX fix */ - char *name; - GLint index; - - /* Check if the state reference is already in the list */ - for (index = 0; index < (GLint) paramList->NumParameters; index++) { - if (!memcmp(paramList->Parameters[index].StateIndexes, - stateTokens, STATE_LENGTH * sizeof(gl_state_index))) { - return index; - } - } - - name = _mesa_program_state_string(stateTokens); - index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name, - size, GL_NONE, - NULL, (gl_state_index *) stateTokens, 0x0); - paramList->StateFlags |= _mesa_program_state_flags(stateTokens); - - /* free name string here since we duplicated it in add_parameter() */ - free(name); - - return index; -} - - -/** - * Lookup a parameter value by name in the given parameter list. - * \return pointer to the float[4] values. - */ -gl_constant_value * -_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList, - GLsizei nameLen, const char *name) -{ - GLint i = _mesa_lookup_parameter_index(paramList, nameLen, name); - if (i < 0) - return NULL; - else - return paramList->ParameterValues[i]; -} - - -/** - * Given a program parameter name, find its position in the list of parameters. - * \param paramList the parameter list to search - * \param nameLen length of name (in chars). - * If length is negative, assume that name is null-terminated. - * \param name the name to search for - * \return index of parameter in the list. - */ -GLint -_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList, - GLsizei nameLen, const char *name) -{ - GLint i; - - if (!paramList) - return -1; - - if (nameLen == -1) { - /* name is null-terminated */ - for (i = 0; i < (GLint) paramList->NumParameters; i++) { - if (paramList->Parameters[i].Name && - strcmp(paramList->Parameters[i].Name, name) == 0) - return i; - } - } - else { - /* name is not null-terminated, use nameLen */ - for (i = 0; i < (GLint) paramList->NumParameters; i++) { - if (paramList->Parameters[i].Name && - strncmp(paramList->Parameters[i].Name, name, nameLen) == 0 - && strlen(paramList->Parameters[i].Name) == (size_t)nameLen) - return i; - } - } - return -1; -} - - -/** - * Look for a float vector in the given parameter list. The float vector - * may be of length 1, 2, 3 or 4. If swizzleOut is non-null, we'll try - * swizzling to find a match. - * \param list the parameter list to search - * \param v the float vector to search for - * \param vSize number of element in v - * \param posOut returns the position of the constant, if found - * \param swizzleOut returns a swizzle mask describing location of the - * vector elements if found. - * \return GL_TRUE if found, GL_FALSE if not found - */ -GLboolean -_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, - const gl_constant_value v[], GLuint vSize, - GLint *posOut, GLuint *swizzleOut) -{ - GLuint i; - - assert(vSize >= 1); - assert(vSize <= 4); - - if (!list) { - *posOut = -1; - return GL_FALSE; - } - - for (i = 0; i < list->NumParameters; i++) { - if (list->Parameters[i].Type == PROGRAM_CONSTANT) { - if (!swizzleOut) { - /* swizzle not allowed */ - GLuint j, match = 0; - for (j = 0; j < vSize; j++) { - if (v[j].u == list->ParameterValues[i][j].u) - match++; - } - if (match == vSize) { - *posOut = i; - return GL_TRUE; - } - } - else { - /* try matching w/ swizzle */ - if (vSize == 1) { - /* look for v[0] anywhere within float[4] value */ - GLuint j; - for (j = 0; j < list->Parameters[i].Size; j++) { - if (list->ParameterValues[i][j].u == v[0].u) { - /* found it */ - *posOut = i; - *swizzleOut = MAKE_SWIZZLE4(j, j, j, j); - return GL_TRUE; - } - } - } - else if (vSize <= list->Parameters[i].Size) { - /* see if we can match this constant (with a swizzle) */ - GLuint swz[4]; - GLuint match = 0, j, k; - for (j = 0; j < vSize; j++) { - if (v[j].u == list->ParameterValues[i][j].u) { - swz[j] = j; - match++; - } - else { - for (k = 0; k < list->Parameters[i].Size; k++) { - if (v[j].u == list->ParameterValues[i][k].u) { - swz[j] = k; - match++; - break; - } - } - } - } - /* smear last value to remaining positions */ - for (; j < 4; j++) - swz[j] = swz[j-1]; - - if (match == vSize) { - *posOut = i; - *swizzleOut = MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]); - return GL_TRUE; - } - } - } - } - } - - *posOut = -1; - return GL_FALSE; -} - - -struct gl_program_parameter_list * -_mesa_clone_parameter_list(const struct gl_program_parameter_list *list) -{ - struct gl_program_parameter_list *clone; - GLuint i; - - clone = _mesa_new_parameter_list(); - if (!clone) - return NULL; - - /** Not too efficient, but correct */ - for (i = 0; i < list->NumParameters; i++) { - struct gl_program_parameter *p = list->Parameters + i; - struct gl_program_parameter *pCopy; - GLuint size = MIN2(p->Size, 4); - GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType, - list->ParameterValues[i], NULL, 0x0); - ASSERT(j >= 0); - pCopy = clone->Parameters + j; - pCopy->Flags = p->Flags; - /* copy state indexes */ - if (p->Type == PROGRAM_STATE_VAR) { - GLint k; - for (k = 0; k < STATE_LENGTH; k++) { - pCopy->StateIndexes[k] = p->StateIndexes[k]; - } - } - else { - clone->Parameters[j].Size = p->Size; - } - - } - - clone->StateFlags = list->StateFlags; - - return clone; -} - - -/** - * Return a new parameter list which is listA + listB. - */ -struct gl_program_parameter_list * -_mesa_combine_parameter_lists(const struct gl_program_parameter_list *listA, - const struct gl_program_parameter_list *listB) -{ - struct gl_program_parameter_list *list; - - if (listA) { - list = _mesa_clone_parameter_list(listA); - if (list && listB) { - GLuint i; - for (i = 0; i < listB->NumParameters; i++) { - struct gl_program_parameter *param = listB->Parameters + i; - _mesa_add_parameter(list, param->Type, param->Name, param->Size, - param->DataType, - listB->ParameterValues[i], - param->StateIndexes, - param->Flags); - } - } - } - else if (listB) { - list = _mesa_clone_parameter_list(listB); - } - else { - list = NULL; - } - return list; -} - - -/** - * Count the number of parameters in the last that match the given type. - */ -GLuint -_mesa_num_parameters_of_type(const struct gl_program_parameter_list *list, - gl_register_file type) -{ - GLuint i, count = 0; - if (list) { - for (i = 0; i < list->NumParameters; i++) { - if (list->Parameters[i].Type == type) - count++; - } - } - return count; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.h deleted file mode 100644 index 3c6dc8cf996..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 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. - */ - -/** - * \file prog_parameter.c - * Program parameter lists and functions. - * \author Brian Paul - */ - -#ifndef PROG_PARAMETER_H -#define PROG_PARAMETER_H - -#include "main/mtypes.h" -#include "prog_statevars.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Program parameter flags - */ -/*@{*/ -#define PROG_PARAM_BIT_CENTROID 0x1 /**< for varying vars (GLSL 1.20) */ -#define PROG_PARAM_BIT_INVARIANT 0x2 /**< for varying vars (GLSL 1.20) */ -#define PROG_PARAM_BIT_FLAT 0x4 /**< for varying vars (GLSL 1.30) */ -#define PROG_PARAM_BIT_LINEAR 0x8 /**< for varying vars (GLSL 1.30) */ -#define PROG_PARAM_BIT_CYL_WRAP 0x10 /**< XXX gallium debug */ -/*@}*/ - - -/** - * Actual data for constant values of parameters. - */ -typedef union gl_constant_value -{ - GLfloat f; - GLint b; - GLint i; - GLuint u; -} gl_constant_value; - - -/** - * Program parameter. - * Used by shaders/programs for uniforms, constants, varying vars, etc. - */ -struct gl_program_parameter -{ - const char *Name; /**< Null-terminated string */ - gl_register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ - GLenum DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */ - /** - * Number of components (1..4), or more. - * If the number of components is greater than 4, - * this parameter is part of a larger uniform like a GLSL matrix or array. - * The next program parameter's Size will be Size-4 of this parameter. - */ - GLuint Size; - GLboolean Initialized; /**< debug: Has the ParameterValue[] been set? */ - GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ - /** - * A sequence of STATE_* tokens and integers to identify GL state. - */ - gl_state_index StateIndexes[STATE_LENGTH]; -}; - - -/** - * List of gl_program_parameter instances. - */ -struct gl_program_parameter_list -{ - GLuint Size; /**< allocated size of Parameters, ParameterValues */ - GLuint NumParameters; /**< number of parameters in arrays */ - struct gl_program_parameter *Parameters; /**< Array [Size] */ - gl_constant_value (*ParameterValues)[4]; /**< Array [Size] of constant[4] */ - GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes - might invalidate ParameterValues[] */ -}; - - -extern struct gl_program_parameter_list * -_mesa_new_parameter_list(void); - -extern struct gl_program_parameter_list * -_mesa_new_parameter_list_sized(unsigned size); - -extern void -_mesa_free_parameter_list(struct gl_program_parameter_list *paramList); - -extern struct gl_program_parameter_list * -_mesa_clone_parameter_list(const struct gl_program_parameter_list *list); - -extern struct gl_program_parameter_list * -_mesa_combine_parameter_lists(const struct gl_program_parameter_list *a, - const struct gl_program_parameter_list *b); - -static inline GLuint -_mesa_num_parameters(const struct gl_program_parameter_list *list) -{ - return list ? list->NumParameters : 0; -} - -extern GLint -_mesa_add_parameter(struct gl_program_parameter_list *paramList, - gl_register_file type, const char *name, - GLuint size, GLenum datatype, - const gl_constant_value *values, - const gl_state_index state[STATE_LENGTH], - GLbitfield flags); - -extern GLint -_mesa_add_named_parameter(struct gl_program_parameter_list *paramList, - const char *name, const gl_constant_value values[4]); - -extern GLint -_mesa_add_named_constant(struct gl_program_parameter_list *paramList, - const char *name, const gl_constant_value values[4], - GLuint size); - -extern GLint -_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList, - const gl_constant_value values[4], GLuint size, - GLenum datatype, GLuint *swizzleOut); - -extern GLint -_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, - const gl_constant_value values[4], GLuint size, - GLuint *swizzleOut); - -extern GLint -_mesa_add_varying(struct gl_program_parameter_list *paramList, - const char *name, GLuint size, GLenum datatype, - GLbitfield flags); - -extern GLint -_mesa_add_attribute(struct gl_program_parameter_list *paramList, - const char *name, GLint size, GLenum datatype, GLint attrib); - -extern GLint -_mesa_add_state_reference(struct gl_program_parameter_list *paramList, - const gl_state_index stateTokens[STATE_LENGTH]); - -extern gl_constant_value * -_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList, - GLsizei nameLen, const char *name); - -extern GLint -_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList, - GLsizei nameLen, const char *name); - -extern GLboolean -_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list, - const gl_constant_value v[], GLuint vSize, - GLint *posOut, GLuint *swizzleOut); - -extern GLuint -_mesa_num_parameters_of_type(const struct gl_program_parameter_list *list, - gl_register_file type); - - -#ifdef __cplusplus -} -#endif - -#endif /* PROG_PARAMETER_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.c deleted file mode 100644 index e4f2db3b379..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file prog_parameter_layout.c - * \brief Helper functions to layout storage for program parameters - * - * \author Ian Romanick - */ - -#include "main/compiler.h" -#include "main/mtypes.h" -#include "prog_parameter.h" -#include "prog_parameter_layout.h" -#include "prog_instruction.h" -#include "program_parser.h" - -unsigned -_mesa_combine_swizzles(unsigned base, unsigned applied) -{ - unsigned swiz = 0; - unsigned i; - - for (i = 0; i < 4; i++) { - const unsigned s = GET_SWZ(applied, i); - - swiz |= ((s <= SWIZZLE_W) ? GET_SWZ(base, s) : s) << (i * 3); - } - - return swiz; -} - - -/** - * Copy indirect access array from one parameter list to another - * - * \param src Parameter array copied from - * \param dst Parameter array copied to - * \param first Index of first element in \c src to copy - * \param count Number of elements to copy - * - * \return - * The location in \c dst of the first element copied from \c src on - * success. -1 on failure. - * - * \warning - * This function assumes that there is already enough space available in - * \c dst to hold all of the elements that will be copied over. - */ -static int -copy_indirect_accessed_array(struct gl_program_parameter_list *src, - struct gl_program_parameter_list *dst, - unsigned first, unsigned count) -{ - const int base = dst->NumParameters; - unsigned i, j; - - for (i = first; i < (first + count); i++) { - struct gl_program_parameter *curr = & src->Parameters[i]; - - if (curr->Type == PROGRAM_CONSTANT) { - j = dst->NumParameters; - } else { - for (j = 0; j < dst->NumParameters; j++) { - if (memcmp(dst->Parameters[j].StateIndexes, curr->StateIndexes, - sizeof(curr->StateIndexes)) == 0) { - return -1; - } - } - } - - assert(j == dst->NumParameters); - - /* copy src parameter [i] to dest parameter [j] */ - memcpy(& dst->Parameters[j], curr, - sizeof(dst->Parameters[j])); - memcpy(dst->ParameterValues[j], src->ParameterValues[i], - sizeof(GLfloat) * 4); - - /* Pointer to the string name was copied. Null-out src param name - * to prevent double free later. - */ - curr->Name = NULL; - - dst->NumParameters++; - } - - return base; -} - - -/** - * XXX description??? - * \return GL_TRUE for success, GL_FALSE for failure - */ -GLboolean -_mesa_layout_parameters(struct asm_parser_state *state) -{ - struct gl_program_parameter_list *layout; - struct asm_instruction *inst; - unsigned i; - - layout = - _mesa_new_parameter_list_sized(state->prog->Parameters->NumParameters); - - /* PASS 1: Move any parameters that are accessed indirectly from the - * original parameter list to the new parameter list. - */ - for (inst = state->inst_head; inst != NULL; inst = inst->next) { - for (i = 0; i < 3; i++) { - if (inst->SrcReg[i].Base.RelAddr) { - /* Only attempt to add the to the new parameter list once. - */ - if (!inst->SrcReg[i].Symbol->pass1_done) { - const int new_begin = - copy_indirect_accessed_array(state->prog->Parameters, layout, - inst->SrcReg[i].Symbol->param_binding_begin, - inst->SrcReg[i].Symbol->param_binding_length); - - if (new_begin < 0) { - _mesa_free_parameter_list(layout); - return GL_FALSE; - } - - inst->SrcReg[i].Symbol->param_binding_begin = new_begin; - inst->SrcReg[i].Symbol->pass1_done = 1; - } - - /* Previously the Index was just the offset from the parameter - * array. Now that the base of the parameter array is known, the - * index can be updated to its actual value. - */ - inst->Base.SrcReg[i] = inst->SrcReg[i].Base; - inst->Base.SrcReg[i].Index += - inst->SrcReg[i].Symbol->param_binding_begin; - } - } - } - - /* PASS 2: Move any parameters that are not accessed indirectly from the - * original parameter list to the new parameter list. - */ - for (inst = state->inst_head; inst != NULL; inst = inst->next) { - for (i = 0; i < 3; i++) { - const struct gl_program_parameter *p; - const int idx = inst->SrcReg[i].Base.Index; - unsigned swizzle = SWIZZLE_NOOP; - - /* All relative addressed operands were processed on the first - * pass. Just skip them here. - */ - if (inst->SrcReg[i].Base.RelAddr) { - continue; - } - - if ((inst->SrcReg[i].Base.File <= PROGRAM_VARYING ) - || (inst->SrcReg[i].Base.File >= PROGRAM_WRITE_ONLY)) { - continue; - } - - inst->Base.SrcReg[i] = inst->SrcReg[i].Base; - p = & state->prog->Parameters->Parameters[idx]; - - switch (p->Type) { - case PROGRAM_CONSTANT: { - const gl_constant_value *const v = - state->prog->Parameters->ParameterValues[idx]; - - inst->Base.SrcReg[i].Index = - _mesa_add_unnamed_constant(layout, v, p->Size, & swizzle); - - inst->Base.SrcReg[i].Swizzle = - _mesa_combine_swizzles(swizzle, inst->Base.SrcReg[i].Swizzle); - break; - } - - case PROGRAM_STATE_VAR: - inst->Base.SrcReg[i].Index = - _mesa_add_state_reference(layout, p->StateIndexes); - break; - - default: - break; - } - - inst->SrcReg[i].Base.File = p->Type; - inst->Base.SrcReg[i].File = p->Type; - } - } - - layout->StateFlags = state->prog->Parameters->StateFlags; - _mesa_free_parameter_list(state->prog->Parameters); - state->prog->Parameters = layout; - - return GL_TRUE; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.h deleted file mode 100644 index 99a7b6c7266..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_parameter_layout.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file prog_parameter_layout.h - * \brief Helper functions to layout storage for program parameters - * - * \author Ian Romanick - */ - -#pragma once - -#ifndef PROG_PARAMETER_LAYOUT_H -#define PROG_PARAMETER_LAYOUT_H - -extern unsigned _mesa_combine_swizzles(unsigned base, unsigned applied); - -struct asm_parser_state; - -extern GLboolean _mesa_layout_parameters(struct asm_parser_state *state); - -#endif /* PROG_PARAMETER_LAYOUT_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_print.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_print.c deleted file mode 100644 index 4d736ec72fd..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_print.c +++ /dev/null @@ -1,1126 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.3 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. 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. - */ - -/** - * \file prog_print.c - * Print vertex/fragment programs - for debugging. - * \author Brian Paul - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/imports.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_print.h" -#include "prog_statevars.h" - - - -/** - * Return string name for given program/register file. - */ -const char * -_mesa_register_file_name(gl_register_file f) -{ - switch (f) { - case PROGRAM_TEMPORARY: - return "TEMP"; - case PROGRAM_LOCAL_PARAM: - return "LOCAL"; - case PROGRAM_ENV_PARAM: - return "ENV"; - case PROGRAM_STATE_VAR: - return "STATE"; - case PROGRAM_INPUT: - return "INPUT"; - case PROGRAM_OUTPUT: - return "OUTPUT"; - case PROGRAM_NAMED_PARAM: - return "NAMED"; - case PROGRAM_CONSTANT: - return "CONST"; - case PROGRAM_UNIFORM: - return "UNIFORM"; - case PROGRAM_VARYING: - return "VARYING"; - case PROGRAM_WRITE_ONLY: - return "WRITE_ONLY"; - case PROGRAM_ADDRESS: - return "ADDR"; - case PROGRAM_SAMPLER: - return "SAMPLER"; - case PROGRAM_SYSTEM_VALUE: - return "SYSVAL"; - case PROGRAM_UNDEFINED: - return "UNDEFINED"; - default: - { - static char s[20]; - _mesa_snprintf(s, sizeof(s), "FILE%u", f); - return s; - } - } -} - - -/** - * Return ARB_v/f_prog-style input attrib string. - */ -static const char * -arb_input_attrib_string(GLint index, GLenum progType) -{ - /* - * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. - */ - static const char *const vertAttribs[] = { - "vertex.position", - "vertex.weight", - "vertex.normal", - "vertex.color.primary", - "vertex.color.secondary", - "vertex.fogcoord", - "vertex.(six)", /* VERT_ATTRIB_COLOR_INDEX */ - "vertex.(seven)", /* VERT_ATTRIB_EDGEFLAG */ - "vertex.texcoord[0]", - "vertex.texcoord[1]", - "vertex.texcoord[2]", - "vertex.texcoord[3]", - "vertex.texcoord[4]", - "vertex.texcoord[5]", - "vertex.texcoord[6]", - "vertex.texcoord[7]", - "vertex.(sixteen)", /* VERT_ATTRIB_POINT_SIZE */ - "vertex.attrib[0]", - "vertex.attrib[1]", - "vertex.attrib[2]", - "vertex.attrib[3]", - "vertex.attrib[4]", - "vertex.attrib[5]", - "vertex.attrib[6]", - "vertex.attrib[7]", - "vertex.attrib[8]", - "vertex.attrib[9]", - "vertex.attrib[10]", - "vertex.attrib[11]", - "vertex.attrib[12]", - "vertex.attrib[13]", - "vertex.attrib[14]", - "vertex.attrib[15]" /* MAX_VARYING = 16 */ - }; - static const char *const fragAttribs[] = { - "fragment.position", - "fragment.color.primary", - "fragment.color.secondary", - "fragment.fogcoord", - "fragment.texcoord[0]", - "fragment.texcoord[1]", - "fragment.texcoord[2]", - "fragment.texcoord[3]", - "fragment.texcoord[4]", - "fragment.texcoord[5]", - "fragment.texcoord[6]", - "fragment.texcoord[7]", - "fragment.(twelve)", /* FRAG_ATTRIB_FACE */ - "fragment.(thirteen)", /* FRAG_ATTRIB_PNTC */ - "fragment.(fourteen)", /* FRAG_ATTRIB_CLIP_DIST0 */ - "fragment.(fifteen)", /* FRAG_ATTRIB_CLIP_DIST1 */ - "fragment.varying[0]", - "fragment.varying[1]", - "fragment.varying[2]", - "fragment.varying[3]", - "fragment.varying[4]", - "fragment.varying[5]", - "fragment.varying[6]", - "fragment.varying[7]", - "fragment.varying[8]", - "fragment.varying[9]", - "fragment.varying[10]", - "fragment.varying[11]", - "fragment.varying[12]", - "fragment.varying[13]", - "fragment.varying[14]", - "fragment.varying[15]" /* MAX_VARYING = 16 */ - }; - - /* sanity checks */ - STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX); - STATIC_ASSERT(Elements(fragAttribs) == FRAG_ATTRIB_MAX); - assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); - assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); - assert(strcmp(fragAttribs[FRAG_ATTRIB_TEX0], "fragment.texcoord[0]") == 0); - assert(strcmp(fragAttribs[FRAG_ATTRIB_VAR0+15], "fragment.varying[15]") == 0); - - if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertAttribs)); - return vertAttribs[index]; - } - else { - assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragAttribs)); - return fragAttribs[index]; - } -} - - -/** - * Print a vertex program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_vp_inputs(GLbitfield inputs) -{ - printf("VP Inputs 0x%x: \n", inputs); - while (inputs) { - GLint attr = _mesa_ffs(inputs) - 1; - const char *name = arb_input_attrib_string(attr, - GL_VERTEX_PROGRAM_ARB); - printf(" %d: %s\n", attr, name); - inputs &= ~(1 << attr); - } -} - - -/** - * Print a fragment program's InputsRead field in human-readable format. - * For debugging. - */ -void -_mesa_print_fp_inputs(GLbitfield inputs) -{ - printf("FP Inputs 0x%x: \n", inputs); - while (inputs) { - GLint attr = _mesa_ffs(inputs) - 1; - const char *name = arb_input_attrib_string(attr, - GL_FRAGMENT_PROGRAM_ARB); - printf(" %d: %s\n", attr, name); - inputs &= ~(1 << attr); - } -} - - - -/** - * Return ARB_v/f_prog-style output attrib string. - */ -static const char * -arb_output_attrib_string(GLint index, GLenum progType) -{ - /* - * These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens. - */ - static const char *const vertResults[] = { - "result.position", - "result.color.primary", - "result.color.secondary", - "result.fogcoord", - "result.texcoord[0]", - "result.texcoord[1]", - "result.texcoord[2]", - "result.texcoord[3]", - "result.texcoord[4]", - "result.texcoord[5]", - "result.texcoord[6]", - "result.texcoord[7]", - "result.pointsize", /* VERT_RESULT_PSIZ */ - "result.(thirteen)", /* VERT_RESULT_BFC0 */ - "result.(fourteen)", /* VERT_RESULT_BFC1 */ - "result.(fifteen)", /* VERT_RESULT_EDGE */ - "result.(sixteen)", /* VERT_RESULT_CLIP_VERTEX */ - "result.(seventeen)", /* VERT_RESULT_CLIP_DIST0 */ - "result.(eighteen)", /* VERT_RESULT_CLIP_DIST1 */ - "result.varying[0]", - "result.varying[1]", - "result.varying[2]", - "result.varying[3]", - "result.varying[4]", - "result.varying[5]", - "result.varying[6]", - "result.varying[7]", - "result.varying[8]", - "result.varying[9]", - "result.varying[10]", - "result.varying[11]", - "result.varying[12]", - "result.varying[13]", - "result.varying[14]", - "result.varying[15]" /* MAX_VARYING = 16 */ - }; - static const char *const fragResults[] = { - "result.depth", /* FRAG_RESULT_DEPTH */ - "result.(one)", /* FRAG_RESULT_STENCIL */ - "result.color", /* FRAG_RESULT_COLOR */ - }; - - /* sanity checks */ - STATIC_ASSERT(Elements(vertResults) == VERT_RESULT_MAX); - STATIC_ASSERT(Elements(fragResults) == FRAG_RESULT_MAX); - assert(strcmp(vertResults[VERT_RESULT_HPOS], "result.position") == 0); - assert(strcmp(vertResults[VERT_RESULT_VAR0], "result.varying[0]") == 0); - assert(strcmp(fragResults[FRAG_RESULT_DATA0], "result.color[0]") == 0); - - if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertResults)); - return vertResults[index]; - } - else { - assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragResults)); - return fragResults[index]; - } -} - - -/** - * Return string representation of the given register. - * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined - * by the ARB/NV program languages so we've taken some liberties here. - * \param f the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc) - * \param index number of the register in the register file - * \param mode the output format/mode/style - * \param prog pointer to containing program - */ -static const char * -reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, - GLboolean relAddr, const struct gl_program *prog, - GLboolean hasIndex2, GLboolean relAddr2, GLint index2) -{ - static char str[100]; - const char *addr = relAddr ? "ADDR+" : ""; - - str[0] = 0; - - switch (mode) { - case PROG_PRINT_DEBUG: - sprintf(str, "%s[%s%d]", - _mesa_register_file_name(f), addr, index); - if (hasIndex2) { - int offset = strlen(str); - const char *addr2 = relAddr2 ? "ADDR+" : ""; - sprintf(str+offset, "[%s%d]", addr2, index2); - } - break; - - case PROG_PRINT_ARB: - switch (f) { - case PROGRAM_INPUT: - sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); - break; - case PROGRAM_OUTPUT: - sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); - break; - case PROGRAM_TEMPORARY: - sprintf(str, "temp%d", index); - break; - case PROGRAM_ENV_PARAM: - sprintf(str, "program.env[%s%d]", addr, index); - break; - case PROGRAM_LOCAL_PARAM: - sprintf(str, "program.local[%s%d]", addr, index); - break; - case PROGRAM_VARYING: /* extension */ - sprintf(str, "varying[%s%d]", addr, index); - break; - case PROGRAM_CONSTANT: /* extension */ - sprintf(str, "constant[%s%d]", addr, index); - break; - case PROGRAM_UNIFORM: /* extension */ - sprintf(str, "uniform[%s%d]", addr, index); - break; - case PROGRAM_SYSTEM_VALUE: - sprintf(str, "sysvalue[%s%d]", addr, index); - break; - case PROGRAM_STATE_VAR: - { - struct gl_program_parameter *param - = prog->Parameters->Parameters + index; - char *state = _mesa_program_state_string(param->StateIndexes); - sprintf(str, "%s", state); - free(state); - } - break; - case PROGRAM_ADDRESS: - sprintf(str, "A%d", index); - break; - default: - _mesa_problem(NULL, "bad file in reg_string()"); - } - break; - - case PROG_PRINT_NV: - switch (f) { - case PROGRAM_INPUT: - if (prog->Target == GL_VERTEX_PROGRAM_ARB) - sprintf(str, "v[%d]", index); - else - sprintf(str, "f[%d]", index); - break; - case PROGRAM_OUTPUT: - sprintf(str, "o[%d]", index); - break; - case PROGRAM_TEMPORARY: - sprintf(str, "R%d", index); - break; - case PROGRAM_ENV_PARAM: - sprintf(str, "c[%d]", index); - break; - case PROGRAM_VARYING: /* extension */ - sprintf(str, "varying[%s%d]", addr, index); - break; - case PROGRAM_UNIFORM: /* extension */ - sprintf(str, "uniform[%s%d]", addr, index); - break; - case PROGRAM_CONSTANT: /* extension */ - sprintf(str, "constant[%s%d]", addr, index); - break; - case PROGRAM_STATE_VAR: /* extension */ - sprintf(str, "state[%s%d]", addr, index); - break; - default: - _mesa_problem(NULL, "bad file in reg_string()"); - } - break; - - default: - _mesa_problem(NULL, "bad mode in reg_string()"); - } - - return str; -} - - -/** - * Return a string representation of the given swizzle word. - * If extended is true, use extended (comma-separated) format. - * \param swizzle the swizzle field - * \param negateBase 4-bit negation vector - * \param extended if true, also allow 0, 1 values - */ -const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateMask, GLboolean extended) -{ - static const char swz[] = "xyzw01!?"; /* See SWIZZLE_x definitions */ - static char s[20]; - GLuint i = 0; - - if (!extended && swizzle == SWIZZLE_NOOP && negateMask == 0) - return ""; /* no swizzle/negation */ - - if (!extended) - s[i++] = '.'; - - if (negateMask & NEGATE_X) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 0)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_Y) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 1)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_Z) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 2)]; - - if (extended) { - s[i++] = ','; - } - - if (negateMask & NEGATE_W) - s[i++] = '-'; - s[i++] = swz[GET_SWZ(swizzle, 3)]; - - s[i] = 0; - return s; -} - - -void -_mesa_print_swizzle(GLuint swizzle) -{ - if (swizzle == SWIZZLE_XYZW) { - printf(".xyzw\n"); - } - else { - const char *s = _mesa_swizzle_string(swizzle, 0, 0); - printf("%s\n", s); - } -} - - -const char * -_mesa_writemask_string(GLuint writeMask) -{ - static char s[10]; - GLuint i = 0; - - if (writeMask == WRITEMASK_XYZW) - return ""; - - s[i++] = '.'; - if (writeMask & WRITEMASK_X) - s[i++] = 'x'; - if (writeMask & WRITEMASK_Y) - s[i++] = 'y'; - if (writeMask & WRITEMASK_Z) - s[i++] = 'z'; - if (writeMask & WRITEMASK_W) - s[i++] = 'w'; - - s[i] = 0; - return s; -} - - -const char * -_mesa_condcode_string(GLuint condcode) -{ - switch (condcode) { - case COND_GT: return "GT"; - case COND_EQ: return "EQ"; - case COND_LT: return "LT"; - case COND_UN: return "UN"; - case COND_GE: return "GE"; - case COND_LE: return "LE"; - case COND_NE: return "NE"; - case COND_TR: return "TR"; - case COND_FL: return "FL"; - default: return "cond???"; - } -} - - -static void -fprint_dst_reg(FILE * f, - const struct prog_dst_register *dstReg, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - fprintf(f, "%s%s", - reg_string((gl_register_file) dstReg->File, - dstReg->Index, mode, dstReg->RelAddr, prog, - GL_FALSE, GL_FALSE, 0), - _mesa_writemask_string(dstReg->WriteMask)); - - if (dstReg->CondMask != COND_TR) { - fprintf(f, " (%s.%s)", - _mesa_condcode_string(dstReg->CondMask), - _mesa_swizzle_string(dstReg->CondSwizzle, - GL_FALSE, GL_FALSE)); - } - -#if 0 - fprintf(f, "%s[%d]%s", - _mesa_register_file_name((gl_register_file) dstReg->File), - dstReg->Index, - _mesa_writemask_string(dstReg->WriteMask)); -#endif -} - - -static void -fprint_src_reg(FILE *f, - const struct prog_src_register *srcReg, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - const char *abs = srcReg->Abs ? "|" : ""; - - fprintf(f, "%s%s%s%s", - abs, - reg_string((gl_register_file) srcReg->File, - srcReg->Index, mode, srcReg->RelAddr, prog, - srcReg->HasIndex2, srcReg->RelAddr2, srcReg->Index2), - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE), - abs); -#if 0 - fprintf(f, "%s[%d]%s", - _mesa_register_file_name((gl_register_file) srcReg->File), - srcReg->Index, - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE)); -#endif -} - - -static void -fprint_comment(FILE *f, const struct prog_instruction *inst) -{ - if (inst->Comment) - fprintf(f, "; # %s\n", inst->Comment); - else - fprintf(f, ";\n"); -} - - -void -_mesa_fprint_alu_instruction(FILE *f, - const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - GLuint j; - - fprintf(f, "%s", opcode_string); - if (inst->CondUpdate) - fprintf(f, ".C"); - - /* frag prog only */ - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - - fprintf(f, " "); - if (inst->DstReg.File != PROGRAM_UNDEFINED) { - fprint_dst_reg(f, &inst->DstReg, mode, prog); - } - else { - fprintf(f, " ???"); - } - - if (numRegs > 0) - fprintf(f, ", "); - - for (j = 0; j < numRegs; j++) { - fprint_src_reg(f, inst->SrcReg + j, mode, prog); - if (j + 1 < numRegs) - fprintf(f, ", "); - } - - fprint_comment(f, inst); -} - - -void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs) -{ - _mesa_fprint_alu_instruction(stderr, inst, opcode_string, - numRegs, PROG_PRINT_DEBUG, NULL); -} - - -/** - * Print a single vertex/fragment program instruction. - */ -GLint -_mesa_fprint_instruction_opt(FILE *f, - const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - GLint i; - - if (inst->Opcode == OPCODE_ELSE || - inst->Opcode == OPCODE_ENDIF || - inst->Opcode == OPCODE_ENDLOOP || - inst->Opcode == OPCODE_ENDSUB) { - indent -= 3; - } - for (i = 0; i < indent; i++) { - fprintf(f, " "); - } - - switch (inst->Opcode) { - case OPCODE_PRINT: - fprintf(f, "PRINT '%s'", (char *) inst->Data); - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - fprintf(f, ", "); - fprintf(f, "%s[%d]%s", - _mesa_register_file_name((gl_register_file) inst->SrcReg[0].File), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_FALSE)); - } - if (inst->Comment) - fprintf(f, " # %s", inst->Comment); - fprint_comment(f, inst); - break; - case OPCODE_SWZ: - fprintf(f, "SWZ"); - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - fprintf(f, " "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", %s[%d], %s", - _mesa_register_file_name((gl_register_file) inst->SrcReg[0].File), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_TRUE)); - fprint_comment(f, inst); - break; - case OPCODE_TEX: - case OPCODE_TXP: - case OPCODE_TXL: - case OPCODE_TXB: - case OPCODE_TXD: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - if (inst->SaturateMode == SATURATE_ZERO_ONE) - fprintf(f, "_SAT"); - fprintf(f, " "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - if (inst->Opcode == OPCODE_TXD) { - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[1], mode, prog); - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[2], mode, prog); - } - fprintf(f, ", texture[%d], ", inst->TexSrcUnit); - switch (inst->TexSrcTarget) { - case TEXTURE_1D_INDEX: fprintf(f, "1D"); break; - case TEXTURE_2D_INDEX: fprintf(f, "2D"); break; - case TEXTURE_3D_INDEX: fprintf(f, "3D"); break; - case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE"); break; - default: - ; - } - if (inst->TexShadow) - fprintf(f, " SHADOW"); - fprint_comment(f, inst); - break; - - case OPCODE_KIL: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - fprintf(f, " "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprint_comment(f, inst); - break; - case OPCODE_KIL_NV: - fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - fprintf(f, " "); - fprintf(f, "%s.%s", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - GL_FALSE, GL_FALSE)); - fprint_comment(f, inst); - break; - - case OPCODE_ARL: - fprintf(f, "ARL "); - fprint_dst_reg(f, &inst->DstReg, mode, prog); - fprintf(f, ", "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprint_comment(f, inst); - break; - case OPCODE_BRA: - fprintf(f, "BRA %d (%s%s)", - inst->BranchTarget, - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); - fprint_comment(f, inst); - break; - case OPCODE_IF: - if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - /* Use ordinary register */ - fprintf(f, "IF "); - fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - fprintf(f, "; "); - } - else { - /* Use cond codes */ - fprintf(f, "IF (%s%s);", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - 0, GL_FALSE)); - } - fprintf(f, " # (if false, goto %d)", inst->BranchTarget); - fprint_comment(f, inst); - return indent + 3; - case OPCODE_ELSE: - fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); - return indent + 3; - case OPCODE_ENDIF: - fprintf(f, "ENDIF;\n"); - break; - case OPCODE_BGNLOOP: - fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); - return indent + 3; - case OPCODE_ENDLOOP: - fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); - break; - case OPCODE_BRK: - case OPCODE_CONT: - fprintf(f, "%s (%s%s); # (goto %d)", - _mesa_opcode_string(inst->Opcode), - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), - inst->BranchTarget); - fprint_comment(f, inst); - break; - - case OPCODE_BGNSUB: - if (mode == PROG_PRINT_NV) { - fprintf(f, "%s:\n", inst->Comment); /* comment is label */ - return indent; - } - else { - fprintf(f, "BGNSUB"); - fprint_comment(f, inst); - return indent + 3; - } - case OPCODE_ENDSUB: - if (mode == PROG_PRINT_DEBUG) { - fprintf(f, "ENDSUB"); - fprint_comment(f, inst); - } - break; - case OPCODE_CAL: - if (mode == PROG_PRINT_NV) { - fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); - } - else { - fprintf(f, "CAL %u", inst->BranchTarget); - fprint_comment(f, inst); - } - break; - case OPCODE_RET: - fprintf(f, "RET (%s%s)", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); - fprint_comment(f, inst); - break; - - case OPCODE_END: - fprintf(f, "END\n"); - break; - case OPCODE_NOP: - if (mode == PROG_PRINT_DEBUG) { - fprintf(f, "NOP"); - fprint_comment(f, inst); - } - else if (inst->Comment) { - /* ARB/NV extensions don't have NOP instruction */ - fprintf(f, "# %s\n", inst->Comment); - } - break; - case OPCODE_EMIT_VERTEX: - fprintf(f, "EMIT_VERTEX\n"); - break; - case OPCODE_END_PRIMITIVE: - fprintf(f, "END_PRIMITIVE\n"); - break; - /* XXX may need other special-case instructions */ - default: - if (inst->Opcode < MAX_OPCODE) { - /* typical alu instruction */ - _mesa_fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - _mesa_num_inst_src_regs(inst->Opcode), - mode, prog); - } - else { - _mesa_fprint_alu_instruction(f, inst, - _mesa_opcode_string(inst->Opcode), - 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, - mode, prog); - } - break; - } - return indent; -} - - -GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog) -{ - return _mesa_fprint_instruction_opt(stderr, inst, indent, mode, prog); -} - - -void -_mesa_print_instruction(const struct prog_instruction *inst) -{ - /* note: 4th param should be ignored for PROG_PRINT_DEBUG */ - _mesa_fprint_instruction_opt(stderr, inst, 0, PROG_PRINT_DEBUG, NULL); -} - - - -/** - * Print program, with options. - */ -void -_mesa_fprint_program_opt(FILE *f, - const struct gl_program *prog, - gl_prog_print_mode mode, - GLboolean lineNumbers) -{ - GLuint i, indent = 0; - - switch (prog->Target) { - case GL_VERTEX_PROGRAM_ARB: - if (mode == PROG_PRINT_ARB) - fprintf(f, "!!ARBvp1.0\n"); - else if (mode == PROG_PRINT_NV) - fprintf(f, "!!VP1.0\n"); - else - fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); - break; - case GL_FRAGMENT_PROGRAM_ARB: - case GL_FRAGMENT_PROGRAM_NV: - if (mode == PROG_PRINT_ARB) - fprintf(f, "!!ARBfp1.0\n"); - else if (mode == PROG_PRINT_NV) - fprintf(f, "!!FP1.0\n"); - else - fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); - break; - } - - for (i = 0; i < prog->NumInstructions; i++) { - if (lineNumbers) - fprintf(f, "%3d: ", i); - indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i, - indent, mode, prog); - } -} - - -/** - * Print program to stderr, default options. - */ -void -_mesa_print_program(const struct gl_program *prog) -{ - _mesa_fprint_program_opt(stderr, prog, PROG_PRINT_DEBUG, GL_TRUE); -} - - -/** - * Return binary representation of 64-bit value (as a string). - * Insert a comma to separate each group of 8 bits. - * Note we return a pointer to local static storage so this is not - * re-entrant, etc. - * XXX move to imports.[ch] if useful elsewhere. - */ -static const char * -binary(GLbitfield64 val) -{ - static char buf[80]; - GLint i, len = 0; - for (i = 63; i >= 0; --i) { - if (val & (BITFIELD64_BIT(i))) - buf[len++] = '1'; - else if (len > 0 || i == 0) - buf[len++] = '0'; - if (len > 0 && ((i-1) % 8) == 7) - buf[len++] = ','; - } - buf[len] = '\0'; - return buf; -} - - -/** - * Print all of a program's parameters/fields to given file. - */ -static void -_mesa_fprint_program_parameters(FILE *f, - struct gl_context *ctx, - const struct gl_program *prog) -{ - GLuint i; - - fprintf(f, "InputsRead: 0x%llx (0b%s)\n", - (unsigned long long) prog->InputsRead, binary(prog->InputsRead)); - fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", - (unsigned long long)prog->OutputsWritten, - binary(prog->OutputsWritten)); - fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); - fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); - fprintf(f, "NumParameters=%d\n", prog->NumParameters); - fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); - fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); - fprintf(f, "IndirectRegisterFiles: 0x%x (0b%s)\n", - prog->IndirectRegisterFiles, binary(prog->IndirectRegisterFiles)); - fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", - prog->SamplersUsed, binary(prog->SamplersUsed)); - fprintf(f, "Samplers=[ "); - for (i = 0; i < MAX_SAMPLERS; i++) { - fprintf(f, "%d ", prog->SamplerUnits[i]); - } - fprintf(f, "]\n"); - - _mesa_load_state_parameters(ctx, prog->Parameters); - -#if 0 - fprintf(f, "Local Params:\n"); - for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ - const GLfloat *p = prog->LocalParams[i]; - fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); - } -#endif - _mesa_print_parameter_list(prog->Parameters); -} - - -/** - * Print all of a program's parameters/fields to stderr. - */ -void -_mesa_print_program_parameters(struct gl_context *ctx, const struct gl_program *prog) -{ - _mesa_fprint_program_parameters(stderr, ctx, prog); -} - - -/** - * Print a program parameter list to given file. - */ -static void -_mesa_fprint_parameter_list(FILE *f, - const struct gl_program_parameter_list *list) -{ - GLuint i; - - if (!list) - return; - - if (0) - fprintf(f, "param list %p\n", (void *) list); - fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); - for (i = 0; i < list->NumParameters; i++){ - struct gl_program_parameter *param = list->Parameters + i; - const GLfloat *v = (GLfloat *) list->ParameterValues[i]; - fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", - i, param->Size, - _mesa_register_file_name(list->Parameters[i].Type), - param->Name, v[0], v[1], v[2], v[3]); - if (param->Flags & PROG_PARAM_BIT_CENTROID) - fprintf(f, " Centroid"); - if (param->Flags & PROG_PARAM_BIT_INVARIANT) - fprintf(f, " Invariant"); - if (param->Flags & PROG_PARAM_BIT_FLAT) - fprintf(f, " Flat"); - if (param->Flags & PROG_PARAM_BIT_LINEAR) - fprintf(f, " Linear"); - fprintf(f, "\n"); - } -} - - -/** - * Print a program parameter list to stderr. - */ -void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list) -{ - _mesa_fprint_parameter_list(stderr, list); -} - - -/** - * Write shader and associated info to a file. - */ -void -_mesa_write_shader_to_file(const struct gl_shader *shader) -{ - const char *type; - char filename[100]; - FILE *f; - - if (shader->Type == GL_FRAGMENT_SHADER) - type = "frag"; - else if (shader->Type == GL_VERTEX_SHADER) - type = "vert"; - - _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); - f = fopen(filename, "w"); - if (!f) { - fprintf(stderr, "Unable to open %s for writing\n", filename); - return; - } - - fprintf(f, "/* Shader %u source, checksum %u */\n", shader->Name, shader->SourceChecksum); - fputs(shader->Source, f); - fprintf(f, "\n"); - - fprintf(f, "/* Compile status: %s */\n", - shader->CompileStatus ? "ok" : "fail"); - fprintf(f, "/* Log Info: */\n"); - if (shader->InfoLog) { - fputs(shader->InfoLog, f); - } - if (shader->CompileStatus && shader->Program) { - fprintf(f, "/* GPU code */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); - fprintf(f, "*/\n"); - fprintf(f, "/* Parameters / constants */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_parameter_list(f, shader->Program->Parameters); - fprintf(f, "*/\n"); - } - - fclose(f); -} - - -/** - * Append the shader's uniform info/values to the shader log file. - * The log file will typically have been created by the - * _mesa_write_shader_to_file function. - */ -void -_mesa_append_uniforms_to_file(const struct gl_shader *shader) -{ - const struct gl_program *const prog = shader->Program; - const char *type; - char filename[100]; - FILE *f; - - if (shader->Type == GL_FRAGMENT_SHADER) - type = "frag"; - else - type = "vert"; - - _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); - f = fopen(filename, "a"); /* append */ - if (!f) { - fprintf(stderr, "Unable to open %s for appending\n", filename); - return; - } - - fprintf(f, "/* First-draw parameters / constants */\n"); - fprintf(f, "/*\n"); - _mesa_fprint_parameter_list(f, prog->Parameters); - fprintf(f, "*/\n"); - - fclose(f); -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_print.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_print.h deleted file mode 100644 index b95ec2be570..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_print.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 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 PROG_PRINT_H -#define PROG_PRINT_H - -#include - -#include "main/glheader.h" -#include "main/mtypes.h" - -struct gl_program; -struct gl_program_parameter_list; -struct gl_shader; -struct prog_instruction; - - -/** - * The output style to use when printing programs. - */ -typedef enum { - PROG_PRINT_ARB, - PROG_PRINT_NV, - PROG_PRINT_DEBUG -} gl_prog_print_mode; - - -extern const char * -_mesa_register_file_name(gl_register_file f); - -extern void -_mesa_print_vp_inputs(GLbitfield inputs); - -extern void -_mesa_print_fp_inputs(GLbitfield inputs); - -extern const char * -_mesa_condcode_string(GLuint condcode); - -extern const char * -_mesa_swizzle_string(GLuint swizzle, GLuint negateBase, GLboolean extended); - -const char * -_mesa_writemask_string(GLuint writeMask); - -extern void -_mesa_print_swizzle(GLuint swizzle); - -extern void -_mesa_fprint_alu_instruction(FILE *f, - const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs, - gl_prog_print_mode mode, - const struct gl_program *prog); - -extern void -_mesa_print_alu_instruction(const struct prog_instruction *inst, - const char *opcode_string, GLuint numRegs); - -extern void -_mesa_print_instruction(const struct prog_instruction *inst); - -extern GLint -_mesa_fprint_instruction_opt(FILE *f, - const struct prog_instruction *inst, - GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog); - -extern GLint -_mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent, - gl_prog_print_mode mode, - const struct gl_program *prog); - -extern void -_mesa_print_program(const struct gl_program *prog); - -extern void -_mesa_fprint_program_opt(FILE *f, - const struct gl_program *prog, gl_prog_print_mode mode, - GLboolean lineNumbers); - -extern void -_mesa_print_program_parameters(struct gl_context *ctx, const struct gl_program *prog); - -extern void -_mesa_print_parameter_list(const struct gl_program_parameter_list *list); - - -extern void -_mesa_write_shader_to_file(const struct gl_shader *shader); - -extern void -_mesa_append_uniforms_to_file(const struct gl_shader *shader); - - -#endif /* PROG_PRINT_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.c b/reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.c deleted file mode 100644 index 030af503204..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.c +++ /dev/null @@ -1,1182 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 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. - */ - -/** - * \file prog_statevars.c - * Program state variable management. - * \author Brian Paul - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/imports.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "prog_statevars.h" -#include "prog_parameter.h" - - -/** - * Use the list of tokens in the state[] array to find global GL state - * and return it in . Usually, four values are returned in - * but matrix queries may return as many as 16 values. - * This function is used for ARB vertex/fragment programs. - * The program parser will produce the state[] values. - */ -static void -_mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], - GLfloat *value) -{ - switch (state[0]) { - case STATE_MATERIAL: - { - /* state[1] is either 0=front or 1=back side */ - const GLuint face = (GLuint) state[1]; - const struct gl_material *mat = &ctx->Light.Material; - ASSERT(face == 0 || face == 1); - /* we rely on tokens numbered so that _BACK_ == _FRONT_+ 1 */ - ASSERT(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT); - /* XXX we could get rid of this switch entirely with a little - * work in arbprogparse.c's parse_state_single_item(). - */ - /* state[2] is the material attribute */ - switch (state[2]) { - case STATE_AMBIENT: - COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_AMBIENT + face]); - return; - case STATE_DIFFUSE: - COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_DIFFUSE + face]); - return; - case STATE_SPECULAR: - COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_SPECULAR + face]); - return; - case STATE_EMISSION: - COPY_4V(value, mat->Attrib[MAT_ATTRIB_FRONT_EMISSION + face]); - return; - case STATE_SHININESS: - value[0] = mat->Attrib[MAT_ATTRIB_FRONT_SHININESS + face][0]; - value[1] = 0.0F; - value[2] = 0.0F; - value[3] = 1.0F; - return; - default: - _mesa_problem(ctx, "Invalid material state in fetch_state"); - return; - } - } - case STATE_LIGHT: - { - /* state[1] is the light number */ - const GLuint ln = (GLuint) state[1]; - /* state[2] is the light attribute */ - switch (state[2]) { - case STATE_AMBIENT: - COPY_4V(value, ctx->Light.Light[ln].Ambient); - return; - case STATE_DIFFUSE: - COPY_4V(value, ctx->Light.Light[ln].Diffuse); - return; - case STATE_SPECULAR: - COPY_4V(value, ctx->Light.Light[ln].Specular); - return; - case STATE_POSITION: - COPY_4V(value, ctx->Light.Light[ln].EyePosition); - return; - case STATE_ATTENUATION: - value[0] = ctx->Light.Light[ln].ConstantAttenuation; - value[1] = ctx->Light.Light[ln].LinearAttenuation; - value[2] = ctx->Light.Light[ln].QuadraticAttenuation; - value[3] = ctx->Light.Light[ln].SpotExponent; - return; - case STATE_SPOT_DIRECTION: - COPY_3V(value, ctx->Light.Light[ln].SpotDirection); - value[3] = ctx->Light.Light[ln]._CosCutoff; - return; - case STATE_SPOT_CUTOFF: - value[0] = ctx->Light.Light[ln].SpotCutoff; - return; - case STATE_HALF_VECTOR: - { - static const GLfloat eye_z[] = {0, 0, 1}; - GLfloat p[3]; - /* Compute infinite half angle vector: - * halfVector = normalize(normalize(lightPos) + (0, 0, 1)) - * light.EyePosition.w should be 0 for infinite lights. - */ - COPY_3V(p, ctx->Light.Light[ln].EyePosition); - NORMALIZE_3FV(p); - ADD_3V(value, p, eye_z); - NORMALIZE_3FV(value); - value[3] = 1.0; - } - return; - default: - _mesa_problem(ctx, "Invalid light state in fetch_state"); - return; - } - } - case STATE_LIGHTMODEL_AMBIENT: - COPY_4V(value, ctx->Light.Model.Ambient); - return; - case STATE_LIGHTMODEL_SCENECOLOR: - if (state[1] == 0) { - /* front */ - GLint i; - for (i = 0; i < 3; i++) { - value[i] = ctx->Light.Model.Ambient[i] - * ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT][i] - + ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION][i]; - } - value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - } - else { - /* back */ - GLint i; - for (i = 0; i < 3; i++) { - value[i] = ctx->Light.Model.Ambient[i] - * ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_AMBIENT][i] - + ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_EMISSION][i]; - } - value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; - } - return; - case STATE_LIGHTPROD: - { - const GLuint ln = (GLuint) state[1]; - const GLuint face = (GLuint) state[2]; - GLint i; - ASSERT(face == 0 || face == 1); - switch (state[3]) { - case STATE_AMBIENT: - for (i = 0; i < 3; i++) { - value[i] = ctx->Light.Light[ln].Ambient[i] * - ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT+face][i]; - } - /* [3] = material alpha */ - value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT+face][3]; - return; - case STATE_DIFFUSE: - for (i = 0; i < 3; i++) { - value[i] = ctx->Light.Light[ln].Diffuse[i] * - ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][i]; - } - /* [3] = material alpha */ - value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][3]; - return; - case STATE_SPECULAR: - for (i = 0; i < 3; i++) { - value[i] = ctx->Light.Light[ln].Specular[i] * - ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SPECULAR+face][i]; - } - /* [3] = material alpha */ - value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SPECULAR+face][3]; - return; - default: - _mesa_problem(ctx, "Invalid lightprod state in fetch_state"); - return; - } - } - case STATE_TEXGEN: - { - /* state[1] is the texture unit */ - const GLuint unit = (GLuint) state[1]; - /* state[2] is the texgen attribute */ - switch (state[2]) { - case STATE_TEXGEN_EYE_S: - COPY_4V(value, ctx->Texture.Unit[unit].GenS.EyePlane); - return; - case STATE_TEXGEN_EYE_T: - COPY_4V(value, ctx->Texture.Unit[unit].GenT.EyePlane); - return; - case STATE_TEXGEN_EYE_R: - COPY_4V(value, ctx->Texture.Unit[unit].GenR.EyePlane); - return; - case STATE_TEXGEN_EYE_Q: - COPY_4V(value, ctx->Texture.Unit[unit].GenQ.EyePlane); - return; - case STATE_TEXGEN_OBJECT_S: - COPY_4V(value, ctx->Texture.Unit[unit].GenS.ObjectPlane); - return; - case STATE_TEXGEN_OBJECT_T: - COPY_4V(value, ctx->Texture.Unit[unit].GenT.ObjectPlane); - return; - case STATE_TEXGEN_OBJECT_R: - COPY_4V(value, ctx->Texture.Unit[unit].GenR.ObjectPlane); - return; - case STATE_TEXGEN_OBJECT_Q: - COPY_4V(value, ctx->Texture.Unit[unit].GenQ.ObjectPlane); - return; - default: - _mesa_problem(ctx, "Invalid texgen state in fetch_state"); - return; - } - } - case STATE_TEXENV_COLOR: - { - /* state[1] is the texture unit */ - const GLuint unit = (GLuint) state[1]; - COPY_4V(value, ctx->Texture.Unit[unit].EnvColor); - } - return; - case STATE_FOG_COLOR: - COPY_4V(value, ctx->Fog.Color); - return; - case STATE_FOG_PARAMS: - value[0] = ctx->Fog.Density; - value[1] = ctx->Fog.Start; - value[2] = ctx->Fog.End; - value[3] = (ctx->Fog.End == ctx->Fog.Start) - ? 1.0f : (GLfloat)(1.0 / (ctx->Fog.End - ctx->Fog.Start)); - return; - case STATE_CLIPPLANE: - { - const GLuint plane = (GLuint) state[1]; - COPY_4V(value, ctx->Transform.EyeUserPlane[plane]); - } - return; - case STATE_POINT_SIZE: - value[0] = ctx->Point.Size; - value[1] = ctx->Point.MinSize; - value[2] = ctx->Point.MaxSize; - value[3] = ctx->Point.Threshold; - return; - case STATE_POINT_ATTENUATION: - value[0] = ctx->Point.Params[0]; - value[1] = ctx->Point.Params[1]; - value[2] = ctx->Point.Params[2]; - value[3] = 1.0F; - return; - case STATE_MODELVIEW_MATRIX: - case STATE_PROJECTION_MATRIX: - case STATE_MVP_MATRIX: - case STATE_TEXTURE_MATRIX: - case STATE_PROGRAM_MATRIX: - { - /* state[0] = modelview, projection, texture, etc. */ - /* state[1] = which texture matrix or program matrix */ - /* state[2] = first row to fetch */ - /* state[3] = last row to fetch */ - /* state[4] = transpose, inverse or invtrans */ - const GLmatrix *matrix; - const gl_state_index mat = state[0]; - const GLuint index = (GLuint) state[1]; - const GLuint firstRow = (GLuint) state[2]; - const GLuint lastRow = (GLuint) state[3]; - const gl_state_index modifier = state[4]; - const GLfloat *m; - GLuint row, i; - ASSERT(firstRow >= 0); - ASSERT(firstRow < 4); - ASSERT(lastRow >= 0); - ASSERT(lastRow < 4); - if (mat == STATE_MODELVIEW_MATRIX) { - matrix = ctx->ModelviewMatrixStack.Top; - } - else if (mat == STATE_PROJECTION_MATRIX) { - matrix = ctx->ProjectionMatrixStack.Top; - } - else if (mat == STATE_MVP_MATRIX) { - matrix = &ctx->_ModelProjectMatrix; - } - else if (mat == STATE_TEXTURE_MATRIX) { - ASSERT(index < Elements(ctx->TextureMatrixStack)); - matrix = ctx->TextureMatrixStack[index].Top; - } - else if (mat == STATE_PROGRAM_MATRIX) { - ASSERT(index < Elements(ctx->ProgramMatrixStack)); - matrix = ctx->ProgramMatrixStack[index].Top; - } - else { - _mesa_problem(ctx, "Bad matrix name in _mesa_fetch_state()"); - return; - } - if (modifier == STATE_MATRIX_INVERSE || - modifier == STATE_MATRIX_INVTRANS) { - /* Be sure inverse is up to date: - */ - _math_matrix_alloc_inv( (GLmatrix *) matrix ); - _math_matrix_analyse( (GLmatrix*) matrix ); - m = matrix->inv; - } - else { - m = matrix->m; - } - if (modifier == STATE_MATRIX_TRANSPOSE || - modifier == STATE_MATRIX_INVTRANS) { - for (i = 0, row = firstRow; row <= lastRow; row++) { - value[i++] = m[row * 4 + 0]; - value[i++] = m[row * 4 + 1]; - value[i++] = m[row * 4 + 2]; - value[i++] = m[row * 4 + 3]; - } - } - else { - for (i = 0, row = firstRow; row <= lastRow; row++) { - value[i++] = m[row + 0]; - value[i++] = m[row + 4]; - value[i++] = m[row + 8]; - value[i++] = m[row + 12]; - } - } - } - return; - case STATE_DEPTH_RANGE: - value[0] = ctx->Viewport.Near; /* near */ - value[1] = ctx->Viewport.Far; /* far */ - value[2] = ctx->Viewport.Far - ctx->Viewport.Near; /* far - near */ - value[3] = 1.0; - return; - case STATE_FRAGMENT_PROGRAM: - { - /* state[1] = {STATE_ENV, STATE_LOCAL} */ - /* state[2] = parameter index */ - const int idx = (int) state[2]; - switch (state[1]) { - case STATE_ENV: - COPY_4V(value, ctx->FragmentProgram.Parameters[idx]); - return; - case STATE_LOCAL: - COPY_4V(value, ctx->FragmentProgram.Current->Base.LocalParams[idx]); - return; - default: - _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()"); - return; - } - } - return; - - case STATE_VERTEX_PROGRAM: - { - /* state[1] = {STATE_ENV, STATE_LOCAL} */ - /* state[2] = parameter index */ - const int idx = (int) state[2]; - switch (state[1]) { - case STATE_ENV: - COPY_4V(value, ctx->VertexProgram.Parameters[idx]); - return; - case STATE_LOCAL: - COPY_4V(value, ctx->VertexProgram.Current->Base.LocalParams[idx]); - return; - default: - _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()"); - return; - } - } - return; - - case STATE_NORMAL_SCALE: - ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1); - return; - - case STATE_INTERNAL: - switch (state[1]) { - case STATE_CURRENT_ATTRIB: - { - const GLuint idx = (GLuint) state[2]; - COPY_4V(value, ctx->Current.Attrib[idx]); - } - return; - - case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: - { - const GLuint idx = (GLuint) state[2]; - if(idx == VERT_ATTRIB_COLOR0 || - idx == VERT_ATTRIB_COLOR1) { - value[0] = CLAMP(ctx->Current.Attrib[idx][0], 0.0f, 1.0f); - value[1] = CLAMP(ctx->Current.Attrib[idx][1], 0.0f, 1.0f); - value[2] = CLAMP(ctx->Current.Attrib[idx][2], 0.0f, 1.0f); - value[3] = CLAMP(ctx->Current.Attrib[idx][3], 0.0f, 1.0f); - } - else - COPY_4V(value, ctx->Current.Attrib[idx]); - } - return; - - case STATE_NORMAL_SCALE: - ASSIGN_4V(value, - ctx->_ModelViewInvScale, - ctx->_ModelViewInvScale, - ctx->_ModelViewInvScale, - 1); - return; - - case STATE_TEXRECT_SCALE: - /* Value = { 1/texWidth, 1/texHeight, 0, 1 }. - * Used to convert unnormalized texcoords to normalized texcoords. - */ - { - const int unit = (int) state[2]; - const struct gl_texture_object *texObj - = ctx->Texture.Unit[unit]._Current; - if (texObj) { - struct gl_texture_image *texImage = texObj->Image[0][0]; - ASSIGN_4V(value, - (GLfloat) (1.0 / texImage->Width), - (GLfloat) (1.0 / texImage->Height), - 0.0f, 1.0f); - } - } - return; - - case STATE_FOG_PARAMS_OPTIMIZED: - /* for simpler per-vertex/pixel fog calcs. POW (for EXP/EXP2 fog) - * might be more expensive than EX2 on some hw, plus it needs - * another constant (e) anyway. Linear fog can now be done with a - * single MAD. - * linear: fogcoord * -1/(end-start) + end/(end-start) - * exp: 2^-(density/ln(2) * fogcoord) - * exp2: 2^-((density/(ln(2)^2) * fogcoord)^2) - */ - value[0] = (ctx->Fog.End == ctx->Fog.Start) - ? 1.0f : (GLfloat)(-1.0F / (ctx->Fog.End - ctx->Fog.Start)); - value[1] = ctx->Fog.End * -value[0]; - value[2] = (GLfloat)(ctx->Fog.Density * M_LOG2E); /* M_LOG2E == 1/ln(2) */ - value[3] = (GLfloat)(ctx->Fog.Density * ONE_DIV_SQRT_LN2); - return; - - case STATE_POINT_SIZE_CLAMPED: - { - /* this includes implementation dependent limits, to avoid - * another potentially necessary clamp. - * Note: for sprites, point smooth (point AA) is ignored - * and we'll clamp to MinPointSizeAA and MaxPointSize, because we - * expect drivers will want to say their minimum for AA size is 0.0 - * but for non-AA it's 1.0 (because normal points with size below 1.0 - * need to get rounded up to 1.0, hence never disappear). GL does - * not specify max clamp size for sprites, other than it needs to be - * at least as large as max AA size, hence use non-AA size there. - */ - GLfloat minImplSize; - GLfloat maxImplSize; - if (ctx->Point.PointSprite) { - minImplSize = ctx->Const.MinPointSizeAA; - maxImplSize = ctx->Const.MaxPointSize; - } - else if (ctx->Point.SmoothFlag || ctx->Multisample._Enabled) { - minImplSize = ctx->Const.MinPointSizeAA; - maxImplSize = ctx->Const.MaxPointSizeAA; - } - else { - minImplSize = ctx->Const.MinPointSize; - maxImplSize = ctx->Const.MaxPointSize; - } - value[0] = ctx->Point.Size; - value[1] = ctx->Point.MinSize >= minImplSize ? ctx->Point.MinSize : minImplSize; - value[2] = ctx->Point.MaxSize <= maxImplSize ? ctx->Point.MaxSize : maxImplSize; - value[3] = ctx->Point.Threshold; - } - return; - case STATE_POINT_SIZE_IMPL_CLAMP: - { - /* for implementation clamp only in vs */ - GLfloat minImplSize; - GLfloat maxImplSize; - if (ctx->Point.PointSprite) { - minImplSize = ctx->Const.MinPointSizeAA; - maxImplSize = ctx->Const.MaxPointSize; - } - else if (ctx->Point.SmoothFlag || ctx->Multisample._Enabled) { - minImplSize = ctx->Const.MinPointSizeAA; - maxImplSize = ctx->Const.MaxPointSizeAA; - } - else { - minImplSize = ctx->Const.MinPointSize; - maxImplSize = ctx->Const.MaxPointSize; - } - value[0] = ctx->Point.Size; - value[1] = minImplSize; - value[2] = maxImplSize; - value[3] = ctx->Point.Threshold; - } - return; - case STATE_LIGHT_SPOT_DIR_NORMALIZED: - { - /* here, state[2] is the light number */ - /* pre-normalize spot dir */ - const GLuint ln = (GLuint) state[2]; - COPY_3V(value, ctx->Light.Light[ln]._NormSpotDirection); - value[3] = ctx->Light.Light[ln]._CosCutoff; - } - return; - - case STATE_LIGHT_POSITION: - { - const GLuint ln = (GLuint) state[2]; - COPY_4V(value, ctx->Light.Light[ln]._Position); - } - return; - - case STATE_LIGHT_POSITION_NORMALIZED: - { - const GLuint ln = (GLuint) state[2]; - COPY_4V(value, ctx->Light.Light[ln]._Position); - NORMALIZE_3FV( value ); - } - return; - - case STATE_LIGHT_HALF_VECTOR: - { - const GLuint ln = (GLuint) state[2]; - GLfloat p[3]; - /* Compute infinite half angle vector: - * halfVector = normalize(normalize(lightPos) + (0, 0, 1)) - * light.EyePosition.w should be 0 for infinite lights. - */ - COPY_3V(p, ctx->Light.Light[ln]._Position); - NORMALIZE_3FV(p); - ADD_3V(value, p, ctx->_EyeZDir); - NORMALIZE_3FV(value); - value[3] = 1.0; - } - return; - - case STATE_PT_SCALE: - value[0] = ctx->Pixel.RedScale; - value[1] = ctx->Pixel.GreenScale; - value[2] = ctx->Pixel.BlueScale; - value[3] = ctx->Pixel.AlphaScale; - return; - - case STATE_PT_BIAS: - value[0] = ctx->Pixel.RedBias; - value[1] = ctx->Pixel.GreenBias; - value[2] = ctx->Pixel.BlueBias; - value[3] = ctx->Pixel.AlphaBias; - return; - - case STATE_FB_SIZE: - value[0] = (GLfloat) (ctx->DrawBuffer->Width - 1); - value[1] = (GLfloat) (ctx->DrawBuffer->Height - 1); - value[2] = 0.0F; - value[3] = 0.0F; - return; - - case STATE_FB_WPOS_Y_TRANSFORM: - /* A driver may negate this conditional by using ZW swizzle - * instead of XY (based on e.g. some other state). */ - /* Flipping Y upside down (XY) followed by identity (ZW). */ - value[0] = -1.0F; - value[1] = (GLfloat) ctx->DrawBuffer->Height; - value[2] = 1.0F; - value[3] = 0.0F; - return; - - case STATE_ROT_MATRIX_0: - { - const int unit = (int) state[2]; - GLfloat *rotMat22 = ctx->Texture.Unit[unit].RotMatrix; - value[0] = rotMat22[0]; - value[1] = rotMat22[2]; - value[2] = 0.0; - value[3] = 0.0; - } - return; - - case STATE_ROT_MATRIX_1: - { - const int unit = (int) state[2]; - GLfloat *rotMat22 = ctx->Texture.Unit[unit].RotMatrix; - value[0] = rotMat22[1]; - value[1] = rotMat22[3]; - value[2] = 0.0; - value[3] = 0.0; - } - return; - - /* XXX: make sure new tokens added here are also handled in the - * _mesa_program_state_flags() switch, below. - */ - default: - /* Unknown state indexes are silently ignored here. - * Drivers may do something special. - */ - return; - } - return; - - default: - _mesa_problem(ctx, "Invalid state in _mesa_fetch_state"); - return; - } -} - - -/** - * Return a bitmask of the Mesa state flags (_NEW_* values) which would - * indicate that the given context state may have changed. - * The bitmask is used during validation to determine if we need to update - * vertex/fragment program parameters (like "state.material.color") when - * some GL state has changed. - */ -GLbitfield -_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) -{ - switch (state[0]) { - case STATE_MATERIAL: - case STATE_LIGHTPROD: - case STATE_LIGHTMODEL_SCENECOLOR: - /* these can be effected by glColor when colormaterial mode is used */ - return _NEW_LIGHT | _NEW_CURRENT_ATTRIB; - - case STATE_LIGHT: - case STATE_LIGHTMODEL_AMBIENT: - return _NEW_LIGHT; - - case STATE_TEXGEN: - return _NEW_TEXTURE; - case STATE_TEXENV_COLOR: - return _NEW_TEXTURE | _NEW_BUFFERS; - - case STATE_FOG_COLOR: - return _NEW_FOG | _NEW_BUFFERS; - case STATE_FOG_PARAMS: - return _NEW_FOG; - - case STATE_CLIPPLANE: - return _NEW_TRANSFORM; - - case STATE_POINT_SIZE: - case STATE_POINT_ATTENUATION: - return _NEW_POINT; - - case STATE_MODELVIEW_MATRIX: - return _NEW_MODELVIEW; - case STATE_PROJECTION_MATRIX: - return _NEW_PROJECTION; - case STATE_MVP_MATRIX: - return _NEW_MODELVIEW | _NEW_PROJECTION; - case STATE_TEXTURE_MATRIX: - return _NEW_TEXTURE_MATRIX; - case STATE_PROGRAM_MATRIX: - return _NEW_TRACK_MATRIX; - - case STATE_DEPTH_RANGE: - return _NEW_VIEWPORT; - - case STATE_FRAGMENT_PROGRAM: - case STATE_VERTEX_PROGRAM: - return _NEW_PROGRAM; - - case STATE_NORMAL_SCALE: - return _NEW_MODELVIEW; - - case STATE_INTERNAL: - switch (state[1]) { - case STATE_CURRENT_ATTRIB: - return _NEW_CURRENT_ATTRIB; - case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: - return _NEW_CURRENT_ATTRIB | _NEW_LIGHT | _NEW_BUFFERS; - - case STATE_NORMAL_SCALE: - return _NEW_MODELVIEW; - - case STATE_TEXRECT_SCALE: - case STATE_SHADOW_AMBIENT: - case STATE_ROT_MATRIX_0: - case STATE_ROT_MATRIX_1: - return _NEW_TEXTURE; - case STATE_FOG_PARAMS_OPTIMIZED: - return _NEW_FOG; - case STATE_POINT_SIZE_CLAMPED: - case STATE_POINT_SIZE_IMPL_CLAMP: - return _NEW_POINT; - case STATE_LIGHT_SPOT_DIR_NORMALIZED: - case STATE_LIGHT_POSITION: - case STATE_LIGHT_POSITION_NORMALIZED: - case STATE_LIGHT_HALF_VECTOR: - return _NEW_LIGHT; - - case STATE_PT_SCALE: - case STATE_PT_BIAS: - return _NEW_PIXEL; - - case STATE_FB_SIZE: - case STATE_FB_WPOS_Y_TRANSFORM: - return _NEW_BUFFERS; - - default: - /* unknown state indexes are silently ignored and - * no flag set, since it is handled by the driver. - */ - return 0; - } - - default: - _mesa_problem(NULL, "unexpected state[0] in make_state_flags()"); - return 0; - } -} - - -static void -append(char *dst, const char *src) -{ - while (*dst) - dst++; - while (*src) - *dst++ = *src++; - *dst = 0; -} - - -/** - * Convert token 'k' to a string, append it onto 'dst' string. - */ -static void -append_token(char *dst, gl_state_index k) -{ - switch (k) { - case STATE_MATERIAL: - append(dst, "material"); - break; - case STATE_LIGHT: - append(dst, "light"); - break; - case STATE_LIGHTMODEL_AMBIENT: - append(dst, "lightmodel.ambient"); - break; - case STATE_LIGHTMODEL_SCENECOLOR: - break; - case STATE_LIGHTPROD: - append(dst, "lightprod"); - break; - case STATE_TEXGEN: - append(dst, "texgen"); - break; - case STATE_FOG_COLOR: - append(dst, "fog.color"); - break; - case STATE_FOG_PARAMS: - append(dst, "fog.params"); - break; - case STATE_CLIPPLANE: - append(dst, "clip"); - break; - case STATE_POINT_SIZE: - append(dst, "point.size"); - break; - case STATE_POINT_ATTENUATION: - append(dst, "point.attenuation"); - break; - case STATE_MODELVIEW_MATRIX: - append(dst, "matrix.modelview"); - break; - case STATE_PROJECTION_MATRIX: - append(dst, "matrix.projection"); - break; - case STATE_MVP_MATRIX: - append(dst, "matrix.mvp"); - break; - case STATE_TEXTURE_MATRIX: - append(dst, "matrix.texture"); - break; - case STATE_PROGRAM_MATRIX: - append(dst, "matrix.program"); - break; - case STATE_MATRIX_INVERSE: - append(dst, ".inverse"); - break; - case STATE_MATRIX_TRANSPOSE: - append(dst, ".transpose"); - break; - case STATE_MATRIX_INVTRANS: - append(dst, ".invtrans"); - break; - case STATE_AMBIENT: - append(dst, ".ambient"); - break; - case STATE_DIFFUSE: - append(dst, ".diffuse"); - break; - case STATE_SPECULAR: - append(dst, ".specular"); - break; - case STATE_EMISSION: - append(dst, ".emission"); - break; - case STATE_SHININESS: - append(dst, "lshininess"); - break; - case STATE_HALF_VECTOR: - append(dst, ".half"); - break; - case STATE_POSITION: - append(dst, ".position"); - break; - case STATE_ATTENUATION: - append(dst, ".attenuation"); - break; - case STATE_SPOT_DIRECTION: - append(dst, ".spot.direction"); - break; - case STATE_SPOT_CUTOFF: - append(dst, ".spot.cutoff"); - break; - case STATE_TEXGEN_EYE_S: - append(dst, ".eye.s"); - break; - case STATE_TEXGEN_EYE_T: - append(dst, ".eye.t"); - break; - case STATE_TEXGEN_EYE_R: - append(dst, ".eye.r"); - break; - case STATE_TEXGEN_EYE_Q: - append(dst, ".eye.q"); - break; - case STATE_TEXGEN_OBJECT_S: - append(dst, ".object.s"); - break; - case STATE_TEXGEN_OBJECT_T: - append(dst, ".object.t"); - break; - case STATE_TEXGEN_OBJECT_R: - append(dst, ".object.r"); - break; - case STATE_TEXGEN_OBJECT_Q: - append(dst, ".object.q"); - break; - case STATE_TEXENV_COLOR: - append(dst, "texenv"); - break; - case STATE_DEPTH_RANGE: - append(dst, "depth.range"); - break; - case STATE_VERTEX_PROGRAM: - case STATE_FRAGMENT_PROGRAM: - break; - case STATE_ENV: - append(dst, "env"); - break; - case STATE_LOCAL: - append(dst, "local"); - break; - /* BEGIN internal state vars */ - case STATE_INTERNAL: - append(dst, ".internal."); - break; - case STATE_CURRENT_ATTRIB: - append(dst, "current"); - break; - case STATE_NORMAL_SCALE: - append(dst, "normalScale"); - break; - case STATE_TEXRECT_SCALE: - append(dst, "texrectScale"); - break; - case STATE_FOG_PARAMS_OPTIMIZED: - append(dst, "fogParamsOptimized"); - break; - case STATE_POINT_SIZE_CLAMPED: - append(dst, "pointSizeClamped"); - break; - case STATE_POINT_SIZE_IMPL_CLAMP: - append(dst, "pointSizeImplClamp"); - break; - case STATE_LIGHT_SPOT_DIR_NORMALIZED: - append(dst, "lightSpotDirNormalized"); - break; - case STATE_LIGHT_POSITION: - append(dst, "lightPosition"); - break; - case STATE_LIGHT_POSITION_NORMALIZED: - append(dst, "light.position.normalized"); - break; - case STATE_LIGHT_HALF_VECTOR: - append(dst, "lightHalfVector"); - break; - case STATE_PT_SCALE: - append(dst, "PTscale"); - break; - case STATE_PT_BIAS: - append(dst, "PTbias"); - break; - case STATE_SHADOW_AMBIENT: - append(dst, "CompareFailValue"); - break; - case STATE_FB_SIZE: - append(dst, "FbSize"); - break; - case STATE_FB_WPOS_Y_TRANSFORM: - append(dst, "FbWposYTransform"); - break; - case STATE_ROT_MATRIX_0: - append(dst, "rotMatrixRow0"); - break; - case STATE_ROT_MATRIX_1: - append(dst, "rotMatrixRow1"); - break; - default: - /* probably STATE_INTERNAL_DRIVER+i (driver private state) */ - append(dst, "driverState"); - } -} - -static void -append_face(char *dst, GLint face) -{ - if (face == 0) - append(dst, "front."); - else - append(dst, "back."); -} - -static void -append_index(char *dst, GLint index) -{ - char s[20]; - sprintf(s, "[%d]", index); - append(dst, s); -} - -/** - * Make a string from the given state vector. - * For example, return "state.matrix.texture[2].inverse". - * Use free() to deallocate the string. - */ -char * -_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) -{ - char str[1000] = ""; - char tmp[30]; - - append(str, "state."); - append_token(str, state[0]); - - switch (state[0]) { - case STATE_MATERIAL: - append_face(str, state[1]); - append_token(str, state[2]); - break; - case STATE_LIGHT: - append_index(str, state[1]); /* light number [i]. */ - append_token(str, state[2]); /* coefficients */ - break; - case STATE_LIGHTMODEL_AMBIENT: - append(str, "lightmodel.ambient"); - break; - case STATE_LIGHTMODEL_SCENECOLOR: - if (state[1] == 0) { - append(str, "lightmodel.front.scenecolor"); - } - else { - append(str, "lightmodel.back.scenecolor"); - } - break; - case STATE_LIGHTPROD: - append_index(str, state[1]); /* light number [i]. */ - append_face(str, state[2]); - append_token(str, state[3]); - break; - case STATE_TEXGEN: - append_index(str, state[1]); /* tex unit [i] */ - append_token(str, state[2]); /* plane coef */ - break; - case STATE_TEXENV_COLOR: - append_index(str, state[1]); /* tex unit [i] */ - append(str, "color"); - break; - case STATE_CLIPPLANE: - append_index(str, state[1]); /* plane [i] */ - append(str, ".plane"); - break; - case STATE_MODELVIEW_MATRIX: - case STATE_PROJECTION_MATRIX: - case STATE_MVP_MATRIX: - case STATE_TEXTURE_MATRIX: - case STATE_PROGRAM_MATRIX: - { - /* state[0] = modelview, projection, texture, etc. */ - /* state[1] = which texture matrix or program matrix */ - /* state[2] = first row to fetch */ - /* state[3] = last row to fetch */ - /* state[4] = transpose, inverse or invtrans */ - const gl_state_index mat = state[0]; - const GLuint index = (GLuint) state[1]; - const GLuint firstRow = (GLuint) state[2]; - const GLuint lastRow = (GLuint) state[3]; - const gl_state_index modifier = state[4]; - if (index || - mat == STATE_TEXTURE_MATRIX || - mat == STATE_PROGRAM_MATRIX) - append_index(str, index); - if (modifier) - append_token(str, modifier); - if (firstRow == lastRow) - sprintf(tmp, ".row[%d]", firstRow); - else - sprintf(tmp, ".row[%d..%d]", firstRow, lastRow); - append(str, tmp); - } - break; - case STATE_POINT_SIZE: - break; - case STATE_POINT_ATTENUATION: - break; - case STATE_FOG_PARAMS: - break; - case STATE_FOG_COLOR: - break; - case STATE_DEPTH_RANGE: - break; - case STATE_FRAGMENT_PROGRAM: - case STATE_VERTEX_PROGRAM: - /* state[1] = {STATE_ENV, STATE_LOCAL} */ - /* state[2] = parameter index */ - append_token(str, state[1]); - append_index(str, state[2]); - break; - case STATE_NORMAL_SCALE: - break; - case STATE_INTERNAL: - append_token(str, state[1]); - if (state[1] == STATE_CURRENT_ATTRIB) - append_index(str, state[2]); - break; - default: - _mesa_problem(NULL, "Invalid state in _mesa_program_state_string"); - break; - } - - return _mesa_strdup(str); -} - - -/** - * Loop over all the parameters in a parameter list. If the parameter - * is a GL state reference, look up the current value of that state - * variable and put it into the parameter's Value[4] array. - * Other parameter types never change or are explicitly set by the user - * with glUniform() or glProgramParameter(), etc. - * This would be called at glBegin time. - */ -void -_mesa_load_state_parameters(struct gl_context *ctx, - struct gl_program_parameter_list *paramList) -{ - GLuint i; - - if (!paramList) - return; - - for (i = 0; i < paramList->NumParameters; i++) { - if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) { - _mesa_fetch_state(ctx, - paramList->Parameters[i].StateIndexes, - ¶mList->ParameterValues[i][0].f); - } - } -} - - -/** - * Copy the 16 elements of a matrix into four consecutive program - * registers starting at 'pos'. - */ -static void -load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16]) -{ - GLuint i; - for (i = 0; i < 4; i++) { - registers[pos + i][0] = mat[0 + i]; - registers[pos + i][1] = mat[4 + i]; - registers[pos + i][2] = mat[8 + i]; - registers[pos + i][3] = mat[12 + i]; - } -} - - -/** - * As above, but transpose the matrix. - */ -static void -load_transpose_matrix(GLfloat registers[][4], GLuint pos, - const GLfloat mat[16]) -{ - memcpy(registers[pos], mat, 16 * sizeof(GLfloat)); -} - - -/** - * Load current vertex program's parameter registers with tracked - * matrices (if NV program). This only needs to be done per - * glBegin/glEnd, not per-vertex. - */ -void -_mesa_load_tracked_matrices(struct gl_context *ctx) -{ - GLuint i; - - for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) { - /* point 'mat' at source matrix */ - GLmatrix *mat; - if (ctx->VertexProgram.TrackMatrix[i] == GL_MODELVIEW) { - mat = ctx->ModelviewMatrixStack.Top; - } - else if (ctx->VertexProgram.TrackMatrix[i] == GL_PROJECTION) { - mat = ctx->ProjectionMatrixStack.Top; - } - else if (ctx->VertexProgram.TrackMatrix[i] == GL_TEXTURE) { - GLuint unit = MIN2(ctx->Texture.CurrentUnit, - Elements(ctx->TextureMatrixStack) - 1); - mat = ctx->TextureMatrixStack[unit].Top; - } - else if (ctx->VertexProgram.TrackMatrix[i]==GL_MODELVIEW_PROJECTION_NV) { - /* XXX verify the combined matrix is up to date */ - mat = &ctx->_ModelProjectMatrix; - } - else if (ctx->VertexProgram.TrackMatrix[i] >= GL_MATRIX0_NV && - ctx->VertexProgram.TrackMatrix[i] <= GL_MATRIX7_NV) { - GLuint n = ctx->VertexProgram.TrackMatrix[i] - GL_MATRIX0_NV; - ASSERT(n < Elements(ctx->ProgramMatrixStack)); - mat = ctx->ProgramMatrixStack[n].Top; - } - else { - /* no matrix is tracked, but we leave the register values as-is */ - assert(ctx->VertexProgram.TrackMatrix[i] == GL_NONE); - continue; - } - - /* load the matrix values into sequential registers */ - if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) { - load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); - } - else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_INVERSE_NV) { - _math_matrix_analyse(mat); /* update the inverse */ - ASSERT(!_math_matrix_is_dirty(mat)); - load_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); - } - else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_TRANSPOSE_NV) { - load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); - } - else { - assert(ctx->VertexProgram.TrackMatrixTransform[i] - == GL_INVERSE_TRANSPOSE_NV); - _math_matrix_analyse(mat); /* update the inverse */ - ASSERT(!_math_matrix_is_dirty(mat)); - load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); - } - } -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.h b/reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.h deleted file mode 100644 index 8b731e12bbe..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/prog_statevars.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 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 PROG_STATEVARS_H -#define PROG_STATEVARS_H - - -#include "main/glheader.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -struct gl_context; -struct gl_program_parameter_list; - -/** - * Number of STATE_* values we need to address any GL state. - * Used to dimension arrays. - */ -#define STATE_LENGTH 5 - - -/** - * Used for describing GL state referenced from inside ARB vertex and - * fragment programs. - * A string such as "state.light[0].ambient" gets translated into a - * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ]. - * - * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should - * always be the array index. - */ -typedef enum gl_state_index_ { - STATE_MATERIAL = 100, /* start at 100 so small ints are seen as ints */ - - STATE_LIGHT, - STATE_LIGHTMODEL_AMBIENT, - STATE_LIGHTMODEL_SCENECOLOR, - STATE_LIGHTPROD, - - STATE_TEXGEN, - - STATE_FOG_COLOR, - STATE_FOG_PARAMS, - - STATE_CLIPPLANE, - - STATE_POINT_SIZE, - STATE_POINT_ATTENUATION, - - STATE_MODELVIEW_MATRIX, - STATE_PROJECTION_MATRIX, - STATE_MVP_MATRIX, - STATE_TEXTURE_MATRIX, - STATE_PROGRAM_MATRIX, - STATE_MATRIX_INVERSE, - STATE_MATRIX_TRANSPOSE, - STATE_MATRIX_INVTRANS, - - STATE_AMBIENT, - STATE_DIFFUSE, - STATE_SPECULAR, - STATE_EMISSION, - STATE_SHININESS, - STATE_HALF_VECTOR, - - STATE_POSITION, /**< xyzw = position */ - STATE_ATTENUATION, /**< xyz = attenuation, w = spot exponent */ - STATE_SPOT_DIRECTION, /**< xyz = direction, w = cos(cutoff) */ - STATE_SPOT_CUTOFF, /**< x = cutoff, yzw = undefined */ - - STATE_TEXGEN_EYE_S, - STATE_TEXGEN_EYE_T, - STATE_TEXGEN_EYE_R, - STATE_TEXGEN_EYE_Q, - STATE_TEXGEN_OBJECT_S, - STATE_TEXGEN_OBJECT_T, - STATE_TEXGEN_OBJECT_R, - STATE_TEXGEN_OBJECT_Q, - - STATE_TEXENV_COLOR, - - STATE_DEPTH_RANGE, - - STATE_VERTEX_PROGRAM, - STATE_FRAGMENT_PROGRAM, - - STATE_ENV, - STATE_LOCAL, - - STATE_INTERNAL, /* Mesa additions */ - STATE_CURRENT_ATTRIB, /* ctx->Current vertex attrib value */ - STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, /* ctx->Current vertex attrib value after passthrough vertex processing */ - STATE_NORMAL_SCALE, - STATE_TEXRECT_SCALE, - STATE_FOG_PARAMS_OPTIMIZED, /* for faster fog calc */ - STATE_POINT_SIZE_CLAMPED, /* includes implementation dependent size clamp */ - STATE_POINT_SIZE_IMPL_CLAMP, /* for implementation clamp only in vs */ - STATE_LIGHT_SPOT_DIR_NORMALIZED, /* pre-normalized spot dir */ - STATE_LIGHT_POSITION, /* object vs eye space */ - STATE_LIGHT_POSITION_NORMALIZED, /* object vs eye space */ - STATE_LIGHT_HALF_VECTOR, /* object vs eye space */ - STATE_PT_SCALE, /**< Pixel transfer RGBA scale */ - STATE_PT_BIAS, /**< Pixel transfer RGBA bias */ - STATE_SHADOW_AMBIENT, /**< ARB_shadow_ambient fail value; token[2] is texture unit index */ - STATE_FB_SIZE, /**< (width-1, height-1, 0, 0) */ - STATE_FB_WPOS_Y_TRANSFORM, /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */ - STATE_ROT_MATRIX_0, /**< ATI_envmap_bumpmap, rot matrix row 0 */ - STATE_ROT_MATRIX_1, /**< ATI_envmap_bumpmap, rot matrix row 1 */ - STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */ -} gl_state_index; - - - -extern void -_mesa_load_state_parameters(struct gl_context *ctx, - struct gl_program_parameter_list *paramList); - - -extern GLbitfield -_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]); - - -extern char * -_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]); - - -extern void -_mesa_load_tracked_matrices(struct gl_context *ctx); - - -#ifdef __cplusplus -} -#endif - -#endif /* PROG_STATEVARS_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program.c b/reactos/dll/opengl/mesa/src/mesa/program/program.c deleted file mode 100644 index 5040c32721d..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program.c +++ /dev/null @@ -1,975 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 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. - */ - -/** - * \file program.c - * Vertex and fragment program support functions. - * \author Brian Paul - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "main/hash.h" -#include "main/mfeatures.h" -#include "program.h" -#include "prog_cache.h" -#include "prog_parameter.h" -#include "prog_instruction.h" - - -/** - * A pointer to this dummy program is put into the hash table when - * glGenPrograms is called. - */ -struct gl_program _mesa_DummyProgram; - - -/** - * Init context's vertex/fragment program state - */ -void -_mesa_init_program(struct gl_context *ctx) -{ - GLuint i; - - /* - * If this assertion fails, we need to increase the field - * size for register indexes (see INST_INDEX_BITS). - */ - ASSERT(ctx->Const.VertexProgram.MaxUniformComponents / 4 - <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.FragmentProgram.MaxUniformComponents / 4 - <= (1 << INST_INDEX_BITS)); - - ASSERT(ctx->Const.VertexProgram.MaxTemps <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.VertexProgram.MaxLocalParams <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.FragmentProgram.MaxTemps <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.FragmentProgram.MaxLocalParams <= (1 << INST_INDEX_BITS)); - - ASSERT(ctx->Const.VertexProgram.MaxUniformComponents <= 4 * MAX_UNIFORMS); - ASSERT(ctx->Const.FragmentProgram.MaxUniformComponents <= 4 * MAX_UNIFORMS); - - ASSERT(ctx->Const.VertexProgram.MaxAddressOffset <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.FragmentProgram.MaxAddressOffset <= (1 << INST_INDEX_BITS)); - - /* If this fails, increase prog_instruction::TexSrcUnit size */ - ASSERT(MAX_TEXTURE_UNITS <= (1 << 5)); - - /* If this fails, increase prog_instruction::TexSrcTarget size */ - ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4)); - - ctx->Program.ErrorPos = -1; - ctx->Program.ErrorString = _mesa_strdup(""); - -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - ctx->VertexProgram.Enabled = GL_FALSE; - ctx->VertexProgram.PointSizeEnabled = GL_FALSE; - ctx->VertexProgram.TwoSideEnabled = GL_FALSE; - _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, - ctx->Shared->DefaultVertexProgram); - assert(ctx->VertexProgram.Current); - for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) { - ctx->VertexProgram.TrackMatrix[i] = GL_NONE; - ctx->VertexProgram.TrackMatrixTransform[i] = GL_IDENTITY_NV; - } - ctx->VertexProgram.Cache = _mesa_new_program_cache(); -#endif - -#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program - ctx->FragmentProgram.Enabled = GL_FALSE; - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - ctx->Shared->DefaultFragmentProgram); - assert(ctx->FragmentProgram.Current); - ctx->FragmentProgram.Cache = _mesa_new_program_cache(); -#endif -} - - -/** - * Free a context's vertex/fragment program state - */ -void -_mesa_free_program_data(struct gl_context *ctx) -{ -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL); - _mesa_delete_program_cache(ctx, ctx->VertexProgram.Cache); -#endif -#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); - _mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache); -#endif - free((void *) ctx->Program.ErrorString); -} - - -/** - * Update the default program objects in the given context to reference those - * specified in the shared state and release those referencing the old - * shared state. - */ -void -_mesa_update_default_objects_program(struct gl_context *ctx) -{ -#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program - _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, - (struct gl_vertex_program *) - ctx->Shared->DefaultVertexProgram); - assert(ctx->VertexProgram.Current); -#endif - -#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - (struct gl_fragment_program *) - ctx->Shared->DefaultFragmentProgram); - assert(ctx->FragmentProgram.Current); -#endif -} - - -/** - * Set the vertex/fragment program error state (position and error string). - * This is generally called from within the parsers. - */ -void -_mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string) -{ - ctx->Program.ErrorPos = pos; - free((void *) ctx->Program.ErrorString); - if (!string) - string = ""; - ctx->Program.ErrorString = _mesa_strdup(string); -} - - -/** - * Find the line number and column for 'pos' within 'string'. - * Return a copy of the line which contains 'pos'. Free the line with - * free(). - * \param string the program string - * \param pos the position within the string - * \param line returns the line number corresponding to 'pos'. - * \param col returns the column number corresponding to 'pos'. - * \return copy of the line containing 'pos'. - */ -const GLubyte * -_mesa_find_line_column(const GLubyte *string, const GLubyte *pos, - GLint *line, GLint *col) -{ - const GLubyte *lineStart = string; - const GLubyte *p = string; - GLubyte *s; - int len; - - *line = 1; - - while (p != pos) { - if (*p == (GLubyte) '\n') { - (*line)++; - lineStart = p + 1; - } - p++; - } - - *col = (pos - lineStart) + 1; - - /* return copy of this line */ - while (*p != 0 && *p != '\n') - p++; - len = p - lineStart; - s = (GLubyte *) malloc(len + 1); - memcpy(s, lineStart, len); - s[len] = 0; - - return s; -} - - -/** - * Initialize a new vertex/fragment program object. - */ -static struct gl_program * -_mesa_init_program_struct( struct gl_context *ctx, struct gl_program *prog, - GLenum target, GLuint id) -{ - (void) ctx; - if (prog) { - GLuint i; - memset(prog, 0, sizeof(*prog)); - prog->Id = id; - prog->Target = target; - prog->Resident = GL_TRUE; - prog->RefCount = 1; - prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB; - - /* default mapping from samplers to texture units */ - for (i = 0; i < MAX_SAMPLERS; i++) - prog->SamplerUnits[i] = i; - } - - return prog; -} - - -/** - * Initialize a new fragment program object. - */ -struct gl_program * -_mesa_init_fragment_program( struct gl_context *ctx, struct gl_fragment_program *prog, - GLenum target, GLuint id) -{ - if (prog) - return _mesa_init_program_struct( ctx, &prog->Base, target, id ); - else - return NULL; -} - - -/** - * Initialize a new vertex program object. - */ -struct gl_program * -_mesa_init_vertex_program( struct gl_context *ctx, struct gl_vertex_program *prog, - GLenum target, GLuint id) -{ - if (prog) - return _mesa_init_program_struct( ctx, &prog->Base, target, id ); - else - return NULL; -} - - -/** - * Allocate and initialize a new fragment/vertex program object but - * don't put it into the program hash table. Called via - * ctx->Driver.NewProgram. May be overridden (ie. replaced) by a - * device driver function to implement OO deriviation with additional - * types not understood by this function. - * - * \param ctx context - * \param id program id/number - * \param target program target/type - * \return pointer to new program object - */ -struct gl_program * -_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id) -{ - struct gl_program *prog; - switch (target) { - case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */ - case GL_VERTEX_STATE_PROGRAM_NV: - prog = _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program), - target, id ); - break; - case GL_FRAGMENT_PROGRAM_NV: - case GL_FRAGMENT_PROGRAM_ARB: - prog =_mesa_init_fragment_program(ctx, - CALLOC_STRUCT(gl_fragment_program), - target, id ); - break; - default: - _mesa_problem(ctx, "bad target in _mesa_new_program"); - prog = NULL; - } - return prog; -} - - -/** - * Delete a program and remove it from the hash table, ignoring the - * reference count. - * Called via ctx->Driver.DeleteProgram. May be wrapped (OO deriviation) - * by a device driver function. - */ -void -_mesa_delete_program(struct gl_context *ctx, struct gl_program *prog) -{ - (void) ctx; - ASSERT(prog); - ASSERT(prog->RefCount==0); - - if (prog == &_mesa_DummyProgram) - return; - - if (prog->String) - free(prog->String); - - if (prog->Instructions) { - _mesa_free_instructions(prog->Instructions, prog->NumInstructions); - } - if (prog->Parameters) { - _mesa_free_parameter_list(prog->Parameters); - } - - free(prog); -} - - -/** - * Return the gl_program object for a given ID. - * Basically just a wrapper for _mesa_HashLookup() to avoid a lot of - * casts elsewhere. - */ -struct gl_program * -_mesa_lookup_program(struct gl_context *ctx, GLuint id) -{ - if (id) - return (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id); - else - return NULL; -} - - -/** - * Reference counting for vertex/fragment programs - * This is normally only called from the _mesa_reference_program() macro - * when there's a real pointer change. - */ -void -_mesa_reference_program_(struct gl_context *ctx, - struct gl_program **ptr, - struct gl_program *prog) -{ -#ifndef NDEBUG - assert(ptr); - if (*ptr && prog) { - /* sanity check */ - if ((*ptr)->Target == GL_VERTEX_PROGRAM_ARB) - ASSERT(prog->Target == GL_VERTEX_PROGRAM_ARB); - else if ((*ptr)->Target == GL_FRAGMENT_PROGRAM_ARB) - ASSERT(prog->Target == GL_FRAGMENT_PROGRAM_ARB || - prog->Target == GL_FRAGMENT_PROGRAM_NV); - } -#endif - - if (*ptr) { - GLboolean deleteFlag; - - /*_glthread_LOCK_MUTEX((*ptr)->Mutex);*/ -#if 0 - printf("Program %p ID=%u Target=%s Refcount-- to %d\n", - *ptr, (*ptr)->Id, - ((*ptr)->Target == GL_VERTEX_PROGRAM_ARB ? "VP" : "FP")), - (*ptr)->RefCount - 1); -#endif - ASSERT((*ptr)->RefCount > 0); - (*ptr)->RefCount--; - - deleteFlag = ((*ptr)->RefCount == 0); - /*_glthread_UNLOCK_MUTEX((*ptr)->Mutex);*/ - - if (deleteFlag) { - ASSERT(ctx); - ctx->Driver.DeleteProgram(ctx, *ptr); - } - - *ptr = NULL; - } - - assert(!*ptr); - if (prog) { - /*_glthread_LOCK_MUTEX(prog->Mutex);*/ - prog->RefCount++; -#if 0 - printf("Program %p ID=%u Target=%s Refcount++ to %d\n", - prog, prog->Id, - (prog->Target == GL_VERTEX_PROGRAM_ARB ? "VP" : "FP")), - prog->RefCount); -#endif - /*_glthread_UNLOCK_MUTEX(prog->Mutex);*/ - } - - *ptr = prog; -} - - -/** - * Return a copy of a program. - * XXX Problem here if the program object is actually OO-derivation - * made by a device driver. - */ -struct gl_program * -_mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog) -{ - struct gl_program *clone; - - clone = ctx->Driver.NewProgram(ctx, prog->Target, prog->Id); - if (!clone) - return NULL; - - assert(clone->Target == prog->Target); - assert(clone->RefCount == 1); - - clone->String = (GLubyte *) _mesa_strdup((char *) prog->String); - clone->Format = prog->Format; - clone->Instructions = _mesa_alloc_instructions(prog->NumInstructions); - if (!clone->Instructions) { - _mesa_reference_program(ctx, &clone, NULL); - return NULL; - } - _mesa_copy_instructions(clone->Instructions, prog->Instructions, - prog->NumInstructions); - clone->InputsRead = prog->InputsRead; - clone->OutputsWritten = prog->OutputsWritten; - clone->SamplersUsed = prog->SamplersUsed; - clone->ShadowSamplers = prog->ShadowSamplers; - memcpy(clone->TexturesUsed, prog->TexturesUsed, sizeof(prog->TexturesUsed)); - - if (prog->Parameters) - clone->Parameters = _mesa_clone_parameter_list(prog->Parameters); - memcpy(clone->LocalParams, prog->LocalParams, sizeof(clone->LocalParams)); - memcpy(clone->LocalParams, prog->LocalParams, sizeof(clone->LocalParams)); - clone->IndirectRegisterFiles = prog->IndirectRegisterFiles; - clone->NumInstructions = prog->NumInstructions; - clone->NumTemporaries = prog->NumTemporaries; - clone->NumParameters = prog->NumParameters; - clone->NumAttributes = prog->NumAttributes; - clone->NumAddressRegs = prog->NumAddressRegs; - clone->NumNativeInstructions = prog->NumNativeInstructions; - clone->NumNativeTemporaries = prog->NumNativeTemporaries; - clone->NumNativeParameters = prog->NumNativeParameters; - clone->NumNativeAttributes = prog->NumNativeAttributes; - clone->NumNativeAddressRegs = prog->NumNativeAddressRegs; - clone->NumAluInstructions = prog->NumAluInstructions; - clone->NumTexInstructions = prog->NumTexInstructions; - clone->NumTexIndirections = prog->NumTexIndirections; - clone->NumNativeAluInstructions = prog->NumNativeAluInstructions; - clone->NumNativeTexInstructions = prog->NumNativeTexInstructions; - clone->NumNativeTexIndirections = prog->NumNativeTexIndirections; - - switch (prog->Target) { - case GL_VERTEX_PROGRAM_ARB: - { - const struct gl_vertex_program *vp - = (const struct gl_vertex_program *) prog; - struct gl_vertex_program *vpc = (struct gl_vertex_program *) clone; - vpc->IsPositionInvariant = vp->IsPositionInvariant; - vpc->IsNVProgram = vp->IsNVProgram; - } - break; - case GL_FRAGMENT_PROGRAM_ARB: - { - const struct gl_fragment_program *fp - = (const struct gl_fragment_program *) prog; - struct gl_fragment_program *fpc = (struct gl_fragment_program *) clone; - fpc->UsesKill = fp->UsesKill; - } - break; - default: - _mesa_problem(NULL, "Unexpected target in _mesa_clone_program"); - } - - return clone; -} - - -/** - * Insert 'count' NOP instructions at 'start' in the given program. - * Adjust branch targets accordingly. - */ -GLboolean -_mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count) -{ - const GLuint origLen = prog->NumInstructions; - const GLuint newLen = origLen + count; - struct prog_instruction *newInst; - GLuint i; - - /* adjust branches */ - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - if (inst->BranchTarget > 0) { - if ((GLuint)inst->BranchTarget >= start) { - inst->BranchTarget += count; - } - } - } - - /* Alloc storage for new instructions */ - newInst = _mesa_alloc_instructions(newLen); - if (!newInst) { - return GL_FALSE; - } - - /* Copy 'start' instructions into new instruction buffer */ - _mesa_copy_instructions(newInst, prog->Instructions, start); - - /* init the new instructions */ - _mesa_init_instructions(newInst + start, count); - - /* Copy the remaining/tail instructions to new inst buffer */ - _mesa_copy_instructions(newInst + start + count, - prog->Instructions + start, - origLen - start); - - /* free old instructions */ - _mesa_free_instructions(prog->Instructions, origLen); - - /* install new instructions */ - prog->Instructions = newInst; - prog->NumInstructions = newLen; - - return GL_TRUE; -} - -/** - * Delete 'count' instructions at 'start' in the given program. - * Adjust branch targets accordingly. - */ -GLboolean -_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count) -{ - const GLuint origLen = prog->NumInstructions; - const GLuint newLen = origLen - count; - struct prog_instruction *newInst; - GLuint i; - - /* adjust branches */ - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - if (inst->BranchTarget > 0) { - if (inst->BranchTarget > (GLint) start) { - inst->BranchTarget -= count; - } - } - } - - /* Alloc storage for new instructions */ - newInst = _mesa_alloc_instructions(newLen); - if (!newInst) { - return GL_FALSE; - } - - /* Copy 'start' instructions into new instruction buffer */ - _mesa_copy_instructions(newInst, prog->Instructions, start); - - /* Copy the remaining/tail instructions to new inst buffer */ - _mesa_copy_instructions(newInst + start, - prog->Instructions + start + count, - newLen - start); - - /* free old instructions */ - _mesa_free_instructions(prog->Instructions, origLen); - - /* install new instructions */ - prog->Instructions = newInst; - prog->NumInstructions = newLen; - - return GL_TRUE; -} - - -/** - * Search instructions for registers that match (oldFile, oldIndex), - * replacing them with (newFile, newIndex). - */ -static void -replace_registers(struct prog_instruction *inst, GLuint numInst, - GLuint oldFile, GLuint oldIndex, - GLuint newFile, GLuint newIndex) -{ - GLuint i, j; - for (i = 0; i < numInst; i++) { - /* src regs */ - for (j = 0; j < _mesa_num_inst_src_regs(inst[i].Opcode); j++) { - if (inst[i].SrcReg[j].File == oldFile && - inst[i].SrcReg[j].Index == oldIndex) { - inst[i].SrcReg[j].File = newFile; - inst[i].SrcReg[j].Index = newIndex; - } - } - /* dst reg */ - if (inst[i].DstReg.File == oldFile && inst[i].DstReg.Index == oldIndex) { - inst[i].DstReg.File = newFile; - inst[i].DstReg.Index = newIndex; - } - } -} - - -/** - * Search instructions for references to program parameters. When found, - * increment the parameter index by 'offset'. - * Used when combining programs. - */ -static void -adjust_param_indexes(struct prog_instruction *inst, GLuint numInst, - GLuint offset) -{ - GLuint i, j; - for (i = 0; i < numInst; i++) { - for (j = 0; j < _mesa_num_inst_src_regs(inst[i].Opcode); j++) { - GLuint f = inst[i].SrcReg[j].File; - if (f == PROGRAM_CONSTANT || - f == PROGRAM_UNIFORM || - f == PROGRAM_STATE_VAR) { - inst[i].SrcReg[j].Index += offset; - } - } - } -} - - -/** - * Combine two programs into one. Fix instructions so the outputs of - * the first program go to the inputs of the second program. - */ -struct gl_program * -_mesa_combine_programs(struct gl_context *ctx, - const struct gl_program *progA, - const struct gl_program *progB) -{ - struct prog_instruction *newInst; - struct gl_program *newProg; - const GLuint lenA = progA->NumInstructions - 1; /* omit END instr */ - const GLuint lenB = progB->NumInstructions; - const GLuint numParamsA = _mesa_num_parameters(progA->Parameters); - const GLuint newLength = lenA + lenB; - GLboolean usedTemps[MAX_PROGRAM_TEMPS]; - GLuint firstTemp = 0; - GLbitfield inputsB; - GLuint i; - - ASSERT(progA->Target == progB->Target); - - newInst = _mesa_alloc_instructions(newLength); - if (!newInst) - return GL_FALSE; - - _mesa_copy_instructions(newInst, progA->Instructions, lenA); - _mesa_copy_instructions(newInst + lenA, progB->Instructions, lenB); - - /* adjust branch / instruction addresses for B's instructions */ - for (i = 0; i < lenB; i++) { - newInst[lenA + i].BranchTarget += lenA; - } - - newProg = ctx->Driver.NewProgram(ctx, progA->Target, 0); - newProg->Instructions = newInst; - newProg->NumInstructions = newLength; - - /* find used temp regs (we may need new temps below) */ - _mesa_find_used_registers(newProg, PROGRAM_TEMPORARY, - usedTemps, MAX_PROGRAM_TEMPS); - - if (newProg->Target == GL_FRAGMENT_PROGRAM_ARB) { - struct gl_fragment_program *fprogA, *fprogB, *newFprog; - GLbitfield progB_inputsRead = progB->InputsRead; - GLint progB_colorFile, progB_colorIndex; - - fprogA = (struct gl_fragment_program *) progA; - fprogB = (struct gl_fragment_program *) progB; - newFprog = (struct gl_fragment_program *) newProg; - - newFprog->UsesKill = fprogA->UsesKill || fprogB->UsesKill; - - /* We'll do a search and replace for instances - * of progB_colorFile/progB_colorIndex below... - */ - progB_colorFile = PROGRAM_INPUT; - progB_colorIndex = FRAG_ATTRIB_COL0; - - /* - * The fragment program may get color from a state var rather than - * a fragment input (vertex output) if it's constant. - * See the texenvprogram.c code. - * So, search the program's parameter list now to see if the program - * gets color from a state var instead of a conventional fragment - * input register. - */ - for (i = 0; i < progB->Parameters->NumParameters; i++) { - struct gl_program_parameter *p = &progB->Parameters->Parameters[i]; - if (p->Type == PROGRAM_STATE_VAR && - p->StateIndexes[0] == STATE_INTERNAL && - p->StateIndexes[1] == STATE_CURRENT_ATTRIB && - (int) p->StateIndexes[2] == (int) VERT_ATTRIB_COLOR0) { - progB_inputsRead |= FRAG_BIT_COL0; - progB_colorFile = PROGRAM_STATE_VAR; - progB_colorIndex = i; - break; - } - } - - /* Connect color outputs of fprogA to color inputs of fprogB, via a - * new temporary register. - */ - if ((progA->OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) && - (progB_inputsRead & FRAG_BIT_COL0)) { - GLint tempReg = _mesa_find_free_register(usedTemps, MAX_PROGRAM_TEMPS, - firstTemp); - if (tempReg < 0) { - _mesa_problem(ctx, "No free temp regs found in " - "_mesa_combine_programs(), using 31"); - tempReg = 31; - } - firstTemp = tempReg + 1; - - /* replace writes to result.color[0] with tempReg */ - replace_registers(newInst, lenA, - PROGRAM_OUTPUT, FRAG_RESULT_COLOR, - PROGRAM_TEMPORARY, tempReg); - /* replace reads from the input color with tempReg */ - replace_registers(newInst + lenA, lenB, - progB_colorFile, progB_colorIndex, /* search for */ - PROGRAM_TEMPORARY, tempReg /* replace with */ ); - } - - /* compute combined program's InputsRead */ - inputsB = progB_inputsRead; - if (progA->OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) { - inputsB &= ~(1 << FRAG_ATTRIB_COL0); - } - newProg->InputsRead = progA->InputsRead | inputsB; - newProg->OutputsWritten = progB->OutputsWritten; - newProg->SamplersUsed = progA->SamplersUsed | progB->SamplersUsed; - } - else { - /* vertex program */ - assert(0); /* XXX todo */ - } - - /* - * Merge parameters (uniforms, constants, etc) - */ - newProg->Parameters = _mesa_combine_parameter_lists(progA->Parameters, - progB->Parameters); - - adjust_param_indexes(newInst + lenA, lenB, numParamsA); - - - return newProg; -} - - -/** - * Populate the 'used' array with flags indicating which registers (TEMPs, - * INPUTs, OUTPUTs, etc, are used by the given program. - * \param file type of register to scan for - * \param used returns true/false flags for in use / free - * \param usedSize size of the 'used' array - */ -void -_mesa_find_used_registers(const struct gl_program *prog, - gl_register_file file, - GLboolean used[], GLuint usedSize) -{ - GLuint i, j; - - memset(used, 0, usedSize); - - for (i = 0; i < prog->NumInstructions; i++) { - const struct prog_instruction *inst = prog->Instructions + i; - const GLuint n = _mesa_num_inst_src_regs(inst->Opcode); - - if (inst->DstReg.File == file) { - ASSERT(inst->DstReg.Index < usedSize); - if(inst->DstReg.Index < usedSize) - used[inst->DstReg.Index] = GL_TRUE; - } - - for (j = 0; j < n; j++) { - if (inst->SrcReg[j].File == file) { - ASSERT(inst->SrcReg[j].Index < usedSize); - if(inst->SrcReg[j].Index < usedSize) - used[inst->SrcReg[j].Index] = GL_TRUE; - } - } - } -} - - -/** - * Scan the given 'used' register flag array for the first entry - * that's >= firstReg. - * \param used vector of flags indicating registers in use (as returned - * by _mesa_find_used_registers()) - * \param usedSize size of the 'used' array - * \param firstReg first register to start searching at - * \return index of unused register, or -1 if none. - */ -GLint -_mesa_find_free_register(const GLboolean used[], - GLuint usedSize, GLuint firstReg) -{ - GLuint i; - - assert(firstReg < usedSize); - - for (i = firstReg; i < usedSize; i++) - if (!used[i]) - return i; - - return -1; -} - - - -/** - * Check if the given register index is valid (doesn't exceed implementation- - * dependent limits). - * \return GL_TRUE if OK, GL_FALSE if bad index - */ -GLboolean -_mesa_valid_register_index(const struct gl_context *ctx, - gl_shader_type shaderType, - gl_register_file file, GLint index) -{ - const struct gl_program_constants *c; - - switch (shaderType) { - case MESA_SHADER_VERTEX: - c = &ctx->Const.VertexProgram; - break; - case MESA_SHADER_FRAGMENT: - c = &ctx->Const.FragmentProgram; - break; - default: - _mesa_problem(ctx, - "unexpected shader type in _mesa_valid_register_index()"); - return GL_FALSE; - } - - switch (file) { - case PROGRAM_UNDEFINED: - return GL_TRUE; /* XXX or maybe false? */ - - case PROGRAM_TEMPORARY: - return index >= 0 && index < c->MaxTemps; - - case PROGRAM_ENV_PARAM: - return index >= 0 && index < c->MaxEnvParams; - - case PROGRAM_LOCAL_PARAM: - return index >= 0 && index < c->MaxLocalParams; - - case PROGRAM_NAMED_PARAM: - return index >= 0 && index < c->MaxParameters; - - case PROGRAM_UNIFORM: - case PROGRAM_STATE_VAR: - /* aka constant buffer */ - return index >= 0 && index < c->MaxUniformComponents / 4; - - case PROGRAM_CONSTANT: - /* constant buffer w/ possible relative negative addressing */ - return (index > (int) c->MaxUniformComponents / -4 && - index < c->MaxUniformComponents / 4); - - case PROGRAM_INPUT: - if (index < 0) - return GL_FALSE; - - switch (shaderType) { - case MESA_SHADER_VERTEX: - return index < VERT_ATTRIB_GENERIC0 + c->MaxAttribs; - case MESA_SHADER_FRAGMENT: - return index < FRAG_ATTRIB_VAR0 + ctx->Const.MaxVarying; - default: - return GL_FALSE; - } - - case PROGRAM_OUTPUT: - if (index < 0) - return GL_FALSE; - - switch (shaderType) { - case MESA_SHADER_VERTEX: - return index < VERT_RESULT_VAR0 + ctx->Const.MaxVarying; - case MESA_SHADER_FRAGMENT: - return index <= FRAG_RESULT_DATA0; - default: - return GL_FALSE; - } - - case PROGRAM_ADDRESS: - return index >= 0 && index < c->MaxAddressRegs; - - default: - _mesa_problem(ctx, - "unexpected register file in _mesa_valid_register_index()"); - return GL_FALSE; - } -} - - - -/** - * "Post-process" a GPU program. This is intended to be used for debugging. - * Example actions include no-op'ing instructions or changing instruction - * behaviour. - */ -void -_mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog) -{ - static const GLfloat white[4] = { 0.5, 0.5, 0.5, 0.5 }; - GLuint i; - GLuint whiteSwizzle; - GLint whiteIndex = _mesa_add_unnamed_constant(prog->Parameters, - (gl_constant_value *) white, - 4, &whiteSwizzle); - - (void) whiteIndex; - - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - const GLuint n = _mesa_num_inst_src_regs(inst->Opcode); - - (void) n; - - if (_mesa_is_tex_instruction(inst->Opcode)) { -#if 0 - /* replace TEX/TXP/TXB with MOV */ - inst->Opcode = OPCODE_MOV; - inst->DstReg.WriteMask = WRITEMASK_XYZW; - inst->SrcReg[0].Swizzle = SWIZZLE_XYZW; - inst->SrcReg[0].Negate = NEGATE_NONE; -#endif - -#if 0 - /* disable shadow texture mode */ - inst->TexShadow = 0; -#endif - } - - if (inst->Opcode == OPCODE_TXP) { -#if 0 - inst->Opcode = OPCODE_MOV; - inst->DstReg.WriteMask = WRITEMASK_XYZW; - inst->SrcReg[0].File = PROGRAM_CONSTANT; - inst->SrcReg[0].Index = whiteIndex; - inst->SrcReg[0].Swizzle = SWIZZLE_XYZW; - inst->SrcReg[0].Negate = NEGATE_NONE; -#endif -#if 0 - inst->TexShadow = 0; -#endif -#if 0 - inst->Opcode = OPCODE_TEX; - inst->TexShadow = 0; -#endif - } - - } -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program.h b/reactos/dll/opengl/mesa/src/mesa/program/program.h deleted file mode 100644 index e8d49499fb0..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 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. - */ - -/** - * \file program.c - * Vertex and fragment program support functions. - * \author Brian Paul - */ - - -/** - * \mainpage Mesa vertex and fragment program module - * - * This module or directory contains most of the code for vertex and - * fragment programs and shaders, including state management, parsers, - * and (some) software routines for executing programs - */ - -#ifndef PROGRAM_H -#define PROGRAM_H - -#include "main/compiler.h" -#include "main/mtypes.h" - - -extern struct gl_program _mesa_DummyProgram; - - -extern void -_mesa_init_program(struct gl_context *ctx); - -extern void -_mesa_free_program_data(struct gl_context *ctx); - -extern void -_mesa_update_default_objects_program(struct gl_context *ctx); - -extern void -_mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string); - -extern const GLubyte * -_mesa_find_line_column(const GLubyte *string, const GLubyte *pos, - GLint *line, GLint *col); - - -extern struct gl_program * -_mesa_init_vertex_program(struct gl_context *ctx, - struct gl_vertex_program *prog, - GLenum target, GLuint id); - -extern struct gl_program * -_mesa_init_fragment_program(struct gl_context *ctx, - struct gl_fragment_program *prog, - GLenum target, GLuint id); - -extern struct gl_program * -_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id); - -extern void -_mesa_delete_program(struct gl_context *ctx, struct gl_program *prog); - -extern struct gl_program * -_mesa_lookup_program(struct gl_context *ctx, GLuint id); - -extern void -_mesa_reference_program_(struct gl_context *ctx, - struct gl_program **ptr, - struct gl_program *prog); - -static inline void -_mesa_reference_program(struct gl_context *ctx, - struct gl_program **ptr, - struct gl_program *prog) -{ - if (*ptr != prog) - _mesa_reference_program_(ctx, ptr, prog); -} - -static inline void -_mesa_reference_vertprog(struct gl_context *ctx, - struct gl_vertex_program **ptr, - struct gl_vertex_program *prog) -{ - _mesa_reference_program(ctx, (struct gl_program **) ptr, - (struct gl_program *) prog); -} - -static inline void -_mesa_reference_fragprog(struct gl_context *ctx, - struct gl_fragment_program **ptr, - struct gl_fragment_program *prog) -{ - _mesa_reference_program(ctx, (struct gl_program **) ptr, - (struct gl_program *) prog); -} - -extern struct gl_program * -_mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog); - -static inline struct gl_vertex_program * -_mesa_clone_vertex_program(struct gl_context *ctx, - const struct gl_vertex_program *prog) -{ - return (struct gl_vertex_program *) _mesa_clone_program(ctx, &prog->Base); -} - -static inline struct gl_fragment_program * -_mesa_clone_fragment_program(struct gl_context *ctx, - const struct gl_fragment_program *prog) -{ - return (struct gl_fragment_program *) _mesa_clone_program(ctx, &prog->Base); -} - - -extern GLboolean -_mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count); - -extern GLboolean -_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count); - -extern struct gl_program * -_mesa_combine_programs(struct gl_context *ctx, - const struct gl_program *progA, - const struct gl_program *progB); - -extern void -_mesa_find_used_registers(const struct gl_program *prog, - gl_register_file file, - GLboolean used[], GLuint usedSize); - -extern GLint -_mesa_find_free_register(const GLboolean used[], - GLuint maxRegs, GLuint firstReg); - - -extern GLboolean -_mesa_valid_register_index(const struct gl_context *ctx, - gl_shader_type shaderType, - gl_register_file file, GLint index); - -extern void -_mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog); - -/* keep these in the same order as TGSI_PROCESSOR_* */ - -static inline GLuint -_mesa_program_target_to_index(GLenum v) -{ - switch(v) - { - case GL_VERTEX_PROGRAM_ARB: - return MESA_SHADER_VERTEX; - case GL_FRAGMENT_PROGRAM_ARB: - return MESA_SHADER_FRAGMENT; - default: - ASSERT(0); - return ~0; - } -} - -static inline GLenum -_mesa_program_index_to_target(GLuint i) -{ - GLenum enums[MESA_SHADER_TYPES] = { - GL_VERTEX_PROGRAM_ARB, - GL_FRAGMENT_PROGRAM_ARB - }; - if(i >= MESA_SHADER_TYPES) - return 0; - else - return enums[i]; -} - -#endif /* PROGRAM_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program_lexer.l b/reactos/dll/opengl/mesa/src/mesa/program/program_lexer.l deleted file mode 100644 index 0a50dab97fd..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program_lexer.l +++ /dev/null @@ -1,507 +0,0 @@ -%{ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include "main/glheader.h" -#include "main/imports.h" -#include "program/prog_instruction.h" -#include "program/prog_statevars.h" -#include "program/symbol_table.h" -#include "program/program_parser.h" -#include "program/program_parse.tab.h" - -#define require_ARB_vp (yyextra->mode == ARB_vertex) -#define require_ARB_fp (yyextra->mode == ARB_fragment) -#define require_NV_fp (yyextra->option.NV_fragment) -#define require_shadow (yyextra->option.Shadow) -#define require_rect (yyextra->option.TexRect) -#define require_texarray (yyextra->option.TexArray) - -#ifndef HAVE_UNISTD_H -#define YY_NO_UNISTD_H -#endif - -#define return_token_or_IDENTIFIER(condition, token) \ - do { \ - if (condition) { \ - return token; \ - } else { \ - return handle_ident(yyextra, yytext, yylval); \ - } \ - } while (0) - -#define return_token_or_DOT(condition, token) \ - do { \ - if (condition) { \ - return token; \ - } else { \ - yyless(1); \ - return DOT; \ - } \ - } while (0) - - -#define return_opcode(condition, token, opcode, len) \ - do { \ - if (condition && \ - _mesa_parse_instruction_suffix(yyextra, \ - yytext + len, \ - & yylval->temp_inst)) { \ - yylval->temp_inst.Opcode = OPCODE_ ## opcode; \ - return token; \ - } else { \ - return handle_ident(yyextra, yytext, yylval); \ - } \ - } while (0) - -#define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ - SWIZZLE_NIL, SWIZZLE_NIL) - -static unsigned -mask_from_char(char c) -{ - switch (c) { - case 'x': - case 'r': - return WRITEMASK_X; - case 'y': - case 'g': - return WRITEMASK_Y; - case 'z': - case 'b': - return WRITEMASK_Z; - case 'w': - case 'a': - return WRITEMASK_W; - } - - return 0; -} - -static unsigned -swiz_from_char(char c) -{ - switch (c) { - case 'x': - case 'r': - return SWIZZLE_X; - case 'y': - case 'g': - return SWIZZLE_Y; - case 'z': - case 'b': - return SWIZZLE_Z; - case 'w': - case 'a': - return SWIZZLE_W; - } - - return 0; -} - -static int -handle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval) -{ - lval->string = strdup(text); - - return (_mesa_symbol_table_find_symbol(state->st, 0, text) == NULL) - ? IDENTIFIER : USED_IDENTIFIER; -} - -#define YY_USER_ACTION \ - do { \ - yylloc->first_column = yylloc->last_column; \ - yylloc->last_column += yyleng; \ - if ((yylloc->first_line == 1) \ - && (yylloc->first_column == 1)) { \ - yylloc->position = 1; \ - } else { \ - yylloc->position += yylloc->last_column - yylloc->first_column; \ - } \ - } while(0); - -#define YY_NO_INPUT - -/* Yes, this is intentionally doing nothing. We have this line of code -here only to avoid the compiler complaining about an unput function -that is defined, but never called. */ -#define YY_USER_INIT while (0) { unput(0); } - -#define YY_EXTRA_TYPE struct asm_parser_state * - -/* Flex defines a couple of functions with no declarations nor the -static keyword. Declare them here to avoid a compiler warning. */ -int yyget_column (yyscan_t yyscanner); -void yyset_column (int column_no , yyscan_t yyscanner); - -%} - -num [0-9]+ -exp [Ee][-+]?[0-9]+ -frac "."[0-9]+ -dot "."[ \t]* - -sz [HRX]? -szf [HR]? -cc C? -sat (_SAT)? - -%option bison-bridge bison-locations reentrant noyywrap -%% - -"!!ARBvp1.0" { return ARBvp_10; } -"!!ARBfp1.0" { return ARBfp_10; } -ADDRESS { - yylval->integer = at_address; - return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS); -} -ALIAS { return ALIAS; } -ATTRIB { return ATTRIB; } -END { return END; } -OPTION { return OPTION; } -OUTPUT { return OUTPUT; } -PARAM { return PARAM; } -TEMP { yylval->integer = at_temp; return TEMP; } - -ABS{sz}{cc}{sat} { return_opcode( 1, VECTOR_OP, ABS, 3); } -ADD{sz}{cc}{sat} { return_opcode( 1, BIN_OP, ADD, 3); } -ARL { return_opcode(require_ARB_vp, ARL, ARL, 3); } - -CMP{sat} { return_opcode(require_ARB_fp, TRI_OP, CMP, 3); } -COS{szf}{cc}{sat} { return_opcode(require_ARB_fp, SCALAR_OP, COS, 3); } - -DDX{szf}{cc}{sat} { return_opcode(require_NV_fp, VECTOR_OP, DDX, 3); } -DDY{szf}{cc}{sat} { return_opcode(require_NV_fp, VECTOR_OP, DDY, 3); } -DP3{sz}{cc}{sat} { return_opcode( 1, BIN_OP, DP3, 3); } -DP4{sz}{cc}{sat} { return_opcode( 1, BIN_OP, DP4, 3); } -DPH{sz}{cc}{sat} { return_opcode( 1, BIN_OP, DPH, 3); } -DST{szf}{cc}{sat} { return_opcode( 1, BIN_OP, DST, 3); } - -EX2{szf}{cc}{sat} { return_opcode( 1, SCALAR_OP, EX2, 3); } -EXP { return_opcode(require_ARB_vp, SCALAR_OP, EXP, 3); } - -FLR{sz}{cc}{sat} { return_opcode( 1, VECTOR_OP, FLR, 3); } -FRC{sz}{cc}{sat} { return_opcode( 1, VECTOR_OP, FRC, 3); } - -KIL { return_opcode(require_ARB_fp, KIL, KIL, 3); } - -LIT{szf}{cc}{sat} { return_opcode( 1, VECTOR_OP, LIT, 3); } -LG2{szf}{cc}{sat} { return_opcode( 1, SCALAR_OP, LG2, 3); } -LOG { return_opcode(require_ARB_vp, SCALAR_OP, LOG, 3); } -LRP{sz}{cc}{sat} { return_opcode(require_ARB_fp, TRI_OP, LRP, 3); } - -MAD{sz}{cc}{sat} { return_opcode( 1, TRI_OP, MAD, 3); } -MAX{sz}{cc}{sat} { return_opcode( 1, BIN_OP, MAX, 3); } -MIN{sz}{cc}{sat} { return_opcode( 1, BIN_OP, MIN, 3); } -MOV{sz}{cc}{sat} { return_opcode( 1, VECTOR_OP, MOV, 3); } -MUL{sz}{cc}{sat} { return_opcode( 1, BIN_OP, MUL, 3); } - -PK2H { return_opcode(require_NV_fp, VECTOR_OP, PK2H, 4); } -PK2US { return_opcode(require_NV_fp, VECTOR_OP, PK2US, 5); } -PK4B { return_opcode(require_NV_fp, VECTOR_OP, PK4B, 4); } -PK4UB { return_opcode(require_NV_fp, VECTOR_OP, PK4UB, 5); } -POW{szf}{cc}{sat} { return_opcode( 1, BINSC_OP, POW, 3); } - -RCP{szf}{cc}{sat} { return_opcode( 1, SCALAR_OP, RCP, 3); } -RFL{szf}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, RFL, 3); } -RSQ{szf}{cc}{sat} { return_opcode( 1, SCALAR_OP, RSQ, 3); } - -SCS{sat} { return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); } -SEQ{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SEQ, 3); } -SFL{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SFL, 3); } -SGE{sz}{cc}{sat} { return_opcode( 1, BIN_OP, SGE, 3); } -SGT{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SGT, 3); } -SIN{szf}{cc}{sat} { return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); } -SLE{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SLE, 3); } -SLT{sz}{cc}{sat} { return_opcode( 1, BIN_OP, SLT, 3); } -SNE{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, SNE, 3); } -STR{sz}{cc}{sat} { return_opcode(require_NV_fp, BIN_OP, STR, 3); } -SUB{sz}{cc}{sat} { return_opcode( 1, BIN_OP, SUB, 3); } -SWZ{sat} { return_opcode( 1, SWZ, SWZ, 3); } - -TEX{cc}{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, 3); } -TXB{cc}{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); } -TXD{cc}{sat} { return_opcode(require_NV_fp, TXD_OP, TXD, 3); } -TXP{cc}{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); } - -UP2H{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP2H, 4); } -UP2US{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP2US, 5); } -UP4B{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP4B, 4); } -UP4UB{cc}{sat} { return_opcode(require_NV_fp, SCALAR_OP, UP4UB, 5); } - -X2D{szf}{cc}{sat} { return_opcode(require_NV_fp, TRI_OP, X2D, 3); } -XPD{sat} { return_opcode( 1, BIN_OP, XPD, 3); } - -vertex { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); } -fragment { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); } -program { return PROGRAM; } -state { return STATE; } -result { return RESULT; } - -{dot}ambient { return AMBIENT; } -{dot}attenuation { return ATTENUATION; } -{dot}back { return BACK; } -{dot}clip { return_token_or_DOT(require_ARB_vp, CLIP); } -{dot}color { return COLOR; } -{dot}depth { return_token_or_DOT(require_ARB_fp, DEPTH); } -{dot}diffuse { return DIFFUSE; } -{dot}direction { return DIRECTION; } -{dot}emission { return EMISSION; } -{dot}env { return ENV; } -{dot}eye { return EYE; } -{dot}fogcoord { return FOGCOORD; } -{dot}fog { return FOG; } -{dot}front { return FRONT; } -{dot}half { return HALF; } -{dot}inverse { return INVERSE; } -{dot}invtrans { return INVTRANS; } -{dot}light { return LIGHT; } -{dot}lightmodel { return LIGHTMODEL; } -{dot}lightprod { return LIGHTPROD; } -{dot}local { return LOCAL; } -{dot}material { return MATERIAL; } -{dot}program { return MAT_PROGRAM; } -{dot}matrix { return MATRIX; } -{dot}matrixindex { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); } -{dot}modelview { return MODELVIEW; } -{dot}mvp { return MVP; } -{dot}normal { return_token_or_DOT(require_ARB_vp, NORMAL); } -{dot}object { return OBJECT; } -{dot}palette { return PALETTE; } -{dot}params { return PARAMS; } -{dot}plane { return PLANE; } -{dot}point { return_token_or_DOT(require_ARB_vp, POINT_TOK); } -{dot}pointsize { return_token_or_DOT(require_ARB_vp, POINTSIZE); } -{dot}position { return POSITION; } -{dot}primary { return PRIMARY; } -{dot}projection { return PROJECTION; } -{dot}range { return_token_or_DOT(require_ARB_fp, RANGE); } -{dot}row { return ROW; } -{dot}scenecolor { return SCENECOLOR; } -{dot}secondary { return SECONDARY; } -{dot}shininess { return SHININESS; } -{dot}size { return_token_or_DOT(require_ARB_vp, SIZE_TOK); } -{dot}specular { return SPECULAR; } -{dot}spot { return SPOT; } -{dot}texcoord { return TEXCOORD; } -{dot}texenv { return_token_or_DOT(require_ARB_fp, TEXENV); } -{dot}texgen { return_token_or_DOT(require_ARB_vp, TEXGEN); } -{dot}q { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); } -{dot}s { return_token_or_DOT(require_ARB_vp, TEXGEN_S); } -{dot}t { return_token_or_DOT(require_ARB_vp, TEXGEN_T); } -{dot}texture { return TEXTURE; } -{dot}transpose { return TRANSPOSE; } -{dot}attrib { return_token_or_DOT(require_ARB_vp, VTXATTRIB); } -{dot}weight { return_token_or_DOT(require_ARB_vp, WEIGHT); } - -texture { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); } -1D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); } -2D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); } -3D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); } -CUBE { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); } -RECT { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); } -SHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); } -SHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); } -SHADOWRECT { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); } -ARRAY1D { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); } -ARRAY2D { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); } -ARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); } -ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } - -[_a-zA-Z$][_a-zA-Z0-9$]* { return handle_ident(yyextra, yytext, yylval); } - -".." { return DOT_DOT; } - -{num} { - yylval->integer = strtol(yytext, NULL, 10); - return INTEGER; -} -{num}?{frac}{exp}? { - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} -{num}"."/[^.] { - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} -{num}{exp} { - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} -{num}"."{exp} { - yylval->real = _mesa_strtof(yytext, NULL); - return REAL; -} - -".xyzw" { - yylval->swiz_mask.swizzle = SWIZZLE_NOOP; - yylval->swiz_mask.mask = WRITEMASK_XYZW; - return MASK4; -} - -".xy"[zw] { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XY - | mask_from_char(yytext[3]); - return MASK3; -} -".xzw" { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XZW; - return MASK3; -} -".yzw" { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_YZW; - return MASK3; -} - -".x"[yzw] { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_X - | mask_from_char(yytext[2]); - return MASK2; -} -".y"[zw] { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_Y - | mask_from_char(yytext[2]); - return MASK2; -} -".zw" { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_ZW; - return MASK2; -} - -"."[xyzw] { - const unsigned s = swiz_from_char(yytext[1]); - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); - yylval->swiz_mask.mask = mask_from_char(yytext[1]); - return MASK1; -} - -"."[xyzw]{4} { - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), - swiz_from_char(yytext[2]), - swiz_from_char(yytext[3]), - swiz_from_char(yytext[4])); - yylval->swiz_mask.mask = 0; - return SWIZZLE; -} - -".rgba" { - yylval->swiz_mask.swizzle = SWIZZLE_NOOP; - yylval->swiz_mask.mask = WRITEMASK_XYZW; - return_token_or_DOT(require_ARB_fp, MASK4); -} - -".rg"[ba] { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XY - | mask_from_char(yytext[3]); - return_token_or_DOT(require_ARB_fp, MASK3); -} -".rba" { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_XZW; - return_token_or_DOT(require_ARB_fp, MASK3); -} -".gba" { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_YZW; - return_token_or_DOT(require_ARB_fp, MASK3); -} - -".r"[gba] { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_X - | mask_from_char(yytext[2]); - return_token_or_DOT(require_ARB_fp, MASK2); -} -".g"[ba] { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_Y - | mask_from_char(yytext[2]); - return_token_or_DOT(require_ARB_fp, MASK2); -} -".ba" { - yylval->swiz_mask.swizzle = SWIZZLE_INVAL; - yylval->swiz_mask.mask = WRITEMASK_ZW; - return_token_or_DOT(require_ARB_fp, MASK2); -} - -"."[gba] { - const unsigned s = swiz_from_char(yytext[1]); - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); - yylval->swiz_mask.mask = mask_from_char(yytext[1]); - return_token_or_DOT(require_ARB_fp, MASK1); -} - - -".r" { - if (require_ARB_vp) { - return TEXGEN_R; - } else { - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, - SWIZZLE_X, SWIZZLE_X); - yylval->swiz_mask.mask = WRITEMASK_X; - return MASK1; - } -} - -"."[rgba]{4} { - yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), - swiz_from_char(yytext[2]), - swiz_from_char(yytext[3]), - swiz_from_char(yytext[4])); - yylval->swiz_mask.mask = 0; - return_token_or_DOT(require_ARB_fp, SWIZZLE); -} - -"." { return DOT; } - -\n { - yylloc->first_line++; - yylloc->first_column = 1; - yylloc->last_line++; - yylloc->last_column = 1; - yylloc->position++; -} -[ \t\r]+ /* eat whitespace */ ; -#.*$ /* eat comments */ ; -. { return yytext[0]; } -%% - -void -_mesa_program_lexer_ctor(void **scanner, struct asm_parser_state *state, - const char *string, size_t len) -{ - yylex_init_extra(state, scanner); - yy_scan_bytes(string, len, *scanner); -} - -void -_mesa_program_lexer_dtor(void *scanner) -{ - yylex_destroy(scanner); -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.c b/reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.c deleted file mode 100644 index 6f30ef5a5b4..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.c +++ /dev/null @@ -1,5739 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.4.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - -/* Using locations. */ -#define YYLSP_NEEDED 1 - - - -/* Copy the first part of user declarations. */ - -/* Line 189 of yacc.c */ -#line 1 "program/program_parse.y" - -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include -#include - -#include "main/mtypes.h" -#include "main/imports.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/prog_parameter_layout.h" -#include "program/prog_statevars.h" -#include "program/prog_instruction.h" - -#include "program/symbol_table.h" -#include "program/program_parser.h" - -extern void *yy_scan_string(char *); -extern void yy_delete_buffer(void *); - -static struct asm_symbol *declare_variable(struct asm_parser_state *state, - char *name, enum asm_type t, struct YYLTYPE *locp); - -static int add_state_reference(struct gl_program_parameter_list *param_list, - const gl_state_index tokens[STATE_LENGTH]); - -static int initialize_symbol_from_state(struct gl_program *prog, - struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]); - -static int initialize_symbol_from_param(struct gl_program *prog, - struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]); - -static int initialize_symbol_from_const(struct gl_program *prog, - struct asm_symbol *param_var, const struct asm_vector *vec, - GLboolean allowSwizzle); - -static int yyparse(struct asm_parser_state *state); - -static char *make_error_string(const char *fmt, ...); - -static void yyerror(struct YYLTYPE *locp, struct asm_parser_state *state, - const char *s); - -static int validate_inputs(struct YYLTYPE *locp, - struct asm_parser_state *state); - -static void init_dst_reg(struct prog_dst_register *r); - -static void set_dst_reg(struct prog_dst_register *r, - gl_register_file file, GLint index); - -static void init_src_reg(struct asm_src_register *r); - -static void set_src_reg(struct asm_src_register *r, - gl_register_file file, GLint index); - -static void set_src_reg_swz(struct asm_src_register *r, - gl_register_file file, GLint index, GLuint swizzle); - -static void asm_instruction_set_operands(struct asm_instruction *inst, - const struct prog_dst_register *dst, const struct asm_src_register *src0, - const struct asm_src_register *src1, const struct asm_src_register *src2); - -static struct asm_instruction *asm_instruction_ctor(gl_inst_opcode op, - const struct prog_dst_register *dst, const struct asm_src_register *src0, - const struct asm_src_register *src1, const struct asm_src_register *src2); - -static struct asm_instruction *asm_instruction_copy_ctor( - const struct prog_instruction *base, const struct prog_dst_register *dst, - const struct asm_src_register *src0, const struct asm_src_register *src1, - const struct asm_src_register *src2); - -#ifndef FALSE -#define FALSE 0 -#define TRUE (!FALSE) -#endif - -#define YYLLOC_DEFAULT(Current, Rhs, N) \ - do { \ - if (YYID(N)) { \ - (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ - (Current).position = YYRHSLOC(Rhs, 1).position; \ - (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ - } else { \ - (Current).first_line = YYRHSLOC(Rhs, 0).last_line; \ - (Current).last_line = (Current).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 0).last_column; \ - (Current).last_column = (Current).first_column; \ - (Current).position = YYRHSLOC(Rhs, 0).position \ - + (Current).first_column; \ - } \ - } while(YYID(0)) - -#define YYLEX_PARAM state->scanner - - -/* Line 189 of yacc.c */ -#line 192 "program/program_parse.tab.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ARBvp_10 = 258, - ARBfp_10 = 259, - ADDRESS = 260, - ALIAS = 261, - ATTRIB = 262, - OPTION = 263, - OUTPUT = 264, - PARAM = 265, - TEMP = 266, - END = 267, - BIN_OP = 268, - BINSC_OP = 269, - SAMPLE_OP = 270, - SCALAR_OP = 271, - TRI_OP = 272, - VECTOR_OP = 273, - ARL = 274, - KIL = 275, - SWZ = 276, - TXD_OP = 277, - INTEGER = 278, - REAL = 279, - AMBIENT = 280, - ATTENUATION = 281, - BACK = 282, - CLIP = 283, - COLOR = 284, - DEPTH = 285, - DIFFUSE = 286, - DIRECTION = 287, - EMISSION = 288, - ENV = 289, - EYE = 290, - FOG = 291, - FOGCOORD = 292, - FRAGMENT = 293, - FRONT = 294, - HALF = 295, - INVERSE = 296, - INVTRANS = 297, - LIGHT = 298, - LIGHTMODEL = 299, - LIGHTPROD = 300, - LOCAL = 301, - MATERIAL = 302, - MAT_PROGRAM = 303, - MATRIX = 304, - MATRIXINDEX = 305, - MODELVIEW = 306, - MVP = 307, - NORMAL = 308, - OBJECT = 309, - PALETTE = 310, - PARAMS = 311, - PLANE = 312, - POINT_TOK = 313, - POINTSIZE = 314, - POSITION = 315, - PRIMARY = 316, - PROGRAM = 317, - PROJECTION = 318, - RANGE = 319, - RESULT = 320, - ROW = 321, - SCENECOLOR = 322, - SECONDARY = 323, - SHININESS = 324, - SIZE_TOK = 325, - SPECULAR = 326, - SPOT = 327, - STATE = 328, - TEXCOORD = 329, - TEXENV = 330, - TEXGEN = 331, - TEXGEN_Q = 332, - TEXGEN_R = 333, - TEXGEN_S = 334, - TEXGEN_T = 335, - TEXTURE = 336, - TRANSPOSE = 337, - TEXTURE_UNIT = 338, - TEX_1D = 339, - TEX_2D = 340, - TEX_3D = 341, - TEX_CUBE = 342, - TEX_RECT = 343, - TEX_SHADOW1D = 344, - TEX_SHADOW2D = 345, - TEX_SHADOWRECT = 346, - TEX_ARRAY1D = 347, - TEX_ARRAY2D = 348, - TEX_ARRAYSHADOW1D = 349, - TEX_ARRAYSHADOW2D = 350, - VERTEX = 351, - VTXATTRIB = 352, - WEIGHT = 353, - IDENTIFIER = 354, - USED_IDENTIFIER = 355, - MASK4 = 356, - MASK3 = 357, - MASK2 = 358, - MASK1 = 359, - SWIZZLE = 360, - DOT_DOT = 361, - DOT = 362 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ - -/* Line 214 of yacc.c */ -#line 126 "program/program_parse.y" - - struct asm_instruction *inst; - struct asm_symbol *sym; - struct asm_symbol temp_sym; - struct asm_swizzle_mask swiz_mask; - struct asm_src_register src_reg; - struct prog_dst_register dst_reg; - struct prog_instruction temp_inst; - char *string; - unsigned result; - unsigned attrib; - int integer; - float real; - gl_state_index state[STATE_LENGTH]; - int negate; - struct asm_vector vector; - gl_inst_opcode opcode; - - struct { - unsigned swz; - unsigned rgba_valid:1; - unsigned xyzw_valid:1; - unsigned negate:1; - } ext_swizzle; - - - -/* Line 214 of yacc.c */ -#line 363 "program/program_parse.tab.c" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - -/* Copy the second part of user declarations. */ - -/* Line 264 of yacc.c */ -#line 271 "program/program_parse.y" - -extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, - void *yyscanner); - - -/* Line 264 of yacc.c */ -#line 394 "program/program_parse.tab.c" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ - && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; - YYLTYPE yyls_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 5 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 402 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 120 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 143 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 283 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 478 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 362 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 115, 116, 2, 113, 109, 114, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 108, - 2, 117, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 111, 2, 112, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 118, 110, 119, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 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 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 8, 10, 12, 15, 16, 20, 23, - 24, 27, 30, 32, 34, 36, 38, 40, 42, 44, - 46, 48, 50, 52, 54, 59, 64, 69, 76, 83, - 92, 101, 104, 107, 120, 123, 125, 127, 129, 131, - 133, 135, 137, 139, 141, 143, 145, 147, 154, 157, - 162, 165, 167, 171, 177, 181, 184, 192, 195, 197, - 199, 201, 203, 208, 210, 212, 214, 216, 218, 220, - 222, 226, 227, 230, 233, 235, 237, 239, 241, 243, - 245, 247, 249, 251, 252, 254, 256, 258, 260, 261, - 265, 269, 270, 273, 276, 278, 280, 282, 284, 286, - 288, 290, 292, 297, 300, 303, 305, 308, 310, 313, - 315, 318, 323, 328, 330, 331, 335, 337, 339, 342, - 344, 347, 349, 351, 355, 362, 363, 365, 368, 373, - 375, 379, 381, 383, 385, 387, 389, 391, 393, 395, - 397, 399, 402, 405, 408, 411, 414, 417, 420, 423, - 426, 429, 432, 435, 439, 441, 443, 445, 451, 453, - 455, 457, 460, 462, 464, 467, 469, 472, 479, 481, - 485, 487, 489, 491, 493, 495, 500, 502, 504, 506, - 508, 510, 512, 515, 517, 519, 525, 527, 530, 532, - 534, 540, 543, 544, 551, 555, 556, 558, 560, 562, - 564, 566, 569, 571, 573, 576, 581, 586, 587, 591, - 593, 595, 597, 600, 602, 604, 606, 608, 614, 616, - 620, 626, 632, 634, 638, 644, 646, 648, 650, 652, - 654, 656, 658, 660, 662, 666, 672, 680, 690, 693, - 696, 698, 700, 701, 702, 707, 709, 710, 711, 715, - 719, 721, 727, 730, 733, 736, 739, 743, 746, 750, - 751, 755, 757, 759, 760, 762, 764, 765, 767, 769, - 770, 772, 774, 775, 779, 780, 784, 785, 789, 791, - 793, 795, 800, 802 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 121, 0, -1, 122, 123, 125, 12, -1, 3, -1, - 4, -1, 123, 124, -1, -1, 8, 262, 108, -1, - 125, 126, -1, -1, 127, 108, -1, 170, 108, -1, - 128, -1, 129, -1, 130, -1, 131, -1, 132, -1, - 133, -1, 134, -1, 135, -1, 141, -1, 136, -1, - 137, -1, 138, -1, 19, 146, 109, 142, -1, 18, - 145, 109, 144, -1, 16, 145, 109, 142, -1, 14, - 145, 109, 142, 109, 142, -1, 13, 145, 109, 144, - 109, 144, -1, 17, 145, 109, 144, 109, 144, 109, - 144, -1, 15, 145, 109, 144, 109, 139, 109, 140, - -1, 20, 144, -1, 20, 166, -1, 22, 145, 109, - 144, 109, 144, 109, 144, 109, 139, 109, 140, -1, - 83, 256, -1, 84, -1, 85, -1, 86, -1, 87, - -1, 88, -1, 89, -1, 90, -1, 91, -1, 92, - -1, 93, -1, 94, -1, 95, -1, 21, 145, 109, - 150, 109, 147, -1, 241, 143, -1, 241, 110, 143, - 110, -1, 150, 162, -1, 238, -1, 241, 150, 163, - -1, 241, 110, 150, 163, 110, -1, 151, 164, 165, - -1, 159, 161, -1, 148, 109, 148, 109, 148, 109, - 148, -1, 241, 149, -1, 23, -1, 262, -1, 100, - -1, 172, -1, 152, 111, 153, 112, -1, 186, -1, - 249, -1, 100, -1, 100, -1, 154, -1, 155, -1, - 23, -1, 159, 160, 156, -1, -1, 113, 157, -1, - 114, 158, -1, 23, -1, 23, -1, 100, -1, 104, - -1, 104, -1, 104, -1, 104, -1, 101, -1, 105, - -1, -1, 101, -1, 102, -1, 103, -1, 104, -1, - -1, 115, 166, 116, -1, 115, 167, 116, -1, -1, - 168, 163, -1, 169, 163, -1, 99, -1, 100, -1, - 171, -1, 178, -1, 242, -1, 245, -1, 248, -1, - 261, -1, 7, 99, 117, 172, -1, 96, 173, -1, - 38, 177, -1, 60, -1, 98, 175, -1, 53, -1, - 29, 254, -1, 37, -1, 74, 255, -1, 50, 111, - 176, 112, -1, 97, 111, 174, 112, -1, 23, -1, - -1, 111, 176, 112, -1, 23, -1, 60, -1, 29, - 254, -1, 37, -1, 74, 255, -1, 179, -1, 180, - -1, 10, 99, 182, -1, 10, 99, 111, 181, 112, - 183, -1, -1, 23, -1, 117, 185, -1, 117, 118, - 184, 119, -1, 187, -1, 184, 109, 187, -1, 189, - -1, 225, -1, 235, -1, 189, -1, 225, -1, 236, - -1, 188, -1, 226, -1, 235, -1, 189, -1, 73, - 213, -1, 73, 190, -1, 73, 192, -1, 73, 195, - -1, 73, 197, -1, 73, 203, -1, 73, 199, -1, - 73, 206, -1, 73, 208, -1, 73, 210, -1, 73, - 212, -1, 73, 224, -1, 47, 253, 191, -1, 201, - -1, 33, -1, 69, -1, 43, 111, 202, 112, 193, - -1, 201, -1, 60, -1, 26, -1, 72, 194, -1, - 40, -1, 32, -1, 44, 196, -1, 25, -1, 253, - 67, -1, 45, 111, 202, 112, 253, 198, -1, 201, - -1, 75, 257, 200, -1, 29, -1, 25, -1, 31, - -1, 71, -1, 23, -1, 76, 255, 204, 205, -1, - 35, -1, 54, -1, 79, -1, 80, -1, 78, -1, - 77, -1, 36, 207, -1, 29, -1, 56, -1, 28, - 111, 209, 112, 57, -1, 23, -1, 58, 211, -1, - 70, -1, 26, -1, 215, 66, 111, 218, 112, -1, - 215, 214, -1, -1, 66, 111, 218, 106, 218, 112, - -1, 49, 219, 216, -1, -1, 217, -1, 41, -1, - 82, -1, 42, -1, 23, -1, 51, 220, -1, 63, - -1, 52, -1, 81, 255, -1, 55, 111, 222, 112, - -1, 48, 111, 223, 112, -1, -1, 111, 221, 112, - -1, 23, -1, 23, -1, 23, -1, 30, 64, -1, - 229, -1, 232, -1, 227, -1, 230, -1, 62, 34, - 111, 228, 112, -1, 233, -1, 233, 106, 233, -1, - 62, 34, 111, 233, 112, -1, 62, 46, 111, 231, - 112, -1, 234, -1, 234, 106, 234, -1, 62, 46, - 111, 234, 112, -1, 23, -1, 23, -1, 237, -1, - 239, -1, 238, -1, 239, -1, 240, -1, 24, -1, - 23, -1, 118, 240, 119, -1, 118, 240, 109, 240, - 119, -1, 118, 240, 109, 240, 109, 240, 119, -1, - 118, 240, 109, 240, 109, 240, 109, 240, 119, -1, - 241, 24, -1, 241, 23, -1, 113, -1, 114, -1, - -1, -1, 244, 11, 243, 247, -1, 262, -1, -1, - -1, 5, 246, 247, -1, 247, 109, 99, -1, 99, - -1, 244, 9, 99, 117, 249, -1, 65, 60, -1, - 65, 37, -1, 65, 250, -1, 65, 59, -1, 65, - 74, 255, -1, 65, 30, -1, 29, 251, 252, -1, - -1, 111, 23, 112, -1, 39, -1, 27, -1, -1, - 61, -1, 68, -1, -1, 39, -1, 27, -1, -1, - 61, -1, 68, -1, -1, 111, 258, 112, -1, -1, - 111, 259, 112, -1, -1, 111, 260, 112, -1, 23, - -1, 23, -1, 23, -1, 6, 99, 117, 100, -1, - 99, -1, 100, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 278, 278, 281, 289, 301, 302, 305, 329, 330, - 333, 348, 351, 356, 363, 364, 365, 366, 367, 368, - 369, 372, 373, 374, 377, 383, 389, 395, 402, 408, - 415, 459, 464, 474, 518, 524, 525, 526, 527, 528, - 529, 530, 531, 532, 533, 534, 535, 538, 550, 558, - 575, 582, 601, 612, 632, 657, 664, 697, 704, 719, - 774, 817, 826, 848, 858, 862, 891, 910, 910, 912, - 919, 931, 932, 933, 936, 950, 964, 984, 995, 1007, - 1009, 1010, 1011, 1012, 1015, 1015, 1015, 1015, 1016, 1019, - 1023, 1028, 1035, 1042, 1049, 1072, 1095, 1096, 1097, 1098, - 1099, 1100, 1103, 1122, 1126, 1132, 1136, 1140, 1144, 1153, - 1162, 1166, 1171, 1177, 1188, 1188, 1189, 1191, 1195, 1199, - 1203, 1209, 1209, 1211, 1229, 1255, 1258, 1273, 1279, 1285, - 1286, 1293, 1299, 1305, 1313, 1319, 1325, 1333, 1339, 1345, - 1353, 1354, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, - 1365, 1366, 1367, 1370, 1379, 1383, 1387, 1393, 1402, 1406, - 1410, 1419, 1423, 1429, 1435, 1442, 1447, 1455, 1465, 1467, - 1475, 1481, 1485, 1489, 1495, 1506, 1515, 1519, 1524, 1528, - 1532, 1536, 1542, 1549, 1553, 1559, 1567, 1578, 1585, 1589, - 1595, 1605, 1616, 1620, 1638, 1647, 1650, 1656, 1660, 1664, - 1670, 1681, 1686, 1691, 1696, 1701, 1706, 1714, 1717, 1722, - 1735, 1743, 1754, 1762, 1762, 1764, 1764, 1766, 1776, 1781, - 1788, 1798, 1807, 1812, 1819, 1829, 1839, 1851, 1851, 1852, - 1852, 1854, 1864, 1872, 1882, 1890, 1898, 1907, 1918, 1922, - 1928, 1929, 1930, 1933, 1933, 1936, 1971, 1975, 1975, 1978, - 1985, 1994, 2008, 2017, 2026, 2030, 2039, 2048, 2059, 2066, - 2076, 2104, 2113, 2125, 2128, 2137, 2148, 2149, 2150, 2153, - 2154, 2155, 2158, 2159, 2162, 2163, 2166, 2167, 2170, 2181, - 2192, 2203, 2229, 2230 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "ARBvp_10", "ARBfp_10", "ADDRESS", - "ALIAS", "ATTRIB", "OPTION", "OUTPUT", "PARAM", "TEMP", "END", "BIN_OP", - "BINSC_OP", "SAMPLE_OP", "SCALAR_OP", "TRI_OP", "VECTOR_OP", "ARL", - "KIL", "SWZ", "TXD_OP", "INTEGER", "REAL", "AMBIENT", "ATTENUATION", - "BACK", "CLIP", "COLOR", "DEPTH", "DIFFUSE", "DIRECTION", "EMISSION", - "ENV", "EYE", "FOG", "FOGCOORD", "FRAGMENT", "FRONT", "HALF", "INVERSE", - "INVTRANS", "LIGHT", "LIGHTMODEL", "LIGHTPROD", "LOCAL", "MATERIAL", - "MAT_PROGRAM", "MATRIX", "MATRIXINDEX", "MODELVIEW", "MVP", "NORMAL", - "OBJECT", "PALETTE", "PARAMS", "PLANE", "POINT_TOK", "POINTSIZE", - "POSITION", "PRIMARY", "PROGRAM", "PROJECTION", "RANGE", "RESULT", "ROW", - "SCENECOLOR", "SECONDARY", "SHININESS", "SIZE_TOK", "SPECULAR", "SPOT", - "STATE", "TEXCOORD", "TEXENV", "TEXGEN", "TEXGEN_Q", "TEXGEN_R", - "TEXGEN_S", "TEXGEN_T", "TEXTURE", "TRANSPOSE", "TEXTURE_UNIT", "TEX_1D", - "TEX_2D", "TEX_3D", "TEX_CUBE", "TEX_RECT", "TEX_SHADOW1D", - "TEX_SHADOW2D", "TEX_SHADOWRECT", "TEX_ARRAY1D", "TEX_ARRAY2D", - "TEX_ARRAYSHADOW1D", "TEX_ARRAYSHADOW2D", "VERTEX", "VTXATTRIB", - "WEIGHT", "IDENTIFIER", "USED_IDENTIFIER", "MASK4", "MASK3", "MASK2", - "MASK1", "SWIZZLE", "DOT_DOT", "DOT", "';'", "','", "'|'", "'['", "']'", - "'+'", "'-'", "'('", "')'", "'='", "'{'", "'}'", "$accept", "program", - "language", "optionSequence", "option", "statementSequence", "statement", - "instruction", "ALU_instruction", "TexInstruction", "ARL_instruction", - "VECTORop_instruction", "SCALARop_instruction", "BINSCop_instruction", - "BINop_instruction", "TRIop_instruction", "SAMPLE_instruction", - "KIL_instruction", "TXD_instruction", "texImageUnit", "texTarget", - "SWZ_instruction", "scalarSrcReg", "scalarUse", "swizzleSrcReg", - "maskedDstReg", "maskedAddrReg", "extendedSwizzle", "extSwizComp", - "extSwizSel", "srcReg", "dstReg", "progParamArray", "progParamArrayMem", - "progParamArrayAbs", "progParamArrayRel", "addrRegRelOffset", - "addrRegPosOffset", "addrRegNegOffset", "addrReg", "addrComponent", - "addrWriteMask", "scalarSuffix", "swizzleSuffix", "optionalMask", - "optionalCcMask", "ccTest", "ccTest2", "ccMaskRule", "ccMaskRule2", - "namingStatement", "ATTRIB_statement", "attribBinding", "vtxAttribItem", - "vtxAttribNum", "vtxOptWeightNum", "vtxWeightNum", "fragAttribItem", - "PARAM_statement", "PARAM_singleStmt", "PARAM_multipleStmt", - "optArraySize", "paramSingleInit", "paramMultipleInit", - "paramMultInitList", "paramSingleItemDecl", "paramSingleItemUse", - "paramMultipleItem", "stateMultipleItem", "stateSingleItem", - "stateMaterialItem", "stateMatProperty", "stateLightItem", - "stateLightProperty", "stateSpotProperty", "stateLightModelItem", - "stateLModProperty", "stateLightProdItem", "stateLProdProperty", - "stateTexEnvItem", "stateTexEnvProperty", "ambDiffSpecProperty", - "stateLightNumber", "stateTexGenItem", "stateTexGenType", - "stateTexGenCoord", "stateFogItem", "stateFogProperty", - "stateClipPlaneItem", "stateClipPlaneNum", "statePointItem", - "statePointProperty", "stateMatrixRow", "stateMatrixRows", - "optMatrixRows", "stateMatrixItem", "stateOptMatModifier", - "stateMatModifier", "stateMatrixRowNum", "stateMatrixName", - "stateOptModMatNum", "stateModMatNum", "statePaletteMatNum", - "stateProgramMatNum", "stateDepthItem", "programSingleItem", - "programMultipleItem", "progEnvParams", "progEnvParamNums", - "progEnvParam", "progLocalParams", "progLocalParamNums", - "progLocalParam", "progEnvParamNum", "progLocalParamNum", - "paramConstDecl", "paramConstUse", "paramConstScalarDecl", - "paramConstScalarUse", "paramConstVector", "signedFloatConstant", - "optionalSign", "TEMP_statement", "@1", "optVarSize", - "ADDRESS_statement", "@2", "varNameList", "OUTPUT_statement", - "resultBinding", "resultColBinding", "optResultFaceType", - "optResultColorType", "optFaceType", "optColorType", - "optTexCoordUnitNum", "optTexImageUnitNum", "optLegacyTexUnitNum", - "texCoordUnitNum", "texImageUnitNum", "legacyTexUnitNum", - "ALIAS_statement", "string", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 59, 44, - 124, 91, 93, 43, 45, 40, 41, 61, 123, 125 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint16 yyr1[] = -{ - 0, 120, 121, 122, 122, 123, 123, 124, 125, 125, - 126, 126, 127, 127, 128, 128, 128, 128, 128, 128, - 128, 129, 129, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 137, 138, 139, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 140, 140, 140, 141, 142, 142, - 143, 143, 144, 144, 145, 146, 147, 148, 149, 149, - 150, 150, 150, 150, 151, 151, 152, 153, 153, 154, - 155, 156, 156, 156, 157, 158, 159, 160, 161, 162, - 163, 163, 163, 163, 164, 164, 164, 164, 164, 165, - 165, 165, 166, 167, 168, 169, 170, 170, 170, 170, - 170, 170, 171, 172, 172, 173, 173, 173, 173, 173, - 173, 173, 173, 174, 175, 175, 176, 177, 177, 177, - 177, 178, 178, 179, 180, 181, 181, 182, 183, 184, - 184, 185, 185, 185, 186, 186, 186, 187, 187, 187, - 188, 188, 189, 189, 189, 189, 189, 189, 189, 189, - 189, 189, 189, 190, 191, 191, 191, 192, 193, 193, - 193, 193, 193, 194, 195, 196, 196, 197, 198, 199, - 200, 201, 201, 201, 202, 203, 204, 204, 205, 205, - 205, 205, 206, 207, 207, 208, 209, 210, 211, 211, - 212, 213, 214, 214, 215, 216, 216, 217, 217, 217, - 218, 219, 219, 219, 219, 219, 219, 220, 220, 221, - 222, 223, 224, 225, 225, 226, 226, 227, 228, 228, - 229, 230, 231, 231, 232, 233, 234, 235, 235, 236, - 236, 237, 238, 238, 239, 239, 239, 239, 240, 240, - 241, 241, 241, 243, 242, 244, 244, 246, 245, 247, - 247, 248, 249, 249, 249, 249, 249, 249, 250, 251, - 251, 251, 251, 252, 252, 252, 253, 253, 253, 254, - 254, 254, 255, 255, 256, 256, 257, 257, 258, 259, - 260, 261, 262, 262 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 4, 1, 1, 2, 0, 3, 2, 0, - 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 4, 4, 4, 6, 6, 8, - 8, 2, 2, 12, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 6, 2, 4, - 2, 1, 3, 5, 3, 2, 7, 2, 1, 1, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 3, 0, 2, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 1, 1, 1, 1, 0, 3, - 3, 0, 2, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 4, 2, 2, 1, 2, 1, 2, 1, - 2, 4, 4, 1, 0, 3, 1, 1, 2, 1, - 2, 1, 1, 3, 6, 0, 1, 2, 4, 1, - 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 3, 1, 1, 1, 5, 1, 1, - 1, 2, 1, 1, 2, 1, 2, 6, 1, 3, - 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, - 1, 1, 2, 1, 1, 5, 1, 2, 1, 1, - 5, 2, 0, 6, 3, 0, 1, 1, 1, 1, - 1, 2, 1, 1, 2, 4, 4, 0, 3, 1, - 1, 1, 2, 1, 1, 1, 1, 5, 1, 3, - 5, 5, 1, 3, 5, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 5, 7, 9, 2, 2, - 1, 1, 0, 0, 4, 1, 0, 0, 3, 3, - 1, 5, 2, 2, 2, 2, 3, 2, 3, 0, - 3, 1, 1, 0, 1, 1, 0, 1, 1, 0, - 1, 1, 0, 3, 0, 3, 0, 3, 1, 1, - 1, 4, 1, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint16 yydefact[] = -{ - 0, 3, 4, 0, 6, 1, 9, 0, 5, 246, - 282, 283, 0, 247, 0, 0, 0, 2, 0, 0, - 0, 0, 0, 0, 0, 242, 0, 0, 8, 0, - 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, - 23, 20, 0, 96, 97, 121, 122, 98, 0, 99, - 100, 101, 245, 7, 0, 0, 0, 0, 0, 65, - 0, 88, 64, 0, 0, 0, 0, 0, 76, 0, - 0, 94, 240, 241, 31, 32, 83, 0, 0, 0, - 10, 11, 0, 243, 250, 248, 0, 0, 125, 242, - 123, 259, 257, 253, 255, 252, 272, 254, 242, 84, - 85, 86, 87, 91, 242, 242, 242, 242, 242, 242, - 78, 55, 81, 80, 82, 92, 233, 232, 0, 0, - 0, 0, 60, 0, 242, 83, 0, 61, 63, 134, - 135, 213, 214, 136, 229, 230, 0, 242, 0, 0, - 0, 281, 102, 126, 0, 127, 131, 132, 133, 227, - 228, 231, 0, 262, 261, 0, 263, 0, 256, 0, - 0, 54, 0, 0, 0, 26, 0, 25, 24, 269, - 119, 117, 272, 104, 0, 0, 0, 0, 0, 0, - 266, 0, 266, 0, 0, 276, 272, 142, 143, 144, - 145, 147, 146, 148, 149, 150, 151, 0, 152, 269, - 109, 0, 107, 105, 272, 0, 114, 103, 83, 0, - 52, 0, 0, 0, 0, 244, 249, 0, 239, 238, - 0, 264, 265, 258, 278, 0, 242, 95, 0, 0, - 83, 242, 0, 48, 0, 51, 0, 242, 270, 271, - 118, 120, 0, 0, 0, 212, 183, 184, 182, 0, - 165, 268, 267, 164, 0, 0, 0, 0, 207, 203, - 0, 202, 272, 195, 189, 188, 187, 0, 0, 0, - 0, 108, 0, 110, 0, 0, 106, 0, 242, 234, - 69, 0, 67, 68, 0, 242, 242, 251, 0, 124, - 260, 273, 28, 89, 90, 93, 27, 0, 79, 50, - 274, 0, 0, 225, 0, 226, 0, 186, 0, 174, - 0, 166, 0, 171, 172, 155, 156, 173, 153, 154, - 0, 0, 201, 0, 204, 197, 199, 198, 194, 196, - 280, 0, 170, 169, 176, 177, 0, 0, 116, 0, - 113, 0, 0, 53, 0, 62, 77, 71, 47, 0, - 0, 0, 242, 49, 0, 34, 0, 242, 220, 224, - 0, 0, 266, 211, 0, 209, 0, 210, 0, 277, - 181, 180, 178, 179, 175, 200, 0, 111, 112, 115, - 242, 235, 0, 0, 70, 242, 58, 57, 59, 242, - 0, 0, 0, 129, 137, 140, 138, 215, 216, 139, - 279, 0, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 30, 29, 185, 160, 162, 159, - 0, 157, 158, 0, 206, 208, 205, 190, 0, 74, - 72, 75, 73, 0, 0, 0, 0, 141, 192, 242, - 128, 275, 163, 161, 167, 168, 242, 236, 242, 0, - 0, 0, 0, 191, 130, 0, 0, 0, 0, 218, - 0, 222, 0, 237, 242, 0, 217, 0, 221, 0, - 0, 56, 33, 219, 223, 0, 0, 193 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 3, 4, 6, 8, 9, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 301, - 414, 41, 162, 233, 74, 60, 69, 348, 349, 387, - 234, 61, 126, 281, 282, 283, 384, 430, 432, 70, - 347, 111, 299, 115, 103, 161, 75, 229, 76, 230, - 42, 43, 127, 207, 341, 276, 339, 173, 44, 45, - 46, 144, 90, 289, 392, 145, 128, 393, 394, 129, - 187, 318, 188, 421, 443, 189, 253, 190, 444, 191, - 333, 319, 310, 192, 336, 374, 193, 248, 194, 308, - 195, 266, 196, 437, 453, 197, 328, 329, 376, 263, - 322, 366, 368, 364, 198, 130, 396, 397, 458, 131, - 398, 460, 132, 304, 306, 399, 133, 149, 134, 135, - 151, 77, 47, 139, 48, 49, 54, 85, 50, 62, - 97, 156, 223, 254, 240, 158, 355, 268, 225, 401, - 331, 51, 12 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -398 -static const yytype_int16 yypact[] = -{ - 52, -398, -398, 14, -398, -398, 67, 152, -398, 24, - -398, -398, 5, -398, 47, 81, 99, -398, -1, -1, - -1, -1, -1, -1, 43, 56, -1, -1, -398, 97, - -398, -398, -398, -398, -398, -398, -398, -398, -398, -398, - -398, -398, 112, -398, -398, -398, -398, -398, 156, -398, - -398, -398, -398, -398, 111, 98, 141, 95, 127, -398, - 84, 142, -398, 146, 150, 153, 157, 158, -398, 159, - 165, -398, -398, -398, -398, -398, 113, -13, 161, 163, - -398, -398, 162, -398, -398, 164, 174, 10, 252, -3, - -398, -11, -398, -398, -398, -398, 166, -398, -20, -398, - -398, -398, -398, 167, -20, -20, -20, -20, -20, -20, - -398, -398, -398, -398, -398, -398, -398, -398, 137, 70, - 132, 85, 168, 34, -20, 113, 169, -398, -398, -398, - -398, -398, -398, -398, -398, -398, 34, -20, 171, 111, - 179, -398, -398, -398, 172, -398, -398, -398, -398, -398, - -398, -398, 216, -398, -398, 253, 76, 258, -398, 176, - 154, -398, 178, 29, 180, -398, 181, -398, -398, 110, - -398, -398, 166, -398, 175, 182, 183, 219, 32, 184, - 177, 186, 94, 140, 7, 187, 166, -398, -398, -398, - -398, -398, -398, -398, -398, -398, -398, 226, -398, 110, - -398, 188, -398, -398, 166, 189, 190, -398, 113, 9, - -398, 1, 193, 195, 240, 164, -398, 191, -398, -398, - 194, -398, -398, -398, -398, 197, -20, -398, 196, 198, - 113, -20, 34, -398, 203, 206, 228, -20, -398, -398, - -398, -398, 290, 292, 293, -398, -398, -398, -398, 294, - -398, -398, -398, -398, 251, 294, 48, 208, 209, -398, - 210, -398, 166, 21, -398, -398, -398, 299, 295, 12, - 212, -398, 302, -398, 304, 302, -398, 218, -20, -398, - -398, 217, -398, -398, 227, -20, -20, -398, 214, -398, - -398, -398, -398, -398, -398, -398, -398, 220, -398, -398, - 222, 225, 229, -398, 223, -398, 224, -398, 230, -398, - 231, -398, 233, -398, -398, -398, -398, -398, -398, -398, - 314, 316, -398, 317, -398, -398, -398, -398, -398, -398, - -398, 234, -398, -398, -398, -398, 170, 318, -398, 235, - -398, 236, 237, -398, 44, -398, -398, 143, -398, 244, - -15, 245, 36, -398, 332, -398, 138, -20, -398, -398, - 301, 101, 94, -398, 248, -398, 249, -398, 250, -398, - -398, -398, -398, -398, -398, -398, 254, -398, -398, -398, - -20, -398, 333, 340, -398, -20, -398, -398, -398, -20, - 102, 132, 75, -398, -398, -398, -398, -398, -398, -398, - -398, 255, -398, -398, -398, -398, -398, -398, -398, -398, - -398, -398, -398, -398, -398, -398, -398, -398, -398, -398, - 336, -398, -398, 49, -398, -398, -398, -398, 90, -398, - -398, -398, -398, 256, 260, 259, 261, -398, 298, 36, - -398, -398, -398, -398, -398, -398, -20, -398, -20, 228, - 290, 292, 262, -398, -398, 257, 265, 268, 266, 273, - 269, 274, 318, -398, -20, 138, -398, 290, -398, 292, - 107, -398, -398, -398, -398, 318, 270, -398 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -398, -398, -398, -398, -398, -398, -398, -398, -398, -398, - -398, -398, -398, -398, -398, -398, -398, -398, -398, -78, - -82, -398, -100, 155, -86, 215, -398, -398, -372, -398, - -54, -398, -398, -398, -398, -398, -398, -398, -398, 173, - -398, -398, -398, -118, -398, -398, 232, -398, -398, -398, - -398, -398, 303, -398, -398, -398, 114, -398, -398, -398, - -398, -398, -398, -398, -398, -398, -398, -53, -398, -88, - -398, -398, -398, -398, -398, -398, -398, -398, -398, -398, - -398, -334, 130, -398, -398, -398, -398, -398, -398, -398, - -398, -398, -398, -398, -398, 0, -398, -398, -397, -398, - -398, -398, -398, -398, -398, 305, -398, -398, -398, -398, - -398, -398, -398, -396, -383, 306, -398, -398, -137, -87, - -120, -89, -398, -398, -398, -398, -398, 263, -398, 185, - -398, -398, -398, -177, 199, -154, -398, -398, -398, -398, - -398, -398, -6 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -230 -static const yytype_int16 yytable[] = -{ - 152, 146, 150, 52, 209, 256, 165, 210, 386, 168, - 116, 117, 159, 433, 5, 163, 153, 163, 241, 164, - 163, 166, 167, 125, 280, 118, 235, 422, 154, 13, - 14, 15, 269, 264, 16, 152, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 334, 118, 119, - 273, 213, 116, 117, 459, 1, 2, 116, 117, 119, - 120, 246, 325, 326, 58, 470, 335, 118, 461, 208, - 120, 473, 118, 313, 313, 7, 456, 265, 476, 314, - 314, 315, 212, 121, 10, 11, 474, 122, 247, 445, - 277, 119, 471, 72, 73, 235, 119, 123, 390, 59, - 155, 68, 120, 327, 174, 124, 121, 120, 324, 391, - 72, 73, 295, 53, 199, 124, 175, 316, 278, 317, - 317, 251, 200, 10, 11, 121, 313, 417, 279, 122, - 121, 296, 314, 252, 122, 201, 435, 221, 202, 232, - 292, 418, 163, 68, 222, 203, 55, 124, 436, 72, - 73, 302, 124, 380, 124, 71, 91, 92, 344, 204, - 176, 419, 177, 381, 93, 82, 169, 83, 178, 72, - 73, 238, 317, 420, 170, 179, 180, 181, 239, 182, - 56, 183, 205, 206, 439, 423, 94, 95, 257, 152, - 184, 258, 259, 98, 440, 260, 350, 171, 57, 446, - 351, 96, 250, 261, 251, 80, 88, 185, 186, 447, - 84, 172, 89, 475, 112, 86, 252, 113, 114, 427, - 81, 262, 402, 403, 404, 405, 406, 407, 408, 409, - 410, 411, 412, 413, 63, 64, 65, 66, 67, 218, - 219, 78, 79, 99, 100, 101, 102, 370, 371, 372, - 373, 10, 11, 71, 227, 104, 382, 383, 87, 105, - 428, 138, 106, 152, 395, 150, 107, 108, 109, 110, - 136, 415, 137, 140, 141, 143, 220, 157, 216, -66, - 211, 224, 160, 245, 217, 226, 242, 231, 214, 236, - 237, 152, 270, 243, 244, 249, 350, 255, 267, 272, - 274, 275, 285, 434, 286, 58, 290, 298, 288, 291, - -229, 300, 293, 303, 294, 305, 307, 309, 311, 320, - 321, 323, 330, 337, 332, 338, 455, 340, 343, 345, - 353, 346, 352, 354, 356, 358, 359, 363, 357, 365, - 367, 375, 360, 361, 388, 362, 369, 377, 378, 379, - 152, 395, 150, 385, 389, 400, 429, 152, 416, 350, - 424, 425, 426, 431, 452, 448, 427, 441, 442, 449, - 450, 457, 451, 462, 464, 350, 463, 465, 466, 467, - 469, 468, 477, 472, 284, 312, 454, 297, 0, 342, - 142, 438, 228, 0, 147, 148, 0, 0, 271, 287, - 0, 0, 215 -}; - -static const yytype_int16 yycheck[] = -{ - 89, 89, 89, 9, 124, 182, 106, 125, 23, 109, - 23, 24, 98, 385, 0, 104, 27, 106, 172, 105, - 109, 107, 108, 77, 23, 38, 163, 361, 39, 5, - 6, 7, 186, 26, 10, 124, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 35, 38, 62, - 204, 137, 23, 24, 450, 3, 4, 23, 24, 62, - 73, 29, 41, 42, 65, 462, 54, 38, 451, 123, - 73, 467, 38, 25, 25, 8, 448, 70, 475, 31, - 31, 33, 136, 96, 99, 100, 469, 100, 56, 423, - 208, 62, 464, 113, 114, 232, 62, 110, 62, 100, - 111, 100, 73, 82, 34, 118, 96, 73, 262, 73, - 113, 114, 230, 108, 29, 118, 46, 69, 109, 71, - 71, 27, 37, 99, 100, 96, 25, 26, 119, 100, - 96, 231, 31, 39, 100, 50, 34, 61, 53, 110, - 226, 40, 231, 100, 68, 60, 99, 118, 46, 113, - 114, 237, 118, 109, 118, 99, 29, 30, 278, 74, - 28, 60, 30, 119, 37, 9, 29, 11, 36, 113, - 114, 61, 71, 72, 37, 43, 44, 45, 68, 47, - 99, 49, 97, 98, 109, 362, 59, 60, 48, 278, - 58, 51, 52, 109, 119, 55, 285, 60, 99, 109, - 286, 74, 25, 63, 27, 108, 111, 75, 76, 119, - 99, 74, 117, 106, 101, 117, 39, 104, 105, 112, - 108, 81, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 19, 20, 21, 22, 23, 23, - 24, 26, 27, 101, 102, 103, 104, 77, 78, 79, - 80, 99, 100, 99, 100, 109, 113, 114, 117, 109, - 380, 99, 109, 352, 352, 352, 109, 109, 109, 104, - 109, 357, 109, 109, 100, 23, 23, 111, 99, 111, - 111, 23, 115, 64, 112, 109, 111, 109, 117, 109, - 109, 380, 66, 111, 111, 111, 385, 111, 111, 111, - 111, 111, 109, 389, 109, 65, 112, 104, 117, 112, - 104, 83, 116, 23, 116, 23, 23, 23, 67, 111, - 111, 111, 23, 111, 29, 23, 446, 23, 110, 112, - 110, 104, 118, 111, 109, 112, 112, 23, 109, 23, - 23, 23, 112, 112, 350, 112, 112, 112, 112, 112, - 439, 439, 439, 109, 109, 23, 23, 446, 57, 448, - 112, 112, 112, 23, 66, 109, 112, 112, 32, 109, - 111, 449, 111, 111, 109, 464, 119, 109, 112, 106, - 106, 112, 112, 465, 211, 255, 439, 232, -1, 275, - 87, 391, 160, -1, 89, 89, -1, -1, 199, 214, - -1, -1, 139 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint16 yystos[] = -{ - 0, 3, 4, 121, 122, 0, 123, 8, 124, 125, - 99, 100, 262, 5, 6, 7, 10, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 141, 170, 171, 178, 179, 180, 242, 244, 245, - 248, 261, 262, 108, 246, 99, 99, 99, 65, 100, - 145, 151, 249, 145, 145, 145, 145, 145, 100, 146, - 159, 99, 113, 114, 144, 166, 168, 241, 145, 145, - 108, 108, 9, 11, 99, 247, 117, 117, 111, 117, - 182, 29, 30, 37, 59, 60, 74, 250, 109, 101, - 102, 103, 104, 164, 109, 109, 109, 109, 109, 109, - 104, 161, 101, 104, 105, 163, 23, 24, 38, 62, - 73, 96, 100, 110, 118, 150, 152, 172, 186, 189, - 225, 229, 232, 236, 238, 239, 109, 109, 99, 243, - 109, 100, 172, 23, 181, 185, 189, 225, 235, 237, - 239, 240, 241, 27, 39, 111, 251, 111, 255, 144, - 115, 165, 142, 241, 144, 142, 144, 144, 142, 29, - 37, 60, 74, 177, 34, 46, 28, 30, 36, 43, - 44, 45, 47, 49, 58, 75, 76, 190, 192, 195, - 197, 199, 203, 206, 208, 210, 212, 215, 224, 29, - 37, 50, 53, 60, 74, 97, 98, 173, 150, 240, - 163, 111, 150, 144, 117, 247, 99, 112, 23, 24, - 23, 61, 68, 252, 23, 258, 109, 100, 166, 167, - 169, 109, 110, 143, 150, 238, 109, 109, 61, 68, - 254, 255, 111, 111, 111, 64, 29, 56, 207, 111, - 25, 27, 39, 196, 253, 111, 253, 48, 51, 52, - 55, 63, 81, 219, 26, 70, 211, 111, 257, 255, - 66, 254, 111, 255, 111, 111, 175, 163, 109, 119, - 23, 153, 154, 155, 159, 109, 109, 249, 117, 183, - 112, 112, 144, 116, 116, 163, 142, 143, 104, 162, - 83, 139, 144, 23, 233, 23, 234, 23, 209, 23, - 202, 67, 202, 25, 31, 33, 69, 71, 191, 201, - 111, 111, 220, 111, 255, 41, 42, 82, 216, 217, - 23, 260, 29, 200, 35, 54, 204, 111, 23, 176, - 23, 174, 176, 110, 240, 112, 104, 160, 147, 148, - 241, 144, 118, 110, 111, 256, 109, 109, 112, 112, - 112, 112, 112, 23, 223, 23, 221, 23, 222, 112, - 77, 78, 79, 80, 205, 23, 218, 112, 112, 112, - 109, 119, 113, 114, 156, 109, 23, 149, 262, 109, - 62, 73, 184, 187, 188, 189, 226, 227, 230, 235, - 23, 259, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 140, 144, 57, 26, 40, 60, - 72, 193, 201, 253, 112, 112, 112, 112, 240, 23, - 157, 23, 158, 148, 144, 34, 46, 213, 215, 109, - 119, 112, 32, 194, 198, 201, 109, 119, 109, 109, - 111, 111, 66, 214, 187, 240, 148, 139, 228, 233, - 231, 234, 111, 119, 109, 109, 112, 106, 112, 106, - 218, 148, 140, 233, 234, 106, 218, 112 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, state, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval, &yylloc, scanner) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, Location, state); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct asm_parser_state *state) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - struct asm_parser_state *state; -#endif -{ - if (!yyvaluep) - return; - YYUSE (yylocationp); - YYUSE (state); -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct asm_parser_state *state) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, state) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - struct asm_parser_state *state; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - YY_LOCATION_PRINT (yyoutput, *yylocationp); - YYFPRINTF (yyoutput, ": "); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, struct asm_parser_state *state) -#else -static void -yy_reduce_print (yyvsp, yylsp, yyrule, state) - YYSTYPE *yyvsp; - YYLTYPE *yylsp; - int yyrule; - struct asm_parser_state *state; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , &(yylsp[(yyi + 1) - (yynrhs)]) , state); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, yylsp, Rule, state); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct asm_parser_state *state) -#else -static void -yydestruct (yymsg, yytype, yyvaluep, yylocationp, state) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; - YYLTYPE *yylocationp; - struct asm_parser_state *state; -#endif -{ - YYUSE (yyvaluep); - YYUSE (yylocationp); - YYUSE (state); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (struct asm_parser_state *state); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (struct asm_parser_state *state) -#else -int -yyparse (state) - struct asm_parser_state *state; -#endif -#endif -{ -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Location data for the lookahead symbol. */ -YYLTYPE yylloc; - - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls; - YYLTYPE *yylsp; - - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yyls = yylsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - yylsp = yyls; - -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - /* Initialize the default location before parsing starts. */ - yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 1; -#endif - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - YYLTYPE *yyls1 = yyls; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), - &yystacksize); - - yyls = yyls1; - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); - YYSTACK_RELOCATE (yyls_alloc, yyls); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - yylsp = yyls + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - *++yylsp = yylloc; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 3: - -/* Line 1464 of yacc.c */ -#line 282 "program/program_parse.y" - { - if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid fragment program header"); - - } - state->mode = ARB_vertex; - ;} - break; - - case 4: - -/* Line 1464 of yacc.c */ -#line 290 "program/program_parse.y" - { - if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex program header"); - } - state->mode = ARB_fragment; - ;} - break; - - case 7: - -/* Line 1464 of yacc.c */ -#line 306 "program/program_parse.y" - { - int valid = 0; - - if (state->mode == ARB_vertex) { - valid = _mesa_ARBvp_parse_option(state, (yyvsp[(2) - (3)].string)); - } else if (state->mode == ARB_fragment) { - valid = _mesa_ARBfp_parse_option(state, (yyvsp[(2) - (3)].string)); - } - - - free((yyvsp[(2) - (3)].string)); - - if (!valid) { - const char *const err_str = (state->mode == ARB_vertex) - ? "invalid ARB vertex program option" - : "invalid ARB fragment program option"; - - yyerror(& (yylsp[(2) - (3)]), state, err_str); - YYERROR; - } - ;} - break; - - case 10: - -/* Line 1464 of yacc.c */ -#line 334 "program/program_parse.y" - { - if ((yyvsp[(1) - (2)].inst) != NULL) { - if (state->inst_tail == NULL) { - state->inst_head = (yyvsp[(1) - (2)].inst); - } else { - state->inst_tail->next = (yyvsp[(1) - (2)].inst); - } - - state->inst_tail = (yyvsp[(1) - (2)].inst); - (yyvsp[(1) - (2)].inst)->next = NULL; - - state->prog->NumInstructions++; - } - ;} - break; - - case 12: - -/* Line 1464 of yacc.c */ -#line 352 "program/program_parse.y" - { - (yyval.inst) = (yyvsp[(1) - (1)].inst); - state->prog->NumAluInstructions++; - ;} - break; - - case 13: - -/* Line 1464 of yacc.c */ -#line 357 "program/program_parse.y" - { - (yyval.inst) = (yyvsp[(1) - (1)].inst); - state->prog->NumTexInstructions++; - ;} - break; - - case 24: - -/* Line 1464 of yacc.c */ -#line 378 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_ctor(OPCODE_ARL, & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); - ;} - break; - - case 25: - -/* Line 1464 of yacc.c */ -#line 384 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); - ;} - break; - - case 26: - -/* Line 1464 of yacc.c */ -#line 390 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); - ;} - break; - - case 27: - -/* Line 1464 of yacc.c */ -#line 396 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL); - ;} - break; - - case 28: - -/* Line 1464 of yacc.c */ -#line 403 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL); - ;} - break; - - case 29: - -/* Line 1464 of yacc.c */ -#line 410 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), & (yyvsp[(6) - (8)].src_reg), & (yyvsp[(8) - (8)].src_reg)); - ;} - break; - - case 30: - -/* Line 1464 of yacc.c */ -#line 416 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), NULL, NULL); - if ((yyval.inst) != NULL) { - const GLbitfield tex_mask = (1U << (yyvsp[(6) - (8)].integer)); - GLbitfield shadow_tex = 0; - GLbitfield target_mask = 0; - - - (yyval.inst)->Base.TexSrcUnit = (yyvsp[(6) - (8)].integer); - - if ((yyvsp[(8) - (8)].integer) < 0) { - shadow_tex = tex_mask; - - (yyval.inst)->Base.TexSrcTarget = -(yyvsp[(8) - (8)].integer); - (yyval.inst)->Base.TexShadow = 1; - } else { - (yyval.inst)->Base.TexSrcTarget = (yyvsp[(8) - (8)].integer); - } - - target_mask = (1U << (yyval.inst)->Base.TexSrcTarget); - - /* If this texture unit was previously accessed and that access - * had a different texture target, generate an error. - * - * If this texture unit was previously accessed and that access - * had a different shadow mode, generate an error. - */ - if ((state->prog->TexturesUsed[(yyvsp[(6) - (8)].integer)] != 0) - && ((state->prog->TexturesUsed[(yyvsp[(6) - (8)].integer)] != target_mask) - || ((state->prog->ShadowSamplers & tex_mask) - != shadow_tex))) { - yyerror(& (yylsp[(8) - (8)]), state, - "multiple targets used on one texture image unit"); - YYERROR; - } - - - state->prog->TexturesUsed[(yyvsp[(6) - (8)].integer)] |= target_mask; - state->prog->ShadowSamplers |= shadow_tex; - } - ;} - break; - - case 31: - -/* Line 1464 of yacc.c */ -#line 460 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_ctor(OPCODE_KIL, NULL, & (yyvsp[(2) - (2)].src_reg), NULL, NULL); - state->fragment.UsesKill = 1; - ;} - break; - - case 32: - -/* Line 1464 of yacc.c */ -#line 465 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_ctor(OPCODE_KIL_NV, NULL, NULL, NULL, NULL); - (yyval.inst)->Base.DstReg.CondMask = (yyvsp[(2) - (2)].dst_reg).CondMask; - (yyval.inst)->Base.DstReg.CondSwizzle = (yyvsp[(2) - (2)].dst_reg).CondSwizzle; - (yyval.inst)->Base.DstReg.CondSrc = (yyvsp[(2) - (2)].dst_reg).CondSrc; - state->fragment.UsesKill = 1; - ;} - break; - - case 33: - -/* Line 1464 of yacc.c */ -#line 475 "program/program_parse.y" - { - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (12)].temp_inst), & (yyvsp[(2) - (12)].dst_reg), & (yyvsp[(4) - (12)].src_reg), & (yyvsp[(6) - (12)].src_reg), & (yyvsp[(8) - (12)].src_reg)); - if ((yyval.inst) != NULL) { - const GLbitfield tex_mask = (1U << (yyvsp[(10) - (12)].integer)); - GLbitfield shadow_tex = 0; - GLbitfield target_mask = 0; - - - (yyval.inst)->Base.TexSrcUnit = (yyvsp[(10) - (12)].integer); - - if ((yyvsp[(12) - (12)].integer) < 0) { - shadow_tex = tex_mask; - - (yyval.inst)->Base.TexSrcTarget = -(yyvsp[(12) - (12)].integer); - (yyval.inst)->Base.TexShadow = 1; - } else { - (yyval.inst)->Base.TexSrcTarget = (yyvsp[(12) - (12)].integer); - } - - target_mask = (1U << (yyval.inst)->Base.TexSrcTarget); - - /* If this texture unit was previously accessed and that access - * had a different texture target, generate an error. - * - * If this texture unit was previously accessed and that access - * had a different shadow mode, generate an error. - */ - if ((state->prog->TexturesUsed[(yyvsp[(10) - (12)].integer)] != 0) - && ((state->prog->TexturesUsed[(yyvsp[(10) - (12)].integer)] != target_mask) - || ((state->prog->ShadowSamplers & tex_mask) - != shadow_tex))) { - yyerror(& (yylsp[(12) - (12)]), state, - "multiple targets used on one texture image unit"); - YYERROR; - } - - - state->prog->TexturesUsed[(yyvsp[(10) - (12)].integer)] |= target_mask; - state->prog->ShadowSamplers |= shadow_tex; - } - ;} - break; - - case 34: - -/* Line 1464 of yacc.c */ -#line 519 "program/program_parse.y" - { - (yyval.integer) = (yyvsp[(2) - (2)].integer); - ;} - break; - - case 35: - -/* Line 1464 of yacc.c */ -#line 524 "program/program_parse.y" - { (yyval.integer) = TEXTURE_1D_INDEX; ;} - break; - - case 36: - -/* Line 1464 of yacc.c */ -#line 525 "program/program_parse.y" - { (yyval.integer) = TEXTURE_2D_INDEX; ;} - break; - - case 37: - -/* Line 1464 of yacc.c */ -#line 526 "program/program_parse.y" - { (yyval.integer) = TEXTURE_3D_INDEX; ;} - break; - - case 38: - -/* Line 1464 of yacc.c */ -#line 527 "program/program_parse.y" - { (yyval.integer) = TEXTURE_CUBE_INDEX; ;} - break; - - case 40: - -/* Line 1464 of yacc.c */ -#line 529 "program/program_parse.y" - { (yyval.integer) = -TEXTURE_1D_INDEX; ;} - break; - - case 41: - -/* Line 1464 of yacc.c */ -#line 530 "program/program_parse.y" - { (yyval.integer) = -TEXTURE_2D_INDEX; ;} - break; - - case 47: - -/* Line 1464 of yacc.c */ -#line 539 "program/program_parse.y" - { - /* FIXME: Is this correct? Should the extenedSwizzle be applied - * FIXME: to the existing swizzle? - */ - (yyvsp[(4) - (6)].src_reg).Base.Swizzle = (yyvsp[(6) - (6)].swiz_mask).swizzle; - (yyvsp[(4) - (6)].src_reg).Base.Negate = (yyvsp[(6) - (6)].swiz_mask).mask; - - (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), NULL, NULL); - ;} - break; - - case 48: - -/* Line 1464 of yacc.c */ -#line 551 "program/program_parse.y" - { - (yyval.src_reg) = (yyvsp[(2) - (2)].src_reg); - - if ((yyvsp[(1) - (2)].negate)) { - (yyval.src_reg).Base.Negate = ~(yyval.src_reg).Base.Negate; - } - ;} - break; - - case 49: - -/* Line 1464 of yacc.c */ -#line 559 "program/program_parse.y" - { - (yyval.src_reg) = (yyvsp[(3) - (4)].src_reg); - - if (!state->option.NV_fragment) { - yyerror(& (yylsp[(2) - (4)]), state, "unexpected character '|'"); - YYERROR; - } - - if ((yyvsp[(1) - (4)].negate)) { - (yyval.src_reg).Base.Negate = ~(yyval.src_reg).Base.Negate; - } - - (yyval.src_reg).Base.Abs = 1; - ;} - break; - - case 50: - -/* Line 1464 of yacc.c */ -#line 576 "program/program_parse.y" - { - (yyval.src_reg) = (yyvsp[(1) - (2)].src_reg); - - (yyval.src_reg).Base.Swizzle = _mesa_combine_swizzles((yyval.src_reg).Base.Swizzle, - (yyvsp[(2) - (2)].swiz_mask).swizzle); - ;} - break; - - case 51: - -/* Line 1464 of yacc.c */ -#line 583 "program/program_parse.y" - { - struct asm_symbol temp_sym; - - if (!state->option.NV_fragment) { - yyerror(& (yylsp[(1) - (1)]), state, "expected scalar suffix"); - YYERROR; - } - - memset(& temp_sym, 0, sizeof(temp_sym)); - temp_sym.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & temp_sym, & (yyvsp[(1) - (1)].vector), GL_TRUE); - - set_src_reg_swz(& (yyval.src_reg), PROGRAM_CONSTANT, - temp_sym.param_binding_begin, - temp_sym.param_binding_swizzle); - ;} - break; - - case 52: - -/* Line 1464 of yacc.c */ -#line 602 "program/program_parse.y" - { - (yyval.src_reg) = (yyvsp[(2) - (3)].src_reg); - - if ((yyvsp[(1) - (3)].negate)) { - (yyval.src_reg).Base.Negate = ~(yyval.src_reg).Base.Negate; - } - - (yyval.src_reg).Base.Swizzle = _mesa_combine_swizzles((yyval.src_reg).Base.Swizzle, - (yyvsp[(3) - (3)].swiz_mask).swizzle); - ;} - break; - - case 53: - -/* Line 1464 of yacc.c */ -#line 613 "program/program_parse.y" - { - (yyval.src_reg) = (yyvsp[(3) - (5)].src_reg); - - if (!state->option.NV_fragment) { - yyerror(& (yylsp[(2) - (5)]), state, "unexpected character '|'"); - YYERROR; - } - - if ((yyvsp[(1) - (5)].negate)) { - (yyval.src_reg).Base.Negate = ~(yyval.src_reg).Base.Negate; - } - - (yyval.src_reg).Base.Abs = 1; - (yyval.src_reg).Base.Swizzle = _mesa_combine_swizzles((yyval.src_reg).Base.Swizzle, - (yyvsp[(4) - (5)].swiz_mask).swizzle); - ;} - break; - - case 54: - -/* Line 1464 of yacc.c */ -#line 633 "program/program_parse.y" - { - (yyval.dst_reg) = (yyvsp[(1) - (3)].dst_reg); - (yyval.dst_reg).WriteMask = (yyvsp[(2) - (3)].swiz_mask).mask; - (yyval.dst_reg).CondMask = (yyvsp[(3) - (3)].dst_reg).CondMask; - (yyval.dst_reg).CondSwizzle = (yyvsp[(3) - (3)].dst_reg).CondSwizzle; - (yyval.dst_reg).CondSrc = (yyvsp[(3) - (3)].dst_reg).CondSrc; - - if ((yyval.dst_reg).File == PROGRAM_OUTPUT) { - /* Technically speaking, this should check that it is in - * vertex program mode. However, PositionInvariant can never be - * set in fragment program mode, so it is somewhat irrelevant. - */ - if (state->option.PositionInvariant - && ((yyval.dst_reg).Index == VERT_RESULT_HPOS)) { - yyerror(& (yylsp[(1) - (3)]), state, "position-invariant programs cannot " - "write position"); - YYERROR; - } - - state->prog->OutputsWritten |= BITFIELD64_BIT((yyval.dst_reg).Index); - } - ;} - break; - - case 55: - -/* Line 1464 of yacc.c */ -#line 658 "program/program_parse.y" - { - set_dst_reg(& (yyval.dst_reg), PROGRAM_ADDRESS, 0); - (yyval.dst_reg).WriteMask = (yyvsp[(2) - (2)].swiz_mask).mask; - ;} - break; - - case 56: - -/* Line 1464 of yacc.c */ -#line 665 "program/program_parse.y" - { - const unsigned xyzw_valid = - ((yyvsp[(1) - (7)].ext_swizzle).xyzw_valid << 0) - | ((yyvsp[(3) - (7)].ext_swizzle).xyzw_valid << 1) - | ((yyvsp[(5) - (7)].ext_swizzle).xyzw_valid << 2) - | ((yyvsp[(7) - (7)].ext_swizzle).xyzw_valid << 3); - const unsigned rgba_valid = - ((yyvsp[(1) - (7)].ext_swizzle).rgba_valid << 0) - | ((yyvsp[(3) - (7)].ext_swizzle).rgba_valid << 1) - | ((yyvsp[(5) - (7)].ext_swizzle).rgba_valid << 2) - | ((yyvsp[(7) - (7)].ext_swizzle).rgba_valid << 3); - - /* All of the swizzle components have to be valid in either RGBA - * or XYZW. Note that 0 and 1 are valid in both, so both masks - * can have some bits set. - * - * We somewhat deviate from the spec here. It would be really hard - * to figure out which component is the error, and there probably - * isn't a lot of benefit. - */ - if ((rgba_valid != 0x0f) && (xyzw_valid != 0x0f)) { - yyerror(& (yylsp[(1) - (7)]), state, "cannot combine RGBA and XYZW swizzle " - "components"); - YYERROR; - } - - (yyval.swiz_mask).swizzle = MAKE_SWIZZLE4((yyvsp[(1) - (7)].ext_swizzle).swz, (yyvsp[(3) - (7)].ext_swizzle).swz, (yyvsp[(5) - (7)].ext_swizzle).swz, (yyvsp[(7) - (7)].ext_swizzle).swz); - (yyval.swiz_mask).mask = ((yyvsp[(1) - (7)].ext_swizzle).negate) | ((yyvsp[(3) - (7)].ext_swizzle).negate << 1) | ((yyvsp[(5) - (7)].ext_swizzle).negate << 2) - | ((yyvsp[(7) - (7)].ext_swizzle).negate << 3); - ;} - break; - - case 57: - -/* Line 1464 of yacc.c */ -#line 698 "program/program_parse.y" - { - (yyval.ext_swizzle) = (yyvsp[(2) - (2)].ext_swizzle); - (yyval.ext_swizzle).negate = ((yyvsp[(1) - (2)].negate)) ? 1 : 0; - ;} - break; - - case 58: - -/* Line 1464 of yacc.c */ -#line 705 "program/program_parse.y" - { - if (((yyvsp[(1) - (1)].integer) != 0) && ((yyvsp[(1) - (1)].integer) != 1)) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector"); - YYERROR; - } - - (yyval.ext_swizzle).swz = ((yyvsp[(1) - (1)].integer) == 0) ? SWIZZLE_ZERO : SWIZZLE_ONE; - - /* 0 and 1 are valid for both RGBA swizzle names and XYZW - * swizzle names. - */ - (yyval.ext_swizzle).xyzw_valid = 1; - (yyval.ext_swizzle).rgba_valid = 1; - ;} - break; - - case 59: - -/* Line 1464 of yacc.c */ -#line 720 "program/program_parse.y" - { - char s; - - if (strlen((yyvsp[(1) - (1)].string)) > 1) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector"); - YYERROR; - } - - s = (yyvsp[(1) - (1)].string)[0]; - free((yyvsp[(1) - (1)].string)); - - switch (s) { - case 'x': - (yyval.ext_swizzle).swz = SWIZZLE_X; - (yyval.ext_swizzle).xyzw_valid = 1; - break; - case 'y': - (yyval.ext_swizzle).swz = SWIZZLE_Y; - (yyval.ext_swizzle).xyzw_valid = 1; - break; - case 'z': - (yyval.ext_swizzle).swz = SWIZZLE_Z; - (yyval.ext_swizzle).xyzw_valid = 1; - break; - case 'w': - (yyval.ext_swizzle).swz = SWIZZLE_W; - (yyval.ext_swizzle).xyzw_valid = 1; - break; - - case 'r': - (yyval.ext_swizzle).swz = SWIZZLE_X; - (yyval.ext_swizzle).rgba_valid = 1; - break; - case 'g': - (yyval.ext_swizzle).swz = SWIZZLE_Y; - (yyval.ext_swizzle).rgba_valid = 1; - break; - case 'b': - (yyval.ext_swizzle).swz = SWIZZLE_Z; - (yyval.ext_swizzle).rgba_valid = 1; - break; - case 'a': - (yyval.ext_swizzle).swz = SWIZZLE_W; - (yyval.ext_swizzle).rgba_valid = 1; - break; - - default: - yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector"); - YYERROR; - break; - } - ;} - break; - - case 60: - -/* Line 1464 of yacc.c */ -#line 775 "program/program_parse.y" - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); - - free((yyvsp[(1) - (1)].string)); - - if (s == NULL) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable"); - YYERROR; - } else if ((s->type != at_param) && (s->type != at_temp) - && (s->type != at_attrib)) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable"); - YYERROR; - } else if ((s->type == at_param) && s->param_is_array) { - yyerror(& (yylsp[(1) - (1)]), state, "non-array access to array PARAM"); - YYERROR; - } - - init_src_reg(& (yyval.src_reg)); - switch (s->type) { - case at_temp: - set_src_reg(& (yyval.src_reg), PROGRAM_TEMPORARY, s->temp_binding); - break; - case at_param: - set_src_reg_swz(& (yyval.src_reg), s->param_binding_type, - s->param_binding_begin, - s->param_binding_swizzle); - break; - case at_attrib: - set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, s->attrib_binding); - state->prog->InputsRead |= BITFIELD64_BIT((yyval.src_reg).Base.Index); - - if (!validate_inputs(& (yylsp[(1) - (1)]), state)) { - YYERROR; - } - break; - - default: - YYERROR; - break; - } - ;} - break; - - case 61: - -/* Line 1464 of yacc.c */ -#line 818 "program/program_parse.y" - { - set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, (yyvsp[(1) - (1)].attrib)); - state->prog->InputsRead |= BITFIELD64_BIT((yyval.src_reg).Base.Index); - - if (!validate_inputs(& (yylsp[(1) - (1)]), state)) { - YYERROR; - } - ;} - break; - - case 62: - -/* Line 1464 of yacc.c */ -#line 827 "program/program_parse.y" - { - if (! (yyvsp[(3) - (4)].src_reg).Base.RelAddr - && ((unsigned) (yyvsp[(3) - (4)].src_reg).Base.Index >= (yyvsp[(1) - (4)].sym)->param_binding_length)) { - yyerror(& (yylsp[(3) - (4)]), state, "out of bounds array access"); - YYERROR; - } - - init_src_reg(& (yyval.src_reg)); - (yyval.src_reg).Base.File = (yyvsp[(1) - (4)].sym)->param_binding_type; - - if ((yyvsp[(3) - (4)].src_reg).Base.RelAddr) { - state->prog->IndirectRegisterFiles |= (1 << (yyval.src_reg).Base.File); - (yyvsp[(1) - (4)].sym)->param_accessed_indirectly = 1; - - (yyval.src_reg).Base.RelAddr = 1; - (yyval.src_reg).Base.Index = (yyvsp[(3) - (4)].src_reg).Base.Index; - (yyval.src_reg).Symbol = (yyvsp[(1) - (4)].sym); - } else { - (yyval.src_reg).Base.Index = (yyvsp[(1) - (4)].sym)->param_binding_begin + (yyvsp[(3) - (4)].src_reg).Base.Index; - } - ;} - break; - - case 63: - -/* Line 1464 of yacc.c */ -#line 849 "program/program_parse.y" - { - gl_register_file file = ((yyvsp[(1) - (1)].temp_sym).name != NULL) - ? (yyvsp[(1) - (1)].temp_sym).param_binding_type - : PROGRAM_CONSTANT; - set_src_reg_swz(& (yyval.src_reg), file, (yyvsp[(1) - (1)].temp_sym).param_binding_begin, - (yyvsp[(1) - (1)].temp_sym).param_binding_swizzle); - ;} - break; - - case 64: - -/* Line 1464 of yacc.c */ -#line 859 "program/program_parse.y" - { - set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, (yyvsp[(1) - (1)].result)); - ;} - break; - - case 65: - -/* Line 1464 of yacc.c */ -#line 863 "program/program_parse.y" - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); - - free((yyvsp[(1) - (1)].string)); - - if (s == NULL) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable"); - YYERROR; - } else if ((s->type != at_output) && (s->type != at_temp)) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable"); - YYERROR; - } - - switch (s->type) { - case at_temp: - set_dst_reg(& (yyval.dst_reg), PROGRAM_TEMPORARY, s->temp_binding); - break; - case at_output: - set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, s->output_binding); - break; - default: - set_dst_reg(& (yyval.dst_reg), s->param_binding_type, s->param_binding_begin); - break; - } - ;} - break; - - case 66: - -/* Line 1464 of yacc.c */ -#line 892 "program/program_parse.y" - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); - - free((yyvsp[(1) - (1)].string)); - - if (s == NULL) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid operand variable"); - YYERROR; - } else if ((s->type != at_param) || !s->param_is_array) { - yyerror(& (yylsp[(1) - (1)]), state, "array access to non-PARAM variable"); - YYERROR; - } else { - (yyval.sym) = s; - } - ;} - break; - - case 69: - -/* Line 1464 of yacc.c */ -#line 913 "program/program_parse.y" - { - init_src_reg(& (yyval.src_reg)); - (yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 70: - -/* Line 1464 of yacc.c */ -#line 920 "program/program_parse.y" - { - /* FINISHME: Add support for multiple address registers. - */ - /* FINISHME: Add support for 4-component address registers. - */ - init_src_reg(& (yyval.src_reg)); - (yyval.src_reg).Base.RelAddr = 1; - (yyval.src_reg).Base.Index = (yyvsp[(3) - (3)].integer); - ;} - break; - - case 71: - -/* Line 1464 of yacc.c */ -#line 931 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 72: - -/* Line 1464 of yacc.c */ -#line 932 "program/program_parse.y" - { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} - break; - - case 73: - -/* Line 1464 of yacc.c */ -#line 933 "program/program_parse.y" - { (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;} - break; - - case 74: - -/* Line 1464 of yacc.c */ -#line 937 "program/program_parse.y" - { - if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > (state->limits->MaxAddressOffset - 1))) { - char s[100]; - _mesa_snprintf(s, sizeof(s), - "relative address offset too large (%d)", (yyvsp[(1) - (1)].integer)); - yyerror(& (yylsp[(1) - (1)]), state, s); - YYERROR; - } else { - (yyval.integer) = (yyvsp[(1) - (1)].integer); - } - ;} - break; - - case 75: - -/* Line 1464 of yacc.c */ -#line 951 "program/program_parse.y" - { - if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > state->limits->MaxAddressOffset)) { - char s[100]; - _mesa_snprintf(s, sizeof(s), - "relative address offset too large (%d)", (yyvsp[(1) - (1)].integer)); - yyerror(& (yylsp[(1) - (1)]), state, s); - YYERROR; - } else { - (yyval.integer) = (yyvsp[(1) - (1)].integer); - } - ;} - break; - - case 76: - -/* Line 1464 of yacc.c */ -#line 965 "program/program_parse.y" - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); - - free((yyvsp[(1) - (1)].string)); - - if (s == NULL) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid array member"); - YYERROR; - } else if (s->type != at_address) { - yyerror(& (yylsp[(1) - (1)]), state, - "invalid variable for indexed array access"); - YYERROR; - } else { - (yyval.sym) = s; - } - ;} - break; - - case 77: - -/* Line 1464 of yacc.c */ -#line 985 "program/program_parse.y" - { - if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid address component selector"); - YYERROR; - } else { - (yyval.swiz_mask) = (yyvsp[(1) - (1)].swiz_mask); - } - ;} - break; - - case 78: - -/* Line 1464 of yacc.c */ -#line 996 "program/program_parse.y" - { - if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) { - yyerror(& (yylsp[(1) - (1)]), state, - "address register write mask must be \".x\""); - YYERROR; - } else { - (yyval.swiz_mask) = (yyvsp[(1) - (1)].swiz_mask); - } - ;} - break; - - case 83: - -/* Line 1464 of yacc.c */ -#line 1012 "program/program_parse.y" - { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;} - break; - - case 88: - -/* Line 1464 of yacc.c */ -#line 1016 "program/program_parse.y" - { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;} - break; - - case 89: - -/* Line 1464 of yacc.c */ -#line 1020 "program/program_parse.y" - { - (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg); - ;} - break; - - case 90: - -/* Line 1464 of yacc.c */ -#line 1024 "program/program_parse.y" - { - (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg); - ;} - break; - - case 91: - -/* Line 1464 of yacc.c */ -#line 1028 "program/program_parse.y" - { - (yyval.dst_reg).CondMask = COND_TR; - (yyval.dst_reg).CondSwizzle = SWIZZLE_NOOP; - (yyval.dst_reg).CondSrc = 0; - ;} - break; - - case 92: - -/* Line 1464 of yacc.c */ -#line 1036 "program/program_parse.y" - { - (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg); - (yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle; - ;} - break; - - case 93: - -/* Line 1464 of yacc.c */ -#line 1043 "program/program_parse.y" - { - (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg); - (yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle; - ;} - break; - - case 94: - -/* Line 1464 of yacc.c */ -#line 1050 "program/program_parse.y" - { - const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string)); - if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) { - char *const err_str = - make_error_string("invalid condition code \"%s\"", (yyvsp[(1) - (1)].string)); - - yyerror(& (yylsp[(1) - (1)]), state, (err_str != NULL) - ? err_str : "invalid condition code"); - - if (err_str != NULL) { - free(err_str); - } - - YYERROR; - } - - (yyval.dst_reg).CondMask = cond; - (yyval.dst_reg).CondSwizzle = SWIZZLE_NOOP; - (yyval.dst_reg).CondSrc = 0; - ;} - break; - - case 95: - -/* Line 1464 of yacc.c */ -#line 1073 "program/program_parse.y" - { - const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string)); - if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) { - char *const err_str = - make_error_string("invalid condition code \"%s\"", (yyvsp[(1) - (1)].string)); - - yyerror(& (yylsp[(1) - (1)]), state, (err_str != NULL) - ? err_str : "invalid condition code"); - - if (err_str != NULL) { - free(err_str); - } - - YYERROR; - } - - (yyval.dst_reg).CondMask = cond; - (yyval.dst_reg).CondSwizzle = SWIZZLE_NOOP; - (yyval.dst_reg).CondSrc = 0; - ;} - break; - - case 102: - -/* Line 1464 of yacc.c */ -#line 1104 "program/program_parse.y" - { - struct asm_symbol *const s = - declare_variable(state, (yyvsp[(2) - (4)].string), at_attrib, & (yylsp[(2) - (4)])); - - if (s == NULL) { - free((yyvsp[(2) - (4)].string)); - YYERROR; - } else { - s->attrib_binding = (yyvsp[(4) - (4)].attrib); - state->InputsBound |= BITFIELD64_BIT(s->attrib_binding); - - if (!validate_inputs(& (yylsp[(4) - (4)]), state)) { - YYERROR; - } - } - ;} - break; - - case 103: - -/* Line 1464 of yacc.c */ -#line 1123 "program/program_parse.y" - { - (yyval.attrib) = (yyvsp[(2) - (2)].attrib); - ;} - break; - - case 104: - -/* Line 1464 of yacc.c */ -#line 1127 "program/program_parse.y" - { - (yyval.attrib) = (yyvsp[(2) - (2)].attrib); - ;} - break; - - case 105: - -/* Line 1464 of yacc.c */ -#line 1133 "program/program_parse.y" - { - (yyval.attrib) = VERT_ATTRIB_POS; - ;} - break; - - case 106: - -/* Line 1464 of yacc.c */ -#line 1137 "program/program_parse.y" - { - (yyval.attrib) = VERT_ATTRIB_WEIGHT; - ;} - break; - - case 107: - -/* Line 1464 of yacc.c */ -#line 1141 "program/program_parse.y" - { - (yyval.attrib) = VERT_ATTRIB_NORMAL; - ;} - break; - - case 108: - -/* Line 1464 of yacc.c */ -#line 1145 "program/program_parse.y" - { - if (!state->ctx->Extensions.EXT_secondary_color) { - yyerror(& (yylsp[(2) - (2)]), state, "GL_EXT_secondary_color not supported"); - YYERROR; - } - - (yyval.attrib) = VERT_ATTRIB_COLOR0 + (yyvsp[(2) - (2)].integer); - ;} - break; - - case 109: - -/* Line 1464 of yacc.c */ -#line 1154 "program/program_parse.y" - { - if (!state->ctx->Extensions.EXT_fog_coord) { - yyerror(& (yylsp[(1) - (1)]), state, "GL_EXT_fog_coord not supported"); - YYERROR; - } - - (yyval.attrib) = VERT_ATTRIB_FOG; - ;} - break; - - case 110: - -/* Line 1464 of yacc.c */ -#line 1163 "program/program_parse.y" - { - (yyval.attrib) = VERT_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer); - ;} - break; - - case 111: - -/* Line 1464 of yacc.c */ -#line 1167 "program/program_parse.y" - { - yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported"); - YYERROR; - ;} - break; - - case 112: - -/* Line 1464 of yacc.c */ -#line 1172 "program/program_parse.y" - { - (yyval.attrib) = VERT_ATTRIB_GENERIC0 + (yyvsp[(3) - (4)].integer); - ;} - break; - - case 113: - -/* Line 1464 of yacc.c */ -#line 1178 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxAttribs) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex attribute reference"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 117: - -/* Line 1464 of yacc.c */ -#line 1192 "program/program_parse.y" - { - (yyval.attrib) = FRAG_ATTRIB_WPOS; - ;} - break; - - case 118: - -/* Line 1464 of yacc.c */ -#line 1196 "program/program_parse.y" - { - (yyval.attrib) = FRAG_ATTRIB_COL0 + (yyvsp[(2) - (2)].integer); - ;} - break; - - case 119: - -/* Line 1464 of yacc.c */ -#line 1200 "program/program_parse.y" - { - (yyval.attrib) = FRAG_ATTRIB_FOGC; - ;} - break; - - case 120: - -/* Line 1464 of yacc.c */ -#line 1204 "program/program_parse.y" - { - (yyval.attrib) = FRAG_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer); - ;} - break; - - case 123: - -/* Line 1464 of yacc.c */ -#line 1212 "program/program_parse.y" - { - struct asm_symbol *const s = - declare_variable(state, (yyvsp[(2) - (3)].string), at_param, & (yylsp[(2) - (3)])); - - if (s == NULL) { - free((yyvsp[(2) - (3)].string)); - YYERROR; - } else { - s->param_binding_type = (yyvsp[(3) - (3)].temp_sym).param_binding_type; - s->param_binding_begin = (yyvsp[(3) - (3)].temp_sym).param_binding_begin; - s->param_binding_length = (yyvsp[(3) - (3)].temp_sym).param_binding_length; - s->param_binding_swizzle = (yyvsp[(3) - (3)].temp_sym).param_binding_swizzle; - s->param_is_array = 0; - } - ;} - break; - - case 124: - -/* Line 1464 of yacc.c */ -#line 1230 "program/program_parse.y" - { - if (((yyvsp[(4) - (6)].integer) != 0) && ((unsigned) (yyvsp[(4) - (6)].integer) != (yyvsp[(6) - (6)].temp_sym).param_binding_length)) { - free((yyvsp[(2) - (6)].string)); - yyerror(& (yylsp[(4) - (6)]), state, - "parameter array size and number of bindings must match"); - YYERROR; - } else { - struct asm_symbol *const s = - declare_variable(state, (yyvsp[(2) - (6)].string), (yyvsp[(6) - (6)].temp_sym).type, & (yylsp[(2) - (6)])); - - if (s == NULL) { - free((yyvsp[(2) - (6)].string)); - YYERROR; - } else { - s->param_binding_type = (yyvsp[(6) - (6)].temp_sym).param_binding_type; - s->param_binding_begin = (yyvsp[(6) - (6)].temp_sym).param_binding_begin; - s->param_binding_length = (yyvsp[(6) - (6)].temp_sym).param_binding_length; - s->param_binding_swizzle = SWIZZLE_XYZW; - s->param_is_array = 1; - } - } - ;} - break; - - case 125: - -/* Line 1464 of yacc.c */ -#line 1255 "program/program_parse.y" - { - (yyval.integer) = 0; - ;} - break; - - case 126: - -/* Line 1464 of yacc.c */ -#line 1259 "program/program_parse.y" - { - if (((yyvsp[(1) - (1)].integer) < 1) || ((unsigned) (yyvsp[(1) - (1)].integer) > state->limits->MaxParameters)) { - char msg[100]; - _mesa_snprintf(msg, sizeof(msg), - "invalid parameter array size (size=%d max=%u)", - (yyvsp[(1) - (1)].integer), state->limits->MaxParameters); - yyerror(& (yylsp[(1) - (1)]), state, msg); - YYERROR; - } else { - (yyval.integer) = (yyvsp[(1) - (1)].integer); - } - ;} - break; - - case 127: - -/* Line 1464 of yacc.c */ -#line 1274 "program/program_parse.y" - { - (yyval.temp_sym) = (yyvsp[(2) - (2)].temp_sym); - ;} - break; - - case 128: - -/* Line 1464 of yacc.c */ -#line 1280 "program/program_parse.y" - { - (yyval.temp_sym) = (yyvsp[(3) - (4)].temp_sym); - ;} - break; - - case 130: - -/* Line 1464 of yacc.c */ -#line 1287 "program/program_parse.y" - { - (yyvsp[(1) - (3)].temp_sym).param_binding_length += (yyvsp[(3) - (3)].temp_sym).param_binding_length; - (yyval.temp_sym) = (yyvsp[(1) - (3)].temp_sym); - ;} - break; - - case 131: - -/* Line 1464 of yacc.c */ -#line 1294 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_state(state->prog, & (yyval.temp_sym), (yyvsp[(1) - (1)].state)); - ;} - break; - - case 132: - -/* Line 1464 of yacc.c */ -#line 1300 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_param(state->prog, & (yyval.temp_sym), (yyvsp[(1) - (1)].state)); - ;} - break; - - case 133: - -/* Line 1464 of yacc.c */ -#line 1306 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector), GL_TRUE); - ;} - break; - - case 134: - -/* Line 1464 of yacc.c */ -#line 1314 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_state(state->prog, & (yyval.temp_sym), (yyvsp[(1) - (1)].state)); - ;} - break; - - case 135: - -/* Line 1464 of yacc.c */ -#line 1320 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_param(state->prog, & (yyval.temp_sym), (yyvsp[(1) - (1)].state)); - ;} - break; - - case 136: - -/* Line 1464 of yacc.c */ -#line 1326 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector), GL_TRUE); - ;} - break; - - case 137: - -/* Line 1464 of yacc.c */ -#line 1334 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_state(state->prog, & (yyval.temp_sym), (yyvsp[(1) - (1)].state)); - ;} - break; - - case 138: - -/* Line 1464 of yacc.c */ -#line 1340 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_param(state->prog, & (yyval.temp_sym), (yyvsp[(1) - (1)].state)); - ;} - break; - - case 139: - -/* Line 1464 of yacc.c */ -#line 1346 "program/program_parse.y" - { - memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); - (yyval.temp_sym).param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & (yyval.temp_sym), & (yyvsp[(1) - (1)].vector), GL_FALSE); - ;} - break; - - case 140: - -/* Line 1464 of yacc.c */ -#line 1353 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(1) - (1)].state), sizeof((yyval.state))); ;} - break; - - case 141: - -/* Line 1464 of yacc.c */ -#line 1354 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 142: - -/* Line 1464 of yacc.c */ -#line 1357 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 143: - -/* Line 1464 of yacc.c */ -#line 1358 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 144: - -/* Line 1464 of yacc.c */ -#line 1359 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 145: - -/* Line 1464 of yacc.c */ -#line 1360 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 146: - -/* Line 1464 of yacc.c */ -#line 1361 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 147: - -/* Line 1464 of yacc.c */ -#line 1362 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 148: - -/* Line 1464 of yacc.c */ -#line 1363 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 149: - -/* Line 1464 of yacc.c */ -#line 1364 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 150: - -/* Line 1464 of yacc.c */ -#line 1365 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 151: - -/* Line 1464 of yacc.c */ -#line 1366 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 152: - -/* Line 1464 of yacc.c */ -#line 1367 "program/program_parse.y" - { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} - break; - - case 153: - -/* Line 1464 of yacc.c */ -#line 1371 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_MATERIAL; - (yyval.state)[1] = (yyvsp[(2) - (3)].integer); - (yyval.state)[2] = (yyvsp[(3) - (3)].integer); - ;} - break; - - case 154: - -/* Line 1464 of yacc.c */ -#line 1380 "program/program_parse.y" - { - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 155: - -/* Line 1464 of yacc.c */ -#line 1384 "program/program_parse.y" - { - (yyval.integer) = STATE_EMISSION; - ;} - break; - - case 156: - -/* Line 1464 of yacc.c */ -#line 1388 "program/program_parse.y" - { - (yyval.integer) = STATE_SHININESS; - ;} - break; - - case 157: - -/* Line 1464 of yacc.c */ -#line 1394 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_LIGHT; - (yyval.state)[1] = (yyvsp[(3) - (5)].integer); - (yyval.state)[2] = (yyvsp[(5) - (5)].integer); - ;} - break; - - case 158: - -/* Line 1464 of yacc.c */ -#line 1403 "program/program_parse.y" - { - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 159: - -/* Line 1464 of yacc.c */ -#line 1407 "program/program_parse.y" - { - (yyval.integer) = STATE_POSITION; - ;} - break; - - case 160: - -/* Line 1464 of yacc.c */ -#line 1411 "program/program_parse.y" - { - if (!state->ctx->Extensions.EXT_point_parameters) { - yyerror(& (yylsp[(1) - (1)]), state, "GL_ARB_point_parameters not supported"); - YYERROR; - } - - (yyval.integer) = STATE_ATTENUATION; - ;} - break; - - case 161: - -/* Line 1464 of yacc.c */ -#line 1420 "program/program_parse.y" - { - (yyval.integer) = (yyvsp[(2) - (2)].integer); - ;} - break; - - case 162: - -/* Line 1464 of yacc.c */ -#line 1424 "program/program_parse.y" - { - (yyval.integer) = STATE_HALF_VECTOR; - ;} - break; - - case 163: - -/* Line 1464 of yacc.c */ -#line 1430 "program/program_parse.y" - { - (yyval.integer) = STATE_SPOT_DIRECTION; - ;} - break; - - case 164: - -/* Line 1464 of yacc.c */ -#line 1436 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(2) - (2)].state)[0]; - (yyval.state)[1] = (yyvsp[(2) - (2)].state)[1]; - ;} - break; - - case 165: - -/* Line 1464 of yacc.c */ -#line 1443 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_LIGHTMODEL_AMBIENT; - ;} - break; - - case 166: - -/* Line 1464 of yacc.c */ -#line 1448 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_LIGHTMODEL_SCENECOLOR; - (yyval.state)[1] = (yyvsp[(1) - (2)].integer); - ;} - break; - - case 167: - -/* Line 1464 of yacc.c */ -#line 1456 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_LIGHTPROD; - (yyval.state)[1] = (yyvsp[(3) - (6)].integer); - (yyval.state)[2] = (yyvsp[(5) - (6)].integer); - (yyval.state)[3] = (yyvsp[(6) - (6)].integer); - ;} - break; - - case 169: - -/* Line 1464 of yacc.c */ -#line 1468 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = (yyvsp[(3) - (3)].integer); - (yyval.state)[1] = (yyvsp[(2) - (3)].integer); - ;} - break; - - case 170: - -/* Line 1464 of yacc.c */ -#line 1476 "program/program_parse.y" - { - (yyval.integer) = STATE_TEXENV_COLOR; - ;} - break; - - case 171: - -/* Line 1464 of yacc.c */ -#line 1482 "program/program_parse.y" - { - (yyval.integer) = STATE_AMBIENT; - ;} - break; - - case 172: - -/* Line 1464 of yacc.c */ -#line 1486 "program/program_parse.y" - { - (yyval.integer) = STATE_DIFFUSE; - ;} - break; - - case 173: - -/* Line 1464 of yacc.c */ -#line 1490 "program/program_parse.y" - { - (yyval.integer) = STATE_SPECULAR; - ;} - break; - - case 174: - -/* Line 1464 of yacc.c */ -#line 1496 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxLights) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid light selector"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 175: - -/* Line 1464 of yacc.c */ -#line 1507 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_TEXGEN; - (yyval.state)[1] = (yyvsp[(2) - (4)].integer); - (yyval.state)[2] = (yyvsp[(3) - (4)].integer) + (yyvsp[(4) - (4)].integer); - ;} - break; - - case 176: - -/* Line 1464 of yacc.c */ -#line 1516 "program/program_parse.y" - { - (yyval.integer) = STATE_TEXGEN_EYE_S; - ;} - break; - - case 177: - -/* Line 1464 of yacc.c */ -#line 1520 "program/program_parse.y" - { - (yyval.integer) = STATE_TEXGEN_OBJECT_S; - ;} - break; - - case 178: - -/* Line 1464 of yacc.c */ -#line 1525 "program/program_parse.y" - { - (yyval.integer) = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S; - ;} - break; - - case 179: - -/* Line 1464 of yacc.c */ -#line 1529 "program/program_parse.y" - { - (yyval.integer) = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S; - ;} - break; - - case 180: - -/* Line 1464 of yacc.c */ -#line 1533 "program/program_parse.y" - { - (yyval.integer) = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S; - ;} - break; - - case 181: - -/* Line 1464 of yacc.c */ -#line 1537 "program/program_parse.y" - { - (yyval.integer) = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S; - ;} - break; - - case 182: - -/* Line 1464 of yacc.c */ -#line 1543 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = (yyvsp[(2) - (2)].integer); - ;} - break; - - case 183: - -/* Line 1464 of yacc.c */ -#line 1550 "program/program_parse.y" - { - (yyval.integer) = STATE_FOG_COLOR; - ;} - break; - - case 184: - -/* Line 1464 of yacc.c */ -#line 1554 "program/program_parse.y" - { - (yyval.integer) = STATE_FOG_PARAMS; - ;} - break; - - case 185: - -/* Line 1464 of yacc.c */ -#line 1560 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_CLIPPLANE; - (yyval.state)[1] = (yyvsp[(3) - (5)].integer); - ;} - break; - - case 186: - -/* Line 1464 of yacc.c */ -#line 1568 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxClipPlanes) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid clip plane selector"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 187: - -/* Line 1464 of yacc.c */ -#line 1579 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = (yyvsp[(2) - (2)].integer); - ;} - break; - - case 188: - -/* Line 1464 of yacc.c */ -#line 1586 "program/program_parse.y" - { - (yyval.integer) = STATE_POINT_SIZE; - ;} - break; - - case 189: - -/* Line 1464 of yacc.c */ -#line 1590 "program/program_parse.y" - { - (yyval.integer) = STATE_POINT_ATTENUATION; - ;} - break; - - case 190: - -/* Line 1464 of yacc.c */ -#line 1596 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(1) - (5)].state)[0]; - (yyval.state)[1] = (yyvsp[(1) - (5)].state)[1]; - (yyval.state)[2] = (yyvsp[(4) - (5)].integer); - (yyval.state)[3] = (yyvsp[(4) - (5)].integer); - (yyval.state)[4] = (yyvsp[(1) - (5)].state)[2]; - ;} - break; - - case 191: - -/* Line 1464 of yacc.c */ -#line 1606 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(1) - (2)].state)[0]; - (yyval.state)[1] = (yyvsp[(1) - (2)].state)[1]; - (yyval.state)[2] = (yyvsp[(2) - (2)].state)[2]; - (yyval.state)[3] = (yyvsp[(2) - (2)].state)[3]; - (yyval.state)[4] = (yyvsp[(1) - (2)].state)[2]; - ;} - break; - - case 192: - -/* Line 1464 of yacc.c */ -#line 1616 "program/program_parse.y" - { - (yyval.state)[2] = 0; - (yyval.state)[3] = 3; - ;} - break; - - case 193: - -/* Line 1464 of yacc.c */ -#line 1621 "program/program_parse.y" - { - /* It seems logical that the matrix row range specifier would have - * to specify a range or more than one row (i.e., $5 > $3). - * However, the ARB_vertex_program spec says "a program will fail - * to load if is greater than ." This means that $3 == $5 - * is valid. - */ - if ((yyvsp[(3) - (6)].integer) > (yyvsp[(5) - (6)].integer)) { - yyerror(& (yylsp[(3) - (6)]), state, "invalid matrix row range"); - YYERROR; - } - - (yyval.state)[2] = (yyvsp[(3) - (6)].integer); - (yyval.state)[3] = (yyvsp[(5) - (6)].integer); - ;} - break; - - case 194: - -/* Line 1464 of yacc.c */ -#line 1639 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(2) - (3)].state)[0]; - (yyval.state)[1] = (yyvsp[(2) - (3)].state)[1]; - (yyval.state)[2] = (yyvsp[(3) - (3)].integer); - ;} - break; - - case 195: - -/* Line 1464 of yacc.c */ -#line 1647 "program/program_parse.y" - { - (yyval.integer) = 0; - ;} - break; - - case 196: - -/* Line 1464 of yacc.c */ -#line 1651 "program/program_parse.y" - { - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 197: - -/* Line 1464 of yacc.c */ -#line 1657 "program/program_parse.y" - { - (yyval.integer) = STATE_MATRIX_INVERSE; - ;} - break; - - case 198: - -/* Line 1464 of yacc.c */ -#line 1661 "program/program_parse.y" - { - (yyval.integer) = STATE_MATRIX_TRANSPOSE; - ;} - break; - - case 199: - -/* Line 1464 of yacc.c */ -#line 1665 "program/program_parse.y" - { - (yyval.integer) = STATE_MATRIX_INVTRANS; - ;} - break; - - case 200: - -/* Line 1464 of yacc.c */ -#line 1671 "program/program_parse.y" - { - if ((yyvsp[(1) - (1)].integer) > 3) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid matrix row reference"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 201: - -/* Line 1464 of yacc.c */ -#line 1682 "program/program_parse.y" - { - (yyval.state)[0] = STATE_MODELVIEW_MATRIX; - (yyval.state)[1] = (yyvsp[(2) - (2)].integer); - ;} - break; - - case 202: - -/* Line 1464 of yacc.c */ -#line 1687 "program/program_parse.y" - { - (yyval.state)[0] = STATE_PROJECTION_MATRIX; - (yyval.state)[1] = 0; - ;} - break; - - case 203: - -/* Line 1464 of yacc.c */ -#line 1692 "program/program_parse.y" - { - (yyval.state)[0] = STATE_MVP_MATRIX; - (yyval.state)[1] = 0; - ;} - break; - - case 204: - -/* Line 1464 of yacc.c */ -#line 1697 "program/program_parse.y" - { - (yyval.state)[0] = STATE_TEXTURE_MATRIX; - (yyval.state)[1] = (yyvsp[(2) - (2)].integer); - ;} - break; - - case 205: - -/* Line 1464 of yacc.c */ -#line 1702 "program/program_parse.y" - { - yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported"); - YYERROR; - ;} - break; - - case 206: - -/* Line 1464 of yacc.c */ -#line 1707 "program/program_parse.y" - { - (yyval.state)[0] = STATE_PROGRAM_MATRIX; - (yyval.state)[1] = (yyvsp[(3) - (4)].integer); - ;} - break; - - case 207: - -/* Line 1464 of yacc.c */ -#line 1714 "program/program_parse.y" - { - (yyval.integer) = 0; - ;} - break; - - case 208: - -/* Line 1464 of yacc.c */ -#line 1718 "program/program_parse.y" - { - (yyval.integer) = (yyvsp[(2) - (3)].integer); - ;} - break; - - case 209: - -/* Line 1464 of yacc.c */ -#line 1723 "program/program_parse.y" - { - /* Since GL_ARB_vertex_blend isn't supported, only modelview matrix - * zero is valid. - */ - if ((yyvsp[(1) - (1)].integer) != 0) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid modelview matrix index"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 210: - -/* Line 1464 of yacc.c */ -#line 1736 "program/program_parse.y" - { - /* Since GL_ARB_matrix_palette isn't supported, just let any value - * through here. The error will be generated later. - */ - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 211: - -/* Line 1464 of yacc.c */ -#line 1744 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxProgramMatrices) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid program matrix selector"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 212: - -/* Line 1464 of yacc.c */ -#line 1755 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = STATE_DEPTH_RANGE; - ;} - break; - - case 217: - -/* Line 1464 of yacc.c */ -#line 1767 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = state->state_param_enum; - (yyval.state)[1] = STATE_ENV; - (yyval.state)[2] = (yyvsp[(4) - (5)].state)[0]; - (yyval.state)[3] = (yyvsp[(4) - (5)].state)[1]; - ;} - break; - - case 218: - -/* Line 1464 of yacc.c */ -#line 1777 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(1) - (1)].integer); - (yyval.state)[1] = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 219: - -/* Line 1464 of yacc.c */ -#line 1782 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(1) - (3)].integer); - (yyval.state)[1] = (yyvsp[(3) - (3)].integer); - ;} - break; - - case 220: - -/* Line 1464 of yacc.c */ -#line 1789 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = state->state_param_enum; - (yyval.state)[1] = STATE_ENV; - (yyval.state)[2] = (yyvsp[(4) - (5)].integer); - (yyval.state)[3] = (yyvsp[(4) - (5)].integer); - ;} - break; - - case 221: - -/* Line 1464 of yacc.c */ -#line 1799 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = state->state_param_enum; - (yyval.state)[1] = STATE_LOCAL; - (yyval.state)[2] = (yyvsp[(4) - (5)].state)[0]; - (yyval.state)[3] = (yyvsp[(4) - (5)].state)[1]; - ;} - break; - - case 222: - -/* Line 1464 of yacc.c */ -#line 1808 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(1) - (1)].integer); - (yyval.state)[1] = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 223: - -/* Line 1464 of yacc.c */ -#line 1813 "program/program_parse.y" - { - (yyval.state)[0] = (yyvsp[(1) - (3)].integer); - (yyval.state)[1] = (yyvsp[(3) - (3)].integer); - ;} - break; - - case 224: - -/* Line 1464 of yacc.c */ -#line 1820 "program/program_parse.y" - { - memset((yyval.state), 0, sizeof((yyval.state))); - (yyval.state)[0] = state->state_param_enum; - (yyval.state)[1] = STATE_LOCAL; - (yyval.state)[2] = (yyvsp[(4) - (5)].integer); - (yyval.state)[3] = (yyvsp[(4) - (5)].integer); - ;} - break; - - case 225: - -/* Line 1464 of yacc.c */ -#line 1830 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxEnvParams) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid environment parameter reference"); - YYERROR; - } - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 226: - -/* Line 1464 of yacc.c */ -#line 1840 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxLocalParams) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid local parameter reference"); - YYERROR; - } - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 231: - -/* Line 1464 of yacc.c */ -#line 1855 "program/program_parse.y" - { - (yyval.vector).count = 4; - (yyval.vector).data[0].f = (yyvsp[(1) - (1)].real); - (yyval.vector).data[1].f = (yyvsp[(1) - (1)].real); - (yyval.vector).data[2].f = (yyvsp[(1) - (1)].real); - (yyval.vector).data[3].f = (yyvsp[(1) - (1)].real); - ;} - break; - - case 232: - -/* Line 1464 of yacc.c */ -#line 1865 "program/program_parse.y" - { - (yyval.vector).count = 1; - (yyval.vector).data[0].f = (yyvsp[(1) - (1)].real); - (yyval.vector).data[1].f = (yyvsp[(1) - (1)].real); - (yyval.vector).data[2].f = (yyvsp[(1) - (1)].real); - (yyval.vector).data[3].f = (yyvsp[(1) - (1)].real); - ;} - break; - - case 233: - -/* Line 1464 of yacc.c */ -#line 1873 "program/program_parse.y" - { - (yyval.vector).count = 1; - (yyval.vector).data[0].f = (float) (yyvsp[(1) - (1)].integer); - (yyval.vector).data[1].f = (float) (yyvsp[(1) - (1)].integer); - (yyval.vector).data[2].f = (float) (yyvsp[(1) - (1)].integer); - (yyval.vector).data[3].f = (float) (yyvsp[(1) - (1)].integer); - ;} - break; - - case 234: - -/* Line 1464 of yacc.c */ -#line 1883 "program/program_parse.y" - { - (yyval.vector).count = 4; - (yyval.vector).data[0].f = (yyvsp[(2) - (3)].real); - (yyval.vector).data[1].f = 0.0f; - (yyval.vector).data[2].f = 0.0f; - (yyval.vector).data[3].f = 1.0f; - ;} - break; - - case 235: - -/* Line 1464 of yacc.c */ -#line 1891 "program/program_parse.y" - { - (yyval.vector).count = 4; - (yyval.vector).data[0].f = (yyvsp[(2) - (5)].real); - (yyval.vector).data[1].f = (yyvsp[(4) - (5)].real); - (yyval.vector).data[2].f = 0.0f; - (yyval.vector).data[3].f = 1.0f; - ;} - break; - - case 236: - -/* Line 1464 of yacc.c */ -#line 1900 "program/program_parse.y" - { - (yyval.vector).count = 4; - (yyval.vector).data[0].f = (yyvsp[(2) - (7)].real); - (yyval.vector).data[1].f = (yyvsp[(4) - (7)].real); - (yyval.vector).data[2].f = (yyvsp[(6) - (7)].real); - (yyval.vector).data[3].f = 1.0f; - ;} - break; - - case 237: - -/* Line 1464 of yacc.c */ -#line 1909 "program/program_parse.y" - { - (yyval.vector).count = 4; - (yyval.vector).data[0].f = (yyvsp[(2) - (9)].real); - (yyval.vector).data[1].f = (yyvsp[(4) - (9)].real); - (yyval.vector).data[2].f = (yyvsp[(6) - (9)].real); - (yyval.vector).data[3].f = (yyvsp[(8) - (9)].real); - ;} - break; - - case 238: - -/* Line 1464 of yacc.c */ -#line 1919 "program/program_parse.y" - { - (yyval.real) = ((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].real) : (yyvsp[(2) - (2)].real); - ;} - break; - - case 239: - -/* Line 1464 of yacc.c */ -#line 1923 "program/program_parse.y" - { - (yyval.real) = (float)(((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].integer) : (yyvsp[(2) - (2)].integer)); - ;} - break; - - case 240: - -/* Line 1464 of yacc.c */ -#line 1928 "program/program_parse.y" - { (yyval.negate) = FALSE; ;} - break; - - case 241: - -/* Line 1464 of yacc.c */ -#line 1929 "program/program_parse.y" - { (yyval.negate) = TRUE; ;} - break; - - case 242: - -/* Line 1464 of yacc.c */ -#line 1930 "program/program_parse.y" - { (yyval.negate) = FALSE; ;} - break; - - case 243: - -/* Line 1464 of yacc.c */ -#line 1933 "program/program_parse.y" - { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} - break; - - case 245: - -/* Line 1464 of yacc.c */ -#line 1937 "program/program_parse.y" - { - /* NV_fragment_program_option defines the size qualifiers in a - * fairly broken way. "SHORT" or "LONG" can optionally be used - * before TEMP or OUTPUT. However, neither is a reserved word! - * This means that we have to parse it as an identifier, then check - * to make sure it's one of the valid values. *sigh* - * - * In addition, the grammar in the extension spec does *not* allow - * the size specifier to be optional, but all known implementations - * do. - */ - if (!state->option.NV_fragment) { - yyerror(& (yylsp[(1) - (1)]), state, "unexpected IDENTIFIER"); - YYERROR; - } - - if (strcmp("SHORT", (yyvsp[(1) - (1)].string)) == 0) { - } else if (strcmp("LONG", (yyvsp[(1) - (1)].string)) == 0) { - } else { - char *const err_str = - make_error_string("invalid storage size specifier \"%s\"", - (yyvsp[(1) - (1)].string)); - - yyerror(& (yylsp[(1) - (1)]), state, (err_str != NULL) - ? err_str : "invalid storage size specifier"); - - if (err_str != NULL) { - free(err_str); - } - - YYERROR; - } - ;} - break; - - case 246: - -/* Line 1464 of yacc.c */ -#line 1971 "program/program_parse.y" - { - ;} - break; - - case 247: - -/* Line 1464 of yacc.c */ -#line 1975 "program/program_parse.y" - { (yyval.integer) = (yyvsp[(1) - (1)].integer); ;} - break; - - case 249: - -/* Line 1464 of yacc.c */ -#line 1979 "program/program_parse.y" - { - if (!declare_variable(state, (yyvsp[(3) - (3)].string), (yyvsp[(0) - (3)].integer), & (yylsp[(3) - (3)]))) { - free((yyvsp[(3) - (3)].string)); - YYERROR; - } - ;} - break; - - case 250: - -/* Line 1464 of yacc.c */ -#line 1986 "program/program_parse.y" - { - if (!declare_variable(state, (yyvsp[(1) - (1)].string), (yyvsp[(0) - (1)].integer), & (yylsp[(1) - (1)]))) { - free((yyvsp[(1) - (1)].string)); - YYERROR; - } - ;} - break; - - case 251: - -/* Line 1464 of yacc.c */ -#line 1995 "program/program_parse.y" - { - struct asm_symbol *const s = - declare_variable(state, (yyvsp[(3) - (5)].string), at_output, & (yylsp[(3) - (5)])); - - if (s == NULL) { - free((yyvsp[(3) - (5)].string)); - YYERROR; - } else { - s->output_binding = (yyvsp[(5) - (5)].result); - } - ;} - break; - - case 252: - -/* Line 1464 of yacc.c */ -#line 2009 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.result) = VERT_RESULT_HPOS; - } else { - yyerror(& (yylsp[(2) - (2)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 253: - -/* Line 1464 of yacc.c */ -#line 2018 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.result) = VERT_RESULT_FOGC; - } else { - yyerror(& (yylsp[(2) - (2)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 254: - -/* Line 1464 of yacc.c */ -#line 2027 "program/program_parse.y" - { - (yyval.result) = (yyvsp[(2) - (2)].result); - ;} - break; - - case 255: - -/* Line 1464 of yacc.c */ -#line 2031 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.result) = VERT_RESULT_PSIZ; - } else { - yyerror(& (yylsp[(2) - (2)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 256: - -/* Line 1464 of yacc.c */ -#line 2040 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.result) = VERT_RESULT_TEX0 + (yyvsp[(3) - (3)].integer); - } else { - yyerror(& (yylsp[(2) - (3)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 257: - -/* Line 1464 of yacc.c */ -#line 2049 "program/program_parse.y" - { - if (state->mode == ARB_fragment) { - (yyval.result) = FRAG_RESULT_DEPTH; - } else { - yyerror(& (yylsp[(2) - (2)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 258: - -/* Line 1464 of yacc.c */ -#line 2060 "program/program_parse.y" - { - (yyval.result) = (yyvsp[(2) - (3)].integer) + (yyvsp[(3) - (3)].integer); - ;} - break; - - case 259: - -/* Line 1464 of yacc.c */ -#line 2066 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.integer) = VERT_RESULT_COL0; - } else { - if (state->option.DrawBuffers) - (yyval.integer) = FRAG_RESULT_DATA0; - else - (yyval.integer) = FRAG_RESULT_COLOR; - } - ;} - break; - - case 260: - -/* Line 1464 of yacc.c */ -#line 2077 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - yyerror(& (yylsp[(1) - (3)]), state, "invalid program result name"); - YYERROR; - } else { - if (!state->option.DrawBuffers) { - /* From the ARB_draw_buffers spec (same text exists - * for ATI_draw_buffers): - * - * If this option is not specified, a fragment - * program that attempts to bind - * "result.color[n]" will fail to load, and only - * "result.color" will be allowed. - */ - yyerror(& (yylsp[(1) - (3)]), state, - "result.color[] used without " - "`OPTION ARB_draw_buffers' or " - "`OPTION ATI_draw_buffers'"); - YYERROR; - } else if ((yyvsp[(2) - (3)].integer) >= state->MaxDrawBuffers) { - yyerror(& (yylsp[(1) - (3)]), state, - "result.color[] exceeds MAX_DRAW_BUFFERS_ARB"); - YYERROR; - } - (yyval.integer) = FRAG_RESULT_DATA0 + (yyvsp[(2) - (3)].integer); - } - ;} - break; - - case 261: - -/* Line 1464 of yacc.c */ -#line 2105 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.integer) = VERT_RESULT_COL0; - } else { - yyerror(& (yylsp[(1) - (1)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 262: - -/* Line 1464 of yacc.c */ -#line 2114 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.integer) = VERT_RESULT_BFC0; - } else { - yyerror(& (yylsp[(1) - (1)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 263: - -/* Line 1464 of yacc.c */ -#line 2125 "program/program_parse.y" - { - (yyval.integer) = 0; - ;} - break; - - case 264: - -/* Line 1464 of yacc.c */ -#line 2129 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.integer) = 0; - } else { - yyerror(& (yylsp[(1) - (1)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 265: - -/* Line 1464 of yacc.c */ -#line 2138 "program/program_parse.y" - { - if (state->mode == ARB_vertex) { - (yyval.integer) = 1; - } else { - yyerror(& (yylsp[(1) - (1)]), state, "invalid program result name"); - YYERROR; - } - ;} - break; - - case 266: - -/* Line 1464 of yacc.c */ -#line 2148 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 267: - -/* Line 1464 of yacc.c */ -#line 2149 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 268: - -/* Line 1464 of yacc.c */ -#line 2150 "program/program_parse.y" - { (yyval.integer) = 1; ;} - break; - - case 269: - -/* Line 1464 of yacc.c */ -#line 2153 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 270: - -/* Line 1464 of yacc.c */ -#line 2154 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 271: - -/* Line 1464 of yacc.c */ -#line 2155 "program/program_parse.y" - { (yyval.integer) = 1; ;} - break; - - case 272: - -/* Line 1464 of yacc.c */ -#line 2158 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 273: - -/* Line 1464 of yacc.c */ -#line 2159 "program/program_parse.y" - { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} - break; - - case 274: - -/* Line 1464 of yacc.c */ -#line 2162 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 275: - -/* Line 1464 of yacc.c */ -#line 2163 "program/program_parse.y" - { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} - break; - - case 276: - -/* Line 1464 of yacc.c */ -#line 2166 "program/program_parse.y" - { (yyval.integer) = 0; ;} - break; - - case 277: - -/* Line 1464 of yacc.c */ -#line 2167 "program/program_parse.y" - { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} - break; - - case 278: - -/* Line 1464 of yacc.c */ -#line 2171 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureCoordUnits) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid texture coordinate unit selector"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 279: - -/* Line 1464 of yacc.c */ -#line 2182 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureImageUnits) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid texture image unit selector"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 280: - -/* Line 1464 of yacc.c */ -#line 2193 "program/program_parse.y" - { - if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureUnits) { - yyerror(& (yylsp[(1) - (1)]), state, "invalid texture unit selector"); - YYERROR; - } - - (yyval.integer) = (yyvsp[(1) - (1)].integer); - ;} - break; - - case 281: - -/* Line 1464 of yacc.c */ -#line 2204 "program/program_parse.y" - { - struct asm_symbol *exist = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(2) - (4)].string)); - struct asm_symbol *target = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(4) - (4)].string)); - - free((yyvsp[(4) - (4)].string)); - - if (exist != NULL) { - char m[1000]; - _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string)); - free((yyvsp[(2) - (4)].string)); - yyerror(& (yylsp[(2) - (4)]), state, m); - YYERROR; - } else if (target == NULL) { - free((yyvsp[(2) - (4)].string)); - yyerror(& (yylsp[(4) - (4)]), state, - "undefined variable binding in ALIAS statement"); - YYERROR; - } else { - _mesa_symbol_table_add_symbol(state->st, 0, (yyvsp[(2) - (4)].string), target); - } - ;} - break; - - - -/* Line 1464 of yacc.c */ -#line 4991 "program/program_parse.tab.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - *++yylsp = yyloc; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (&yylloc, state, YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (&yylloc, state, yymsg); - } - else - { - yyerror (&yylloc, state, YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - yyerror_range[1] = yylloc; - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval, &yylloc, state); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - yyerror_range[1] = yylsp[1-yylen]; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - yyerror_range[1] = *yylsp; - yydestruct ("Error: popping", - yystos[yystate], yyvsp, yylsp, state); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - *++yyvsp = yylval; - - yyerror_range[2] = yylloc; - /* Using YYLLOC is tempting, but would change the location of - the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); - *++yylsp = yyloc; - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined(yyoverflow) || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (&yylloc, state, YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, state); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, yylsp, state); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - - -/* Line 1684 of yacc.c */ -#line 2233 "program/program_parse.y" - - -void -asm_instruction_set_operands(struct asm_instruction *inst, - const struct prog_dst_register *dst, - const struct asm_src_register *src0, - const struct asm_src_register *src1, - const struct asm_src_register *src2) -{ - /* In the core ARB extensions only the KIL instruction doesn't have a - * destination register. - */ - if (dst == NULL) { - init_dst_reg(& inst->Base.DstReg); - } else { - inst->Base.DstReg = *dst; - } - - /* The only instruction that doesn't have any source registers is the - * condition-code based KIL instruction added by NV_fragment_program_option. - */ - if (src0 != NULL) { - inst->Base.SrcReg[0] = src0->Base; - inst->SrcReg[0] = *src0; - } else { - init_src_reg(& inst->SrcReg[0]); - } - - if (src1 != NULL) { - inst->Base.SrcReg[1] = src1->Base; - inst->SrcReg[1] = *src1; - } else { - init_src_reg(& inst->SrcReg[1]); - } - - if (src2 != NULL) { - inst->Base.SrcReg[2] = src2->Base; - inst->SrcReg[2] = *src2; - } else { - init_src_reg(& inst->SrcReg[2]); - } -} - - -struct asm_instruction * -asm_instruction_ctor(gl_inst_opcode op, - const struct prog_dst_register *dst, - const struct asm_src_register *src0, - const struct asm_src_register *src1, - const struct asm_src_register *src2) -{ - struct asm_instruction *inst = CALLOC_STRUCT(asm_instruction); - - if (inst) { - _mesa_init_instructions(& inst->Base, 1); - inst->Base.Opcode = op; - - asm_instruction_set_operands(inst, dst, src0, src1, src2); - } - - return inst; -} - - -struct asm_instruction * -asm_instruction_copy_ctor(const struct prog_instruction *base, - const struct prog_dst_register *dst, - const struct asm_src_register *src0, - const struct asm_src_register *src1, - const struct asm_src_register *src2) -{ - struct asm_instruction *inst = CALLOC_STRUCT(asm_instruction); - - if (inst) { - _mesa_init_instructions(& inst->Base, 1); - inst->Base.Opcode = base->Opcode; - inst->Base.CondUpdate = base->CondUpdate; - inst->Base.CondDst = base->CondDst; - inst->Base.SaturateMode = base->SaturateMode; - inst->Base.Precision = base->Precision; - - asm_instruction_set_operands(inst, dst, src0, src1, src2); - } - - return inst; -} - - -void -init_dst_reg(struct prog_dst_register *r) -{ - memset(r, 0, sizeof(*r)); - r->File = PROGRAM_UNDEFINED; - r->WriteMask = WRITEMASK_XYZW; - r->CondMask = COND_TR; - r->CondSwizzle = SWIZZLE_NOOP; -} - - -/** Like init_dst_reg() but set the File and Index fields. */ -void -set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index) -{ - const GLint maxIndex = 1 << INST_INDEX_BITS; - const GLint minIndex = 0; - ASSERT(index >= minIndex); - (void) minIndex; - ASSERT(index <= maxIndex); - (void) maxIndex; - ASSERT(file == PROGRAM_TEMPORARY || - file == PROGRAM_ADDRESS || - file == PROGRAM_OUTPUT); - memset(r, 0, sizeof(*r)); - r->File = file; - r->Index = index; - r->WriteMask = WRITEMASK_XYZW; - r->CondMask = COND_TR; - r->CondSwizzle = SWIZZLE_NOOP; -} - - -void -init_src_reg(struct asm_src_register *r) -{ - memset(r, 0, sizeof(*r)); - r->Base.File = PROGRAM_UNDEFINED; - r->Base.Swizzle = SWIZZLE_NOOP; - r->Symbol = NULL; -} - - -/** Like init_src_reg() but set the File and Index fields. - * \return GL_TRUE if a valid src register, GL_FALSE otherwise - */ -void -set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index) -{ - set_src_reg_swz(r, file, index, SWIZZLE_XYZW); -} - - -void -set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, - GLuint swizzle) -{ - const GLint maxIndex = (1 << INST_INDEX_BITS) - 1; - const GLint minIndex = -(1 << INST_INDEX_BITS); - ASSERT(file < PROGRAM_FILE_MAX); - ASSERT(index >= minIndex); - (void) minIndex; - ASSERT(index <= maxIndex); - (void) maxIndex; - memset(r, 0, sizeof(*r)); - r->Base.File = file; - r->Base.Index = index; - r->Base.Swizzle = swizzle; - r->Symbol = NULL; -} - - -/** - * Validate the set of inputs used by a program - * - * Validates that legal sets of inputs are used by the program. In this case - * "used" included both reading the input or binding the input to a name using - * the \c ATTRIB command. - * - * \return - * \c TRUE if the combination of inputs used is valid, \c FALSE otherwise. - */ -int -validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state) -{ - const GLbitfield64 inputs = state->prog->InputsRead | state->InputsBound; - - if (((inputs & VERT_BIT_FF_ALL) & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) { - yyerror(locp, state, "illegal use of generic attribute and name attribute"); - return 0; - } - - return 1; -} - - -struct asm_symbol * -declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, - struct YYLTYPE *locp) -{ - struct asm_symbol *s = NULL; - struct asm_symbol *exist = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, name); - - - if (exist != NULL) { - yyerror(locp, state, "redeclared identifier"); - } else { - s = calloc(1, sizeof(struct asm_symbol)); - s->name = name; - s->type = t; - - switch (t) { - case at_temp: - if (state->prog->NumTemporaries >= state->limits->MaxTemps) { - yyerror(locp, state, "too many temporaries declared"); - free(s); - return NULL; - } - - s->temp_binding = state->prog->NumTemporaries; - state->prog->NumTemporaries++; - break; - - case at_address: - if (state->prog->NumAddressRegs >= state->limits->MaxAddressRegs) { - yyerror(locp, state, "too many address registers declared"); - free(s); - return NULL; - } - - /* FINISHME: Add support for multiple address registers. - */ - state->prog->NumAddressRegs++; - break; - - default: - break; - } - - _mesa_symbol_table_add_symbol(state->st, 0, s->name, s); - s->next = state->sym; - state->sym = s; - } - - return s; -} - - -int add_state_reference(struct gl_program_parameter_list *param_list, - const gl_state_index tokens[STATE_LENGTH]) -{ - const GLuint size = 4; /* XXX fix */ - char *name; - GLint index; - - name = _mesa_program_state_string(tokens); - index = _mesa_add_parameter(param_list, PROGRAM_STATE_VAR, name, - size, GL_NONE, NULL, tokens, 0x0); - param_list->StateFlags |= _mesa_program_state_flags(tokens); - - /* free name string here since we duplicated it in add_parameter() */ - free(name); - - return index; -} - - -int -initialize_symbol_from_state(struct gl_program *prog, - struct asm_symbol *param_var, - const gl_state_index tokens[STATE_LENGTH]) -{ - int idx = -1; - gl_state_index state_tokens[STATE_LENGTH]; - - - memcpy(state_tokens, tokens, sizeof(state_tokens)); - - param_var->type = at_param; - param_var->param_binding_type = PROGRAM_STATE_VAR; - - /* If we are adding a STATE_MATRIX that has multiple rows, we need to - * unroll it and call add_state_reference() for each row - */ - if ((state_tokens[0] == STATE_MODELVIEW_MATRIX || - state_tokens[0] == STATE_PROJECTION_MATRIX || - state_tokens[0] == STATE_MVP_MATRIX || - state_tokens[0] == STATE_TEXTURE_MATRIX || - state_tokens[0] == STATE_PROGRAM_MATRIX) - && (state_tokens[2] != state_tokens[3])) { - int row; - const int first_row = state_tokens[2]; - const int last_row = state_tokens[3]; - - for (row = first_row; row <= last_row; row++) { - state_tokens[2] = state_tokens[3] = row; - - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - - param_var->param_binding_length++; - } - } - else { - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - param_var->param_binding_length++; - } - - return idx; -} - - -int -initialize_symbol_from_param(struct gl_program *prog, - struct asm_symbol *param_var, - const gl_state_index tokens[STATE_LENGTH]) -{ - int idx = -1; - gl_state_index state_tokens[STATE_LENGTH]; - - - memcpy(state_tokens, tokens, sizeof(state_tokens)); - - assert((state_tokens[0] == STATE_VERTEX_PROGRAM) - || (state_tokens[0] == STATE_FRAGMENT_PROGRAM)); - assert((state_tokens[1] == STATE_ENV) - || (state_tokens[1] == STATE_LOCAL)); - - /* - * The param type is STATE_VAR. The program parameter entry will - * effectively be a pointer into the LOCAL or ENV parameter array. - */ - param_var->type = at_param; - param_var->param_binding_type = PROGRAM_STATE_VAR; - - /* If we are adding a STATE_ENV or STATE_LOCAL that has multiple elements, - * we need to unroll it and call add_state_reference() for each row - */ - if (state_tokens[2] != state_tokens[3]) { - int row; - const int first_row = state_tokens[2]; - const int last_row = state_tokens[3]; - - for (row = first_row; row <= last_row; row++) { - state_tokens[2] = state_tokens[3] = row; - - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - param_var->param_binding_length++; - } - } - else { - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - param_var->param_binding_length++; - } - - return idx; -} - - -/** - * Put a float/vector constant/literal into the parameter list. - * \param param_var returns info about the parameter/constant's location, - * binding, type, etc. - * \param vec the vector/constant to add - * \param allowSwizzle if true, try to consolidate constants which only differ - * by a swizzle. We don't want to do this when building - * arrays of constants that may be indexed indirectly. - * \return index of the constant in the parameter list. - */ -int -initialize_symbol_from_const(struct gl_program *prog, - struct asm_symbol *param_var, - const struct asm_vector *vec, - GLboolean allowSwizzle) -{ - unsigned swizzle; - const int idx = _mesa_add_unnamed_constant(prog->Parameters, - vec->data, vec->count, - allowSwizzle ? &swizzle : NULL); - - param_var->type = at_param; - param_var->param_binding_type = PROGRAM_CONSTANT; - - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = allowSwizzle ? swizzle : SWIZZLE_XYZW; - } - param_var->param_binding_length++; - - return idx; -} - - -char * -make_error_string(const char *fmt, ...) -{ - int length; - char *str; - va_list args; - - - /* Call vsnprintf once to determine how large the final string is. Call it - * again to do the actual formatting. from the vsnprintf manual page: - * - * Upon successful return, these functions return the number of - * characters printed (not including the trailing '\0' used to end - * output to strings). - */ - va_start(args, fmt); - length = 1 + vsnprintf(NULL, 0, fmt, args); - va_end(args); - - str = malloc(length); - if (str) { - va_start(args, fmt); - vsnprintf(str, length, fmt, args); - va_end(args); - } - - return str; -} - - -void -yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s) -{ - char *err_str; - - - err_str = make_error_string("glProgramStringARB(%s)\n", s); - if (err_str) { - _mesa_error(state->ctx, GL_INVALID_OPERATION, "%s", err_str); - free(err_str); - } - - err_str = make_error_string("line %u, char %u: error: %s\n", - locp->first_line, locp->first_column, s); - _mesa_set_program_error(state->ctx, locp->position, err_str); - - if (err_str) { - free(err_str); - } -} - - -GLboolean -_mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *str, - GLsizei len, struct asm_parser_state *state) -{ - struct asm_instruction *inst; - unsigned i; - GLubyte *strz; - GLboolean result = GL_FALSE; - void *temp; - struct asm_symbol *sym; - - state->ctx = ctx; - state->prog->Target = target; - state->prog->Parameters = _mesa_new_parameter_list(); - - /* Make a copy of the program string and force it to be NUL-terminated. - */ - strz = (GLubyte *) malloc(len + 1); - if (strz == NULL) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); - return GL_FALSE; - } - memcpy (strz, str, len); - strz[len] = '\0'; - - state->prog->String = strz; - - state->st = _mesa_symbol_table_ctor(); - - state->limits = (target == GL_VERTEX_PROGRAM_ARB) - ? & ctx->Const.VertexProgram - : & ctx->Const.FragmentProgram; - - state->MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; - state->MaxTextureCoordUnits = ctx->Const.MaxTextureCoordUnits; - state->MaxTextureUnits = ctx->Const.MaxTextureUnits; - state->MaxClipPlanes = ctx->Const.MaxClipPlanes; - state->MaxLights = ctx->Const.MaxLights; - state->MaxProgramMatrices = ctx->Const.MaxProgramMatrices; - state->MaxDrawBuffers = ctx->Const.MaxDrawBuffers; - - state->state_param_enum = (target == GL_VERTEX_PROGRAM_ARB) - ? STATE_VERTEX_PROGRAM : STATE_FRAGMENT_PROGRAM; - - _mesa_set_program_error(ctx, -1, NULL); - - _mesa_program_lexer_ctor(& state->scanner, state, (const char *) str, len); - yyparse(state); - _mesa_program_lexer_dtor(state->scanner); - - - if (ctx->Program.ErrorPos != -1) { - goto error; - } - - if (! _mesa_layout_parameters(state)) { - struct YYLTYPE loc; - - loc.first_line = 0; - loc.first_column = 0; - loc.position = len; - - yyerror(& loc, state, "invalid PARAM usage"); - goto error; - } - - - - /* Add one instruction to store the "END" instruction. - */ - state->prog->Instructions = - _mesa_alloc_instructions(state->prog->NumInstructions + 1); - inst = state->inst_head; - for (i = 0; i < state->prog->NumInstructions; i++) { - struct asm_instruction *const temp = inst->next; - - state->prog->Instructions[i] = inst->Base; - inst = temp; - } - - /* Finally, tag on an OPCODE_END instruction */ - { - const GLuint numInst = state->prog->NumInstructions; - _mesa_init_instructions(state->prog->Instructions + numInst, 1); - state->prog->Instructions[numInst].Opcode = OPCODE_END; - } - state->prog->NumInstructions++; - - state->prog->NumParameters = state->prog->Parameters->NumParameters; - state->prog->NumAttributes = _mesa_bitcount_64(state->prog->InputsRead); - - /* - * Initialize native counts to logical counts. The device driver may - * change them if program is translated into a hardware program. - */ - state->prog->NumNativeInstructions = state->prog->NumInstructions; - state->prog->NumNativeTemporaries = state->prog->NumTemporaries; - state->prog->NumNativeParameters = state->prog->NumParameters; - state->prog->NumNativeAttributes = state->prog->NumAttributes; - state->prog->NumNativeAddressRegs = state->prog->NumAddressRegs; - - result = GL_TRUE; - -error: - for (inst = state->inst_head; inst != NULL; inst = temp) { - temp = inst->next; - free(inst); - } - - state->inst_head = NULL; - state->inst_tail = NULL; - - for (sym = state->sym; sym != NULL; sym = temp) { - temp = sym->next; - - free((void *) sym->name); - free(sym); - } - state->sym = NULL; - - _mesa_symbol_table_dtor(state->st); - state->st = NULL; - - return result; -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.h b/reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.h deleted file mode 100644 index 5dbbcc2377f..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program_parse.tab.h +++ /dev/null @@ -1,208 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ARBvp_10 = 258, - ARBfp_10 = 259, - ADDRESS = 260, - ALIAS = 261, - ATTRIB = 262, - OPTION = 263, - OUTPUT = 264, - PARAM = 265, - TEMP = 266, - END = 267, - BIN_OP = 268, - BINSC_OP = 269, - SAMPLE_OP = 270, - SCALAR_OP = 271, - TRI_OP = 272, - VECTOR_OP = 273, - ARL = 274, - KIL = 275, - SWZ = 276, - TXD_OP = 277, - INTEGER = 278, - REAL = 279, - AMBIENT = 280, - ATTENUATION = 281, - BACK = 282, - CLIP = 283, - COLOR = 284, - DEPTH = 285, - DIFFUSE = 286, - DIRECTION = 287, - EMISSION = 288, - ENV = 289, - EYE = 290, - FOG = 291, - FOGCOORD = 292, - FRAGMENT = 293, - FRONT = 294, - HALF = 295, - INVERSE = 296, - INVTRANS = 297, - LIGHT = 298, - LIGHTMODEL = 299, - LIGHTPROD = 300, - LOCAL = 301, - MATERIAL = 302, - MAT_PROGRAM = 303, - MATRIX = 304, - MATRIXINDEX = 305, - MODELVIEW = 306, - MVP = 307, - NORMAL = 308, - OBJECT = 309, - PALETTE = 310, - PARAMS = 311, - PLANE = 312, - POINT_TOK = 313, - POINTSIZE = 314, - POSITION = 315, - PRIMARY = 316, - PROGRAM = 317, - PROJECTION = 318, - RANGE = 319, - RESULT = 320, - ROW = 321, - SCENECOLOR = 322, - SECONDARY = 323, - SHININESS = 324, - SIZE_TOK = 325, - SPECULAR = 326, - SPOT = 327, - STATE = 328, - TEXCOORD = 329, - TEXENV = 330, - TEXGEN = 331, - TEXGEN_Q = 332, - TEXGEN_R = 333, - TEXGEN_S = 334, - TEXGEN_T = 335, - TEXTURE = 336, - TRANSPOSE = 337, - TEXTURE_UNIT = 338, - TEX_1D = 339, - TEX_2D = 340, - TEX_3D = 341, - TEX_CUBE = 342, - TEX_RECT = 343, - TEX_SHADOW1D = 344, - TEX_SHADOW2D = 345, - TEX_SHADOWRECT = 346, - TEX_ARRAY1D = 347, - TEX_ARRAY2D = 348, - TEX_ARRAYSHADOW1D = 349, - TEX_ARRAYSHADOW2D = 350, - VERTEX = 351, - VTXATTRIB = 352, - WEIGHT = 353, - IDENTIFIER = 354, - USED_IDENTIFIER = 355, - MASK4 = 356, - MASK3 = 357, - MASK2 = 358, - MASK1 = 359, - SWIZZLE = 360, - DOT_DOT = 361, - DOT = 362 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ - -/* Line 1685 of yacc.c */ -#line 126 "program/program_parse.y" - - struct asm_instruction *inst; - struct asm_symbol *sym; - struct asm_symbol temp_sym; - struct asm_swizzle_mask swiz_mask; - struct asm_src_register src_reg; - struct prog_dst_register dst_reg; - struct prog_instruction temp_inst; - char *string; - unsigned result; - unsigned attrib; - int integer; - float real; - gl_state_index state[STATE_LENGTH]; - int negate; - struct asm_vector vector; - gl_inst_opcode opcode; - - struct { - unsigned swz; - unsigned rgba_valid:1; - unsigned xyzw_valid:1; - unsigned negate:1; - } ext_swizzle; - - - -/* Line 1685 of yacc.c */ -#line 186 "program/program_parse.tab.h" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program_parse.y b/reactos/dll/opengl/mesa/src/mesa/program/program_parse.y deleted file mode 100644 index 4f958a99388..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program_parse.y +++ /dev/null @@ -1,2806 +0,0 @@ -%{ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#include -#include -#include - -#include "main/mtypes.h" -#include "main/imports.h" -#include "program/program.h" -#include "program/prog_parameter.h" -#include "program/prog_parameter_layout.h" -#include "program/prog_statevars.h" -#include "program/prog_instruction.h" - -#include "program/symbol_table.h" -#include "program/program_parser.h" - -extern void *yy_scan_string(char *); -extern void yy_delete_buffer(void *); - -static struct asm_symbol *declare_variable(struct asm_parser_state *state, - char *name, enum asm_type t, struct YYLTYPE *locp); - -static int add_state_reference(struct gl_program_parameter_list *param_list, - const gl_state_index tokens[STATE_LENGTH]); - -static int initialize_symbol_from_state(struct gl_program *prog, - struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]); - -static int initialize_symbol_from_param(struct gl_program *prog, - struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]); - -static int initialize_symbol_from_const(struct gl_program *prog, - struct asm_symbol *param_var, const struct asm_vector *vec, - GLboolean allowSwizzle); - -static int yyparse(struct asm_parser_state *state); - -static char *make_error_string(const char *fmt, ...); - -static void yyerror(struct YYLTYPE *locp, struct asm_parser_state *state, - const char *s); - -static int validate_inputs(struct YYLTYPE *locp, - struct asm_parser_state *state); - -static void init_dst_reg(struct prog_dst_register *r); - -static void set_dst_reg(struct prog_dst_register *r, - gl_register_file file, GLint index); - -static void init_src_reg(struct asm_src_register *r); - -static void set_src_reg(struct asm_src_register *r, - gl_register_file file, GLint index); - -static void set_src_reg_swz(struct asm_src_register *r, - gl_register_file file, GLint index, GLuint swizzle); - -static void asm_instruction_set_operands(struct asm_instruction *inst, - const struct prog_dst_register *dst, const struct asm_src_register *src0, - const struct asm_src_register *src1, const struct asm_src_register *src2); - -static struct asm_instruction *asm_instruction_ctor(gl_inst_opcode op, - const struct prog_dst_register *dst, const struct asm_src_register *src0, - const struct asm_src_register *src1, const struct asm_src_register *src2); - -static struct asm_instruction *asm_instruction_copy_ctor( - const struct prog_instruction *base, const struct prog_dst_register *dst, - const struct asm_src_register *src0, const struct asm_src_register *src1, - const struct asm_src_register *src2); - -#ifndef FALSE -#define FALSE 0 -#define TRUE (!FALSE) -#endif - -#define YYLLOC_DEFAULT(Current, Rhs, N) \ - do { \ - if (YYID(N)) { \ - (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ - (Current).position = YYRHSLOC(Rhs, 1).position; \ - (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ - } else { \ - (Current).first_line = YYRHSLOC(Rhs, 0).last_line; \ - (Current).last_line = (Current).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 0).last_column; \ - (Current).last_column = (Current).first_column; \ - (Current).position = YYRHSLOC(Rhs, 0).position \ - + (Current).first_column; \ - } \ - } while(YYID(0)) - -#define YYLEX_PARAM state->scanner -%} - -%pure-parser -%locations -%parse-param { struct asm_parser_state *state } -%error-verbose -%lex-param { void *scanner } - -%union { - struct asm_instruction *inst; - struct asm_symbol *sym; - struct asm_symbol temp_sym; - struct asm_swizzle_mask swiz_mask; - struct asm_src_register src_reg; - struct prog_dst_register dst_reg; - struct prog_instruction temp_inst; - char *string; - unsigned result; - unsigned attrib; - int integer; - float real; - gl_state_index state[STATE_LENGTH]; - int negate; - struct asm_vector vector; - gl_inst_opcode opcode; - - struct { - unsigned swz; - unsigned rgba_valid:1; - unsigned xyzw_valid:1; - unsigned negate:1; - } ext_swizzle; -} - -%token ARBvp_10 ARBfp_10 - -/* Tokens for assembler pseudo-ops */ -%token ADDRESS -%token ALIAS ATTRIB -%token OPTION OUTPUT -%token PARAM -%token TEMP -%token END - - /* Tokens for instructions */ -%token BIN_OP BINSC_OP SAMPLE_OP SCALAR_OP TRI_OP VECTOR_OP -%token ARL KIL SWZ TXD_OP - -%token INTEGER -%token REAL - -%token AMBIENT ATTENUATION -%token BACK -%token CLIP COLOR -%token DEPTH DIFFUSE DIRECTION -%token EMISSION ENV EYE -%token FOG FOGCOORD FRAGMENT FRONT -%token HALF -%token INVERSE INVTRANS -%token LIGHT LIGHTMODEL LIGHTPROD LOCAL -%token MATERIAL MAT_PROGRAM MATRIX MATRIXINDEX MODELVIEW MVP -%token NORMAL -%token OBJECT -%token PALETTE PARAMS PLANE POINT_TOK POINTSIZE POSITION PRIMARY PROGRAM PROJECTION -%token RANGE RESULT ROW -%token SCENECOLOR SECONDARY SHININESS SIZE_TOK SPECULAR SPOT STATE -%token TEXCOORD TEXENV TEXGEN TEXGEN_Q TEXGEN_R TEXGEN_S TEXGEN_T TEXTURE TRANSPOSE -%token TEXTURE_UNIT TEX_1D TEX_2D TEX_3D TEX_CUBE TEX_RECT -%token TEX_SHADOW1D TEX_SHADOW2D TEX_SHADOWRECT -%token TEX_ARRAY1D TEX_ARRAY2D TEX_ARRAYSHADOW1D TEX_ARRAYSHADOW2D -%token VERTEX VTXATTRIB -%token WEIGHT - -%token IDENTIFIER USED_IDENTIFIER -%type string -%token MASK4 MASK3 MASK2 MASK1 SWIZZLE -%token DOT_DOT -%token DOT - -%type instruction ALU_instruction TexInstruction -%type ARL_instruction VECTORop_instruction -%type SCALARop_instruction BINSCop_instruction BINop_instruction -%type TRIop_instruction TXD_instruction SWZ_instruction SAMPLE_instruction -%type KIL_instruction - -%type dstReg maskedDstReg maskedAddrReg -%type srcReg scalarUse scalarSrcReg swizzleSrcReg -%type scalarSuffix swizzleSuffix extendedSwizzle -%type extSwizComp extSwizSel -%type optionalMask - -%type progParamArray -%type addrRegRelOffset addrRegPosOffset addrRegNegOffset -%type progParamArrayMem progParamArrayAbs progParamArrayRel -%type addrReg -%type addrComponent addrWriteMask - -%type ccMaskRule ccTest ccMaskRule2 ccTest2 optionalCcMask - -%type resultBinding resultColBinding -%type optFaceType optColorType -%type optResultFaceType optResultColorType - -%type optTexImageUnitNum texImageUnitNum -%type optTexCoordUnitNum texCoordUnitNum -%type optLegacyTexUnitNum legacyTexUnitNum -%type texImageUnit texTarget -%type vtxAttribNum - -%type attribBinding vtxAttribItem fragAttribItem - -%type paramSingleInit paramSingleItemDecl -%type optArraySize - -%type stateSingleItem stateMultipleItem -%type stateMaterialItem -%type stateLightItem stateLightModelItem stateLightProdItem -%type stateTexGenItem stateFogItem stateClipPlaneItem statePointItem -%type stateMatrixItem stateMatrixRow stateMatrixRows -%type stateTexEnvItem stateDepthItem - -%type stateLModProperty -%type stateMatrixName optMatrixRows - -%type stateMatProperty -%type stateLightProperty stateSpotProperty -%type stateLightNumber stateLProdProperty -%type stateTexGenType stateTexGenCoord -%type stateTexEnvProperty -%type stateFogProperty -%type stateClipPlaneNum -%type statePointProperty - -%type stateOptMatModifier stateMatModifier stateMatrixRowNum -%type stateOptModMatNum stateModMatNum statePaletteMatNum -%type stateProgramMatNum - -%type ambDiffSpecProperty - -%type programSingleItem progEnvParam progLocalParam -%type programMultipleItem progEnvParams progLocalParams - -%type paramMultipleInit paramMultInitList paramMultipleItem -%type paramSingleItemUse - -%type progEnvParamNum progLocalParamNum -%type progEnvParamNums progLocalParamNums - -%type paramConstDecl paramConstUse -%type paramConstScalarDecl paramConstScalarUse paramConstVector -%type signedFloatConstant -%type optionalSign - -%{ -extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, - void *yyscanner); -%} - -%% - -program: language optionSequence statementSequence END - ; - -language: ARBvp_10 - { - if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) { - yyerror(& @1, state, "invalid fragment program header"); - - } - state->mode = ARB_vertex; - } - | ARBfp_10 - { - if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) { - yyerror(& @1, state, "invalid vertex program header"); - } - state->mode = ARB_fragment; - - state->option.TexRect = - (state->ctx->Extensions.NV_texture_rectangle != GL_FALSE); - } - ; - -optionSequence: optionSequence option - | - ; - -option: OPTION string ';' - { - int valid = 0; - - if (state->mode == ARB_vertex) { - valid = _mesa_ARBvp_parse_option(state, $2); - } else if (state->mode == ARB_fragment) { - valid = _mesa_ARBfp_parse_option(state, $2); - } - - - free($2); - - if (!valid) { - const char *const err_str = (state->mode == ARB_vertex) - ? "invalid ARB vertex program option" - : "invalid ARB fragment program option"; - - yyerror(& @2, state, err_str); - YYERROR; - } - } - ; - -statementSequence: statementSequence statement - | - ; - -statement: instruction ';' - { - if ($1 != NULL) { - if (state->inst_tail == NULL) { - state->inst_head = $1; - } else { - state->inst_tail->next = $1; - } - - state->inst_tail = $1; - $1->next = NULL; - - state->prog->NumInstructions++; - } - } - | namingStatement ';' - ; - -instruction: ALU_instruction - { - $$ = $1; - state->prog->NumAluInstructions++; - } - | TexInstruction - { - $$ = $1; - state->prog->NumTexInstructions++; - } - ; - -ALU_instruction: ARL_instruction - | VECTORop_instruction - | SCALARop_instruction - | BINSCop_instruction - | BINop_instruction - | TRIop_instruction - | SWZ_instruction - ; - -TexInstruction: SAMPLE_instruction - | KIL_instruction - | TXD_instruction - ; - -ARL_instruction: ARL maskedAddrReg ',' scalarSrcReg - { - $$ = asm_instruction_ctor(OPCODE_ARL, & $2, & $4, NULL, NULL); - } - ; - -VECTORop_instruction: VECTOR_OP maskedDstReg ',' swizzleSrcReg - { - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, NULL, NULL); - } - ; - -SCALARop_instruction: SCALAR_OP maskedDstReg ',' scalarSrcReg - { - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, NULL, NULL); - } - ; - -BINSCop_instruction: BINSC_OP maskedDstReg ',' scalarSrcReg ',' scalarSrcReg - { - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, & $6, NULL); - } - ; - - -BINop_instruction: BIN_OP maskedDstReg ',' swizzleSrcReg ',' swizzleSrcReg - { - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, & $6, NULL); - } - ; - -TRIop_instruction: TRI_OP maskedDstReg ',' - swizzleSrcReg ',' swizzleSrcReg ',' swizzleSrcReg - { - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, & $6, & $8); - } - ; - -SAMPLE_instruction: SAMPLE_OP maskedDstReg ',' swizzleSrcReg ',' texImageUnit ',' texTarget - { - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, NULL, NULL); - if ($$ != NULL) { - const GLbitfield tex_mask = (1U << $6); - GLbitfield shadow_tex = 0; - GLbitfield target_mask = 0; - - - $$->Base.TexSrcUnit = $6; - - if ($8 < 0) { - shadow_tex = tex_mask; - - $$->Base.TexSrcTarget = -$8; - $$->Base.TexShadow = 1; - } else { - $$->Base.TexSrcTarget = $8; - } - - target_mask = (1U << $$->Base.TexSrcTarget); - - /* If this texture unit was previously accessed and that access - * had a different texture target, generate an error. - * - * If this texture unit was previously accessed and that access - * had a different shadow mode, generate an error. - */ - if ((state->prog->TexturesUsed[$6] != 0) - && ((state->prog->TexturesUsed[$6] != target_mask) - || ((state->prog->ShadowSamplers & tex_mask) - != shadow_tex))) { - yyerror(& @8, state, - "multiple targets used on one texture image unit"); - YYERROR; - } - - - state->prog->TexturesUsed[$6] |= target_mask; - state->prog->ShadowSamplers |= shadow_tex; - } - } - ; - -KIL_instruction: KIL swizzleSrcReg - { - $$ = asm_instruction_ctor(OPCODE_KIL, NULL, & $2, NULL, NULL); - state->fragment.UsesKill = 1; - } - | KIL ccTest - { - $$ = asm_instruction_ctor(OPCODE_KIL_NV, NULL, NULL, NULL, NULL); - $$->Base.DstReg.CondMask = $2.CondMask; - $$->Base.DstReg.CondSwizzle = $2.CondSwizzle; - $$->Base.DstReg.CondSrc = $2.CondSrc; - state->fragment.UsesKill = 1; - } - ; - -TXD_instruction: TXD_OP maskedDstReg ',' swizzleSrcReg ',' swizzleSrcReg ',' swizzleSrcReg ',' texImageUnit ',' texTarget - { - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, & $6, & $8); - if ($$ != NULL) { - const GLbitfield tex_mask = (1U << $10); - GLbitfield shadow_tex = 0; - GLbitfield target_mask = 0; - - - $$->Base.TexSrcUnit = $10; - - if ($12 < 0) { - shadow_tex = tex_mask; - - $$->Base.TexSrcTarget = -$12; - $$->Base.TexShadow = 1; - } else { - $$->Base.TexSrcTarget = $12; - } - - target_mask = (1U << $$->Base.TexSrcTarget); - - /* If this texture unit was previously accessed and that access - * had a different texture target, generate an error. - * - * If this texture unit was previously accessed and that access - * had a different shadow mode, generate an error. - */ - if ((state->prog->TexturesUsed[$10] != 0) - && ((state->prog->TexturesUsed[$10] != target_mask) - || ((state->prog->ShadowSamplers & tex_mask) - != shadow_tex))) { - yyerror(& @12, state, - "multiple targets used on one texture image unit"); - YYERROR; - } - - - state->prog->TexturesUsed[$10] |= target_mask; - state->prog->ShadowSamplers |= shadow_tex; - } - } - ; - -texImageUnit: TEXTURE_UNIT optTexImageUnitNum - { - $$ = $2; - } - ; - -texTarget: TEX_1D { $$ = TEXTURE_1D_INDEX; } - | TEX_2D { $$ = TEXTURE_2D_INDEX; } - | TEX_3D { $$ = TEXTURE_3D_INDEX; } - | TEX_CUBE { $$ = TEXTURE_CUBE_INDEX; } - | TEX_RECT { $$ = TEXTURE_RECT_INDEX; } - | TEX_SHADOW1D { $$ = -TEXTURE_1D_INDEX; } - | TEX_SHADOW2D { $$ = -TEXTURE_2D_INDEX; } - | TEX_SHADOWRECT { $$ = -TEXTURE_RECT_INDEX; } - | TEX_ARRAY1D { $$ = TEXTURE_1D_ARRAY_INDEX; } - | TEX_ARRAY2D { $$ = TEXTURE_2D_ARRAY_INDEX; } - | TEX_ARRAYSHADOW1D { $$ = -TEXTURE_1D_ARRAY_INDEX; } - | TEX_ARRAYSHADOW2D { $$ = -TEXTURE_2D_ARRAY_INDEX; } - ; - -SWZ_instruction: SWZ maskedDstReg ',' srcReg ',' extendedSwizzle - { - /* FIXME: Is this correct? Should the extenedSwizzle be applied - * FIXME: to the existing swizzle? - */ - $4.Base.Swizzle = $6.swizzle; - $4.Base.Negate = $6.mask; - - $$ = asm_instruction_copy_ctor(& $1, & $2, & $4, NULL, NULL); - } - ; - -scalarSrcReg: optionalSign scalarUse - { - $$ = $2; - - if ($1) { - $$.Base.Negate = ~$$.Base.Negate; - } - } - | optionalSign '|' scalarUse '|' - { - $$ = $3; - - if (!state->option.NV_fragment) { - yyerror(& @2, state, "unexpected character '|'"); - YYERROR; - } - - if ($1) { - $$.Base.Negate = ~$$.Base.Negate; - } - - $$.Base.Abs = 1; - } - ; - -scalarUse: srcReg scalarSuffix - { - $$ = $1; - - $$.Base.Swizzle = _mesa_combine_swizzles($$.Base.Swizzle, - $2.swizzle); - } - | paramConstScalarUse - { - struct asm_symbol temp_sym; - - if (!state->option.NV_fragment) { - yyerror(& @1, state, "expected scalar suffix"); - YYERROR; - } - - memset(& temp_sym, 0, sizeof(temp_sym)); - temp_sym.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & temp_sym, & $1, GL_TRUE); - - set_src_reg_swz(& $$, PROGRAM_CONSTANT, - temp_sym.param_binding_begin, - temp_sym.param_binding_swizzle); - } - ; - -swizzleSrcReg: optionalSign srcReg swizzleSuffix - { - $$ = $2; - - if ($1) { - $$.Base.Negate = ~$$.Base.Negate; - } - - $$.Base.Swizzle = _mesa_combine_swizzles($$.Base.Swizzle, - $3.swizzle); - } - | optionalSign '|' srcReg swizzleSuffix '|' - { - $$ = $3; - - if (!state->option.NV_fragment) { - yyerror(& @2, state, "unexpected character '|'"); - YYERROR; - } - - if ($1) { - $$.Base.Negate = ~$$.Base.Negate; - } - - $$.Base.Abs = 1; - $$.Base.Swizzle = _mesa_combine_swizzles($$.Base.Swizzle, - $4.swizzle); - } - - ; - -maskedDstReg: dstReg optionalMask optionalCcMask - { - $$ = $1; - $$.WriteMask = $2.mask; - $$.CondMask = $3.CondMask; - $$.CondSwizzle = $3.CondSwizzle; - $$.CondSrc = $3.CondSrc; - - if ($$.File == PROGRAM_OUTPUT) { - /* Technically speaking, this should check that it is in - * vertex program mode. However, PositionInvariant can never be - * set in fragment program mode, so it is somewhat irrelevant. - */ - if (state->option.PositionInvariant - && ($$.Index == VERT_RESULT_HPOS)) { - yyerror(& @1, state, "position-invariant programs cannot " - "write position"); - YYERROR; - } - - state->prog->OutputsWritten |= BITFIELD64_BIT($$.Index); - } - } - ; - -maskedAddrReg: addrReg addrWriteMask - { - set_dst_reg(& $$, PROGRAM_ADDRESS, 0); - $$.WriteMask = $2.mask; - } - ; - -extendedSwizzle: extSwizComp ',' extSwizComp ',' extSwizComp ',' extSwizComp - { - const unsigned xyzw_valid = - ($1.xyzw_valid << 0) - | ($3.xyzw_valid << 1) - | ($5.xyzw_valid << 2) - | ($7.xyzw_valid << 3); - const unsigned rgba_valid = - ($1.rgba_valid << 0) - | ($3.rgba_valid << 1) - | ($5.rgba_valid << 2) - | ($7.rgba_valid << 3); - - /* All of the swizzle components have to be valid in either RGBA - * or XYZW. Note that 0 and 1 are valid in both, so both masks - * can have some bits set. - * - * We somewhat deviate from the spec here. It would be really hard - * to figure out which component is the error, and there probably - * isn't a lot of benefit. - */ - if ((rgba_valid != 0x0f) && (xyzw_valid != 0x0f)) { - yyerror(& @1, state, "cannot combine RGBA and XYZW swizzle " - "components"); - YYERROR; - } - - $$.swizzle = MAKE_SWIZZLE4($1.swz, $3.swz, $5.swz, $7.swz); - $$.mask = ($1.negate) | ($3.negate << 1) | ($5.negate << 2) - | ($7.negate << 3); - } - ; - -extSwizComp: optionalSign extSwizSel - { - $$ = $2; - $$.negate = ($1) ? 1 : 0; - } - ; - -extSwizSel: INTEGER - { - if (($1 != 0) && ($1 != 1)) { - yyerror(& @1, state, "invalid extended swizzle selector"); - YYERROR; - } - - $$.swz = ($1 == 0) ? SWIZZLE_ZERO : SWIZZLE_ONE; - - /* 0 and 1 are valid for both RGBA swizzle names and XYZW - * swizzle names. - */ - $$.xyzw_valid = 1; - $$.rgba_valid = 1; - } - | string - { - char s; - - if (strlen($1) > 1) { - yyerror(& @1, state, "invalid extended swizzle selector"); - YYERROR; - } - - s = $1[0]; - free($1); - - switch (s) { - case 'x': - $$.swz = SWIZZLE_X; - $$.xyzw_valid = 1; - break; - case 'y': - $$.swz = SWIZZLE_Y; - $$.xyzw_valid = 1; - break; - case 'z': - $$.swz = SWIZZLE_Z; - $$.xyzw_valid = 1; - break; - case 'w': - $$.swz = SWIZZLE_W; - $$.xyzw_valid = 1; - break; - - case 'r': - $$.swz = SWIZZLE_X; - $$.rgba_valid = 1; - break; - case 'g': - $$.swz = SWIZZLE_Y; - $$.rgba_valid = 1; - break; - case 'b': - $$.swz = SWIZZLE_Z; - $$.rgba_valid = 1; - break; - case 'a': - $$.swz = SWIZZLE_W; - $$.rgba_valid = 1; - break; - - default: - yyerror(& @1, state, "invalid extended swizzle selector"); - YYERROR; - break; - } - } - ; - -srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */ - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, $1); - - free($1); - - if (s == NULL) { - yyerror(& @1, state, "invalid operand variable"); - YYERROR; - } else if ((s->type != at_param) && (s->type != at_temp) - && (s->type != at_attrib)) { - yyerror(& @1, state, "invalid operand variable"); - YYERROR; - } else if ((s->type == at_param) && s->param_is_array) { - yyerror(& @1, state, "non-array access to array PARAM"); - YYERROR; - } - - init_src_reg(& $$); - switch (s->type) { - case at_temp: - set_src_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding); - break; - case at_param: - set_src_reg_swz(& $$, s->param_binding_type, - s->param_binding_begin, - s->param_binding_swizzle); - break; - case at_attrib: - set_src_reg(& $$, PROGRAM_INPUT, s->attrib_binding); - state->prog->InputsRead |= BITFIELD64_BIT($$.Base.Index); - - if (!validate_inputs(& @1, state)) { - YYERROR; - } - break; - - default: - YYERROR; - break; - } - } - | attribBinding - { - set_src_reg(& $$, PROGRAM_INPUT, $1); - state->prog->InputsRead |= BITFIELD64_BIT($$.Base.Index); - - if (!validate_inputs(& @1, state)) { - YYERROR; - } - } - | progParamArray '[' progParamArrayMem ']' - { - if (! $3.Base.RelAddr - && ((unsigned) $3.Base.Index >= $1->param_binding_length)) { - yyerror(& @3, state, "out of bounds array access"); - YYERROR; - } - - init_src_reg(& $$); - $$.Base.File = $1->param_binding_type; - - if ($3.Base.RelAddr) { - state->prog->IndirectRegisterFiles |= (1 << $$.Base.File); - $1->param_accessed_indirectly = 1; - - $$.Base.RelAddr = 1; - $$.Base.Index = $3.Base.Index; - $$.Symbol = $1; - } else { - $$.Base.Index = $1->param_binding_begin + $3.Base.Index; - } - } - | paramSingleItemUse - { - gl_register_file file = ($1.name != NULL) - ? $1.param_binding_type - : PROGRAM_CONSTANT; - set_src_reg_swz(& $$, file, $1.param_binding_begin, - $1.param_binding_swizzle); - } - ; - -dstReg: resultBinding - { - set_dst_reg(& $$, PROGRAM_OUTPUT, $1); - } - | USED_IDENTIFIER /* temporaryReg | vertexResultReg */ - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, $1); - - free($1); - - if (s == NULL) { - yyerror(& @1, state, "invalid operand variable"); - YYERROR; - } else if ((s->type != at_output) && (s->type != at_temp)) { - yyerror(& @1, state, "invalid operand variable"); - YYERROR; - } - - switch (s->type) { - case at_temp: - set_dst_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding); - break; - case at_output: - set_dst_reg(& $$, PROGRAM_OUTPUT, s->output_binding); - break; - default: - set_dst_reg(& $$, s->param_binding_type, s->param_binding_begin); - break; - } - } - ; - -progParamArray: USED_IDENTIFIER - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, $1); - - free($1); - - if (s == NULL) { - yyerror(& @1, state, "invalid operand variable"); - YYERROR; - } else if ((s->type != at_param) || !s->param_is_array) { - yyerror(& @1, state, "array access to non-PARAM variable"); - YYERROR; - } else { - $$ = s; - } - } - ; - -progParamArrayMem: progParamArrayAbs | progParamArrayRel; - -progParamArrayAbs: INTEGER - { - init_src_reg(& $$); - $$.Base.Index = $1; - } - ; - -progParamArrayRel: addrReg addrComponent addrRegRelOffset - { - /* FINISHME: Add support for multiple address registers. - */ - /* FINISHME: Add support for 4-component address registers. - */ - init_src_reg(& $$); - $$.Base.RelAddr = 1; - $$.Base.Index = $3; - } - ; - -addrRegRelOffset: { $$ = 0; } - | '+' addrRegPosOffset { $$ = $2; } - | '-' addrRegNegOffset { $$ = -$2; } - ; - -addrRegPosOffset: INTEGER - { - if (($1 < 0) || ($1 > (state->limits->MaxAddressOffset - 1))) { - char s[100]; - _mesa_snprintf(s, sizeof(s), - "relative address offset too large (%d)", $1); - yyerror(& @1, state, s); - YYERROR; - } else { - $$ = $1; - } - } - ; - -addrRegNegOffset: INTEGER - { - if (($1 < 0) || ($1 > state->limits->MaxAddressOffset)) { - char s[100]; - _mesa_snprintf(s, sizeof(s), - "relative address offset too large (%d)", $1); - yyerror(& @1, state, s); - YYERROR; - } else { - $$ = $1; - } - } - ; - -addrReg: USED_IDENTIFIER - { - struct asm_symbol *const s = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, $1); - - free($1); - - if (s == NULL) { - yyerror(& @1, state, "invalid array member"); - YYERROR; - } else if (s->type != at_address) { - yyerror(& @1, state, - "invalid variable for indexed array access"); - YYERROR; - } else { - $$ = s; - } - } - ; - -addrComponent: MASK1 - { - if ($1.mask != WRITEMASK_X) { - yyerror(& @1, state, "invalid address component selector"); - YYERROR; - } else { - $$ = $1; - } - } - ; - -addrWriteMask: MASK1 - { - if ($1.mask != WRITEMASK_X) { - yyerror(& @1, state, - "address register write mask must be \".x\""); - YYERROR; - } else { - $$ = $1; - } - } - ; - -scalarSuffix: MASK1; - -swizzleSuffix: MASK1 - | MASK4 - | SWIZZLE - | { $$.swizzle = SWIZZLE_NOOP; $$.mask = WRITEMASK_XYZW; } - ; - -optionalMask: MASK4 | MASK3 | MASK2 | MASK1 - | { $$.swizzle = SWIZZLE_NOOP; $$.mask = WRITEMASK_XYZW; } - ; - -optionalCcMask: '(' ccTest ')' - { - $$ = $2; - } - | '(' ccTest2 ')' - { - $$ = $2; - } - | - { - $$.CondMask = COND_TR; - $$.CondSwizzle = SWIZZLE_NOOP; - $$.CondSrc = 0; - } - ; - -ccTest: ccMaskRule swizzleSuffix - { - $$ = $1; - $$.CondSwizzle = $2.swizzle; - } - ; - -ccTest2: ccMaskRule2 swizzleSuffix - { - $$ = $1; - $$.CondSwizzle = $2.swizzle; - } - ; - -ccMaskRule: IDENTIFIER - { - const int cond = _mesa_parse_cc($1); - if ((cond == 0) || ($1[2] != '\0')) { - char *const err_str = - make_error_string("invalid condition code \"%s\"", $1); - - yyerror(& @1, state, (err_str != NULL) - ? err_str : "invalid condition code"); - - if (err_str != NULL) { - free(err_str); - } - - YYERROR; - } - - $$.CondMask = cond; - $$.CondSwizzle = SWIZZLE_NOOP; - $$.CondSrc = 0; - } - ; - -ccMaskRule2: USED_IDENTIFIER - { - const int cond = _mesa_parse_cc($1); - if ((cond == 0) || ($1[2] != '\0')) { - char *const err_str = - make_error_string("invalid condition code \"%s\"", $1); - - yyerror(& @1, state, (err_str != NULL) - ? err_str : "invalid condition code"); - - if (err_str != NULL) { - free(err_str); - } - - YYERROR; - } - - $$.CondMask = cond; - $$.CondSwizzle = SWIZZLE_NOOP; - $$.CondSrc = 0; - } - ; - -namingStatement: ATTRIB_statement - | PARAM_statement - | TEMP_statement - | ADDRESS_statement - | OUTPUT_statement - | ALIAS_statement - ; - -ATTRIB_statement: ATTRIB IDENTIFIER '=' attribBinding - { - struct asm_symbol *const s = - declare_variable(state, $2, at_attrib, & @2); - - if (s == NULL) { - free($2); - YYERROR; - } else { - s->attrib_binding = $4; - state->InputsBound |= BITFIELD64_BIT(s->attrib_binding); - - if (!validate_inputs(& @4, state)) { - YYERROR; - } - } - } - ; - -attribBinding: VERTEX vtxAttribItem - { - $$ = $2; - } - | FRAGMENT fragAttribItem - { - $$ = $2; - } - ; - -vtxAttribItem: POSITION - { - $$ = VERT_ATTRIB_POS; - } - | WEIGHT vtxOptWeightNum - { - $$ = VERT_ATTRIB_WEIGHT; - } - | NORMAL - { - $$ = VERT_ATTRIB_NORMAL; - } - | COLOR optColorType - { - if (!state->ctx->Extensions.EXT_secondary_color) { - yyerror(& @2, state, "GL_EXT_secondary_color not supported"); - YYERROR; - } - - $$ = VERT_ATTRIB_COLOR0 + $2; - } - | FOGCOORD - { - if (!state->ctx->Extensions.EXT_fog_coord) { - yyerror(& @1, state, "GL_EXT_fog_coord not supported"); - YYERROR; - } - - $$ = VERT_ATTRIB_FOG; - } - | TEXCOORD optTexCoordUnitNum - { - $$ = VERT_ATTRIB_TEX0 + $2; - } - | MATRIXINDEX '[' vtxWeightNum ']' - { - yyerror(& @1, state, "GL_ARB_matrix_palette not supported"); - YYERROR; - } - | VTXATTRIB '[' vtxAttribNum ']' - { - $$ = VERT_ATTRIB_GENERIC0 + $3; - } - ; - -vtxAttribNum: INTEGER - { - if ((unsigned) $1 >= state->limits->MaxAttribs) { - yyerror(& @1, state, "invalid vertex attribute reference"); - YYERROR; - } - - $$ = $1; - } - ; - -vtxOptWeightNum: | '[' vtxWeightNum ']'; -vtxWeightNum: INTEGER; - -fragAttribItem: POSITION - { - $$ = FRAG_ATTRIB_WPOS; - } - | COLOR optColorType - { - $$ = FRAG_ATTRIB_COL0 + $2; - } - | FOGCOORD - { - $$ = FRAG_ATTRIB_FOGC; - } - | TEXCOORD optTexCoordUnitNum - { - $$ = FRAG_ATTRIB_TEX0 + $2; - } - ; - -PARAM_statement: PARAM_singleStmt | PARAM_multipleStmt; - -PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit - { - struct asm_symbol *const s = - declare_variable(state, $2, at_param, & @2); - - if (s == NULL) { - free($2); - YYERROR; - } else { - s->param_binding_type = $3.param_binding_type; - s->param_binding_begin = $3.param_binding_begin; - s->param_binding_length = $3.param_binding_length; - s->param_binding_swizzle = $3.param_binding_swizzle; - s->param_is_array = 0; - } - } - ; - -PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit - { - if (($4 != 0) && ((unsigned) $4 != $6.param_binding_length)) { - free($2); - yyerror(& @4, state, - "parameter array size and number of bindings must match"); - YYERROR; - } else { - struct asm_symbol *const s = - declare_variable(state, $2, $6.type, & @2); - - if (s == NULL) { - free($2); - YYERROR; - } else { - s->param_binding_type = $6.param_binding_type; - s->param_binding_begin = $6.param_binding_begin; - s->param_binding_length = $6.param_binding_length; - s->param_binding_swizzle = SWIZZLE_XYZW; - s->param_is_array = 1; - } - } - } - ; - -optArraySize: - { - $$ = 0; - } - | INTEGER - { - if (($1 < 1) || ((unsigned) $1 > state->limits->MaxParameters)) { - char msg[100]; - _mesa_snprintf(msg, sizeof(msg), - "invalid parameter array size (size=%d max=%u)", - $1, state->limits->MaxParameters); - yyerror(& @1, state, msg); - YYERROR; - } else { - $$ = $1; - } - } - ; - -paramSingleInit: '=' paramSingleItemDecl - { - $$ = $2; - } - ; - -paramMultipleInit: '=' '{' paramMultInitList '}' - { - $$ = $3; - } - ; - -paramMultInitList: paramMultipleItem - | paramMultInitList ',' paramMultipleItem - { - $1.param_binding_length += $3.param_binding_length; - $$ = $1; - } - ; - -paramSingleItemDecl: stateSingleItem - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_state(state->prog, & $$, $1); - } - | programSingleItem - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_param(state->prog, & $$, $1); - } - | paramConstDecl - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & $$, & $1, GL_TRUE); - } - ; - -paramSingleItemUse: stateSingleItem - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_state(state->prog, & $$, $1); - } - | programSingleItem - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_param(state->prog, & $$, $1); - } - | paramConstUse - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & $$, & $1, GL_TRUE); - } - ; - -paramMultipleItem: stateMultipleItem - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_state(state->prog, & $$, $1); - } - | programMultipleItem - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_param(state->prog, & $$, $1); - } - | paramConstDecl - { - memset(& $$, 0, sizeof($$)); - $$.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & $$, & $1, GL_FALSE); - } - ; - -stateMultipleItem: stateSingleItem { memcpy($$, $1, sizeof($$)); } - | STATE stateMatrixRows { memcpy($$, $2, sizeof($$)); } - ; - -stateSingleItem: STATE stateMaterialItem { memcpy($$, $2, sizeof($$)); } - | STATE stateLightItem { memcpy($$, $2, sizeof($$)); } - | STATE stateLightModelItem { memcpy($$, $2, sizeof($$)); } - | STATE stateLightProdItem { memcpy($$, $2, sizeof($$)); } - | STATE stateTexGenItem { memcpy($$, $2, sizeof($$)); } - | STATE stateTexEnvItem { memcpy($$, $2, sizeof($$)); } - | STATE stateFogItem { memcpy($$, $2, sizeof($$)); } - | STATE stateClipPlaneItem { memcpy($$, $2, sizeof($$)); } - | STATE statePointItem { memcpy($$, $2, sizeof($$)); } - | STATE stateMatrixRow { memcpy($$, $2, sizeof($$)); } - | STATE stateDepthItem { memcpy($$, $2, sizeof($$)); } - ; - -stateMaterialItem: MATERIAL optFaceType stateMatProperty - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_MATERIAL; - $$[1] = $2; - $$[2] = $3; - } - ; - -stateMatProperty: ambDiffSpecProperty - { - $$ = $1; - } - | EMISSION - { - $$ = STATE_EMISSION; - } - | SHININESS - { - $$ = STATE_SHININESS; - } - ; - -stateLightItem: LIGHT '[' stateLightNumber ']' stateLightProperty - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_LIGHT; - $$[1] = $3; - $$[2] = $5; - } - ; - -stateLightProperty: ambDiffSpecProperty - { - $$ = $1; - } - | POSITION - { - $$ = STATE_POSITION; - } - | ATTENUATION - { - if (!state->ctx->Extensions.EXT_point_parameters) { - yyerror(& @1, state, "GL_ARB_point_parameters not supported"); - YYERROR; - } - - $$ = STATE_ATTENUATION; - } - | SPOT stateSpotProperty - { - $$ = $2; - } - | HALF - { - $$ = STATE_HALF_VECTOR; - } - ; - -stateSpotProperty: DIRECTION - { - $$ = STATE_SPOT_DIRECTION; - } - ; - -stateLightModelItem: LIGHTMODEL stateLModProperty - { - $$[0] = $2[0]; - $$[1] = $2[1]; - } - ; - -stateLModProperty: AMBIENT - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_LIGHTMODEL_AMBIENT; - } - | optFaceType SCENECOLOR - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_LIGHTMODEL_SCENECOLOR; - $$[1] = $1; - } - ; - -stateLightProdItem: LIGHTPROD '[' stateLightNumber ']' optFaceType stateLProdProperty - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_LIGHTPROD; - $$[1] = $3; - $$[2] = $5; - $$[3] = $6; - } - ; - -stateLProdProperty: ambDiffSpecProperty; - -stateTexEnvItem: TEXENV optLegacyTexUnitNum stateTexEnvProperty - { - memset($$, 0, sizeof($$)); - $$[0] = $3; - $$[1] = $2; - } - ; - -stateTexEnvProperty: COLOR - { - $$ = STATE_TEXENV_COLOR; - } - ; - -ambDiffSpecProperty: AMBIENT - { - $$ = STATE_AMBIENT; - } - | DIFFUSE - { - $$ = STATE_DIFFUSE; - } - | SPECULAR - { - $$ = STATE_SPECULAR; - } - ; - -stateLightNumber: INTEGER - { - if ((unsigned) $1 >= state->MaxLights) { - yyerror(& @1, state, "invalid light selector"); - YYERROR; - } - - $$ = $1; - } - ; - -stateTexGenItem: TEXGEN optTexCoordUnitNum stateTexGenType stateTexGenCoord - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_TEXGEN; - $$[1] = $2; - $$[2] = $3 + $4; - } - ; - -stateTexGenType: EYE - { - $$ = STATE_TEXGEN_EYE_S; - } - | OBJECT - { - $$ = STATE_TEXGEN_OBJECT_S; - } - ; -stateTexGenCoord: TEXGEN_S - { - $$ = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S; - } - | TEXGEN_T - { - $$ = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S; - } - | TEXGEN_R - { - $$ = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S; - } - | TEXGEN_Q - { - $$ = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S; - } - ; - -stateFogItem: FOG stateFogProperty - { - memset($$, 0, sizeof($$)); - $$[0] = $2; - } - ; - -stateFogProperty: COLOR - { - $$ = STATE_FOG_COLOR; - } - | PARAMS - { - $$ = STATE_FOG_PARAMS; - } - ; - -stateClipPlaneItem: CLIP '[' stateClipPlaneNum ']' PLANE - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_CLIPPLANE; - $$[1] = $3; - } - ; - -stateClipPlaneNum: INTEGER - { - if ((unsigned) $1 >= state->MaxClipPlanes) { - yyerror(& @1, state, "invalid clip plane selector"); - YYERROR; - } - - $$ = $1; - } - ; - -statePointItem: POINT_TOK statePointProperty - { - memset($$, 0, sizeof($$)); - $$[0] = $2; - } - ; - -statePointProperty: SIZE_TOK - { - $$ = STATE_POINT_SIZE; - } - | ATTENUATION - { - $$ = STATE_POINT_ATTENUATION; - } - ; - -stateMatrixRow: stateMatrixItem ROW '[' stateMatrixRowNum ']' - { - $$[0] = $1[0]; - $$[1] = $1[1]; - $$[2] = $4; - $$[3] = $4; - $$[4] = $1[2]; - } - ; - -stateMatrixRows: stateMatrixItem optMatrixRows - { - $$[0] = $1[0]; - $$[1] = $1[1]; - $$[2] = $2[2]; - $$[3] = $2[3]; - $$[4] = $1[2]; - } - ; - -optMatrixRows: - { - $$[2] = 0; - $$[3] = 3; - } - | ROW '[' stateMatrixRowNum DOT_DOT stateMatrixRowNum ']' - { - /* It seems logical that the matrix row range specifier would have - * to specify a range or more than one row (i.e., $5 > $3). - * However, the ARB_vertex_program spec says "a program will fail - * to load if is greater than ." This means that $3 == $5 - * is valid. - */ - if ($3 > $5) { - yyerror(& @3, state, "invalid matrix row range"); - YYERROR; - } - - $$[2] = $3; - $$[3] = $5; - } - ; - -stateMatrixItem: MATRIX stateMatrixName stateOptMatModifier - { - $$[0] = $2[0]; - $$[1] = $2[1]; - $$[2] = $3; - } - ; - -stateOptMatModifier: - { - $$ = 0; - } - | stateMatModifier - { - $$ = $1; - } - ; - -stateMatModifier: INVERSE - { - $$ = STATE_MATRIX_INVERSE; - } - | TRANSPOSE - { - $$ = STATE_MATRIX_TRANSPOSE; - } - | INVTRANS - { - $$ = STATE_MATRIX_INVTRANS; - } - ; - -stateMatrixRowNum: INTEGER - { - if ($1 > 3) { - yyerror(& @1, state, "invalid matrix row reference"); - YYERROR; - } - - $$ = $1; - } - ; - -stateMatrixName: MODELVIEW stateOptModMatNum - { - $$[0] = STATE_MODELVIEW_MATRIX; - $$[1] = $2; - } - | PROJECTION - { - $$[0] = STATE_PROJECTION_MATRIX; - $$[1] = 0; - } - | MVP - { - $$[0] = STATE_MVP_MATRIX; - $$[1] = 0; - } - | TEXTURE optTexCoordUnitNum - { - $$[0] = STATE_TEXTURE_MATRIX; - $$[1] = $2; - } - | PALETTE '[' statePaletteMatNum ']' - { - yyerror(& @1, state, "GL_ARB_matrix_palette not supported"); - YYERROR; - } - | MAT_PROGRAM '[' stateProgramMatNum ']' - { - $$[0] = STATE_PROGRAM_MATRIX; - $$[1] = $3; - } - ; - -stateOptModMatNum: - { - $$ = 0; - } - | '[' stateModMatNum ']' - { - $$ = $2; - } - ; -stateModMatNum: INTEGER - { - /* Since GL_ARB_vertex_blend isn't supported, only modelview matrix - * zero is valid. - */ - if ($1 != 0) { - yyerror(& @1, state, "invalid modelview matrix index"); - YYERROR; - } - - $$ = $1; - } - ; -statePaletteMatNum: INTEGER - { - /* Since GL_ARB_matrix_palette isn't supported, just let any value - * through here. The error will be generated later. - */ - $$ = $1; - } - ; -stateProgramMatNum: INTEGER - { - if ((unsigned) $1 >= state->MaxProgramMatrices) { - yyerror(& @1, state, "invalid program matrix selector"); - YYERROR; - } - - $$ = $1; - } - ; - -stateDepthItem: DEPTH RANGE - { - memset($$, 0, sizeof($$)); - $$[0] = STATE_DEPTH_RANGE; - } - ; - - -programSingleItem: progEnvParam | progLocalParam; - -programMultipleItem: progEnvParams | progLocalParams; - -progEnvParams: PROGRAM ENV '[' progEnvParamNums ']' - { - memset($$, 0, sizeof($$)); - $$[0] = state->state_param_enum; - $$[1] = STATE_ENV; - $$[2] = $4[0]; - $$[3] = $4[1]; - } - ; - -progEnvParamNums: progEnvParamNum - { - $$[0] = $1; - $$[1] = $1; - } - | progEnvParamNum DOT_DOT progEnvParamNum - { - $$[0] = $1; - $$[1] = $3; - } - ; - -progEnvParam: PROGRAM ENV '[' progEnvParamNum ']' - { - memset($$, 0, sizeof($$)); - $$[0] = state->state_param_enum; - $$[1] = STATE_ENV; - $$[2] = $4; - $$[3] = $4; - } - ; - -progLocalParams: PROGRAM LOCAL '[' progLocalParamNums ']' - { - memset($$, 0, sizeof($$)); - $$[0] = state->state_param_enum; - $$[1] = STATE_LOCAL; - $$[2] = $4[0]; - $$[3] = $4[1]; - } - -progLocalParamNums: progLocalParamNum - { - $$[0] = $1; - $$[1] = $1; - } - | progLocalParamNum DOT_DOT progLocalParamNum - { - $$[0] = $1; - $$[1] = $3; - } - ; - -progLocalParam: PROGRAM LOCAL '[' progLocalParamNum ']' - { - memset($$, 0, sizeof($$)); - $$[0] = state->state_param_enum; - $$[1] = STATE_LOCAL; - $$[2] = $4; - $$[3] = $4; - } - ; - -progEnvParamNum: INTEGER - { - if ((unsigned) $1 >= state->limits->MaxEnvParams) { - yyerror(& @1, state, "invalid environment parameter reference"); - YYERROR; - } - $$ = $1; - } - ; - -progLocalParamNum: INTEGER - { - if ((unsigned) $1 >= state->limits->MaxLocalParams) { - yyerror(& @1, state, "invalid local parameter reference"); - YYERROR; - } - $$ = $1; - } - ; - - - -paramConstDecl: paramConstScalarDecl | paramConstVector; -paramConstUse: paramConstScalarUse | paramConstVector; - -paramConstScalarDecl: signedFloatConstant - { - $$.count = 4; - $$.data[0].f = $1; - $$.data[1].f = $1; - $$.data[2].f = $1; - $$.data[3].f = $1; - } - ; - -paramConstScalarUse: REAL - { - $$.count = 1; - $$.data[0].f = $1; - $$.data[1].f = $1; - $$.data[2].f = $1; - $$.data[3].f = $1; - } - | INTEGER - { - $$.count = 1; - $$.data[0].f = (float) $1; - $$.data[1].f = (float) $1; - $$.data[2].f = (float) $1; - $$.data[3].f = (float) $1; - } - ; - -paramConstVector: '{' signedFloatConstant '}' - { - $$.count = 4; - $$.data[0].f = $2; - $$.data[1].f = 0.0f; - $$.data[2].f = 0.0f; - $$.data[3].f = 1.0f; - } - | '{' signedFloatConstant ',' signedFloatConstant '}' - { - $$.count = 4; - $$.data[0].f = $2; - $$.data[1].f = $4; - $$.data[2].f = 0.0f; - $$.data[3].f = 1.0f; - } - | '{' signedFloatConstant ',' signedFloatConstant ',' - signedFloatConstant '}' - { - $$.count = 4; - $$.data[0].f = $2; - $$.data[1].f = $4; - $$.data[2].f = $6; - $$.data[3].f = 1.0f; - } - | '{' signedFloatConstant ',' signedFloatConstant ',' - signedFloatConstant ',' signedFloatConstant '}' - { - $$.count = 4; - $$.data[0].f = $2; - $$.data[1].f = $4; - $$.data[2].f = $6; - $$.data[3].f = $8; - } - ; - -signedFloatConstant: optionalSign REAL - { - $$ = ($1) ? -$2 : $2; - } - | optionalSign INTEGER - { - $$ = (float)(($1) ? -$2 : $2); - } - ; - -optionalSign: '+' { $$ = FALSE; } - | '-' { $$ = TRUE; } - | { $$ = FALSE; } - ; - -TEMP_statement: optVarSize TEMP { $$ = $2; } varNameList - ; - -optVarSize: string - { - /* NV_fragment_program_option defines the size qualifiers in a - * fairly broken way. "SHORT" or "LONG" can optionally be used - * before TEMP or OUTPUT. However, neither is a reserved word! - * This means that we have to parse it as an identifier, then check - * to make sure it's one of the valid values. *sigh* - * - * In addition, the grammar in the extension spec does *not* allow - * the size specifier to be optional, but all known implementations - * do. - */ - if (!state->option.NV_fragment) { - yyerror(& @1, state, "unexpected IDENTIFIER"); - YYERROR; - } - - if (strcmp("SHORT", $1) == 0) { - } else if (strcmp("LONG", $1) == 0) { - } else { - char *const err_str = - make_error_string("invalid storage size specifier \"%s\"", - $1); - - yyerror(& @1, state, (err_str != NULL) - ? err_str : "invalid storage size specifier"); - - if (err_str != NULL) { - free(err_str); - } - - YYERROR; - } - } - | - { - } - ; - -ADDRESS_statement: ADDRESS { $$ = $1; } varNameList - ; - -varNameList: varNameList ',' IDENTIFIER - { - if (!declare_variable(state, $3, $0, & @3)) { - free($3); - YYERROR; - } - } - | IDENTIFIER - { - if (!declare_variable(state, $1, $0, & @1)) { - free($1); - YYERROR; - } - } - ; - -OUTPUT_statement: optVarSize OUTPUT IDENTIFIER '=' resultBinding - { - struct asm_symbol *const s = - declare_variable(state, $3, at_output, & @3); - - if (s == NULL) { - free($3); - YYERROR; - } else { - s->output_binding = $5; - } - } - ; - -resultBinding: RESULT POSITION - { - if (state->mode == ARB_vertex) { - $$ = VERT_RESULT_HPOS; - } else { - yyerror(& @2, state, "invalid program result name"); - YYERROR; - } - } - | RESULT FOGCOORD - { - if (state->mode == ARB_vertex) { - $$ = VERT_RESULT_FOGC; - } else { - yyerror(& @2, state, "invalid program result name"); - YYERROR; - } - } - | RESULT resultColBinding - { - $$ = $2; - } - | RESULT POINTSIZE - { - if (state->mode == ARB_vertex) { - $$ = VERT_RESULT_PSIZ; - } else { - yyerror(& @2, state, "invalid program result name"); - YYERROR; - } - } - | RESULT TEXCOORD optTexCoordUnitNum - { - if (state->mode == ARB_vertex) { - $$ = VERT_RESULT_TEX0 + $3; - } else { - yyerror(& @2, state, "invalid program result name"); - YYERROR; - } - } - | RESULT DEPTH - { - if (state->mode == ARB_fragment) { - $$ = FRAG_RESULT_DEPTH; - } else { - yyerror(& @2, state, "invalid program result name"); - YYERROR; - } - } - ; - -resultColBinding: COLOR optResultFaceType optResultColorType - { - $$ = $2 + $3; - } - ; - -optResultFaceType: - { - if (state->mode == ARB_vertex) { - $$ = VERT_RESULT_COL0; - } else { - if (state->option.DrawBuffers) - $$ = FRAG_RESULT_DATA0; - else - $$ = FRAG_RESULT_COLOR; - } - } - | '[' INTEGER ']' - { - if (state->mode == ARB_vertex) { - yyerror(& @1, state, "invalid program result name"); - YYERROR; - } else { - if (!state->option.DrawBuffers) { - /* From the ARB_draw_buffers spec (same text exists - * for ATI_draw_buffers): - * - * If this option is not specified, a fragment - * program that attempts to bind - * "result.color[n]" will fail to load, and only - * "result.color" will be allowed. - */ - yyerror(& @1, state, - "result.color[] used without " - "`OPTION ARB_draw_buffers' or " - "`OPTION ATI_draw_buffers'"); - YYERROR; - } else if ($2 >= state->MaxDrawBuffers) { - yyerror(& @1, state, - "result.color[] exceeds MAX_DRAW_BUFFERS_ARB"); - YYERROR; - } - $$ = FRAG_RESULT_DATA0 + $2; - } - } - | FRONT - { - if (state->mode == ARB_vertex) { - $$ = VERT_RESULT_COL0; - } else { - yyerror(& @1, state, "invalid program result name"); - YYERROR; - } - } - | BACK - { - if (state->mode == ARB_vertex) { - $$ = VERT_RESULT_BFC0; - } else { - yyerror(& @1, state, "invalid program result name"); - YYERROR; - } - } - ; - -optResultColorType: - { - $$ = 0; - } - | PRIMARY - { - if (state->mode == ARB_vertex) { - $$ = 0; - } else { - yyerror(& @1, state, "invalid program result name"); - YYERROR; - } - } - | SECONDARY - { - if (state->mode == ARB_vertex) { - $$ = 1; - } else { - yyerror(& @1, state, "invalid program result name"); - YYERROR; - } - } - ; - -optFaceType: { $$ = 0; } - | FRONT { $$ = 0; } - | BACK { $$ = 1; } - ; - -optColorType: { $$ = 0; } - | PRIMARY { $$ = 0; } - | SECONDARY { $$ = 1; } - ; - -optTexCoordUnitNum: { $$ = 0; } - | '[' texCoordUnitNum ']' { $$ = $2; } - ; - -optTexImageUnitNum: { $$ = 0; } - | '[' texImageUnitNum ']' { $$ = $2; } - ; - -optLegacyTexUnitNum: { $$ = 0; } - | '[' legacyTexUnitNum ']' { $$ = $2; } - ; - -texCoordUnitNum: INTEGER - { - if ((unsigned) $1 >= state->MaxTextureCoordUnits) { - yyerror(& @1, state, "invalid texture coordinate unit selector"); - YYERROR; - } - - $$ = $1; - } - ; - -texImageUnitNum: INTEGER - { - if ((unsigned) $1 >= state->MaxTextureImageUnits) { - yyerror(& @1, state, "invalid texture image unit selector"); - YYERROR; - } - - $$ = $1; - } - ; - -legacyTexUnitNum: INTEGER - { - if ((unsigned) $1 >= state->MaxTextureUnits) { - yyerror(& @1, state, "invalid texture unit selector"); - YYERROR; - } - - $$ = $1; - } - ; - -ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER - { - struct asm_symbol *exist = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, $2); - struct asm_symbol *target = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, $4); - - free($4); - - if (exist != NULL) { - char m[1000]; - _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", $2); - free($2); - yyerror(& @2, state, m); - YYERROR; - } else if (target == NULL) { - free($2); - yyerror(& @4, state, - "undefined variable binding in ALIAS statement"); - YYERROR; - } else { - _mesa_symbol_table_add_symbol(state->st, 0, $2, target); - } - } - ; - -string: IDENTIFIER - | USED_IDENTIFIER - ; - -%% - -void -asm_instruction_set_operands(struct asm_instruction *inst, - const struct prog_dst_register *dst, - const struct asm_src_register *src0, - const struct asm_src_register *src1, - const struct asm_src_register *src2) -{ - /* In the core ARB extensions only the KIL instruction doesn't have a - * destination register. - */ - if (dst == NULL) { - init_dst_reg(& inst->Base.DstReg); - } else { - inst->Base.DstReg = *dst; - } - - /* The only instruction that doesn't have any source registers is the - * condition-code based KIL instruction added by NV_fragment_program_option. - */ - if (src0 != NULL) { - inst->Base.SrcReg[0] = src0->Base; - inst->SrcReg[0] = *src0; - } else { - init_src_reg(& inst->SrcReg[0]); - } - - if (src1 != NULL) { - inst->Base.SrcReg[1] = src1->Base; - inst->SrcReg[1] = *src1; - } else { - init_src_reg(& inst->SrcReg[1]); - } - - if (src2 != NULL) { - inst->Base.SrcReg[2] = src2->Base; - inst->SrcReg[2] = *src2; - } else { - init_src_reg(& inst->SrcReg[2]); - } -} - - -struct asm_instruction * -asm_instruction_ctor(gl_inst_opcode op, - const struct prog_dst_register *dst, - const struct asm_src_register *src0, - const struct asm_src_register *src1, - const struct asm_src_register *src2) -{ - struct asm_instruction *inst = CALLOC_STRUCT(asm_instruction); - - if (inst) { - _mesa_init_instructions(& inst->Base, 1); - inst->Base.Opcode = op; - - asm_instruction_set_operands(inst, dst, src0, src1, src2); - } - - return inst; -} - - -struct asm_instruction * -asm_instruction_copy_ctor(const struct prog_instruction *base, - const struct prog_dst_register *dst, - const struct asm_src_register *src0, - const struct asm_src_register *src1, - const struct asm_src_register *src2) -{ - struct asm_instruction *inst = CALLOC_STRUCT(asm_instruction); - - if (inst) { - _mesa_init_instructions(& inst->Base, 1); - inst->Base.Opcode = base->Opcode; - inst->Base.CondUpdate = base->CondUpdate; - inst->Base.CondDst = base->CondDst; - inst->Base.SaturateMode = base->SaturateMode; - inst->Base.Precision = base->Precision; - - asm_instruction_set_operands(inst, dst, src0, src1, src2); - } - - return inst; -} - - -void -init_dst_reg(struct prog_dst_register *r) -{ - memset(r, 0, sizeof(*r)); - r->File = PROGRAM_UNDEFINED; - r->WriteMask = WRITEMASK_XYZW; - r->CondMask = COND_TR; - r->CondSwizzle = SWIZZLE_NOOP; -} - - -/** Like init_dst_reg() but set the File and Index fields. */ -void -set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index) -{ - const GLint maxIndex = 1 << INST_INDEX_BITS; - const GLint minIndex = 0; - ASSERT(index >= minIndex); - (void) minIndex; - ASSERT(index <= maxIndex); - (void) maxIndex; - ASSERT(file == PROGRAM_TEMPORARY || - file == PROGRAM_ADDRESS || - file == PROGRAM_OUTPUT); - memset(r, 0, sizeof(*r)); - r->File = file; - r->Index = index; - r->WriteMask = WRITEMASK_XYZW; - r->CondMask = COND_TR; - r->CondSwizzle = SWIZZLE_NOOP; -} - - -void -init_src_reg(struct asm_src_register *r) -{ - memset(r, 0, sizeof(*r)); - r->Base.File = PROGRAM_UNDEFINED; - r->Base.Swizzle = SWIZZLE_NOOP; - r->Symbol = NULL; -} - - -/** Like init_src_reg() but set the File and Index fields. - * \return GL_TRUE if a valid src register, GL_FALSE otherwise - */ -void -set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index) -{ - set_src_reg_swz(r, file, index, SWIZZLE_XYZW); -} - - -void -set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, - GLuint swizzle) -{ - const GLint maxIndex = (1 << INST_INDEX_BITS) - 1; - const GLint minIndex = -(1 << INST_INDEX_BITS); - ASSERT(file < PROGRAM_FILE_MAX); - ASSERT(index >= minIndex); - (void) minIndex; - ASSERT(index <= maxIndex); - (void) maxIndex; - memset(r, 0, sizeof(*r)); - r->Base.File = file; - r->Base.Index = index; - r->Base.Swizzle = swizzle; - r->Symbol = NULL; -} - - -/** - * Validate the set of inputs used by a program - * - * Validates that legal sets of inputs are used by the program. In this case - * "used" included both reading the input or binding the input to a name using - * the \c ATTRIB command. - * - * \return - * \c TRUE if the combination of inputs used is valid, \c FALSE otherwise. - */ -int -validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state) -{ - const GLbitfield64 inputs = state->prog->InputsRead | state->InputsBound; - - if (((inputs & VERT_BIT_FF_ALL) & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) { - yyerror(locp, state, "illegal use of generic attribute and name attribute"); - return 0; - } - - return 1; -} - - -struct asm_symbol * -declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, - struct YYLTYPE *locp) -{ - struct asm_symbol *s = NULL; - struct asm_symbol *exist = (struct asm_symbol *) - _mesa_symbol_table_find_symbol(state->st, 0, name); - - - if (exist != NULL) { - yyerror(locp, state, "redeclared identifier"); - } else { - s = calloc(1, sizeof(struct asm_symbol)); - s->name = name; - s->type = t; - - switch (t) { - case at_temp: - if (state->prog->NumTemporaries >= state->limits->MaxTemps) { - yyerror(locp, state, "too many temporaries declared"); - free(s); - return NULL; - } - - s->temp_binding = state->prog->NumTemporaries; - state->prog->NumTemporaries++; - break; - - case at_address: - if (state->prog->NumAddressRegs >= state->limits->MaxAddressRegs) { - yyerror(locp, state, "too many address registers declared"); - free(s); - return NULL; - } - - /* FINISHME: Add support for multiple address registers. - */ - state->prog->NumAddressRegs++; - break; - - default: - break; - } - - _mesa_symbol_table_add_symbol(state->st, 0, s->name, s); - s->next = state->sym; - state->sym = s; - } - - return s; -} - - -int add_state_reference(struct gl_program_parameter_list *param_list, - const gl_state_index tokens[STATE_LENGTH]) -{ - const GLuint size = 4; /* XXX fix */ - char *name; - GLint index; - - name = _mesa_program_state_string(tokens); - index = _mesa_add_parameter(param_list, PROGRAM_STATE_VAR, name, - size, GL_NONE, NULL, tokens, 0x0); - param_list->StateFlags |= _mesa_program_state_flags(tokens); - - /* free name string here since we duplicated it in add_parameter() */ - free(name); - - return index; -} - - -int -initialize_symbol_from_state(struct gl_program *prog, - struct asm_symbol *param_var, - const gl_state_index tokens[STATE_LENGTH]) -{ - int idx = -1; - gl_state_index state_tokens[STATE_LENGTH]; - - - memcpy(state_tokens, tokens, sizeof(state_tokens)); - - param_var->type = at_param; - param_var->param_binding_type = PROGRAM_STATE_VAR; - - /* If we are adding a STATE_MATRIX that has multiple rows, we need to - * unroll it and call add_state_reference() for each row - */ - if ((state_tokens[0] == STATE_MODELVIEW_MATRIX || - state_tokens[0] == STATE_PROJECTION_MATRIX || - state_tokens[0] == STATE_MVP_MATRIX || - state_tokens[0] == STATE_TEXTURE_MATRIX || - state_tokens[0] == STATE_PROGRAM_MATRIX) - && (state_tokens[2] != state_tokens[3])) { - int row; - const int first_row = state_tokens[2]; - const int last_row = state_tokens[3]; - - for (row = first_row; row <= last_row; row++) { - state_tokens[2] = state_tokens[3] = row; - - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - - param_var->param_binding_length++; - } - } - else { - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - param_var->param_binding_length++; - } - - return idx; -} - - -int -initialize_symbol_from_param(struct gl_program *prog, - struct asm_symbol *param_var, - const gl_state_index tokens[STATE_LENGTH]) -{ - int idx = -1; - gl_state_index state_tokens[STATE_LENGTH]; - - - memcpy(state_tokens, tokens, sizeof(state_tokens)); - - assert((state_tokens[0] == STATE_VERTEX_PROGRAM) - || (state_tokens[0] == STATE_FRAGMENT_PROGRAM)); - assert((state_tokens[1] == STATE_ENV) - || (state_tokens[1] == STATE_LOCAL)); - - /* - * The param type is STATE_VAR. The program parameter entry will - * effectively be a pointer into the LOCAL or ENV parameter array. - */ - param_var->type = at_param; - param_var->param_binding_type = PROGRAM_STATE_VAR; - - /* If we are adding a STATE_ENV or STATE_LOCAL that has multiple elements, - * we need to unroll it and call add_state_reference() for each row - */ - if (state_tokens[2] != state_tokens[3]) { - int row; - const int first_row = state_tokens[2]; - const int last_row = state_tokens[3]; - - for (row = first_row; row <= last_row; row++) { - state_tokens[2] = state_tokens[3] = row; - - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - param_var->param_binding_length++; - } - } - else { - idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = SWIZZLE_XYZW; - } - param_var->param_binding_length++; - } - - return idx; -} - - -/** - * Put a float/vector constant/literal into the parameter list. - * \param param_var returns info about the parameter/constant's location, - * binding, type, etc. - * \param vec the vector/constant to add - * \param allowSwizzle if true, try to consolidate constants which only differ - * by a swizzle. We don't want to do this when building - * arrays of constants that may be indexed indirectly. - * \return index of the constant in the parameter list. - */ -int -initialize_symbol_from_const(struct gl_program *prog, - struct asm_symbol *param_var, - const struct asm_vector *vec, - GLboolean allowSwizzle) -{ - unsigned swizzle; - const int idx = _mesa_add_unnamed_constant(prog->Parameters, - vec->data, vec->count, - allowSwizzle ? &swizzle : NULL); - - param_var->type = at_param; - param_var->param_binding_type = PROGRAM_CONSTANT; - - if (param_var->param_binding_begin == ~0U) { - param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = allowSwizzle ? swizzle : SWIZZLE_XYZW; - } - param_var->param_binding_length++; - - return idx; -} - - -char * -make_error_string(const char *fmt, ...) -{ - int length; - char *str; - va_list args; - - - /* Call vsnprintf once to determine how large the final string is. Call it - * again to do the actual formatting. from the vsnprintf manual page: - * - * Upon successful return, these functions return the number of - * characters printed (not including the trailing '\0' used to end - * output to strings). - */ - va_start(args, fmt); - length = 1 + vsnprintf(NULL, 0, fmt, args); - va_end(args); - - str = malloc(length); - if (str) { - va_start(args, fmt); - vsnprintf(str, length, fmt, args); - va_end(args); - } - - return str; -} - - -void -yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s) -{ - char *err_str; - - - err_str = make_error_string("glProgramStringARB(%s)\n", s); - if (err_str) { - _mesa_error(state->ctx, GL_INVALID_OPERATION, "%s", err_str); - free(err_str); - } - - err_str = make_error_string("line %u, char %u: error: %s\n", - locp->first_line, locp->first_column, s); - _mesa_set_program_error(state->ctx, locp->position, err_str); - - if (err_str) { - free(err_str); - } -} - - -GLboolean -_mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *str, - GLsizei len, struct asm_parser_state *state) -{ - struct asm_instruction *inst; - unsigned i; - GLubyte *strz; - GLboolean result = GL_FALSE; - void *temp; - struct asm_symbol *sym; - - state->ctx = ctx; - state->prog->Target = target; - state->prog->Parameters = _mesa_new_parameter_list(); - - /* Make a copy of the program string and force it to be NUL-terminated. - */ - strz = (GLubyte *) malloc(len + 1); - if (strz == NULL) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); - return GL_FALSE; - } - memcpy (strz, str, len); - strz[len] = '\0'; - - state->prog->String = strz; - - state->st = _mesa_symbol_table_ctor(); - - state->limits = (target == GL_VERTEX_PROGRAM_ARB) - ? & ctx->Const.VertexProgram - : & ctx->Const.FragmentProgram; - - state->MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; - state->MaxTextureCoordUnits = ctx->Const.MaxTextureCoordUnits; - state->MaxTextureUnits = ctx->Const.MaxTextureUnits; - state->MaxClipPlanes = ctx->Const.MaxClipPlanes; - state->MaxLights = ctx->Const.MaxLights; - state->MaxProgramMatrices = ctx->Const.MaxProgramMatrices; - state->MaxDrawBuffers = ctx->Const.MaxDrawBuffers; - - state->state_param_enum = (target == GL_VERTEX_PROGRAM_ARB) - ? STATE_VERTEX_PROGRAM : STATE_FRAGMENT_PROGRAM; - - _mesa_set_program_error(ctx, -1, NULL); - - _mesa_program_lexer_ctor(& state->scanner, state, (const char *) str, len); - yyparse(state); - _mesa_program_lexer_dtor(state->scanner); - - - if (ctx->Program.ErrorPos != -1) { - goto error; - } - - if (! _mesa_layout_parameters(state)) { - struct YYLTYPE loc; - - loc.first_line = 0; - loc.first_column = 0; - loc.position = len; - - yyerror(& loc, state, "invalid PARAM usage"); - goto error; - } - - - - /* Add one instruction to store the "END" instruction. - */ - state->prog->Instructions = - _mesa_alloc_instructions(state->prog->NumInstructions + 1); - inst = state->inst_head; - for (i = 0; i < state->prog->NumInstructions; i++) { - struct asm_instruction *const temp = inst->next; - - state->prog->Instructions[i] = inst->Base; - inst = temp; - } - - /* Finally, tag on an OPCODE_END instruction */ - { - const GLuint numInst = state->prog->NumInstructions; - _mesa_init_instructions(state->prog->Instructions + numInst, 1); - state->prog->Instructions[numInst].Opcode = OPCODE_END; - } - state->prog->NumInstructions++; - - state->prog->NumParameters = state->prog->Parameters->NumParameters; - state->prog->NumAttributes = _mesa_bitcount_64(state->prog->InputsRead); - - /* - * Initialize native counts to logical counts. The device driver may - * change them if program is translated into a hardware program. - */ - state->prog->NumNativeInstructions = state->prog->NumInstructions; - state->prog->NumNativeTemporaries = state->prog->NumTemporaries; - state->prog->NumNativeParameters = state->prog->NumParameters; - state->prog->NumNativeAttributes = state->prog->NumAttributes; - state->prog->NumNativeAddressRegs = state->prog->NumAddressRegs; - - result = GL_TRUE; - -error: - for (inst = state->inst_head; inst != NULL; inst = temp) { - temp = inst->next; - free(inst); - } - - state->inst_head = NULL; - state->inst_tail = NULL; - - for (sym = state->sym; sym != NULL; sym = temp) { - temp = sym->next; - - free((void *) sym->name); - free(sym); - } - state->sym = NULL; - - _mesa_symbol_table_dtor(state->st); - state->st = NULL; - - return result; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program_parse_extra.c b/reactos/dll/opengl/mesa/src/mesa/program/program_parse_extra.c deleted file mode 100644 index 5c892c90408..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program_parse_extra.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include -#include "main/mtypes.h" -#include "prog_instruction.h" -#include "program_parser.h" - - -/** - * Extra assembly-level parser routines - * - * \author Ian Romanick - */ - -int -_mesa_parse_instruction_suffix(const struct asm_parser_state *state, - const char *suffix, - struct prog_instruction *inst) -{ - inst->CondUpdate = 0; - inst->CondDst = 0; - inst->SaturateMode = SATURATE_OFF; - inst->Precision = FLOAT32; - - - /* The first possible suffix element is the precision specifier from - * NV_fragment_program_option. - */ - if (state->option.NV_fragment) { - switch (suffix[0]) { - case 'H': - inst->Precision = FLOAT16; - suffix++; - break; - case 'R': - inst->Precision = FLOAT32; - suffix++; - break; - case 'X': - inst->Precision = FIXED12; - suffix++; - break; - default: - break; - } - } - - /* The next possible suffix element is the condition code modifier selection - * from NV_fragment_program_option. - */ - if (state->option.NV_fragment) { - if (suffix[0] == 'C') { - inst->CondUpdate = 1; - suffix++; - } - } - - - /* The final possible suffix element is the saturation selector from - * ARB_fragment_program. - */ - if (state->mode == ARB_fragment) { - if (strcmp(suffix, "_SAT") == 0) { - inst->SaturateMode = SATURATE_ZERO_ONE; - suffix += 4; - } - } - - - /* It is an error for all of the suffix string not to be consumed. - */ - return suffix[0] == '\0'; -} - - -int -_mesa_parse_cc(const char *s) -{ - int cond = 0; - - switch (s[0]) { - case 'E': - if (s[1] == 'Q') { - cond = COND_EQ; - } - break; - - case 'F': - if (s[1] == 'L') { - cond = COND_FL; - } - break; - - case 'G': - if (s[1] == 'E') { - cond = COND_GE; - } else if (s[1] == 'T') { - cond = COND_GT; - } - break; - - case 'L': - if (s[1] == 'E') { - cond = COND_LE; - } else if (s[1] == 'T') { - cond = COND_LT; - } - break; - - case 'N': - if (s[1] == 'E') { - cond = COND_NE; - } - break; - - case 'T': - if (s[1] == 'R') { - cond = COND_TR; - } - break; - - default: - break; - } - - return ((cond == 0) || (s[2] != '\0')) ? 0 : cond; -} - - -int -_mesa_ARBvp_parse_option(struct asm_parser_state *state, const char *option) -{ - if (strcmp(option, "ARB_position_invariant") == 0) { - state->option.PositionInvariant = 1; - return 1; - } - - return 0; -} - - -int -_mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option) -{ - /* All of the options currently supported start with "ARB_". The code is - * currently structured with nested if-statements because eventually options - * that start with "NV_" will be supported. This structure will result in - * less churn when those options are added. - */ - if (strncmp(option, "ARB_", 4) == 0) { - /* Advance the pointer past the "ARB_" prefix. - */ - option += 4; - - - if (strncmp(option, "fog_", 4) == 0) { - option += 4; - - if (state->option.Fog == OPTION_NONE) { - if (strcmp(option, "exp") == 0) { - state->option.Fog = OPTION_FOG_EXP; - return 1; - } else if (strcmp(option, "exp2") == 0) { - state->option.Fog = OPTION_FOG_EXP2; - return 1; - } else if (strcmp(option, "linear") == 0) { - state->option.Fog = OPTION_FOG_LINEAR; - return 1; - } - } - - return 0; - } else if (strncmp(option, "precision_hint_", 15) == 0) { - option += 15; - - if (state->option.PrecisionHint == OPTION_NONE) { - if (strcmp(option, "nicest") == 0) { - state->option.PrecisionHint = OPTION_NICEST; - return 1; - } else if (strcmp(option, "fastest") == 0) { - state->option.PrecisionHint = OPTION_FASTEST; - return 1; - } - } - - return 0; - } else if (strcmp(option, "draw_buffers") == 0) { - /* Don't need to check extension availability because all Mesa-based - * drivers support GL_ARB_draw_buffers. - */ - state->option.DrawBuffers = 1; - return 1; - } else if (strcmp(option, "fragment_program_shadow") == 0) { - if (state->ctx->Extensions.ARB_fragment_program_shadow) { - state->option.Shadow = 1; - return 1; - } - } - } else if (strncmp(option, "ATI_", 4) == 0) { - option += 4; - - if (strcmp(option, "draw_buffers") == 0) { - /* Don't need to check extension availability because all Mesa-based - * drivers support GL_ATI_draw_buffers. - */ - state->option.DrawBuffers = 1; - return 1; - } - } else if (strncmp(option, "NV_fragment_program", 19) == 0) { - option += 19; - - /* Other NV_fragment_program strings may be supported later. - */ - if (option[0] == '\0') { - if (state->ctx->Extensions.NV_fragment_program_option) { - state->option.NV_fragment = 1; - return 1; - } - } - } - - return 0; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/program_parser.h b/reactos/dll/opengl/mesa/src/mesa/program/program_parser.h deleted file mode 100644 index e580231662e..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/program_parser.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ -#pragma once - -#include "main/config.h" -#include "program/prog_parameter.h" - -struct gl_context; - -enum asm_type { - at_none, - at_address, - at_attrib, - at_param, - at_temp, - at_output -}; - -struct asm_symbol { - struct asm_symbol *next; /**< List linkage for freeing. */ - const char *name; - enum asm_type type; - unsigned attrib_binding; - unsigned output_binding; /**< Output / result register number. */ - - /** - * One of PROGRAM_STATE_VAR, PROGRAM_LOCAL_PARAM, or PROGRAM_ENV_PARAM. - */ - unsigned param_binding_type; - - /** - * Offset into the program_parameter_list where the tokens representing our - * bound state (or constants) start. - */ - unsigned param_binding_begin; - - /** - * Constants put into the parameter list may be swizzled. This - * field contain's the symbol's swizzle. (SWIZZLE_X/Y/Z/W) - */ - unsigned param_binding_swizzle; - - /* This is how many entries in the program_parameter_list we take up - * with our state tokens or constants. Note that this is _not_ the same as - * the number of param registers we eventually use. - */ - unsigned param_binding_length; - - /** - * Index of the temp register assigned to this variable. - */ - unsigned temp_binding; - - /** - * Flag whether or not a PARAM is an array - */ - unsigned param_is_array:1; - - - /** - * Flag whether or not a PARAM array is accessed indirectly - */ - unsigned param_accessed_indirectly:1; - - - /** - * \brief Is first pass of parameter layout done with this variable? - * - * The parameter layout routine operates in two passes. This flag tracks - * whether or not the first pass has handled this variable. - * - * \sa _mesa_layout_parameters - */ - unsigned pass1_done:1; -}; - - -struct asm_vector { - unsigned count; - gl_constant_value data[4]; -}; - - -struct asm_swizzle_mask { - unsigned swizzle:12; - unsigned mask:4; -}; - - -struct asm_src_register { - struct prog_src_register Base; - - /** - * Symbol associated with indirect access to parameter arrays. - * - * If \c Base::RelAddr is 1, this will point to the symbol for the parameter - * that is being dereferenced. Further, \c Base::Index will be the offset - * from the address register being used. - */ - struct asm_symbol *Symbol; -}; - - -struct asm_instruction { - struct prog_instruction Base; - struct asm_instruction *next; - struct asm_src_register SrcReg[3]; -}; - - -struct asm_parser_state { - struct gl_context *ctx; - struct gl_program *prog; - - /** - * Per-program target limits - */ - struct gl_program_constants *limits; - - struct _mesa_symbol_table *st; - - /** - * Linked list of symbols - * - * This list is \b only used when cleaning up compiler state and freeing - * memory. - */ - struct asm_symbol *sym; - - /** - * State for the lexer. - */ - void *scanner; - - /** - * Linked list of instructions generated during parsing. - */ - /*@{*/ - struct asm_instruction *inst_head; - struct asm_instruction *inst_tail; - /*@}*/ - - - /** - * Selected limits copied from gl_constants - * - * These are limits from the GL context, but various bits in the program - * must be validated against these values. - */ - /*@{*/ - unsigned MaxTextureCoordUnits; - unsigned MaxTextureImageUnits; - unsigned MaxTextureUnits; - unsigned MaxClipPlanes; - unsigned MaxLights; - unsigned MaxProgramMatrices; - unsigned MaxDrawBuffers; - /*@}*/ - - /** - * Value to use in state vector accessors for environment and local - * parameters - */ - unsigned state_param_enum; - - - /** - * Input attributes bound to specific names - * - * This is only needed so that errors can be properly produced when - * multiple ATTRIB statements bind illegal combinations of vertex - * attributes. - */ - GLbitfield64 InputsBound; - - enum { - invalid_mode = 0, - ARB_vertex, - ARB_fragment - } mode; - - struct { - unsigned PositionInvariant:1; - unsigned Fog:2; - unsigned PrecisionHint:2; - unsigned DrawBuffers:1; - unsigned Shadow:1; - unsigned TexArray:1; - unsigned NV_fragment:1; - } option; - - struct { - unsigned UsesKill:1; - } fragment; -}; - -#define OPTION_NONE 0 -#define OPTION_FOG_EXP 1 -#define OPTION_FOG_EXP2 2 -#define OPTION_FOG_LINEAR 3 -#define OPTION_NICEST 1 -#define OPTION_FASTEST 2 - -typedef struct YYLTYPE { - int first_line; - int first_column; - int last_line; - int last_column; - int position; -} YYLTYPE; - -#define YYLTYPE_IS_DECLARED 1 -#define YYLTYPE_IS_TRIVIAL 1 - - -extern GLboolean _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, - const GLubyte *str, GLsizei len, struct asm_parser_state *state); - - - -/* From program_lexer.l. */ -extern void _mesa_program_lexer_dtor(void *scanner); - -extern void _mesa_program_lexer_ctor(void **scanner, - struct asm_parser_state *state, const char *string, size_t len); - - -/** - *\name From program_parse_extra.c - */ -/*@{*/ - -/** - * Parses and processes an option string to an ARB vertex program - * - * \return - * Non-zero on success, zero on failure. - */ -extern int _mesa_ARBvp_parse_option(struct asm_parser_state *state, - const char *option); - -/** - * Parses and processes an option string to an ARB fragment program - * - * \return - * Non-zero on success, zero on failure. - */ -extern int _mesa_ARBfp_parse_option(struct asm_parser_state *state, - const char *option); - -/** - * Parses and processes instruction suffixes - * - * Instruction suffixes, such as \c _SAT, are processed. The relevant bits - * are set in \c inst. If suffixes are encountered that are either not known - * or not supported by the modes and options set in \c state, zero will be - * returned. - * - * \return - * Non-zero on success, zero on failure. - */ -extern int _mesa_parse_instruction_suffix(const struct asm_parser_state *state, - const char *suffix, struct prog_instruction *inst); - -/** - * Parses a condition code name - * - * The condition code names (e.g., \c LT, \c GT, \c NE) were added to assembly - * shaders with the \c GL_NV_fragment_program_option extension. This function - * converts a string representation into one of the \c COND_ macros. - * - * \return - * One of the \c COND_ macros defined in prog_instruction.h on success or zero - * on failure. - */ -extern int _mesa_parse_cc(const char *s); - -/*@}*/ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/programopt.c b/reactos/dll/opengl/mesa/src/mesa/program/programopt.c deleted file mode 100644 index 389ea218b48..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/programopt.c +++ /dev/null @@ -1,685 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 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. - */ - -/** - * \file programopt.c - * Vertex/Fragment program optimizations and transformations for program - * options, etc. - * - * \author Brian Paul - */ - - -#include "main/glheader.h" -#include "main/context.h" -#include "prog_parameter.h" -#include "prog_statevars.h" -#include "program.h" -#include "programopt.h" -#include "prog_instruction.h" - - -/** - * This function inserts instructions for coordinate modelview * projection - * into a vertex program. - * May be used to implement the position_invariant option. - */ -static void -_mesa_insert_mvp_dp4_code(struct gl_context *ctx, struct gl_vertex_program *vprog) -{ - struct prog_instruction *newInst; - const GLuint origLen = vprog->Base.NumInstructions; - const GLuint newLen = origLen + 4; - GLuint i; - - /* - * Setup state references for the modelview/projection matrix. - * XXX we should check if these state vars are already declared. - */ - static const gl_state_index mvpState[4][STATE_LENGTH] = { - { STATE_MVP_MATRIX, 0, 0, 0, 0 }, /* state.matrix.mvp.row[0] */ - { STATE_MVP_MATRIX, 0, 1, 1, 0 }, /* state.matrix.mvp.row[1] */ - { STATE_MVP_MATRIX, 0, 2, 2, 0 }, /* state.matrix.mvp.row[2] */ - { STATE_MVP_MATRIX, 0, 3, 3, 0 }, /* state.matrix.mvp.row[3] */ - }; - GLint mvpRef[4]; - - for (i = 0; i < 4; i++) { - mvpRef[i] = _mesa_add_state_reference(vprog->Base.Parameters, - mvpState[i]); - } - - /* Alloc storage for new instructions */ - newInst = _mesa_alloc_instructions(newLen); - if (!newInst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glProgramString(inserting position_invariant code)"); - return; - } - - /* - * Generated instructions: - * newInst[0] = DP4 result.position.x, mvp.row[0], vertex.position; - * newInst[1] = DP4 result.position.y, mvp.row[1], vertex.position; - * newInst[2] = DP4 result.position.z, mvp.row[2], vertex.position; - * newInst[3] = DP4 result.position.w, mvp.row[3], vertex.position; - */ - _mesa_init_instructions(newInst, 4); - for (i = 0; i < 4; i++) { - newInst[i].Opcode = OPCODE_DP4; - newInst[i].DstReg.File = PROGRAM_OUTPUT; - newInst[i].DstReg.Index = VERT_RESULT_HPOS; - newInst[i].DstReg.WriteMask = (WRITEMASK_X << i); - newInst[i].SrcReg[0].File = PROGRAM_STATE_VAR; - newInst[i].SrcReg[0].Index = mvpRef[i]; - newInst[i].SrcReg[0].Swizzle = SWIZZLE_NOOP; - newInst[i].SrcReg[1].File = PROGRAM_INPUT; - newInst[i].SrcReg[1].Index = VERT_ATTRIB_POS; - newInst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; - } - - /* Append original instructions after new instructions */ - _mesa_copy_instructions (newInst + 4, vprog->Base.Instructions, origLen); - - /* free old instructions */ - _mesa_free_instructions(vprog->Base.Instructions, origLen); - - /* install new instructions */ - vprog->Base.Instructions = newInst; - vprog->Base.NumInstructions = newLen; - vprog->Base.InputsRead |= VERT_BIT_POS; - vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS); -} - - -static void -_mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_vertex_program *vprog) -{ - struct prog_instruction *newInst; - const GLuint origLen = vprog->Base.NumInstructions; - const GLuint newLen = origLen + 4; - GLuint hposTemp; - GLuint i; - - /* - * Setup state references for the modelview/projection matrix. - * XXX we should check if these state vars are already declared. - */ - static const gl_state_index mvpState[4][STATE_LENGTH] = { - { STATE_MVP_MATRIX, 0, 0, 0, STATE_MATRIX_TRANSPOSE }, - { STATE_MVP_MATRIX, 0, 1, 1, STATE_MATRIX_TRANSPOSE }, - { STATE_MVP_MATRIX, 0, 2, 2, STATE_MATRIX_TRANSPOSE }, - { STATE_MVP_MATRIX, 0, 3, 3, STATE_MATRIX_TRANSPOSE }, - }; - GLint mvpRef[4]; - - for (i = 0; i < 4; i++) { - mvpRef[i] = _mesa_add_state_reference(vprog->Base.Parameters, - mvpState[i]); - } - - /* Alloc storage for new instructions */ - newInst = _mesa_alloc_instructions(newLen); - if (!newInst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glProgramString(inserting position_invariant code)"); - return; - } - - /* TEMP hposTemp; */ - hposTemp = vprog->Base.NumTemporaries++; - - /* - * Generated instructions: - * emit_op2(p, OPCODE_MUL, tmp, 0, swizzle1(src,X), mat[0]); - * emit_op3(p, OPCODE_MAD, tmp, 0, swizzle1(src,Y), mat[1], tmp); - * emit_op3(p, OPCODE_MAD, tmp, 0, swizzle1(src,Z), mat[2], tmp); - * emit_op3(p, OPCODE_MAD, dest, 0, swizzle1(src,W), mat[3], tmp); - */ - _mesa_init_instructions(newInst, 4); - - newInst[0].Opcode = OPCODE_MUL; - newInst[0].DstReg.File = PROGRAM_TEMPORARY; - newInst[0].DstReg.Index = hposTemp; - newInst[0].DstReg.WriteMask = WRITEMASK_XYZW; - newInst[0].SrcReg[0].File = PROGRAM_INPUT; - newInst[0].SrcReg[0].Index = VERT_ATTRIB_POS; - newInst[0].SrcReg[0].Swizzle = SWIZZLE_XXXX; - newInst[0].SrcReg[1].File = PROGRAM_STATE_VAR; - newInst[0].SrcReg[1].Index = mvpRef[0]; - newInst[0].SrcReg[1].Swizzle = SWIZZLE_NOOP; - - for (i = 1; i <= 2; i++) { - newInst[i].Opcode = OPCODE_MAD; - newInst[i].DstReg.File = PROGRAM_TEMPORARY; - newInst[i].DstReg.Index = hposTemp; - newInst[i].DstReg.WriteMask = WRITEMASK_XYZW; - newInst[i].SrcReg[0].File = PROGRAM_INPUT; - newInst[i].SrcReg[0].Index = VERT_ATTRIB_POS; - newInst[i].SrcReg[0].Swizzle = MAKE_SWIZZLE4(i,i,i,i); - newInst[i].SrcReg[1].File = PROGRAM_STATE_VAR; - newInst[i].SrcReg[1].Index = mvpRef[i]; - newInst[i].SrcReg[1].Swizzle = SWIZZLE_NOOP; - newInst[i].SrcReg[2].File = PROGRAM_TEMPORARY; - newInst[i].SrcReg[2].Index = hposTemp; - newInst[1].SrcReg[2].Swizzle = SWIZZLE_NOOP; - } - - newInst[3].Opcode = OPCODE_MAD; - newInst[3].DstReg.File = PROGRAM_OUTPUT; - newInst[3].DstReg.Index = VERT_RESULT_HPOS; - newInst[3].DstReg.WriteMask = WRITEMASK_XYZW; - newInst[3].SrcReg[0].File = PROGRAM_INPUT; - newInst[3].SrcReg[0].Index = VERT_ATTRIB_POS; - newInst[3].SrcReg[0].Swizzle = SWIZZLE_WWWW; - newInst[3].SrcReg[1].File = PROGRAM_STATE_VAR; - newInst[3].SrcReg[1].Index = mvpRef[3]; - newInst[3].SrcReg[1].Swizzle = SWIZZLE_NOOP; - newInst[3].SrcReg[2].File = PROGRAM_TEMPORARY; - newInst[3].SrcReg[2].Index = hposTemp; - newInst[3].SrcReg[2].Swizzle = SWIZZLE_NOOP; - - - /* Append original instructions after new instructions */ - _mesa_copy_instructions (newInst + 4, vprog->Base.Instructions, origLen); - - /* free old instructions */ - _mesa_free_instructions(vprog->Base.Instructions, origLen); - - /* install new instructions */ - vprog->Base.Instructions = newInst; - vprog->Base.NumInstructions = newLen; - vprog->Base.InputsRead |= VERT_BIT_POS; - vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS); -} - - -void -_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog) -{ - if (ctx->mvp_with_dp4) - _mesa_insert_mvp_dp4_code( ctx, vprog ); - else - _mesa_insert_mvp_mad_code( ctx, vprog ); -} - - - - - - -/** - * Append instructions to implement fog - * - * The \c fragment.fogcoord input is used to compute the fog blend factor. - * - * \param ctx The GL context - * \param fprog Fragment program that fog instructions will be appended to. - * \param fog_mode Fog mode. One of \c GL_EXP, \c GL_EXP2, or \c GL_LINEAR. - * \param saturate True if writes to color outputs should be clamped to [0, 1] - * - * \note - * This function sets \c FRAG_BIT_FOGC in \c fprog->Base.InputsRead. - * - * \todo With a little work, this function could be adapted to add fog code - * to vertex programs too. - */ -void -_mesa_append_fog_code(struct gl_context *ctx, - struct gl_fragment_program *fprog, GLenum fog_mode, - GLboolean saturate) -{ - static const gl_state_index fogPStateOpt[STATE_LENGTH] - = { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 }; - static const gl_state_index fogColorState[STATE_LENGTH] - = { STATE_FOG_COLOR, 0, 0, 0, 0}; - struct prog_instruction *newInst, *inst; - const GLuint origLen = fprog->Base.NumInstructions; - const GLuint newLen = origLen + 5; - GLuint i; - GLint fogPRefOpt, fogColorRef; /* state references */ - GLuint colorTemp, fogFactorTemp; /* temporary registerss */ - - if (fog_mode == GL_NONE) { - _mesa_problem(ctx, "_mesa_append_fog_code() called for fragment program" - " with fog_mode == GL_NONE"); - return; - } - - if (!(fprog->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR))) { - /* program doesn't output color, so nothing to do */ - return; - } - - /* Alloc storage for new instructions */ - newInst = _mesa_alloc_instructions(newLen); - if (!newInst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glProgramString(inserting fog_option code)"); - return; - } - - /* Copy orig instructions into new instruction buffer */ - _mesa_copy_instructions(newInst, fprog->Base.Instructions, origLen); - - /* PARAM fogParamsRefOpt = internal optimized fog params; */ - fogPRefOpt - = _mesa_add_state_reference(fprog->Base.Parameters, fogPStateOpt); - /* PARAM fogColorRef = state.fog.color; */ - fogColorRef - = _mesa_add_state_reference(fprog->Base.Parameters, fogColorState); - - /* TEMP colorTemp; */ - colorTemp = fprog->Base.NumTemporaries++; - /* TEMP fogFactorTemp; */ - fogFactorTemp = fprog->Base.NumTemporaries++; - - /* Scan program to find where result.color is written */ - inst = newInst; - for (i = 0; i < fprog->Base.NumInstructions; i++) { - if (inst->Opcode == OPCODE_END) - break; - if (inst->DstReg.File == PROGRAM_OUTPUT && - inst->DstReg.Index == FRAG_RESULT_COLOR) { - /* change the instruction to write to colorTemp w/ clamping */ - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = colorTemp; - inst->SaturateMode = saturate; - /* don't break (may be several writes to result.color) */ - } - inst++; - } - assert(inst->Opcode == OPCODE_END); /* we'll overwrite this inst */ - - _mesa_init_instructions(inst, 5); - - /* emit instructions to compute fog blending factor */ - /* this is always clamped to [0, 1] regardless of fragment clamping */ - if (fog_mode == GL_LINEAR) { - /* MAD fogFactorTemp.x, fragment.fogcoord.x, fogPRefOpt.x, fogPRefOpt.y; */ - inst->Opcode = OPCODE_MAD; - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = fogFactorTemp; - inst->DstReg.WriteMask = WRITEMASK_X; - inst->SrcReg[0].File = PROGRAM_INPUT; - inst->SrcReg[0].Index = FRAG_ATTRIB_FOGC; - inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; - inst->SrcReg[1].File = PROGRAM_STATE_VAR; - inst->SrcReg[1].Index = fogPRefOpt; - inst->SrcReg[1].Swizzle = SWIZZLE_XXXX; - inst->SrcReg[2].File = PROGRAM_STATE_VAR; - inst->SrcReg[2].Index = fogPRefOpt; - inst->SrcReg[2].Swizzle = SWIZZLE_YYYY; - inst->SaturateMode = SATURATE_ZERO_ONE; - inst++; - } - else { - ASSERT(fog_mode == GL_EXP || fog_mode == GL_EXP2); - /* fogPRefOpt.z = d/ln(2), fogPRefOpt.w = d/sqrt(ln(2) */ - /* EXP: MUL fogFactorTemp.x, fogPRefOpt.z, fragment.fogcoord.x; */ - /* EXP2: MUL fogFactorTemp.x, fogPRefOpt.w, fragment.fogcoord.x; */ - inst->Opcode = OPCODE_MUL; - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = fogFactorTemp; - inst->DstReg.WriteMask = WRITEMASK_X; - inst->SrcReg[0].File = PROGRAM_STATE_VAR; - inst->SrcReg[0].Index = fogPRefOpt; - inst->SrcReg[0].Swizzle - = (fog_mode == GL_EXP) ? SWIZZLE_ZZZZ : SWIZZLE_WWWW; - inst->SrcReg[1].File = PROGRAM_INPUT; - inst->SrcReg[1].Index = FRAG_ATTRIB_FOGC; - inst->SrcReg[1].Swizzle = SWIZZLE_XXXX; - inst++; - if (fog_mode == GL_EXP2) { - /* MUL fogFactorTemp.x, fogFactorTemp.x, fogFactorTemp.x; */ - inst->Opcode = OPCODE_MUL; - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = fogFactorTemp; - inst->DstReg.WriteMask = WRITEMASK_X; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = fogFactorTemp; - inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; - inst->SrcReg[1].File = PROGRAM_TEMPORARY; - inst->SrcReg[1].Index = fogFactorTemp; - inst->SrcReg[1].Swizzle = SWIZZLE_XXXX; - inst++; - } - /* EX2_SAT fogFactorTemp.x, -fogFactorTemp.x; */ - inst->Opcode = OPCODE_EX2; - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = fogFactorTemp; - inst->DstReg.WriteMask = WRITEMASK_X; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = fogFactorTemp; - inst->SrcReg[0].Negate = NEGATE_XYZW; - inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; - inst->SaturateMode = SATURATE_ZERO_ONE; - inst++; - } - /* LRP result.color.xyz, fogFactorTemp.xxxx, colorTemp, fogColorRef; */ - inst->Opcode = OPCODE_LRP; - inst->DstReg.File = PROGRAM_OUTPUT; - inst->DstReg.Index = FRAG_RESULT_COLOR; - inst->DstReg.WriteMask = WRITEMASK_XYZ; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = fogFactorTemp; - inst->SrcReg[0].Swizzle = SWIZZLE_XXXX; - inst->SrcReg[1].File = PROGRAM_TEMPORARY; - inst->SrcReg[1].Index = colorTemp; - inst->SrcReg[1].Swizzle = SWIZZLE_NOOP; - inst->SrcReg[2].File = PROGRAM_STATE_VAR; - inst->SrcReg[2].Index = fogColorRef; - inst->SrcReg[2].Swizzle = SWIZZLE_NOOP; - inst++; - /* MOV result.color.w, colorTemp.x; # copy alpha */ - inst->Opcode = OPCODE_MOV; - inst->DstReg.File = PROGRAM_OUTPUT; - inst->DstReg.Index = FRAG_RESULT_COLOR; - inst->DstReg.WriteMask = WRITEMASK_W; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = colorTemp; - inst->SrcReg[0].Swizzle = SWIZZLE_NOOP; - inst++; - /* END; */ - inst->Opcode = OPCODE_END; - inst++; - - /* free old instructions */ - _mesa_free_instructions(fprog->Base.Instructions, origLen); - - /* install new instructions */ - fprog->Base.Instructions = newInst; - fprog->Base.NumInstructions = inst - newInst; - fprog->Base.InputsRead |= FRAG_BIT_FOGC; - assert(fprog->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR)); -} - - - -static GLboolean -is_texture_instruction(const struct prog_instruction *inst) -{ - switch (inst->Opcode) { - case OPCODE_TEX: - case OPCODE_TXB: - case OPCODE_TXD: - case OPCODE_TXL: - case OPCODE_TXP: - case OPCODE_TXP_NV: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/** - * Count the number of texure indirections in the given program. - * The program's NumTexIndirections field will be updated. - * See the GL_ARB_fragment_program spec (issue 24) for details. - * XXX we count texture indirections in texenvprogram.c (maybe use this code - * instead and elsewhere). - */ -void -_mesa_count_texture_indirections(struct gl_program *prog) -{ - GLuint indirections = 1; - GLbitfield tempsOutput = 0x0; - GLbitfield aluTemps = 0x0; - GLuint i; - - for (i = 0; i < prog->NumInstructions; i++) { - const struct prog_instruction *inst = prog->Instructions + i; - - if (is_texture_instruction(inst)) { - if (((inst->SrcReg[0].File == PROGRAM_TEMPORARY) && - (tempsOutput & (1 << inst->SrcReg[0].Index))) || - ((inst->Opcode != OPCODE_KIL) && - (inst->DstReg.File == PROGRAM_TEMPORARY) && - (aluTemps & (1 << inst->DstReg.Index)))) - { - indirections++; - tempsOutput = 0x0; - aluTemps = 0x0; - } - } - else { - GLuint j; - for (j = 0; j < 3; j++) { - if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) - aluTemps |= (1 << inst->SrcReg[j].Index); - } - if (inst->DstReg.File == PROGRAM_TEMPORARY) - aluTemps |= (1 << inst->DstReg.Index); - } - - if ((inst->Opcode != OPCODE_KIL) && (inst->DstReg.File == PROGRAM_TEMPORARY)) - tempsOutput |= (1 << inst->DstReg.Index); - } - - prog->NumTexIndirections = indirections; -} - - -/** - * Count number of texture instructions in given program and update the - * program's NumTexInstructions field. - */ -void -_mesa_count_texture_instructions(struct gl_program *prog) -{ - GLuint i; - prog->NumTexInstructions = 0; - for (i = 0; i < prog->NumInstructions; i++) { - prog->NumTexInstructions += is_texture_instruction(prog->Instructions + i); - } -} - - -/** - * Scan/rewrite program to remove reads of custom (output) registers. - * The passed type has to be either PROGRAM_OUTPUT or PROGRAM_VARYING - * (for vertex shaders). - * In GLSL shaders, varying vars can be read and written. - * On some hardware, trying to read an output register causes trouble. - * So, rewrite the program to use a temporary register in this case. - */ -void -_mesa_remove_output_reads(struct gl_program *prog, gl_register_file type) -{ - GLuint i; - GLint outputMap[VERT_RESULT_MAX]; - GLuint numVaryingReads = 0; - GLboolean usedTemps[MAX_PROGRAM_TEMPS]; - GLuint firstTemp = 0; - - _mesa_find_used_registers(prog, PROGRAM_TEMPORARY, - usedTemps, MAX_PROGRAM_TEMPS); - - assert(type == PROGRAM_VARYING || type == PROGRAM_OUTPUT); - assert(prog->Target == GL_VERTEX_PROGRAM_ARB || type != PROGRAM_VARYING); - - for (i = 0; i < VERT_RESULT_MAX; i++) - outputMap[i] = -1; - - /* look for instructions which read from varying vars */ - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode); - GLuint j; - for (j = 0; j < numSrc; j++) { - if (inst->SrcReg[j].File == type) { - /* replace the read with a temp reg */ - const GLuint var = inst->SrcReg[j].Index; - if (outputMap[var] == -1) { - numVaryingReads++; - outputMap[var] = _mesa_find_free_register(usedTemps, - MAX_PROGRAM_TEMPS, - firstTemp); - firstTemp = outputMap[var] + 1; - } - inst->SrcReg[j].File = PROGRAM_TEMPORARY; - inst->SrcReg[j].Index = outputMap[var]; - } - } - } - - if (numVaryingReads == 0) - return; /* nothing to be done */ - - /* look for instructions which write to the varying vars identified above */ - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - if (inst->DstReg.File == type && - outputMap[inst->DstReg.Index] >= 0) { - /* change inst to write to the temp reg, instead of the varying */ - inst->DstReg.File = PROGRAM_TEMPORARY; - inst->DstReg.Index = outputMap[inst->DstReg.Index]; - } - } - - /* insert new instructions to copy the temp vars to the varying vars */ - { - struct prog_instruction *inst; - GLint endPos, var; - - /* Look for END instruction and insert the new varying writes */ - endPos = -1; - for (i = 0; i < prog->NumInstructions; i++) { - struct prog_instruction *inst = prog->Instructions + i; - if (inst->Opcode == OPCODE_END) { - endPos = i; - _mesa_insert_instructions(prog, i, numVaryingReads); - break; - } - } - - assert(endPos >= 0); - - /* insert new MOV instructions here */ - inst = prog->Instructions + endPos; - for (var = 0; var < VERT_RESULT_MAX; var++) { - if (outputMap[var] >= 0) { - /* MOV VAR[var], TEMP[tmp]; */ - inst->Opcode = OPCODE_MOV; - inst->DstReg.File = type; - inst->DstReg.Index = var; - inst->SrcReg[0].File = PROGRAM_TEMPORARY; - inst->SrcReg[0].Index = outputMap[var]; - inst++; - } - } - } -} - - -/** - * Make the given fragment program into a "no-op" shader. - * Actually, just copy the incoming fragment color (or texcoord) - * to the output color. - * This is for debug/test purposes. - */ -void -_mesa_nop_fragment_program(struct gl_context *ctx, struct gl_fragment_program *prog) -{ - struct prog_instruction *inst; - GLuint inputAttr; - - inst = _mesa_alloc_instructions(2); - if (!inst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "_mesa_nop_fragment_program"); - return; - } - - _mesa_init_instructions(inst, 2); - - inst[0].Opcode = OPCODE_MOV; - inst[0].DstReg.File = PROGRAM_OUTPUT; - inst[0].DstReg.Index = FRAG_RESULT_COLOR; - inst[0].SrcReg[0].File = PROGRAM_INPUT; - if (prog->Base.InputsRead & FRAG_BIT_COL0) - inputAttr = FRAG_ATTRIB_COL0; - else - inputAttr = FRAG_ATTRIB_TEX0; - inst[0].SrcReg[0].Index = inputAttr; - - inst[1].Opcode = OPCODE_END; - - _mesa_free_instructions(prog->Base.Instructions, - prog->Base.NumInstructions); - - prog->Base.Instructions = inst; - prog->Base.NumInstructions = 2; - prog->Base.InputsRead = BITFIELD64_BIT(inputAttr); - prog->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR); -} - - -/** - * \sa _mesa_nop_fragment_program - * Replace the given vertex program with a "no-op" program that just - * transforms vertex position and emits color. - */ -void -_mesa_nop_vertex_program(struct gl_context *ctx, struct gl_vertex_program *prog) -{ - struct prog_instruction *inst; - GLuint inputAttr; - - /* - * Start with a simple vertex program that emits color. - */ - inst = _mesa_alloc_instructions(2); - if (!inst) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "_mesa_nop_vertex_program"); - return; - } - - _mesa_init_instructions(inst, 2); - - inst[0].Opcode = OPCODE_MOV; - inst[0].DstReg.File = PROGRAM_OUTPUT; - inst[0].DstReg.Index = VERT_RESULT_COL0; - inst[0].SrcReg[0].File = PROGRAM_INPUT; - if (prog->Base.InputsRead & VERT_BIT_COLOR0) - inputAttr = VERT_ATTRIB_COLOR0; - else - inputAttr = VERT_ATTRIB_TEX0; - inst[0].SrcReg[0].Index = inputAttr; - - inst[1].Opcode = OPCODE_END; - - _mesa_free_instructions(prog->Base.Instructions, - prog->Base.NumInstructions); - - prog->Base.Instructions = inst; - prog->Base.NumInstructions = 2; - prog->Base.InputsRead = BITFIELD64_BIT(inputAttr); - prog->Base.OutputsWritten = BITFIELD64_BIT(VERT_RESULT_COL0); - - /* - * Now insert code to do standard modelview/projection transformation. - */ - _mesa_insert_mvp_code(ctx, prog); -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/programopt.h b/reactos/dll/opengl/mesa/src/mesa/program/programopt.h deleted file mode 100644 index b9205823c29..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/programopt.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 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 PROGRAMOPT_H -#define PROGRAMOPT_H 1 - -#include "main/mtypes.h" - -extern void -_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog); - -extern void -_mesa_append_fog_code(struct gl_context *ctx, - struct gl_fragment_program *fprog, GLenum fog_mode, - GLboolean saturate); - -extern void -_mesa_count_texture_indirections(struct gl_program *prog); - -extern void -_mesa_count_texture_instructions(struct gl_program *prog); - -extern void -_mesa_remove_output_reads(struct gl_program *prog, gl_register_file type); - -extern void -_mesa_nop_fragment_program(struct gl_context *ctx, struct gl_fragment_program *prog); - -extern void -_mesa_nop_vertex_program(struct gl_context *ctx, struct gl_vertex_program *prog); - - -#endif /* PROGRAMOPT_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/program/register_allocate.c b/reactos/dll/opengl/mesa/src/mesa/program/register_allocate.c deleted file mode 100644 index f08c9d28d6b..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/register_allocate.c +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: - * Eric Anholt - * - */ - -/** @file register_allocate.c - * - * Graph-coloring register allocator. - * - * The basic idea of graph coloring is to make a node in a graph for - * every thing that needs a register (color) number assigned, and make - * edges in the graph between nodes that interfere (can't be allocated - * to the same register at the same time). - * - * During the "simplify" process, any any node with fewer edges than - * there are registers means that that edge can get assigned a - * register regardless of what its neighbors choose, so that node is - * pushed on a stack and removed (with its edges) from the graph. - * That likely causes other nodes to become trivially colorable as well. - * - * Then during the "select" process, nodes are popped off of that - * stack, their edges restored, and assigned a color different from - * their neighbors. Because they were pushed on the stack only when - * they were trivially colorable, any color chosen won't interfere - * with the registers to be popped later. - * - * The downside to most graph coloring is that real hardware often has - * limitations, like registers that need to be allocated to a node in - * pairs, or aligned on some boundary. This implementation follows - * the paper "Retargetable Graph-Coloring Register Allocation for - * Irregular Architectures" by Johan Runeson and Sven-Olof Nyström. - * - * In this system, there are register classes each containing various - * registers, and registers may interfere with other registers. For - * example, one might have a class of base registers, and a class of - * aligned register pairs that would each interfere with their pair of - * the base registers. Each node has a register class it needs to be - * assigned to. Define p(B) to be the size of register class B, and - * q(B,C) to be the number of registers in B that the worst choice - * register in C could conflict with. Then, this system replaces the - * basic graph coloring test of "fewer edges from this node than there - * are registers" with "For this node of class B, the sum of q(B,C) - * for each neighbor node of class C is less than pB". - * - * A nice feature of the pq test is that q(B,C) can be computed once - * up front and stored in a 2-dimensional array, so that the cost of - * coloring a node is constant with the number of registers. We do - * this during ra_set_finalize(). - */ - -#include - -#include "main/imports.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "register_allocate.h" - -#define NO_REG ~0 - -struct ra_reg { - GLboolean *conflicts; - unsigned int *conflict_list; - unsigned int conflict_list_size; - unsigned int num_conflicts; -}; - -struct ra_regs { - struct ra_reg *regs; - unsigned int count; - - struct ra_class **classes; - unsigned int class_count; -}; - -struct ra_class { - GLboolean *regs; - - /** - * p(B) in Runeson/Nyström paper. - * - * This is "how many regs are in the set." - */ - unsigned int p; - - /** - * q(B,C) (indexed by C, B is this register class) in - * Runeson/Nyström paper. This is "how many registers of B could - * the worst choice register from C conflict with". - */ - unsigned int *q; -}; - -struct ra_node { - /** @{ - * - * List of which nodes this node interferes with. This should be - * symmetric with the other node. - */ - GLboolean *adjacency; - unsigned int *adjacency_list; - unsigned int adjacency_count; - /** @} */ - - unsigned int class; - - /* Register, if assigned, or NO_REG. */ - unsigned int reg; - - /** - * Set when the node is in the trivially colorable stack. When - * set, the adjacency to this node is ignored, to implement the - * "remove the edge from the graph" in simplification without - * having to actually modify the adjacency_list. - */ - GLboolean in_stack; - - /* For an implementation that needs register spilling, this is the - * approximate cost of spilling this node. - */ - float spill_cost; -}; - -struct ra_graph { - struct ra_regs *regs; - /** - * the variables that need register allocation. - */ - struct ra_node *nodes; - unsigned int count; /**< count of nodes. */ - - unsigned int *stack; - unsigned int stack_count; -}; - -/** - * Creates a set of registers for the allocator. - * - * mem_ctx is a ralloc context for the allocator. The reg set may be freed - * using ralloc_free(). - */ -struct ra_regs * -ra_alloc_reg_set(void *mem_ctx, unsigned int count) -{ - unsigned int i; - struct ra_regs *regs; - - regs = rzalloc(mem_ctx, struct ra_regs); - regs->count = count; - regs->regs = rzalloc_array(regs, struct ra_reg, count); - - for (i = 0; i < count; i++) { - regs->regs[i].conflicts = rzalloc_array(regs->regs, GLboolean, count); - regs->regs[i].conflicts[i] = GL_TRUE; - - regs->regs[i].conflict_list = ralloc_array(regs->regs, unsigned int, 4); - regs->regs[i].conflict_list_size = 4; - regs->regs[i].conflict_list[0] = i; - regs->regs[i].num_conflicts = 1; - } - - return regs; -} - -static void -ra_add_conflict_list(struct ra_regs *regs, unsigned int r1, unsigned int r2) -{ - struct ra_reg *reg1 = ®s->regs[r1]; - - if (reg1->conflict_list_size == reg1->num_conflicts) { - reg1->conflict_list_size *= 2; - reg1->conflict_list = reralloc(regs->regs, reg1->conflict_list, - unsigned int, reg1->conflict_list_size); - } - reg1->conflict_list[reg1->num_conflicts++] = r2; - reg1->conflicts[r2] = GL_TRUE; -} - -void -ra_add_reg_conflict(struct ra_regs *regs, unsigned int r1, unsigned int r2) -{ - if (!regs->regs[r1].conflicts[r2]) { - ra_add_conflict_list(regs, r1, r2); - ra_add_conflict_list(regs, r2, r1); - } -} - -/** - * Adds a conflict between base_reg and reg, and also between reg and - * anything that base_reg conflicts with. - * - * This can simplify code for setting up multiple register classes - * which are aggregates of some base hardware registers, compared to - * explicitly using ra_add_reg_conflict. - */ -void -ra_add_transitive_reg_conflict(struct ra_regs *regs, - unsigned int base_reg, unsigned int reg) -{ - int i; - - ra_add_reg_conflict(regs, reg, base_reg); - - for (i = 0; i < regs->regs[base_reg].num_conflicts; i++) { - ra_add_reg_conflict(regs, reg, regs->regs[base_reg].conflict_list[i]); - } -} - -unsigned int -ra_alloc_reg_class(struct ra_regs *regs) -{ - struct ra_class *class; - - regs->classes = reralloc(regs->regs, regs->classes, struct ra_class *, - regs->class_count + 1); - - class = rzalloc(regs, struct ra_class); - regs->classes[regs->class_count] = class; - - class->regs = rzalloc_array(class, GLboolean, regs->count); - - return regs->class_count++; -} - -void -ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r) -{ - struct ra_class *class = regs->classes[c]; - - class->regs[r] = GL_TRUE; - class->p++; -} - -/** - * Must be called after all conflicts and register classes have been - * set up and before the register set is used for allocation. - */ -void -ra_set_finalize(struct ra_regs *regs) -{ - unsigned int b, c; - - for (b = 0; b < regs->class_count; b++) { - regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count); - } - - /* Compute, for each class B and C, how many regs of B an - * allocation to C could conflict with. - */ - for (b = 0; b < regs->class_count; b++) { - for (c = 0; c < regs->class_count; c++) { - unsigned int rc; - int max_conflicts = 0; - - for (rc = 0; rc < regs->count; rc++) { - int conflicts = 0; - int i; - - if (!regs->classes[c]->regs[rc]) - continue; - - for (i = 0; i < regs->regs[rc].num_conflicts; i++) { - unsigned int rb = regs->regs[rc].conflict_list[i]; - if (regs->classes[b]->regs[rb]) - conflicts++; - } - max_conflicts = MAX2(max_conflicts, conflicts); - } - regs->classes[b]->q[c] = max_conflicts; - } - } -} - -static void -ra_add_node_adjacency(struct ra_graph *g, unsigned int n1, unsigned int n2) -{ - g->nodes[n1].adjacency[n2] = GL_TRUE; - g->nodes[n1].adjacency_list[g->nodes[n1].adjacency_count] = n2; - g->nodes[n1].adjacency_count++; -} - -struct ra_graph * -ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count) -{ - struct ra_graph *g; - unsigned int i; - - g = rzalloc(regs, struct ra_graph); - g->regs = regs; - g->nodes = rzalloc_array(g, struct ra_node, count); - g->count = count; - - g->stack = rzalloc_array(g, unsigned int, count); - - for (i = 0; i < count; i++) { - g->nodes[i].adjacency = rzalloc_array(g, GLboolean, count); - g->nodes[i].adjacency_list = ralloc_array(g, unsigned int, count); - g->nodes[i].adjacency_count = 0; - ra_add_node_adjacency(g, i, i); - g->nodes[i].reg = NO_REG; - } - - return g; -} - -void -ra_set_node_class(struct ra_graph *g, - unsigned int n, unsigned int class) -{ - g->nodes[n].class = class; -} - -void -ra_add_node_interference(struct ra_graph *g, - unsigned int n1, unsigned int n2) -{ - if (!g->nodes[n1].adjacency[n2]) { - ra_add_node_adjacency(g, n1, n2); - ra_add_node_adjacency(g, n2, n1); - } -} - -static GLboolean pq_test(struct ra_graph *g, unsigned int n) -{ - unsigned int j; - unsigned int q = 0; - int n_class = g->nodes[n].class; - - for (j = 0; j < g->nodes[n].adjacency_count; j++) { - unsigned int n2 = g->nodes[n].adjacency_list[j]; - unsigned int n2_class = g->nodes[n2].class; - - if (n != n2 && !g->nodes[n2].in_stack) { - q += g->regs->classes[n_class]->q[n2_class]; - } - } - - return q < g->regs->classes[n_class]->p; -} - -/** - * Simplifies the interference graph by pushing all - * trivially-colorable nodes into a stack of nodes to be colored, - * removing them from the graph, and rinsing and repeating. - * - * Returns GL_TRUE if all nodes were removed from the graph. GL_FALSE - * means that either spilling will be required, or optimistic coloring - * should be applied. - */ -GLboolean -ra_simplify(struct ra_graph *g) -{ - GLboolean progress = GL_TRUE; - int i; - - while (progress) { - progress = GL_FALSE; - - for (i = g->count - 1; i >= 0; i--) { - if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG) - continue; - - if (pq_test(g, i)) { - g->stack[g->stack_count] = i; - g->stack_count++; - g->nodes[i].in_stack = GL_TRUE; - progress = GL_TRUE; - } - } - } - - for (i = 0; i < g->count; i++) { - if (!g->nodes[i].in_stack) - return GL_FALSE; - } - - return GL_TRUE; -} - -/** - * Pops nodes from the stack back into the graph, coloring them with - * registers as they go. - * - * If all nodes were trivially colorable, then this must succeed. If - * not (optimistic coloring), then it may return GL_FALSE; - */ -GLboolean -ra_select(struct ra_graph *g) -{ - int i; - - while (g->stack_count != 0) { - unsigned int r; - int n = g->stack[g->stack_count - 1]; - struct ra_class *c = g->regs->classes[g->nodes[n].class]; - - /* Find the lowest-numbered reg which is not used by a member - * of the graph adjacent to us. - */ - for (r = 0; r < g->regs->count; r++) { - if (!c->regs[r]) - continue; - - /* Check if any of our neighbors conflict with this register choice. */ - for (i = 0; i < g->nodes[n].adjacency_count; i++) { - unsigned int n2 = g->nodes[n].adjacency_list[i]; - - if (!g->nodes[n2].in_stack && - g->regs->regs[r].conflicts[g->nodes[n2].reg]) { - break; - } - } - if (i == g->nodes[n].adjacency_count) - break; - } - if (r == g->regs->count) - return GL_FALSE; - - g->nodes[n].reg = r; - g->nodes[n].in_stack = GL_FALSE; - g->stack_count--; - } - - return GL_TRUE; -} - -/** - * Optimistic register coloring: Just push the remaining nodes - * on the stack. They'll be colored first in ra_select(), and - * if they succeed then the locally-colorable nodes are still - * locally-colorable and the rest of the register allocation - * will succeed. - */ -void -ra_optimistic_color(struct ra_graph *g) -{ - unsigned int i; - - for (i = 0; i < g->count; i++) { - if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG) - continue; - - g->stack[g->stack_count] = i; - g->stack_count++; - g->nodes[i].in_stack = GL_TRUE; - } -} - -GLboolean -ra_allocate_no_spills(struct ra_graph *g) -{ - if (!ra_simplify(g)) { - ra_optimistic_color(g); - } - return ra_select(g); -} - -unsigned int -ra_get_node_reg(struct ra_graph *g, unsigned int n) -{ - return g->nodes[n].reg; -} - -/** - * Forces a node to a specific register. This can be used to avoid - * creating a register class containing one node when handling data - * that must live in a fixed location and is known to not conflict - * with other forced register assignment (as is common with shader - * input data). These nodes do not end up in the stack during - * ra_simplify(), and thus at ra_select() time it is as if they were - * the first popped off the stack and assigned their fixed locations. - * - * Must be called before ra_simplify(). - */ -void -ra_set_node_reg(struct ra_graph *g, unsigned int n, unsigned int reg) -{ - g->nodes[n].reg = reg; - g->nodes[n].in_stack = GL_FALSE; -} - -static float -ra_get_spill_benefit(struct ra_graph *g, unsigned int n) -{ - int j; - float benefit = 0; - int n_class = g->nodes[n].class; - - /* Define the benefit of eliminating an interference between n, n2 - * through spilling as q(C, B) / p(C). This is similar to the - * "count number of edges" approach of traditional graph coloring, - * but takes classes into account. - */ - for (j = 0; j < g->nodes[n].adjacency_count; j++) { - unsigned int n2 = g->nodes[n].adjacency_list[j]; - if (n != n2) { - unsigned int n2_class = g->nodes[n2].class; - benefit += ((float)g->regs->classes[n_class]->q[n2_class] / - g->regs->classes[n_class]->p); - } - } - - return benefit; -} - -/** - * Returns a node number to be spilled according to the cost/benefit using - * the pq test, or -1 if there are no spillable nodes. - */ -int -ra_get_best_spill_node(struct ra_graph *g) -{ - unsigned int best_node = -1; - unsigned int best_benefit = 0.0; - unsigned int n; - - for (n = 0; n < g->count; n++) { - float cost = g->nodes[n].spill_cost; - float benefit; - - if (cost <= 0.0) - continue; - - benefit = ra_get_spill_benefit(g, n); - - if (benefit / cost > best_benefit) { - best_benefit = benefit / cost; - best_node = n; - } - } - - return best_node; -} - -/** - * Only nodes with a spill cost set (cost != 0.0) will be considered - * for register spilling. - */ -void -ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost) -{ - g->nodes[n].spill_cost = cost; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/register_allocate.h b/reactos/dll/opengl/mesa/src/mesa/program/register_allocate.h deleted file mode 100644 index 00b851ec21b..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/register_allocate.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - * - * Authors: - * Eric Anholt - * - */ - -struct ra_class; -struct ra_regs; - -/* @{ - * Register set setup. - * - * This should be done once at backend initializaion, as - * ra_set_finalize is O(r^2*c^2). The registers may be virtual - * registers, such as aligned register pairs that conflict with the - * two real registers from which they are composed. - */ -struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count); -unsigned int ra_alloc_reg_class(struct ra_regs *regs); -void ra_add_reg_conflict(struct ra_regs *regs, - unsigned int r1, unsigned int r2); -void ra_add_transitive_reg_conflict(struct ra_regs *regs, - unsigned int base_reg, unsigned int reg); -void ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int reg); -void ra_set_finalize(struct ra_regs *regs); -/** @} */ - -/** @{ Interference graph setup. - * - * Each interference graph node is a virtual variable in the IL. It - * is up to the user to ra_set_node_class() for the virtual variable, - * and compute live ranges and ra_node_interfere() between conflicting - * live ranges. - */ -struct ra_graph *ra_alloc_interference_graph(struct ra_regs *regs, - unsigned int count); -void ra_set_node_class(struct ra_graph *g, unsigned int n, unsigned int c); -void ra_add_node_interference(struct ra_graph *g, - unsigned int n1, unsigned int n2); -/** @} */ - -/** @{ Graph-coloring register allocation */ -GLboolean ra_simplify(struct ra_graph *g); -void ra_optimistic_color(struct ra_graph *g); -GLboolean ra_select(struct ra_graph *g); -GLboolean ra_allocate_no_spills(struct ra_graph *g); - -unsigned int ra_get_node_reg(struct ra_graph *g, unsigned int n); -void ra_set_node_reg(struct ra_graph * g, unsigned int n, unsigned int reg); -void ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost); -int ra_get_best_spill_node(struct ra_graph *g); -/** @} */ - diff --git a/reactos/dll/opengl/mesa/src/mesa/program/sampler.cpp b/reactos/dll/opengl/mesa/src/mesa/program/sampler.cpp deleted file mode 100644 index e3641aaa958..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/sampler.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "ir.h" -#include "glsl_types.h" -#include "ir_visitor.h" -#include "../glsl/program.h" -#include "program/hash_table.h" -#include "ir_uniform.h" - -extern "C" { -#include "main/compiler.h" -#include "main/mtypes.h" -#include "program/prog_parameter.h" -} - -class get_sampler_name : public ir_hierarchical_visitor -{ -public: - get_sampler_name(ir_dereference *last, - struct gl_shader_program *shader_program) - { - this->mem_ctx = ralloc_context(NULL); - this->shader_program = shader_program; - this->name = NULL; - this->offset = 0; - this->last = last; - } - - ~get_sampler_name() - { - ralloc_free(this->mem_ctx); - } - - virtual ir_visitor_status visit(ir_dereference_variable *ir) - { - this->name = ir->var->name; - return visit_continue; - } - - virtual ir_visitor_status visit_leave(ir_dereference_record *ir) - { - this->name = ralloc_asprintf(mem_ctx, "%s.%s", name, ir->field); - return visit_continue; - } - - virtual ir_visitor_status visit_leave(ir_dereference_array *ir) - { - ir_constant *index = ir->array_index->as_constant(); - int i; - - if (index) { - i = index->value.i[0]; - } else { - /* GLSL 1.10 and 1.20 allowed variable sampler array indices, - * while GLSL 1.30 requires that the array indices be - * constant integer expressions. We don't expect any driver - * to actually work with a really variable array index, so - * all that would work would be an unrolled loop counter that ends - * up being constant above. - */ - ralloc_strcat(&shader_program->InfoLog, - "warning: Variable sampler array index unsupported.\n" - "This feature of the language was removed in GLSL 1.20 " - "and is unlikely to be supported for 1.10 in Mesa.\n"); - i = 0; - } - if (ir != last) { - this->name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i); - } else { - offset = i; - } - return visit_continue; - } - - struct gl_shader_program *shader_program; - const char *name; - void *mem_ctx; - int offset; - ir_dereference *last; -}; - -extern "C" { -int -_mesa_get_sampler_uniform_value(class ir_dereference *sampler, - struct gl_shader_program *shader_program, - const struct gl_program *prog) -{ - get_sampler_name getname(sampler, shader_program); - - sampler->accept(&getname); - - unsigned location; - if (!shader_program->UniformHash->get(location, getname.name)) { - linker_error(shader_program, - "failed to find sampler named %s.\n", getname.name); - return 0; - } - - return shader_program->UniformStorage[location].sampler + getname.offset; -} -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/sampler.h b/reactos/dll/opengl/mesa/src/mesa/program/sampler.h deleted file mode 100644 index 22467e99020..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/sampler.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. - * Copyright (C) 2008 VMware, Inc. All Rights Reserved. - * Copyright © 2010 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -int -_mesa_get_sampler_uniform_value(class ir_dereference *sampler, - struct gl_shader_program *shader_program, - const struct gl_program *prog); diff --git a/reactos/dll/opengl/mesa/src/mesa/program/string_to_uint_map.cpp b/reactos/dll/opengl/mesa/src/mesa/program/string_to_uint_map.cpp deleted file mode 100644 index cfa73abe089..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/string_to_uint_map.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/** - * \file string_to_uint_map.cpp - * \brief Dumb wrapprs so that C code can create and destroy maps. - * - * \author Ian Romanick - */ -#include "hash_table.h" - -extern "C" struct string_to_uint_map * -string_to_uint_map_ctor() -{ - return new string_to_uint_map; -} - -extern "C" void -string_to_uint_map_dtor(struct string_to_uint_map *map) -{ - delete map; -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/symbol_table.c b/reactos/dll/opengl/mesa/src/mesa/program/symbol_table.c deleted file mode 100644 index 4f6f31f3109..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/symbol_table.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#include "main/imports.h" -#include "symbol_table.h" -#include "hash_table.h" - -struct symbol { - /** - * Link to the next symbol in the table with the same name - * - * The linked list of symbols with the same name is ordered by scope - * from inner-most to outer-most. - */ - struct symbol *next_with_same_name; - - - /** - * Link to the next symbol in the table with the same scope - * - * The linked list of symbols with the same scope is unordered. Symbols - * in this list my have unique names. - */ - struct symbol *next_with_same_scope; - - - /** - * Header information for the list of symbols with the same name. - */ - struct symbol_header *hdr; - - - /** - * Name space of the symbol - * - * Name space are arbitrary user assigned integers. No two symbols can - * exist in the same name space at the same scope level. - */ - int name_space; - - /** Scope depth where this symbol was defined. */ - unsigned depth; - - /** - * Arbitrary user supplied data. - */ - void *data; -}; - - -/** - */ -struct symbol_header { - /** Linkage in list of all headers in a given symbol table. */ - struct symbol_header *next; - - /** Symbol name. */ - char *name; - - /** Linked list of symbols with the same name. */ - struct symbol *symbols; -}; - - -/** - * Element of the scope stack. - */ -struct scope_level { - /** Link to next (inner) scope level. */ - struct scope_level *next; - - /** Linked list of symbols with the same scope. */ - struct symbol *symbols; -}; - - -/** - * - */ -struct _mesa_symbol_table { - /** Hash table containing all symbols in the symbol table. */ - struct hash_table *ht; - - /** Top of scope stack. */ - struct scope_level *current_scope; - - /** List of all symbol headers in the table. */ - struct symbol_header *hdr; - - /** Current scope depth. */ - unsigned depth; -}; - - -struct _mesa_symbol_table_iterator { - /** - * Name space of symbols returned by this iterator. - */ - int name_space; - - - /** - * Currently iterated symbol - * - * The next call to \c _mesa_symbol_table_iterator_get will return this - * value. It will also update this value to the value that should be - * returned by the next call. - */ - struct symbol *curr; -}; - - -static void -check_symbol_table(struct _mesa_symbol_table *table) -{ -#if 1 - struct scope_level *scope; - - for (scope = table->current_scope; scope != NULL; scope = scope->next) { - struct symbol *sym; - - for (sym = scope->symbols - ; sym != NULL - ; sym = sym->next_with_same_name) { - const struct symbol_header *const hdr = sym->hdr; - struct symbol *sym2; - - for (sym2 = hdr->symbols - ; sym2 != NULL - ; sym2 = sym2->next_with_same_name) { - assert(sym2->hdr == hdr); - } - } - } -#endif -} - -void -_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table) -{ - struct scope_level *const scope = table->current_scope; - struct symbol *sym = scope->symbols; - - table->current_scope = scope->next; - table->depth--; - - free(scope); - - while (sym != NULL) { - struct symbol *const next = sym->next_with_same_scope; - struct symbol_header *const hdr = sym->hdr; - - assert(hdr->symbols == sym); - - hdr->symbols = sym->next_with_same_name; - - free(sym); - - sym = next; - } - - check_symbol_table(table); -} - - -void -_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table) -{ - struct scope_level *const scope = calloc(1, sizeof(*scope)); - - scope->next = table->current_scope; - table->current_scope = scope; - table->depth++; -} - - -static struct symbol_header * -find_symbol(struct _mesa_symbol_table *table, const char *name) -{ - return (struct symbol_header *) hash_table_find(table->ht, name); -} - - -struct _mesa_symbol_table_iterator * -_mesa_symbol_table_iterator_ctor(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct _mesa_symbol_table_iterator *iter = calloc(1, sizeof(*iter)); - struct symbol_header *const hdr = find_symbol(table, name); - - iter->name_space = name_space; - - if (hdr != NULL) { - struct symbol *sym; - - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - iter->curr = sym; - break; - } - } - } - - return iter; -} - - -void -_mesa_symbol_table_iterator_dtor(struct _mesa_symbol_table_iterator *iter) -{ - free(iter); -} - - -void * -_mesa_symbol_table_iterator_get(struct _mesa_symbol_table_iterator *iter) -{ - return (iter->curr == NULL) ? NULL : iter->curr->data; -} - - -int -_mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter) -{ - struct symbol_header *hdr; - - if (iter->curr == NULL) { - return 0; - } - - hdr = iter->curr->hdr; - iter->curr = iter->curr->next_with_same_name; - - while (iter->curr != NULL) { - assert(iter->curr->hdr == hdr); - (void)hdr; - - if ((iter->name_space == -1) - || (iter->curr->name_space == iter->name_space)) { - return 1; - } - - iter->curr = iter->curr->next_with_same_name; - } - - return 0; -} - - -/** - * Determine the scope "distance" of a symbol from the current scope - * - * \return - * A non-negative number for the number of scopes between the current scope - * and the scope where a symbol was defined. A value of zero means the current - * scope. A negative number if the symbol does not exist. - */ -int -_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct symbol_header *const hdr = find_symbol(table, name); - struct symbol *sym; - - if (hdr != NULL) { - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - assert(sym->depth <= table->depth); - return sym->depth - table->depth; - } - } - } - - return -1; -} - - -void * -_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, - int name_space, const char *name) -{ - struct symbol_header *const hdr = find_symbol(table, name); - - if (hdr != NULL) { - struct symbol *sym; - - - for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) { - assert(sym->hdr == hdr); - - if ((name_space == -1) || (sym->name_space == name_space)) { - return sym->data; - } - } - } - - return NULL; -} - - -int -_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table, - int name_space, const char *name, - void *declaration) -{ - struct symbol_header *hdr; - struct symbol *sym; - - check_symbol_table(table); - - hdr = find_symbol(table, name); - - check_symbol_table(table); - - if (hdr == NULL) { - hdr = calloc(1, sizeof(*hdr)); - hdr->name = strdup(name); - - hash_table_insert(table->ht, hdr, hdr->name); - hdr->next = table->hdr; - table->hdr = hdr; - } - - check_symbol_table(table); - - /* If the symbol already exists in this namespace at this scope, it cannot - * be added to the table. - */ - for (sym = hdr->symbols - ; (sym != NULL) && (sym->name_space != name_space) - ; sym = sym->next_with_same_name) { - /* empty */ - } - - if (sym && (sym->depth == table->depth)) - return -1; - - sym = calloc(1, sizeof(*sym)); - sym->next_with_same_name = hdr->symbols; - sym->next_with_same_scope = table->current_scope->symbols; - sym->hdr = hdr; - sym->name_space = name_space; - sym->data = declaration; - sym->depth = table->depth; - - assert(sym->hdr == hdr); - - hdr->symbols = sym; - table->current_scope->symbols = sym; - - check_symbol_table(table); - return 0; -} - - -int -_mesa_symbol_table_add_global_symbol(struct _mesa_symbol_table *table, - int name_space, const char *name, - void *declaration) -{ - struct symbol_header *hdr; - struct symbol *sym; - struct symbol *curr; - struct scope_level *top_scope; - - check_symbol_table(table); - - hdr = find_symbol(table, name); - - check_symbol_table(table); - - if (hdr == NULL) { - hdr = calloc(1, sizeof(*hdr)); - hdr->name = strdup(name); - - hash_table_insert(table->ht, hdr, hdr->name); - hdr->next = table->hdr; - table->hdr = hdr; - } - - check_symbol_table(table); - - /* If the symbol already exists in this namespace at this scope, it cannot - * be added to the table. - */ - for (sym = hdr->symbols - ; (sym != NULL) && (sym->name_space != name_space) - ; sym = sym->next_with_same_name) { - /* empty */ - } - - if (sym && sym->depth == 0) - return -1; - - /* Find the top-level scope */ - for (top_scope = table->current_scope - ; top_scope->next != NULL - ; top_scope = top_scope->next) { - /* empty */ - } - - sym = calloc(1, sizeof(*sym)); - sym->next_with_same_scope = top_scope->symbols; - sym->hdr = hdr; - sym->name_space = name_space; - sym->data = declaration; - - assert(sym->hdr == hdr); - - /* Since next_with_same_name is ordered by scope, we need to append the - * new symbol to the _end_ of the list. - */ - if (hdr->symbols == NULL) { - hdr->symbols = sym; - } else { - for (curr = hdr->symbols - ; curr->next_with_same_name != NULL - ; curr = curr->next_with_same_name) { - /* empty */ - } - curr->next_with_same_name = sym; - } - top_scope->symbols = sym; - - check_symbol_table(table); - return 0; -} - - - -struct _mesa_symbol_table * -_mesa_symbol_table_ctor(void) -{ - struct _mesa_symbol_table *table = calloc(1, sizeof(*table)); - - if (table != NULL) { - table->ht = hash_table_ctor(32, hash_table_string_hash, - hash_table_string_compare); - - _mesa_symbol_table_push_scope(table); - } - - return table; -} - - -void -_mesa_symbol_table_dtor(struct _mesa_symbol_table *table) -{ - struct symbol_header *hdr; - struct symbol_header *next; - - while (table->current_scope != NULL) { - _mesa_symbol_table_pop_scope(table); - } - - for (hdr = table->hdr; hdr != NULL; hdr = next) { - next = hdr->next; - free(hdr->name); - free(hdr); - } - - hash_table_dtor(table->ht); - free(table); -} diff --git a/reactos/dll/opengl/mesa/src/mesa/program/symbol_table.h b/reactos/dll/opengl/mesa/src/mesa/program/symbol_table.h deleted file mode 100644 index f9d91649bbc..00000000000 --- a/reactos/dll/opengl/mesa/src/mesa/program/symbol_table.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2008 Intel Corporation - * - * 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 (including the next - * paragraph) 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 - * THE AUTHORS OR COPYRIGHT HOLDERS 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 MESA_SYMBOL_TABLE_H -#define MESA_SYMBOL_TABLE_H - -struct _mesa_symbol_table; -struct _mesa_symbol_table_iterator; - -extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table); - -extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table); - -extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, - int name_space, const char *name, void *declaration); - -extern int _mesa_symbol_table_add_global_symbol( - struct _mesa_symbol_table *symtab, int name_space, const char *name, - void *declaration); - -extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table, - int name_space, const char *name); - -extern void *_mesa_symbol_table_find_symbol( - struct _mesa_symbol_table *symtab, int name_space, const char *name); - -extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void); - -extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *); - -extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor( - struct _mesa_symbol_table *table, int name_space, const char *name); - -extern void _mesa_symbol_table_iterator_dtor( - struct _mesa_symbol_table_iterator *); - -extern void *_mesa_symbol_table_iterator_get( - struct _mesa_symbol_table_iterator *iter); - -extern int _mesa_symbol_table_iterator_next( - struct _mesa_symbol_table_iterator *iter); - -#endif /* MESA_SYMBOL_TABLE_H */ diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_aaline.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_aaline.c index 4aaf491adb8..ba21990a59a 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_aaline.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_aaline.c @@ -478,7 +478,7 @@ _swrast_choose_aa_line_function(struct gl_context *ctx) ASSERT(ctx->Line.SmoothFlag); - if (ctx->Texture._EnabledCoordUnits != 0 + if (ctx->Texture._EnabledCoord || (ctx->Light.Enabled && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) || ctx->Fog.ColorSumEnabled diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_aalinetemp.h b/reactos/dll/opengl/mesa/src/mesa/swrast/s_aalinetemp.h index 4f4f7af5cdc..7a8ab7a4412 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_aalinetemp.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_aalinetemp.h @@ -66,15 +66,14 @@ NAME(plot)(struct gl_context *ctx, struct LineInfo *line, int ix, int iy) #if defined(DO_ATTRIBS) ATTRIB_LOOP_BEGIN GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; - if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) { + if (attr == FRAG_ATTRIB_TEX) { /* texcoord w/ divide by Q */ - const GLuint unit = attr - FRAG_ATTRIB_TEX0; const GLfloat invQ = solve_plane_recip(fx, fy, line->attrPlane[attr][3]); GLuint c; for (c = 0; c < 3; c++) { attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invQ; } - line->span.array->lambda[unit][i] + line->span.array->lambda[i] = compute_lambda(line->attrPlane[attr][0], line->attrPlane[attr][1], invQ, line->texWidth[attr], line->texHeight[attr]); @@ -175,9 +174,8 @@ NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1) } } line.span.arrayAttribs |= BITFIELD64_BIT(attr); - if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) { - const GLuint u = attr - FRAG_ATTRIB_TEX0; - const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; + if (attr == FRAG_ATTRIB_TEX) { + const struct gl_texture_object *obj = ctx->Texture.Unit._Current; const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; line.texWidth[attr] = (GLfloat) texImage->Width; line.texHeight[attr] = (GLfloat) texImage->Height; diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_aatriangle.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_aatriangle.c index 3bbdd5263a2..d19d6781c8f 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_aatriangle.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_aatriangle.c @@ -298,7 +298,7 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx) ASSERT(ctx->Polygon.SmoothFlag); - if (ctx->Texture._EnabledCoordUnits != 0 + if (ctx->Texture._EnabledCoord || swrast->_FogEnabled || _mesa_need_secondary_color(ctx)) { SWRAST_CONTEXT(ctx)->Triangle = general_aa_tri; diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.c index 7847e2c94a9..17ecc7e7c10 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.c @@ -31,8 +31,6 @@ #include "main/colormac.h" #include "main/mtypes.h" #include "main/teximage.h" -#include "program/prog_parameter.h" -#include "program/prog_statevars.h" #include "swrast.h" #include "s_blend.h" #include "s_context.h" @@ -70,7 +68,7 @@ _swrast_update_rasterflags( struct gl_context *ctx ) } if (ctx->Color.ColorLogicOpEnabled) rasterMask |= LOGIC_OP_BIT; - if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT; + if (ctx->Texture._Enabled) rasterMask |= TEXTURE_BIT; if ( ctx->Viewport.X < 0 || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width || ctx->Viewport.Y < 0 @@ -155,23 +153,20 @@ static void _swrast_update_texture_env( struct gl_context *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLuint i; + const struct gl_tex_env_combine_state *combine = + ctx->Texture.Unit._CurrentCombine; + GLuint term; swrast->_TextureCombinePrimary = GL_FALSE; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - const struct gl_tex_env_combine_state *combine = - ctx->Texture.Unit[i]._CurrentCombine; - GLuint term; - for (term = 0; term < combine->_NumArgsRGB; term++) { - if (combine->SourceRGB[term] == GL_PRIMARY_COLOR) { - swrast->_TextureCombinePrimary = GL_TRUE; - return; - } - if (combine->SourceA[term] == GL_PRIMARY_COLOR) { - swrast->_TextureCombinePrimary = GL_TRUE; - return; - } + for (term = 0; term < combine->_NumArgsRGB; term++) { + if (combine->SourceRGB[term] == GL_PRIMARY_COLOR) { + swrast->_TextureCombinePrimary = GL_TRUE; + return; + } + if (combine->SourceA[term] == GL_PRIMARY_COLOR) { + swrast->_TextureCombinePrimary = GL_TRUE; + return; } } } @@ -203,11 +198,6 @@ static void _swrast_update_fog_state( struct gl_context *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; - - assert((fp == NULL) || - (fp->Base.Target == GL_FRAGMENT_PROGRAM_ARB) || - (fp->Base.Target == GL_FRAGMENT_PROGRAM_NV)); /* determine if fog is needed, and if so, which fog mode */ swrast->_FogEnabled = ctx->Fog.Enabled; @@ -226,13 +216,11 @@ _swrast_update_specular_vertex_add(struct gl_context *ctx) (ctx->Light.Enabled && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR); - swrast->SpecularVertexAdd = (separateSpecular - && ctx->Texture._EnabledUnits == 0x0); + swrast->SpecularVertexAdd = (separateSpecular && !ctx->Texture._Enabled); } #define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \ - _NEW_PROGRAM_CONSTANTS | \ _NEW_TEXTURE | \ _NEW_HINT | \ _NEW_POLYGON ) @@ -371,7 +359,6 @@ static void _swrast_invalidate_state( struct gl_context *ctx, GLbitfield new_state ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLuint i; swrast->NewState |= new_state; @@ -397,8 +384,7 @@ _swrast_invalidate_state( struct gl_context *ctx, GLbitfield new_state ) swrast->BlendFunc = _swrast_validate_blend_func; if (new_state & _SWRAST_NEW_TEXTURE_SAMPLE_FUNC) - for (i = 0 ; i < ctx->Const.MaxTextureImageUnits ; i++) - swrast->TextureSample[i] = NULL; + swrast->TextureSample = NULL; } @@ -406,21 +392,20 @@ void _swrast_update_texture_samplers(struct gl_context *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLuint u; + struct gl_texture_object *tObj; if (!swrast) return; /* pipe hack */ + + tObj = ctx->Texture.Unit._Current; - for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) { - struct gl_texture_object *tObj = ctx->Texture.Unit[u]._Current; - /* Note: If tObj is NULL, the sample function will be a simple - * function that just returns opaque black (0,0,0,1). - */ - if (tObj) { - _mesa_update_fetch_functions(tObj); - } - swrast->TextureSample[u] = _swrast_choose_texture_sample_func(ctx, tObj); + /* Note: If tObj is NULL, the sample function will be a simple + * function that just returns opaque black (0,0,0,1). + */ + if (tObj) { + _mesa_update_fetch_functions(tObj); } + swrast->TextureSample = _swrast_choose_texture_sample_func(ctx, tObj); } @@ -452,7 +437,7 @@ _swrast_update_active_attribs(struct gl_context *ctx) if (swrast->_FogEnabled) attribsMask |= FRAG_BIT_FOGC; - attribsMask |= (ctx->Texture._EnabledUnits << FRAG_ATTRIB_TEX0); + attribsMask |= ctx->Texture._Enabled << FRAG_ATTRIB_TEX; swrast->_ActiveAttribMask = attribsMask; @@ -483,20 +468,20 @@ _swrast_validate_derived( struct gl_context *ctx ) if (swrast->NewState & _NEW_POLYGON) _swrast_update_polygon( ctx ); - if (swrast->NewState & (_NEW_HINT | _NEW_PROGRAM)) + if (swrast->NewState & _NEW_HINT) _swrast_update_fog_hint( ctx ); if (swrast->NewState & _SWRAST_NEW_TEXTURE_ENV_MODE) _swrast_update_texture_env( ctx ); - if (swrast->NewState & (_NEW_FOG | _NEW_PROGRAM)) + if (swrast->NewState & _NEW_FOG) _swrast_update_fog_state( ctx ); - if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM)) { + if (swrast->NewState & _NEW_TEXTURE) { _swrast_update_texture_samplers( ctx ); } - if (swrast->NewState & (_NEW_COLOR | _NEW_PROGRAM)) + if (swrast->NewState & _NEW_COLOR) _swrast_update_deferred_texture(ctx); if (swrast->NewState & _SWRAST_NEW_RASTERMASK) @@ -505,12 +490,10 @@ _swrast_validate_derived( struct gl_context *ctx ) if (swrast->NewState & (_NEW_DEPTH | _NEW_FOG | _NEW_LIGHT | - _NEW_PROGRAM | _NEW_TEXTURE)) _swrast_update_active_attribs(ctx); if (swrast->NewState & (_NEW_FOG | - _NEW_PROGRAM | _NEW_LIGHT | _NEW_TEXTURE)) _swrast_update_specular_vertex_add(ctx); @@ -620,24 +603,6 @@ _swrast_allow_pixel_fog( struct gl_context *ctx, GLboolean value ) } -/** - * Initialize native program limits by copying the logical limits. - * See comments in init_program_limits() in context.c - */ -static void -init_program_native_limits(struct gl_program_constants *prog) -{ - prog->MaxNativeInstructions = prog->MaxInstructions; - prog->MaxNativeAluInstructions = prog->MaxAluInstructions; - prog->MaxNativeTexInstructions = prog->MaxTexInstructions; - prog->MaxNativeTexIndirections = prog->MaxTexIndirections; - prog->MaxNativeAttribs = prog->MaxAttribs; - prog->MaxNativeTemps = prog->MaxTemps; - prog->MaxNativeAddressRegs = prog->MaxAddressRegs; - prog->MaxNativeParameters = prog->MaxParameters; -} - - GLboolean _swrast_CreateContext( struct gl_context *ctx ) { @@ -678,8 +643,7 @@ _swrast_CreateContext( struct gl_context *ctx ) swrast->Driver.SpanRenderStart = _swrast_span_render_start; swrast->Driver.SpanRenderFinish = _swrast_span_render_finish; - for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) - swrast->TextureSample[i] = NULL; + swrast->TextureSample = NULL; /* SpanArrays is global and shared by all SWspan instances. However, when * using multiple threads, it is necessary to have one SpanArrays instance @@ -707,9 +671,6 @@ _swrast_CreateContext( struct gl_context *ctx ) swrast->PointSpan.facing = 0; swrast->PointSpan.array = swrast->SpanArrays; - init_program_native_limits(&ctx->Const.VertexProgram); - init_program_native_limits(&ctx->Const.FragmentProgram); - ctx->swrast_context = swrast; return GL_TRUE; @@ -816,13 +777,12 @@ _swrast_print_vertex( struct gl_context *ctx, const SWvertex *v ) v->attrib[FRAG_ATTRIB_WPOS][2], v->attrib[FRAG_ATTRIB_WPOS][3]); - for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) - if (ctx->Texture.Unit[i]._ReallyEnabled) + if (ctx->Texture.Unit._ReallyEnabled) _mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i, - v->attrib[FRAG_ATTRIB_TEX0 + i][0], - v->attrib[FRAG_ATTRIB_TEX0 + i][1], - v->attrib[FRAG_ATTRIB_TEX0 + i][2], - v->attrib[FRAG_ATTRIB_TEX0 + i][3]); + v->attrib[FRAG_ATTRIB_TEX][0], + v->attrib[FRAG_ATTRIB_TEX][1], + v->attrib[FRAG_ATTRIB_TEX][2], + v->attrib[FRAG_ATTRIB_TEX][3]); #if CHAN_TYPE == GL_FLOAT _mesa_debug(ctx, "color %f %f %f %f\n", diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.h b/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.h index 7e2a9b7d98d..cb71716c04d 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_context.h @@ -45,7 +45,6 @@ #include "main/compiler.h" #include "main/mtypes.h" -#include "program/prog_execute.h" #include "swrast.h" #include "s_span.h" @@ -99,7 +98,6 @@ typedef void (*validate_texture_image_func)(struct gl_context *ctx, _NEW_COLOR| \ _NEW_DEPTH| \ _NEW_FOG| \ - _NEW_PROGRAM| \ _NEW_STENCIL| \ _NEW_TEXTURE| \ _NEW_VIEWPORT| \ @@ -290,7 +288,7 @@ typedef struct /** Internal hooks, kept up to date by the same mechanism as above. */ blend_func BlendFunc; - texture_sample_func TextureSample[MAX_TEXTURE_IMAGE_UNITS]; + texture_sample_func TextureSample; /** Buffer for saving the sampled texture colors. * Needed for GL_ARB_texture_env_crossbar implementation. @@ -299,9 +297,6 @@ typedef struct validate_texture_image_func ValidateTextureImage; - /** State used during execution of fragment programs */ - struct gl_program_machine FragProgMachine; - } SWcontext; diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_drawpix.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_drawpix.c index f287e44f4e9..b2cbf6a7dfa 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_drawpix.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_drawpix.c @@ -202,7 +202,7 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y, return GL_TRUE; /* no-op */ if ((swrast->_RasterMask & ~CLIP_BIT) || - ctx->Texture._EnabledCoordUnits || + ctx->Texture._EnabledCoord || userUnpack->SwapBytes || ctx->Pixel.ZoomX != 1.0f || fabsf(ctx->Pixel.ZoomY) != 1.0f || @@ -504,17 +504,6 @@ _swrast_DrawPixels( struct gl_context *ctx, const GLvoid *pixels ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLboolean save_vp_override = ctx->VertexProgram._Overriden; - - /* We are creating fragments directly, without going through vertex - * programs. - * - * This override flag tells the fragment processing code that its input - * comes from a non-standard source, and it may therefore not rely on - * optimizations that assume e.g. constant color if there is no color - * vertex array. - */ - _mesa_set_vp_override(ctx, GL_TRUE); if (ctx->NewState) _mesa_update_state(ctx); @@ -524,7 +513,6 @@ _swrast_DrawPixels( struct gl_context *ctx, pixels = _mesa_map_pbo_source(ctx, unpack, pixels); if (!pixels) { - _mesa_set_vp_override(ctx, save_vp_override); return; } @@ -547,7 +535,5 @@ _swrast_DrawPixels( struct gl_context *ctx, draw_rgba_pixels(ctx, x, y, width, height, format, type, unpack, pixels); } - _mesa_set_vp_override(ctx, save_vp_override); - _mesa_unmap_pbo_source(ctx, unpack); } diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_feedback.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_feedback.c index 00f92d463c3..59269b4dce3 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_feedback.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_feedback.c @@ -37,7 +37,7 @@ static void feedback_vertex(struct gl_context * ctx, const SWvertex * v, const SWvertex * pv) { GLfloat win[4]; - const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX0]; + const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX]; const GLfloat *color = v->attrib[FRAG_ATTRIB_COL0]; win[0] = v->attrib[FRAG_ATTRIB_WPOS][0]; diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_lines.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_lines.c index 9e4ea3241cf..9f4237adc8d 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_lines.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_lines.c @@ -235,7 +235,7 @@ _swrast_choose_line( struct gl_context *ctx ) _swrast_choose_aa_line_function(ctx); ASSERT(swrast->Line); } - else if (ctx->Texture._EnabledCoordUnits + else if (ctx->Texture._EnabledCoord || swrast->_FogEnabled || specular) { USE(general_line); diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_points.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_points.c index 11b7ef7b1f8..5bae6b066e3 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_points.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_points.c @@ -56,7 +56,7 @@ get_size(const struct gl_context *ctx, const SWvertex *vert, GLboolean smoothed) { GLfloat size; - if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + if (ctx->Point._Attenuated) { /* use vertex's point size */ size = vert->pointSize; } @@ -85,8 +85,7 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert) SWcontext *swrast = SWRAST_CONTEXT(ctx); SWspan span; GLfloat size; - GLuint tCoords[MAX_TEXTURE_COORD_UNITS + 1]; - GLuint numTcoords = 0; + GLuint tCoords; GLfloat t0, dtdy; CULL_INVALID(vert); @@ -137,12 +136,10 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert) } ATTRIB_LOOP_BEGIN - if (attr >= FRAG_ATTRIB_TEX0 && attr <= FRAG_ATTRIB_TEX7) { + if (attr == FRAG_ATTRIB_TEX) { /* a texcoord attribute */ - const GLuint u = attr - FRAG_ATTRIB_TEX0; - ASSERT(u < Elements(ctx->Point.CoordReplace)); - if (ctx->Point.CoordReplace[u]) { - tCoords[numTcoords++] = attr; + if (ctx->Point.CoordReplace) { + tCoords = attr; if (ctx->Point.SpriteRMode == GL_ZERO) r = 0.0F; @@ -177,7 +174,7 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert) span.attrStepX[FRAG_ATTRIB_PNTC][1] = 0.0; span.attrStepY[FRAG_ATTRIB_PNTC][0] = 0.0; span.attrStepY[FRAG_ATTRIB_PNTC][1] = dtdy; - tCoords[numTcoords++] = FRAG_ATTRIB_PNTC; + tCoords = FRAG_ATTRIB_PNTC; continue; } /* use vertex's texcoord/attrib */ @@ -217,11 +214,8 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert) /* render spans */ for (iy = ymin; iy <= ymax; iy++) { - GLuint i; /* setup texcoord T for this row */ - for (i = 0; i < numTcoords; i++) { - span.attrStart[tCoords[i]][1] = tcoord; - } + span.attrStart[tCoords][1] = tcoord; /* these might get changed by span clipping */ span.x = xmin; @@ -554,8 +548,7 @@ _swrast_choose_point(struct gl_context *ctx) swrast->Point = smooth_point; } else if (size > 1.0 || - ctx->Point._Attenuated || - ctx->VertexProgram.PointSizeEnabled) { + ctx->Point._Attenuated) { swrast->Point = large_point; } else { diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.c index bb232aeb001..3ae4c9248e6 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.c @@ -133,23 +133,20 @@ _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span) /* texcoords */ { - GLuint i; - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - const GLuint attr = FRAG_ATTRIB_TEX0 + i; - const GLfloat *tc = ctx->Current.RasterTexCoords[i]; - if (tc[3] > 0.0F) { - /* use (s/q, t/q, r/q, 1) */ - span->attrStart[attr][0] = tc[0] / tc[3]; - span->attrStart[attr][1] = tc[1] / tc[3]; - span->attrStart[attr][2] = tc[2] / tc[3]; - span->attrStart[attr][3] = 1.0; - } - else { - ASSIGN_4V(span->attrStart[attr], 0.0F, 0.0F, 0.0F, 1.0F); - } - ASSIGN_4V(span->attrStepX[attr], 0.0F, 0.0F, 0.0F, 0.0F); - ASSIGN_4V(span->attrStepY[attr], 0.0F, 0.0F, 0.0F, 0.0F); + const GLuint attr = FRAG_ATTRIB_TEX; + const GLfloat *tc = ctx->Current.RasterTexCoords; + if (tc[3] > 0.0F) { + /* use (s/q, t/q, r/q, 1) */ + span->attrStart[attr][0] = tc[0] / tc[3]; + span->attrStart[attr][1] = tc[1] / tc[3]; + span->attrStart[attr][2] = tc[2] / tc[3]; + span->attrStart[attr][3] = 1.0; } + else { + ASSIGN_4V(span->attrStart[attr], 0.0F, 0.0F, 0.0F, 1.0F); + } + ASSIGN_4V(span->attrStepX[attr], 0.0F, 0.0F, 0.0F, 0.0F); + ASSIGN_4V(span->attrStepY[attr], 0.0F, 0.0F, 0.0F, 0.0F); } } @@ -462,105 +459,98 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, static void interpolate_texcoords(struct gl_context *ctx, SWspan *span) { - const GLuint maxUnit - = (ctx->Texture._EnabledCoordUnits > 1) ? ctx->Const.MaxTextureUnits : 1; - GLuint u; + if (ctx->Texture._EnabledCoord) { + const GLuint attr = FRAG_ATTRIB_TEX; + const struct gl_texture_object *obj = ctx->Texture.Unit._Current; + GLfloat texW, texH; + GLboolean needLambda; + GLfloat (*texcoord)[4] = span->array->attribs[attr]; + GLfloat *lambda = span->array->lambda; + const GLfloat dsdx = span->attrStepX[attr][0]; + const GLfloat dsdy = span->attrStepY[attr][0]; + const GLfloat dtdx = span->attrStepX[attr][1]; + const GLfloat dtdy = span->attrStepY[attr][1]; + const GLfloat drdx = span->attrStepX[attr][2]; + const GLfloat dqdx = span->attrStepX[attr][3]; + const GLfloat dqdy = span->attrStepY[attr][3]; + GLfloat s = span->attrStart[attr][0] + span->leftClip * dsdx; + GLfloat t = span->attrStart[attr][1] + span->leftClip * dtdx; + GLfloat r = span->attrStart[attr][2] + span->leftClip * drdx; + GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx; - /* XXX CoordUnits vs. ImageUnits */ - for (u = 0; u < maxUnit; u++) { - if (ctx->Texture._EnabledCoordUnits & (1 << u)) { - const GLuint attr = FRAG_ATTRIB_TEX0 + u; - const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; - GLfloat texW, texH; - GLboolean needLambda; - GLfloat (*texcoord)[4] = span->array->attribs[attr]; - GLfloat *lambda = span->array->lambda[u]; - const GLfloat dsdx = span->attrStepX[attr][0]; - const GLfloat dsdy = span->attrStepY[attr][0]; - const GLfloat dtdx = span->attrStepX[attr][1]; - const GLfloat dtdy = span->attrStepY[attr][1]; - const GLfloat drdx = span->attrStepX[attr][2]; - const GLfloat dqdx = span->attrStepX[attr][3]; - const GLfloat dqdy = span->attrStepY[attr][3]; - GLfloat s = span->attrStart[attr][0] + span->leftClip * dsdx; - GLfloat t = span->attrStart[attr][1] + span->leftClip * dtdx; - GLfloat r = span->attrStart[attr][2] + span->leftClip * drdx; - GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx; + if (obj) { + const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(img); - if (obj) { - const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; - const struct swrast_texture_image *swImg = - swrast_texture_image_const(img); - - needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter); - /* LOD is calculated directly in the ansiotropic filter, we can - * skip the normal lambda function as the result is ignored. - */ - if (obj->Sampler.MaxAnisotropy > 1.0 && - obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { - needLambda = GL_FALSE; - } - texW = swImg->WidthScale; - texH = swImg->HeightScale; - } - else { - /* using a fragment program */ - texW = 1.0; - texH = 1.0; + needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter); + /* LOD is calculated directly in the ansiotropic filter, we can + * skip the normal lambda function as the result is ignored. + */ + if (obj->Sampler.MaxAnisotropy > 1.0 && + obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { needLambda = GL_FALSE; } + texW = swImg->WidthScale; + texH = swImg->HeightScale; + } + else { + /* using a fragment program */ + texW = 1.0; + texH = 1.0; + needLambda = GL_FALSE; + } - if (needLambda) { - GLuint i; + if (needLambda) { + GLuint i; + for (i = 0; i < span->end; i++) { + const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); + texcoord[i][0] = s * invQ; + texcoord[i][1] = t * invQ; + texcoord[i][2] = r * invQ; + texcoord[i][3] = q; + lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy, + dqdx, dqdy, texW, texH, + s, t, q, invQ); + s += dsdx; + t += dtdx; + r += drdx; + q += dqdx; + } + span->arrayMask |= SPAN_LAMBDA; + } + else { + GLuint i; + if (dqdx == 0.0F) { + /* Ortho projection or polygon's parallel to window X axis */ + const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); + for (i = 0; i < span->end; i++) { + texcoord[i][0] = s * invQ; + texcoord[i][1] = t * invQ; + texcoord[i][2] = r * invQ; + texcoord[i][3] = q; + lambda[i] = 0.0; + s += dsdx; + t += dtdx; + r += drdx; + } + } + else { for (i = 0; i < span->end; i++) { const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); texcoord[i][0] = s * invQ; texcoord[i][1] = t * invQ; texcoord[i][2] = r * invQ; texcoord[i][3] = q; - lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy, - dqdx, dqdy, texW, texH, - s, t, q, invQ); + lambda[i] = 0.0; s += dsdx; t += dtdx; r += drdx; q += dqdx; } - span->arrayMask |= SPAN_LAMBDA; } - else { - GLuint i; - if (dqdx == 0.0F) { - /* Ortho projection or polygon's parallel to window X axis */ - const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); - for (i = 0; i < span->end; i++) { - texcoord[i][0] = s * invQ; - texcoord[i][1] = t * invQ; - texcoord[i][2] = r * invQ; - texcoord[i][3] = q; - lambda[i] = 0.0; - s += dsdx; - t += dtdx; - r += drdx; - } - } - else { - for (i = 0; i < span->end; i++) { - const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); - texcoord[i][0] = s * invQ; - texcoord[i][1] = t * invQ; - texcoord[i][2] = r * invQ; - texcoord[i][3] = q; - lambda[i] = 0.0; - s += dsdx; - t += dtdx; - r += drdx; - q += dqdx; - } - } - } /* lambda */ - } /* if */ - } /* for */ + } /* lambda */ + } /* if */ } @@ -748,9 +738,7 @@ clip_span( struct gl_context *ctx, SWspan *span ) SHIFT_ARRAY(span->array->y, leftClip, n - leftClip); SHIFT_ARRAY(span->array->z, leftClip, n - leftClip); SHIFT_ARRAY(span->array->index, leftClip, n - leftClip); - for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { - SHIFT_ARRAY(span->array->lambda[i], leftClip, n - leftClip); - } + SHIFT_ARRAY(span->array->lambda, leftClip, n - leftClip); SHIFT_ARRAY(span->array->coverage, leftClip, n - leftClip); #undef SHIFT_ARRAY @@ -923,7 +911,7 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output) static inline void shade_texture_span(struct gl_context *ctx, SWspan *span) { - if (ctx->Texture._EnabledCoordUnits) { + if (ctx->Texture._EnabledCoord) { /* conventional texturing */ #if CHAN_BITS == 32 @@ -934,7 +922,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) if (!(span->arrayMask & SPAN_RGBA)) interpolate_int_colors(ctx, span); #endif - if ((span->arrayAttribs & FRAG_BITS_TEX_ANY) == 0x0) + if (!(span->arrayAttribs & FRAG_BIT_TEX)) interpolate_texcoords(ctx, span); _swrast_texture_span(ctx, span); @@ -1048,7 +1036,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) const GLbitfield64 origArrayAttribs = span->arrayAttribs; const GLenum origChanType = span->array->ChanType; void * const origRgba = span->array->rgba; - const GLboolean texture = ctx->Texture._EnabledCoordUnits; + const GLboolean texture = ctx->Texture._EnabledCoord; struct gl_framebuffer *fb = ctx->DrawBuffer; /* diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.h b/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.h index ff0fe6cd94c..a58d1ad64ce 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_span.h @@ -87,7 +87,7 @@ typedef struct sw_span_arrays GLint y[MAX_WIDTH]; /**< fragment Y coords */ GLuint z[MAX_WIDTH]; /**< fragment Z coords */ GLuint index[MAX_WIDTH]; /**< Color indexes */ - GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH]; /**< Texture LOD */ + GLfloat lambda[MAX_WIDTH]; /**< Texture LOD */ GLfloat coverage[MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */ /*@}*/ } SWspanarrays; diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texcombine.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texcombine.c index 05479af13ed..66536378f26 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texcombine.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texcombine.c @@ -29,7 +29,6 @@ #include "main/colormac.h" #include "main/imports.h" #include "main/pixeltransfer.h" -#include "program/prog_instruction.h" #include "s_context.h" #include "s_texcombine.h" @@ -46,12 +45,12 @@ typedef float (*float4_array)[4]; * Return array of texels for given unit. */ static inline float4_array -get_texel_array(SWcontext *swrast, GLuint unit) +get_texel_array(SWcontext *swrast) { #ifdef _OPENMP - return (float4_array) (swrast->TexelBuffer + unit * MAX_WIDTH * 4 * omp_get_num_threads() + (MAX_WIDTH * 4 * omp_get_thread_num())); + return (float4_array) (swrast->TexelBuffer + (MAX_WIDTH * 4 * omp_get_thread_num())); #else - return (float4_array) (swrast->TexelBuffer + unit * MAX_WIDTH * 4); + return (float4_array) (swrast->TexelBuffer); #endif } @@ -77,13 +76,13 @@ get_texel_array(SWcontext *swrast, GLuint unit) * span->array->rgba: incoming/result fragment colors */ static void -texture_combine( struct gl_context *ctx, GLuint unit, +texture_combine( struct gl_context *ctx, const float4_array primary_rgba, const GLfloat *texelBuffer, SWspan *span ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - const struct gl_texture_unit *textureUnit = &(ctx->Texture.Unit[unit]); + const struct gl_texture_unit *textureUnit = &ctx->Texture.Unit; const struct gl_tex_env_combine_state *combine = textureUnit->_CurrentCombine; float4_array argRGB[MAX_COMBINER_TERMS]; float4_array argA[MAX_COMBINER_TERMS]; @@ -142,7 +141,7 @@ texture_combine( struct gl_context *ctx, GLuint unit, switch (srcRGB) { case GL_TEXTURE: - argRGB[term] = get_texel_array(swrast, unit); + argRGB[term] = get_texel_array(swrast); break; case GL_PRIMARY_COLOR: argRGB[term] = primary_rgba; @@ -186,11 +185,9 @@ texture_combine( struct gl_context *ctx, GLuint unit, default: /* ARB_texture_env_crossbar source */ { - const GLuint srcUnit = srcRGB - GL_TEXTURE0; - ASSERT(srcUnit < ctx->Const.MaxTextureUnits); - if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled) + if (!ctx->Texture.Unit._ReallyEnabled) goto end; - argRGB[term] = get_texel_array(swrast, srcUnit); + argRGB[term] = get_texel_array(swrast); } } @@ -238,7 +235,7 @@ texture_combine( struct gl_context *ctx, GLuint unit, switch (srcA) { case GL_TEXTURE: - argA[term] = get_texel_array(swrast, unit); + argA[term] = get_texel_array(swrast); break; case GL_PRIMARY_COLOR: argA[term] = primary_rgba; @@ -276,11 +273,9 @@ texture_combine( struct gl_context *ctx, GLuint unit, default: /* ARB_texture_env_crossbar source */ { - const GLuint srcUnit = srcA - GL_TEXTURE0; - ASSERT(srcUnit < ctx->Const.MaxTextureUnits); - if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled) + if (!ctx->Texture.Unit._ReallyEnabled) goto end; - argA[term] = get_texel_array(swrast, srcUnit); + argA[term] = get_texel_array(swrast); } } @@ -428,16 +423,6 @@ texture_combine( struct gl_context *ctx, GLuint unit, arg1[i][BCOMP]) * scaleRGB; } break; - case GL_BUMP_ENVMAP_ATI: - /* this produces a fixed rgba color, and the coord calc is done elsewhere */ - for (i = 0; i < n; i++) { - /* rgba result is 0,0,0,1 */ - rgba[i][RCOMP] = 0.0; - rgba[i][GCOMP] = 0.0; - rgba[i][BCOMP] = 0.0; - rgba[i][ACOMP] = 1.0; - } - goto end; /* no alpha processing */ default: _mesa_problem(ctx, "invalid combine mode"); } @@ -565,7 +550,6 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); float4_array primary_rgba; - GLuint unit; if (!swrast->TexelBuffer) { #ifdef _OPENMP @@ -578,12 +562,10 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) * instances; when running with multiple threads, create one per * thread. */ - swrast->TexelBuffer = - (GLfloat *) MALLOC(ctx->Const.MaxTextureImageUnits * maxThreads * - MAX_WIDTH * 4 * sizeof(GLfloat)); + swrast->TexelBuffer = (GLfloat *) MALLOC(maxThreads * MAX_WIDTH * 4 * sizeof(GLfloat)); if (!swrast->TexelBuffer) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); - return; + _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine"); + return; } } @@ -609,55 +591,18 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) } } - /* First must sample all bump maps */ - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - - if (texUnit->_ReallyEnabled && - texUnit->_CurrentCombine->ModeRGB == GL_BUMP_ENVMAP_ATI) { - const GLfloat (*texcoords)[4] = (const GLfloat (*)[4]) - span->array->attribs[FRAG_ATTRIB_TEX0 + unit]; - float4_array targetcoords = - span->array->attribs[FRAG_ATTRIB_TEX0 + - ctx->Texture.Unit[unit].BumpTarget - GL_TEXTURE0]; - - GLfloat *lambda = span->array->lambda[unit]; - float4_array texels = get_texel_array(swrast, unit); - GLuint i; - GLfloat rotMatrix00 = ctx->Texture.Unit[unit].RotMatrix[0]; - GLfloat rotMatrix01 = ctx->Texture.Unit[unit].RotMatrix[1]; - GLfloat rotMatrix10 = ctx->Texture.Unit[unit].RotMatrix[2]; - GLfloat rotMatrix11 = ctx->Texture.Unit[unit].RotMatrix[3]; - - /* Sample the texture (span->end = number of fragments) */ - swrast->TextureSample[unit]( ctx, texUnit->_Current, span->end, - texcoords, lambda, texels ); - - /* manipulate the span values of the bump target - not sure this can work correctly even ignoring - the problem that channel is unsigned */ - for (i = 0; i < span->end; i++) { - targetcoords[i][0] += (texels[i][0] * rotMatrix00 + texels[i][1] * - rotMatrix01) / targetcoords[i][3]; - targetcoords[i][1] += (texels[i][0] * rotMatrix10 + texels[i][1] * - rotMatrix11) / targetcoords[i][3]; - } - } - } - /* * Must do all texture sampling before combining in order to * accomodate GL_ARB_texture_env_crossbar. */ - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - if (texUnit->_ReallyEnabled && - texUnit->_CurrentCombine->ModeRGB != GL_BUMP_ENVMAP_ATI) { + { + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; + if (texUnit->_ReallyEnabled) { const GLfloat (*texcoords)[4] = (const GLfloat (*)[4]) - span->array->attribs[FRAG_ATTRIB_TEX0 + unit]; + span->array->attribs[FRAG_ATTRIB_TEX]; const struct gl_texture_object *curObj = texUnit->_Current; - GLfloat *lambda = span->array->lambda[unit]; - float4_array texels = get_texel_array(swrast, unit); + GLfloat *lambda = span->array->lambda; + float4_array texels = get_texel_array(swrast); if (curObj->Sampler.MaxAnisotropy > 1.0 && curObj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { @@ -673,8 +618,8 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) } /* Sample the texture (span->end = number of fragments) */ - swrast->TextureSample[unit]( ctx, texUnit->_Current, span->end, - texcoords, lambda, texels ); + swrast->TextureSample( ctx, texUnit->_Current, span->end, + texcoords, lambda, texels ); } } @@ -682,10 +627,8 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) * OK, now apply the texture (aka texture combine/blend). * We modify the span->color.rgba values. */ - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - if (ctx->Texture.Unit[unit]._ReallyEnabled) - texture_combine(ctx, unit, primary_rgba, swrast->TexelBuffer, span); - } + if (ctx->Texture.Unit._ReallyEnabled) + texture_combine(ctx, primary_rgba, swrast->TexelBuffer, span); free(primary_rgba); } diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch.c index d52150c9e80..3c5cb325d29 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch.c @@ -653,14 +653,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] = fetch_texel_3d_rgba_uint32 }, - /* dudv */ - { - MESA_FORMAT_DUDV8, - fetch_texel_1d_dudv8, - fetch_texel_2d_dudv8, - fetch_texel_3d_dudv8 - }, - /* signed, normalized */ { MESA_FORMAT_SIGNED_RGBA_16, diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch_tmp.h b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch_tmp.h index 7b92d2d0d63..da996b8a100 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch_tmp.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfetch_tmp.h @@ -881,22 +881,6 @@ FETCH(rgba_uint32)(const struct swrast_texture_image *texImage, - -/* MESA_FORMAT_DUDV8 ********************************************************/ - -/* this format by definition produces 0,0,0,1 as rgba values, - however we'll return the dudv values as rg and fix up elsewhere */ -static void FETCH(dudv8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2); - texel[RCOMP] = BYTE_TO_FLOAT(src[0]); - texel[GCOMP] = BYTE_TO_FLOAT(src[1]); - texel[BCOMP] = 0; - texel[ACOMP] = 0; -} - - /* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ static void diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfilter.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfilter.c index 4d6b57f7db8..9f2a0a29879 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfilter.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texfilter.c @@ -1722,31 +1722,6 @@ sample_2d_footprint(struct gl_context *ctx, rgba[3] = num[3] / numSamples; } - -/** - * Returns the index of the specified texture object in the - * gl_context texture unit array. - */ -static inline GLuint -texture_unit_index(const struct gl_context *ctx, - const struct gl_texture_object *tObj) -{ - const GLuint maxUnit - = (ctx->Texture._EnabledCoordUnits > 1) ? ctx->Const.MaxTextureUnits : 1; - GLuint u; - - /* XXX CoordUnits vs. ImageUnits */ - for (u = 0; u < maxUnit; u++) { - if (ctx->Texture.Unit[u]._Current == tObj) - break; /* found */ - } - if (u >= maxUnit) - u = 0; /* not found, use 1st one; should never happen */ - - return u; -} - - /** * Sample 2D texture using an anisotropic filter. * NOTE: the const GLfloat lambda_iso[] parameter does *NOT* contain @@ -1778,8 +1753,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx, /* find the texture unit index by looking up the current texture object * from the context list of available texture objects. */ - const GLuint u = texture_unit_index(ctx, tObj); - const GLuint attr = FRAG_ATTRIB_TEX0 + u; + const GLuint attr = FRAG_ATTRIB_TEX; GLfloat texW, texH; const GLfloat dsdx = span->attrStepX[attr][0]; diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texture.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texture.c index a627547115f..acb5cb66baf 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_texture.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_texture.c @@ -281,16 +281,10 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) void _swrast_map_textures(struct gl_context *ctx) { - GLbitfield enabledUnits = ctx->Texture._EnabledUnits; - - /* loop over enabled texture units */ - while (enabledUnits) { - GLuint unit = _mesa_ffs(enabledUnits) - 1; - struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; + if (ctx->Texture._Enabled) { + struct gl_texture_object *texObj = ctx->Texture.Unit._Current; _swrast_map_texture(ctx, texObj); - - enabledUnits &= ~(1 << unit); } } @@ -301,16 +295,10 @@ _swrast_map_textures(struct gl_context *ctx) void _swrast_unmap_textures(struct gl_context *ctx) { - GLbitfield enabledUnits = ctx->Texture._EnabledUnits; - - /* loop over enabled texture units */ - while (enabledUnits) { - GLuint unit = _mesa_ffs(enabledUnits) - 1; - struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; + if(ctx->Texture._Enabled) { + struct gl_texture_object *texObj = ctx->Texture.Unit._Current; _swrast_unmap_texture(ctx, texObj); - - enabledUnits &= ~(1 << unit); } } diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_triangle.c b/reactos/dll/opengl/mesa/src/mesa/swrast/s_triangle.c index ec720eff57d..cdfaf36daf5 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_triangle.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_triangle.c @@ -36,7 +36,6 @@ #include "main/macros.h" #include "main/mtypes.h" #include "main/state.h" -#include "program/prog_instruction.h" #include "s_aatriangle.h" #include "s_context.h" @@ -76,7 +75,7 @@ _swrast_culltriangle( struct gl_context *ctx, #define NAME flat_rgba_triangle #define INTERP_Z 1 #define SETUP_CODE \ - ASSERT(ctx->Texture._EnabledCoordUnits == 0);\ + ASSERT(!ctx->Texture._EnabledCoord);\ ASSERT(ctx->Light.ShadeModel==GL_FLAT); \ span.interpMask |= SPAN_RGBA; \ span.red = ChanToFixed(v2->color[0]); \ @@ -102,7 +101,7 @@ _swrast_culltriangle( struct gl_context *ctx, #define SETUP_CODE \ { \ /* texturing must be off */ \ - ASSERT(ctx->Texture._EnabledCoordUnits == 0); \ + ASSERT(!ctx->Texture._EnabledCoord); \ ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \ } #define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); @@ -124,7 +123,7 @@ _swrast_culltriangle( struct gl_context *ctx, #define SETUP_CODE \ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffer; \ const struct gl_texture_object *obj = \ - ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ + ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ obj->Image[0][obj->BaseLevel]; \ const struct swrast_texture_image *swImg = \ @@ -182,7 +181,7 @@ _swrast_culltriangle( struct gl_context *ctx, #define SETUP_CODE \ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffer; \ const struct gl_texture_object *obj = \ - ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ + ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ obj->Image[0][obj->BaseLevel]; \ const struct swrast_texture_image *swImg = \ @@ -269,7 +268,7 @@ affine_span(struct gl_context *ctx, SWspan *span, struct affine_info *info) { GLchan sample[4]; /* the filtered texture sample */ - const GLuint texEnableSave = ctx->Texture._EnabledCoordUnits; + const GLboolean texEnableSave = ctx->Texture._EnabledCoord; /* Instead of defining a function for each mode, a test is done * between the outer and inner loops. This is to reduce code size @@ -408,7 +407,7 @@ affine_span(struct gl_context *ctx, SWspan *span, GLchan *dest = span->array->rgba[0]; /* Disable tex units so they're not re-applied in swrast_write_rgba_span */ - ctx->Texture._EnabledCoordUnits = 0x0; + ctx->Texture._EnabledCoord = GL_FALSE; span->intTex[0] -= FIXED_HALF; span->intTex[1] -= FIXED_HALF; @@ -515,7 +514,7 @@ affine_span(struct gl_context *ctx, SWspan *span, _swrast_write_rgba_span(ctx, span); /* re-enable texture units */ - ctx->Texture._EnabledCoordUnits = texEnableSave; + ctx->Texture._EnabledCoord = texEnableSave; #undef SPAN_NEAREST #undef SPAN_LINEAR @@ -536,9 +535,9 @@ affine_span(struct gl_context *ctx, SWspan *span, #define SETUP_CODE \ struct affine_info info; \ - struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ + struct gl_texture_unit *unit = &ctx->Texture.Unit; \ const struct gl_texture_object *obj = \ - ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ + ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ obj->Image[0][obj->BaseLevel]; \ const struct swrast_texture_image *swImg = \ @@ -673,16 +672,16 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, GLfloat tex_coord[3], tex_step[3]; GLchan *dest = span->array->rgba[0]; - const GLuint texEnableSave = ctx->Texture._EnabledCoordUnits; - ctx->Texture._EnabledCoordUnits = 0; + const GLboolean texEnableSave = ctx->Texture._EnabledCoord; + ctx->Texture._EnabledCoord = GL_FALSE; - tex_coord[0] = span->attrStart[FRAG_ATTRIB_TEX0][0] * (info->smask + 1); - tex_step[0] = span->attrStepX[FRAG_ATTRIB_TEX0][0] * (info->smask + 1); - tex_coord[1] = span->attrStart[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1); - tex_step[1] = span->attrStepX[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1); + tex_coord[0] = span->attrStart[FRAG_ATTRIB_TEX][0] * (info->smask + 1); + tex_step[0] = span->attrStepX[FRAG_ATTRIB_TEX][0] * (info->smask + 1); + tex_coord[1] = span->attrStart[FRAG_ATTRIB_TEX][1] * (info->tmask + 1); + tex_step[1] = span->attrStepX[FRAG_ATTRIB_TEX][1] * (info->tmask + 1); /* span->attrStart[FRAG_ATTRIB_TEX0][2] only if 3D-texturing, here only 2D */ - tex_coord[2] = span->attrStart[FRAG_ATTRIB_TEX0][3]; - tex_step[2] = span->attrStepX[FRAG_ATTRIB_TEX0][3]; + tex_coord[2] = span->attrStart[FRAG_ATTRIB_TEX][3]; + tex_step[2] = span->attrStepX[FRAG_ATTRIB_TEX][3]; switch (info->filter) { case GL_NEAREST: @@ -787,7 +786,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, #undef SPAN_LINEAR /* restore state */ - ctx->Texture._EnabledCoordUnits = texEnableSave; + ctx->Texture._EnabledCoord = texEnableSave; } @@ -805,9 +804,9 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, #define SETUP_CODE \ struct persp_info info; \ - const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ + const struct gl_texture_unit *unit = &ctx->Texture.Unit; \ const struct gl_texture_object *obj = \ - ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ + ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; \ const struct gl_texture_image *texImg = \ obj->Image[0][obj->BaseLevel]; \ const struct swrast_texture_image *swImg = \ @@ -984,7 +983,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) * XXX should examine swrast->_ActiveAttribMask to determine what * needs to be interpolated. */ - if (ctx->Texture._EnabledCoordUnits || + if (ctx->Texture._EnabledCoord || _mesa_need_secondary_color(ctx) || swrast->_FogEnabled) { /* Ugh, we do a _lot_ of tests to pick the best textured tri func */ @@ -993,7 +992,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) const struct swrast_texture_image *swImg; GLenum minFilter, magFilter, envMode; gl_format format; - texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; + texObj2D = ctx->Texture.Unit.CurrentTex[TEXTURE_2D_INDEX]; texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL; swImg = swrast_texture_image_const(texImg); @@ -1001,12 +1000,12 @@ _swrast_choose_triangle( struct gl_context *ctx ) format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE; minFilter = texObj2D ? texObj2D->Sampler.MinFilter : GL_NONE; magFilter = texObj2D ? texObj2D->Sampler.MagFilter : GL_NONE; - envMode = ctx->Texture.Unit[0].EnvMode; + envMode = ctx->Texture.Unit.EnvMode; /* First see if we can use an optimized 2-D texture function */ - if (ctx->Texture._EnabledCoordUnits == 0x1 - && ctx->Texture._EnabledUnits == 0x1 - && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT + if (ctx->Texture._EnabledCoord + && ctx->Texture._Enabled + && ctx->Texture.Unit._ReallyEnabled == TEXTURE_2D_BIT && texObj2D->Sampler.WrapS == GL_REPEAT && texObj2D->Sampler.WrapT == GL_REPEAT && swImg->_IsPowerOfTwo @@ -1016,8 +1015,8 @@ _swrast_choose_triangle( struct gl_context *ctx ) && minFilter == magFilter && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR && !swrast->_FogEnabled - && ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT - && ctx->Texture.Unit[0].EnvMode != GL_COMBINE4_NV) { + && ctx->Texture.Unit.EnvMode != GL_COMBINE_EXT + && ctx->Texture.Unit.EnvMode != GL_COMBINE4_NV) { if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) { if (minFilter == GL_NEAREST && format == MESA_FORMAT_RGB888 diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/s_tritemp.h b/reactos/dll/opengl/mesa/src/mesa/swrast/s_tritemp.h index 061759d26d2..ee434d21015 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/s_tritemp.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/s_tritemp.h @@ -396,16 +396,16 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0, #endif /* INTERP_RGB */ #ifdef INTERP_INT_TEX { - GLfloat eMaj_ds = (vMax->attrib[FRAG_ATTRIB_TEX0][0] - vMin->attrib[FRAG_ATTRIB_TEX0][0]) * S_SCALE; - GLfloat eBot_ds = (vMid->attrib[FRAG_ATTRIB_TEX0][0] - vMin->attrib[FRAG_ATTRIB_TEX0][0]) * S_SCALE; - GLfloat eMaj_dt = (vMax->attrib[FRAG_ATTRIB_TEX0][1] - vMin->attrib[FRAG_ATTRIB_TEX0][1]) * T_SCALE; - GLfloat eBot_dt = (vMid->attrib[FRAG_ATTRIB_TEX0][1] - vMin->attrib[FRAG_ATTRIB_TEX0][1]) * T_SCALE; - span.attrStepX[FRAG_ATTRIB_TEX0][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds); - span.attrStepY[FRAG_ATTRIB_TEX0][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); - span.attrStepX[FRAG_ATTRIB_TEX0][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt); - span.attrStepY[FRAG_ATTRIB_TEX0][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); - span.intTexStep[0] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX0][0]); - span.intTexStep[1] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX0][1]); + GLfloat eMaj_ds = (vMax->attrib[FRAG_ATTRIB_TEX][0] - vMin->attrib[FRAG_ATTRIB_TEX][0]) * S_SCALE; + GLfloat eBot_ds = (vMid->attrib[FRAG_ATTRIB_TEX][0] - vMin->attrib[FRAG_ATTRIB_TEX][0]) * S_SCALE; + GLfloat eMaj_dt = (vMax->attrib[FRAG_ATTRIB_TEX][1] - vMin->attrib[FRAG_ATTRIB_TEX][1]) * T_SCALE; + GLfloat eBot_dt = (vMid->attrib[FRAG_ATTRIB_TEX][1] - vMin->attrib[FRAG_ATTRIB_TEX][1]) * T_SCALE; + span.attrStepX[FRAG_ATTRIB_TEX][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds); + span.attrStepY[FRAG_ATTRIB_TEX][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx); + span.attrStepX[FRAG_ATTRIB_TEX][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt); + span.attrStepY[FRAG_ATTRIB_TEX][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx); + span.intTexStep[0] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX][0]); + span.intTexStep[1] = SignedFloatToFixed(span.attrStepX[FRAG_ATTRIB_TEX][1]); } #endif #ifdef INTERP_ATTRIBS @@ -678,17 +678,17 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0, #ifdef INTERP_INT_TEX { GLfloat s0, t0; - s0 = vLower->attrib[FRAG_ATTRIB_TEX0][0] * S_SCALE; - sLeft = (GLfixed)(s0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX0][0] * adjx - + span.attrStepY[FRAG_ATTRIB_TEX0][0] * adjy) + FIXED_HALF; - dsOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX0][0] - + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX0][0]); + s0 = vLower->attrib[FRAG_ATTRIB_TEX][0] * S_SCALE; + sLeft = (GLfixed)(s0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX][0] * adjx + + span.attrStepY[FRAG_ATTRIB_TEX][0] * adjy) + FIXED_HALF; + dsOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX][0] + + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX][0]); - t0 = vLower->attrib[FRAG_ATTRIB_TEX0][1] * T_SCALE; - tLeft = (GLfixed)(t0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX0][1] * adjx - + span.attrStepY[FRAG_ATTRIB_TEX0][1] * adjy) + FIXED_HALF; - dtOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX0][1] - + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX0][1]); + t0 = vLower->attrib[FRAG_ATTRIB_TEX][1] * T_SCALE; + tLeft = (GLfixed)(t0 * FIXED_SCALE + span.attrStepX[FRAG_ATTRIB_TEX][1] * adjx + + span.attrStepY[FRAG_ATTRIB_TEX][1] * adjy) + FIXED_HALF; + dtOuter = SignedFloatToFixed(span.attrStepY[FRAG_ATTRIB_TEX][1] + + dxOuter * span.attrStepX[FRAG_ATTRIB_TEX][1]); } #endif #ifdef INTERP_ATTRIBS diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast/swrast.h b/reactos/dll/opengl/mesa/src/mesa/swrast/swrast.h index 9e42c80c068..bf7d101990c 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast/swrast.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast/swrast.h @@ -70,7 +70,7 @@ * primitives unaccelerated), hook in swrast_setup instead. */ typedef struct { - GLfloat attrib[FRAG_ATTRIB_MAX][4]; + GLfloat attrib[32][4]; GLchan color[4]; /** integer color */ GLfloat pointSize; } SWvertex; diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_context.c b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_context.c index 544ee7e4166..c7e55a2252f 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_context.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_context.c @@ -40,7 +40,7 @@ /* Need to check lighting state and vertex program state to know * if two-sided lighting is in effect. */ -#define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT|_NEW_PROGRAM) +#define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT) #define VARYING_EMIT_STYLE EMIT_4F @@ -112,15 +112,14 @@ setup_vertex_format(struct gl_context *ctx) { TNLcontext *tnl = TNL_CONTEXT(ctx); SScontext *swsetup = SWSETUP_CONTEXT(ctx); - GLboolean intColors = !ctx->FragmentProgram._Current - && ctx->RenderMode == GL_RENDER + GLboolean intColors = ctx->RenderMode == GL_RENDER && CHAN_TYPE != GL_FLOAT; if (intColors != swsetup->intColors || tnl->render_inputs_bitset != swsetup->last_index_bitset) { GLbitfield64 index_bitset = tnl->render_inputs_bitset; struct tnl_attr_map map[_TNL_ATTRIB_MAX]; - unsigned int i, e = 0; + unsigned e = 0; swsetup->intColors = intColors; @@ -138,28 +137,12 @@ setup_vertex_format(struct gl_context *ctx) } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) { - const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F; - EMIT_ATTR( _TNL_ATTRIB_FOG, emit, attrib[FRAG_ATTRIB_FOGC]); + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, attrib[FRAG_ATTRIB_FOGC]); } - if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)) - { - for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { - if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX(i))) { - EMIT_ATTR( _TNL_ATTRIB_TEX(i), EMIT_4F, - attrib[FRAG_ATTRIB_TEX0 + i] ); - } - } - } - - /* shader varying vars */ - if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_GENERIC0, _TNL_NUM_GENERIC)) { - for (i = 0; i < ctx->Const.MaxVarying; i++) { - if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i))) { - EMIT_ATTR( _TNL_ATTRIB_GENERIC(i), VARYING_EMIT_STYLE, - attrib[FRAG_ATTRIB_VAR0 + i] ); - } - } + if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX)) { + EMIT_ATTR( _TNL_ATTRIB_TEX, EMIT_4F, + attrib[FRAG_ATTRIB_TEX] ); } if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE)) @@ -189,10 +172,6 @@ _swsetup_RenderStart( struct gl_context *ctx ) _swsetup_choose_trifuncs(ctx); } - if (swsetup->NewState & _NEW_PROGRAM) { - swsetup->last_index_bitset = 0; - } - swsetup->NewState = 0; /* This will change if drawing unfilled tris */ @@ -256,46 +235,3 @@ _swsetup_Wakeup( struct gl_context *ctx ) swsetup->verts = (SWvertex *)tnl->clipspace.vertex_buf; swsetup->last_index_bitset = 0; } - - -/** - * Populate a swrast SWvertex from an attrib-style vertex. - */ -void -_swsetup_Translate( struct gl_context *ctx, const void *vertex, SWvertex *dest ) -{ - const GLfloat *m = ctx->Viewport._WindowMap.m; - GLfloat tmp[4]; - GLuint i; - - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POS, tmp ); - - dest->attrib[FRAG_ATTRIB_WPOS][0] = m[0] * tmp[0] + m[12]; - dest->attrib[FRAG_ATTRIB_WPOS][1] = m[5] * tmp[1] + m[13]; - dest->attrib[FRAG_ATTRIB_WPOS][2] = m[10] * tmp[2] + m[14]; - dest->attrib[FRAG_ATTRIB_WPOS][3] = tmp[3]; - - /** XXX try to limit these loops someday */ - for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0 + i, - dest->attrib[FRAG_ATTRIB_TEX0 + i] ); - - for (i = 0 ; i < ctx->Const.MaxVarying ; i++) - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0 + i, - dest->attrib[FRAG_ATTRIB_VAR0 + i] ); - - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, - dest->attrib[FRAG_ATTRIB_COL0] ); - UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp ); - - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, - dest->attrib[FRAG_ATTRIB_COL1]); - - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp ); - dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0]; - - /* XXX See _tnl_get_attr about pointsize ... */ - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp ); - dest->pointSize = tmp[0]; -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_triangle.c b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_triangle.c index 5d1c70e9481..75ee52a3d8b 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_triangle.c +++ b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_triangle.c @@ -246,8 +246,7 @@ void _swsetup_choose_trifuncs( struct gl_context *ctx ) ctx->Polygon.OffsetFill) ind |= SS_OFFSET_BIT; - if ((ctx->Light.Enabled && ctx->Light.Model.TwoSide) || - (ctx->VertexProgram._Current && ctx->VertexProgram.TwoSideEnabled)) + if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) ind |= SS_TWOSIDE_BIT; /* We piggyback the two-sided stencil front/back determination on the diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_tritmp.h b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_tritmp.h index 5844ad594cd..89ed0418dbd 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_tritmp.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/ss_tritmp.h @@ -32,23 +32,27 @@ */ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e2 ) { +#if IND & SS_TWOSIDE_BIT struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; SScontext *swsetup = SWSETUP_CONTEXT(ctx); - SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; - SWvertex *v[3]; - GLfloat z[3]; - GLfloat offset, oz0, oz1, oz2; - GLenum mode = GL_FILL; - GLuint facing = 0; GLchan saved_color[3][4] = { { 0 } }; GLfloat saved_col0[3][4] = { { 0 } }; GLfloat saved_spec[3][4] = { { 0 } }; +#endif + SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; + SWvertex *v[3]; +#if IND & SS_OFFSET_BIT + GLfloat z[3]; +#endif + GLfloat oz0, oz1, oz2; + GLenum mode = GL_FILL; + GLuint facing = 0; v[0] = &verts[e0]; v[1] = &verts[e1]; v[2] = &verts[e2]; - if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT)) +#if IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT) { GLfloat ex = v[0]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0]; GLfloat ey = v[0]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1]; @@ -56,15 +60,16 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e GLfloat fy = v[1]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1]; GLfloat cc = ex*fy - ey*fx; - if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT)) +#if IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT) { facing = (cc < 0.0) ^ ctx->Polygon._FrontBit; - if (IND & SS_UNFILLED_BIT) +#if IND & SS_UNFILLED_BIT mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; +#endif +#if IND & SS_TWOSIDE_BIT if (facing == 1) { - if (IND & SS_TWOSIDE_BIT) { if (VB->BackfaceColorPtr) { GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data; @@ -125,10 +130,13 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e } } } - } +#endif } +#endif - if (IND & SS_OFFSET_BIT) { +#if IND & SS_OFFSET_BIT + { + GLfloat offset; const GLfloat max = ctx->DrawBuffer->_DepthMaxF; /* save original Z values (restored later) */ z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2]; @@ -151,7 +159,9 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max); oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max); } +#endif } +#endif if (mode == GL_POINT) { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { @@ -167,25 +177,31 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; } _swsetup_render_tri(ctx, e0, e1, e2, facing, _swsetup_edge_render_line_tri); - } else { - if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) { + } + else { +#if IND & SS_OFFSET_BIT + if (ctx->Polygon.OffsetFill) { v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; } +#endif _swrast_Triangle( ctx, v[0], v[1], v[2] ); } /* * Restore original vertex colors, etc. */ - if (IND & SS_OFFSET_BIT) { +#if IND & SS_OFFSET_BIT + { v[0]->attrib[FRAG_ATTRIB_WPOS][2] = z[0]; v[1]->attrib[FRAG_ATTRIB_WPOS][2] = z[1]; v[2]->attrib[FRAG_ATTRIB_WPOS][2] = z[2]; } +#endif - if (IND & SS_TWOSIDE_BIT) { +#if IND & SS_TWOSIDE_BIT + { if (facing == 1) { if (VB->BackfaceColorPtr) { if (swsetup->intColors) { @@ -207,6 +223,7 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e } } } +#endif } diff --git a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/swrast_setup.h b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/swrast_setup.h index 1d87ec1082d..56f9144d746 100644 --- a/reactos/dll/opengl/mesa/src/mesa/swrast_setup/swrast_setup.h +++ b/reactos/dll/opengl/mesa/src/mesa/swrast_setup/swrast_setup.h @@ -52,10 +52,4 @@ _swsetup_InvalidateState( struct gl_context *ctx, GLuint new_state ); extern void _swsetup_Wakeup( struct gl_context *ctx ); -/* Helper function to translate a hardware vertex (as understood by - * the tnl/t_vertex.c code) to a swrast vertex. - */ -extern void -_swsetup_Translate( struct gl_context *ctx, const void *vertex, SWvertex *dest ); - #endif diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.c index f2984906815..890998f784e 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.c @@ -102,14 +102,11 @@ void _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - const struct gl_vertex_program *vp = ctx->VertexProgram._Current; - const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; - GLuint i; - if (new_state & (_NEW_HINT | _NEW_PROGRAM)) { + if (new_state & _NEW_HINT) { ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog); tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog) && !fp; + || !tnl->AllowPixelFog); } tnl->pipeline.new_state |= new_state; @@ -119,22 +116,16 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) */ tnl->render_inputs_bitset = BITFIELD64_BIT(_TNL_ATTRIB_POS); - if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) { - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR0); - } + tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR0); if (_mesa_need_secondary_color(ctx)) tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR1); - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { - if (ctx->Texture._EnabledCoordUnits & (1 << i) || - (fp && fp->Base.InputsRead & FRAG_BIT_TEX(i))) { - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX(i)); - } + if (ctx->Texture._EnabledCoord) { + tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX); } - if (ctx->Fog.Enabled - || (fp != NULL && (fp->Base.InputsRead & FRAG_BIT_FOGC) != 0)) { + if (ctx->Fog.Enabled) { /* Either fixed-function fog or a fragment program needs fog coord. */ tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_FOG); @@ -145,20 +136,10 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_EDGEFLAG); if (ctx->RenderMode == GL_FEEDBACK) - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX0); + tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX); - if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) + if (ctx->Point._Attenuated) tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE); - - /* check for varying vars which are written by the vertex program */ - if (vp) { - GLuint i; - for (i = 0; i < MAX_VARYING; i++) { - if (vp->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_VAR0 + i)) { - tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i)); - } - } - } } @@ -198,7 +179,7 @@ _tnl_allow_vertex_fog( struct gl_context *ctx, GLboolean value ) TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->AllowVertexFog = value; tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current; + || !tnl->AllowPixelFog); } @@ -208,6 +189,6 @@ _tnl_allow_pixel_fog( struct gl_context *ctx, GLboolean value ) TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->AllowPixelFog = value; tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) - || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current; + || !tnl->AllowPixelFog); } diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.h b/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.h index c5a902082b8..de8aa1323b3 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.h +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_context.h @@ -84,31 +84,7 @@ enum { _TNL_ATTRIB_FOG = 5, _TNL_ATTRIB_COLOR_INDEX = 6, _TNL_ATTRIB_EDGEFLAG = 7, - _TNL_ATTRIB_TEX0 = 8, - _TNL_ATTRIB_TEX1 = 9, - _TNL_ATTRIB_TEX2 = 10, - _TNL_ATTRIB_TEX3 = 11, - _TNL_ATTRIB_TEX4 = 12, - _TNL_ATTRIB_TEX5 = 13, - _TNL_ATTRIB_TEX6 = 14, - _TNL_ATTRIB_TEX7 = 15, - - _TNL_ATTRIB_GENERIC0 = 17, /* doesn't really exist! */ - _TNL_ATTRIB_GENERIC1 = 18, - _TNL_ATTRIB_GENERIC2 = 19, - _TNL_ATTRIB_GENERIC3 = 20, - _TNL_ATTRIB_GENERIC4 = 21, - _TNL_ATTRIB_GENERIC5 = 22, - _TNL_ATTRIB_GENERIC6 = 23, - _TNL_ATTRIB_GENERIC7 = 24, - _TNL_ATTRIB_GENERIC8 = 25, - _TNL_ATTRIB_GENERIC9 = 26, - _TNL_ATTRIB_GENERIC10 = 27, - _TNL_ATTRIB_GENERIC11 = 28, - _TNL_ATTRIB_GENERIC12 = 29, - _TNL_ATTRIB_GENERIC13 = 30, - _TNL_ATTRIB_GENERIC14 = 31, - _TNL_ATTRIB_GENERIC15 = 32, + _TNL_ATTRIB_TEX = 8, /* These alias with the generics, but they are not active * concurrently, so it's not a problem. The TNL module @@ -120,28 +96,27 @@ enum { * generic attribute in order to pick up per-vertex material * data. */ - _TNL_ATTRIB_MAT_FRONT_AMBIENT = 17, - _TNL_ATTRIB_MAT_BACK_AMBIENT = 18, - _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 19, - _TNL_ATTRIB_MAT_BACK_DIFFUSE = 20, - _TNL_ATTRIB_MAT_FRONT_SPECULAR = 21, - _TNL_ATTRIB_MAT_BACK_SPECULAR = 22, - _TNL_ATTRIB_MAT_FRONT_EMISSION = 23, - _TNL_ATTRIB_MAT_BACK_EMISSION = 24, - _TNL_ATTRIB_MAT_FRONT_SHININESS = 25, - _TNL_ATTRIB_MAT_BACK_SHININESS = 26, - _TNL_ATTRIB_MAT_FRONT_INDEXES = 27, - _TNL_ATTRIB_MAT_BACK_INDEXES = 28, + _TNL_ATTRIB_MAT_FRONT_AMBIENT = 10, + _TNL_ATTRIB_MAT_BACK_AMBIENT = 11, + _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 12, + _TNL_ATTRIB_MAT_BACK_DIFFUSE = 13, + _TNL_ATTRIB_MAT_FRONT_SPECULAR = 14, + _TNL_ATTRIB_MAT_BACK_SPECULAR = 15, + _TNL_ATTRIB_MAT_FRONT_EMISSION = 16, + _TNL_ATTRIB_MAT_BACK_EMISSION = 17, + _TNL_ATTRIB_MAT_FRONT_SHININESS = 18, + _TNL_ATTRIB_MAT_BACK_SHININESS = 19, + _TNL_ATTRIB_MAT_FRONT_INDEXES = 20, + _TNL_ATTRIB_MAT_BACK_INDEXES = 21, /* This is really a VERT_RESULT, not an attrib. Need to fix * tnl to understand the difference. */ - _TNL_ATTRIB_POINTSIZE = 16, + _TNL_ATTRIB_POINTSIZE = 9, - _TNL_ATTRIB_MAX = 33 + _TNL_ATTRIB_MAX = 22 } ; -#define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u)) #define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n)) /* special index used for handing invalid glVertexAttribute() indices */ @@ -151,16 +126,10 @@ enum { * Handy attribute ranges: */ #define _TNL_FIRST_PROG _TNL_ATTRIB_WEIGHT -#define _TNL_LAST_PROG _TNL_ATTRIB_TEX7 +#define _TNL_LAST_PROG _TNL_ATTRIB_TEX -#define _TNL_FIRST_TEX _TNL_ATTRIB_TEX0 -#define _TNL_LAST_TEX _TNL_ATTRIB_TEX7 - -#define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0 -#define _TNL_LAST_GENERIC _TNL_ATTRIB_GENERIC15 - -#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */ -#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES /* GENERIC11 */ +#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT +#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES /* Number of available texture attributes */ #define _TNL_NUM_TEX 8 @@ -510,11 +479,11 @@ typedef struct GLbitfield64 render_inputs_bitset; - GLvector4f tmp_inputs[VERT_ATTRIB_MAX]; + GLvector4f tmp_inputs[_TNL_ATTRIB_MAX]; /* Temp storage for t_draw.c: */ - GLubyte *block[VERT_ATTRIB_MAX]; + GLubyte *block[_TNL_ATTRIB_MAX]; GLuint nr_blocks; GLuint CurInstance; diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_draw.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_draw.c index 5b05977fce6..0eba6ee70d1 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_draw.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_draw.c @@ -231,6 +231,8 @@ static GLboolean *_tnl_import_edgeflag( struct gl_context *ctx, return space; } +static const GLfloat zero_floats[4] = {0.0, 0.0, 0.0, 0.0}; + static void bind_inputs( struct gl_context *ctx, const struct gl_client_array *inputs[], @@ -244,7 +246,7 @@ static void bind_inputs( struct gl_context *ctx, /* Map all the VBOs */ - for (i = 0; i < VERT_ATTRIB_MAX; i++) { + for (i = 0; i < _TNL_ATTRIB_MAX; i++) { const void *ptr; if (inputs[i]->BufferObj->Name) { @@ -447,7 +449,7 @@ void _tnl_draw_prims( struct gl_context *ctx, /* May need to map a vertex buffer object for every attribute plus * one for the index buffer. */ - struct gl_buffer_object *bo[VERT_ATTRIB_MAX + 1]; + struct gl_buffer_object *bo[_TNL_ATTRIB_MAX]; GLuint nr_bo = 0; GLuint inst; diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_pipeline.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_pipeline.c index c5e36870d8b..2788d11afc1 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_pipeline.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_pipeline.c @@ -75,7 +75,7 @@ static GLuint check_input_changes( struct gl_context *ctx ) TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint i; - for (i = 0; i <= _TNL_LAST_MAT; i++) { + for (i = 0; i < _TNL_FIRST_MAT; i++) { if (tnl->vb.AttribPtr[i]->size != tnl->pipeline.last_attrib_size[i] || tnl->vb.AttribPtr[i]->stride != tnl->pipeline.last_attrib_stride[i]) { tnl->pipeline.last_attrib_size[i] = tnl->vb.AttribPtr[i]->size; diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_rasterpos.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_rasterpos.c index 165eb09816b..f3bf35a4a67 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_rasterpos.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_rasterpos.c @@ -259,9 +259,9 @@ shade_rastpos(struct gl_context *ctx, */ static void compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye[4], - const GLfloat normal[3], GLuint unit, GLfloat texcoord[4]) + const GLfloat normal[3], GLfloat texcoord[4]) { - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; /* always compute sphere map terms, just in case */ GLfloat u[3], two_nu, rx, ry, rz, m, mInv; @@ -370,103 +370,93 @@ compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye void _tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]) { - if (ctx->VertexProgram._Enabled) { - /* XXX implement this */ - _mesa_problem(ctx, "Vertex programs not implemented for glRasterPos"); + GLfloat eye[4], clip[4], ndc[3], d; + GLfloat *norm, eyenorm[3]; + GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; + + /* apply modelview matrix: eye = MV * obj */ + TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, vObj ); + /* apply projection matrix: clip = Proj * eye */ + TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye ); + + /* clip to view volume. */ + if (viewclip_point_z(clip) == 0) { + ctx->Current.RasterPosValid = GL_FALSE; return; } - else { - GLfloat eye[4], clip[4], ndc[3], d; - GLfloat *norm, eyenorm[3]; - GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; - - /* apply modelview matrix: eye = MV * obj */ - TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, vObj ); - /* apply projection matrix: clip = Proj * eye */ - TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye ); - - /* clip to view volume. */ - if (viewclip_point_z(clip) == 0) { + if (!ctx->Transform.RasterPositionUnclipped) { + if (viewclip_point_xy(clip) == 0) { ctx->Current.RasterPosValid = GL_FALSE; return; } - if (!ctx->Transform.RasterPositionUnclipped) { - if (viewclip_point_xy(clip) == 0) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - } - - /* clip to user clipping planes */ - if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) { - ctx->Current.RasterPosValid = GL_FALSE; - return; - } - - /* ndc = clip / W */ - d = (clip[3] == 0.0F) ? 1.0F : 1.0F / clip[3]; - ndc[0] = clip[0] * d; - ndc[1] = clip[1] * d; - ndc[2] = clip[2] * d; - /* wincoord = viewport_mapping(ndc) */ - ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] - + ctx->Viewport._WindowMap.m[MAT_TX]); - ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] - + ctx->Viewport._WindowMap.m[MAT_TY]); - ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] - + ctx->Viewport._WindowMap.m[MAT_TZ]) - / ctx->DrawBuffer->_DepthMaxF; - ctx->Current.RasterPos[3] = clip[3]; - - /* compute raster distance */ - if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) - ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - else - ctx->Current.RasterDistance = - SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); - - /* compute transformed normal vector (for lighting or texgen) */ - if (ctx->_NeedEyeCoords) { - const GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv; - TRANSFORM_NORMAL( eyenorm, objnorm, inv ); - norm = eyenorm; - } - else { - norm = objnorm; - } - - /* update raster color */ - if (ctx->Light.Enabled) { - /* lighting */ - shade_rastpos( ctx, vObj, norm, - ctx->Current.RasterColor, - ctx->Current.RasterSecondaryColor ); - } - else { - /* use current color */ - COPY_4FV(ctx->Current.RasterColor, - ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); - COPY_4FV(ctx->Current.RasterSecondaryColor, - ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); - } - - /* texture coords */ - { - GLuint u; - for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { - GLfloat tc[4]; - COPY_4V(tc, ctx->Current.Attrib[VERT_ATTRIB_TEX0 + u]); - if (ctx->Texture.Unit[u].TexGenEnabled) { - compute_texgen(ctx, vObj, eye, norm, u, tc); - } - TRANSFORM_POINT(ctx->Current.RasterTexCoords[u], - ctx->TextureMatrixStack[u].Top->m, tc); - } - } - - ctx->Current.RasterPosValid = GL_TRUE; } + /* clip to user clipping planes */ + if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) { + ctx->Current.RasterPosValid = GL_FALSE; + return; + } + + /* ndc = clip / W */ + d = (clip[3] == 0.0F) ? 1.0F : 1.0F / clip[3]; + ndc[0] = clip[0] * d; + ndc[1] = clip[1] * d; + ndc[2] = clip[2] * d; + /* wincoord = viewport_mapping(ndc) */ + ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] + + ctx->Viewport._WindowMap.m[MAT_TX]); + ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] + + ctx->Viewport._WindowMap.m[MAT_TY]); + ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] + + ctx->Viewport._WindowMap.m[MAT_TZ]) + / ctx->DrawBuffer->_DepthMaxF; + ctx->Current.RasterPos[3] = clip[3]; + + /* compute raster distance */ + if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) + ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; + else + ctx->Current.RasterDistance = + SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] ); + + /* compute transformed normal vector (for lighting or texgen) */ + if (ctx->_NeedEyeCoords) { + const GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv; + TRANSFORM_NORMAL( eyenorm, objnorm, inv ); + norm = eyenorm; + } + else { + norm = objnorm; + } + + /* update raster color */ + if (ctx->Light.Enabled) { + /* lighting */ + shade_rastpos( ctx, vObj, norm, + ctx->Current.RasterColor, + ctx->Current.RasterSecondaryColor ); + } + else { + /* use current color */ + COPY_4FV(ctx->Current.RasterColor, + ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); + COPY_4FV(ctx->Current.RasterSecondaryColor, + ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); + } + + /* texture coords */ + { + GLfloat tc[4]; + COPY_4V(tc, ctx->Current.Attrib[VERT_ATTRIB_TEX]); + if (ctx->Texture.Unit.TexGenEnabled) { + compute_texgen(ctx, vObj, eye, norm, tc); + } + TRANSFORM_POINT(ctx->Current.RasterTexCoords, + ctx->TextureMatrixStack.Top->m, tc); + } + + ctx->Current.RasterPosValid = GL_TRUE; + if (ctx->RenderMode == GL_SELECT) { _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); } diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_fog.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_fog.c index cbd8dfc967f..75294e349ce 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_fog.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_fog.c @@ -151,7 +151,7 @@ run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) if (!ctx->Fog.Enabled) return GL_TRUE; - if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && !ctx->VertexProgram._Current) { + if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) { GLuint i; GLfloat *coord; /* Fog is computed from vertex or fragment Z values */ diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_light.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_light.c index 3acedf6e577..a79bc41052e 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_light.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_light.c @@ -201,8 +201,8 @@ static GLboolean run_lighting( struct gl_context *ctx, GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->AttribPtr[_TNL_ATTRIB_POS]; GLuint idx; - if (!ctx->Light.Enabled || ctx->VertexProgram._Current) - return GL_TRUE; + if (!ctx->Light.Enabled) + return GL_TRUE; /* Make sure we can talk about position x,y and z: */ @@ -255,7 +255,7 @@ static void validate_lighting( struct gl_context *ctx, { light_func *tab; - if (!ctx->Light.Enabled || ctx->VertexProgram._Current) + if (!ctx->Light.Enabled) return; if (ctx->Light._NeedVertices) { diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_normals.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_normals.c index c19b48e51ee..fb7bb58223d 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_normals.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_normals.c @@ -93,9 +93,8 @@ validate_normal_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) { struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); - if (ctx->VertexProgram._Current || - (!ctx->Light.Enabled && - !(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))) { + if (!ctx->Light.Enabled && + !(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS)) { store->NormalTransform = NULL; return; } diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_points.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_points.c index 9edbbc708e6..b0110289976 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_points.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_points.c @@ -49,7 +49,7 @@ struct point_stage_data { static GLboolean run_point_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) { - if (ctx->Point._Attenuated && !ctx->VertexProgram._Current) { + if (ctx->Point._Attenuated) { struct point_stage_data *store = POINT_STAGE_DATA(stage); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; const GLfloat *eyeCoord = (GLfloat *) VB->EyePtr->data + 2; diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texgen.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texgen.c index 61430c396d5..d8c2008eeac 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texgen.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texgen.c @@ -55,16 +55,15 @@ struct texgen_stage_data; typedef void (*texgen_func)( struct gl_context *ctx, - struct texgen_stage_data *store, - GLuint unit); + struct texgen_stage_data *store); struct texgen_stage_data { /* Per-texunit derived state. */ - GLuint TexgenSize[MAX_TEXTURE_COORD_UNITS]; - texgen_func TexgenFunc[MAX_TEXTURE_COORD_UNITS]; + GLuint TexgenSize; + texgen_func TexgenFunc; /* Temporary values used in texgen. */ @@ -73,7 +72,7 @@ struct texgen_stage_data { /* Buffered outputs of the stage. */ - GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS]; + GLvector4f texcoord; }; @@ -249,12 +248,11 @@ static build_f_func build_f_tab[5] = { /* Special case texgen functions. */ static void texgen_reflection_map_nv( struct gl_context *ctx, - struct texgen_stage_data *store, - GLuint unit ) + struct texgen_stage_data *store) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit]; - GLvector4f *out = &store->texcoord[unit]; + GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; + GLvector4f *out = &store->texcoord; build_f_tab[VB->EyePtr->size]( out->start, out->stride, @@ -271,12 +269,11 @@ static void texgen_reflection_map_nv( struct gl_context *ctx, static void texgen_normal_map_nv( struct gl_context *ctx, - struct texgen_stage_data *store, - GLuint unit ) + struct texgen_stage_data *store) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit]; - GLvector4f *out = &store->texcoord[unit]; + GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; + GLvector4f *out = &store->texcoord; GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start; GLuint count = VB->Count; @@ -299,12 +296,11 @@ static void texgen_normal_map_nv( struct gl_context *ctx, static void texgen_sphere_map( struct gl_context *ctx, - struct texgen_stage_data *store, - GLuint unit ) + struct texgen_stage_data *store) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit]; - GLvector4f *out = &store->texcoord[unit]; + GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; + GLvector4f *out = &store->texcoord; GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start; GLuint count = VB->Count; GLuint i; @@ -332,14 +328,13 @@ static void texgen_sphere_map( struct gl_context *ctx, static void texgen( struct gl_context *ctx, - struct texgen_stage_data *store, - GLuint unit ) + struct texgen_stage_data *store) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit]; - GLvector4f *out = &store->texcoord[unit]; - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX]; + GLvector4f *out = &store->texcoord; + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit; const GLvector4f *obj = VB->AttribPtr[_TNL_ATTRIB_POS]; const GLvector4f *eye = VB->EyePtr; const GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; @@ -356,7 +351,7 @@ static void texgen( struct gl_context *ctx, } - out->size = MAX2(in->size, store->TexgenSize[unit]); + out->size = MAX2(in->size, store->TexgenSize); out->flags |= (in->flags & VEC_SIZE_FLAGS) | texUnit->TexGenEnabled; out->count = count; @@ -485,19 +480,18 @@ static GLboolean run_texgen_stage( struct gl_context *ctx, { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); - GLuint i; - if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) + if (!ctx->Texture._TexGenEnabled) return GL_TRUE; - for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; if (texUnit->TexGenEnabled) { - store->TexgenFunc[i]( ctx, store, i ); + store->TexgenFunc( ctx, store); - VB->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->texcoord[i]; + VB->AttribPtr[VERT_ATTRIB_TEX] = &store->texcoord; } } @@ -509,41 +503,40 @@ static void validate_texgen_stage( struct gl_context *ctx, struct tnl_pipeline_stage *stage ) { struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); - GLuint i; - if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current) + if (!ctx->Texture._TexGenEnabled) return; - for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit; if (texUnit->TexGenEnabled) { - GLuint sz; + GLuint sz; - if (texUnit->TexGenEnabled & Q_BIT) - sz = 4; - else if (texUnit->TexGenEnabled & R_BIT) - sz = 3; - else if (texUnit->TexGenEnabled & T_BIT) - sz = 2; - else - sz = 1; + if (texUnit->TexGenEnabled & Q_BIT) + sz = 4; + else if (texUnit->TexGenEnabled & R_BIT) + sz = 3; + else if (texUnit->TexGenEnabled & T_BIT) + sz = 2; + else + sz = 1; - store->TexgenSize[i] = sz; - store->TexgenFunc[i] = texgen; /* general solution */ + store->TexgenSize = sz; + store->TexgenFunc = texgen; /* general solution */ - /* look for special texgen cases */ - if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) { - if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) { - store->TexgenFunc[i] = texgen_reflection_map_nv; - } - else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) { - store->TexgenFunc[i] = texgen_normal_map_nv; - } - } + /* look for special texgen cases */ + if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) { + if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) { + store->TexgenFunc = texgen_reflection_map_nv; + } + else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) { + store->TexgenFunc = texgen_normal_map_nv; + } + } else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) && texUnit->_GenFlags == TEXGEN_SPHERE_MAP) { - store->TexgenFunc[i] = texgen_sphere_map; + store->TexgenFunc = texgen_sphere_map; } } } @@ -560,15 +553,13 @@ static GLboolean alloc_texgen_data( struct gl_context *ctx, { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct texgen_stage_data *store; - GLuint i; stage->privatePtr = CALLOC(sizeof(*store)); store = TEXGEN_STAGE_DATA(stage); if (!store) return GL_FALSE; - for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) - _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 ); + _mesa_vector4f_alloc( &store->texcoord, 0, VB->Size, 32 ); store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3); store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat)); @@ -581,12 +572,10 @@ static void free_texgen_data( struct tnl_pipeline_stage *stage ) { struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); - GLuint i; if (store) { - for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) - if (store->texcoord[i].data) - _mesa_vector4f_free( &store->texcoord[i] ); + if (store->texcoord.data) + _mesa_vector4f_free( &store->texcoord ); if (store->tmp_f) FREE( store->tmp_f ); diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texmat.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texmat.c index 38aa51fc496..b3ddc660835 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texmat.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_texmat.c @@ -46,7 +46,7 @@ * is very appealing. */ struct texmat_stage_data { - GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS]; + GLvector4f texcoord; }; #define TEXMAT_STAGE_DATA(stage) ((struct texmat_stage_data *)stage->privatePtr) @@ -58,22 +58,19 @@ static GLboolean run_texmat_stage( struct gl_context *ctx, { struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLuint i; - if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Current) + if (!ctx->Texture._TexMatEnabled) return GL_TRUE; /* ENABLE_TEXMAT implies that the texture matrix is not the * identity, so we don't have to check that here. */ - for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) { - if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) { - (void) TransformRaw( &store->texcoord[i], - ctx->TextureMatrixStack[i].Top, - VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]); + if (ctx->Texture._TexMatEnabled) { + (void) TransformRaw( &store->texcoord, + ctx->TextureMatrixStack.Top, + VB->AttribPtr[_TNL_ATTRIB_TEX]); - VB->AttribPtr[VERT_ATTRIB_TEX0+i] = &store->texcoord[i]; - } + VB->AttribPtr[VERT_ATTRIB_TEX] = &store->texcoord; } return GL_TRUE; @@ -87,15 +84,13 @@ static GLboolean alloc_texmat_data( struct gl_context *ctx, { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct texmat_stage_data *store; - GLuint i; stage->privatePtr = CALLOC(sizeof(*store)); store = TEXMAT_STAGE_DATA(stage); if (!store) return GL_FALSE; - for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) - _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 ); + _mesa_vector4f_alloc( &store->texcoord, 0, VB->Size, 32 ); return GL_TRUE; } @@ -104,12 +99,10 @@ static GLboolean alloc_texmat_data( struct gl_context *ctx, static void free_texmat_data( struct tnl_pipeline_stage *stage ) { struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage); - GLuint i; if (store) { - for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) - if (store->texcoord[i].data) - _mesa_vector4f_free( &store->texcoord[i] ); + if (store->texcoord.data) + _mesa_vector4f_free( &store->texcoord ); FREE( store ); stage->privatePtr = NULL; } diff --git a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_vertex.c b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_vertex.c index 43acd76ebbb..c3de3a503b5 100644 --- a/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_vertex.c +++ b/reactos/dll/opengl/mesa/src/mesa/tnl/t_vb_vertex.c @@ -125,9 +125,6 @@ static GLboolean run_vertex_stage( struct gl_context *ctx, TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - if (ctx->VertexProgram._Current) - return GL_TRUE; - if (ctx->_NeedEyeCoords) { /* Separate modelview transformation: * Use combined ModelProject to avoid some depth artifacts diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo.h b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo.h index 86802d4580e..ed2c9f1c7db 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo.h +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo.h @@ -109,8 +109,6 @@ void vbo_split_prims( struct gl_context *ctx, /* Helpers for dealing translating away non-zero min_index. */ -GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] ); -GLboolean vbo_any_varyings_in_vbos( const struct gl_client_array *arrays[] ); void vbo_rebase_prims( struct gl_context *ctx, const struct gl_client_array *arrays[], @@ -142,43 +140,4 @@ void vbo_bind_arrays(struct gl_context *ctx); size_t count_tessellated_primitives(const struct _mesa_prim *prim); -void GLAPIENTRY -_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); - -void GLAPIENTRY -_es_Normal3f(GLfloat x, GLfloat y, GLfloat z); - -void GLAPIENTRY -_es_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); - -void GLAPIENTRY -_es_Materialfv(GLenum face, GLenum pname, const GLfloat *params); - -void GLAPIENTRY -_es_Materialf(GLenum face, GLenum pname, GLfloat param); - -void GLAPIENTRY -_es_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - -void GLAPIENTRY -_es_VertexAttrib1f(GLuint indx, GLfloat x); - -void GLAPIENTRY -_es_VertexAttrib1fv(GLuint indx, const GLfloat* values); - -void GLAPIENTRY -_es_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); - -void GLAPIENTRY -_es_VertexAttrib2fv(GLuint indx, const GLfloat* values); - -void GLAPIENTRY -_es_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); - -void GLAPIENTRY -_es_VertexAttrib3fv(GLuint indx, const GLfloat* values); - -void GLAPIENTRY -_es_VertexAttrib4fv(GLuint indx, const GLfloat* values); - #endif diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib.h b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib.h index c2f4e6ec889..e0ec4df4ee2 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib.h +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib.h @@ -52,52 +52,23 @@ enum { VBO_ATTRIB_FOG = 5, VBO_ATTRIB_INDEX = 6, VBO_ATTRIB_EDGEFLAG = 7, - VBO_ATTRIB_TEX0 = 8, - VBO_ATTRIB_TEX1 = 9, - VBO_ATTRIB_TEX2 = 10, - VBO_ATTRIB_TEX3 = 11, - VBO_ATTRIB_TEX4 = 12, - VBO_ATTRIB_TEX5 = 13, - VBO_ATTRIB_TEX6 = 14, - VBO_ATTRIB_TEX7 = 15, - VBO_ATTRIB_POINT_SIZE = 16, + VBO_ATTRIB_TEX = 8, + VBO_ATTRIB_POINT_SIZE = 9, + + VBO_ATTRIB_MAT_FRONT_AMBIENT = 10, + VBO_ATTRIB_MAT_BACK_AMBIENT = 11, + VBO_ATTRIB_MAT_FRONT_DIFFUSE = 12, + VBO_ATTRIB_MAT_BACK_DIFFUSE = 13, + VBO_ATTRIB_MAT_FRONT_SPECULAR = 14, + VBO_ATTRIB_MAT_BACK_SPECULAR = 15, + VBO_ATTRIB_MAT_FRONT_EMISSION = 16, + VBO_ATTRIB_MAT_BACK_EMISSION = 17, + VBO_ATTRIB_MAT_FRONT_SHININESS = 18, + VBO_ATTRIB_MAT_BACK_SHININESS = 19, + VBO_ATTRIB_MAT_FRONT_INDEXES = 20, + VBO_ATTRIB_MAT_BACK_INDEXES = 21, - VBO_ATTRIB_GENERIC0 = 17, /* Not used? */ - VBO_ATTRIB_GENERIC1 = 18, - VBO_ATTRIB_GENERIC2 = 19, - VBO_ATTRIB_GENERIC3 = 20, - VBO_ATTRIB_GENERIC4 = 21, - VBO_ATTRIB_GENERIC5 = 22, - VBO_ATTRIB_GENERIC6 = 23, - VBO_ATTRIB_GENERIC7 = 24, - VBO_ATTRIB_GENERIC8 = 25, - VBO_ATTRIB_GENERIC9 = 26, - VBO_ATTRIB_GENERIC10 = 27, - VBO_ATTRIB_GENERIC11 = 28, - VBO_ATTRIB_GENERIC12 = 29, - VBO_ATTRIB_GENERIC13 = 30, - VBO_ATTRIB_GENERIC14 = 31, - VBO_ATTRIB_GENERIC15 = 32, - - /* XXX: in the vertex program InputsRead flag, we alias - * materials and generics and use knowledge about the program - * (whether it is a fixed-function emulation) to - * differentiate. Here we must keep them apart instead. - */ - VBO_ATTRIB_MAT_FRONT_AMBIENT = 33, - VBO_ATTRIB_MAT_BACK_AMBIENT = 34, - VBO_ATTRIB_MAT_FRONT_DIFFUSE = 35, - VBO_ATTRIB_MAT_BACK_DIFFUSE = 36, - VBO_ATTRIB_MAT_FRONT_SPECULAR = 37, - VBO_ATTRIB_MAT_BACK_SPECULAR = 38, - VBO_ATTRIB_MAT_FRONT_EMISSION = 39, - VBO_ATTRIB_MAT_BACK_EMISSION = 40, - VBO_ATTRIB_MAT_FRONT_SHININESS = 41, - VBO_ATTRIB_MAT_BACK_SHININESS = 42, - VBO_ATTRIB_MAT_FRONT_INDEXES = 43, - VBO_ATTRIB_MAT_BACK_INDEXES = 44, - - VBO_ATTRIB_MAX = 45 + VBO_ATTRIB_MAX = 22 }; #define VBO_ATTRIB_FIRST_MATERIAL VBO_ATTRIB_MAT_FRONT_AMBIENT diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib_tmp.h b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib_tmp.h index d0f6404bdbf..2570030b9d5 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib_tmp.h +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_attrib_tmp.h @@ -107,56 +107,56 @@ static void GLAPIENTRY TAG(TexCoord1f)(GLfloat x) { GET_CURRENT_CONTEXT(ctx); - ATTR1F(VBO_ATTRIB_TEX0, x); + ATTR1F(VBO_ATTRIB_TEX, x); } static void GLAPIENTRY TAG(TexCoord1fv)(const GLfloat * v) { GET_CURRENT_CONTEXT(ctx); - ATTR1FV(VBO_ATTRIB_TEX0, v); + ATTR1FV(VBO_ATTRIB_TEX, v); } static void GLAPIENTRY TAG(TexCoord2f)(GLfloat x, GLfloat y) { GET_CURRENT_CONTEXT(ctx); - ATTR2F(VBO_ATTRIB_TEX0, x, y); + ATTR2F(VBO_ATTRIB_TEX, x, y); } static void GLAPIENTRY TAG(TexCoord2fv)(const GLfloat * v) { GET_CURRENT_CONTEXT(ctx); - ATTR2FV(VBO_ATTRIB_TEX0, v); + ATTR2FV(VBO_ATTRIB_TEX, v); } static void GLAPIENTRY TAG(TexCoord3f)(GLfloat x, GLfloat y, GLfloat z) { GET_CURRENT_CONTEXT(ctx); - ATTR3F(VBO_ATTRIB_TEX0, x, y, z); + ATTR3F(VBO_ATTRIB_TEX, x, y, z); } static void GLAPIENTRY TAG(TexCoord3fv)(const GLfloat * v) { GET_CURRENT_CONTEXT(ctx); - ATTR3FV(VBO_ATTRIB_TEX0, v); + ATTR3FV(VBO_ATTRIB_TEX, v); } static void GLAPIENTRY TAG(TexCoord4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) { GET_CURRENT_CONTEXT(ctx); - ATTR4F(VBO_ATTRIB_TEX0, x, y, z, w); + ATTR4F(VBO_ATTRIB_TEX, x, y, z, w); } static void GLAPIENTRY TAG(TexCoord4fv)(const GLfloat * v) { GET_CURRENT_CONTEXT(ctx); - ATTR4FV(VBO_ATTRIB_TEX0, v); + ATTR4FV(VBO_ATTRIB_TEX, v); } @@ -264,348 +264,6 @@ TAG(Indexfv)(const GLfloat * f) -static void GLAPIENTRY -TAG(MultiTexCoord1f)(GLenum target, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR1F(attr, x); -} - -static void GLAPIENTRY -TAG(MultiTexCoord1fv)(GLenum target, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR1FV(attr, v); -} - -static void GLAPIENTRY -TAG(MultiTexCoord2f)(GLenum target, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR2F(attr, x, y); -} - -static void GLAPIENTRY -TAG(MultiTexCoord2fv)(GLenum target, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR2FV(attr, v); -} - -static void GLAPIENTRY -TAG(MultiTexCoord3f)(GLenum target, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR3F(attr, x, y, z); -} - -static void GLAPIENTRY -TAG(MultiTexCoord3fv)(GLenum target, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR3FV(attr, v); -} - -static void GLAPIENTRY -TAG(MultiTexCoord4f)(GLenum target, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR4F(attr, x, y, z, w); -} - -static void GLAPIENTRY -TAG(MultiTexCoord4fv)(GLenum target, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0; - ATTR4FV(attr, v); -} - - - -static void GLAPIENTRY -TAG(VertexAttrib1fARB)(GLuint index, GLfloat x) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR1F(0, x); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR1F(VBO_ATTRIB_GENERIC0 + index, x); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttrib1fvARB)(GLuint index, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR1FV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttrib2fARB)(GLuint index, GLfloat x, GLfloat y) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR2F(0, x, y); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttrib2fvARB)(GLuint index, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR2FV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttrib3fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR3F(0, x, y, z); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttrib3fvARB)(GLuint index, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR3FV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttrib4fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR4F(0, x, y, z, w); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttrib4fvARB)(GLuint index, const GLfloat * v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR4FV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - - - -/* Integer-valued generic attributes. - * XXX: the integers just get converted to floats at this time - */ -static void GLAPIENTRY -TAG(VertexAttribI1i)(GLuint index, GLint x) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR1I(0, x); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR1I(VBO_ATTRIB_GENERIC0 + index, x); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI2i)(GLuint index, GLint x, GLint y) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR2I(0, x, y); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR2I(VBO_ATTRIB_GENERIC0 + index, x, y); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR3I(0, x, y, z); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR3I(VBO_ATTRIB_GENERIC0 + index, x, y, z); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR4I(0, x, y, z, w); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR4I(VBO_ATTRIB_GENERIC0 + index, x, y, z, w); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI2iv)(GLuint index, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR2IV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR2IV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI3iv)(GLuint index, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR3IV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR3IV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI4iv)(GLuint index, const GLint *v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR4IV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR4IV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - - - -/* Unsigned integer-valued generic attributes. - * XXX: the integers just get converted to floats at this time - */ -static void GLAPIENTRY -TAG(VertexAttribI1ui)(GLuint index, GLuint x) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR1UI(0, x); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR1UI(VBO_ATTRIB_GENERIC0 + index, x); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI2ui)(GLuint index, GLuint x, GLuint y) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR2UI(0, x, y); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR2UI(VBO_ATTRIB_GENERIC0 + index, x, y); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR3UI(0, x, y, z); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR3UI(VBO_ATTRIB_GENERIC0 + index, x, y, z); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR4UI(0, x, y, z, w); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR4UI(VBO_ATTRIB_GENERIC0 + index, x, y, z, w); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI2uiv)(GLuint index, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR2UIV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR2UIV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI3uiv)(GLuint index, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR3UIV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR3UIV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - -static void GLAPIENTRY -TAG(VertexAttribI4uiv)(GLuint index, const GLuint *v) -{ - GET_CURRENT_CONTEXT(ctx); - if (index == 0) - ATTR4UIV(0, v); - else if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR4UIV(VBO_ATTRIB_GENERIC0 + index, v); - else - ERROR(GL_INVALID_VALUE); -} - - - /* In addition to supporting NV_vertex_program, these entrypoints are * used by the display list and other code specifically because of * their property of aliasing with other attributes. (See diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.c index 116e3857ce5..7724b00ee85 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.c @@ -50,12 +50,12 @@ static void init_legacy_currval(struct gl_context *ctx) struct gl_client_array *arrays = vbo->legacy_currval; GLuint i; - memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_FF_MAX); + memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_MAX); /* Set up a constant (StrideB == 0) array for each current * attribute: */ - for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) { + for (i = 0; i < VERT_ATTRIB_MAX; i++) { struct gl_client_array *cl = &arrays[i]; /* Size will have to be determined at runtime: @@ -73,32 +73,6 @@ static void init_legacy_currval(struct gl_context *ctx) } -static void init_generic_currval(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct gl_client_array *arrays = vbo->generic_currval; - GLuint i; - - memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_GENERIC_MAX); - - for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) { - struct gl_client_array *cl = &arrays[i]; - - /* This will have to be determined at runtime: - */ - cl->Size = 1; - cl->Type = GL_FLOAT; - cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; - cl->Stride = 0; - cl->StrideB = 0; - cl->Enabled = 1; - cl->_ElementSize = cl->Size * sizeof(GLfloat); - _mesa_reference_buffer_object(ctx, &cl->BufferObj, - ctx->Shared->NullBufferObj); - } -} - - static void init_mat_currval(struct gl_context *ctx) { struct vbo_context *vbo = vbo_context(ctx); @@ -118,7 +92,7 @@ static void init_mat_currval(struct gl_context *ctx) /* Size is fixed for the material attributes, for others will * be determined at runtime: */ - switch (i - VERT_ATTRIB_GENERIC0) { + switch (i) { case MAT_ATTRIB_FRONT_SHININESS: case MAT_ATTRIB_BACK_SHININESS: cl->Size = 1; @@ -132,7 +106,7 @@ static void init_mat_currval(struct gl_context *ctx) break; } - cl->Ptr = (const void *)ctx->Light.Material.Attrib[i]; + cl->Ptr = (const void*)ctx->Light.Material.Attrib[i]; cl->Type = GL_FLOAT; cl->Stride = 0; cl->StrideB = 0; @@ -160,31 +134,11 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) /* TODO: remove these pointers. */ vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS]; - vbo->generic_currval = &vbo->currval[VBO_ATTRIB_GENERIC0]; vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT]; init_legacy_currval( ctx ); - init_generic_currval( ctx ); init_mat_currval( ctx ); - /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type - * of vertex program active. - */ - { - GLuint i; - - /* identity mapping */ - for (i = 0; i < Elements(vbo->map_vp_none); i++) - vbo->map_vp_none[i] = i; - /* map material attribs to generic slots */ - for (i = 0; i < NR_MAT_ATTRIBS; i++) - vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] - = VBO_ATTRIB_MAT_FRONT_AMBIENT + i; - - for (i = 0; i < Elements(vbo->map_vp_arb); i++) - vbo->map_vp_arb[i] = i; - } - /* Hook our functions into exec and compile dispatch tables. These * will pretty much be permanently installed, which means that the diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.h b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.h index 86c1ae38b94..221828d4906 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.h +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_context.h @@ -64,13 +64,8 @@ struct vbo_context { /* These point into the above. TODO: remove. */ struct gl_client_array *legacy_currval; - struct gl_client_array *generic_currval; struct gl_client_array *mat_currval; - /** Map VERT_ATTRIB_x to VBO_ATTRIB_y */ - GLuint map_vp_none[VERT_ATTRIB_MAX]; - GLuint map_vp_arb[VERT_ATTRIB_MAX]; - GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->Current, ctx->Light.Material */ GLfloat CurrentFloatEdgeFlag; @@ -93,20 +88,4 @@ static inline struct vbo_context *vbo_context(struct gl_context *ctx) } -/** - * Return VP_x token to indicate whether we're running fixed-function - * vertex transformation, an NV vertex program or ARB vertex program/shader. - */ -static inline enum vp_mode -get_program_mode( struct gl_context *ctx ) -{ - if (!ctx->VertexProgram._Current) - return VP_NONE; - else if (ctx->VertexProgram._Current->IsNVProgram) - return VP_NV; - else - return VP_ARB; -} - - #endif diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.c index 05c3ec1ae9d..472cf88688e 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.c @@ -85,7 +85,7 @@ void vbo_exec_invalidate_state( struct gl_context *ctx, GLuint new_state ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - if (new_state & (_NEW_PROGRAM|_NEW_EVAL)) + if (new_state & _NEW_EVAL) exec->eval.recalculate_maps = 1; _ae_invalidate_state(ctx, new_state); diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.h b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.h index f6ede99cd75..a016666e8d6 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.h +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec.h @@ -119,13 +119,13 @@ struct vbo_exec_context GLubyte active_sz[VBO_ATTRIB_MAX]; GLfloat *attrptr[VBO_ATTRIB_MAX]; - struct gl_client_array arrays[VERT_ATTRIB_MAX]; + struct gl_client_array arrays[VBO_ATTRIB_MAX]; /* According to program mode, the values above plus current * values are squashed down to the 32 attributes passed to the * vertex program below: */ - const struct gl_client_array *inputs[VERT_ATTRIB_MAX]; + const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; } vtx; @@ -140,7 +140,7 @@ struct vbo_exec_context * mode, etc. These are the attributes as seen by vertex * programs: */ - const struct gl_client_array *inputs[VERT_ATTRIB_MAX]; + const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; } array; /* Which flags to set in vbo_exec_BeginVertices() */ diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_api.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_api.c index 82789f9cf2e..b4db10f91a8 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_api.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_api.c @@ -154,7 +154,7 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) /* Note: the exec->vtx.current[i] pointers point into the * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. */ - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; + GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; GLfloat tmp[4]; COPY_CLEAN_4V(tmp, @@ -176,8 +176,7 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) /* This triggers rather too much recalculation of Mesa state * that doesn't get used (eg light positions). */ - if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && - i <= VBO_ATTRIB_MAT_BACK_INDEXES) + if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && i <= VBO_ATTRIB_MAT_BACK_INDEXES) ctx->NewState |= _NEW_LIGHT; ctx->NewState |= _NEW_CURRENT_ATTRIB; @@ -561,7 +560,7 @@ static void GLAPIENTRY vbo_exec_EvalCoord1f( GLfloat u ) if (exec->eval.recalculate_maps) vbo_exec_eval_update( exec ); - for (i = 0; i <= VBO_ATTRIB_TEX7; i++) { + for (i = 0; i <= VBO_ATTRIB_TEX; i++) { if (exec->eval.map1[i].map) if (exec->vtx.active_sz[i] != exec->eval.map1[i].sz) vbo_exec_fixup_vertex( ctx, i, exec->eval.map1[i].sz ); @@ -588,7 +587,7 @@ static void GLAPIENTRY vbo_exec_EvalCoord2f( GLfloat u, GLfloat v ) if (exec->eval.recalculate_maps) vbo_exec_eval_update( exec ); - for (i = 0; i <= VBO_ATTRIB_TEX7; i++) { + for (i = 0; i <= VBO_ATTRIB_TEX; i++) { if (exec->eval.map2[i].map) if (exec->vtx.active_sz[i] != exec->eval.map2[i].sz) vbo_exec_fixup_vertex( ctx, i, exec->eval.map2[i].sz ); @@ -668,8 +667,7 @@ vbo_exec_EvalMesh1(GLenum mode, GLint i1, GLint i2) /* No effect if vertex maps disabled. */ if (!ctx->Eval.Map1Vertex4 && - !ctx->Eval.Map1Vertex3 && - !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) + !ctx->Eval.Map1Vertex3) return; du = ctx->Eval.MapGrid1du; @@ -705,8 +703,7 @@ vbo_exec_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) /* No effect if vertex maps disabled. */ if (!ctx->Eval.Map2Vertex4 && - !ctx->Eval.Map2Vertex3 && - !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) + !ctx->Eval.Map2Vertex3) return; du = ctx->Eval.MapGrid2du; @@ -888,14 +885,6 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) vfmt->Color4fv = vbo_Color4fv; vfmt->FogCoordfEXT = vbo_FogCoordfEXT; vfmt->FogCoordfvEXT = vbo_FogCoordfvEXT; - vfmt->MultiTexCoord1fARB = vbo_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = vbo_MultiTexCoord1fv; - vfmt->MultiTexCoord2fARB = vbo_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = vbo_MultiTexCoord2fv; - vfmt->MultiTexCoord3fARB = vbo_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = vbo_MultiTexCoord3fv; - vfmt->MultiTexCoord4fARB = vbo_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = vbo_MultiTexCoord4fv; vfmt->Normal3f = vbo_Normal3f; vfmt->Normal3fv = vbo_Normal3fv; vfmt->SecondaryColor3fEXT = vbo_SecondaryColor3fEXT; @@ -914,15 +903,6 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) vfmt->Vertex3fv = vbo_Vertex3fv; vfmt->Vertex4f = vbo_Vertex4f; vfmt->Vertex4fv = vbo_Vertex4fv; - - vfmt->VertexAttrib1fARB = vbo_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = vbo_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = vbo_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = vbo_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = vbo_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = vbo_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = vbo_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = vbo_VertexAttrib4fvARB; vfmt->VertexAttrib1fNV = vbo_VertexAttrib1fNV; vfmt->VertexAttrib1fvNV = vbo_VertexAttrib1fvNV; @@ -933,24 +913,6 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) vfmt->VertexAttrib4fNV = vbo_VertexAttrib4fNV; vfmt->VertexAttrib4fvNV = vbo_VertexAttrib4fvNV; - /* integer-valued */ - vfmt->VertexAttribI1i = vbo_VertexAttribI1i; - vfmt->VertexAttribI2i = vbo_VertexAttribI2i; - vfmt->VertexAttribI3i = vbo_VertexAttribI3i; - vfmt->VertexAttribI4i = vbo_VertexAttribI4i; - vfmt->VertexAttribI2iv = vbo_VertexAttribI2iv; - vfmt->VertexAttribI3iv = vbo_VertexAttribI3iv; - vfmt->VertexAttribI4iv = vbo_VertexAttribI4iv; - - /* unsigned integer-valued */ - vfmt->VertexAttribI1ui = vbo_VertexAttribI1ui; - vfmt->VertexAttribI2ui = vbo_VertexAttribI2ui; - vfmt->VertexAttribI3ui = vbo_VertexAttribI3ui; - vfmt->VertexAttribI4ui = vbo_VertexAttribI4ui; - vfmt->VertexAttribI2uiv = vbo_VertexAttribI2uiv; - vfmt->VertexAttribI3uiv = vbo_VertexAttribI3uiv; - vfmt->VertexAttribI4uiv = vbo_VertexAttribI4uiv; - vfmt->Materialfv = vbo_Materialfv; vfmt->EdgeFlag = vbo_EdgeFlag; @@ -998,15 +960,6 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) (void) vbo_Vertex4f; (void) vbo_Vertex4fv; - (void) vbo_VertexAttrib1fARB; - (void) vbo_VertexAttrib1fvARB; - (void) vbo_VertexAttrib2fARB; - (void) vbo_VertexAttrib2fvARB; - (void) vbo_VertexAttrib3fARB; - (void) vbo_VertexAttrib3fvARB; - (void) vbo_VertexAttrib4fARB; - (void) vbo_VertexAttrib4fvARB; - (void) vbo_VertexAttrib1fNV; (void) vbo_VertexAttrib1fvNV; (void) vbo_VertexAttrib2fNV; @@ -1117,24 +1070,14 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) unsigned i; memcpy(arrays, vbo->legacy_currval, - VERT_ATTRIB_FF_MAX * sizeof(arrays[0])); - for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) { + VERT_ATTRIB_MAX * sizeof(arrays[0])); + for (i = 0; i < VERT_ATTRIB_MAX; ++i) { struct gl_client_array *array; - array = &arrays[VERT_ATTRIB_FF(i)]; + array = &arrays[VERT_ATTRIB(i)]; array->BufferObj = NULL; _mesa_reference_buffer_object(ctx, &arrays->BufferObj, vbo->legacy_currval[i].BufferObj); } - - memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval, - VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0])); - for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) { - struct gl_client_array *array; - array = &arrays[VERT_ATTRIB_GENERIC(i)]; - array->BufferObj = NULL; - _mesa_reference_buffer_object(ctx, &array->BufferObj, - vbo->generic_currval[i].BufferObj); - } } exec->vtx.vertex_size = 0; @@ -1241,112 +1184,4 @@ static void reset_attrfv( struct vbo_exec_context *exec ) } exec->vtx.vertex_size = 0; -} - - -void GLAPIENTRY -_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) -{ - vbo_Color4f(r, g, b, a); -} - - -void GLAPIENTRY -_es_Normal3f(GLfloat x, GLfloat y, GLfloat z) -{ - vbo_Normal3f(x, y, z); -} - - -void GLAPIENTRY -_es_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) -{ - vbo_MultiTexCoord4f(target, s, t, r, q); -} - - -void GLAPIENTRY -_es_Materialfv(GLenum face, GLenum pname, const GLfloat *params) -{ - vbo_Materialfv(face, pname, params); -} - - -void GLAPIENTRY -_es_Materialf(GLenum face, GLenum pname, GLfloat param) -{ - GLfloat p[4]; - p[0] = param; - p[1] = p[2] = p[3] = 0.0F; - vbo_Materialfv(face, pname, p); -} - - -/** - * A special version of glVertexAttrib4f that does not treat index 0 as - * VBO_ATTRIB_POS. - */ -static void -VertexAttrib4f_nopos(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) - ATTR(VBO_ATTRIB_GENERIC0 + index, 4, x, y, z, w); - else - ERROR(GL_INVALID_VALUE); -} - -void GLAPIENTRY -_es_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - VertexAttrib4f_nopos(index, x, y, z, w); -} - - -void GLAPIENTRY -_es_VertexAttrib1f(GLuint indx, GLfloat x) -{ - VertexAttrib4f_nopos(indx, x, 0.0f, 0.0f, 1.0f); -} - - -void GLAPIENTRY -_es_VertexAttrib1fv(GLuint indx, const GLfloat* values) -{ - VertexAttrib4f_nopos(indx, values[0], 0.0f, 0.0f, 1.0f); -} - - -void GLAPIENTRY -_es_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) -{ - VertexAttrib4f_nopos(indx, x, y, 0.0f, 1.0f); -} - - -void GLAPIENTRY -_es_VertexAttrib2fv(GLuint indx, const GLfloat* values) -{ - VertexAttrib4f_nopos(indx, values[0], values[1], 0.0f, 1.0f); -} - - -void GLAPIENTRY -_es_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) -{ - VertexAttrib4f_nopos(indx, x, y, z, 1.0f); -} - - -void GLAPIENTRY -_es_VertexAttrib3fv(GLuint indx, const GLfloat* values) -{ - VertexAttrib4f_nopos(indx, values[0], values[1], values[2], 1.0f); -} - - -void GLAPIENTRY -_es_VertexAttrib4fv(GLuint indx, const GLfloat* values) -{ - VertexAttrib4f_nopos(indx, values[0], values[1], values[2], values[3]); -} +} \ No newline at end of file diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_array.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_array.c index 8c937bf8cfa..b4528c799f9 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_array.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_array.c @@ -48,7 +48,7 @@ check_buffers_are_unmapped(const struct gl_client_array **inputs) #ifdef DEBUG GLuint i; - for (i = 0; i < VERT_ATTRIB_MAX; i++) { + for (i = 0; i < VBO_ATTRIB_MAX; i++) { if (inputs[i]) { struct gl_buffer_object *obj = inputs[i]->BufferObj; assert(!_mesa_bufferobj_mapped(obj)); @@ -315,7 +315,7 @@ print_draw_arrays(struct gl_context *ctx, exec->array.inputs[i]->Size, stride, /*exec->array.inputs[i]->Enabled,*/ - arrayObj->VertexAttrib[VERT_ATTRIB_FF(i)].Enabled, + arrayObj->VertexAttrib[VERT_ATTRIB(i)].Enabled, exec->array.inputs[i]->Ptr, bufName); @@ -357,106 +357,17 @@ recalculate_input_bindings(struct gl_context *ctx) GLbitfield64 const_inputs = 0x0; GLuint i; - switch (get_program_mode(ctx)) { - case VP_NONE: - /* When no vertex program is active (or the vertex program is generated - * from fixed-function state). We put the material values into the - * generic slots. This is the only situation where material values - * are available as per-vertex attributes. - */ - for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) { - if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled) - inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)]; - else { - inputs[i] = &vbo->legacy_currval[i]; - const_inputs |= VERT_BIT(i); - } - } - - for (i = 0; i < MAT_ATTRIB_MAX; i++) { - inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->mat_currval[i]; - const_inputs |= VERT_BIT_GENERIC(i); - } - - /* Could use just about anything, just to fill in the empty - * slots: - */ - for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) { - inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i]; - const_inputs |= VERT_BIT_GENERIC(i); - } - - ctx->NewState |= _NEW_ARRAY; - break; - - case VP_NV: - /* NV_vertex_program - attribute arrays alias and override - * conventional, legacy arrays. No materials, and the generic - * slots are vacant. - */ - for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) { - if (i < VERT_ATTRIB_GENERIC_MAX - && vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) - inputs[i] = &vertexAttrib[VERT_ATTRIB_GENERIC(i)]; - else if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled) - inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)]; - else { - inputs[i] = &vbo->legacy_currval[i]; - const_inputs |= VERT_BIT_FF(i); - } - } - - /* Could use just about anything, just to fill in the empty - * slots: - */ - for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) { - inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i]; - const_inputs |= VERT_BIT_GENERIC(i); - } - - ctx->NewState |= _NEW_ARRAY; - break; - - case VP_ARB: - /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0] - * attribute array aliases and overrides the legacy position array. - * - * Otherwise, legacy attributes available in the legacy slots, - * generic attributes in the generic slots and materials are not - * available as per-vertex attributes. - */ - if (vertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) - inputs[0] = &vertexAttrib[VERT_ATTRIB_GENERIC0]; - else if (vertexAttrib[VERT_ATTRIB_POS].Enabled) - inputs[0] = &vertexAttrib[VERT_ATTRIB_POS]; + for (i = 0; i < VBO_ATTRIB_MAX; i++) { + if ((i < VERT_ATTRIB_MAX) && (vertexAttrib[VERT_ATTRIB(i)].Enabled)) + inputs[i] = &vertexAttrib[VERT_ATTRIB(i)]; else { - inputs[0] = &vbo->legacy_currval[0]; - const_inputs |= VERT_BIT_POS; + inputs[i] = &vbo->currval[i]; + const_inputs |= VERT_BIT(i); } - - for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) { - if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled) - inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)]; - else { - inputs[i] = &vbo->legacy_currval[i]; - const_inputs |= VERT_BIT_FF(i); - } - } - - for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { - if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) - inputs[VERT_ATTRIB_GENERIC(i)] = &vertexAttrib[VERT_ATTRIB_GENERIC(i)]; - else { - inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i]; - const_inputs |= VERT_BIT_GENERIC(i); - } - } - - inputs[VERT_ATTRIB_GENERIC0] = inputs[0]; - ctx->NewState |= _NEW_ARRAY; - break; } + ctx->NewState |= _NEW_ARRAY; + _mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) ); } @@ -795,149 +706,6 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, } - -/** - * Inner support for both _mesa_MultiDrawElements() and - * _mesa_MultiDrawRangeElements(). - * This does the actual rendering after we've checked array indexes, etc. - */ -static void -vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct _mesa_index_buffer ib; - struct _mesa_prim *prim; - unsigned int index_type_size = vbo_sizeof_ib_type(type); - uintptr_t min_index_ptr, max_index_ptr; - GLboolean fallback = GL_FALSE; - int i; - - if (primcount == 0) - return; - - FLUSH_CURRENT( ctx, 0 ); - - if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) { - return; - } - - prim = calloc(1, primcount * sizeof(*prim)); - if (prim == NULL) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements"); - return; - } - - /* Decide if we can do this all as one set of primitives sharing the - * same index buffer, or if we have to reset the index pointer per - * primitive. - */ - vbo_bind_arrays( ctx ); - - /* check for dirty state again */ - if (ctx->NewState) - _mesa_update_state( ctx ); - - min_index_ptr = (uintptr_t)indices[0]; - max_index_ptr = 0; - for (i = 0; i < primcount; i++) { - min_index_ptr = MIN2(min_index_ptr, (uintptr_t)indices[i]); - max_index_ptr = MAX2(max_index_ptr, (uintptr_t)indices[i] + - index_type_size * count[i]); - } - - /* Check if we can handle this thing as a bunch of index offsets from the - * same index pointer. If we can't, then we have to fall back to doing - * a draw_prims per primitive. - * Check that the difference between each prim's indexes is a multiple of - * the index/element size. - */ - if (index_type_size != 1) { - for (i = 0; i < primcount; i++) { - if ((((uintptr_t)indices[i] - min_index_ptr) % index_type_size) != 0) { - fallback = GL_TRUE; - break; - } - } - } - - /* If the index buffer isn't in a VBO, then treating the application's - * subranges of the index buffer as one large index buffer may lead to - * us reading unmapped memory. - */ - if (!_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) - fallback = GL_TRUE; - - if (!fallback) { - ib.count = (max_index_ptr - min_index_ptr) / index_type_size; - ib.type = type; - ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj; - ib.ptr = (void *)min_index_ptr; - - for (i = 0; i < primcount; i++) { - prim[i].begin = (i == 0); - prim[i].end = (i == primcount - 1); - prim[i].weak = 0; - prim[i].pad = 0; - prim[i].mode = mode; - prim[i].start = ((uintptr_t)indices[i] - min_index_ptr) / index_type_size; - prim[i].count = count[i]; - prim[i].indexed = 1; - prim[i].num_instances = 1; - } - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib, - GL_FALSE, ~0, ~0); - } else { - /* render one prim at a time */ - for (i = 0; i < primcount; i++) { - ib.count = count[i]; - ib.type = type; - ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj; - ib.ptr = indices[i]; - - prim[0].begin = 1; - prim[0].end = 1; - prim[0].weak = 0; - prim[0].pad = 0; - prim[0].mode = mode; - prim[0].start = 0; - prim[0].count = count[i]; - prim[0].indexed = 1; - prim[0].num_instances = 1; - - check_buffers_are_unmapped(exec->array.inputs); - vbo->draw_prims(ctx, exec->array.inputs, prim, 1, &ib, - GL_FALSE, ~0, ~0); - } - } - - free(prim); -} - - -static void GLAPIENTRY -vbo_exec_MultiDrawElements(GLenum mode, - const GLsizei *count, GLenum type, - const GLvoid **indices, - GLsizei primcount) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - for (i = 0; i < primcount; i++) { - if (!_mesa_validate_DrawElements(ctx, mode, count[i], type, indices[i])) - return; - } - - vbo_validated_multidrawelements(ctx, mode, count, type, indices, primcount); -} - /** * Plug in the immediate-mode vertex array drawing commands into the * givven vbo_exec_context object. @@ -948,7 +716,6 @@ vbo_exec_array_init( struct vbo_exec_context *exec ) exec->vtxfmt.DrawArrays = vbo_exec_DrawArrays; exec->vtxfmt.DrawElements = vbo_exec_DrawElements; exec->vtxfmt.DrawRangeElements = vbo_exec_DrawRangeElements; - exec->vtxfmt.MultiDrawElementsEXT = vbo_exec_MultiDrawElements; } @@ -988,11 +755,3 @@ _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, vbo_exec_DrawRangeElements(mode, start, end, count, type, indices); } - -void GLAPIENTRY -_mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) -{ - vbo_exec_MultiDrawElements(mode, count, type, indices, primcount); -} - diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_draw.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_draw.c index d414b6578f5..7cc922b30ca 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_draw.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_draw.c @@ -164,63 +164,23 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) struct vbo_exec_context *exec = &vbo->exec; struct gl_client_array *arrays = exec->vtx.arrays; const GLuint count = exec->vtx.vert_count; - const GLuint *map; GLuint attr; GLbitfield64 varying_inputs = 0x0; /* Install the default (ie Current) attributes first, then overlay * all active ones. */ - switch (get_program_mode(exec->ctx)) { - case VP_NONE: - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) { - exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; - } - for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { - ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); - exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->mat_currval[attr]; - } - map = vbo->map_vp_none; - break; - case VP_NV: - case VP_ARB: - /* The aliasing of attributes for NV vertex programs has already - * occurred. NV vertex programs cannot access material values, - * nor attributes greater than VERT_ATTRIB_TEX7. - */ - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) { - exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; - } - for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) { - ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); - exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->generic_currval[attr]; - } - map = vbo->map_vp_arb; - - /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. - * In that case we effectively need to route the data from - * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. - */ - if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 && - (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { - exec->vtx.inputs[VERT_ATTRIB_GENERIC0] = exec->vtx.inputs[0]; - exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0]; - exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0]; - exec->vtx.attrsz[0] = 0; - } - break; - default: - assert(0); + for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { + exec->vtx.inputs[attr] = &vbo->legacy_currval[attr]; } /* Make all active attributes (including edgeflag) available as * arrays of floats. */ - for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) { - const GLuint src = map[attr]; + for (attr = 0; attr < VBO_ATTRIB_MAX ; attr++) { - if (exec->vtx.attrsz[src]) { - GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[src] - + if (exec->vtx.attrsz[attr]) { + GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[attr] - (GLbyte *)exec->vtx.vertex; /* override the default array set above */ @@ -238,7 +198,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) /* Ptr into ordinary app memory */ arrays[attr].Ptr = (GLubyte *)exec->vtx.buffer_map + offset; } - arrays[attr].Size = exec->vtx.attrsz[src]; + arrays[attr].Size = exec->vtx.attrsz[attr]; arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_eval.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_eval.c index 1e8c3c45bb5..fc7f1a761b1 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_eval.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_exec_eval.c @@ -84,22 +84,22 @@ void vbo_exec_eval_update( struct vbo_exec_context *exec ) set_active_eval2( exec, VBO_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map2Color4 ); if (ctx->Eval.Map1TextureCoord4) - set_active_eval1( exec, VBO_ATTRIB_TEX0, 4, &ctx->EvalMap.Map1Texture4 ); + set_active_eval1( exec, VBO_ATTRIB_TEX, 4, &ctx->EvalMap.Map1Texture4 ); else if (ctx->Eval.Map1TextureCoord3) - set_active_eval1( exec, VBO_ATTRIB_TEX0, 3, &ctx->EvalMap.Map1Texture3 ); + set_active_eval1( exec, VBO_ATTRIB_TEX, 3, &ctx->EvalMap.Map1Texture3 ); else if (ctx->Eval.Map1TextureCoord2) - set_active_eval1( exec, VBO_ATTRIB_TEX0, 2, &ctx->EvalMap.Map1Texture2 ); + set_active_eval1( exec, VBO_ATTRIB_TEX, 2, &ctx->EvalMap.Map1Texture2 ); else if (ctx->Eval.Map1TextureCoord1) - set_active_eval1( exec, VBO_ATTRIB_TEX0, 1, &ctx->EvalMap.Map1Texture1 ); + set_active_eval1( exec, VBO_ATTRIB_TEX, 1, &ctx->EvalMap.Map1Texture1 ); if (ctx->Eval.Map2TextureCoord4) - set_active_eval2( exec, VBO_ATTRIB_TEX0, 4, &ctx->EvalMap.Map2Texture4 ); + set_active_eval2( exec, VBO_ATTRIB_TEX, 4, &ctx->EvalMap.Map2Texture4 ); else if (ctx->Eval.Map2TextureCoord3) - set_active_eval2( exec, VBO_ATTRIB_TEX0, 3, &ctx->EvalMap.Map2Texture3 ); + set_active_eval2( exec, VBO_ATTRIB_TEX, 3, &ctx->EvalMap.Map2Texture3 ); else if (ctx->Eval.Map2TextureCoord2) - set_active_eval2( exec, VBO_ATTRIB_TEX0, 2, &ctx->EvalMap.Map2Texture2 ); + set_active_eval2( exec, VBO_ATTRIB_TEX, 2, &ctx->EvalMap.Map2Texture2 ); else if (ctx->Eval.Map2TextureCoord1) - set_active_eval2( exec, VBO_ATTRIB_TEX0, 1, &ctx->EvalMap.Map2Texture1 ); + set_active_eval2( exec, VBO_ATTRIB_TEX, 1, &ctx->EvalMap.Map2Texture1 ); if (ctx->Eval.Map1Normal) set_active_eval1( exec, VBO_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map1Normal ); @@ -117,23 +117,6 @@ void vbo_exec_eval_update( struct vbo_exec_context *exec ) else if (ctx->Eval.Map2Vertex3) set_active_eval2( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 ); - /* _NEW_PROGRAM */ - if (ctx->VertexProgram._Enabled) { - /* These are the 16 evaluators which GL_NV_vertex_program defines. - * They alias and override the conventional vertex attributs. - */ - for (attr = 0; attr < 16; attr++) { - /* _NEW_EVAL */ - assert(attr < Elements(ctx->Eval.Map1Attrib)); - if (ctx->Eval.Map1Attrib[attr]) - set_active_eval1( exec, attr, 4, &ctx->EvalMap.Map1Attrib[attr] ); - - assert(attr < Elements(ctx->Eval.Map2Attrib)); - if (ctx->Eval.Map2Attrib[attr]) - set_active_eval2( exec, attr, 4, &ctx->EvalMap.Map2Attrib[attr] ); - } - } - exec->eval.recalculate_maps = 0; } @@ -143,7 +126,7 @@ void vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u) { GLuint attr; - for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) { + for (attr = 1; attr <= VBO_ATTRIB_TEX; attr++) { struct gl_1d_map *map = exec->eval.map1[attr].map; if (map) { GLfloat uu = (u - map->u1) * map->du; @@ -188,7 +171,7 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, { GLuint attr; - for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) { + for (attr = 1; attr <= VBO_ATTRIB_TEX; attr++) { struct gl_2d_map *map = exec->eval.map2[attr].map; if (map) { GLfloat uu = (u - map->u1) * map->du; diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_noop.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_noop.c index 0ff33bfe35a..36892e433a1 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_noop.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_noop.c @@ -95,47 +95,6 @@ _mesa_noop_Color3fv(const GLfloat * v) { } -static void GLAPIENTRY -_mesa_noop_MultiTexCoord1fARB(GLenum target, GLfloat a) -{ -} - -static void GLAPIENTRY -_mesa_noop_MultiTexCoord1fvARB(GLenum target, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_MultiTexCoord2fARB(GLenum target, GLfloat a, GLfloat b) -{ -} - -static void GLAPIENTRY -_mesa_noop_MultiTexCoord2fvARB(GLenum target, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_MultiTexCoord3fARB(GLenum target, GLfloat a, GLfloat b, GLfloat c) -{ -} - -static void GLAPIENTRY -_mesa_noop_MultiTexCoord3fvARB(GLenum target, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_MultiTexCoord4fARB(GLenum target, GLfloat a, GLfloat b, - GLfloat c, GLfloat d) -{ -} - -static void GLAPIENTRY -_mesa_noop_MultiTexCoord4fvARB(GLenum target, const GLfloat * v) -{ -} - static void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT(GLfloat a, GLfloat b, GLfloat c) { @@ -227,48 +186,6 @@ _mesa_noop_VertexAttrib4fvNV(GLuint index, const GLfloat * v) { } - -static void GLAPIENTRY -_mesa_noop_VertexAttrib1fARB(GLuint index, GLfloat x) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib1fvARB(GLuint index, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib2fvARB(GLuint index, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib3fvARB(GLuint index, const GLfloat * v) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib4fARB(GLuint index, GLfloat x, - GLfloat y, GLfloat z, GLfloat w) -{ -} - -static void GLAPIENTRY -_mesa_noop_VertexAttrib4fvARB(GLuint index, const GLfloat * v) -{ -} - static void GLAPIENTRY _mesa_noop_Materialfv(GLenum face, GLenum pname, const GLfloat * params) { @@ -375,12 +292,6 @@ _mesa_noop_DrawRangeElements(GLenum mode, { } -static void GLAPIENTRY -_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei * count, GLenum type, - const GLvoid ** indices, GLsizei primcount) -{ -} - static void GLAPIENTRY _mesa_noop_EvalMesh1(GLenum mode, GLint i1, GLint i2) { @@ -420,14 +331,6 @@ _mesa_noop_vtxfmt_init(GLvertexformat * vfmt) vfmt->Indexf = _mesa_noop_Indexf; vfmt->Indexfv = _mesa_noop_Indexfv; vfmt->Materialfv = _mesa_noop_Materialfv; - vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB; - vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB; - vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB; - vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB; - vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB; - vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB; - vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB; - vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB; vfmt->Normal3f = _mesa_noop_Normal3f; vfmt->Normal3fv = _mesa_noop_Normal3fv; vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT; @@ -454,21 +357,12 @@ _mesa_noop_vtxfmt_init(GLvertexformat * vfmt) vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV; vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV; vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB; vfmt->Rectf = _mesa_noop_Rectf; vfmt->DrawArrays = _mesa_noop_DrawArrays; vfmt->DrawElements = _mesa_noop_DrawElements; vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; - vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements; } diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_rebase.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_rebase.c index d72d71c9180..dc2c58d3b19 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_rebase.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_rebase.c @@ -51,6 +51,7 @@ #include "main/mtypes.h" #include "vbo.h" +#include "vbo_attrib.h" #define REBASE(TYPE) \ @@ -73,29 +74,6 @@ REBASE(GLuint) REBASE(GLushort) REBASE(GLubyte) -GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] ) -{ - GLuint i; - - for (i = 0; i < VERT_ATTRIB_MAX; i++) - if (arrays[i]->StrideB && - arrays[i]->BufferObj->Name == 0) - return GL_FALSE; - - return GL_TRUE; -} - -GLboolean vbo_any_varyings_in_vbos( const struct gl_client_array *arrays[] ) -{ - GLuint i; - - for (i = 0; i < VERT_ATTRIB_MAX; i++) - if (arrays[i]->BufferObj->Name != 0) - return GL_TRUE; - - return GL_FALSE; -} - /* Adjust primitives, indices and vertex definitions so that min_index * becomes zero. There are lots of reasons for wanting to do this, eg: * @@ -124,8 +102,8 @@ void vbo_rebase_prims( struct gl_context *ctx, GLuint max_index, vbo_draw_func draw ) { - struct gl_client_array tmp_arrays[VERT_ATTRIB_MAX]; - const struct gl_client_array *tmp_array_pointers[VERT_ATTRIB_MAX]; + struct gl_client_array tmp_arrays[VBO_ATTRIB_MAX]; + const struct gl_client_array *tmp_array_pointers[VBO_ATTRIB_MAX]; struct _mesa_index_buffer tmp_ib; struct _mesa_prim *tmp_prims = NULL; @@ -203,7 +181,7 @@ void vbo_rebase_prims( struct gl_context *ctx, * For drivers with hardware tnl, you only want to do this if you * are forced to, eg non-VBO indexed rendering with start != 0. */ - for (i = 0; i < VERT_ATTRIB_MAX; i++) { + for (i = 0; i < VBO_ATTRIB_MAX; i++) { tmp_arrays[i] = *arrays[i]; tmp_arrays[i].Ptr += min_index * tmp_arrays[i].StrideB; tmp_array_pointers[i] = &tmp_arrays[i]; diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save.c index e0270619118..4ee99940aa7 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save.c @@ -63,24 +63,14 @@ void vbo_save_init( struct gl_context *ctx ) struct gl_client_array *arrays = save->arrays; unsigned i; - memcpy(arrays, vbo->legacy_currval, - VERT_ATTRIB_FF_MAX * sizeof(arrays[0])); - for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) { + memcpy(arrays, vbo->currval, + VBO_ATTRIB_MAX * sizeof(arrays[0])); + for (i = 0; i < VBO_ATTRIB_MAX; ++i) { struct gl_client_array *array; - array = &arrays[VERT_ATTRIB_FF(i)]; + array = &arrays[i]; array->BufferObj = NULL; _mesa_reference_buffer_object(ctx, &arrays->BufferObj, - vbo->legacy_currval[i].BufferObj); - } - - memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval, - VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0])); - for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) { - struct gl_client_array *array; - array = &arrays[VERT_ATTRIB_GENERIC(i)]; - array->BufferObj = NULL; - _mesa_reference_buffer_object(ctx, &array->BufferObj, - vbo->generic_currval[i].BufferObj); + vbo->currval[i].BufferObj); } } diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_api.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_api.c index 5f10d62be09..c803411a053 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_api.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_api.c @@ -746,6 +746,8 @@ _save_Materialfv(GLenum face, GLenum pname, const GLfloat *params) _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)"); return; } + + __debugbreak(); switch (pname) { case GL_EMISSION: @@ -990,20 +992,6 @@ _save_DrawArrays(GLenum mode, GLint start, GLsizei count) } -static void GLAPIENTRY -_save_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; - (void) count; - (void) type; - (void) indices; - (void) primcount; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glMultiDrawElements"); -} - - static void GLAPIENTRY _save_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { @@ -1162,20 +1150,6 @@ _save_OBE_DrawRangeElements(GLenum mode, GLuint start, GLuint end, } -static void GLAPIENTRY -_save_OBE_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) -{ - GLsizei i; - - for (i = 0; i < primcount; i++) { - if (count[i] > 0) { - CALL_DrawElements(GET_DISPATCH(), (mode, count[i], type, indices[i])); - } - } -} - - static void _save_vtxfmt_init(struct gl_context *ctx) { @@ -1196,14 +1170,6 @@ _save_vtxfmt_init(struct gl_context *ctx) vfmt->Indexf = _save_Indexf; vfmt->Indexfv = _save_Indexfv; vfmt->Materialfv = _save_Materialfv; - vfmt->MultiTexCoord1fARB = _save_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = _save_MultiTexCoord1fv; - vfmt->MultiTexCoord2fARB = _save_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = _save_MultiTexCoord2fv; - vfmt->MultiTexCoord3fARB = _save_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = _save_MultiTexCoord3fv; - vfmt->MultiTexCoord4fARB = _save_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = _save_MultiTexCoord4fv; vfmt->Normal3f = _save_Normal3f; vfmt->Normal3fv = _save_Normal3fv; vfmt->SecondaryColor3fEXT = _save_SecondaryColor3fEXT; @@ -1222,14 +1188,6 @@ _save_vtxfmt_init(struct gl_context *ctx) vfmt->Vertex3fv = _save_Vertex3fv; vfmt->Vertex4f = _save_Vertex4f; vfmt->Vertex4fv = _save_Vertex4fv; - vfmt->VertexAttrib1fARB = _save_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = _save_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = _save_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = _save_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = _save_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = _save_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = _save_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = _save_VertexAttrib4fvARB; vfmt->VertexAttrib1fNV = _save_VertexAttrib1fNV; vfmt->VertexAttrib1fvNV = _save_VertexAttrib1fvNV; @@ -1240,24 +1198,6 @@ _save_vtxfmt_init(struct gl_context *ctx) vfmt->VertexAttrib4fNV = _save_VertexAttrib4fNV; vfmt->VertexAttrib4fvNV = _save_VertexAttrib4fvNV; - /* integer-valued */ - vfmt->VertexAttribI1i = _save_VertexAttribI1i; - vfmt->VertexAttribI2i = _save_VertexAttribI2i; - vfmt->VertexAttribI3i = _save_VertexAttribI3i; - vfmt->VertexAttribI4i = _save_VertexAttribI4i; - vfmt->VertexAttribI2iv = _save_VertexAttribI2iv; - vfmt->VertexAttribI3iv = _save_VertexAttribI3iv; - vfmt->VertexAttribI4iv = _save_VertexAttribI4iv; - - /* unsigned integer-valued */ - vfmt->VertexAttribI1ui = _save_VertexAttribI1ui; - vfmt->VertexAttribI2ui = _save_VertexAttribI2ui; - vfmt->VertexAttribI3ui = _save_VertexAttribI3ui; - vfmt->VertexAttribI4ui = _save_VertexAttribI4ui; - vfmt->VertexAttribI2uiv = _save_VertexAttribI2uiv; - vfmt->VertexAttribI3uiv = _save_VertexAttribI3uiv; - vfmt->VertexAttribI4uiv = _save_VertexAttribI4uiv; - /* This will all require us to fallback to saving the list as opcodes: */ _MESA_INIT_DLIST_VTXFMT(vfmt, _save_); /* inside begin/end */ @@ -1272,7 +1212,6 @@ _save_vtxfmt_init(struct gl_context *ctx) vfmt->DrawArrays = _save_DrawArrays; vfmt->DrawElements = _save_DrawElements; vfmt->DrawRangeElements = _save_DrawRangeElements; - vfmt->MultiDrawElementsEXT = _save_MultiDrawElements; } @@ -1425,7 +1364,7 @@ _save_current_init(struct gl_context *ctx) struct vbo_save_context *save = &vbo_context(ctx)->save; GLint i; - for (i = VBO_ATTRIB_POS; i <= VBO_ATTRIB_GENERIC15; i++) { + for (i = VBO_ATTRIB_POS; i <= VBO_ATTRIB_POINT_SIZE; i++) { const GLuint j = i - VBO_ATTRIB_POS; ASSERT(j < VERT_ATTRIB_MAX); save->currentsz[i] = &ctx->ListState.ActiveAttribSize[j]; @@ -1474,7 +1413,6 @@ vbo_save_api_init(struct vbo_save_context *save) ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays; ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements; ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements; - ctx->ListState.ListVtxfmt.MultiDrawElementsEXT = _save_OBE_MultiDrawElements; _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); } diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_draw.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_draw.c index 59b4948907f..e1e4ebcf000 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_draw.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_save_draw.c @@ -134,7 +134,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, struct vbo_save_context *save = &vbo->save; struct gl_client_array *arrays = save->arrays; GLuint buffer_offset = node->buffer_offset; - const GLuint *map; GLuint attr; GLubyte node_attrsz[VBO_ATTRIB_MAX]; /* copy of node->attrsz[] */ GLbitfield64 varying_inputs = 0x0; @@ -144,54 +143,18 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, /* Install the default (ie Current) attributes first, then overlay * all active ones. */ - switch (get_program_mode(ctx)) { - case VP_NONE: - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) { - save->inputs[attr] = &vbo->legacy_currval[attr]; - } - for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { - save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->mat_currval[attr]; - } - map = vbo->map_vp_none; - break; - case VP_NV: - case VP_ARB: - /* The aliasing of attributes for NV vertex programs has already - * occurred. NV vertex programs cannot access material values, - * nor attributes greater than VERT_ATTRIB_TEX7. - */ - for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) { - save->inputs[attr] = &vbo->legacy_currval[attr]; - } - for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) { - save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->generic_currval[attr]; - } - map = vbo->map_vp_arb; - - /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. - * In that case we effectively need to route the data from - * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. - */ - if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 && - (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { - save->inputs[VERT_ATTRIB_GENERIC0] = save->inputs[0]; - node_attrsz[VERT_ATTRIB_GENERIC0] = node_attrsz[0]; - node_attrsz[0] = 0; - } - break; - default: - assert(0); + for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { + save->inputs[attr] = &vbo->currval[attr]; } - for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { - const GLuint src = map[attr]; + for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { - if (node_attrsz[src]) { + if (node_attrsz[attr]) { /* override the default array set above */ save->inputs[attr] = &arrays[attr]; arrays[attr].Ptr = (const GLubyte *) NULL + buffer_offset; - arrays[attr].Size = node_attrsz[src]; + arrays[attr].Size = node_attrsz[attr]; arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat); arrays[attr].Stride = node->vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; @@ -204,7 +167,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, assert(arrays[attr].BufferObj->Name); - buffer_offset += node_attrsz[src] * sizeof(GLfloat); + buffer_offset += node_attrsz[attr] * sizeof(GLfloat); varying_inputs |= VERT_BIT(attr); ctx->NewState |= _NEW_ARRAY; } @@ -276,14 +239,6 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) if (ctx->NewState) _mesa_update_state( ctx ); - /* XXX also need to check if shader enabled, but invalid */ - if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) || - (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBegin (invalid vertex/fragment program)"); - return; - } - vbo_bind_vertex_list( ctx, node ); vbo_draw_method(exec, DRAW_DISPLAY_LIST); diff --git a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_split_copy.c b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_split_copy.c index 3ec4eb69a83..20f4560d2e9 100644 --- a/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_split_copy.c +++ b/reactos/dll/opengl/mesa/src/mesa/vbo/vbo_split_copy.c @@ -36,6 +36,7 @@ #include "main/macros.h" #include "main/mtypes.h" +#include "vbo_attrib.h" #include "vbo_split.h" #include "vbo.h" @@ -66,10 +67,10 @@ struct copy_context { struct gl_client_array dstarray; - } varying[VERT_ATTRIB_MAX]; + } varying[VBO_ATTRIB_MAX]; GLuint nr_varying; - const struct gl_client_array *dstarray_ptr[VERT_ATTRIB_MAX]; + const struct gl_client_array *dstarray_ptr[VBO_ATTRIB_MAX]; struct _mesa_index_buffer dstib; GLuint *translated_elt_buf; @@ -152,7 +153,7 @@ dump_draw_info(struct gl_context *ctx, printf("Prim %u of %u\n", i, nr_prims); printf(" Prim mode 0x%x\n", prims[i].mode); printf(" IB: %p\n", (void*) ib); - for (j = 0; j < VERT_ATTRIB_MAX; j++) { + for (j = 0; j < VBO_ATTRIB_MAX; j++) { printf(" array %d at %p:\n", j, (void*) arrays[j]); printf(" enabled %d, ptr %p, size %d, type 0x%x, stride %d\n", arrays[j]->Enabled, arrays[j]->Ptr, @@ -429,7 +430,7 @@ replay_init( struct copy_context *copy ) * calculate vertex size. */ copy->vertex_size = 0; - for (i = 0; i < VERT_ATTRIB_MAX; i++) { + for (i = 0; i < VBO_ATTRIB_MAX; i++) { struct gl_buffer_object *vbo = copy->array[i]->BufferObj; if (copy->array[i]->StrideB == 0) { diff --git a/reactos/dll/opengl/mesa/src/mesa/x86/gen_matypes.c b/reactos/dll/opengl/mesa/src/mesa/x86/gen_matypes.c index 97f71f92cea..2eaea8841a8 100644 --- a/reactos/dll/opengl/mesa/src/mesa/x86/gen_matypes.c +++ b/reactos/dll/opengl/mesa/src/mesa/x86/gen_matypes.c @@ -123,10 +123,7 @@ int main( int argc, char **argv ) OFFSET( "VB_CLIP_MASK ", struct vertex_buffer, ClipMask ); OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_NORMAL] ); OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer, EdgeFlag ); - OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX0] ); - OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX1] ); - OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX2] ); - OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX3] ); + OFFSET( "VB_TEX_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX] ); OFFSET( "VB_INDEX_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR_INDEX] ); OFFSET( "VB_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR0] ); OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR1] ); diff --git a/reactos/dll/opengl/opengl32/CMakeLists.txt b/reactos/dll/opengl/opengl32/CMakeLists.txt index 2ee6be2d90d..d5b438245b1 100644 --- a/reactos/dll/opengl/opengl32/CMakeLists.txt +++ b/reactos/dll/opengl/opengl32/CMakeLists.txt @@ -1,8 +1,6 @@ spec2def(opengl32.dll opengl32.spec ADD_IMPORTLIB) -set_cpp(WITH_STL) - include_directories( ../mesa/src/mesa ../mesa/src/mapi) @@ -50,9 +48,7 @@ target_link_libraries(opengl32 mesa_tnl mesa_main mesa_vbo - mesa_program mesa_math - mesa_glsl ) if((ARCH STREQUAL "i386") AND (NOT MSVC))