summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-08-16 19:08:53 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-08-16 19:08:53 -0700
commit6c03c576cc49bbb008de66d374f4302ff0fe0390 (patch)
tree7ddeb3ee88532d9aef8728b9aa256edf7c125247
parent15a3b42e135a3a2cb463ec3cff80a55dd8528051 (diff)
parenta433cd286c60eb9d4c2114f042709eda0f3de676 (diff)
Merge branch 'glsl2'
Conflicts: src/mesa/program/prog_optimize.c
-rw-r--r--SConstruct22
-rw-r--r--configs/default2
-rw-r--r--configs/linux-llvm2
-rw-r--r--configure.ac4
-rw-r--r--include/c99/inttypes.h305
-rw-r--r--include/c99/stdint.h338
-rw-r--r--src/SConscript3
-rw-r--r--src/gallium/targets/Makefile.dri13
-rw-r--r--src/gallium/targets/libgl-gdi/SConscript1
-rw-r--r--src/gallium/targets/libgl-xlib/SConscript1
-rw-r--r--src/glsl/.dir-locals.el3
-rw-r--r--src/glsl/.gitignore2
-rw-r--r--src/glsl/Makefile177
-rw-r--r--src/glsl/Makefile.am75
-rw-r--r--src/glsl/README190
-rw-r--r--src/glsl/SConscript114
-rw-r--r--src/glsl/TODO50
-rw-r--r--src/glsl/ast.h664
-rw-r--r--src/glsl/ast_expr.cpp96
-rw-r--r--src/glsl/ast_function.cpp1247
-rw-r--r--src/glsl/ast_to_hir.cpp2607
-rw-r--r--src/glsl/ast_type.cpp122
-rwxr-xr-xsrc/glsl/autogen.sh12
-rw-r--r--src/glsl/builtin_function.cpp24404
-rw-r--r--src/glsl/builtin_types.h290
-rw-r--r--src/glsl/builtin_variables.h98
-rw-r--r--src/glsl/builtins/ir/abs21
-rw-r--r--src/glsl/builtins/ir/acos22
-rw-r--r--src/glsl/builtins/ir/all16
-rw-r--r--src/glsl/builtins/ir/any16
-rw-r--r--src/glsl/builtins/ir/asin97
-rw-r--r--src/glsl/builtins/ir/atan154
-rw-r--r--src/glsl/builtins/ir/ceil21
-rw-r--r--src/glsl/builtins/ir/clamp148
-rw-r--r--src/glsl/builtins/ir/cos21
-rw-r--r--src/glsl/builtins/ir/cosh30
-rw-r--r--src/glsl/builtins/ir/cross7
-rw-r--r--src/glsl/builtins/ir/dFdx21
-rw-r--r--src/glsl/builtins/ir/dFdy21
-rw-r--r--src/glsl/builtins/ir/degrees21
-rw-r--r--src/glsl/builtins/ir/distance33
-rw-r--r--src/glsl/builtins/ir/dot25
-rw-r--r--src/glsl/builtins/ir/equal91
-rw-r--r--src/glsl/builtins/ir/exp21
-rw-r--r--src/glsl/builtins/ir/exp221
-rw-r--r--src/glsl/builtins/ir/faceforward37
-rw-r--r--src/glsl/builtins/ir/floor21
-rw-r--r--src/glsl/builtins/ir/fract22
-rw-r--r--src/glsl/builtins/ir/ftransform9
-rw-r--r--src/glsl/builtins/ir/fwidth29
-rw-r--r--src/glsl/builtins/ir/greaterThan91
-rw-r--r--src/glsl/builtins/ir/greaterThanEqual91
-rw-r--r--src/glsl/builtins/ir/inversesqrt21
-rw-r--r--src/glsl/builtins/ir/length21
-rw-r--r--src/glsl/builtins/ir/lessThan91
-rw-r--r--src/glsl/builtins/ir/lessThanEqual91
-rw-r--r--src/glsl/builtins/ir/log21
-rw-r--r--src/glsl/builtins/ir/log221
-rw-r--r--src/glsl/builtins/ir/matrixCompMult91
-rw-r--r--src/glsl/builtins/ir/max127
-rw-r--r--src/glsl/builtins/ir/min127
-rw-r--r--src/glsl/builtins/ir/mix88
-rw-r--r--src/glsl/builtins/ir/mod43
-rw-r--r--src/glsl/builtins/ir/noise118
-rw-r--r--src/glsl/builtins/ir/noise218
-rw-r--r--src/glsl/builtins/ir/noise318
-rw-r--r--src/glsl/builtins/ir/noise418
-rw-r--r--src/glsl/builtins/ir/normalize21
-rw-r--r--src/glsl/builtins/ir/not16
-rw-r--r--src/glsl/builtins/ir/notEqual91
-rw-r--r--src/glsl/builtins/ir/outerProduct92
-rw-r--r--src/glsl/builtins/ir/pow25
-rw-r--r--src/glsl/builtins/ir/radians21
-rw-r--r--src/glsl/builtins/ir/reflect58
-rw-r--r--src/glsl/builtins/ir/refract102
-rw-r--r--src/glsl/builtins/ir/sign42
-rw-r--r--src/glsl/builtins/ir/sin21
-rw-r--r--src/glsl/builtins/ir/sinh30
-rw-r--r--src/glsl/builtins/ir/smoothstep153
-rw-r--r--src/glsl/builtins/ir/sqrt21
-rw-r--r--src/glsl/builtins/ir/step68
-rw-r--r--src/glsl/builtins/ir/tan21
-rw-r--r--src/glsl/builtins/ir/tanh42
-rw-r--r--src/glsl/builtins/ir/transpose139
-rw-r--r--src/glsl/builtins/profiles/110.frag364
-rw-r--r--src/glsl/builtins/profiles/110.vert351
-rw-r--r--src/glsl/builtins/profiles/120.frag396
-rw-r--r--src/glsl/builtins/profiles/120.vert383
-rw-r--r--src/glsl/builtins/profiles/130.frag999
-rw-r--r--src/glsl/builtins/profiles/130.vert987
-rw-r--r--src/glsl/builtins/profiles/ARB_texture_rectangle.frag7
-rw-r--r--src/glsl/builtins/profiles/ARB_texture_rectangle.vert7
-rw-r--r--src/glsl/builtins/profiles/EXT_texture_array.frag11
-rw-r--r--src/glsl/builtins/profiles/EXT_texture_array.vert11
-rw-r--r--src/glsl/builtins/tools/builtin_function.cpp39
-rwxr-xr-xsrc/glsl/builtins/tools/generate_builtins.py207
-rwxr-xr-xsrc/glsl/builtins/tools/generate_matrixCompMultGLSL.py28
-rwxr-xr-xsrc/glsl/builtins/tools/generate_outerProductGLSL.py23
-rwxr-xr-xsrc/glsl/builtins/tools/generate_transposeGLSL.py28
-rwxr-xr-xsrc/glsl/builtins/tools/texture_builtins.py349
-rw-r--r--src/glsl/configure.ac69
-rw-r--r--src/glsl/glcpp/.gitignore8
-rw-r--r--src/glsl/glcpp/Makefile.am44
-rw-r--r--src/glsl/glcpp/README30
-rw-r--r--src/glsl/glcpp/glcpp-lex.c2624
-rw-r--r--src/glsl/glcpp/glcpp-lex.l291
-rw-r--r--src/glsl/glcpp/glcpp-parse.c4055
-rw-r--r--src/glsl/glcpp/glcpp-parse.h100
-rw-r--r--src/glsl/glcpp/glcpp-parse.y1729
-rw-r--r--src/glsl/glcpp/glcpp.c85
-rw-r--r--src/glsl/glcpp/glcpp.h222
-rw-r--r--src/glsl/glcpp/pp.c166
-rw-r--r--src/glsl/glcpp/tests/000-content-with-spaces.c1
-rw-r--r--src/glsl/glcpp/tests/000-content-with-spaces.c.expected2
-rw-r--r--src/glsl/glcpp/tests/001-define.c2
-rw-r--r--src/glsl/glcpp/tests/001-define.c.expected3
-rw-r--r--src/glsl/glcpp/tests/002-define-chain.c3
-rw-r--r--src/glsl/glcpp/tests/002-define-chain.c.expected4
-rw-r--r--src/glsl/glcpp/tests/003-define-chain-reverse.c3
-rw-r--r--src/glsl/glcpp/tests/003-define-chain-reverse.c.expected4
-rw-r--r--src/glsl/glcpp/tests/004-define-recursive.c6
-rw-r--r--src/glsl/glcpp/tests/004-define-recursive.c.expected7
-rw-r--r--src/glsl/glcpp/tests/005-define-composite-chain.c3
-rw-r--r--src/glsl/glcpp/tests/005-define-composite-chain.c.expected4
-rw-r--r--src/glsl/glcpp/tests/006-define-composite-chain-reverse.c3
-rw-r--r--src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected4
-rw-r--r--src/glsl/glcpp/tests/007-define-composite-recursive.c6
-rw-r--r--src/glsl/glcpp/tests/007-define-composite-recursive.c.expected7
-rw-r--r--src/glsl/glcpp/tests/008-define-empty.c2
-rw-r--r--src/glsl/glcpp/tests/008-define-empty.c.expected3
-rw-r--r--src/glsl/glcpp/tests/009-undef.c4
-rw-r--r--src/glsl/glcpp/tests/009-undef.c.expected5
-rw-r--r--src/glsl/glcpp/tests/010-undef-re-define.c6
-rw-r--r--src/glsl/glcpp/tests/010-undef-re-define.c.expected7
-rw-r--r--src/glsl/glcpp/tests/011-define-func-empty.c2
-rw-r--r--src/glsl/glcpp/tests/011-define-func-empty.c.expected3
-rw-r--r--src/glsl/glcpp/tests/012-define-func-no-args.c2
-rw-r--r--src/glsl/glcpp/tests/012-define-func-no-args.c.expected3
-rw-r--r--src/glsl/glcpp/tests/013-define-func-1-arg-unused.c2
-rw-r--r--src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected3
-rw-r--r--src/glsl/glcpp/tests/014-define-func-2-arg-unused.c2
-rw-r--r--src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected3
-rw-r--r--src/glsl/glcpp/tests/015-define-object-with-parens.c4
-rw-r--r--src/glsl/glcpp/tests/015-define-object-with-parens.c.expected5
-rw-r--r--src/glsl/glcpp/tests/016-define-func-1-arg.c2
-rw-r--r--src/glsl/glcpp/tests/016-define-func-1-arg.c.expected3
-rw-r--r--src/glsl/glcpp/tests/017-define-func-2-args.c2
-rw-r--r--src/glsl/glcpp/tests/017-define-func-2-args.c.expected3
-rw-r--r--src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c3
-rw-r--r--src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected4
-rw-r--r--src/glsl/glcpp/tests/019-define-func-1-arg-multi.c2
-rw-r--r--src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected3
-rw-r--r--src/glsl/glcpp/tests/020-define-func-2-arg-multi.c2
-rw-r--r--src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected3
-rw-r--r--src/glsl/glcpp/tests/021-define-func-compose.c3
-rw-r--r--src/glsl/glcpp/tests/021-define-func-compose.c.expected4
-rw-r--r--src/glsl/glcpp/tests/022-define-func-arg-with-parens.c2
-rw-r--r--src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected3
-rw-r--r--src/glsl/glcpp/tests/023-define-extra-whitespace.c8
-rw-r--r--src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected9
-rw-r--r--src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c3
-rw-r--r--src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected4
-rw-r--r--src/glsl/glcpp/tests/025-func-macro-as-non-macro.c2
-rw-r--r--src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected3
-rw-r--r--src/glsl/glcpp/tests/026-define-func-extra-newlines.c6
-rw-r--r--src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected4
-rw-r--r--src/glsl/glcpp/tests/027-define-chain-obj-to-func.c3
-rw-r--r--src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected4
-rw-r--r--src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c3
-rw-r--r--src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected4
-rw-r--r--src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c3
-rw-r--r--src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected4
-rw-r--r--src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c4
-rw-r--r--src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected5
-rw-r--r--src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c4
-rw-r--r--src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected5
-rw-r--r--src/glsl/glcpp/tests/032-define-func-self-recurse.c2
-rw-r--r--src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected3
-rw-r--r--src/glsl/glcpp/tests/033-define-func-self-compose.c2
-rw-r--r--src/glsl/glcpp/tests/033-define-func-self-compose.c.expected3
-rw-r--r--src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c2
-rw-r--r--src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected3
-rw-r--r--src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c2
-rw-r--r--src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected3
-rw-r--r--src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c3
-rw-r--r--src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected4
-rw-r--r--src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c3
-rw-r--r--src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected4
-rw-r--r--src/glsl/glcpp/tests/038-func-arg-with-commas.c2
-rw-r--r--src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected3
-rw-r--r--src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c3
-rw-r--r--src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected4
-rw-r--r--src/glsl/glcpp/tests/040-token-pasting.c2
-rw-r--r--src/glsl/glcpp/tests/040-token-pasting.c.expected3
-rw-r--r--src/glsl/glcpp/tests/041-if-0.c5
-rw-r--r--src/glsl/glcpp/tests/041-if-0.c.expected6
-rw-r--r--src/glsl/glcpp/tests/042-if-1.c5
-rw-r--r--src/glsl/glcpp/tests/042-if-1.c.expected6
-rw-r--r--src/glsl/glcpp/tests/043-if-0-else.c7
-rw-r--r--src/glsl/glcpp/tests/043-if-0-else.c.expected8
-rw-r--r--src/glsl/glcpp/tests/044-if-1-else.c7
-rw-r--r--src/glsl/glcpp/tests/044-if-1-else.c.expected8
-rw-r--r--src/glsl/glcpp/tests/045-if-0-elif.c11
-rw-r--r--src/glsl/glcpp/tests/045-if-0-elif.c.expected12
-rw-r--r--src/glsl/glcpp/tests/046-if-1-elsif.c11
-rw-r--r--src/glsl/glcpp/tests/046-if-1-elsif.c.expected12
-rw-r--r--src/glsl/glcpp/tests/047-if-elif-else.c11
-rw-r--r--src/glsl/glcpp/tests/047-if-elif-else.c.expected12
-rw-r--r--src/glsl/glcpp/tests/048-if-nested.c11
-rw-r--r--src/glsl/glcpp/tests/048-if-nested.c.expected12
-rw-r--r--src/glsl/glcpp/tests/049-if-expression-precedence.c5
-rw-r--r--src/glsl/glcpp/tests/049-if-expression-precedence.c.expected6
-rw-r--r--src/glsl/glcpp/tests/050-if-defined.c17
-rw-r--r--src/glsl/glcpp/tests/050-if-defined.c.expected18
-rw-r--r--src/glsl/glcpp/tests/051-if-relational.c35
-rw-r--r--src/glsl/glcpp/tests/051-if-relational.c.expected36
-rw-r--r--src/glsl/glcpp/tests/052-if-bitwise.c20
-rw-r--r--src/glsl/glcpp/tests/052-if-bitwise.c.expected21
-rw-r--r--src/glsl/glcpp/tests/053-if-divide-and-shift.c15
-rw-r--r--src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected16
-rw-r--r--src/glsl/glcpp/tests/054-if-with-macros.c34
-rw-r--r--src/glsl/glcpp/tests/054-if-with-macros.c.expected35
-rw-r--r--src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c3
-rw-r--r--src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected4
-rw-r--r--src/glsl/glcpp/tests/056-macro-argument-with-comma.c4
-rw-r--r--src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected5
-rw-r--r--src/glsl/glcpp/tests/057-empty-arguments.c6
-rw-r--r--src/glsl/glcpp/tests/057-empty-arguments.c.expected7
-rw-r--r--src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c5
-rw-r--r--src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected6
-rw-r--r--src/glsl/glcpp/tests/059-token-pasting-integer.c4
-rw-r--r--src/glsl/glcpp/tests/059-token-pasting-integer.c.expected5
-rw-r--r--src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c3
-rw-r--r--src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected4
-rw-r--r--src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c5
-rw-r--r--src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected6
-rw-r--r--src/glsl/glcpp/tests/062-if-0-skips-garbage.c5
-rw-r--r--src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected6
-rw-r--r--src/glsl/glcpp/tests/063-comments.c20
-rw-r--r--src/glsl/glcpp/tests/063-comments.c.expected14
-rw-r--r--src/glsl/glcpp/tests/064-version.c2
-rw-r--r--src/glsl/glcpp/tests/064-version.c.expected4
-rw-r--r--src/glsl/glcpp/tests/065-if-defined-parens.c17
-rw-r--r--src/glsl/glcpp/tests/065-if-defined-parens.c.expected18
-rw-r--r--src/glsl/glcpp/tests/066-if-nospace-expression.c3
-rw-r--r--src/glsl/glcpp/tests/066-if-nospace-expression.c.expected4
-rw-r--r--src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c40
-rw-r--r--src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected41
-rw-r--r--src/glsl/glcpp/tests/068-accidental-pasting.c11
-rw-r--r--src/glsl/glcpp/tests/068-accidental-pasting.c.expected12
-rw-r--r--src/glsl/glcpp/tests/069-repeated-argument.c2
-rw-r--r--src/glsl/glcpp/tests/069-repeated-argument.c.expected3
-rw-r--r--src/glsl/glcpp/tests/070-undefined-macro-in-expression.c2
-rw-r--r--src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected2
-rw-r--r--src/glsl/glcpp/tests/071-punctuator.c1
-rw-r--r--src/glsl/glcpp/tests/071-punctuator.c.expected2
-rw-r--r--src/glsl/glcpp/tests/072-token-pasting-same-line.c2
-rw-r--r--src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected3
-rw-r--r--src/glsl/glcpp/tests/073-if-in-ifdef.c4
-rw-r--r--src/glsl/glcpp/tests/073-if-in-ifdef.c.expected5
-rw-r--r--src/glsl/glcpp/tests/074-elif-undef.c3
-rw-r--r--src/glsl/glcpp/tests/074-elif-undef.c.expected4
-rw-r--r--src/glsl/glcpp/tests/075-elif-elif-undef.c4
-rw-r--r--src/glsl/glcpp/tests/075-elif-elif-undef.c.expected5
-rw-r--r--src/glsl/glcpp/tests/076-elif-undef-nested.c5
-rw-r--r--src/glsl/glcpp/tests/076-elif-undef-nested.c.expected6
-rw-r--r--src/glsl/glcpp/tests/077-else-without-if.c1
-rw-r--r--src/glsl/glcpp/tests/077-else-without-if.c.expected4
-rw-r--r--src/glsl/glcpp/tests/078-elif-without-if.c1
-rw-r--r--src/glsl/glcpp/tests/078-elif-without-if.c.expected4
-rw-r--r--src/glsl/glcpp/tests/079-endif-without-if.c1
-rw-r--r--src/glsl/glcpp/tests/079-endif-without-if.c.expected4
-rw-r--r--src/glsl/glcpp/tests/080-if-without-expression.c4
-rw-r--r--src/glsl/glcpp/tests/080-if-without-expression.c.expected6
-rw-r--r--src/glsl/glcpp/tests/081-elif-without-expression.c3
-rw-r--r--src/glsl/glcpp/tests/081-elif-without-expression.c.expected5
-rw-r--r--src/glsl/glcpp/tests/082-invalid-paste.c2
-rw-r--r--src/glsl/glcpp/tests/082-invalid-paste.c.expected5
-rw-r--r--src/glsl/glcpp/tests/083-unterminated-if.c2
-rw-r--r--src/glsl/glcpp/tests/083-unterminated-if.c.expected5
-rw-r--r--src/glsl/glcpp/tests/084-unbalanced-parentheses.c2
-rw-r--r--src/glsl/glcpp/tests/085-incorrect-argument-count.c5
-rw-r--r--src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected12
-rw-r--r--src/glsl/glcpp/tests/086-reserved-macro-names.c2
-rw-r--r--src/glsl/glcpp/tests/086-reserved-macro-names.c.expected7
-rw-r--r--src/glsl/glcpp/tests/099-c99-example.c17
-rw-r--r--src/glsl/glcpp/tests/099-c99-example.c.expected17
-rwxr-xr-xsrc/glsl/glcpp/tests/glcpp-test49
-rw-r--r--src/glsl/glsl_lexer.cpp3416
-rw-r--r--src/glsl/glsl_lexer.lpp369
-rw-r--r--src/glsl/glsl_parser.cpp5245
-rw-r--r--src/glsl/glsl_parser.h291
-rw-r--r--src/glsl/glsl_parser.ypp1508
-rw-r--r--src/glsl/glsl_parser_extras.cpp743
-rw-r--r--src/glsl/glsl_parser_extras.h214
-rw-r--r--src/glsl/glsl_symbol_table.h171
-rw-r--r--src/glsl/glsl_types.cpp550
-rw-r--r--src/glsl/glsl_types.h480
-rw-r--r--src/glsl/hir_field_selection.cpp103
-rw-r--r--src/glsl/ir.cpp1062
-rw-r--r--src/glsl/ir.h1398
-rw-r--r--src/glsl/ir_algebraic.cpp392
-rw-r--r--src/glsl/ir_basic_block.cpp149
-rw-r--r--src/glsl/ir_basic_block.h28
-rw-r--r--src/glsl/ir_clone.cpp401
-rw-r--r--src/glsl/ir_constant_expression.cpp1144
-rw-r--r--src/glsl/ir_constant_folding.cpp273
-rw-r--r--src/glsl/ir_constant_propagation.cpp435
-rw-r--r--src/glsl/ir_constant_variable.cpp198
-rw-r--r--src/glsl/ir_copy_propagation.cpp362
-rw-r--r--src/glsl/ir_dead_code.cpp135
-rw-r--r--src/glsl/ir_dead_code_local.cpp229
-rw-r--r--src/glsl/ir_dead_functions.cpp151
-rw-r--r--src/glsl/ir_div_to_mul_rcp.cpp115
-rw-r--r--src/glsl/ir_explog_to_explog2.cpp85
-rw-r--r--src/glsl/ir_expression_flattening.cpp188
-rw-r--r--src/glsl/ir_expression_flattening.h38
-rw-r--r--src/glsl/ir_function.cpp224
-rw-r--r--src/glsl/ir_function_can_inline.cpp71
-rw-r--r--src/glsl/ir_function_inlining.cpp417
-rw-r--r--src/glsl/ir_function_inlining.h30
-rw-r--r--src/glsl/ir_hierarchical_visitor.cpp295
-rw-r--r--src/glsl/ir_hierarchical_visitor.h176
-rw-r--r--src/glsl/ir_hv_accept.cpp369
-rw-r--r--src/glsl/ir_if_return.cpp246
-rw-r--r--src/glsl/ir_if_simplification.cpp84
-rw-r--r--src/glsl/ir_if_to_cond_assign.cpp168
-rw-r--r--src/glsl/ir_import_prototypes.cpp138
-rw-r--r--src/glsl/ir_mat_op_to_vec.cpp397
-rw-r--r--src/glsl/ir_mod_to_fract.cpp90
-rw-r--r--src/glsl/ir_noop_swizzle.cpp80
-rw-r--r--src/glsl/ir_optimization.h57
-rw-r--r--src/glsl/ir_print_visitor.cpp465
-rw-r--r--src/glsl/ir_print_visitor.h83
-rw-r--r--src/glsl/ir_reader.cpp1088
-rw-r--r--src/glsl/ir_reader.h34
-rw-r--r--src/glsl/ir_rvalue_visitor.cpp134
-rw-r--r--src/glsl/ir_rvalue_visitor.h47
-rw-r--r--src/glsl/ir_set_program_inouts.cpp167
-rw-r--r--src/glsl/ir_structure_splitting.cpp356
-rw-r--r--src/glsl/ir_sub_to_add_neg.cpp76
-rw-r--r--src/glsl/ir_swizzle_swizzle.cpp93
-rw-r--r--src/glsl/ir_tree_grafting.cpp361
-rw-r--r--src/glsl/ir_validate.cpp397
-rw-r--r--src/glsl/ir_variable.cpp416
-rw-r--r--src/glsl/ir_variable_refcount.cpp100
-rw-r--r--src/glsl/ir_variable_refcount.h85
-rw-r--r--src/glsl/ir_vec_index_to_cond_assign.cpp258
-rw-r--r--src/glsl/ir_vec_index_to_swizzle.cpp157
-rw-r--r--src/glsl/ir_visitor.h67
-rw-r--r--src/glsl/link_functions.cpp262
-rw-r--r--src/glsl/linker.cpp1341
-rw-r--r--src/glsl/linker.h35
-rw-r--r--src/glsl/list.h465
-rw-r--r--src/glsl/main.cpp283
-rw-r--r--src/glsl/program.h33
-rw-r--r--src/glsl/s_expression.cpp131
-rw-r--r--src/glsl/s_expression.h142
-rw-r--r--src/glsl/tests/array-01.glsl3
-rw-r--r--src/glsl/tests/array-02.glsl3
-rw-r--r--src/glsl/tests/array-03.glsl3
-rw-r--r--src/glsl/tests/array-04.glsl2
-rw-r--r--src/glsl/tests/array-05.glsl2
-rw-r--r--src/glsl/tests/array-06.glsl2
-rw-r--r--src/glsl/tests/array-07.glsl2
-rw-r--r--src/glsl/tests/array-08.glsl2
-rw-r--r--src/glsl/tests/array-09.glsl9
-rw-r--r--src/glsl/tests/array-10.glsl11
-rw-r--r--src/glsl/tests/array-11.glsl9
-rw-r--r--src/glsl/tests/array-12.glsl11
-rw-r--r--src/glsl/tests/array-13.glsl11
-rw-r--r--src/glsl/tests/attribute-01.glsl7
-rw-r--r--src/glsl/tests/attribute-02.glsl7
-rw-r--r--src/glsl/tests/attribute-03.glsl7
-rw-r--r--src/glsl/tests/attribute-04.glsl7
-rw-r--r--src/glsl/tests/attribute-05.glsl7
-rw-r--r--src/glsl/tests/attribute-06.glsl7
-rw-r--r--src/glsl/tests/attribute-07.glsl7
-rw-r--r--src/glsl/tests/attribute-08.glsl7
-rw-r--r--src/glsl/tests/attribute-09.glsl7
-rw-r--r--src/glsl/tests/attribute-10.glsl8
-rw-r--r--src/glsl/tests/attribute-11.glsl8
-rw-r--r--src/glsl/tests/condition-01.glsl8
-rw-r--r--src/glsl/tests/condition-02.glsl8
-rw-r--r--src/glsl/tests/condition-03.glsl8
-rw-r--r--src/glsl/tests/condition-04.glsl8
-rw-r--r--src/glsl/tests/condition-05.glsl13
-rw-r--r--src/glsl/tests/constructor-01.glsl6
-rw-r--r--src/glsl/tests/constructor-02.glsl7
-rw-r--r--src/glsl/tests/constructor-03.glsl12
-rw-r--r--src/glsl/tests/constructor-04.glsl14
-rw-r--r--src/glsl/tests/constructor-05.glsl13
-rw-r--r--src/glsl/tests/constructor-06.glsl13
-rw-r--r--src/glsl/tests/constructor-07.glsl13
-rw-r--r--src/glsl/tests/constructor-08.glsl13
-rw-r--r--src/glsl/tests/constructor-09.glsl26
-rw-r--r--src/glsl/tests/function-01.glsl16
-rw-r--r--src/glsl/tests/function-02.glsl16
-rw-r--r--src/glsl/tests/function-03.glsl16
-rw-r--r--src/glsl/tests/function-04.glsl15
-rw-r--r--src/glsl/tests/function-05.glsl26
-rw-r--r--src/glsl/tests/if-01.glsl11
-rw-r--r--src/glsl/tests/if-02.glsl11
-rw-r--r--src/glsl/tests/if-03.glsl11
-rw-r--r--src/glsl/tests/if-04.glsl11
-rw-r--r--src/glsl/tests/matrix-01.glsl6
-rw-r--r--src/glsl/tests/matrix-02.glsl6
-rw-r--r--src/glsl/tests/matrix-03.glsl6
-rw-r--r--src/glsl/tests/matrix-04.glsl6
-rw-r--r--src/glsl/tests/matrix-05.glsl6
-rw-r--r--src/glsl/tests/matrix-06.glsl6
-rw-r--r--src/glsl/tests/matrix-07.glsl27
-rw-r--r--src/glsl/tests/matrix-08.glsl19
-rw-r--r--src/glsl/tests/matrix-09.glsl11
-rw-r--r--src/glsl/tests/matrix-10.glsl12
-rw-r--r--src/glsl/tests/parameters-01.glsl11
-rw-r--r--src/glsl/tests/parameters-02.glsl11
-rw-r--r--src/glsl/tests/parameters-03.glsl9
-rw-r--r--src/glsl/tests/qualifier-01.glsl3
-rw-r--r--src/glsl/tests/qualifier-02.glsl2
-rw-r--r--src/glsl/tests/qualifier-03.glsl2
-rw-r--r--src/glsl/tests/qualifier-04.glsl3
-rw-r--r--src/glsl/tests/qualifier-05.glsl3
-rw-r--r--src/glsl/tests/qualifier-06.glsl7
-rw-r--r--src/glsl/tests/qualifier-07.glsl7
-rw-r--r--src/glsl/tests/swiz-01.glsl11
-rw-r--r--src/glsl/tests/swiz-02.glsl11
-rw-r--r--src/glsl/tests/void-01.glsl2
-rw-r--r--src/mesa/Makefile21
-rw-r--r--src/mesa/SConscript8
-rw-r--r--src/mesa/drivers/dri/Makefile.template4
-rw-r--r--src/mesa/drivers/dri/common/dri_util.h4
-rw-r--r--src/mesa/drivers/dri/i915/i915_context.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c6
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.c8
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_emit.c25
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.h9
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_emit.c53
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_fp.c11
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_glsl.c8
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_pass1.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.h1
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex.h2
-rw-r--r--src/mesa/drivers/osmesa/Makefile3
-rw-r--r--src/mesa/main/dd.h21
-rw-r--r--src/mesa/main/imports.h29
-rw-r--r--src/mesa/main/mtypes.h24
-rw-r--r--src/mesa/main/shaderapi.c10
-rw-r--r--src/mesa/main/shaderobj.c18
-rw-r--r--src/mesa/main/shaderobj.h24
-rw-r--r--src/mesa/program/hash_table.c31
-rw-r--r--src/mesa/program/hash_table.h35
-rw-r--r--src/mesa/program/ir_to_mesa.cpp2725
-rw-r--r--src/mesa/program/ir_to_mesa.h38
-rw-r--r--src/mesa/program/prog_execute.c6
-rw-r--r--src/mesa/program/prog_instruction.h2
-rw-r--r--src/mesa/program/prog_optimize.c78
-rw-r--r--src/mesa/program/prog_parameter.c9
-rw-r--r--src/mesa/program/prog_parameter.h2
-rw-r--r--src/mesa/program/prog_print.c38
-rw-r--r--src/mesa/program/prog_print.h7
-rw-r--r--src/mesa/program/symbol_table.c59
-rw-r--r--src/mesa/program/symbol_table.h3
-rw-r--r--src/mesa/sources.mak21
-rw-r--r--src/mesa/state_tracker/st_program.c8
-rw-r--r--src/talloc/SConscript20
-rw-r--r--src/talloc/gpl-3.0.txt674
-rw-r--r--src/talloc/lgpl-3.0.txt165
-rw-r--r--src/talloc/talloc.c2034
-rw-r--r--src/talloc/talloc.def63
-rw-r--r--src/talloc/talloc.h202
-rw-r--r--src/talloc/talloc_guide.txt757
474 files changed, 85895 insertions, 306 deletions
diff --git a/SConstruct b/SConstruct
index a187d8d1b6f..bb03e5055ea 100644
--- a/SConstruct
+++ b/SConstruct
@@ -206,28 +206,6 @@ Export('env')
206# TODO: Build several variants at the same time? 206# TODO: Build several variants at the same time?
207# http://www.scons.org/wiki/SimultaneousVariantBuilds 207# http://www.scons.org/wiki/SimultaneousVariantBuilds
208 208
209if env['platform'] != common.default_platform:
210 # GLSL code has to be built twice -- one for the host OS, another for the target OS...
211
212 host_env = Environment(
213 # options are ignored
214 # default tool is used
215 tools = ['default', 'custom'],
216 toolpath = ['#scons'],
217 ENV = os.environ,
218 )
219
220 host_env['platform'] = common.default_platform
221 host_env['machine'] = common.default_machine
222 host_env['debug'] = env['debug']
223
224 SConscript(
225 'src/glsl/SConscript',
226 variant_dir = os.path.join(env['build'], 'host'),
227 duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
228 exports={'env':host_env},
229 )
230
231SConscript( 209SConscript(
232 'src/SConscript', 210 'src/SConscript',
233 variant_dir = env['build'], 211 variant_dir = env['build'],
diff --git a/configs/default b/configs/default
index 8711a382cc0..4f6334b43ba 100644
--- a/configs/default
+++ b/configs/default
@@ -116,7 +116,7 @@ EGL_CLIENT_APIS = $(GL_LIB)
116 116
117# Library dependencies 117# Library dependencies
118#EXTRA_LIB_PATH ?= 118#EXTRA_LIB_PATH ?=
119GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread 119GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -ltalloc
120EGL_LIB_DEPS = $(EXTRA_LIB_PATH) -ldl -lpthread 120EGL_LIB_DEPS = $(EXTRA_LIB_PATH) -ldl -lpthread
121OSMESA_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) 121OSMESA_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
122GLU_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm 122GLU_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
diff --git a/configs/linux-llvm b/configs/linux-llvm
index 83d2fc37176..6aa434032dc 100644
--- a/configs/linux-llvm
+++ b/configs/linux-llvm
@@ -41,4 +41,4 @@ else
41endif 41endif
42 42
43LD = g++ 43LD = g++
44GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -lstdc++ -ludis86 44GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread -ltalloc -lstdc++ -ludis86
diff --git a/configure.ac b/configure.ac
index 9f3006230eb..3d86decadaf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -463,6 +463,8 @@ xxlib|xdri|xosmesa)
463 ;; 463 ;;
464esac 464esac
465 465
466PKG_CHECK_MODULES([TALLOC], [talloc])
467
466dnl 468dnl
467dnl Driver specific build directories 469dnl Driver specific build directories
468dnl 470dnl
@@ -853,7 +855,7 @@ if test "$mesa_driver" = dri; then
853 [AC_MSG_ERROR([Expat required for DRI.])]) 855 [AC_MSG_ERROR([Expat required for DRI.])])
854 856
855 # put all the necessary libs together 857 # put all the necessary libs together
856 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS" 858 DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS $TALLOC_LIBS"
857fi 859fi
858AC_SUBST([DRI_DIRS]) 860AC_SUBST([DRI_DIRS])
859AC_SUBST([EXPAT_INCLUDES]) 861AC_SUBST([EXPAT_INCLUDES])
diff --git a/include/c99/inttypes.h b/include/c99/inttypes.h
new file mode 100644
index 00000000000..4b3828a2162
--- /dev/null
+++ b/include/c99/inttypes.h
@@ -0,0 +1,305 @@
1// ISO C9x compliant inttypes.h for Microsoft Visual Studio
2// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
3//
4// Copyright (c) 2006 Alexander Chemeris
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are met:
8//
9// 1. Redistributions of source code must retain the above copyright notice,
10// this list of conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright
13// notice, this list of conditions and the following disclaimer in the
14// documentation and/or other materials provided with the distribution.
15//
16// 3. The name of the author may be used to endorse or promote products
17// derived from this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
22// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30///////////////////////////////////////////////////////////////////////////////
31
32#ifndef _MSC_VER // [
33#error "Use this header only with Microsoft Visual C++ compilers!"
34#endif // _MSC_VER ]
35
36#ifndef _MSC_INTTYPES_H_ // [
37#define _MSC_INTTYPES_H_
38
39#if _MSC_VER > 1000
40#pragma once
41#endif
42
43#include "stdint.h"
44
45// 7.8 Format conversion of integer types
46
47typedef struct {
48 intmax_t quot;
49 intmax_t rem;
50} imaxdiv_t;
51
52// 7.8.1 Macros for format specifiers
53
54#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
55
56// The fprintf macros for signed integers are:
57#define PRId8 "d"
58#define PRIi8 "i"
59#define PRIdLEAST8 "d"
60#define PRIiLEAST8 "i"
61#define PRIdFAST8 "d"
62#define PRIiFAST8 "i"
63
64#define PRId16 "hd"
65#define PRIi16 "hi"
66#define PRIdLEAST16 "hd"
67#define PRIiLEAST16 "hi"
68#define PRIdFAST16 "hd"
69#define PRIiFAST16 "hi"
70
71#define PRId32 "I32d"
72#define PRIi32 "I32i"
73#define PRIdLEAST32 "I32d"
74#define PRIiLEAST32 "I32i"
75#define PRIdFAST32 "I32d"
76#define PRIiFAST32 "I32i"
77
78#define PRId64 "I64d"
79#define PRIi64 "I64i"
80#define PRIdLEAST64 "I64d"
81#define PRIiLEAST64 "I64i"
82#define PRIdFAST64 "I64d"
83#define PRIiFAST64 "I64i"
84
85#define PRIdMAX "I64d"
86#define PRIiMAX "I64i"
87
88#define PRIdPTR "Id"
89#define PRIiPTR "Ii"
90
91// The fprintf macros for unsigned integers are:
92#define PRIo8 "o"
93#define PRIu8 "u"
94#define PRIx8 "x"
95#define PRIX8 "X"
96#define PRIoLEAST8 "o"
97#define PRIuLEAST8 "u"
98#define PRIxLEAST8 "x"
99#define PRIXLEAST8 "X"
100#define PRIoFAST8 "o"
101#define PRIuFAST8 "u"
102#define PRIxFAST8 "x"
103#define PRIXFAST8 "X"
104
105#define PRIo16 "ho"
106#define PRIu16 "hu"
107#define PRIx16 "hx"
108#define PRIX16 "hX"
109#define PRIoLEAST16 "ho"
110#define PRIuLEAST16 "hu"
111#define PRIxLEAST16 "hx"
112#define PRIXLEAST16 "hX"
113#define PRIoFAST16 "ho"
114#define PRIuFAST16 "hu"
115#define PRIxFAST16 "hx"
116#define PRIXFAST16 "hX"
117
118#define PRIo32 "I32o"
119#define PRIu32 "I32u"
120#define PRIx32 "I32x"
121#define PRIX32 "I32X"
122#define PRIoLEAST32 "I32o"
123#define PRIuLEAST32 "I32u"
124#define PRIxLEAST32 "I32x"
125#define PRIXLEAST32 "I32X"
126#define PRIoFAST32 "I32o"
127#define PRIuFAST32 "I32u"
128#define PRIxFAST32 "I32x"
129#define PRIXFAST32 "I32X"
130
131#define PRIo64 "I64o"
132#define PRIu64 "I64u"
133#define PRIx64 "I64x"
134#define PRIX64 "I64X"
135#define PRIoLEAST64 "I64o"
136#define PRIuLEAST64 "I64u"
137#define PRIxLEAST64 "I64x"
138#define PRIXLEAST64 "I64X"
139#define PRIoFAST64 "I64o"
140#define PRIuFAST64 "I64u"
141#define PRIxFAST64 "I64x"
142#define PRIXFAST64 "I64X"
143
144#define PRIoMAX "I64o"
145#define PRIuMAX "I64u"
146#define PRIxMAX "I64x"
147#define PRIXMAX "I64X"
148
149#define PRIoPTR "Io"
150#define PRIuPTR "Iu"
151#define PRIxPTR "Ix"
152#define PRIXPTR "IX"
153
154// The fscanf macros for signed integers are:
155#define SCNd8 "d"
156#define SCNi8 "i"
157#define SCNdLEAST8 "d"
158#define SCNiLEAST8 "i"
159#define SCNdFAST8 "d"
160#define SCNiFAST8 "i"
161
162#define SCNd16 "hd"
163#define SCNi16 "hi"
164#define SCNdLEAST16 "hd"
165#define SCNiLEAST16 "hi"
166#define SCNdFAST16 "hd"
167#define SCNiFAST16 "hi"
168
169#define SCNd32 "ld"
170#define SCNi32 "li"
171#define SCNdLEAST32 "ld"
172#define SCNiLEAST32 "li"
173#define SCNdFAST32 "ld"
174#define SCNiFAST32 "li"
175
176#define SCNd64 "I64d"
177#define SCNi64 "I64i"
178#define SCNdLEAST64 "I64d"
179#define SCNiLEAST64 "I64i"
180#define SCNdFAST64 "I64d"
181#define SCNiFAST64 "I64i"
182
183#define SCNdMAX "I64d"
184#define SCNiMAX "I64i"
185
186#ifdef _WIN64 // [
187# define SCNdPTR "I64d"
188# define SCNiPTR "I64i"
189#else // _WIN64 ][
190# define SCNdPTR "ld"
191# define SCNiPTR "li"
192#endif // _WIN64 ]
193
194// The fscanf macros for unsigned integers are:
195#define SCNo8 "o"
196#define SCNu8 "u"
197#define SCNx8 "x"
198#define SCNX8 "X"
199#define SCNoLEAST8 "o"
200#define SCNuLEAST8 "u"
201#define SCNxLEAST8 "x"
202#define SCNXLEAST8 "X"
203#define SCNoFAST8 "o"
204#define SCNuFAST8 "u"
205#define SCNxFAST8 "x"
206#define SCNXFAST8 "X"
207
208#define SCNo16 "ho"
209#define SCNu16 "hu"
210#define SCNx16 "hx"
211#define SCNX16 "hX"
212#define SCNoLEAST16 "ho"
213#define SCNuLEAST16 "hu"
214#define SCNxLEAST16 "hx"
215#define SCNXLEAST16 "hX"
216#define SCNoFAST16 "ho"
217#define SCNuFAST16 "hu"
218#define SCNxFAST16 "hx"
219#define SCNXFAST16 "hX"
220
221#define SCNo32 "lo"
222#define SCNu32 "lu"
223#define SCNx32 "lx"
224#define SCNX32 "lX"
225#define SCNoLEAST32 "lo"
226#define SCNuLEAST32 "lu"
227#define SCNxLEAST32 "lx"
228#define SCNXLEAST32 "lX"
229#define SCNoFAST32 "lo"
230#define SCNuFAST32 "lu"
231#define SCNxFAST32 "lx"
232#define SCNXFAST32 "lX"
233
234#define SCNo64 "I64o"
235#define SCNu64 "I64u"
236#define SCNx64 "I64x"
237#define SCNX64 "I64X"
238#define SCNoLEAST64 "I64o"
239#define SCNuLEAST64 "I64u"
240#define SCNxLEAST64 "I64x"
241#define SCNXLEAST64 "I64X"
242#define SCNoFAST64 "I64o"
243#define SCNuFAST64 "I64u"
244#define SCNxFAST64 "I64x"
245#define SCNXFAST64 "I64X"
246
247#define SCNoMAX "I64o"
248#define SCNuMAX "I64u"
249#define SCNxMAX "I64x"
250#define SCNXMAX "I64X"
251
252#ifdef _WIN64 // [
253# define SCNoPTR "I64o"
254# define SCNuPTR "I64u"
255# define SCNxPTR "I64x"
256# define SCNXPTR "I64X"
257#else // _WIN64 ][
258# define SCNoPTR "lo"
259# define SCNuPTR "lu"
260# define SCNxPTR "lx"
261# define SCNXPTR "lX"
262#endif // _WIN64 ]
263
264#endif // __STDC_FORMAT_MACROS ]
265
266// 7.8.2 Functions for greatest-width integer types
267
268// 7.8.2.1 The imaxabs function
269#define imaxabs _abs64
270
271// 7.8.2.2 The imaxdiv function
272
273// This is modified version of div() function from Microsoft's div.c found
274// in %MSVC.NET%\crt\src\div.c
275#ifdef STATIC_IMAXDIV // [
276static
277#else // STATIC_IMAXDIV ][
278_inline
279#endif // STATIC_IMAXDIV ]
280imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
281{
282 imaxdiv_t result;
283
284 result.quot = numer / denom;
285 result.rem = numer % denom;
286
287 if (numer < 0 && result.rem > 0) {
288 // did division wrong; must fix up
289 ++result.quot;
290 result.rem -= denom;
291 }
292
293 return result;
294}
295
296// 7.8.2.3 The strtoimax and strtoumax functions
297#define strtoimax _strtoi64
298#define strtoumax _strtoui64
299
300// 7.8.2.4 The wcstoimax and wcstoumax functions
301#define wcstoimax _wcstoi64
302#define wcstoumax _wcstoui64
303
304
305#endif // _MSC_INTTYPES_H_ ]
diff --git a/include/c99/stdint.h b/include/c99/stdint.h
index fc6459d03d2..d02608a5972 100644
--- a/include/c99/stdint.h
+++ b/include/c99/stdint.h
@@ -1,117 +1,247 @@
1/************************************************************************** 1// ISO C9x compliant stdint.h for Microsoft Visual Studio
2 * 2// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
3 * Copyright 2007-2010 VMware, Inc. 3//
4 * All Rights Reserved. 4// Copyright (c) 2006-2008 Alexander Chemeris
5 * 5//
6 * Permission is hereby granted, free of charge, to any person obtaining a 6// Redistribution and use in source and binary forms, with or without
7 * copy of this software and associated documentation files (the 7// modification, are permitted provided that the following conditions are met:
8 * "Software"), to deal in the Software without restriction, including 8//
9 * without limitation the rights to use, copy, modify, merge, publish, 9// 1. Redistributions of source code must retain the above copyright notice,
10 * distribute, sub license, and/or sell copies of the Software, and to 10// this list of conditions and the following disclaimer.
11 * permit persons to whom the Software is furnished to do so, subject to 11//
12 * the following conditions: 12// 2. Redistributions in binary form must reproduce the above copyright
13 * 13// notice, this list of conditions and the following disclaimer in the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14// documentation and/or other materials provided with the distribution.
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15//
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 16// 3. The name of the author may be used to endorse or promote products
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 17// derived from this software without specific prior written permission.
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 18//
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 19// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 * USE OR OTHER DEALINGS IN THE SOFTWARE. 20// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * 21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
22 * The above copyright notice and this permission notice (including the 22// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * next paragraph) shall be included in all copies or substantial portions 23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * of the Software. 24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 * 25// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 **************************************************************************/ 26// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 27// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28/* 28// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * stdint.h -- 29//
30 * 30///////////////////////////////////////////////////////////////////////////////
31 * Portable subset of C99's stdint.h.
32 *
33 * At the moment it only supports MSVC, given all other mainstream compilers
34 * already support C99. If this is necessary for other compilers then it
35 * might be worth to replace this with
36 * http://www.azillionmonkeys.com/qed/pstdint.h.
37 */
38
39#ifndef _STDINT_H_
40#define _STDINT_H_
41
42
43#ifndef INT8_MAX
44#define INT8_MAX 127
45#endif
46#ifndef INT8_MIN
47#define INT8_MIN -128
48#endif
49#ifndef UINT8_MAX
50#define UINT8_MAX 255
51#endif
52#ifndef INT16_MAX
53#define INT16_MAX 32767
54#endif
55#ifndef INT16_MIN
56#define INT16_MIN -32768
57#endif
58#ifndef UINT16_MAX
59#define UINT16_MAX 65535
60#endif
61#ifndef INT32_MAX
62#define INT32_MAX 2147483647
63#endif
64#ifndef INT32_MIN
65#define INT32_MIN -2147483648
66#endif
67#ifndef UINT32_MAX
68#define UINT32_MAX 4294967295U
69#endif
70 31
71#ifndef INT8_C 32#ifndef _MSC_VER // [
72#define INT8_C(__val) __val 33#error "Use this header only with Microsoft Visual C++ compilers!"
73#endif 34#endif // _MSC_VER ]
74#ifndef UINT8_C 35
75#define UINT8_C(__val) __val 36#ifndef _MSC_STDINT_H_ // [
76#endif 37#define _MSC_STDINT_H_
77#ifndef INT16_C 38
78#define INT16_C(__val) __val 39#if _MSC_VER > 1000
40#pragma once
79#endif 41#endif
80#ifndef UINT16_C 42
81#define UINT16_C(__val) __val 43#include <limits.h>
44
45// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
46// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
47// or compiler give many errors like this:
48// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
49#ifdef __cplusplus
50extern "C" {
82#endif 51#endif
83#ifndef INT32_C 52# include <wchar.h>
84#define INT32_C(__val) __val 53#ifdef __cplusplus
54}
85#endif 55#endif
86#ifndef UINT32_C 56
87#define UINT32_C(__val) __val##U 57// Define _W64 macros to mark types changing their size, like intptr_t.
58#ifndef _W64
59# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
60# define _W64 __w64
61# else
62# define _W64
63# endif
88#endif 64#endif
89 65
90 66
91#if defined(_MSC_VER) 67// 7.18.1 Integer types
92 68
93typedef __int8 int8_t; 69// 7.18.1.1 Exact-width integer types
94typedef unsigned __int8 uint8_t;
95typedef __int16 int16_t;
96typedef unsigned __int16 uint16_t;
97typedef __int32 int32_t;
98typedef unsigned __int32 uint32_t;
99typedef __int64 int64_t;
100typedef unsigned __int64 uint64_t;
101 70
102#if defined(_WIN64) 71// Visual Studio 6 and Embedded Visual C++ 4 doesn't
103typedef __int64 intptr_t; 72// realize that, e.g. char has the same size as __int8
104typedef unsigned __int64 uintptr_t; 73// so we give up on __intX for them.
74#if (_MSC_VER < 1300)
75 typedef signed char int8_t;
76 typedef signed short int16_t;
77 typedef signed int int32_t;
78 typedef unsigned char uint8_t;
79 typedef unsigned short uint16_t;
80 typedef unsigned int uint32_t;
105#else 81#else
106typedef __int32 intptr_t; 82 typedef signed __int8 int8_t;
107typedef unsigned __int32 uintptr_t; 83 typedef signed __int16 int16_t;
108#endif 84 typedef signed __int32 int32_t;
85 typedef unsigned __int8 uint8_t;
86 typedef unsigned __int16 uint16_t;
87 typedef unsigned __int32 uint32_t;
88#endif
89typedef signed __int64 int64_t;
90typedef unsigned __int64 uint64_t;
109 91
110#define INT64_C(__val) __val##i64
111#define UINT64_C(__val) __val##ui64
112 92
113#else 93// 7.18.1.2 Minimum-width integer types
114#error "Unsupported compiler" 94typedef int8_t int_least8_t;
115#endif 95typedef int16_t int_least16_t;
96typedef int32_t int_least32_t;
97typedef int64_t int_least64_t;
98typedef uint8_t uint_least8_t;
99typedef uint16_t uint_least16_t;
100typedef uint32_t uint_least32_t;
101typedef uint64_t uint_least64_t;
102
103// 7.18.1.3 Fastest minimum-width integer types
104typedef int8_t int_fast8_t;
105typedef int16_t int_fast16_t;
106typedef int32_t int_fast32_t;
107typedef int64_t int_fast64_t;
108typedef uint8_t uint_fast8_t;
109typedef uint16_t uint_fast16_t;
110typedef uint32_t uint_fast32_t;
111typedef uint64_t uint_fast64_t;
112
113// 7.18.1.4 Integer types capable of holding object pointers
114#ifdef _WIN64 // [
115 typedef signed __int64 intptr_t;
116 typedef unsigned __int64 uintptr_t;
117#else // _WIN64 ][
118 typedef _W64 signed int intptr_t;
119 typedef _W64 unsigned int uintptr_t;
120#endif // _WIN64 ]
121
122// 7.18.1.5 Greatest-width integer types
123typedef int64_t intmax_t;
124typedef uint64_t uintmax_t;
125
126
127// 7.18.2 Limits of specified-width integer types
128
129#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
130
131// 7.18.2.1 Limits of exact-width integer types
132#define INT8_MIN ((int8_t)_I8_MIN)
133#define INT8_MAX _I8_MAX
134#define INT16_MIN ((int16_t)_I16_MIN)
135#define INT16_MAX _I16_MAX
136#define INT32_MIN ((int32_t)_I32_MIN)
137#define INT32_MAX _I32_MAX
138#define INT64_MIN ((int64_t)_I64_MIN)
139#define INT64_MAX _I64_MAX
140#define UINT8_MAX _UI8_MAX
141#define UINT16_MAX _UI16_MAX
142#define UINT32_MAX _UI32_MAX
143#define UINT64_MAX _UI64_MAX
144
145// 7.18.2.2 Limits of minimum-width integer types
146#define INT_LEAST8_MIN INT8_MIN
147#define INT_LEAST8_MAX INT8_MAX
148#define INT_LEAST16_MIN INT16_MIN
149#define INT_LEAST16_MAX INT16_MAX
150#define INT_LEAST32_MIN INT32_MIN
151#define INT_LEAST32_MAX INT32_MAX
152#define INT_LEAST64_MIN INT64_MIN
153#define INT_LEAST64_MAX INT64_MAX
154#define UINT_LEAST8_MAX UINT8_MAX
155#define UINT_LEAST16_MAX UINT16_MAX
156#define UINT_LEAST32_MAX UINT32_MAX
157#define UINT_LEAST64_MAX UINT64_MAX
158
159// 7.18.2.3 Limits of fastest minimum-width integer types
160#define INT_FAST8_MIN INT8_MIN
161#define INT_FAST8_MAX INT8_MAX
162#define INT_FAST16_MIN INT16_MIN
163#define INT_FAST16_MAX INT16_MAX
164#define INT_FAST32_MIN INT32_MIN
165#define INT_FAST32_MAX INT32_MAX
166#define INT_FAST64_MIN INT64_MIN
167#define INT_FAST64_MAX INT64_MAX
168#define UINT_FAST8_MAX UINT8_MAX
169#define UINT_FAST16_MAX UINT16_MAX
170#define UINT_FAST32_MAX UINT32_MAX
171#define UINT_FAST64_MAX UINT64_MAX
172
173// 7.18.2.4 Limits of integer types capable of holding object pointers
174#ifdef _WIN64 // [
175# define INTPTR_MIN INT64_MIN
176# define INTPTR_MAX INT64_MAX
177# define UINTPTR_MAX UINT64_MAX
178#else // _WIN64 ][
179# define INTPTR_MIN INT32_MIN
180# define INTPTR_MAX INT32_MAX
181# define UINTPTR_MAX UINT32_MAX
182#endif // _WIN64 ]
183
184// 7.18.2.5 Limits of greatest-width integer types
185#define INTMAX_MIN INT64_MIN
186#define INTMAX_MAX INT64_MAX
187#define UINTMAX_MAX UINT64_MAX
188
189// 7.18.3 Limits of other integer types
190
191#ifdef _WIN64 // [
192# define PTRDIFF_MIN _I64_MIN
193# define PTRDIFF_MAX _I64_MAX
194#else // _WIN64 ][
195# define PTRDIFF_MIN _I32_MIN
196# define PTRDIFF_MAX _I32_MAX
197#endif // _WIN64 ]
198
199#define SIG_ATOMIC_MIN INT_MIN
200#define SIG_ATOMIC_MAX INT_MAX
201
202#ifndef SIZE_MAX // [
203# ifdef _WIN64 // [
204# define SIZE_MAX _UI64_MAX
205# else // _WIN64 ][
206# define SIZE_MAX _UI32_MAX
207# endif // _WIN64 ]
208#endif // SIZE_MAX ]
209
210// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
211#ifndef WCHAR_MIN // [
212# define WCHAR_MIN 0
213#endif // WCHAR_MIN ]
214#ifndef WCHAR_MAX // [
215# define WCHAR_MAX _UI16_MAX
216#endif // WCHAR_MAX ]
217
218#define WINT_MIN 0
219#define WINT_MAX _UI16_MAX
220
221#endif // __STDC_LIMIT_MACROS ]
222
223
224// 7.18.4 Limits of other integer types
225
226#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
227
228// 7.18.4.1 Macros for minimum-width integer constants
229
230#define INT8_C(val) val##i8
231#define INT16_C(val) val##i16
232#define INT32_C(val) val##i32
233#define INT64_C(val) val##i64
234
235#define UINT8_C(val) val##ui8
236#define UINT16_C(val) val##ui16
237#define UINT32_C(val) val##ui32
238#define UINT64_C(val) val##ui64
239
240// 7.18.4.2 Macros for greatest-width integer constants
241#define INTMAX_C INT64_C
242#define UINTMAX_C UINT64_C
243
244#endif // __STDC_CONSTANT_MACROS ]
245
116 246
117#endif /* _STDINT_H_ */ 247#endif // _MSC_STDINT_H_ ]
diff --git a/src/SConscript b/src/SConscript
index 2b46186f986..c3e34be6f76 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -5,6 +5,9 @@ if 'egl' in env['statetrackers']:
5 SConscript('egl/main/SConscript') 5 SConscript('egl/main/SConscript')
6 6
7if 'mesa' in env['statetrackers']: 7if 'mesa' in env['statetrackers']:
8 if platform == 'windows':
9 SConscript('talloc/SConscript')
10
8 SConscript('glsl/SConscript') 11 SConscript('glsl/SConscript')
9 SConscript('mapi/glapi/SConscript') 12 SConscript('mapi/glapi/SConscript')
10 SConscript('mesa/SConscript') 13 SConscript('mesa/SConscript')
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
index de05f96d231..59961e982aa 100644
--- a/src/gallium/targets/Makefile.dri
+++ b/src/gallium/targets/Makefile.dri
@@ -1,11 +1,12 @@
1# -*-makefile-*- 1# -*-makefile-*-
2 2
3
3ifeq ($(MESA_LLVM),1) 4ifeq ($(MESA_LLVM),1)
4PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a 5PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
5LDFLAGS += $(LLVM_LDFLAGS) 6LDFLAGS += $(LLVM_LDFLAGS)
6LD = g++
7DRIVER_EXTRAS = $(LLVM_LIBS) 7DRIVER_EXTRAS = $(LLVM_LIBS)
8USE_CXX=1 8else
9LDFLAGS += -lstdc++
9endif 10endif
10 11
11MESA_MODULES = \ 12MESA_MODULES = \
@@ -75,15 +76,11 @@ default: depend symlinks $(TOP)/$(LIB_DIR)/gallium $(LIBNAME) $(LIBNAME_STAGING)
75 76
76$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ 77$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
77 $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o 78 $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o
78 $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ 79 $(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
79 $(OBJECTS) $(PIPE_DRIVERS) \ 80 $(OBJECTS) $(PIPE_DRIVERS) \
80 -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ 81 -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
81 $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) 82 $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
82 if [ "x${USE_CXX}" == "x" ]; then \ 83 $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS);
83 $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \
84 else \
85 $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \
86 fi
87 @rm -f $@.test 84 @rm -f $@.test
88 mv -f $@.tmp $@ 85 mv -f $@.tmp $@
89 86
diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript
index 144084f74f8..12fe403f62f 100644
--- a/src/gallium/targets/libgl-gdi/SConscript
+++ b/src/gallium/targets/libgl-gdi/SConscript
@@ -17,6 +17,7 @@ if env['platform'] == 'windows':
17 'user32', 17 'user32',
18 'kernel32', 18 'kernel32',
19 'ws2_32', 19 'ws2_32',
20 talloc,
20 ]) 21 ])
21 22
22 sources = [] 23 sources = []
diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript
index 78703fd096d..88e216a65be 100644
--- a/src/gallium/targets/libgl-xlib/SConscript
+++ b/src/gallium/targets/libgl-xlib/SConscript
@@ -35,6 +35,7 @@ env.Prepend(LIBS = [
35 mesa, 35 mesa,
36 glsl, 36 glsl,
37 gallium, 37 gallium,
38 'talloc'
38]) 39])
39 40
40sources = [ 41sources = [
diff --git a/src/glsl/.dir-locals.el b/src/glsl/.dir-locals.el
new file mode 100644
index 00000000000..be19e29a5ab
--- /dev/null
+++ b/src/glsl/.dir-locals.el
@@ -0,0 +1,3 @@
1((c-mode . ((c-basic-offset . 3)))
2 (c++-mode . ((c-basic-offset . 3)))
3)
diff --git a/src/glsl/.gitignore b/src/glsl/.gitignore
new file mode 100644
index 00000000000..4c212313e45
--- /dev/null
+++ b/src/glsl/.gitignore
@@ -0,0 +1,2 @@
1glsl_compiler
2glsl_parser.output
diff --git a/src/glsl/Makefile b/src/glsl/Makefile
index ca7f2d2ac7d..1d200b47b40 100644
--- a/src/glsl/Makefile
+++ b/src/glsl/Makefile
@@ -1,15 +1,176 @@
1# src/glsl/Makefile 1#src/glsl/pp/Makefile
2 2
3TOP = ../.. 3TOP = ../..
4 4
5include $(TOP)/configs/current 5include $(TOP)/configs/current
6 6
7SUBDIRS = pp cl apps 7LIBNAME = glsl
8 8
9default install clean: 9LIBGLCPP_SOURCES = \
10 @for dir in $(SUBDIRS) ; do \ 10 glcpp/glcpp-lex.c \
11 if [ -d $$dir ] ; then \ 11 glcpp/glcpp-parse.c \
12 (cd $$dir && $(MAKE) $@) || exit 1; \ 12 glcpp/pp.c
13 fi \
14 done
15 13
14GLCPP_SOURCES = \
15 $(LIBGLCPP_SOURCES) \
16 glcpp/glcpp.c
17
18C_SOURCES = \
19 $(LIBGLCPP_SOURCES)
20
21CXX_SOURCES = \
22 ast_expr.cpp \
23 ast_function.cpp \
24 ast_to_hir.cpp \
25 ast_type.cpp \
26 builtin_function.cpp \
27 glsl_lexer.cpp \
28 glsl_parser.cpp \
29 glsl_parser_extras.cpp \
30 glsl_types.cpp \
31 hir_field_selection.cpp \
32 ir_algebraic.cpp \
33 ir_basic_block.cpp \
34 ir_clone.cpp \
35 ir_constant_expression.cpp \
36 ir_constant_folding.cpp \
37 ir_constant_propagation.cpp \
38 ir_constant_variable.cpp \
39 ir_copy_propagation.cpp \
40 ir.cpp \
41 ir_dead_code.cpp \
42 ir_dead_code_local.cpp \
43 ir_dead_functions.cpp \
44 ir_div_to_mul_rcp.cpp \
45 ir_explog_to_explog2.cpp \
46 ir_expression_flattening.cpp \
47 ir_function_can_inline.cpp \
48 ir_function.cpp \
49 ir_function_inlining.cpp \
50 ir_hierarchical_visitor.cpp \
51 ir_hv_accept.cpp \
52 ir_if_return.cpp \
53 ir_if_simplification.cpp \
54 ir_if_to_cond_assign.cpp \
55 ir_import_prototypes.cpp \
56 ir_mat_op_to_vec.cpp \
57 ir_mod_to_fract.cpp \
58 ir_noop_swizzle.cpp \
59 ir_print_visitor.cpp \
60 ir_reader.cpp \
61 ir_rvalue_visitor.cpp \
62 ir_set_program_inouts.cpp \
63 ir_structure_splitting.cpp \
64 ir_sub_to_add_neg.cpp \
65 ir_swizzle_swizzle.cpp \
66 ir_tree_grafting.cpp \
67 ir_validate.cpp \
68 ir_variable.cpp \
69 ir_variable_refcount.cpp \
70 ir_vec_index_to_cond_assign.cpp \
71 ir_vec_index_to_swizzle.cpp \
72 linker.cpp \
73 link_functions.cpp \
74 s_expression.cpp
75
76LIBS = \
77 $(TOP)/src/glsl/libglsl.a \
78 $(shell pkg-config --libs talloc)
79
80APPS = glsl_compiler glcpp/glcpp
81
82GLSL2_C_SOURCES = \
83 ../mesa/program/hash_table.c \
84 ../mesa/program/symbol_table.c
85GLSL2_CXX_SOURCES = \
86 main.cpp
87
88GLSL2_OBJECTS = \
89 $(GLSL2_C_SOURCES:.c=.o) \
90 $(GLSL2_CXX_SOURCES:.cpp=.o)
91
92### Basic defines ###
93
94DEFINES += \
95 $(LIBRARY_DEFINES) \
96 $(API_DEFINES)
97
98GLCPP_OBJECTS = \
99 $(GLCPP_SOURCES:.c=.o) \
100 ../mesa/program/hash_table.o
101
102OBJECTS = \
103 $(C_SOURCES:.c=.o) \
104 $(CXX_SOURCES:.cpp=.o)
105
106INCLUDES = \
107 -I. \
108 -I../mesa \
109 -I../mapi \
110 -I../../include \
111 $(LIBRARY_INCLUDES)
112
113ALL_SOURCES = \
114 $(C_SOURCES) \
115 $(CXX_SOURCES) \
116 $(GLSL2_CXX_SOURCES) \
117 $(GLSL2_C_SOURCES)
118
119##### TARGETS #####
120
121default: depend lib$(LIBNAME).a $(APPS)
122
123lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template
124 $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS)
125
126depend: $(ALL_SOURCES) Makefile
127 rm -f depend
128 touch depend
129 $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
130
131# Remove .o and backup files
132clean:
133 rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak
134 -rm -f $(APPS)
135
136# Dummy target
137install:
138 @echo -n ""
139
140
141##### RULES #####
142
143glsl_compiler: $(GLSL2_OBJECTS) libglsl.a
144 $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) $(LIBS) -o $@
145
146glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a
147 $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) $(LIBS) -o $@
148
149.cpp.o:
150 $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@
151
152.c.o:
153 $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
154
155glsl_lexer.cpp: glsl_lexer.lpp
156 flex --nounistd -o$@ $<
157
158glsl_parser.cpp: glsl_parser.ypp
159 bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $<
160
161glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
162 flex --nounistd -o$@ $<
163
164glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
165 bison -v -o "$@" --defines=glcpp/glcpp-parse.h $<
166
167builtins: builtin_function.cpp builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py
168 @echo Bootstrapping the compiler...
169 cp builtins/tools/builtin_function.cpp .
170 make glsl_compiler
171 @echo Regenerating builtin_function.cpp...
172 ./builtins/tools/generate_builtins.py > builtin_function.cpp
173 @echo Rebuilding the real compiler...
174 make glsl_compiler
175
176-include depend
diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
new file mode 100644
index 00000000000..5728a8b63da
--- /dev/null
+++ b/src/glsl/Makefile.am
@@ -0,0 +1,75 @@
1# Copyright © 2010 Intel Corporation
2# All Rights Reserved.
3#
4# Permission is hereby granted, free of charge, to any person obtaining a
5# copy of this software and associated documentation files (the "Software"),
6# to deal in the Software without restriction, including without limitation
7# on the rights to use, copy, modify, merge, publish, distribute, sub
8# license, and/or sell copies of the Software, and to permit persons to whom
9# the Software is furnished to do so, subject to the following conditions:
10#
11# The above copyright notice and this permission notice (including the next
12# paragraph) shall be included in all copies or substantial portions of the
13# Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21# USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23AUTOMAKE_OPTIONS = foreign
24AM_CPPFLAGS = -I mesa
25
26SUBDIRS = glcpp
27
28bin_PROGRAMS = glsl
29
30glsl_LDADD = ./glcpp/libglcpp.la
31glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS)
32glsl_SOURCES = \
33 main.cpp \
34 builtin_types.h \
35 glsl_types.cpp \
36 glsl_parser.ypp glsl_lexer.lpp glsl_parser_extras.cpp \
37 ast_expr.cpp ast_to_hir.cpp ast_function.cpp ast_type.cpp \
38 ir.cpp hir_field_selection.cpp builtin_function.cpp \
39 ir_print_visitor.cpp ir_variable.cpp ir_function.cpp \
40 ir_basic_block.cpp \
41 ir_basic_block.h \
42 ir_clone.cpp \
43 ir_constant_expression.cpp \
44 ir_constant_folding.cpp \
45 ir_constant_variable.cpp \
46 ir_copy_propagation.cpp \
47 ir_copy_propagation.h \
48 ir_dead_code.cpp \
49 ir_dead_code.h \
50 ir_dead_code_local.cpp \
51 ir_expression_flattening.cpp \
52 ir_function_can_inline.cpp \
53 ir_function_inlining.cpp \
54 ir_if_simplification.cpp \
55 ir_optimization.h \
56 ir_reader.cpp s_expression.cpp \
57 ir_hv_accept.cpp \
58 ir_hierarchical_visitor.h \
59 ir_hierarchical_visitor.cpp \
60 ir_swizzle_swizzle.cpp \
61 ir_to_mesa.cpp \
62 ir_to_mesa.h \
63 ir_validate.cpp \
64 ir_vec_index_to_swizzle.cpp \
65 linker.cpp
66
67BUILT_SOURCES = glsl_parser.h glsl_parser.cpp glsl_lexer.cpp
68CLEANFILES = $(BUILT_SOURCES)
69
70builtin_function.cpp: builtins/*/*
71 ./builtins/tools/generate_builtins.pl > builtin_function.cpp
72glsl_parser.h: glsl_parser.cpp
73
74.lpp.cpp:
75 $(LEXCOMPILE) --outfile="$@" $<
diff --git a/src/glsl/README b/src/glsl/README
new file mode 100644
index 00000000000..74520321b21
--- /dev/null
+++ b/src/glsl/README
@@ -0,0 +1,190 @@
1Welcome to Mesa's GLSL compiler. A brief overview of how things flow:
2
31) lex and yacc-based preprocessor takes the incoming shader string
4and produces a new string containing the preprocessed shader. This
5takes care of things like #if, #ifdef, #define, and preprocessor macro
6invocations. Note that #version, #extension, and some others are
7passed straight through. See glcpp/*
8
92) lex and yacc-based parser takes the preprocessed string and
10generates the AST (abstract syntax tree). Almost no checking is
11performed in this stage. See glsl_lexer.lpp and glsl_parser.ypp.
12
133) The AST is converted to "HIR". This is the intermediate
14representation of the compiler. Constructors are generated, function
15calls are resolved to particular function signatures, and all the
16semantic checking is performed. See ast_*.cpp for the conversion, and
17ir.h for the IR structures.
18
194) The driver (Mesa, or main.cpp for the standalone binary) performs
20optimizations. These include copy propagation, dead code elimination,
21constant folding, and others. Generally the driver will call
22optimizations in a loop, as each may open up opportunities for other
23optimizations to do additional work. See most files called ir_*.cpp
24
255) linking is performed. This does checking to ensure that the
26outputs of the vertex shader match the inputs of the fragment shader,
27and assigns locations to uniforms, attributes, and varyings. See
28linker.cpp.
29
306) The driver may perform additional optimization at this point, as
31for example dead code elimination previously couldn't remove functions
32or global variable usage when we didn't know what other code would be
33linked in.
34
357) The driver performs code generation out of the IR, taking a linked
36shader program and producing a compiled program for each stage. See
37ir_to_mesa.cpp for Mesa IR code generation.
38
39FAQ:
40
41Q: What is HIR versus IR versus LIR?
42
43A: The idea behind the naming was that ast_to_hir would produce a
44high-level IR ("HIR"), with things like matrix operations, structure
45assignments, etc., present. A series of lowering passes would occur
46that do things like break matrix multiplication into a series of dot
47products/MADs, make structure assignment be a series of assignment of
48components, flatten if statements into conditional moves, and such,
49producing a low level IR ("LIR").
50
51However, it now appears that each driver will have different
52requirements from a LIR. A 915-generation chipset wants all functions
53inlined, all loops unrolled, all ifs flattened, no variable array
54accesses, and matrix multiplication broken down. The Mesa IR backend
55for swrast would like matrices and structure assignment broken down,
56but it can support function calls and dynamic branching. A 965 vertex
57shader IR backend could potentially even handle some matrix operations
58without breaking them down, but the 965 fragment shader IR backend
59would want to break to have (almost) all operations down channel-wise
60and perform optimization on that. As a result, there's no single
61low-level IR that will make everyone happy. So that usage has fallen
62out of favor, and each driver will perform a series of lowering passes
63to take the HIR down to whatever restrictions it wants to impose
64before doing codegen.
65
66Q: How is the IR structured?
67
68A: The best way to get started seeing it would be to run the
69standalone compiler against a shader:
70
71./glsl_compiler --dump-lir \
72 ~/src/piglit/tests/shaders/glsl-orangebook-ch06-bump.frag
73
74So for example one of the ir_instructions in main() contains:
75
76(assign (constant bool (1)) (var_ref litColor) (expression vec3 * (var_ref Surf
77aceColor) (var_ref __retval) ) )
78
79Or more visually:
80 (assign)
81 / | \
82 (var_ref) (expression *) (constant bool 1)
83 / / \
84(litColor) (var_ref) (var_ref)
85 / \
86 (SurfaceColor) (__retval)
87
88which came from:
89
90litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0);
91
92(the max call is not represented in this expression tree, as it was a
93function call that got inlined but not brought into this expression
94tree)
95
96Each of those nodes is a subclass of ir_instruction. A particular
97ir_instruction instance may only appear once in the whole IR tree with
98the exception of ir_variables, which appear once as variable
99declarations:
100
101(declare () vec3 normDelta)
102
103and multiple times as the targets of variable dereferences:
104...
105(assign (constant bool (1)) (var_ref __retval) (expression float dot
106 (var_ref normDelta) (var_ref LightDir) ) )
107...
108(assign (constant bool (1)) (var_ref __retval) (expression vec3 -
109 (var_ref LightDir) (expression vec3 * (constant float (2.000000))
110 (expression vec3 * (expression float dot (var_ref normDelta) (var_ref
111 LightDir) ) (var_ref normDelta) ) ) ) )
112...
113
114Each node has a type. Expressions may involve several different types:
115(declare (uniform ) mat4 gl_ModelViewMatrix)
116((assign (constant bool (1)) (var_ref constructor_tmp) (expression
117 vec4 * (var_ref gl_ModelViewMatrix) (var_ref gl_Vertex) ) )
118
119An expression tree can be arbitrarily deep, and the compiler tries to
120keep them structured like that so that things like algebraic
121optimizations ((color * 1.0 == color) and ((mat1 * mat2) * vec == mat1
122* (mat2 * vec))) or recognizing operation patterns for code generation
123(vec1 * vec2 + vec3 == mad(vec1, vec2, vec3)) are easier. This comes
124at the expense of additional trickery in implementing some
125optimizations like CSE where one must navigate an expression tree.
126
127Q: Why no SSA representation?
128
129A: Converting an IR tree to SSA form makes dead code elmimination,
130common subexpression elimination, and many other optimizations much
131easier. However, in our primarily vector-based language, there's some
132major questions as to how it would work. Do we do SSA on the scalar
133or vector level? If we do it at the vector level, we're going to end
134up with many different versions of the variable when encountering code
135like:
136
137(assign (constant bool (1)) (swiz x (var_ref __retval) ) (var_ref a) )
138(assign (constant bool (1)) (swiz y (var_ref __retval) ) (var_ref b) )
139(assign (constant bool (1)) (swiz z (var_ref __retval) ) (var_ref c) )
140
141If every masked update of a component relies on the previous value of
142the variable, then we're probably going to be quite limited in our
143dead code elimination wins, and recognizing common expressions may
144just not happen. On the other hand, if we operate channel-wise, then
145we'll be prone to optimizing the operation on one of the channels at
146the expense of making its instruction flow different from the other
147channels, and a vector-based GPU would end up with worse code than if
148we didn't optimize operations on that channel!
149
150Once again, it appears that our optimization requirements are driven
151significantly by the target architecture. For now, targeting the Mesa
152IR backend, SSA does not appear to be that important to producing
153excellent code, but we do expect to do some SSA-based optimizations
154for the 965 fragment shader backend when that is developed.
155
156Q: How should I expand instructions that take multiple backend instructions?
157
158Sometimes you'll have to do the expansion in your code generation --
159see, for example, ir_to_mesa.cpp's handling of ir_binop_mul for
160matrices. However, in many cases you'll want to do a pass over the IR
161to convert non-native instructions to a series of native instructions.
162For example, for the Mesa backend we have ir_div_to_mul_rcp.cpp because
163Mesa IR (and many hardware backends) only have a reciprocal
164instruction, not a divide. Implementing non-native instructions this
165way gives the chance for constant folding to occur, so (a / 2.0)
166becomes (a * 0.5) after codegen instead of (a * (1.0 / 2.0))
167
168Q: How shoud I handle my special hardware instructions with respect to IR?
169
170Our current theory is that if multiple targets have an instruction for
171some operation, then we should probably be able to represent that in
172the IR. Generally this is in the form of an ir_{bin,un}op expression
173type. For example, we initially implemented fract() using (a -
174floor(a)), but both 945 and 965 have instructions to give that result,
175and it would also simplify the implementation of mod(), so
176ir_unop_fract was added. The following areas need updating to add a
177new expression type:
178
179ir.h (new enum)
180ir.cpp:get_num_operands() (used for ir_reader)
181ir.cpp:operator_strs (used for ir_reader)
182ir_constant_expression.cpp (you probably want to be able to constant fold)
183
184You may also need to update the backends if they will see the new expr type:
185
186../mesa/shaders/ir_to_mesa.cpp
187
188You can then use the new expression from builtins (if all backends
189would rather see it), or scan the IR and convert to use your new
190expression type (see ir_mod_to_fract, for example).
diff --git a/src/glsl/SConscript b/src/glsl/SConscript
index 8e18626c404..96a226d0dd2 100644
--- a/src/glsl/SConscript
+++ b/src/glsl/SConscript
@@ -4,23 +4,71 @@ Import('*')
4 4
5env = env.Clone() 5env = env.Clone()
6 6
7env.Prepend(CPPPATH = [
8 '#src/mapi',
9 '#src/mesa',
10])
11
12if env['platform'] == 'windows':
13 env.Prepend(CPPPATH = ['#src/talloc'])
14
7sources = [ 15sources = [
8 'pp/sl_pp_context.c', 16 'glcpp/glcpp-lex.c',
9 'pp/sl_pp_define.c', 17 'glcpp/glcpp-parse.c',
10 'pp/sl_pp_dict.c', 18 'glcpp/pp.c',
11 'pp/sl_pp_error.c', 19 'ast_expr.cpp',
12 'pp/sl_pp_expression.c', 20 'ast_function.cpp',
13 'pp/sl_pp_extension.c', 21 'ast_to_hir.cpp',
14 'pp/sl_pp_if.c', 22 'ast_type.cpp',
15 'pp/sl_pp_line.c', 23 'builtin_function.cpp',
16 'pp/sl_pp_macro.c', 24 'glsl_lexer.cpp',
17 'pp/sl_pp_pragma.c', 25 'glsl_parser.cpp',
18 'pp/sl_pp_process.c', 26 'glsl_parser_extras.cpp',
19 'pp/sl_pp_purify.c', 27 'glsl_types.cpp',
20 'pp/sl_pp_token.c', 28 'hir_field_selection.cpp',
21 'pp/sl_pp_token_util.c', 29 'ir_algebraic.cpp',
22 'pp/sl_pp_version.c', 30 'ir_basic_block.cpp',
23 'cl/sl_cl_parse.c', 31 'ir_clone.cpp',
32 'ir_constant_expression.cpp',
33 'ir_constant_folding.cpp',
34 'ir_constant_propagation.cpp',
35 'ir_constant_variable.cpp',
36 'ir_copy_propagation.cpp',
37 'ir.cpp',
38 'ir_dead_code.cpp',
39 'ir_dead_code_local.cpp',
40 'ir_dead_functions.cpp',
41 'ir_div_to_mul_rcp.cpp',
42 'ir_explog_to_explog2.cpp',
43 'ir_expression_flattening.cpp',
44 'ir_function_can_inline.cpp',
45 'ir_function.cpp',
46 'ir_function_inlining.cpp',
47 'ir_hierarchical_visitor.cpp',
48 'ir_hv_accept.cpp',
49 'ir_if_return.cpp',
50 'ir_if_simplification.cpp',
51 'ir_if_to_cond_assign.cpp',
52 'ir_import_prototypes.cpp',
53 'ir_mat_op_to_vec.cpp',
54 'ir_mod_to_fract.cpp',
55 'ir_noop_swizzle.cpp',
56 'ir_print_visitor.cpp',
57 'ir_reader.cpp',
58 'ir_rvalue_visitor.cpp',
59 'ir_set_program_inouts.cpp',
60 'ir_structure_splitting.cpp',
61 'ir_sub_to_add_neg.cpp',
62 'ir_swizzle_swizzle.cpp',
63 'ir_tree_grafting.cpp',
64 'ir_validate.cpp',
65 'ir_variable.cpp',
66 'ir_variable_refcount.cpp',
67 'ir_vec_index_to_cond_assign.cpp',
68 'ir_vec_index_to_swizzle.cpp',
69 'linker.cpp',
70 'link_functions.cpp',
71 's_expression.cpp',
24] 72]
25 73
26glsl = env.ConvenienceLibrary( 74glsl = env.ConvenienceLibrary(
@@ -30,6 +78,9 @@ glsl = env.ConvenienceLibrary(
30 78
31Export('glsl') 79Export('glsl')
32 80
81# FIXME: We can't build the programs because there's a cyclic dependency between tis directory and src/mesa
82Return()
83
33env = env.Clone() 84env = env.Clone()
34 85
35if env['platform'] == 'windows': 86if env['platform'] == 'windows':
@@ -37,33 +88,16 @@ if env['platform'] == 'windows':
37 'user32', 88 'user32',
38 ]) 89 ])
39 90
40env.Prepend(LIBS = [glsl]) 91env.Prepend(LIBS = [glsl, talloc])
41
42env.Program(
43 target = 'purify',
44 source = ['apps/purify.c'],
45)
46 92
47env.Program( 93env.Program(
48 target = 'tokenise', 94 target = 'glsl2',
49 source = ['apps/tokenise.c'], 95 source = [
96 'main.cpp',
97 ]
50) 98)
51 99
52env.Program( 100env.Program(
53 target = 'version', 101 target = 'glcpp',
54 source = ['apps/version.c'], 102 source = ['glcpp/glcpp.c'],
55) 103)
56
57env.Program(
58 target = 'process',
59 source = ['apps/process.c'],
60)
61
62glsl_compile = env.Program(
63 target = 'compile',
64 source = ['apps/compile.c'],
65)
66
67if env['platform'] == common.default_platform:
68 # Only export the GLSL compiler when building for the host platform
69 Export('glsl_compile')
diff --git a/src/glsl/TODO b/src/glsl/TODO
new file mode 100644
index 00000000000..07ac5f5c6e8
--- /dev/null
+++ b/src/glsl/TODO
@@ -0,0 +1,50 @@
1- Handle constant expressions of (struct == struct)
2
3- Handle constant expressions of (struct != struct)
4
5- Treat built-in functions with constant parameters as constant expressions.
6 - Rewrite all built-in functions return a single expression.
7 - Modify the HIR generator for functions to automatically inline built-in
8 functions durning translation.
9 - Care must be taken to handle both the 1.10 rules and the 1.20+ rules. In
10 1.10, built-in functions cannot be constant expressions.
11
12- Detect code paths in non-void functions that don't reach a return statement
13
14- Handle over-riding built-in functions
15 - Is the overload per-compilation unit or per-linked shader?
16
17- Handle redeclaration of built-in variables
18 - Handle addition of qualifiers such as 'invariant' or 'centroid'.
19 - Handle resizing of arrays.
20 - Other? We'll have to look at the spec.
21
22- Improve handling of constants and their initializers. Constant initializers
23 should never generate any code. This is trival for scalar constants. It is
24 also trivial for arrays, matrices, and vectors that are accessed with
25 constant index values. For others it is more complicated. Perhaps these
26 cases should be silently converted to uniforms?
27
281.30 features:
29
30- Implement AST-to-HIR conversion of bit-shift operators.
31
32- Implement AST-to-HIR conversion of bit-wise {&,|,^,!} operators.
33
34- Implement AST-to-HIR conversion of switch-statements
35 - switch
36 - case
37 - Update break to correcly handle mixed nexting of switch-statements
38 and loops.
39
40- Handle currently unsupported constant expression types
41 - ir_unop_bit_not
42 - ir_binop_mod
43 - ir_binop_lshift
44 - ir_binop_rshift
45 - ir_binop_bit_and
46 - ir_binop_bit_xor
47 - ir_binop_bit_or
48
49- Implement support for 1.30 style shadow compares which only return a float
50 instead of a vec4.
diff --git a/src/glsl/ast.h b/src/glsl/ast.h
new file mode 100644
index 00000000000..44c31b6e627
--- /dev/null
+++ b/src/glsl/ast.h
@@ -0,0 +1,664 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2009 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef AST_H
27#define AST_H
28
29#include "list.h"
30#include "glsl_parser_extras.h"
31
32struct _mesa_glsl_parse_state;
33
34struct YYLTYPE;
35
36class ast_node {
37public:
38 /* Callers of this talloc-based new need not call delete. It's
39 * easier to just talloc_free 'ctx' (or any of its ancestors). */
40 static void* operator new(size_t size, void *ctx)
41 {
42 void *node;
43
44 node = talloc_zero_size(ctx, size);
45 assert(node != NULL);
46
47 return node;
48 }
49
50 /* If the user *does* call delete, that's OK, we will just
51 * talloc_free in that case. */
52 static void operator delete(void *table)
53 {
54 talloc_free(table);
55 }
56
57 virtual void print(void) const;
58 virtual ir_rvalue *hir(exec_list *instructions,
59 struct _mesa_glsl_parse_state *state);
60
61 /**
62 * Retrieve the source location of an AST node
63 *
64 * This function is primarily used to get the source position of an AST node
65 * into a form that can be passed to \c _mesa_glsl_error.
66 *
67 * \sa _mesa_glsl_error, ast_node::set_location
68 */
69 struct YYLTYPE get_location(void) const
70 {
71 struct YYLTYPE locp;
72
73 locp.source = this->location.source;
74 locp.first_line = this->location.line;
75 locp.first_column = this->location.column;
76 locp.last_line = locp.first_line;
77 locp.last_column = locp.first_column;
78
79 return locp;
80 }
81
82 /**
83 * Set the source location of an AST node from a parser location
84 *
85 * \sa ast_node::get_location
86 */
87 void set_location(const struct YYLTYPE &locp)
88 {
89 this->location.source = locp.source;
90 this->location.line = locp.first_line;
91 this->location.column = locp.first_column;
92 }
93
94 struct {
95 unsigned source;
96 unsigned line;
97 unsigned column;
98 } location;
99
100 exec_node link;
101
102protected:
103 ast_node(void);
104};
105
106
107enum ast_operators {
108 ast_assign,
109 ast_plus, /**< Unary + operator. */
110 ast_neg,
111 ast_add,
112 ast_sub,
113 ast_mul,
114 ast_div,
115 ast_mod,
116 ast_lshift,
117 ast_rshift,
118 ast_less,
119 ast_greater,
120 ast_lequal,
121 ast_gequal,
122 ast_equal,
123 ast_nequal,
124 ast_bit_and,
125 ast_bit_xor,
126 ast_bit_or,
127 ast_bit_not,
128 ast_logic_and,
129 ast_logic_xor,
130 ast_logic_or,
131 ast_logic_not,
132
133 ast_mul_assign,
134 ast_div_assign,
135 ast_mod_assign,
136 ast_add_assign,
137 ast_sub_assign,
138 ast_ls_assign,
139 ast_rs_assign,
140 ast_and_assign,
141 ast_xor_assign,
142 ast_or_assign,
143
144 ast_conditional,
145
146 ast_pre_inc,
147 ast_pre_dec,
148 ast_post_inc,
149 ast_post_dec,
150 ast_field_selection,
151 ast_array_index,
152
153 ast_function_call,
154
155 ast_identifier,
156 ast_int_constant,
157 ast_uint_constant,
158 ast_float_constant,
159 ast_bool_constant,
160
161 ast_sequence
162};
163
164class ast_expression : public ast_node {
165public:
166 ast_expression(int oper, ast_expression *,
167 ast_expression *, ast_expression *);
168
169 ast_expression(const char *identifier) :
170 oper(ast_identifier)
171 {
172 subexpressions[0] = NULL;
173 subexpressions[1] = NULL;
174 subexpressions[2] = NULL;
175 primary_expression.identifier = (char *) identifier;
176 }
177
178 static const char *operator_string(enum ast_operators op);
179
180 virtual ir_rvalue *hir(exec_list *instructions,
181 struct _mesa_glsl_parse_state *state);
182
183 virtual void print(void) const;
184
185 enum ast_operators oper;
186
187 ast_expression *subexpressions[3];
188
189 union {
190 char *identifier;
191 int int_constant;
192 float float_constant;
193 unsigned uint_constant;
194 int bool_constant;
195 } primary_expression;
196
197
198 /**
199 * List of expressions for an \c ast_sequence or parameters for an
200 * \c ast_function_call
201 */
202 exec_list expressions;
203};
204
205class ast_expression_bin : public ast_expression {
206public:
207 ast_expression_bin(int oper, ast_expression *, ast_expression *);
208
209 virtual void print(void) const;
210};
211
212/**
213 * Subclass of expressions for function calls
214 */
215class ast_function_expression : public ast_expression {
216public:
217 ast_function_expression(ast_expression *callee)
218 : ast_expression(ast_function_call, callee,
219 NULL, NULL),
220 cons(false)
221 {
222 /* empty */
223 }
224
225 ast_function_expression(class ast_type_specifier *type)
226 : ast_expression(ast_function_call, (ast_expression *) type,
227 NULL, NULL),
228 cons(true)
229 {
230 /* empty */
231 }
232
233 bool is_constructor() const
234 {
235 return cons;
236 }
237
238 virtual ir_rvalue *hir(exec_list *instructions,
239 struct _mesa_glsl_parse_state *state);
240
241private:
242 /**
243 * Is this function call actually a constructor?
244 */
245 bool cons;
246};
247
248
249/**
250 * Number of possible operators for an ast_expression
251 *
252 * This is done as a define instead of as an additional value in the enum so
253 * that the compiler won't generate spurious messages like "warning:
254 * enumeration value ‘ast_num_operators’ not handled in switch"
255 */
256#define AST_NUM_OPERATORS (ast_sequence + 1)
257
258
259class ast_compound_statement : public ast_node {
260public:
261 ast_compound_statement(int new_scope, ast_node *statements);
262 virtual void print(void) const;
263
264 virtual ir_rvalue *hir(exec_list *instructions,
265 struct _mesa_glsl_parse_state *state);
266
267 int new_scope;
268 exec_list statements;
269};
270
271class ast_declaration : public ast_node {
272public:
273 ast_declaration(char *identifier, int is_array, ast_expression *array_size,
274 ast_expression *initializer);
275 virtual void print(void) const;
276
277 char *identifier;
278
279 int is_array;
280 ast_expression *array_size;
281
282 ast_expression *initializer;
283};
284
285
286enum {
287 ast_precision_high = 0, /**< Default precision. */
288 ast_precision_medium,
289 ast_precision_low
290};
291
292struct ast_type_qualifier {
293 unsigned invariant:1;
294 unsigned constant:1;
295 unsigned attribute:1;
296 unsigned varying:1;
297 unsigned in:1;
298 unsigned out:1;
299 unsigned centroid:1;
300 unsigned uniform:1;
301 unsigned smooth:1;
302 unsigned flat:1;
303 unsigned noperspective:1;
304
305 /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */
306 /*@{*/
307 unsigned origin_upper_left:1;
308 unsigned pixel_center_integer:1;
309 /*@}*/
310};
311
312class ast_struct_specifier : public ast_node {
313public:
314 ast_struct_specifier(char *identifier, ast_node *declarator_list);
315 virtual void print(void) const;
316
317 virtual ir_rvalue *hir(exec_list *instructions,
318 struct _mesa_glsl_parse_state *state);
319
320 char *name;
321 exec_list declarations;
322};
323
324
325enum ast_types {
326 ast_void,
327 ast_float,
328 ast_int,
329 ast_uint,
330 ast_bool,
331 ast_vec2,
332 ast_vec3,
333 ast_vec4,
334 ast_bvec2,
335 ast_bvec3,
336 ast_bvec4,
337 ast_ivec2,
338 ast_ivec3,
339 ast_ivec4,
340 ast_uvec2,
341 ast_uvec3,
342 ast_uvec4,
343 ast_mat2,
344 ast_mat2x3,
345 ast_mat2x4,
346 ast_mat3x2,
347 ast_mat3,
348 ast_mat3x4,
349 ast_mat4x2,
350 ast_mat4x3,
351 ast_mat4,
352 ast_sampler1d,
353 ast_sampler2d,
354 ast_sampler2drect,
355 ast_sampler3d,
356 ast_samplercube,
357 ast_sampler1dshadow,
358 ast_sampler2dshadow,
359 ast_sampler2drectshadow,
360 ast_samplercubeshadow,
361 ast_sampler1darray,
362 ast_sampler2darray,
363 ast_sampler1darrayshadow,
364 ast_sampler2darrayshadow,
365 ast_isampler1d,
366 ast_isampler2d,
367 ast_isampler3d,
368 ast_isamplercube,
369 ast_isampler1darray,
370 ast_isampler2darray,
371 ast_usampler1d,
372 ast_usampler2d,
373 ast_usampler3d,
374 ast_usamplercube,
375 ast_usampler1darray,
376 ast_usampler2darray,
377
378 ast_struct,
379 ast_type_name
380};
381
382
383class ast_type_specifier : public ast_node {
384public:
385 ast_type_specifier(int specifier);
386
387 /** Construct a type specifier from a type name */
388 ast_type_specifier(const char *name)
389 : type_specifier(ast_type_name), type_name(name), structure(NULL),
390 is_array(false), array_size(NULL), precision(ast_precision_high)
391 {
392 /* empty */
393 }
394
395 /** Construct a type specifier from a structure definition */
396 ast_type_specifier(ast_struct_specifier *s)
397 : type_specifier(ast_struct), type_name(s->name), structure(s),
398 is_array(false), array_size(NULL), precision(ast_precision_high)
399 {
400 /* empty */
401 }
402
403 const struct glsl_type *glsl_type(const char **name,
404 struct _mesa_glsl_parse_state *state)
405 const;
406
407 virtual void print(void) const;
408
409 ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
410
411 enum ast_types type_specifier;
412
413 const char *type_name;
414 ast_struct_specifier *structure;
415
416 int is_array;
417 ast_expression *array_size;
418
419 unsigned precision:2;
420};
421
422
423class ast_fully_specified_type : public ast_node {
424public:
425 virtual void print(void) const;
426 bool has_qualifiers() const;
427
428 ast_type_qualifier qualifier;
429 ast_type_specifier *specifier;
430};
431
432
433class ast_declarator_list : public ast_node {
434public:
435 ast_declarator_list(ast_fully_specified_type *);
436 virtual void print(void) const;
437
438 virtual ir_rvalue *hir(exec_list *instructions,
439 struct _mesa_glsl_parse_state *state);
440
441 ast_fully_specified_type *type;
442 exec_list declarations;
443
444 /**
445 * Special flag for vertex shader "invariant" declarations.
446 *
447 * Vertex shaders can contain "invariant" variable redeclarations that do
448 * not include a type. For example, "invariant gl_Position;". This flag
449 * is used to note these cases when no type is specified.
450 */
451 int invariant;
452};
453
454
455class ast_parameter_declarator : public ast_node {
456public:
457 ast_parameter_declarator()
458 {
459 this->identifier = NULL;
460 this->is_array = false;
461 this->array_size = 0;
462 }
463
464 virtual void print(void) const;
465
466 virtual ir_rvalue *hir(exec_list *instructions,
467 struct _mesa_glsl_parse_state *state);
468
469 ast_fully_specified_type *type;
470 char *identifier;
471 int is_array;
472 ast_expression *array_size;
473
474 static void parameters_to_hir(exec_list *ast_parameters,
475 bool formal, exec_list *ir_parameters,
476 struct _mesa_glsl_parse_state *state);
477
478private:
479 /** Is this parameter declaration part of a formal parameter list? */
480 bool formal_parameter;
481
482 /**
483 * Is this parameter 'void' type?
484 *
485 * This field is set by \c ::hir.
486 */
487 bool is_void;
488};
489
490
491class ast_function : public ast_node {
492public:
493 ast_function(void);
494
495 virtual void print(void) const;
496
497 virtual ir_rvalue *hir(exec_list *instructions,
498 struct _mesa_glsl_parse_state *state);
499
500 ast_fully_specified_type *return_type;
501 char *identifier;
502
503 exec_list parameters;
504
505private:
506 /**
507 * Is this prototype part of the function definition?
508 *
509 * Used by ast_function_definition::hir to process the parameters, etc.
510 * of the function.
511 *
512 * \sa ::hir
513 */
514 bool is_definition;
515
516 /**
517 * Function signature corresponding to this function prototype instance
518 *
519 * Used by ast_function_definition::hir to process the parameters, etc.
520 * of the function.
521 *
522 * \sa ::hir
523 */
524 class ir_function_signature *signature;
525
526 friend class ast_function_definition;
527};
528
529
530class ast_declaration_statement : public ast_node {
531public:
532 ast_declaration_statement(void);
533
534 enum {
535 ast_function,
536 ast_declaration,
537 ast_precision
538 } mode;
539
540 union {
541 class ast_function *function;
542 ast_declarator_list *declarator;
543 ast_type_specifier *type;
544 ast_node *node;
545 } declaration;
546};
547
548
549class ast_expression_statement : public ast_node {
550public:
551 ast_expression_statement(ast_expression *);
552 virtual void print(void) const;
553
554 virtual ir_rvalue *hir(exec_list *instructions,
555 struct _mesa_glsl_parse_state *state);
556
557 ast_expression *expression;
558};
559
560
561class ast_case_label : public ast_node {
562public:
563
564 /**
565 * An expression of NULL means 'default'.
566 */
567 ast_expression *expression;
568};
569
570class ast_selection_statement : public ast_node {
571public:
572 ast_selection_statement(ast_expression *condition,
573 ast_node *then_statement,
574 ast_node *else_statement);
575 virtual void print(void) const;
576
577 virtual ir_rvalue *hir(exec_list *instructions,
578 struct _mesa_glsl_parse_state *state);
579
580 ast_expression *condition;
581 ast_node *then_statement;
582 ast_node *else_statement;
583};
584
585
586class ast_switch_statement : public ast_node {
587public:
588 ast_expression *expression;
589 exec_list statements;
590};
591
592class ast_iteration_statement : public ast_node {
593public:
594 ast_iteration_statement(int mode, ast_node *init, ast_node *condition,
595 ast_expression *rest_expression, ast_node *body);
596
597 virtual void print(void) const;
598
599 virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
600
601 enum ast_iteration_modes {
602 ast_for,
603 ast_while,
604 ast_do_while
605 } mode;
606
607
608 ast_node *init_statement;
609 ast_node *condition;
610 ast_expression *rest_expression;
611
612 ast_node *body;
613
614private:
615 /**
616 * Generate IR from the condition of a loop
617 *
618 * This is factored out of ::hir because some loops have the condition
619 * test at the top (for and while), and others have it at the end (do-while).
620 */
621 void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *);
622};
623
624
625class ast_jump_statement : public ast_node {
626public:
627 ast_jump_statement(int mode, ast_expression *return_value);
628 virtual void print(void) const;
629
630 virtual ir_rvalue *hir(exec_list *instructions,
631 struct _mesa_glsl_parse_state *state);
632
633 enum ast_jump_modes {
634 ast_continue,
635 ast_break,
636 ast_return,
637 ast_discard
638 } mode;
639
640 ast_expression *opt_return_value;
641};
642
643
644class ast_function_definition : public ast_node {
645public:
646 virtual void print(void) const;
647
648 virtual ir_rvalue *hir(exec_list *instructions,
649 struct _mesa_glsl_parse_state *state);
650
651 ast_function *prototype;
652 ast_compound_statement *body;
653};
654
655
656extern void
657_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state);
658
659extern ir_rvalue *
660_mesa_ast_field_selection_to_hir(const ast_expression *expr,
661 exec_list *instructions,
662 struct _mesa_glsl_parse_state *state);
663
664#endif /* AST_H */
diff --git a/src/glsl/ast_expr.cpp b/src/glsl/ast_expr.cpp
new file mode 100644
index 00000000000..4e83decb924
--- /dev/null
+++ b/src/glsl/ast_expr.cpp
@@ -0,0 +1,96 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23#include <cstdio>
24#include <cassert>
25#include "ast.h"
26
27const char *
28ast_expression::operator_string(enum ast_operators op)
29{
30 static const char *const operators[] = {
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 assert((unsigned int)op < sizeof(operators) / sizeof(operators[0]));
77
78 return operators[op];
79}
80
81
82ast_expression_bin::ast_expression_bin(int oper, ast_expression *ex0,
83 ast_expression *ex1) :
84 ast_expression(oper, ex0, ex1, NULL)
85{
86 assert((oper >= ast_plus) && (oper <= ast_logic_not));
87}
88
89
90void
91ast_expression_bin::print(void) const
92{
93 subexpressions[0]->print();
94 printf("%s ", operator_string(oper));
95 subexpressions[1]->print();
96}
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
new file mode 100644
index 00000000000..6c36a04889e
--- /dev/null
+++ b/src/glsl/ast_function.cpp
@@ -0,0 +1,1247 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "glsl_symbol_table.h"
25#include "ast.h"
26#include "glsl_types.h"
27#include "ir.h"
28#include "main/macros.h"
29
30static ir_rvalue *
31convert_component(ir_rvalue *src, const glsl_type *desired_type);
32
33static unsigned
34process_parameters(exec_list *instructions, exec_list *actual_parameters,
35 exec_list *parameters,
36 struct _mesa_glsl_parse_state *state)
37{
38 unsigned count = 0;
39
40 foreach_list (n, parameters) {
41 ast_node *const ast = exec_node_data(ast_node, n, link);
42 ir_rvalue *result = ast->hir(instructions, state);
43
44 ir_constant *const constant = result->constant_expression_value();
45 if (constant != NULL)
46 result = constant;
47
48 actual_parameters->push_tail(result);
49 count++;
50 }
51
52 return count;
53}
54
55
56/**
57 * Generate a source prototype for a function signature
58 *
59 * \param return_type Return type of the function. May be \c NULL.
60 * \param name Name of the function.
61 * \param parameters Parameter list for the function. This may be either a
62 * formal or actual parameter list. Only the type is used.
63 *
64 * \return
65 * A talloced string representing the prototype of the function.
66 */
67char *
68prototype_string(const glsl_type *return_type, const char *name,
69 exec_list *parameters)
70{
71 char *str = NULL;
72
73 if (return_type != NULL)
74 str = talloc_asprintf(str, "%s ", return_type->name);
75
76 str = talloc_asprintf_append(str, "%s(", name);
77
78 const char *comma = "";
79 foreach_list(node, parameters) {
80 const ir_instruction *const param = (ir_instruction *) node;
81
82 str = talloc_asprintf_append(str, "%s%s", comma, param->type->name);
83 comma = ", ";
84 }
85
86 str = talloc_strdup_append(str, ")");
87 return str;
88}
89
90
91static ir_rvalue *
92process_call(exec_list *instructions, ir_function *f,
93 YYLTYPE *loc, exec_list *actual_parameters,
94 struct _mesa_glsl_parse_state *state)
95{
96 void *ctx = state;
97
98 ir_function_signature *sig = f->matching_signature(actual_parameters);
99
100 /* The instructions param will be used when the FINISHMEs below are done */
101 (void) instructions;
102
103 if (sig != NULL) {
104 /* Verify that 'out' and 'inout' actual parameters are lvalues. This
105 * isn't done in ir_function::matching_signature because that function
106 * cannot generate the necessary diagnostics.
107 */
108 exec_list_iterator actual_iter = actual_parameters->iterator();
109 exec_list_iterator formal_iter = sig->parameters.iterator();
110
111 while (actual_iter.has_next()) {
112 ir_rvalue *actual = (ir_rvalue *) actual_iter.get();
113 ir_variable *formal = (ir_variable *) formal_iter.get();
114
115 assert(actual != NULL);
116 assert(formal != NULL);
117
118 if ((formal->mode == ir_var_out)
119 || (formal->mode == ir_var_inout)) {
120 if (! actual->is_lvalue()) {
121 /* FINISHME: Log a better diagnostic here. There is no way
122 * FINISHME: to tell the user which parameter is invalid.
123 */
124 _mesa_glsl_error(loc, state, "`%s' parameter is not lvalue",
125 (formal->mode == ir_var_out) ? "out" : "inout");
126 }
127 }
128
129 if (formal->type->is_numeric() || formal->type->is_boolean()) {
130 ir_rvalue *converted = convert_component(actual, formal->type);
131 actual->replace_with(converted);
132 }
133
134 actual_iter.next();
135 formal_iter.next();
136 }
137
138 /* Always insert the call in the instruction stream, and return a deref
139 * of its return val if it returns a value, since we don't know if
140 * the rvalue is going to be assigned to anything or not.
141 */
142 ir_call *call = new(ctx) ir_call(sig, actual_parameters);
143 if (!sig->return_type->is_void()) {
144 ir_variable *var;
145 ir_dereference_variable *deref;
146
147 var = new(ctx) ir_variable(sig->return_type,
148 talloc_asprintf(ctx, "%s_retval",
149 sig->function_name()),
150 ir_var_temporary);
151 instructions->push_tail(var);
152
153 deref = new(ctx) ir_dereference_variable(var);
154 ir_assignment *assign = new(ctx) ir_assignment(deref, call, NULL);
155 instructions->push_tail(assign);
156 if (state->language_version >= 120)
157 var->constant_value = call->constant_expression_value();
158
159 deref = new(ctx) ir_dereference_variable(var);
160 return deref;
161 } else {
162 instructions->push_tail(call);
163 return NULL;
164 }
165 } else {
166 char *str = prototype_string(NULL, f->name, actual_parameters);
167
168 _mesa_glsl_error(loc, state, "no matching function for call to `%s'",
169 str);
170 talloc_free(str);
171
172 const char *prefix = "candidates are: ";
173 foreach_list (node, &f->signatures) {
174 ir_function_signature *sig = (ir_function_signature *) node;
175
176 str = prototype_string(sig->return_type, f->name, &sig->parameters);
177 _mesa_glsl_error(loc, state, "%s%s\n", prefix, str);
178 talloc_free(str);
179
180 prefix = " ";
181 }
182
183 return ir_call::get_error_instruction(ctx);
184 }
185}
186
187
188static ir_rvalue *
189match_function_by_name(exec_list *instructions, const char *name,
190 YYLTYPE *loc, exec_list *actual_parameters,
191 struct _mesa_glsl_parse_state *state)
192{
193 void *ctx = state;
194 ir_function *f = state->symbols->get_function(name);
195
196 if (f == NULL) {
197 _mesa_glsl_error(loc, state, "function `%s' undeclared", name);
198 return ir_call::get_error_instruction(ctx);
199 }
200
201 /* Once we've determined that the function being called might exist, try
202 * to find an overload of the function that matches the parameters.
203 */
204 return process_call(instructions, f, loc, actual_parameters, state);
205}
206
207
208/**
209 * Perform automatic type conversion of constructor parameters
210 *
211 * This implements the rules in the "Conversion and Scalar Constructors"
212 * section (GLSL 1.10 section 5.4.1), not the "Implicit Conversions" rules.
213 */
214static ir_rvalue *
215convert_component(ir_rvalue *src, const glsl_type *desired_type)
216{
217 void *ctx = talloc_parent(src);
218 const unsigned a = desired_type->base_type;
219 const unsigned b = src->type->base_type;
220 ir_expression *result = NULL;
221
222 if (src->type->is_error())
223 return src;
224
225 assert(a <= GLSL_TYPE_BOOL);
226 assert(b <= GLSL_TYPE_BOOL);
227
228 if ((a == b) || (src->type->is_integer() && desired_type->is_integer()))
229 return src;
230
231 switch (a) {
232 case GLSL_TYPE_UINT:
233 case GLSL_TYPE_INT:
234 if (b == GLSL_TYPE_FLOAT)
235 result = new(ctx) ir_expression(ir_unop_f2i, desired_type, src, NULL);
236 else {
237 assert(b == GLSL_TYPE_BOOL);
238 result = new(ctx) ir_expression(ir_unop_b2i, desired_type, src, NULL);
239 }
240 break;
241 case GLSL_TYPE_FLOAT:
242 switch (b) {
243 case GLSL_TYPE_UINT:
244 result = new(ctx) ir_expression(ir_unop_u2f, desired_type, src, NULL);
245 break;
246 case GLSL_TYPE_INT:
247 result = new(ctx) ir_expression(ir_unop_i2f, desired_type, src, NULL);
248 break;
249 case GLSL_TYPE_BOOL:
250 result = new(ctx) ir_expression(ir_unop_b2f, desired_type, src, NULL);
251 break;
252 }
253 break;
254 case GLSL_TYPE_BOOL:
255 switch (b) {
256 case GLSL_TYPE_UINT:
257 case GLSL_TYPE_INT:
258 result = new(ctx) ir_expression(ir_unop_i2b, desired_type, src, NULL);
259 break;
260 case GLSL_TYPE_FLOAT:
261 result = new(ctx) ir_expression(ir_unop_f2b, desired_type, src, NULL);
262 break;
263 }
264 break;
265 }
266
267 assert(result != NULL);
268
269 /* Try constant folding; it may fold in the conversion we just added. */
270 ir_constant *const constant = result->constant_expression_value();
271 return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result;
272}
273
274/**
275 * Dereference a specific component from a scalar, vector, or matrix
276 */
277static ir_rvalue *
278dereference_component(ir_rvalue *src, unsigned component)
279{
280 void *ctx = talloc_parent(src);
281 assert(component < src->type->components());
282
283 /* If the source is a constant, just create a new constant instead of a
284 * dereference of the existing constant.
285 */
286 ir_constant *constant = src->as_constant();
287 if (constant)
288 return new(ctx) ir_constant(constant, component);
289
290 if (src->type->is_scalar()) {
291 return src;
292 } else if (src->type->is_vector()) {
293 return new(ctx) ir_swizzle(src, component, 0, 0, 0, 1);
294 } else {
295 assert(src->type->is_matrix());
296
297 /* Dereference a row of the matrix, then call this function again to get
298 * a specific element from that row.
299 */
300 const int c = component / src->type->column_type()->vector_elements;
301 const int r = component % src->type->column_type()->vector_elements;
302 ir_constant *const col_index = new(ctx) ir_constant(c);
303 ir_dereference *const col = new(ctx) ir_dereference_array(src, col_index);
304
305 col->type = src->type->column_type();
306
307 return dereference_component(col, r);
308 }
309
310 assert(!"Should not get here.");
311 return NULL;
312}
313
314
315static ir_rvalue *
316process_array_constructor(exec_list *instructions,
317 const glsl_type *constructor_type,
318 YYLTYPE *loc, exec_list *parameters,
319 struct _mesa_glsl_parse_state *state)
320{
321 void *ctx = state;
322 /* Array constructors come in two forms: sized and unsized. Sized array
323 * constructors look like 'vec4[2](a, b)', where 'a' and 'b' are vec4
324 * variables. In this case the number of parameters must exactly match the
325 * specified size of the array.
326 *
327 * Unsized array constructors look like 'vec4[](a, b)', where 'a' and 'b'
328 * are vec4 variables. In this case the size of the array being constructed
329 * is determined by the number of parameters.
330 *
331 * From page 52 (page 58 of the PDF) of the GLSL 1.50 spec:
332 *
333 * "There must be exactly the same number of arguments as the size of
334 * the array being constructed. If no size is present in the
335 * constructor, then the array is explicitly sized to the number of
336 * arguments provided. The arguments are assigned in order, starting at
337 * element 0, to the elements of the constructed array. Each argument
338 * must be the same type as the element type of the array, or be a type
339 * that can be converted to the element type of the array according to
340 * Section 4.1.10 "Implicit Conversions.""
341 */
342 exec_list actual_parameters;
343 const unsigned parameter_count =
344 process_parameters(instructions, &actual_parameters, parameters, state);
345
346 if ((parameter_count == 0)
347 || ((constructor_type->length != 0)
348 && (constructor_type->length != parameter_count))) {
349 const unsigned min_param = (constructor_type->length == 0)
350 ? 1 : constructor_type->length;
351
352 _mesa_glsl_error(loc, state, "array constructor must have %s %u "
353 "parameter%s",
354 (constructor_type->length != 0) ? "at least" : "exactly",
355 min_param, (min_param <= 1) ? "" : "s");
356 return ir_call::get_error_instruction(ctx);
357 }
358
359 if (constructor_type->length == 0) {
360 constructor_type =
361 glsl_type::get_array_instance(constructor_type->element_type(),
362 parameter_count);
363 assert(constructor_type != NULL);
364 assert(constructor_type->length == parameter_count);
365 }
366
367 bool all_parameters_are_constant = true;
368
369 /* Type cast each parameter and, if possible, fold constants. */
370 foreach_list_safe(n, &actual_parameters) {
371 ir_rvalue *ir = (ir_rvalue *) n;
372 ir_rvalue *result = ir;
373
374 /* Apply implicit conversions (not the scalar constructor rules!) */
375 if (constructor_type->element_type()->is_float()) {
376 const glsl_type *desired_type =
377 glsl_type::get_instance(GLSL_TYPE_FLOAT,
378 ir->type->vector_elements,
379 ir->type->matrix_columns);
380 result = convert_component(ir, desired_type);
381 }
382
383 if (result->type != constructor_type->element_type()) {
384 _mesa_glsl_error(loc, state, "type error in array constructor: "
385 "expected: %s, found %s",
386 constructor_type->element_type()->name,
387 result->type->name);
388 }
389
390 /* Attempt to convert the parameter to a constant valued expression.
391 * After doing so, track whether or not all the parameters to the
392 * constructor are trivially constant valued expressions.
393 */
394 ir_rvalue *const constant = result->constant_expression_value();
395
396 if (constant != NULL)
397 result = constant;
398 else
399 all_parameters_are_constant = false;
400
401 ir->replace_with(result);
402 }
403
404 if (all_parameters_are_constant)
405 return new(ctx) ir_constant(constructor_type, &actual_parameters);
406
407 ir_variable *var = new(ctx) ir_variable(constructor_type, "array_ctor",
408 ir_var_temporary);
409 instructions->push_tail(var);
410
411 int i = 0;
412 foreach_list(node, &actual_parameters) {
413 ir_rvalue *rhs = (ir_rvalue *) node;
414 ir_rvalue *lhs = new(ctx) ir_dereference_array(var,
415 new(ctx) ir_constant(i));
416
417 ir_instruction *assignment = new(ctx) ir_assignment(lhs, rhs, NULL);
418 instructions->push_tail(assignment);
419
420 i++;
421 }
422
423 return new(ctx) ir_dereference_variable(var);
424}
425
426
427/**
428 * Try to convert a record constructor to a constant expression
429 */
430static ir_constant *
431constant_record_constructor(const glsl_type *constructor_type,
432 YYLTYPE *loc, exec_list *parameters,
433 struct _mesa_glsl_parse_state *state)
434{
435 void *ctx = state;
436 bool all_parameters_are_constant = true;
437
438 exec_node *node = parameters->head;
439 for (unsigned i = 0; i < constructor_type->length; i++) {
440 ir_instruction *ir = (ir_instruction *) node;
441
442 if (node->is_tail_sentinel()) {
443 _mesa_glsl_error(loc, state,
444 "insufficient parameters to constructor for `%s'",
445 constructor_type->name);
446 return NULL;
447 }
448
449 if (ir->type != constructor_type->fields.structure[i].type) {
450 _mesa_glsl_error(loc, state,
451 "parameter type mismatch in constructor for `%s' "
452 " (%s vs %s)",
453 constructor_type->name,
454 ir->type->name,
455 constructor_type->fields.structure[i].type->name);
456 return NULL;
457 }
458
459 if (ir->as_constant() == NULL)
460 all_parameters_are_constant = false;
461
462 node = node->next;
463 }
464
465 if (!all_parameters_are_constant)
466 return NULL;
467
468 return new(ctx) ir_constant(constructor_type, parameters);
469}
470
471
472/**
473 * Generate data for a constant matrix constructor w/a single scalar parameter
474 *
475 * Matrix constructors in GLSL can be passed a single scalar of the
476 * approriate type. In these cases, the resulting matrix is the identity
477 * matrix multipled by the specified scalar. This function generates data for
478 * that matrix.
479 *
480 * \param type Type of the desired matrix.
481 * \param initializer Scalar value used to initialize the matrix diagonal.
482 * \param data Location to store the resulting matrix.
483 */
484void
485generate_constructor_matrix(const glsl_type *type, ir_constant *initializer,
486 ir_constant_data *data)
487{
488 switch (type->base_type) {
489 case GLSL_TYPE_UINT:
490 case GLSL_TYPE_INT:
491 for (unsigned i = 0; i < type->components(); i++)
492 data->u[i] = 0;
493
494 for (unsigned i = 0; i < type->matrix_columns; i++) {
495 /* The array offset of the ith row and column of the matrix.
496 */
497 const unsigned idx = (i * type->vector_elements) + i;
498
499 data->u[idx] = initializer->value.u[0];
500 }
501 break;
502
503 case GLSL_TYPE_FLOAT:
504 for (unsigned i = 0; i < type->components(); i++)
505 data->f[i] = 0;
506
507 for (unsigned i = 0; i < type->matrix_columns; i++) {
508 /* The array offset of the ith row and column of the matrix.
509 */
510 const unsigned idx = (i * type->vector_elements) + i;
511
512 data->f[idx] = initializer->value.f[0];
513 }
514
515 break;
516
517 default:
518 assert(!"Should not get here.");
519 break;
520 }
521}
522
523
524/**
525 * Generate data for a constant vector constructor w/a single scalar parameter
526 *
527 * Vector constructors in GLSL can be passed a single scalar of the
528 * approriate type. In these cases, the resulting vector contains the specified
529 * value in all components. This function generates data for that vector.
530 *
531 * \param type Type of the desired vector.
532 * \param initializer Scalar value used to initialize the vector.
533 * \param data Location to store the resulting vector data.
534 */
535void
536generate_constructor_vector(const glsl_type *type, ir_constant *initializer,
537 ir_constant_data *data)
538{
539 switch (type->base_type) {
540 case GLSL_TYPE_UINT:
541 case GLSL_TYPE_INT:
542 for (unsigned i = 0; i < type->components(); i++)
543 data->u[i] = initializer->value.u[0];
544
545 break;
546
547 case GLSL_TYPE_FLOAT:
548 for (unsigned i = 0; i < type->components(); i++)
549 data->f[i] = initializer->value.f[0];
550
551 break;
552
553 case GLSL_TYPE_BOOL:
554 for (unsigned i = 0; i < type->components(); i++)
555 data->b[i] = initializer->value.b[0];
556
557 break;
558
559 default:
560 assert(!"Should not get here.");
561 break;
562 }
563}
564
565
566/**
567 * Determine if a list consists of a single scalar r-value
568 */
569bool
570single_scalar_parameter(exec_list *parameters)
571{
572 const ir_rvalue *const p = (ir_rvalue *) parameters->head;
573 assert(((ir_rvalue *)p)->as_rvalue() != NULL);
574
575 return (p->type->is_scalar() && p->next->is_tail_sentinel());
576}
577
578
579/**
580 * Generate inline code for a vector constructor
581 *
582 * The generated constructor code will consist of a temporary variable
583 * declaration of the same type as the constructor. A sequence of assignments
584 * from constructor parameters to the temporary will follow.
585 *
586 * \return
587 * An \c ir_dereference_variable of the temprorary generated in the constructor
588 * body.
589 */
590ir_rvalue *
591emit_inline_vector_constructor(const glsl_type *type,
592 exec_list *instructions,
593 exec_list *parameters,
594 void *ctx)
595{
596 assert(!parameters->is_empty());
597
598 ir_variable *var = new(ctx) ir_variable(type, "vec_ctor", ir_var_temporary);
599 instructions->push_tail(var);
600
601 /* There are two kinds of vector constructors.
602 *
603 * - Construct a vector from a single scalar by replicating that scalar to
604 * all components of the vector.
605 *
606 * - Construct a vector from an arbirary combination of vectors and
607 * scalars. The components of the constructor parameters are assigned
608 * to the vector in order until the vector is full.
609 */
610 const unsigned lhs_components = type->components();
611 if (single_scalar_parameter(parameters)) {
612 ir_rvalue *first_param = (ir_rvalue *)parameters->head;
613 ir_rvalue *rhs = new(ctx) ir_swizzle(first_param, 0, 0, 0, 0,
614 lhs_components);
615 ir_dereference_variable *lhs = new(ctx) ir_dereference_variable(var);
616 const unsigned mask = (1U << lhs_components) - 1;
617
618 assert(rhs->type == lhs->type);
619
620 ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL, mask);
621 instructions->push_tail(inst);
622 } else {
623 unsigned base_component = 0;
624 foreach_list(node, parameters) {
625 ir_rvalue *param = (ir_rvalue *) node;
626 unsigned rhs_components = param->type->components();
627
628 /* Do not try to assign more components to the vector than it has!
629 */
630 if ((rhs_components + base_component) > lhs_components) {
631 rhs_components = lhs_components - base_component;
632 }
633
634 /* Generate a swizzle that puts the first element of the source at
635 * the location of the first element of the destination.
636 */
637 unsigned swiz[4] = { 0, 0, 0, 0 };
638 for (unsigned i = 0; i < rhs_components; i++)
639 swiz[i + base_component] = i;
640
641 /* Mask of fields to be written in the assignment.
642 */
643 const unsigned write_mask = ((1U << rhs_components) - 1)
644 << base_component;
645
646 ir_dereference *lhs = new(ctx) ir_dereference_variable(var);
647 ir_rvalue *rhs = new(ctx) ir_swizzle(param, swiz, lhs_components);
648
649 ir_instruction *inst =
650 new(ctx) ir_assignment(lhs, rhs, NULL, write_mask);
651 instructions->push_tail(inst);
652
653 /* Advance the component index by the number of components that were
654 * just assigned.
655 */
656 base_component += rhs_components;
657 }
658 }
659 return new(ctx) ir_dereference_variable(var);
660}
661
662
663/**
664 * Generate assignment of a portion of a vector to a portion of a matrix column
665 *
666 * \param src_base First component of the source to be used in assignment
667 * \param column Column of destination to be assiged
668 * \param row_base First component of the destination column to be assigned
669 * \param count Number of components to be assigned
670 *
671 * \note
672 * \c src_base + \c count must be less than or equal to the number of components
673 * in the source vector.
674 */
675ir_instruction *
676assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base,
677 ir_rvalue *src, unsigned src_base, unsigned count,
678 void *mem_ctx)
679{
680 ir_constant *col_idx = new(mem_ctx) ir_constant(column);
681 ir_dereference *column_ref = new(mem_ctx) ir_dereference_array(var, col_idx);
682
683 assert(column_ref->type->components() >= (row_base + count));
684 assert(src->type->components() >= (src_base + count));
685
686 /* Generate a swizzle that puts the first element of the source at the
687 * location of the first element of the destination.
688 */
689 unsigned swiz[4] = { src_base, src_base, src_base, src_base };
690 for (unsigned i = 0; i < count; i++)
691 swiz[i + row_base] = src_base + i;
692
693 ir_rvalue *const rhs =
694 new(mem_ctx) ir_swizzle(src, swiz, column_ref->type->components());
695
696 /* Mask of fields to be written in the assignment.
697 */
698 const unsigned write_mask = ((1U << count) - 1) << row_base;
699
700 return new(mem_ctx) ir_assignment(column_ref, rhs, NULL, write_mask);
701}
702
703
704/**
705 * Generate inline code for a matrix constructor
706 *
707 * The generated constructor code will consist of a temporary variable
708 * declaration of the same type as the constructor. A sequence of assignments
709 * from constructor parameters to the temporary will follow.
710 *
711 * \return
712 * An \c ir_dereference_variable of the temprorary generated in the constructor
713 * body.
714 */
715ir_rvalue *
716emit_inline_matrix_constructor(const glsl_type *type,
717 exec_list *instructions,
718 exec_list *parameters,
719 void *ctx)
720{
721 assert(!parameters->is_empty());
722
723 ir_variable *var = new(ctx) ir_variable(type, "mat_ctor", ir_var_temporary);
724 instructions->push_tail(var);
725
726 /* There are three kinds of matrix constructors.
727 *
728 * - Construct a matrix from a single scalar by replicating that scalar to
729 * along the diagonal of the matrix and setting all other components to
730 * zero.
731 *
732 * - Construct a matrix from an arbirary combination of vectors and
733 * scalars. The components of the constructor parameters are assigned
734 * to the matrix in colum-major order until the matrix is full.
735 *
736 * - Construct a matrix from a single matrix. The source matrix is copied
737 * to the upper left portion of the constructed matrix, and the remaining
738 * elements take values from the identity matrix.
739 */
740 ir_rvalue *const first_param = (ir_rvalue *) parameters->head;
741 if (single_scalar_parameter(parameters)) {
742 /* Assign the scalar to the X component of a vec4, and fill the remaining
743 * components with zero.
744 */
745 ir_variable *rhs_var =
746 new(ctx) ir_variable(glsl_type::vec4_type, "mat_ctor_vec",
747 ir_var_temporary);
748 instructions->push_tail(rhs_var);
749
750 ir_constant_data zero;
751 zero.f[0] = 0.0;
752 zero.f[1] = 0.0;
753 zero.f[2] = 0.0;
754 zero.f[3] = 0.0;
755
756 ir_instruction *inst =
757 new(ctx) ir_assignment(new(ctx) ir_dereference_variable(rhs_var),
758 new(ctx) ir_constant(rhs_var->type, &zero),
759 NULL);
760 instructions->push_tail(inst);
761
762 ir_dereference *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var);
763
764 inst = new(ctx) ir_assignment(rhs_ref, first_param, NULL, 0x01);
765 instructions->push_tail(inst);
766
767 /* Assign the temporary vector to each column of the destination matrix
768 * with a swizzle that puts the X component on the diagonal of the
769 * matrix. In some cases this may mean that the X component does not
770 * get assigned into the column at all (i.e., when the matrix has more
771 * columns than rows).
772 */
773 static const unsigned rhs_swiz[4][4] = {
774 { 0, 1, 1, 1 },
775 { 1, 0, 1, 1 },
776 { 1, 1, 0, 1 },
777 { 1, 1, 1, 0 }
778 };
779
780 const unsigned cols_to_init = MIN2(type->matrix_columns,
781 type->vector_elements);
782 for (unsigned i = 0; i < cols_to_init; i++) {
783 ir_constant *const col_idx = new(ctx) ir_constant(i);
784 ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx);
785
786 ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var);
787 ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, rhs_swiz[i],
788 type->vector_elements);
789
790 inst = new(ctx) ir_assignment(col_ref, rhs, NULL);
791 instructions->push_tail(inst);
792 }
793
794 for (unsigned i = cols_to_init; i < type->matrix_columns; i++) {
795 ir_constant *const col_idx = new(ctx) ir_constant(i);
796 ir_rvalue *const col_ref = new(ctx) ir_dereference_array(var, col_idx);
797
798 ir_rvalue *const rhs_ref = new(ctx) ir_dereference_variable(rhs_var);
799 ir_rvalue *const rhs = new(ctx) ir_swizzle(rhs_ref, 1, 1, 1, 1,
800 type->vector_elements);
801
802 inst = new(ctx) ir_assignment(col_ref, rhs, NULL);
803 instructions->push_tail(inst);
804 }
805 } else if (first_param->type->is_matrix()) {
806 /* From page 50 (56 of the PDF) of the GLSL 1.50 spec:
807 *
808 * "If a matrix is constructed from a matrix, then each component
809 * (column i, row j) in the result that has a corresponding
810 * component (column i, row j) in the argument will be initialized
811 * from there. All other components will be initialized to the
812 * identity matrix. If a matrix argument is given to a matrix
813 * constructor, it is an error to have any other arguments."
814 */
815 assert(first_param->next->is_tail_sentinel());
816 ir_rvalue *const src_matrix = first_param;
817
818 /* If the source matrix is smaller, pre-initialize the relavent parts of
819 * the destination matrix to the identity matrix.
820 */
821 if ((src_matrix->type->matrix_columns < var->type->matrix_columns)
822 || (src_matrix->type->vector_elements < var->type->vector_elements)) {
823
824 /* If the source matrix has fewer rows, every column of the destination
825 * must be initialized. Otherwise only the columns in the destination
826 * that do not exist in the source must be initialized.
827 */
828 unsigned col =
829 (src_matrix->type->vector_elements < var->type->vector_elements)
830 ? 0 : src_matrix->type->matrix_columns;
831
832 const glsl_type *const col_type = var->type->column_type();
833 for (/* empty */; col < var->type->matrix_columns; col++) {
834 ir_constant_data ident;
835
836 ident.f[0] = 0.0;
837 ident.f[1] = 0.0;
838 ident.f[2] = 0.0;
839 ident.f[3] = 0.0;
840
841 ident.f[col] = 1.0;
842
843 ir_rvalue *const rhs = new(ctx) ir_constant(col_type, &ident);
844
845 ir_rvalue *const lhs =
846 new(ctx) ir_dereference_array(var, new(ctx) ir_constant(col));
847
848 ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL);
849 instructions->push_tail(inst);
850 }
851 }
852
853 /* Assign columns from the source matrix to the destination matrix.
854 *
855 * Since the parameter will be used in the RHS of multiple assignments,
856 * generate a temporary and copy the paramter there.
857 */
858 ir_variable *const rhs_var =
859 new(ctx) ir_variable(first_param->type, "mat_ctor_mat",
860 ir_var_temporary);
861 instructions->push_tail(rhs_var);
862
863 ir_dereference *const rhs_var_ref =
864 new(ctx) ir_dereference_variable(rhs_var);
865 ir_instruction *const inst =
866 new(ctx) ir_assignment(rhs_var_ref, first_param, NULL);
867 instructions->push_tail(inst);
868
869
870 unsigned swiz[4] = { 0, 0, 0, 0 };
871 for (unsigned i = 1; i < src_matrix->type->vector_elements; i++)
872 swiz[i] = i;
873
874 const unsigned last_col = MIN2(src_matrix->type->matrix_columns,
875 var->type->matrix_columns);
876 const unsigned write_mask = (1U << var->type->vector_elements) - 1;
877
878 for (unsigned i = 0; i < last_col; i++) {
879 ir_dereference *const lhs =
880 new(ctx) ir_dereference_array(var, new(ctx) ir_constant(i));
881 ir_rvalue *const rhs_col =
882 new(ctx) ir_dereference_array(rhs_var, new(ctx) ir_constant(i));
883
884 /* If one matrix has columns that are smaller than the columns of the
885 * other matrix, wrap the column access of the larger with a swizzle
886 * so that the LHS and RHS of the assignment have the same size (and
887 * therefore have the same type).
888 *
889 * It would be perfectly valid to unconditionally generate the
890 * swizzles, this this will typically result in a more compact IR tree.
891 */
892 ir_rvalue *rhs;
893 if (lhs->type->vector_elements != rhs_col->type->vector_elements) {
894 rhs = new(ctx) ir_swizzle(rhs_col, swiz,
895 lhs->type->vector_elements);
896 } else {
897 rhs = rhs_col;
898 }
899
900 assert(lhs->type == rhs->type);
901
902 ir_instruction *inst =
903 new(ctx) ir_assignment(lhs, rhs, NULL, write_mask);
904 instructions->push_tail(inst);
905 }
906 } else {
907 const unsigned rows = type->matrix_columns;
908 const unsigned cols = type->vector_elements;
909 unsigned col_idx = 0;
910 unsigned row_idx = 0;
911
912 foreach_list (node, parameters) {
913 ir_rvalue *const rhs = (ir_rvalue *) node;
914 const unsigned components_remaining_this_column = rows - row_idx;
915 unsigned rhs_components = rhs->type->components();
916 unsigned rhs_base = 0;
917
918 /* Since the parameter might be used in the RHS of two assignments,
919 * generate a temporary and copy the paramter there.
920 */
921 ir_variable *rhs_var =
922 new(ctx) ir_variable(rhs->type, "mat_ctor_vec", ir_var_temporary);
923 instructions->push_tail(rhs_var);
924
925 ir_dereference *rhs_var_ref =
926 new(ctx) ir_dereference_variable(rhs_var);
927 ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs, NULL);
928 instructions->push_tail(inst);
929
930 /* Assign the current parameter to as many components of the matrix
931 * as it will fill.
932 *
933 * NOTE: A single vector parameter can span two matrix columns. A
934 * single vec4, for example, can completely fill a mat2.
935 */
936 if (rhs_components >= components_remaining_this_column) {
937 const unsigned count = MIN2(rhs_components,
938 components_remaining_this_column);
939
940 rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var);
941
942 ir_instruction *inst = assign_to_matrix_column(var, col_idx,
943 row_idx,
944 rhs_var_ref, 0,
945 count, ctx);
946 instructions->push_tail(inst);
947
948 rhs_base = count;
949
950 col_idx++;
951 row_idx = 0;
952 }
953
954 /* If there is data left in the parameter and components left to be
955 * set in the destination, emit another assignment. It is possible
956 * that the assignment could be of a vec4 to the last element of the
957 * matrix. In this case col_idx==cols, but there is still data
958 * left in the source parameter. Obviously, don't emit an assignment
959 * to data outside the destination matrix.
960 */
961 if ((col_idx < cols) && (rhs_base < rhs_components)) {
962 const unsigned count = rhs_components - rhs_base;
963
964 rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var);
965
966 ir_instruction *inst = assign_to_matrix_column(var, col_idx,
967 row_idx,
968 rhs_var_ref,
969 rhs_base,
970 count, ctx);
971 instructions->push_tail(inst);
972
973 row_idx += count;
974 }
975 }
976 }
977
978 return new(ctx) ir_dereference_variable(var);
979}
980
981
982ir_rvalue *
983ast_function_expression::hir(exec_list *instructions,
984 struct _mesa_glsl_parse_state *state)
985{
986 void *ctx = state;
987 /* There are three sorts of function calls.
988 *
989 * 1. constructors - The first subexpression is an ast_type_specifier.
990 * 2. methods - Only the .length() method of array types.
991 * 3. functions - Calls to regular old functions.
992 *
993 * Method calls are actually detected when the ast_field_selection
994 * expression is handled.
995 */
996 if (is_constructor()) {
997 const ast_type_specifier *type = (ast_type_specifier *) subexpressions[0];
998 YYLTYPE loc = type->get_location();
999 const char *name;
1000
1001 const glsl_type *const constructor_type = type->glsl_type(& name, state);
1002
1003
1004 /* Constructors for samplers are illegal.
1005 */
1006 if (constructor_type->is_sampler()) {
1007 _mesa_glsl_error(& loc, state, "cannot construct sampler type `%s'",
1008 constructor_type->name);
1009 return ir_call::get_error_instruction(ctx);
1010 }
1011
1012 if (constructor_type->is_array()) {
1013 if (state->language_version <= 110) {
1014 _mesa_glsl_error(& loc, state,
1015 "array constructors forbidden in GLSL 1.10");
1016 return ir_call::get_error_instruction(ctx);
1017 }
1018
1019 return process_array_constructor(instructions, constructor_type,
1020 & loc, &this->expressions, state);
1021 }
1022
1023 /* There are two kinds of constructor call. Constructors for built-in
1024 * language types, such as mat4 and vec2, are free form. The only
1025 * requirement is that the parameters must provide enough values of the
1026 * correct scalar type. Constructors for arrays and structures must
1027 * have the exact number of parameters with matching types in the
1028 * correct order. These constructors follow essentially the same type
1029 * matching rules as functions.
1030 */
1031 if (!constructor_type->is_numeric() && !constructor_type->is_boolean())
1032 return ir_call::get_error_instruction(ctx);
1033
1034 /* Total number of components of the type being constructed. */
1035 const unsigned type_components = constructor_type->components();
1036
1037 /* Number of components from parameters that have actually been
1038 * consumed. This is used to perform several kinds of error checking.
1039 */
1040 unsigned components_used = 0;
1041
1042 unsigned matrix_parameters = 0;
1043 unsigned nonmatrix_parameters = 0;
1044 exec_list actual_parameters;
1045
1046 foreach_list (n, &this->expressions) {
1047 ast_node *ast = exec_node_data(ast_node, n, link);
1048 ir_rvalue *result = ast->hir(instructions, state)->as_rvalue();
1049
1050 /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec:
1051 *
1052 * "It is an error to provide extra arguments beyond this
1053 * last used argument."
1054 */
1055 if (components_used >= type_components) {
1056 _mesa_glsl_error(& loc, state, "too many parameters to `%s' "
1057 "constructor",
1058 constructor_type->name);
1059 return ir_call::get_error_instruction(ctx);
1060 }
1061
1062 if (!result->type->is_numeric() && !result->type->is_boolean()) {
1063 _mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
1064 "non-numeric data type",
1065 constructor_type->name);
1066 return ir_call::get_error_instruction(ctx);
1067 }
1068
1069 /* Count the number of matrix and nonmatrix parameters. This
1070 * is used below to enforce some of the constructor rules.
1071 */
1072 if (result->type->is_matrix())
1073 matrix_parameters++;
1074 else
1075 nonmatrix_parameters++;
1076
1077 actual_parameters.push_tail(result);
1078 components_used += result->type->components();
1079 }
1080
1081 /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec:
1082 *
1083 * "It is an error to construct matrices from other matrices. This
1084 * is reserved for future use."
1085 */
1086 if ((state->language_version <= 110) && (matrix_parameters > 0)
1087 && constructor_type->is_matrix()) {
1088 _mesa_glsl_error(& loc, state, "cannot construct `%s' from a "
1089 "matrix in GLSL 1.10",
1090 constructor_type->name);
1091 return ir_call::get_error_instruction(ctx);
1092 }
1093
1094 /* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec:
1095 *
1096 * "If a matrix argument is given to a matrix constructor, it is
1097 * an error to have any other arguments."
1098 */
1099 if ((matrix_parameters > 0)
1100 && ((matrix_parameters + nonmatrix_parameters) > 1)
1101 && constructor_type->is_matrix()) {
1102 _mesa_glsl_error(& loc, state, "for matrix `%s' constructor, "
1103 "matrix must be only parameter",
1104 constructor_type->name);
1105 return ir_call::get_error_instruction(ctx);
1106 }
1107
1108 /* From page 28 (page 34 of the PDF) of the GLSL 1.10 spec:
1109 *
1110 * "In these cases, there must be enough components provided in the
1111 * arguments to provide an initializer for every component in the
1112 * constructed value."
1113 */
1114 if ((components_used < type_components) && (components_used != 1)) {
1115 _mesa_glsl_error(& loc, state, "too few components to construct "
1116 "`%s'",
1117 constructor_type->name);
1118 return ir_call::get_error_instruction(ctx);
1119 }
1120
1121 /* Later, we cast each parameter to the same base type as the
1122 * constructor. Since there are no non-floating point matrices, we
1123 * need to break them up into a series of column vectors.
1124 */
1125 if (constructor_type->base_type != GLSL_TYPE_FLOAT) {
1126 foreach_list_safe(n, &actual_parameters) {
1127 ir_rvalue *matrix = (ir_rvalue *) n;
1128
1129 if (!matrix->type->is_matrix())
1130 continue;
1131
1132 /* Create a temporary containing the matrix. */
1133 ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp",
1134 ir_var_temporary);
1135 instructions->push_tail(var);
1136 instructions->push_tail(new(ctx) ir_assignment(new(ctx)
1137 ir_dereference_variable(var), matrix, NULL));
1138 var->constant_value = matrix->constant_expression_value();
1139
1140 /* Replace the matrix with dereferences of its columns. */
1141 for (int i = 0; i < matrix->type->matrix_columns; i++) {
1142 matrix->insert_before(new (ctx) ir_dereference_array(var,
1143 new(ctx) ir_constant(i)));
1144 }
1145 matrix->remove();
1146 }
1147 }
1148
1149 bool all_parameters_are_constant = true;
1150
1151 /* Type cast each parameter and, if possible, fold constants.*/
1152 foreach_list_safe(n, &actual_parameters) {
1153 ir_rvalue *ir = (ir_rvalue *) n;
1154
1155 const glsl_type *desired_type =
1156 glsl_type::get_instance(constructor_type->base_type,
1157 ir->type->vector_elements,
1158 ir->type->matrix_columns);
1159 ir_rvalue *result = convert_component(ir, desired_type);
1160
1161 /* Attempt to convert the parameter to a constant valued expression.
1162 * After doing so, track whether or not all the parameters to the
1163 * constructor are trivially constant valued expressions.
1164 */
1165 ir_rvalue *const constant = result->constant_expression_value();
1166
1167 if (constant != NULL)
1168 result = constant;
1169 else
1170 all_parameters_are_constant = false;
1171
1172 if (result != ir) {
1173 ir->replace_with(result);
1174 }
1175 }
1176
1177 /* If all of the parameters are trivially constant, create a
1178 * constant representing the complete collection of parameters.
1179 */
1180 if (all_parameters_are_constant) {
1181 if (components_used >= type_components)
1182 return new(ctx) ir_constant(constructor_type,
1183 & actual_parameters);
1184
1185 /* The above case must handle all scalar constructors.
1186 */
1187 assert(constructor_type->is_vector()
1188 || constructor_type->is_matrix());
1189
1190 /* Constructors with exactly one component are special for
1191 * vectors and matrices. For vectors it causes all elements of
1192 * the vector to be filled with the value. For matrices it
1193 * causes the matrix to be filled with 0 and the diagonal to be
1194 * filled with the value.
1195 */
1196 ir_constant_data data;
1197 ir_constant *const initializer =
1198 (ir_constant *) actual_parameters.head;
1199 if (constructor_type->is_matrix())
1200 generate_constructor_matrix(constructor_type, initializer,
1201 &data);
1202 else
1203 generate_constructor_vector(constructor_type, initializer,
1204 &data);
1205
1206 return new(ctx) ir_constant(constructor_type, &data);
1207 } else if (constructor_type->is_scalar()) {
1208 return dereference_component((ir_rvalue *) actual_parameters.head,
1209 0);
1210 } else if (constructor_type->is_vector()) {
1211 return emit_inline_vector_constructor(constructor_type,
1212 instructions,
1213 &actual_parameters,
1214 ctx);
1215 } else {
1216 assert(constructor_type->is_matrix());
1217 return emit_inline_matrix_constructor(constructor_type,
1218 instructions,
1219 &actual_parameters,
1220 ctx);
1221 }
1222 } else {
1223 const ast_expression *id = subexpressions[0];
1224 YYLTYPE loc = id->get_location();
1225 exec_list actual_parameters;
1226
1227 process_parameters(instructions, &actual_parameters, &this->expressions,
1228 state);
1229
1230 const glsl_type *const type =
1231 state->symbols->get_type(id->primary_expression.identifier);
1232
1233 if ((type != NULL) && type->is_record()) {
1234 ir_constant *constant =
1235 constant_record_constructor(type, &loc, &actual_parameters, state);
1236
1237 if (constant != NULL)
1238 return constant;
1239 }
1240
1241 return match_function_by_name(instructions,
1242 id->primary_expression.identifier, & loc,
1243 &actual_parameters, state);
1244 }
1245
1246 return ir_call::get_error_instruction(ctx);
1247}
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
new file mode 100644
index 00000000000..6e5d01ee265
--- /dev/null
+++ b/src/glsl/ast_to_hir.cpp
@@ -0,0 +1,2607 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ast_to_hir.c
26 * Convert abstract syntax to to high-level intermediate reprensentation (HIR).
27 *
28 * During the conversion to HIR, the majority of the symantic checking is
29 * preformed on the program. This includes:
30 *
31 * * Symbol table management
32 * * Type checking
33 * * Function binding
34 *
35 * The majority of this work could be done during parsing, and the parser could
36 * probably generate HIR directly. However, this results in frequent changes
37 * to the parser code. Since we do not assume that every system this complier
38 * is built on will have Flex and Bison installed, we have to store the code
39 * generated by these tools in our version control system. In other parts of
40 * the system we've seen problems where a parser was changed but the generated
41 * code was not committed, merge conflicts where created because two developers
42 * had slightly different versions of Bison installed, etc.
43 *
44 * I have also noticed that running Bison generated parsers in GDB is very
45 * irritating. When you get a segfault on '$$ = $1->foo', you can't very
46 * well 'print $1' in GDB.
47 *
48 * As a result, my preference is to put as little C code as possible in the
49 * parser (and lexer) sources.
50 */
51
52#include "main/imports.h"
53#include "main/extensions.h"
54#include "glsl_symbol_table.h"
55#include "glsl_parser_extras.h"
56#include "ast.h"
57#include "glsl_types.h"
58#include "ir.h"
59
60void
61_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
62{
63 _mesa_glsl_initialize_variables(instructions, state);
64 _mesa_glsl_initialize_functions(instructions, state);
65
66 state->current_function = NULL;
67
68 foreach_list_typed (ast_node, ast, link, & state->translation_unit)
69 ast->hir(instructions, state);
70}
71
72
73/**
74 * If a conversion is available, convert one operand to a different type
75 *
76 * The \c from \c ir_rvalue is converted "in place".
77 *
78 * \param to Type that the operand it to be converted to
79 * \param from Operand that is being converted
80 * \param state GLSL compiler state
81 *
82 * \return
83 * If a conversion is possible (or unnecessary), \c true is returned.
84 * Otherwise \c false is returned.
85 */
86static bool
87apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
88 struct _mesa_glsl_parse_state *state)
89{
90 void *ctx = state;
91 if (to->base_type == from->type->base_type)
92 return true;
93
94 /* This conversion was added in GLSL 1.20. If the compilation mode is
95 * GLSL 1.10, the conversion is skipped.
96 */
97 if (state->language_version < 120)
98 return false;
99
100 /* From page 27 (page 33 of the PDF) of the GLSL 1.50 spec:
101 *
102 * "There are no implicit array or structure conversions. For
103 * example, an array of int cannot be implicitly converted to an
104 * array of float. There are no implicit conversions between
105 * signed and unsigned integers."
106 */
107 /* FINISHME: The above comment is partially a lie. There is int/uint
108 * FINISHME: conversion for immediate constants.
109 */
110 if (!to->is_float() || !from->type->is_numeric())
111 return false;
112
113 /* Convert to a floating point type with the same number of components
114 * as the original type - i.e. int to float, not int to vec4.
115 */
116 to = glsl_type::get_instance(GLSL_TYPE_FLOAT, from->type->vector_elements,
117 from->type->matrix_columns);
118
119 switch (from->type->base_type) {
120 case GLSL_TYPE_INT:
121 from = new(ctx) ir_expression(ir_unop_i2f, to, from, NULL);
122 break;
123 case GLSL_TYPE_UINT:
124 from = new(ctx) ir_expression(ir_unop_u2f, to, from, NULL);
125 break;
126 case GLSL_TYPE_BOOL:
127 from = new(ctx) ir_expression(ir_unop_b2f, to, from, NULL);
128 break;
129 default:
130 assert(0);
131 }
132
133 return true;
134}
135
136
137static const struct glsl_type *
138arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b,
139 bool multiply,
140 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
141{
142 const glsl_type *type_a = value_a->type;
143 const glsl_type *type_b = value_b->type;
144
145 /* From GLSL 1.50 spec, page 56:
146 *
147 * "The arithmetic binary operators add (+), subtract (-),
148 * multiply (*), and divide (/) operate on integer and
149 * floating-point scalars, vectors, and matrices."
150 */
151 if (!type_a->is_numeric() || !type_b->is_numeric()) {
152 _mesa_glsl_error(loc, state,
153 "Operands to arithmetic operators must be numeric");
154 return glsl_type::error_type;
155 }
156
157
158 /* "If one operand is floating-point based and the other is
159 * not, then the conversions from Section 4.1.10 "Implicit
160 * Conversions" are applied to the non-floating-point-based operand."
161 */
162 if (!apply_implicit_conversion(type_a, value_b, state)
163 && !apply_implicit_conversion(type_b, value_a, state)) {
164 _mesa_glsl_error(loc, state,
165 "Could not implicitly convert operands to "
166 "arithmetic operator");
167 return glsl_type::error_type;
168 }
169 type_a = value_a->type;
170 type_b = value_b->type;
171
172 /* "If the operands are integer types, they must both be signed or
173 * both be unsigned."
174 *
175 * From this rule and the preceeding conversion it can be inferred that
176 * both types must be GLSL_TYPE_FLOAT, or GLSL_TYPE_UINT, or GLSL_TYPE_INT.
177 * The is_numeric check above already filtered out the case where either
178 * type is not one of these, so now the base types need only be tested for
179 * equality.
180 */
181 if (type_a->base_type != type_b->base_type) {
182 _mesa_glsl_error(loc, state,
183 "base type mismatch for arithmetic operator");
184 return glsl_type::error_type;
185 }
186
187 /* "All arithmetic binary operators result in the same fundamental type
188 * (signed integer, unsigned integer, or floating-point) as the
189 * operands they operate on, after operand type conversion. After
190 * conversion, the following cases are valid
191 *
192 * * The two operands are scalars. In this case the operation is
193 * applied, resulting in a scalar."
194 */
195 if (type_a->is_scalar() && type_b->is_scalar())
196 return type_a;
197
198 /* "* One operand is a scalar, and the other is a vector or matrix.
199 * In this case, the scalar operation is applied independently to each
200 * component of the vector or matrix, resulting in the same size
201 * vector or matrix."
202 */
203 if (type_a->is_scalar()) {
204 if (!type_b->is_scalar())
205 return type_b;
206 } else if (type_b->is_scalar()) {
207 return type_a;
208 }
209
210 /* All of the combinations of <scalar, scalar>, <vector, scalar>,
211 * <scalar, vector>, <scalar, matrix>, and <matrix, scalar> have been
212 * handled.
213 */
214 assert(!type_a->is_scalar());
215 assert(!type_b->is_scalar());
216
217 /* "* The two operands are vectors of the same size. In this case, the
218 * operation is done component-wise resulting in the same size
219 * vector."
220 */
221 if (type_a->is_vector() && type_b->is_vector()) {
222 if (type_a == type_b) {
223 return type_a;
224 } else {
225 _mesa_glsl_error(loc, state,
226 "vector size mismatch for arithmetic operator");
227 return glsl_type::error_type;
228 }
229 }
230
231 /* All of the combinations of <scalar, scalar>, <vector, scalar>,
232 * <scalar, vector>, <scalar, matrix>, <matrix, scalar>, and
233 * <vector, vector> have been handled. At least one of the operands must
234 * be matrix. Further, since there are no integer matrix types, the base
235 * type of both operands must be float.
236 */
237 assert(type_a->is_matrix() || type_b->is_matrix());
238 assert(type_a->base_type == GLSL_TYPE_FLOAT);
239 assert(type_b->base_type == GLSL_TYPE_FLOAT);
240
241 /* "* The operator is add (+), subtract (-), or divide (/), and the
242 * operands are matrices with the same number of rows and the same
243 * number of columns. In this case, the operation is done component-
244 * wise resulting in the same size matrix."
245 * * The operator is multiply (*), where both operands are matrices or
246 * one operand is a vector and the other a matrix. A right vector
247 * operand is treated as a column vector and a left vector operand as a
248 * row vector. In all these cases, it is required that the number of
249 * columns of the left operand is equal to the number of rows of the
250 * right operand. Then, the multiply (*) operation does a linear
251 * algebraic multiply, yielding an object that has the same number of
252 * rows as the left operand and the same number of columns as the right
253 * operand. Section 5.10 "Vector and Matrix Operations" explains in
254 * more detail how vectors and matrices are operated on."
255 */
256 if (! multiply) {
257 if (type_a == type_b)
258 return type_a;
259 } else {
260 if (type_a->is_matrix() && type_b->is_matrix()) {
261 /* Matrix multiply. The columns of A must match the rows of B. Given
262 * the other previously tested constraints, this means the vector type
263 * of a row from A must be the same as the vector type of a column from
264 * B.
265 */
266 if (type_a->row_type() == type_b->column_type()) {
267 /* The resulting matrix has the number of columns of matrix B and
268 * the number of rows of matrix A. We get the row count of A by
269 * looking at the size of a vector that makes up a column. The
270 * transpose (size of a row) is done for B.
271 */
272 const glsl_type *const type =
273 glsl_type::get_instance(type_a->base_type,
274 type_a->column_type()->vector_elements,
275 type_b->row_type()->vector_elements);
276 assert(type != glsl_type::error_type);
277
278 return type;
279 }
280 } else if (type_a->is_matrix()) {
281 /* A is a matrix and B is a column vector. Columns of A must match
282 * rows of B. Given the other previously tested constraints, this
283 * means the vector type of a row from A must be the same as the
284 * vector the type of B.
285 */
286 if (type_a->row_type() == type_b) {
287 /* The resulting vector has a number of elements equal to
288 * the number of rows of matrix A. */
289 const glsl_type *const type =
290 glsl_type::get_instance(type_a->base_type,
291 type_a->column_type()->vector_elements,
292 1);
293 assert(type != glsl_type::error_type);
294
295 return type;
296 }
297 } else {
298 assert(type_b->is_matrix());
299
300 /* A is a row vector and B is a matrix. Columns of A must match rows
301 * of B. Given the other previously tested constraints, this means
302 * the type of A must be the same as the vector type of a column from
303 * B.
304 */
305 if (type_a == type_b->column_type()) {
306 /* The resulting vector has a number of elements equal to
307 * the number of columns of matrix B. */
308 const glsl_type *const type =
309 glsl_type::get_instance(type_a->base_type,
310 type_b->row_type()->vector_elements,
311 1);
312 assert(type != glsl_type::error_type);
313
314 return type;
315 }
316 }
317
318 _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication");
319 return glsl_type::error_type;
320 }
321
322
323 /* "All other cases are illegal."
324 */
325 _mesa_glsl_error(loc, state, "type mismatch");
326 return glsl_type::error_type;
327}
328
329
330static const struct glsl_type *
331unary_arithmetic_result_type(const struct glsl_type *type,
332 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
333{
334 /* From GLSL 1.50 spec, page 57:
335 *
336 * "The arithmetic unary operators negate (-), post- and pre-increment
337 * and decrement (-- and ++) operate on integer or floating-point
338 * values (including vectors and matrices). All unary operators work
339 * component-wise on their operands. These result with the same type
340 * they operated on."
341 */
342 if (!type->is_numeric()) {
343 _mesa_glsl_error(loc, state,
344 "Operands to arithmetic operators must be numeric");
345 return glsl_type::error_type;
346 }
347
348 return type;
349}
350
351
352static const struct glsl_type *
353modulus_result_type(const struct glsl_type *type_a,
354 const struct glsl_type *type_b,
355 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
356{
357 /* From GLSL 1.50 spec, page 56:
358 * "The operator modulus (%) operates on signed or unsigned integers or
359 * integer vectors. The operand types must both be signed or both be
360 * unsigned."
361 */
362 if (!type_a->is_integer() || !type_b->is_integer()
363 || (type_a->base_type != type_b->base_type)) {
364 _mesa_glsl_error(loc, state, "type mismatch");
365 return glsl_type::error_type;
366 }
367
368 /* "The operands cannot be vectors of differing size. If one operand is
369 * a scalar and the other vector, then the scalar is applied component-
370 * wise to the vector, resulting in the same type as the vector. If both
371 * are vectors of the same size, the result is computed component-wise."
372 */
373 if (type_a->is_vector()) {
374 if (!type_b->is_vector()
375 || (type_a->vector_elements == type_b->vector_elements))
376 return type_a;
377 } else
378 return type_b;
379
380 /* "The operator modulus (%) is not defined for any other data types
381 * (non-integer types)."
382 */
383 _mesa_glsl_error(loc, state, "type mismatch");
384 return glsl_type::error_type;
385}
386
387
388static const struct glsl_type *
389relational_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b,
390 struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
391{
392 const glsl_type *type_a = value_a->type;
393 const glsl_type *type_b = value_b->type;
394
395 /* From GLSL 1.50 spec, page 56:
396 * "The relational operators greater than (>), less than (<), greater
397 * than or equal (>=), and less than or equal (<=) operate only on
398 * scalar integer and scalar floating-point expressions."
399 */
400 if (!type_a->is_numeric()
401 || !type_b->is_numeric()
402 || !type_a->is_scalar()
403 || !type_b->is_scalar()) {
404 _mesa_glsl_error(loc, state,
405 "Operands to relational operators must be scalar and "
406 "numeric");
407 return glsl_type::error_type;
408 }
409
410 /* "Either the operands' types must match, or the conversions from
411 * Section 4.1.10 "Implicit Conversions" will be applied to the integer
412 * operand, after which the types must match."
413 */
414 if (!apply_implicit_conversion(type_a, value_b, state)
415 && !apply_implicit_conversion(type_b, value_a, state)) {
416 _mesa_glsl_error(loc, state,
417 "Could not implicitly convert operands to "
418 "relational operator");
419 return glsl_type::error_type;
420 }
421 type_a = value_a->type;
422 type_b = value_b->type;
423
424 if (type_a->base_type != type_b->base_type) {
425 _mesa_glsl_error(loc, state, "base type mismatch");
426 return glsl_type::error_type;
427 }
428
429 /* "The result is scalar Boolean."
430 */
431 return glsl_type::bool_type;
432}
433
434
435/**
436 * Validates that a value can be assigned to a location with a specified type
437 *
438 * Validates that \c rhs can be assigned to some location. If the types are
439 * not an exact match but an automatic conversion is possible, \c rhs will be
440 * converted.
441 *
442 * \return
443 * \c NULL if \c rhs cannot be assigned to a location with type \c lhs_type.
444 * Otherwise the actual RHS to be assigned will be returned. This may be
445 * \c rhs, or it may be \c rhs after some type conversion.
446 *
447 * \note
448 * In addition to being used for assignments, this function is used to
449 * type-check return values.
450 */
451ir_rvalue *
452validate_assignment(struct _mesa_glsl_parse_state *state,
453 const glsl_type *lhs_type, ir_rvalue *rhs)
454{
455 const glsl_type *rhs_type = rhs->type;
456
457 /* If there is already some error in the RHS, just return it. Anything
458 * else will lead to an avalanche of error message back to the user.
459 */
460 if (rhs_type->is_error())
461 return rhs;
462
463 /* If the types are identical, the assignment can trivially proceed.
464 */
465 if (rhs_type == lhs_type)
466 return rhs;
467
468 /* If the array element types are the same and the size of the LHS is zero,
469 * the assignment is okay.
470 *
471 * Note: Whole-array assignments are not permitted in GLSL 1.10, but this
472 * is handled by ir_dereference::is_lvalue.
473 */
474 if (lhs_type->is_array() && rhs->type->is_array()
475 && (lhs_type->element_type() == rhs->type->element_type())
476 && (lhs_type->array_size() == 0)) {
477 return rhs;
478 }
479
480 /* Check for implicit conversion in GLSL 1.20 */
481 if (apply_implicit_conversion(lhs_type, rhs, state)) {
482 rhs_type = rhs->type;
483 if (rhs_type == lhs_type)
484 return rhs;
485 }
486
487 return NULL;
488}
489
490ir_rvalue *
491do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
492 ir_rvalue *lhs, ir_rvalue *rhs,
493 YYLTYPE lhs_loc)
494{
495 void *ctx = state;
496 bool error_emitted = (lhs->type->is_error() || rhs->type->is_error());
497
498 if (!error_emitted) {
499 /* FINISHME: This does not handle 'foo.bar.a.b.c[5].d = 5' */
500 if (!lhs->is_lvalue()) {
501 _mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment");
502 error_emitted = true;
503 }
504 }
505
506 ir_rvalue *new_rhs = validate_assignment(state, lhs->type, rhs);
507 if (new_rhs == NULL) {
508 _mesa_glsl_error(& lhs_loc, state, "type mismatch");
509 } else {
510 rhs = new_rhs;
511
512 /* If the LHS array was not declared with a size, it takes it size from
513 * the RHS. If the LHS is an l-value and a whole array, it must be a
514 * dereference of a variable. Any other case would require that the LHS
515 * is either not an l-value or not a whole array.
516 */
517 if (lhs->type->array_size() == 0) {
518 ir_dereference *const d = lhs->as_dereference();
519
520 assert(d != NULL);
521
522 ir_variable *const var = d->variable_referenced();
523
524 assert(var != NULL);
525
526 if (var->max_array_access >= unsigned(rhs->type->array_size())) {
527 /* FINISHME: This should actually log the location of the RHS. */
528 _mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to "
529 "previous access",
530 var->max_array_access);
531 }
532
533 var->type = glsl_type::get_array_instance(lhs->type->element_type(),
534 rhs->type->array_size());
535 d->type = var->type;
536 }
537 }
538
539 /* Most callers of do_assignment (assign, add_assign, pre_inc/dec,
540 * but not post_inc) need the converted assigned value as an rvalue
541 * to handle things like:
542 *
543 * i = j += 1;
544 *
545 * So we always just store the computed value being assigned to a
546 * temporary and return a deref of that temporary. If the rvalue
547 * ends up not being used, the temp will get copy-propagated out.
548 */
549 ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp",
550 ir_var_temporary);
551 ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var);
552 instructions->push_tail(var);
553 instructions->push_tail(new(ctx) ir_assignment(deref_var,
554 rhs,
555 NULL));
556 deref_var = new(ctx) ir_dereference_variable(var);
557
558 if (!error_emitted)
559 instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var, NULL));
560
561 return new(ctx) ir_dereference_variable(var);
562}
563
564static ir_rvalue *
565get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue)
566{
567 void *ctx = talloc_parent(lvalue);
568 ir_variable *var;
569
570 /* FINISHME: Give unique names to the temporaries. */
571 var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp",
572 ir_var_temporary);
573 instructions->push_tail(var);
574 var->mode = ir_var_auto;
575
576 instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var),
577 lvalue, NULL));
578
579 /* Once we've created this temporary, mark it read only so it's no
580 * longer considered an lvalue.
581 */
582 var->read_only = true;
583
584 return new(ctx) ir_dereference_variable(var);
585}
586
587
588ir_rvalue *
589ast_node::hir(exec_list *instructions,
590 struct _mesa_glsl_parse_state *state)
591{
592 (void) instructions;
593 (void) state;
594
595 return NULL;
596}
597
598
599ir_rvalue *
600ast_expression::hir(exec_list *instructions,
601 struct _mesa_glsl_parse_state *state)
602{
603 void *ctx = state;
604 static const int operations[AST_NUM_OPERATORS] = {
605 -1, /* ast_assign doesn't convert to ir_expression. */
606 -1, /* ast_plus doesn't convert to ir_expression. */
607 ir_unop_neg,
608 ir_binop_add,
609 ir_binop_sub,
610 ir_binop_mul,
611 ir_binop_div,
612 ir_binop_mod,
613 ir_binop_lshift,
614 ir_binop_rshift,
615 ir_binop_less,
616 ir_binop_greater,
617 ir_binop_lequal,
618 ir_binop_gequal,
619 ir_binop_equal,
620 ir_binop_nequal,
621 ir_binop_bit_and,
622 ir_binop_bit_xor,
623 ir_binop_bit_or,
624 ir_unop_bit_not,
625 ir_binop_logic_and,
626 ir_binop_logic_xor,
627 ir_binop_logic_or,
628 ir_unop_logic_not,
629
630 /* Note: The following block of expression types actually convert
631 * to multiple IR instructions.
632 */
633 ir_binop_mul, /* ast_mul_assign */
634 ir_binop_div, /* ast_div_assign */
635 ir_binop_mod, /* ast_mod_assign */
636 ir_binop_add, /* ast_add_assign */
637 ir_binop_sub, /* ast_sub_assign */
638 ir_binop_lshift, /* ast_ls_assign */
639 ir_binop_rshift, /* ast_rs_assign */
640 ir_binop_bit_and, /* ast_and_assign */
641 ir_binop_bit_xor, /* ast_xor_assign */
642 ir_binop_bit_or, /* ast_or_assign */
643
644 -1, /* ast_conditional doesn't convert to ir_expression. */
645 ir_binop_add, /* ast_pre_inc. */
646 ir_binop_sub, /* ast_pre_dec. */
647 ir_binop_add, /* ast_post_inc. */
648 ir_binop_sub, /* ast_post_dec. */
649 -1, /* ast_field_selection doesn't conv to ir_expression. */
650 -1, /* ast_array_index doesn't convert to ir_expression. */
651 -1, /* ast_function_call doesn't conv to ir_expression. */
652 -1, /* ast_identifier doesn't convert to ir_expression. */
653 -1, /* ast_int_constant doesn't convert to ir_expression. */
654 -1, /* ast_uint_constant doesn't conv to ir_expression. */
655 -1, /* ast_float_constant doesn't conv to ir_expression. */
656 -1, /* ast_bool_constant doesn't conv to ir_expression. */
657 -1, /* ast_sequence doesn't convert to ir_expression. */
658 };
659 ir_rvalue *result = NULL;
660 ir_rvalue *op[3];
661 const struct glsl_type *type = glsl_type::error_type;
662 bool error_emitted = false;
663 YYLTYPE loc;
664
665 loc = this->get_location();
666
667 switch (this->oper) {
668 case ast_assign: {
669 op[0] = this->subexpressions[0]->hir(instructions, state);
670 op[1] = this->subexpressions[1]->hir(instructions, state);
671
672 result = do_assignment(instructions, state, op[0], op[1],
673 this->subexpressions[0]->get_location());
674 error_emitted = result->type->is_error();
675 type = result->type;
676 break;
677 }
678
679 case ast_plus:
680 op[0] = this->subexpressions[0]->hir(instructions, state);
681
682 type = unary_arithmetic_result_type(op[0]->type, state, & loc);
683
684 error_emitted = type->is_error();
685
686 result = op[0];
687 break;
688
689 case ast_neg:
690 op[0] = this->subexpressions[0]->hir(instructions, state);
691
692 type = unary_arithmetic_result_type(op[0]->type, state, & loc);
693
694 error_emitted = type->is_error();
695
696 result = new(ctx) ir_expression(operations[this->oper], type,
697 op[0], NULL);
698 break;
699
700 case ast_add:
701 case ast_sub:
702 case ast_mul:
703 case ast_div:
704 op[0] = this->subexpressions[0]->hir(instructions, state);
705 op[1] = this->subexpressions[1]->hir(instructions, state);
706
707 type = arithmetic_result_type(op[0], op[1],
708 (this->oper == ast_mul),
709 state, & loc);
710 error_emitted = type->is_error();
711
712 result = new(ctx) ir_expression(operations[this->oper], type,
713 op[0], op[1]);
714 break;
715
716 case ast_mod:
717 op[0] = this->subexpressions[0]->hir(instructions, state);
718 op[1] = this->subexpressions[1]->hir(instructions, state);
719
720 type = modulus_result_type(op[0]->type, op[1]->type, state, & loc);
721
722 assert(operations[this->oper] == ir_binop_mod);
723
724 result = new(ctx) ir_expression(operations[this->oper], type,
725 op[0], op[1]);
726 error_emitted = type->is_error();
727 break;
728
729 case ast_lshift:
730 case ast_rshift:
731 _mesa_glsl_error(& loc, state, "FINISHME: implement bit-shift operators");
732 error_emitted = true;
733 break;
734
735 case ast_less:
736 case ast_greater:
737 case ast_lequal:
738 case ast_gequal:
739 op[0] = this->subexpressions[0]->hir(instructions, state);
740 op[1] = this->subexpressions[1]->hir(instructions, state);
741
742 type = relational_result_type(op[0], op[1], state, & loc);
743
744 /* The relational operators must either generate an error or result
745 * in a scalar boolean. See page 57 of the GLSL 1.50 spec.
746 */
747 assert(type->is_error()
748 || ((type->base_type == GLSL_TYPE_BOOL)
749 && type->is_scalar()));
750
751 result = new(ctx) ir_expression(operations[this->oper], type,
752 op[0], op[1]);
753 error_emitted = type->is_error();
754 break;
755
756 case ast_nequal:
757 case ast_equal:
758 op[0] = this->subexpressions[0]->hir(instructions, state);
759 op[1] = this->subexpressions[1]->hir(instructions, state);
760
761 /* From page 58 (page 64 of the PDF) of the GLSL 1.50 spec:
762 *
763 * "The equality operators equal (==), and not equal (!=)
764 * operate on all types. They result in a scalar Boolean. If
765 * the operand types do not match, then there must be a
766 * conversion from Section 4.1.10 "Implicit Conversions"
767 * applied to one operand that can make them match, in which
768 * case this conversion is done."
769 */
770 if ((!apply_implicit_conversion(op[0]->type, op[1], state)
771 && !apply_implicit_conversion(op[1]->type, op[0], state))
772 || (op[0]->type != op[1]->type)) {
773 _mesa_glsl_error(& loc, state, "operands of `%s' must have the same "
774 "type", (this->oper == ast_equal) ? "==" : "!=");
775 error_emitted = true;
776 } else if ((state->language_version <= 110)
777 && (op[0]->type->is_array() || op[1]->type->is_array())) {
778 _mesa_glsl_error(& loc, state, "array comparisons forbidden in "
779 "GLSL 1.10");
780 error_emitted = true;
781 }
782
783 result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type,
784 op[0], op[1]);
785 type = glsl_type::bool_type;
786
787 assert(result->type == glsl_type::bool_type);
788 break;
789
790 case ast_bit_and:
791 case ast_bit_xor:
792 case ast_bit_or:
793 case ast_bit_not:
794 _mesa_glsl_error(& loc, state, "FINISHME: implement bit-wise operators");
795 error_emitted = true;
796 break;
797
798 case ast_logic_and: {
799 op[0] = this->subexpressions[0]->hir(instructions, state);
800
801 if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) {
802 YYLTYPE loc = this->subexpressions[0]->get_location();
803
804 _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean",
805 operator_string(this->oper));
806 error_emitted = true;
807 }
808
809 ir_constant *op0_const = op[0]->constant_expression_value();
810 if (op0_const) {
811 if (op0_const->value.b[0]) {
812 op[1] = this->subexpressions[1]->hir(instructions, state);
813
814 if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) {
815 YYLTYPE loc = this->subexpressions[1]->get_location();
816
817 _mesa_glsl_error(& loc, state,
818 "RHS of `%s' must be scalar boolean",
819 operator_string(this->oper));
820 error_emitted = true;
821 }
822 result = op[1];
823 } else {
824 result = op0_const;
825 }
826 type = glsl_type::bool_type;
827 } else {
828 ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type,
829 "and_tmp",
830 ir_var_temporary);
831 instructions->push_tail(tmp);
832
833 ir_if *const stmt = new(ctx) ir_if(op[0]);
834 instructions->push_tail(stmt);
835
836 op[1] = this->subexpressions[1]->hir(&stmt->then_instructions, state);
837
838 if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) {
839 YYLTYPE loc = this->subexpressions[1]->get_location();
840
841 _mesa_glsl_error(& loc, state,
842 "RHS of `%s' must be scalar boolean",
843 operator_string(this->oper));
844 error_emitted = true;
845 }
846
847 ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp);
848 ir_assignment *const then_assign =
849 new(ctx) ir_assignment(then_deref, op[1], NULL);
850 stmt->then_instructions.push_tail(then_assign);
851
852 ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp);
853 ir_assignment *const else_assign =
854 new(ctx) ir_assignment(else_deref, new(ctx) ir_constant(false), NULL);
855 stmt->else_instructions.push_tail(else_assign);
856
857 result = new(ctx) ir_dereference_variable(tmp);
858 type = tmp->type;
859 }
860 break;
861 }
862
863 case ast_logic_or: {
864 op[0] = this->subexpressions[0]->hir(instructions, state);
865
866 if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) {
867 YYLTYPE loc = this->subexpressions[0]->get_location();
868
869 _mesa_glsl_error(& loc, state, "LHS of `%s' must be scalar boolean",
870 operator_string(this->oper));
871 error_emitted = true;
872 }
873
874 ir_constant *op0_const = op[0]->constant_expression_value();
875 if (op0_const) {
876 if (op0_const->value.b[0]) {
877 result = op0_const;
878 } else {
879 op[1] = this->subexpressions[1]->hir(instructions, state);
880
881 if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) {
882 YYLTYPE loc = this->subexpressions[1]->get_location();
883
884 _mesa_glsl_error(& loc, state,
885 "RHS of `%s' must be scalar boolean",
886 operator_string(this->oper));
887 error_emitted = true;
888 }
889 result = op[1];
890 }
891 type = glsl_type::bool_type;
892 } else {
893 ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type,
894 "or_tmp",
895 ir_var_temporary);
896 instructions->push_tail(tmp);
897
898 ir_if *const stmt = new(ctx) ir_if(op[0]);
899 instructions->push_tail(stmt);
900
901 op[1] = this->subexpressions[1]->hir(&stmt->else_instructions, state);
902
903 if (!op[1]->type->is_boolean() || !op[1]->type->is_scalar()) {
904 YYLTYPE loc = this->subexpressions[1]->get_location();
905
906 _mesa_glsl_error(& loc, state, "RHS of `%s' must be scalar boolean",
907 operator_string(this->oper));
908 error_emitted = true;
909 }
910
911 ir_dereference *const then_deref = new(ctx) ir_dereference_variable(tmp);
912 ir_assignment *const then_assign =
913 new(ctx) ir_assignment(then_deref, new(ctx) ir_constant(true), NULL);
914 stmt->then_instructions.push_tail(then_assign);
915
916 ir_dereference *const else_deref = new(ctx) ir_dereference_variable(tmp);
917 ir_assignment *const else_assign =
918 new(ctx) ir_assignment(else_deref, op[1], NULL);
919 stmt->else_instructions.push_tail(else_assign);
920
921 result = new(ctx) ir_dereference_variable(tmp);
922 type = tmp->type;
923 }
924 break;
925 }
926
927 case ast_logic_xor:
928 op[0] = this->subexpressions[0]->hir(instructions, state);
929 op[1] = this->subexpressions[1]->hir(instructions, state);
930
931
932 result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type,
933 op[0], op[1]);
934 type = glsl_type::bool_type;
935 break;
936
937 case ast_logic_not:
938 op[0] = this->subexpressions[0]->hir(instructions, state);
939
940 if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) {
941 YYLTYPE loc = this->subexpressions[0]->get_location();
942
943 _mesa_glsl_error(& loc, state,
944 "operand of `!' must be scalar boolean");
945 error_emitted = true;
946 }
947
948 result = new(ctx) ir_expression(operations[this->oper], glsl_type::bool_type,
949 op[0], NULL);
950 type = glsl_type::bool_type;
951 break;
952
953 case ast_mul_assign:
954 case ast_div_assign:
955 case ast_add_assign:
956 case ast_sub_assign: {
957 op[0] = this->subexpressions[0]->hir(instructions, state);
958 op[1] = this->subexpressions[1]->hir(instructions, state);
959
960 type = arithmetic_result_type(op[0], op[1],
961 (this->oper == ast_mul_assign),
962 state, & loc);
963
964 ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type,
965 op[0], op[1]);
966
967 result = do_assignment(instructions, state,
968 op[0]->clone(ctx, NULL), temp_rhs,
969 this->subexpressions[0]->get_location());
970 type = result->type;
971 error_emitted = (op[0]->type->is_error());
972
973 /* GLSL 1.10 does not allow array assignment. However, we don't have to
974 * explicitly test for this because none of the binary expression
975 * operators allow array operands either.
976 */
977
978 break;
979 }
980
981 case ast_mod_assign: {
982 op[0] = this->subexpressions[0]->hir(instructions, state);
983 op[1] = this->subexpressions[1]->hir(instructions, state);
984
985 type = modulus_result_type(op[0]->type, op[1]->type, state, & loc);
986
987 assert(operations[this->oper] == ir_binop_mod);
988
989 ir_rvalue *temp_rhs;
990 temp_rhs = new(ctx) ir_expression(operations[this->oper], type,
991 op[0], op[1]);
992
993 result = do_assignment(instructions, state,
994 op[0]->clone(ctx, NULL), temp_rhs,
995 this->subexpressions[0]->get_location());
996 type = result->type;
997 error_emitted = type->is_error();
998 break;
999 }
1000
1001 case ast_ls_assign:
1002 case ast_rs_assign:
1003 _mesa_glsl_error(& loc, state,
1004 "FINISHME: implement bit-shift assignment operators");
1005 error_emitted = true;
1006 break;
1007
1008 case ast_and_assign:
1009 case ast_xor_assign:
1010 case ast_or_assign:
1011 _mesa_glsl_error(& loc, state,
1012 "FINISHME: implement logic assignment operators");
1013 error_emitted = true;
1014 break;
1015
1016 case ast_conditional: {
1017 op[0] = this->subexpressions[0]->hir(instructions, state);
1018
1019 /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec:
1020 *
1021 * "The ternary selection operator (?:). It operates on three
1022 * expressions (exp1 ? exp2 : exp3). This operator evaluates the
1023 * first expression, which must result in a scalar Boolean."
1024 */
1025 if (!op[0]->type->is_boolean() || !op[0]->type->is_scalar()) {
1026 YYLTYPE loc = this->subexpressions[0]->get_location();
1027
1028 _mesa_glsl_error(& loc, state, "?: condition must be scalar boolean");
1029 error_emitted = true;
1030 }
1031
1032 /* The :? operator is implemented by generating an anonymous temporary
1033 * followed by an if-statement. The last instruction in each branch of
1034 * the if-statement assigns a value to the anonymous temporary. This
1035 * temporary is the r-value of the expression.
1036 */
1037 exec_list then_instructions;
1038 exec_list else_instructions;
1039
1040 op[1] = this->subexpressions[1]->hir(&then_instructions, state);
1041 op[2] = this->subexpressions[2]->hir(&else_instructions, state);
1042
1043 /* From page 59 (page 65 of the PDF) of the GLSL 1.50 spec:
1044 *
1045 * "The second and third expressions can be any type, as
1046 * long their types match, or there is a conversion in
1047 * Section 4.1.10 "Implicit Conversions" that can be applied
1048 * to one of the expressions to make their types match. This
1049 * resulting matching type is the type of the entire
1050 * expression."
1051 */
1052 if ((!apply_implicit_conversion(op[1]->type, op[2], state)
1053 && !apply_implicit_conversion(op[2]->type, op[1], state))
1054 || (op[1]->type != op[2]->type)) {
1055 YYLTYPE loc = this->subexpressions[1]->get_location();
1056
1057 _mesa_glsl_error(& loc, state, "Second and third operands of ?: "
1058 "operator must have matching types.");
1059 error_emitted = true;
1060 type = glsl_type::error_type;
1061 } else {
1062 type = op[1]->type;
1063 }
1064
1065 ir_constant *cond_val = op[0]->constant_expression_value();
1066 ir_constant *then_val = op[1]->constant_expression_value();
1067 ir_constant *else_val = op[2]->constant_expression_value();
1068
1069 if (then_instructions.is_empty()
1070 && else_instructions.is_empty()
1071 && (cond_val != NULL) && (then_val != NULL) && (else_val != NULL)) {
1072 result = (cond_val->value.b[0]) ? then_val : else_val;
1073 } else {
1074 ir_variable *const tmp =
1075 new(ctx) ir_variable(type, "conditional_tmp", ir_var_temporary);
1076 instructions->push_tail(tmp);
1077
1078 ir_if *const stmt = new(ctx) ir_if(op[0]);
1079 instructions->push_tail(stmt);
1080
1081 then_instructions.move_nodes_to(& stmt->then_instructions);
1082 ir_dereference *const then_deref =
1083 new(ctx) ir_dereference_variable(tmp);
1084 ir_assignment *const then_assign =
1085 new(ctx) ir_assignment(then_deref, op[1], NULL);
1086 stmt->then_instructions.push_tail(then_assign);
1087
1088 else_instructions.move_nodes_to(& stmt->else_instructions);
1089 ir_dereference *const else_deref =
1090 new(ctx) ir_dereference_variable(tmp);
1091 ir_assignment *const else_assign =
1092 new(ctx) ir_assignment(else_deref, op[2], NULL);
1093 stmt->else_instructions.push_tail(else_assign);
1094
1095 result = new(ctx) ir_dereference_variable(tmp);
1096 }
1097 break;
1098 }
1099
1100 case ast_pre_inc:
1101 case ast_pre_dec: {
1102 op[0] = this->subexpressions[0]->hir(instructions, state);
1103 if (op[0]->type->base_type == GLSL_TYPE_FLOAT)
1104 op[1] = new(ctx) ir_constant(1.0f);
1105 else
1106 op[1] = new(ctx) ir_constant(1);
1107
1108 type = arithmetic_result_type(op[0], op[1], false, state, & loc);
1109
1110 ir_rvalue *temp_rhs;
1111 temp_rhs = new(ctx) ir_expression(operations[this->oper], type,
1112 op[0], op[1]);
1113
1114 result = do_assignment(instructions, state,
1115 op[0]->clone(ctx, NULL), temp_rhs,
1116 this->subexpressions[0]->get_location());
1117 type = result->type;
1118 error_emitted = op[0]->type->is_error();
1119 break;
1120 }
1121
1122 case ast_post_inc:
1123 case ast_post_dec: {
1124 op[0] = this->subexpressions[0]->hir(instructions, state);
1125 if (op[0]->type->base_type == GLSL_TYPE_FLOAT)
1126 op[1] = new(ctx) ir_constant(1.0f);
1127 else
1128 op[1] = new(ctx) ir_constant(1);
1129
1130 error_emitted = op[0]->type->is_error() || op[1]->type->is_error();
1131
1132 type = arithmetic_result_type(op[0], op[1], false, state, & loc);
1133
1134 ir_rvalue *temp_rhs;
1135 temp_rhs = new(ctx) ir_expression(operations[this->oper], type,
1136 op[0], op[1]);
1137
1138 /* Get a temporary of a copy of the lvalue before it's modified.
1139 * This may get thrown away later.
1140 */
1141 result = get_lvalue_copy(instructions, op[0]->clone(ctx, NULL));
1142
1143 (void)do_assignment(instructions, state,
1144 op[0]->clone(ctx, NULL), temp_rhs,
1145 this->subexpressions[0]->get_location());
1146
1147 type = result->type;
1148 error_emitted = op[0]->type->is_error();
1149 break;
1150 }
1151
1152 case ast_field_selection:
1153 result = _mesa_ast_field_selection_to_hir(this, instructions, state);
1154 type = result->type;
1155 break;
1156
1157 case ast_array_index: {
1158 YYLTYPE index_loc = subexpressions[1]->get_location();
1159
1160 op[0] = subexpressions[0]->hir(instructions, state);
1161 op[1] = subexpressions[1]->hir(instructions, state);
1162
1163 error_emitted = op[0]->type->is_error() || op[1]->type->is_error();
1164
1165 ir_rvalue *const array = op[0];
1166
1167 result = new(ctx) ir_dereference_array(op[0], op[1]);
1168
1169 /* Do not use op[0] after this point. Use array.
1170 */
1171 op[0] = NULL;
1172
1173
1174 if (error_emitted)
1175 break;
1176
1177 if (!array->type->is_array()
1178 && !array->type->is_matrix()
1179 && !array->type->is_vector()) {
1180 _mesa_glsl_error(& index_loc, state,
1181 "cannot dereference non-array / non-matrix / "
1182 "non-vector");
1183 error_emitted = true;
1184 }
1185
1186 if (!op[1]->type->is_integer()) {
1187 _mesa_glsl_error(& index_loc, state,
1188 "array index must be integer type");
1189 error_emitted = true;
1190 } else if (!op[1]->type->is_scalar()) {
1191 _mesa_glsl_error(& index_loc, state,
1192 "array index must be scalar");
1193 error_emitted = true;
1194 }
1195
1196 /* If the array index is a constant expression and the array has a
1197 * declared size, ensure that the access is in-bounds. If the array
1198 * index is not a constant expression, ensure that the array has a
1199 * declared size.
1200 */
1201 ir_constant *const const_index = op[1]->constant_expression_value();
1202 if (const_index != NULL) {
1203 const int idx = const_index->value.i[0];
1204 const char *type_name;
1205 unsigned bound = 0;
1206
1207 if (array->type->is_matrix()) {
1208 type_name = "matrix";
1209 } else if (array->type->is_vector()) {
1210 type_name = "vector";
1211 } else {
1212 type_name = "array";
1213 }
1214
1215 /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec:
1216 *
1217 * "It is illegal to declare an array with a size, and then
1218 * later (in the same shader) index the same array with an
1219 * integral constant expression greater than or equal to the
1220 * declared size. It is also illegal to index an array with a
1221 * negative constant expression."
1222 */
1223 if (array->type->is_matrix()) {
1224 if (array->type->row_type()->vector_elements <= idx) {
1225 bound = array->type->row_type()->vector_elements;
1226 }
1227 } else if (array->type->is_vector()) {
1228 if (array->type->vector_elements <= idx) {
1229 bound = array->type->vector_elements;
1230 }
1231 } else {
1232 if ((array->type->array_size() > 0)
1233 && (array->type->array_size() <= idx)) {
1234 bound = array->type->array_size();
1235 }
1236 }
1237
1238 if (bound > 0) {
1239 _mesa_glsl_error(& loc, state, "%s index must be < %u",
1240 type_name, bound);
1241 error_emitted = true;
1242 } else if (idx < 0) {
1243 _mesa_glsl_error(& loc, state, "%s index must be >= 0",
1244 type_name);
1245 error_emitted = true;
1246 }
1247
1248 if (array->type->is_array()) {
1249 /* If the array is a variable dereference, it dereferences the
1250 * whole array, by definition. Use this to get the variable.
1251 *
1252 * FINISHME: Should some methods for getting / setting / testing
1253 * FINISHME: array access limits be added to ir_dereference?
1254 */
1255 ir_variable *const v = array->whole_variable_referenced();
1256 if ((v != NULL) && (unsigned(idx) > v->max_array_access))
1257 v->max_array_access = idx;
1258 }
1259 } else if (array->type->array_size() == 0) {
1260 _mesa_glsl_error(&loc, state, "unsized array index must be constant");
1261 }
1262
1263 if (error_emitted)
1264 result->type = glsl_type::error_type;
1265
1266 type = result->type;
1267 break;
1268 }
1269
1270 case ast_function_call:
1271 /* Should *NEVER* get here. ast_function_call should always be handled
1272 * by ast_function_expression::hir.
1273 */
1274 assert(0);
1275 break;
1276
1277 case ast_identifier: {
1278 /* ast_identifier can appear several places in a full abstract syntax
1279 * tree. This particular use must be at location specified in the grammar
1280 * as 'variable_identifier'.
1281 */
1282 ir_variable *var =
1283 state->symbols->get_variable(this->primary_expression.identifier);
1284
1285 result = new(ctx) ir_dereference_variable(var);
1286
1287 if (var != NULL) {
1288 type = result->type;
1289 } else {
1290 _mesa_glsl_error(& loc, state, "`%s' undeclared",
1291 this->primary_expression.identifier);
1292
1293 error_emitted = true;
1294 }
1295 break;
1296 }
1297
1298 case ast_int_constant:
1299 type = glsl_type::int_type;
1300 result = new(ctx) ir_constant(this->primary_expression.int_constant);
1301 break;
1302
1303 case ast_uint_constant:
1304 type = glsl_type::uint_type;
1305 result = new(ctx) ir_constant(this->primary_expression.uint_constant);
1306 break;
1307
1308 case ast_float_constant:
1309 type = glsl_type::float_type;
1310 result = new(ctx) ir_constant(this->primary_expression.float_constant);
1311 break;
1312
1313 case ast_bool_constant:
1314 type = glsl_type::bool_type;
1315 result = new(ctx) ir_constant(bool(this->primary_expression.bool_constant));
1316 break;
1317
1318 case ast_sequence: {
1319 /* It should not be possible to generate a sequence in the AST without
1320 * any expressions in it.
1321 */
1322 assert(!this->expressions.is_empty());
1323
1324 /* The r-value of a sequence is the last expression in the sequence. If
1325 * the other expressions in the sequence do not have side-effects (and
1326 * therefore add instructions to the instruction list), they get dropped
1327 * on the floor.
1328 */
1329 foreach_list_typed (ast_node, ast, link, &this->expressions)
1330 result = ast->hir(instructions, state);
1331
1332 type = result->type;
1333
1334 /* Any errors should have already been emitted in the loop above.
1335 */
1336 error_emitted = true;
1337 break;
1338 }
1339 }
1340
1341 if (type->is_error() && !error_emitted)
1342 _mesa_glsl_error(& loc, state, "type mismatch");
1343
1344 return result;
1345}
1346
1347
1348ir_rvalue *
1349ast_expression_statement::hir(exec_list *instructions,
1350 struct _mesa_glsl_parse_state *state)
1351{
1352 /* It is possible to have expression statements that don't have an
1353 * expression. This is the solitary semicolon:
1354 *
1355 * for (i = 0; i < 5; i++)
1356 * ;
1357 *
1358 * In this case the expression will be NULL. Test for NULL and don't do
1359 * anything in that case.
1360 */
1361 if (expression != NULL)
1362 expression->hir(instructions, state);
1363
1364 /* Statements do not have r-values.
1365 */
1366 return NULL;
1367}
1368
1369
1370ir_rvalue *
1371ast_compound_statement::hir(exec_list *instructions,
1372 struct _mesa_glsl_parse_state *state)
1373{
1374 if (new_scope)
1375 state->symbols->push_scope();
1376
1377 foreach_list_typed (ast_node, ast, link, &this->statements)
1378 ast->hir(instructions, state);
1379
1380 if (new_scope)
1381 state->symbols->pop_scope();
1382
1383 /* Compound statements do not have r-values.
1384 */
1385 return NULL;
1386}
1387
1388
1389static const glsl_type *
1390process_array_type(const glsl_type *base, ast_node *array_size,
1391 struct _mesa_glsl_parse_state *state)
1392{
1393 unsigned length = 0;
1394
1395 /* FINISHME: Reject delcarations of multidimensional arrays. */
1396
1397 if (array_size != NULL) {
1398 exec_list dummy_instructions;
1399 ir_rvalue *const ir = array_size->hir(& dummy_instructions, state);
1400 YYLTYPE loc = array_size->get_location();
1401
1402 /* FINISHME: Verify that the grammar forbids side-effects in array
1403 * FINISHME: sizes. i.e., 'vec4 [x = 12] data'
1404 */
1405 assert(dummy_instructions.is_empty());
1406
1407 if (ir != NULL) {
1408 if (!ir->type->is_integer()) {
1409 _mesa_glsl_error(& loc, state, "array size must be integer type");
1410 } else if (!ir->type->is_scalar()) {
1411 _mesa_glsl_error(& loc, state, "array size must be scalar type");
1412 } else {
1413 ir_constant *const size = ir->constant_expression_value();
1414
1415 if (size == NULL) {
1416 _mesa_glsl_error(& loc, state, "array size must be a "
1417 "constant valued expression");
1418 } else if (size->value.i[0] <= 0) {
1419 _mesa_glsl_error(& loc, state, "array size must be > 0");
1420 } else {
1421 assert(size->type == ir->type);
1422 length = size->value.u[0];
1423 }
1424 }
1425 }
1426 }
1427
1428 return glsl_type::get_array_instance(base, length);
1429}
1430
1431
1432const glsl_type *
1433ast_type_specifier::glsl_type(const char **name,
1434 struct _mesa_glsl_parse_state *state) const
1435{
1436 const struct glsl_type *type;
1437
1438 if ((this->type_specifier == ast_struct) && (this->type_name == NULL)) {
1439 /* FINISHME: Handle annonymous structures. */
1440 type = NULL;
1441 } else {
1442 type = state->symbols->get_type(this->type_name);
1443 *name = this->type_name;
1444
1445 if (this->is_array) {
1446 type = process_array_type(type, this->array_size, state);
1447 }
1448 }
1449
1450 return type;
1451}
1452
1453
1454static void
1455apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
1456 ir_variable *var,
1457 struct _mesa_glsl_parse_state *state,
1458 YYLTYPE *loc)
1459{
1460 if (qual->invariant)
1461 var->invariant = 1;
1462
1463 /* FINISHME: Mark 'in' variables at global scope as read-only. */
1464 if (qual->constant || qual->attribute || qual->uniform
1465 || (qual->varying && (state->target == fragment_shader)))
1466 var->read_only = 1;
1467
1468 if (qual->centroid)
1469 var->centroid = 1;
1470
1471 if (qual->attribute && state->target != vertex_shader) {
1472 var->type = glsl_type::error_type;
1473 _mesa_glsl_error(loc, state,
1474 "`attribute' variables may not be declared in the "
1475 "%s shader",
1476 _mesa_glsl_shader_target_name(state->target));
1477 }
1478
1479 /* From page 25 (page 31 of the PDF) of the GLSL 1.10 spec:
1480 *
1481 * "The varying qualifier can be used only with the data types
1482 * float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of
1483 * these."
1484 */
1485 if (qual->varying) {
1486 const glsl_type *non_array_type;
1487
1488 if (var->type && var->type->is_array())
1489 non_array_type = var->type->fields.array;
1490 else
1491 non_array_type = var->type;
1492
1493 if (non_array_type && non_array_type->base_type != GLSL_TYPE_FLOAT) {
1494 var->type = glsl_type::error_type;
1495 _mesa_glsl_error(loc, state,
1496 "varying variables must be of base type float");
1497 }
1498 }
1499
1500 /* If there is no qualifier that changes the mode of the variable, leave
1501 * the setting alone.
1502 */
1503 if (qual->in && qual->out)
1504 var->mode = ir_var_inout;
1505 else if (qual->attribute || qual->in
1506 || (qual->varying && (state->target == fragment_shader)))
1507 var->mode = ir_var_in;
1508 else if (qual->out || (qual->varying && (state->target == vertex_shader)))
1509 var->mode = ir_var_out;
1510 else if (qual->uniform)
1511 var->mode = ir_var_uniform;
1512
1513 if (qual->flat)
1514 var->interpolation = ir_var_flat;
1515 else if (qual->noperspective)
1516 var->interpolation = ir_var_noperspective;
1517 else
1518 var->interpolation = ir_var_smooth;
1519
1520 var->pixel_center_integer = qual->pixel_center_integer;
1521 var->origin_upper_left = qual->origin_upper_left;
1522 if ((qual->origin_upper_left || qual->pixel_center_integer)
1523 && (strcmp(var->name, "gl_FragCoord") != 0)) {
1524 const char *const qual_string = (qual->origin_upper_left)
1525 ? "origin_upper_left" : "pixel_center_integer";
1526
1527 _mesa_glsl_error(loc, state,
1528 "layout qualifier `%s' can only be applied to "
1529 "fragment shader input `gl_FragCoord'",
1530 qual_string);
1531 }
1532
1533 if (var->type->is_array() && (state->language_version >= 120)) {
1534 var->array_lvalue = true;
1535 }
1536}
1537
1538
1539ir_rvalue *
1540ast_declarator_list::hir(exec_list *instructions,
1541 struct _mesa_glsl_parse_state *state)
1542{
1543 void *ctx = state;
1544 const struct glsl_type *decl_type;
1545 const char *type_name = NULL;
1546 ir_rvalue *result = NULL;
1547 YYLTYPE loc = this->get_location();
1548
1549 /* From page 46 (page 52 of the PDF) of the GLSL 1.50 spec:
1550 *
1551 * "To ensure that a particular output variable is invariant, it is
1552 * necessary to use the invariant qualifier. It can either be used to
1553 * qualify a previously declared variable as being invariant
1554 *
1555 * invariant gl_Position; // make existing gl_Position be invariant"
1556 *
1557 * In these cases the parser will set the 'invariant' flag in the declarator
1558 * list, and the type will be NULL.
1559 */
1560 if (this->invariant) {
1561 assert(this->type == NULL);
1562
1563 if (state->current_function != NULL) {
1564 _mesa_glsl_error(& loc, state,
1565 "All uses of `invariant' keyword must be at global "
1566 "scope\n");
1567 }
1568
1569 foreach_list_typed (ast_declaration, decl, link, &this->declarations) {
1570 assert(!decl->is_array);
1571 assert(decl->array_size == NULL);
1572 assert(decl->initializer == NULL);
1573
1574 ir_variable *const earlier =
1575 state->symbols->get_variable(decl->identifier);
1576 if (earlier == NULL) {
1577 _mesa_glsl_error(& loc, state,
1578 "Undeclared variable `%s' cannot be marked "
1579 "invariant\n", decl->identifier);
1580 } else if ((state->target == vertex_shader)
1581 && (earlier->mode != ir_var_out)) {
1582 _mesa_glsl_error(& loc, state,
1583 "`%s' cannot be marked invariant, vertex shader "
1584 "outputs only\n", decl->identifier);
1585 } else if ((state->target == fragment_shader)
1586 && (earlier->mode != ir_var_in)) {
1587 _mesa_glsl_error(& loc, state,
1588 "`%s' cannot be marked invariant, fragment shader "
1589 "inputs only\n", decl->identifier);
1590 } else {
1591 earlier->invariant = true;
1592 }
1593 }
1594
1595 /* Invariant redeclarations do not have r-values.
1596 */
1597 return NULL;
1598 }
1599
1600 assert(this->type != NULL);
1601 assert(!this->invariant);
1602
1603 /* The type specifier may contain a structure definition. Process that
1604 * before any of the variable declarations.
1605 */
1606 (void) this->type->specifier->hir(instructions, state);
1607
1608 decl_type = this->type->specifier->glsl_type(& type_name, state);
1609 if (this->declarations.is_empty()) {
1610 /* The only valid case where the declaration list can be empty is when
1611 * the declaration is setting the default precision of a built-in type
1612 * (e.g., 'precision highp vec4;').
1613 */
1614
1615 if (decl_type != NULL) {
1616 } else {
1617 _mesa_glsl_error(& loc, state, "incomplete declaration");
1618 }
1619 }
1620
1621 foreach_list_typed (ast_declaration, decl, link, &this->declarations) {
1622 const struct glsl_type *var_type;
1623 ir_variable *var;
1624
1625 /* FINISHME: Emit a warning if a variable declaration shadows a
1626 * FINISHME: declaration at a higher scope.
1627 */
1628
1629 if ((decl_type == NULL) || decl_type->is_void()) {
1630 if (type_name != NULL) {
1631 _mesa_glsl_error(& loc, state,
1632 "invalid type `%s' in declaration of `%s'",
1633 type_name, decl->identifier);
1634 } else {
1635 _mesa_glsl_error(& loc, state,
1636 "invalid type in declaration of `%s'",
1637 decl->identifier);
1638 }
1639 continue;
1640 }
1641
1642 if (decl->is_array) {
1643 var_type = process_array_type(decl_type, decl->array_size, state);
1644 } else {
1645 var_type = decl_type;
1646 }
1647
1648 var = new(ctx) ir_variable(var_type, decl->identifier, ir_var_auto);
1649
1650 /* From page 22 (page 28 of the PDF) of the GLSL 1.10 specification;
1651 *
1652 * "Global variables can only use the qualifiers const,
1653 * attribute, uni form, or varying. Only one may be
1654 * specified.
1655 *
1656 * Local variables can only use the qualifier const."
1657 *
1658 * This is relaxed in GLSL 1.30.
1659 */
1660 if (state->language_version < 120) {
1661 if (this->type->qualifier.out) {
1662 _mesa_glsl_error(& loc, state,
1663 "`out' qualifier in declaration of `%s' "
1664 "only valid for function parameters in GLSL 1.10.",
1665 decl->identifier);
1666 }
1667 if (this->type->qualifier.in) {
1668 _mesa_glsl_error(& loc, state,
1669 "`in' qualifier in declaration of `%s' "
1670 "only valid for function parameters in GLSL 1.10.",
1671 decl->identifier);
1672 }
1673 /* FINISHME: Test for other invalid qualifiers. */
1674 }
1675
1676 apply_type_qualifier_to_variable(& this->type->qualifier, var, state,
1677 & loc);
1678
1679 if (this->type->qualifier.invariant) {
1680 if ((state->target == vertex_shader) && !(var->mode == ir_var_out ||
1681 var->mode == ir_var_inout)) {
1682 /* FINISHME: Note that this doesn't work for invariant on
1683 * a function signature outval
1684 */
1685 _mesa_glsl_error(& loc, state,
1686 "`%s' cannot be marked invariant, vertex shader "
1687 "outputs only\n", var->name);
1688 } else if ((state->target == fragment_shader) &&
1689 !(var->mode == ir_var_in || var->mode == ir_var_inout)) {
1690 /* FINISHME: Note that this doesn't work for invariant on
1691 * a function signature inval
1692 */
1693 _mesa_glsl_error(& loc, state,
1694 "`%s' cannot be marked invariant, fragment shader "
1695 "inputs only\n", var->name);
1696 }
1697 }
1698
1699 if (state->current_function != NULL) {
1700 const char *mode = NULL;
1701 const char *extra = "";
1702
1703 /* There is no need to check for 'inout' here because the parser will
1704 * only allow that in function parameter lists.
1705 */
1706 if (this->type->qualifier.attribute) {
1707 mode = "attribute";
1708 } else if (this->type->qualifier.uniform) {
1709 mode = "uniform";
1710 } else if (this->type->qualifier.varying) {
1711 mode = "varying";
1712 } else if (this->type->qualifier.in) {
1713 mode = "in";
1714 extra = " or in function parameter list";
1715 } else if (this->type->qualifier.out) {
1716 mode = "out";
1717 extra = " or in function parameter list";
1718 }
1719
1720 if (mode) {
1721 _mesa_glsl_error(& loc, state,
1722 "%s variable `%s' must be declared at "
1723 "global scope%s",
1724 mode, var->name, extra);
1725 }
1726 } else if (var->mode == ir_var_in) {
1727 if (state->target == vertex_shader) {
1728 bool error_emitted = false;
1729
1730 /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec:
1731 *
1732 * "Vertex shader inputs can only be float, floating-point
1733 * vectors, matrices, signed and unsigned integers and integer
1734 * vectors. Vertex shader inputs can also form arrays of these
1735 * types, but not structures."
1736 *
1737 * From page 31 (page 27 of the PDF) of the GLSL 1.30 spec:
1738 *
1739 * "Vertex shader inputs can only be float, floating-point
1740 * vectors, matrices, signed and unsigned integers and integer
1741 * vectors. They cannot be arrays or structures."
1742 *
1743 * From page 23 (page 29 of the PDF) of the GLSL 1.20 spec:
1744 *
1745 * "The attribute qualifier can be used only with float,
1746 * floating-point vectors, and matrices. Attribute variables
1747 * cannot be declared as arrays or structures."
1748 */
1749 const glsl_type *check_type = var->type->is_array()
1750 ? var->type->fields.array : var->type;
1751
1752 switch (check_type->base_type) {
1753 case GLSL_TYPE_FLOAT:
1754 break;
1755 case GLSL_TYPE_UINT:
1756 case GLSL_TYPE_INT:
1757 if (state->language_version > 120)
1758 break;
1759 /* FALLTHROUGH */
1760 default:
1761 _mesa_glsl_error(& loc, state,
1762 "vertex shader input / attribute cannot have "
1763 "type %s`%s'",
1764 var->type->is_array() ? "array of " : "",
1765 check_type->name);
1766 error_emitted = true;
1767 }
1768
1769 if (!error_emitted && (state->language_version <= 130)
1770 && var->type->is_array()) {
1771 _mesa_glsl_error(& loc, state,
1772 "vertex shader input / attribute cannot have "
1773 "array type");
1774 error_emitted = true;
1775 }
1776 }
1777 }
1778
1779 /* Process the initializer and add its instructions to a temporary
1780 * list. This list will be added to the instruction stream (below) after
1781 * the declaration is added. This is done because in some cases (such as
1782 * redeclarations) the declaration may not actually be added to the
1783 * instruction stream.
1784 */
1785 exec_list initializer_instructions;
1786 if (decl->initializer != NULL) {
1787 YYLTYPE initializer_loc = decl->initializer->get_location();
1788
1789 /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec:
1790 *
1791 * "All uniform variables are read-only and are initialized either
1792 * directly by an application via API commands, or indirectly by
1793 * OpenGL."
1794 */
1795 if ((state->language_version <= 110)
1796 && (var->mode == ir_var_uniform)) {
1797 _mesa_glsl_error(& initializer_loc, state,
1798 "cannot initialize uniforms in GLSL 1.10");
1799 }
1800
1801 if (var->type->is_sampler()) {
1802 _mesa_glsl_error(& initializer_loc, state,
1803 "cannot initialize samplers");
1804 }
1805
1806 if ((var->mode == ir_var_in) && (state->current_function == NULL)) {
1807 _mesa_glsl_error(& initializer_loc, state,
1808 "cannot initialize %s shader input / %s",
1809 _mesa_glsl_shader_target_name(state->target),
1810 (state->target == vertex_shader)
1811 ? "attribute" : "varying");
1812 }
1813
1814 ir_dereference *const lhs = new(ctx) ir_dereference_variable(var);
1815 ir_rvalue *rhs = decl->initializer->hir(&initializer_instructions,
1816 state);
1817
1818 /* Calculate the constant value if this is a const or uniform
1819 * declaration.
1820 */
1821 if (this->type->qualifier.constant || this->type->qualifier.uniform) {
1822 ir_rvalue *new_rhs = validate_assignment(state, var->type, rhs);
1823 if (new_rhs != NULL) {
1824 rhs = new_rhs;
1825 } else {
1826 _mesa_glsl_error(&initializer_loc, state,
1827 "initializer of type %s cannot be assigned to "
1828 "variable of type %s",
1829 rhs->type->name, var->type->name);
1830 }
1831
1832 ir_constant *constant_value = rhs->constant_expression_value();
1833 if (!constant_value) {
1834 _mesa_glsl_error(& initializer_loc, state,
1835 "initializer of %s variable `%s' must be a "
1836 "constant expression",
1837 (this->type->qualifier.constant)
1838 ? "const" : "uniform",
1839 decl->identifier);
1840 } else {
1841 rhs = constant_value;
1842 var->constant_value = constant_value;
1843 }
1844 }
1845
1846 if (rhs && !rhs->type->is_error()) {
1847 bool temp = var->read_only;
1848 if (this->type->qualifier.constant)
1849 var->read_only = false;
1850
1851 /* Never emit code to initialize a uniform.
1852 */
1853 if (!this->type->qualifier.uniform)
1854 result = do_assignment(&initializer_instructions, state,
1855 lhs, rhs,
1856 this->get_location());
1857 var->read_only = temp;
1858 }
1859 }
1860
1861 /* From page 23 (page 29 of the PDF) of the GLSL 1.10 spec:
1862 *
1863 * "It is an error to write to a const variable outside of
1864 * its declaration, so they must be initialized when
1865 * declared."
1866 */
1867 if (this->type->qualifier.constant && decl->initializer == NULL) {
1868 _mesa_glsl_error(& loc, state,
1869 "const declaration of `%s' must be initialized");
1870 }
1871
1872 /* Attempt to add the variable to the symbol table. If this fails, it
1873 * means the variable has already been declared at this scope. Arrays
1874 * fudge this rule a little bit.
1875 *
1876 * From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,
1877 *
1878 * "It is legal to declare an array without a size and then
1879 * later re-declare the same name as an array of the same
1880 * type and specify a size."
1881 */
1882 if (state->symbols->name_declared_this_scope(decl->identifier)) {
1883 ir_variable *const earlier =
1884 state->symbols->get_variable(decl->identifier);
1885
1886 if ((earlier != NULL)
1887 && (earlier->type->array_size() == 0)
1888 && var->type->is_array()
1889 && (var->type->element_type() == earlier->type->element_type())) {
1890 /* FINISHME: This doesn't match the qualifiers on the two
1891 * FINISHME: declarations. It's not 100% clear whether this is
1892 * FINISHME: required or not.
1893 */
1894
1895 /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
1896 *
1897 * "The size [of gl_TexCoord] can be at most
1898 * gl_MaxTextureCoords."
1899 */
1900 const unsigned size = unsigned(var->type->array_size());
1901 if ((strcmp("gl_TexCoord", var->name) == 0)
1902 && (size > state->Const.MaxTextureCoords)) {
1903 YYLTYPE loc = this->get_location();
1904
1905 _mesa_glsl_error(& loc, state, "`gl_TexCoord' array size cannot "
1906 "be larger than gl_MaxTextureCoords (%u)\n",
1907 state->Const.MaxTextureCoords);
1908 } else if ((size > 0) && (size <= earlier->max_array_access)) {
1909 YYLTYPE loc = this->get_location();
1910
1911 _mesa_glsl_error(& loc, state, "array size must be > %u due to "
1912 "previous access",
1913 earlier->max_array_access);
1914 }
1915
1916 earlier->type = var->type;
1917 delete var;
1918 var = NULL;
1919 } else if (state->extensions->ARB_fragment_coord_conventions &&
1920 (earlier != NULL) &&
1921 (strcmp(var->name, "gl_FragCoord") == 0) &&
1922 earlier->type == var->type &&
1923 earlier->mode == var->mode) {
1924 /* Allow redeclaration of gl_FragCoord for ARB_fcc layout
1925 * qualifiers.
1926 */
1927 earlier->origin_upper_left = var->origin_upper_left;
1928 earlier->pixel_center_integer = var->pixel_center_integer;
1929 } else {
1930 YYLTYPE loc = this->get_location();
1931
1932 _mesa_glsl_error(& loc, state, "`%s' redeclared",
1933 decl->identifier);
1934 }
1935
1936 continue;
1937 }
1938
1939 /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec,
1940 *
1941 * "Identifiers starting with "gl_" are reserved for use by
1942 * OpenGL, and may not be declared in a shader as either a
1943 * variable or a function."
1944 */
1945 if (strncmp(decl->identifier, "gl_", 3) == 0) {
1946 /* FINISHME: This should only trigger if we're not redefining
1947 * FINISHME: a builtin (to add a qualifier, for example).
1948 */
1949 _mesa_glsl_error(& loc, state,
1950 "identifier `%s' uses reserved `gl_' prefix",
1951 decl->identifier);
1952 }
1953
1954 /* Push the variable declaration to the top. It means that all
1955 * the variable declarations will appear in a funny
1956 * last-to-first order, but otherwise we run into trouble if a
1957 * function is prototyped, a global var is decled, then the
1958 * function is defined with usage of the global var. See
1959 * glslparsertest's CorrectModule.frag.
1960 */
1961 instructions->push_head(var);
1962 instructions->append_list(&initializer_instructions);
1963
1964 /* Add the variable to the symbol table after processing the initializer.
1965 * This differs from most C-like languages, but it follows the GLSL
1966 * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50
1967 * spec:
1968 *
1969 * "Within a declaration, the scope of a name starts immediately
1970 * after the initializer if present or immediately after the name
1971 * being declared if not."
1972 */
1973 const bool added_variable =
1974 state->symbols->add_variable(var->name, var);
1975 assert(added_variable);
1976 }
1977
1978
1979 /* Generally, variable declarations do not have r-values. However,
1980 * one is used for the declaration in
1981 *
1982 * while (bool b = some_condition()) {
1983 * ...
1984 * }
1985 *
1986 * so we return the rvalue from the last seen declaration here.
1987 */
1988 return result;
1989}
1990
1991
1992ir_rvalue *
1993ast_parameter_declarator::hir(exec_list *instructions,
1994 struct _mesa_glsl_parse_state *state)
1995{
1996 void *ctx = state;
1997 const struct glsl_type *type;
1998 const char *name = NULL;
1999 YYLTYPE loc = this->get_location();
2000
2001 type = this->type->specifier->glsl_type(& name, state);
2002
2003 if (type == NULL) {
2004 if (name != NULL) {
2005 _mesa_glsl_error(& loc, state,
2006 "invalid type `%s' in declaration of `%s'",
2007 name, this->identifier);
2008 } else {
2009 _mesa_glsl_error(& loc, state,
2010 "invalid type in declaration of `%s'",
2011 this->identifier);
2012 }
2013
2014 type = glsl_type::error_type;
2015 }
2016
2017 /* From page 62 (page 68 of the PDF) of the GLSL 1.50 spec:
2018 *
2019 * "Functions that accept no input arguments need not use void in the
2020 * argument list because prototypes (or definitions) are required and
2021 * therefore there is no ambiguity when an empty argument list "( )" is
2022 * declared. The idiom "(void)" as a parameter list is provided for
2023 * convenience."
2024 *
2025 * Placing this check here prevents a void parameter being set up
2026 * for a function, which avoids tripping up checks for main taking
2027 * parameters and lookups of an unnamed symbol.
2028 */
2029 if (type->is_void()) {
2030 if (this->identifier != NULL)
2031 _mesa_glsl_error(& loc, state,
2032 "named parameter cannot have type `void'");
2033
2034 is_void = true;
2035 return NULL;
2036 }
2037
2038 if (formal_parameter && (this->identifier == NULL)) {
2039 _mesa_glsl_error(& loc, state, "formal parameter lacks a name");
2040 return NULL;
2041 }
2042
2043 is_void = false;
2044 ir_variable *var = new(ctx) ir_variable(type, this->identifier, ir_var_in);
2045
2046 /* FINISHME: Handle array declarations. Note that this requires
2047 * FINISHME: complete handling of constant expressions.
2048 */
2049
2050 /* Apply any specified qualifiers to the parameter declaration. Note that
2051 * for function parameters the default mode is 'in'.
2052 */
2053 apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc);
2054
2055 instructions->push_tail(var);
2056
2057 /* Parameter declarations do not have r-values.
2058 */
2059 return NULL;
2060}
2061
2062
2063void
2064ast_parameter_declarator::parameters_to_hir(exec_list *ast_parameters,
2065 bool formal,
2066 exec_list *ir_parameters,
2067 _mesa_glsl_parse_state *state)
2068{
2069 ast_parameter_declarator *void_param = NULL;
2070 unsigned count = 0;
2071
2072 foreach_list_typed (ast_parameter_declarator, param, link, ast_parameters) {
2073 param->formal_parameter = formal;
2074 param->hir(ir_parameters, state);
2075
2076 if (param->is_void)
2077 void_param = param;
2078
2079 count++;
2080 }
2081
2082 if ((void_param != NULL) && (count > 1)) {
2083 YYLTYPE loc = void_param->get_location();
2084
2085 _mesa_glsl_error(& loc, state,
2086 "`void' parameter must be only parameter");
2087 }
2088}
2089
2090
2091ir_rvalue *
2092ast_function::hir(exec_list *instructions,
2093 struct _mesa_glsl_parse_state *state)
2094{
2095 void *ctx = state;
2096 ir_function *f = NULL;
2097 ir_function_signature *sig = NULL;
2098 exec_list hir_parameters;
2099
2100 const char *const name = identifier;
2101
2102 /* Convert the list of function parameters to HIR now so that they can be
2103 * used below to compare this function's signature with previously seen
2104 * signatures for functions with the same name.
2105 */
2106 ast_parameter_declarator::parameters_to_hir(& this->parameters,
2107 is_definition,
2108 & hir_parameters, state);
2109
2110 const char *return_type_name;
2111 const glsl_type *return_type =
2112 this->return_type->specifier->glsl_type(& return_type_name, state);
2113
2114 assert(return_type != NULL);
2115
2116 /* From page 56 (page 62 of the PDF) of the GLSL 1.30 spec:
2117 * "No qualifier is allowed on the return type of a function."
2118 */
2119 if (this->return_type->has_qualifiers()) {
2120 YYLTYPE loc = this->get_location();
2121 _mesa_glsl_error(& loc, state,
2122 "function `%s' return type has qualifiers", name);
2123 }
2124
2125 /* Verify that this function's signature either doesn't match a previously
2126 * seen signature for a function with the same name, or, if a match is found,
2127 * that the previously seen signature does not have an associated definition.
2128 */
2129 f = state->symbols->get_function(name);
2130 if (f != NULL) {
2131 sig = f->exact_matching_signature(&hir_parameters);
2132 if (sig != NULL) {
2133 const char *badvar = sig->qualifiers_match(&hir_parameters);
2134 if (badvar != NULL) {
2135 YYLTYPE loc = this->get_location();
2136
2137 _mesa_glsl_error(&loc, state, "function `%s' parameter `%s' "
2138 "qualifiers don't match prototype", name, badvar);
2139 }
2140
2141 if (sig->return_type != return_type) {
2142 YYLTYPE loc = this->get_location();
2143
2144 _mesa_glsl_error(&loc, state, "function `%s' return type doesn't "
2145 "match prototype", name);
2146 }
2147
2148 if (is_definition && sig->is_defined) {
2149 YYLTYPE loc = this->get_location();
2150
2151 _mesa_glsl_error(& loc, state, "function `%s' redefined", name);
2152 sig = NULL;
2153 }
2154 }
2155 } else if (state->symbols->name_declared_this_scope(name)) {
2156 /* This function name shadows a non-function use of the same name.
2157 */
2158 YYLTYPE loc = this->get_location();
2159
2160 _mesa_glsl_error(& loc, state, "function name `%s' conflicts with "
2161 "non-function", name);
2162 sig = NULL;
2163 } else {
2164 f = new(ctx) ir_function(name);
2165 state->symbols->add_function(f->name, f);
2166
2167 /* Emit the new function header */
2168 instructions->push_tail(f);
2169 }
2170
2171 /* Verify the return type of main() */
2172 if (strcmp(name, "main") == 0) {
2173 if (! return_type->is_void()) {
2174 YYLTYPE loc = this->get_location();
2175
2176 _mesa_glsl_error(& loc, state, "main() must return void");
2177 }
2178
2179 if (!hir_parameters.is_empty()) {
2180 YYLTYPE loc = this->get_location();
2181
2182 _mesa_glsl_error(& loc, state, "main() must not take any parameters");
2183 }
2184 }
2185
2186 /* Finish storing the information about this new function in its signature.
2187 */
2188 if (sig == NULL) {
2189 sig = new(ctx) ir_function_signature(return_type);
2190 f->add_signature(sig);
2191 }
2192
2193 sig->replace_parameters(&hir_parameters);
2194 signature = sig;
2195
2196 /* Function declarations (prototypes) do not have r-values.
2197 */
2198 return NULL;
2199}
2200
2201
2202ir_rvalue *
2203ast_function_definition::hir(exec_list *instructions,
2204 struct _mesa_glsl_parse_state *state)
2205{
2206 prototype->is_definition = true;
2207 prototype->hir(instructions, state);
2208
2209 ir_function_signature *signature = prototype->signature;
2210
2211 assert(state->current_function == NULL);
2212 state->current_function = signature;
2213 state->found_return = false;
2214
2215 /* Duplicate parameters declared in the prototype as concrete variables.
2216 * Add these to the symbol table.
2217 */
2218 state->symbols->push_scope();
2219 foreach_iter(exec_list_iterator, iter, signature->parameters) {
2220 ir_variable *const var = ((ir_instruction *) iter.get())->as_variable();
2221
2222 assert(var != NULL);
2223
2224 /* The only way a parameter would "exist" is if two parameters have
2225 * the same name.
2226 */
2227 if (state->symbols->name_declared_this_scope(var->name)) {
2228 YYLTYPE loc = this->get_location();
2229
2230 _mesa_glsl_error(& loc, state, "parameter `%s' redeclared", var->name);
2231 } else {
2232 state->symbols->add_variable(var->name, var);
2233 }
2234 }
2235
2236 /* Convert the body of the function to HIR. */
2237 this->body->hir(&signature->body, state);
2238 signature->is_defined = true;
2239
2240 state->symbols->pop_scope();
2241
2242 assert(state->current_function == signature);
2243 state->current_function = NULL;
2244
2245 if (!signature->return_type->is_void() && !state->found_return) {
2246 YYLTYPE loc = this->get_location();
2247 _mesa_glsl_error(& loc, state, "function `%s' has non-void return type "
2248 "%s, but no return statement",
2249 signature->function_name(),
2250 signature->return_type->name);
2251 }
2252
2253 /* Function definitions do not have r-values.
2254 */
2255 return NULL;
2256}
2257
2258
2259ir_rvalue *
2260ast_jump_statement::hir(exec_list *instructions,
2261 struct _mesa_glsl_parse_state *state)
2262{
2263 void *ctx = state;
2264
2265 switch (mode) {
2266 case ast_return: {
2267 ir_return *inst;
2268 assert(state->current_function);
2269
2270 if (opt_return_value) {
2271 if (state->current_function->return_type->base_type ==
2272 GLSL_TYPE_VOID) {
2273 YYLTYPE loc = this->get_location();
2274
2275 _mesa_glsl_error(& loc, state,
2276 "`return` with a value, in function `%s' "
2277 "returning void",
2278 state->current_function->function_name());
2279 }
2280
2281 ir_expression *const ret = (ir_expression *)
2282 opt_return_value->hir(instructions, state);
2283 assert(ret != NULL);
2284
2285 /* Implicit conversions are not allowed for return values. */
2286 if (state->current_function->return_type != ret->type) {
2287 YYLTYPE loc = this->get_location();
2288
2289 _mesa_glsl_error(& loc, state,
2290 "`return' with wrong type %s, in function `%s' "
2291 "returning %s",
2292 ret->type->name,
2293 state->current_function->function_name(),
2294 state->current_function->return_type->name);
2295 }
2296
2297 inst = new(ctx) ir_return(ret);
2298 } else {
2299 if (state->current_function->return_type->base_type !=
2300 GLSL_TYPE_VOID) {
2301 YYLTYPE loc = this->get_location();
2302
2303 _mesa_glsl_error(& loc, state,
2304 "`return' with no value, in function %s returning "
2305 "non-void",
2306 state->current_function->function_name());
2307 }
2308 inst = new(ctx) ir_return;
2309 }
2310
2311 state->found_return = true;
2312 instructions->push_tail(inst);
2313 break;
2314 }
2315
2316 case ast_discard:
2317 if (state->target != fragment_shader) {
2318 YYLTYPE loc = this->get_location();
2319
2320 _mesa_glsl_error(& loc, state,
2321 "`discard' may only appear in a fragment shader");
2322 }
2323 instructions->push_tail(new(ctx) ir_discard);
2324 break;
2325
2326 case ast_break:
2327 case ast_continue:
2328 /* FINISHME: Handle switch-statements. They cannot contain 'continue',
2329 * FINISHME: and they use a different IR instruction for 'break'.
2330 */
2331 /* FINISHME: Correctly handle the nesting. If a switch-statement is
2332 * FINISHME: inside a loop, a 'continue' is valid and will bind to the
2333 * FINISHME: loop.
2334 */
2335 if (state->loop_or_switch_nesting == NULL) {
2336 YYLTYPE loc = this->get_location();
2337
2338 _mesa_glsl_error(& loc, state,
2339 "`%s' may only appear in a loop",
2340 (mode == ast_break) ? "break" : "continue");
2341 } else {
2342 ir_loop *const loop = state->loop_or_switch_nesting->as_loop();
2343
2344 /* Inline the for loop expression again, since we don't know
2345 * where near the end of the loop body the normal copy of it
2346 * is going to be placed.
2347 */
2348 if (mode == ast_continue &&
2349 state->loop_or_switch_nesting_ast->rest_expression) {
2350 state->loop_or_switch_nesting_ast->rest_expression->hir(instructions,
2351 state);
2352 }
2353
2354 if (loop != NULL) {
2355 ir_loop_jump *const jump =
2356 new(ctx) ir_loop_jump((mode == ast_break)
2357 ? ir_loop_jump::jump_break
2358 : ir_loop_jump::jump_continue);
2359 instructions->push_tail(jump);
2360 }
2361 }
2362
2363 break;
2364 }
2365
2366 /* Jump instructions do not have r-values.
2367 */
2368 return NULL;
2369}
2370
2371
2372ir_rvalue *
2373ast_selection_statement::hir(exec_list *instructions,
2374 struct _mesa_glsl_parse_state *state)
2375{
2376 void *ctx = state;
2377
2378 ir_rvalue *const condition = this->condition->hir(instructions, state);
2379
2380 /* From page 66 (page 72 of the PDF) of the GLSL 1.50 spec:
2381 *
2382 * "Any expression whose type evaluates to a Boolean can be used as the
2383 * conditional expression bool-expression. Vector types are not accepted
2384 * as the expression to if."
2385 *
2386 * The checks are separated so that higher quality diagnostics can be
2387 * generated for cases where both rules are violated.
2388 */
2389 if (!condition->type->is_boolean() || !condition->type->is_scalar()) {
2390 YYLTYPE loc = this->condition->get_location();
2391
2392 _mesa_glsl_error(& loc, state, "if-statement condition must be scalar "
2393 "boolean");
2394 }
2395
2396 ir_if *const stmt = new(ctx) ir_if(condition);
2397
2398 if (then_statement != NULL)
2399 then_statement->hir(& stmt->then_instructions, state);
2400
2401 if (else_statement != NULL)
2402 else_statement->hir(& stmt->else_instructions, state);
2403
2404 instructions->push_tail(stmt);
2405
2406 /* if-statements do not have r-values.
2407 */
2408 return NULL;
2409}
2410
2411
2412void
2413ast_iteration_statement::condition_to_hir(ir_loop *stmt,
2414 struct _mesa_glsl_parse_state *state)
2415{
2416 void *ctx = state;
2417
2418 if (condition != NULL) {
2419 ir_rvalue *const cond =
2420 condition->hir(& stmt->body_instructions, state);
2421
2422 if ((cond == NULL)
2423 || !cond->type->is_boolean() || !cond->type->is_scalar()) {
2424 YYLTYPE loc = condition->get_location();
2425
2426 _mesa_glsl_error(& loc, state,
2427 "loop condition must be scalar boolean");
2428 } else {
2429 /* As the first code in the loop body, generate a block that looks
2430 * like 'if (!condition) break;' as the loop termination condition.
2431 */
2432 ir_rvalue *const not_cond =
2433 new(ctx) ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond,
2434 NULL);
2435
2436 ir_if *const if_stmt = new(ctx) ir_if(not_cond);
2437
2438 ir_jump *const break_stmt =
2439 new(ctx) ir_loop_jump(ir_loop_jump::jump_break);
2440
2441 if_stmt->then_instructions.push_tail(break_stmt);
2442 stmt->body_instructions.push_tail(if_stmt);
2443 }
2444 }
2445}
2446
2447
2448ir_rvalue *
2449ast_iteration_statement::hir(exec_list *instructions,
2450 struct _mesa_glsl_parse_state *state)
2451{
2452 void *ctx = state;
2453
2454 /* For-loops and while-loops start a new scope, but do-while loops do not.
2455 */
2456 if (mode != ast_do_while)
2457 state->symbols->push_scope();
2458
2459 if (init_statement != NULL)
2460 init_statement->hir(instructions, state);
2461
2462 ir_loop *const stmt = new(ctx) ir_loop();
2463 instructions->push_tail(stmt);
2464
2465 /* Track the current loop and / or switch-statement nesting.
2466 */
2467 ir_instruction *const nesting = state->loop_or_switch_nesting;
2468 ast_iteration_statement *nesting_ast = state->loop_or_switch_nesting_ast;
2469
2470 state->loop_or_switch_nesting = stmt;
2471 state->loop_or_switch_nesting_ast = this;
2472
2473 if (mode != ast_do_while)
2474 condition_to_hir(stmt, state);
2475
2476 if (body != NULL)
2477 body->hir(& stmt->body_instructions, state);
2478
2479 if (rest_expression != NULL)
2480 rest_expression->hir(& stmt->body_instructions, state);
2481
2482 if (mode == ast_do_while)
2483 condition_to_hir(stmt, state);
2484
2485 if (mode != ast_do_while)
2486 state->symbols->pop_scope();
2487
2488 /* Restore previous nesting before returning.
2489 */
2490 state->loop_or_switch_nesting = nesting;
2491 state->loop_or_switch_nesting_ast = nesting_ast;
2492
2493 /* Loops do not have r-values.
2494 */
2495 return NULL;
2496}
2497
2498
2499ir_rvalue *
2500ast_type_specifier::hir(exec_list *instructions,
2501 struct _mesa_glsl_parse_state *state)
2502{
2503 if (this->structure != NULL)
2504 return this->structure->hir(instructions, state);
2505
2506 return NULL;
2507}
2508
2509
2510ir_rvalue *
2511ast_struct_specifier::hir(exec_list *instructions,
2512 struct _mesa_glsl_parse_state *state)
2513{
2514 unsigned decl_count = 0;
2515
2516 /* Make an initial pass over the list of structure fields to determine how
2517 * many there are. Each element in this list is an ast_declarator_list.
2518 * This means that we actually need to count the number of elements in the
2519 * 'declarations' list in each of the elements.
2520 */
2521 foreach_list_typed (ast_declarator_list, decl_list, link,
2522 &this->declarations) {
2523 foreach_list_const (decl_ptr, & decl_list->declarations) {
2524 decl_count++;
2525 }
2526 }
2527
2528
2529 /* Allocate storage for the structure fields and process the field
2530 * declarations. As the declarations are processed, try to also convert
2531 * the types to HIR. This ensures that structure definitions embedded in
2532 * other structure definitions are processed.
2533 */
2534 glsl_struct_field *const fields = talloc_array(state, glsl_struct_field,
2535 decl_count);
2536
2537 unsigned i = 0;
2538 foreach_list_typed (ast_declarator_list, decl_list, link,
2539 &this->declarations) {
2540 const char *type_name;
2541
2542 decl_list->type->specifier->hir(instructions, state);
2543
2544 const glsl_type *decl_type =
2545 decl_list->type->specifier->glsl_type(& type_name, state);
2546
2547 foreach_list_typed (ast_declaration, decl, link,
2548 &decl_list->declarations) {
2549 const struct glsl_type *const field_type =
2550 (decl->is_array)
2551 ? process_array_type(decl_type, decl->array_size, state)
2552 : decl_type;
2553
2554 fields[i].type = (field_type != NULL)
2555 ? field_type : glsl_type::error_type;
2556 fields[i].name = decl->identifier;
2557 i++;
2558 }
2559 }
2560
2561 assert(i == decl_count);
2562
2563 const char *name;
2564 if (this->name == NULL) {
2565 static unsigned anon_count = 1;
2566 char buf[32];
2567
2568 snprintf(buf, sizeof(buf), "#anon_struct_%04x", anon_count);
2569 anon_count++;
2570
2571 name = strdup(buf);
2572 } else {
2573 name = this->name;
2574 }
2575
2576 const glsl_type *t =
2577 glsl_type::get_record_instance(fields, decl_count, name);
2578
2579 YYLTYPE loc = this->get_location();
2580 if (!state->symbols->add_type(name, t)) {
2581 _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name);
2582 } else {
2583 /* This logic is a bit tricky. It is an error to declare a structure at
2584 * global scope if there is also a function with the same name.
2585 */
2586 if ((state->current_function == NULL)
2587 && (state->symbols->get_function(name) != NULL)) {
2588 _mesa_glsl_error(& loc, state, "name `%s' previously defined", name);
2589 } else {
2590 t->generate_constructor(state->symbols);
2591 }
2592
2593 const glsl_type **s = (const glsl_type **)
2594 realloc(state->user_structures,
2595 sizeof(state->user_structures[0]) *
2596 (state->num_user_structures + 1));
2597 if (s != NULL) {
2598 s[state->num_user_structures] = t;
2599 state->user_structures = s;
2600 state->num_user_structures++;
2601 }
2602 }
2603
2604 /* Structure type definitions do not have r-values.
2605 */
2606 return NULL;
2607}
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
new file mode 100644
index 00000000000..9a957044e7a
--- /dev/null
+++ b/src/glsl/ast_type.cpp
@@ -0,0 +1,122 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <cstdio>
25#include "ast.h"
26extern "C" {
27#include "program/symbol_table.h"
28}
29
30void
31ast_type_specifier::print(void) const
32{
33 if (type_specifier == ast_struct) {
34 structure->print();
35 } else {
36 printf("%s ", type_name);
37 }
38
39 if (is_array) {
40 printf("[ ");
41
42 if (array_size) {
43 array_size->print();
44 }
45
46 printf("] ");
47 }
48}
49
50ast_type_specifier::ast_type_specifier(int specifier)
51 : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL),
52 is_array(false), array_size(NULL), precision(ast_precision_high)
53{
54 static const char *const names[] = {
55 "void",
56 "float",
57 "int",
58 "uint",
59 "bool",
60 "vec2",
61 "vec3",
62 "vec4",
63 "bvec2",
64 "bvec3",
65 "bvec4",
66 "ivec2",
67 "ivec3",
68 "ivec4",
69 "uvec2",
70 "uvec3",
71 "uvec4",
72 "mat2",
73 "mat2x3",
74 "mat2x4",
75 "mat3x2",
76 "mat3",
77 "mat3x4",
78 "mat4x2",
79 "mat4x3",
80 "mat4",
81 "sampler1D",
82 "sampler2D",
83 "sampler2DRect",
84 "sampler3D",
85 "samplerCube",
86 "sampler1DShadow",
87 "sampler2DShadow",
88 "sampler2DRectShadow",
89 "samplerCubeShadow",
90 "sampler1DArray",
91 "sampler2DArray",
92 "sampler1DArrayShadow",
93 "sampler2DArrayShadow",
94 "isampler1D",
95 "isampler2D",
96 "isampler3D",
97 "isamplerCube",
98 "isampler1DArray",
99 "isampler2DArray",
100 "usampler1D",
101 "usampler2D",
102 "usampler3D",
103 "usamplerCube",
104 "usampler1DArray",
105 "usampler2DArray",
106
107 NULL, /* ast_struct */
108 NULL /* ast_type_name */
109 };
110
111 type_name = names[specifier];
112}
113
114bool
115ast_fully_specified_type::has_qualifiers() const
116{
117 return qualifier.invariant || qualifier.constant || qualifier.attribute
118 || qualifier.varying || qualifier.in
119 || qualifier.out || qualifier.centroid
120 || qualifier.uniform || qualifier.smooth
121 || qualifier.flat || qualifier.noperspective;
122}
diff --git a/src/glsl/autogen.sh b/src/glsl/autogen.sh
new file mode 100755
index 00000000000..904cd6746c8
--- /dev/null
+++ b/src/glsl/autogen.sh
@@ -0,0 +1,12 @@
1#! /bin/sh
2
3srcdir=`dirname $0`
4test -z "$srcdir" && srcdir=.
5
6ORIGDIR=`pwd`
7cd $srcdir
8
9autoreconf -v --install || exit 1
10cd $ORIGDIR || exit $?
11
12$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp
new file mode 100644
index 00000000000..652e4f61bb5
--- /dev/null
+++ b/src/glsl/builtin_function.cpp
@@ -0,0 +1,24404 @@
1/* DO NOT MODIFY - automatically generated by generate_builtins.py */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include <stdio.h>
26#include "main/compiler.h"
27#include "glsl_parser_extras.h"
28#include "ir_reader.h"
29#include "program.h"
30#include "ast.h"
31
32extern "C" struct gl_shader *
33_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
34
35gl_shader *
36read_builtins(GLenum target, const char *protos, const char **functions, unsigned count)
37{
38 gl_shader *sh = _mesa_new_shader(NULL, 0, target);
39 struct _mesa_glsl_parse_state *st =
40 new(sh) _mesa_glsl_parse_state(NULL, target, sh);
41
42 st->language_version = 130;
43 st->ARB_texture_rectangle_enable = true;
44 st->EXT_texture_array_enable = true;
45 _mesa_glsl_initialize_types(st);
46
47 sh->ir = new(sh) exec_list;
48 sh->symbols = st->symbols;
49
50 /* Read the IR containing the prototypes */
51 _mesa_glsl_read_ir(st, sh->ir, protos, true);
52
53 /* Read ALL the function bodies, telling the IR reader not to scan for
54 * prototypes (we've already created them). The IR reader will skip any
55 * signature that does not already exist as a prototype.
56 */
57 for (unsigned i = 0; i < count; i++) {
58 _mesa_glsl_read_ir(st, sh->ir, functions[i], false);
59
60 if (st->error) {
61 printf("error reading builtin: %.35s ...\n", functions[i]);
62 talloc_free(sh);
63 return NULL;
64 }
65 }
66
67 reparent_ir(sh->ir, sh);
68 delete st;
69
70 return sh;
71}
72
73static const char *builtin_all =
74 "((function all\n"
75 " (signature bool\n"
76 " (parameters\n"
77 " (declare (in) bvec2 arg0))\n"
78 " ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n"
79 "\n"
80 " (signature bool\n"
81 " (parameters\n"
82 " (declare (in) bvec3 arg0))\n"
83 " ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n"
84 "\n"
85 " (signature bool\n"
86 " (parameters\n"
87 " (declare (in) bvec4 arg0))\n"
88 " ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n"
89 "))\n"
90 ""
91;
92static const char *builtin_textureProj =
93 "((function textureProj\n"
94 " (signature vec4\n"
95 " (parameters\n"
96 " (declare (in) sampler1D sampler)\n"
97 " (declare (in) vec2 P) )\n"
98 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n"
99 "\n"
100 " (signature ivec4\n"
101 " (parameters\n"
102 " (declare (in) isampler1D sampler)\n"
103 " (declare (in) vec2 P) )\n"
104 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n"
105 "\n"
106 " (signature uvec4\n"
107 " (parameters\n"
108 " (declare (in) usampler1D sampler)\n"
109 " (declare (in) vec2 P) )\n"
110 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n"
111 "\n"
112 " (signature vec4\n"
113 " (parameters\n"
114 " (declare (in) sampler1D sampler)\n"
115 " (declare (in) vec4 P) )\n"
116 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
117 "\n"
118 " (signature ivec4\n"
119 " (parameters\n"
120 " (declare (in) isampler1D sampler)\n"
121 " (declare (in) vec4 P) )\n"
122 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
123 "\n"
124 " (signature uvec4\n"
125 " (parameters\n"
126 " (declare (in) usampler1D sampler)\n"
127 " (declare (in) vec4 P) )\n"
128 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
129 "\n"
130 " (signature vec4\n"
131 " (parameters\n"
132 " (declare (in) sampler2D sampler)\n"
133 " (declare (in) vec3 P) )\n"
134 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n"
135 "\n"
136 " (signature ivec4\n"
137 " (parameters\n"
138 " (declare (in) isampler2D sampler)\n"
139 " (declare (in) vec3 P) )\n"
140 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n"
141 "\n"
142 " (signature uvec4\n"
143 " (parameters\n"
144 " (declare (in) usampler2D sampler)\n"
145 " (declare (in) vec3 P) )\n"
146 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n"
147 "\n"
148 " (signature vec4\n"
149 " (parameters\n"
150 " (declare (in) sampler2D sampler)\n"
151 " (declare (in) vec4 P) )\n"
152 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
153 "\n"
154 " (signature ivec4\n"
155 " (parameters\n"
156 " (declare (in) isampler2D sampler)\n"
157 " (declare (in) vec4 P) )\n"
158 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
159 "\n"
160 " (signature uvec4\n"
161 " (parameters\n"
162 " (declare (in) usampler2D sampler)\n"
163 " (declare (in) vec4 P) )\n"
164 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
165 "\n"
166 " (signature vec4\n"
167 " (parameters\n"
168 " (declare (in) sampler3D sampler)\n"
169 " (declare (in) vec4 P) )\n"
170 " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
171 "\n"
172 " (signature ivec4\n"
173 " (parameters\n"
174 " (declare (in) isampler3D sampler)\n"
175 " (declare (in) vec4 P) )\n"
176 " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
177 "\n"
178 " (signature uvec4\n"
179 " (parameters\n"
180 " (declare (in) usampler3D sampler)\n"
181 " (declare (in) vec4 P) )\n"
182 " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
183 "\n"
184 " (signature vec4\n"
185 " (parameters\n"
186 " (declare (in) sampler1D sampler)\n"
187 " (declare (in) vec2 P) \n"
188 " (declare (in) float bias) )\n"
189 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n"
190 "\n"
191 " (signature ivec4\n"
192 " (parameters\n"
193 " (declare (in) isampler1D sampler)\n"
194 " (declare (in) vec2 P) \n"
195 " (declare (in) float bias) )\n"
196 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n"
197 "\n"
198 " (signature uvec4\n"
199 " (parameters\n"
200 " (declare (in) usampler1D sampler)\n"
201 " (declare (in) vec2 P) \n"
202 " (declare (in) float bias) )\n"
203 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n"
204 "\n"
205 " (signature vec4\n"
206 " (parameters\n"
207 " (declare (in) sampler1D sampler)\n"
208 " (declare (in) vec4 P) \n"
209 " (declare (in) float bias) )\n"
210 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
211 "\n"
212 " (signature ivec4\n"
213 " (parameters\n"
214 " (declare (in) isampler1D sampler)\n"
215 " (declare (in) vec4 P) \n"
216 " (declare (in) float bias) )\n"
217 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
218 "\n"
219 " (signature uvec4\n"
220 " (parameters\n"
221 " (declare (in) usampler1D sampler)\n"
222 " (declare (in) vec4 P) \n"
223 " (declare (in) float bias) )\n"
224 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
225 "\n"
226 " (signature vec4\n"
227 " (parameters\n"
228 " (declare (in) sampler2D sampler)\n"
229 " (declare (in) vec3 P) \n"
230 " (declare (in) float bias) )\n"
231 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n"
232 "\n"
233 " (signature ivec4\n"
234 " (parameters\n"
235 " (declare (in) isampler2D sampler)\n"
236 " (declare (in) vec3 P) \n"
237 " (declare (in) float bias) )\n"
238 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n"
239 "\n"
240 " (signature uvec4\n"
241 " (parameters\n"
242 " (declare (in) usampler2D sampler)\n"
243 " (declare (in) vec3 P) \n"
244 " (declare (in) float bias) )\n"
245 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n"
246 "\n"
247 " (signature vec4\n"
248 " (parameters\n"
249 " (declare (in) sampler2D sampler)\n"
250 " (declare (in) vec4 P) \n"
251 " (declare (in) float bias) )\n"
252 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
253 "\n"
254 " (signature ivec4\n"
255 " (parameters\n"
256 " (declare (in) isampler2D sampler)\n"
257 " (declare (in) vec4 P) \n"
258 " (declare (in) float bias) )\n"
259 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
260 "\n"
261 " (signature uvec4\n"
262 " (parameters\n"
263 " (declare (in) usampler2D sampler)\n"
264 " (declare (in) vec4 P) \n"
265 " (declare (in) float bias) )\n"
266 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
267 "\n"
268 " (signature vec4\n"
269 " (parameters\n"
270 " (declare (in) sampler3D sampler)\n"
271 " (declare (in) vec4 P) \n"
272 " (declare (in) float bias) )\n"
273 " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
274 "\n"
275 " (signature ivec4\n"
276 " (parameters\n"
277 " (declare (in) isampler3D sampler)\n"
278 " (declare (in) vec4 P) \n"
279 " (declare (in) float bias) )\n"
280 " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
281 "\n"
282 " (signature uvec4\n"
283 " (parameters\n"
284 " (declare (in) usampler3D sampler)\n"
285 " (declare (in) vec4 P) \n"
286 " (declare (in) float bias) )\n"
287 " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
288 "\n"
289 "))\n"
290 ""
291;
292static const char *builtin_fwidth =
293 "((function fwidth\n"
294 " (signature float\n"
295 " (parameters\n"
296 " (declare (in) float p))\n"
297 " ((return (expression float +\n"
298 " (expression float abs (expression float dFdx (var_ref p)))\n"
299 " (expression float abs (expression float dFdy (var_ref p)))))))\n"
300 "\n"
301 " (signature vec2\n"
302 " (parameters\n"
303 " (declare (in) vec2 p))\n"
304 " ((return (expression vec2 +\n"
305 " (expression vec2 abs (expression vec2 dFdx (var_ref p)))\n"
306 " (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))\n"
307 "\n"
308 " (signature vec3\n"
309 " (parameters\n"
310 " (declare (in) vec3 p))\n"
311 " ((return (expression vec3 +\n"
312 " (expression vec3 abs (expression vec3 dFdx (var_ref p)))\n"
313 " (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))\n"
314 "\n"
315 " (signature vec4\n"
316 " (parameters\n"
317 " (declare (in) vec4 p))\n"
318 " ((return (expression vec4 +\n"
319 " (expression vec4 abs (expression vec4 dFdx (var_ref p)))\n"
320 " (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))\n"
321 "))\n"
322 ""
323;
324static const char *builtin_texture2DProj =
325 "((function texture2DProj\n"
326 " (signature vec4\n"
327 " (parameters\n"
328 " (declare (in) sampler2D sampler)\n"
329 " (declare (in) vec3 P) )\n"
330 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n"
331 "\n"
332 " (signature vec4\n"
333 " (parameters\n"
334 " (declare (in) sampler2D sampler)\n"
335 " (declare (in) vec4 P) )\n"
336 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
337 "\n"
338 " (signature vec4\n"
339 " (parameters\n"
340 " (declare (in) sampler2D sampler)\n"
341 " (declare (in) vec3 P) \n"
342 " (declare (in) float bias) )\n"
343 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref bias) ))))\n"
344 "\n"
345 " (signature vec4\n"
346 " (parameters\n"
347 " (declare (in) sampler2D sampler)\n"
348 " (declare (in) vec4 P) \n"
349 " (declare (in) float bias) )\n"
350 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
351 "\n"
352 "))\n"
353 ""
354;
355static const char *builtin_shadow1DProjLod =
356 "((function shadow1DProjLod\n"
357 " (signature vec4\n"
358 " (parameters\n"
359 " (declare (in) sampler1DShadow sampler)\n"
360 " (declare (in) vec4 P) \n"
361 " (declare (in) float lod) )\n"
362 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n"
363 "\n"
364 "))\n"
365 ""
366;
367static const char *builtin_texture3DLod =
368 "((function texture3DLod\n"
369 " (signature vec4\n"
370 " (parameters\n"
371 " (declare (in) sampler3D sampler)\n"
372 " (declare (in) vec3 P) \n"
373 " (declare (in) float lod) )\n"
374 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
375 "\n"
376 "))\n"
377 ""
378;
379static const char *builtin_textureCubeLod =
380 "((function textureCubeLod\n"
381 " (signature vec4\n"
382 " (parameters\n"
383 " (declare (in) samplerCube sampler)\n"
384 " (declare (in) vec3 P) \n"
385 " (declare (in) float lod) )\n"
386 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
387 "\n"
388 "))\n"
389 ""
390;
391static const char *builtin_texture =
392 "((function texture\n"
393 " (signature vec4\n"
394 " (parameters\n"
395 " (declare (in) sampler1D sampler)\n"
396 " (declare (in) float P) )\n"
397 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
398 "\n"
399 " (signature ivec4\n"
400 " (parameters\n"
401 " (declare (in) isampler1D sampler)\n"
402 " (declare (in) float P) )\n"
403 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
404 "\n"
405 " (signature uvec4\n"
406 " (parameters\n"
407 " (declare (in) usampler1D sampler)\n"
408 " (declare (in) float P) )\n"
409 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
410 "\n"
411 " (signature vec4\n"
412 " (parameters\n"
413 " (declare (in) sampler2D sampler)\n"
414 " (declare (in) vec2 P) )\n"
415 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
416 "\n"
417 " (signature ivec4\n"
418 " (parameters\n"
419 " (declare (in) isampler2D sampler)\n"
420 " (declare (in) vec2 P) )\n"
421 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
422 "\n"
423 " (signature uvec4\n"
424 " (parameters\n"
425 " (declare (in) usampler2D sampler)\n"
426 " (declare (in) vec2 P) )\n"
427 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
428 "\n"
429 " (signature vec4\n"
430 " (parameters\n"
431 " (declare (in) sampler3D sampler)\n"
432 " (declare (in) vec3 P) )\n"
433 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
434 "\n"
435 " (signature ivec4\n"
436 " (parameters\n"
437 " (declare (in) isampler3D sampler)\n"
438 " (declare (in) vec3 P) )\n"
439 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
440 "\n"
441 " (signature uvec4\n"
442 " (parameters\n"
443 " (declare (in) usampler3D sampler)\n"
444 " (declare (in) vec3 P) )\n"
445 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
446 "\n"
447 " (signature vec4\n"
448 " (parameters\n"
449 " (declare (in) samplerCube sampler)\n"
450 " (declare (in) vec3 P) )\n"
451 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
452 "\n"
453 " (signature ivec4\n"
454 " (parameters\n"
455 " (declare (in) isamplerCube sampler)\n"
456 " (declare (in) vec3 P) )\n"
457 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
458 "\n"
459 " (signature uvec4\n"
460 " (parameters\n"
461 " (declare (in) usamplerCube sampler)\n"
462 " (declare (in) vec3 P) )\n"
463 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
464 "\n"
465 " (signature vec4\n"
466 " (parameters\n"
467 " (declare (in) sampler1DArray sampler)\n"
468 " (declare (in) vec2 P) )\n"
469 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
470 "\n"
471 " (signature ivec4\n"
472 " (parameters\n"
473 " (declare (in) isampler1DArray sampler)\n"
474 " (declare (in) vec2 P) )\n"
475 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
476 "\n"
477 " (signature uvec4\n"
478 " (parameters\n"
479 " (declare (in) usampler1DArray sampler)\n"
480 " (declare (in) vec2 P) )\n"
481 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
482 "\n"
483 " (signature vec4\n"
484 " (parameters\n"
485 " (declare (in) sampler2DArray sampler)\n"
486 " (declare (in) vec3 P) )\n"
487 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
488 "\n"
489 " (signature ivec4\n"
490 " (parameters\n"
491 " (declare (in) isampler2DArray sampler)\n"
492 " (declare (in) vec3 P) )\n"
493 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
494 "\n"
495 " (signature uvec4\n"
496 " (parameters\n"
497 " (declare (in) usampler2DArray sampler)\n"
498 " (declare (in) vec3 P) )\n"
499 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
500 "\n"
501 " (signature vec4\n"
502 " (parameters\n"
503 " (declare (in) sampler1D sampler)\n"
504 " (declare (in) float P) \n"
505 " (declare (in) float bias) )\n"
506 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
507 "\n"
508 " (signature ivec4\n"
509 " (parameters\n"
510 " (declare (in) isampler1D sampler)\n"
511 " (declare (in) float P) \n"
512 " (declare (in) float bias) )\n"
513 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
514 "\n"
515 " (signature uvec4\n"
516 " (parameters\n"
517 " (declare (in) usampler1D sampler)\n"
518 " (declare (in) float P) \n"
519 " (declare (in) float bias) )\n"
520 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
521 "\n"
522 " (signature vec4\n"
523 " (parameters\n"
524 " (declare (in) sampler2D sampler)\n"
525 " (declare (in) vec2 P) \n"
526 " (declare (in) float bias) )\n"
527 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
528 "\n"
529 " (signature ivec4\n"
530 " (parameters\n"
531 " (declare (in) isampler2D sampler)\n"
532 " (declare (in) vec2 P) \n"
533 " (declare (in) float bias) )\n"
534 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
535 "\n"
536 " (signature uvec4\n"
537 " (parameters\n"
538 " (declare (in) usampler2D sampler)\n"
539 " (declare (in) vec2 P) \n"
540 " (declare (in) float bias) )\n"
541 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
542 "\n"
543 " (signature vec4\n"
544 " (parameters\n"
545 " (declare (in) sampler3D sampler)\n"
546 " (declare (in) vec3 P) \n"
547 " (declare (in) float bias) )\n"
548 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
549 "\n"
550 " (signature ivec4\n"
551 " (parameters\n"
552 " (declare (in) isampler3D sampler)\n"
553 " (declare (in) vec3 P) \n"
554 " (declare (in) float bias) )\n"
555 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
556 "\n"
557 " (signature uvec4\n"
558 " (parameters\n"
559 " (declare (in) usampler3D sampler)\n"
560 " (declare (in) vec3 P) \n"
561 " (declare (in) float bias) )\n"
562 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
563 "\n"
564 " (signature vec4\n"
565 " (parameters\n"
566 " (declare (in) samplerCube sampler)\n"
567 " (declare (in) vec3 P) \n"
568 " (declare (in) float bias) )\n"
569 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
570 "\n"
571 " (signature ivec4\n"
572 " (parameters\n"
573 " (declare (in) isamplerCube sampler)\n"
574 " (declare (in) vec3 P) \n"
575 " (declare (in) float bias) )\n"
576 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
577 "\n"
578 " (signature uvec4\n"
579 " (parameters\n"
580 " (declare (in) usamplerCube sampler)\n"
581 " (declare (in) vec3 P) \n"
582 " (declare (in) float bias) )\n"
583 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
584 "\n"
585 " (signature vec4\n"
586 " (parameters\n"
587 " (declare (in) sampler1DArray sampler)\n"
588 " (declare (in) vec2 P) \n"
589 " (declare (in) float bias) )\n"
590 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
591 "\n"
592 " (signature ivec4\n"
593 " (parameters\n"
594 " (declare (in) isampler1DArray sampler)\n"
595 " (declare (in) vec2 P) \n"
596 " (declare (in) float bias) )\n"
597 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
598 "\n"
599 " (signature uvec4\n"
600 " (parameters\n"
601 " (declare (in) usampler1DArray sampler)\n"
602 " (declare (in) vec2 P) \n"
603 " (declare (in) float bias) )\n"
604 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
605 "\n"
606 " (signature vec4\n"
607 " (parameters\n"
608 " (declare (in) sampler2DArray sampler)\n"
609 " (declare (in) vec3 P) \n"
610 " (declare (in) float bias) )\n"
611 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
612 "\n"
613 " (signature ivec4\n"
614 " (parameters\n"
615 " (declare (in) isampler2DArray sampler)\n"
616 " (declare (in) vec3 P) \n"
617 " (declare (in) float bias) )\n"
618 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
619 "\n"
620 " (signature uvec4\n"
621 " (parameters\n"
622 " (declare (in) usampler2DArray sampler)\n"
623 " (declare (in) vec3 P) \n"
624 " (declare (in) float bias) )\n"
625 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
626 "\n"
627 "))\n"
628 ""
629;
630static const char *builtin_degrees =
631 "((function degrees\n"
632 " (signature float\n"
633 " (parameters\n"
634 " (declare (in) float arg0))\n"
635 " ((return (expression float * (var_ref arg0) (constant float (57.295780))))))\n"
636 "\n"
637 " (signature vec2\n"
638 " (parameters\n"
639 " (declare (in) vec2 arg0))\n"
640 " ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))\n"
641 "\n"
642 " (signature vec3\n"
643 " (parameters\n"
644 " (declare (in) vec3 arg0))\n"
645 " ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))\n"
646 "\n"
647 " (signature vec4\n"
648 " (parameters\n"
649 " (declare (in) vec4 arg0))\n"
650 " ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))\n"
651 "))\n"
652 ""
653;
654static const char *builtin_texture2DArrayLod =
655 "((function texture2DArrayLod\n"
656 " (signature vec4\n"
657 " (parameters\n"
658 " (declare (in) sampler2DArray sampler)\n"
659 " (declare (in) vec3 P) \n"
660 " (declare (in) float lod) )\n"
661 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
662 "\n"
663 "))\n"
664 ""
665;
666static const char *builtin_ceil =
667 "((function ceil\n"
668 " (signature float\n"
669 " (parameters\n"
670 " (declare (in) float arg0))\n"
671 " ((return (expression float ceil (var_ref arg0)))))\n"
672 "\n"
673 " (signature vec2\n"
674 " (parameters\n"
675 " (declare (in) vec2 arg0))\n"
676 " ((return (expression vec2 ceil (var_ref arg0)))))\n"
677 "\n"
678 " (signature vec3\n"
679 " (parameters\n"
680 " (declare (in) vec3 arg0))\n"
681 " ((return (expression vec3 ceil (var_ref arg0)))))\n"
682 "\n"
683 " (signature vec4\n"
684 " (parameters\n"
685 " (declare (in) vec4 arg0))\n"
686 " ((return (expression vec4 ceil (var_ref arg0)))))\n"
687 "))\n"
688 ""
689;
690static const char *builtin_texture1D =
691 "((function texture1D\n"
692 " (signature vec4\n"
693 " (parameters\n"
694 " (declare (in) sampler1D sampler)\n"
695 " (declare (in) float P) )\n"
696 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
697 "\n"
698 " (signature vec4\n"
699 " (parameters\n"
700 " (declare (in) sampler1D sampler)\n"
701 " (declare (in) float P) \n"
702 " (declare (in) float bias) )\n"
703 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
704 "\n"
705 "))\n"
706 ""
707;
708static const char *builtin_not =
709 "((function not\n"
710 " (signature bvec2\n"
711 " (parameters\n"
712 " (declare (in) bvec2 arg0))\n"
713 " ((return (expression bvec2 ! (var_ref arg0)))))\n"
714 "\n"
715 " (signature bvec3\n"
716 " (parameters\n"
717 " (declare (in) bvec3 arg0))\n"
718 " ((return (expression bvec3 ! (var_ref arg0)))))\n"
719 "\n"
720 " (signature bvec4\n"
721 " (parameters\n"
722 " (declare (in) bvec4 arg0))\n"
723 " ((return (expression bvec4 ! (var_ref arg0)))))\n"
724 "))\n"
725 ""
726;
727static const char *builtin_texture2DRectProj =
728 "((function texture2DRectProj\n"
729 " (signature vec4\n"
730 " (parameters\n"
731 " (declare (in) sampler2DRect sampler)\n"
732 " (declare (in) vec3 P) )\n"
733 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ))))\n"
734 "\n"
735 " (signature vec4\n"
736 " (parameters\n"
737 " (declare (in) sampler2DRect sampler)\n"
738 " (declare (in) vec4 P) )\n"
739 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
740 "\n"
741 "))\n"
742 ""
743;
744static const char *builtin_mod =
745 "((function mod\n"
746 " (signature float\n"
747 " (parameters\n"
748 " (declare (in) float arg0)\n"
749 " (declare (in) float arg1))\n"
750 " ((return (expression float % (var_ref arg0) (var_ref arg1)))))\n"
751 "\n"
752 " (signature vec2\n"
753 " (parameters\n"
754 " (declare (in) vec2 arg0)\n"
755 " (declare (in) vec2 arg1))\n"
756 " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n"
757 "\n"
758 " (signature vec3\n"
759 " (parameters\n"
760 " (declare (in) vec3 arg0)\n"
761 " (declare (in) vec3 arg1))\n"
762 " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n"
763 "\n"
764 " (signature vec4\n"
765 " (parameters\n"
766 " (declare (in) vec4 arg0)\n"
767 " (declare (in) vec4 arg1))\n"
768 " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n"
769 "\n"
770 " (signature vec2\n"
771 " (parameters\n"
772 " (declare (in) vec2 arg0)\n"
773 " (declare (in) float arg1))\n"
774 " ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))\n"
775 "\n"
776 " (signature vec3\n"
777 " (parameters\n"
778 " (declare (in) vec3 arg0)\n"
779 " (declare (in) float arg1))\n"
780 " ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))\n"
781 "\n"
782 " (signature vec4\n"
783 " (parameters\n"
784 " (declare (in) vec4 arg0)\n"
785 " (declare (in) float arg1))\n"
786 " ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))\n"
787 "))\n"
788 ""
789;
790static const char *builtin_radians =
791 "((function radians\n"
792 " (signature float\n"
793 " (parameters\n"
794 " (declare (in) float arg0))\n"
795 " ((return (expression float * (var_ref arg0) (constant float (0.017453))))))\n"
796 "\n"
797 " (signature vec2\n"
798 " (parameters\n"
799 " (declare (in) vec2 arg0))\n"
800 " ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))\n"
801 "\n"
802 " (signature vec3\n"
803 " (parameters\n"
804 " (declare (in) vec3 arg0))\n"
805 " ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))\n"
806 "\n"
807 " (signature vec4\n"
808 " (parameters\n"
809 " (declare (in) vec4 arg0))\n"
810 " ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))\n"
811 "))\n"
812 ""
813;
814static const char *builtin_smoothstep =
815 "((function smoothstep\n"
816 " (signature float\n"
817 " (parameters\n"
818 " (declare (in) float edge0)\n"
819 " (declare (in) float edge1)\n"
820 " (declare (in) float x))\n"
821 " ((declare () float t)\n"
822 "\n"
823 " (assign (constant bool (1)) (var_ref t)\n"
824 " (expression float max\n"
825 " (expression float min\n"
826 " (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
827 " (constant float (1.0)))\n"
828 " (constant float (0.0))))\n"
829 " (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))\n"
830 "\n"
831 " (signature vec2\n"
832 " (parameters\n"
833 " (declare (in) float edge0)\n"
834 " (declare (in) float edge1)\n"
835 " (declare (in) vec2 x))\n"
836 " ((declare () vec2 t)\n"
837 " (declare () vec2 retval)\n"
838 "\n"
839 " (assign (constant bool (1)) (swiz x (var_ref t))\n"
840 " (expression float max\n"
841 " (expression float min\n"
842 " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
843 " (constant float (1.0)))\n"
844 " (constant float (0.0))))\n"
845 " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n"
846 "\n"
847 " (assign (constant bool (1)) (swiz y (var_ref t))\n"
848 " (expression float max\n"
849 " (expression float min\n"
850 " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
851 " (constant float (1.0)))\n"
852 " (constant float (0.0))))\n"
853 " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n"
854 " (return (var_ref retval))\n"
855 " ))\n"
856 "\n"
857 " (signature vec3\n"
858 " (parameters\n"
859 " (declare (in) float edge0)\n"
860 " (declare (in) float edge1)\n"
861 " (declare (in) vec3 x))\n"
862 " ((declare () vec3 t)\n"
863 " (declare () vec3 retval)\n"
864 "\n"
865 " (assign (constant bool (1)) (swiz x (var_ref t))\n"
866 " (expression float max\n"
867 " (expression float min\n"
868 " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
869 " (constant float (1.0)))\n"
870 " (constant float (0.0))))\n"
871 " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n"
872 "\n"
873 " (assign (constant bool (1)) (swiz y (var_ref t))\n"
874 " (expression float max\n"
875 " (expression float min\n"
876 " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
877 " (constant float (1.0)))\n"
878 " (constant float (0.0))))\n"
879 " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n"
880 "\n"
881 " (assign (constant bool (1)) (swiz z (var_ref t))\n"
882 " (expression float max\n"
883 " (expression float min\n"
884 " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
885 " (constant float (1.0)))\n"
886 " (constant float (0.0))))\n"
887 " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n"
888 " (return (var_ref retval))\n"
889 " ))\n"
890 "\n"
891 "\n"
892 " (signature vec4\n"
893 " (parameters\n"
894 " (declare (in) float edge0)\n"
895 " (declare (in) float edge1)\n"
896 " (declare (in) vec4 x))\n"
897 " ((declare () vec4 t)\n"
898 " (declare () vec4 retval)\n"
899 "\n"
900 " (assign (constant bool (1)) (swiz x (var_ref t))\n"
901 " (expression float max\n"
902 " (expression float min\n"
903 " (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
904 " (constant float (1.0)))\n"
905 " (constant float (0.0))))\n"
906 " (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))\n"
907 "\n"
908 " (assign (constant bool (1)) (swiz y (var_ref t))\n"
909 " (expression float max\n"
910 " (expression float min\n"
911 " (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
912 " (constant float (1.0)))\n"
913 " (constant float (0.0))))\n"
914 " (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))\n"
915 "\n"
916 " (assign (constant bool (1)) (swiz z (var_ref t))\n"
917 " (expression float max\n"
918 " (expression float min\n"
919 " (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
920 " (constant float (1.0)))\n"
921 " (constant float (0.0))))\n"
922 " (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))\n"
923 "\n"
924 " (assign (constant bool (1)) (swiz w (var_ref t))\n"
925 " (expression float max\n"
926 " (expression float min\n"
927 " (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))\n"
928 " (constant float (1.0)))\n"
929 " (constant float (0.0))))\n"
930 " (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))\n"
931 " (return (var_ref retval))\n"
932 " ))\n"
933 "\n"
934 " (signature vec2\n"
935 " (parameters\n"
936 " (declare (in) vec2 edge0)\n"
937 " (declare (in) vec2 edge1)\n"
938 " (declare (in) vec2 x))\n"
939 " ((return (expression vec2 max\n"
940 " (expression vec2 min\n"
941 " (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))\n"
942 " (constant vec2 (1.0 1.0)))\n"
943 " (constant vec2 (0.0 0.0))))))\n"
944 "\n"
945 " (signature vec3\n"
946 " (parameters\n"
947 " (declare (in) vec3 edge0)\n"
948 " (declare (in) vec3 edge1)\n"
949 " (declare (in) vec3 x))\n"
950 " ((return (expression vec3 max\n"
951 " (expression vec3 min\n"
952 " (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))\n"
953 " (constant vec3 (1.0 1.0 1.0)))\n"
954 " (constant vec3 (0.0 0.0 0.0))))))\n"
955 "\n"
956 " (signature vec4\n"
957 " (parameters\n"
958 " (declare (in) vec4 edge0)\n"
959 " (declare (in) vec4 edge1)\n"
960 " (declare (in) vec4 x))\n"
961 " ((return (expression vec4 max\n"
962 " (expression vec4 min\n"
963 " (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))\n"
964 " (constant vec4 (1.0 1.0 1.0 1.0)))\n"
965 " (constant vec4 (0.0 0.0 0.0 0.0))))))\n"
966 "))\n"
967 "\n"
968 ""
969;
970static const char *builtin_textureProjGrad =
971 "((function textureProjGrad\n"
972 " (signature vec4\n"
973 " (parameters\n"
974 " (declare (in) sampler1D sampler)\n"
975 " (declare (in) vec2 P) \n"
976 " (declare (in) float dPdx) \n"
977 " (declare (in) float dPdy) )\n"
978 " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
979 "\n"
980 " (signature ivec4\n"
981 " (parameters\n"
982 " (declare (in) isampler1D sampler)\n"
983 " (declare (in) vec2 P) \n"
984 " (declare (in) float dPdx) \n"
985 " (declare (in) float dPdy) )\n"
986 " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
987 "\n"
988 " (signature uvec4\n"
989 " (parameters\n"
990 " (declare (in) usampler1D sampler)\n"
991 " (declare (in) vec2 P) \n"
992 " (declare (in) float dPdx) \n"
993 " (declare (in) float dPdy) )\n"
994 " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
995 "\n"
996 " (signature vec4\n"
997 " (parameters\n"
998 " (declare (in) sampler1D sampler)\n"
999 " (declare (in) vec4 P) \n"
1000 " (declare (in) float dPdx) \n"
1001 " (declare (in) float dPdy) )\n"
1002 " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1003 "\n"
1004 " (signature ivec4\n"
1005 " (parameters\n"
1006 " (declare (in) isampler1D sampler)\n"
1007 " (declare (in) vec4 P) \n"
1008 " (declare (in) float dPdx) \n"
1009 " (declare (in) float dPdy) )\n"
1010 " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1011 "\n"
1012 " (signature uvec4\n"
1013 " (parameters\n"
1014 " (declare (in) usampler1D sampler)\n"
1015 " (declare (in) vec4 P) \n"
1016 " (declare (in) float dPdx) \n"
1017 " (declare (in) float dPdy) )\n"
1018 " ((return (txd (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1019 "\n"
1020 " (signature vec4\n"
1021 " (parameters\n"
1022 " (declare (in) sampler2D sampler)\n"
1023 " (declare (in) vec3 P) \n"
1024 " (declare (in) vec2 dPdx) \n"
1025 " (declare (in) vec2 dPdy) )\n"
1026 " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1027 "\n"
1028 " (signature ivec4\n"
1029 " (parameters\n"
1030 " (declare (in) isampler2D sampler)\n"
1031 " (declare (in) vec3 P) \n"
1032 " (declare (in) vec2 dPdx) \n"
1033 " (declare (in) vec2 dPdy) )\n"
1034 " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1035 "\n"
1036 " (signature uvec4\n"
1037 " (parameters\n"
1038 " (declare (in) usampler2D sampler)\n"
1039 " (declare (in) vec3 P) \n"
1040 " (declare (in) vec2 dPdx) \n"
1041 " (declare (in) vec2 dPdy) )\n"
1042 " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1043 "\n"
1044 " (signature vec4\n"
1045 " (parameters\n"
1046 " (declare (in) sampler2D sampler)\n"
1047 " (declare (in) vec4 P) \n"
1048 " (declare (in) vec2 dPdx) \n"
1049 " (declare (in) vec2 dPdy) )\n"
1050 " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1051 "\n"
1052 " (signature ivec4\n"
1053 " (parameters\n"
1054 " (declare (in) isampler2D sampler)\n"
1055 " (declare (in) vec4 P) \n"
1056 " (declare (in) vec2 dPdx) \n"
1057 " (declare (in) vec2 dPdy) )\n"
1058 " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1059 "\n"
1060 " (signature uvec4\n"
1061 " (parameters\n"
1062 " (declare (in) usampler2D sampler)\n"
1063 " (declare (in) vec4 P) \n"
1064 " (declare (in) vec2 dPdx) \n"
1065 " (declare (in) vec2 dPdy) )\n"
1066 " ((return (txd (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1067 "\n"
1068 " (signature vec4\n"
1069 " (parameters\n"
1070 " (declare (in) sampler3D sampler)\n"
1071 " (declare (in) vec4 P) \n"
1072 " (declare (in) vec3 dPdx) \n"
1073 " (declare (in) vec3 dPdy) )\n"
1074 " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1075 "\n"
1076 " (signature ivec4\n"
1077 " (parameters\n"
1078 " (declare (in) isampler3D sampler)\n"
1079 " (declare (in) vec4 P) \n"
1080 " (declare (in) vec3 dPdx) \n"
1081 " (declare (in) vec3 dPdy) )\n"
1082 " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1083 "\n"
1084 " (signature uvec4\n"
1085 " (parameters\n"
1086 " (declare (in) usampler3D sampler)\n"
1087 " (declare (in) vec4 P) \n"
1088 " (declare (in) vec3 dPdx) \n"
1089 " (declare (in) vec3 dPdy) )\n"
1090 " ((return (txd (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1091 "\n"
1092 "))\n"
1093 ""
1094;
1095static const char *builtin_dFdx =
1096 "((function dFdx\n"
1097 " (signature float\n"
1098 " (parameters\n"
1099 " (declare (in) float p))\n"
1100 " ((return (expression float dFdx (var_ref p)))))\n"
1101 "\n"
1102 " (signature vec2\n"
1103 " (parameters\n"
1104 " (declare (in) vec2 p))\n"
1105 " ((return (expression vec2 dFdx (var_ref p)))))\n"
1106 "\n"
1107 " (signature vec3\n"
1108 " (parameters\n"
1109 " (declare (in) vec3 p))\n"
1110 " ((return (expression vec3 dFdx (var_ref p)))))\n"
1111 "\n"
1112 " (signature vec4\n"
1113 " (parameters\n"
1114 " (declare (in) vec4 p))\n"
1115 " ((return (expression vec4 dFdx (var_ref p)))))\n"
1116 "))\n"
1117 ""
1118;
1119static const char *builtin_dFdy =
1120 "((function dFdy\n"
1121 " (signature float\n"
1122 " (parameters\n"
1123 " (declare (in) float p))\n"
1124 " ((return (expression float dFdy (var_ref p)))))\n"
1125 "\n"
1126 " (signature vec2\n"
1127 " (parameters\n"
1128 " (declare (in) vec2 p))\n"
1129 " ((return (expression vec2 dFdy (var_ref p)))))\n"
1130 "\n"
1131 " (signature vec3\n"
1132 " (parameters\n"
1133 " (declare (in) vec3 p))\n"
1134 " ((return (expression vec3 dFdy (var_ref p)))))\n"
1135 "\n"
1136 " (signature vec4\n"
1137 " (parameters\n"
1138 " (declare (in) vec4 p))\n"
1139 " ((return (expression vec4 dFdy (var_ref p)))))\n"
1140 "))\n"
1141 ""
1142;
1143static const char *builtin_textureGrad =
1144 "((function textureGrad\n"
1145 " (signature vec4\n"
1146 " (parameters\n"
1147 " (declare (in) sampler1D sampler)\n"
1148 " (declare (in) float P) \n"
1149 " (declare (in) float dPdx) \n"
1150 " (declare (in) float dPdy) )\n"
1151 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1152 "\n"
1153 " (signature ivec4\n"
1154 " (parameters\n"
1155 " (declare (in) isampler1D sampler)\n"
1156 " (declare (in) float P) \n"
1157 " (declare (in) float dPdx) \n"
1158 " (declare (in) float dPdy) )\n"
1159 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1160 "\n"
1161 " (signature uvec4\n"
1162 " (parameters\n"
1163 " (declare (in) usampler1D sampler)\n"
1164 " (declare (in) float P) \n"
1165 " (declare (in) float dPdx) \n"
1166 " (declare (in) float dPdy) )\n"
1167 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1168 "\n"
1169 " (signature vec4\n"
1170 " (parameters\n"
1171 " (declare (in) sampler2D sampler)\n"
1172 " (declare (in) vec2 P) \n"
1173 " (declare (in) vec2 dPdx) \n"
1174 " (declare (in) vec2 dPdy) )\n"
1175 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1176 "\n"
1177 " (signature ivec4\n"
1178 " (parameters\n"
1179 " (declare (in) isampler2D sampler)\n"
1180 " (declare (in) vec2 P) \n"
1181 " (declare (in) vec2 dPdx) \n"
1182 " (declare (in) vec2 dPdy) )\n"
1183 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1184 "\n"
1185 " (signature uvec4\n"
1186 " (parameters\n"
1187 " (declare (in) usampler2D sampler)\n"
1188 " (declare (in) vec2 P) \n"
1189 " (declare (in) vec2 dPdx) \n"
1190 " (declare (in) vec2 dPdy) )\n"
1191 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1192 "\n"
1193 " (signature vec4\n"
1194 " (parameters\n"
1195 " (declare (in) sampler3D sampler)\n"
1196 " (declare (in) vec3 P) \n"
1197 " (declare (in) vec3 dPdx) \n"
1198 " (declare (in) vec3 dPdy) )\n"
1199 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1200 "\n"
1201 " (signature ivec4\n"
1202 " (parameters\n"
1203 " (declare (in) isampler3D sampler)\n"
1204 " (declare (in) vec3 P) \n"
1205 " (declare (in) vec3 dPdx) \n"
1206 " (declare (in) vec3 dPdy) )\n"
1207 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1208 "\n"
1209 " (signature uvec4\n"
1210 " (parameters\n"
1211 " (declare (in) usampler3D sampler)\n"
1212 " (declare (in) vec3 P) \n"
1213 " (declare (in) vec3 dPdx) \n"
1214 " (declare (in) vec3 dPdy) )\n"
1215 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1216 "\n"
1217 " (signature vec4\n"
1218 " (parameters\n"
1219 " (declare (in) samplerCube sampler)\n"
1220 " (declare (in) vec3 P) \n"
1221 " (declare (in) vec3 dPdx) \n"
1222 " (declare (in) vec3 dPdy) )\n"
1223 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1224 "\n"
1225 " (signature ivec4\n"
1226 " (parameters\n"
1227 " (declare (in) isamplerCube sampler)\n"
1228 " (declare (in) vec3 P) \n"
1229 " (declare (in) vec3 dPdx) \n"
1230 " (declare (in) vec3 dPdy) )\n"
1231 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1232 "\n"
1233 " (signature uvec4\n"
1234 " (parameters\n"
1235 " (declare (in) usamplerCube sampler)\n"
1236 " (declare (in) vec3 P) \n"
1237 " (declare (in) vec3 dPdx) \n"
1238 " (declare (in) vec3 dPdy) )\n"
1239 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1240 "\n"
1241 " (signature vec4\n"
1242 " (parameters\n"
1243 " (declare (in) sampler1DArray sampler)\n"
1244 " (declare (in) vec2 P) \n"
1245 " (declare (in) vec2 dPdx) \n"
1246 " (declare (in) vec2 dPdy) )\n"
1247 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1248 "\n"
1249 " (signature ivec4\n"
1250 " (parameters\n"
1251 " (declare (in) isampler1DArray sampler)\n"
1252 " (declare (in) vec2 P) \n"
1253 " (declare (in) vec2 dPdx) \n"
1254 " (declare (in) vec2 dPdy) )\n"
1255 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1256 "\n"
1257 " (signature uvec4\n"
1258 " (parameters\n"
1259 " (declare (in) usampler1DArray sampler)\n"
1260 " (declare (in) vec2 P) \n"
1261 " (declare (in) vec2 dPdx) \n"
1262 " (declare (in) vec2 dPdy) )\n"
1263 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1264 "\n"
1265 " (signature vec4\n"
1266 " (parameters\n"
1267 " (declare (in) sampler2DArray sampler)\n"
1268 " (declare (in) vec3 P) \n"
1269 " (declare (in) vec3 dPdx) \n"
1270 " (declare (in) vec3 dPdy) )\n"
1271 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1272 "\n"
1273 " (signature ivec4\n"
1274 " (parameters\n"
1275 " (declare (in) isampler2DArray sampler)\n"
1276 " (declare (in) vec3 P) \n"
1277 " (declare (in) vec3 dPdx) \n"
1278 " (declare (in) vec3 dPdy) )\n"
1279 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1280 "\n"
1281 " (signature uvec4\n"
1282 " (parameters\n"
1283 " (declare (in) usampler2DArray sampler)\n"
1284 " (declare (in) vec3 P) \n"
1285 " (declare (in) vec3 dPdx) \n"
1286 " (declare (in) vec3 dPdy) )\n"
1287 " ((return (txd (var_ref sampler) (var_ref P) (0 0 0) 1 () ((var_ref dPdx) (var_ref dPdy)) ))))\n"
1288 "\n"
1289 "))\n"
1290 ""
1291;
1292static const char *builtin_clamp =
1293 "((function clamp\n"
1294 " (signature float\n"
1295 " (parameters\n"
1296 " (declare (in) float arg0)\n"
1297 " (declare (in) float arg1)\n"
1298 " (declare (in) float arg2))\n"
1299 " ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1300 "\n"
1301 " (signature vec2\n"
1302 " (parameters\n"
1303 " (declare (in) vec2 arg0)\n"
1304 " (declare (in) vec2 arg1)\n"
1305 " (declare (in) vec2 arg2))\n"
1306 " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1307 "\n"
1308 " (signature vec3\n"
1309 " (parameters\n"
1310 " (declare (in) vec3 arg0)\n"
1311 " (declare (in) vec3 arg1)\n"
1312 " (declare (in) vec3 arg2))\n"
1313 " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1314 "\n"
1315 " (signature vec4\n"
1316 " (parameters\n"
1317 " (declare (in) vec4 arg0)\n"
1318 " (declare (in) vec4 arg1)\n"
1319 " (declare (in) vec4 arg2))\n"
1320 " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1321 "\n"
1322 " (signature vec2\n"
1323 " (parameters\n"
1324 " (declare (in) vec2 arg0)\n"
1325 " (declare (in) float arg1)\n"
1326 " (declare (in) float arg2))\n"
1327 " ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1328 "\n"
1329 " (signature vec3\n"
1330 " (parameters\n"
1331 " (declare (in) vec3 arg0)\n"
1332 " (declare (in) float arg1)\n"
1333 " (declare (in) float arg2))\n"
1334 " ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1335 "\n"
1336 " (signature vec4\n"
1337 " (parameters\n"
1338 " (declare (in) vec4 arg0)\n"
1339 " (declare (in) float arg1)\n"
1340 " (declare (in) float arg2))\n"
1341 " ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1342 "\n"
1343 " (signature int\n"
1344 " (parameters\n"
1345 " (declare (in) int arg0)\n"
1346 " (declare (in) int arg1)\n"
1347 " (declare (in) int arg2))\n"
1348 " ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1349 "\n"
1350 " (signature ivec2\n"
1351 " (parameters\n"
1352 " (declare (in) ivec2 arg0)\n"
1353 " (declare (in) ivec2 arg1)\n"
1354 " (declare (in) ivec2 arg2))\n"
1355 " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1356 "\n"
1357 " (signature ivec3\n"
1358 " (parameters\n"
1359 " (declare (in) ivec3 arg0)\n"
1360 " (declare (in) ivec3 arg1)\n"
1361 " (declare (in) ivec3 arg2))\n"
1362 " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1363 "\n"
1364 " (signature ivec4\n"
1365 " (parameters\n"
1366 " (declare (in) ivec4 arg0)\n"
1367 " (declare (in) ivec4 arg1)\n"
1368 " (declare (in) ivec4 arg2))\n"
1369 " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1370 "\n"
1371 " (signature ivec2\n"
1372 " (parameters\n"
1373 " (declare (in) ivec2 arg0)\n"
1374 " (declare (in) int arg1)\n"
1375 " (declare (in) int arg2))\n"
1376 " ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1377 "\n"
1378 " (signature ivec3\n"
1379 " (parameters\n"
1380 " (declare (in) ivec3 arg0)\n"
1381 " (declare (in) int arg1)\n"
1382 " (declare (in) int arg2))\n"
1383 " ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1384 "\n"
1385 " (signature ivec4\n"
1386 " (parameters\n"
1387 " (declare (in) ivec4 arg0)\n"
1388 " (declare (in) int arg1)\n"
1389 " (declare (in) int arg2))\n"
1390 " ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1391 "\n"
1392 " (signature uint\n"
1393 " (parameters\n"
1394 " (declare (in) uint arg0)\n"
1395 " (declare (in) uint arg1)\n"
1396 " (declare (in) uint arg2))\n"
1397 " ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1398 "\n"
1399 " (signature uvec2\n"
1400 " (parameters\n"
1401 " (declare (in) uvec2 arg0)\n"
1402 " (declare (in) uvec2 arg1)\n"
1403 " (declare (in) uvec2 arg2))\n"
1404 " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1405 "\n"
1406 " (signature uvec3\n"
1407 " (parameters\n"
1408 " (declare (in) uvec3 arg0)\n"
1409 " (declare (in) uvec3 arg1)\n"
1410 " (declare (in) uvec3 arg2))\n"
1411 " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1412 "\n"
1413 " (signature uvec4\n"
1414 " (parameters\n"
1415 " (declare (in) uvec4 arg0)\n"
1416 " (declare (in) uvec4 arg1)\n"
1417 " (declare (in) uvec4 arg2))\n"
1418 " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1419 "\n"
1420 " (signature uvec2\n"
1421 " (parameters\n"
1422 " (declare (in) uvec2 arg0)\n"
1423 " (declare (in) uint arg1)\n"
1424 " (declare (in) uint arg2))\n"
1425 " ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1426 "\n"
1427 " (signature uvec3\n"
1428 " (parameters\n"
1429 " (declare (in) uvec3 arg0)\n"
1430 " (declare (in) uint arg1)\n"
1431 " (declare (in) uint arg2))\n"
1432 " ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1433 "\n"
1434 " (signature uvec4\n"
1435 " (parameters\n"
1436 " (declare (in) uvec4 arg0)\n"
1437 " (declare (in) uint arg1)\n"
1438 " (declare (in) uint arg2))\n"
1439 " ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))\n"
1440 "))\n"
1441 ""
1442;
1443static const char *builtin_texture2DRect =
1444 "((function texture2DRect\n"
1445 " (signature vec4\n"
1446 " (parameters\n"
1447 " (declare (in) sampler2DRect sampler)\n"
1448 " (declare (in) vec2 P) )\n"
1449 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
1450 "\n"
1451 "))\n"
1452 ""
1453;
1454static const char *builtin_cosh =
1455 "((function cosh\n"
1456 " (signature float\n"
1457 " (parameters\n"
1458 " (declare (in) float x))\n"
1459 " ((return (expression float * (constant float (0.5))\n"
1460 " (expression float +\n"
1461 " (expression float exp (var_ref x))\n"
1462 " (expression float exp (expression float neg (var_ref x))))))))\n"
1463 " (signature vec2\n"
1464 " (parameters\n"
1465 " (declare (in) vec2 x))\n"
1466 " ((return (expression vec2 * (constant vec2 (0.5))\n"
1467 " (expression vec2 +\n"
1468 " (expression vec2 exp (var_ref x))\n"
1469 " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n"
1470 " (signature vec3\n"
1471 " (parameters\n"
1472 " (declare (in) vec3 x))\n"
1473 " ((return (expression vec3 * (constant vec3 (0.5))\n"
1474 " (expression vec3 +\n"
1475 " (expression vec3 exp (var_ref x))\n"
1476 " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n"
1477 " (signature vec4\n"
1478 " (parameters\n"
1479 " (declare (in) vec4 x))\n"
1480 " ((return (expression vec4 * (constant vec4 (0.5))\n"
1481 " (expression vec4 +\n"
1482 " (expression vec4 exp (var_ref x))\n"
1483 " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n"
1484 "))\n"
1485 ""
1486;
1487static const char *builtin_texture1DArrayLod =
1488 "((function texture1DArrayLod\n"
1489 " (signature vec4\n"
1490 " (parameters\n"
1491 " (declare (in) sampler1DArray sampler)\n"
1492 " (declare (in) vec2 P) \n"
1493 " (declare (in) float lod) )\n"
1494 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1495 "\n"
1496 "))\n"
1497 ""
1498;
1499static const char *builtin_asin =
1500 "((function asin\n"
1501 " (signature float\n"
1502 " (parameters\n"
1503 " (declare (in) float x))\n"
1504 " ((return (expression float *\n"
1505 " (expression float sign (var_ref x))\n"
1506 " (expression float -\n"
1507 " (expression float *\n"
1508 " (constant float (3.1415926))\n"
1509 " (constant float (0.5)))\n"
1510 " (expression float *\n"
1511 " (expression float sqrt\n"
1512 " (expression float -\n"
1513 " (constant float (1.0))\n"
1514 " (expression float abs (var_ref x))))\n"
1515 " (expression float +\n"
1516 " (constant float (1.5707288))\n"
1517 " (expression float *\n"
1518 " (expression float abs (var_ref x))\n"
1519 " (expression float +\n"
1520 " (constant float (-0.2121144))\n"
1521 " (expression float *\n"
1522 " (constant float (0.0742610))\n"
1523 " (expression float abs (var_ref x))))))))))))\n"
1524 "\n"
1525 " (signature vec2\n"
1526 " (parameters\n"
1527 " (declare (in) vec2 x))\n"
1528 " ((return (expression vec2 *\n"
1529 " (expression vec2 sign (var_ref x))\n"
1530 " (expression vec2 -\n"
1531 " (expression float *\n"
1532 " (constant float (3.1415926))\n"
1533 " (constant float (0.5)))\n"
1534 " (expression vec2 *\n"
1535 " (expression vec2 sqrt\n"
1536 " (expression vec2 -\n"
1537 " (constant float (1.0))\n"
1538 " (expression vec2 abs (var_ref x))))\n"
1539 " (expression vec2 +\n"
1540 " (constant float (1.5707288))\n"
1541 " (expression vec2 *\n"
1542 " (expression vec2 abs (var_ref x))\n"
1543 " (expression vec2 +\n"
1544 " (constant float (-0.2121144))\n"
1545 " (expression vec2 *\n"
1546 " (constant float (0.0742610))\n"
1547 " (expression vec2 abs (var_ref x))))))))))))\n"
1548 "\n"
1549 " (signature vec3\n"
1550 " (parameters\n"
1551 " (declare (in) vec3 x))\n"
1552 " ((return (expression vec3 *\n"
1553 " (expression vec3 sign (var_ref x))\n"
1554 " (expression vec3 -\n"
1555 " (expression float *\n"
1556 " (constant float (3.1415926))\n"
1557 " (constant float (0.5)))\n"
1558 " (expression vec3 *\n"
1559 " (expression vec3 sqrt\n"
1560 " (expression vec3 -\n"
1561 " (constant float (1.0))\n"
1562 " (expression vec3 abs (var_ref x))))\n"
1563 " (expression vec3 +\n"
1564 " (constant float (1.5707288))\n"
1565 " (expression vec3 *\n"
1566 " (expression vec3 abs (var_ref x))\n"
1567 " (expression vec3 +\n"
1568 " (constant float (-0.2121144))\n"
1569 " (expression vec3 *\n"
1570 " (constant float (0.0742610))\n"
1571 " (expression vec3 abs (var_ref x))))))))))))\n"
1572 "\n"
1573 " (signature vec4\n"
1574 " (parameters\n"
1575 " (declare (in) vec4 x))\n"
1576 " ((return (expression vec4 *\n"
1577 " (expression vec4 sign (var_ref x))\n"
1578 " (expression vec4 -\n"
1579 " (expression float *\n"
1580 " (constant float (3.1415926))\n"
1581 " (constant float (0.5)))\n"
1582 " (expression vec4 *\n"
1583 " (expression vec4 sqrt\n"
1584 " (expression vec4 -\n"
1585 " (constant float (1.0))\n"
1586 " (expression vec4 abs (var_ref x))))\n"
1587 " (expression vec4 +\n"
1588 " (constant float (1.5707288))\n"
1589 " (expression vec4 *\n"
1590 " (expression vec4 abs (var_ref x))\n"
1591 " (expression vec4 +\n"
1592 " (constant float (-0.2121144))\n"
1593 " (expression vec4 *\n"
1594 " (constant float (0.0742610))\n"
1595 " (expression vec4 abs (var_ref x))))))))))))\n"
1596 "))\n"
1597 ""
1598;
1599static const char *builtin_texture1DProj =
1600 "((function texture1DProj\n"
1601 " (signature vec4\n"
1602 " (parameters\n"
1603 " (declare (in) sampler1D sampler)\n"
1604 " (declare (in) vec2 P) )\n"
1605 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () ))))\n"
1606 "\n"
1607 " (signature vec4\n"
1608 " (parameters\n"
1609 " (declare (in) sampler1D sampler)\n"
1610 " (declare (in) vec4 P) )\n"
1611 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
1612 "\n"
1613 " (signature vec4\n"
1614 " (parameters\n"
1615 " (declare (in) sampler1D sampler)\n"
1616 " (declare (in) vec2 P) \n"
1617 " (declare (in) float bias) )\n"
1618 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref bias) ))))\n"
1619 "\n"
1620 " (signature vec4\n"
1621 " (parameters\n"
1622 " (declare (in) sampler1D sampler)\n"
1623 " (declare (in) vec4 P) \n"
1624 " (declare (in) float bias) )\n"
1625 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
1626 "\n"
1627 "))\n"
1628 ""
1629;
1630static const char *builtin_lessThan =
1631 "((function lessThan\n"
1632 " (signature bvec2\n"
1633 " (parameters\n"
1634 " (declare (in) vec2 arg0)\n"
1635 " (declare (in) vec2 arg1))\n"
1636 " ((declare () bvec2 temp)\n"
1637 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1638 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1639 " (return (var_ref temp))))\n"
1640 "\n"
1641 " (signature bvec3\n"
1642 " (parameters\n"
1643 " (declare (in) vec3 arg0)\n"
1644 " (declare (in) vec3 arg1))\n"
1645 " ((declare () bvec3 temp)\n"
1646 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1647 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1648 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
1649 " (return (var_ref temp))))\n"
1650 "\n"
1651 " (signature bvec4\n"
1652 " (parameters\n"
1653 " (declare (in) vec4 arg0)\n"
1654 " (declare (in) vec4 arg1))\n"
1655 " ((declare () bvec4 temp)\n"
1656 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1657 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1658 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
1659 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
1660 " (return (var_ref temp))))\n"
1661 "\n"
1662 " (signature bvec2\n"
1663 " (parameters\n"
1664 " (declare (in) ivec2 arg0)\n"
1665 " (declare (in) ivec2 arg1))\n"
1666 " ((declare () bvec2 temp)\n"
1667 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1668 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1669 " (return (var_ref temp))))\n"
1670 "\n"
1671 " (signature bvec3\n"
1672 " (parameters\n"
1673 " (declare (in) ivec3 arg0)\n"
1674 " (declare (in) ivec3 arg1))\n"
1675 " ((declare () bvec3 temp)\n"
1676 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1677 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1678 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
1679 " (return (var_ref temp))))\n"
1680 "\n"
1681 " (signature bvec4\n"
1682 " (parameters\n"
1683 " (declare (in) ivec4 arg0)\n"
1684 " (declare (in) ivec4 arg1))\n"
1685 " ((declare () bvec4 temp)\n"
1686 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1687 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1688 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
1689 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
1690 " (return (var_ref temp))))\n"
1691 "\n"
1692 " (signature bvec2\n"
1693 " (parameters\n"
1694 " (declare (in) uvec2 arg0)\n"
1695 " (declare (in) uvec2 arg1))\n"
1696 " ((declare () bvec2 temp)\n"
1697 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1698 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1699 " (return (var_ref temp))))\n"
1700 "\n"
1701 " (signature bvec3\n"
1702 " (parameters\n"
1703 " (declare (in) uvec3 arg0)\n"
1704 " (declare (in) uvec3 arg1))\n"
1705 " ((declare () bvec3 temp)\n"
1706 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1707 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1708 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
1709 " (return (var_ref temp))))\n"
1710 "\n"
1711 " (signature bvec4\n"
1712 " (parameters\n"
1713 " (declare (in) uvec4 arg0)\n"
1714 " (declare (in) uvec4 arg1))\n"
1715 " ((declare () bvec4 temp)\n"
1716 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1717 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1718 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
1719 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
1720 " (return (var_ref temp))))\n"
1721 "))\n"
1722 ""
1723;
1724static const char *builtin_shadow2DProj =
1725 "((function shadow2DProj\n"
1726 " (signature vec4\n"
1727 " (parameters\n"
1728 " (declare (in) sampler2DShadow sampler)\n"
1729 " (declare (in) vec4 P) )\n"
1730 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n"
1731 "\n"
1732 " (signature vec4\n"
1733 " (parameters\n"
1734 " (declare (in) sampler2DShadow sampler)\n"
1735 " (declare (in) vec4 P) \n"
1736 " (declare (in) float bias) )\n"
1737 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n"
1738 "\n"
1739 "))\n"
1740 ""
1741;
1742static const char *builtin_textureLod =
1743 "((function textureLod\n"
1744 " (signature vec4\n"
1745 " (parameters\n"
1746 " (declare (in) sampler1D sampler)\n"
1747 " (declare (in) float P) \n"
1748 " (declare (in) float lod) )\n"
1749 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1750 "\n"
1751 " (signature ivec4\n"
1752 " (parameters\n"
1753 " (declare (in) isampler1D sampler)\n"
1754 " (declare (in) float P) \n"
1755 " (declare (in) float lod) )\n"
1756 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1757 "\n"
1758 " (signature uvec4\n"
1759 " (parameters\n"
1760 " (declare (in) usampler1D sampler)\n"
1761 " (declare (in) float P) \n"
1762 " (declare (in) float lod) )\n"
1763 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1764 "\n"
1765 " (signature vec4\n"
1766 " (parameters\n"
1767 " (declare (in) sampler2D sampler)\n"
1768 " (declare (in) vec2 P) \n"
1769 " (declare (in) float lod) )\n"
1770 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1771 "\n"
1772 " (signature ivec4\n"
1773 " (parameters\n"
1774 " (declare (in) isampler2D sampler)\n"
1775 " (declare (in) vec2 P) \n"
1776 " (declare (in) float lod) )\n"
1777 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1778 "\n"
1779 " (signature uvec4\n"
1780 " (parameters\n"
1781 " (declare (in) usampler2D sampler)\n"
1782 " (declare (in) vec2 P) \n"
1783 " (declare (in) float lod) )\n"
1784 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1785 "\n"
1786 " (signature vec4\n"
1787 " (parameters\n"
1788 " (declare (in) sampler3D sampler)\n"
1789 " (declare (in) vec3 P) \n"
1790 " (declare (in) float lod) )\n"
1791 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1792 "\n"
1793 " (signature ivec4\n"
1794 " (parameters\n"
1795 " (declare (in) isampler3D sampler)\n"
1796 " (declare (in) vec3 P) \n"
1797 " (declare (in) float lod) )\n"
1798 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1799 "\n"
1800 " (signature uvec4\n"
1801 " (parameters\n"
1802 " (declare (in) usampler3D sampler)\n"
1803 " (declare (in) vec3 P) \n"
1804 " (declare (in) float lod) )\n"
1805 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1806 "\n"
1807 " (signature vec4\n"
1808 " (parameters\n"
1809 " (declare (in) samplerCube sampler)\n"
1810 " (declare (in) vec3 P) \n"
1811 " (declare (in) float lod) )\n"
1812 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1813 "\n"
1814 " (signature ivec4\n"
1815 " (parameters\n"
1816 " (declare (in) isamplerCube sampler)\n"
1817 " (declare (in) vec3 P) \n"
1818 " (declare (in) float lod) )\n"
1819 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1820 "\n"
1821 " (signature uvec4\n"
1822 " (parameters\n"
1823 " (declare (in) usamplerCube sampler)\n"
1824 " (declare (in) vec3 P) \n"
1825 " (declare (in) float lod) )\n"
1826 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1827 "\n"
1828 " (signature vec4\n"
1829 " (parameters\n"
1830 " (declare (in) sampler1DArray sampler)\n"
1831 " (declare (in) vec2 P) \n"
1832 " (declare (in) float lod) )\n"
1833 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1834 "\n"
1835 " (signature ivec4\n"
1836 " (parameters\n"
1837 " (declare (in) isampler1DArray sampler)\n"
1838 " (declare (in) vec2 P) \n"
1839 " (declare (in) float lod) )\n"
1840 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1841 "\n"
1842 " (signature uvec4\n"
1843 " (parameters\n"
1844 " (declare (in) usampler1DArray sampler)\n"
1845 " (declare (in) vec2 P) \n"
1846 " (declare (in) float lod) )\n"
1847 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1848 "\n"
1849 " (signature vec4\n"
1850 " (parameters\n"
1851 " (declare (in) sampler2DArray sampler)\n"
1852 " (declare (in) vec3 P) \n"
1853 " (declare (in) float lod) )\n"
1854 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1855 "\n"
1856 " (signature ivec4\n"
1857 " (parameters\n"
1858 " (declare (in) isampler2DArray sampler)\n"
1859 " (declare (in) vec3 P) \n"
1860 " (declare (in) float lod) )\n"
1861 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1862 "\n"
1863 " (signature uvec4\n"
1864 " (parameters\n"
1865 " (declare (in) usampler2DArray sampler)\n"
1866 " (declare (in) vec3 P) \n"
1867 " (declare (in) float lod) )\n"
1868 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
1869 "\n"
1870 "))\n"
1871 ""
1872;
1873static const char *builtin_faceforward =
1874 "((function faceforward\n"
1875 " (signature float\n"
1876 " (parameters\n"
1877 " (declare (in) float N)\n"
1878 " (declare (in) float I)\n"
1879 " (declare (in) float Nref))\n"
1880 " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n"
1881 " ((return (var_ref N)))\n"
1882 " ((return (expression float neg (var_ref N)))))))\n"
1883 "\n"
1884 " (signature vec2\n"
1885 " (parameters\n"
1886 " (declare (in) vec2 N)\n"
1887 " (declare (in) vec2 I)\n"
1888 " (declare (in) vec2 Nref))\n"
1889 " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n"
1890 " ((return (var_ref N)))\n"
1891 " ((return (expression vec2 neg (var_ref N)))))))\n"
1892 "\n"
1893 " (signature vec3\n"
1894 " (parameters\n"
1895 " (declare (in) vec3 N)\n"
1896 " (declare (in) vec3 I)\n"
1897 " (declare (in) vec3 Nref))\n"
1898 " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n"
1899 " ((return (var_ref N)))\n"
1900 " ((return (expression vec3 neg (var_ref N)))))))\n"
1901 "\n"
1902 " (signature vec4\n"
1903 " (parameters\n"
1904 " (declare (in) vec4 N)\n"
1905 " (declare (in) vec4 I)\n"
1906 " (declare (in) vec4 Nref))\n"
1907 " ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))\n"
1908 " ((return (var_ref N)))\n"
1909 " ((return (expression vec4 neg (var_ref N)))))))\n"
1910 "))\n"
1911 ""
1912;
1913static const char *builtin_abs =
1914 "((function abs\n"
1915 " (signature float\n"
1916 " (parameters\n"
1917 " (declare (in) float arg0))\n"
1918 " ((return (expression float abs (var_ref arg0)))))\n"
1919 "\n"
1920 " (signature vec2\n"
1921 " (parameters\n"
1922 " (declare (in) vec2 arg0))\n"
1923 " ((return (expression vec2 abs (var_ref arg0)))))\n"
1924 "\n"
1925 " (signature vec3\n"
1926 " (parameters\n"
1927 " (declare (in) vec3 arg0))\n"
1928 " ((return (expression vec3 abs (var_ref arg0)))))\n"
1929 "\n"
1930 " (signature vec4\n"
1931 " (parameters\n"
1932 " (declare (in) vec4 arg0))\n"
1933 " ((return (expression vec4 abs (var_ref arg0)))))\n"
1934 "))\n"
1935 ""
1936;
1937static const char *builtin_log2 =
1938 "((function log2\n"
1939 " (signature float\n"
1940 " (parameters\n"
1941 " (declare (in) float arg0))\n"
1942 " ((return (expression float log2 (var_ref arg0)))))\n"
1943 "\n"
1944 " (signature vec2\n"
1945 " (parameters\n"
1946 " (declare (in) vec2 arg0))\n"
1947 " ((return (expression vec2 log2 (var_ref arg0)))))\n"
1948 "\n"
1949 " (signature vec3\n"
1950 " (parameters\n"
1951 " (declare (in) vec3 arg0))\n"
1952 " ((return (expression vec3 log2 (var_ref arg0)))))\n"
1953 "\n"
1954 " (signature vec4\n"
1955 " (parameters\n"
1956 " (declare (in) vec4 arg0))\n"
1957 " ((return (expression vec4 log2 (var_ref arg0)))))\n"
1958 "))\n"
1959 ""
1960;
1961static const char *builtin_shadow2DRect =
1962 "((function shadow2DRect\n"
1963 " (signature vec4\n"
1964 " (parameters\n"
1965 " (declare (in) sampler2DRectShadow sampler)\n"
1966 " (declare (in) vec3 P) )\n"
1967 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n"
1968 "\n"
1969 "))\n"
1970 ""
1971;
1972static const char *builtin_lessThanEqual =
1973 "((function lessThanEqual\n"
1974 " (signature bvec2\n"
1975 " (parameters\n"
1976 " (declare (in) vec2 arg0)\n"
1977 " (declare (in) vec2 arg1))\n"
1978 " ((declare () bvec2 temp)\n"
1979 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1980 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1981 " (return (var_ref temp))))\n"
1982 "\n"
1983 " (signature bvec3\n"
1984 " (parameters\n"
1985 " (declare (in) vec3 arg0)\n"
1986 " (declare (in) vec3 arg1))\n"
1987 " ((declare () bvec3 temp)\n"
1988 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1989 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
1990 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
1991 " (return (var_ref temp))))\n"
1992 "\n"
1993 " (signature bvec4\n"
1994 " (parameters\n"
1995 " (declare (in) vec4 arg0)\n"
1996 " (declare (in) vec4 arg1))\n"
1997 " ((declare () bvec4 temp)\n"
1998 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
1999 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2000 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2001 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
2002 " (return (var_ref temp))))\n"
2003 "\n"
2004 " (signature bvec2\n"
2005 " (parameters\n"
2006 " (declare (in) ivec2 arg0)\n"
2007 " (declare (in) ivec2 arg1))\n"
2008 " ((declare () bvec2 temp)\n"
2009 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2010 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2011 " (return (var_ref temp))))\n"
2012 "\n"
2013 " (signature bvec3\n"
2014 " (parameters\n"
2015 " (declare (in) ivec3 arg0)\n"
2016 " (declare (in) ivec3 arg1))\n"
2017 " ((declare () bvec3 temp)\n"
2018 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2019 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2020 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2021 " (return (var_ref temp))))\n"
2022 "\n"
2023 " (signature bvec4\n"
2024 " (parameters\n"
2025 " (declare (in) ivec4 arg0)\n"
2026 " (declare (in) ivec4 arg1))\n"
2027 " ((declare () bvec4 temp)\n"
2028 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2029 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2030 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2031 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
2032 " (return (var_ref temp))))\n"
2033 "\n"
2034 " (signature bvec2\n"
2035 " (parameters\n"
2036 " (declare (in) uvec2 arg0)\n"
2037 " (declare (in) uvec2 arg1))\n"
2038 " ((declare () bvec2 temp)\n"
2039 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2040 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2041 " (return (var_ref temp))))\n"
2042 "\n"
2043 " (signature bvec3\n"
2044 " (parameters\n"
2045 " (declare (in) uvec3 arg0)\n"
2046 " (declare (in) uvec3 arg1))\n"
2047 " ((declare () bvec3 temp)\n"
2048 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2049 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2050 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2051 " (return (var_ref temp))))\n"
2052 "\n"
2053 " (signature bvec4\n"
2054 " (parameters\n"
2055 " (declare (in) uvec4 arg0)\n"
2056 " (declare (in) uvec4 arg1))\n"
2057 " ((declare () bvec4 temp)\n"
2058 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2059 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2060 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2061 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
2062 " (return (var_ref temp))))\n"
2063 "))\n"
2064 ""
2065;
2066static const char *builtin_transpose =
2067 "((function transpose\n"
2068 " (signature mat2\n"
2069 " (parameters\n"
2070 " (declare (in) mat2 m))\n"
2071 " ((declare () mat2 t)\n"
2072 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2073 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2074 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2075 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2076 "(return (var_ref t))))\n"
2077 "\n"
2078 " (signature mat3x2\n"
2079 " (parameters\n"
2080 " (declare (in) mat2x3 m))\n"
2081 " ((declare () mat3x2 t)\n"
2082 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2083 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2084 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n"
2085 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2086 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2087 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n"
2088 "(return (var_ref t))))\n"
2089 "\n"
2090 " (signature mat4x2\n"
2091 " (parameters\n"
2092 " (declare (in) mat2x4 m))\n"
2093 " ((declare () mat4x2 t)\n"
2094 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2095 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2096 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n"
2097 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n"
2098 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2099 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2100 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n"
2101 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n"
2102 "(return (var_ref t))))\n"
2103 "\n"
2104 " (signature mat2x3\n"
2105 " (parameters\n"
2106 " (declare (in) mat3x2 m))\n"
2107 " ((declare () mat2x3 t)\n"
2108 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2109 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2110 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2111 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2112 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n"
2113 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n"
2114 "(return (var_ref t))))\n"
2115 "\n"
2116 " (signature mat3\n"
2117 " (parameters\n"
2118 " (declare (in) mat3 m))\n"
2119 " ((declare () mat3 t)\n"
2120 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2121 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2122 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n"
2123 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2124 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2125 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n"
2126 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n"
2127 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n"
2128 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n"
2129 "(return (var_ref t))))\n"
2130 "\n"
2131 " (signature mat4x3\n"
2132 " (parameters\n"
2133 " (declare (in) mat3x4 m))\n"
2134 " ((declare () mat4x3 t)\n"
2135 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2136 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2137 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n"
2138 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n"
2139 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2140 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2141 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n"
2142 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n"
2143 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n"
2144 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n"
2145 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n"
2146 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n"
2147 "(return (var_ref t))))\n"
2148 "\n"
2149 " (signature mat2x4\n"
2150 " (parameters\n"
2151 " (declare (in) mat4x2 m))\n"
2152 " ((declare () mat2x4 t)\n"
2153 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2154 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2155 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2156 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2157 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n"
2158 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n"
2159 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n"
2160 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n"
2161 "(return (var_ref t))))\n"
2162 "\n"
2163 " (signature mat3x4\n"
2164 " (parameters\n"
2165 " (declare (in) mat4x3 m))\n"
2166 " ((declare () mat3x4 t)\n"
2167 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2168 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2169 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n"
2170 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2171 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2172 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n"
2173 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n"
2174 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n"
2175 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n"
2176 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n"
2177 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n"
2178 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n"
2179 "(return (var_ref t))))\n"
2180 "\n"
2181 " (signature mat4\n"
2182 " (parameters\n"
2183 " (declare (in) mat4 m))\n"
2184 " ((declare () mat4 t)\n"
2185 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0))))) \n"
2186 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0))))) \n"
2187 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0))))) \n"
2188 " (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0))))) \n"
2189 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1))))) \n"
2190 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1))))) \n"
2191 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1))))) \n"
2192 " (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1))))) \n"
2193 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2))))) \n"
2194 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2))))) \n"
2195 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2))))) \n"
2196 " (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2))))) \n"
2197 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3))))) \n"
2198 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3))))) \n"
2199 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3))))) \n"
2200 " (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (3))))) \n"
2201 "(return (var_ref t))))\n"
2202 ")\n"
2203 "\n"
2204 ")\n"
2205 "\n"
2206 ""
2207;
2208static const char *builtin_step =
2209 "((function step\n"
2210 " (signature float\n"
2211 " (parameters\n"
2212 " (declare (in) float edge)\n"
2213 " (declare (in) float x))\n"
2214 " ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge))))))\n"
2215 "\n"
2216 " (signature vec2\n"
2217 " (parameters\n"
2218 " (declare (in) float edge)\n"
2219 " (declare (in) vec2 x))\n"
2220 " ((declare () vec2 t)\n"
2221 " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n"
2222 " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n"
2223 " (return (var_ref t))))\n"
2224 "\n"
2225 " (signature vec3\n"
2226 " (parameters\n"
2227 " (declare (in) float edge)\n"
2228 " (declare (in) vec3 x))\n"
2229 " ((declare () vec3 t)\n"
2230 " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n"
2231 " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n"
2232 " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n"
2233 " (return (var_ref t))))\n"
2234 "\n"
2235 " (signature vec4\n"
2236 " (parameters\n"
2237 " (declare (in) float edge)\n"
2238 " (declare (in) vec4 x))\n"
2239 " ((declare () vec4 t)\n"
2240 " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))\n"
2241 " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))\n"
2242 " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))\n"
2243 " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))\n"
2244 " (return (var_ref t))))\n"
2245 "\n"
2246 " (signature vec2\n"
2247 " (parameters\n"
2248 " (declare (in) vec2 edge)\n"
2249 " (declare (in) vec2 x))\n"
2250 " ((declare () vec2 t)\n"
2251 " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n"
2252 " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n"
2253 " (return (var_ref t))))\n"
2254 "\n"
2255 " (signature vec3\n"
2256 " (parameters\n"
2257 " (declare (in) vec3 edge)\n"
2258 " (declare (in) vec3 x))\n"
2259 " ((declare () vec3 t)\n"
2260 " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n"
2261 " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n"
2262 " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))\n"
2263 " (return (var_ref t))))\n"
2264 "\n"
2265 " (signature vec4\n"
2266 " (parameters\n"
2267 " (declare (in) vec4 edge)\n"
2268 " (declare (in) vec4 x))\n"
2269 " ((declare () vec4 t)\n"
2270 " (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))\n"
2271 " (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))\n"
2272 " (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge)))))\n"
2273 " (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))\n"
2274 " (return (var_ref t))))\n"
2275 "))\n"
2276 "\n"
2277 ""
2278;
2279static const char *builtin_sinh =
2280 "((function sinh\n"
2281 " (signature float\n"
2282 " (parameters\n"
2283 " (declare (in) float x))\n"
2284 " ((return (expression float * (constant float (0.5))\n"
2285 " (expression float -\n"
2286 " (expression float exp (var_ref x))\n"
2287 " (expression float exp (expression float neg (var_ref x))))))))\n"
2288 " (signature vec2\n"
2289 " (parameters\n"
2290 " (declare (in) vec2 x))\n"
2291 " ((return (expression vec2 * (constant vec2 (0.5))\n"
2292 " (expression vec2 -\n"
2293 " (expression vec2 exp (var_ref x))\n"
2294 " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n"
2295 " (signature vec3\n"
2296 " (parameters\n"
2297 " (declare (in) vec3 x))\n"
2298 " ((return (expression vec3 * (constant vec3 (0.5))\n"
2299 " (expression vec3 -\n"
2300 " (expression vec3 exp (var_ref x))\n"
2301 " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n"
2302 " (signature vec4\n"
2303 " (parameters\n"
2304 " (declare (in) vec4 x))\n"
2305 " ((return (expression vec4 * (constant vec4 (0.5))\n"
2306 " (expression vec4 -\n"
2307 " (expression vec4 exp (var_ref x))\n"
2308 " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n"
2309 "))\n"
2310 ""
2311;
2312static const char *builtin_cos =
2313 "((function cos\n"
2314 " (signature float\n"
2315 " (parameters\n"
2316 " (declare (in) float angle))\n"
2317 " ((return (expression float cos (var_ref angle)))))\n"
2318 "\n"
2319 " (signature vec2\n"
2320 " (parameters\n"
2321 " (declare (in) vec2 angle))\n"
2322 " ((return (expression vec2 cos (var_ref angle)))))\n"
2323 "\n"
2324 " (signature vec3\n"
2325 " (parameters\n"
2326 " (declare (in) vec3 angle))\n"
2327 " ((return (expression vec3 cos (var_ref angle)))))\n"
2328 "\n"
2329 " (signature vec4\n"
2330 " (parameters\n"
2331 " (declare (in) vec4 angle))\n"
2332 " ((return (expression vec4 cos (var_ref angle)))))\n"
2333 "))\n"
2334 ""
2335;
2336static const char *builtin_shadow2DProjLod =
2337 "((function shadow2DProjLod\n"
2338 " (signature vec4\n"
2339 " (parameters\n"
2340 " (declare (in) sampler2DShadow sampler)\n"
2341 " (declare (in) vec4 P) \n"
2342 " (declare (in) float lod) )\n"
2343 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref lod) ))))\n"
2344 "\n"
2345 "))\n"
2346 ""
2347;
2348static const char *builtin_shadow2DArray =
2349 "((function shadow2DArray\n"
2350 " (signature vec4\n"
2351 " (parameters\n"
2352 " (declare (in) sampler2DArrayShadow sampler)\n"
2353 " (declare (in) vec4 P) )\n"
2354 " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) 1 (swiz w (var_ref P)) ))))\n"
2355 "\n"
2356 "))\n"
2357 ""
2358;
2359static const char *builtin_equal =
2360 "((function equal\n"
2361 " (signature bvec2\n"
2362 " (parameters\n"
2363 " (declare (in) vec2 arg0)\n"
2364 " (declare (in) vec2 arg1))\n"
2365 " ((declare () bvec2 temp)\n"
2366 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2367 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2368 " (return (var_ref temp))))\n"
2369 "\n"
2370 " (signature bvec3\n"
2371 " (parameters\n"
2372 " (declare (in) vec3 arg0)\n"
2373 " (declare (in) vec3 arg1))\n"
2374 " ((declare () bvec3 temp)\n"
2375 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2376 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2377 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2378 " (return (var_ref temp))))\n"
2379 "\n"
2380 " (signature bvec4\n"
2381 " (parameters\n"
2382 " (declare (in) vec4 arg0)\n"
2383 " (declare (in) vec4 arg1))\n"
2384 " ((declare () bvec4 temp)\n"
2385 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2386 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2387 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2388 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
2389 " (return (var_ref temp))))\n"
2390 "\n"
2391 " (signature bvec2\n"
2392 " (parameters\n"
2393 " (declare (in) ivec2 arg0)\n"
2394 " (declare (in) ivec2 arg1))\n"
2395 " ((declare () bvec2 temp)\n"
2396 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2397 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2398 " (return (var_ref temp))))\n"
2399 "\n"
2400 " (signature bvec3\n"
2401 " (parameters\n"
2402 " (declare (in) ivec3 arg0)\n"
2403 " (declare (in) ivec3 arg1))\n"
2404 " ((declare () bvec3 temp)\n"
2405 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2406 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2407 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2408 " (return (var_ref temp))))\n"
2409 "\n"
2410 " (signature bvec4\n"
2411 " (parameters\n"
2412 " (declare (in) ivec4 arg0)\n"
2413 " (declare (in) ivec4 arg1))\n"
2414 " ((declare () bvec4 temp)\n"
2415 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2416 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2417 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2418 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
2419 " (return (var_ref temp))))\n"
2420 "\n"
2421 " (signature bvec2\n"
2422 " (parameters\n"
2423 " (declare (in) uvec2 arg0)\n"
2424 " (declare (in) uvec2 arg1))\n"
2425 " ((declare () bvec2 temp)\n"
2426 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2427 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2428 " (return (var_ref temp))))\n"
2429 "\n"
2430 " (signature bvec3\n"
2431 " (parameters\n"
2432 " (declare (in) uvec3 arg0)\n"
2433 " (declare (in) uvec3 arg1))\n"
2434 " ((declare () bvec3 temp)\n"
2435 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2436 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2437 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2438 " (return (var_ref temp))))\n"
2439 "\n"
2440 " (signature bvec4\n"
2441 " (parameters\n"
2442 " (declare (in) uvec4 arg0)\n"
2443 " (declare (in) uvec4 arg1))\n"
2444 " ((declare () bvec4 temp)\n"
2445 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
2446 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
2447 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
2448 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
2449 " (return (var_ref temp))))\n"
2450 "))\n"
2451 ""
2452;
2453static const char *builtin_length =
2454 "((function length\n"
2455 " (signature float\n"
2456 " (parameters\n"
2457 " (declare (in) float arg0))\n"
2458 " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n"
2459 "\n"
2460 " (signature float\n"
2461 " (parameters\n"
2462 " (declare (in) vec2 arg0))\n"
2463 " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n"
2464 "\n"
2465 " (signature float\n"
2466 " (parameters\n"
2467 " (declare (in) vec3 arg0))\n"
2468 " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n"
2469 "\n"
2470 " (signature float\n"
2471 " (parameters\n"
2472 " (declare (in) vec4 arg0))\n"
2473 " ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))\n"
2474 "))\n"
2475 ""
2476;
2477static const char *builtin_acos =
2478 "((function acos\n"
2479 " (signature float\n"
2480 " (parameters\n"
2481 " (declare (in) float x))\n"
2482 " ((return (expression float - (constant float (1.5707963))\n"
2483 " (call asin ((var_ref x)))))))\n"
2484 " (signature vec2\n"
2485 " (parameters\n"
2486 " (declare (in) vec2 x))\n"
2487 " ((return (expression vec2 - (constant float (1.5707963))\n"
2488 " (call asin ((var_ref x)))))))\n"
2489 " (signature vec3\n"
2490 " (parameters\n"
2491 " (declare (in) vec3 x))\n"
2492 " ((return (expression vec3 - (constant float (1.5707963))\n"
2493 " (call asin ((var_ref x)))))))\n"
2494 " (signature vec4\n"
2495 " (parameters\n"
2496 " (declare (in) vec4 x))\n"
2497 " ((return (expression vec4 - (constant float (1.5707963))\n"
2498 " (call asin ((var_ref x)))))))\n"
2499 "))\n"
2500 ""
2501;
2502static const char *builtin_matrixCompMult =
2503 "((function matrixCompMult\n"
2504 " (signature mat2\n"
2505 " (parameters\n"
2506 " (declare (in) mat2 x)\n"
2507 " (declare (in) mat2 y))\n"
2508 " ((declare () mat2 z)\n"
2509 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2510 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2511 "(return (var_ref z))))\n"
2512 "\n"
2513 " (signature mat3\n"
2514 " (parameters\n"
2515 " (declare (in) mat3 x)\n"
2516 " (declare (in) mat3 y))\n"
2517 " ((declare () mat3 z)\n"
2518 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2519 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2520 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) \n"
2521 "(return (var_ref z))))\n"
2522 "\n"
2523 " (signature mat4\n"
2524 " (parameters\n"
2525 " (declare (in) mat4 x)\n"
2526 " (declare (in) mat4 y))\n"
2527 " ((declare () mat4 z)\n"
2528 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2529 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2530 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) \n"
2531 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (3))) (expression vec4 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3))))) \n"
2532 "(return (var_ref z))))\n"
2533 "\n"
2534 " (signature mat2x3\n"
2535 " (parameters\n"
2536 " (declare (in) mat2x3 x)\n"
2537 " (declare (in) mat2x3 y))\n"
2538 " ((declare () mat2x3 z)\n"
2539 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2540 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2541 "(return (var_ref z))))\n"
2542 "\n"
2543 " (signature mat3x2\n"
2544 " (parameters\n"
2545 " (declare (in) mat3x2 x)\n"
2546 " (declare (in) mat3x2 y))\n"
2547 " ((declare () mat3x2 z)\n"
2548 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2549 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2550 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) \n"
2551 "(return (var_ref z))))\n"
2552 "\n"
2553 " (signature mat2x4\n"
2554 " (parameters\n"
2555 " (declare (in) mat2x4 x)\n"
2556 " (declare (in) mat2x4 y))\n"
2557 " ((declare () mat2x4 z)\n"
2558 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2559 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2560 "(return (var_ref z))))\n"
2561 "\n"
2562 " (signature mat4x2\n"
2563 " (parameters\n"
2564 " (declare (in) mat4x2 x)\n"
2565 " (declare (in) mat4x2 y))\n"
2566 " ((declare () mat4x2 z)\n"
2567 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2568 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2569 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) \n"
2570 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (3))) (expression vec2 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3))))) \n"
2571 "(return (var_ref z))))\n"
2572 "\n"
2573 " (signature mat3x4\n"
2574 " (parameters\n"
2575 " (declare (in) mat3x4 x)\n"
2576 " (declare (in) mat3x4 y))\n"
2577 " ((declare () mat3x4 z)\n"
2578 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2579 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2580 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) \n"
2581 "(return (var_ref z))))\n"
2582 "\n"
2583 " (signature mat4x3\n"
2584 " (parameters\n"
2585 " (declare (in) mat4x3 x)\n"
2586 " (declare (in) mat4x3 y))\n"
2587 " ((declare () mat4x3 z)\n"
2588 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0))))) \n"
2589 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1))))) \n"
2590 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2))))) \n"
2591 " (assign (constant bool (1)) (array_ref (var_ref z) (constant int (3))) (expression vec3 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3))))) \n"
2592 "(return (var_ref z))))\n"
2593 "))\n"
2594 ""
2595;
2596static const char *builtin_pow =
2597 "((function pow\n"
2598 " (signature float\n"
2599 " (parameters\n"
2600 " (declare (in) float arg0)\n"
2601 " (declare (in) float arg1))\n"
2602 " ((return (expression float pow (var_ref arg0) (var_ref arg1)))))\n"
2603 "\n"
2604 " (signature vec2\n"
2605 " (parameters\n"
2606 " (declare (in) vec2 arg0)\n"
2607 " (declare (in) vec2 arg1))\n"
2608 " ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))\n"
2609 "\n"
2610 " (signature vec3\n"
2611 " (parameters\n"
2612 " (declare (in) vec3 arg0)\n"
2613 " (declare (in) vec3 arg1))\n"
2614 " ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))\n"
2615 "\n"
2616 " (signature vec4\n"
2617 " (parameters\n"
2618 " (declare (in) vec4 arg0)\n"
2619 " (declare (in) vec4 arg1))\n"
2620 " ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))\n"
2621 "))\n"
2622 ""
2623;
2624static const char *builtin_texture2DProjLod =
2625 "((function texture2DProjLod\n"
2626 " (signature vec4\n"
2627 " (parameters\n"
2628 " (declare (in) sampler2D sampler)\n"
2629 " (declare (in) vec3 P) \n"
2630 " (declare (in) float lod) )\n"
2631 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n"
2632 "\n"
2633 " (signature vec4\n"
2634 " (parameters\n"
2635 " (declare (in) sampler2D sampler)\n"
2636 " (declare (in) vec4 P) \n"
2637 " (declare (in) float lod) )\n"
2638 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2639 "\n"
2640 "))\n"
2641 ""
2642;
2643static const char *builtin_textureProjLod =
2644 "((function textureProjLod\n"
2645 " (signature vec4\n"
2646 " (parameters\n"
2647 " (declare (in) sampler1D sampler)\n"
2648 " (declare (in) vec2 P) \n"
2649 " (declare (in) float lod) )\n"
2650 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n"
2651 "\n"
2652 " (signature ivec4\n"
2653 " (parameters\n"
2654 " (declare (in) isampler1D sampler)\n"
2655 " (declare (in) vec2 P) \n"
2656 " (declare (in) float lod) )\n"
2657 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n"
2658 "\n"
2659 " (signature uvec4\n"
2660 " (parameters\n"
2661 " (declare (in) usampler1D sampler)\n"
2662 " (declare (in) vec2 P) \n"
2663 " (declare (in) float lod) )\n"
2664 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n"
2665 "\n"
2666 " (signature vec4\n"
2667 " (parameters\n"
2668 " (declare (in) sampler1D sampler)\n"
2669 " (declare (in) vec4 P) \n"
2670 " (declare (in) float lod) )\n"
2671 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2672 "\n"
2673 " (signature ivec4\n"
2674 " (parameters\n"
2675 " (declare (in) isampler1D sampler)\n"
2676 " (declare (in) vec4 P) \n"
2677 " (declare (in) float lod) )\n"
2678 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2679 "\n"
2680 " (signature uvec4\n"
2681 " (parameters\n"
2682 " (declare (in) usampler1D sampler)\n"
2683 " (declare (in) vec4 P) \n"
2684 " (declare (in) float lod) )\n"
2685 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2686 "\n"
2687 " (signature vec4\n"
2688 " (parameters\n"
2689 " (declare (in) sampler2D sampler)\n"
2690 " (declare (in) vec3 P) \n"
2691 " (declare (in) float lod) )\n"
2692 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n"
2693 "\n"
2694 " (signature ivec4\n"
2695 " (parameters\n"
2696 " (declare (in) isampler2D sampler)\n"
2697 " (declare (in) vec3 P) \n"
2698 " (declare (in) float lod) )\n"
2699 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n"
2700 "\n"
2701 " (signature uvec4\n"
2702 " (parameters\n"
2703 " (declare (in) usampler2D sampler)\n"
2704 " (declare (in) vec3 P) \n"
2705 " (declare (in) float lod) )\n"
2706 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz z (var_ref P)) () (var_ref lod) ))))\n"
2707 "\n"
2708 " (signature vec4\n"
2709 " (parameters\n"
2710 " (declare (in) sampler2D sampler)\n"
2711 " (declare (in) vec4 P) \n"
2712 " (declare (in) float lod) )\n"
2713 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2714 "\n"
2715 " (signature ivec4\n"
2716 " (parameters\n"
2717 " (declare (in) isampler2D sampler)\n"
2718 " (declare (in) vec4 P) \n"
2719 " (declare (in) float lod) )\n"
2720 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2721 "\n"
2722 " (signature uvec4\n"
2723 " (parameters\n"
2724 " (declare (in) usampler2D sampler)\n"
2725 " (declare (in) vec4 P) \n"
2726 " (declare (in) float lod) )\n"
2727 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2728 "\n"
2729 " (signature vec4\n"
2730 " (parameters\n"
2731 " (declare (in) sampler3D sampler)\n"
2732 " (declare (in) vec4 P) \n"
2733 " (declare (in) float lod) )\n"
2734 " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2735 "\n"
2736 " (signature ivec4\n"
2737 " (parameters\n"
2738 " (declare (in) isampler3D sampler)\n"
2739 " (declare (in) vec4 P) \n"
2740 " (declare (in) float lod) )\n"
2741 " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2742 "\n"
2743 " (signature uvec4\n"
2744 " (parameters\n"
2745 " (declare (in) usampler3D sampler)\n"
2746 " (declare (in) vec4 P) \n"
2747 " (declare (in) float lod) )\n"
2748 " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
2749 "\n"
2750 "))\n"
2751 ""
2752;
2753static const char *builtin_log =
2754 "((function log\n"
2755 " (signature float\n"
2756 " (parameters\n"
2757 " (declare (in) float arg0))\n"
2758 " ((return (expression float log (var_ref arg0)))))\n"
2759 "\n"
2760 " (signature vec2\n"
2761 " (parameters\n"
2762 " (declare (in) vec2 arg0))\n"
2763 " ((return (expression vec2 log (var_ref arg0)))))\n"
2764 "\n"
2765 " (signature vec3\n"
2766 " (parameters\n"
2767 " (declare (in) vec3 arg0))\n"
2768 " ((return (expression vec3 log (var_ref arg0)))))\n"
2769 "\n"
2770 " (signature vec4\n"
2771 " (parameters\n"
2772 " (declare (in) vec4 arg0))\n"
2773 " ((return (expression vec4 log (var_ref arg0)))))\n"
2774 "))\n"
2775 ""
2776;
2777static const char *builtin_exp2 =
2778 "((function exp2\n"
2779 " (signature float\n"
2780 " (parameters\n"
2781 " (declare (in) float arg0))\n"
2782 " ((return (expression float exp2 (var_ref arg0)))))\n"
2783 "\n"
2784 " (signature vec2\n"
2785 " (parameters\n"
2786 " (declare (in) vec2 arg0))\n"
2787 " ((return (expression vec2 exp2 (var_ref arg0)))))\n"
2788 "\n"
2789 " (signature vec3\n"
2790 " (parameters\n"
2791 " (declare (in) vec3 arg0))\n"
2792 " ((return (expression vec3 exp2 (var_ref arg0)))))\n"
2793 "\n"
2794 " (signature vec4\n"
2795 " (parameters\n"
2796 " (declare (in) vec4 arg0))\n"
2797 " ((return (expression vec4 exp2 (var_ref arg0)))))\n"
2798 "))\n"
2799 ""
2800;
2801static const char *builtin_fract =
2802 "((function fract\n"
2803 " (signature float\n"
2804 " (parameters\n"
2805 " (declare (in) float x))\n"
2806 " ((return (expression float fract (var_ref x)))))\n"
2807 "\n"
2808 " (signature vec2\n"
2809 " (parameters\n"
2810 " (declare (in) vec2 x))\n"
2811 " ((return (expression vec2 fract (var_ref x)))))\n"
2812 "\n"
2813 " (signature vec3\n"
2814 " (parameters\n"
2815 " (declare (in) vec3 x))\n"
2816 " ((return (expression vec3 fract (var_ref x)))))\n"
2817 "\n"
2818 " (signature vec4\n"
2819 " (parameters\n"
2820 " (declare (in) vec4 x))\n"
2821 " ((return (expression vec4 fract (var_ref x)))))\n"
2822 "))\n"
2823 "\n"
2824 ""
2825;
2826static const char *builtin_shadow1DLod =
2827 "((function shadow1DLod\n"
2828 " (signature vec4\n"
2829 " (parameters\n"
2830 " (declare (in) sampler1DShadow sampler)\n"
2831 " (declare (in) vec3 P) \n"
2832 " (declare (in) float lod) )\n"
2833 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n"
2834 "\n"
2835 "))\n"
2836 ""
2837;
2838static const char *builtin_texture1DLod =
2839 "((function texture1DLod\n"
2840 " (signature vec4\n"
2841 " (parameters\n"
2842 " (declare (in) sampler1D sampler)\n"
2843 " (declare (in) float P) \n"
2844 " (declare (in) float lod) )\n"
2845 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
2846 "\n"
2847 "))\n"
2848 ""
2849;
2850static const char *builtin_texture2DArray =
2851 "((function texture2DArray\n"
2852 " (signature vec4\n"
2853 " (parameters\n"
2854 " (declare (in) sampler2DArray sampler)\n"
2855 " (declare (in) vec3 P) )\n"
2856 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
2857 "\n"
2858 " (signature vec4\n"
2859 " (parameters\n"
2860 " (declare (in) sampler2DArray sampler)\n"
2861 " (declare (in) vec3 P) \n"
2862 " (declare (in) float bias) )\n"
2863 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
2864 "\n"
2865 "))\n"
2866 ""
2867;
2868static const char *builtin_texture3DProj =
2869 "((function texture3DProj\n"
2870 " (signature vec4\n"
2871 " (parameters\n"
2872 " (declare (in) sampler3D sampler)\n"
2873 " (declare (in) vec4 P) )\n"
2874 " ((return (tex (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () ))))\n"
2875 "\n"
2876 " (signature vec4\n"
2877 " (parameters\n"
2878 " (declare (in) sampler3D sampler)\n"
2879 " (declare (in) vec4 P) \n"
2880 " (declare (in) float bias) )\n"
2881 " ((return (txb (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref bias) ))))\n"
2882 "\n"
2883 "))\n"
2884 ""
2885;
2886static const char *builtin_sign =
2887 "((function sign\n"
2888 " (signature float\n"
2889 " (parameters\n"
2890 " (declare (in) float x))\n"
2891 " ((return (expression float sign (var_ref x)))))\n"
2892 "\n"
2893 " (signature vec2\n"
2894 " (parameters\n"
2895 " (declare (in) vec2 x))\n"
2896 " ((return (expression vec2 sign (var_ref x)))))\n"
2897 "\n"
2898 " (signature vec3\n"
2899 " (parameters\n"
2900 " (declare (in) vec3 x))\n"
2901 " ((return (expression vec3 sign (var_ref x)))))\n"
2902 "\n"
2903 " (signature vec4\n"
2904 " (parameters\n"
2905 " (declare (in) vec4 x))\n"
2906 " ((return (expression vec4 sign (var_ref x)))))\n"
2907 "\n"
2908 " (signature int\n"
2909 " (parameters\n"
2910 " (declare (in) int x))\n"
2911 " ((return (expression int sign (var_ref x)))))\n"
2912 "\n"
2913 " (signature ivec2\n"
2914 " (parameters\n"
2915 " (declare (in) ivec2 x))\n"
2916 " ((return (expression ivec2 sign (var_ref x)))))\n"
2917 "\n"
2918 " (signature ivec3\n"
2919 " (parameters\n"
2920 " (declare (in) ivec3 x))\n"
2921 " ((return (expression ivec3 sign (var_ref x)))))\n"
2922 "\n"
2923 " (signature ivec4\n"
2924 " (parameters\n"
2925 " (declare (in) ivec4 x))\n"
2926 " ((return (expression ivec4 sign (var_ref x)))))\n"
2927 "))\n"
2928 "\n"
2929 ""
2930;
2931static const char *builtin_inversesqrt =
2932 "((function inversesqrt\n"
2933 " (signature float\n"
2934 " (parameters\n"
2935 " (declare (in) float arg0))\n"
2936 " ((return (expression float rsq (var_ref arg0)))))\n"
2937 "\n"
2938 " (signature vec2\n"
2939 " (parameters\n"
2940 " (declare (in) vec2 arg0))\n"
2941 " ((return (expression vec2 rsq (var_ref arg0)))))\n"
2942 "\n"
2943 " (signature vec3\n"
2944 " (parameters\n"
2945 " (declare (in) vec3 arg0))\n"
2946 " ((return (expression vec3 rsq (var_ref arg0)))))\n"
2947 "\n"
2948 " (signature vec4\n"
2949 " (parameters\n"
2950 " (declare (in) vec4 arg0))\n"
2951 " ((return (expression vec4 rsq (var_ref arg0)))))\n"
2952 "))\n"
2953 ""
2954;
2955static const char *builtin_distance =
2956 "((function distance\n"
2957 " (signature float\n"
2958 " (parameters\n"
2959 " (declare (in) float p0)\n"
2960 " (declare (in) float p1))\n"
2961 " ((declare () float p)\n"
2962 " (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))\n"
2963 " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n"
2964 "\n"
2965 " (signature float\n"
2966 " (parameters\n"
2967 " (declare (in) vec2 p0)\n"
2968 " (declare (in) vec2 p1))\n"
2969 " ((declare () vec2 p)\n"
2970 " (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))\n"
2971 " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n"
2972 "\n"
2973 " (signature float\n"
2974 " (parameters\n"
2975 " (declare (in) vec3 p0)\n"
2976 " (declare (in) vec3 p1))\n"
2977 " ((declare () vec3 p)\n"
2978 " (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))\n"
2979 " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n"
2980 "\n"
2981 " (signature float\n"
2982 " (parameters\n"
2983 " (declare (in) vec4 p0)\n"
2984 " (declare (in) vec4 p1))\n"
2985 " ((declare () vec4 p)\n"
2986 " (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))\n"
2987 " (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))\n"
2988 "))\n"
2989 ""
2990;
2991static const char *builtin_noise2 =
2992 "((function noise2\n"
2993 " (signature vec2\n"
2994 " (parameters\n"
2995 " (declare (in) float x))\n"
2996 " ((return (constant vec2 (0 0)))))\n"
2997 " (signature vec2\n"
2998 " (parameters\n"
2999 " (declare (in) vec2 x))\n"
3000 " ((return (constant vec2 (0 0)))))\n"
3001 " (signature vec2\n"
3002 " (parameters\n"
3003 " (declare (in) vec3 x))\n"
3004 " ((return (constant vec2 (0 0)))))\n"
3005 " (signature vec2\n"
3006 " (parameters\n"
3007 " (declare (in) vec4 x))\n"
3008 " ((return (constant vec2 (0 0)))))\n"
3009 "))\n"
3010 ""
3011;
3012static const char *builtin_tanh =
3013 "((function tanh\n"
3014 " (signature float\n"
3015 " (parameters\n"
3016 " (declare (in) float x))\n"
3017 " ((return (expression float /\n"
3018 " (expression float -\n"
3019 " (expression float exp (var_ref x))\n"
3020 " (expression float exp (expression float neg (var_ref x))))\n"
3021 " (expression float +\n"
3022 " (expression float exp (var_ref x))\n"
3023 " (expression float exp (expression float neg (var_ref x))))))))\n"
3024 " (signature vec2\n"
3025 " (parameters\n"
3026 " (declare (in) vec2 x))\n"
3027 " ((return (expression vec2 /\n"
3028 " (expression vec2 -\n"
3029 " (expression vec2 exp (var_ref x))\n"
3030 " (expression vec2 exp (expression vec2 neg (var_ref x))))\n"
3031 " (expression vec2 +\n"
3032 " (expression vec2 exp (var_ref x))\n"
3033 " (expression vec2 exp (expression vec2 neg (var_ref x))))))))\n"
3034 " (signature vec3\n"
3035 " (parameters\n"
3036 " (declare (in) vec3 x))\n"
3037 " ((return (expression vec3 /\n"
3038 " (expression vec3 -\n"
3039 " (expression vec3 exp (var_ref x))\n"
3040 " (expression vec3 exp (expression vec3 neg (var_ref x))))\n"
3041 " (expression vec3 +\n"
3042 " (expression vec3 exp (var_ref x))\n"
3043 " (expression vec3 exp (expression vec3 neg (var_ref x))))))))\n"
3044 " (signature vec4\n"
3045 " (parameters\n"
3046 " (declare (in) vec4 x))\n"
3047 " ((return (expression vec4 /\n"
3048 " (expression vec4 -\n"
3049 " (expression vec4 exp (var_ref x))\n"
3050 " (expression vec4 exp (expression vec4 neg (var_ref x))))\n"
3051 " (expression vec4 +\n"
3052 " (expression vec4 exp (var_ref x))\n"
3053 " (expression vec4 exp (expression vec4 neg (var_ref x))))))))\n"
3054 "))\n"
3055 ""
3056;
3057static const char *builtin_texture1DProjLod =
3058 "((function texture1DProjLod\n"
3059 " (signature vec4\n"
3060 " (parameters\n"
3061 " (declare (in) sampler1D sampler)\n"
3062 " (declare (in) vec2 P) \n"
3063 " (declare (in) float lod) )\n"
3064 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz y (var_ref P)) () (var_ref lod) ))))\n"
3065 "\n"
3066 " (signature vec4\n"
3067 " (parameters\n"
3068 " (declare (in) sampler1D sampler)\n"
3069 " (declare (in) vec4 P) \n"
3070 " (declare (in) float lod) )\n"
3071 " ((return (txl (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
3072 "\n"
3073 "))\n"
3074 ""
3075;
3076static const char *builtin_texture1DArray =
3077 "((function texture1DArray\n"
3078 " (signature vec4\n"
3079 " (parameters\n"
3080 " (declare (in) sampler1DArray sampler)\n"
3081 " (declare (in) vec2 P) )\n"
3082 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
3083 "\n"
3084 " (signature vec4\n"
3085 " (parameters\n"
3086 " (declare (in) sampler1DArray sampler)\n"
3087 " (declare (in) vec2 P) \n"
3088 " (declare (in) float bias) )\n"
3089 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
3090 "\n"
3091 "))\n"
3092 ""
3093;
3094static const char *builtin_texture2D =
3095 "((function texture2D\n"
3096 " (signature vec4\n"
3097 " (parameters\n"
3098 " (declare (in) sampler2D sampler)\n"
3099 " (declare (in) vec2 P) )\n"
3100 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
3101 "\n"
3102 " (signature vec4\n"
3103 " (parameters\n"
3104 " (declare (in) sampler2D sampler)\n"
3105 " (declare (in) vec2 P) \n"
3106 " (declare (in) float bias) )\n"
3107 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
3108 "\n"
3109 "))\n"
3110 ""
3111;
3112static const char *builtin_greaterThanEqual =
3113 "((function greaterThanEqual\n"
3114 " (signature bvec2\n"
3115 " (parameters\n"
3116 " (declare (in) vec2 arg0)\n"
3117 " (declare (in) vec2 arg1))\n"
3118 " ((declare () bvec2 temp)\n"
3119 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3120 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3121 " (return (var_ref temp))))\n"
3122 "\n"
3123 " (signature bvec3\n"
3124 " (parameters\n"
3125 " (declare (in) vec3 arg0)\n"
3126 " (declare (in) vec3 arg1))\n"
3127 " ((declare () bvec3 temp)\n"
3128 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3129 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3130 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
3131 " (return (var_ref temp))))\n"
3132 "\n"
3133 " (signature bvec4\n"
3134 " (parameters\n"
3135 " (declare (in) vec4 arg0)\n"
3136 " (declare (in) vec4 arg1))\n"
3137 " ((declare () bvec4 temp)\n"
3138 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3139 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3140 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
3141 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
3142 " (return (var_ref temp))))\n"
3143 "\n"
3144 " (signature bvec2\n"
3145 " (parameters\n"
3146 " (declare (in) ivec2 arg0)\n"
3147 " (declare (in) ivec2 arg1))\n"
3148 " ((declare () bvec2 temp)\n"
3149 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3150 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3151 " (return (var_ref temp))))\n"
3152 "\n"
3153 " (signature bvec3\n"
3154 " (parameters\n"
3155 " (declare (in) ivec3 arg0)\n"
3156 " (declare (in) ivec3 arg1))\n"
3157 " ((declare () bvec3 temp)\n"
3158 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3159 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3160 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
3161 " (return (var_ref temp))))\n"
3162 "\n"
3163 " (signature bvec4\n"
3164 " (parameters\n"
3165 " (declare (in) ivec4 arg0)\n"
3166 " (declare (in) ivec4 arg1))\n"
3167 " ((declare () bvec4 temp)\n"
3168 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3169 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3170 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
3171 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
3172 " (return (var_ref temp))))\n"
3173 "\n"
3174 " (signature bvec2\n"
3175 " (parameters\n"
3176 " (declare (in) uvec2 arg0)\n"
3177 " (declare (in) uvec2 arg1))\n"
3178 " ((declare () bvec2 temp)\n"
3179 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3180 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3181 " (return (var_ref temp))))\n"
3182 "\n"
3183 " (signature bvec3\n"
3184 " (parameters\n"
3185 " (declare (in) uvec3 arg0)\n"
3186 " (declare (in) uvec3 arg1))\n"
3187 " ((declare () bvec3 temp)\n"
3188 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3189 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3190 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
3191 " (return (var_ref temp))))\n"
3192 "\n"
3193 " (signature bvec4\n"
3194 " (parameters\n"
3195 " (declare (in) uvec4 arg0)\n"
3196 " (declare (in) uvec4 arg1))\n"
3197 " ((declare () bvec4 temp)\n"
3198 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
3199 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
3200 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
3201 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
3202 " (return (var_ref temp))))\n"
3203 "))\n"
3204 ""
3205;
3206static const char *builtin_texture3DProjLod =
3207 "((function texture3DProjLod\n"
3208 " (signature vec4\n"
3209 " (parameters\n"
3210 " (declare (in) sampler3D sampler)\n"
3211 " (declare (in) vec4 P) \n"
3212 " (declare (in) float lod) )\n"
3213 " ((return (txl (var_ref sampler) (swiz xyz (var_ref P)) (0 0 0) (swiz w (var_ref P)) () (var_ref lod) ))))\n"
3214 "\n"
3215 "))\n"
3216 ""
3217;
3218static const char *builtin_tan =
3219 "((function tan\n"
3220 " (signature float\n"
3221 " (parameters\n"
3222 " (declare (in) float angle))\n"
3223 " ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))\n"
3224 "\n"
3225 " (signature vec2\n"
3226 " (parameters\n"
3227 " (declare (in) vec2 angle))\n"
3228 " ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))\n"
3229 "\n"
3230 " (signature vec3\n"
3231 " (parameters\n"
3232 " (declare (in) vec3 angle))\n"
3233 " ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))\n"
3234 "\n"
3235 " (signature vec4\n"
3236 " (parameters\n"
3237 " (declare (in) vec4 angle))\n"
3238 " ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))\n"
3239 "))\n"
3240 ""
3241;
3242static const char *builtin_any =
3243 "((function any\n"
3244 " (signature bool\n"
3245 " (parameters\n"
3246 " (declare (in) bvec2 arg0))\n"
3247 " ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))\n"
3248 "\n"
3249 " (signature bool\n"
3250 " (parameters\n"
3251 " (declare (in) bvec3 arg0))\n"
3252 " ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))\n"
3253 "\n"
3254 " (signature bool\n"
3255 " (parameters\n"
3256 " (declare (in) bvec4 arg0))\n"
3257 " ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))\n"
3258 "))\n"
3259 ""
3260;
3261static const char *builtin_normalize =
3262 "((function normalize\n"
3263 " (signature float\n"
3264 " (parameters\n"
3265 " (declare (in) float arg0))\n"
3266 " ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n"
3267 "\n"
3268 " (signature vec2\n"
3269 " (parameters\n"
3270 " (declare (in) vec2 arg0))\n"
3271 " ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n"
3272 "\n"
3273 " (signature vec3\n"
3274 " (parameters\n"
3275 " (declare (in) vec3 arg0))\n"
3276 " ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n"
3277 "\n"
3278 " (signature vec4\n"
3279 " (parameters\n"
3280 " (declare (in) vec4 arg0))\n"
3281 " ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))\n"
3282 "))\n"
3283 ""
3284;
3285static const char *builtin_shadow1DProj =
3286 "((function shadow1DProj\n"
3287 " (signature vec4\n"
3288 " (parameters\n"
3289 " (declare (in) sampler1DShadow sampler)\n"
3290 " (declare (in) vec4 P) )\n"
3291 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n"
3292 "\n"
3293 " (signature vec4\n"
3294 " (parameters\n"
3295 " (declare (in) sampler1DShadow sampler)\n"
3296 " (declare (in) vec4 P) \n"
3297 " (declare (in) float bias) )\n"
3298 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) (var_ref bias) ))))\n"
3299 "\n"
3300 "))\n"
3301 ""
3302;
3303static const char *builtin_floor =
3304 "((function floor\n"
3305 " (signature float\n"
3306 " (parameters\n"
3307 " (declare (in) float arg0))\n"
3308 " ((return (expression float floor (var_ref arg0)))))\n"
3309 "\n"
3310 " (signature vec2\n"
3311 " (parameters\n"
3312 " (declare (in) vec2 arg0))\n"
3313 " ((return (expression vec2 floor (var_ref arg0)))))\n"
3314 "\n"
3315 " (signature vec3\n"
3316 " (parameters\n"
3317 " (declare (in) vec3 arg0))\n"
3318 " ((return (expression vec3 floor (var_ref arg0)))))\n"
3319 "\n"
3320 " (signature vec4\n"
3321 " (parameters\n"
3322 " (declare (in) vec4 arg0))\n"
3323 " ((return (expression vec4 floor (var_ref arg0)))))\n"
3324 "))\n"
3325 ""
3326;
3327static const char *builtin_cross =
3328 "((function cross\n"
3329 " (signature vec3\n"
3330 " (parameters\n"
3331 " (declare (in) vec3 arg0)\n"
3332 " (declare (in) vec3 arg1))\n"
3333 " ((return (expression vec3 cross (var_ref arg0) (var_ref arg1)))))\n"
3334 "))\n"
3335 ""
3336;
3337static const char *builtin_sqrt =
3338 "((function sqrt\n"
3339 " (signature float\n"
3340 " (parameters\n"
3341 " (declare (in) float arg0))\n"
3342 " ((return (expression float sqrt (var_ref arg0)))))\n"
3343 "\n"
3344 " (signature vec2\n"
3345 " (parameters\n"
3346 " (declare (in) vec2 arg0))\n"
3347 " ((return (expression vec2 sqrt (var_ref arg0)))))\n"
3348 "\n"
3349 " (signature vec3\n"
3350 " (parameters\n"
3351 " (declare (in) vec3 arg0))\n"
3352 " ((return (expression vec3 sqrt (var_ref arg0)))))\n"
3353 "\n"
3354 " (signature vec4\n"
3355 " (parameters\n"
3356 " (declare (in) vec4 arg0))\n"
3357 " ((return (expression vec4 sqrt (var_ref arg0)))))\n"
3358 "))\n"
3359 ""
3360;
3361static const char *builtin_mix =
3362 "((function mix\n"
3363 " (signature float\n"
3364 " (parameters\n"
3365 " (declare (in) float arg0)\n"
3366 " (declare (in) float arg1)\n"
3367 " (declare (in) float arg2))\n"
3368 " ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))\n"
3369 "\n"
3370 " (signature vec2\n"
3371 " (parameters\n"
3372 " (declare (in) vec2 arg0)\n"
3373 " (declare (in) vec2 arg1)\n"
3374 " (declare (in) vec2 arg2))\n"
3375 " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n"
3376 "\n"
3377 " (signature vec3\n"
3378 " (parameters\n"
3379 " (declare (in) vec3 arg0)\n"
3380 " (declare (in) vec3 arg1)\n"
3381 " (declare (in) vec3 arg2))\n"
3382 " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n"
3383 "\n"
3384 " (signature vec4\n"
3385 " (parameters\n"
3386 " (declare (in) vec4 arg0)\n"
3387 " (declare (in) vec4 arg1)\n"
3388 " (declare (in) vec4 arg2))\n"
3389 " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n"
3390 "\n"
3391 " (signature vec2\n"
3392 " (parameters\n"
3393 " (declare (in) vec2 arg0)\n"
3394 " (declare (in) vec2 arg1)\n"
3395 " (declare (in) float arg2))\n"
3396 " ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))\n"
3397 "\n"
3398 " (signature vec3\n"
3399 " (parameters\n"
3400 " (declare (in) vec3 arg0)\n"
3401 " (declare (in) vec3 arg1)\n"
3402 " (declare (in) float arg2))\n"
3403 " ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))\n"
3404 "\n"
3405 " (signature vec4\n"
3406 " (parameters\n"
3407 " (declare (in) vec4 arg0)\n"
3408 " (declare (in) vec4 arg1)\n"
3409 " (declare (in) float arg2))\n"
3410 " ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))\n"
3411 "\n"
3412 " (signature float\n"
3413 " (parameters\n"
3414 " (declare (in) float v1)\n"
3415 " (declare (in) float v2)\n"
3416 " (declare (in) bool a))\n"
3417 " ((assign (var_ref a) (var_ref v1) (var_ref v2))\n"
3418 " (return (var_ref v1))))\n"
3419 "\n"
3420 " (signature vec2\n"
3421 " (parameters\n"
3422 " (declare (in) vec2 v1)\n"
3423 " (declare (in) vec2 v2)\n"
3424 " (declare (in) bvec2 a))\n"
3425 " ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))\n"
3426 " (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))\n"
3427 " (return (var_ref v1))))\n"
3428 "\n"
3429 " (signature vec3\n"
3430 " (parameters\n"
3431 " (declare (in) vec3 v1)\n"
3432 " (declare (in) vec3 v2)\n"
3433 " (declare (in) bvec3 a))\n"
3434 " ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))\n"
3435 " (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))\n"
3436 " (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2)))\n"
3437 " (return (var_ref v1))))\n"
3438 "\n"
3439 " (signature vec4\n"
3440 " (parameters\n"
3441 " (declare (in) vec4 v1)\n"
3442 " (declare (in) vec4 v2)\n"
3443 " (declare (in) bvec4 a))\n"
3444 " ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))\n"
3445 " (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))\n"
3446 " (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2)))\n"
3447 " (assign (swiz w (var_ref a)) (swiz w (var_ref v1)) (swiz w (var_ref v2)))\n"
3448 " (return (var_ref v1))))\n"
3449 "))\n"
3450 ""
3451;
3452static const char *builtin_shadow1DArrayLod =
3453 "((function shadow1DArrayLod\n"
3454 " (signature vec4\n"
3455 " (parameters\n"
3456 " (declare (in) sampler1DArrayShadow sampler)\n"
3457 " (declare (in) vec3 P) \n"
3458 " (declare (in) float lod) )\n"
3459 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n"
3460 "\n"
3461 "))\n"
3462 ""
3463;
3464static const char *builtin_ftransform =
3465 "((declare (uniform) mat4 gl_ModelViewProjectionMatrix)\n"
3466 " (declare (in) vec4 gl_Vertex)\n"
3467 " (function ftransform\n"
3468 " (signature vec4\n"
3469 " (parameters)\n"
3470 " ((return (expression vec4 *\n"
3471 " (var_ref gl_ModelViewProjectionMatrix)\n"
3472 " (var_ref gl_Vertex)))))\n"
3473 "))\n"
3474 ""
3475;
3476static const char *builtin_sin =
3477 "((function sin\n"
3478 " (signature float\n"
3479 " (parameters\n"
3480 " (declare (in) float angle))\n"
3481 " ((return (expression float sin (var_ref angle)))))\n"
3482 "\n"
3483 " (signature vec2\n"
3484 " (parameters\n"
3485 " (declare (in) vec2 angle))\n"
3486 " ((return (expression vec2 sin (var_ref angle)))))\n"
3487 "\n"
3488 " (signature vec3\n"
3489 " (parameters\n"
3490 " (declare (in) vec3 angle))\n"
3491 " ((return (expression vec3 sin (var_ref angle)))))\n"
3492 "\n"
3493 " (signature vec4\n"
3494 " (parameters\n"
3495 " (declare (in) vec4 angle))\n"
3496 " ((return (expression vec4 sin (var_ref angle)))))\n"
3497 "))\n"
3498 ""
3499;
3500static const char *builtin_shadow2D =
3501 "((function shadow2D\n"
3502 " (signature vec4\n"
3503 " (parameters\n"
3504 " (declare (in) sampler2DShadow sampler)\n"
3505 " (declare (in) vec3 P) )\n"
3506 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n"
3507 "\n"
3508 " (signature vec4\n"
3509 " (parameters\n"
3510 " (declare (in) sampler2DShadow sampler)\n"
3511 " (declare (in) vec3 P) \n"
3512 " (declare (in) float bias) )\n"
3513 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n"
3514 "\n"
3515 "))\n"
3516 ""
3517;
3518static const char *builtin_shadow2DLod =
3519 "((function shadow2DLod\n"
3520 " (signature vec4\n"
3521 " (parameters\n"
3522 " (declare (in) sampler2DShadow sampler)\n"
3523 " (declare (in) vec3 P) \n"
3524 " (declare (in) float lod) )\n"
3525 " ((return (txl (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref lod) ))))\n"
3526 "\n"
3527 "))\n"
3528 ""
3529;
3530static const char *builtin_shadow2DRectProj =
3531 "((function shadow2DRectProj\n"
3532 " (signature vec4\n"
3533 " (parameters\n"
3534 " (declare (in) sampler2DRectShadow sampler)\n"
3535 " (declare (in) vec4 P) )\n"
3536 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) (swiz w (var_ref P)) (swiz z (var_ref P)) ))))\n"
3537 "\n"
3538 "))\n"
3539 ""
3540;
3541static const char *builtin_atan =
3542 "((function atan\n"
3543 " (signature float\n"
3544 " (parameters\n"
3545 " (declare (in) float x))\n"
3546 " ((return (call asin ((expression float *\n"
3547 " (var_ref x)\n"
3548 " (expression float rsq\n"
3549 " (expression float +\n"
3550 " (expression float *\n"
3551 " (var_ref x)\n"
3552 " (var_ref x))\n"
3553 " (constant float (1.0))))))))))\n"
3554 "\n"
3555 " (signature vec2\n"
3556 " (parameters\n"
3557 " (declare (in) vec2 y_over_x))\n"
3558 " ((return (call asin ((expression vec2 *\n"
3559 " (var_ref y_over_x)\n"
3560 " (expression vec2 rsq\n"
3561 " (expression vec2 +\n"
3562 " (expression vec2 *\n"
3563 " (var_ref y_over_x)\n"
3564 " (var_ref y_over_x))\n"
3565 " (constant float (1.0))))))))))\n"
3566 "\n"
3567 " (signature vec3\n"
3568 " (parameters\n"
3569 " (declare (in) vec3 y_over_x))\n"
3570 " ((return (call asin ((expression vec3 *\n"
3571 " (var_ref y_over_x)\n"
3572 " (expression vec3 rsq\n"
3573 " (expression vec3 +\n"
3574 " (expression vec3 *\n"
3575 " (var_ref y_over_x)\n"
3576 " (var_ref y_over_x))\n"
3577 " (constant float (1.0))))))))))\n"
3578 "\n"
3579 " (signature vec4\n"
3580 " (parameters\n"
3581 " (declare (in) vec4 y_over_x))\n"
3582 " ((return (call asin ((expression vec4 *\n"
3583 " (var_ref y_over_x)\n"
3584 " (expression vec4 rsq\n"
3585 " (expression vec4 +\n"
3586 " (expression vec4 *\n"
3587 " (var_ref y_over_x)\n"
3588 " (var_ref y_over_x))\n"
3589 " (constant float (1.0))))))))))\n"
3590 "\n"
3591 " (signature float\n"
3592 " (parameters\n"
3593 " (declare (in ) float y)\n"
3594 " (declare (in ) float x)\n"
3595 " )\n"
3596 " (\n"
3597 " (declare () float r)\n"
3598 " (declare ( ) float abs_retval)\n"
3599 " (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) ))\n"
3600 ") \n"
3601 " (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) (\n"
3602 " (declare ( ) float atan_retval)\n"
3603 " (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) ))\n"
3604 ") \n"
3605 " (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) ) \n"
3606 " (if (expression bool < (var_ref x) (constant float (0.000000)) ) (\n"
3607 " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n"
3608 " (declare ( ) float assignment_tmp)\n"
3609 " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) ) \n"
3610 " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n"
3611 " )\n"
3612 " (\n"
3613 " (declare ( ) float assignment_tmp)\n"
3614 " (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) ) \n"
3615 " (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) ) \n"
3616 " ))\n"
3617 "\n"
3618 " )\n"
3619 " (\n"
3620 " ))\n"
3621 "\n"
3622 " )\n"
3623 " (\n"
3624 " (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (\n"
3625 " (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) ) \n"
3626 " )\n"
3627 " (\n"
3628 " (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) ) \n"
3629 " ))\n"
3630 "\n"
3631 " ))\n"
3632 "\n"
3633 " (return (var_ref r) )\n"
3634 " ))\n"
3635 "\n"
3636 "\n"
3637 "\n"
3638 " (signature vec2\n"
3639 " (parameters\n"
3640 " (declare (in) vec2 y)\n"
3641 " (declare (in) vec2 x))\n"
3642 " ((declare () vec2 r)\n"
3643 " (assign (constant bool (1))\n"
3644 " (swiz x (var_ref r))\n"
3645 " (call atan ((swiz x (var_ref y))\n"
3646 " (swiz x (var_ref x)))))\n"
3647 " (assign (constant bool (1))\n"
3648 " (swiz y (var_ref r))\n"
3649 " (call atan ((swiz y (var_ref y))\n"
3650 " (swiz y (var_ref x)))))\n"
3651 " (return (var_ref r))))\n"
3652 "\n"
3653 " (signature vec3\n"
3654 " (parameters\n"
3655 " (declare (in) vec3 y)\n"
3656 " (declare (in) vec3 x))\n"
3657 " ((declare () vec3 r)\n"
3658 " (assign (constant bool (1))\n"
3659 " (swiz x (var_ref r))\n"
3660 " (call atan ((swiz x (var_ref y))\n"
3661 " (swiz x (var_ref x)))))\n"
3662 " (assign (constant bool (1))\n"
3663 " (swiz y (var_ref r))\n"
3664 " (call atan ((swiz y (var_ref y))\n"
3665 " (swiz y (var_ref x)))))\n"
3666 " (assign (constant bool (1))\n"
3667 " (swiz z (var_ref r))\n"
3668 " (call atan ((swiz z (var_ref y))\n"
3669 " (swiz z (var_ref x)))))\n"
3670 " (return (var_ref r))))\n"
3671 "\n"
3672 " (signature vec4\n"
3673 " (parameters\n"
3674 " (declare (in) vec4 y)\n"
3675 " (declare (in) vec4 x))\n"
3676 " ((declare () vec4 r)\n"
3677 " (assign (constant bool (1))\n"
3678 " (swiz x (var_ref r))\n"
3679 " (call atan ((swiz x (var_ref y))\n"
3680 " (swiz x (var_ref x)))))\n"
3681 " (assign (constant bool (1))\n"
3682 " (swiz y (var_ref r))\n"
3683 " (call atan ((swiz y (var_ref y))\n"
3684 " (swiz y (var_ref x)))))\n"
3685 " (assign (constant bool (1))\n"
3686 " (swiz z (var_ref r))\n"
3687 " (call atan ((swiz z (var_ref y))\n"
3688 " (swiz z (var_ref x)))))\n"
3689 " (assign (constant bool (1))\n"
3690 " (swiz w (var_ref r))\n"
3691 " (call atan ((swiz w (var_ref y))\n"
3692 " (swiz w (var_ref x)))))\n"
3693 " (return (var_ref r)))))\n"
3694 "\n"
3695 "))\n"
3696 ""
3697;
3698static const char *builtin_max =
3699 "((function max\n"
3700 " (signature float\n"
3701 " (parameters\n"
3702 " (declare (in) float arg0)\n"
3703 " (declare (in) float arg1))\n"
3704 " ((return (expression float max (var_ref arg0) (var_ref arg1)))))\n"
3705 "\n"
3706 " (signature vec2\n"
3707 " (parameters\n"
3708 " (declare (in) vec2 arg0)\n"
3709 " (declare (in) vec2 arg1))\n"
3710 " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n"
3711 "\n"
3712 " (signature vec3\n"
3713 " (parameters\n"
3714 " (declare (in) vec3 arg0)\n"
3715 " (declare (in) vec3 arg1))\n"
3716 " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n"
3717 "\n"
3718 " (signature vec4\n"
3719 " (parameters\n"
3720 " (declare (in) vec4 arg0)\n"
3721 " (declare (in) vec4 arg1))\n"
3722 " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n"
3723 "\n"
3724 " (signature vec2\n"
3725 " (parameters\n"
3726 " (declare (in) vec2 arg0)\n"
3727 " (declare (in) float arg1))\n"
3728 " ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))\n"
3729 "\n"
3730 " (signature vec3\n"
3731 " (parameters\n"
3732 " (declare (in) vec3 arg0)\n"
3733 " (declare (in) float arg1))\n"
3734 " ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))\n"
3735 "\n"
3736 " (signature vec4\n"
3737 " (parameters\n"
3738 " (declare (in) vec4 arg0)\n"
3739 " (declare (in) float arg1))\n"
3740 " ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))\n"
3741 "\n"
3742 " (signature int\n"
3743 " (parameters\n"
3744 " (declare (in) int arg0)\n"
3745 " (declare (in) int arg1))\n"
3746 " ((return (expression int max (var_ref arg0) (var_ref arg1)))))\n"
3747 "\n"
3748 " (signature ivec2\n"
3749 " (parameters\n"
3750 " (declare (in) ivec2 arg0)\n"
3751 " (declare (in) ivec2 arg1))\n"
3752 " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n"
3753 "\n"
3754 " (signature ivec3\n"
3755 " (parameters\n"
3756 " (declare (in) ivec3 arg0)\n"
3757 " (declare (in) ivec3 arg1))\n"
3758 " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n"
3759 "\n"
3760 " (signature ivec4\n"
3761 " (parameters\n"
3762 " (declare (in) ivec4 arg0)\n"
3763 " (declare (in) ivec4 arg1))\n"
3764 " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n"
3765 "\n"
3766 " (signature ivec2\n"
3767 " (parameters\n"
3768 " (declare (in) ivec2 arg0)\n"
3769 " (declare (in) int arg1))\n"
3770 " ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))\n"
3771 "\n"
3772 " (signature ivec3\n"
3773 " (parameters\n"
3774 " (declare (in) ivec3 arg0)\n"
3775 " (declare (in) int arg1))\n"
3776 " ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))\n"
3777 "\n"
3778 " (signature ivec4\n"
3779 " (parameters\n"
3780 " (declare (in) ivec4 arg0)\n"
3781 " (declare (in) int arg1))\n"
3782 " ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))\n"
3783 "\n"
3784 " (signature uint\n"
3785 " (parameters\n"
3786 " (declare (in) uint arg0)\n"
3787 " (declare (in) uint arg1))\n"
3788 " ((return (expression uint max (var_ref arg0) (var_ref arg1)))))\n"
3789 "\n"
3790 " (signature uvec2\n"
3791 " (parameters\n"
3792 " (declare (in) uvec2 arg0)\n"
3793 " (declare (in) uvec2 arg1))\n"
3794 " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n"
3795 "\n"
3796 " (signature uvec3\n"
3797 " (parameters\n"
3798 " (declare (in) uvec3 arg0)\n"
3799 " (declare (in) uvec3 arg1))\n"
3800 " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n"
3801 "\n"
3802 " (signature uvec4\n"
3803 " (parameters\n"
3804 " (declare (in) uvec4 arg0)\n"
3805 " (declare (in) uvec4 arg1))\n"
3806 " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n"
3807 "\n"
3808 " (signature uvec2\n"
3809 " (parameters\n"
3810 " (declare (in) uvec2 arg0)\n"
3811 " (declare (in) uint arg1))\n"
3812 " ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))\n"
3813 "\n"
3814 " (signature uvec3\n"
3815 " (parameters\n"
3816 " (declare (in) uvec3 arg0)\n"
3817 " (declare (in) uint arg1))\n"
3818 " ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))\n"
3819 "\n"
3820 " (signature uvec4\n"
3821 " (parameters\n"
3822 " (declare (in) uvec4 arg0)\n"
3823 " (declare (in) uint arg1))\n"
3824 " ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))\n"
3825 "))\n"
3826 ""
3827;
3828static const char *builtin_reflect =
3829 "((function reflect\n"
3830 " (signature float\n"
3831 " (parameters\n"
3832 " (declare (in) float i)\n"
3833 " (declare (in) float n))\n"
3834 " ((return (expression float -\n"
3835 " (var_ref i)\n"
3836 " (expression float *\n"
3837 " (constant float (2.0))\n"
3838 " (expression float *\n"
3839 " (expression float dot\n"
3840 " (var_ref n)\n"
3841 " (var_ref i))\n"
3842 " (var_ref n)))))))\n"
3843 "\n"
3844 " (signature vec2\n"
3845 " (parameters\n"
3846 " (declare (in) vec2 i)\n"
3847 " (declare (in) vec2 n))\n"
3848 " ((return (expression vec2 -\n"
3849 " (var_ref i)\n"
3850 " (expression vec2 *\n"
3851 " (constant float (2.0))\n"
3852 " (expression vec2 *\n"
3853 " (expression float dot\n"
3854 " (var_ref n)\n"
3855 " (var_ref i))\n"
3856 " (var_ref n)))))))\n"
3857 "\n"
3858 " (signature vec3\n"
3859 " (parameters\n"
3860 " (declare (in) vec3 i)\n"
3861 " (declare (in) vec3 n))\n"
3862 " ((return (expression vec3 -\n"
3863 " (var_ref i)\n"
3864 " (expression vec3 *\n"
3865 " (constant float (2.0))\n"
3866 " (expression vec3 *\n"
3867 " (expression float dot\n"
3868 " (var_ref n)\n"
3869 " (var_ref i))\n"
3870 " (var_ref n)))))))\n"
3871 "\n"
3872 " (signature vec4\n"
3873 " (parameters\n"
3874 " (declare (in) vec4 i)\n"
3875 " (declare (in) vec4 n))\n"
3876 " ((return (expression vec4 -\n"
3877 " (var_ref i)\n"
3878 " (expression vec4 *\n"
3879 " (constant float (2.0))\n"
3880 " (expression vec4 *\n"
3881 " (expression float dot\n"
3882 " (var_ref n)\n"
3883 " (var_ref i))\n"
3884 " (var_ref n)))))))\n"
3885 "\n"
3886 "))\n"
3887 ""
3888;
3889static const char *builtin_texture3D =
3890 "((function texture3D\n"
3891 " (signature vec4\n"
3892 " (parameters\n"
3893 " (declare (in) sampler3D sampler)\n"
3894 " (declare (in) vec3 P) )\n"
3895 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
3896 "\n"
3897 " (signature vec4\n"
3898 " (parameters\n"
3899 " (declare (in) sampler3D sampler)\n"
3900 " (declare (in) vec3 P) \n"
3901 " (declare (in) float bias) )\n"
3902 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
3903 "\n"
3904 "))\n"
3905 ""
3906;
3907static const char *builtin_texelFetch =
3908 "((function texelFetch\n"
3909 " (signature vec4\n"
3910 " (parameters\n"
3911 " (declare (in) sampler1D sampler)\n"
3912 " (declare (in) int P) \n"
3913 " (declare (in) int lod) )\n"
3914 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3915 "\n"
3916 " (signature ivec4\n"
3917 " (parameters\n"
3918 " (declare (in) isampler1D sampler)\n"
3919 " (declare (in) int P) \n"
3920 " (declare (in) int lod) )\n"
3921 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3922 "\n"
3923 " (signature uvec4\n"
3924 " (parameters\n"
3925 " (declare (in) usampler1D sampler)\n"
3926 " (declare (in) int P) \n"
3927 " (declare (in) int lod) )\n"
3928 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3929 "\n"
3930 " (signature vec4\n"
3931 " (parameters\n"
3932 " (declare (in) sampler2D sampler)\n"
3933 " (declare (in) ivec2 P) \n"
3934 " (declare (in) int lod) )\n"
3935 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3936 "\n"
3937 " (signature ivec4\n"
3938 " (parameters\n"
3939 " (declare (in) isampler2D sampler)\n"
3940 " (declare (in) ivec2 P) \n"
3941 " (declare (in) int lod) )\n"
3942 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3943 "\n"
3944 " (signature uvec4\n"
3945 " (parameters\n"
3946 " (declare (in) usampler2D sampler)\n"
3947 " (declare (in) ivec2 P) \n"
3948 " (declare (in) int lod) )\n"
3949 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3950 "\n"
3951 " (signature vec4\n"
3952 " (parameters\n"
3953 " (declare (in) sampler3D sampler)\n"
3954 " (declare (in) ivec3 P) \n"
3955 " (declare (in) int lod) )\n"
3956 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3957 "\n"
3958 " (signature ivec4\n"
3959 " (parameters\n"
3960 " (declare (in) isampler3D sampler)\n"
3961 " (declare (in) ivec3 P) \n"
3962 " (declare (in) int lod) )\n"
3963 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3964 "\n"
3965 " (signature uvec4\n"
3966 " (parameters\n"
3967 " (declare (in) usampler3D sampler)\n"
3968 " (declare (in) ivec3 P) \n"
3969 " (declare (in) int lod) )\n"
3970 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3971 "\n"
3972 " (signature vec4\n"
3973 " (parameters\n"
3974 " (declare (in) sampler1DArray sampler)\n"
3975 " (declare (in) ivec2 P) \n"
3976 " (declare (in) int lod) )\n"
3977 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3978 "\n"
3979 " (signature ivec4\n"
3980 " (parameters\n"
3981 " (declare (in) isampler1DArray sampler)\n"
3982 " (declare (in) ivec2 P) \n"
3983 " (declare (in) int lod) )\n"
3984 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3985 "\n"
3986 " (signature uvec4\n"
3987 " (parameters\n"
3988 " (declare (in) usampler1DArray sampler)\n"
3989 " (declare (in) ivec2 P) \n"
3990 " (declare (in) int lod) )\n"
3991 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3992 "\n"
3993 " (signature vec4\n"
3994 " (parameters\n"
3995 " (declare (in) sampler2DArray sampler)\n"
3996 " (declare (in) ivec3 P) \n"
3997 " (declare (in) int lod) )\n"
3998 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
3999 "\n"
4000 " (signature ivec4\n"
4001 " (parameters\n"
4002 " (declare (in) isampler2DArray sampler)\n"
4003 " (declare (in) ivec3 P) \n"
4004 " (declare (in) int lod) )\n"
4005 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
4006 "\n"
4007 " (signature uvec4\n"
4008 " (parameters\n"
4009 " (declare (in) usampler2DArray sampler)\n"
4010 " (declare (in) ivec3 P) \n"
4011 " (declare (in) int lod) )\n"
4012 " ((return (txf (var_ref sampler) (var_ref P) (0 0 0) (var_ref lod) ))))\n"
4013 "\n"
4014 "))\n"
4015 ""
4016;
4017static const char *builtin_noise4 =
4018 "((function noise4\n"
4019 " (signature vec4\n"
4020 " (parameters\n"
4021 " (declare (in) float x))\n"
4022 " ((return (constant vec4 (0 0 0 0)))))\n"
4023 " (signature vec4\n"
4024 " (parameters\n"
4025 " (declare (in) vec2 x))\n"
4026 " ((return (constant vec4 (0 0 0 0)))))\n"
4027 " (signature vec4\n"
4028 " (parameters\n"
4029 " (declare (in) vec3 x))\n"
4030 " ((return (constant vec4 (0 0 0 0)))))\n"
4031 " (signature vec4\n"
4032 " (parameters\n"
4033 " (declare (in) vec4 x))\n"
4034 " ((return (constant vec4 (0 0 0 0)))))\n"
4035 "))\n"
4036 ""
4037;
4038static const char *builtin_notEqual =
4039 "((function notEqual\n"
4040 " (signature bvec2\n"
4041 " (parameters\n"
4042 " (declare (in) vec2 arg0)\n"
4043 " (declare (in) vec2 arg1))\n"
4044 " ((declare () bvec2 temp)\n"
4045 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n"
4046 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n"
4047 " (return (var_ref temp))))\n"
4048 "\n"
4049 " (signature bvec3\n"
4050 " (parameters\n"
4051 " (declare (in) vec3 arg0)\n"
4052 " (declare (in) vec3 arg1))\n"
4053 " ((declare () bvec3 temp)\n"
4054 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n"
4055 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n"
4056 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n"
4057 " (return (var_ref temp))))\n"
4058 "\n"
4059 " (signature bvec4\n"
4060 " (parameters\n"
4061 " (declare (in) vec4 arg0)\n"
4062 " (declare (in) vec4 arg1))\n"
4063 " ((declare () bvec4 temp)\n"
4064 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n"
4065 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n"
4066 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n"
4067 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n"
4068 " (return (var_ref temp))))\n"
4069 "\n"
4070 " (signature bvec2\n"
4071 " (parameters\n"
4072 " (declare (in) ivec2 arg0)\n"
4073 " (declare (in) ivec2 arg1))\n"
4074 " ((declare () bvec2 temp)\n"
4075 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n"
4076 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n"
4077 " (return (var_ref temp))))\n"
4078 "\n"
4079 " (signature bvec3\n"
4080 " (parameters\n"
4081 " (declare (in) ivec3 arg0)\n"
4082 " (declare (in) ivec3 arg1))\n"
4083 " ((declare () bvec3 temp)\n"
4084 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n"
4085 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n"
4086 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n"
4087 " (return (var_ref temp))))\n"
4088 "\n"
4089 " (signature bvec4\n"
4090 " (parameters\n"
4091 " (declare (in) ivec4 arg0)\n"
4092 " (declare (in) ivec4 arg1))\n"
4093 " ((declare () bvec4 temp)\n"
4094 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))\n"
4095 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))\n"
4096 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))\n"
4097 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))\n"
4098 " (return (var_ref temp))))\n"
4099 "\n"
4100 " (signature bvec2\n"
4101 " (parameters\n"
4102 " (declare (in) uvec2 arg0)\n"
4103 " (declare (in) uvec2 arg1))\n"
4104 " ((declare () bvec2 temp)\n"
4105 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4106 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4107 " (return (var_ref temp))))\n"
4108 "\n"
4109 " (signature bvec3\n"
4110 " (parameters\n"
4111 " (declare (in) uvec3 arg0)\n"
4112 " (declare (in) uvec3 arg1))\n"
4113 " ((declare () bvec3 temp)\n"
4114 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4115 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4116 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4117 " (return (var_ref temp))))\n"
4118 "\n"
4119 " (signature bvec4\n"
4120 " (parameters\n"
4121 " (declare (in) uvec4 arg0)\n"
4122 " (declare (in) uvec4 arg1))\n"
4123 " ((declare () bvec4 temp)\n"
4124 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4125 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4126 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4127 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
4128 " (return (var_ref temp))))\n"
4129 "))\n"
4130 ""
4131;
4132static const char *builtin_outerProduct =
4133 "((function outerProduct\n"
4134 " (signature mat2\n"
4135 " (parameters\n"
4136 " (declare (in) vec2 u)\n"
4137 " (declare (in) vec2 v))\n"
4138 " ((declare () mat2 m)\n"
4139 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n"
4140 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n"
4141 " (return (var_ref m))))\n"
4142 "\n"
4143 " (signature mat2x3\n"
4144 " (parameters\n"
4145 " (declare (in) vec3 u)\n"
4146 " (declare (in) vec2 v))\n"
4147 " ((declare () mat2x3 m)\n"
4148 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n"
4149 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n"
4150 " (return (var_ref m))))\n"
4151 "\n"
4152 " (signature mat2x4\n"
4153 " (parameters\n"
4154 " (declare (in) vec4 u)\n"
4155 " (declare (in) vec2 v))\n"
4156 " ((declare () mat2x4 m)\n"
4157 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n"
4158 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n"
4159 " (return (var_ref m))))\n"
4160 "\n"
4161 " (signature mat3x2\n"
4162 " (parameters\n"
4163 " (declare (in) vec2 u)\n"
4164 " (declare (in) vec3 v))\n"
4165 " ((declare () mat3x2 m)\n"
4166 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n"
4167 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n"
4168 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n"
4169 " (return (var_ref m))\n"
4170 " ))\n"
4171 "\n"
4172 " (signature mat3\n"
4173 " (parameters\n"
4174 " (declare (in) vec3 u)\n"
4175 " (declare (in) vec3 v))\n"
4176 " ((declare () mat3 m)\n"
4177 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n"
4178 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n"
4179 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n"
4180 " (return (var_ref m))))\n"
4181 "\n"
4182 " (signature mat3x4\n"
4183 " (parameters\n"
4184 " (declare (in) vec4 u)\n"
4185 " (declare (in) vec3 v))\n"
4186 " ((declare () mat3x4 m)\n"
4187 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n"
4188 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n"
4189 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n"
4190 " (return (var_ref m))))\n"
4191 "\n"
4192 " (signature mat4x2\n"
4193 " (parameters\n"
4194 " (declare (in) vec2 u)\n"
4195 " (declare (in) vec4 v))\n"
4196 " ((declare () mat4x2 m)\n"
4197 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))\n"
4198 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))\n"
4199 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))\n"
4200 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))\n"
4201 " (return (var_ref m))))\n"
4202 "\n"
4203 " (signature mat4x3\n"
4204 " (parameters\n"
4205 " (declare (in) vec3 u)\n"
4206 " (declare (in) vec4 v))\n"
4207 " ((declare () mat4x3 m)\n"
4208 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))\n"
4209 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))\n"
4210 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))\n"
4211 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))\n"
4212 " (return (var_ref m))))\n"
4213 "\n"
4214 " (signature mat4\n"
4215 " (parameters\n"
4216 " (declare (in) vec4 u)\n"
4217 " (declare (in) vec4 v))\n"
4218 " ((declare () mat4 m)\n"
4219 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))\n"
4220 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))\n"
4221 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))\n"
4222 " (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))\n"
4223 " (return (var_ref m))))\n"
4224 "))\n"
4225 ""
4226;
4227static const char *builtin_shadow1D =
4228 "((function shadow1D\n"
4229 " (signature vec4\n"
4230 " (parameters\n"
4231 " (declare (in) sampler1DShadow sampler)\n"
4232 " (declare (in) vec3 P) )\n"
4233 " ((return (tex (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n"
4234 "\n"
4235 " (signature vec4\n"
4236 " (parameters\n"
4237 " (declare (in) sampler1DShadow sampler)\n"
4238 " (declare (in) vec3 P) \n"
4239 " (declare (in) float bias) )\n"
4240 " ((return (txb (var_ref sampler) (swiz x (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n"
4241 "\n"
4242 "))\n"
4243 ""
4244;
4245static const char *builtin_noise1 =
4246 "((function noise1\n"
4247 " (signature float\n"
4248 " (parameters\n"
4249 " (declare (in) float x))\n"
4250 " ((return (constant float (0)))))\n"
4251 " (signature float\n"
4252 " (parameters\n"
4253 " (declare (in) vec2 x))\n"
4254 " ((return (constant float (0)))))\n"
4255 " (signature float\n"
4256 " (parameters\n"
4257 " (declare (in) vec3 x))\n"
4258 " ((return (constant float (0)))))\n"
4259 " (signature float\n"
4260 " (parameters\n"
4261 " (declare (in) vec4 x))\n"
4262 " ((return (constant float (0)))))\n"
4263 "))\n"
4264 ""
4265;
4266static const char *builtin_refract =
4267 "((function refract\n"
4268 " (signature float\n"
4269 " (parameters\n"
4270 " (declare (in) float i)\n"
4271 " (declare (in) float n)\n"
4272 " (declare (in) float eta))\n"
4273 " ((declare () float k)\n"
4274 " (assign (constant bool (1)) (var_ref k)\n"
4275 " (expression float - (constant float (1.0))\n"
4276 " (expression float * (var_ref eta)\n"
4277 " (expression float * (var_ref eta)\n"
4278 " (expression float - (constant float (1.0))\n"
4279 " (expression float * \n"
4280 " (expression float dot (var_ref n) (var_ref i))\n"
4281 " (expression float dot (var_ref n) (var_ref i))))))))\n"
4282 " (if (expression bool < (var_ref k) (constant float (0.0)))\n"
4283 " ((return (constant float (0.0))))\n"
4284 " ((return (expression float -\n"
4285 " (expression float * (var_ref eta) (var_ref i))\n"
4286 " (expression float *\n"
4287 " (expression float +\n"
4288 " (expression float * (var_ref eta)\n"
4289 " (expression float dot (var_ref n) (var_ref i)))\n"
4290 " (expression float sqrt (var_ref k)))\n"
4291 " (var_ref n))))))))\n"
4292 "\n"
4293 " (signature vec2\n"
4294 " (parameters\n"
4295 " (declare (in) vec2 i)\n"
4296 " (declare (in) vec2 n)\n"
4297 " (declare (in) float eta))\n"
4298 " ((declare () float k)\n"
4299 " (assign (constant bool (1)) (var_ref k)\n"
4300 " (expression float - (constant float (1.0))\n"
4301 " (expression float * (var_ref eta)\n"
4302 " (expression float * (var_ref eta)\n"
4303 " (expression float - (constant float (1.0))\n"
4304 " (expression float * \n"
4305 " (expression float dot (var_ref n) (var_ref i))\n"
4306 " (expression float dot (var_ref n) (var_ref i))))))))\n"
4307 " (if (expression bool < (var_ref k) (constant float (0.0)))\n"
4308 " ((return (constant vec2 (0.0 0.0))))\n"
4309 " ((return (expression vec2 -\n"
4310 " (expression vec2 * (var_ref eta) (var_ref i))\n"
4311 " (expression vec2 *\n"
4312 " (expression float +\n"
4313 " (expression float * (var_ref eta)\n"
4314 " (expression float dot (var_ref n) (var_ref i)))\n"
4315 " (expression float sqrt (var_ref k)))\n"
4316 " (var_ref n))))))))\n"
4317 "\n"
4318 " (signature vec3\n"
4319 " (parameters\n"
4320 " (declare (in) vec3 i)\n"
4321 " (declare (in) vec3 n)\n"
4322 " (declare (in) float eta))\n"
4323 " ((declare () float k)\n"
4324 " (assign (constant bool (1)) (var_ref k)\n"
4325 " (expression float - (constant float (1.0))\n"
4326 " (expression float * (var_ref eta)\n"
4327 " (expression float * (var_ref eta)\n"
4328 " (expression float - (constant float (1.0))\n"
4329 " (expression float * \n"
4330 " (expression float dot (var_ref n) (var_ref i))\n"
4331 " (expression float dot (var_ref n) (var_ref i))))))))\n"
4332 " (if (expression bool < (var_ref k) (constant float (0.0)))\n"
4333 " ((return (constant vec3 (0.0 0.0 0.0))))\n"
4334 " ((return (expression vec3 -\n"
4335 " (expression vec3 * (var_ref eta) (var_ref i))\n"
4336 " (expression vec3 *\n"
4337 " (expression float +\n"
4338 " (expression float * (var_ref eta)\n"
4339 " (expression float dot (var_ref n) (var_ref i)))\n"
4340 " (expression float sqrt (var_ref k)))\n"
4341 " (var_ref n))))))))\n"
4342 "\n"
4343 " (signature vec4\n"
4344 " (parameters\n"
4345 " (declare (in) vec4 i)\n"
4346 " (declare (in) vec4 n)\n"
4347 " (declare (in) float eta))\n"
4348 " ((declare () float k)\n"
4349 " (assign (constant bool (1)) (var_ref k)\n"
4350 " (expression float - (constant float (1.0))\n"
4351 " (expression float * (var_ref eta)\n"
4352 " (expression float * (var_ref eta)\n"
4353 " (expression float - (constant float (1.0))\n"
4354 " (expression float * \n"
4355 " (expression float dot (var_ref n) (var_ref i))\n"
4356 " (expression float dot (var_ref n) (var_ref i))))))))\n"
4357 " (if (expression bool < (var_ref k) (constant float (0.0)))\n"
4358 " ((return (constant vec4 (0.0 0.0 0.0 0.0))))\n"
4359 " ((return (expression vec4 -\n"
4360 " (expression vec4 * (var_ref eta) (var_ref i))\n"
4361 " (expression vec4 *\n"
4362 " (expression float +\n"
4363 " (expression float * (var_ref eta)\n"
4364 " (expression float dot (var_ref n) (var_ref i)))\n"
4365 " (expression float sqrt (var_ref k)))\n"
4366 " (var_ref n))))))))\n"
4367 "\n"
4368 "))\n"
4369 ""
4370;
4371static const char *builtin_noise3 =
4372 "((function noise3\n"
4373 " (signature vec3\n"
4374 " (parameters\n"
4375 " (declare (in) float x))\n"
4376 " ((return (constant vec3 (0 0 0)))))\n"
4377 " (signature vec3\n"
4378 " (parameters\n"
4379 " (declare (in) vec2 x))\n"
4380 " ((return (constant vec3 (0 0 0)))))\n"
4381 " (signature vec3\n"
4382 " (parameters\n"
4383 " (declare (in) vec3 x))\n"
4384 " ((return (constant vec3 (0 0 0)))))\n"
4385 " (signature vec3\n"
4386 " (parameters\n"
4387 " (declare (in) vec4 x))\n"
4388 " ((return (constant vec3 (0 0 0)))))\n"
4389 "))\n"
4390 ""
4391;
4392static const char *builtin_min =
4393 "((function min\n"
4394 " (signature float\n"
4395 " (parameters\n"
4396 " (declare (in) float arg0)\n"
4397 " (declare (in) float arg1))\n"
4398 " ((return (expression float min (var_ref arg0) (var_ref arg1)))))\n"
4399 "\n"
4400 " (signature vec2\n"
4401 " (parameters\n"
4402 " (declare (in) vec2 arg0)\n"
4403 " (declare (in) vec2 arg1))\n"
4404 " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n"
4405 "\n"
4406 " (signature vec3\n"
4407 " (parameters\n"
4408 " (declare (in) vec3 arg0)\n"
4409 " (declare (in) vec3 arg1))\n"
4410 " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n"
4411 "\n"
4412 " (signature vec4\n"
4413 " (parameters\n"
4414 " (declare (in) vec4 arg0)\n"
4415 " (declare (in) vec4 arg1))\n"
4416 " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n"
4417 "\n"
4418 " (signature vec2\n"
4419 " (parameters\n"
4420 " (declare (in) vec2 arg0)\n"
4421 " (declare (in) float arg1))\n"
4422 " ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))\n"
4423 "\n"
4424 " (signature vec3\n"
4425 " (parameters\n"
4426 " (declare (in) vec3 arg0)\n"
4427 " (declare (in) float arg1))\n"
4428 " ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))\n"
4429 "\n"
4430 " (signature vec4\n"
4431 " (parameters\n"
4432 " (declare (in) vec4 arg0)\n"
4433 " (declare (in) float arg1))\n"
4434 " ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))\n"
4435 "\n"
4436 " (signature int\n"
4437 " (parameters\n"
4438 " (declare (in) int arg0)\n"
4439 " (declare (in) int arg1))\n"
4440 " ((return (expression int min (var_ref arg0) (var_ref arg1)))))\n"
4441 "\n"
4442 " (signature ivec2\n"
4443 " (parameters\n"
4444 " (declare (in) ivec2 arg0)\n"
4445 " (declare (in) ivec2 arg1))\n"
4446 " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n"
4447 "\n"
4448 " (signature ivec3\n"
4449 " (parameters\n"
4450 " (declare (in) ivec3 arg0)\n"
4451 " (declare (in) ivec3 arg1))\n"
4452 " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n"
4453 "\n"
4454 " (signature ivec4\n"
4455 " (parameters\n"
4456 " (declare (in) ivec4 arg0)\n"
4457 " (declare (in) ivec4 arg1))\n"
4458 " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n"
4459 "\n"
4460 " (signature ivec2\n"
4461 " (parameters\n"
4462 " (declare (in) ivec2 arg0)\n"
4463 " (declare (in) int arg1))\n"
4464 " ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))\n"
4465 "\n"
4466 " (signature ivec3\n"
4467 " (parameters\n"
4468 " (declare (in) ivec3 arg0)\n"
4469 " (declare (in) int arg1))\n"
4470 " ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))\n"
4471 "\n"
4472 " (signature ivec4\n"
4473 " (parameters\n"
4474 " (declare (in) ivec4 arg0)\n"
4475 " (declare (in) int arg1))\n"
4476 " ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))\n"
4477 "\n"
4478 " (signature uint\n"
4479 " (parameters\n"
4480 " (declare (in) uint arg0)\n"
4481 " (declare (in) uint arg1))\n"
4482 " ((return (expression uint min (var_ref arg0) (var_ref arg1)))))\n"
4483 "\n"
4484 " (signature uvec2\n"
4485 " (parameters\n"
4486 " (declare (in) uvec2 arg0)\n"
4487 " (declare (in) uvec2 arg1))\n"
4488 " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n"
4489 "\n"
4490 " (signature uvec3\n"
4491 " (parameters\n"
4492 " (declare (in) uvec3 arg0)\n"
4493 " (declare (in) uvec3 arg1))\n"
4494 " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n"
4495 "\n"
4496 " (signature uvec4\n"
4497 " (parameters\n"
4498 " (declare (in) uvec4 arg0)\n"
4499 " (declare (in) uvec4 arg1))\n"
4500 " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n"
4501 "\n"
4502 " (signature uvec2\n"
4503 " (parameters\n"
4504 " (declare (in) uvec2 arg0)\n"
4505 " (declare (in) uint arg1))\n"
4506 " ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))\n"
4507 "\n"
4508 " (signature uvec3\n"
4509 " (parameters\n"
4510 " (declare (in) uvec3 arg0)\n"
4511 " (declare (in) uint arg1))\n"
4512 " ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))\n"
4513 "\n"
4514 " (signature uvec4\n"
4515 " (parameters\n"
4516 " (declare (in) uvec4 arg0)\n"
4517 " (declare (in) uint arg1))\n"
4518 " ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))\n"
4519 "))\n"
4520 ""
4521;
4522static const char *builtin_textureCube =
4523 "((function textureCube\n"
4524 " (signature vec4\n"
4525 " (parameters\n"
4526 " (declare (in) samplerCube sampler)\n"
4527 " (declare (in) vec3 P) )\n"
4528 " ((return (tex (var_ref sampler) (var_ref P) (0 0 0) 1 () ))))\n"
4529 "\n"
4530 " (signature vec4\n"
4531 " (parameters\n"
4532 " (declare (in) samplerCube sampler)\n"
4533 " (declare (in) vec3 P) \n"
4534 " (declare (in) float bias) )\n"
4535 " ((return (txb (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref bias) ))))\n"
4536 "\n"
4537 "))\n"
4538 ""
4539;
4540static const char *builtin_shadow1DArray =
4541 "((function shadow1DArray\n"
4542 " (signature vec4\n"
4543 " (parameters\n"
4544 " (declare (in) sampler1DArrayShadow sampler)\n"
4545 " (declare (in) vec3 P) )\n"
4546 " ((return (tex (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) ))))\n"
4547 "\n"
4548 " (signature vec4\n"
4549 " (parameters\n"
4550 " (declare (in) sampler1DArrayShadow sampler)\n"
4551 " (declare (in) vec3 P) \n"
4552 " (declare (in) float bias) )\n"
4553 " ((return (txb (var_ref sampler) (swiz xy (var_ref P)) (0 0 0) 1 (swiz z (var_ref P)) (var_ref bias) ))))\n"
4554 "\n"
4555 "))\n"
4556 ""
4557;
4558static const char *builtin_exp =
4559 "((function exp\n"
4560 " (signature float\n"
4561 " (parameters\n"
4562 " (declare (in) float arg0))\n"
4563 " ((return (expression float exp (var_ref arg0)))))\n"
4564 "\n"
4565 " (signature vec2\n"
4566 " (parameters\n"
4567 " (declare (in) vec2 arg0))\n"
4568 " ((return (expression vec2 exp (var_ref arg0)))))\n"
4569 "\n"
4570 " (signature vec3\n"
4571 " (parameters\n"
4572 " (declare (in) vec3 arg0))\n"
4573 " ((return (expression vec3 exp (var_ref arg0)))))\n"
4574 "\n"
4575 " (signature vec4\n"
4576 " (parameters\n"
4577 " (declare (in) vec4 arg0))\n"
4578 " ((return (expression vec4 exp (var_ref arg0)))))\n"
4579 "))\n"
4580 ""
4581;
4582static const char *builtin_greaterThan =
4583 "((function greaterThan\n"
4584 " (signature bvec2\n"
4585 " (parameters\n"
4586 " (declare (in) vec2 arg0)\n"
4587 " (declare (in) vec2 arg1))\n"
4588 " ((declare () bvec2 temp)\n"
4589 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4590 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4591 " (return (var_ref temp))))\n"
4592 "\n"
4593 " (signature bvec3\n"
4594 " (parameters\n"
4595 " (declare (in) vec3 arg0)\n"
4596 " (declare (in) vec3 arg1))\n"
4597 " ((declare () bvec3 temp)\n"
4598 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4599 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4600 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4601 " (return (var_ref temp))))\n"
4602 "\n"
4603 " (signature bvec4\n"
4604 " (parameters\n"
4605 " (declare (in) vec4 arg0)\n"
4606 " (declare (in) vec4 arg1))\n"
4607 " ((declare () bvec4 temp)\n"
4608 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4609 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4610 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4611 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
4612 " (return (var_ref temp))))\n"
4613 "\n"
4614 " (signature bvec2\n"
4615 " (parameters\n"
4616 " (declare (in) ivec2 arg0)\n"
4617 " (declare (in) ivec2 arg1))\n"
4618 " ((declare () bvec2 temp)\n"
4619 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4620 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4621 " (return (var_ref temp))))\n"
4622 "\n"
4623 " (signature bvec3\n"
4624 " (parameters\n"
4625 " (declare (in) ivec3 arg0)\n"
4626 " (declare (in) ivec3 arg1))\n"
4627 " ((declare () bvec3 temp)\n"
4628 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4629 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4630 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4631 " (return (var_ref temp))))\n"
4632 "\n"
4633 " (signature bvec4\n"
4634 " (parameters\n"
4635 " (declare (in) ivec4 arg0)\n"
4636 " (declare (in) ivec4 arg1))\n"
4637 " ((declare () bvec4 temp)\n"
4638 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4639 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4640 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4641 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
4642 " (return (var_ref temp))))\n"
4643 "\n"
4644 " (signature bvec2\n"
4645 " (parameters\n"
4646 " (declare (in) uvec2 arg0)\n"
4647 " (declare (in) uvec2 arg1))\n"
4648 " ((declare () bvec2 temp)\n"
4649 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4650 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4651 " (return (var_ref temp))))\n"
4652 "\n"
4653 " (signature bvec3\n"
4654 " (parameters\n"
4655 " (declare (in) uvec3 arg0)\n"
4656 " (declare (in) uvec3 arg1))\n"
4657 " ((declare () bvec3 temp)\n"
4658 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4659 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4660 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4661 " (return (var_ref temp))))\n"
4662 "\n"
4663 " (signature bvec4\n"
4664 " (parameters\n"
4665 " (declare (in) uvec4 arg0)\n"
4666 " (declare (in) uvec4 arg1))\n"
4667 " ((declare () bvec4 temp)\n"
4668 " (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1)))) \n"
4669 " (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1)))) \n"
4670 " (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1)))) \n"
4671 " (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1)))) \n"
4672 " (return (var_ref temp))))\n"
4673 "))\n"
4674 ""
4675;
4676static const char *builtin_texture2DLod =
4677 "((function texture2DLod\n"
4678 " (signature vec4\n"
4679 " (parameters\n"
4680 " (declare (in) sampler2D sampler)\n"
4681 " (declare (in) vec2 P) \n"
4682 " (declare (in) float lod) )\n"
4683 " ((return (txl (var_ref sampler) (var_ref P) (0 0 0) 1 () (var_ref lod) ))))\n"
4684 "\n"
4685 "))\n"
4686 ""
4687;
4688static const char *builtin_dot =
4689 "((function dot\n"
4690 " (signature float\n"
4691 " (parameters\n"
4692 " (declare (in) float arg0)\n"
4693 " (declare (in) float arg1))\n"
4694 " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n"
4695 "\n"
4696 " (signature float\n"
4697 " (parameters\n"
4698 " (declare (in) vec2 arg0)\n"
4699 " (declare (in) vec2 arg1))\n"
4700 " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n"
4701 "\n"
4702 " (signature float\n"
4703 " (parameters\n"
4704 " (declare (in) vec3 arg0)\n"
4705 " (declare (in) vec3 arg1))\n"
4706 " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n"
4707 "\n"
4708 " (signature float\n"
4709 " (parameters\n"
4710 " (declare (in) vec4 arg0)\n"
4711 " (declare (in) vec4 arg1))\n"
4712 " ((return (expression float dot (var_ref arg0) (var_ref arg1)))))\n"
4713 "))\n"
4714 ""
4715;
4716static const char *prototypes_for_120_vert =
4717 "(\n"
4718 "(function radians\n"
4719 " (signature float\n"
4720 " (parameters\n"
4721 " (declare (in ) float degrees@0x13d20b0)\n"
4722 " )\n"
4723 " (\n"
4724 " ))\n"
4725 "\n"
4726 " (signature vec2\n"
4727 " (parameters\n"
4728 " (declare (in ) vec2 degrees@0x13d2430)\n"
4729 " )\n"
4730 " (\n"
4731 " ))\n"
4732 "\n"
4733 " (signature vec3\n"
4734 " (parameters\n"
4735 " (declare (in ) vec3 degrees@0x13d2610)\n"
4736 " )\n"
4737 " (\n"
4738 " ))\n"
4739 "\n"
4740 " (signature vec4\n"
4741 " (parameters\n"
4742 " (declare (in ) vec4 degrees@0x13d27f0)\n"
4743 " )\n"
4744 " (\n"
4745 " ))\n"
4746 "\n"
4747 ")\n"
4748 "\n"
4749 "(function degrees\n"
4750 " (signature float\n"
4751 " (parameters\n"
4752 " (declare (in ) float radians@0x13d29d0)\n"
4753 " )\n"
4754 " (\n"
4755 " ))\n"
4756 "\n"
4757 " (signature vec2\n"
4758 " (parameters\n"
4759 " (declare (in ) vec2 radians@0x13d2d50)\n"
4760 " )\n"
4761 " (\n"
4762 " ))\n"
4763 "\n"
4764 " (signature vec3\n"
4765 " (parameters\n"
4766 " (declare (in ) vec3 radians@0x13d2f30)\n"
4767 " )\n"
4768 " (\n"
4769 " ))\n"
4770 "\n"
4771 " (signature vec4\n"
4772 " (parameters\n"
4773 " (declare (in ) vec4 radians@0x13d3110)\n"
4774 " )\n"
4775 " (\n"
4776 " ))\n"
4777 "\n"
4778 ")\n"
4779 "\n"
4780 "(function sin\n"
4781 " (signature float\n"
4782 " (parameters\n"
4783 " (declare (in ) float angle@0x13d32f0)\n"
4784 " )\n"
4785 " (\n"
4786 " ))\n"
4787 "\n"
4788 " (signature vec2\n"
4789 " (parameters\n"
4790 " (declare (in ) vec2 angle@0x13d3670)\n"
4791 " )\n"
4792 " (\n"
4793 " ))\n"
4794 "\n"
4795 " (signature vec3\n"
4796 " (parameters\n"
4797 " (declare (in ) vec3 angle@0x13d3850)\n"
4798 " )\n"
4799 " (\n"
4800 " ))\n"
4801 "\n"
4802 " (signature vec4\n"
4803 " (parameters\n"
4804 " (declare (in ) vec4 angle@0x13d3a30)\n"
4805 " )\n"
4806 " (\n"
4807 " ))\n"
4808 "\n"
4809 ")\n"
4810 "\n"
4811 "(function cos\n"
4812 " (signature float\n"
4813 " (parameters\n"
4814 " (declare (in ) float angle@0x13d3c10)\n"
4815 " )\n"
4816 " (\n"
4817 " ))\n"
4818 "\n"
4819 " (signature vec2\n"
4820 " (parameters\n"
4821 " (declare (in ) vec2 angle@0x13d3f90)\n"
4822 " )\n"
4823 " (\n"
4824 " ))\n"
4825 "\n"
4826 " (signature vec3\n"
4827 " (parameters\n"
4828 " (declare (in ) vec3 angle@0x13d4170)\n"
4829 " )\n"
4830 " (\n"
4831 " ))\n"
4832 "\n"
4833 " (signature vec4\n"
4834 " (parameters\n"
4835 " (declare (in ) vec4 angle@0x13d4350)\n"
4836 " )\n"
4837 " (\n"
4838 " ))\n"
4839 "\n"
4840 ")\n"
4841 "\n"
4842 "(function tan\n"
4843 " (signature float\n"
4844 " (parameters\n"
4845 " (declare (in ) float angle@0x13d4530)\n"
4846 " )\n"
4847 " (\n"
4848 " ))\n"
4849 "\n"
4850 " (signature vec2\n"
4851 " (parameters\n"
4852 " (declare (in ) vec2 angle@0x13d48b0)\n"
4853 " )\n"
4854 " (\n"
4855 " ))\n"
4856 "\n"
4857 " (signature vec3\n"
4858 " (parameters\n"
4859 " (declare (in ) vec3 angle@0x13d4a90)\n"
4860 " )\n"
4861 " (\n"
4862 " ))\n"
4863 "\n"
4864 " (signature vec4\n"
4865 " (parameters\n"
4866 " (declare (in ) vec4 angle@0x13d4c70)\n"
4867 " )\n"
4868 " (\n"
4869 " ))\n"
4870 "\n"
4871 ")\n"
4872 "\n"
4873 "(function asin\n"
4874 " (signature float\n"
4875 " (parameters\n"
4876 " (declare (in ) float angle@0x13d4e50)\n"
4877 " )\n"
4878 " (\n"
4879 " ))\n"
4880 "\n"
4881 " (signature vec2\n"
4882 " (parameters\n"
4883 " (declare (in ) vec2 angle@0x13d51d0)\n"
4884 " )\n"
4885 " (\n"
4886 " ))\n"
4887 "\n"
4888 " (signature vec3\n"
4889 " (parameters\n"
4890 " (declare (in ) vec3 angle@0x13d53b0)\n"
4891 " )\n"
4892 " (\n"
4893 " ))\n"
4894 "\n"
4895 " (signature vec4\n"
4896 " (parameters\n"
4897 " (declare (in ) vec4 angle@0x13d5590)\n"
4898 " )\n"
4899 " (\n"
4900 " ))\n"
4901 "\n"
4902 ")\n"
4903 "\n"
4904 "(function acos\n"
4905 " (signature float\n"
4906 " (parameters\n"
4907 " (declare (in ) float angle@0x13d5770)\n"
4908 " )\n"
4909 " (\n"
4910 " ))\n"
4911 "\n"
4912 " (signature vec2\n"
4913 " (parameters\n"
4914 " (declare (in ) vec2 angle@0x13d5af0)\n"
4915 " )\n"
4916 " (\n"
4917 " ))\n"
4918 "\n"
4919 " (signature vec3\n"
4920 " (parameters\n"
4921 " (declare (in ) vec3 angle@0x13d5cd0)\n"
4922 " )\n"
4923 " (\n"
4924 " ))\n"
4925 "\n"
4926 " (signature vec4\n"
4927 " (parameters\n"
4928 " (declare (in ) vec4 angle@0x13d5eb0)\n"
4929 " )\n"
4930 " (\n"
4931 " ))\n"
4932 "\n"
4933 ")\n"
4934 "\n"
4935 "(function atan\n"
4936 " (signature float\n"
4937 " (parameters\n"
4938 " (declare (in ) float y@0x13d6090)\n"
4939 " (declare (in ) float x@0x13d61a0)\n"
4940 " )\n"
4941 " (\n"
4942 " ))\n"
4943 "\n"
4944 " (signature vec2\n"
4945 " (parameters\n"
4946 " (declare (in ) vec2 y@0x13d6520)\n"
4947 " (declare (in ) vec2 x@0x13d6630)\n"
4948 " )\n"
4949 " (\n"
4950 " ))\n"
4951 "\n"
4952 " (signature vec3\n"
4953 " (parameters\n"
4954 " (declare (in ) vec3 y@0x13d6810)\n"
4955 " (declare (in ) vec3 x@0x13d6920)\n"
4956 " )\n"
4957 " (\n"
4958 " ))\n"
4959 "\n"
4960 " (signature vec4\n"
4961 " (parameters\n"
4962 " (declare (in ) vec4 y@0x13d6b00)\n"
4963 " (declare (in ) vec4 x@0x13d6c10)\n"
4964 " )\n"
4965 " (\n"
4966 " ))\n"
4967 "\n"
4968 " (signature float\n"
4969 " (parameters\n"
4970 " (declare (in ) float y_over_x@0x13d6df0)\n"
4971 " )\n"
4972 " (\n"
4973 " ))\n"
4974 "\n"
4975 " (signature vec2\n"
4976 " (parameters\n"
4977 " (declare (in ) vec2 y_over_x@0x13d6fe0)\n"
4978 " )\n"
4979 " (\n"
4980 " ))\n"
4981 "\n"
4982 " (signature vec3\n"
4983 " (parameters\n"
4984 " (declare (in ) vec3 y_over_x@0x13d71d0)\n"
4985 " )\n"
4986 " (\n"
4987 " ))\n"
4988 "\n"
4989 " (signature vec4\n"
4990 " (parameters\n"
4991 " (declare (in ) vec4 y_over_x@0x13d73c0)\n"
4992 " )\n"
4993 " (\n"
4994 " ))\n"
4995 "\n"
4996 ")\n"
4997 "\n"
4998 "(function pow\n"
4999 " (signature float\n"
5000 " (parameters\n"
5001 " (declare (in ) float x@0x13d75b0)\n"
5002 " (declare (in ) float y@0x13d76c0)\n"
5003 " )\n"
5004 " (\n"
5005 " ))\n"
5006 "\n"
5007 " (signature vec2\n"
5008 " (parameters\n"
5009 " (declare (in ) vec2 x@0x13d7a40)\n"
5010 " (declare (in ) vec2 y@0x13d7b50)\n"
5011 " )\n"
5012 " (\n"
5013 " ))\n"
5014 "\n"
5015 " (signature vec3\n"
5016 " (parameters\n"
5017 " (declare (in ) vec3 x@0x13d7d30)\n"
5018 " (declare (in ) vec3 y@0x13d7e40)\n"
5019 " )\n"
5020 " (\n"
5021 " ))\n"
5022 "\n"
5023 " (signature vec4\n"
5024 " (parameters\n"
5025 " (declare (in ) vec4 x@0x13d8020)\n"
5026 " (declare (in ) vec4 y@0x13d8130)\n"
5027 " )\n"
5028 " (\n"
5029 " ))\n"
5030 "\n"
5031 ")\n"
5032 "\n"
5033 "(function exp\n"
5034 " (signature float\n"
5035 " (parameters\n"
5036 " (declare (in ) float x@0x13d8310)\n"
5037 " )\n"
5038 " (\n"
5039 " ))\n"
5040 "\n"
5041 " (signature vec2\n"
5042 " (parameters\n"
5043 " (declare (in ) vec2 x@0x13d8690)\n"
5044 " )\n"
5045 " (\n"
5046 " ))\n"
5047 "\n"
5048 " (signature vec3\n"
5049 " (parameters\n"
5050 " (declare (in ) vec3 x@0x13d8870)\n"
5051 " )\n"
5052 " (\n"
5053 " ))\n"
5054 "\n"
5055 " (signature vec4\n"
5056 " (parameters\n"
5057 " (declare (in ) vec4 x@0x13d8a50)\n"
5058 " )\n"
5059 " (\n"
5060 " ))\n"
5061 "\n"
5062 ")\n"
5063 "\n"
5064 "(function log\n"
5065 " (signature float\n"
5066 " (parameters\n"
5067 " (declare (in ) float x@0x13d8c30)\n"
5068 " )\n"
5069 " (\n"
5070 " ))\n"
5071 "\n"
5072 " (signature vec2\n"
5073 " (parameters\n"
5074 " (declare (in ) vec2 x@0x13d8fb0)\n"
5075 " )\n"
5076 " (\n"
5077 " ))\n"
5078 "\n"
5079 " (signature vec3\n"
5080 " (parameters\n"
5081 " (declare (in ) vec3 x@0x13d9190)\n"
5082 " )\n"
5083 " (\n"
5084 " ))\n"
5085 "\n"
5086 " (signature vec4\n"
5087 " (parameters\n"
5088 " (declare (in ) vec4 x@0x13d9370)\n"
5089 " )\n"
5090 " (\n"
5091 " ))\n"
5092 "\n"
5093 ")\n"
5094 "\n"
5095 "(function exp2\n"
5096 " (signature float\n"
5097 " (parameters\n"
5098 " (declare (in ) float x@0x13d9550)\n"
5099 " )\n"
5100 " (\n"
5101 " ))\n"
5102 "\n"
5103 " (signature vec2\n"
5104 " (parameters\n"
5105 " (declare (in ) vec2 x@0x13d98d0)\n"
5106 " )\n"
5107 " (\n"
5108 " ))\n"
5109 "\n"
5110 " (signature vec3\n"
5111 " (parameters\n"
5112 " (declare (in ) vec3 x@0x13d9ab0)\n"
5113 " )\n"
5114 " (\n"
5115 " ))\n"
5116 "\n"
5117 " (signature vec4\n"
5118 " (parameters\n"
5119 " (declare (in ) vec4 x@0x13d9c90)\n"
5120 " )\n"
5121 " (\n"
5122 " ))\n"
5123 "\n"
5124 ")\n"
5125 "\n"
5126 "(function log2\n"
5127 " (signature float\n"
5128 " (parameters\n"
5129 " (declare (in ) float x@0x13d9e70)\n"
5130 " )\n"
5131 " (\n"
5132 " ))\n"
5133 "\n"
5134 " (signature vec2\n"
5135 " (parameters\n"
5136 " (declare (in ) vec2 x@0x13da1f0)\n"
5137 " )\n"
5138 " (\n"
5139 " ))\n"
5140 "\n"
5141 " (signature vec3\n"
5142 " (parameters\n"
5143 " (declare (in ) vec3 x@0x13da3d0)\n"
5144 " )\n"
5145 " (\n"
5146 " ))\n"
5147 "\n"
5148 " (signature vec4\n"
5149 " (parameters\n"
5150 " (declare (in ) vec4 x@0x13da5b0)\n"
5151 " )\n"
5152 " (\n"
5153 " ))\n"
5154 "\n"
5155 ")\n"
5156 "\n"
5157 "(function sqrt\n"
5158 " (signature float\n"
5159 " (parameters\n"
5160 " (declare (in ) float x@0x13da790)\n"
5161 " )\n"
5162 " (\n"
5163 " ))\n"
5164 "\n"
5165 " (signature vec2\n"
5166 " (parameters\n"
5167 " (declare (in ) vec2 x@0x13dab10)\n"
5168 " )\n"
5169 " (\n"
5170 " ))\n"
5171 "\n"
5172 " (signature vec3\n"
5173 " (parameters\n"
5174 " (declare (in ) vec3 x@0x13dacf0)\n"
5175 " )\n"
5176 " (\n"
5177 " ))\n"
5178 "\n"
5179 " (signature vec4\n"
5180 " (parameters\n"
5181 " (declare (in ) vec4 x@0x13daed0)\n"
5182 " )\n"
5183 " (\n"
5184 " ))\n"
5185 "\n"
5186 ")\n"
5187 "\n"
5188 "(function inversesqrt\n"
5189 " (signature float\n"
5190 " (parameters\n"
5191 " (declare (in ) float x@0x13db0b0)\n"
5192 " )\n"
5193 " (\n"
5194 " ))\n"
5195 "\n"
5196 " (signature vec2\n"
5197 " (parameters\n"
5198 " (declare (in ) vec2 x@0x13db440)\n"
5199 " )\n"
5200 " (\n"
5201 " ))\n"
5202 "\n"
5203 " (signature vec3\n"
5204 " (parameters\n"
5205 " (declare (in ) vec3 x@0x13db620)\n"
5206 " )\n"
5207 " (\n"
5208 " ))\n"
5209 "\n"
5210 " (signature vec4\n"
5211 " (parameters\n"
5212 " (declare (in ) vec4 x@0x13db800)\n"
5213 " )\n"
5214 " (\n"
5215 " ))\n"
5216 "\n"
5217 ")\n"
5218 "\n"
5219 "(function abs\n"
5220 " (signature float\n"
5221 " (parameters\n"
5222 " (declare (in ) float x@0x13db9e0)\n"
5223 " )\n"
5224 " (\n"
5225 " ))\n"
5226 "\n"
5227 " (signature vec2\n"
5228 " (parameters\n"
5229 " (declare (in ) vec2 x@0x13dbd60)\n"
5230 " )\n"
5231 " (\n"
5232 " ))\n"
5233 "\n"
5234 " (signature vec3\n"
5235 " (parameters\n"
5236 " (declare (in ) vec3 x@0x13dbf40)\n"
5237 " )\n"
5238 " (\n"
5239 " ))\n"
5240 "\n"
5241 " (signature vec4\n"
5242 " (parameters\n"
5243 " (declare (in ) vec4 x@0x13dc120)\n"
5244 " )\n"
5245 " (\n"
5246 " ))\n"
5247 "\n"
5248 ")\n"
5249 "\n"
5250 "(function sign\n"
5251 " (signature float\n"
5252 " (parameters\n"
5253 " (declare (in ) float x@0x13dc300)\n"
5254 " )\n"
5255 " (\n"
5256 " ))\n"
5257 "\n"
5258 " (signature vec2\n"
5259 " (parameters\n"
5260 " (declare (in ) vec2 x@0x13dc680)\n"
5261 " )\n"
5262 " (\n"
5263 " ))\n"
5264 "\n"
5265 " (signature vec3\n"
5266 " (parameters\n"
5267 " (declare (in ) vec3 x@0x13dc860)\n"
5268 " )\n"
5269 " (\n"
5270 " ))\n"
5271 "\n"
5272 " (signature vec4\n"
5273 " (parameters\n"
5274 " (declare (in ) vec4 x@0x13dca40)\n"
5275 " )\n"
5276 " (\n"
5277 " ))\n"
5278 "\n"
5279 ")\n"
5280 "\n"
5281 "(function floor\n"
5282 " (signature float\n"
5283 " (parameters\n"
5284 " (declare (in ) float x@0x13dcc20)\n"
5285 " )\n"
5286 " (\n"
5287 " ))\n"
5288 "\n"
5289 " (signature vec2\n"
5290 " (parameters\n"
5291 " (declare (in ) vec2 x@0x13dcfa0)\n"
5292 " )\n"
5293 " (\n"
5294 " ))\n"
5295 "\n"
5296 " (signature vec3\n"
5297 " (parameters\n"
5298 " (declare (in ) vec3 x@0x13dd180)\n"
5299 " )\n"
5300 " (\n"
5301 " ))\n"
5302 "\n"
5303 " (signature vec4\n"
5304 " (parameters\n"
5305 " (declare (in ) vec4 x@0x13dd360)\n"
5306 " )\n"
5307 " (\n"
5308 " ))\n"
5309 "\n"
5310 ")\n"
5311 "\n"
5312 "(function ceil\n"
5313 " (signature float\n"
5314 " (parameters\n"
5315 " (declare (in ) float x@0x13dd540)\n"
5316 " )\n"
5317 " (\n"
5318 " ))\n"
5319 "\n"
5320 " (signature vec2\n"
5321 " (parameters\n"
5322 " (declare (in ) vec2 x@0x13dd8c0)\n"
5323 " )\n"
5324 " (\n"
5325 " ))\n"
5326 "\n"
5327 " (signature vec3\n"
5328 " (parameters\n"
5329 " (declare (in ) vec3 x@0x13ddaa0)\n"
5330 " )\n"
5331 " (\n"
5332 " ))\n"
5333 "\n"
5334 " (signature vec4\n"
5335 " (parameters\n"
5336 " (declare (in ) vec4 x@0x13ddc80)\n"
5337 " )\n"
5338 " (\n"
5339 " ))\n"
5340 "\n"
5341 ")\n"
5342 "\n"
5343 "(function fract\n"
5344 " (signature float\n"
5345 " (parameters\n"
5346 " (declare (in ) float x@0x13dde60)\n"
5347 " )\n"
5348 " (\n"
5349 " ))\n"
5350 "\n"
5351 " (signature vec2\n"
5352 " (parameters\n"
5353 " (declare (in ) vec2 x@0x13de1e0)\n"
5354 " )\n"
5355 " (\n"
5356 " ))\n"
5357 "\n"
5358 " (signature vec3\n"
5359 " (parameters\n"
5360 " (declare (in ) vec3 x@0x13de3c0)\n"
5361 " )\n"
5362 " (\n"
5363 " ))\n"
5364 "\n"
5365 " (signature vec4\n"
5366 " (parameters\n"
5367 " (declare (in ) vec4 x@0x13de5a0)\n"
5368 " )\n"
5369 " (\n"
5370 " ))\n"
5371 "\n"
5372 ")\n"
5373 "\n"
5374 "(function mod\n"
5375 " (signature float\n"
5376 " (parameters\n"
5377 " (declare (in ) float x@0x13de780)\n"
5378 " (declare (in ) float y@0x13de890)\n"
5379 " )\n"
5380 " (\n"
5381 " ))\n"
5382 "\n"
5383 " (signature vec2\n"
5384 " (parameters\n"
5385 " (declare (in ) vec2 x@0x13dec10)\n"
5386 " (declare (in ) float y@0x13ded20)\n"
5387 " )\n"
5388 " (\n"
5389 " ))\n"
5390 "\n"
5391 " (signature vec3\n"
5392 " (parameters\n"
5393 " (declare (in ) vec3 x@0x13def00)\n"
5394 " (declare (in ) float y@0x13df010)\n"
5395 " )\n"
5396 " (\n"
5397 " ))\n"
5398 "\n"
5399 " (signature vec4\n"
5400 " (parameters\n"
5401 " (declare (in ) vec4 x@0x13df1f0)\n"
5402 " (declare (in ) float y@0x13df300)\n"
5403 " )\n"
5404 " (\n"
5405 " ))\n"
5406 "\n"
5407 " (signature vec2\n"
5408 " (parameters\n"
5409 " (declare (in ) vec2 x@0x13df4e0)\n"
5410 " (declare (in ) vec2 y@0x13df5f0)\n"
5411 " )\n"
5412 " (\n"
5413 " ))\n"
5414 "\n"
5415 " (signature vec3\n"
5416 " (parameters\n"
5417 " (declare (in ) vec3 x@0x13df7d0)\n"
5418 " (declare (in ) vec3 y@0x13df8e0)\n"
5419 " )\n"
5420 " (\n"
5421 " ))\n"
5422 "\n"
5423 " (signature vec4\n"
5424 " (parameters\n"
5425 " (declare (in ) vec4 x@0x13dfac0)\n"
5426 " (declare (in ) vec4 y@0x13dfbd0)\n"
5427 " )\n"
5428 " (\n"
5429 " ))\n"
5430 "\n"
5431 ")\n"
5432 "\n"
5433 "(function min\n"
5434 " (signature float\n"
5435 " (parameters\n"
5436 " (declare (in ) float x@0x13dfdb0)\n"
5437 " (declare (in ) float y@0x13dfec0)\n"
5438 " )\n"
5439 " (\n"
5440 " ))\n"
5441 "\n"
5442 " (signature vec2\n"
5443 " (parameters\n"
5444 " (declare (in ) vec2 x@0x13e0240)\n"
5445 " (declare (in ) vec2 y@0x13e0350)\n"
5446 " )\n"
5447 " (\n"
5448 " ))\n"
5449 "\n"
5450 " (signature vec3\n"
5451 " (parameters\n"
5452 " (declare (in ) vec3 x@0x13e0530)\n"
5453 " (declare (in ) vec3 y@0x13e0640)\n"
5454 " )\n"
5455 " (\n"
5456 " ))\n"
5457 "\n"
5458 " (signature vec4\n"
5459 " (parameters\n"
5460 " (declare (in ) vec4 x@0x13e0820)\n"
5461 " (declare (in ) vec4 y@0x13e0930)\n"
5462 " )\n"
5463 " (\n"
5464 " ))\n"
5465 "\n"
5466 " (signature vec2\n"
5467 " (parameters\n"
5468 " (declare (in ) vec2 x@0x13e0b10)\n"
5469 " (declare (in ) float y@0x13e0c20)\n"
5470 " )\n"
5471 " (\n"
5472 " ))\n"
5473 "\n"
5474 " (signature vec3\n"
5475 " (parameters\n"
5476 " (declare (in ) vec3 x@0x13e0e00)\n"
5477 " (declare (in ) float y@0x13e0f10)\n"
5478 " )\n"
5479 " (\n"
5480 " ))\n"
5481 "\n"
5482 " (signature vec4\n"
5483 " (parameters\n"
5484 " (declare (in ) vec4 x@0x13e10f0)\n"
5485 " (declare (in ) float y@0x13e1200)\n"
5486 " )\n"
5487 " (\n"
5488 " ))\n"
5489 "\n"
5490 ")\n"
5491 "\n"
5492 "(function max\n"
5493 " (signature float\n"
5494 " (parameters\n"
5495 " (declare (in ) float x@0x13e13e0)\n"
5496 " (declare (in ) float y@0x13e14f0)\n"
5497 " )\n"
5498 " (\n"
5499 " ))\n"
5500 "\n"
5501 " (signature vec2\n"
5502 " (parameters\n"
5503 " (declare (in ) vec2 x@0x13e1870)\n"
5504 " (declare (in ) vec2 y@0x13e1980)\n"
5505 " )\n"
5506 " (\n"
5507 " ))\n"
5508 "\n"
5509 " (signature vec3\n"
5510 " (parameters\n"
5511 " (declare (in ) vec3 x@0x13e1b60)\n"
5512 " (declare (in ) vec3 y@0x13e1c70)\n"
5513 " )\n"
5514 " (\n"
5515 " ))\n"
5516 "\n"
5517 " (signature vec4\n"
5518 " (parameters\n"
5519 " (declare (in ) vec4 x@0x13e1e50)\n"
5520 " (declare (in ) vec4 y@0x13e1f60)\n"
5521 " )\n"
5522 " (\n"
5523 " ))\n"
5524 "\n"
5525 " (signature vec2\n"
5526 " (parameters\n"
5527 " (declare (in ) vec2 x@0x13e2140)\n"
5528 " (declare (in ) float y@0x13e2250)\n"
5529 " )\n"
5530 " (\n"
5531 " ))\n"
5532 "\n"
5533 " (signature vec3\n"
5534 " (parameters\n"
5535 " (declare (in ) vec3 x@0x13e2430)\n"
5536 " (declare (in ) float y@0x13e2540)\n"
5537 " )\n"
5538 " (\n"
5539 " ))\n"
5540 "\n"
5541 " (signature vec4\n"
5542 " (parameters\n"
5543 " (declare (in ) vec4 x@0x13e2720)\n"
5544 " (declare (in ) float y@0x13e2830)\n"
5545 " )\n"
5546 " (\n"
5547 " ))\n"
5548 "\n"
5549 ")\n"
5550 "\n"
5551 "(function clamp\n"
5552 " (signature float\n"
5553 " (parameters\n"
5554 " (declare (in ) float x@0x13e2a10)\n"
5555 " (declare (in ) float minVal@0x13e2b20)\n"
5556 " (declare (in ) float maxVal@0x13e2c30)\n"
5557 " )\n"
5558 " (\n"
5559 " ))\n"
5560 "\n"
5561 " (signature vec2\n"
5562 " (parameters\n"
5563 " (declare (in ) vec2 x@0x13e2fb0)\n"
5564 " (declare (in ) vec2 minVal@0x13e30c0)\n"
5565 " (declare (in ) vec2 maxVal@0x13e31d0)\n"
5566 " )\n"
5567 " (\n"
5568 " ))\n"
5569 "\n"
5570 " (signature vec3\n"
5571 " (parameters\n"
5572 " (declare (in ) vec3 x@0x13e33b0)\n"
5573 " (declare (in ) vec3 minVal@0x13e34c0)\n"
5574 " (declare (in ) vec3 maxVal@0x13e35d0)\n"
5575 " )\n"
5576 " (\n"
5577 " ))\n"
5578 "\n"
5579 " (signature vec4\n"
5580 " (parameters\n"
5581 " (declare (in ) vec4 x@0x13e37b0)\n"
5582 " (declare (in ) vec4 minVal@0x13e38c0)\n"
5583 " (declare (in ) vec4 maxVal@0x13e39d0)\n"
5584 " )\n"
5585 " (\n"
5586 " ))\n"
5587 "\n"
5588 " (signature vec2\n"
5589 " (parameters\n"
5590 " (declare (in ) vec2 x@0x13e3bb0)\n"
5591 " (declare (in ) float minVal@0x13e3cc0)\n"
5592 " (declare (in ) float maxVal@0x13e3dd0)\n"
5593 " )\n"
5594 " (\n"
5595 " ))\n"
5596 "\n"
5597 " (signature vec3\n"
5598 " (parameters\n"
5599 " (declare (in ) vec3 x@0x13e3fb0)\n"
5600 " (declare (in ) float minVal@0x13e40c0)\n"
5601 " (declare (in ) float maxVal@0x13e41d0)\n"
5602 " )\n"
5603 " (\n"
5604 " ))\n"
5605 "\n"
5606 " (signature vec4\n"
5607 " (parameters\n"
5608 " (declare (in ) vec4 x@0x13e43b0)\n"
5609 " (declare (in ) float minVal@0x13e44c0)\n"
5610 " (declare (in ) float maxVal@0x13e45d0)\n"
5611 " )\n"
5612 " (\n"
5613 " ))\n"
5614 "\n"
5615 ")\n"
5616 "\n"
5617 "(function mix\n"
5618 " (signature float\n"
5619 " (parameters\n"
5620 " (declare (in ) float x@0x13e47b0)\n"
5621 " (declare (in ) float y@0x13e48c0)\n"
5622 " (declare (in ) float a@0x13e49d0)\n"
5623 " )\n"
5624 " (\n"
5625 " ))\n"
5626 "\n"
5627 " (signature vec2\n"
5628 " (parameters\n"
5629 " (declare (in ) vec2 x@0x13e4d50)\n"
5630 " (declare (in ) vec2 y@0x13e4e60)\n"
5631 " (declare (in ) vec2 a@0x13e4f70)\n"
5632 " )\n"
5633 " (\n"
5634 " ))\n"
5635 "\n"
5636 " (signature vec3\n"
5637 " (parameters\n"
5638 " (declare (in ) vec3 x@0x13e5150)\n"
5639 " (declare (in ) vec3 y@0x13e5260)\n"
5640 " (declare (in ) vec3 a@0x13e5370)\n"
5641 " )\n"
5642 " (\n"
5643 " ))\n"
5644 "\n"
5645 " (signature vec4\n"
5646 " (parameters\n"
5647 " (declare (in ) vec4 x@0x13e5550)\n"
5648 " (declare (in ) vec4 y@0x13e5660)\n"
5649 " (declare (in ) vec4 a@0x13e5770)\n"
5650 " )\n"
5651 " (\n"
5652 " ))\n"
5653 "\n"
5654 " (signature vec2\n"
5655 " (parameters\n"
5656 " (declare (in ) vec2 x@0x13e5950)\n"
5657 " (declare (in ) vec2 y@0x13e5a60)\n"
5658 " (declare (in ) float a@0x13e5b70)\n"
5659 " )\n"
5660 " (\n"
5661 " ))\n"
5662 "\n"
5663 " (signature vec3\n"
5664 " (parameters\n"
5665 " (declare (in ) vec3 x@0x13e5d50)\n"
5666 " (declare (in ) vec3 y@0x13e5e60)\n"
5667 " (declare (in ) float a@0x13e5f70)\n"
5668 " )\n"
5669 " (\n"
5670 " ))\n"
5671 "\n"
5672 " (signature vec4\n"
5673 " (parameters\n"
5674 " (declare (in ) vec4 x@0x13e6150)\n"
5675 " (declare (in ) vec4 y@0x13e6260)\n"
5676 " (declare (in ) float a@0x13e6370)\n"
5677 " )\n"
5678 " (\n"
5679 " ))\n"
5680 "\n"
5681 ")\n"
5682 "\n"
5683 "(function step\n"
5684 " (signature float\n"
5685 " (parameters\n"
5686 " (declare (in ) float edge@0x13e6550)\n"
5687 " (declare (in ) float x@0x13e6660)\n"
5688 " )\n"
5689 " (\n"
5690 " ))\n"
5691 "\n"
5692 " (signature vec2\n"
5693 " (parameters\n"
5694 " (declare (in ) vec2 edge@0x13e69e0)\n"
5695 " (declare (in ) vec2 x@0x13e6af0)\n"
5696 " )\n"
5697 " (\n"
5698 " ))\n"
5699 "\n"
5700 " (signature vec3\n"
5701 " (parameters\n"
5702 " (declare (in ) vec3 edge@0x13e6cd0)\n"
5703 " (declare (in ) vec3 x@0x13e6de0)\n"
5704 " )\n"
5705 " (\n"
5706 " ))\n"
5707 "\n"
5708 " (signature vec4\n"
5709 " (parameters\n"
5710 " (declare (in ) vec4 edge@0x13e6fc0)\n"
5711 " (declare (in ) vec4 x@0x13e70d0)\n"
5712 " )\n"
5713 " (\n"
5714 " ))\n"
5715 "\n"
5716 " (signature vec2\n"
5717 " (parameters\n"
5718 " (declare (in ) float edge@0x13e72b0)\n"
5719 " (declare (in ) vec2 x@0x13e73c0)\n"
5720 " )\n"
5721 " (\n"
5722 " ))\n"
5723 "\n"
5724 " (signature vec3\n"
5725 " (parameters\n"
5726 " (declare (in ) float edge@0x13e75a0)\n"
5727 " (declare (in ) vec3 x@0x13e76b0)\n"
5728 " )\n"
5729 " (\n"
5730 " ))\n"
5731 "\n"
5732 " (signature vec4\n"
5733 " (parameters\n"
5734 " (declare (in ) float edge@0x13e7890)\n"
5735 " (declare (in ) vec4 x@0x13e79a0)\n"
5736 " )\n"
5737 " (\n"
5738 " ))\n"
5739 "\n"
5740 ")\n"
5741 "\n"
5742 "(function smoothstep\n"
5743 " (signature float\n"
5744 " (parameters\n"
5745 " (declare (in ) float edge0@0x13e7b80)\n"
5746 " (declare (in ) float edge1@0x13e7c90)\n"
5747 " (declare (in ) float x@0x13e7da0)\n"
5748 " )\n"
5749 " (\n"
5750 " ))\n"
5751 "\n"
5752 " (signature vec2\n"
5753 " (parameters\n"
5754 " (declare (in ) vec2 edge0@0x13e8130)\n"
5755 " (declare (in ) vec2 edge1@0x13e8240)\n"
5756 " (declare (in ) vec2 x@0x13e8350)\n"
5757 " )\n"
5758 " (\n"
5759 " ))\n"
5760 "\n"
5761 " (signature vec3\n"
5762 " (parameters\n"
5763 " (declare (in ) vec3 edge0@0x13e8530)\n"
5764 " (declare (in ) vec3 edge1@0x13e8640)\n"
5765 " (declare (in ) vec3 x@0x13e8750)\n"
5766 " )\n"
5767 " (\n"
5768 " ))\n"
5769 "\n"
5770 " (signature vec4\n"
5771 " (parameters\n"
5772 " (declare (in ) vec4 edge0@0x13e8930)\n"
5773 " (declare (in ) vec4 edge1@0x13e8a40)\n"
5774 " (declare (in ) vec4 x@0x13e8b50)\n"
5775 " )\n"
5776 " (\n"
5777 " ))\n"
5778 "\n"
5779 " (signature vec2\n"
5780 " (parameters\n"
5781 " (declare (in ) float edge0@0x13e8d30)\n"
5782 " (declare (in ) float edge1@0x13e8e40)\n"
5783 " (declare (in ) vec2 x@0x13e8f50)\n"
5784 " )\n"
5785 " (\n"
5786 " ))\n"
5787 "\n"
5788 " (signature vec3\n"
5789 " (parameters\n"
5790 " (declare (in ) float edge0@0x13e9130)\n"
5791 " (declare (in ) float edge1@0x13e9240)\n"
5792 " (declare (in ) vec3 x@0x13e9350)\n"
5793 " )\n"
5794 " (\n"
5795 " ))\n"
5796 "\n"
5797 " (signature vec4\n"
5798 " (parameters\n"
5799 " (declare (in ) float edge0@0x13e9530)\n"
5800 " (declare (in ) float edge1@0x13e9640)\n"
5801 " (declare (in ) vec4 x@0x13e9750)\n"
5802 " )\n"
5803 " (\n"
5804 " ))\n"
5805 "\n"
5806 ")\n"
5807 "\n"
5808 "(function length\n"
5809 " (signature float\n"
5810 " (parameters\n"
5811 " (declare (in ) float x@0x13e9930)\n"
5812 " )\n"
5813 " (\n"
5814 " ))\n"
5815 "\n"
5816 " (signature float\n"
5817 " (parameters\n"
5818 " (declare (in ) vec2 x@0x13e9cb0)\n"
5819 " )\n"
5820 " (\n"
5821 " ))\n"
5822 "\n"
5823 " (signature float\n"
5824 " (parameters\n"
5825 " (declare (in ) vec3 x@0x13e9e90)\n"
5826 " )\n"
5827 " (\n"
5828 " ))\n"
5829 "\n"
5830 " (signature float\n"
5831 " (parameters\n"
5832 " (declare (in ) vec4 x@0x13ea070)\n"
5833 " )\n"
5834 " (\n"
5835 " ))\n"
5836 "\n"
5837 ")\n"
5838 "\n"
5839 "(function distance\n"
5840 " (signature float\n"
5841 " (parameters\n"
5842 " (declare (in ) float p0@0x13ea250)\n"
5843 " (declare (in ) float p1@0x13ea360)\n"
5844 " )\n"
5845 " (\n"
5846 " ))\n"
5847 "\n"
5848 " (signature float\n"
5849 " (parameters\n"
5850 " (declare (in ) vec2 p0@0x13ea6f0)\n"
5851 " (declare (in ) vec2 p1@0x13ea800)\n"
5852 " )\n"
5853 " (\n"
5854 " ))\n"
5855 "\n"
5856 " (signature float\n"
5857 " (parameters\n"
5858 " (declare (in ) vec3 p0@0x13ea9e0)\n"
5859 " (declare (in ) vec3 p1@0x13eaaf0)\n"
5860 " )\n"
5861 " (\n"
5862 " ))\n"
5863 "\n"
5864 " (signature float\n"
5865 " (parameters\n"
5866 " (declare (in ) vec4 p0@0x13eacd0)\n"
5867 " (declare (in ) vec4 p1@0x13eade0)\n"
5868 " )\n"
5869 " (\n"
5870 " ))\n"
5871 "\n"
5872 ")\n"
5873 "\n"
5874 "(function dot\n"
5875 " (signature float\n"
5876 " (parameters\n"
5877 " (declare (in ) float x@0x13eafc0)\n"
5878 " (declare (in ) float y@0x13eb0d0)\n"
5879 " )\n"
5880 " (\n"
5881 " ))\n"
5882 "\n"
5883 " (signature float\n"
5884 " (parameters\n"
5885 " (declare (in ) vec2 x@0x13eb450)\n"
5886 " (declare (in ) vec2 y@0x13eb560)\n"
5887 " )\n"
5888 " (\n"
5889 " ))\n"
5890 "\n"
5891 " (signature float\n"
5892 " (parameters\n"
5893 " (declare (in ) vec3 x@0x13eb740)\n"
5894 " (declare (in ) vec3 y@0x13eb850)\n"
5895 " )\n"
5896 " (\n"
5897 " ))\n"
5898 "\n"
5899 " (signature float\n"
5900 " (parameters\n"
5901 " (declare (in ) vec4 x@0x13eba30)\n"
5902 " (declare (in ) vec4 y@0x13ebb40)\n"
5903 " )\n"
5904 " (\n"
5905 " ))\n"
5906 "\n"
5907 ")\n"
5908 "\n"
5909 "(function cross\n"
5910 " (signature vec3\n"
5911 " (parameters\n"
5912 " (declare (in ) vec3 x@0x13ebd20)\n"
5913 " (declare (in ) vec3 y@0x13ebe30)\n"
5914 " )\n"
5915 " (\n"
5916 " ))\n"
5917 "\n"
5918 ")\n"
5919 "\n"
5920 "(function normalize\n"
5921 " (signature float\n"
5922 " (parameters\n"
5923 " (declare (in ) float x@0x13ec1b0)\n"
5924 " )\n"
5925 " (\n"
5926 " ))\n"
5927 "\n"
5928 " (signature vec2\n"
5929 " (parameters\n"
5930 " (declare (in ) vec2 x@0x13ec540)\n"
5931 " )\n"
5932 " (\n"
5933 " ))\n"
5934 "\n"
5935 " (signature vec3\n"
5936 " (parameters\n"
5937 " (declare (in ) vec3 x@0x13ec720)\n"
5938 " )\n"
5939 " (\n"
5940 " ))\n"
5941 "\n"
5942 " (signature vec4\n"
5943 " (parameters\n"
5944 " (declare (in ) vec4 x@0x13ec900)\n"
5945 " )\n"
5946 " (\n"
5947 " ))\n"
5948 "\n"
5949 ")\n"
5950 "\n"
5951 "(function ftransform\n"
5952 " (signature vec4\n"
5953 " (parameters\n"
5954 " )\n"
5955 " (\n"
5956 " ))\n"
5957 "\n"
5958 ")\n"
5959 "\n"
5960 "(function faceforward\n"
5961 " (signature float\n"
5962 " (parameters\n"
5963 " (declare (in ) float N@0x13ecd60)\n"
5964 " (declare (in ) float I@0x13ece70)\n"
5965 " (declare (in ) float Nref@0x13ecf80)\n"
5966 " )\n"
5967 " (\n"
5968 " ))\n"
5969 "\n"
5970 " (signature vec2\n"
5971 " (parameters\n"
5972 " (declare (in ) vec2 N@0x13ed310)\n"
5973 " (declare (in ) vec2 I@0x13ed420)\n"
5974 " (declare (in ) vec2 Nref@0x13ed530)\n"
5975 " )\n"
5976 " (\n"
5977 " ))\n"
5978 "\n"
5979 " (signature vec3\n"
5980 " (parameters\n"
5981 " (declare (in ) vec3 N@0x13ed710)\n"
5982 " (declare (in ) vec3 I@0x13ed820)\n"
5983 " (declare (in ) vec3 Nref@0x13ed930)\n"
5984 " )\n"
5985 " (\n"
5986 " ))\n"
5987 "\n"
5988 " (signature vec4\n"
5989 " (parameters\n"
5990 " (declare (in ) vec4 N@0x13edb10)\n"
5991 " (declare (in ) vec4 I@0x13edc20)\n"
5992 " (declare (in ) vec4 Nref@0x13edd30)\n"
5993 " )\n"
5994 " (\n"
5995 " ))\n"
5996 "\n"
5997 ")\n"
5998 "\n"
5999 "(function reflect\n"
6000 " (signature float\n"
6001 " (parameters\n"
6002 " (declare (in ) float I@0x13edf10)\n"
6003 " (declare (in ) float N@0x13ee020)\n"
6004 " )\n"
6005 " (\n"
6006 " ))\n"
6007 "\n"
6008 " (signature vec2\n"
6009 " (parameters\n"
6010 " (declare (in ) vec2 I@0x13ee3a0)\n"
6011 " (declare (in ) vec2 N@0x13ee4b0)\n"
6012 " )\n"
6013 " (\n"
6014 " ))\n"
6015 "\n"
6016 " (signature vec3\n"
6017 " (parameters\n"
6018 " (declare (in ) vec3 I@0x13ee690)\n"
6019 " (declare (in ) vec3 N@0x13ee7a0)\n"
6020 " )\n"
6021 " (\n"
6022 " ))\n"
6023 "\n"
6024 " (signature vec4\n"
6025 " (parameters\n"
6026 " (declare (in ) vec4 I@0x13ee980)\n"
6027 " (declare (in ) vec4 N@0x13eea90)\n"
6028 " )\n"
6029 " (\n"
6030 " ))\n"
6031 "\n"
6032 ")\n"
6033 "\n"
6034 "(function refract\n"
6035 " (signature float\n"
6036 " (parameters\n"
6037 " (declare (in ) float I@0x13eec70)\n"
6038 " (declare (in ) float N@0x13eed80)\n"
6039 " (declare (in ) float eta@0x13eee90)\n"
6040 " )\n"
6041 " (\n"
6042 " ))\n"
6043 "\n"
6044 " (signature vec2\n"
6045 " (parameters\n"
6046 " (declare (in ) vec2 I@0x13ef210)\n"
6047 " (declare (in ) vec2 N@0x13ef320)\n"
6048 " (declare (in ) float eta@0x13ef430)\n"
6049 " )\n"
6050 " (\n"
6051 " ))\n"
6052 "\n"
6053 " (signature vec3\n"
6054 " (parameters\n"
6055 " (declare (in ) vec3 I@0x13ef610)\n"
6056 " (declare (in ) vec3 N@0x13ef720)\n"
6057 " (declare (in ) float eta@0x13ef830)\n"
6058 " )\n"
6059 " (\n"
6060 " ))\n"
6061 "\n"
6062 " (signature vec4\n"
6063 " (parameters\n"
6064 " (declare (in ) vec4 I@0x13efa10)\n"
6065 " (declare (in ) vec4 N@0x13efb20)\n"
6066 " (declare (in ) float eta@0x13efc30)\n"
6067 " )\n"
6068 " (\n"
6069 " ))\n"
6070 "\n"
6071 ")\n"
6072 "\n"
6073 "(function matrixCompMult\n"
6074 " (signature mat2\n"
6075 " (parameters\n"
6076 " (declare (in ) mat2 x@0x13efe10)\n"
6077 " (declare (in ) mat2 y@0x13eff20)\n"
6078 " )\n"
6079 " (\n"
6080 " ))\n"
6081 "\n"
6082 " (signature mat3\n"
6083 " (parameters\n"
6084 " (declare (in ) mat3 x@0x13f02b0)\n"
6085 " (declare (in ) mat3 y@0x13f03c0)\n"
6086 " )\n"
6087 " (\n"
6088 " ))\n"
6089 "\n"
6090 " (signature mat4\n"
6091 " (parameters\n"
6092 " (declare (in ) mat4 x@0x13f05a0)\n"
6093 " (declare (in ) mat4 y@0x13f06b0)\n"
6094 " )\n"
6095 " (\n"
6096 " ))\n"
6097 "\n"
6098 " (signature mat2x3\n"
6099 " (parameters\n"
6100 " (declare (in ) mat2x3 x@0x13f0890)\n"
6101 " (declare (in ) mat2x3 y@0x13f09a0)\n"
6102 " )\n"
6103 " (\n"
6104 " ))\n"
6105 "\n"
6106 " (signature mat2x4\n"
6107 " (parameters\n"
6108 " (declare (in ) mat2x4 x@0x13f0b80)\n"
6109 " (declare (in ) mat2x4 y@0x13f0c90)\n"
6110 " )\n"
6111 " (\n"
6112 " ))\n"
6113 "\n"
6114 " (signature mat3x2\n"
6115 " (parameters\n"
6116 " (declare (in ) mat3x2 x@0x13f0e70)\n"
6117 " (declare (in ) mat3x2 y@0x13f0f80)\n"
6118 " )\n"
6119 " (\n"
6120 " ))\n"
6121 "\n"
6122 " (signature mat3x4\n"
6123 " (parameters\n"
6124 " (declare (in ) mat3x4 x@0x13f1160)\n"
6125 " (declare (in ) mat3x4 y@0x13f1270)\n"
6126 " )\n"
6127 " (\n"
6128 " ))\n"
6129 "\n"
6130 " (signature mat4x2\n"
6131 " (parameters\n"
6132 " (declare (in ) mat4x2 x@0x13f1450)\n"
6133 " (declare (in ) mat4x2 y@0x13f1560)\n"
6134 " )\n"
6135 " (\n"
6136 " ))\n"
6137 "\n"
6138 " (signature mat4x3\n"
6139 " (parameters\n"
6140 " (declare (in ) mat4x3 x@0x13f1740)\n"
6141 " (declare (in ) mat4x3 y@0x13f1850)\n"
6142 " )\n"
6143 " (\n"
6144 " ))\n"
6145 "\n"
6146 ")\n"
6147 "\n"
6148 "(function outerProduct\n"
6149 " (signature mat2\n"
6150 " (parameters\n"
6151 " (declare (in ) vec2 c@0x13f1a30)\n"
6152 " (declare (in ) vec2 r@0x13f1b40)\n"
6153 " )\n"
6154 " (\n"
6155 " ))\n"
6156 "\n"
6157 " (signature mat3\n"
6158 " (parameters\n"
6159 " (declare (in ) vec3 c@0x13f1ed0)\n"
6160 " (declare (in ) vec3 r@0x13f1fe0)\n"
6161 " )\n"
6162 " (\n"
6163 " ))\n"
6164 "\n"
6165 " (signature mat4\n"
6166 " (parameters\n"
6167 " (declare (in ) vec4 c@0x13f21c0)\n"
6168 " (declare (in ) vec4 r@0x13f22d0)\n"
6169 " )\n"
6170 " (\n"
6171 " ))\n"
6172 "\n"
6173 " (signature mat2x3\n"
6174 " (parameters\n"
6175 " (declare (in ) vec3 c@0x13f24b0)\n"
6176 " (declare (in ) vec2 r@0x13f25c0)\n"
6177 " )\n"
6178 " (\n"
6179 " ))\n"
6180 "\n"
6181 " (signature mat3x2\n"
6182 " (parameters\n"
6183 " (declare (in ) vec2 c@0x13f27a0)\n"
6184 " (declare (in ) vec3 r@0x13f28b0)\n"
6185 " )\n"
6186 " (\n"
6187 " ))\n"
6188 "\n"
6189 " (signature mat2x4\n"
6190 " (parameters\n"
6191 " (declare (in ) vec4 c@0x13f2a90)\n"
6192 " (declare (in ) vec2 r@0x13f2ba0)\n"
6193 " )\n"
6194 " (\n"
6195 " ))\n"
6196 "\n"
6197 " (signature mat4x2\n"
6198 " (parameters\n"
6199 " (declare (in ) vec2 c@0x13f2d80)\n"
6200 " (declare (in ) vec4 r@0x13f2e90)\n"
6201 " )\n"
6202 " (\n"
6203 " ))\n"
6204 "\n"
6205 " (signature mat3x4\n"
6206 " (parameters\n"
6207 " (declare (in ) vec4 c@0x13f3070)\n"
6208 " (declare (in ) vec3 r@0x13f3180)\n"
6209 " )\n"
6210 " (\n"
6211 " ))\n"
6212 "\n"
6213 " (signature mat4x3\n"
6214 " (parameters\n"
6215 " (declare (in ) vec3 c@0x13f3360)\n"
6216 " (declare (in ) vec4 r@0x13f3470)\n"
6217 " )\n"
6218 " (\n"
6219 " ))\n"
6220 "\n"
6221 ")\n"
6222 "\n"
6223 "(function transpose\n"
6224 " (signature mat2\n"
6225 " (parameters\n"
6226 " (declare (in ) mat2 m@0x13f3650)\n"
6227 " )\n"
6228 " (\n"
6229 " ))\n"
6230 "\n"
6231 " (signature mat3\n"
6232 " (parameters\n"
6233 " (declare (in ) mat3 m@0x13f39e0)\n"
6234 " )\n"
6235 " (\n"
6236 " ))\n"
6237 "\n"
6238 " (signature mat4\n"
6239 " (parameters\n"
6240 " (declare (in ) mat4 m@0x13f3bc0)\n"
6241 " )\n"
6242 " (\n"
6243 " ))\n"
6244 "\n"
6245 " (signature mat2x3\n"
6246 " (parameters\n"
6247 " (declare (in ) mat3x2 m@0x13f3da0)\n"
6248 " )\n"
6249 " (\n"
6250 " ))\n"
6251 "\n"
6252 " (signature mat3x2\n"
6253 " (parameters\n"
6254 " (declare (in ) mat2x3 m@0x13f3f80)\n"
6255 " )\n"
6256 " (\n"
6257 " ))\n"
6258 "\n"
6259 " (signature mat2x4\n"
6260 " (parameters\n"
6261 " (declare (in ) mat4x2 m@0x13f4160)\n"
6262 " )\n"
6263 " (\n"
6264 " ))\n"
6265 "\n"
6266 " (signature mat4x2\n"
6267 " (parameters\n"
6268 " (declare (in ) mat2x4 m@0x13f4340)\n"
6269 " )\n"
6270 " (\n"
6271 " ))\n"
6272 "\n"
6273 " (signature mat3x4\n"
6274 " (parameters\n"
6275 " (declare (in ) mat4x3 m@0x13f4520)\n"
6276 " )\n"
6277 " (\n"
6278 " ))\n"
6279 "\n"
6280 " (signature mat4x3\n"
6281 " (parameters\n"
6282 " (declare (in ) mat3x4 m@0x13f4700)\n"
6283 " )\n"
6284 " (\n"
6285 " ))\n"
6286 "\n"
6287 ")\n"
6288 "\n"
6289 "(function lessThan\n"
6290 " (signature bvec2\n"
6291 " (parameters\n"
6292 " (declare (in ) vec2 x@0x13f48e0)\n"
6293 " (declare (in ) vec2 y@0x13f49f0)\n"
6294 " )\n"
6295 " (\n"
6296 " ))\n"
6297 "\n"
6298 " (signature bvec3\n"
6299 " (parameters\n"
6300 " (declare (in ) vec3 x@0x13f4d80)\n"
6301 " (declare (in ) vec3 y@0x13f4e90)\n"
6302 " )\n"
6303 " (\n"
6304 " ))\n"
6305 "\n"
6306 " (signature bvec4\n"
6307 " (parameters\n"
6308 " (declare (in ) vec4 x@0x13f5070)\n"
6309 " (declare (in ) vec4 y@0x13f5180)\n"
6310 " )\n"
6311 " (\n"
6312 " ))\n"
6313 "\n"
6314 " (signature bvec2\n"
6315 " (parameters\n"
6316 " (declare (in ) ivec2 x@0x13f5360)\n"
6317 " (declare (in ) ivec2 y@0x13f5470)\n"
6318 " )\n"
6319 " (\n"
6320 " ))\n"
6321 "\n"
6322 " (signature bvec3\n"
6323 " (parameters\n"
6324 " (declare (in ) ivec3 x@0x13f5650)\n"
6325 " (declare (in ) ivec3 y@0x13f5760)\n"
6326 " )\n"
6327 " (\n"
6328 " ))\n"
6329 "\n"
6330 " (signature bvec4\n"
6331 " (parameters\n"
6332 " (declare (in ) ivec4 x@0x13f5940)\n"
6333 " (declare (in ) ivec4 y@0x13f5a50)\n"
6334 " )\n"
6335 " (\n"
6336 " ))\n"
6337 "\n"
6338 ")\n"
6339 "\n"
6340 "(function lessThanEqual\n"
6341 " (signature bvec2\n"
6342 " (parameters\n"
6343 " (declare (in ) vec2 x@0x13f5c30)\n"
6344 " (declare (in ) vec2 y@0x13f5d40)\n"
6345 " )\n"
6346 " (\n"
6347 " ))\n"
6348 "\n"
6349 " (signature bvec3\n"
6350 " (parameters\n"
6351 " (declare (in ) vec3 x@0x13f60d0)\n"
6352 " (declare (in ) vec3 y@0x13f61e0)\n"
6353 " )\n"
6354 " (\n"
6355 " ))\n"
6356 "\n"
6357 " (signature bvec4\n"
6358 " (parameters\n"
6359 " (declare (in ) vec4 x@0x13f63c0)\n"
6360 " (declare (in ) vec4 y@0x13f64d0)\n"
6361 " )\n"
6362 " (\n"
6363 " ))\n"
6364 "\n"
6365 " (signature bvec2\n"
6366 " (parameters\n"
6367 " (declare (in ) ivec2 x@0x13f66b0)\n"
6368 " (declare (in ) ivec2 y@0x13f67c0)\n"
6369 " )\n"
6370 " (\n"
6371 " ))\n"
6372 "\n"
6373 " (signature bvec3\n"
6374 " (parameters\n"
6375 " (declare (in ) ivec3 x@0x13f69a0)\n"
6376 " (declare (in ) ivec3 y@0x13f6ab0)\n"
6377 " )\n"
6378 " (\n"
6379 " ))\n"
6380 "\n"
6381 " (signature bvec4\n"
6382 " (parameters\n"
6383 " (declare (in ) ivec4 x@0x13f6c90)\n"
6384 " (declare (in ) ivec4 y@0x13f6da0)\n"
6385 " )\n"
6386 " (\n"
6387 " ))\n"
6388 "\n"
6389 ")\n"
6390 "\n"
6391 "(function greaterThan\n"
6392 " (signature bvec2\n"
6393 " (parameters\n"
6394 " (declare (in ) vec2 x@0x13f6f80)\n"
6395 " (declare (in ) vec2 y@0x13f7090)\n"
6396 " )\n"
6397 " (\n"
6398 " ))\n"
6399 "\n"
6400 " (signature bvec3\n"
6401 " (parameters\n"
6402 " (declare (in ) vec3 x@0x13f7420)\n"
6403 " (declare (in ) vec3 y@0x13f7530)\n"
6404 " )\n"
6405 " (\n"
6406 " ))\n"
6407 "\n"
6408 " (signature bvec4\n"
6409 " (parameters\n"
6410 " (declare (in ) vec4 x@0x13f7710)\n"
6411 " (declare (in ) vec4 y@0x13f7820)\n"
6412 " )\n"
6413 " (\n"
6414 " ))\n"
6415 "\n"
6416 " (signature bvec2\n"
6417 " (parameters\n"
6418 " (declare (in ) ivec2 x@0x13f7a00)\n"
6419 " (declare (in ) ivec2 y@0x13f7b10)\n"
6420 " )\n"
6421 " (\n"
6422 " ))\n"
6423 "\n"
6424 " (signature bvec3\n"
6425 " (parameters\n"
6426 " (declare (in ) ivec3 x@0x13f7cf0)\n"
6427 " (declare (in ) ivec3 y@0x13f7e00)\n"
6428 " )\n"
6429 " (\n"
6430 " ))\n"
6431 "\n"
6432 " (signature bvec4\n"
6433 " (parameters\n"
6434 " (declare (in ) ivec4 x@0x13f7fe0)\n"
6435 " (declare (in ) ivec4 y@0x13f80f0)\n"
6436 " )\n"
6437 " (\n"
6438 " ))\n"
6439 "\n"
6440 ")\n"
6441 "\n"
6442 "(function greaterThanEqual\n"
6443 " (signature bvec2\n"
6444 " (parameters\n"
6445 " (declare (in ) vec2 x@0x13f82d0)\n"
6446 " (declare (in ) vec2 y@0x13f83e0)\n"
6447 " )\n"
6448 " (\n"
6449 " ))\n"
6450 "\n"
6451 " (signature bvec3\n"
6452 " (parameters\n"
6453 " (declare (in ) vec3 x@0x13f8770)\n"
6454 " (declare (in ) vec3 y@0x13f8880)\n"
6455 " )\n"
6456 " (\n"
6457 " ))\n"
6458 "\n"
6459 " (signature bvec4\n"
6460 " (parameters\n"
6461 " (declare (in ) vec4 x@0x13f8a60)\n"
6462 " (declare (in ) vec4 y@0x13f8b70)\n"
6463 " )\n"
6464 " (\n"
6465 " ))\n"
6466 "\n"
6467 " (signature bvec2\n"
6468 " (parameters\n"
6469 " (declare (in ) ivec2 x@0x13f8d50)\n"
6470 " (declare (in ) ivec2 y@0x13f8e60)\n"
6471 " )\n"
6472 " (\n"
6473 " ))\n"
6474 "\n"
6475 " (signature bvec3\n"
6476 " (parameters\n"
6477 " (declare (in ) ivec3 x@0x13f9040)\n"
6478 " (declare (in ) ivec3 y@0x13f9150)\n"
6479 " )\n"
6480 " (\n"
6481 " ))\n"
6482 "\n"
6483 " (signature bvec4\n"
6484 " (parameters\n"
6485 " (declare (in ) ivec4 x@0x13f9330)\n"
6486 " (declare (in ) ivec4 y@0x13f9440)\n"
6487 " )\n"
6488 " (\n"
6489 " ))\n"
6490 "\n"
6491 ")\n"
6492 "\n"
6493 "(function equal\n"
6494 " (signature bvec2\n"
6495 " (parameters\n"
6496 " (declare (in ) vec2 x@0x13f9620)\n"
6497 " (declare (in ) vec2 y@0x13f9730)\n"
6498 " )\n"
6499 " (\n"
6500 " ))\n"
6501 "\n"
6502 " (signature bvec3\n"
6503 " (parameters\n"
6504 " (declare (in ) vec3 x@0x13f9ab0)\n"
6505 " (declare (in ) vec3 y@0x13f9bc0)\n"
6506 " )\n"
6507 " (\n"
6508 " ))\n"
6509 "\n"
6510 " (signature bvec4\n"
6511 " (parameters\n"
6512 " (declare (in ) vec4 x@0x13f9da0)\n"
6513 " (declare (in ) vec4 y@0x13f9eb0)\n"
6514 " )\n"
6515 " (\n"
6516 " ))\n"
6517 "\n"
6518 " (signature bvec2\n"
6519 " (parameters\n"
6520 " (declare (in ) ivec2 x@0x13fa090)\n"
6521 " (declare (in ) ivec2 y@0x13fa1a0)\n"
6522 " )\n"
6523 " (\n"
6524 " ))\n"
6525 "\n"
6526 " (signature bvec3\n"
6527 " (parameters\n"
6528 " (declare (in ) ivec3 x@0x13fa380)\n"
6529 " (declare (in ) ivec3 y@0x13fa490)\n"
6530 " )\n"
6531 " (\n"
6532 " ))\n"
6533 "\n"
6534 " (signature bvec4\n"
6535 " (parameters\n"
6536 " (declare (in ) ivec4 x@0x13fa670)\n"
6537 " (declare (in ) ivec4 y@0x13fa780)\n"
6538 " )\n"
6539 " (\n"
6540 " ))\n"
6541 "\n"
6542 " (signature bvec2\n"
6543 " (parameters\n"
6544 " (declare (in ) bvec2 x@0x13fa960)\n"
6545 " (declare (in ) bvec2 y@0x13faa70)\n"
6546 " )\n"
6547 " (\n"
6548 " ))\n"
6549 "\n"
6550 " (signature bvec3\n"
6551 " (parameters\n"
6552 " (declare (in ) bvec3 x@0x13fac50)\n"
6553 " (declare (in ) bvec3 y@0x13fad60)\n"
6554 " )\n"
6555 " (\n"
6556 " ))\n"
6557 "\n"
6558 " (signature bvec4\n"
6559 " (parameters\n"
6560 " (declare (in ) bvec4 x@0x13faf40)\n"
6561 " (declare (in ) bvec4 y@0x13fb050)\n"
6562 " )\n"
6563 " (\n"
6564 " ))\n"
6565 "\n"
6566 ")\n"
6567 "\n"
6568 "(function notEqual\n"
6569 " (signature bvec2\n"
6570 " (parameters\n"
6571 " (declare (in ) vec2 x@0x13fb230)\n"
6572 " (declare (in ) vec2 y@0x13fb340)\n"
6573 " )\n"
6574 " (\n"
6575 " ))\n"
6576 "\n"
6577 " (signature bvec3\n"
6578 " (parameters\n"
6579 " (declare (in ) vec3 x@0x13fb6d0)\n"
6580 " (declare (in ) vec3 y@0x13fb7e0)\n"
6581 " )\n"
6582 " (\n"
6583 " ))\n"
6584 "\n"
6585 " (signature bvec4\n"
6586 " (parameters\n"
6587 " (declare (in ) vec4 x@0x13fb9c0)\n"
6588 " (declare (in ) vec4 y@0x13fbad0)\n"
6589 " )\n"
6590 " (\n"
6591 " ))\n"
6592 "\n"
6593 " (signature bvec2\n"
6594 " (parameters\n"
6595 " (declare (in ) ivec2 x@0x13fbcb0)\n"
6596 " (declare (in ) ivec2 y@0x13fbdc0)\n"
6597 " )\n"
6598 " (\n"
6599 " ))\n"
6600 "\n"
6601 " (signature bvec3\n"
6602 " (parameters\n"
6603 " (declare (in ) ivec3 x@0x13fbfa0)\n"
6604 " (declare (in ) ivec3 y@0x13fc0b0)\n"
6605 " )\n"
6606 " (\n"
6607 " ))\n"
6608 "\n"
6609 " (signature bvec4\n"
6610 " (parameters\n"
6611 " (declare (in ) ivec4 x@0x13fc290)\n"
6612 " (declare (in ) ivec4 y@0x13fc3a0)\n"
6613 " )\n"
6614 " (\n"
6615 " ))\n"
6616 "\n"
6617 " (signature bvec2\n"
6618 " (parameters\n"
6619 " (declare (in ) bvec2 x@0x13fc580)\n"
6620 " (declare (in ) bvec2 y@0x13fc690)\n"
6621 " )\n"
6622 " (\n"
6623 " ))\n"
6624 "\n"
6625 " (signature bvec3\n"
6626 " (parameters\n"
6627 " (declare (in ) bvec3 x@0x13fc870)\n"
6628 " (declare (in ) bvec3 y@0x13fc980)\n"
6629 " )\n"
6630 " (\n"
6631 " ))\n"
6632 "\n"
6633 " (signature bvec4\n"
6634 " (parameters\n"
6635 " (declare (in ) bvec4 x@0x13fcb60)\n"
6636 " (declare (in ) bvec4 y@0x13fcc70)\n"
6637 " )\n"
6638 " (\n"
6639 " ))\n"
6640 "\n"
6641 ")\n"
6642 "\n"
6643 "(function any\n"
6644 " (signature bool\n"
6645 " (parameters\n"
6646 " (declare (in ) bvec2 x@0x13fce50)\n"
6647 " )\n"
6648 " (\n"
6649 " ))\n"
6650 "\n"
6651 " (signature bool\n"
6652 " (parameters\n"
6653 " (declare (in ) bvec3 x@0x13fd1d0)\n"
6654 " )\n"
6655 " (\n"
6656 " ))\n"
6657 "\n"
6658 " (signature bool\n"
6659 " (parameters\n"
6660 " (declare (in ) bvec4 x@0x13fd3b0)\n"
6661 " )\n"
6662 " (\n"
6663 " ))\n"
6664 "\n"
6665 ")\n"
6666 "\n"
6667 "(function all\n"
6668 " (signature bool\n"
6669 " (parameters\n"
6670 " (declare (in ) bvec2 x@0x13fd590)\n"
6671 " )\n"
6672 " (\n"
6673 " ))\n"
6674 "\n"
6675 " (signature bool\n"
6676 " (parameters\n"
6677 " (declare (in ) bvec3 x@0x13fd910)\n"
6678 " )\n"
6679 " (\n"
6680 " ))\n"
6681 "\n"
6682 " (signature bool\n"
6683 " (parameters\n"
6684 " (declare (in ) bvec4 x@0x13fdaf0)\n"
6685 " )\n"
6686 " (\n"
6687 " ))\n"
6688 "\n"
6689 ")\n"
6690 "\n"
6691 "(function not\n"
6692 " (signature bvec2\n"
6693 " (parameters\n"
6694 " (declare (in ) bvec2 x@0x13fdcd0)\n"
6695 " )\n"
6696 " (\n"
6697 " ))\n"
6698 "\n"
6699 " (signature bvec3\n"
6700 " (parameters\n"
6701 " (declare (in ) bvec3 x@0x13fe050)\n"
6702 " )\n"
6703 " (\n"
6704 " ))\n"
6705 "\n"
6706 " (signature bvec4\n"
6707 " (parameters\n"
6708 " (declare (in ) bvec4 x@0x13fe230)\n"
6709 " )\n"
6710 " (\n"
6711 " ))\n"
6712 "\n"
6713 ")\n"
6714 "\n"
6715 "(function texture1D\n"
6716 " (signature vec4\n"
6717 " (parameters\n"
6718 " (declare (in ) sampler1D sampler@0x13fe410)\n"
6719 " (declare (in ) float coord@0x13fe520)\n"
6720 " )\n"
6721 " (\n"
6722 " ))\n"
6723 "\n"
6724 ")\n"
6725 "\n"
6726 "(function texture1DProj\n"
6727 " (signature vec4\n"
6728 " (parameters\n"
6729 " (declare (in ) sampler1D sampler@0x13fe8b0)\n"
6730 " (declare (in ) vec2 coord@0x13fe9c0)\n"
6731 " )\n"
6732 " (\n"
6733 " ))\n"
6734 "\n"
6735 " (signature vec4\n"
6736 " (parameters\n"
6737 " (declare (in ) sampler1D sampler@0x13fed50)\n"
6738 " (declare (in ) vec4 coord@0x13fee60)\n"
6739 " )\n"
6740 " (\n"
6741 " ))\n"
6742 "\n"
6743 ")\n"
6744 "\n"
6745 "(function texture1DLod\n"
6746 " (signature vec4\n"
6747 " (parameters\n"
6748 " (declare (in ) sampler1D sampler@0x13ff040)\n"
6749 " (declare (in ) float coord@0x13ff150)\n"
6750 " (declare (in ) float lod@0x13ff260)\n"
6751 " )\n"
6752 " (\n"
6753 " ))\n"
6754 "\n"
6755 ")\n"
6756 "\n"
6757 "(function texture1DProjLod\n"
6758 " (signature vec4\n"
6759 " (parameters\n"
6760 " (declare (in ) sampler1D sampler@0x13ff5f0)\n"
6761 " (declare (in ) vec2 coord@0x13ff700)\n"
6762 " (declare (in ) float lod@0x13ff810)\n"
6763 " )\n"
6764 " (\n"
6765 " ))\n"
6766 "\n"
6767 " (signature vec4\n"
6768 " (parameters\n"
6769 " (declare (in ) sampler1D sampler@0x13ffba0)\n"
6770 " (declare (in ) vec4 coord@0x13ffcb0)\n"
6771 " (declare (in ) float lod@0x13ffdc0)\n"
6772 " )\n"
6773 " (\n"
6774 " ))\n"
6775 "\n"
6776 ")\n"
6777 "\n"
6778 "(function texture2D\n"
6779 " (signature vec4\n"
6780 " (parameters\n"
6781 " (declare (in ) sampler2D sampler@0x13fffa0)\n"
6782 " (declare (in ) vec2 coord@0x14000b0)\n"
6783 " )\n"
6784 " (\n"
6785 " ))\n"
6786 "\n"
6787 ")\n"
6788 "\n"
6789 "(function texture2DProj\n"
6790 " (signature vec4\n"
6791 " (parameters\n"
6792 " (declare (in ) sampler2D sampler@0x1400440)\n"
6793 " (declare (in ) vec3 coord@0x1400550)\n"
6794 " )\n"
6795 " (\n"
6796 " ))\n"
6797 "\n"
6798 " (signature vec4\n"
6799 " (parameters\n"
6800 " (declare (in ) sampler2D sampler@0x14008e0)\n"
6801 " (declare (in ) vec4 coord@0x14009f0)\n"
6802 " )\n"
6803 " (\n"
6804 " ))\n"
6805 "\n"
6806 ")\n"
6807 "\n"
6808 "(function texture2DLod\n"
6809 " (signature vec4\n"
6810 " (parameters\n"
6811 " (declare (in ) sampler2D sampler@0x1400bd0)\n"
6812 " (declare (in ) vec2 coord@0x1400ce0)\n"
6813 " (declare (in ) float lod@0x1400df0)\n"
6814 " )\n"
6815 " (\n"
6816 " ))\n"
6817 "\n"
6818 ")\n"
6819 "\n"
6820 "(function texture2DProjLod\n"
6821 " (signature vec4\n"
6822 " (parameters\n"
6823 " (declare (in ) sampler2D sampler@0x1401180)\n"
6824 " (declare (in ) vec3 coord@0x1401290)\n"
6825 " (declare (in ) float lod@0x14013a0)\n"
6826 " )\n"
6827 " (\n"
6828 " ))\n"
6829 "\n"
6830 " (signature vec4\n"
6831 " (parameters\n"
6832 " (declare (in ) sampler2D sampler@0x1401730)\n"
6833 " (declare (in ) vec4 coord@0x1401840)\n"
6834 " (declare (in ) float lod@0x1401950)\n"
6835 " )\n"
6836 " (\n"
6837 " ))\n"
6838 "\n"
6839 ")\n"
6840 "\n"
6841 "(function texture3D\n"
6842 " (signature vec4\n"
6843 " (parameters\n"
6844 " (declare (in ) sampler3D sampler@0x1401b30)\n"
6845 " (declare (in ) vec3 coord@0x1401c40)\n"
6846 " )\n"
6847 " (\n"
6848 " ))\n"
6849 "\n"
6850 ")\n"
6851 "\n"
6852 "(function texture3DProj\n"
6853 " (signature vec4\n"
6854 " (parameters\n"
6855 " (declare (in ) sampler3D sampler@0x1401fd0)\n"
6856 " (declare (in ) vec4 coord@0x14020e0)\n"
6857 " )\n"
6858 " (\n"
6859 " ))\n"
6860 "\n"
6861 ")\n"
6862 "\n"
6863 "(function texture3DLod\n"
6864 " (signature vec4\n"
6865 " (parameters\n"
6866 " (declare (in ) sampler3D sampler@0x1402470)\n"
6867 " (declare (in ) vec3 coord@0x1402580)\n"
6868 " (declare (in ) float lod@0x1402690)\n"
6869 " )\n"
6870 " (\n"
6871 " ))\n"
6872 "\n"
6873 ")\n"
6874 "\n"
6875 "(function texture3DProjLod\n"
6876 " (signature vec4\n"
6877 " (parameters\n"
6878 " (declare (in ) sampler3D sampler@0x1402a20)\n"
6879 " (declare (in ) vec4 coord@0x1402b30)\n"
6880 " (declare (in ) float lod@0x1402c40)\n"
6881 " )\n"
6882 " (\n"
6883 " ))\n"
6884 "\n"
6885 ")\n"
6886 "\n"
6887 "(function textureCube\n"
6888 " (signature vec4\n"
6889 " (parameters\n"
6890 " (declare (in ) samplerCube sampler@0x1402fd0)\n"
6891 " (declare (in ) vec3 coord@0x14030e0)\n"
6892 " )\n"
6893 " (\n"
6894 " ))\n"
6895 "\n"
6896 ")\n"
6897 "\n"
6898 "(function textureCubeLod\n"
6899 " (signature vec4\n"
6900 " (parameters\n"
6901 " (declare (in ) samplerCube sampler@0x1403470)\n"
6902 " (declare (in ) vec3 coord@0x1403580)\n"
6903 " (declare (in ) float lod@0x1403690)\n"
6904 " )\n"
6905 " (\n"
6906 " ))\n"
6907 "\n"
6908 ")\n"
6909 "\n"
6910 "(function shadow1D\n"
6911 " (signature vec4\n"
6912 " (parameters\n"
6913 " (declare (in ) sampler1DShadow sampler@0x1403a20)\n"
6914 " (declare (in ) vec3 coord@0x1403b30)\n"
6915 " )\n"
6916 " (\n"
6917 " ))\n"
6918 "\n"
6919 ")\n"
6920 "\n"
6921 "(function shadow2D\n"
6922 " (signature vec4\n"
6923 " (parameters\n"
6924 " (declare (in ) sampler2DShadow sampler@0x1403ec0)\n"
6925 " (declare (in ) vec3 coord@0x1403fd0)\n"
6926 " )\n"
6927 " (\n"
6928 " ))\n"
6929 "\n"
6930 ")\n"
6931 "\n"
6932 "(function shadow1DProj\n"
6933 " (signature vec4\n"
6934 " (parameters\n"
6935 " (declare (in ) sampler1DShadow sampler@0x1404360)\n"
6936 " (declare (in ) vec4 coord@0x1404470)\n"
6937 " )\n"
6938 " (\n"
6939 " ))\n"
6940 "\n"
6941 ")\n"
6942 "\n"
6943 "(function shadow2DProj\n"
6944 " (signature vec4\n"
6945 " (parameters\n"
6946 " (declare (in ) sampler2DShadow sampler@0x1404800)\n"
6947 " (declare (in ) vec4 coord@0x1404910)\n"
6948 " )\n"
6949 " (\n"
6950 " ))\n"
6951 "\n"
6952 ")\n"
6953 "\n"
6954 "(function shadow1DLod\n"
6955 " (signature vec4\n"
6956 " (parameters\n"
6957 " (declare (in ) sampler1DShadow sampler@0x1404ca0)\n"
6958 " (declare (in ) vec3 coord@0x1404db0)\n"
6959 " (declare (in ) float lod@0x1404ec0)\n"
6960 " )\n"
6961 " (\n"
6962 " ))\n"
6963 "\n"
6964 ")\n"
6965 "\n"
6966 "(function shadow2DLod\n"
6967 " (signature vec4\n"
6968 " (parameters\n"
6969 " (declare (in ) sampler2DShadow sampler@0x1405250)\n"
6970 " (declare (in ) vec3 coord@0x1405360)\n"
6971 " (declare (in ) float lod@0x1405470)\n"
6972 " )\n"
6973 " (\n"
6974 " ))\n"
6975 "\n"
6976 ")\n"
6977 "\n"
6978 "(function shadow1DProjLod\n"
6979 " (signature vec4\n"
6980 " (parameters\n"
6981 " (declare (in ) sampler1DShadow sampler@0x1405800)\n"
6982 " (declare (in ) vec4 coord@0x1405910)\n"
6983 " (declare (in ) float lod@0x1405a20)\n"
6984 " )\n"
6985 " (\n"
6986 " ))\n"
6987 "\n"
6988 ")\n"
6989 "\n"
6990 "(function shadow2DProjLod\n"
6991 " (signature vec4\n"
6992 " (parameters\n"
6993 " (declare (in ) sampler2DShadow sampler@0x1405db0)\n"
6994 " (declare (in ) vec4 coord@0x1405ec0)\n"
6995 " (declare (in ) float lod@0x1405fd0)\n"
6996 " )\n"
6997 " (\n"
6998 " ))\n"
6999 "\n"
7000 ")\n"
7001 "\n"
7002 "(function noise1\n"
7003 " (signature float\n"
7004 " (parameters\n"
7005 " (declare (in ) float x@0x1406360)\n"
7006 " )\n"
7007 " (\n"
7008 " ))\n"
7009 "\n"
7010 " (signature float\n"
7011 " (parameters\n"
7012 " (declare (in ) vec2 x@0x14066e0)\n"
7013 " )\n"
7014 " (\n"
7015 " ))\n"
7016 "\n"
7017 " (signature float\n"
7018 " (parameters\n"
7019 " (declare (in ) vec3 x@0x14068c0)\n"
7020 " )\n"
7021 " (\n"
7022 " ))\n"
7023 "\n"
7024 " (signature float\n"
7025 " (parameters\n"
7026 " (declare (in ) vec4 x@0x1406aa0)\n"
7027 " )\n"
7028 " (\n"
7029 " ))\n"
7030 "\n"
7031 ")\n"
7032 "\n"
7033 "(function noise2\n"
7034 " (signature vec2\n"
7035 " (parameters\n"
7036 " (declare (in ) float x@0x1406c80)\n"
7037 " )\n"
7038 " (\n"
7039 " ))\n"
7040 "\n"
7041 " (signature vec2\n"
7042 " (parameters\n"
7043 " (declare (in ) vec2 x@0x1407000)\n"
7044 " )\n"
7045 " (\n"
7046 " ))\n"
7047 "\n"
7048 " (signature vec2\n"
7049 " (parameters\n"
7050 " (declare (in ) vec3 x@0x14071e0)\n"
7051 " )\n"
7052 " (\n"
7053 " ))\n"
7054 "\n"
7055 " (signature vec2\n"
7056 " (parameters\n"
7057 " (declare (in ) vec4 x@0x14073c0)\n"
7058 " )\n"
7059 " (\n"
7060 " ))\n"
7061 "\n"
7062 ")\n"
7063 "\n"
7064 "(function noise3\n"
7065 " (signature vec3\n"
7066 " (parameters\n"
7067 " (declare (in ) float x@0x14075a0)\n"
7068 " )\n"
7069 " (\n"
7070 " ))\n"
7071 "\n"
7072 " (signature vec3\n"
7073 " (parameters\n"
7074 " (declare (in ) vec2 x@0x1407920)\n"
7075 " )\n"
7076 " (\n"
7077 " ))\n"
7078 "\n"
7079 " (signature vec3\n"
7080 " (parameters\n"
7081 " (declare (in ) vec3 x@0x1407b00)\n"
7082 " )\n"
7083 " (\n"
7084 " ))\n"
7085 "\n"
7086 " (signature vec3\n"
7087 " (parameters\n"
7088 " (declare (in ) vec4 x@0x1407ce0)\n"
7089 " )\n"
7090 " (\n"
7091 " ))\n"
7092 "\n"
7093 ")\n"
7094 "\n"
7095 "(function noise4\n"
7096 " (signature vec4\n"
7097 " (parameters\n"
7098 " (declare (in ) float x@0x1407ec0)\n"
7099 " )\n"
7100 " (\n"
7101 " ))\n"
7102 "\n"
7103 " (signature vec4\n"
7104 " (parameters\n"
7105 " (declare (in ) vec2 x@0x1408240)\n"
7106 " )\n"
7107 " (\n"
7108 " ))\n"
7109 "\n"
7110 " (signature vec4\n"
7111 " (parameters\n"
7112 " (declare (in ) vec3 x@0x1408420)\n"
7113 " )\n"
7114 " (\n"
7115 " ))\n"
7116 "\n"
7117 " (signature vec4\n"
7118 " (parameters\n"
7119 " (declare (in ) vec4 x@0x1408600)\n"
7120 " )\n"
7121 " (\n"
7122 " ))\n"
7123 "\n"
7124 ")\n"
7125 "\n"
7126 "\n"
7127 ")"
7128;
7129static const char *functions_for_120_vert [] = {
7130 builtin_clamp,
7131 builtin_matrixCompMult,
7132 builtin_shadow2DProjLod,
7133 builtin_noise2,
7134 builtin_texture3DProjLod,
7135 builtin_pow,
7136 builtin_texture2DProj,
7137 builtin_greaterThanEqual,
7138 builtin_sign,
7139 builtin_texture3DProj,
7140 builtin_texture2D,
7141 builtin_equal,
7142 builtin_faceforward,
7143 builtin_tan,
7144 builtin_shadow2DProj,
7145 builtin_shadow1DProjLod,
7146 builtin_any,
7147 builtin_shadow1DProj,
7148 builtin_normalize,
7149 builtin_asin,
7150 builtin_texture1DProj,
7151 builtin_log,
7152 builtin_floor,
7153 builtin_exp2,
7154 builtin_lessThan,
7155 builtin_cross,
7156 builtin_sqrt,
7157 builtin_texture3DLod,
7158 builtin_fract,
7159 builtin_abs,
7160 builtin_degrees,
7161 builtin_shadow1DLod,
7162 builtin_ftransform,
7163 builtin_sin,
7164 builtin_shadow2D,
7165 builtin_shadow2DLod,
7166 builtin_all,
7167 builtin_log2,
7168 builtin_atan,
7169 builtin_notEqual,
7170 builtin_max,
7171 builtin_lessThanEqual,
7172 builtin_transpose,
7173 builtin_outerProduct,
7174 builtin_ceil,
7175 builtin_reflect,
7176 builtin_textureCubeLod,
7177 builtin_step,
7178 builtin_texture1D,
7179 builtin_greaterThan,
7180 builtin_texture3D,
7181 builtin_not,
7182 builtin_texture2DProjLod,
7183 builtin_inversesqrt,
7184 builtin_mod,
7185 builtin_noise4,
7186 builtin_distance,
7187 builtin_cos,
7188 builtin_shadow1D,
7189 builtin_noise1,
7190 builtin_refract,
7191 builtin_noise3,
7192 builtin_texture2DLod,
7193 builtin_min,
7194 builtin_radians,
7195 builtin_smoothstep,
7196 builtin_texture1DProjLod,
7197 builtin_textureCube,
7198 builtin_length,
7199 builtin_texture1DLod,
7200 builtin_exp,
7201 builtin_acos,
7202 builtin_mix,
7203 builtin_dot,
7204};
7205static const char *prototypes_for_EXT_texture_array_frag =
7206 "(\n"
7207 "(function texture1DArray\n"
7208 " (signature vec4\n"
7209 " (parameters\n"
7210 " (declare (in ) sampler1DArray sampler@0xbe3bd0)\n"
7211 " (declare (in ) vec2 coord@0xbe3ce0)\n"
7212 " )\n"
7213 " (\n"
7214 " ))\n"
7215 "\n"
7216 " (signature vec4\n"
7217 " (parameters\n"
7218 " (declare (in ) sampler1DArray sampler@0xbe4070)\n"
7219 " (declare (in ) vec2 coord@0xbe4180)\n"
7220 " (declare (in ) float bias@0xbe4290)\n"
7221 " )\n"
7222 " (\n"
7223 " ))\n"
7224 "\n"
7225 ")\n"
7226 "\n"
7227 "(function texture2DArray\n"
7228 " (signature vec4\n"
7229 " (parameters\n"
7230 " (declare (in ) sampler1DArray sampler@0xbe4470)\n"
7231 " (declare (in ) vec2 coord@0xbe4580)\n"
7232 " )\n"
7233 " (\n"
7234 " ))\n"
7235 "\n"
7236 " (signature vec4\n"
7237 " (parameters\n"
7238 " (declare (in ) sampler1DArray sampler@0xbe4910)\n"
7239 " (declare (in ) vec2 coord@0xbe4a20)\n"
7240 " (declare (in ) float bias@0xbe4b30)\n"
7241 " )\n"
7242 " (\n"
7243 " ))\n"
7244 "\n"
7245 ")\n"
7246 "\n"
7247 "(function shadow1DArray\n"
7248 " (signature vec4\n"
7249 " (parameters\n"
7250 " (declare (in ) sampler1DArrayShadow sampler@0xbe4d10)\n"
7251 " (declare (in ) vec3 coord@0xbe4e20)\n"
7252 " )\n"
7253 " (\n"
7254 " ))\n"
7255 "\n"
7256 " (signature vec4\n"
7257 " (parameters\n"
7258 " (declare (in ) sampler1DArrayShadow sampler@0xbe51b0)\n"
7259 " (declare (in ) vec3 coord@0xbe52c0)\n"
7260 " (declare (in ) float bias@0xbe53d0)\n"
7261 " )\n"
7262 " (\n"
7263 " ))\n"
7264 "\n"
7265 ")\n"
7266 "\n"
7267 "(function shadow2DArray\n"
7268 " (signature vec4\n"
7269 " (parameters\n"
7270 " (declare (in ) sampler2DArrayShadow sampler@0xbe55b0)\n"
7271 " (declare (in ) vec4 coord@0xbe56c0)\n"
7272 " )\n"
7273 " (\n"
7274 " ))\n"
7275 "\n"
7276 ")\n"
7277 "\n"
7278 "\n"
7279 ")"
7280;
7281static const char *functions_for_EXT_texture_array_frag [] = {
7282 builtin_shadow2DArray,
7283 builtin_shadow1DArray,
7284 builtin_texture1DArray,
7285 builtin_texture2DArray,
7286};
7287static const char *prototypes_for_110_vert =
7288 "(\n"
7289 "(function radians\n"
7290 " (signature float\n"
7291 " (parameters\n"
7292 " (declare (in ) float degrees@0x1aa51c0)\n"
7293 " )\n"
7294 " (\n"
7295 " ))\n"
7296 "\n"
7297 " (signature vec2\n"
7298 " (parameters\n"
7299 " (declare (in ) vec2 degrees@0x1aa5540)\n"
7300 " )\n"
7301 " (\n"
7302 " ))\n"
7303 "\n"
7304 " (signature vec3\n"
7305 " (parameters\n"
7306 " (declare (in ) vec3 degrees@0x1aa5720)\n"
7307 " )\n"
7308 " (\n"
7309 " ))\n"
7310 "\n"
7311 " (signature vec4\n"
7312 " (parameters\n"
7313 " (declare (in ) vec4 degrees@0x1aa5900)\n"
7314 " )\n"
7315 " (\n"
7316 " ))\n"
7317 "\n"
7318 ")\n"
7319 "\n"
7320 "(function degrees\n"
7321 " (signature float\n"
7322 " (parameters\n"
7323 " (declare (in ) float radians@0x1aa5ae0)\n"
7324 " )\n"
7325 " (\n"
7326 " ))\n"
7327 "\n"
7328 " (signature vec2\n"
7329 " (parameters\n"
7330 " (declare (in ) vec2 radians@0x1aa5e60)\n"
7331 " )\n"
7332 " (\n"
7333 " ))\n"
7334 "\n"
7335 " (signature vec3\n"
7336 " (parameters\n"
7337 " (declare (in ) vec3 radians@0x1aa6040)\n"
7338 " )\n"
7339 " (\n"
7340 " ))\n"
7341 "\n"
7342 " (signature vec4\n"
7343 " (parameters\n"
7344 " (declare (in ) vec4 radians@0x1aa6220)\n"
7345 " )\n"
7346 " (\n"
7347 " ))\n"
7348 "\n"
7349 ")\n"
7350 "\n"
7351 "(function sin\n"
7352 " (signature float\n"
7353 " (parameters\n"
7354 " (declare (in ) float angle@0x1aa6400)\n"
7355 " )\n"
7356 " (\n"
7357 " ))\n"
7358 "\n"
7359 " (signature vec2\n"
7360 " (parameters\n"
7361 " (declare (in ) vec2 angle@0x1aa6780)\n"
7362 " )\n"
7363 " (\n"
7364 " ))\n"
7365 "\n"
7366 " (signature vec3\n"
7367 " (parameters\n"
7368 " (declare (in ) vec3 angle@0x1aa6960)\n"
7369 " )\n"
7370 " (\n"
7371 " ))\n"
7372 "\n"
7373 " (signature vec4\n"
7374 " (parameters\n"
7375 " (declare (in ) vec4 angle@0x1aa6b40)\n"
7376 " )\n"
7377 " (\n"
7378 " ))\n"
7379 "\n"
7380 ")\n"
7381 "\n"
7382 "(function cos\n"
7383 " (signature float\n"
7384 " (parameters\n"
7385 " (declare (in ) float angle@0x1aa6d20)\n"
7386 " )\n"
7387 " (\n"
7388 " ))\n"
7389 "\n"
7390 " (signature vec2\n"
7391 " (parameters\n"
7392 " (declare (in ) vec2 angle@0x1aa70a0)\n"
7393 " )\n"
7394 " (\n"
7395 " ))\n"
7396 "\n"
7397 " (signature vec3\n"
7398 " (parameters\n"
7399 " (declare (in ) vec3 angle@0x1aa7280)\n"
7400 " )\n"
7401 " (\n"
7402 " ))\n"
7403 "\n"
7404 " (signature vec4\n"
7405 " (parameters\n"
7406 " (declare (in ) vec4 angle@0x1aa7460)\n"
7407 " )\n"
7408 " (\n"
7409 " ))\n"
7410 "\n"
7411 ")\n"
7412 "\n"
7413 "(function tan\n"
7414 " (signature float\n"
7415 " (parameters\n"
7416 " (declare (in ) float angle@0x1aa7640)\n"
7417 " )\n"
7418 " (\n"
7419 " ))\n"
7420 "\n"
7421 " (signature vec2\n"
7422 " (parameters\n"
7423 " (declare (in ) vec2 angle@0x1aa79c0)\n"
7424 " )\n"
7425 " (\n"
7426 " ))\n"
7427 "\n"
7428 " (signature vec3\n"
7429 " (parameters\n"
7430 " (declare (in ) vec3 angle@0x1aa7ba0)\n"
7431 " )\n"
7432 " (\n"
7433 " ))\n"
7434 "\n"
7435 " (signature vec4\n"
7436 " (parameters\n"
7437 " (declare (in ) vec4 angle@0x1aa7d80)\n"
7438 " )\n"
7439 " (\n"
7440 " ))\n"
7441 "\n"
7442 ")\n"
7443 "\n"
7444 "(function asin\n"
7445 " (signature float\n"
7446 " (parameters\n"
7447 " (declare (in ) float angle@0x1aa7f60)\n"
7448 " )\n"
7449 " (\n"
7450 " ))\n"
7451 "\n"
7452 " (signature vec2\n"
7453 " (parameters\n"
7454 " (declare (in ) vec2 angle@0x1aa82e0)\n"
7455 " )\n"
7456 " (\n"
7457 " ))\n"
7458 "\n"
7459 " (signature vec3\n"
7460 " (parameters\n"
7461 " (declare (in ) vec3 angle@0x1aa84c0)\n"
7462 " )\n"
7463 " (\n"
7464 " ))\n"
7465 "\n"
7466 " (signature vec4\n"
7467 " (parameters\n"
7468 " (declare (in ) vec4 angle@0x1aa86a0)\n"
7469 " )\n"
7470 " (\n"
7471 " ))\n"
7472 "\n"
7473 ")\n"
7474 "\n"
7475 "(function acos\n"
7476 " (signature float\n"
7477 " (parameters\n"
7478 " (declare (in ) float angle@0x1aa8880)\n"
7479 " )\n"
7480 " (\n"
7481 " ))\n"
7482 "\n"
7483 " (signature vec2\n"
7484 " (parameters\n"
7485 " (declare (in ) vec2 angle@0x1aa8c00)\n"
7486 " )\n"
7487 " (\n"
7488 " ))\n"
7489 "\n"
7490 " (signature vec3\n"
7491 " (parameters\n"
7492 " (declare (in ) vec3 angle@0x1aa8de0)\n"
7493 " )\n"
7494 " (\n"
7495 " ))\n"
7496 "\n"
7497 " (signature vec4\n"
7498 " (parameters\n"
7499 " (declare (in ) vec4 angle@0x1aa8fc0)\n"
7500 " )\n"
7501 " (\n"
7502 " ))\n"
7503 "\n"
7504 ")\n"
7505 "\n"
7506 "(function atan\n"
7507 " (signature float\n"
7508 " (parameters\n"
7509 " (declare (in ) float y@0x1aa91a0)\n"
7510 " (declare (in ) float x@0x1aa92b0)\n"
7511 " )\n"
7512 " (\n"
7513 " ))\n"
7514 "\n"
7515 " (signature vec2\n"
7516 " (parameters\n"
7517 " (declare (in ) vec2 y@0x1aa9630)\n"
7518 " (declare (in ) vec2 x@0x1aa9740)\n"
7519 " )\n"
7520 " (\n"
7521 " ))\n"
7522 "\n"
7523 " (signature vec3\n"
7524 " (parameters\n"
7525 " (declare (in ) vec3 y@0x1aa9920)\n"
7526 " (declare (in ) vec3 x@0x1aa9a30)\n"
7527 " )\n"
7528 " (\n"
7529 " ))\n"
7530 "\n"
7531 " (signature vec4\n"
7532 " (parameters\n"
7533 " (declare (in ) vec4 y@0x1aa9c10)\n"
7534 " (declare (in ) vec4 x@0x1aa9d20)\n"
7535 " )\n"
7536 " (\n"
7537 " ))\n"
7538 "\n"
7539 " (signature float\n"
7540 " (parameters\n"
7541 " (declare (in ) float y_over_x@0x1aa9f00)\n"
7542 " )\n"
7543 " (\n"
7544 " ))\n"
7545 "\n"
7546 " (signature vec2\n"
7547 " (parameters\n"
7548 " (declare (in ) vec2 y_over_x@0x1aaa0f0)\n"
7549 " )\n"
7550 " (\n"
7551 " ))\n"
7552 "\n"
7553 " (signature vec3\n"
7554 " (parameters\n"
7555 " (declare (in ) vec3 y_over_x@0x1aaa2e0)\n"
7556 " )\n"
7557 " (\n"
7558 " ))\n"
7559 "\n"
7560 " (signature vec4\n"
7561 " (parameters\n"
7562 " (declare (in ) vec4 y_over_x@0x1aaa4d0)\n"
7563 " )\n"
7564 " (\n"
7565 " ))\n"
7566 "\n"
7567 ")\n"
7568 "\n"
7569 "(function pow\n"
7570 " (signature float\n"
7571 " (parameters\n"
7572 " (declare (in ) float x@0x1aaa6c0)\n"
7573 " (declare (in ) float y@0x1aaa7d0)\n"
7574 " )\n"
7575 " (\n"
7576 " ))\n"
7577 "\n"
7578 " (signature vec2\n"
7579 " (parameters\n"
7580 " (declare (in ) vec2 x@0x1aaab50)\n"
7581 " (declare (in ) vec2 y@0x1aaac60)\n"
7582 " )\n"
7583 " (\n"
7584 " ))\n"
7585 "\n"
7586 " (signature vec3\n"
7587 " (parameters\n"
7588 " (declare (in ) vec3 x@0x1aaae40)\n"
7589 " (declare (in ) vec3 y@0x1aaaf50)\n"
7590 " )\n"
7591 " (\n"
7592 " ))\n"
7593 "\n"
7594 " (signature vec4\n"
7595 " (parameters\n"
7596 " (declare (in ) vec4 x@0x1aab130)\n"
7597 " (declare (in ) vec4 y@0x1aab240)\n"
7598 " )\n"
7599 " (\n"
7600 " ))\n"
7601 "\n"
7602 ")\n"
7603 "\n"
7604 "(function exp\n"
7605 " (signature float\n"
7606 " (parameters\n"
7607 " (declare (in ) float x@0x1aab420)\n"
7608 " )\n"
7609 " (\n"
7610 " ))\n"
7611 "\n"
7612 " (signature vec2\n"
7613 " (parameters\n"
7614 " (declare (in ) vec2 x@0x1aab7a0)\n"
7615 " )\n"
7616 " (\n"
7617 " ))\n"
7618 "\n"
7619 " (signature vec3\n"
7620 " (parameters\n"
7621 " (declare (in ) vec3 x@0x1aab980)\n"
7622 " )\n"
7623 " (\n"
7624 " ))\n"
7625 "\n"
7626 " (signature vec4\n"
7627 " (parameters\n"
7628 " (declare (in ) vec4 x@0x1aabb60)\n"
7629 " )\n"
7630 " (\n"
7631 " ))\n"
7632 "\n"
7633 ")\n"
7634 "\n"
7635 "(function log\n"
7636 " (signature float\n"
7637 " (parameters\n"
7638 " (declare (in ) float x@0x1aabd40)\n"
7639 " )\n"
7640 " (\n"
7641 " ))\n"
7642 "\n"
7643 " (signature vec2\n"
7644 " (parameters\n"
7645 " (declare (in ) vec2 x@0x1aac0c0)\n"
7646 " )\n"
7647 " (\n"
7648 " ))\n"
7649 "\n"
7650 " (signature vec3\n"
7651 " (parameters\n"
7652 " (declare (in ) vec3 x@0x1aac2a0)\n"
7653 " )\n"
7654 " (\n"
7655 " ))\n"
7656 "\n"
7657 " (signature vec4\n"
7658 " (parameters\n"
7659 " (declare (in ) vec4 x@0x1aac480)\n"
7660 " )\n"
7661 " (\n"
7662 " ))\n"
7663 "\n"
7664 ")\n"
7665 "\n"
7666 "(function exp2\n"
7667 " (signature float\n"
7668 " (parameters\n"
7669 " (declare (in ) float x@0x1aac660)\n"
7670 " )\n"
7671 " (\n"
7672 " ))\n"
7673 "\n"
7674 " (signature vec2\n"
7675 " (parameters\n"
7676 " (declare (in ) vec2 x@0x1aac9e0)\n"
7677 " )\n"
7678 " (\n"
7679 " ))\n"
7680 "\n"
7681 " (signature vec3\n"
7682 " (parameters\n"
7683 " (declare (in ) vec3 x@0x1aacbc0)\n"
7684 " )\n"
7685 " (\n"
7686 " ))\n"
7687 "\n"
7688 " (signature vec4\n"
7689 " (parameters\n"
7690 " (declare (in ) vec4 x@0x1aacda0)\n"
7691 " )\n"
7692 " (\n"
7693 " ))\n"
7694 "\n"
7695 ")\n"
7696 "\n"
7697 "(function log2\n"
7698 " (signature float\n"
7699 " (parameters\n"
7700 " (declare (in ) float x@0x1aacf80)\n"
7701 " )\n"
7702 " (\n"
7703 " ))\n"
7704 "\n"
7705 " (signature vec2\n"
7706 " (parameters\n"
7707 " (declare (in ) vec2 x@0x1aad300)\n"
7708 " )\n"
7709 " (\n"
7710 " ))\n"
7711 "\n"
7712 " (signature vec3\n"
7713 " (parameters\n"
7714 " (declare (in ) vec3 x@0x1aad4e0)\n"
7715 " )\n"
7716 " (\n"
7717 " ))\n"
7718 "\n"
7719 " (signature vec4\n"
7720 " (parameters\n"
7721 " (declare (in ) vec4 x@0x1aad6c0)\n"
7722 " )\n"
7723 " (\n"
7724 " ))\n"
7725 "\n"
7726 ")\n"
7727 "\n"
7728 "(function sqrt\n"
7729 " (signature float\n"
7730 " (parameters\n"
7731 " (declare (in ) float x@0x1aad8a0)\n"
7732 " )\n"
7733 " (\n"
7734 " ))\n"
7735 "\n"
7736 " (signature vec2\n"
7737 " (parameters\n"
7738 " (declare (in ) vec2 x@0x1aadc20)\n"
7739 " )\n"
7740 " (\n"
7741 " ))\n"
7742 "\n"
7743 " (signature vec3\n"
7744 " (parameters\n"
7745 " (declare (in ) vec3 x@0x1aade00)\n"
7746 " )\n"
7747 " (\n"
7748 " ))\n"
7749 "\n"
7750 " (signature vec4\n"
7751 " (parameters\n"
7752 " (declare (in ) vec4 x@0x1aadfe0)\n"
7753 " )\n"
7754 " (\n"
7755 " ))\n"
7756 "\n"
7757 ")\n"
7758 "\n"
7759 "(function inversesqrt\n"
7760 " (signature float\n"
7761 " (parameters\n"
7762 " (declare (in ) float x@0x1aae1c0)\n"
7763 " )\n"
7764 " (\n"
7765 " ))\n"
7766 "\n"
7767 " (signature vec2\n"
7768 " (parameters\n"
7769 " (declare (in ) vec2 x@0x1aae550)\n"
7770 " )\n"
7771 " (\n"
7772 " ))\n"
7773 "\n"
7774 " (signature vec3\n"
7775 " (parameters\n"
7776 " (declare (in ) vec3 x@0x1aae730)\n"
7777 " )\n"
7778 " (\n"
7779 " ))\n"
7780 "\n"
7781 " (signature vec4\n"
7782 " (parameters\n"
7783 " (declare (in ) vec4 x@0x1aae910)\n"
7784 " )\n"
7785 " (\n"
7786 " ))\n"
7787 "\n"
7788 ")\n"
7789 "\n"
7790 "(function abs\n"
7791 " (signature float\n"
7792 " (parameters\n"
7793 " (declare (in ) float x@0x1aaeaf0)\n"
7794 " )\n"
7795 " (\n"
7796 " ))\n"
7797 "\n"
7798 " (signature vec2\n"
7799 " (parameters\n"
7800 " (declare (in ) vec2 x@0x1aaee70)\n"
7801 " )\n"
7802 " (\n"
7803 " ))\n"
7804 "\n"
7805 " (signature vec3\n"
7806 " (parameters\n"
7807 " (declare (in ) vec3 x@0x1aaf050)\n"
7808 " )\n"
7809 " (\n"
7810 " ))\n"
7811 "\n"
7812 " (signature vec4\n"
7813 " (parameters\n"
7814 " (declare (in ) vec4 x@0x1aaf230)\n"
7815 " )\n"
7816 " (\n"
7817 " ))\n"
7818 "\n"
7819 ")\n"
7820 "\n"
7821 "(function sign\n"
7822 " (signature float\n"
7823 " (parameters\n"
7824 " (declare (in ) float x@0x1aaf410)\n"
7825 " )\n"
7826 " (\n"
7827 " ))\n"
7828 "\n"
7829 " (signature vec2\n"
7830 " (parameters\n"
7831 " (declare (in ) vec2 x@0x1aaf790)\n"
7832 " )\n"
7833 " (\n"
7834 " ))\n"
7835 "\n"
7836 " (signature vec3\n"
7837 " (parameters\n"
7838 " (declare (in ) vec3 x@0x1aaf970)\n"
7839 " )\n"
7840 " (\n"
7841 " ))\n"
7842 "\n"
7843 " (signature vec4\n"
7844 " (parameters\n"
7845 " (declare (in ) vec4 x@0x1aafb50)\n"
7846 " )\n"
7847 " (\n"
7848 " ))\n"
7849 "\n"
7850 ")\n"
7851 "\n"
7852 "(function floor\n"
7853 " (signature float\n"
7854 " (parameters\n"
7855 " (declare (in ) float x@0x1aafd30)\n"
7856 " )\n"
7857 " (\n"
7858 " ))\n"
7859 "\n"
7860 " (signature vec2\n"
7861 " (parameters\n"
7862 " (declare (in ) vec2 x@0x1ab00b0)\n"
7863 " )\n"
7864 " (\n"
7865 " ))\n"
7866 "\n"
7867 " (signature vec3\n"
7868 " (parameters\n"
7869 " (declare (in ) vec3 x@0x1ab0290)\n"
7870 " )\n"
7871 " (\n"
7872 " ))\n"
7873 "\n"
7874 " (signature vec4\n"
7875 " (parameters\n"
7876 " (declare (in ) vec4 x@0x1ab0470)\n"
7877 " )\n"
7878 " (\n"
7879 " ))\n"
7880 "\n"
7881 ")\n"
7882 "\n"
7883 "(function ceil\n"
7884 " (signature float\n"
7885 " (parameters\n"
7886 " (declare (in ) float x@0x1ab0650)\n"
7887 " )\n"
7888 " (\n"
7889 " ))\n"
7890 "\n"
7891 " (signature vec2\n"
7892 " (parameters\n"
7893 " (declare (in ) vec2 x@0x1ab09d0)\n"
7894 " )\n"
7895 " (\n"
7896 " ))\n"
7897 "\n"
7898 " (signature vec3\n"
7899 " (parameters\n"
7900 " (declare (in ) vec3 x@0x1ab0bb0)\n"
7901 " )\n"
7902 " (\n"
7903 " ))\n"
7904 "\n"
7905 " (signature vec4\n"
7906 " (parameters\n"
7907 " (declare (in ) vec4 x@0x1ab0d90)\n"
7908 " )\n"
7909 " (\n"
7910 " ))\n"
7911 "\n"
7912 ")\n"
7913 "\n"
7914 "(function fract\n"
7915 " (signature float\n"
7916 " (parameters\n"
7917 " (declare (in ) float x@0x1ab0f70)\n"
7918 " )\n"
7919 " (\n"
7920 " ))\n"
7921 "\n"
7922 " (signature vec2\n"
7923 " (parameters\n"
7924 " (declare (in ) vec2 x@0x1ab12f0)\n"
7925 " )\n"
7926 " (\n"
7927 " ))\n"
7928 "\n"
7929 " (signature vec3\n"
7930 " (parameters\n"
7931 " (declare (in ) vec3 x@0x1ab14d0)\n"
7932 " )\n"
7933 " (\n"
7934 " ))\n"
7935 "\n"
7936 " (signature vec4\n"
7937 " (parameters\n"
7938 " (declare (in ) vec4 x@0x1ab16b0)\n"
7939 " )\n"
7940 " (\n"
7941 " ))\n"
7942 "\n"
7943 ")\n"
7944 "\n"
7945 "(function mod\n"
7946 " (signature float\n"
7947 " (parameters\n"
7948 " (declare (in ) float x@0x1ab1890)\n"
7949 " (declare (in ) float y@0x1ab19a0)\n"
7950 " )\n"
7951 " (\n"
7952 " ))\n"
7953 "\n"
7954 " (signature vec2\n"
7955 " (parameters\n"
7956 " (declare (in ) vec2 x@0x1ab1d20)\n"
7957 " (declare (in ) float y@0x1ab1e30)\n"
7958 " )\n"
7959 " (\n"
7960 " ))\n"
7961 "\n"
7962 " (signature vec3\n"
7963 " (parameters\n"
7964 " (declare (in ) vec3 x@0x1ab2010)\n"
7965 " (declare (in ) float y@0x1ab2120)\n"
7966 " )\n"
7967 " (\n"
7968 " ))\n"
7969 "\n"
7970 " (signature vec4\n"
7971 " (parameters\n"
7972 " (declare (in ) vec4 x@0x1ab2300)\n"
7973 " (declare (in ) float y@0x1ab2410)\n"
7974 " )\n"
7975 " (\n"
7976 " ))\n"
7977 "\n"
7978 " (signature vec2\n"
7979 " (parameters\n"
7980 " (declare (in ) vec2 x@0x1ab25f0)\n"
7981 " (declare (in ) vec2 y@0x1ab2700)\n"
7982 " )\n"
7983 " (\n"
7984 " ))\n"
7985 "\n"
7986 " (signature vec3\n"
7987 " (parameters\n"
7988 " (declare (in ) vec3 x@0x1ab28e0)\n"
7989 " (declare (in ) vec3 y@0x1ab29f0)\n"
7990 " )\n"
7991 " (\n"
7992 " ))\n"
7993 "\n"
7994 " (signature vec4\n"
7995 " (parameters\n"
7996 " (declare (in ) vec4 x@0x1ab2bd0)\n"
7997 " (declare (in ) vec4 y@0x1ab2ce0)\n"
7998 " )\n"
7999 " (\n"
8000 " ))\n"
8001 "\n"
8002 ")\n"
8003 "\n"
8004 "(function min\n"
8005 " (signature float\n"
8006 " (parameters\n"
8007 " (declare (in ) float x@0x1ab2ec0)\n"
8008 " (declare (in ) float y@0x1ab2fd0)\n"
8009 " )\n"
8010 " (\n"
8011 " ))\n"
8012 "\n"
8013 " (signature vec2\n"
8014 " (parameters\n"
8015 " (declare (in ) vec2 x@0x1ab3350)\n"
8016 " (declare (in ) vec2 y@0x1ab3460)\n"
8017 " )\n"
8018 " (\n"
8019 " ))\n"
8020 "\n"
8021 " (signature vec3\n"
8022 " (parameters\n"
8023 " (declare (in ) vec3 x@0x1ab3640)\n"
8024 " (declare (in ) vec3 y@0x1ab3750)\n"
8025 " )\n"
8026 " (\n"
8027 " ))\n"
8028 "\n"
8029 " (signature vec4\n"
8030 " (parameters\n"
8031 " (declare (in ) vec4 x@0x1ab3930)\n"
8032 " (declare (in ) vec4 y@0x1ab3a40)\n"
8033 " )\n"
8034 " (\n"
8035 " ))\n"
8036 "\n"
8037 " (signature vec2\n"
8038 " (parameters\n"
8039 " (declare (in ) vec2 x@0x1ab3c20)\n"
8040 " (declare (in ) float y@0x1ab3d30)\n"
8041 " )\n"
8042 " (\n"
8043 " ))\n"
8044 "\n"
8045 " (signature vec3\n"
8046 " (parameters\n"
8047 " (declare (in ) vec3 x@0x1ab3f10)\n"
8048 " (declare (in ) float y@0x1ab4020)\n"
8049 " )\n"
8050 " (\n"
8051 " ))\n"
8052 "\n"
8053 " (signature vec4\n"
8054 " (parameters\n"
8055 " (declare (in ) vec4 x@0x1ab4200)\n"
8056 " (declare (in ) float y@0x1ab4310)\n"
8057 " )\n"
8058 " (\n"
8059 " ))\n"
8060 "\n"
8061 ")\n"
8062 "\n"
8063 "(function max\n"
8064 " (signature float\n"
8065 " (parameters\n"
8066 " (declare (in ) float x@0x1ab44f0)\n"
8067 " (declare (in ) float y@0x1ab4600)\n"
8068 " )\n"
8069 " (\n"
8070 " ))\n"
8071 "\n"
8072 " (signature vec2\n"
8073 " (parameters\n"
8074 " (declare (in ) vec2 x@0x1ab4980)\n"
8075 " (declare (in ) vec2 y@0x1ab4a90)\n"
8076 " )\n"
8077 " (\n"
8078 " ))\n"
8079 "\n"
8080 " (signature vec3\n"
8081 " (parameters\n"
8082 " (declare (in ) vec3 x@0x1ab4c70)\n"
8083 " (declare (in ) vec3 y@0x1ab4d80)\n"
8084 " )\n"
8085 " (\n"
8086 " ))\n"
8087 "\n"
8088 " (signature vec4\n"
8089 " (parameters\n"
8090 " (declare (in ) vec4 x@0x1ab4f60)\n"
8091 " (declare (in ) vec4 y@0x1ab5070)\n"
8092 " )\n"
8093 " (\n"
8094 " ))\n"
8095 "\n"
8096 " (signature vec2\n"
8097 " (parameters\n"
8098 " (declare (in ) vec2 x@0x1ab5250)\n"
8099 " (declare (in ) float y@0x1ab5360)\n"
8100 " )\n"
8101 " (\n"
8102 " ))\n"
8103 "\n"
8104 " (signature vec3\n"
8105 " (parameters\n"
8106 " (declare (in ) vec3 x@0x1ab5540)\n"
8107 " (declare (in ) float y@0x1ab5650)\n"
8108 " )\n"
8109 " (\n"
8110 " ))\n"
8111 "\n"
8112 " (signature vec4\n"
8113 " (parameters\n"
8114 " (declare (in ) vec4 x@0x1ab5830)\n"
8115 " (declare (in ) float y@0x1ab5940)\n"
8116 " )\n"
8117 " (\n"
8118 " ))\n"
8119 "\n"
8120 ")\n"
8121 "\n"
8122 "(function clamp\n"
8123 " (signature float\n"
8124 " (parameters\n"
8125 " (declare (in ) float x@0x1ab5b20)\n"
8126 " (declare (in ) float minVal@0x1ab5c30)\n"
8127 " (declare (in ) float maxVal@0x1ab5d40)\n"
8128 " )\n"
8129 " (\n"
8130 " ))\n"
8131 "\n"
8132 " (signature vec2\n"
8133 " (parameters\n"
8134 " (declare (in ) vec2 x@0x1ab60c0)\n"
8135 " (declare (in ) vec2 minVal@0x1ab61d0)\n"
8136 " (declare (in ) vec2 maxVal@0x1ab62e0)\n"
8137 " )\n"
8138 " (\n"
8139 " ))\n"
8140 "\n"
8141 " (signature vec3\n"
8142 " (parameters\n"
8143 " (declare (in ) vec3 x@0x1ab64c0)\n"
8144 " (declare (in ) vec3 minVal@0x1ab65d0)\n"
8145 " (declare (in ) vec3 maxVal@0x1ab66e0)\n"
8146 " )\n"
8147 " (\n"
8148 " ))\n"
8149 "\n"
8150 " (signature vec4\n"
8151 " (parameters\n"
8152 " (declare (in ) vec4 x@0x1ab68c0)\n"
8153 " (declare (in ) vec4 minVal@0x1ab69d0)\n"
8154 " (declare (in ) vec4 maxVal@0x1ab6ae0)\n"
8155 " )\n"
8156 " (\n"
8157 " ))\n"
8158 "\n"
8159 " (signature vec2\n"
8160 " (parameters\n"
8161 " (declare (in ) vec2 x@0x1ab6cc0)\n"
8162 " (declare (in ) float minVal@0x1ab6dd0)\n"
8163 " (declare (in ) float maxVal@0x1ab6ee0)\n"
8164 " )\n"
8165 " (\n"
8166 " ))\n"
8167 "\n"
8168 " (signature vec3\n"
8169 " (parameters\n"
8170 " (declare (in ) vec3 x@0x1ab70c0)\n"
8171 " (declare (in ) float minVal@0x1ab71d0)\n"
8172 " (declare (in ) float maxVal@0x1ab72e0)\n"
8173 " )\n"
8174 " (\n"
8175 " ))\n"
8176 "\n"
8177 " (signature vec4\n"
8178 " (parameters\n"
8179 " (declare (in ) vec4 x@0x1ab74c0)\n"
8180 " (declare (in ) float minVal@0x1ab75d0)\n"
8181 " (declare (in ) float maxVal@0x1ab76e0)\n"
8182 " )\n"
8183 " (\n"
8184 " ))\n"
8185 "\n"
8186 ")\n"
8187 "\n"
8188 "(function mix\n"
8189 " (signature float\n"
8190 " (parameters\n"
8191 " (declare (in ) float x@0x1ab78c0)\n"
8192 " (declare (in ) float y@0x1ab79d0)\n"
8193 " (declare (in ) float a@0x1ab7ae0)\n"
8194 " )\n"
8195 " (\n"
8196 " ))\n"
8197 "\n"
8198 " (signature vec2\n"
8199 " (parameters\n"
8200 " (declare (in ) vec2 x@0x1ab7e60)\n"
8201 " (declare (in ) vec2 y@0x1ab7f70)\n"
8202 " (declare (in ) vec2 a@0x1ab8080)\n"
8203 " )\n"
8204 " (\n"
8205 " ))\n"
8206 "\n"
8207 " (signature vec3\n"
8208 " (parameters\n"
8209 " (declare (in ) vec3 x@0x1ab8260)\n"
8210 " (declare (in ) vec3 y@0x1ab8370)\n"
8211 " (declare (in ) vec3 a@0x1ab8480)\n"
8212 " )\n"
8213 " (\n"
8214 " ))\n"
8215 "\n"
8216 " (signature vec4\n"
8217 " (parameters\n"
8218 " (declare (in ) vec4 x@0x1ab8660)\n"
8219 " (declare (in ) vec4 y@0x1ab8770)\n"
8220 " (declare (in ) vec4 a@0x1ab8880)\n"
8221 " )\n"
8222 " (\n"
8223 " ))\n"
8224 "\n"
8225 " (signature vec2\n"
8226 " (parameters\n"
8227 " (declare (in ) vec2 x@0x1ab8a60)\n"
8228 " (declare (in ) vec2 y@0x1ab8b70)\n"
8229 " (declare (in ) float a@0x1ab8c80)\n"
8230 " )\n"
8231 " (\n"
8232 " ))\n"
8233 "\n"
8234 " (signature vec3\n"
8235 " (parameters\n"
8236 " (declare (in ) vec3 x@0x1ab8e60)\n"
8237 " (declare (in ) vec3 y@0x1ab8f70)\n"
8238 " (declare (in ) float a@0x1ab9080)\n"
8239 " )\n"
8240 " (\n"
8241 " ))\n"
8242 "\n"
8243 " (signature vec4\n"
8244 " (parameters\n"
8245 " (declare (in ) vec4 x@0x1ab9260)\n"
8246 " (declare (in ) vec4 y@0x1ab9370)\n"
8247 " (declare (in ) float a@0x1ab9480)\n"
8248 " )\n"
8249 " (\n"
8250 " ))\n"
8251 "\n"
8252 ")\n"
8253 "\n"
8254 "(function step\n"
8255 " (signature float\n"
8256 " (parameters\n"
8257 " (declare (in ) float edge@0x1ab9660)\n"
8258 " (declare (in ) float x@0x1ab9770)\n"
8259 " )\n"
8260 " (\n"
8261 " ))\n"
8262 "\n"
8263 " (signature vec2\n"
8264 " (parameters\n"
8265 " (declare (in ) vec2 edge@0x1ab9af0)\n"
8266 " (declare (in ) vec2 x@0x1ab9c00)\n"
8267 " )\n"
8268 " (\n"
8269 " ))\n"
8270 "\n"
8271 " (signature vec3\n"
8272 " (parameters\n"
8273 " (declare (in ) vec3 edge@0x1ab9de0)\n"
8274 " (declare (in ) vec3 x@0x1ab9ef0)\n"
8275 " )\n"
8276 " (\n"
8277 " ))\n"
8278 "\n"
8279 " (signature vec4\n"
8280 " (parameters\n"
8281 " (declare (in ) vec4 edge@0x1aba0d0)\n"
8282 " (declare (in ) vec4 x@0x1aba1e0)\n"
8283 " )\n"
8284 " (\n"
8285 " ))\n"
8286 "\n"
8287 " (signature vec2\n"
8288 " (parameters\n"
8289 " (declare (in ) float edge@0x1aba3c0)\n"
8290 " (declare (in ) vec2 x@0x1aba4d0)\n"
8291 " )\n"
8292 " (\n"
8293 " ))\n"
8294 "\n"
8295 " (signature vec3\n"
8296 " (parameters\n"
8297 " (declare (in ) float edge@0x1aba6b0)\n"
8298 " (declare (in ) vec3 x@0x1aba7c0)\n"
8299 " )\n"
8300 " (\n"
8301 " ))\n"
8302 "\n"
8303 " (signature vec4\n"
8304 " (parameters\n"
8305 " (declare (in ) float edge@0x1aba9a0)\n"
8306 " (declare (in ) vec4 x@0x1abaab0)\n"
8307 " )\n"
8308 " (\n"
8309 " ))\n"
8310 "\n"
8311 ")\n"
8312 "\n"
8313 "(function smoothstep\n"
8314 " (signature float\n"
8315 " (parameters\n"
8316 " (declare (in ) float edge0@0x1abac90)\n"
8317 " (declare (in ) float edge1@0x1abada0)\n"
8318 " (declare (in ) float x@0x1abaeb0)\n"
8319 " )\n"
8320 " (\n"
8321 " ))\n"
8322 "\n"
8323 " (signature vec2\n"
8324 " (parameters\n"
8325 " (declare (in ) vec2 edge0@0x1abb240)\n"
8326 " (declare (in ) vec2 edge1@0x1abb350)\n"
8327 " (declare (in ) vec2 x@0x1abb460)\n"
8328 " )\n"
8329 " (\n"
8330 " ))\n"
8331 "\n"
8332 " (signature vec3\n"
8333 " (parameters\n"
8334 " (declare (in ) vec3 edge0@0x1abb640)\n"
8335 " (declare (in ) vec3 edge1@0x1abb750)\n"
8336 " (declare (in ) vec3 x@0x1abb860)\n"
8337 " )\n"
8338 " (\n"
8339 " ))\n"
8340 "\n"
8341 " (signature vec4\n"
8342 " (parameters\n"
8343 " (declare (in ) vec4 edge0@0x1abba40)\n"
8344 " (declare (in ) vec4 edge1@0x1abbb50)\n"
8345 " (declare (in ) vec4 x@0x1abbc60)\n"
8346 " )\n"
8347 " (\n"
8348 " ))\n"
8349 "\n"
8350 " (signature vec2\n"
8351 " (parameters\n"
8352 " (declare (in ) float edge0@0x1abbe40)\n"
8353 " (declare (in ) float edge1@0x1abbf50)\n"
8354 " (declare (in ) vec2 x@0x1abc060)\n"
8355 " )\n"
8356 " (\n"
8357 " ))\n"
8358 "\n"
8359 " (signature vec3\n"
8360 " (parameters\n"
8361 " (declare (in ) float edge0@0x1abc240)\n"
8362 " (declare (in ) float edge1@0x1abc350)\n"
8363 " (declare (in ) vec3 x@0x1abc460)\n"
8364 " )\n"
8365 " (\n"
8366 " ))\n"
8367 "\n"
8368 " (signature vec4\n"
8369 " (parameters\n"
8370 " (declare (in ) float edge0@0x1abc640)\n"
8371 " (declare (in ) float edge1@0x1abc750)\n"
8372 " (declare (in ) vec4 x@0x1abc860)\n"
8373 " )\n"
8374 " (\n"
8375 " ))\n"
8376 "\n"
8377 ")\n"
8378 "\n"
8379 "(function length\n"
8380 " (signature float\n"
8381 " (parameters\n"
8382 " (declare (in ) float x@0x1abca40)\n"
8383 " )\n"
8384 " (\n"
8385 " ))\n"
8386 "\n"
8387 " (signature float\n"
8388 " (parameters\n"
8389 " (declare (in ) vec2 x@0x1abcdc0)\n"
8390 " )\n"
8391 " (\n"
8392 " ))\n"
8393 "\n"
8394 " (signature float\n"
8395 " (parameters\n"
8396 " (declare (in ) vec3 x@0x1abcfa0)\n"
8397 " )\n"
8398 " (\n"
8399 " ))\n"
8400 "\n"
8401 " (signature float\n"
8402 " (parameters\n"
8403 " (declare (in ) vec4 x@0x1abd180)\n"
8404 " )\n"
8405 " (\n"
8406 " ))\n"
8407 "\n"
8408 ")\n"
8409 "\n"
8410 "(function distance\n"
8411 " (signature float\n"
8412 " (parameters\n"
8413 " (declare (in ) float p0@0x1abd360)\n"
8414 " (declare (in ) float p1@0x1abd470)\n"
8415 " )\n"
8416 " (\n"
8417 " ))\n"
8418 "\n"
8419 " (signature float\n"
8420 " (parameters\n"
8421 " (declare (in ) vec2 p0@0x1abd800)\n"
8422 " (declare (in ) vec2 p1@0x1abd910)\n"
8423 " )\n"
8424 " (\n"
8425 " ))\n"
8426 "\n"
8427 " (signature float\n"
8428 " (parameters\n"
8429 " (declare (in ) vec3 p0@0x1abdaf0)\n"
8430 " (declare (in ) vec3 p1@0x1abdc00)\n"
8431 " )\n"
8432 " (\n"
8433 " ))\n"
8434 "\n"
8435 " (signature float\n"
8436 " (parameters\n"
8437 " (declare (in ) vec4 p0@0x1abdde0)\n"
8438 " (declare (in ) vec4 p1@0x1abdef0)\n"
8439 " )\n"
8440 " (\n"
8441 " ))\n"
8442 "\n"
8443 ")\n"
8444 "\n"
8445 "(function dot\n"
8446 " (signature float\n"
8447 " (parameters\n"
8448 " (declare (in ) float x@0x1abe0d0)\n"
8449 " (declare (in ) float y@0x1abe1e0)\n"
8450 " )\n"
8451 " (\n"
8452 " ))\n"
8453 "\n"
8454 " (signature float\n"
8455 " (parameters\n"
8456 " (declare (in ) vec2 x@0x1abe560)\n"
8457 " (declare (in ) vec2 y@0x1abe670)\n"
8458 " )\n"
8459 " (\n"
8460 " ))\n"
8461 "\n"
8462 " (signature float\n"
8463 " (parameters\n"
8464 " (declare (in ) vec3 x@0x1abe850)\n"
8465 " (declare (in ) vec3 y@0x1abe960)\n"
8466 " )\n"
8467 " (\n"
8468 " ))\n"
8469 "\n"
8470 " (signature float\n"
8471 " (parameters\n"
8472 " (declare (in ) vec4 x@0x1abeb40)\n"
8473 " (declare (in ) vec4 y@0x1abec50)\n"
8474 " )\n"
8475 " (\n"
8476 " ))\n"
8477 "\n"
8478 ")\n"
8479 "\n"
8480 "(function cross\n"
8481 " (signature vec3\n"
8482 " (parameters\n"
8483 " (declare (in ) vec3 x@0x1abee30)\n"
8484 " (declare (in ) vec3 y@0x1abef40)\n"
8485 " )\n"
8486 " (\n"
8487 " ))\n"
8488 "\n"
8489 ")\n"
8490 "\n"
8491 "(function normalize\n"
8492 " (signature float\n"
8493 " (parameters\n"
8494 " (declare (in ) float x@0x1abf2c0)\n"
8495 " )\n"
8496 " (\n"
8497 " ))\n"
8498 "\n"
8499 " (signature vec2\n"
8500 " (parameters\n"
8501 " (declare (in ) vec2 x@0x1abf650)\n"
8502 " )\n"
8503 " (\n"
8504 " ))\n"
8505 "\n"
8506 " (signature vec3\n"
8507 " (parameters\n"
8508 " (declare (in ) vec3 x@0x1abf830)\n"
8509 " )\n"
8510 " (\n"
8511 " ))\n"
8512 "\n"
8513 " (signature vec4\n"
8514 " (parameters\n"
8515 " (declare (in ) vec4 x@0x1abfa10)\n"
8516 " )\n"
8517 " (\n"
8518 " ))\n"
8519 "\n"
8520 ")\n"
8521 "\n"
8522 "(function ftransform\n"
8523 " (signature vec4\n"
8524 " (parameters\n"
8525 " )\n"
8526 " (\n"
8527 " ))\n"
8528 "\n"
8529 ")\n"
8530 "\n"
8531 "(function faceforward\n"
8532 " (signature float\n"
8533 " (parameters\n"
8534 " (declare (in ) float N@0x1abfe70)\n"
8535 " (declare (in ) float I@0x1abff80)\n"
8536 " (declare (in ) float Nref@0x1ac0090)\n"
8537 " )\n"
8538 " (\n"
8539 " ))\n"
8540 "\n"
8541 " (signature vec2\n"
8542 " (parameters\n"
8543 " (declare (in ) vec2 N@0x1ac0420)\n"
8544 " (declare (in ) vec2 I@0x1ac0530)\n"
8545 " (declare (in ) vec2 Nref@0x1ac0640)\n"
8546 " )\n"
8547 " (\n"
8548 " ))\n"
8549 "\n"
8550 " (signature vec3\n"
8551 " (parameters\n"
8552 " (declare (in ) vec3 N@0x1ac0820)\n"
8553 " (declare (in ) vec3 I@0x1ac0930)\n"
8554 " (declare (in ) vec3 Nref@0x1ac0a40)\n"
8555 " )\n"
8556 " (\n"
8557 " ))\n"
8558 "\n"
8559 " (signature vec4\n"
8560 " (parameters\n"
8561 " (declare (in ) vec4 N@0x1ac0c20)\n"
8562 " (declare (in ) vec4 I@0x1ac0d30)\n"
8563 " (declare (in ) vec4 Nref@0x1ac0e40)\n"
8564 " )\n"
8565 " (\n"
8566 " ))\n"
8567 "\n"
8568 ")\n"
8569 "\n"
8570 "(function reflect\n"
8571 " (signature float\n"
8572 " (parameters\n"
8573 " (declare (in ) float I@0x1ac1020)\n"
8574 " (declare (in ) float N@0x1ac1130)\n"
8575 " )\n"
8576 " (\n"
8577 " ))\n"
8578 "\n"
8579 " (signature vec2\n"
8580 " (parameters\n"
8581 " (declare (in ) vec2 I@0x1ac14b0)\n"
8582 " (declare (in ) vec2 N@0x1ac15c0)\n"
8583 " )\n"
8584 " (\n"
8585 " ))\n"
8586 "\n"
8587 " (signature vec3\n"
8588 " (parameters\n"
8589 " (declare (in ) vec3 I@0x1ac17a0)\n"
8590 " (declare (in ) vec3 N@0x1ac18b0)\n"
8591 " )\n"
8592 " (\n"
8593 " ))\n"
8594 "\n"
8595 " (signature vec4\n"
8596 " (parameters\n"
8597 " (declare (in ) vec4 I@0x1ac1a90)\n"
8598 " (declare (in ) vec4 N@0x1ac1ba0)\n"
8599 " )\n"
8600 " (\n"
8601 " ))\n"
8602 "\n"
8603 ")\n"
8604 "\n"
8605 "(function refract\n"
8606 " (signature float\n"
8607 " (parameters\n"
8608 " (declare (in ) float I@0x1ac1d80)\n"
8609 " (declare (in ) float N@0x1ac1e90)\n"
8610 " (declare (in ) float eta@0x1ac1fa0)\n"
8611 " )\n"
8612 " (\n"
8613 " ))\n"
8614 "\n"
8615 " (signature vec2\n"
8616 " (parameters\n"
8617 " (declare (in ) vec2 I@0x1ac2320)\n"
8618 " (declare (in ) vec2 N@0x1ac2430)\n"
8619 " (declare (in ) float eta@0x1ac2540)\n"
8620 " )\n"
8621 " (\n"
8622 " ))\n"
8623 "\n"
8624 " (signature vec3\n"
8625 " (parameters\n"
8626 " (declare (in ) vec3 I@0x1ac2720)\n"
8627 " (declare (in ) vec3 N@0x1ac2830)\n"
8628 " (declare (in ) float eta@0x1ac2940)\n"
8629 " )\n"
8630 " (\n"
8631 " ))\n"
8632 "\n"
8633 " (signature vec4\n"
8634 " (parameters\n"
8635 " (declare (in ) vec4 I@0x1ac2b20)\n"
8636 " (declare (in ) vec4 N@0x1ac2c30)\n"
8637 " (declare (in ) float eta@0x1ac2d40)\n"
8638 " )\n"
8639 " (\n"
8640 " ))\n"
8641 "\n"
8642 ")\n"
8643 "\n"
8644 "(function matrixCompMult\n"
8645 " (signature mat2\n"
8646 " (parameters\n"
8647 " (declare (in ) mat2 x@0x1ac2f20)\n"
8648 " (declare (in ) mat2 y@0x1ac3030)\n"
8649 " )\n"
8650 " (\n"
8651 " ))\n"
8652 "\n"
8653 " (signature mat3\n"
8654 " (parameters\n"
8655 " (declare (in ) mat3 x@0x1ac33c0)\n"
8656 " (declare (in ) mat3 y@0x1ac34d0)\n"
8657 " )\n"
8658 " (\n"
8659 " ))\n"
8660 "\n"
8661 " (signature mat4\n"
8662 " (parameters\n"
8663 " (declare (in ) mat4 x@0x1ac36b0)\n"
8664 " (declare (in ) mat4 y@0x1ac37c0)\n"
8665 " )\n"
8666 " (\n"
8667 " ))\n"
8668 "\n"
8669 ")\n"
8670 "\n"
8671 "(function lessThan\n"
8672 " (signature bvec2\n"
8673 " (parameters\n"
8674 " (declare (in ) vec2 x@0x1ac39a0)\n"
8675 " (declare (in ) vec2 y@0x1ac3ab0)\n"
8676 " )\n"
8677 " (\n"
8678 " ))\n"
8679 "\n"
8680 " (signature bvec3\n"
8681 " (parameters\n"
8682 " (declare (in ) vec3 x@0x1ac3e40)\n"
8683 " (declare (in ) vec3 y@0x1ac3f50)\n"
8684 " )\n"
8685 " (\n"
8686 " ))\n"
8687 "\n"
8688 " (signature bvec4\n"
8689 " (parameters\n"
8690 " (declare (in ) vec4 x@0x1ac4130)\n"
8691 " (declare (in ) vec4 y@0x1ac4240)\n"
8692 " )\n"
8693 " (\n"
8694 " ))\n"
8695 "\n"
8696 " (signature bvec2\n"
8697 " (parameters\n"
8698 " (declare (in ) ivec2 x@0x1ac4420)\n"
8699 " (declare (in ) ivec2 y@0x1ac4530)\n"
8700 " )\n"
8701 " (\n"
8702 " ))\n"
8703 "\n"
8704 " (signature bvec3\n"
8705 " (parameters\n"
8706 " (declare (in ) ivec3 x@0x1ac4710)\n"
8707 " (declare (in ) ivec3 y@0x1ac4820)\n"
8708 " )\n"
8709 " (\n"
8710 " ))\n"
8711 "\n"
8712 " (signature bvec4\n"
8713 " (parameters\n"
8714 " (declare (in ) ivec4 x@0x1ac4a00)\n"
8715 " (declare (in ) ivec4 y@0x1ac4b10)\n"
8716 " )\n"
8717 " (\n"
8718 " ))\n"
8719 "\n"
8720 ")\n"
8721 "\n"
8722 "(function lessThanEqual\n"
8723 " (signature bvec2\n"
8724 " (parameters\n"
8725 " (declare (in ) vec2 x@0x1ac4cf0)\n"
8726 " (declare (in ) vec2 y@0x1ac4e00)\n"
8727 " )\n"
8728 " (\n"
8729 " ))\n"
8730 "\n"
8731 " (signature bvec3\n"
8732 " (parameters\n"
8733 " (declare (in ) vec3 x@0x1ac5190)\n"
8734 " (declare (in ) vec3 y@0x1ac52a0)\n"
8735 " )\n"
8736 " (\n"
8737 " ))\n"
8738 "\n"
8739 " (signature bvec4\n"
8740 " (parameters\n"
8741 " (declare (in ) vec4 x@0x1ac5480)\n"
8742 " (declare (in ) vec4 y@0x1ac5590)\n"
8743 " )\n"
8744 " (\n"
8745 " ))\n"
8746 "\n"
8747 " (signature bvec2\n"
8748 " (parameters\n"
8749 " (declare (in ) ivec2 x@0x1ac5770)\n"
8750 " (declare (in ) ivec2 y@0x1ac5880)\n"
8751 " )\n"
8752 " (\n"
8753 " ))\n"
8754 "\n"
8755 " (signature bvec3\n"
8756 " (parameters\n"
8757 " (declare (in ) ivec3 x@0x1ac5a60)\n"
8758 " (declare (in ) ivec3 y@0x1ac5b70)\n"
8759 " )\n"
8760 " (\n"
8761 " ))\n"
8762 "\n"
8763 " (signature bvec4\n"
8764 " (parameters\n"
8765 " (declare (in ) ivec4 x@0x1ac5d50)\n"
8766 " (declare (in ) ivec4 y@0x1ac5e60)\n"
8767 " )\n"
8768 " (\n"
8769 " ))\n"
8770 "\n"
8771 ")\n"
8772 "\n"
8773 "(function greaterThan\n"
8774 " (signature bvec2\n"
8775 " (parameters\n"
8776 " (declare (in ) vec2 x@0x1ac6040)\n"
8777 " (declare (in ) vec2 y@0x1ac6150)\n"
8778 " )\n"
8779 " (\n"
8780 " ))\n"
8781 "\n"
8782 " (signature bvec3\n"
8783 " (parameters\n"
8784 " (declare (in ) vec3 x@0x1ac64e0)\n"
8785 " (declare (in ) vec3 y@0x1ac65f0)\n"
8786 " )\n"
8787 " (\n"
8788 " ))\n"
8789 "\n"
8790 " (signature bvec4\n"
8791 " (parameters\n"
8792 " (declare (in ) vec4 x@0x1ac67d0)\n"
8793 " (declare (in ) vec4 y@0x1ac68e0)\n"
8794 " )\n"
8795 " (\n"
8796 " ))\n"
8797 "\n"
8798 " (signature bvec2\n"
8799 " (parameters\n"
8800 " (declare (in ) ivec2 x@0x1ac6ac0)\n"
8801 " (declare (in ) ivec2 y@0x1ac6bd0)\n"
8802 " )\n"
8803 " (\n"
8804 " ))\n"
8805 "\n"
8806 " (signature bvec3\n"
8807 " (parameters\n"
8808 " (declare (in ) ivec3 x@0x1ac6db0)\n"
8809 " (declare (in ) ivec3 y@0x1ac6ec0)\n"
8810 " )\n"
8811 " (\n"
8812 " ))\n"
8813 "\n"
8814 " (signature bvec4\n"
8815 " (parameters\n"
8816 " (declare (in ) ivec4 x@0x1ac70a0)\n"
8817 " (declare (in ) ivec4 y@0x1ac71b0)\n"
8818 " )\n"
8819 " (\n"
8820 " ))\n"
8821 "\n"
8822 ")\n"
8823 "\n"
8824 "(function greaterThanEqual\n"
8825 " (signature bvec2\n"
8826 " (parameters\n"
8827 " (declare (in ) vec2 x@0x1ac7390)\n"
8828 " (declare (in ) vec2 y@0x1ac74a0)\n"
8829 " )\n"
8830 " (\n"
8831 " ))\n"
8832 "\n"
8833 " (signature bvec3\n"
8834 " (parameters\n"
8835 " (declare (in ) vec3 x@0x1ac7830)\n"
8836 " (declare (in ) vec3 y@0x1ac7940)\n"
8837 " )\n"
8838 " (\n"
8839 " ))\n"
8840 "\n"
8841 " (signature bvec4\n"
8842 " (parameters\n"
8843 " (declare (in ) vec4 x@0x1ac7b20)\n"
8844 " (declare (in ) vec4 y@0x1ac7c30)\n"
8845 " )\n"
8846 " (\n"
8847 " ))\n"
8848 "\n"
8849 " (signature bvec2\n"
8850 " (parameters\n"
8851 " (declare (in ) ivec2 x@0x1ac7e10)\n"
8852 " (declare (in ) ivec2 y@0x1ac7f20)\n"
8853 " )\n"
8854 " (\n"
8855 " ))\n"
8856 "\n"
8857 " (signature bvec3\n"
8858 " (parameters\n"
8859 " (declare (in ) ivec3 x@0x1ac8100)\n"
8860 " (declare (in ) ivec3 y@0x1ac8210)\n"
8861 " )\n"
8862 " (\n"
8863 " ))\n"
8864 "\n"
8865 " (signature bvec4\n"
8866 " (parameters\n"
8867 " (declare (in ) ivec4 x@0x1ac83f0)\n"
8868 " (declare (in ) ivec4 y@0x1ac8500)\n"
8869 " )\n"
8870 " (\n"
8871 " ))\n"
8872 "\n"
8873 ")\n"
8874 "\n"
8875 "(function equal\n"
8876 " (signature bvec2\n"
8877 " (parameters\n"
8878 " (declare (in ) vec2 x@0x1ac86e0)\n"
8879 " (declare (in ) vec2 y@0x1ac87f0)\n"
8880 " )\n"
8881 " (\n"
8882 " ))\n"
8883 "\n"
8884 " (signature bvec3\n"
8885 " (parameters\n"
8886 " (declare (in ) vec3 x@0x1ac8b70)\n"
8887 " (declare (in ) vec3 y@0x1ac8c80)\n"
8888 " )\n"
8889 " (\n"
8890 " ))\n"
8891 "\n"
8892 " (signature bvec4\n"
8893 " (parameters\n"
8894 " (declare (in ) vec4 x@0x1ac8e60)\n"
8895 " (declare (in ) vec4 y@0x1ac8f70)\n"
8896 " )\n"
8897 " (\n"
8898 " ))\n"
8899 "\n"
8900 " (signature bvec2\n"
8901 " (parameters\n"
8902 " (declare (in ) ivec2 x@0x1ac9150)\n"
8903 " (declare (in ) ivec2 y@0x1ac9260)\n"
8904 " )\n"
8905 " (\n"
8906 " ))\n"
8907 "\n"
8908 " (signature bvec3\n"
8909 " (parameters\n"
8910 " (declare (in ) ivec3 x@0x1ac9440)\n"
8911 " (declare (in ) ivec3 y@0x1ac9550)\n"
8912 " )\n"
8913 " (\n"
8914 " ))\n"
8915 "\n"
8916 " (signature bvec4\n"
8917 " (parameters\n"
8918 " (declare (in ) ivec4 x@0x1ac9730)\n"
8919 " (declare (in ) ivec4 y@0x1ac9840)\n"
8920 " )\n"
8921 " (\n"
8922 " ))\n"
8923 "\n"
8924 " (signature bvec2\n"
8925 " (parameters\n"
8926 " (declare (in ) bvec2 x@0x1ac9a20)\n"
8927 " (declare (in ) bvec2 y@0x1ac9b30)\n"
8928 " )\n"
8929 " (\n"
8930 " ))\n"
8931 "\n"
8932 " (signature bvec3\n"
8933 " (parameters\n"
8934 " (declare (in ) bvec3 x@0x1ac9d10)\n"
8935 " (declare (in ) bvec3 y@0x1ac9e20)\n"
8936 " )\n"
8937 " (\n"
8938 " ))\n"
8939 "\n"
8940 " (signature bvec4\n"
8941 " (parameters\n"
8942 " (declare (in ) bvec4 x@0x1aca000)\n"
8943 " (declare (in ) bvec4 y@0x1aca110)\n"
8944 " )\n"
8945 " (\n"
8946 " ))\n"
8947 "\n"
8948 ")\n"
8949 "\n"
8950 "(function notEqual\n"
8951 " (signature bvec2\n"
8952 " (parameters\n"
8953 " (declare (in ) vec2 x@0x1aca2f0)\n"
8954 " (declare (in ) vec2 y@0x1aca400)\n"
8955 " )\n"
8956 " (\n"
8957 " ))\n"
8958 "\n"
8959 " (signature bvec3\n"
8960 " (parameters\n"
8961 " (declare (in ) vec3 x@0x1aca790)\n"
8962 " (declare (in ) vec3 y@0x1aca8a0)\n"
8963 " )\n"
8964 " (\n"
8965 " ))\n"
8966 "\n"
8967 " (signature bvec4\n"
8968 " (parameters\n"
8969 " (declare (in ) vec4 x@0x1acaa80)\n"
8970 " (declare (in ) vec4 y@0x1acab90)\n"
8971 " )\n"
8972 " (\n"
8973 " ))\n"
8974 "\n"
8975 " (signature bvec2\n"
8976 " (parameters\n"
8977 " (declare (in ) ivec2 x@0x1acad70)\n"
8978 " (declare (in ) ivec2 y@0x1acae80)\n"
8979 " )\n"
8980 " (\n"
8981 " ))\n"
8982 "\n"
8983 " (signature bvec3\n"
8984 " (parameters\n"
8985 " (declare (in ) ivec3 x@0x1acb060)\n"
8986 " (declare (in ) ivec3 y@0x1acb170)\n"
8987 " )\n"
8988 " (\n"
8989 " ))\n"
8990 "\n"
8991 " (signature bvec4\n"
8992 " (parameters\n"
8993 " (declare (in ) ivec4 x@0x1acb350)\n"
8994 " (declare (in ) ivec4 y@0x1acb460)\n"
8995 " )\n"
8996 " (\n"
8997 " ))\n"
8998 "\n"
8999 " (signature bvec2\n"
9000 " (parameters\n"
9001 " (declare (in ) bvec2 x@0x1acb640)\n"
9002 " (declare (in ) bvec2 y@0x1acb750)\n"
9003 " )\n"
9004 " (\n"
9005 " ))\n"
9006 "\n"
9007 " (signature bvec3\n"
9008 " (parameters\n"
9009 " (declare (in ) bvec3 x@0x1acb930)\n"
9010 " (declare (in ) bvec3 y@0x1acba40)\n"
9011 " )\n"
9012 " (\n"
9013 " ))\n"
9014 "\n"
9015 " (signature bvec4\n"
9016 " (parameters\n"
9017 " (declare (in ) bvec4 x@0x1acbc20)\n"
9018 " (declare (in ) bvec4 y@0x1acbd30)\n"
9019 " )\n"
9020 " (\n"
9021 " ))\n"
9022 "\n"
9023 ")\n"
9024 "\n"
9025 "(function any\n"
9026 " (signature bool\n"
9027 " (parameters\n"
9028 " (declare (in ) bvec2 x@0x1acbf10)\n"
9029 " )\n"
9030 " (\n"
9031 " ))\n"
9032 "\n"
9033 " (signature bool\n"
9034 " (parameters\n"
9035 " (declare (in ) bvec3 x@0x1acc290)\n"
9036 " )\n"
9037 " (\n"
9038 " ))\n"
9039 "\n"
9040 " (signature bool\n"
9041 " (parameters\n"
9042 " (declare (in ) bvec4 x@0x1acc470)\n"
9043 " )\n"
9044 " (\n"
9045 " ))\n"
9046 "\n"
9047 ")\n"
9048 "\n"
9049 "(function all\n"
9050 " (signature bool\n"
9051 " (parameters\n"
9052 " (declare (in ) bvec2 x@0x1acc650)\n"
9053 " )\n"
9054 " (\n"
9055 " ))\n"
9056 "\n"
9057 " (signature bool\n"
9058 " (parameters\n"
9059 " (declare (in ) bvec3 x@0x1acc9d0)\n"
9060 " )\n"
9061 " (\n"
9062 " ))\n"
9063 "\n"
9064 " (signature bool\n"
9065 " (parameters\n"
9066 " (declare (in ) bvec4 x@0x1accbb0)\n"
9067 " )\n"
9068 " (\n"
9069 " ))\n"
9070 "\n"
9071 ")\n"
9072 "\n"
9073 "(function not\n"
9074 " (signature bvec2\n"
9075 " (parameters\n"
9076 " (declare (in ) bvec2 x@0x1accd90)\n"
9077 " )\n"
9078 " (\n"
9079 " ))\n"
9080 "\n"
9081 " (signature bvec3\n"
9082 " (parameters\n"
9083 " (declare (in ) bvec3 x@0x1acd110)\n"
9084 " )\n"
9085 " (\n"
9086 " ))\n"
9087 "\n"
9088 " (signature bvec4\n"
9089 " (parameters\n"
9090 " (declare (in ) bvec4 x@0x1acd2f0)\n"
9091 " )\n"
9092 " (\n"
9093 " ))\n"
9094 "\n"
9095 ")\n"
9096 "\n"
9097 "(function texture1D\n"
9098 " (signature vec4\n"
9099 " (parameters\n"
9100 " (declare (in ) sampler1D sampler@0x1acd4d0)\n"
9101 " (declare (in ) float coord@0x1acd5e0)\n"
9102 " )\n"
9103 " (\n"
9104 " ))\n"
9105 "\n"
9106 ")\n"
9107 "\n"
9108 "(function texture1DProj\n"
9109 " (signature vec4\n"
9110 " (parameters\n"
9111 " (declare (in ) sampler1D sampler@0x1acd970)\n"
9112 " (declare (in ) vec2 coord@0x1acda80)\n"
9113 " )\n"
9114 " (\n"
9115 " ))\n"
9116 "\n"
9117 " (signature vec4\n"
9118 " (parameters\n"
9119 " (declare (in ) sampler1D sampler@0x1acde10)\n"
9120 " (declare (in ) vec4 coord@0x1acdf20)\n"
9121 " )\n"
9122 " (\n"
9123 " ))\n"
9124 "\n"
9125 ")\n"
9126 "\n"
9127 "(function texture1DLod\n"
9128 " (signature vec4\n"
9129 " (parameters\n"
9130 " (declare (in ) sampler1D sampler@0x1ace100)\n"
9131 " (declare (in ) float coord@0x1ace210)\n"
9132 " (declare (in ) float lod@0x1ace320)\n"
9133 " )\n"
9134 " (\n"
9135 " ))\n"
9136 "\n"
9137 ")\n"
9138 "\n"
9139 "(function texture1DProjLod\n"
9140 " (signature vec4\n"
9141 " (parameters\n"
9142 " (declare (in ) sampler1D sampler@0x1ace6b0)\n"
9143 " (declare (in ) vec2 coord@0x1ace7c0)\n"
9144 " (declare (in ) float lod@0x1ace8d0)\n"
9145 " )\n"
9146 " (\n"
9147 " ))\n"
9148 "\n"
9149 " (signature vec4\n"
9150 " (parameters\n"
9151 " (declare (in ) sampler1D sampler@0x1acec60)\n"
9152 " (declare (in ) vec4 coord@0x1aced70)\n"
9153 " (declare (in ) float lod@0x1acee80)\n"
9154 " )\n"
9155 " (\n"
9156 " ))\n"
9157 "\n"
9158 ")\n"
9159 "\n"
9160 "(function texture2D\n"
9161 " (signature vec4\n"
9162 " (parameters\n"
9163 " (declare (in ) sampler2D sampler@0x1acf060)\n"
9164 " (declare (in ) vec2 coord@0x1acf170)\n"
9165 " )\n"
9166 " (\n"
9167 " ))\n"
9168 "\n"
9169 ")\n"
9170 "\n"
9171 "(function texture2DProj\n"
9172 " (signature vec4\n"
9173 " (parameters\n"
9174 " (declare (in ) sampler2D sampler@0x1acf500)\n"
9175 " (declare (in ) vec3 coord@0x1acf610)\n"
9176 " )\n"
9177 " (\n"
9178 " ))\n"
9179 "\n"
9180 " (signature vec4\n"
9181 " (parameters\n"
9182 " (declare (in ) sampler2D sampler@0x1acf9a0)\n"
9183 " (declare (in ) vec4 coord@0x1acfab0)\n"
9184 " )\n"
9185 " (\n"
9186 " ))\n"
9187 "\n"
9188 ")\n"
9189 "\n"
9190 "(function texture2DLod\n"
9191 " (signature vec4\n"
9192 " (parameters\n"
9193 " (declare (in ) sampler2D sampler@0x1acfc90)\n"
9194 " (declare (in ) vec2 coord@0x1acfda0)\n"
9195 " (declare (in ) float lod@0x1acfeb0)\n"
9196 " )\n"
9197 " (\n"
9198 " ))\n"
9199 "\n"
9200 ")\n"
9201 "\n"
9202 "(function texture2DProjLod\n"
9203 " (signature vec4\n"
9204 " (parameters\n"
9205 " (declare (in ) sampler2D sampler@0x1ad0240)\n"
9206 " (declare (in ) vec3 coord@0x1ad0350)\n"
9207 " (declare (in ) float lod@0x1ad0460)\n"
9208 " )\n"
9209 " (\n"
9210 " ))\n"
9211 "\n"
9212 " (signature vec4\n"
9213 " (parameters\n"
9214 " (declare (in ) sampler2D sampler@0x1ad07f0)\n"
9215 " (declare (in ) vec4 coord@0x1ad0900)\n"
9216 " (declare (in ) float lod@0x1ad0a10)\n"
9217 " )\n"
9218 " (\n"
9219 " ))\n"
9220 "\n"
9221 ")\n"
9222 "\n"
9223 "(function texture3D\n"
9224 " (signature vec4\n"
9225 " (parameters\n"
9226 " (declare (in ) sampler3D sampler@0x1ad0bf0)\n"
9227 " (declare (in ) vec3 coord@0x1ad0d00)\n"
9228 " )\n"
9229 " (\n"
9230 " ))\n"
9231 "\n"
9232 ")\n"
9233 "\n"
9234 "(function texture3DProj\n"
9235 " (signature vec4\n"
9236 " (parameters\n"
9237 " (declare (in ) sampler3D sampler@0x1ad1090)\n"
9238 " (declare (in ) vec4 coord@0x1ad11a0)\n"
9239 " )\n"
9240 " (\n"
9241 " ))\n"
9242 "\n"
9243 ")\n"
9244 "\n"
9245 "(function texture3DLod\n"
9246 " (signature vec4\n"
9247 " (parameters\n"
9248 " (declare (in ) sampler3D sampler@0x1ad1530)\n"
9249 " (declare (in ) vec3 coord@0x1ad1640)\n"
9250 " (declare (in ) float lod@0x1ad1750)\n"
9251 " )\n"
9252 " (\n"
9253 " ))\n"
9254 "\n"
9255 ")\n"
9256 "\n"
9257 "(function texture3DProjLod\n"
9258 " (signature vec4\n"
9259 " (parameters\n"
9260 " (declare (in ) sampler3D sampler@0x1ad1ae0)\n"
9261 " (declare (in ) vec4 coord@0x1ad1bf0)\n"
9262 " (declare (in ) float lod@0x1ad1d00)\n"
9263 " )\n"
9264 " (\n"
9265 " ))\n"
9266 "\n"
9267 ")\n"
9268 "\n"
9269 "(function textureCube\n"
9270 " (signature vec4\n"
9271 " (parameters\n"
9272 " (declare (in ) samplerCube sampler@0x1ad2090)\n"
9273 " (declare (in ) vec3 coord@0x1ad21a0)\n"
9274 " )\n"
9275 " (\n"
9276 " ))\n"
9277 "\n"
9278 ")\n"
9279 "\n"
9280 "(function textureCubeLod\n"
9281 " (signature vec4\n"
9282 " (parameters\n"
9283 " (declare (in ) samplerCube sampler@0x1ad2530)\n"
9284 " (declare (in ) vec3 coord@0x1ad2640)\n"
9285 " (declare (in ) float lod@0x1ad2750)\n"
9286 " )\n"
9287 " (\n"
9288 " ))\n"
9289 "\n"
9290 ")\n"
9291 "\n"
9292 "(function shadow1D\n"
9293 " (signature vec4\n"
9294 " (parameters\n"
9295 " (declare (in ) sampler1DShadow sampler@0x1ad2ae0)\n"
9296 " (declare (in ) vec3 coord@0x1ad2bf0)\n"
9297 " )\n"
9298 " (\n"
9299 " ))\n"
9300 "\n"
9301 ")\n"
9302 "\n"
9303 "(function shadow2D\n"
9304 " (signature vec4\n"
9305 " (parameters\n"
9306 " (declare (in ) sampler2DShadow sampler@0x1ad2f80)\n"
9307 " (declare (in ) vec3 coord@0x1ad3090)\n"
9308 " )\n"
9309 " (\n"
9310 " ))\n"
9311 "\n"
9312 ")\n"
9313 "\n"
9314 "(function shadow1DProj\n"
9315 " (signature vec4\n"
9316 " (parameters\n"
9317 " (declare (in ) sampler1DShadow sampler@0x1ad3420)\n"
9318 " (declare (in ) vec4 coord@0x1ad3530)\n"
9319 " )\n"
9320 " (\n"
9321 " ))\n"
9322 "\n"
9323 ")\n"
9324 "\n"
9325 "(function shadow2DProj\n"
9326 " (signature vec4\n"
9327 " (parameters\n"
9328 " (declare (in ) sampler2DShadow sampler@0x1ad38c0)\n"
9329 " (declare (in ) vec4 coord@0x1ad39d0)\n"
9330 " )\n"
9331 " (\n"
9332 " ))\n"
9333 "\n"
9334 ")\n"
9335 "\n"
9336 "(function shadow1DLod\n"
9337 " (signature vec4\n"
9338 " (parameters\n"
9339 " (declare (in ) sampler1DShadow sampler@0x1ad3d60)\n"
9340 " (declare (in ) vec3 coord@0x1ad3e70)\n"
9341 " (declare (in ) float lod@0x1ad3f80)\n"
9342 " )\n"
9343 " (\n"
9344 " ))\n"
9345 "\n"
9346 ")\n"
9347 "\n"
9348 "(function shadow2DLod\n"
9349 " (signature vec4\n"
9350 " (parameters\n"
9351 " (declare (in ) sampler2DShadow sampler@0x1ad4310)\n"
9352 " (declare (in ) vec3 coord@0x1ad4420)\n"
9353 " (declare (in ) float lod@0x1ad4530)\n"
9354 " )\n"
9355 " (\n"
9356 " ))\n"
9357 "\n"
9358 ")\n"
9359 "\n"
9360 "(function shadow1DProjLod\n"
9361 " (signature vec4\n"
9362 " (parameters\n"
9363 " (declare (in ) sampler1DShadow sampler@0x1ad48c0)\n"
9364 " (declare (in ) vec4 coord@0x1ad49d0)\n"
9365 " (declare (in ) float lod@0x1ad4ae0)\n"
9366 " )\n"
9367 " (\n"
9368 " ))\n"
9369 "\n"
9370 ")\n"
9371 "\n"
9372 "(function shadow2DProjLod\n"
9373 " (signature vec4\n"
9374 " (parameters\n"
9375 " (declare (in ) sampler2DShadow sampler@0x1ad4e70)\n"
9376 " (declare (in ) vec4 coord@0x1ad4f80)\n"
9377 " (declare (in ) float lod@0x1ad5090)\n"
9378 " )\n"
9379 " (\n"
9380 " ))\n"
9381 "\n"
9382 ")\n"
9383 "\n"
9384 "(function noise1\n"
9385 " (signature float\n"
9386 " (parameters\n"
9387 " (declare (in ) float x@0x1ad5420)\n"
9388 " )\n"
9389 " (\n"
9390 " ))\n"
9391 "\n"
9392 " (signature float\n"
9393 " (parameters\n"
9394 " (declare (in ) vec2 x@0x1ad57a0)\n"
9395 " )\n"
9396 " (\n"
9397 " ))\n"
9398 "\n"
9399 " (signature float\n"
9400 " (parameters\n"
9401 " (declare (in ) vec3 x@0x1ad5980)\n"
9402 " )\n"
9403 " (\n"
9404 " ))\n"
9405 "\n"
9406 " (signature float\n"
9407 " (parameters\n"
9408 " (declare (in ) vec4 x@0x1ad5b60)\n"
9409 " )\n"
9410 " (\n"
9411 " ))\n"
9412 "\n"
9413 ")\n"
9414 "\n"
9415 "(function noise2\n"
9416 " (signature vec2\n"
9417 " (parameters\n"
9418 " (declare (in ) float x@0x1ad5d40)\n"
9419 " )\n"
9420 " (\n"
9421 " ))\n"
9422 "\n"
9423 " (signature vec2\n"
9424 " (parameters\n"
9425 " (declare (in ) vec2 x@0x1ad60c0)\n"
9426 " )\n"
9427 " (\n"
9428 " ))\n"
9429 "\n"
9430 " (signature vec2\n"
9431 " (parameters\n"
9432 " (declare (in ) vec3 x@0x1ad62a0)\n"
9433 " )\n"
9434 " (\n"
9435 " ))\n"
9436 "\n"
9437 " (signature vec2\n"
9438 " (parameters\n"
9439 " (declare (in ) vec4 x@0x1ad6480)\n"
9440 " )\n"
9441 " (\n"
9442 " ))\n"
9443 "\n"
9444 ")\n"
9445 "\n"
9446 "(function noise3\n"
9447 " (signature vec3\n"
9448 " (parameters\n"
9449 " (declare (in ) float x@0x1ad6660)\n"
9450 " )\n"
9451 " (\n"
9452 " ))\n"
9453 "\n"
9454 " (signature vec3\n"
9455 " (parameters\n"
9456 " (declare (in ) vec2 x@0x1ad69e0)\n"
9457 " )\n"
9458 " (\n"
9459 " ))\n"
9460 "\n"
9461 " (signature vec3\n"
9462 " (parameters\n"
9463 " (declare (in ) vec3 x@0x1ad6bc0)\n"
9464 " )\n"
9465 " (\n"
9466 " ))\n"
9467 "\n"
9468 " (signature vec3\n"
9469 " (parameters\n"
9470 " (declare (in ) vec4 x@0x1ad6da0)\n"
9471 " )\n"
9472 " (\n"
9473 " ))\n"
9474 "\n"
9475 ")\n"
9476 "\n"
9477 "(function noise4\n"
9478 " (signature vec4\n"
9479 " (parameters\n"
9480 " (declare (in ) float x@0x1ad6f80)\n"
9481 " )\n"
9482 " (\n"
9483 " ))\n"
9484 "\n"
9485 " (signature vec4\n"
9486 " (parameters\n"
9487 " (declare (in ) vec2 x@0x1ad7300)\n"
9488 " )\n"
9489 " (\n"
9490 " ))\n"
9491 "\n"
9492 " (signature vec4\n"
9493 " (parameters\n"
9494 " (declare (in ) vec3 x@0x1ad74e0)\n"
9495 " )\n"
9496 " (\n"
9497 " ))\n"
9498 "\n"
9499 " (signature vec4\n"
9500 " (parameters\n"
9501 " (declare (in ) vec4 x@0x1ad76c0)\n"
9502 " )\n"
9503 " (\n"
9504 " ))\n"
9505 "\n"
9506 ")\n"
9507 "\n"
9508 "\n"
9509 ")"
9510;
9511static const char *functions_for_110_vert [] = {
9512 builtin_clamp,
9513 builtin_matrixCompMult,
9514 builtin_shadow2DProjLod,
9515 builtin_noise2,
9516 builtin_texture3DProjLod,
9517 builtin_pow,
9518 builtin_texture2DProj,
9519 builtin_greaterThanEqual,
9520 builtin_sign,
9521 builtin_texture3DProj,
9522 builtin_texture2D,
9523 builtin_equal,
9524 builtin_faceforward,
9525 builtin_tan,
9526 builtin_shadow2DProj,
9527 builtin_shadow1DProjLod,
9528 builtin_any,
9529 builtin_normalize,
9530 builtin_asin,
9531 builtin_texture1DProj,
9532 builtin_log,
9533 builtin_floor,
9534 builtin_exp2,
9535 builtin_lessThan,
9536 builtin_cross,
9537 builtin_sqrt,
9538 builtin_texture3DLod,
9539 builtin_fract,
9540 builtin_abs,
9541 builtin_degrees,
9542 builtin_shadow1DLod,
9543 builtin_ftransform,
9544 builtin_sin,
9545 builtin_shadow2D,
9546 builtin_shadow2DLod,
9547 builtin_all,
9548 builtin_log2,
9549 builtin_atan,
9550 builtin_notEqual,
9551 builtin_max,
9552 builtin_lessThanEqual,
9553 builtin_shadow1DProj,
9554 builtin_ceil,
9555 builtin_reflect,
9556 builtin_textureCubeLod,
9557 builtin_step,
9558 builtin_texture1D,
9559 builtin_greaterThan,
9560 builtin_texture3D,
9561 builtin_not,
9562 builtin_texture2DProjLod,
9563 builtin_inversesqrt,
9564 builtin_mod,
9565 builtin_noise4,
9566 builtin_distance,
9567 builtin_cos,
9568 builtin_shadow1D,
9569 builtin_noise1,
9570 builtin_refract,
9571 builtin_noise3,
9572 builtin_texture2DLod,
9573 builtin_min,
9574 builtin_radians,
9575 builtin_smoothstep,
9576 builtin_texture1DProjLod,
9577 builtin_textureCube,
9578 builtin_length,
9579 builtin_texture1DLod,
9580 builtin_exp,
9581 builtin_acos,
9582 builtin_mix,
9583 builtin_dot,
9584};
9585static const char *prototypes_for_110_frag =
9586 "(\n"
9587 "(function radians\n"
9588 " (signature float\n"
9589 " (parameters\n"
9590 " (declare (in ) float degrees@0x26c9280)\n"
9591 " )\n"
9592 " (\n"
9593 " ))\n"
9594 "\n"
9595 " (signature vec2\n"
9596 " (parameters\n"
9597 " (declare (in ) vec2 degrees@0x26c9600)\n"
9598 " )\n"
9599 " (\n"
9600 " ))\n"
9601 "\n"
9602 " (signature vec3\n"
9603 " (parameters\n"
9604 " (declare (in ) vec3 degrees@0x26c97e0)\n"
9605 " )\n"
9606 " (\n"
9607 " ))\n"
9608 "\n"
9609 " (signature vec4\n"
9610 " (parameters\n"
9611 " (declare (in ) vec4 degrees@0x26c99c0)\n"
9612 " )\n"
9613 " (\n"
9614 " ))\n"
9615 "\n"
9616 ")\n"
9617 "\n"
9618 "(function degrees\n"
9619 " (signature float\n"
9620 " (parameters\n"
9621 " (declare (in ) float radians@0x26c9ba0)\n"
9622 " )\n"
9623 " (\n"
9624 " ))\n"
9625 "\n"
9626 " (signature vec2\n"
9627 " (parameters\n"
9628 " (declare (in ) vec2 radians@0x26c9f20)\n"
9629 " )\n"
9630 " (\n"
9631 " ))\n"
9632 "\n"
9633 " (signature vec3\n"
9634 " (parameters\n"
9635 " (declare (in ) vec3 radians@0x26ca100)\n"
9636 " )\n"
9637 " (\n"
9638 " ))\n"
9639 "\n"
9640 " (signature vec4\n"
9641 " (parameters\n"
9642 " (declare (in ) vec4 radians@0x26ca2e0)\n"
9643 " )\n"
9644 " (\n"
9645 " ))\n"
9646 "\n"
9647 ")\n"
9648 "\n"
9649 "(function sin\n"
9650 " (signature float\n"
9651 " (parameters\n"
9652 " (declare (in ) float angle@0x26ca4c0)\n"
9653 " )\n"
9654 " (\n"
9655 " ))\n"
9656 "\n"
9657 " (signature vec2\n"
9658 " (parameters\n"
9659 " (declare (in ) vec2 angle@0x26ca840)\n"
9660 " )\n"
9661 " (\n"
9662 " ))\n"
9663 "\n"
9664 " (signature vec3\n"
9665 " (parameters\n"
9666 " (declare (in ) vec3 angle@0x26caa20)\n"
9667 " )\n"
9668 " (\n"
9669 " ))\n"
9670 "\n"
9671 " (signature vec4\n"
9672 " (parameters\n"
9673 " (declare (in ) vec4 angle@0x26cac00)\n"
9674 " )\n"
9675 " (\n"
9676 " ))\n"
9677 "\n"
9678 ")\n"
9679 "\n"
9680 "(function cos\n"
9681 " (signature float\n"
9682 " (parameters\n"
9683 " (declare (in ) float angle@0x26cade0)\n"
9684 " )\n"
9685 " (\n"
9686 " ))\n"
9687 "\n"
9688 " (signature vec2\n"
9689 " (parameters\n"
9690 " (declare (in ) vec2 angle@0x26cb160)\n"
9691 " )\n"
9692 " (\n"
9693 " ))\n"
9694 "\n"
9695 " (signature vec3\n"
9696 " (parameters\n"
9697 " (declare (in ) vec3 angle@0x26cb340)\n"
9698 " )\n"
9699 " (\n"
9700 " ))\n"
9701 "\n"
9702 " (signature vec4\n"
9703 " (parameters\n"
9704 " (declare (in ) vec4 angle@0x26cb520)\n"
9705 " )\n"
9706 " (\n"
9707 " ))\n"
9708 "\n"
9709 ")\n"
9710 "\n"
9711 "(function tan\n"
9712 " (signature float\n"
9713 " (parameters\n"
9714 " (declare (in ) float angle@0x26cb700)\n"
9715 " )\n"
9716 " (\n"
9717 " ))\n"
9718 "\n"
9719 " (signature vec2\n"
9720 " (parameters\n"
9721 " (declare (in ) vec2 angle@0x26cba80)\n"
9722 " )\n"
9723 " (\n"
9724 " ))\n"
9725 "\n"
9726 " (signature vec3\n"
9727 " (parameters\n"
9728 " (declare (in ) vec3 angle@0x26cbc60)\n"
9729 " )\n"
9730 " (\n"
9731 " ))\n"
9732 "\n"
9733 " (signature vec4\n"
9734 " (parameters\n"
9735 " (declare (in ) vec4 angle@0x26cbe40)\n"
9736 " )\n"
9737 " (\n"
9738 " ))\n"
9739 "\n"
9740 ")\n"
9741 "\n"
9742 "(function asin\n"
9743 " (signature float\n"
9744 " (parameters\n"
9745 " (declare (in ) float angle@0x26cc020)\n"
9746 " )\n"
9747 " (\n"
9748 " ))\n"
9749 "\n"
9750 " (signature vec2\n"
9751 " (parameters\n"
9752 " (declare (in ) vec2 angle@0x26cc3a0)\n"
9753 " )\n"
9754 " (\n"
9755 " ))\n"
9756 "\n"
9757 " (signature vec3\n"
9758 " (parameters\n"
9759 " (declare (in ) vec3 angle@0x26cc580)\n"
9760 " )\n"
9761 " (\n"
9762 " ))\n"
9763 "\n"
9764 " (signature vec4\n"
9765 " (parameters\n"
9766 " (declare (in ) vec4 angle@0x26cc760)\n"
9767 " )\n"
9768 " (\n"
9769 " ))\n"
9770 "\n"
9771 ")\n"
9772 "\n"
9773 "(function acos\n"
9774 " (signature float\n"
9775 " (parameters\n"
9776 " (declare (in ) float angle@0x26cc940)\n"
9777 " )\n"
9778 " (\n"
9779 " ))\n"
9780 "\n"
9781 " (signature vec2\n"
9782 " (parameters\n"
9783 " (declare (in ) vec2 angle@0x26cccc0)\n"
9784 " )\n"
9785 " (\n"
9786 " ))\n"
9787 "\n"
9788 " (signature vec3\n"
9789 " (parameters\n"
9790 " (declare (in ) vec3 angle@0x26ccea0)\n"
9791 " )\n"
9792 " (\n"
9793 " ))\n"
9794 "\n"
9795 " (signature vec4\n"
9796 " (parameters\n"
9797 " (declare (in ) vec4 angle@0x26cd080)\n"
9798 " )\n"
9799 " (\n"
9800 " ))\n"
9801 "\n"
9802 ")\n"
9803 "\n"
9804 "(function atan\n"
9805 " (signature float\n"
9806 " (parameters\n"
9807 " (declare (in ) float y@0x26cd260)\n"
9808 " (declare (in ) float x@0x26cd370)\n"
9809 " )\n"
9810 " (\n"
9811 " ))\n"
9812 "\n"
9813 " (signature vec2\n"
9814 " (parameters\n"
9815 " (declare (in ) vec2 y@0x26cd6f0)\n"
9816 " (declare (in ) vec2 x@0x26cd800)\n"
9817 " )\n"
9818 " (\n"
9819 " ))\n"
9820 "\n"
9821 " (signature vec3\n"
9822 " (parameters\n"
9823 " (declare (in ) vec3 y@0x26cd9e0)\n"
9824 " (declare (in ) vec3 x@0x26cdaf0)\n"
9825 " )\n"
9826 " (\n"
9827 " ))\n"
9828 "\n"
9829 " (signature vec4\n"
9830 " (parameters\n"
9831 " (declare (in ) vec4 y@0x26cdcd0)\n"
9832 " (declare (in ) vec4 x@0x26cdde0)\n"
9833 " )\n"
9834 " (\n"
9835 " ))\n"
9836 "\n"
9837 " (signature float\n"
9838 " (parameters\n"
9839 " (declare (in ) float y_over_x@0x26cdfc0)\n"
9840 " )\n"
9841 " (\n"
9842 " ))\n"
9843 "\n"
9844 " (signature vec2\n"
9845 " (parameters\n"
9846 " (declare (in ) vec2 y_over_x@0x26ce1b0)\n"
9847 " )\n"
9848 " (\n"
9849 " ))\n"
9850 "\n"
9851 " (signature vec3\n"
9852 " (parameters\n"
9853 " (declare (in ) vec3 y_over_x@0x26ce3a0)\n"
9854 " )\n"
9855 " (\n"
9856 " ))\n"
9857 "\n"
9858 " (signature vec4\n"
9859 " (parameters\n"
9860 " (declare (in ) vec4 y_over_x@0x26ce590)\n"
9861 " )\n"
9862 " (\n"
9863 " ))\n"
9864 "\n"
9865 ")\n"
9866 "\n"
9867 "(function pow\n"
9868 " (signature float\n"
9869 " (parameters\n"
9870 " (declare (in ) float x@0x26ce780)\n"
9871 " (declare (in ) float y@0x26ce890)\n"
9872 " )\n"
9873 " (\n"
9874 " ))\n"
9875 "\n"
9876 " (signature vec2\n"
9877 " (parameters\n"
9878 " (declare (in ) vec2 x@0x26cec10)\n"
9879 " (declare (in ) vec2 y@0x26ced20)\n"
9880 " )\n"
9881 " (\n"
9882 " ))\n"
9883 "\n"
9884 " (signature vec3\n"
9885 " (parameters\n"
9886 " (declare (in ) vec3 x@0x26cef00)\n"
9887 " (declare (in ) vec3 y@0x26cf010)\n"
9888 " )\n"
9889 " (\n"
9890 " ))\n"
9891 "\n"
9892 " (signature vec4\n"
9893 " (parameters\n"
9894 " (declare (in ) vec4 x@0x26cf1f0)\n"
9895 " (declare (in ) vec4 y@0x26cf300)\n"
9896 " )\n"
9897 " (\n"
9898 " ))\n"
9899 "\n"
9900 ")\n"
9901 "\n"
9902 "(function exp\n"
9903 " (signature float\n"
9904 " (parameters\n"
9905 " (declare (in ) float x@0x26cf4e0)\n"
9906 " )\n"
9907 " (\n"
9908 " ))\n"
9909 "\n"
9910 " (signature vec2\n"
9911 " (parameters\n"
9912 " (declare (in ) vec2 x@0x26cf860)\n"
9913 " )\n"
9914 " (\n"
9915 " ))\n"
9916 "\n"
9917 " (signature vec3\n"
9918 " (parameters\n"
9919 " (declare (in ) vec3 x@0x26cfa40)\n"
9920 " )\n"
9921 " (\n"
9922 " ))\n"
9923 "\n"
9924 " (signature vec4\n"
9925 " (parameters\n"
9926 " (declare (in ) vec4 x@0x26cfc20)\n"
9927 " )\n"
9928 " (\n"
9929 " ))\n"
9930 "\n"
9931 ")\n"
9932 "\n"
9933 "(function log\n"
9934 " (signature float\n"
9935 " (parameters\n"
9936 " (declare (in ) float x@0x26cfe00)\n"
9937 " )\n"
9938 " (\n"
9939 " ))\n"
9940 "\n"
9941 " (signature vec2\n"
9942 " (parameters\n"
9943 " (declare (in ) vec2 x@0x26d0180)\n"
9944 " )\n"
9945 " (\n"
9946 " ))\n"
9947 "\n"
9948 " (signature vec3\n"
9949 " (parameters\n"
9950 " (declare (in ) vec3 x@0x26d0360)\n"
9951 " )\n"
9952 " (\n"
9953 " ))\n"
9954 "\n"
9955 " (signature vec4\n"
9956 " (parameters\n"
9957 " (declare (in ) vec4 x@0x26d0540)\n"
9958 " )\n"
9959 " (\n"
9960 " ))\n"
9961 "\n"
9962 ")\n"
9963 "\n"
9964 "(function exp2\n"
9965 " (signature float\n"
9966 " (parameters\n"
9967 " (declare (in ) float x@0x26d0720)\n"
9968 " )\n"
9969 " (\n"
9970 " ))\n"
9971 "\n"
9972 " (signature vec2\n"
9973 " (parameters\n"
9974 " (declare (in ) vec2 x@0x26d0aa0)\n"
9975 " )\n"
9976 " (\n"
9977 " ))\n"
9978 "\n"
9979 " (signature vec3\n"
9980 " (parameters\n"
9981 " (declare (in ) vec3 x@0x26d0c80)\n"
9982 " )\n"
9983 " (\n"
9984 " ))\n"
9985 "\n"
9986 " (signature vec4\n"
9987 " (parameters\n"
9988 " (declare (in ) vec4 x@0x26d0e60)\n"
9989 " )\n"
9990 " (\n"
9991 " ))\n"
9992 "\n"
9993 ")\n"
9994 "\n"
9995 "(function log2\n"
9996 " (signature float\n"
9997 " (parameters\n"
9998 " (declare (in ) float x@0x26d1040)\n"
9999 " )\n"
10000 " (\n"
10001 " ))\n"
10002 "\n"
10003 " (signature vec2\n"
10004 " (parameters\n"
10005 " (declare (in ) vec2 x@0x26d13c0)\n"
10006 " )\n"
10007 " (\n"
10008 " ))\n"
10009 "\n"
10010 " (signature vec3\n"
10011 " (parameters\n"
10012 " (declare (in ) vec3 x@0x26d15a0)\n"
10013 " )\n"
10014 " (\n"
10015 " ))\n"
10016 "\n"
10017 " (signature vec4\n"
10018 " (parameters\n"
10019 " (declare (in ) vec4 x@0x26d1780)\n"
10020 " )\n"
10021 " (\n"
10022 " ))\n"
10023 "\n"
10024 ")\n"
10025 "\n"
10026 "(function sqrt\n"
10027 " (signature float\n"
10028 " (parameters\n"
10029 " (declare (in ) float x@0x26d1960)\n"
10030 " )\n"
10031 " (\n"
10032 " ))\n"
10033 "\n"
10034 " (signature vec2\n"
10035 " (parameters\n"
10036 " (declare (in ) vec2 x@0x26d1ce0)\n"
10037 " )\n"
10038 " (\n"
10039 " ))\n"
10040 "\n"
10041 " (signature vec3\n"
10042 " (parameters\n"
10043 " (declare (in ) vec3 x@0x26d1ec0)\n"
10044 " )\n"
10045 " (\n"
10046 " ))\n"
10047 "\n"
10048 " (signature vec4\n"
10049 " (parameters\n"
10050 " (declare (in ) vec4 x@0x26d20a0)\n"
10051 " )\n"
10052 " (\n"
10053 " ))\n"
10054 "\n"
10055 ")\n"
10056 "\n"
10057 "(function inversesqrt\n"
10058 " (signature float\n"
10059 " (parameters\n"
10060 " (declare (in ) float x@0x26d2280)\n"
10061 " )\n"
10062 " (\n"
10063 " ))\n"
10064 "\n"
10065 " (signature vec2\n"
10066 " (parameters\n"
10067 " (declare (in ) vec2 x@0x26d2610)\n"
10068 " )\n"
10069 " (\n"
10070 " ))\n"
10071 "\n"
10072 " (signature vec3\n"
10073 " (parameters\n"
10074 " (declare (in ) vec3 x@0x26d27f0)\n"
10075 " )\n"
10076 " (\n"
10077 " ))\n"
10078 "\n"
10079 " (signature vec4\n"
10080 " (parameters\n"
10081 " (declare (in ) vec4 x@0x26d29d0)\n"
10082 " )\n"
10083 " (\n"
10084 " ))\n"
10085 "\n"
10086 ")\n"
10087 "\n"
10088 "(function abs\n"
10089 " (signature float\n"
10090 " (parameters\n"
10091 " (declare (in ) float x@0x26d2bb0)\n"
10092 " )\n"
10093 " (\n"
10094 " ))\n"
10095 "\n"
10096 " (signature vec2\n"
10097 " (parameters\n"
10098 " (declare (in ) vec2 x@0x26d2f30)\n"
10099 " )\n"
10100 " (\n"
10101 " ))\n"
10102 "\n"
10103 " (signature vec3\n"
10104 " (parameters\n"
10105 " (declare (in ) vec3 x@0x26d3110)\n"
10106 " )\n"
10107 " (\n"
10108 " ))\n"
10109 "\n"
10110 " (signature vec4\n"
10111 " (parameters\n"
10112 " (declare (in ) vec4 x@0x26d32f0)\n"
10113 " )\n"
10114 " (\n"
10115 " ))\n"
10116 "\n"
10117 ")\n"
10118 "\n"
10119 "(function sign\n"
10120 " (signature float\n"
10121 " (parameters\n"
10122 " (declare (in ) float x@0x26d34d0)\n"
10123 " )\n"
10124 " (\n"
10125 " ))\n"
10126 "\n"
10127 " (signature vec2\n"
10128 " (parameters\n"
10129 " (declare (in ) vec2 x@0x26d3850)\n"
10130 " )\n"
10131 " (\n"
10132 " ))\n"
10133 "\n"
10134 " (signature vec3\n"
10135 " (parameters\n"
10136 " (declare (in ) vec3 x@0x26d3a30)\n"
10137 " )\n"
10138 " (\n"
10139 " ))\n"
10140 "\n"
10141 " (signature vec4\n"
10142 " (parameters\n"
10143 " (declare (in ) vec4 x@0x26d3c10)\n"
10144 " )\n"
10145 " (\n"
10146 " ))\n"
10147 "\n"
10148 ")\n"
10149 "\n"
10150 "(function floor\n"
10151 " (signature float\n"
10152 " (parameters\n"
10153 " (declare (in ) float x@0x26d3df0)\n"
10154 " )\n"
10155 " (\n"
10156 " ))\n"
10157 "\n"
10158 " (signature vec2\n"
10159 " (parameters\n"
10160 " (declare (in ) vec2 x@0x26d4170)\n"
10161 " )\n"
10162 " (\n"
10163 " ))\n"
10164 "\n"
10165 " (signature vec3\n"
10166 " (parameters\n"
10167 " (declare (in ) vec3 x@0x26d4350)\n"
10168 " )\n"
10169 " (\n"
10170 " ))\n"
10171 "\n"
10172 " (signature vec4\n"
10173 " (parameters\n"
10174 " (declare (in ) vec4 x@0x26d4530)\n"
10175 " )\n"
10176 " (\n"
10177 " ))\n"
10178 "\n"
10179 ")\n"
10180 "\n"
10181 "(function ceil\n"
10182 " (signature float\n"
10183 " (parameters\n"
10184 " (declare (in ) float x@0x26d4710)\n"
10185 " )\n"
10186 " (\n"
10187 " ))\n"
10188 "\n"
10189 " (signature vec2\n"
10190 " (parameters\n"
10191 " (declare (in ) vec2 x@0x26d4a90)\n"
10192 " )\n"
10193 " (\n"
10194 " ))\n"
10195 "\n"
10196 " (signature vec3\n"
10197 " (parameters\n"
10198 " (declare (in ) vec3 x@0x26d4c70)\n"
10199 " )\n"
10200 " (\n"
10201 " ))\n"
10202 "\n"
10203 " (signature vec4\n"
10204 " (parameters\n"
10205 " (declare (in ) vec4 x@0x26d4e50)\n"
10206 " )\n"
10207 " (\n"
10208 " ))\n"
10209 "\n"
10210 ")\n"
10211 "\n"
10212 "(function fract\n"
10213 " (signature float\n"
10214 " (parameters\n"
10215 " (declare (in ) float x@0x26d5030)\n"
10216 " )\n"
10217 " (\n"
10218 " ))\n"
10219 "\n"
10220 " (signature vec2\n"
10221 " (parameters\n"
10222 " (declare (in ) vec2 x@0x26d53b0)\n"
10223 " )\n"
10224 " (\n"
10225 " ))\n"
10226 "\n"
10227 " (signature vec3\n"
10228 " (parameters\n"
10229 " (declare (in ) vec3 x@0x26d5590)\n"
10230 " )\n"
10231 " (\n"
10232 " ))\n"
10233 "\n"
10234 " (signature vec4\n"
10235 " (parameters\n"
10236 " (declare (in ) vec4 x@0x26d5770)\n"
10237 " )\n"
10238 " (\n"
10239 " ))\n"
10240 "\n"
10241 ")\n"
10242 "\n"
10243 "(function mod\n"
10244 " (signature float\n"
10245 " (parameters\n"
10246 " (declare (in ) float x@0x26d5950)\n"
10247 " (declare (in ) float y@0x26d5a60)\n"
10248 " )\n"
10249 " (\n"
10250 " ))\n"
10251 "\n"
10252 " (signature vec2\n"
10253 " (parameters\n"
10254 " (declare (in ) vec2 x@0x26d5de0)\n"
10255 " (declare (in ) float y@0x26d5ef0)\n"
10256 " )\n"
10257 " (\n"
10258 " ))\n"
10259 "\n"
10260 " (signature vec3\n"
10261 " (parameters\n"
10262 " (declare (in ) vec3 x@0x26d60d0)\n"
10263 " (declare (in ) float y@0x26d61e0)\n"
10264 " )\n"
10265 " (\n"
10266 " ))\n"
10267 "\n"
10268 " (signature vec4\n"
10269 " (parameters\n"
10270 " (declare (in ) vec4 x@0x26d63c0)\n"
10271 " (declare (in ) float y@0x26d64d0)\n"
10272 " )\n"
10273 " (\n"
10274 " ))\n"
10275 "\n"
10276 " (signature vec2\n"
10277 " (parameters\n"
10278 " (declare (in ) vec2 x@0x26d66b0)\n"
10279 " (declare (in ) vec2 y@0x26d67c0)\n"
10280 " )\n"
10281 " (\n"
10282 " ))\n"
10283 "\n"
10284 " (signature vec3\n"
10285 " (parameters\n"
10286 " (declare (in ) vec3 x@0x26d69a0)\n"
10287 " (declare (in ) vec3 y@0x26d6ab0)\n"
10288 " )\n"
10289 " (\n"
10290 " ))\n"
10291 "\n"
10292 " (signature vec4\n"
10293 " (parameters\n"
10294 " (declare (in ) vec4 x@0x26d6c90)\n"
10295 " (declare (in ) vec4 y@0x26d6da0)\n"
10296 " )\n"
10297 " (\n"
10298 " ))\n"
10299 "\n"
10300 ")\n"
10301 "\n"
10302 "(function min\n"
10303 " (signature float\n"
10304 " (parameters\n"
10305 " (declare (in ) float x@0x26d6f80)\n"
10306 " (declare (in ) float y@0x26d7090)\n"
10307 " )\n"
10308 " (\n"
10309 " ))\n"
10310 "\n"
10311 " (signature vec2\n"
10312 " (parameters\n"
10313 " (declare (in ) vec2 x@0x26d7410)\n"
10314 " (declare (in ) vec2 y@0x26d7520)\n"
10315 " )\n"
10316 " (\n"
10317 " ))\n"
10318 "\n"
10319 " (signature vec3\n"
10320 " (parameters\n"
10321 " (declare (in ) vec3 x@0x26d7700)\n"
10322 " (declare (in ) vec3 y@0x26d7810)\n"
10323 " )\n"
10324 " (\n"
10325 " ))\n"
10326 "\n"
10327 " (signature vec4\n"
10328 " (parameters\n"
10329 " (declare (in ) vec4 x@0x26d79f0)\n"
10330 " (declare (in ) vec4 y@0x26d7b00)\n"
10331 " )\n"
10332 " (\n"
10333 " ))\n"
10334 "\n"
10335 " (signature vec2\n"
10336 " (parameters\n"
10337 " (declare (in ) vec2 x@0x26d7ce0)\n"
10338 " (declare (in ) float y@0x26d7df0)\n"
10339 " )\n"
10340 " (\n"
10341 " ))\n"
10342 "\n"
10343 " (signature vec3\n"
10344 " (parameters\n"
10345 " (declare (in ) vec3 x@0x26d7fd0)\n"
10346 " (declare (in ) float y@0x26d80e0)\n"
10347 " )\n"
10348 " (\n"
10349 " ))\n"
10350 "\n"
10351 " (signature vec4\n"
10352 " (parameters\n"
10353 " (declare (in ) vec4 x@0x26d82c0)\n"
10354 " (declare (in ) float y@0x26d83d0)\n"
10355 " )\n"
10356 " (\n"
10357 " ))\n"
10358 "\n"
10359 ")\n"
10360 "\n"
10361 "(function max\n"
10362 " (signature float\n"
10363 " (parameters\n"
10364 " (declare (in ) float x@0x26d85b0)\n"
10365 " (declare (in ) float y@0x26d86c0)\n"
10366 " )\n"
10367 " (\n"
10368 " ))\n"
10369 "\n"
10370 " (signature vec2\n"
10371 " (parameters\n"
10372 " (declare (in ) vec2 x@0x26d8a40)\n"
10373 " (declare (in ) vec2 y@0x26d8b50)\n"
10374 " )\n"
10375 " (\n"
10376 " ))\n"
10377 "\n"
10378 " (signature vec3\n"
10379 " (parameters\n"
10380 " (declare (in ) vec3 x@0x26d8d30)\n"
10381 " (declare (in ) vec3 y@0x26d8e40)\n"
10382 " )\n"
10383 " (\n"
10384 " ))\n"
10385 "\n"
10386 " (signature vec4\n"
10387 " (parameters\n"
10388 " (declare (in ) vec4 x@0x26d9020)\n"
10389 " (declare (in ) vec4 y@0x26d9130)\n"
10390 " )\n"
10391 " (\n"
10392 " ))\n"
10393 "\n"
10394 " (signature vec2\n"
10395 " (parameters\n"
10396 " (declare (in ) vec2 x@0x26d9310)\n"
10397 " (declare (in ) float y@0x26d9420)\n"
10398 " )\n"
10399 " (\n"
10400 " ))\n"
10401 "\n"
10402 " (signature vec3\n"
10403 " (parameters\n"
10404 " (declare (in ) vec3 x@0x26d9600)\n"
10405 " (declare (in ) float y@0x26d9710)\n"
10406 " )\n"
10407 " (\n"
10408 " ))\n"
10409 "\n"
10410 " (signature vec4\n"
10411 " (parameters\n"
10412 " (declare (in ) vec4 x@0x26d98f0)\n"
10413 " (declare (in ) float y@0x26d9a00)\n"
10414 " )\n"
10415 " (\n"
10416 " ))\n"
10417 "\n"
10418 ")\n"
10419 "\n"
10420 "(function clamp\n"
10421 " (signature float\n"
10422 " (parameters\n"
10423 " (declare (in ) float x@0x26d9be0)\n"
10424 " (declare (in ) float minVal@0x26d9cf0)\n"
10425 " (declare (in ) float maxVal@0x26d9e00)\n"
10426 " )\n"
10427 " (\n"
10428 " ))\n"
10429 "\n"
10430 " (signature vec2\n"
10431 " (parameters\n"
10432 " (declare (in ) vec2 x@0x26da180)\n"
10433 " (declare (in ) vec2 minVal@0x26da290)\n"
10434 " (declare (in ) vec2 maxVal@0x26da3a0)\n"
10435 " )\n"
10436 " (\n"
10437 " ))\n"
10438 "\n"
10439 " (signature vec3\n"
10440 " (parameters\n"
10441 " (declare (in ) vec3 x@0x26da580)\n"
10442 " (declare (in ) vec3 minVal@0x26da690)\n"
10443 " (declare (in ) vec3 maxVal@0x26da7a0)\n"
10444 " )\n"
10445 " (\n"
10446 " ))\n"
10447 "\n"
10448 " (signature vec4\n"
10449 " (parameters\n"
10450 " (declare (in ) vec4 x@0x26da980)\n"
10451 " (declare (in ) vec4 minVal@0x26daa90)\n"
10452 " (declare (in ) vec4 maxVal@0x26daba0)\n"
10453 " )\n"
10454 " (\n"
10455 " ))\n"
10456 "\n"
10457 " (signature vec2\n"
10458 " (parameters\n"
10459 " (declare (in ) vec2 x@0x26dad80)\n"
10460 " (declare (in ) float minVal@0x26dae90)\n"
10461 " (declare (in ) float maxVal@0x26dafa0)\n"
10462 " )\n"
10463 " (\n"
10464 " ))\n"
10465 "\n"
10466 " (signature vec3\n"
10467 " (parameters\n"
10468 " (declare (in ) vec3 x@0x26db180)\n"
10469 " (declare (in ) float minVal@0x26db290)\n"
10470 " (declare (in ) float maxVal@0x26db3a0)\n"
10471 " )\n"
10472 " (\n"
10473 " ))\n"
10474 "\n"
10475 " (signature vec4\n"
10476 " (parameters\n"
10477 " (declare (in ) vec4 x@0x26db580)\n"
10478 " (declare (in ) float minVal@0x26db690)\n"
10479 " (declare (in ) float maxVal@0x26db7a0)\n"
10480 " )\n"
10481 " (\n"
10482 " ))\n"
10483 "\n"
10484 ")\n"
10485 "\n"
10486 "(function mix\n"
10487 " (signature float\n"
10488 " (parameters\n"
10489 " (declare (in ) float x@0x26db980)\n"
10490 " (declare (in ) float y@0x26dba90)\n"
10491 " (declare (in ) float a@0x26dbba0)\n"
10492 " )\n"
10493 " (\n"
10494 " ))\n"
10495 "\n"
10496 " (signature vec2\n"
10497 " (parameters\n"
10498 " (declare (in ) vec2 x@0x26dbf20)\n"
10499 " (declare (in ) vec2 y@0x26dc030)\n"
10500 " (declare (in ) vec2 a@0x26dc140)\n"
10501 " )\n"
10502 " (\n"
10503 " ))\n"
10504 "\n"
10505 " (signature vec3\n"
10506 " (parameters\n"
10507 " (declare (in ) vec3 x@0x26dc320)\n"
10508 " (declare (in ) vec3 y@0x26dc430)\n"
10509 " (declare (in ) vec3 a@0x26dc540)\n"
10510 " )\n"
10511 " (\n"
10512 " ))\n"
10513 "\n"
10514 " (signature vec4\n"
10515 " (parameters\n"
10516 " (declare (in ) vec4 x@0x26dc720)\n"
10517 " (declare (in ) vec4 y@0x26dc830)\n"
10518 " (declare (in ) vec4 a@0x26dc940)\n"
10519 " )\n"
10520 " (\n"
10521 " ))\n"
10522 "\n"
10523 " (signature vec2\n"
10524 " (parameters\n"
10525 " (declare (in ) vec2 x@0x26dcb20)\n"
10526 " (declare (in ) vec2 y@0x26dcc30)\n"
10527 " (declare (in ) float a@0x26dcd40)\n"
10528 " )\n"
10529 " (\n"
10530 " ))\n"
10531 "\n"
10532 " (signature vec3\n"
10533 " (parameters\n"
10534 " (declare (in ) vec3 x@0x26dcf20)\n"
10535 " (declare (in ) vec3 y@0x26dd030)\n"
10536 " (declare (in ) float a@0x26dd140)\n"
10537 " )\n"
10538 " (\n"
10539 " ))\n"
10540 "\n"
10541 " (signature vec4\n"
10542 " (parameters\n"
10543 " (declare (in ) vec4 x@0x26dd320)\n"
10544 " (declare (in ) vec4 y@0x26dd430)\n"
10545 " (declare (in ) float a@0x26dd540)\n"
10546 " )\n"
10547 " (\n"
10548 " ))\n"
10549 "\n"
10550 ")\n"
10551 "\n"
10552 "(function step\n"
10553 " (signature float\n"
10554 " (parameters\n"
10555 " (declare (in ) float edge@0x26dd720)\n"
10556 " (declare (in ) float x@0x26dd830)\n"
10557 " )\n"
10558 " (\n"
10559 " ))\n"
10560 "\n"
10561 " (signature vec2\n"
10562 " (parameters\n"
10563 " (declare (in ) vec2 edge@0x26ddbb0)\n"
10564 " (declare (in ) vec2 x@0x26ddcc0)\n"
10565 " )\n"
10566 " (\n"
10567 " ))\n"
10568 "\n"
10569 " (signature vec3\n"
10570 " (parameters\n"
10571 " (declare (in ) vec3 edge@0x26ddea0)\n"
10572 " (declare (in ) vec3 x@0x26ddfb0)\n"
10573 " )\n"
10574 " (\n"
10575 " ))\n"
10576 "\n"
10577 " (signature vec4\n"
10578 " (parameters\n"
10579 " (declare (in ) vec4 edge@0x26de190)\n"
10580 " (declare (in ) vec4 x@0x26de2a0)\n"
10581 " )\n"
10582 " (\n"
10583 " ))\n"
10584 "\n"
10585 " (signature vec2\n"
10586 " (parameters\n"
10587 " (declare (in ) float edge@0x26de480)\n"
10588 " (declare (in ) vec2 x@0x26de590)\n"
10589 " )\n"
10590 " (\n"
10591 " ))\n"
10592 "\n"
10593 " (signature vec3\n"
10594 " (parameters\n"
10595 " (declare (in ) float edge@0x26de770)\n"
10596 " (declare (in ) vec3 x@0x26de880)\n"
10597 " )\n"
10598 " (\n"
10599 " ))\n"
10600 "\n"
10601 " (signature vec4\n"
10602 " (parameters\n"
10603 " (declare (in ) float edge@0x26dea60)\n"
10604 " (declare (in ) vec4 x@0x26deb70)\n"
10605 " )\n"
10606 " (\n"
10607 " ))\n"
10608 "\n"
10609 ")\n"
10610 "\n"
10611 "(function smoothstep\n"
10612 " (signature float\n"
10613 " (parameters\n"
10614 " (declare (in ) float edge0@0x26ded50)\n"
10615 " (declare (in ) float edge1@0x26dee60)\n"
10616 " (declare (in ) float x@0x26def70)\n"
10617 " )\n"
10618 " (\n"
10619 " ))\n"
10620 "\n"
10621 " (signature vec2\n"
10622 " (parameters\n"
10623 " (declare (in ) vec2 edge0@0x26df300)\n"
10624 " (declare (in ) vec2 edge1@0x26df410)\n"
10625 " (declare (in ) vec2 x@0x26df520)\n"
10626 " )\n"
10627 " (\n"
10628 " ))\n"
10629 "\n"
10630 " (signature vec3\n"
10631 " (parameters\n"
10632 " (declare (in ) vec3 edge0@0x26df700)\n"
10633 " (declare (in ) vec3 edge1@0x26df810)\n"
10634 " (declare (in ) vec3 x@0x26df920)\n"
10635 " )\n"
10636 " (\n"
10637 " ))\n"
10638 "\n"
10639 " (signature vec4\n"
10640 " (parameters\n"
10641 " (declare (in ) vec4 edge0@0x26dfb00)\n"
10642 " (declare (in ) vec4 edge1@0x26dfc10)\n"
10643 " (declare (in ) vec4 x@0x26dfd20)\n"
10644 " )\n"
10645 " (\n"
10646 " ))\n"
10647 "\n"
10648 " (signature vec2\n"
10649 " (parameters\n"
10650 " (declare (in ) float edge0@0x26dff00)\n"
10651 " (declare (in ) float edge1@0x26e0010)\n"
10652 " (declare (in ) vec2 x@0x26e0120)\n"
10653 " )\n"
10654 " (\n"
10655 " ))\n"
10656 "\n"
10657 " (signature vec3\n"
10658 " (parameters\n"
10659 " (declare (in ) float edge0@0x26e0300)\n"
10660 " (declare (in ) float edge1@0x26e0410)\n"
10661 " (declare (in ) vec3 x@0x26e0520)\n"
10662 " )\n"
10663 " (\n"
10664 " ))\n"
10665 "\n"
10666 " (signature vec4\n"
10667 " (parameters\n"
10668 " (declare (in ) float edge0@0x26e0700)\n"
10669 " (declare (in ) float edge1@0x26e0810)\n"
10670 " (declare (in ) vec4 x@0x26e0920)\n"
10671 " )\n"
10672 " (\n"
10673 " ))\n"
10674 "\n"
10675 ")\n"
10676 "\n"
10677 "(function length\n"
10678 " (signature float\n"
10679 " (parameters\n"
10680 " (declare (in ) float x@0x26e0b00)\n"
10681 " )\n"
10682 " (\n"
10683 " ))\n"
10684 "\n"
10685 " (signature float\n"
10686 " (parameters\n"
10687 " (declare (in ) vec2 x@0x26e0e80)\n"
10688 " )\n"
10689 " (\n"
10690 " ))\n"
10691 "\n"
10692 " (signature float\n"
10693 " (parameters\n"
10694 " (declare (in ) vec3 x@0x26e1060)\n"
10695 " )\n"
10696 " (\n"
10697 " ))\n"
10698 "\n"
10699 " (signature float\n"
10700 " (parameters\n"
10701 " (declare (in ) vec4 x@0x26e1240)\n"
10702 " )\n"
10703 " (\n"
10704 " ))\n"
10705 "\n"
10706 ")\n"
10707 "\n"
10708 "(function distance\n"
10709 " (signature float\n"
10710 " (parameters\n"
10711 " (declare (in ) float p0@0x26e1420)\n"
10712 " (declare (in ) float p1@0x26e1530)\n"
10713 " )\n"
10714 " (\n"
10715 " ))\n"
10716 "\n"
10717 " (signature float\n"
10718 " (parameters\n"
10719 " (declare (in ) vec2 p0@0x26e18c0)\n"
10720 " (declare (in ) vec2 p1@0x26e19d0)\n"
10721 " )\n"
10722 " (\n"
10723 " ))\n"
10724 "\n"
10725 " (signature float\n"
10726 " (parameters\n"
10727 " (declare (in ) vec3 p0@0x26e1bb0)\n"
10728 " (declare (in ) vec3 p1@0x26e1cc0)\n"
10729 " )\n"
10730 " (\n"
10731 " ))\n"
10732 "\n"
10733 " (signature float\n"
10734 " (parameters\n"
10735 " (declare (in ) vec4 p0@0x26e1ea0)\n"
10736 " (declare (in ) vec4 p1@0x26e1fb0)\n"
10737 " )\n"
10738 " (\n"
10739 " ))\n"
10740 "\n"
10741 ")\n"
10742 "\n"
10743 "(function dot\n"
10744 " (signature float\n"
10745 " (parameters\n"
10746 " (declare (in ) float x@0x26e2190)\n"
10747 " (declare (in ) float y@0x26e22a0)\n"
10748 " )\n"
10749 " (\n"
10750 " ))\n"
10751 "\n"
10752 " (signature float\n"
10753 " (parameters\n"
10754 " (declare (in ) vec2 x@0x26e2620)\n"
10755 " (declare (in ) vec2 y@0x26e2730)\n"
10756 " )\n"
10757 " (\n"
10758 " ))\n"
10759 "\n"
10760 " (signature float\n"
10761 " (parameters\n"
10762 " (declare (in ) vec3 x@0x26e2910)\n"
10763 " (declare (in ) vec3 y@0x26e2a20)\n"
10764 " )\n"
10765 " (\n"
10766 " ))\n"
10767 "\n"
10768 " (signature float\n"
10769 " (parameters\n"
10770 " (declare (in ) vec4 x@0x26e2c00)\n"
10771 " (declare (in ) vec4 y@0x26e2d10)\n"
10772 " )\n"
10773 " (\n"
10774 " ))\n"
10775 "\n"
10776 ")\n"
10777 "\n"
10778 "(function cross\n"
10779 " (signature vec3\n"
10780 " (parameters\n"
10781 " (declare (in ) vec3 x@0x26e2ef0)\n"
10782 " (declare (in ) vec3 y@0x26e3000)\n"
10783 " )\n"
10784 " (\n"
10785 " ))\n"
10786 "\n"
10787 ")\n"
10788 "\n"
10789 "(function normalize\n"
10790 " (signature float\n"
10791 " (parameters\n"
10792 " (declare (in ) float x@0x26e3380)\n"
10793 " )\n"
10794 " (\n"
10795 " ))\n"
10796 "\n"
10797 " (signature vec2\n"
10798 " (parameters\n"
10799 " (declare (in ) vec2 x@0x26e3710)\n"
10800 " )\n"
10801 " (\n"
10802 " ))\n"
10803 "\n"
10804 " (signature vec3\n"
10805 " (parameters\n"
10806 " (declare (in ) vec3 x@0x26e38f0)\n"
10807 " )\n"
10808 " (\n"
10809 " ))\n"
10810 "\n"
10811 " (signature vec4\n"
10812 " (parameters\n"
10813 " (declare (in ) vec4 x@0x26e3ad0)\n"
10814 " )\n"
10815 " (\n"
10816 " ))\n"
10817 "\n"
10818 ")\n"
10819 "\n"
10820 "(function faceforward\n"
10821 " (signature float\n"
10822 " (parameters\n"
10823 " (declare (in ) float N@0x26e3cb0)\n"
10824 " (declare (in ) float I@0x26e3dc0)\n"
10825 " (declare (in ) float Nref@0x26e3ed0)\n"
10826 " )\n"
10827 " (\n"
10828 " ))\n"
10829 "\n"
10830 " (signature vec2\n"
10831 " (parameters\n"
10832 " (declare (in ) vec2 N@0x26e4260)\n"
10833 " (declare (in ) vec2 I@0x26e4370)\n"
10834 " (declare (in ) vec2 Nref@0x26e4480)\n"
10835 " )\n"
10836 " (\n"
10837 " ))\n"
10838 "\n"
10839 " (signature vec3\n"
10840 " (parameters\n"
10841 " (declare (in ) vec3 N@0x26e4660)\n"
10842 " (declare (in ) vec3 I@0x26e4770)\n"
10843 " (declare (in ) vec3 Nref@0x26e4880)\n"
10844 " )\n"
10845 " (\n"
10846 " ))\n"
10847 "\n"
10848 " (signature vec4\n"
10849 " (parameters\n"
10850 " (declare (in ) vec4 N@0x26e4a60)\n"
10851 " (declare (in ) vec4 I@0x26e4b70)\n"
10852 " (declare (in ) vec4 Nref@0x26e4c80)\n"
10853 " )\n"
10854 " (\n"
10855 " ))\n"
10856 "\n"
10857 ")\n"
10858 "\n"
10859 "(function reflect\n"
10860 " (signature float\n"
10861 " (parameters\n"
10862 " (declare (in ) float I@0x26e4e60)\n"
10863 " (declare (in ) float N@0x26e4f70)\n"
10864 " )\n"
10865 " (\n"
10866 " ))\n"
10867 "\n"
10868 " (signature vec2\n"
10869 " (parameters\n"
10870 " (declare (in ) vec2 I@0x26e52f0)\n"
10871 " (declare (in ) vec2 N@0x26e5400)\n"
10872 " )\n"
10873 " (\n"
10874 " ))\n"
10875 "\n"
10876 " (signature vec3\n"
10877 " (parameters\n"
10878 " (declare (in ) vec3 I@0x26e55e0)\n"
10879 " (declare (in ) vec3 N@0x26e56f0)\n"
10880 " )\n"
10881 " (\n"
10882 " ))\n"
10883 "\n"
10884 " (signature vec4\n"
10885 " (parameters\n"
10886 " (declare (in ) vec4 I@0x26e58d0)\n"
10887 " (declare (in ) vec4 N@0x26e59e0)\n"
10888 " )\n"
10889 " (\n"
10890 " ))\n"
10891 "\n"
10892 ")\n"
10893 "\n"
10894 "(function refract\n"
10895 " (signature float\n"
10896 " (parameters\n"
10897 " (declare (in ) float I@0x26e5bc0)\n"
10898 " (declare (in ) float N@0x26e5cd0)\n"
10899 " (declare (in ) float eta@0x26e5de0)\n"
10900 " )\n"
10901 " (\n"
10902 " ))\n"
10903 "\n"
10904 " (signature vec2\n"
10905 " (parameters\n"
10906 " (declare (in ) vec2 I@0x26e6160)\n"
10907 " (declare (in ) vec2 N@0x26e6270)\n"
10908 " (declare (in ) float eta@0x26e6380)\n"
10909 " )\n"
10910 " (\n"
10911 " ))\n"
10912 "\n"
10913 " (signature vec3\n"
10914 " (parameters\n"
10915 " (declare (in ) vec3 I@0x26e6560)\n"
10916 " (declare (in ) vec3 N@0x26e6670)\n"
10917 " (declare (in ) float eta@0x26e6780)\n"
10918 " )\n"
10919 " (\n"
10920 " ))\n"
10921 "\n"
10922 " (signature vec4\n"
10923 " (parameters\n"
10924 " (declare (in ) vec4 I@0x26e6960)\n"
10925 " (declare (in ) vec4 N@0x26e6a70)\n"
10926 " (declare (in ) float eta@0x26e6b80)\n"
10927 " )\n"
10928 " (\n"
10929 " ))\n"
10930 "\n"
10931 ")\n"
10932 "\n"
10933 "(function matrixCompMult\n"
10934 " (signature mat2\n"
10935 " (parameters\n"
10936 " (declare (in ) mat2 x@0x26e6d60)\n"
10937 " (declare (in ) mat2 y@0x26e6e70)\n"
10938 " )\n"
10939 " (\n"
10940 " ))\n"
10941 "\n"
10942 " (signature mat3\n"
10943 " (parameters\n"
10944 " (declare (in ) mat3 x@0x26e7200)\n"
10945 " (declare (in ) mat3 y@0x26e7310)\n"
10946 " )\n"
10947 " (\n"
10948 " ))\n"
10949 "\n"
10950 " (signature mat4\n"
10951 " (parameters\n"
10952 " (declare (in ) mat4 x@0x26e74f0)\n"
10953 " (declare (in ) mat4 y@0x26e7600)\n"
10954 " )\n"
10955 " (\n"
10956 " ))\n"
10957 "\n"
10958 ")\n"
10959 "\n"
10960 "(function lessThan\n"
10961 " (signature bvec2\n"
10962 " (parameters\n"
10963 " (declare (in ) vec2 x@0x26e77e0)\n"
10964 " (declare (in ) vec2 y@0x26e78f0)\n"
10965 " )\n"
10966 " (\n"
10967 " ))\n"
10968 "\n"
10969 " (signature bvec3\n"
10970 " (parameters\n"
10971 " (declare (in ) vec3 x@0x26e7c80)\n"
10972 " (declare (in ) vec3 y@0x26e7d90)\n"
10973 " )\n"
10974 " (\n"
10975 " ))\n"
10976 "\n"
10977 " (signature bvec4\n"
10978 " (parameters\n"
10979 " (declare (in ) vec4 x@0x26e7f70)\n"
10980 " (declare (in ) vec4 y@0x26e8080)\n"
10981 " )\n"
10982 " (\n"
10983 " ))\n"
10984 "\n"
10985 " (signature bvec2\n"
10986 " (parameters\n"
10987 " (declare (in ) ivec2 x@0x26e8260)\n"
10988 " (declare (in ) ivec2 y@0x26e8370)\n"
10989 " )\n"
10990 " (\n"
10991 " ))\n"
10992 "\n"
10993 " (signature bvec3\n"
10994 " (parameters\n"
10995 " (declare (in ) ivec3 x@0x26e8550)\n"
10996 " (declare (in ) ivec3 y@0x26e8660)\n"
10997 " )\n"
10998 " (\n"
10999 " ))\n"
11000 "\n"
11001 " (signature bvec4\n"
11002 " (parameters\n"
11003 " (declare (in ) ivec4 x@0x26e8840)\n"
11004 " (declare (in ) ivec4 y@0x26e8950)\n"
11005 " )\n"
11006 " (\n"
11007 " ))\n"
11008 "\n"
11009 ")\n"
11010 "\n"
11011 "(function lessThanEqual\n"
11012 " (signature bvec2\n"
11013 " (parameters\n"
11014 " (declare (in ) vec2 x@0x26e8b30)\n"
11015 " (declare (in ) vec2 y@0x26e8c40)\n"
11016 " )\n"
11017 " (\n"
11018 " ))\n"
11019 "\n"
11020 " (signature bvec3\n"
11021 " (parameters\n"
11022 " (declare (in ) vec3 x@0x26e8fd0)\n"
11023 " (declare (in ) vec3 y@0x26e90e0)\n"
11024 " )\n"
11025 " (\n"
11026 " ))\n"
11027 "\n"
11028 " (signature bvec4\n"
11029 " (parameters\n"
11030 " (declare (in ) vec4 x@0x26e92c0)\n"
11031 " (declare (in ) vec4 y@0x26e93d0)\n"
11032 " )\n"
11033 " (\n"
11034 " ))\n"
11035 "\n"
11036 " (signature bvec2\n"
11037 " (parameters\n"
11038 " (declare (in ) ivec2 x@0x26e95b0)\n"
11039 " (declare (in ) ivec2 y@0x26e96c0)\n"
11040 " )\n"
11041 " (\n"
11042 " ))\n"
11043 "\n"
11044 " (signature bvec3\n"
11045 " (parameters\n"
11046 " (declare (in ) ivec3 x@0x26e98a0)\n"
11047 " (declare (in ) ivec3 y@0x26e99b0)\n"
11048 " )\n"
11049 " (\n"
11050 " ))\n"
11051 "\n"
11052 " (signature bvec4\n"
11053 " (parameters\n"
11054 " (declare (in ) ivec4 x@0x26e9b90)\n"
11055 " (declare (in ) ivec4 y@0x26e9ca0)\n"
11056 " )\n"
11057 " (\n"
11058 " ))\n"
11059 "\n"
11060 ")\n"
11061 "\n"
11062 "(function greaterThan\n"
11063 " (signature bvec2\n"
11064 " (parameters\n"
11065 " (declare (in ) vec2 x@0x26e9e80)\n"
11066 " (declare (in ) vec2 y@0x26e9f90)\n"
11067 " )\n"
11068 " (\n"
11069 " ))\n"
11070 "\n"
11071 " (signature bvec3\n"
11072 " (parameters\n"
11073 " (declare (in ) vec3 x@0x26ea320)\n"
11074 " (declare (in ) vec3 y@0x26ea430)\n"
11075 " )\n"
11076 " (\n"
11077 " ))\n"
11078 "\n"
11079 " (signature bvec4\n"
11080 " (parameters\n"
11081 " (declare (in ) vec4 x@0x26ea610)\n"
11082 " (declare (in ) vec4 y@0x26ea720)\n"
11083 " )\n"
11084 " (\n"
11085 " ))\n"
11086 "\n"
11087 " (signature bvec2\n"
11088 " (parameters\n"
11089 " (declare (in ) ivec2 x@0x26ea900)\n"
11090 " (declare (in ) ivec2 y@0x26eaa10)\n"
11091 " )\n"
11092 " (\n"
11093 " ))\n"
11094 "\n"
11095 " (signature bvec3\n"
11096 " (parameters\n"
11097 " (declare (in ) ivec3 x@0x26eabf0)\n"
11098 " (declare (in ) ivec3 y@0x26ead00)\n"
11099 " )\n"
11100 " (\n"
11101 " ))\n"
11102 "\n"
11103 " (signature bvec4\n"
11104 " (parameters\n"
11105 " (declare (in ) ivec4 x@0x26eaee0)\n"
11106 " (declare (in ) ivec4 y@0x26eaff0)\n"
11107 " )\n"
11108 " (\n"
11109 " ))\n"
11110 "\n"
11111 ")\n"
11112 "\n"
11113 "(function greaterThanEqual\n"
11114 " (signature bvec2\n"
11115 " (parameters\n"
11116 " (declare (in ) vec2 x@0x26eb1d0)\n"
11117 " (declare (in ) vec2 y@0x26eb2e0)\n"
11118 " )\n"
11119 " (\n"
11120 " ))\n"
11121 "\n"
11122 " (signature bvec3\n"
11123 " (parameters\n"
11124 " (declare (in ) vec3 x@0x26eb670)\n"
11125 " (declare (in ) vec3 y@0x26eb780)\n"
11126 " )\n"
11127 " (\n"
11128 " ))\n"
11129 "\n"
11130 " (signature bvec4\n"
11131 " (parameters\n"
11132 " (declare (in ) vec4 x@0x26eb960)\n"
11133 " (declare (in ) vec4 y@0x26eba70)\n"
11134 " )\n"
11135 " (\n"
11136 " ))\n"
11137 "\n"
11138 " (signature bvec2\n"
11139 " (parameters\n"
11140 " (declare (in ) ivec2 x@0x26ebc50)\n"
11141 " (declare (in ) ivec2 y@0x26ebd60)\n"
11142 " )\n"
11143 " (\n"
11144 " ))\n"
11145 "\n"
11146 " (signature bvec3\n"
11147 " (parameters\n"
11148 " (declare (in ) ivec3 x@0x26ebf40)\n"
11149 " (declare (in ) ivec3 y@0x26ec050)\n"
11150 " )\n"
11151 " (\n"
11152 " ))\n"
11153 "\n"
11154 " (signature bvec4\n"
11155 " (parameters\n"
11156 " (declare (in ) ivec4 x@0x26ec230)\n"
11157 " (declare (in ) ivec4 y@0x26ec340)\n"
11158 " )\n"
11159 " (\n"
11160 " ))\n"
11161 "\n"
11162 ")\n"
11163 "\n"
11164 "(function equal\n"
11165 " (signature bvec2\n"
11166 " (parameters\n"
11167 " (declare (in ) vec2 x@0x26ec520)\n"
11168 " (declare (in ) vec2 y@0x26ec630)\n"
11169 " )\n"
11170 " (\n"
11171 " ))\n"
11172 "\n"
11173 " (signature bvec3\n"
11174 " (parameters\n"
11175 " (declare (in ) vec3 x@0x26ec9b0)\n"
11176 " (declare (in ) vec3 y@0x26ecac0)\n"
11177 " )\n"
11178 " (\n"
11179 " ))\n"
11180 "\n"
11181 " (signature bvec4\n"
11182 " (parameters\n"
11183 " (declare (in ) vec4 x@0x26ecca0)\n"
11184 " (declare (in ) vec4 y@0x26ecdb0)\n"
11185 " )\n"
11186 " (\n"
11187 " ))\n"
11188 "\n"
11189 " (signature bvec2\n"
11190 " (parameters\n"
11191 " (declare (in ) ivec2 x@0x26ecf90)\n"
11192 " (declare (in ) ivec2 y@0x26ed0a0)\n"
11193 " )\n"
11194 " (\n"
11195 " ))\n"
11196 "\n"
11197 " (signature bvec3\n"
11198 " (parameters\n"
11199 " (declare (in ) ivec3 x@0x26ed280)\n"
11200 " (declare (in ) ivec3 y@0x26ed390)\n"
11201 " )\n"
11202 " (\n"
11203 " ))\n"
11204 "\n"
11205 " (signature bvec4\n"
11206 " (parameters\n"
11207 " (declare (in ) ivec4 x@0x26ed570)\n"
11208 " (declare (in ) ivec4 y@0x26ed680)\n"
11209 " )\n"
11210 " (\n"
11211 " ))\n"
11212 "\n"
11213 " (signature bvec2\n"
11214 " (parameters\n"
11215 " (declare (in ) bvec2 x@0x26ed860)\n"
11216 " (declare (in ) bvec2 y@0x26ed970)\n"
11217 " )\n"
11218 " (\n"
11219 " ))\n"
11220 "\n"
11221 " (signature bvec3\n"
11222 " (parameters\n"
11223 " (declare (in ) bvec3 x@0x26edb50)\n"
11224 " (declare (in ) bvec3 y@0x26edc60)\n"
11225 " )\n"
11226 " (\n"
11227 " ))\n"
11228 "\n"
11229 " (signature bvec4\n"
11230 " (parameters\n"
11231 " (declare (in ) bvec4 x@0x26ede40)\n"
11232 " (declare (in ) bvec4 y@0x26edf50)\n"
11233 " )\n"
11234 " (\n"
11235 " ))\n"
11236 "\n"
11237 ")\n"
11238 "\n"
11239 "(function notEqual\n"
11240 " (signature bvec2\n"
11241 " (parameters\n"
11242 " (declare (in ) vec2 x@0x26ee130)\n"
11243 " (declare (in ) vec2 y@0x26ee240)\n"
11244 " )\n"
11245 " (\n"
11246 " ))\n"
11247 "\n"
11248 " (signature bvec3\n"
11249 " (parameters\n"
11250 " (declare (in ) vec3 x@0x26ee5d0)\n"
11251 " (declare (in ) vec3 y@0x26ee6e0)\n"
11252 " )\n"
11253 " (\n"
11254 " ))\n"
11255 "\n"
11256 " (signature bvec4\n"
11257 " (parameters\n"
11258 " (declare (in ) vec4 x@0x26ee8c0)\n"
11259 " (declare (in ) vec4 y@0x26ee9d0)\n"
11260 " )\n"
11261 " (\n"
11262 " ))\n"
11263 "\n"
11264 " (signature bvec2\n"
11265 " (parameters\n"
11266 " (declare (in ) ivec2 x@0x26eebb0)\n"
11267 " (declare (in ) ivec2 y@0x26eecc0)\n"
11268 " )\n"
11269 " (\n"
11270 " ))\n"
11271 "\n"
11272 " (signature bvec3\n"
11273 " (parameters\n"
11274 " (declare (in ) ivec3 x@0x26eeea0)\n"
11275 " (declare (in ) ivec3 y@0x26eefb0)\n"
11276 " )\n"
11277 " (\n"
11278 " ))\n"
11279 "\n"
11280 " (signature bvec4\n"
11281 " (parameters\n"
11282 " (declare (in ) ivec4 x@0x26ef190)\n"
11283 " (declare (in ) ivec4 y@0x26ef2a0)\n"
11284 " )\n"
11285 " (\n"
11286 " ))\n"
11287 "\n"
11288 " (signature bvec2\n"
11289 " (parameters\n"
11290 " (declare (in ) bvec2 x@0x26ef480)\n"
11291 " (declare (in ) bvec2 y@0x26ef590)\n"
11292 " )\n"
11293 " (\n"
11294 " ))\n"
11295 "\n"
11296 " (signature bvec3\n"
11297 " (parameters\n"
11298 " (declare (in ) bvec3 x@0x26ef770)\n"
11299 " (declare (in ) bvec3 y@0x26ef880)\n"
11300 " )\n"
11301 " (\n"
11302 " ))\n"
11303 "\n"
11304 " (signature bvec4\n"
11305 " (parameters\n"
11306 " (declare (in ) bvec4 x@0x26efa60)\n"
11307 " (declare (in ) bvec4 y@0x26efb70)\n"
11308 " )\n"
11309 " (\n"
11310 " ))\n"
11311 "\n"
11312 ")\n"
11313 "\n"
11314 "(function any\n"
11315 " (signature bool\n"
11316 " (parameters\n"
11317 " (declare (in ) bvec2 x@0x26efd50)\n"
11318 " )\n"
11319 " (\n"
11320 " ))\n"
11321 "\n"
11322 " (signature bool\n"
11323 " (parameters\n"
11324 " (declare (in ) bvec3 x@0x26f00d0)\n"
11325 " )\n"
11326 " (\n"
11327 " ))\n"
11328 "\n"
11329 " (signature bool\n"
11330 " (parameters\n"
11331 " (declare (in ) bvec4 x@0x26f02b0)\n"
11332 " )\n"
11333 " (\n"
11334 " ))\n"
11335 "\n"
11336 ")\n"
11337 "\n"
11338 "(function all\n"
11339 " (signature bool\n"
11340 " (parameters\n"
11341 " (declare (in ) bvec2 x@0x26f0490)\n"
11342 " )\n"
11343 " (\n"
11344 " ))\n"
11345 "\n"
11346 " (signature bool\n"
11347 " (parameters\n"
11348 " (declare (in ) bvec3 x@0x26f0810)\n"
11349 " )\n"
11350 " (\n"
11351 " ))\n"
11352 "\n"
11353 " (signature bool\n"
11354 " (parameters\n"
11355 " (declare (in ) bvec4 x@0x26f09f0)\n"
11356 " )\n"
11357 " (\n"
11358 " ))\n"
11359 "\n"
11360 ")\n"
11361 "\n"
11362 "(function not\n"
11363 " (signature bvec2\n"
11364 " (parameters\n"
11365 " (declare (in ) bvec2 x@0x26f0bd0)\n"
11366 " )\n"
11367 " (\n"
11368 " ))\n"
11369 "\n"
11370 " (signature bvec3\n"
11371 " (parameters\n"
11372 " (declare (in ) bvec3 x@0x26f0f50)\n"
11373 " )\n"
11374 " (\n"
11375 " ))\n"
11376 "\n"
11377 " (signature bvec4\n"
11378 " (parameters\n"
11379 " (declare (in ) bvec4 x@0x26f1130)\n"
11380 " )\n"
11381 " (\n"
11382 " ))\n"
11383 "\n"
11384 ")\n"
11385 "\n"
11386 "(function texture1D\n"
11387 " (signature vec4\n"
11388 " (parameters\n"
11389 " (declare (in ) sampler1D sampler@0x26f1310)\n"
11390 " (declare (in ) float coord@0x26f1420)\n"
11391 " )\n"
11392 " (\n"
11393 " ))\n"
11394 "\n"
11395 " (signature vec4\n"
11396 " (parameters\n"
11397 " (declare (in ) sampler1D sampler@0x26f1f40)\n"
11398 " (declare (in ) float coord@0x26f2050)\n"
11399 " (declare (in ) float bias@0x26f2160)\n"
11400 " )\n"
11401 " (\n"
11402 " ))\n"
11403 "\n"
11404 ")\n"
11405 "\n"
11406 "(function texture1DProj\n"
11407 " (signature vec4\n"
11408 " (parameters\n"
11409 " (declare (in ) sampler1D sampler@0x26f17b0)\n"
11410 " (declare (in ) vec2 coord@0x26f18c0)\n"
11411 " )\n"
11412 " (\n"
11413 " ))\n"
11414 "\n"
11415 " (signature vec4\n"
11416 " (parameters\n"
11417 " (declare (in ) sampler1D sampler@0x26f1c50)\n"
11418 " (declare (in ) vec4 coord@0x26f1d60)\n"
11419 " )\n"
11420 " (\n"
11421 " ))\n"
11422 "\n"
11423 " (signature vec4\n"
11424 " (parameters\n"
11425 " (declare (in ) sampler1D sampler@0x26f2340)\n"
11426 " (declare (in ) vec2 coord@0x26f2450)\n"
11427 " (declare (in ) float bias@0x26f2560)\n"
11428 " )\n"
11429 " (\n"
11430 " ))\n"
11431 "\n"
11432 " (signature vec4\n"
11433 " (parameters\n"
11434 " (declare (in ) sampler1D sampler@0x26f2740)\n"
11435 " (declare (in ) vec4 coord@0x26f2850)\n"
11436 " (declare (in ) float bias@0x26f2960)\n"
11437 " )\n"
11438 " (\n"
11439 " ))\n"
11440 "\n"
11441 ")\n"
11442 "\n"
11443 "(function texture2D\n"
11444 " (signature vec4\n"
11445 " (parameters\n"
11446 " (declare (in ) sampler2D sampler@0x26f2b40)\n"
11447 " (declare (in ) vec2 coord@0x26f2c50)\n"
11448 " )\n"
11449 " (\n"
11450 " ))\n"
11451 "\n"
11452 " (signature vec4\n"
11453 " (parameters\n"
11454 " (declare (in ) sampler2D sampler@0x26f3770)\n"
11455 " (declare (in ) vec2 coord@0x26f3880)\n"
11456 " (declare (in ) float bias@0x26f3990)\n"
11457 " )\n"
11458 " (\n"
11459 " ))\n"
11460 "\n"
11461 ")\n"
11462 "\n"
11463 "(function texture2DProj\n"
11464 " (signature vec4\n"
11465 " (parameters\n"
11466 " (declare (in ) sampler2D sampler@0x26f2fe0)\n"
11467 " (declare (in ) vec3 coord@0x26f30f0)\n"
11468 " )\n"
11469 " (\n"
11470 " ))\n"
11471 "\n"
11472 " (signature vec4\n"
11473 " (parameters\n"
11474 " (declare (in ) sampler2D sampler@0x26f3480)\n"
11475 " (declare (in ) vec4 coord@0x26f3590)\n"
11476 " )\n"
11477 " (\n"
11478 " ))\n"
11479 "\n"
11480 " (signature vec4\n"
11481 " (parameters\n"
11482 " (declare (in ) sampler2D sampler@0x26f3b70)\n"
11483 " (declare (in ) vec3 coord@0x26f3c80)\n"
11484 " (declare (in ) float bias@0x26f3d90)\n"
11485 " )\n"
11486 " (\n"
11487 " ))\n"
11488 "\n"
11489 " (signature vec4\n"
11490 " (parameters\n"
11491 " (declare (in ) sampler2D sampler@0x26f3f70)\n"
11492 " (declare (in ) vec4 coord@0x26f4080)\n"
11493 " (declare (in ) float bias@0x26f4190)\n"
11494 " )\n"
11495 " (\n"
11496 " ))\n"
11497 "\n"
11498 ")\n"
11499 "\n"
11500 "(function texture3D\n"
11501 " (signature vec4\n"
11502 " (parameters\n"
11503 " (declare (in ) sampler3D sampler@0x26f4370)\n"
11504 " (declare (in ) vec3 coord@0x26f4480)\n"
11505 " )\n"
11506 " (\n"
11507 " ))\n"
11508 "\n"
11509 " (signature vec4\n"
11510 " (parameters\n"
11511 " (declare (in ) sampler3D sampler@0x26f4cb0)\n"
11512 " (declare (in ) vec3 coord@0x26f4dc0)\n"
11513 " (declare (in ) float bias@0x26f4ed0)\n"
11514 " )\n"
11515 " (\n"
11516 " ))\n"
11517 "\n"
11518 ")\n"
11519 "\n"
11520 "(function texture3DProj\n"
11521 " (signature vec4\n"
11522 " (parameters\n"
11523 " (declare (in ) sampler3D sampler@0x26f4810)\n"
11524 " (declare (in ) vec4 coord@0x26f4920)\n"
11525 " )\n"
11526 " (\n"
11527 " ))\n"
11528 "\n"
11529 " (signature vec4\n"
11530 " (parameters\n"
11531 " (declare (in ) sampler3D sampler@0x26f50b0)\n"
11532 " (declare (in ) vec4 coord@0x26f51c0)\n"
11533 " (declare (in ) float bias@0x26f52d0)\n"
11534 " )\n"
11535 " (\n"
11536 " ))\n"
11537 "\n"
11538 ")\n"
11539 "\n"
11540 "(function textureCube\n"
11541 " (signature vec4\n"
11542 " (parameters\n"
11543 " (declare (in ) samplerCube sampler@0x26f54b0)\n"
11544 " (declare (in ) vec3 coord@0x26f55c0)\n"
11545 " )\n"
11546 " (\n"
11547 " ))\n"
11548 "\n"
11549 " (signature vec4\n"
11550 " (parameters\n"
11551 " (declare (in ) samplerCube sampler@0x26f5950)\n"
11552 " (declare (in ) vec3 coord@0x26f5a60)\n"
11553 " (declare (in ) float bias@0x26f5b70)\n"
11554 " )\n"
11555 " (\n"
11556 " ))\n"
11557 "\n"
11558 ")\n"
11559 "\n"
11560 "(function shadow1D\n"
11561 " (signature vec4\n"
11562 " (parameters\n"
11563 " (declare (in ) sampler1DShadow sampler@0x26f5d50)\n"
11564 " (declare (in ) vec3 coord@0x26f5e60)\n"
11565 " )\n"
11566 " (\n"
11567 " ))\n"
11568 "\n"
11569 " (signature vec4\n"
11570 " (parameters\n"
11571 " (declare (in ) sampler1DShadow sampler@0x26f6fd0)\n"
11572 " (declare (in ) vec3 coord@0x26f70e0)\n"
11573 " (declare (in ) float bias@0x26f71f0)\n"
11574 " )\n"
11575 " (\n"
11576 " ))\n"
11577 "\n"
11578 ")\n"
11579 "\n"
11580 "(function shadow2D\n"
11581 " (signature vec4\n"
11582 " (parameters\n"
11583 " (declare (in ) sampler2DShadow sampler@0x26f61f0)\n"
11584 " (declare (in ) vec3 coord@0x26f6300)\n"
11585 " )\n"
11586 " (\n"
11587 " ))\n"
11588 "\n"
11589 " (signature vec4\n"
11590 " (parameters\n"
11591 " (declare (in ) sampler2DShadow sampler@0x26f73d0)\n"
11592 " (declare (in ) vec3 coord@0x26f74e0)\n"
11593 " (declare (in ) float bias@0x26f75f0)\n"
11594 " )\n"
11595 " (\n"
11596 " ))\n"
11597 "\n"
11598 ")\n"
11599 "\n"
11600 "(function shadow1DProj\n"
11601 " (signature vec4\n"
11602 " (parameters\n"
11603 " (declare (in ) sampler1DShadow sampler@0x26f6690)\n"
11604 " (declare (in ) vec4 coord@0x26f67a0)\n"
11605 " )\n"
11606 " (\n"
11607 " ))\n"
11608 "\n"
11609 " (signature vec4\n"
11610 " (parameters\n"
11611 " (declare (in ) sampler1DShadow sampler@0x26f77d0)\n"
11612 " (declare (in ) vec4 coord@0x26f78e0)\n"
11613 " (declare (in ) float bias@0x26f79f0)\n"
11614 " )\n"
11615 " (\n"
11616 " ))\n"
11617 "\n"
11618 ")\n"
11619 "\n"
11620 "(function shadow2DProj\n"
11621 " (signature vec4\n"
11622 " (parameters\n"
11623 " (declare (in ) sampler2DShadow sampler@0x26f6b30)\n"
11624 " (declare (in ) vec4 coord@0x26f6c40)\n"
11625 " )\n"
11626 " (\n"
11627 " ))\n"
11628 "\n"
11629 " (signature vec4\n"
11630 " (parameters\n"
11631 " (declare (in ) sampler2DShadow sampler@0x26f7bd0)\n"
11632 " (declare (in ) vec4 coord@0x26f7ce0)\n"
11633 " (declare (in ) float bias@0x26f7df0)\n"
11634 " )\n"
11635 " (\n"
11636 " ))\n"
11637 "\n"
11638 ")\n"
11639 "\n"
11640 "(function dFdx\n"
11641 " (signature float\n"
11642 " (parameters\n"
11643 " (declare (in ) float p@0x26f7fd0)\n"
11644 " )\n"
11645 " (\n"
11646 " ))\n"
11647 "\n"
11648 " (signature vec2\n"
11649 " (parameters\n"
11650 " (declare (in ) vec2 p@0x26f8350)\n"
11651 " )\n"
11652 " (\n"
11653 " ))\n"
11654 "\n"
11655 " (signature vec3\n"
11656 " (parameters\n"
11657 " (declare (in ) vec3 p@0x26f8530)\n"
11658 " )\n"
11659 " (\n"
11660 " ))\n"
11661 "\n"
11662 " (signature vec4\n"
11663 " (parameters\n"
11664 " (declare (in ) vec4 p@0x26f8710)\n"
11665 " )\n"
11666 " (\n"
11667 " ))\n"
11668 "\n"
11669 ")\n"
11670 "\n"
11671 "(function dFdy\n"
11672 " (signature float\n"
11673 " (parameters\n"
11674 " (declare (in ) float p@0x26f88f0)\n"
11675 " )\n"
11676 " (\n"
11677 " ))\n"
11678 "\n"
11679 " (signature vec2\n"
11680 " (parameters\n"
11681 " (declare (in ) vec2 p@0x26f8c70)\n"
11682 " )\n"
11683 " (\n"
11684 " ))\n"
11685 "\n"
11686 " (signature vec3\n"
11687 " (parameters\n"
11688 " (declare (in ) vec3 p@0x26f8e50)\n"
11689 " )\n"
11690 " (\n"
11691 " ))\n"
11692 "\n"
11693 " (signature vec4\n"
11694 " (parameters\n"
11695 " (declare (in ) vec4 p@0x26f9030)\n"
11696 " )\n"
11697 " (\n"
11698 " ))\n"
11699 "\n"
11700 ")\n"
11701 "\n"
11702 "(function fwidth\n"
11703 " (signature float\n"
11704 " (parameters\n"
11705 " (declare (in ) float p@0x26f9210)\n"
11706 " )\n"
11707 " (\n"
11708 " ))\n"
11709 "\n"
11710 " (signature vec2\n"
11711 " (parameters\n"
11712 " (declare (in ) vec2 p@0x26f9590)\n"
11713 " )\n"
11714 " (\n"
11715 " ))\n"
11716 "\n"
11717 " (signature vec3\n"
11718 " (parameters\n"
11719 " (declare (in ) vec3 p@0x26f9770)\n"
11720 " )\n"
11721 " (\n"
11722 " ))\n"
11723 "\n"
11724 " (signature vec4\n"
11725 " (parameters\n"
11726 " (declare (in ) vec4 p@0x26f9950)\n"
11727 " )\n"
11728 " (\n"
11729 " ))\n"
11730 "\n"
11731 ")\n"
11732 "\n"
11733 "(function noise1\n"
11734 " (signature float\n"
11735 " (parameters\n"
11736 " (declare (in ) float x@0x26f9b30)\n"
11737 " )\n"
11738 " (\n"
11739 " ))\n"
11740 "\n"
11741 " (signature float\n"
11742 " (parameters\n"
11743 " (declare (in ) vec2 x@0x26f9eb0)\n"
11744 " )\n"
11745 " (\n"
11746 " ))\n"
11747 "\n"
11748 " (signature float\n"
11749 " (parameters\n"
11750 " (declare (in ) vec3 x@0x26fa090)\n"
11751 " )\n"
11752 " (\n"
11753 " ))\n"
11754 "\n"
11755 " (signature float\n"
11756 " (parameters\n"
11757 " (declare (in ) vec4 x@0x26fa270)\n"
11758 " )\n"
11759 " (\n"
11760 " ))\n"
11761 "\n"
11762 ")\n"
11763 "\n"
11764 "(function noise2\n"
11765 " (signature vec2\n"
11766 " (parameters\n"
11767 " (declare (in ) float x@0x26fa450)\n"
11768 " )\n"
11769 " (\n"
11770 " ))\n"
11771 "\n"
11772 " (signature vec2\n"
11773 " (parameters\n"
11774 " (declare (in ) vec2 x@0x26fa7d0)\n"
11775 " )\n"
11776 " (\n"
11777 " ))\n"
11778 "\n"
11779 " (signature vec2\n"
11780 " (parameters\n"
11781 " (declare (in ) vec3 x@0x26fa9b0)\n"
11782 " )\n"
11783 " (\n"
11784 " ))\n"
11785 "\n"
11786 " (signature vec2\n"
11787 " (parameters\n"
11788 " (declare (in ) vec4 x@0x26fab90)\n"
11789 " )\n"
11790 " (\n"
11791 " ))\n"
11792 "\n"
11793 ")\n"
11794 "\n"
11795 "(function noise3\n"
11796 " (signature vec3\n"
11797 " (parameters\n"
11798 " (declare (in ) float x@0x26fad70)\n"
11799 " )\n"
11800 " (\n"
11801 " ))\n"
11802 "\n"
11803 " (signature vec3\n"
11804 " (parameters\n"
11805 " (declare (in ) vec2 x@0x26fb0f0)\n"
11806 " )\n"
11807 " (\n"
11808 " ))\n"
11809 "\n"
11810 " (signature vec3\n"
11811 " (parameters\n"
11812 " (declare (in ) vec3 x@0x26fb2d0)\n"
11813 " )\n"
11814 " (\n"
11815 " ))\n"
11816 "\n"
11817 " (signature vec3\n"
11818 " (parameters\n"
11819 " (declare (in ) vec4 x@0x26fb4b0)\n"
11820 " )\n"
11821 " (\n"
11822 " ))\n"
11823 "\n"
11824 ")\n"
11825 "\n"
11826 "(function noise4\n"
11827 " (signature vec4\n"
11828 " (parameters\n"
11829 " (declare (in ) float x@0x26fb690)\n"
11830 " )\n"
11831 " (\n"
11832 " ))\n"
11833 "\n"
11834 " (signature vec4\n"
11835 " (parameters\n"
11836 " (declare (in ) vec2 x@0x26fba10)\n"
11837 " )\n"
11838 " (\n"
11839 " ))\n"
11840 "\n"
11841 " (signature vec4\n"
11842 " (parameters\n"
11843 " (declare (in ) vec3 x@0x26fbbf0)\n"
11844 " )\n"
11845 " (\n"
11846 " ))\n"
11847 "\n"
11848 " (signature vec4\n"
11849 " (parameters\n"
11850 " (declare (in ) vec4 x@0x26fbdd0)\n"
11851 " )\n"
11852 " (\n"
11853 " ))\n"
11854 "\n"
11855 ")\n"
11856 "\n"
11857 "\n"
11858 ")"
11859;
11860static const char *functions_for_110_frag [] = {
11861 builtin_clamp,
11862 builtin_matrixCompMult,
11863 builtin_noise2,
11864 builtin_pow,
11865 builtin_texture2DProj,
11866 builtin_fwidth,
11867 builtin_greaterThanEqual,
11868 builtin_sign,
11869 builtin_texture3DProj,
11870 builtin_texture2D,
11871 builtin_equal,
11872 builtin_faceforward,
11873 builtin_tan,
11874 builtin_any,
11875 builtin_normalize,
11876 builtin_asin,
11877 builtin_texture1DProj,
11878 builtin_log,
11879 builtin_floor,
11880 builtin_exp2,
11881 builtin_lessThan,
11882 builtin_cross,
11883 builtin_sqrt,
11884 builtin_shadow2DProj,
11885 builtin_fract,
11886 builtin_abs,
11887 builtin_degrees,
11888 builtin_dFdx,
11889 builtin_sin,
11890 builtin_shadow2D,
11891 builtin_all,
11892 builtin_log2,
11893 builtin_atan,
11894 builtin_notEqual,
11895 builtin_max,
11896 builtin_lessThanEqual,
11897 builtin_shadow1DProj,
11898 builtin_ceil,
11899 builtin_reflect,
11900 builtin_step,
11901 builtin_texture1D,
11902 builtin_greaterThan,
11903 builtin_texture3D,
11904 builtin_not,
11905 builtin_inversesqrt,
11906 builtin_mod,
11907 builtin_noise4,
11908 builtin_distance,
11909 builtin_cos,
11910 builtin_shadow1D,
11911 builtin_noise1,
11912 builtin_refract,
11913 builtin_noise3,
11914 builtin_min,
11915 builtin_radians,
11916 builtin_smoothstep,
11917 builtin_textureCube,
11918 builtin_length,
11919 builtin_dFdy,
11920 builtin_exp,
11921 builtin_acos,
11922 builtin_mix,
11923 builtin_dot,
11924};
11925static const char *prototypes_for_EXT_texture_array_vert =
11926 "(\n"
11927 "(function texture1DArray\n"
11928 " (signature vec4\n"
11929 " (parameters\n"
11930 " (declare (in ) sampler1DArray sampler@0x2378290)\n"
11931 " (declare (in ) vec2 coord@0x23783a0)\n"
11932 " )\n"
11933 " (\n"
11934 " ))\n"
11935 "\n"
11936 ")\n"
11937 "\n"
11938 "(function texture1DArrayLod\n"
11939 " (signature vec4\n"
11940 " (parameters\n"
11941 " (declare (in ) sampler1DArray sampler@0x2378730)\n"
11942 " (declare (in ) vec2 coord@0x2378840)\n"
11943 " (declare (in ) float lod@0x2378950)\n"
11944 " )\n"
11945 " (\n"
11946 " ))\n"
11947 "\n"
11948 ")\n"
11949 "\n"
11950 "(function texture2DArray\n"
11951 " (signature vec4\n"
11952 " (parameters\n"
11953 " (declare (in ) sampler1DArray sampler@0x2378ce0)\n"
11954 " (declare (in ) vec2 coord@0x2378df0)\n"
11955 " )\n"
11956 " (\n"
11957 " ))\n"
11958 "\n"
11959 ")\n"
11960 "\n"
11961 "(function texture2DArrayLod\n"
11962 " (signature vec4\n"
11963 " (parameters\n"
11964 " (declare (in ) sampler1DArray sampler@0x2379180)\n"
11965 " (declare (in ) vec2 coord@0x2379290)\n"
11966 " (declare (in ) float lod@0x23793a0)\n"
11967 " )\n"
11968 " (\n"
11969 " ))\n"
11970 "\n"
11971 ")\n"
11972 "\n"
11973 "(function shadow1DArray\n"
11974 " (signature vec4\n"
11975 " (parameters\n"
11976 " (declare (in ) sampler1DArrayShadow sampler@0x2379730)\n"
11977 " (declare (in ) vec3 coord@0x2379840)\n"
11978 " )\n"
11979 " (\n"
11980 " ))\n"
11981 "\n"
11982 ")\n"
11983 "\n"
11984 "(function shadow1DArrayLod\n"
11985 " (signature vec4\n"
11986 " (parameters\n"
11987 " (declare (in ) sampler1DArrayShadow sampler@0x2379bd0)\n"
11988 " (declare (in ) vec3 coord@0x2379ce0)\n"
11989 " (declare (in ) float lod@0x2379df0)\n"
11990 " )\n"
11991 " (\n"
11992 " ))\n"
11993 "\n"
11994 ")\n"
11995 "\n"
11996 "(function shadow2DArray\n"
11997 " (signature vec4\n"
11998 " (parameters\n"
11999 " (declare (in ) sampler2DArrayShadow sampler@0x237a180)\n"
12000 " (declare (in ) vec4 coord@0x237a290)\n"
12001 " )\n"
12002 " (\n"
12003 " ))\n"
12004 "\n"
12005 ")\n"
12006 "\n"
12007 "\n"
12008 ")"
12009;
12010static const char *functions_for_EXT_texture_array_vert [] = {
12011 builtin_texture1DArrayLod,
12012 builtin_shadow2DArray,
12013 builtin_texture2DArrayLod,
12014 builtin_shadow1DArrayLod,
12015 builtin_shadow1DArray,
12016 builtin_texture2DArray,
12017 builtin_texture1DArray,
12018};
12019static const char *prototypes_for_130_frag =
12020 "(\n"
12021 "(function radians\n"
12022 " (signature float\n"
12023 " (parameters\n"
12024 " (declare (in ) float degrees@0x141d070)\n"
12025 " )\n"
12026 " (\n"
12027 " ))\n"
12028 "\n"
12029 " (signature vec2\n"
12030 " (parameters\n"
12031 " (declare (in ) vec2 degrees@0x141d3f0)\n"
12032 " )\n"
12033 " (\n"
12034 " ))\n"
12035 "\n"
12036 " (signature vec3\n"
12037 " (parameters\n"
12038 " (declare (in ) vec3 degrees@0x141d5d0)\n"
12039 " )\n"
12040 " (\n"
12041 " ))\n"
12042 "\n"
12043 " (signature vec4\n"
12044 " (parameters\n"
12045 " (declare (in ) vec4 degrees@0x141d7b0)\n"
12046 " )\n"
12047 " (\n"
12048 " ))\n"
12049 "\n"
12050 ")\n"
12051 "\n"
12052 "(function degrees\n"
12053 " (signature float\n"
12054 " (parameters\n"
12055 " (declare (in ) float radians@0x141d990)\n"
12056 " )\n"
12057 " (\n"
12058 " ))\n"
12059 "\n"
12060 " (signature vec2\n"
12061 " (parameters\n"
12062 " (declare (in ) vec2 radians@0x141dd10)\n"
12063 " )\n"
12064 " (\n"
12065 " ))\n"
12066 "\n"
12067 " (signature vec3\n"
12068 " (parameters\n"
12069 " (declare (in ) vec3 radians@0x141def0)\n"
12070 " )\n"
12071 " (\n"
12072 " ))\n"
12073 "\n"
12074 " (signature vec4\n"
12075 " (parameters\n"
12076 " (declare (in ) vec4 radians@0x141e0d0)\n"
12077 " )\n"
12078 " (\n"
12079 " ))\n"
12080 "\n"
12081 ")\n"
12082 "\n"
12083 "(function sin\n"
12084 " (signature float\n"
12085 " (parameters\n"
12086 " (declare (in ) float angle@0x141e2b0)\n"
12087 " )\n"
12088 " (\n"
12089 " ))\n"
12090 "\n"
12091 " (signature vec2\n"
12092 " (parameters\n"
12093 " (declare (in ) vec2 angle@0x141e630)\n"
12094 " )\n"
12095 " (\n"
12096 " ))\n"
12097 "\n"
12098 " (signature vec3\n"
12099 " (parameters\n"
12100 " (declare (in ) vec3 angle@0x141e810)\n"
12101 " )\n"
12102 " (\n"
12103 " ))\n"
12104 "\n"
12105 " (signature vec4\n"
12106 " (parameters\n"
12107 " (declare (in ) vec4 angle@0x141e9f0)\n"
12108 " )\n"
12109 " (\n"
12110 " ))\n"
12111 "\n"
12112 ")\n"
12113 "\n"
12114 "(function cos\n"
12115 " (signature float\n"
12116 " (parameters\n"
12117 " (declare (in ) float angle@0x141ebd0)\n"
12118 " )\n"
12119 " (\n"
12120 " ))\n"
12121 "\n"
12122 " (signature vec2\n"
12123 " (parameters\n"
12124 " (declare (in ) vec2 angle@0x141ef50)\n"
12125 " )\n"
12126 " (\n"
12127 " ))\n"
12128 "\n"
12129 " (signature vec3\n"
12130 " (parameters\n"
12131 " (declare (in ) vec3 angle@0x141f130)\n"
12132 " )\n"
12133 " (\n"
12134 " ))\n"
12135 "\n"
12136 " (signature vec4\n"
12137 " (parameters\n"
12138 " (declare (in ) vec4 angle@0x141f310)\n"
12139 " )\n"
12140 " (\n"
12141 " ))\n"
12142 "\n"
12143 ")\n"
12144 "\n"
12145 "(function tan\n"
12146 " (signature float\n"
12147 " (parameters\n"
12148 " (declare (in ) float angle@0x141f4f0)\n"
12149 " )\n"
12150 " (\n"
12151 " ))\n"
12152 "\n"
12153 " (signature vec2\n"
12154 " (parameters\n"
12155 " (declare (in ) vec2 angle@0x141f870)\n"
12156 " )\n"
12157 " (\n"
12158 " ))\n"
12159 "\n"
12160 " (signature vec3\n"
12161 " (parameters\n"
12162 " (declare (in ) vec3 angle@0x141fa50)\n"
12163 " )\n"
12164 " (\n"
12165 " ))\n"
12166 "\n"
12167 " (signature vec4\n"
12168 " (parameters\n"
12169 " (declare (in ) vec4 angle@0x141fc30)\n"
12170 " )\n"
12171 " (\n"
12172 " ))\n"
12173 "\n"
12174 ")\n"
12175 "\n"
12176 "(function asin\n"
12177 " (signature float\n"
12178 " (parameters\n"
12179 " (declare (in ) float angle@0x141fe10)\n"
12180 " )\n"
12181 " (\n"
12182 " ))\n"
12183 "\n"
12184 " (signature vec2\n"
12185 " (parameters\n"
12186 " (declare (in ) vec2 angle@0x1420190)\n"
12187 " )\n"
12188 " (\n"
12189 " ))\n"
12190 "\n"
12191 " (signature vec3\n"
12192 " (parameters\n"
12193 " (declare (in ) vec3 angle@0x1420370)\n"
12194 " )\n"
12195 " (\n"
12196 " ))\n"
12197 "\n"
12198 " (signature vec4\n"
12199 " (parameters\n"
12200 " (declare (in ) vec4 angle@0x1420550)\n"
12201 " )\n"
12202 " (\n"
12203 " ))\n"
12204 "\n"
12205 ")\n"
12206 "\n"
12207 "(function acos\n"
12208 " (signature float\n"
12209 " (parameters\n"
12210 " (declare (in ) float angle@0x1420730)\n"
12211 " )\n"
12212 " (\n"
12213 " ))\n"
12214 "\n"
12215 " (signature vec2\n"
12216 " (parameters\n"
12217 " (declare (in ) vec2 angle@0x1420ab0)\n"
12218 " )\n"
12219 " (\n"
12220 " ))\n"
12221 "\n"
12222 " (signature vec3\n"
12223 " (parameters\n"
12224 " (declare (in ) vec3 angle@0x1420c90)\n"
12225 " )\n"
12226 " (\n"
12227 " ))\n"
12228 "\n"
12229 " (signature vec4\n"
12230 " (parameters\n"
12231 " (declare (in ) vec4 angle@0x1420e70)\n"
12232 " )\n"
12233 " (\n"
12234 " ))\n"
12235 "\n"
12236 ")\n"
12237 "\n"
12238 "(function atan\n"
12239 " (signature float\n"
12240 " (parameters\n"
12241 " (declare (in ) float y@0x1421050)\n"
12242 " (declare (in ) float x@0x1421160)\n"
12243 " )\n"
12244 " (\n"
12245 " ))\n"
12246 "\n"
12247 " (signature vec2\n"
12248 " (parameters\n"
12249 " (declare (in ) vec2 y@0x14214e0)\n"
12250 " (declare (in ) vec2 x@0x14215f0)\n"
12251 " )\n"
12252 " (\n"
12253 " ))\n"
12254 "\n"
12255 " (signature vec3\n"
12256 " (parameters\n"
12257 " (declare (in ) vec3 y@0x14217d0)\n"
12258 " (declare (in ) vec3 x@0x14218e0)\n"
12259 " )\n"
12260 " (\n"
12261 " ))\n"
12262 "\n"
12263 " (signature vec4\n"
12264 " (parameters\n"
12265 " (declare (in ) vec4 y@0x1421ac0)\n"
12266 " (declare (in ) vec4 x@0x1421bd0)\n"
12267 " )\n"
12268 " (\n"
12269 " ))\n"
12270 "\n"
12271 " (signature float\n"
12272 " (parameters\n"
12273 " (declare (in ) float y_over_x@0x1421db0)\n"
12274 " )\n"
12275 " (\n"
12276 " ))\n"
12277 "\n"
12278 " (signature vec2\n"
12279 " (parameters\n"
12280 " (declare (in ) vec2 y_over_x@0x1421fa0)\n"
12281 " )\n"
12282 " (\n"
12283 " ))\n"
12284 "\n"
12285 " (signature vec3\n"
12286 " (parameters\n"
12287 " (declare (in ) vec3 y_over_x@0x1422190)\n"
12288 " )\n"
12289 " (\n"
12290 " ))\n"
12291 "\n"
12292 " (signature vec4\n"
12293 " (parameters\n"
12294 " (declare (in ) vec4 y_over_x@0x1422380)\n"
12295 " )\n"
12296 " (\n"
12297 " ))\n"
12298 "\n"
12299 ")\n"
12300 "\n"
12301 "(function pow\n"
12302 " (signature float\n"
12303 " (parameters\n"
12304 " (declare (in ) float x@0x1422570)\n"
12305 " (declare (in ) float y@0x1422680)\n"
12306 " )\n"
12307 " (\n"
12308 " ))\n"
12309 "\n"
12310 " (signature vec2\n"
12311 " (parameters\n"
12312 " (declare (in ) vec2 x@0x1422a00)\n"
12313 " (declare (in ) vec2 y@0x1422b10)\n"
12314 " )\n"
12315 " (\n"
12316 " ))\n"
12317 "\n"
12318 " (signature vec3\n"
12319 " (parameters\n"
12320 " (declare (in ) vec3 x@0x1422cf0)\n"
12321 " (declare (in ) vec3 y@0x1422e00)\n"
12322 " )\n"
12323 " (\n"
12324 " ))\n"
12325 "\n"
12326 " (signature vec4\n"
12327 " (parameters\n"
12328 " (declare (in ) vec4 x@0x1422fe0)\n"
12329 " (declare (in ) vec4 y@0x14230f0)\n"
12330 " )\n"
12331 " (\n"
12332 " ))\n"
12333 "\n"
12334 ")\n"
12335 "\n"
12336 "(function exp\n"
12337 " (signature float\n"
12338 " (parameters\n"
12339 " (declare (in ) float x@0x14232d0)\n"
12340 " )\n"
12341 " (\n"
12342 " ))\n"
12343 "\n"
12344 " (signature vec2\n"
12345 " (parameters\n"
12346 " (declare (in ) vec2 x@0x1423650)\n"
12347 " )\n"
12348 " (\n"
12349 " ))\n"
12350 "\n"
12351 " (signature vec3\n"
12352 " (parameters\n"
12353 " (declare (in ) vec3 x@0x1423830)\n"
12354 " )\n"
12355 " (\n"
12356 " ))\n"
12357 "\n"
12358 " (signature vec4\n"
12359 " (parameters\n"
12360 " (declare (in ) vec4 x@0x1423a10)\n"
12361 " )\n"
12362 " (\n"
12363 " ))\n"
12364 "\n"
12365 ")\n"
12366 "\n"
12367 "(function log\n"
12368 " (signature float\n"
12369 " (parameters\n"
12370 " (declare (in ) float x@0x1423bf0)\n"
12371 " )\n"
12372 " (\n"
12373 " ))\n"
12374 "\n"
12375 " (signature vec2\n"
12376 " (parameters\n"
12377 " (declare (in ) vec2 x@0x1423f70)\n"
12378 " )\n"
12379 " (\n"
12380 " ))\n"
12381 "\n"
12382 " (signature vec3\n"
12383 " (parameters\n"
12384 " (declare (in ) vec3 x@0x1424150)\n"
12385 " )\n"
12386 " (\n"
12387 " ))\n"
12388 "\n"
12389 " (signature vec4\n"
12390 " (parameters\n"
12391 " (declare (in ) vec4 x@0x1424330)\n"
12392 " )\n"
12393 " (\n"
12394 " ))\n"
12395 "\n"
12396 ")\n"
12397 "\n"
12398 "(function exp2\n"
12399 " (signature float\n"
12400 " (parameters\n"
12401 " (declare (in ) float x@0x1424510)\n"
12402 " )\n"
12403 " (\n"
12404 " ))\n"
12405 "\n"
12406 " (signature vec2\n"
12407 " (parameters\n"
12408 " (declare (in ) vec2 x@0x1424890)\n"
12409 " )\n"
12410 " (\n"
12411 " ))\n"
12412 "\n"
12413 " (signature vec3\n"
12414 " (parameters\n"
12415 " (declare (in ) vec3 x@0x1424a70)\n"
12416 " )\n"
12417 " (\n"
12418 " ))\n"
12419 "\n"
12420 " (signature vec4\n"
12421 " (parameters\n"
12422 " (declare (in ) vec4 x@0x1424c50)\n"
12423 " )\n"
12424 " (\n"
12425 " ))\n"
12426 "\n"
12427 ")\n"
12428 "\n"
12429 "(function log2\n"
12430 " (signature float\n"
12431 " (parameters\n"
12432 " (declare (in ) float x@0x1424e30)\n"
12433 " )\n"
12434 " (\n"
12435 " ))\n"
12436 "\n"
12437 " (signature vec2\n"
12438 " (parameters\n"
12439 " (declare (in ) vec2 x@0x14251b0)\n"
12440 " )\n"
12441 " (\n"
12442 " ))\n"
12443 "\n"
12444 " (signature vec3\n"
12445 " (parameters\n"
12446 " (declare (in ) vec3 x@0x1425390)\n"
12447 " )\n"
12448 " (\n"
12449 " ))\n"
12450 "\n"
12451 " (signature vec4\n"
12452 " (parameters\n"
12453 " (declare (in ) vec4 x@0x1425570)\n"
12454 " )\n"
12455 " (\n"
12456 " ))\n"
12457 "\n"
12458 ")\n"
12459 "\n"
12460 "(function sqrt\n"
12461 " (signature float\n"
12462 " (parameters\n"
12463 " (declare (in ) float x@0x1425750)\n"
12464 " )\n"
12465 " (\n"
12466 " ))\n"
12467 "\n"
12468 " (signature vec2\n"
12469 " (parameters\n"
12470 " (declare (in ) vec2 x@0x1425ad0)\n"
12471 " )\n"
12472 " (\n"
12473 " ))\n"
12474 "\n"
12475 " (signature vec3\n"
12476 " (parameters\n"
12477 " (declare (in ) vec3 x@0x1425cb0)\n"
12478 " )\n"
12479 " (\n"
12480 " ))\n"
12481 "\n"
12482 " (signature vec4\n"
12483 " (parameters\n"
12484 " (declare (in ) vec4 x@0x1425e90)\n"
12485 " )\n"
12486 " (\n"
12487 " ))\n"
12488 "\n"
12489 ")\n"
12490 "\n"
12491 "(function inversesqrt\n"
12492 " (signature float\n"
12493 " (parameters\n"
12494 " (declare (in ) float x@0x1426070)\n"
12495 " )\n"
12496 " (\n"
12497 " ))\n"
12498 "\n"
12499 " (signature vec2\n"
12500 " (parameters\n"
12501 " (declare (in ) vec2 x@0x1426400)\n"
12502 " )\n"
12503 " (\n"
12504 " ))\n"
12505 "\n"
12506 " (signature vec3\n"
12507 " (parameters\n"
12508 " (declare (in ) vec3 x@0x14265e0)\n"
12509 " )\n"
12510 " (\n"
12511 " ))\n"
12512 "\n"
12513 " (signature vec4\n"
12514 " (parameters\n"
12515 " (declare (in ) vec4 x@0x14267c0)\n"
12516 " )\n"
12517 " (\n"
12518 " ))\n"
12519 "\n"
12520 ")\n"
12521 "\n"
12522 "(function abs\n"
12523 " (signature float\n"
12524 " (parameters\n"
12525 " (declare (in ) float x@0x14269a0)\n"
12526 " )\n"
12527 " (\n"
12528 " ))\n"
12529 "\n"
12530 " (signature vec2\n"
12531 " (parameters\n"
12532 " (declare (in ) vec2 x@0x1426d20)\n"
12533 " )\n"
12534 " (\n"
12535 " ))\n"
12536 "\n"
12537 " (signature vec3\n"
12538 " (parameters\n"
12539 " (declare (in ) vec3 x@0x1426f00)\n"
12540 " )\n"
12541 " (\n"
12542 " ))\n"
12543 "\n"
12544 " (signature vec4\n"
12545 " (parameters\n"
12546 " (declare (in ) vec4 x@0x14270e0)\n"
12547 " )\n"
12548 " (\n"
12549 " ))\n"
12550 "\n"
12551 " (signature int\n"
12552 " (parameters\n"
12553 " (declare (in ) int x@0x14272c0)\n"
12554 " )\n"
12555 " (\n"
12556 " ))\n"
12557 "\n"
12558 " (signature ivec2\n"
12559 " (parameters\n"
12560 " (declare (in ) ivec2 x@0x14274a0)\n"
12561 " )\n"
12562 " (\n"
12563 " ))\n"
12564 "\n"
12565 " (signature ivec3\n"
12566 " (parameters\n"
12567 " (declare (in ) ivec3 x@0x1427680)\n"
12568 " )\n"
12569 " (\n"
12570 " ))\n"
12571 "\n"
12572 " (signature ivec4\n"
12573 " (parameters\n"
12574 " (declare (in ) ivec4 x@0x1427860)\n"
12575 " )\n"
12576 " (\n"
12577 " ))\n"
12578 "\n"
12579 ")\n"
12580 "\n"
12581 "(function sign\n"
12582 " (signature float\n"
12583 " (parameters\n"
12584 " (declare (in ) float x@0x1427a40)\n"
12585 " )\n"
12586 " (\n"
12587 " ))\n"
12588 "\n"
12589 " (signature vec2\n"
12590 " (parameters\n"
12591 " (declare (in ) vec2 x@0x1427dc0)\n"
12592 " )\n"
12593 " (\n"
12594 " ))\n"
12595 "\n"
12596 " (signature vec3\n"
12597 " (parameters\n"
12598 " (declare (in ) vec3 x@0x1427fa0)\n"
12599 " )\n"
12600 " (\n"
12601 " ))\n"
12602 "\n"
12603 " (signature vec4\n"
12604 " (parameters\n"
12605 " (declare (in ) vec4 x@0x1428180)\n"
12606 " )\n"
12607 " (\n"
12608 " ))\n"
12609 "\n"
12610 " (signature int\n"
12611 " (parameters\n"
12612 " (declare (in ) int x@0x1428360)\n"
12613 " )\n"
12614 " (\n"
12615 " ))\n"
12616 "\n"
12617 " (signature ivec2\n"
12618 " (parameters\n"
12619 " (declare (in ) ivec2 x@0x1428540)\n"
12620 " )\n"
12621 " (\n"
12622 " ))\n"
12623 "\n"
12624 " (signature ivec3\n"
12625 " (parameters\n"
12626 " (declare (in ) ivec3 x@0x1428720)\n"
12627 " )\n"
12628 " (\n"
12629 " ))\n"
12630 "\n"
12631 " (signature ivec4\n"
12632 " (parameters\n"
12633 " (declare (in ) ivec4 x@0x1428900)\n"
12634 " )\n"
12635 " (\n"
12636 " ))\n"
12637 "\n"
12638 ")\n"
12639 "\n"
12640 "(function floor\n"
12641 " (signature float\n"
12642 " (parameters\n"
12643 " (declare (in ) float x@0x1428ae0)\n"
12644 " )\n"
12645 " (\n"
12646 " ))\n"
12647 "\n"
12648 " (signature vec2\n"
12649 " (parameters\n"
12650 " (declare (in ) vec2 x@0x1428e60)\n"
12651 " )\n"
12652 " (\n"
12653 " ))\n"
12654 "\n"
12655 " (signature vec3\n"
12656 " (parameters\n"
12657 " (declare (in ) vec3 x@0x1429040)\n"
12658 " )\n"
12659 " (\n"
12660 " ))\n"
12661 "\n"
12662 " (signature vec4\n"
12663 " (parameters\n"
12664 " (declare (in ) vec4 x@0x1429220)\n"
12665 " )\n"
12666 " (\n"
12667 " ))\n"
12668 "\n"
12669 ")\n"
12670 "\n"
12671 "(function ceil\n"
12672 " (signature float\n"
12673 " (parameters\n"
12674 " (declare (in ) float x@0x1429400)\n"
12675 " )\n"
12676 " (\n"
12677 " ))\n"
12678 "\n"
12679 " (signature vec2\n"
12680 " (parameters\n"
12681 " (declare (in ) vec2 x@0x1429780)\n"
12682 " )\n"
12683 " (\n"
12684 " ))\n"
12685 "\n"
12686 " (signature vec3\n"
12687 " (parameters\n"
12688 " (declare (in ) vec3 x@0x1429960)\n"
12689 " )\n"
12690 " (\n"
12691 " ))\n"
12692 "\n"
12693 " (signature vec4\n"
12694 " (parameters\n"
12695 " (declare (in ) vec4 x@0x1429b40)\n"
12696 " )\n"
12697 " (\n"
12698 " ))\n"
12699 "\n"
12700 ")\n"
12701 "\n"
12702 "(function fract\n"
12703 " (signature float\n"
12704 " (parameters\n"
12705 " (declare (in ) float x@0x1429d20)\n"
12706 " )\n"
12707 " (\n"
12708 " ))\n"
12709 "\n"
12710 " (signature vec2\n"
12711 " (parameters\n"
12712 " (declare (in ) vec2 x@0x142a0a0)\n"
12713 " )\n"
12714 " (\n"
12715 " ))\n"
12716 "\n"
12717 " (signature vec3\n"
12718 " (parameters\n"
12719 " (declare (in ) vec3 x@0x142a280)\n"
12720 " )\n"
12721 " (\n"
12722 " ))\n"
12723 "\n"
12724 " (signature vec4\n"
12725 " (parameters\n"
12726 " (declare (in ) vec4 x@0x142a460)\n"
12727 " )\n"
12728 " (\n"
12729 " ))\n"
12730 "\n"
12731 ")\n"
12732 "\n"
12733 "(function mod\n"
12734 " (signature float\n"
12735 " (parameters\n"
12736 " (declare (in ) float x@0x142a640)\n"
12737 " (declare (in ) float y@0x142a750)\n"
12738 " )\n"
12739 " (\n"
12740 " ))\n"
12741 "\n"
12742 " (signature vec2\n"
12743 " (parameters\n"
12744 " (declare (in ) vec2 x@0x142aad0)\n"
12745 " (declare (in ) float y@0x142abe0)\n"
12746 " )\n"
12747 " (\n"
12748 " ))\n"
12749 "\n"
12750 " (signature vec3\n"
12751 " (parameters\n"
12752 " (declare (in ) vec3 x@0x142adc0)\n"
12753 " (declare (in ) float y@0x142aed0)\n"
12754 " )\n"
12755 " (\n"
12756 " ))\n"
12757 "\n"
12758 " (signature vec4\n"
12759 " (parameters\n"
12760 " (declare (in ) vec4 x@0x142b0b0)\n"
12761 " (declare (in ) float y@0x142b1c0)\n"
12762 " )\n"
12763 " (\n"
12764 " ))\n"
12765 "\n"
12766 " (signature vec2\n"
12767 " (parameters\n"
12768 " (declare (in ) vec2 x@0x142b3a0)\n"
12769 " (declare (in ) vec2 y@0x142b4b0)\n"
12770 " )\n"
12771 " (\n"
12772 " ))\n"
12773 "\n"
12774 " (signature vec3\n"
12775 " (parameters\n"
12776 " (declare (in ) vec3 x@0x142b690)\n"
12777 " (declare (in ) vec3 y@0x142b7a0)\n"
12778 " )\n"
12779 " (\n"
12780 " ))\n"
12781 "\n"
12782 " (signature vec4\n"
12783 " (parameters\n"
12784 " (declare (in ) vec4 x@0x142b980)\n"
12785 " (declare (in ) vec4 y@0x142ba90)\n"
12786 " )\n"
12787 " (\n"
12788 " ))\n"
12789 "\n"
12790 ")\n"
12791 "\n"
12792 "(function min\n"
12793 " (signature float\n"
12794 " (parameters\n"
12795 " (declare (in ) float x@0x142bc70)\n"
12796 " (declare (in ) float y@0x142bd80)\n"
12797 " )\n"
12798 " (\n"
12799 " ))\n"
12800 "\n"
12801 " (signature vec2\n"
12802 " (parameters\n"
12803 " (declare (in ) vec2 x@0x142c100)\n"
12804 " (declare (in ) vec2 y@0x142c210)\n"
12805 " )\n"
12806 " (\n"
12807 " ))\n"
12808 "\n"
12809 " (signature vec3\n"
12810 " (parameters\n"
12811 " (declare (in ) vec3 x@0x142c3f0)\n"
12812 " (declare (in ) vec3 y@0x142c500)\n"
12813 " )\n"
12814 " (\n"
12815 " ))\n"
12816 "\n"
12817 " (signature vec4\n"
12818 " (parameters\n"
12819 " (declare (in ) vec4 x@0x142c6e0)\n"
12820 " (declare (in ) vec4 y@0x142c7f0)\n"
12821 " )\n"
12822 " (\n"
12823 " ))\n"
12824 "\n"
12825 " (signature vec2\n"
12826 " (parameters\n"
12827 " (declare (in ) vec2 x@0x142c9d0)\n"
12828 " (declare (in ) float y@0x142cae0)\n"
12829 " )\n"
12830 " (\n"
12831 " ))\n"
12832 "\n"
12833 " (signature vec3\n"
12834 " (parameters\n"
12835 " (declare (in ) vec3 x@0x142ccc0)\n"
12836 " (declare (in ) float y@0x142cdd0)\n"
12837 " )\n"
12838 " (\n"
12839 " ))\n"
12840 "\n"
12841 " (signature vec4\n"
12842 " (parameters\n"
12843 " (declare (in ) vec4 x@0x142cfb0)\n"
12844 " (declare (in ) float y@0x142d0c0)\n"
12845 " )\n"
12846 " (\n"
12847 " ))\n"
12848 "\n"
12849 " (signature int\n"
12850 " (parameters\n"
12851 " (declare (in ) int x@0x142d2a0)\n"
12852 " (declare (in ) int y@0x142d3b0)\n"
12853 " )\n"
12854 " (\n"
12855 " ))\n"
12856 "\n"
12857 " (signature ivec2\n"
12858 " (parameters\n"
12859 " (declare (in ) ivec2 x@0x142d590)\n"
12860 " (declare (in ) ivec2 y@0x142d6a0)\n"
12861 " )\n"
12862 " (\n"
12863 " ))\n"
12864 "\n"
12865 " (signature ivec3\n"
12866 " (parameters\n"
12867 " (declare (in ) ivec3 x@0x142d880)\n"
12868 " (declare (in ) ivec3 y@0x142d990)\n"
12869 " )\n"
12870 " (\n"
12871 " ))\n"
12872 "\n"
12873 " (signature ivec4\n"
12874 " (parameters\n"
12875 " (declare (in ) ivec4 x@0x142db70)\n"
12876 " (declare (in ) ivec4 y@0x142dc80)\n"
12877 " )\n"
12878 " (\n"
12879 " ))\n"
12880 "\n"
12881 " (signature ivec2\n"
12882 " (parameters\n"
12883 " (declare (in ) ivec2 x@0x142de60)\n"
12884 " (declare (in ) int y@0x142df70)\n"
12885 " )\n"
12886 " (\n"
12887 " ))\n"
12888 "\n"
12889 " (signature ivec3\n"
12890 " (parameters\n"
12891 " (declare (in ) ivec3 x@0x142e150)\n"
12892 " (declare (in ) int y@0x142e260)\n"
12893 " )\n"
12894 " (\n"
12895 " ))\n"
12896 "\n"
12897 " (signature ivec4\n"
12898 " (parameters\n"
12899 " (declare (in ) ivec4 x@0x142e440)\n"
12900 " (declare (in ) int y@0x142e550)\n"
12901 " )\n"
12902 " (\n"
12903 " ))\n"
12904 "\n"
12905 " (signature uint\n"
12906 " (parameters\n"
12907 " (declare (in ) uint x@0x142e730)\n"
12908 " (declare (in ) uint y@0x142e840)\n"
12909 " )\n"
12910 " (\n"
12911 " ))\n"
12912 "\n"
12913 " (signature uvec2\n"
12914 " (parameters\n"
12915 " (declare (in ) uvec2 x@0x142ea20)\n"
12916 " (declare (in ) uvec2 y@0x142eb30)\n"
12917 " )\n"
12918 " (\n"
12919 " ))\n"
12920 "\n"
12921 " (signature uvec3\n"
12922 " (parameters\n"
12923 " (declare (in ) uvec3 x@0x142ed10)\n"
12924 " (declare (in ) uvec3 y@0x142ee20)\n"
12925 " )\n"
12926 " (\n"
12927 " ))\n"
12928 "\n"
12929 " (signature uvec4\n"
12930 " (parameters\n"
12931 " (declare (in ) uvec4 x@0x142f000)\n"
12932 " (declare (in ) uvec4 y@0x142f110)\n"
12933 " )\n"
12934 " (\n"
12935 " ))\n"
12936 "\n"
12937 " (signature uvec2\n"
12938 " (parameters\n"
12939 " (declare (in ) uvec2 x@0x142f2f0)\n"
12940 " (declare (in ) uint y@0x142f400)\n"
12941 " )\n"
12942 " (\n"
12943 " ))\n"
12944 "\n"
12945 " (signature uvec3\n"
12946 " (parameters\n"
12947 " (declare (in ) uvec3 x@0x142f5e0)\n"
12948 " (declare (in ) uint y@0x142f6f0)\n"
12949 " )\n"
12950 " (\n"
12951 " ))\n"
12952 "\n"
12953 " (signature uvec4\n"
12954 " (parameters\n"
12955 " (declare (in ) uvec4 x@0x142f8d0)\n"
12956 " (declare (in ) uint y@0x142f9e0)\n"
12957 " )\n"
12958 " (\n"
12959 " ))\n"
12960 "\n"
12961 ")\n"
12962 "\n"
12963 "(function max\n"
12964 " (signature float\n"
12965 " (parameters\n"
12966 " (declare (in ) float x@0x142fbc0)\n"
12967 " (declare (in ) float y@0x142fcd0)\n"
12968 " )\n"
12969 " (\n"
12970 " ))\n"
12971 "\n"
12972 " (signature vec2\n"
12973 " (parameters\n"
12974 " (declare (in ) vec2 x@0x1430050)\n"
12975 " (declare (in ) vec2 y@0x1430160)\n"
12976 " )\n"
12977 " (\n"
12978 " ))\n"
12979 "\n"
12980 " (signature vec3\n"
12981 " (parameters\n"
12982 " (declare (in ) vec3 x@0x1430340)\n"
12983 " (declare (in ) vec3 y@0x1430450)\n"
12984 " )\n"
12985 " (\n"
12986 " ))\n"
12987 "\n"
12988 " (signature vec4\n"
12989 " (parameters\n"
12990 " (declare (in ) vec4 x@0x1430630)\n"
12991 " (declare (in ) vec4 y@0x1430740)\n"
12992 " )\n"
12993 " (\n"
12994 " ))\n"
12995 "\n"
12996 " (signature vec2\n"
12997 " (parameters\n"
12998 " (declare (in ) vec2 x@0x1430920)\n"
12999 " (declare (in ) float y@0x1430a30)\n"
13000 " )\n"
13001 " (\n"
13002 " ))\n"
13003 "\n"
13004 " (signature vec3\n"
13005 " (parameters\n"
13006 " (declare (in ) vec3 x@0x1430c10)\n"
13007 " (declare (in ) float y@0x1430d20)\n"
13008 " )\n"
13009 " (\n"
13010 " ))\n"
13011 "\n"
13012 " (signature vec4\n"
13013 " (parameters\n"
13014 " (declare (in ) vec4 x@0x1430f00)\n"
13015 " (declare (in ) float y@0x1431010)\n"
13016 " )\n"
13017 " (\n"
13018 " ))\n"
13019 "\n"
13020 " (signature int\n"
13021 " (parameters\n"
13022 " (declare (in ) int x@0x14311f0)\n"
13023 " (declare (in ) int y@0x1431300)\n"
13024 " )\n"
13025 " (\n"
13026 " ))\n"
13027 "\n"
13028 " (signature ivec2\n"
13029 " (parameters\n"
13030 " (declare (in ) ivec2 x@0x14314e0)\n"
13031 " (declare (in ) ivec2 y@0x14315f0)\n"
13032 " )\n"
13033 " (\n"
13034 " ))\n"
13035 "\n"
13036 " (signature ivec3\n"
13037 " (parameters\n"
13038 " (declare (in ) ivec3 x@0x14317d0)\n"
13039 " (declare (in ) ivec3 y@0x14318e0)\n"
13040 " )\n"
13041 " (\n"
13042 " ))\n"
13043 "\n"
13044 " (signature ivec4\n"
13045 " (parameters\n"
13046 " (declare (in ) ivec4 x@0x1431ac0)\n"
13047 " (declare (in ) ivec4 y@0x1431bd0)\n"
13048 " )\n"
13049 " (\n"
13050 " ))\n"
13051 "\n"
13052 " (signature ivec2\n"
13053 " (parameters\n"
13054 " (declare (in ) ivec2 x@0x1431db0)\n"
13055 " (declare (in ) int y@0x1431ec0)\n"
13056 " )\n"
13057 " (\n"
13058 " ))\n"
13059 "\n"
13060 " (signature ivec3\n"
13061 " (parameters\n"
13062 " (declare (in ) ivec3 x@0x14320a0)\n"
13063 " (declare (in ) int y@0x14321b0)\n"
13064 " )\n"
13065 " (\n"
13066 " ))\n"
13067 "\n"
13068 " (signature ivec4\n"
13069 " (parameters\n"
13070 " (declare (in ) ivec4 x@0x1432390)\n"
13071 " (declare (in ) int y@0x14324a0)\n"
13072 " )\n"
13073 " (\n"
13074 " ))\n"
13075 "\n"
13076 " (signature uint\n"
13077 " (parameters\n"
13078 " (declare (in ) uint x@0x1432680)\n"
13079 " (declare (in ) uint y@0x1432790)\n"
13080 " )\n"
13081 " (\n"
13082 " ))\n"
13083 "\n"
13084 " (signature uvec2\n"
13085 " (parameters\n"
13086 " (declare (in ) uvec2 x@0x1432970)\n"
13087 " (declare (in ) uvec2 y@0x1432a80)\n"
13088 " )\n"
13089 " (\n"
13090 " ))\n"
13091 "\n"
13092 " (signature uvec3\n"
13093 " (parameters\n"
13094 " (declare (in ) uvec3 x@0x1432c60)\n"
13095 " (declare (in ) uvec3 y@0x1432d70)\n"
13096 " )\n"
13097 " (\n"
13098 " ))\n"
13099 "\n"
13100 " (signature uvec4\n"
13101 " (parameters\n"
13102 " (declare (in ) uvec4 x@0x1432f50)\n"
13103 " (declare (in ) uvec4 y@0x1433060)\n"
13104 " )\n"
13105 " (\n"
13106 " ))\n"
13107 "\n"
13108 " (signature uvec2\n"
13109 " (parameters\n"
13110 " (declare (in ) uvec2 x@0x1433240)\n"
13111 " (declare (in ) uint y@0x1433350)\n"
13112 " )\n"
13113 " (\n"
13114 " ))\n"
13115 "\n"
13116 " (signature uvec3\n"
13117 " (parameters\n"
13118 " (declare (in ) uvec3 x@0x1433530)\n"
13119 " (declare (in ) uint y@0x1433640)\n"
13120 " )\n"
13121 " (\n"
13122 " ))\n"
13123 "\n"
13124 " (signature uvec4\n"
13125 " (parameters\n"
13126 " (declare (in ) uvec4 x@0x1433820)\n"
13127 " (declare (in ) uint y@0x1433930)\n"
13128 " )\n"
13129 " (\n"
13130 " ))\n"
13131 "\n"
13132 ")\n"
13133 "\n"
13134 "(function clamp\n"
13135 " (signature float\n"
13136 " (parameters\n"
13137 " (declare (in ) float x@0x1433b10)\n"
13138 " (declare (in ) float minVal@0x1433c20)\n"
13139 " (declare (in ) float maxVal@0x1433d30)\n"
13140 " )\n"
13141 " (\n"
13142 " ))\n"
13143 "\n"
13144 " (signature vec2\n"
13145 " (parameters\n"
13146 " (declare (in ) vec2 x@0x14340b0)\n"
13147 " (declare (in ) vec2 minVal@0x14341c0)\n"
13148 " (declare (in ) vec2 maxVal@0x14342d0)\n"
13149 " )\n"
13150 " (\n"
13151 " ))\n"
13152 "\n"
13153 " (signature vec3\n"
13154 " (parameters\n"
13155 " (declare (in ) vec3 x@0x14344b0)\n"
13156 " (declare (in ) vec3 minVal@0x14345c0)\n"
13157 " (declare (in ) vec3 maxVal@0x14346d0)\n"
13158 " )\n"
13159 " (\n"
13160 " ))\n"
13161 "\n"
13162 " (signature vec4\n"
13163 " (parameters\n"
13164 " (declare (in ) vec4 x@0x14348b0)\n"
13165 " (declare (in ) vec4 minVal@0x14349c0)\n"
13166 " (declare (in ) vec4 maxVal@0x1434ad0)\n"
13167 " )\n"
13168 " (\n"
13169 " ))\n"
13170 "\n"
13171 " (signature vec2\n"
13172 " (parameters\n"
13173 " (declare (in ) vec2 x@0x1434cb0)\n"
13174 " (declare (in ) float minVal@0x1434dc0)\n"
13175 " (declare (in ) float maxVal@0x1434ed0)\n"
13176 " )\n"
13177 " (\n"
13178 " ))\n"
13179 "\n"
13180 " (signature vec3\n"
13181 " (parameters\n"
13182 " (declare (in ) vec3 x@0x14350b0)\n"
13183 " (declare (in ) float minVal@0x14351c0)\n"
13184 " (declare (in ) float maxVal@0x14352d0)\n"
13185 " )\n"
13186 " (\n"
13187 " ))\n"
13188 "\n"
13189 " (signature vec4\n"
13190 " (parameters\n"
13191 " (declare (in ) vec4 x@0x14354b0)\n"
13192 " (declare (in ) float minVal@0x14355c0)\n"
13193 " (declare (in ) float maxVal@0x14356d0)\n"
13194 " )\n"
13195 " (\n"
13196 " ))\n"
13197 "\n"
13198 " (signature int\n"
13199 " (parameters\n"
13200 " (declare (in ) int x@0x14358b0)\n"
13201 " (declare (in ) int minVal@0x14359c0)\n"
13202 " (declare (in ) int maxVal@0x1435ad0)\n"
13203 " )\n"
13204 " (\n"
13205 " ))\n"
13206 "\n"
13207 " (signature ivec2\n"
13208 " (parameters\n"
13209 " (declare (in ) ivec2 x@0x1435cb0)\n"
13210 " (declare (in ) ivec2 minVal@0x1435dc0)\n"
13211 " (declare (in ) ivec2 maxVal@0x1435ed0)\n"
13212 " )\n"
13213 " (\n"
13214 " ))\n"
13215 "\n"
13216 " (signature ivec3\n"
13217 " (parameters\n"
13218 " (declare (in ) ivec3 x@0x14360b0)\n"
13219 " (declare (in ) ivec3 minVal@0x14361c0)\n"
13220 " (declare (in ) ivec3 maxVal@0x14362d0)\n"
13221 " )\n"
13222 " (\n"
13223 " ))\n"
13224 "\n"
13225 " (signature ivec4\n"
13226 " (parameters\n"
13227 " (declare (in ) ivec4 x@0x14364b0)\n"
13228 " (declare (in ) ivec4 minVal@0x14365c0)\n"
13229 " (declare (in ) ivec4 maxVal@0x14366d0)\n"
13230 " )\n"
13231 " (\n"
13232 " ))\n"
13233 "\n"
13234 " (signature ivec2\n"
13235 " (parameters\n"
13236 " (declare (in ) ivec2 x@0x14368b0)\n"
13237 " (declare (in ) int minVal@0x14369c0)\n"
13238 " (declare (in ) int maxVal@0x1436ad0)\n"
13239 " )\n"
13240 " (\n"
13241 " ))\n"
13242 "\n"
13243 " (signature ivec3\n"
13244 " (parameters\n"
13245 " (declare (in ) ivec3 x@0x1436cb0)\n"
13246 " (declare (in ) int minVal@0x1436dc0)\n"
13247 " (declare (in ) int maxVal@0x1436ed0)\n"
13248 " )\n"
13249 " (\n"
13250 " ))\n"
13251 "\n"
13252 " (signature ivec4\n"
13253 " (parameters\n"
13254 " (declare (in ) ivec4 x@0x14370b0)\n"
13255 " (declare (in ) int minVal@0x14371c0)\n"
13256 " (declare (in ) int maxVal@0x14372d0)\n"
13257 " )\n"
13258 " (\n"
13259 " ))\n"
13260 "\n"
13261 " (signature uint\n"
13262 " (parameters\n"
13263 " (declare (in ) uint x@0x14374b0)\n"
13264 " (declare (in ) uint minVal@0x14375c0)\n"
13265 " (declare (in ) uint maxVal@0x14376d0)\n"
13266 " )\n"
13267 " (\n"
13268 " ))\n"
13269 "\n"
13270 " (signature uvec2\n"
13271 " (parameters\n"
13272 " (declare (in ) uvec2 x@0x14378b0)\n"
13273 " (declare (in ) uvec2 minVal@0x14379c0)\n"
13274 " (declare (in ) uvec2 maxVal@0x1437ad0)\n"
13275 " )\n"
13276 " (\n"
13277 " ))\n"
13278 "\n"
13279 " (signature uvec3\n"
13280 " (parameters\n"
13281 " (declare (in ) uvec3 x@0x1437cb0)\n"
13282 " (declare (in ) uvec3 minVal@0x1437dc0)\n"
13283 " (declare (in ) uvec3 maxVal@0x1437ed0)\n"
13284 " )\n"
13285 " (\n"
13286 " ))\n"
13287 "\n"
13288 " (signature uvec4\n"
13289 " (parameters\n"
13290 " (declare (in ) uvec4 x@0x14380b0)\n"
13291 " (declare (in ) uvec4 minVal@0x14381c0)\n"
13292 " (declare (in ) uvec4 maxVal@0x14382d0)\n"
13293 " )\n"
13294 " (\n"
13295 " ))\n"
13296 "\n"
13297 " (signature uvec2\n"
13298 " (parameters\n"
13299 " (declare (in ) uvec2 x@0x14384b0)\n"
13300 " (declare (in ) uint minVal@0x14385c0)\n"
13301 " (declare (in ) uint maxVal@0x14386d0)\n"
13302 " )\n"
13303 " (\n"
13304 " ))\n"
13305 "\n"
13306 " (signature uvec3\n"
13307 " (parameters\n"
13308 " (declare (in ) uvec3 x@0x14388b0)\n"
13309 " (declare (in ) uint minVal@0x14389c0)\n"
13310 " (declare (in ) uint maxVal@0x1438ad0)\n"
13311 " )\n"
13312 " (\n"
13313 " ))\n"
13314 "\n"
13315 " (signature uvec4\n"
13316 " (parameters\n"
13317 " (declare (in ) uvec4 x@0x1438cb0)\n"
13318 " (declare (in ) uint minVal@0x1438dc0)\n"
13319 " (declare (in ) uint maxVal@0x1438ed0)\n"
13320 " )\n"
13321 " (\n"
13322 " ))\n"
13323 "\n"
13324 ")\n"
13325 "\n"
13326 "(function mix\n"
13327 " (signature float\n"
13328 " (parameters\n"
13329 " (declare (in ) float x@0x14390b0)\n"
13330 " (declare (in ) float y@0x14391c0)\n"
13331 " (declare (in ) float a@0x14392d0)\n"
13332 " )\n"
13333 " (\n"
13334 " ))\n"
13335 "\n"
13336 " (signature vec2\n"
13337 " (parameters\n"
13338 " (declare (in ) vec2 x@0x1439650)\n"
13339 " (declare (in ) vec2 y@0x1439760)\n"
13340 " (declare (in ) vec2 a@0x1439870)\n"
13341 " )\n"
13342 " (\n"
13343 " ))\n"
13344 "\n"
13345 " (signature vec3\n"
13346 " (parameters\n"
13347 " (declare (in ) vec3 x@0x1439a50)\n"
13348 " (declare (in ) vec3 y@0x1439b60)\n"
13349 " (declare (in ) vec3 a@0x1439c70)\n"
13350 " )\n"
13351 " (\n"
13352 " ))\n"
13353 "\n"
13354 " (signature vec4\n"
13355 " (parameters\n"
13356 " (declare (in ) vec4 x@0x1439e50)\n"
13357 " (declare (in ) vec4 y@0x1439f60)\n"
13358 " (declare (in ) vec4 a@0x143a070)\n"
13359 " )\n"
13360 " (\n"
13361 " ))\n"
13362 "\n"
13363 " (signature vec2\n"
13364 " (parameters\n"
13365 " (declare (in ) vec2 x@0x143a250)\n"
13366 " (declare (in ) vec2 y@0x143a360)\n"
13367 " (declare (in ) float a@0x143a470)\n"
13368 " )\n"
13369 " (\n"
13370 " ))\n"
13371 "\n"
13372 " (signature vec3\n"
13373 " (parameters\n"
13374 " (declare (in ) vec3 x@0x143a650)\n"
13375 " (declare (in ) vec3 y@0x143a760)\n"
13376 " (declare (in ) float a@0x143a870)\n"
13377 " )\n"
13378 " (\n"
13379 " ))\n"
13380 "\n"
13381 " (signature vec4\n"
13382 " (parameters\n"
13383 " (declare (in ) vec4 x@0x143aa50)\n"
13384 " (declare (in ) vec4 y@0x143ab60)\n"
13385 " (declare (in ) float a@0x143ac70)\n"
13386 " )\n"
13387 " (\n"
13388 " ))\n"
13389 "\n"
13390 ")\n"
13391 "\n"
13392 "(function step\n"
13393 " (signature float\n"
13394 " (parameters\n"
13395 " (declare (in ) float edge@0x143ae50)\n"
13396 " (declare (in ) float x@0x143af60)\n"
13397 " )\n"
13398 " (\n"
13399 " ))\n"
13400 "\n"
13401 " (signature vec2\n"
13402 " (parameters\n"
13403 " (declare (in ) vec2 edge@0x143b2e0)\n"
13404 " (declare (in ) vec2 x@0x143b3f0)\n"
13405 " )\n"
13406 " (\n"
13407 " ))\n"
13408 "\n"
13409 " (signature vec3\n"
13410 " (parameters\n"
13411 " (declare (in ) vec3 edge@0x143b5d0)\n"
13412 " (declare (in ) vec3 x@0x143b6e0)\n"
13413 " )\n"
13414 " (\n"
13415 " ))\n"
13416 "\n"
13417 " (signature vec4\n"
13418 " (parameters\n"
13419 " (declare (in ) vec4 edge@0x143b8c0)\n"
13420 " (declare (in ) vec4 x@0x143b9d0)\n"
13421 " )\n"
13422 " (\n"
13423 " ))\n"
13424 "\n"
13425 " (signature vec2\n"
13426 " (parameters\n"
13427 " (declare (in ) float edge@0x143bbb0)\n"
13428 " (declare (in ) vec2 x@0x143bcc0)\n"
13429 " )\n"
13430 " (\n"
13431 " ))\n"
13432 "\n"
13433 " (signature vec3\n"
13434 " (parameters\n"
13435 " (declare (in ) float edge@0x143bea0)\n"
13436 " (declare (in ) vec3 x@0x143bfb0)\n"
13437 " )\n"
13438 " (\n"
13439 " ))\n"
13440 "\n"
13441 " (signature vec4\n"
13442 " (parameters\n"
13443 " (declare (in ) float edge@0x143c190)\n"
13444 " (declare (in ) vec4 x@0x143c2a0)\n"
13445 " )\n"
13446 " (\n"
13447 " ))\n"
13448 "\n"
13449 ")\n"
13450 "\n"
13451 "(function smoothstep\n"
13452 " (signature float\n"
13453 " (parameters\n"
13454 " (declare (in ) float edge0@0x143c480)\n"
13455 " (declare (in ) float edge1@0x143c590)\n"
13456 " (declare (in ) float x@0x143c6a0)\n"
13457 " )\n"
13458 " (\n"
13459 " ))\n"
13460 "\n"
13461 " (signature vec2\n"
13462 " (parameters\n"
13463 " (declare (in ) vec2 edge0@0x143ca30)\n"
13464 " (declare (in ) vec2 edge1@0x143cb40)\n"
13465 " (declare (in ) vec2 x@0x143cc50)\n"
13466 " )\n"
13467 " (\n"
13468 " ))\n"
13469 "\n"
13470 " (signature vec3\n"
13471 " (parameters\n"
13472 " (declare (in ) vec3 edge0@0x143ce30)\n"
13473 " (declare (in ) vec3 edge1@0x143cf40)\n"
13474 " (declare (in ) vec3 x@0x143d050)\n"
13475 " )\n"
13476 " (\n"
13477 " ))\n"
13478 "\n"
13479 " (signature vec4\n"
13480 " (parameters\n"
13481 " (declare (in ) vec4 edge0@0x143d230)\n"
13482 " (declare (in ) vec4 edge1@0x143d340)\n"
13483 " (declare (in ) vec4 x@0x143d450)\n"
13484 " )\n"
13485 " (\n"
13486 " ))\n"
13487 "\n"
13488 " (signature vec2\n"
13489 " (parameters\n"
13490 " (declare (in ) float edge0@0x143d630)\n"
13491 " (declare (in ) float edge1@0x143d740)\n"
13492 " (declare (in ) vec2 x@0x143d850)\n"
13493 " )\n"
13494 " (\n"
13495 " ))\n"
13496 "\n"
13497 " (signature vec3\n"
13498 " (parameters\n"
13499 " (declare (in ) float edge0@0x143da30)\n"
13500 " (declare (in ) float edge1@0x143db40)\n"
13501 " (declare (in ) vec3 x@0x143dc50)\n"
13502 " )\n"
13503 " (\n"
13504 " ))\n"
13505 "\n"
13506 " (signature vec4\n"
13507 " (parameters\n"
13508 " (declare (in ) float edge0@0x143de30)\n"
13509 " (declare (in ) float edge1@0x143df40)\n"
13510 " (declare (in ) vec4 x@0x143e050)\n"
13511 " )\n"
13512 " (\n"
13513 " ))\n"
13514 "\n"
13515 ")\n"
13516 "\n"
13517 "(function length\n"
13518 " (signature float\n"
13519 " (parameters\n"
13520 " (declare (in ) float x@0x143e230)\n"
13521 " )\n"
13522 " (\n"
13523 " ))\n"
13524 "\n"
13525 " (signature float\n"
13526 " (parameters\n"
13527 " (declare (in ) vec2 x@0x143e5b0)\n"
13528 " )\n"
13529 " (\n"
13530 " ))\n"
13531 "\n"
13532 " (signature float\n"
13533 " (parameters\n"
13534 " (declare (in ) vec3 x@0x143e790)\n"
13535 " )\n"
13536 " (\n"
13537 " ))\n"
13538 "\n"
13539 " (signature float\n"
13540 " (parameters\n"
13541 " (declare (in ) vec4 x@0x143e970)\n"
13542 " )\n"
13543 " (\n"
13544 " ))\n"
13545 "\n"
13546 ")\n"
13547 "\n"
13548 "(function distance\n"
13549 " (signature float\n"
13550 " (parameters\n"
13551 " (declare (in ) float p0@0x143eb50)\n"
13552 " (declare (in ) float p1@0x143ec60)\n"
13553 " )\n"
13554 " (\n"
13555 " ))\n"
13556 "\n"
13557 " (signature float\n"
13558 " (parameters\n"
13559 " (declare (in ) vec2 p0@0x143eff0)\n"
13560 " (declare (in ) vec2 p1@0x143f100)\n"
13561 " )\n"
13562 " (\n"
13563 " ))\n"
13564 "\n"
13565 " (signature float\n"
13566 " (parameters\n"
13567 " (declare (in ) vec3 p0@0x143f2e0)\n"
13568 " (declare (in ) vec3 p1@0x143f3f0)\n"
13569 " )\n"
13570 " (\n"
13571 " ))\n"
13572 "\n"
13573 " (signature float\n"
13574 " (parameters\n"
13575 " (declare (in ) vec4 p0@0x143f5d0)\n"
13576 " (declare (in ) vec4 p1@0x143f6e0)\n"
13577 " )\n"
13578 " (\n"
13579 " ))\n"
13580 "\n"
13581 ")\n"
13582 "\n"
13583 "(function dot\n"
13584 " (signature float\n"
13585 " (parameters\n"
13586 " (declare (in ) float x@0x143f8c0)\n"
13587 " (declare (in ) float y@0x143f9d0)\n"
13588 " )\n"
13589 " (\n"
13590 " ))\n"
13591 "\n"
13592 " (signature float\n"
13593 " (parameters\n"
13594 " (declare (in ) vec2 x@0x143fd50)\n"
13595 " (declare (in ) vec2 y@0x143fe60)\n"
13596 " )\n"
13597 " (\n"
13598 " ))\n"
13599 "\n"
13600 " (signature float\n"
13601 " (parameters\n"
13602 " (declare (in ) vec3 x@0x1440040)\n"
13603 " (declare (in ) vec3 y@0x1440150)\n"
13604 " )\n"
13605 " (\n"
13606 " ))\n"
13607 "\n"
13608 " (signature float\n"
13609 " (parameters\n"
13610 " (declare (in ) vec4 x@0x1440330)\n"
13611 " (declare (in ) vec4 y@0x1440440)\n"
13612 " )\n"
13613 " (\n"
13614 " ))\n"
13615 "\n"
13616 ")\n"
13617 "\n"
13618 "(function cross\n"
13619 " (signature vec3\n"
13620 " (parameters\n"
13621 " (declare (in ) vec3 x@0x1440620)\n"
13622 " (declare (in ) vec3 y@0x1440730)\n"
13623 " )\n"
13624 " (\n"
13625 " ))\n"
13626 "\n"
13627 ")\n"
13628 "\n"
13629 "(function normalize\n"
13630 " (signature float\n"
13631 " (parameters\n"
13632 " (declare (in ) float x@0x1440ab0)\n"
13633 " )\n"
13634 " (\n"
13635 " ))\n"
13636 "\n"
13637 " (signature vec2\n"
13638 " (parameters\n"
13639 " (declare (in ) vec2 x@0x1440e40)\n"
13640 " )\n"
13641 " (\n"
13642 " ))\n"
13643 "\n"
13644 " (signature vec3\n"
13645 " (parameters\n"
13646 " (declare (in ) vec3 x@0x1441020)\n"
13647 " )\n"
13648 " (\n"
13649 " ))\n"
13650 "\n"
13651 " (signature vec4\n"
13652 " (parameters\n"
13653 " (declare (in ) vec4 x@0x1441200)\n"
13654 " )\n"
13655 " (\n"
13656 " ))\n"
13657 "\n"
13658 ")\n"
13659 "\n"
13660 "(function faceforward\n"
13661 " (signature float\n"
13662 " (parameters\n"
13663 " (declare (in ) float N@0x14413e0)\n"
13664 " (declare (in ) float I@0x14414f0)\n"
13665 " (declare (in ) float Nref@0x1441600)\n"
13666 " )\n"
13667 " (\n"
13668 " ))\n"
13669 "\n"
13670 " (signature vec2\n"
13671 " (parameters\n"
13672 " (declare (in ) vec2 N@0x1441990)\n"
13673 " (declare (in ) vec2 I@0x1441aa0)\n"
13674 " (declare (in ) vec2 Nref@0x1441bb0)\n"
13675 " )\n"
13676 " (\n"
13677 " ))\n"
13678 "\n"
13679 " (signature vec3\n"
13680 " (parameters\n"
13681 " (declare (in ) vec3 N@0x1441d90)\n"
13682 " (declare (in ) vec3 I@0x1441ea0)\n"
13683 " (declare (in ) vec3 Nref@0x1441fb0)\n"
13684 " )\n"
13685 " (\n"
13686 " ))\n"
13687 "\n"
13688 " (signature vec4\n"
13689 " (parameters\n"
13690 " (declare (in ) vec4 N@0x1442190)\n"
13691 " (declare (in ) vec4 I@0x14422a0)\n"
13692 " (declare (in ) vec4 Nref@0x14423b0)\n"
13693 " )\n"
13694 " (\n"
13695 " ))\n"
13696 "\n"
13697 ")\n"
13698 "\n"
13699 "(function reflect\n"
13700 " (signature float\n"
13701 " (parameters\n"
13702 " (declare (in ) float I@0x1442590)\n"
13703 " (declare (in ) float N@0x14426a0)\n"
13704 " )\n"
13705 " (\n"
13706 " ))\n"
13707 "\n"
13708 " (signature vec2\n"
13709 " (parameters\n"
13710 " (declare (in ) vec2 I@0x1442a20)\n"
13711 " (declare (in ) vec2 N@0x1442b30)\n"
13712 " )\n"
13713 " (\n"
13714 " ))\n"
13715 "\n"
13716 " (signature vec3\n"
13717 " (parameters\n"
13718 " (declare (in ) vec3 I@0x1442d10)\n"
13719 " (declare (in ) vec3 N@0x1442e20)\n"
13720 " )\n"
13721 " (\n"
13722 " ))\n"
13723 "\n"
13724 " (signature vec4\n"
13725 " (parameters\n"
13726 " (declare (in ) vec4 I@0x1443000)\n"
13727 " (declare (in ) vec4 N@0x1443110)\n"
13728 " )\n"
13729 " (\n"
13730 " ))\n"
13731 "\n"
13732 ")\n"
13733 "\n"
13734 "(function refract\n"
13735 " (signature float\n"
13736 " (parameters\n"
13737 " (declare (in ) float I@0x14432f0)\n"
13738 " (declare (in ) float N@0x1443400)\n"
13739 " (declare (in ) float eta@0x1443510)\n"
13740 " )\n"
13741 " (\n"
13742 " ))\n"
13743 "\n"
13744 " (signature vec2\n"
13745 " (parameters\n"
13746 " (declare (in ) vec2 I@0x1443890)\n"
13747 " (declare (in ) vec2 N@0x14439a0)\n"
13748 " (declare (in ) float eta@0x1443ab0)\n"
13749 " )\n"
13750 " (\n"
13751 " ))\n"
13752 "\n"
13753 " (signature vec3\n"
13754 " (parameters\n"
13755 " (declare (in ) vec3 I@0x1443c90)\n"
13756 " (declare (in ) vec3 N@0x1443da0)\n"
13757 " (declare (in ) float eta@0x1443eb0)\n"
13758 " )\n"
13759 " (\n"
13760 " ))\n"
13761 "\n"
13762 " (signature vec4\n"
13763 " (parameters\n"
13764 " (declare (in ) vec4 I@0x1444090)\n"
13765 " (declare (in ) vec4 N@0x14441a0)\n"
13766 " (declare (in ) float eta@0x14442b0)\n"
13767 " )\n"
13768 " (\n"
13769 " ))\n"
13770 "\n"
13771 ")\n"
13772 "\n"
13773 "(function matrixCompMult\n"
13774 " (signature mat2\n"
13775 " (parameters\n"
13776 " (declare (in ) mat2 x@0x1444490)\n"
13777 " (declare (in ) mat2 y@0x14445a0)\n"
13778 " )\n"
13779 " (\n"
13780 " ))\n"
13781 "\n"
13782 " (signature mat3\n"
13783 " (parameters\n"
13784 " (declare (in ) mat3 x@0x1444930)\n"
13785 " (declare (in ) mat3 y@0x1444a40)\n"
13786 " )\n"
13787 " (\n"
13788 " ))\n"
13789 "\n"
13790 " (signature mat4\n"
13791 " (parameters\n"
13792 " (declare (in ) mat4 x@0x1444c20)\n"
13793 " (declare (in ) mat4 y@0x1444d30)\n"
13794 " )\n"
13795 " (\n"
13796 " ))\n"
13797 "\n"
13798 " (signature mat2x3\n"
13799 " (parameters\n"
13800 " (declare (in ) mat2x3 x@0x1444f10)\n"
13801 " (declare (in ) mat2x3 y@0x1445020)\n"
13802 " )\n"
13803 " (\n"
13804 " ))\n"
13805 "\n"
13806 " (signature mat2x4\n"
13807 " (parameters\n"
13808 " (declare (in ) mat2x4 x@0x1445200)\n"
13809 " (declare (in ) mat2x4 y@0x1445310)\n"
13810 " )\n"
13811 " (\n"
13812 " ))\n"
13813 "\n"
13814 " (signature mat3x2\n"
13815 " (parameters\n"
13816 " (declare (in ) mat3x2 x@0x14454f0)\n"
13817 " (declare (in ) mat3x2 y@0x1445600)\n"
13818 " )\n"
13819 " (\n"
13820 " ))\n"
13821 "\n"
13822 " (signature mat3x4\n"
13823 " (parameters\n"
13824 " (declare (in ) mat3x4 x@0x14457e0)\n"
13825 " (declare (in ) mat3x4 y@0x14458f0)\n"
13826 " )\n"
13827 " (\n"
13828 " ))\n"
13829 "\n"
13830 " (signature mat4x2\n"
13831 " (parameters\n"
13832 " (declare (in ) mat4x2 x@0x1445ad0)\n"
13833 " (declare (in ) mat4x2 y@0x1445be0)\n"
13834 " )\n"
13835 " (\n"
13836 " ))\n"
13837 "\n"
13838 " (signature mat4x3\n"
13839 " (parameters\n"
13840 " (declare (in ) mat4x3 x@0x1445dc0)\n"
13841 " (declare (in ) mat4x3 y@0x1445ed0)\n"
13842 " )\n"
13843 " (\n"
13844 " ))\n"
13845 "\n"
13846 ")\n"
13847 "\n"
13848 "(function outerProduct\n"
13849 " (signature mat2\n"
13850 " (parameters\n"
13851 " (declare (in ) vec2 c@0x14460b0)\n"
13852 " (declare (in ) vec2 r@0x14461c0)\n"
13853 " )\n"
13854 " (\n"
13855 " ))\n"
13856 "\n"
13857 " (signature mat3\n"
13858 " (parameters\n"
13859 " (declare (in ) vec3 c@0x1446550)\n"
13860 " (declare (in ) vec3 r@0x1446660)\n"
13861 " )\n"
13862 " (\n"
13863 " ))\n"
13864 "\n"
13865 " (signature mat4\n"
13866 " (parameters\n"
13867 " (declare (in ) vec4 c@0x1446840)\n"
13868 " (declare (in ) vec4 r@0x1446950)\n"
13869 " )\n"
13870 " (\n"
13871 " ))\n"
13872 "\n"
13873 " (signature mat2x3\n"
13874 " (parameters\n"
13875 " (declare (in ) vec3 c@0x1446b30)\n"
13876 " (declare (in ) vec2 r@0x1446c40)\n"
13877 " )\n"
13878 " (\n"
13879 " ))\n"
13880 "\n"
13881 " (signature mat3x2\n"
13882 " (parameters\n"
13883 " (declare (in ) vec2 c@0x1446e20)\n"
13884 " (declare (in ) vec3 r@0x1446f30)\n"
13885 " )\n"
13886 " (\n"
13887 " ))\n"
13888 "\n"
13889 " (signature mat2x4\n"
13890 " (parameters\n"
13891 " (declare (in ) vec4 c@0x1447110)\n"
13892 " (declare (in ) vec2 r@0x1447220)\n"
13893 " )\n"
13894 " (\n"
13895 " ))\n"
13896 "\n"
13897 " (signature mat4x2\n"
13898 " (parameters\n"
13899 " (declare (in ) vec2 c@0x1447400)\n"
13900 " (declare (in ) vec4 r@0x1447510)\n"
13901 " )\n"
13902 " (\n"
13903 " ))\n"
13904 "\n"
13905 " (signature mat3x4\n"
13906 " (parameters\n"
13907 " (declare (in ) vec4 c@0x14476f0)\n"
13908 " (declare (in ) vec3 r@0x1447800)\n"
13909 " )\n"
13910 " (\n"
13911 " ))\n"
13912 "\n"
13913 " (signature mat4x3\n"
13914 " (parameters\n"
13915 " (declare (in ) vec3 c@0x14479e0)\n"
13916 " (declare (in ) vec4 r@0x1447af0)\n"
13917 " )\n"
13918 " (\n"
13919 " ))\n"
13920 "\n"
13921 ")\n"
13922 "\n"
13923 "(function transpose\n"
13924 " (signature mat2\n"
13925 " (parameters\n"
13926 " (declare (in ) mat2 m@0x1447cd0)\n"
13927 " )\n"
13928 " (\n"
13929 " ))\n"
13930 "\n"
13931 " (signature mat3\n"
13932 " (parameters\n"
13933 " (declare (in ) mat3 m@0x1448060)\n"
13934 " )\n"
13935 " (\n"
13936 " ))\n"
13937 "\n"
13938 " (signature mat4\n"
13939 " (parameters\n"
13940 " (declare (in ) mat4 m@0x1448240)\n"
13941 " )\n"
13942 " (\n"
13943 " ))\n"
13944 "\n"
13945 " (signature mat2x3\n"
13946 " (parameters\n"
13947 " (declare (in ) mat3x2 m@0x1448420)\n"
13948 " )\n"
13949 " (\n"
13950 " ))\n"
13951 "\n"
13952 " (signature mat3x2\n"
13953 " (parameters\n"
13954 " (declare (in ) mat2x3 m@0x1448600)\n"
13955 " )\n"
13956 " (\n"
13957 " ))\n"
13958 "\n"
13959 " (signature mat2x4\n"
13960 " (parameters\n"
13961 " (declare (in ) mat4x2 m@0x14487e0)\n"
13962 " )\n"
13963 " (\n"
13964 " ))\n"
13965 "\n"
13966 " (signature mat4x2\n"
13967 " (parameters\n"
13968 " (declare (in ) mat2x4 m@0x14489c0)\n"
13969 " )\n"
13970 " (\n"
13971 " ))\n"
13972 "\n"
13973 " (signature mat3x4\n"
13974 " (parameters\n"
13975 " (declare (in ) mat4x3 m@0x1448ba0)\n"
13976 " )\n"
13977 " (\n"
13978 " ))\n"
13979 "\n"
13980 " (signature mat4x3\n"
13981 " (parameters\n"
13982 " (declare (in ) mat3x4 m@0x1448d80)\n"
13983 " )\n"
13984 " (\n"
13985 " ))\n"
13986 "\n"
13987 ")\n"
13988 "\n"
13989 "(function lessThan\n"
13990 " (signature bvec2\n"
13991 " (parameters\n"
13992 " (declare (in ) vec2 x@0x1448f60)\n"
13993 " (declare (in ) vec2 y@0x1449070)\n"
13994 " )\n"
13995 " (\n"
13996 " ))\n"
13997 "\n"
13998 " (signature bvec3\n"
13999 " (parameters\n"
14000 " (declare (in ) vec3 x@0x1449400)\n"
14001 " (declare (in ) vec3 y@0x1449510)\n"
14002 " )\n"
14003 " (\n"
14004 " ))\n"
14005 "\n"
14006 " (signature bvec4\n"
14007 " (parameters\n"
14008 " (declare (in ) vec4 x@0x14496f0)\n"
14009 " (declare (in ) vec4 y@0x1449800)\n"
14010 " )\n"
14011 " (\n"
14012 " ))\n"
14013 "\n"
14014 " (signature bvec2\n"
14015 " (parameters\n"
14016 " (declare (in ) ivec2 x@0x14499e0)\n"
14017 " (declare (in ) ivec2 y@0x1449af0)\n"
14018 " )\n"
14019 " (\n"
14020 " ))\n"
14021 "\n"
14022 " (signature bvec3\n"
14023 " (parameters\n"
14024 " (declare (in ) ivec3 x@0x1449cd0)\n"
14025 " (declare (in ) ivec3 y@0x1449de0)\n"
14026 " )\n"
14027 " (\n"
14028 " ))\n"
14029 "\n"
14030 " (signature bvec4\n"
14031 " (parameters\n"
14032 " (declare (in ) ivec4 x@0x1449fc0)\n"
14033 " (declare (in ) ivec4 y@0x144a0d0)\n"
14034 " )\n"
14035 " (\n"
14036 " ))\n"
14037 "\n"
14038 " (signature bvec2\n"
14039 " (parameters\n"
14040 " (declare (in ) uvec2 x@0x144a2b0)\n"
14041 " (declare (in ) uvec2 y@0x144a3c0)\n"
14042 " )\n"
14043 " (\n"
14044 " ))\n"
14045 "\n"
14046 " (signature bvec3\n"
14047 " (parameters\n"
14048 " (declare (in ) uvec3 x@0x144a5a0)\n"
14049 " (declare (in ) uvec3 y@0x144a6b0)\n"
14050 " )\n"
14051 " (\n"
14052 " ))\n"
14053 "\n"
14054 " (signature bvec4\n"
14055 " (parameters\n"
14056 " (declare (in ) uvec4 x@0x144a890)\n"
14057 " (declare (in ) uvec4 y@0x144a9a0)\n"
14058 " )\n"
14059 " (\n"
14060 " ))\n"
14061 "\n"
14062 ")\n"
14063 "\n"
14064 "(function lessThanEqual\n"
14065 " (signature bvec2\n"
14066 " (parameters\n"
14067 " (declare (in ) vec2 x@0x144ab80)\n"
14068 " (declare (in ) vec2 y@0x144ac90)\n"
14069 " )\n"
14070 " (\n"
14071 " ))\n"
14072 "\n"
14073 " (signature bvec3\n"
14074 " (parameters\n"
14075 " (declare (in ) vec3 x@0x144b020)\n"
14076 " (declare (in ) vec3 y@0x144b130)\n"
14077 " )\n"
14078 " (\n"
14079 " ))\n"
14080 "\n"
14081 " (signature bvec4\n"
14082 " (parameters\n"
14083 " (declare (in ) vec4 x@0x144b310)\n"
14084 " (declare (in ) vec4 y@0x144b420)\n"
14085 " )\n"
14086 " (\n"
14087 " ))\n"
14088 "\n"
14089 " (signature bvec2\n"
14090 " (parameters\n"
14091 " (declare (in ) ivec2 x@0x144b600)\n"
14092 " (declare (in ) ivec2 y@0x144b710)\n"
14093 " )\n"
14094 " (\n"
14095 " ))\n"
14096 "\n"
14097 " (signature bvec3\n"
14098 " (parameters\n"
14099 " (declare (in ) ivec3 x@0x144b8f0)\n"
14100 " (declare (in ) ivec3 y@0x144ba00)\n"
14101 " )\n"
14102 " (\n"
14103 " ))\n"
14104 "\n"
14105 " (signature bvec4\n"
14106 " (parameters\n"
14107 " (declare (in ) ivec4 x@0x144bbe0)\n"
14108 " (declare (in ) ivec4 y@0x144bcf0)\n"
14109 " )\n"
14110 " (\n"
14111 " ))\n"
14112 "\n"
14113 " (signature bvec2\n"
14114 " (parameters\n"
14115 " (declare (in ) uvec2 x@0x144bed0)\n"
14116 " (declare (in ) uvec2 y@0x144bfe0)\n"
14117 " )\n"
14118 " (\n"
14119 " ))\n"
14120 "\n"
14121 " (signature bvec3\n"
14122 " (parameters\n"
14123 " (declare (in ) uvec3 x@0x144c1c0)\n"
14124 " (declare (in ) uvec3 y@0x144c2d0)\n"
14125 " )\n"
14126 " (\n"
14127 " ))\n"
14128 "\n"
14129 " (signature bvec4\n"
14130 " (parameters\n"
14131 " (declare (in ) uvec4 x@0x144c4b0)\n"
14132 " (declare (in ) uvec4 y@0x144c5c0)\n"
14133 " )\n"
14134 " (\n"
14135 " ))\n"
14136 "\n"
14137 ")\n"
14138 "\n"
14139 "(function greaterThan\n"
14140 " (signature bvec2\n"
14141 " (parameters\n"
14142 " (declare (in ) vec2 x@0x144c7a0)\n"
14143 " (declare (in ) vec2 y@0x144c8b0)\n"
14144 " )\n"
14145 " (\n"
14146 " ))\n"
14147 "\n"
14148 " (signature bvec3\n"
14149 " (parameters\n"
14150 " (declare (in ) vec3 x@0x144cc40)\n"
14151 " (declare (in ) vec3 y@0x144cd50)\n"
14152 " )\n"
14153 " (\n"
14154 " ))\n"
14155 "\n"
14156 " (signature bvec4\n"
14157 " (parameters\n"
14158 " (declare (in ) vec4 x@0x144cf30)\n"
14159 " (declare (in ) vec4 y@0x144d040)\n"
14160 " )\n"
14161 " (\n"
14162 " ))\n"
14163 "\n"
14164 " (signature bvec2\n"
14165 " (parameters\n"
14166 " (declare (in ) ivec2 x@0x144d220)\n"
14167 " (declare (in ) ivec2 y@0x144d330)\n"
14168 " )\n"
14169 " (\n"
14170 " ))\n"
14171 "\n"
14172 " (signature bvec3\n"
14173 " (parameters\n"
14174 " (declare (in ) ivec3 x@0x144d510)\n"
14175 " (declare (in ) ivec3 y@0x144d620)\n"
14176 " )\n"
14177 " (\n"
14178 " ))\n"
14179 "\n"
14180 " (signature bvec4\n"
14181 " (parameters\n"
14182 " (declare (in ) ivec4 x@0x144d800)\n"
14183 " (declare (in ) ivec4 y@0x144d910)\n"
14184 " )\n"
14185 " (\n"
14186 " ))\n"
14187 "\n"
14188 " (signature bvec2\n"
14189 " (parameters\n"
14190 " (declare (in ) uvec2 x@0x144daf0)\n"
14191 " (declare (in ) uvec2 y@0x144dc00)\n"
14192 " )\n"
14193 " (\n"
14194 " ))\n"
14195 "\n"
14196 " (signature bvec3\n"
14197 " (parameters\n"
14198 " (declare (in ) uvec3 x@0x144dde0)\n"
14199 " (declare (in ) uvec3 y@0x144def0)\n"
14200 " )\n"
14201 " (\n"
14202 " ))\n"
14203 "\n"
14204 " (signature bvec4\n"
14205 " (parameters\n"
14206 " (declare (in ) uvec4 x@0x144e0d0)\n"
14207 " (declare (in ) uvec4 y@0x144e1e0)\n"
14208 " )\n"
14209 " (\n"
14210 " ))\n"
14211 "\n"
14212 ")\n"
14213 "\n"
14214 "(function greaterThanEqual\n"
14215 " (signature bvec2\n"
14216 " (parameters\n"
14217 " (declare (in ) vec2 x@0x144e3c0)\n"
14218 " (declare (in ) vec2 y@0x144e4d0)\n"
14219 " )\n"
14220 " (\n"
14221 " ))\n"
14222 "\n"
14223 " (signature bvec3\n"
14224 " (parameters\n"
14225 " (declare (in ) vec3 x@0x144e860)\n"
14226 " (declare (in ) vec3 y@0x144e970)\n"
14227 " )\n"
14228 " (\n"
14229 " ))\n"
14230 "\n"
14231 " (signature bvec4\n"
14232 " (parameters\n"
14233 " (declare (in ) vec4 x@0x144eb50)\n"
14234 " (declare (in ) vec4 y@0x144ec60)\n"
14235 " )\n"
14236 " (\n"
14237 " ))\n"
14238 "\n"
14239 " (signature bvec2\n"
14240 " (parameters\n"
14241 " (declare (in ) ivec2 x@0x144ee40)\n"
14242 " (declare (in ) ivec2 y@0x144ef50)\n"
14243 " )\n"
14244 " (\n"
14245 " ))\n"
14246 "\n"
14247 " (signature bvec3\n"
14248 " (parameters\n"
14249 " (declare (in ) ivec3 x@0x144f130)\n"
14250 " (declare (in ) ivec3 y@0x144f240)\n"
14251 " )\n"
14252 " (\n"
14253 " ))\n"
14254 "\n"
14255 " (signature bvec4\n"
14256 " (parameters\n"
14257 " (declare (in ) ivec4 x@0x144f420)\n"
14258 " (declare (in ) ivec4 y@0x144f530)\n"
14259 " )\n"
14260 " (\n"
14261 " ))\n"
14262 "\n"
14263 " (signature bvec2\n"
14264 " (parameters\n"
14265 " (declare (in ) uvec2 x@0x144f710)\n"
14266 " (declare (in ) uvec2 y@0x144f820)\n"
14267 " )\n"
14268 " (\n"
14269 " ))\n"
14270 "\n"
14271 " (signature bvec3\n"
14272 " (parameters\n"
14273 " (declare (in ) uvec3 x@0x144fa00)\n"
14274 " (declare (in ) uvec3 y@0x144fb10)\n"
14275 " )\n"
14276 " (\n"
14277 " ))\n"
14278 "\n"
14279 " (signature bvec4\n"
14280 " (parameters\n"
14281 " (declare (in ) uvec4 x@0x144fcf0)\n"
14282 " (declare (in ) uvec4 y@0x144fe00)\n"
14283 " )\n"
14284 " (\n"
14285 " ))\n"
14286 "\n"
14287 ")\n"
14288 "\n"
14289 "(function equal\n"
14290 " (signature bvec2\n"
14291 " (parameters\n"
14292 " (declare (in ) vec2 x@0x144ffe0)\n"
14293 " (declare (in ) vec2 y@0x14500f0)\n"
14294 " )\n"
14295 " (\n"
14296 " ))\n"
14297 "\n"
14298 " (signature bvec3\n"
14299 " (parameters\n"
14300 " (declare (in ) vec3 x@0x1450470)\n"
14301 " (declare (in ) vec3 y@0x1450580)\n"
14302 " )\n"
14303 " (\n"
14304 " ))\n"
14305 "\n"
14306 " (signature bvec4\n"
14307 " (parameters\n"
14308 " (declare (in ) vec4 x@0x1450760)\n"
14309 " (declare (in ) vec4 y@0x1450870)\n"
14310 " )\n"
14311 " (\n"
14312 " ))\n"
14313 "\n"
14314 " (signature bvec2\n"
14315 " (parameters\n"
14316 " (declare (in ) ivec2 x@0x1450a50)\n"
14317 " (declare (in ) ivec2 y@0x1450b60)\n"
14318 " )\n"
14319 " (\n"
14320 " ))\n"
14321 "\n"
14322 " (signature bvec3\n"
14323 " (parameters\n"
14324 " (declare (in ) ivec3 x@0x1450d40)\n"
14325 " (declare (in ) ivec3 y@0x1450e50)\n"
14326 " )\n"
14327 " (\n"
14328 " ))\n"
14329 "\n"
14330 " (signature bvec4\n"
14331 " (parameters\n"
14332 " (declare (in ) ivec4 x@0x1451030)\n"
14333 " (declare (in ) ivec4 y@0x1451140)\n"
14334 " )\n"
14335 " (\n"
14336 " ))\n"
14337 "\n"
14338 " (signature bvec2\n"
14339 " (parameters\n"
14340 " (declare (in ) uvec2 x@0x1451320)\n"
14341 " (declare (in ) uvec2 y@0x1451430)\n"
14342 " )\n"
14343 " (\n"
14344 " ))\n"
14345 "\n"
14346 " (signature bvec3\n"
14347 " (parameters\n"
14348 " (declare (in ) uvec3 x@0x1451610)\n"
14349 " (declare (in ) uvec3 y@0x1451720)\n"
14350 " )\n"
14351 " (\n"
14352 " ))\n"
14353 "\n"
14354 " (signature bvec4\n"
14355 " (parameters\n"
14356 " (declare (in ) uvec4 x@0x1451900)\n"
14357 " (declare (in ) uvec4 y@0x1451a10)\n"
14358 " )\n"
14359 " (\n"
14360 " ))\n"
14361 "\n"
14362 " (signature bvec2\n"
14363 " (parameters\n"
14364 " (declare (in ) bvec2 x@0x1451bf0)\n"
14365 " (declare (in ) bvec2 y@0x1451d00)\n"
14366 " )\n"
14367 " (\n"
14368 " ))\n"
14369 "\n"
14370 " (signature bvec3\n"
14371 " (parameters\n"
14372 " (declare (in ) bvec3 x@0x1451ee0)\n"
14373 " (declare (in ) bvec3 y@0x1451ff0)\n"
14374 " )\n"
14375 " (\n"
14376 " ))\n"
14377 "\n"
14378 " (signature bvec4\n"
14379 " (parameters\n"
14380 " (declare (in ) bvec4 x@0x14521d0)\n"
14381 " (declare (in ) bvec4 y@0x14522e0)\n"
14382 " )\n"
14383 " (\n"
14384 " ))\n"
14385 "\n"
14386 ")\n"
14387 "\n"
14388 "(function notEqual\n"
14389 " (signature bvec2\n"
14390 " (parameters\n"
14391 " (declare (in ) vec2 x@0x14524c0)\n"
14392 " (declare (in ) vec2 y@0x14525d0)\n"
14393 " )\n"
14394 " (\n"
14395 " ))\n"
14396 "\n"
14397 " (signature bvec3\n"
14398 " (parameters\n"
14399 " (declare (in ) vec3 x@0x1452960)\n"
14400 " (declare (in ) vec3 y@0x1452a70)\n"
14401 " )\n"
14402 " (\n"
14403 " ))\n"
14404 "\n"
14405 " (signature bvec4\n"
14406 " (parameters\n"
14407 " (declare (in ) vec4 x@0x1452c50)\n"
14408 " (declare (in ) vec4 y@0x1452d60)\n"
14409 " )\n"
14410 " (\n"
14411 " ))\n"
14412 "\n"
14413 " (signature bvec2\n"
14414 " (parameters\n"
14415 " (declare (in ) ivec2 x@0x1452f40)\n"
14416 " (declare (in ) ivec2 y@0x1453050)\n"
14417 " )\n"
14418 " (\n"
14419 " ))\n"
14420 "\n"
14421 " (signature bvec3\n"
14422 " (parameters\n"
14423 " (declare (in ) ivec3 x@0x1453230)\n"
14424 " (declare (in ) ivec3 y@0x1453340)\n"
14425 " )\n"
14426 " (\n"
14427 " ))\n"
14428 "\n"
14429 " (signature bvec4\n"
14430 " (parameters\n"
14431 " (declare (in ) ivec4 x@0x1453520)\n"
14432 " (declare (in ) ivec4 y@0x1453630)\n"
14433 " )\n"
14434 " (\n"
14435 " ))\n"
14436 "\n"
14437 " (signature bvec2\n"
14438 " (parameters\n"
14439 " (declare (in ) uvec2 x@0x1453810)\n"
14440 " (declare (in ) uvec2 y@0x1453920)\n"
14441 " )\n"
14442 " (\n"
14443 " ))\n"
14444 "\n"
14445 " (signature bvec3\n"
14446 " (parameters\n"
14447 " (declare (in ) uvec3 x@0x1453b00)\n"
14448 " (declare (in ) uvec3 y@0x1453c10)\n"
14449 " )\n"
14450 " (\n"
14451 " ))\n"
14452 "\n"
14453 " (signature bvec4\n"
14454 " (parameters\n"
14455 " (declare (in ) uvec4 x@0x1453df0)\n"
14456 " (declare (in ) uvec4 y@0x1453f00)\n"
14457 " )\n"
14458 " (\n"
14459 " ))\n"
14460 "\n"
14461 " (signature bvec2\n"
14462 " (parameters\n"
14463 " (declare (in ) bvec2 x@0x14540e0)\n"
14464 " (declare (in ) bvec2 y@0x14541f0)\n"
14465 " )\n"
14466 " (\n"
14467 " ))\n"
14468 "\n"
14469 " (signature bvec3\n"
14470 " (parameters\n"
14471 " (declare (in ) bvec3 x@0x14543d0)\n"
14472 " (declare (in ) bvec3 y@0x14544e0)\n"
14473 " )\n"
14474 " (\n"
14475 " ))\n"
14476 "\n"
14477 " (signature bvec4\n"
14478 " (parameters\n"
14479 " (declare (in ) bvec4 x@0x14546c0)\n"
14480 " (declare (in ) bvec4 y@0x14547d0)\n"
14481 " )\n"
14482 " (\n"
14483 " ))\n"
14484 "\n"
14485 ")\n"
14486 "\n"
14487 "(function any\n"
14488 " (signature bool\n"
14489 " (parameters\n"
14490 " (declare (in ) bvec2 x@0x14549b0)\n"
14491 " )\n"
14492 " (\n"
14493 " ))\n"
14494 "\n"
14495 " (signature bool\n"
14496 " (parameters\n"
14497 " (declare (in ) bvec3 x@0x1454d30)\n"
14498 " )\n"
14499 " (\n"
14500 " ))\n"
14501 "\n"
14502 " (signature bool\n"
14503 " (parameters\n"
14504 " (declare (in ) bvec4 x@0x1454f10)\n"
14505 " )\n"
14506 " (\n"
14507 " ))\n"
14508 "\n"
14509 ")\n"
14510 "\n"
14511 "(function all\n"
14512 " (signature bool\n"
14513 " (parameters\n"
14514 " (declare (in ) bvec2 x@0x14550f0)\n"
14515 " )\n"
14516 " (\n"
14517 " ))\n"
14518 "\n"
14519 " (signature bool\n"
14520 " (parameters\n"
14521 " (declare (in ) bvec3 x@0x1455470)\n"
14522 " )\n"
14523 " (\n"
14524 " ))\n"
14525 "\n"
14526 " (signature bool\n"
14527 " (parameters\n"
14528 " (declare (in ) bvec4 x@0x1455650)\n"
14529 " )\n"
14530 " (\n"
14531 " ))\n"
14532 "\n"
14533 ")\n"
14534 "\n"
14535 "(function not\n"
14536 " (signature bvec2\n"
14537 " (parameters\n"
14538 " (declare (in ) bvec2 x@0x1455830)\n"
14539 " )\n"
14540 " (\n"
14541 " ))\n"
14542 "\n"
14543 " (signature bvec3\n"
14544 " (parameters\n"
14545 " (declare (in ) bvec3 x@0x1455bb0)\n"
14546 " )\n"
14547 " (\n"
14548 " ))\n"
14549 "\n"
14550 " (signature bvec4\n"
14551 " (parameters\n"
14552 " (declare (in ) bvec4 x@0x1455d90)\n"
14553 " )\n"
14554 " (\n"
14555 " ))\n"
14556 "\n"
14557 ")\n"
14558 "\n"
14559 "(function texture\n"
14560 " (signature vec4\n"
14561 " (parameters\n"
14562 " (declare (in ) sampler1D sampler@0x1455f70)\n"
14563 " (declare (in ) float P@0x1456080)\n"
14564 " )\n"
14565 " (\n"
14566 " ))\n"
14567 "\n"
14568 " (signature ivec4\n"
14569 " (parameters\n"
14570 " (declare (in ) isampler1D sampler@0x1456400)\n"
14571 " (declare (in ) float P@0x1456510)\n"
14572 " )\n"
14573 " (\n"
14574 " ))\n"
14575 "\n"
14576 " (signature uvec4\n"
14577 " (parameters\n"
14578 " (declare (in ) usampler1D sampler@0x14566f0)\n"
14579 " (declare (in ) float P@0x1456800)\n"
14580 " )\n"
14581 " (\n"
14582 " ))\n"
14583 "\n"
14584 " (signature vec4\n"
14585 " (parameters\n"
14586 " (declare (in ) sampler2D sampler@0x14569e0)\n"
14587 " (declare (in ) vec2 P@0x1456af0)\n"
14588 " )\n"
14589 " (\n"
14590 " ))\n"
14591 "\n"
14592 " (signature ivec4\n"
14593 " (parameters\n"
14594 " (declare (in ) isampler2D sampler@0x1456cd0)\n"
14595 " (declare (in ) vec2 P@0x1456de0)\n"
14596 " )\n"
14597 " (\n"
14598 " ))\n"
14599 "\n"
14600 " (signature uvec4\n"
14601 " (parameters\n"
14602 " (declare (in ) usampler2D sampler@0x1456fc0)\n"
14603 " (declare (in ) vec2 P@0x14570d0)\n"
14604 " )\n"
14605 " (\n"
14606 " ))\n"
14607 "\n"
14608 " (signature vec4\n"
14609 " (parameters\n"
14610 " (declare (in ) sampler3D sampler@0x14572b0)\n"
14611 " (declare (in ) vec3 P@0x14573c0)\n"
14612 " )\n"
14613 " (\n"
14614 " ))\n"
14615 "\n"
14616 " (signature ivec4\n"
14617 " (parameters\n"
14618 " (declare (in ) isampler3D sampler@0x14575a0)\n"
14619 " (declare (in ) vec3 P@0x14576b0)\n"
14620 " )\n"
14621 " (\n"
14622 " ))\n"
14623 "\n"
14624 " (signature uvec4\n"
14625 " (parameters\n"
14626 " (declare (in ) usampler3D sampler@0x1457890)\n"
14627 " (declare (in ) vec3 P@0x14579a0)\n"
14628 " )\n"
14629 " (\n"
14630 " ))\n"
14631 "\n"
14632 " (signature vec4\n"
14633 " (parameters\n"
14634 " (declare (in ) samplerCube sampler@0x1457b80)\n"
14635 " (declare (in ) vec3 P@0x1457c90)\n"
14636 " )\n"
14637 " (\n"
14638 " ))\n"
14639 "\n"
14640 " (signature ivec4\n"
14641 " (parameters\n"
14642 " (declare (in ) isamplerCube sampler@0x1457e70)\n"
14643 " (declare (in ) vec3 P@0x1457f80)\n"
14644 " )\n"
14645 " (\n"
14646 " ))\n"
14647 "\n"
14648 " (signature uvec4\n"
14649 " (parameters\n"
14650 " (declare (in ) usamplerCube sampler@0x1458160)\n"
14651 " (declare (in ) vec3 P@0x1458270)\n"
14652 " )\n"
14653 " (\n"
14654 " ))\n"
14655 "\n"
14656 " (signature float\n"
14657 " (parameters\n"
14658 " (declare (in ) sampler1DShadow sampler@0x1458450)\n"
14659 " (declare (in ) vec3 P@0x1458560)\n"
14660 " )\n"
14661 " (\n"
14662 " ))\n"
14663 "\n"
14664 " (signature float\n"
14665 " (parameters\n"
14666 " (declare (in ) sampler2DShadow sampler@0x1458740)\n"
14667 " (declare (in ) vec3 P@0x1458850)\n"
14668 " )\n"
14669 " (\n"
14670 " ))\n"
14671 "\n"
14672 " (signature float\n"
14673 " (parameters\n"
14674 " (declare (in ) samplerCubeShadow sampler@0x1458a30)\n"
14675 " (declare (in ) vec4 P@0x1458b40)\n"
14676 " )\n"
14677 " (\n"
14678 " ))\n"
14679 "\n"
14680 " (signature vec4\n"
14681 " (parameters\n"
14682 " (declare (in ) sampler1DArray sampler@0x1458d20)\n"
14683 " (declare (in ) vec2 P@0x1458e30)\n"
14684 " )\n"
14685 " (\n"
14686 " ))\n"
14687 "\n"
14688 " (signature ivec4\n"
14689 " (parameters\n"
14690 " (declare (in ) isampler1DArray sampler@0x1459010)\n"
14691 " (declare (in ) vec2 P@0x1459120)\n"
14692 " )\n"
14693 " (\n"
14694 " ))\n"
14695 "\n"
14696 " (signature uvec4\n"
14697 " (parameters\n"
14698 " (declare (in ) usampler1DArray sampler@0x1459300)\n"
14699 " (declare (in ) vec2 P@0x1459410)\n"
14700 " )\n"
14701 " (\n"
14702 " ))\n"
14703 "\n"
14704 " (signature vec4\n"
14705 " (parameters\n"
14706 " (declare (in ) sampler2DArray sampler@0x14595f0)\n"
14707 " (declare (in ) vec3 P@0x1459700)\n"
14708 " )\n"
14709 " (\n"
14710 " ))\n"
14711 "\n"
14712 " (signature ivec4\n"
14713 " (parameters\n"
14714 " (declare (in ) isampler2DArray sampler@0x14598e0)\n"
14715 " (declare (in ) vec3 P@0x14599f0)\n"
14716 " )\n"
14717 " (\n"
14718 " ))\n"
14719 "\n"
14720 " (signature uvec4\n"
14721 " (parameters\n"
14722 " (declare (in ) usampler2DArray sampler@0x1459bd0)\n"
14723 " (declare (in ) vec3 P@0x1459ce0)\n"
14724 " )\n"
14725 " (\n"
14726 " ))\n"
14727 "\n"
14728 " (signature float\n"
14729 " (parameters\n"
14730 " (declare (in ) sampler1DArrayShadow sampler@0x1459ec0)\n"
14731 " (declare (in ) vec3 P@0x1459fd0)\n"
14732 " )\n"
14733 " (\n"
14734 " ))\n"
14735 "\n"
14736 " (signature float\n"
14737 " (parameters\n"
14738 " (declare (in ) sampler2DArrayShadow sampler@0x145a1b0)\n"
14739 " (declare (in ) vec4 P@0x145a2c0)\n"
14740 " )\n"
14741 " (\n"
14742 " ))\n"
14743 "\n"
14744 " (signature vec4\n"
14745 " (parameters\n"
14746 " (declare (in ) sampler1D sampler@0x145a4a0)\n"
14747 " (declare (in ) float P@0x145a5b0)\n"
14748 " (declare (in ) float bias@0x145a6c0)\n"
14749 " )\n"
14750 " (\n"
14751 " ))\n"
14752 "\n"
14753 " (signature ivec4\n"
14754 " (parameters\n"
14755 " (declare (in ) isampler1D sampler@0x145a8a0)\n"
14756 " (declare (in ) float P@0x145a9b0)\n"
14757 " (declare (in ) float bias@0x145aac0)\n"
14758 " )\n"
14759 " (\n"
14760 " ))\n"
14761 "\n"
14762 " (signature uvec4\n"
14763 " (parameters\n"
14764 " (declare (in ) usampler1D sampler@0x145aca0)\n"
14765 " (declare (in ) float P@0x145adb0)\n"
14766 " (declare (in ) float bias@0x145aec0)\n"
14767 " )\n"
14768 " (\n"
14769 " ))\n"
14770 "\n"
14771 " (signature vec4\n"
14772 " (parameters\n"
14773 " (declare (in ) sampler2D sampler@0x145b0a0)\n"
14774 " (declare (in ) vec2 P@0x145b1b0)\n"
14775 " (declare (in ) float bias@0x145b2c0)\n"
14776 " )\n"
14777 " (\n"
14778 " ))\n"
14779 "\n"
14780 " (signature ivec4\n"
14781 " (parameters\n"
14782 " (declare (in ) isampler2D sampler@0x145b4a0)\n"
14783 " (declare (in ) vec2 P@0x145b5b0)\n"
14784 " (declare (in ) float bias@0x145b6c0)\n"
14785 " )\n"
14786 " (\n"
14787 " ))\n"
14788 "\n"
14789 " (signature uvec4\n"
14790 " (parameters\n"
14791 " (declare (in ) usampler2D sampler@0x145b8a0)\n"
14792 " (declare (in ) vec2 P@0x145b9b0)\n"
14793 " (declare (in ) float bias@0x145bac0)\n"
14794 " )\n"
14795 " (\n"
14796 " ))\n"
14797 "\n"
14798 " (signature vec4\n"
14799 " (parameters\n"
14800 " (declare (in ) sampler3D sampler@0x145bca0)\n"
14801 " (declare (in ) vec3 P@0x145bdb0)\n"
14802 " (declare (in ) float bias@0x145bec0)\n"
14803 " )\n"
14804 " (\n"
14805 " ))\n"
14806 "\n"
14807 " (signature ivec4\n"
14808 " (parameters\n"
14809 " (declare (in ) isampler3D sampler@0x145c0a0)\n"
14810 " (declare (in ) vec3 P@0x145c1b0)\n"
14811 " (declare (in ) float bias@0x145c2c0)\n"
14812 " )\n"
14813 " (\n"
14814 " ))\n"
14815 "\n"
14816 " (signature uvec4\n"
14817 " (parameters\n"
14818 " (declare (in ) usampler3D sampler@0x145c4a0)\n"
14819 " (declare (in ) vec3 P@0x145c5b0)\n"
14820 " (declare (in ) float bias@0x145c6c0)\n"
14821 " )\n"
14822 " (\n"
14823 " ))\n"
14824 "\n"
14825 " (signature vec4\n"
14826 " (parameters\n"
14827 " (declare (in ) samplerCube sampler@0x145c8a0)\n"
14828 " (declare (in ) vec3 P@0x145c9b0)\n"
14829 " (declare (in ) float bias@0x145cac0)\n"
14830 " )\n"
14831 " (\n"
14832 " ))\n"
14833 "\n"
14834 " (signature ivec4\n"
14835 " (parameters\n"
14836 " (declare (in ) isamplerCube sampler@0x145cca0)\n"
14837 " (declare (in ) vec3 P@0x145cdb0)\n"
14838 " (declare (in ) float bias@0x145cec0)\n"
14839 " )\n"
14840 " (\n"
14841 " ))\n"
14842 "\n"
14843 " (signature uvec4\n"
14844 " (parameters\n"
14845 " (declare (in ) usamplerCube sampler@0x145d0a0)\n"
14846 " (declare (in ) vec3 P@0x145d1b0)\n"
14847 " (declare (in ) float bias@0x145d2c0)\n"
14848 " )\n"
14849 " (\n"
14850 " ))\n"
14851 "\n"
14852 " (signature float\n"
14853 " (parameters\n"
14854 " (declare (in ) sampler1DShadow sampler@0x145d4a0)\n"
14855 " (declare (in ) vec3 P@0x145d5b0)\n"
14856 " (declare (in ) float bias@0x145d6c0)\n"
14857 " )\n"
14858 " (\n"
14859 " ))\n"
14860 "\n"
14861 " (signature float\n"
14862 " (parameters\n"
14863 " (declare (in ) sampler2DShadow sampler@0x145d8a0)\n"
14864 " (declare (in ) vec3 P@0x145d9b0)\n"
14865 " (declare (in ) float bias@0x145dac0)\n"
14866 " )\n"
14867 " (\n"
14868 " ))\n"
14869 "\n"
14870 " (signature float\n"
14871 " (parameters\n"
14872 " (declare (in ) samplerCubeShadow sampler@0x145dca0)\n"
14873 " (declare (in ) vec4 P@0x145ddb0)\n"
14874 " (declare (in ) float bias@0x145dec0)\n"
14875 " )\n"
14876 " (\n"
14877 " ))\n"
14878 "\n"
14879 " (signature vec4\n"
14880 " (parameters\n"
14881 " (declare (in ) sampler1DArray sampler@0x145e0a0)\n"
14882 " (declare (in ) vec2 P@0x145e1b0)\n"
14883 " (declare (in ) float bias@0x145e2c0)\n"
14884 " )\n"
14885 " (\n"
14886 " ))\n"
14887 "\n"
14888 " (signature ivec4\n"
14889 " (parameters\n"
14890 " (declare (in ) isampler1DArray sampler@0x145e4a0)\n"
14891 " (declare (in ) vec2 P@0x145e5b0)\n"
14892 " (declare (in ) float bias@0x145e6c0)\n"
14893 " )\n"
14894 " (\n"
14895 " ))\n"
14896 "\n"
14897 " (signature uvec4\n"
14898 " (parameters\n"
14899 " (declare (in ) usampler1DArray sampler@0x145e8a0)\n"
14900 " (declare (in ) vec2 P@0x145e9b0)\n"
14901 " (declare (in ) float bias@0x145eac0)\n"
14902 " )\n"
14903 " (\n"
14904 " ))\n"
14905 "\n"
14906 " (signature vec4\n"
14907 " (parameters\n"
14908 " (declare (in ) sampler2DArray sampler@0x145eca0)\n"
14909 " (declare (in ) vec3 P@0x145edb0)\n"
14910 " (declare (in ) float bias@0x145eec0)\n"
14911 " )\n"
14912 " (\n"
14913 " ))\n"
14914 "\n"
14915 " (signature ivec4\n"
14916 " (parameters\n"
14917 " (declare (in ) isampler2DArray sampler@0x145f0a0)\n"
14918 " (declare (in ) vec3 P@0x145f1b0)\n"
14919 " (declare (in ) float bias@0x145f2c0)\n"
14920 " )\n"
14921 " (\n"
14922 " ))\n"
14923 "\n"
14924 " (signature uvec4\n"
14925 " (parameters\n"
14926 " (declare (in ) usampler2DArray sampler@0x145f4a0)\n"
14927 " (declare (in ) vec3 P@0x145f5b0)\n"
14928 " (declare (in ) float bias@0x145f6c0)\n"
14929 " )\n"
14930 " (\n"
14931 " ))\n"
14932 "\n"
14933 " (signature float\n"
14934 " (parameters\n"
14935 " (declare (in ) sampler1DArrayShadow sampler@0x145f8a0)\n"
14936 " (declare (in ) vec3 P@0x145f9b0)\n"
14937 " (declare (in ) float bias@0x145fac0)\n"
14938 " )\n"
14939 " (\n"
14940 " ))\n"
14941 "\n"
14942 ")\n"
14943 "\n"
14944 "(function textureProj\n"
14945 " (signature vec4\n"
14946 " (parameters\n"
14947 " (declare (in ) sampler1D sampler@0x145fca0)\n"
14948 " (declare (in ) vec2 P@0x145fdb0)\n"
14949 " )\n"
14950 " (\n"
14951 " ))\n"
14952 "\n"
14953 " (signature ivec4\n"
14954 " (parameters\n"
14955 " (declare (in ) isampler1D sampler@0x1460140)\n"
14956 " (declare (in ) vec2 P@0x1460250)\n"
14957 " )\n"
14958 " (\n"
14959 " ))\n"
14960 "\n"
14961 " (signature uvec4\n"
14962 " (parameters\n"
14963 " (declare (in ) usampler1D sampler@0x1460430)\n"
14964 " (declare (in ) vec2 P@0x1460540)\n"
14965 " )\n"
14966 " (\n"
14967 " ))\n"
14968 "\n"
14969 " (signature vec4\n"
14970 " (parameters\n"
14971 " (declare (in ) sampler1D sampler@0x1460720)\n"
14972 " (declare (in ) vec4 P@0x1460830)\n"
14973 " )\n"
14974 " (\n"
14975 " ))\n"
14976 "\n"
14977 " (signature ivec4\n"
14978 " (parameters\n"
14979 " (declare (in ) isampler1D sampler@0x1460a10)\n"
14980 " (declare (in ) vec4 P@0x1460b20)\n"
14981 " )\n"
14982 " (\n"
14983 " ))\n"
14984 "\n"
14985 " (signature uvec4\n"
14986 " (parameters\n"
14987 " (declare (in ) usampler1D sampler@0x1460d00)\n"
14988 " (declare (in ) vec4 P@0x1460e10)\n"
14989 " )\n"
14990 " (\n"
14991 " ))\n"
14992 "\n"
14993 " (signature vec4\n"
14994 " (parameters\n"
14995 " (declare (in ) sampler2D sampler@0x1460ff0)\n"
14996 " (declare (in ) vec3 P@0x1461100)\n"
14997 " )\n"
14998 " (\n"
14999 " ))\n"
15000 "\n"
15001 " (signature ivec4\n"
15002 " (parameters\n"
15003 " (declare (in ) isampler2D sampler@0x14612e0)\n"
15004 " (declare (in ) vec3 P@0x14613f0)\n"
15005 " )\n"
15006 " (\n"
15007 " ))\n"
15008 "\n"
15009 " (signature uvec4\n"
15010 " (parameters\n"
15011 " (declare (in ) usampler2D sampler@0x14615d0)\n"
15012 " (declare (in ) vec3 P@0x14616e0)\n"
15013 " )\n"
15014 " (\n"
15015 " ))\n"
15016 "\n"
15017 " (signature vec4\n"
15018 " (parameters\n"
15019 " (declare (in ) sampler2D sampler@0x14618c0)\n"
15020 " (declare (in ) vec4 P@0x14619d0)\n"
15021 " )\n"
15022 " (\n"
15023 " ))\n"
15024 "\n"
15025 " (signature ivec4\n"
15026 " (parameters\n"
15027 " (declare (in ) isampler2D sampler@0x1461bb0)\n"
15028 " (declare (in ) vec4 P@0x1461cc0)\n"
15029 " )\n"
15030 " (\n"
15031 " ))\n"
15032 "\n"
15033 " (signature uvec4\n"
15034 " (parameters\n"
15035 " (declare (in ) usampler2D sampler@0x1461ea0)\n"
15036 " (declare (in ) vec4 P@0x1461fb0)\n"
15037 " )\n"
15038 " (\n"
15039 " ))\n"
15040 "\n"
15041 " (signature vec4\n"
15042 " (parameters\n"
15043 " (declare (in ) sampler3D sampler@0x1462190)\n"
15044 " (declare (in ) vec4 P@0x14622a0)\n"
15045 " )\n"
15046 " (\n"
15047 " ))\n"
15048 "\n"
15049 " (signature ivec4\n"
15050 " (parameters\n"
15051 " (declare (in ) isampler3D sampler@0x1462480)\n"
15052 " (declare (in ) vec4 P@0x1462590)\n"
15053 " )\n"
15054 " (\n"
15055 " ))\n"
15056 "\n"
15057 " (signature uvec4\n"
15058 " (parameters\n"
15059 " (declare (in ) usampler3D sampler@0x1462770)\n"
15060 " (declare (in ) vec4 P@0x1462880)\n"
15061 " )\n"
15062 " (\n"
15063 " ))\n"
15064 "\n"
15065 " (signature float\n"
15066 " (parameters\n"
15067 " (declare (in ) sampler1DShadow sampler@0x1462a60)\n"
15068 " (declare (in ) vec4 P@0x1462b70)\n"
15069 " )\n"
15070 " (\n"
15071 " ))\n"
15072 "\n"
15073 " (signature float\n"
15074 " (parameters\n"
15075 " (declare (in ) sampler2DShadow sampler@0x1462d50)\n"
15076 " (declare (in ) vec4 P@0x1462e60)\n"
15077 " )\n"
15078 " (\n"
15079 " ))\n"
15080 "\n"
15081 " (signature vec4\n"
15082 " (parameters\n"
15083 " (declare (in ) sampler1D sampler@0x1463040)\n"
15084 " (declare (in ) vec2 P@0x1463150)\n"
15085 " (declare (in ) float bias@0x1463260)\n"
15086 " )\n"
15087 " (\n"
15088 " ))\n"
15089 "\n"
15090 " (signature ivec4\n"
15091 " (parameters\n"
15092 " (declare (in ) isampler1D sampler@0x1463440)\n"
15093 " (declare (in ) vec2 P@0x1463550)\n"
15094 " (declare (in ) float bias@0x1463660)\n"
15095 " )\n"
15096 " (\n"
15097 " ))\n"
15098 "\n"
15099 " (signature uvec4\n"
15100 " (parameters\n"
15101 " (declare (in ) usampler1D sampler@0x1463840)\n"
15102 " (declare (in ) vec2 P@0x1463950)\n"
15103 " (declare (in ) float bias@0x1463a60)\n"
15104 " )\n"
15105 " (\n"
15106 " ))\n"
15107 "\n"
15108 " (signature vec4\n"
15109 " (parameters\n"
15110 " (declare (in ) sampler1D sampler@0x1463c40)\n"
15111 " (declare (in ) vec4 P@0x1463d50)\n"
15112 " (declare (in ) float bias@0x1463e60)\n"
15113 " )\n"
15114 " (\n"
15115 " ))\n"
15116 "\n"
15117 " (signature ivec4\n"
15118 " (parameters\n"
15119 " (declare (in ) isampler1D sampler@0x1464040)\n"
15120 " (declare (in ) vec4 P@0x1464150)\n"
15121 " (declare (in ) float bias@0x1464260)\n"
15122 " )\n"
15123 " (\n"
15124 " ))\n"
15125 "\n"
15126 " (signature uvec4\n"
15127 " (parameters\n"
15128 " (declare (in ) usampler1D sampler@0x1464440)\n"
15129 " (declare (in ) vec4 P@0x1464550)\n"
15130 " (declare (in ) float bias@0x1464660)\n"
15131 " )\n"
15132 " (\n"
15133 " ))\n"
15134 "\n"
15135 " (signature vec4\n"
15136 " (parameters\n"
15137 " (declare (in ) sampler2D sampler@0x1464840)\n"
15138 " (declare (in ) vec3 P@0x1464950)\n"
15139 " (declare (in ) float bias@0x1464a60)\n"
15140 " )\n"
15141 " (\n"
15142 " ))\n"
15143 "\n"
15144 " (signature ivec4\n"
15145 " (parameters\n"
15146 " (declare (in ) isampler2D sampler@0x1464c40)\n"
15147 " (declare (in ) vec3 P@0x1464d50)\n"
15148 " (declare (in ) float bias@0x1464e60)\n"
15149 " )\n"
15150 " (\n"
15151 " ))\n"
15152 "\n"
15153 " (signature uvec4\n"
15154 " (parameters\n"
15155 " (declare (in ) usampler2D sampler@0x1465040)\n"
15156 " (declare (in ) vec3 P@0x1465150)\n"
15157 " (declare (in ) float bias@0x1465260)\n"
15158 " )\n"
15159 " (\n"
15160 " ))\n"
15161 "\n"
15162 " (signature vec4\n"
15163 " (parameters\n"
15164 " (declare (in ) sampler2D sampler@0x1465440)\n"
15165 " (declare (in ) vec4 P@0x1465550)\n"
15166 " (declare (in ) float bias@0x1465660)\n"
15167 " )\n"
15168 " (\n"
15169 " ))\n"
15170 "\n"
15171 " (signature ivec4\n"
15172 " (parameters\n"
15173 " (declare (in ) isampler2D sampler@0x1465840)\n"
15174 " (declare (in ) vec4 P@0x1465950)\n"
15175 " (declare (in ) float bias@0x1465a60)\n"
15176 " )\n"
15177 " (\n"
15178 " ))\n"
15179 "\n"
15180 " (signature uvec4\n"
15181 " (parameters\n"
15182 " (declare (in ) usampler2D sampler@0x1465c40)\n"
15183 " (declare (in ) vec4 P@0x1465d50)\n"
15184 " (declare (in ) float bias@0x1465e60)\n"
15185 " )\n"
15186 " (\n"
15187 " ))\n"
15188 "\n"
15189 " (signature vec4\n"
15190 " (parameters\n"
15191 " (declare (in ) sampler3D sampler@0x1466040)\n"
15192 " (declare (in ) vec4 P@0x1466150)\n"
15193 " (declare (in ) float bias@0x1466260)\n"
15194 " )\n"
15195 " (\n"
15196 " ))\n"
15197 "\n"
15198 " (signature ivec4\n"
15199 " (parameters\n"
15200 " (declare (in ) isampler3D sampler@0x1466440)\n"
15201 " (declare (in ) vec4 P@0x1466550)\n"
15202 " (declare (in ) float bias@0x1466660)\n"
15203 " )\n"
15204 " (\n"
15205 " ))\n"
15206 "\n"
15207 " (signature uvec4\n"
15208 " (parameters\n"
15209 " (declare (in ) usampler3D sampler@0x1466840)\n"
15210 " (declare (in ) vec4 P@0x1466950)\n"
15211 " (declare (in ) float bias@0x1466a60)\n"
15212 " )\n"
15213 " (\n"
15214 " ))\n"
15215 "\n"
15216 " (signature float\n"
15217 " (parameters\n"
15218 " (declare (in ) sampler1DShadow sampler@0x1466c40)\n"
15219 " (declare (in ) vec4 P@0x1466d50)\n"
15220 " (declare (in ) float bias@0x1466e60)\n"
15221 " )\n"
15222 " (\n"
15223 " ))\n"
15224 "\n"
15225 " (signature float\n"
15226 " (parameters\n"
15227 " (declare (in ) sampler2DShadow sampler@0x1467040)\n"
15228 " (declare (in ) vec4 P@0x1467150)\n"
15229 " (declare (in ) float bias@0x1467260)\n"
15230 " )\n"
15231 " (\n"
15232 " ))\n"
15233 "\n"
15234 ")\n"
15235 "\n"
15236 "(function textureLod\n"
15237 " (signature vec4\n"
15238 " (parameters\n"
15239 " (declare (in ) sampler1D sampler@0x1467440)\n"
15240 " (declare (in ) float P@0x1467550)\n"
15241 " (declare (in ) float lod@0x1467660)\n"
15242 " )\n"
15243 " (\n"
15244 " ))\n"
15245 "\n"
15246 " (signature ivec4\n"
15247 " (parameters\n"
15248 " (declare (in ) isampler1D sampler@0x14679f0)\n"
15249 " (declare (in ) float P@0x1467b00)\n"
15250 " (declare (in ) float lod@0x1467c10)\n"
15251 " )\n"
15252 " (\n"
15253 " ))\n"
15254 "\n"
15255 " (signature uvec4\n"
15256 " (parameters\n"
15257 " (declare (in ) usampler1D sampler@0x1467df0)\n"
15258 " (declare (in ) float P@0x1467f00)\n"
15259 " (declare (in ) float lod@0x1468010)\n"
15260 " )\n"
15261 " (\n"
15262 " ))\n"
15263 "\n"
15264 " (signature vec4\n"
15265 " (parameters\n"
15266 " (declare (in ) sampler2D sampler@0x14681f0)\n"
15267 " (declare (in ) vec2 P@0x1468300)\n"
15268 " (declare (in ) float lod@0x1468410)\n"
15269 " )\n"
15270 " (\n"
15271 " ))\n"
15272 "\n"
15273 " (signature ivec4\n"
15274 " (parameters\n"
15275 " (declare (in ) isampler2D sampler@0x14685f0)\n"
15276 " (declare (in ) vec2 P@0x1468700)\n"
15277 " (declare (in ) float lod@0x1468810)\n"
15278 " )\n"
15279 " (\n"
15280 " ))\n"
15281 "\n"
15282 " (signature uvec4\n"
15283 " (parameters\n"
15284 " (declare (in ) usampler2D sampler@0x14689f0)\n"
15285 " (declare (in ) vec2 P@0x1468b00)\n"
15286 " (declare (in ) float lod@0x1468c10)\n"
15287 " )\n"
15288 " (\n"
15289 " ))\n"
15290 "\n"
15291 " (signature vec4\n"
15292 " (parameters\n"
15293 " (declare (in ) sampler3D sampler@0x1468df0)\n"
15294 " (declare (in ) vec3 P@0x1468f00)\n"
15295 " (declare (in ) float lod@0x1469010)\n"
15296 " )\n"
15297 " (\n"
15298 " ))\n"
15299 "\n"
15300 " (signature ivec4\n"
15301 " (parameters\n"
15302 " (declare (in ) isampler3D sampler@0x14691f0)\n"
15303 " (declare (in ) vec3 P@0x1469300)\n"
15304 " (declare (in ) float lod@0x1469410)\n"
15305 " )\n"
15306 " (\n"
15307 " ))\n"
15308 "\n"
15309 " (signature uvec4\n"
15310 " (parameters\n"
15311 " (declare (in ) usampler3D sampler@0x14695f0)\n"
15312 " (declare (in ) vec3 P@0x1469700)\n"
15313 " (declare (in ) float lod@0x1469810)\n"
15314 " )\n"
15315 " (\n"
15316 " ))\n"
15317 "\n"
15318 " (signature vec4\n"
15319 " (parameters\n"
15320 " (declare (in ) samplerCube sampler@0x14699f0)\n"
15321 " (declare (in ) vec3 P@0x1469b00)\n"
15322 " (declare (in ) float lod@0x1469c10)\n"
15323 " )\n"
15324 " (\n"
15325 " ))\n"
15326 "\n"
15327 " (signature ivec4\n"
15328 " (parameters\n"
15329 " (declare (in ) isamplerCube sampler@0x1469df0)\n"
15330 " (declare (in ) vec3 P@0x1469f00)\n"
15331 " (declare (in ) float lod@0x146a010)\n"
15332 " )\n"
15333 " (\n"
15334 " ))\n"
15335 "\n"
15336 " (signature uvec4\n"
15337 " (parameters\n"
15338 " (declare (in ) usamplerCube sampler@0x146a1f0)\n"
15339 " (declare (in ) vec3 P@0x146a300)\n"
15340 " (declare (in ) float lod@0x146a410)\n"
15341 " )\n"
15342 " (\n"
15343 " ))\n"
15344 "\n"
15345 " (signature float\n"
15346 " (parameters\n"
15347 " (declare (in ) sampler1DShadow sampler@0x146a5f0)\n"
15348 " (declare (in ) vec3 P@0x146a700)\n"
15349 " (declare (in ) float lod@0x146a810)\n"
15350 " )\n"
15351 " (\n"
15352 " ))\n"
15353 "\n"
15354 " (signature float\n"
15355 " (parameters\n"
15356 " (declare (in ) sampler2DShadow sampler@0x146a9f0)\n"
15357 " (declare (in ) vec3 P@0x146ab00)\n"
15358 " (declare (in ) float lod@0x146ac10)\n"
15359 " )\n"
15360 " (\n"
15361 " ))\n"
15362 "\n"
15363 " (signature vec4\n"
15364 " (parameters\n"
15365 " (declare (in ) sampler1DArray sampler@0x146adf0)\n"
15366 " (declare (in ) vec2 P@0x146af00)\n"
15367 " (declare (in ) float lod@0x146b010)\n"
15368 " )\n"
15369 " (\n"
15370 " ))\n"
15371 "\n"
15372 " (signature ivec4\n"
15373 " (parameters\n"
15374 " (declare (in ) isampler1DArray sampler@0x146b1f0)\n"
15375 " (declare (in ) vec2 P@0x146b300)\n"
15376 " (declare (in ) float lod@0x146b410)\n"
15377 " )\n"
15378 " (\n"
15379 " ))\n"
15380 "\n"
15381 " (signature uvec4\n"
15382 " (parameters\n"
15383 " (declare (in ) usampler1DArray sampler@0x146b5f0)\n"
15384 " (declare (in ) vec2 P@0x146b700)\n"
15385 " (declare (in ) float lod@0x146b810)\n"
15386 " )\n"
15387 " (\n"
15388 " ))\n"
15389 "\n"
15390 " (signature vec4\n"
15391 " (parameters\n"
15392 " (declare (in ) sampler2DArray sampler@0x146b9f0)\n"
15393 " (declare (in ) vec3 P@0x146bb00)\n"
15394 " (declare (in ) float lod@0x146bc10)\n"
15395 " )\n"
15396 " (\n"
15397 " ))\n"
15398 "\n"
15399 " (signature ivec4\n"
15400 " (parameters\n"
15401 " (declare (in ) isampler2DArray sampler@0x146bdf0)\n"
15402 " (declare (in ) vec3 P@0x146bf00)\n"
15403 " (declare (in ) float lod@0x146c010)\n"
15404 " )\n"
15405 " (\n"
15406 " ))\n"
15407 "\n"
15408 " (signature uvec4\n"
15409 " (parameters\n"
15410 " (declare (in ) usampler2DArray sampler@0x146c1f0)\n"
15411 " (declare (in ) vec3 P@0x146c300)\n"
15412 " (declare (in ) float lod@0x146c410)\n"
15413 " )\n"
15414 " (\n"
15415 " ))\n"
15416 "\n"
15417 " (signature float\n"
15418 " (parameters\n"
15419 " (declare (in ) sampler1DArrayShadow sampler@0x146c5f0)\n"
15420 " (declare (in ) vec3 P@0x146c700)\n"
15421 " (declare (in ) float lod@0x146c810)\n"
15422 " )\n"
15423 " (\n"
15424 " ))\n"
15425 "\n"
15426 ")\n"
15427 "\n"
15428 "(function texelFetch\n"
15429 " (signature vec4\n"
15430 " (parameters\n"
15431 " (declare (in ) sampler1D sampler@0x146c9f0)\n"
15432 " (declare (in ) int P@0x146cb00)\n"
15433 " (declare (in ) int lod@0x146cc10)\n"
15434 " )\n"
15435 " (\n"
15436 " ))\n"
15437 "\n"
15438 " (signature ivec4\n"
15439 " (parameters\n"
15440 " (declare (in ) isampler1D sampler@0x146cfa0)\n"
15441 " (declare (in ) int P@0x146d0b0)\n"
15442 " (declare (in ) int lod@0x146d1c0)\n"
15443 " )\n"
15444 " (\n"
15445 " ))\n"
15446 "\n"
15447 " (signature uvec4\n"
15448 " (parameters\n"
15449 " (declare (in ) usampler1D sampler@0x146d3a0)\n"
15450 " (declare (in ) int P@0x146d4b0)\n"
15451 " (declare (in ) int lod@0x146d5c0)\n"
15452 " )\n"
15453 " (\n"
15454 " ))\n"
15455 "\n"
15456 " (signature vec4\n"
15457 " (parameters\n"
15458 " (declare (in ) sampler2D sampler@0x146d7a0)\n"
15459 " (declare (in ) ivec2 P@0x146d8b0)\n"
15460 " (declare (in ) int lod@0x146d9c0)\n"
15461 " )\n"
15462 " (\n"
15463 " ))\n"
15464 "\n"
15465 " (signature ivec4\n"
15466 " (parameters\n"
15467 " (declare (in ) isampler2D sampler@0x146dba0)\n"
15468 " (declare (in ) ivec2 P@0x146dcb0)\n"
15469 " (declare (in ) int lod@0x146ddc0)\n"
15470 " )\n"
15471 " (\n"
15472 " ))\n"
15473 "\n"
15474 " (signature uvec4\n"
15475 " (parameters\n"
15476 " (declare (in ) usampler2D sampler@0x146dfa0)\n"
15477 " (declare (in ) ivec2 P@0x146e0b0)\n"
15478 " (declare (in ) int lod@0x146e1c0)\n"
15479 " )\n"
15480 " (\n"
15481 " ))\n"
15482 "\n"
15483 " (signature vec4\n"
15484 " (parameters\n"
15485 " (declare (in ) sampler3D sampler@0x146e3a0)\n"
15486 " (declare (in ) ivec3 P@0x146e4b0)\n"
15487 " (declare (in ) int lod@0x146e5c0)\n"
15488 " )\n"
15489 " (\n"
15490 " ))\n"
15491 "\n"
15492 " (signature ivec4\n"
15493 " (parameters\n"
15494 " (declare (in ) isampler3D sampler@0x146e7a0)\n"
15495 " (declare (in ) ivec3 P@0x146e8b0)\n"
15496 " (declare (in ) int lod@0x146e9c0)\n"
15497 " )\n"
15498 " (\n"
15499 " ))\n"
15500 "\n"
15501 " (signature uvec4\n"
15502 " (parameters\n"
15503 " (declare (in ) usampler3D sampler@0x146eba0)\n"
15504 " (declare (in ) ivec3 P@0x146ecb0)\n"
15505 " (declare (in ) int lod@0x146edc0)\n"
15506 " )\n"
15507 " (\n"
15508 " ))\n"
15509 "\n"
15510 " (signature vec4\n"
15511 " (parameters\n"
15512 " (declare (in ) sampler1DArray sampler@0x146efa0)\n"
15513 " (declare (in ) ivec2 P@0x146f0b0)\n"
15514 " (declare (in ) int lod@0x146f1c0)\n"
15515 " )\n"
15516 " (\n"
15517 " ))\n"
15518 "\n"
15519 " (signature ivec4\n"
15520 " (parameters\n"
15521 " (declare (in ) isampler1DArray sampler@0x146f3a0)\n"
15522 " (declare (in ) ivec2 P@0x146f4b0)\n"
15523 " (declare (in ) int lod@0x146f5c0)\n"
15524 " )\n"
15525 " (\n"
15526 " ))\n"
15527 "\n"
15528 " (signature uvec4\n"
15529 " (parameters\n"
15530 " (declare (in ) usampler1DArray sampler@0x146f7a0)\n"
15531 " (declare (in ) ivec2 P@0x146f8b0)\n"
15532 " (declare (in ) int lod@0x146f9c0)\n"
15533 " )\n"
15534 " (\n"
15535 " ))\n"
15536 "\n"
15537 " (signature vec4\n"
15538 " (parameters\n"
15539 " (declare (in ) sampler2DArray sampler@0x146fba0)\n"
15540 " (declare (in ) ivec3 P@0x146fcb0)\n"
15541 " (declare (in ) int lod@0x146fdc0)\n"
15542 " )\n"
15543 " (\n"
15544 " ))\n"
15545 "\n"
15546 " (signature ivec4\n"
15547 " (parameters\n"
15548 " (declare (in ) isampler2DArray sampler@0x146ffa0)\n"
15549 " (declare (in ) ivec3 P@0x14700b0)\n"
15550 " (declare (in ) int lod@0x14701c0)\n"
15551 " )\n"
15552 " (\n"
15553 " ))\n"
15554 "\n"
15555 " (signature uvec4\n"
15556 " (parameters\n"
15557 " (declare (in ) usampler2DArray sampler@0x14703a0)\n"
15558 " (declare (in ) ivec3 P@0x14704b0)\n"
15559 " (declare (in ) int lod@0x14705c0)\n"
15560 " )\n"
15561 " (\n"
15562 " ))\n"
15563 "\n"
15564 ")\n"
15565 "\n"
15566 "(function textureProjLod\n"
15567 " (signature vec4\n"
15568 " (parameters\n"
15569 " (declare (in ) sampler1D sampler@0x14707a0)\n"
15570 " (declare (in ) vec2 P@0x14708b0)\n"
15571 " (declare (in ) float lod@0x14709c0)\n"
15572 " )\n"
15573 " (\n"
15574 " ))\n"
15575 "\n"
15576 " (signature ivec4\n"
15577 " (parameters\n"
15578 " (declare (in ) isampler1D sampler@0x1470d50)\n"
15579 " (declare (in ) vec2 P@0x1470e60)\n"
15580 " (declare (in ) float lod@0x1470f70)\n"
15581 " )\n"
15582 " (\n"
15583 " ))\n"
15584 "\n"
15585 " (signature uvec4\n"
15586 " (parameters\n"
15587 " (declare (in ) usampler1D sampler@0x1471150)\n"
15588 " (declare (in ) vec2 P@0x1471260)\n"
15589 " (declare (in ) float lod@0x1471370)\n"
15590 " )\n"
15591 " (\n"
15592 " ))\n"
15593 "\n"
15594 " (signature vec4\n"
15595 " (parameters\n"
15596 " (declare (in ) sampler1D sampler@0x1471550)\n"
15597 " (declare (in ) vec4 P@0x1471660)\n"
15598 " (declare (in ) float lod@0x1471770)\n"
15599 " )\n"
15600 " (\n"
15601 " ))\n"
15602 "\n"
15603 " (signature ivec4\n"
15604 " (parameters\n"
15605 " (declare (in ) isampler1D sampler@0x1471950)\n"
15606 " (declare (in ) vec4 P@0x1471a60)\n"
15607 " (declare (in ) float lod@0x1471b70)\n"
15608 " )\n"
15609 " (\n"
15610 " ))\n"
15611 "\n"
15612 " (signature uvec4\n"
15613 " (parameters\n"
15614 " (declare (in ) usampler1D sampler@0x1471d50)\n"
15615 " (declare (in ) vec4 P@0x1471e60)\n"
15616 " (declare (in ) float lod@0x1471f70)\n"
15617 " )\n"
15618 " (\n"
15619 " ))\n"
15620 "\n"
15621 " (signature vec4\n"
15622 " (parameters\n"
15623 " (declare (in ) sampler2D sampler@0x1472150)\n"
15624 " (declare (in ) vec3 P@0x1472260)\n"
15625 " (declare (in ) float lod@0x1472370)\n"
15626 " )\n"
15627 " (\n"
15628 " ))\n"
15629 "\n"
15630 " (signature ivec4\n"
15631 " (parameters\n"
15632 " (declare (in ) isampler2D sampler@0x1472550)\n"
15633 " (declare (in ) vec3 P@0x1472660)\n"
15634 " (declare (in ) float lod@0x1472770)\n"
15635 " )\n"
15636 " (\n"
15637 " ))\n"
15638 "\n"
15639 " (signature uvec4\n"
15640 " (parameters\n"
15641 " (declare (in ) usampler2D sampler@0x1472950)\n"
15642 " (declare (in ) vec3 P@0x1472a60)\n"
15643 " (declare (in ) float lod@0x1472b70)\n"
15644 " )\n"
15645 " (\n"
15646 " ))\n"
15647 "\n"
15648 " (signature vec4\n"
15649 " (parameters\n"
15650 " (declare (in ) sampler2D sampler@0x1472d50)\n"
15651 " (declare (in ) vec4 P@0x1472e60)\n"
15652 " (declare (in ) float lod@0x1472f70)\n"
15653 " )\n"
15654 " (\n"
15655 " ))\n"
15656 "\n"
15657 " (signature ivec4\n"
15658 " (parameters\n"
15659 " (declare (in ) isampler2D sampler@0x1473150)\n"
15660 " (declare (in ) vec4 P@0x1473260)\n"
15661 " (declare (in ) float lod@0x1473370)\n"
15662 " )\n"
15663 " (\n"
15664 " ))\n"
15665 "\n"
15666 " (signature uvec4\n"
15667 " (parameters\n"
15668 " (declare (in ) usampler2D sampler@0x1473550)\n"
15669 " (declare (in ) vec4 P@0x1473660)\n"
15670 " (declare (in ) float lod@0x1473770)\n"
15671 " )\n"
15672 " (\n"
15673 " ))\n"
15674 "\n"
15675 " (signature vec4\n"
15676 " (parameters\n"
15677 " (declare (in ) sampler3D sampler@0x1473950)\n"
15678 " (declare (in ) vec4 P@0x1473a60)\n"
15679 " (declare (in ) float lod@0x1473b70)\n"
15680 " )\n"
15681 " (\n"
15682 " ))\n"
15683 "\n"
15684 " (signature ivec4\n"
15685 " (parameters\n"
15686 " (declare (in ) isampler3D sampler@0x1473d50)\n"
15687 " (declare (in ) vec4 P@0x1473e60)\n"
15688 " (declare (in ) float lod@0x1473f70)\n"
15689 " )\n"
15690 " (\n"
15691 " ))\n"
15692 "\n"
15693 " (signature uvec4\n"
15694 " (parameters\n"
15695 " (declare (in ) usampler3D sampler@0x1474150)\n"
15696 " (declare (in ) vec4 P@0x1474260)\n"
15697 " (declare (in ) float lod@0x1474370)\n"
15698 " )\n"
15699 " (\n"
15700 " ))\n"
15701 "\n"
15702 " (signature float\n"
15703 " (parameters\n"
15704 " (declare (in ) sampler1DShadow sampler@0x1474550)\n"
15705 " (declare (in ) vec4 P@0x1474660)\n"
15706 " (declare (in ) float lod@0x1474770)\n"
15707 " )\n"
15708 " (\n"
15709 " ))\n"
15710 "\n"
15711 " (signature float\n"
15712 " (parameters\n"
15713 " (declare (in ) sampler2DShadow sampler@0x1474950)\n"
15714 " (declare (in ) vec4 P@0x1474a60)\n"
15715 " (declare (in ) float lod@0x1474b70)\n"
15716 " )\n"
15717 " (\n"
15718 " ))\n"
15719 "\n"
15720 ")\n"
15721 "\n"
15722 "(function textureGrad\n"
15723 " (signature vec4\n"
15724 " (parameters\n"
15725 " (declare (in ) sampler1D sampler@0x1474d50)\n"
15726 " (declare (in ) float P@0x1474e60)\n"
15727 " (declare (in ) float dPdx@0x1474f70)\n"
15728 " (declare (in ) float dPdy@0x1475080)\n"
15729 " )\n"
15730 " (\n"
15731 " ))\n"
15732 "\n"
15733 " (signature ivec4\n"
15734 " (parameters\n"
15735 " (declare (in ) isampler1D sampler@0x1475410)\n"
15736 " (declare (in ) float P@0x1475520)\n"
15737 " (declare (in ) float dPdx@0x1475630)\n"
15738 " (declare (in ) float dPdy@0x1475740)\n"
15739 " )\n"
15740 " (\n"
15741 " ))\n"
15742 "\n"
15743 " (signature uvec4\n"
15744 " (parameters\n"
15745 " (declare (in ) usampler1D sampler@0x1475920)\n"
15746 " (declare (in ) float P@0x1475a30)\n"
15747 " (declare (in ) float dPdx@0x1475b40)\n"
15748 " (declare (in ) float dPdy@0x1475c50)\n"
15749 " )\n"
15750 " (\n"
15751 " ))\n"
15752 "\n"
15753 " (signature vec4\n"
15754 " (parameters\n"
15755 " (declare (in ) sampler2D sampler@0x1475e30)\n"
15756 " (declare (in ) vec2 P@0x1475f40)\n"
15757 " (declare (in ) vec2 dPdx@0x1476050)\n"
15758 " (declare (in ) vec2 dPdy@0x1476160)\n"
15759 " )\n"
15760 " (\n"
15761 " ))\n"
15762 "\n"
15763 " (signature ivec4\n"
15764 " (parameters\n"
15765 " (declare (in ) isampler2D sampler@0x1476340)\n"
15766 " (declare (in ) vec2 P@0x1476450)\n"
15767 " (declare (in ) vec2 dPdx@0x1476560)\n"
15768 " (declare (in ) vec2 dPdy@0x1476670)\n"
15769 " )\n"
15770 " (\n"
15771 " ))\n"
15772 "\n"
15773 " (signature uvec4\n"
15774 " (parameters\n"
15775 " (declare (in ) usampler2D sampler@0x1476850)\n"
15776 " (declare (in ) vec2 P@0x1476960)\n"
15777 " (declare (in ) vec2 dPdx@0x1476a70)\n"
15778 " (declare (in ) vec2 dPdy@0x1476b80)\n"
15779 " )\n"
15780 " (\n"
15781 " ))\n"
15782 "\n"
15783 " (signature vec4\n"
15784 " (parameters\n"
15785 " (declare (in ) sampler3D sampler@0x1476d60)\n"
15786 " (declare (in ) vec3 P@0x1476e70)\n"
15787 " (declare (in ) vec3 dPdx@0x1476f80)\n"
15788 " (declare (in ) vec3 dPdy@0x1477090)\n"
15789 " )\n"
15790 " (\n"
15791 " ))\n"
15792 "\n"
15793 " (signature ivec4\n"
15794 " (parameters\n"
15795 " (declare (in ) isampler3D sampler@0x1477270)\n"
15796 " (declare (in ) vec3 P@0x1477380)\n"
15797 " (declare (in ) vec3 dPdx@0x1477490)\n"
15798 " (declare (in ) vec3 dPdy@0x14775a0)\n"
15799 " )\n"
15800 " (\n"
15801 " ))\n"
15802 "\n"
15803 " (signature uvec4\n"
15804 " (parameters\n"
15805 " (declare (in ) usampler3D sampler@0x1477780)\n"
15806 " (declare (in ) vec3 P@0x1477890)\n"
15807 " (declare (in ) vec3 dPdx@0x14779a0)\n"
15808 " (declare (in ) vec3 dPdy@0x1477ab0)\n"
15809 " )\n"
15810 " (\n"
15811 " ))\n"
15812 "\n"
15813 " (signature vec4\n"
15814 " (parameters\n"
15815 " (declare (in ) samplerCube sampler@0x1477c90)\n"
15816 " (declare (in ) vec3 P@0x1477da0)\n"
15817 " (declare (in ) vec3 dPdx@0x1477eb0)\n"
15818 " (declare (in ) vec3 dPdy@0x1477fc0)\n"
15819 " )\n"
15820 " (\n"
15821 " ))\n"
15822 "\n"
15823 " (signature ivec4\n"
15824 " (parameters\n"
15825 " (declare (in ) isamplerCube sampler@0x14781a0)\n"
15826 " (declare (in ) vec3 P@0x14782b0)\n"
15827 " (declare (in ) vec3 dPdx@0x14783c0)\n"
15828 " (declare (in ) vec3 dPdy@0x14784d0)\n"
15829 " )\n"
15830 " (\n"
15831 " ))\n"
15832 "\n"
15833 " (signature uvec4\n"
15834 " (parameters\n"
15835 " (declare (in ) usamplerCube sampler@0x14786b0)\n"
15836 " (declare (in ) vec3 P@0x14787c0)\n"
15837 " (declare (in ) vec3 dPdx@0x14788d0)\n"
15838 " (declare (in ) vec3 dPdy@0x14789e0)\n"
15839 " )\n"
15840 " (\n"
15841 " ))\n"
15842 "\n"
15843 " (signature float\n"
15844 " (parameters\n"
15845 " (declare (in ) sampler1DShadow sampler@0x1478bc0)\n"
15846 " (declare (in ) vec3 P@0x1478cd0)\n"
15847 " (declare (in ) float dPdx@0x1478de0)\n"
15848 " (declare (in ) float dPdy@0x1478ef0)\n"
15849 " )\n"
15850 " (\n"
15851 " ))\n"
15852 "\n"
15853 " (signature float\n"
15854 " (parameters\n"
15855 " (declare (in ) sampler2DShadow sampler@0x14790d0)\n"
15856 " (declare (in ) vec3 P@0x14791e0)\n"
15857 " (declare (in ) vec2 dPdx@0x14792f0)\n"
15858 " (declare (in ) vec2 dPdy@0x1479400)\n"
15859 " )\n"
15860 " (\n"
15861 " ))\n"
15862 "\n"
15863 " (signature float\n"
15864 " (parameters\n"
15865 " (declare (in ) samplerCubeShadow sampler@0x14795e0)\n"
15866 " (declare (in ) vec4 P@0x14796f0)\n"
15867 " (declare (in ) vec3 dPdx@0x1479800)\n"
15868 " (declare (in ) vec3 dPdy@0x1479910)\n"
15869 " )\n"
15870 " (\n"
15871 " ))\n"
15872 "\n"
15873 " (signature vec4\n"
15874 " (parameters\n"
15875 " (declare (in ) sampler1DArray sampler@0x1479af0)\n"
15876 " (declare (in ) vec2 P@0x1479c00)\n"
15877 " (declare (in ) float dPdx@0x1479d10)\n"
15878 " (declare (in ) float dPdy@0x1479e20)\n"
15879 " )\n"
15880 " (\n"
15881 " ))\n"
15882 "\n"
15883 " (signature ivec4\n"
15884 " (parameters\n"
15885 " (declare (in ) isampler1DArray sampler@0x147a000)\n"
15886 " (declare (in ) vec2 P@0x147a110)\n"
15887 " (declare (in ) float dPdx@0x147a220)\n"
15888 " (declare (in ) float dPdy@0x147a330)\n"
15889 " )\n"
15890 " (\n"
15891 " ))\n"
15892 "\n"
15893 " (signature uvec4\n"
15894 " (parameters\n"
15895 " (declare (in ) usampler1DArray sampler@0x147a510)\n"
15896 " (declare (in ) vec2 P@0x147a620)\n"
15897 " (declare (in ) float dPdx@0x147a730)\n"
15898 " (declare (in ) float dPdy@0x147a840)\n"
15899 " )\n"
15900 " (\n"
15901 " ))\n"
15902 "\n"
15903 " (signature vec4\n"
15904 " (parameters\n"
15905 " (declare (in ) sampler2DArray sampler@0x147aa20)\n"
15906 " (declare (in ) vec3 P@0x147ab30)\n"
15907 " (declare (in ) vec2 dPdx@0x147ac40)\n"
15908 " (declare (in ) vec2 dPdy@0x147ad50)\n"
15909 " )\n"
15910 " (\n"
15911 " ))\n"
15912 "\n"
15913 " (signature ivec4\n"
15914 " (parameters\n"
15915 " (declare (in ) isampler2DArray sampler@0x147af30)\n"
15916 " (declare (in ) vec3 P@0x147b040)\n"
15917 " (declare (in ) vec2 dPdx@0x147b150)\n"
15918 " (declare (in ) vec2 dPdy@0x147b260)\n"
15919 " )\n"
15920 " (\n"
15921 " ))\n"
15922 "\n"
15923 " (signature uvec4\n"
15924 " (parameters\n"
15925 " (declare (in ) usampler2DArray sampler@0x147b440)\n"
15926 " (declare (in ) vec3 P@0x147b550)\n"
15927 " (declare (in ) vec2 dPdx@0x147b660)\n"
15928 " (declare (in ) vec2 dPdy@0x147b770)\n"
15929 " )\n"
15930 " (\n"
15931 " ))\n"
15932 "\n"
15933 " (signature float\n"
15934 " (parameters\n"
15935 " (declare (in ) sampler1DArrayShadow sampler@0x147b950)\n"
15936 " (declare (in ) vec3 P@0x147ba60)\n"
15937 " (declare (in ) float dPdx@0x147bb70)\n"
15938 " (declare (in ) float dPdy@0x147bc80)\n"
15939 " )\n"
15940 " (\n"
15941 " ))\n"
15942 "\n"
15943 " (signature float\n"
15944 " (parameters\n"
15945 " (declare (in ) sampler2DArrayShadow sampler@0x147be60)\n"
15946 " (declare (in ) vec4 P@0x147bf70)\n"
15947 " (declare (in ) vec2 dPdx@0x147c080)\n"
15948 " (declare (in ) vec2 dPdy@0x147c190)\n"
15949 " )\n"
15950 " (\n"
15951 " ))\n"
15952 "\n"
15953 ")\n"
15954 "\n"
15955 "(function textureProjGrad\n"
15956 " (signature vec4\n"
15957 " (parameters\n"
15958 " (declare (in ) sampler1D sampler@0x147c370)\n"
15959 " (declare (in ) vec2 P@0x147c480)\n"
15960 " (declare (in ) float dPdx@0x147c590)\n"
15961 " (declare (in ) float dPdy@0x147c6a0)\n"
15962 " )\n"
15963 " (\n"
15964 " ))\n"
15965 "\n"
15966 " (signature ivec4\n"
15967 " (parameters\n"
15968 " (declare (in ) isampler1D sampler@0x147ca30)\n"
15969 " (declare (in ) vec2 P@0x147cb40)\n"
15970 " (declare (in ) float dPdx@0x147cc50)\n"
15971 " (declare (in ) float dPdy@0x147cd60)\n"
15972 " )\n"
15973 " (\n"
15974 " ))\n"
15975 "\n"
15976 " (signature uvec4\n"
15977 " (parameters\n"
15978 " (declare (in ) usampler1D sampler@0x147cf40)\n"
15979 " (declare (in ) vec2 P@0x147d050)\n"
15980 " (declare (in ) float dPdx@0x147d160)\n"
15981 " (declare (in ) float dPdy@0x147d270)\n"
15982 " )\n"
15983 " (\n"
15984 " ))\n"
15985 "\n"
15986 " (signature vec4\n"
15987 " (parameters\n"
15988 " (declare (in ) sampler1D sampler@0x147d450)\n"
15989 " (declare (in ) vec4 P@0x147d560)\n"
15990 " (declare (in ) float dPdx@0x147d670)\n"
15991 " (declare (in ) float dPdy@0x147d780)\n"
15992 " )\n"
15993 " (\n"
15994 " ))\n"
15995 "\n"
15996 " (signature ivec4\n"
15997 " (parameters\n"
15998 " (declare (in ) isampler1D sampler@0x147d960)\n"
15999 " (declare (in ) vec4 P@0x147da70)\n"
16000 " (declare (in ) float dPdx@0x147db80)\n"
16001 " (declare (in ) float dPdy@0x147dc90)\n"
16002 " )\n"
16003 " (\n"
16004 " ))\n"
16005 "\n"
16006 " (signature uvec4\n"
16007 " (parameters\n"
16008 " (declare (in ) usampler1D sampler@0x147de70)\n"
16009 " (declare (in ) vec4 P@0x147df80)\n"
16010 " (declare (in ) float dPdx@0x147e090)\n"
16011 " (declare (in ) float dPdy@0x147e1a0)\n"
16012 " )\n"
16013 " (\n"
16014 " ))\n"
16015 "\n"
16016 " (signature vec4\n"
16017 " (parameters\n"
16018 " (declare (in ) sampler2D sampler@0x147e380)\n"
16019 " (declare (in ) vec3 P@0x147e490)\n"
16020 " (declare (in ) vec2 dPdx@0x147e5a0)\n"
16021 " (declare (in ) vec2 dPdy@0x147e6b0)\n"
16022 " )\n"
16023 " (\n"
16024 " ))\n"
16025 "\n"
16026 " (signature ivec4\n"
16027 " (parameters\n"
16028 " (declare (in ) isampler2D sampler@0x147e890)\n"
16029 " (declare (in ) vec3 P@0x147e9a0)\n"
16030 " (declare (in ) vec2 dPdx@0x147eab0)\n"
16031 " (declare (in ) vec2 dPdy@0x147ebc0)\n"
16032 " )\n"
16033 " (\n"
16034 " ))\n"
16035 "\n"
16036 " (signature uvec4\n"
16037 " (parameters\n"
16038 " (declare (in ) usampler2D sampler@0x147eda0)\n"
16039 " (declare (in ) vec3 P@0x147eeb0)\n"
16040 " (declare (in ) vec2 dPdx@0x147efc0)\n"
16041 " (declare (in ) vec2 dPdy@0x147f0d0)\n"
16042 " )\n"
16043 " (\n"
16044 " ))\n"
16045 "\n"
16046 " (signature vec4\n"
16047 " (parameters\n"
16048 " (declare (in ) sampler2D sampler@0x147f2b0)\n"
16049 " (declare (in ) vec4 P@0x147f3c0)\n"
16050 " (declare (in ) vec2 dPdx@0x147f4d0)\n"
16051 " (declare (in ) vec2 dPdy@0x147f5e0)\n"
16052 " )\n"
16053 " (\n"
16054 " ))\n"
16055 "\n"
16056 " (signature ivec4\n"
16057 " (parameters\n"
16058 " (declare (in ) isampler2D sampler@0x147f7c0)\n"
16059 " (declare (in ) vec4 P@0x147f8d0)\n"
16060 " (declare (in ) vec2 dPdx@0x147f9e0)\n"
16061 " (declare (in ) vec2 dPdy@0x147faf0)\n"
16062 " )\n"
16063 " (\n"
16064 " ))\n"
16065 "\n"
16066 " (signature uvec4\n"
16067 " (parameters\n"
16068 " (declare (in ) usampler2D sampler@0x147fcd0)\n"
16069 " (declare (in ) vec4 P@0x147fde0)\n"
16070 " (declare (in ) vec2 dPdx@0x147fef0)\n"
16071 " (declare (in ) vec2 dPdy@0x1480000)\n"
16072 " )\n"
16073 " (\n"
16074 " ))\n"
16075 "\n"
16076 " (signature vec4\n"
16077 " (parameters\n"
16078 " (declare (in ) sampler3D sampler@0x14801e0)\n"
16079 " (declare (in ) vec4 P@0x14802f0)\n"
16080 " (declare (in ) vec3 dPdx@0x1480400)\n"
16081 " (declare (in ) vec3 dPdy@0x1480510)\n"
16082 " )\n"
16083 " (\n"
16084 " ))\n"
16085 "\n"
16086 " (signature ivec4\n"
16087 " (parameters\n"
16088 " (declare (in ) isampler3D sampler@0x14806f0)\n"
16089 " (declare (in ) vec4 P@0x1480800)\n"
16090 " (declare (in ) vec3 dPdx@0x1480910)\n"
16091 " (declare (in ) vec3 dPdy@0x1480a20)\n"
16092 " )\n"
16093 " (\n"
16094 " ))\n"
16095 "\n"
16096 " (signature uvec4\n"
16097 " (parameters\n"
16098 " (declare (in ) usampler3D sampler@0x1480c00)\n"
16099 " (declare (in ) vec4 P@0x1480d10)\n"
16100 " (declare (in ) vec3 dPdx@0x1480e20)\n"
16101 " (declare (in ) vec3 dPdy@0x1480f30)\n"
16102 " )\n"
16103 " (\n"
16104 " ))\n"
16105 "\n"
16106 " (signature float\n"
16107 " (parameters\n"
16108 " (declare (in ) sampler1DShadow sampler@0x1481110)\n"
16109 " (declare (in ) vec4 P@0x1481220)\n"
16110 " (declare (in ) float dPdx@0x1481330)\n"
16111 " (declare (in ) float dPdy@0x1481440)\n"
16112 " )\n"
16113 " (\n"
16114 " ))\n"
16115 "\n"
16116 " (signature float\n"
16117 " (parameters\n"
16118 " (declare (in ) sampler2DShadow sampler@0x1481620)\n"
16119 " (declare (in ) vec4 P@0x1481730)\n"
16120 " (declare (in ) vec2 dPdx@0x1481840)\n"
16121 " (declare (in ) vec2 dPdy@0x1481950)\n"
16122 " )\n"
16123 " (\n"
16124 " ))\n"
16125 "\n"
16126 ")\n"
16127 "\n"
16128 "(function texture1D\n"
16129 " (signature vec4\n"
16130 " (parameters\n"
16131 " (declare (in ) sampler1D sampler@0x1481b30)\n"
16132 " (declare (in ) float coord@0x1481c40)\n"
16133 " )\n"
16134 " (\n"
16135 " ))\n"
16136 "\n"
16137 " (signature vec4\n"
16138 " (parameters\n"
16139 " (declare (in ) sampler1D sampler@0x1482760)\n"
16140 " (declare (in ) float coord@0x1482870)\n"
16141 " (declare (in ) float bias@0x1482980)\n"
16142 " )\n"
16143 " (\n"
16144 " ))\n"
16145 "\n"
16146 ")\n"
16147 "\n"
16148 "(function texture1DProj\n"
16149 " (signature vec4\n"
16150 " (parameters\n"
16151 " (declare (in ) sampler1D sampler@0x1481fd0)\n"
16152 " (declare (in ) vec2 coord@0x14820e0)\n"
16153 " )\n"
16154 " (\n"
16155 " ))\n"
16156 "\n"
16157 " (signature vec4\n"
16158 " (parameters\n"
16159 " (declare (in ) sampler1D sampler@0x1482470)\n"
16160 " (declare (in ) vec4 coord@0x1482580)\n"
16161 " )\n"
16162 " (\n"
16163 " ))\n"
16164 "\n"
16165 " (signature vec4\n"
16166 " (parameters\n"
16167 " (declare (in ) sampler1D sampler@0x1482b60)\n"
16168 " (declare (in ) vec2 coord@0x1482c70)\n"
16169 " (declare (in ) float bias@0x1482d80)\n"
16170 " )\n"
16171 " (\n"
16172 " ))\n"
16173 "\n"
16174 " (signature vec4\n"
16175 " (parameters\n"
16176 " (declare (in ) sampler1D sampler@0x1482f60)\n"
16177 " (declare (in ) vec4 coord@0x1483070)\n"
16178 " (declare (in ) float bias@0x1483180)\n"
16179 " )\n"
16180 " (\n"
16181 " ))\n"
16182 "\n"
16183 ")\n"
16184 "\n"
16185 "(function texture1DLod\n"
16186 " (signature vec4\n"
16187 " (parameters\n"
16188 " (declare (in ) sampler1D sampler@0x1483360)\n"
16189 " (declare (in ) float coord@0x1483470)\n"
16190 " (declare (in ) float lod@0x1483580)\n"
16191 " )\n"
16192 " (\n"
16193 " ))\n"
16194 "\n"
16195 ")\n"
16196 "\n"
16197 "(function texture1DProjLod\n"
16198 " (signature vec4\n"
16199 " (parameters\n"
16200 " (declare (in ) sampler1D sampler@0x1483910)\n"
16201 " (declare (in ) vec2 coord@0x1483a20)\n"
16202 " (declare (in ) float lod@0x1483b30)\n"
16203 " )\n"
16204 " (\n"
16205 " ))\n"
16206 "\n"
16207 " (signature vec4\n"
16208 " (parameters\n"
16209 " (declare (in ) sampler1D sampler@0x1483ec0)\n"
16210 " (declare (in ) vec4 coord@0x1483fd0)\n"
16211 " (declare (in ) float lod@0x14840e0)\n"
16212 " )\n"
16213 " (\n"
16214 " ))\n"
16215 "\n"
16216 ")\n"
16217 "\n"
16218 "(function texture2D\n"
16219 " (signature vec4\n"
16220 " (parameters\n"
16221 " (declare (in ) sampler2D sampler@0x14842c0)\n"
16222 " (declare (in ) vec2 coord@0x14843d0)\n"
16223 " )\n"
16224 " (\n"
16225 " ))\n"
16226 "\n"
16227 " (signature vec4\n"
16228 " (parameters\n"
16229 " (declare (in ) sampler2D sampler@0x1484ef0)\n"
16230 " (declare (in ) vec2 coord@0x1485000)\n"
16231 " (declare (in ) float bias@0x1485110)\n"
16232 " )\n"
16233 " (\n"
16234 " ))\n"
16235 "\n"
16236 ")\n"
16237 "\n"
16238 "(function texture2DProj\n"
16239 " (signature vec4\n"
16240 " (parameters\n"
16241 " (declare (in ) sampler2D sampler@0x1484760)\n"
16242 " (declare (in ) vec3 coord@0x1484870)\n"
16243 " )\n"
16244 " (\n"
16245 " ))\n"
16246 "\n"
16247 " (signature vec4\n"
16248 " (parameters\n"
16249 " (declare (in ) sampler2D sampler@0x1484c00)\n"
16250 " (declare (in ) vec4 coord@0x1484d10)\n"
16251 " )\n"
16252 " (\n"
16253 " ))\n"
16254 "\n"
16255 " (signature vec4\n"
16256 " (parameters\n"
16257 " (declare (in ) sampler2D sampler@0x14852f0)\n"
16258 " (declare (in ) vec3 coord@0x1485400)\n"
16259 " (declare (in ) float bias@0x1485510)\n"
16260 " )\n"
16261 " (\n"
16262 " ))\n"
16263 "\n"
16264 " (signature vec4\n"
16265 " (parameters\n"
16266 " (declare (in ) sampler2D sampler@0x14856f0)\n"
16267 " (declare (in ) vec4 coord@0x1485800)\n"
16268 " (declare (in ) float bias@0x1485910)\n"
16269 " )\n"
16270 " (\n"
16271 " ))\n"
16272 "\n"
16273 ")\n"
16274 "\n"
16275 "(function texture2DLod\n"
16276 " (signature vec4\n"
16277 " (parameters\n"
16278 " (declare (in ) sampler2D sampler@0x1485af0)\n"
16279 " (declare (in ) vec2 coord@0x1485c00)\n"
16280 " (declare (in ) float lod@0x1485d10)\n"
16281 " )\n"
16282 " (\n"
16283 " ))\n"
16284 "\n"
16285 ")\n"
16286 "\n"
16287 "(function texture2DProjLod\n"
16288 " (signature vec4\n"
16289 " (parameters\n"
16290 " (declare (in ) sampler2D sampler@0x14860a0)\n"
16291 " (declare (in ) vec3 coord@0x14861b0)\n"
16292 " (declare (in ) float lod@0x14862c0)\n"
16293 " )\n"
16294 " (\n"
16295 " ))\n"
16296 "\n"
16297 " (signature vec4\n"
16298 " (parameters\n"
16299 " (declare (in ) sampler2D sampler@0x1486650)\n"
16300 " (declare (in ) vec4 coord@0x1486760)\n"
16301 " (declare (in ) float lod@0x1486870)\n"
16302 " )\n"
16303 " (\n"
16304 " ))\n"
16305 "\n"
16306 ")\n"
16307 "\n"
16308 "(function texture3D\n"
16309 " (signature vec4\n"
16310 " (parameters\n"
16311 " (declare (in ) sampler3D sampler@0x1486a50)\n"
16312 " (declare (in ) vec3 coord@0x1486b60)\n"
16313 " )\n"
16314 " (\n"
16315 " ))\n"
16316 "\n"
16317 " (signature vec4\n"
16318 " (parameters\n"
16319 " (declare (in ) sampler3D sampler@0x1487390)\n"
16320 " (declare (in ) vec3 coord@0x14874a0)\n"
16321 " (declare (in ) float bias@0x14875b0)\n"
16322 " )\n"
16323 " (\n"
16324 " ))\n"
16325 "\n"
16326 ")\n"
16327 "\n"
16328 "(function texture3DProj\n"
16329 " (signature vec4\n"
16330 " (parameters\n"
16331 " (declare (in ) sampler3D sampler@0x1486ef0)\n"
16332 " (declare (in ) vec4 coord@0x1487000)\n"
16333 " )\n"
16334 " (\n"
16335 " ))\n"
16336 "\n"
16337 " (signature vec4\n"
16338 " (parameters\n"
16339 " (declare (in ) sampler3D sampler@0x1487790)\n"
16340 " (declare (in ) vec4 coord@0x14878a0)\n"
16341 " (declare (in ) float bias@0x14879b0)\n"
16342 " )\n"
16343 " (\n"
16344 " ))\n"
16345 "\n"
16346 ")\n"
16347 "\n"
16348 "(function texture3DLod\n"
16349 " (signature vec4\n"
16350 " (parameters\n"
16351 " (declare (in ) sampler3D sampler@0x1487b90)\n"
16352 " (declare (in ) vec3 coord@0x1487ca0)\n"
16353 " (declare (in ) float lod@0x1487db0)\n"
16354 " )\n"
16355 " (\n"
16356 " ))\n"
16357 "\n"
16358 ")\n"
16359 "\n"
16360 "(function texture3DProjLod\n"
16361 " (signature vec4\n"
16362 " (parameters\n"
16363 " (declare (in ) sampler3D sampler@0x1488140)\n"
16364 " (declare (in ) vec4 coord@0x1488250)\n"
16365 " (declare (in ) float lod@0x1488360)\n"
16366 " )\n"
16367 " (\n"
16368 " ))\n"
16369 "\n"
16370 ")\n"
16371 "\n"
16372 "(function textureCube\n"
16373 " (signature vec4\n"
16374 " (parameters\n"
16375 " (declare (in ) samplerCube sampler@0x14886f0)\n"
16376 " (declare (in ) vec3 coord@0x1488800)\n"
16377 " )\n"
16378 " (\n"
16379 " ))\n"
16380 "\n"
16381 " (signature vec4\n"
16382 " (parameters\n"
16383 " (declare (in ) samplerCube sampler@0x1488b90)\n"
16384 " (declare (in ) vec3 coord@0x1488ca0)\n"
16385 " (declare (in ) float bias@0x1488db0)\n"
16386 " )\n"
16387 " (\n"
16388 " ))\n"
16389 "\n"
16390 ")\n"
16391 "\n"
16392 "(function textureCubeLod\n"
16393 " (signature vec4\n"
16394 " (parameters\n"
16395 " (declare (in ) samplerCube sampler@0x1488f90)\n"
16396 " (declare (in ) vec3 coord@0x14890a0)\n"
16397 " (declare (in ) float lod@0x14891b0)\n"
16398 " )\n"
16399 " (\n"
16400 " ))\n"
16401 "\n"
16402 ")\n"
16403 "\n"
16404 "(function shadow1D\n"
16405 " (signature vec4\n"
16406 " (parameters\n"
16407 " (declare (in ) sampler1DShadow sampler@0x1489540)\n"
16408 " (declare (in ) vec3 coord@0x1489650)\n"
16409 " )\n"
16410 " (\n"
16411 " ))\n"
16412 "\n"
16413 " (signature vec4\n"
16414 " (parameters\n"
16415 " (declare (in ) sampler1DShadow sampler@0x148a7c0)\n"
16416 " (declare (in ) vec3 coord@0x148a8d0)\n"
16417 " (declare (in ) float bias@0x148a9e0)\n"
16418 " )\n"
16419 " (\n"
16420 " ))\n"
16421 "\n"
16422 ")\n"
16423 "\n"
16424 "(function shadow2D\n"
16425 " (signature vec4\n"
16426 " (parameters\n"
16427 " (declare (in ) sampler2DShadow sampler@0x14899e0)\n"
16428 " (declare (in ) vec3 coord@0x1489af0)\n"
16429 " )\n"
16430 " (\n"
16431 " ))\n"
16432 "\n"
16433 " (signature vec4\n"
16434 " (parameters\n"
16435 " (declare (in ) sampler2DShadow sampler@0x148abc0)\n"
16436 " (declare (in ) vec3 coord@0x148acd0)\n"
16437 " (declare (in ) float bias@0x148ade0)\n"
16438 " )\n"
16439 " (\n"
16440 " ))\n"
16441 "\n"
16442 ")\n"
16443 "\n"
16444 "(function shadow1DProj\n"
16445 " (signature vec4\n"
16446 " (parameters\n"
16447 " (declare (in ) sampler1DShadow sampler@0x1489e80)\n"
16448 " (declare (in ) vec4 coord@0x1489f90)\n"
16449 " )\n"
16450 " (\n"
16451 " ))\n"
16452 "\n"
16453 " (signature vec4\n"
16454 " (parameters\n"
16455 " (declare (in ) sampler1DShadow sampler@0x148afc0)\n"
16456 " (declare (in ) vec4 coord@0x148b0d0)\n"
16457 " (declare (in ) float bias@0x148b1e0)\n"
16458 " )\n"
16459 " (\n"
16460 " ))\n"
16461 "\n"
16462 ")\n"
16463 "\n"
16464 "(function shadow2DProj\n"
16465 " (signature vec4\n"
16466 " (parameters\n"
16467 " (declare (in ) sampler2DShadow sampler@0x148a320)\n"
16468 " (declare (in ) vec4 coord@0x148a430)\n"
16469 " )\n"
16470 " (\n"
16471 " ))\n"
16472 "\n"
16473 " (signature vec4\n"
16474 " (parameters\n"
16475 " (declare (in ) sampler2DShadow sampler@0x148b3c0)\n"
16476 " (declare (in ) vec4 coord@0x148b4d0)\n"
16477 " (declare (in ) float bias@0x148b5e0)\n"
16478 " )\n"
16479 " (\n"
16480 " ))\n"
16481 "\n"
16482 ")\n"
16483 "\n"
16484 "(function shadow1DLod\n"
16485 " (signature vec4\n"
16486 " (parameters\n"
16487 " (declare (in ) sampler1DShadow sampler@0x148b7c0)\n"
16488 " (declare (in ) vec3 coord@0x148b8d0)\n"
16489 " (declare (in ) float lod@0x148b9e0)\n"
16490 " )\n"
16491 " (\n"
16492 " ))\n"
16493 "\n"
16494 ")\n"
16495 "\n"
16496 "(function shadow2DLod\n"
16497 " (signature vec4\n"
16498 " (parameters\n"
16499 " (declare (in ) sampler2DShadow sampler@0x148bd70)\n"
16500 " (declare (in ) vec3 coord@0x148be80)\n"
16501 " (declare (in ) float lod@0x148bf90)\n"
16502 " )\n"
16503 " (\n"
16504 " ))\n"
16505 "\n"
16506 ")\n"
16507 "\n"
16508 "(function shadow1DProjLod\n"
16509 " (signature vec4\n"
16510 " (parameters\n"
16511 " (declare (in ) sampler1DShadow sampler@0x148c320)\n"
16512 " (declare (in ) vec4 coord@0x148c430)\n"
16513 " (declare (in ) float lod@0x148c540)\n"
16514 " )\n"
16515 " (\n"
16516 " ))\n"
16517 "\n"
16518 ")\n"
16519 "\n"
16520 "(function shadow2DProjLod\n"
16521 " (signature vec4\n"
16522 " (parameters\n"
16523 " (declare (in ) sampler2DShadow sampler@0x148c8d0)\n"
16524 " (declare (in ) vec4 coord@0x148c9e0)\n"
16525 " (declare (in ) float lod@0x148caf0)\n"
16526 " )\n"
16527 " (\n"
16528 " ))\n"
16529 "\n"
16530 ")\n"
16531 "\n"
16532 "(function dFdx\n"
16533 " (signature float\n"
16534 " (parameters\n"
16535 " (declare (in ) float p@0x148ce80)\n"
16536 " )\n"
16537 " (\n"
16538 " ))\n"
16539 "\n"
16540 " (signature vec2\n"
16541 " (parameters\n"
16542 " (declare (in ) vec2 p@0x148d200)\n"
16543 " )\n"
16544 " (\n"
16545 " ))\n"
16546 "\n"
16547 " (signature vec3\n"
16548 " (parameters\n"
16549 " (declare (in ) vec3 p@0x148d3e0)\n"
16550 " )\n"
16551 " (\n"
16552 " ))\n"
16553 "\n"
16554 " (signature vec4\n"
16555 " (parameters\n"
16556 " (declare (in ) vec4 p@0x148d5c0)\n"
16557 " )\n"
16558 " (\n"
16559 " ))\n"
16560 "\n"
16561 ")\n"
16562 "\n"
16563 "(function dFdy\n"
16564 " (signature float\n"
16565 " (parameters\n"
16566 " (declare (in ) float p@0x148d7a0)\n"
16567 " )\n"
16568 " (\n"
16569 " ))\n"
16570 "\n"
16571 " (signature vec2\n"
16572 " (parameters\n"
16573 " (declare (in ) vec2 p@0x148db20)\n"
16574 " )\n"
16575 " (\n"
16576 " ))\n"
16577 "\n"
16578 " (signature vec3\n"
16579 " (parameters\n"
16580 " (declare (in ) vec3 p@0x148dd00)\n"
16581 " )\n"
16582 " (\n"
16583 " ))\n"
16584 "\n"
16585 " (signature vec4\n"
16586 " (parameters\n"
16587 " (declare (in ) vec4 p@0x148dee0)\n"
16588 " )\n"
16589 " (\n"
16590 " ))\n"
16591 "\n"
16592 ")\n"
16593 "\n"
16594 "(function fwidth\n"
16595 " (signature float\n"
16596 " (parameters\n"
16597 " (declare (in ) float p@0x148e0c0)\n"
16598 " )\n"
16599 " (\n"
16600 " ))\n"
16601 "\n"
16602 " (signature vec2\n"
16603 " (parameters\n"
16604 " (declare (in ) vec2 p@0x148e440)\n"
16605 " )\n"
16606 " (\n"
16607 " ))\n"
16608 "\n"
16609 " (signature vec3\n"
16610 " (parameters\n"
16611 " (declare (in ) vec3 p@0x148e620)\n"
16612 " )\n"
16613 " (\n"
16614 " ))\n"
16615 "\n"
16616 " (signature vec4\n"
16617 " (parameters\n"
16618 " (declare (in ) vec4 p@0x148e800)\n"
16619 " )\n"
16620 " (\n"
16621 " ))\n"
16622 "\n"
16623 ")\n"
16624 "\n"
16625 "(function noise1\n"
16626 " (signature float\n"
16627 " (parameters\n"
16628 " (declare (in ) float x@0x148e9e0)\n"
16629 " )\n"
16630 " (\n"
16631 " ))\n"
16632 "\n"
16633 " (signature float\n"
16634 " (parameters\n"
16635 " (declare (in ) vec2 x@0x148ed60)\n"
16636 " )\n"
16637 " (\n"
16638 " ))\n"
16639 "\n"
16640 " (signature float\n"
16641 " (parameters\n"
16642 " (declare (in ) vec3 x@0x148ef40)\n"
16643 " )\n"
16644 " (\n"
16645 " ))\n"
16646 "\n"
16647 " (signature float\n"
16648 " (parameters\n"
16649 " (declare (in ) vec4 x@0x148f120)\n"
16650 " )\n"
16651 " (\n"
16652 " ))\n"
16653 "\n"
16654 ")\n"
16655 "\n"
16656 "(function noise2\n"
16657 " (signature vec2\n"
16658 " (parameters\n"
16659 " (declare (in ) float x@0x148f300)\n"
16660 " )\n"
16661 " (\n"
16662 " ))\n"
16663 "\n"
16664 " (signature vec2\n"
16665 " (parameters\n"
16666 " (declare (in ) vec2 x@0x148f680)\n"
16667 " )\n"
16668 " (\n"
16669 " ))\n"
16670 "\n"
16671 " (signature vec2\n"
16672 " (parameters\n"
16673 " (declare (in ) vec3 x@0x148f860)\n"
16674 " )\n"
16675 " (\n"
16676 " ))\n"
16677 "\n"
16678 " (signature vec2\n"
16679 " (parameters\n"
16680 " (declare (in ) vec4 x@0x148fa40)\n"
16681 " )\n"
16682 " (\n"
16683 " ))\n"
16684 "\n"
16685 ")\n"
16686 "\n"
16687 "(function noise3\n"
16688 " (signature vec3\n"
16689 " (parameters\n"
16690 " (declare (in ) float x@0x148fc20)\n"
16691 " )\n"
16692 " (\n"
16693 " ))\n"
16694 "\n"
16695 " (signature vec3\n"
16696 " (parameters\n"
16697 " (declare (in ) vec2 x@0x148ffa0)\n"
16698 " )\n"
16699 " (\n"
16700 " ))\n"
16701 "\n"
16702 " (signature vec3\n"
16703 " (parameters\n"
16704 " (declare (in ) vec3 x@0x1490180)\n"
16705 " )\n"
16706 " (\n"
16707 " ))\n"
16708 "\n"
16709 " (signature vec3\n"
16710 " (parameters\n"
16711 " (declare (in ) vec4 x@0x1490360)\n"
16712 " )\n"
16713 " (\n"
16714 " ))\n"
16715 "\n"
16716 ")\n"
16717 "\n"
16718 "(function noise4\n"
16719 " (signature vec4\n"
16720 " (parameters\n"
16721 " (declare (in ) float x@0x1490540)\n"
16722 " )\n"
16723 " (\n"
16724 " ))\n"
16725 "\n"
16726 " (signature vec4\n"
16727 " (parameters\n"
16728 " (declare (in ) vec2 x@0x14908c0)\n"
16729 " )\n"
16730 " (\n"
16731 " ))\n"
16732 "\n"
16733 " (signature vec4\n"
16734 " (parameters\n"
16735 " (declare (in ) vec3 x@0x1490aa0)\n"
16736 " )\n"
16737 " (\n"
16738 " ))\n"
16739 "\n"
16740 " (signature vec4\n"
16741 " (parameters\n"
16742 " (declare (in ) vec4 x@0x1490c80)\n"
16743 " )\n"
16744 " (\n"
16745 " ))\n"
16746 "\n"
16747 ")\n"
16748 "\n"
16749 "\n"
16750 ")"
16751;
16752static const char *functions_for_130_frag [] = {
16753 builtin_clamp,
16754 builtin_matrixCompMult,
16755 builtin_textureProj,
16756 builtin_noise2,
16757 builtin_texture3DProjLod,
16758 builtin_pow,
16759 builtin_texture2DProj,
16760 builtin_fwidth,
16761 builtin_greaterThanEqual,
16762 builtin_sign,
16763 builtin_texture3DProj,
16764 builtin_textureProjLod,
16765 builtin_texture,
16766 builtin_texture2D,
16767 builtin_equal,
16768 builtin_faceforward,
16769 builtin_tan,
16770 builtin_shadow2DProj,
16771 builtin_shadow1DProjLod,
16772 builtin_any,
16773 builtin_shadow1DProj,
16774 builtin_normalize,
16775 builtin_asin,
16776 builtin_texture1DProj,
16777 builtin_log,
16778 builtin_floor,
16779 builtin_exp2,
16780 builtin_lessThan,
16781 builtin_cross,
16782 builtin_sqrt,
16783 builtin_texture3DLod,
16784 builtin_textureLod,
16785 builtin_fract,
16786 builtin_abs,
16787 builtin_degrees,
16788 builtin_shadow1DLod,
16789 builtin_dFdx,
16790 builtin_sin,
16791 builtin_shadow2D,
16792 builtin_shadow2DLod,
16793 builtin_all,
16794 builtin_log2,
16795 builtin_textureGrad,
16796 builtin_atan,
16797 builtin_notEqual,
16798 builtin_max,
16799 builtin_lessThanEqual,
16800 builtin_transpose,
16801 builtin_outerProduct,
16802 builtin_ceil,
16803 builtin_reflect,
16804 builtin_textureCubeLod,
16805 builtin_step,
16806 builtin_texture1D,
16807 builtin_greaterThan,
16808 builtin_texture3D,
16809 builtin_shadow2DProjLod,
16810 builtin_not,
16811 builtin_texture2DProjLod,
16812 builtin_dFdy,
16813 builtin_inversesqrt,
16814 builtin_mod,
16815 builtin_noise4,
16816 builtin_distance,
16817 builtin_cos,
16818 builtin_shadow1D,
16819 builtin_noise1,
16820 builtin_refract,
16821 builtin_noise3,
16822 builtin_texelFetch,
16823 builtin_min,
16824 builtin_radians,
16825 builtin_smoothstep,
16826 builtin_textureProjGrad,
16827 builtin_texture1DProjLod,
16828 builtin_textureCube,
16829 builtin_length,
16830 builtin_texture1DLod,
16831 builtin_texture2DLod,
16832 builtin_exp,
16833 builtin_acos,
16834 builtin_mix,
16835 builtin_dot,
16836};
16837static const char *prototypes_for_ARB_texture_rectangle_vert =
16838 "(\n"
16839 "(function texture2DRect\n"
16840 " (signature vec4\n"
16841 " (parameters\n"
16842 " (declare (in ) sampler2DRect sampler@0x9f07b0)\n"
16843 " (declare (in ) vec2 coord@0x9f08c0)\n"
16844 " )\n"
16845 " (\n"
16846 " ))\n"
16847 "\n"
16848 ")\n"
16849 "\n"
16850 "(function texture2DRectProj\n"
16851 " (signature vec4\n"
16852 " (parameters\n"
16853 " (declare (in ) sampler2DRect sampler@0x9f0c50)\n"
16854 " (declare (in ) vec3 coord@0x9f0d60)\n"
16855 " )\n"
16856 " (\n"
16857 " ))\n"
16858 "\n"
16859 " (signature vec4\n"
16860 " (parameters\n"
16861 " (declare (in ) sampler2DRect sampler@0x9f10f0)\n"
16862 " (declare (in ) vec4 coord@0x9f1200)\n"
16863 " )\n"
16864 " (\n"
16865 " ))\n"
16866 "\n"
16867 ")\n"
16868 "\n"
16869 "(function shadow2DRect\n"
16870 " (signature vec4\n"
16871 " (parameters\n"
16872 " (declare (in ) sampler2DRectShadow sampler@0x9f13e0)\n"
16873 " (declare (in ) vec3 coord@0x9f14f0)\n"
16874 " )\n"
16875 " (\n"
16876 " ))\n"
16877 "\n"
16878 ")\n"
16879 "\n"
16880 "(function shadow2DRectProj\n"
16881 " (signature vec4\n"
16882 " (parameters\n"
16883 " (declare (in ) sampler2DRectShadow sampler@0x9f1880)\n"
16884 " (declare (in ) vec4 coord@0x9f1990)\n"
16885 " )\n"
16886 " (\n"
16887 " ))\n"
16888 "\n"
16889 ")\n"
16890 "\n"
16891 "\n"
16892 ")"
16893;
16894static const char *functions_for_ARB_texture_rectangle_vert [] = {
16895 builtin_texture2DRect,
16896 builtin_shadow2DRectProj,
16897 builtin_shadow2DRect,
16898 builtin_texture2DRectProj,
16899};
16900static const char *prototypes_for_130_vert =
16901 "(\n"
16902 "(function radians\n"
16903 " (signature float\n"
16904 " (parameters\n"
16905 " (declare (in ) float degrees@0x16a1fa0)\n"
16906 " )\n"
16907 " (\n"
16908 " ))\n"
16909 "\n"
16910 " (signature vec2\n"
16911 " (parameters\n"
16912 " (declare (in ) vec2 degrees@0x16a2320)\n"
16913 " )\n"
16914 " (\n"
16915 " ))\n"
16916 "\n"
16917 " (signature vec3\n"
16918 " (parameters\n"
16919 " (declare (in ) vec3 degrees@0x16a2500)\n"
16920 " )\n"
16921 " (\n"
16922 " ))\n"
16923 "\n"
16924 " (signature vec4\n"
16925 " (parameters\n"
16926 " (declare (in ) vec4 degrees@0x16a26e0)\n"
16927 " )\n"
16928 " (\n"
16929 " ))\n"
16930 "\n"
16931 ")\n"
16932 "\n"
16933 "(function degrees\n"
16934 " (signature float\n"
16935 " (parameters\n"
16936 " (declare (in ) float radians@0x16a28c0)\n"
16937 " )\n"
16938 " (\n"
16939 " ))\n"
16940 "\n"
16941 " (signature vec2\n"
16942 " (parameters\n"
16943 " (declare (in ) vec2 radians@0x16a2c40)\n"
16944 " )\n"
16945 " (\n"
16946 " ))\n"
16947 "\n"
16948 " (signature vec3\n"
16949 " (parameters\n"
16950 " (declare (in ) vec3 radians@0x16a2e20)\n"
16951 " )\n"
16952 " (\n"
16953 " ))\n"
16954 "\n"
16955 " (signature vec4\n"
16956 " (parameters\n"
16957 " (declare (in ) vec4 radians@0x16a3000)\n"
16958 " )\n"
16959 " (\n"
16960 " ))\n"
16961 "\n"
16962 ")\n"
16963 "\n"
16964 "(function sin\n"
16965 " (signature float\n"
16966 " (parameters\n"
16967 " (declare (in ) float angle@0x16a31e0)\n"
16968 " )\n"
16969 " (\n"
16970 " ))\n"
16971 "\n"
16972 " (signature vec2\n"
16973 " (parameters\n"
16974 " (declare (in ) vec2 angle@0x16a3560)\n"
16975 " )\n"
16976 " (\n"
16977 " ))\n"
16978 "\n"
16979 " (signature vec3\n"
16980 " (parameters\n"
16981 " (declare (in ) vec3 angle@0x16a3740)\n"
16982 " )\n"
16983 " (\n"
16984 " ))\n"
16985 "\n"
16986 " (signature vec4\n"
16987 " (parameters\n"
16988 " (declare (in ) vec4 angle@0x16a3920)\n"
16989 " )\n"
16990 " (\n"
16991 " ))\n"
16992 "\n"
16993 ")\n"
16994 "\n"
16995 "(function cos\n"
16996 " (signature float\n"
16997 " (parameters\n"
16998 " (declare (in ) float angle@0x16a3b00)\n"
16999 " )\n"
17000 " (\n"
17001 " ))\n"
17002 "\n"
17003 " (signature vec2\n"
17004 " (parameters\n"
17005 " (declare (in ) vec2 angle@0x16a3e80)\n"
17006 " )\n"
17007 " (\n"
17008 " ))\n"
17009 "\n"
17010 " (signature vec3\n"
17011 " (parameters\n"
17012 " (declare (in ) vec3 angle@0x16a4060)\n"
17013 " )\n"
17014 " (\n"
17015 " ))\n"
17016 "\n"
17017 " (signature vec4\n"
17018 " (parameters\n"
17019 " (declare (in ) vec4 angle@0x16a4240)\n"
17020 " )\n"
17021 " (\n"
17022 " ))\n"
17023 "\n"
17024 ")\n"
17025 "\n"
17026 "(function tan\n"
17027 " (signature float\n"
17028 " (parameters\n"
17029 " (declare (in ) float angle@0x16a4420)\n"
17030 " )\n"
17031 " (\n"
17032 " ))\n"
17033 "\n"
17034 " (signature vec2\n"
17035 " (parameters\n"
17036 " (declare (in ) vec2 angle@0x16a47a0)\n"
17037 " )\n"
17038 " (\n"
17039 " ))\n"
17040 "\n"
17041 " (signature vec3\n"
17042 " (parameters\n"
17043 " (declare (in ) vec3 angle@0x16a4980)\n"
17044 " )\n"
17045 " (\n"
17046 " ))\n"
17047 "\n"
17048 " (signature vec4\n"
17049 " (parameters\n"
17050 " (declare (in ) vec4 angle@0x16a4b60)\n"
17051 " )\n"
17052 " (\n"
17053 " ))\n"
17054 "\n"
17055 ")\n"
17056 "\n"
17057 "(function asin\n"
17058 " (signature float\n"
17059 " (parameters\n"
17060 " (declare (in ) float angle@0x16a4d40)\n"
17061 " )\n"
17062 " (\n"
17063 " ))\n"
17064 "\n"
17065 " (signature vec2\n"
17066 " (parameters\n"
17067 " (declare (in ) vec2 angle@0x16a50c0)\n"
17068 " )\n"
17069 " (\n"
17070 " ))\n"
17071 "\n"
17072 " (signature vec3\n"
17073 " (parameters\n"
17074 " (declare (in ) vec3 angle@0x16a52a0)\n"
17075 " )\n"
17076 " (\n"
17077 " ))\n"
17078 "\n"
17079 " (signature vec4\n"
17080 " (parameters\n"
17081 " (declare (in ) vec4 angle@0x16a5480)\n"
17082 " )\n"
17083 " (\n"
17084 " ))\n"
17085 "\n"
17086 ")\n"
17087 "\n"
17088 "(function acos\n"
17089 " (signature float\n"
17090 " (parameters\n"
17091 " (declare (in ) float angle@0x16a5660)\n"
17092 " )\n"
17093 " (\n"
17094 " ))\n"
17095 "\n"
17096 " (signature vec2\n"
17097 " (parameters\n"
17098 " (declare (in ) vec2 angle@0x16a59e0)\n"
17099 " )\n"
17100 " (\n"
17101 " ))\n"
17102 "\n"
17103 " (signature vec3\n"
17104 " (parameters\n"
17105 " (declare (in ) vec3 angle@0x16a5bc0)\n"
17106 " )\n"
17107 " (\n"
17108 " ))\n"
17109 "\n"
17110 " (signature vec4\n"
17111 " (parameters\n"
17112 " (declare (in ) vec4 angle@0x16a5da0)\n"
17113 " )\n"
17114 " (\n"
17115 " ))\n"
17116 "\n"
17117 ")\n"
17118 "\n"
17119 "(function atan\n"
17120 " (signature float\n"
17121 " (parameters\n"
17122 " (declare (in ) float y@0x16a5f80)\n"
17123 " (declare (in ) float x@0x16a6090)\n"
17124 " )\n"
17125 " (\n"
17126 " ))\n"
17127 "\n"
17128 " (signature vec2\n"
17129 " (parameters\n"
17130 " (declare (in ) vec2 y@0x16a6410)\n"
17131 " (declare (in ) vec2 x@0x16a6520)\n"
17132 " )\n"
17133 " (\n"
17134 " ))\n"
17135 "\n"
17136 " (signature vec3\n"
17137 " (parameters\n"
17138 " (declare (in ) vec3 y@0x16a6700)\n"
17139 " (declare (in ) vec3 x@0x16a6810)\n"
17140 " )\n"
17141 " (\n"
17142 " ))\n"
17143 "\n"
17144 " (signature vec4\n"
17145 " (parameters\n"
17146 " (declare (in ) vec4 y@0x16a69f0)\n"
17147 " (declare (in ) vec4 x@0x16a6b00)\n"
17148 " )\n"
17149 " (\n"
17150 " ))\n"
17151 "\n"
17152 " (signature float\n"
17153 " (parameters\n"
17154 " (declare (in ) float y_over_x@0x16a6ce0)\n"
17155 " )\n"
17156 " (\n"
17157 " ))\n"
17158 "\n"
17159 " (signature vec2\n"
17160 " (parameters\n"
17161 " (declare (in ) vec2 y_over_x@0x16a6ed0)\n"
17162 " )\n"
17163 " (\n"
17164 " ))\n"
17165 "\n"
17166 " (signature vec3\n"
17167 " (parameters\n"
17168 " (declare (in ) vec3 y_over_x@0x16a70c0)\n"
17169 " )\n"
17170 " (\n"
17171 " ))\n"
17172 "\n"
17173 " (signature vec4\n"
17174 " (parameters\n"
17175 " (declare (in ) vec4 y_over_x@0x16a72b0)\n"
17176 " )\n"
17177 " (\n"
17178 " ))\n"
17179 "\n"
17180 ")\n"
17181 "\n"
17182 "(function pow\n"
17183 " (signature float\n"
17184 " (parameters\n"
17185 " (declare (in ) float x@0x16a74a0)\n"
17186 " (declare (in ) float y@0x16a75b0)\n"
17187 " )\n"
17188 " (\n"
17189 " ))\n"
17190 "\n"
17191 " (signature vec2\n"
17192 " (parameters\n"
17193 " (declare (in ) vec2 x@0x16a7930)\n"
17194 " (declare (in ) vec2 y@0x16a7a40)\n"
17195 " )\n"
17196 " (\n"
17197 " ))\n"
17198 "\n"
17199 " (signature vec3\n"
17200 " (parameters\n"
17201 " (declare (in ) vec3 x@0x16a7c20)\n"
17202 " (declare (in ) vec3 y@0x16a7d30)\n"
17203 " )\n"
17204 " (\n"
17205 " ))\n"
17206 "\n"
17207 " (signature vec4\n"
17208 " (parameters\n"
17209 " (declare (in ) vec4 x@0x16a7f10)\n"
17210 " (declare (in ) vec4 y@0x16a8020)\n"
17211 " )\n"
17212 " (\n"
17213 " ))\n"
17214 "\n"
17215 ")\n"
17216 "\n"
17217 "(function exp\n"
17218 " (signature float\n"
17219 " (parameters\n"
17220 " (declare (in ) float x@0x16a8200)\n"
17221 " )\n"
17222 " (\n"
17223 " ))\n"
17224 "\n"
17225 " (signature vec2\n"
17226 " (parameters\n"
17227 " (declare (in ) vec2 x@0x16a8580)\n"
17228 " )\n"
17229 " (\n"
17230 " ))\n"
17231 "\n"
17232 " (signature vec3\n"
17233 " (parameters\n"
17234 " (declare (in ) vec3 x@0x16a8760)\n"
17235 " )\n"
17236 " (\n"
17237 " ))\n"
17238 "\n"
17239 " (signature vec4\n"
17240 " (parameters\n"
17241 " (declare (in ) vec4 x@0x16a8940)\n"
17242 " )\n"
17243 " (\n"
17244 " ))\n"
17245 "\n"
17246 ")\n"
17247 "\n"
17248 "(function log\n"
17249 " (signature float\n"
17250 " (parameters\n"
17251 " (declare (in ) float x@0x16a8b20)\n"
17252 " )\n"
17253 " (\n"
17254 " ))\n"
17255 "\n"
17256 " (signature vec2\n"
17257 " (parameters\n"
17258 " (declare (in ) vec2 x@0x16a8ea0)\n"
17259 " )\n"
17260 " (\n"
17261 " ))\n"
17262 "\n"
17263 " (signature vec3\n"
17264 " (parameters\n"
17265 " (declare (in ) vec3 x@0x16a9080)\n"
17266 " )\n"
17267 " (\n"
17268 " ))\n"
17269 "\n"
17270 " (signature vec4\n"
17271 " (parameters\n"
17272 " (declare (in ) vec4 x@0x16a9260)\n"
17273 " )\n"
17274 " (\n"
17275 " ))\n"
17276 "\n"
17277 ")\n"
17278 "\n"
17279 "(function exp2\n"
17280 " (signature float\n"
17281 " (parameters\n"
17282 " (declare (in ) float x@0x16a9440)\n"
17283 " )\n"
17284 " (\n"
17285 " ))\n"
17286 "\n"
17287 " (signature vec2\n"
17288 " (parameters\n"
17289 " (declare (in ) vec2 x@0x16a97c0)\n"
17290 " )\n"
17291 " (\n"
17292 " ))\n"
17293 "\n"
17294 " (signature vec3\n"
17295 " (parameters\n"
17296 " (declare (in ) vec3 x@0x16a99a0)\n"
17297 " )\n"
17298 " (\n"
17299 " ))\n"
17300 "\n"
17301 " (signature vec4\n"
17302 " (parameters\n"
17303 " (declare (in ) vec4 x@0x16a9b80)\n"
17304 " )\n"
17305 " (\n"
17306 " ))\n"
17307 "\n"
17308 ")\n"
17309 "\n"
17310 "(function log2\n"
17311 " (signature float\n"
17312 " (parameters\n"
17313 " (declare (in ) float x@0x16a9d60)\n"
17314 " )\n"
17315 " (\n"
17316 " ))\n"
17317 "\n"
17318 " (signature vec2\n"
17319 " (parameters\n"
17320 " (declare (in ) vec2 x@0x16aa0e0)\n"
17321 " )\n"
17322 " (\n"
17323 " ))\n"
17324 "\n"
17325 " (signature vec3\n"
17326 " (parameters\n"
17327 " (declare (in ) vec3 x@0x16aa2c0)\n"
17328 " )\n"
17329 " (\n"
17330 " ))\n"
17331 "\n"
17332 " (signature vec4\n"
17333 " (parameters\n"
17334 " (declare (in ) vec4 x@0x16aa4a0)\n"
17335 " )\n"
17336 " (\n"
17337 " ))\n"
17338 "\n"
17339 ")\n"
17340 "\n"
17341 "(function sqrt\n"
17342 " (signature float\n"
17343 " (parameters\n"
17344 " (declare (in ) float x@0x16aa680)\n"
17345 " )\n"
17346 " (\n"
17347 " ))\n"
17348 "\n"
17349 " (signature vec2\n"
17350 " (parameters\n"
17351 " (declare (in ) vec2 x@0x16aaa00)\n"
17352 " )\n"
17353 " (\n"
17354 " ))\n"
17355 "\n"
17356 " (signature vec3\n"
17357 " (parameters\n"
17358 " (declare (in ) vec3 x@0x16aabe0)\n"
17359 " )\n"
17360 " (\n"
17361 " ))\n"
17362 "\n"
17363 " (signature vec4\n"
17364 " (parameters\n"
17365 " (declare (in ) vec4 x@0x16aadc0)\n"
17366 " )\n"
17367 " (\n"
17368 " ))\n"
17369 "\n"
17370 ")\n"
17371 "\n"
17372 "(function inversesqrt\n"
17373 " (signature float\n"
17374 " (parameters\n"
17375 " (declare (in ) float x@0x16aafa0)\n"
17376 " )\n"
17377 " (\n"
17378 " ))\n"
17379 "\n"
17380 " (signature vec2\n"
17381 " (parameters\n"
17382 " (declare (in ) vec2 x@0x16ab330)\n"
17383 " )\n"
17384 " (\n"
17385 " ))\n"
17386 "\n"
17387 " (signature vec3\n"
17388 " (parameters\n"
17389 " (declare (in ) vec3 x@0x16ab510)\n"
17390 " )\n"
17391 " (\n"
17392 " ))\n"
17393 "\n"
17394 " (signature vec4\n"
17395 " (parameters\n"
17396 " (declare (in ) vec4 x@0x16ab6f0)\n"
17397 " )\n"
17398 " (\n"
17399 " ))\n"
17400 "\n"
17401 ")\n"
17402 "\n"
17403 "(function abs\n"
17404 " (signature float\n"
17405 " (parameters\n"
17406 " (declare (in ) float x@0x16ab8d0)\n"
17407 " )\n"
17408 " (\n"
17409 " ))\n"
17410 "\n"
17411 " (signature vec2\n"
17412 " (parameters\n"
17413 " (declare (in ) vec2 x@0x16abc50)\n"
17414 " )\n"
17415 " (\n"
17416 " ))\n"
17417 "\n"
17418 " (signature vec3\n"
17419 " (parameters\n"
17420 " (declare (in ) vec3 x@0x16abe30)\n"
17421 " )\n"
17422 " (\n"
17423 " ))\n"
17424 "\n"
17425 " (signature vec4\n"
17426 " (parameters\n"
17427 " (declare (in ) vec4 x@0x16ac010)\n"
17428 " )\n"
17429 " (\n"
17430 " ))\n"
17431 "\n"
17432 " (signature int\n"
17433 " (parameters\n"
17434 " (declare (in ) int x@0x16ac1f0)\n"
17435 " )\n"
17436 " (\n"
17437 " ))\n"
17438 "\n"
17439 " (signature ivec2\n"
17440 " (parameters\n"
17441 " (declare (in ) ivec2 x@0x16ac3d0)\n"
17442 " )\n"
17443 " (\n"
17444 " ))\n"
17445 "\n"
17446 " (signature ivec3\n"
17447 " (parameters\n"
17448 " (declare (in ) ivec3 x@0x16ac5b0)\n"
17449 " )\n"
17450 " (\n"
17451 " ))\n"
17452 "\n"
17453 " (signature ivec4\n"
17454 " (parameters\n"
17455 " (declare (in ) ivec4 x@0x16ac790)\n"
17456 " )\n"
17457 " (\n"
17458 " ))\n"
17459 "\n"
17460 ")\n"
17461 "\n"
17462 "(function sign\n"
17463 " (signature float\n"
17464 " (parameters\n"
17465 " (declare (in ) float x@0x16ac970)\n"
17466 " )\n"
17467 " (\n"
17468 " ))\n"
17469 "\n"
17470 " (signature vec2\n"
17471 " (parameters\n"
17472 " (declare (in ) vec2 x@0x16accf0)\n"
17473 " )\n"
17474 " (\n"
17475 " ))\n"
17476 "\n"
17477 " (signature vec3\n"
17478 " (parameters\n"
17479 " (declare (in ) vec3 x@0x16aced0)\n"
17480 " )\n"
17481 " (\n"
17482 " ))\n"
17483 "\n"
17484 " (signature vec4\n"
17485 " (parameters\n"
17486 " (declare (in ) vec4 x@0x16ad0b0)\n"
17487 " )\n"
17488 " (\n"
17489 " ))\n"
17490 "\n"
17491 " (signature int\n"
17492 " (parameters\n"
17493 " (declare (in ) int x@0x16ad290)\n"
17494 " )\n"
17495 " (\n"
17496 " ))\n"
17497 "\n"
17498 " (signature ivec2\n"
17499 " (parameters\n"
17500 " (declare (in ) ivec2 x@0x16ad470)\n"
17501 " )\n"
17502 " (\n"
17503 " ))\n"
17504 "\n"
17505 " (signature ivec3\n"
17506 " (parameters\n"
17507 " (declare (in ) ivec3 x@0x16ad650)\n"
17508 " )\n"
17509 " (\n"
17510 " ))\n"
17511 "\n"
17512 " (signature ivec4\n"
17513 " (parameters\n"
17514 " (declare (in ) ivec4 x@0x16ad830)\n"
17515 " )\n"
17516 " (\n"
17517 " ))\n"
17518 "\n"
17519 ")\n"
17520 "\n"
17521 "(function floor\n"
17522 " (signature float\n"
17523 " (parameters\n"
17524 " (declare (in ) float x@0x16ada10)\n"
17525 " )\n"
17526 " (\n"
17527 " ))\n"
17528 "\n"
17529 " (signature vec2\n"
17530 " (parameters\n"
17531 " (declare (in ) vec2 x@0x16add90)\n"
17532 " )\n"
17533 " (\n"
17534 " ))\n"
17535 "\n"
17536 " (signature vec3\n"
17537 " (parameters\n"
17538 " (declare (in ) vec3 x@0x16adf70)\n"
17539 " )\n"
17540 " (\n"
17541 " ))\n"
17542 "\n"
17543 " (signature vec4\n"
17544 " (parameters\n"
17545 " (declare (in ) vec4 x@0x16ae150)\n"
17546 " )\n"
17547 " (\n"
17548 " ))\n"
17549 "\n"
17550 ")\n"
17551 "\n"
17552 "(function ceil\n"
17553 " (signature float\n"
17554 " (parameters\n"
17555 " (declare (in ) float x@0x16ae330)\n"
17556 " )\n"
17557 " (\n"
17558 " ))\n"
17559 "\n"
17560 " (signature vec2\n"
17561 " (parameters\n"
17562 " (declare (in ) vec2 x@0x16ae6b0)\n"
17563 " )\n"
17564 " (\n"
17565 " ))\n"
17566 "\n"
17567 " (signature vec3\n"
17568 " (parameters\n"
17569 " (declare (in ) vec3 x@0x16ae890)\n"
17570 " )\n"
17571 " (\n"
17572 " ))\n"
17573 "\n"
17574 " (signature vec4\n"
17575 " (parameters\n"
17576 " (declare (in ) vec4 x@0x16aea70)\n"
17577 " )\n"
17578 " (\n"
17579 " ))\n"
17580 "\n"
17581 ")\n"
17582 "\n"
17583 "(function fract\n"
17584 " (signature float\n"
17585 " (parameters\n"
17586 " (declare (in ) float x@0x16aec50)\n"
17587 " )\n"
17588 " (\n"
17589 " ))\n"
17590 "\n"
17591 " (signature vec2\n"
17592 " (parameters\n"
17593 " (declare (in ) vec2 x@0x16aefd0)\n"
17594 " )\n"
17595 " (\n"
17596 " ))\n"
17597 "\n"
17598 " (signature vec3\n"
17599 " (parameters\n"
17600 " (declare (in ) vec3 x@0x16af1b0)\n"
17601 " )\n"
17602 " (\n"
17603 " ))\n"
17604 "\n"
17605 " (signature vec4\n"
17606 " (parameters\n"
17607 " (declare (in ) vec4 x@0x16af390)\n"
17608 " )\n"
17609 " (\n"
17610 " ))\n"
17611 "\n"
17612 ")\n"
17613 "\n"
17614 "(function mod\n"
17615 " (signature float\n"
17616 " (parameters\n"
17617 " (declare (in ) float x@0x16af570)\n"
17618 " (declare (in ) float y@0x16af680)\n"
17619 " )\n"
17620 " (\n"
17621 " ))\n"
17622 "\n"
17623 " (signature vec2\n"
17624 " (parameters\n"
17625 " (declare (in ) vec2 x@0x16afa00)\n"
17626 " (declare (in ) float y@0x16afb10)\n"
17627 " )\n"
17628 " (\n"
17629 " ))\n"
17630 "\n"
17631 " (signature vec3\n"
17632 " (parameters\n"
17633 " (declare (in ) vec3 x@0x16afcf0)\n"
17634 " (declare (in ) float y@0x16afe00)\n"
17635 " )\n"
17636 " (\n"
17637 " ))\n"
17638 "\n"
17639 " (signature vec4\n"
17640 " (parameters\n"
17641 " (declare (in ) vec4 x@0x16affe0)\n"
17642 " (declare (in ) float y@0x16b00f0)\n"
17643 " )\n"
17644 " (\n"
17645 " ))\n"
17646 "\n"
17647 " (signature vec2\n"
17648 " (parameters\n"
17649 " (declare (in ) vec2 x@0x16b02d0)\n"
17650 " (declare (in ) vec2 y@0x16b03e0)\n"
17651 " )\n"
17652 " (\n"
17653 " ))\n"
17654 "\n"
17655 " (signature vec3\n"
17656 " (parameters\n"
17657 " (declare (in ) vec3 x@0x16b05c0)\n"
17658 " (declare (in ) vec3 y@0x16b06d0)\n"
17659 " )\n"
17660 " (\n"
17661 " ))\n"
17662 "\n"
17663 " (signature vec4\n"
17664 " (parameters\n"
17665 " (declare (in ) vec4 x@0x16b08b0)\n"
17666 " (declare (in ) vec4 y@0x16b09c0)\n"
17667 " )\n"
17668 " (\n"
17669 " ))\n"
17670 "\n"
17671 ")\n"
17672 "\n"
17673 "(function min\n"
17674 " (signature float\n"
17675 " (parameters\n"
17676 " (declare (in ) float x@0x16b0ba0)\n"
17677 " (declare (in ) float y@0x16b0cb0)\n"
17678 " )\n"
17679 " (\n"
17680 " ))\n"
17681 "\n"
17682 " (signature vec2\n"
17683 " (parameters\n"
17684 " (declare (in ) vec2 x@0x16b1030)\n"
17685 " (declare (in ) vec2 y@0x16b1140)\n"
17686 " )\n"
17687 " (\n"
17688 " ))\n"
17689 "\n"
17690 " (signature vec3\n"
17691 " (parameters\n"
17692 " (declare (in ) vec3 x@0x16b1320)\n"
17693 " (declare (in ) vec3 y@0x16b1430)\n"
17694 " )\n"
17695 " (\n"
17696 " ))\n"
17697 "\n"
17698 " (signature vec4\n"
17699 " (parameters\n"
17700 " (declare (in ) vec4 x@0x16b1610)\n"
17701 " (declare (in ) vec4 y@0x16b1720)\n"
17702 " )\n"
17703 " (\n"
17704 " ))\n"
17705 "\n"
17706 " (signature vec2\n"
17707 " (parameters\n"
17708 " (declare (in ) vec2 x@0x16b1900)\n"
17709 " (declare (in ) float y@0x16b1a10)\n"
17710 " )\n"
17711 " (\n"
17712 " ))\n"
17713 "\n"
17714 " (signature vec3\n"
17715 " (parameters\n"
17716 " (declare (in ) vec3 x@0x16b1bf0)\n"
17717 " (declare (in ) float y@0x16b1d00)\n"
17718 " )\n"
17719 " (\n"
17720 " ))\n"
17721 "\n"
17722 " (signature vec4\n"
17723 " (parameters\n"
17724 " (declare (in ) vec4 x@0x16b1ee0)\n"
17725 " (declare (in ) float y@0x16b1ff0)\n"
17726 " )\n"
17727 " (\n"
17728 " ))\n"
17729 "\n"
17730 " (signature int\n"
17731 " (parameters\n"
17732 " (declare (in ) int x@0x16b21d0)\n"
17733 " (declare (in ) int y@0x16b22e0)\n"
17734 " )\n"
17735 " (\n"
17736 " ))\n"
17737 "\n"
17738 " (signature ivec2\n"
17739 " (parameters\n"
17740 " (declare (in ) ivec2 x@0x16b24c0)\n"
17741 " (declare (in ) ivec2 y@0x16b25d0)\n"
17742 " )\n"
17743 " (\n"
17744 " ))\n"
17745 "\n"
17746 " (signature ivec3\n"
17747 " (parameters\n"
17748 " (declare (in ) ivec3 x@0x16b27b0)\n"
17749 " (declare (in ) ivec3 y@0x16b28c0)\n"
17750 " )\n"
17751 " (\n"
17752 " ))\n"
17753 "\n"
17754 " (signature ivec4\n"
17755 " (parameters\n"
17756 " (declare (in ) ivec4 x@0x16b2aa0)\n"
17757 " (declare (in ) ivec4 y@0x16b2bb0)\n"
17758 " )\n"
17759 " (\n"
17760 " ))\n"
17761 "\n"
17762 " (signature ivec2\n"
17763 " (parameters\n"
17764 " (declare (in ) ivec2 x@0x16b2d90)\n"
17765 " (declare (in ) int y@0x16b2ea0)\n"
17766 " )\n"
17767 " (\n"
17768 " ))\n"
17769 "\n"
17770 " (signature ivec3\n"
17771 " (parameters\n"
17772 " (declare (in ) ivec3 x@0x16b3080)\n"
17773 " (declare (in ) int y@0x16b3190)\n"
17774 " )\n"
17775 " (\n"
17776 " ))\n"
17777 "\n"
17778 " (signature ivec4\n"
17779 " (parameters\n"
17780 " (declare (in ) ivec4 x@0x16b3370)\n"
17781 " (declare (in ) int y@0x16b3480)\n"
17782 " )\n"
17783 " (\n"
17784 " ))\n"
17785 "\n"
17786 " (signature uint\n"
17787 " (parameters\n"
17788 " (declare (in ) uint x@0x16b3660)\n"
17789 " (declare (in ) uint y@0x16b3770)\n"
17790 " )\n"
17791 " (\n"
17792 " ))\n"
17793 "\n"
17794 " (signature uvec2\n"
17795 " (parameters\n"
17796 " (declare (in ) uvec2 x@0x16b3950)\n"
17797 " (declare (in ) uvec2 y@0x16b3a60)\n"
17798 " )\n"
17799 " (\n"
17800 " ))\n"
17801 "\n"
17802 " (signature uvec3\n"
17803 " (parameters\n"
17804 " (declare (in ) uvec3 x@0x16b3c40)\n"
17805 " (declare (in ) uvec3 y@0x16b3d50)\n"
17806 " )\n"
17807 " (\n"
17808 " ))\n"
17809 "\n"
17810 " (signature uvec4\n"
17811 " (parameters\n"
17812 " (declare (in ) uvec4 x@0x16b3f30)\n"
17813 " (declare (in ) uvec4 y@0x16b4040)\n"
17814 " )\n"
17815 " (\n"
17816 " ))\n"
17817 "\n"
17818 " (signature uvec2\n"
17819 " (parameters\n"
17820 " (declare (in ) uvec2 x@0x16b4220)\n"
17821 " (declare (in ) uint y@0x16b4330)\n"
17822 " )\n"
17823 " (\n"
17824 " ))\n"
17825 "\n"
17826 " (signature uvec3\n"
17827 " (parameters\n"
17828 " (declare (in ) uvec3 x@0x16b4510)\n"
17829 " (declare (in ) uint y@0x16b4620)\n"
17830 " )\n"
17831 " (\n"
17832 " ))\n"
17833 "\n"
17834 " (signature uvec4\n"
17835 " (parameters\n"
17836 " (declare (in ) uvec4 x@0x16b4800)\n"
17837 " (declare (in ) uint y@0x16b4910)\n"
17838 " )\n"
17839 " (\n"
17840 " ))\n"
17841 "\n"
17842 ")\n"
17843 "\n"
17844 "(function max\n"
17845 " (signature float\n"
17846 " (parameters\n"
17847 " (declare (in ) float x@0x16b4af0)\n"
17848 " (declare (in ) float y@0x16b4c00)\n"
17849 " )\n"
17850 " (\n"
17851 " ))\n"
17852 "\n"
17853 " (signature vec2\n"
17854 " (parameters\n"
17855 " (declare (in ) vec2 x@0x16b4f80)\n"
17856 " (declare (in ) vec2 y@0x16b5090)\n"
17857 " )\n"
17858 " (\n"
17859 " ))\n"
17860 "\n"
17861 " (signature vec3\n"
17862 " (parameters\n"
17863 " (declare (in ) vec3 x@0x16b5270)\n"
17864 " (declare (in ) vec3 y@0x16b5380)\n"
17865 " )\n"
17866 " (\n"
17867 " ))\n"
17868 "\n"
17869 " (signature vec4\n"
17870 " (parameters\n"
17871 " (declare (in ) vec4 x@0x16b5560)\n"
17872 " (declare (in ) vec4 y@0x16b5670)\n"
17873 " )\n"
17874 " (\n"
17875 " ))\n"
17876 "\n"
17877 " (signature vec2\n"
17878 " (parameters\n"
17879 " (declare (in ) vec2 x@0x16b5850)\n"
17880 " (declare (in ) float y@0x16b5960)\n"
17881 " )\n"
17882 " (\n"
17883 " ))\n"
17884 "\n"
17885 " (signature vec3\n"
17886 " (parameters\n"
17887 " (declare (in ) vec3 x@0x16b5b40)\n"
17888 " (declare (in ) float y@0x16b5c50)\n"
17889 " )\n"
17890 " (\n"
17891 " ))\n"
17892 "\n"
17893 " (signature vec4\n"
17894 " (parameters\n"
17895 " (declare (in ) vec4 x@0x16b5e30)\n"
17896 " (declare (in ) float y@0x16b5f40)\n"
17897 " )\n"
17898 " (\n"
17899 " ))\n"
17900 "\n"
17901 " (signature int\n"
17902 " (parameters\n"
17903 " (declare (in ) int x@0x16b6120)\n"
17904 " (declare (in ) int y@0x16b6230)\n"
17905 " )\n"
17906 " (\n"
17907 " ))\n"
17908 "\n"
17909 " (signature ivec2\n"
17910 " (parameters\n"
17911 " (declare (in ) ivec2 x@0x16b6410)\n"
17912 " (declare (in ) ivec2 y@0x16b6520)\n"
17913 " )\n"
17914 " (\n"
17915 " ))\n"
17916 "\n"
17917 " (signature ivec3\n"
17918 " (parameters\n"
17919 " (declare (in ) ivec3 x@0x16b6700)\n"
17920 " (declare (in ) ivec3 y@0x16b6810)\n"
17921 " )\n"
17922 " (\n"
17923 " ))\n"
17924 "\n"
17925 " (signature ivec4\n"
17926 " (parameters\n"
17927 " (declare (in ) ivec4 x@0x16b69f0)\n"
17928 " (declare (in ) ivec4 y@0x16b6b00)\n"
17929 " )\n"
17930 " (\n"
17931 " ))\n"
17932 "\n"
17933 " (signature ivec2\n"
17934 " (parameters\n"
17935 " (declare (in ) ivec2 x@0x16b6ce0)\n"
17936 " (declare (in ) int y@0x16b6df0)\n"
17937 " )\n"
17938 " (\n"
17939 " ))\n"
17940 "\n"
17941 " (signature ivec3\n"
17942 " (parameters\n"
17943 " (declare (in ) ivec3 x@0x16b6fd0)\n"
17944 " (declare (in ) int y@0x16b70e0)\n"
17945 " )\n"
17946 " (\n"
17947 " ))\n"
17948 "\n"
17949 " (signature ivec4\n"
17950 " (parameters\n"
17951 " (declare (in ) ivec4 x@0x16b72c0)\n"
17952 " (declare (in ) int y@0x16b73d0)\n"
17953 " )\n"
17954 " (\n"
17955 " ))\n"
17956 "\n"
17957 " (signature uint\n"
17958 " (parameters\n"
17959 " (declare (in ) uint x@0x16b75b0)\n"
17960 " (declare (in ) uint y@0x16b76c0)\n"
17961 " )\n"
17962 " (\n"
17963 " ))\n"
17964 "\n"
17965 " (signature uvec2\n"
17966 " (parameters\n"
17967 " (declare (in ) uvec2 x@0x16b78a0)\n"
17968 " (declare (in ) uvec2 y@0x16b79b0)\n"
17969 " )\n"
17970 " (\n"
17971 " ))\n"
17972 "\n"
17973 " (signature uvec3\n"
17974 " (parameters\n"
17975 " (declare (in ) uvec3 x@0x16b7b90)\n"
17976 " (declare (in ) uvec3 y@0x16b7ca0)\n"
17977 " )\n"
17978 " (\n"
17979 " ))\n"
17980 "\n"
17981 " (signature uvec4\n"
17982 " (parameters\n"
17983 " (declare (in ) uvec4 x@0x16b7e80)\n"
17984 " (declare (in ) uvec4 y@0x16b7f90)\n"
17985 " )\n"
17986 " (\n"
17987 " ))\n"
17988 "\n"
17989 " (signature uvec2\n"
17990 " (parameters\n"
17991 " (declare (in ) uvec2 x@0x16b8170)\n"
17992 " (declare (in ) uint y@0x16b8280)\n"
17993 " )\n"
17994 " (\n"
17995 " ))\n"
17996 "\n"
17997 " (signature uvec3\n"
17998 " (parameters\n"
17999 " (declare (in ) uvec3 x@0x16b8460)\n"
18000 " (declare (in ) uint y@0x16b8570)\n"
18001 " )\n"
18002 " (\n"
18003 " ))\n"
18004 "\n"
18005 " (signature uvec4\n"
18006 " (parameters\n"
18007 " (declare (in ) uvec4 x@0x16b8750)\n"
18008 " (declare (in ) uint y@0x16b8860)\n"
18009 " )\n"
18010 " (\n"
18011 " ))\n"
18012 "\n"
18013 ")\n"
18014 "\n"
18015 "(function clamp\n"
18016 " (signature float\n"
18017 " (parameters\n"
18018 " (declare (in ) float x@0x16b8a40)\n"
18019 " (declare (in ) float minVal@0x16b8b50)\n"
18020 " (declare (in ) float maxVal@0x16b8c60)\n"
18021 " )\n"
18022 " (\n"
18023 " ))\n"
18024 "\n"
18025 " (signature vec2\n"
18026 " (parameters\n"
18027 " (declare (in ) vec2 x@0x16b8fe0)\n"
18028 " (declare (in ) vec2 minVal@0x16b90f0)\n"
18029 " (declare (in ) vec2 maxVal@0x16b9200)\n"
18030 " )\n"
18031 " (\n"
18032 " ))\n"
18033 "\n"
18034 " (signature vec3\n"
18035 " (parameters\n"
18036 " (declare (in ) vec3 x@0x16b93e0)\n"
18037 " (declare (in ) vec3 minVal@0x16b94f0)\n"
18038 " (declare (in ) vec3 maxVal@0x16b9600)\n"
18039 " )\n"
18040 " (\n"
18041 " ))\n"
18042 "\n"
18043 " (signature vec4\n"
18044 " (parameters\n"
18045 " (declare (in ) vec4 x@0x16b97e0)\n"
18046 " (declare (in ) vec4 minVal@0x16b98f0)\n"
18047 " (declare (in ) vec4 maxVal@0x16b9a00)\n"
18048 " )\n"
18049 " (\n"
18050 " ))\n"
18051 "\n"
18052 " (signature vec2\n"
18053 " (parameters\n"
18054 " (declare (in ) vec2 x@0x16b9be0)\n"
18055 " (declare (in ) float minVal@0x16b9cf0)\n"
18056 " (declare (in ) float maxVal@0x16b9e00)\n"
18057 " )\n"
18058 " (\n"
18059 " ))\n"
18060 "\n"
18061 " (signature vec3\n"
18062 " (parameters\n"
18063 " (declare (in ) vec3 x@0x16b9fe0)\n"
18064 " (declare (in ) float minVal@0x16ba0f0)\n"
18065 " (declare (in ) float maxVal@0x16ba200)\n"
18066 " )\n"
18067 " (\n"
18068 " ))\n"
18069 "\n"
18070 " (signature vec4\n"
18071 " (parameters\n"
18072 " (declare (in ) vec4 x@0x16ba3e0)\n"
18073 " (declare (in ) float minVal@0x16ba4f0)\n"
18074 " (declare (in ) float maxVal@0x16ba600)\n"
18075 " )\n"
18076 " (\n"
18077 " ))\n"
18078 "\n"
18079 " (signature int\n"
18080 " (parameters\n"
18081 " (declare (in ) int x@0x16ba7e0)\n"
18082 " (declare (in ) int minVal@0x16ba8f0)\n"
18083 " (declare (in ) int maxVal@0x16baa00)\n"
18084 " )\n"
18085 " (\n"
18086 " ))\n"
18087 "\n"
18088 " (signature ivec2\n"
18089 " (parameters\n"
18090 " (declare (in ) ivec2 x@0x16babe0)\n"
18091 " (declare (in ) ivec2 minVal@0x16bacf0)\n"
18092 " (declare (in ) ivec2 maxVal@0x16bae00)\n"
18093 " )\n"
18094 " (\n"
18095 " ))\n"
18096 "\n"
18097 " (signature ivec3\n"
18098 " (parameters\n"
18099 " (declare (in ) ivec3 x@0x16bafe0)\n"
18100 " (declare (in ) ivec3 minVal@0x16bb0f0)\n"
18101 " (declare (in ) ivec3 maxVal@0x16bb200)\n"
18102 " )\n"
18103 " (\n"
18104 " ))\n"
18105 "\n"
18106 " (signature ivec4\n"
18107 " (parameters\n"
18108 " (declare (in ) ivec4 x@0x16bb3e0)\n"
18109 " (declare (in ) ivec4 minVal@0x16bb4f0)\n"
18110 " (declare (in ) ivec4 maxVal@0x16bb600)\n"
18111 " )\n"
18112 " (\n"
18113 " ))\n"
18114 "\n"
18115 " (signature ivec2\n"
18116 " (parameters\n"
18117 " (declare (in ) ivec2 x@0x16bb7e0)\n"
18118 " (declare (in ) int minVal@0x16bb8f0)\n"
18119 " (declare (in ) int maxVal@0x16bba00)\n"
18120 " )\n"
18121 " (\n"
18122 " ))\n"
18123 "\n"
18124 " (signature ivec3\n"
18125 " (parameters\n"
18126 " (declare (in ) ivec3 x@0x16bbbe0)\n"
18127 " (declare (in ) int minVal@0x16bbcf0)\n"
18128 " (declare (in ) int maxVal@0x16bbe00)\n"
18129 " )\n"
18130 " (\n"
18131 " ))\n"
18132 "\n"
18133 " (signature ivec4\n"
18134 " (parameters\n"
18135 " (declare (in ) ivec4 x@0x16bbfe0)\n"
18136 " (declare (in ) int minVal@0x16bc0f0)\n"
18137 " (declare (in ) int maxVal@0x16bc200)\n"
18138 " )\n"
18139 " (\n"
18140 " ))\n"
18141 "\n"
18142 " (signature uint\n"
18143 " (parameters\n"
18144 " (declare (in ) uint x@0x16bc3e0)\n"
18145 " (declare (in ) uint minVal@0x16bc4f0)\n"
18146 " (declare (in ) uint maxVal@0x16bc600)\n"
18147 " )\n"
18148 " (\n"
18149 " ))\n"
18150 "\n"
18151 " (signature uvec2\n"
18152 " (parameters\n"
18153 " (declare (in ) uvec2 x@0x16bc7e0)\n"
18154 " (declare (in ) uvec2 minVal@0x16bc8f0)\n"
18155 " (declare (in ) uvec2 maxVal@0x16bca00)\n"
18156 " )\n"
18157 " (\n"
18158 " ))\n"
18159 "\n"
18160 " (signature uvec3\n"
18161 " (parameters\n"
18162 " (declare (in ) uvec3 x@0x16bcbe0)\n"
18163 " (declare (in ) uvec3 minVal@0x16bccf0)\n"
18164 " (declare (in ) uvec3 maxVal@0x16bce00)\n"
18165 " )\n"
18166 " (\n"
18167 " ))\n"
18168 "\n"
18169 " (signature uvec4\n"
18170 " (parameters\n"
18171 " (declare (in ) uvec4 x@0x16bcfe0)\n"
18172 " (declare (in ) uvec4 minVal@0x16bd0f0)\n"
18173 " (declare (in ) uvec4 maxVal@0x16bd200)\n"
18174 " )\n"
18175 " (\n"
18176 " ))\n"
18177 "\n"
18178 " (signature uvec2\n"
18179 " (parameters\n"
18180 " (declare (in ) uvec2 x@0x16bd3e0)\n"
18181 " (declare (in ) uint minVal@0x16bd4f0)\n"
18182 " (declare (in ) uint maxVal@0x16bd600)\n"
18183 " )\n"
18184 " (\n"
18185 " ))\n"
18186 "\n"
18187 " (signature uvec3\n"
18188 " (parameters\n"
18189 " (declare (in ) uvec3 x@0x16bd7e0)\n"
18190 " (declare (in ) uint minVal@0x16bd8f0)\n"
18191 " (declare (in ) uint maxVal@0x16bda00)\n"
18192 " )\n"
18193 " (\n"
18194 " ))\n"
18195 "\n"
18196 " (signature uvec4\n"
18197 " (parameters\n"
18198 " (declare (in ) uvec4 x@0x16bdbe0)\n"
18199 " (declare (in ) uint minVal@0x16bdcf0)\n"
18200 " (declare (in ) uint maxVal@0x16bde00)\n"
18201 " )\n"
18202 " (\n"
18203 " ))\n"
18204 "\n"
18205 ")\n"
18206 "\n"
18207 "(function mix\n"
18208 " (signature float\n"
18209 " (parameters\n"
18210 " (declare (in ) float x@0x16bdfe0)\n"
18211 " (declare (in ) float y@0x16be0f0)\n"
18212 " (declare (in ) float a@0x16be200)\n"
18213 " )\n"
18214 " (\n"
18215 " ))\n"
18216 "\n"
18217 " (signature vec2\n"
18218 " (parameters\n"
18219 " (declare (in ) vec2 x@0x16be580)\n"
18220 " (declare (in ) vec2 y@0x16be690)\n"
18221 " (declare (in ) vec2 a@0x16be7a0)\n"
18222 " )\n"
18223 " (\n"
18224 " ))\n"
18225 "\n"
18226 " (signature vec3\n"
18227 " (parameters\n"
18228 " (declare (in ) vec3 x@0x16be980)\n"
18229 " (declare (in ) vec3 y@0x16bea90)\n"
18230 " (declare (in ) vec3 a@0x16beba0)\n"
18231 " )\n"
18232 " (\n"
18233 " ))\n"
18234 "\n"
18235 " (signature vec4\n"
18236 " (parameters\n"
18237 " (declare (in ) vec4 x@0x16bed80)\n"
18238 " (declare (in ) vec4 y@0x16bee90)\n"
18239 " (declare (in ) vec4 a@0x16befa0)\n"
18240 " )\n"
18241 " (\n"
18242 " ))\n"
18243 "\n"
18244 " (signature vec2\n"
18245 " (parameters\n"
18246 " (declare (in ) vec2 x@0x16bf180)\n"
18247 " (declare (in ) vec2 y@0x16bf290)\n"
18248 " (declare (in ) float a@0x16bf3a0)\n"
18249 " )\n"
18250 " (\n"
18251 " ))\n"
18252 "\n"
18253 " (signature vec3\n"
18254 " (parameters\n"
18255 " (declare (in ) vec3 x@0x16bf580)\n"
18256 " (declare (in ) vec3 y@0x16bf690)\n"
18257 " (declare (in ) float a@0x16bf7a0)\n"
18258 " )\n"
18259 " (\n"
18260 " ))\n"
18261 "\n"
18262 " (signature vec4\n"
18263 " (parameters\n"
18264 " (declare (in ) vec4 x@0x16bf980)\n"
18265 " (declare (in ) vec4 y@0x16bfa90)\n"
18266 " (declare (in ) float a@0x16bfba0)\n"
18267 " )\n"
18268 " (\n"
18269 " ))\n"
18270 "\n"
18271 ")\n"
18272 "\n"
18273 "(function step\n"
18274 " (signature float\n"
18275 " (parameters\n"
18276 " (declare (in ) float edge@0x16bfd80)\n"
18277 " (declare (in ) float x@0x16bfe90)\n"
18278 " )\n"
18279 " (\n"
18280 " ))\n"
18281 "\n"
18282 " (signature vec2\n"
18283 " (parameters\n"
18284 " (declare (in ) vec2 edge@0x16c0210)\n"
18285 " (declare (in ) vec2 x@0x16c0320)\n"
18286 " )\n"
18287 " (\n"
18288 " ))\n"
18289 "\n"
18290 " (signature vec3\n"
18291 " (parameters\n"
18292 " (declare (in ) vec3 edge@0x16c0500)\n"
18293 " (declare (in ) vec3 x@0x16c0610)\n"
18294 " )\n"
18295 " (\n"
18296 " ))\n"
18297 "\n"
18298 " (signature vec4\n"
18299 " (parameters\n"
18300 " (declare (in ) vec4 edge@0x16c07f0)\n"
18301 " (declare (in ) vec4 x@0x16c0900)\n"
18302 " )\n"
18303 " (\n"
18304 " ))\n"
18305 "\n"
18306 " (signature vec2\n"
18307 " (parameters\n"
18308 " (declare (in ) float edge@0x16c0ae0)\n"
18309 " (declare (in ) vec2 x@0x16c0bf0)\n"
18310 " )\n"
18311 " (\n"
18312 " ))\n"
18313 "\n"
18314 " (signature vec3\n"
18315 " (parameters\n"
18316 " (declare (in ) float edge@0x16c0dd0)\n"
18317 " (declare (in ) vec3 x@0x16c0ee0)\n"
18318 " )\n"
18319 " (\n"
18320 " ))\n"
18321 "\n"
18322 " (signature vec4\n"
18323 " (parameters\n"
18324 " (declare (in ) float edge@0x16c10c0)\n"
18325 " (declare (in ) vec4 x@0x16c11d0)\n"
18326 " )\n"
18327 " (\n"
18328 " ))\n"
18329 "\n"
18330 ")\n"
18331 "\n"
18332 "(function smoothstep\n"
18333 " (signature float\n"
18334 " (parameters\n"
18335 " (declare (in ) float edge0@0x16c13b0)\n"
18336 " (declare (in ) float edge1@0x16c14c0)\n"
18337 " (declare (in ) float x@0x16c15d0)\n"
18338 " )\n"
18339 " (\n"
18340 " ))\n"
18341 "\n"
18342 " (signature vec2\n"
18343 " (parameters\n"
18344 " (declare (in ) vec2 edge0@0x16c1960)\n"
18345 " (declare (in ) vec2 edge1@0x16c1a70)\n"
18346 " (declare (in ) vec2 x@0x16c1b80)\n"
18347 " )\n"
18348 " (\n"
18349 " ))\n"
18350 "\n"
18351 " (signature vec3\n"
18352 " (parameters\n"
18353 " (declare (in ) vec3 edge0@0x16c1d60)\n"
18354 " (declare (in ) vec3 edge1@0x16c1e70)\n"
18355 " (declare (in ) vec3 x@0x16c1f80)\n"
18356 " )\n"
18357 " (\n"
18358 " ))\n"
18359 "\n"
18360 " (signature vec4\n"
18361 " (parameters\n"
18362 " (declare (in ) vec4 edge0@0x16c2160)\n"
18363 " (declare (in ) vec4 edge1@0x16c2270)\n"
18364 " (declare (in ) vec4 x@0x16c2380)\n"
18365 " )\n"
18366 " (\n"
18367 " ))\n"
18368 "\n"
18369 " (signature vec2\n"
18370 " (parameters\n"
18371 " (declare (in ) float edge0@0x16c2560)\n"
18372 " (declare (in ) float edge1@0x16c2670)\n"
18373 " (declare (in ) vec2 x@0x16c2780)\n"
18374 " )\n"
18375 " (\n"
18376 " ))\n"
18377 "\n"
18378 " (signature vec3\n"
18379 " (parameters\n"
18380 " (declare (in ) float edge0@0x16c2960)\n"
18381 " (declare (in ) float edge1@0x16c2a70)\n"
18382 " (declare (in ) vec3 x@0x16c2b80)\n"
18383 " )\n"
18384 " (\n"
18385 " ))\n"
18386 "\n"
18387 " (signature vec4\n"
18388 " (parameters\n"
18389 " (declare (in ) float edge0@0x16c2d60)\n"
18390 " (declare (in ) float edge1@0x16c2e70)\n"
18391 " (declare (in ) vec4 x@0x16c2f80)\n"
18392 " )\n"
18393 " (\n"
18394 " ))\n"
18395 "\n"
18396 ")\n"
18397 "\n"
18398 "(function length\n"
18399 " (signature float\n"
18400 " (parameters\n"
18401 " (declare (in ) float x@0x16c3160)\n"
18402 " )\n"
18403 " (\n"
18404 " ))\n"
18405 "\n"
18406 " (signature float\n"
18407 " (parameters\n"
18408 " (declare (in ) vec2 x@0x16c34e0)\n"
18409 " )\n"
18410 " (\n"
18411 " ))\n"
18412 "\n"
18413 " (signature float\n"
18414 " (parameters\n"
18415 " (declare (in ) vec3 x@0x16c36c0)\n"
18416 " )\n"
18417 " (\n"
18418 " ))\n"
18419 "\n"
18420 " (signature float\n"
18421 " (parameters\n"
18422 " (declare (in ) vec4 x@0x16c38a0)\n"
18423 " )\n"
18424 " (\n"
18425 " ))\n"
18426 "\n"
18427 ")\n"
18428 "\n"
18429 "(function distance\n"
18430 " (signature float\n"
18431 " (parameters\n"
18432 " (declare (in ) float p0@0x16c3a80)\n"
18433 " (declare (in ) float p1@0x16c3b90)\n"
18434 " )\n"
18435 " (\n"
18436 " ))\n"
18437 "\n"
18438 " (signature float\n"
18439 " (parameters\n"
18440 " (declare (in ) vec2 p0@0x16c3f20)\n"
18441 " (declare (in ) vec2 p1@0x16c4030)\n"
18442 " )\n"
18443 " (\n"
18444 " ))\n"
18445 "\n"
18446 " (signature float\n"
18447 " (parameters\n"
18448 " (declare (in ) vec3 p0@0x16c4210)\n"
18449 " (declare (in ) vec3 p1@0x16c4320)\n"
18450 " )\n"
18451 " (\n"
18452 " ))\n"
18453 "\n"
18454 " (signature float\n"
18455 " (parameters\n"
18456 " (declare (in ) vec4 p0@0x16c4500)\n"
18457 " (declare (in ) vec4 p1@0x16c4610)\n"
18458 " )\n"
18459 " (\n"
18460 " ))\n"
18461 "\n"
18462 ")\n"
18463 "\n"
18464 "(function dot\n"
18465 " (signature float\n"
18466 " (parameters\n"
18467 " (declare (in ) float x@0x16c47f0)\n"
18468 " (declare (in ) float y@0x16c4900)\n"
18469 " )\n"
18470 " (\n"
18471 " ))\n"
18472 "\n"
18473 " (signature float\n"
18474 " (parameters\n"
18475 " (declare (in ) vec2 x@0x16c4c80)\n"
18476 " (declare (in ) vec2 y@0x16c4d90)\n"
18477 " )\n"
18478 " (\n"
18479 " ))\n"
18480 "\n"
18481 " (signature float\n"
18482 " (parameters\n"
18483 " (declare (in ) vec3 x@0x16c4f70)\n"
18484 " (declare (in ) vec3 y@0x16c5080)\n"
18485 " )\n"
18486 " (\n"
18487 " ))\n"
18488 "\n"
18489 " (signature float\n"
18490 " (parameters\n"
18491 " (declare (in ) vec4 x@0x16c5260)\n"
18492 " (declare (in ) vec4 y@0x16c5370)\n"
18493 " )\n"
18494 " (\n"
18495 " ))\n"
18496 "\n"
18497 ")\n"
18498 "\n"
18499 "(function cross\n"
18500 " (signature vec3\n"
18501 " (parameters\n"
18502 " (declare (in ) vec3 x@0x16c5550)\n"
18503 " (declare (in ) vec3 y@0x16c5660)\n"
18504 " )\n"
18505 " (\n"
18506 " ))\n"
18507 "\n"
18508 ")\n"
18509 "\n"
18510 "(function normalize\n"
18511 " (signature float\n"
18512 " (parameters\n"
18513 " (declare (in ) float x@0x16c59e0)\n"
18514 " )\n"
18515 " (\n"
18516 " ))\n"
18517 "\n"
18518 " (signature vec2\n"
18519 " (parameters\n"
18520 " (declare (in ) vec2 x@0x16c5d70)\n"
18521 " )\n"
18522 " (\n"
18523 " ))\n"
18524 "\n"
18525 " (signature vec3\n"
18526 " (parameters\n"
18527 " (declare (in ) vec3 x@0x16c5f50)\n"
18528 " )\n"
18529 " (\n"
18530 " ))\n"
18531 "\n"
18532 " (signature vec4\n"
18533 " (parameters\n"
18534 " (declare (in ) vec4 x@0x16c6130)\n"
18535 " )\n"
18536 " (\n"
18537 " ))\n"
18538 "\n"
18539 ")\n"
18540 "\n"
18541 "(function ftransform\n"
18542 " (signature vec4\n"
18543 " (parameters\n"
18544 " )\n"
18545 " (\n"
18546 " ))\n"
18547 "\n"
18548 ")\n"
18549 "\n"
18550 "(function faceforward\n"
18551 " (signature float\n"
18552 " (parameters\n"
18553 " (declare (in ) float N@0x16c6590)\n"
18554 " (declare (in ) float I@0x16c66a0)\n"
18555 " (declare (in ) float Nref@0x16c67b0)\n"
18556 " )\n"
18557 " (\n"
18558 " ))\n"
18559 "\n"
18560 " (signature vec2\n"
18561 " (parameters\n"
18562 " (declare (in ) vec2 N@0x16c6b40)\n"
18563 " (declare (in ) vec2 I@0x16c6c50)\n"
18564 " (declare (in ) vec2 Nref@0x16c6d60)\n"
18565 " )\n"
18566 " (\n"
18567 " ))\n"
18568 "\n"
18569 " (signature vec3\n"
18570 " (parameters\n"
18571 " (declare (in ) vec3 N@0x16c6f40)\n"
18572 " (declare (in ) vec3 I@0x16c7050)\n"
18573 " (declare (in ) vec3 Nref@0x16c7160)\n"
18574 " )\n"
18575 " (\n"
18576 " ))\n"
18577 "\n"
18578 " (signature vec4\n"
18579 " (parameters\n"
18580 " (declare (in ) vec4 N@0x16c7340)\n"
18581 " (declare (in ) vec4 I@0x16c7450)\n"
18582 " (declare (in ) vec4 Nref@0x16c7560)\n"
18583 " )\n"
18584 " (\n"
18585 " ))\n"
18586 "\n"
18587 ")\n"
18588 "\n"
18589 "(function reflect\n"
18590 " (signature float\n"
18591 " (parameters\n"
18592 " (declare (in ) float I@0x16c7740)\n"
18593 " (declare (in ) float N@0x16c7850)\n"
18594 " )\n"
18595 " (\n"
18596 " ))\n"
18597 "\n"
18598 " (signature vec2\n"
18599 " (parameters\n"
18600 " (declare (in ) vec2 I@0x16c7bd0)\n"
18601 " (declare (in ) vec2 N@0x16c7ce0)\n"
18602 " )\n"
18603 " (\n"
18604 " ))\n"
18605 "\n"
18606 " (signature vec3\n"
18607 " (parameters\n"
18608 " (declare (in ) vec3 I@0x16c7ec0)\n"
18609 " (declare (in ) vec3 N@0x16c7fd0)\n"
18610 " )\n"
18611 " (\n"
18612 " ))\n"
18613 "\n"
18614 " (signature vec4\n"
18615 " (parameters\n"
18616 " (declare (in ) vec4 I@0x16c81b0)\n"
18617 " (declare (in ) vec4 N@0x16c82c0)\n"
18618 " )\n"
18619 " (\n"
18620 " ))\n"
18621 "\n"
18622 ")\n"
18623 "\n"
18624 "(function refract\n"
18625 " (signature float\n"
18626 " (parameters\n"
18627 " (declare (in ) float I@0x16c84a0)\n"
18628 " (declare (in ) float N@0x16c85b0)\n"
18629 " (declare (in ) float eta@0x16c86c0)\n"
18630 " )\n"
18631 " (\n"
18632 " ))\n"
18633 "\n"
18634 " (signature vec2\n"
18635 " (parameters\n"
18636 " (declare (in ) vec2 I@0x16c8a40)\n"
18637 " (declare (in ) vec2 N@0x16c8b50)\n"
18638 " (declare (in ) float eta@0x16c8c60)\n"
18639 " )\n"
18640 " (\n"
18641 " ))\n"
18642 "\n"
18643 " (signature vec3\n"
18644 " (parameters\n"
18645 " (declare (in ) vec3 I@0x16c8e40)\n"
18646 " (declare (in ) vec3 N@0x16c8f50)\n"
18647 " (declare (in ) float eta@0x16c9060)\n"
18648 " )\n"
18649 " (\n"
18650 " ))\n"
18651 "\n"
18652 " (signature vec4\n"
18653 " (parameters\n"
18654 " (declare (in ) vec4 I@0x16c9240)\n"
18655 " (declare (in ) vec4 N@0x16c9350)\n"
18656 " (declare (in ) float eta@0x16c9460)\n"
18657 " )\n"
18658 " (\n"
18659 " ))\n"
18660 "\n"
18661 ")\n"
18662 "\n"
18663 "(function matrixCompMult\n"
18664 " (signature mat2\n"
18665 " (parameters\n"
18666 " (declare (in ) mat2 x@0x16c9640)\n"
18667 " (declare (in ) mat2 y@0x16c9750)\n"
18668 " )\n"
18669 " (\n"
18670 " ))\n"
18671 "\n"
18672 " (signature mat3\n"
18673 " (parameters\n"
18674 " (declare (in ) mat3 x@0x16c9ae0)\n"
18675 " (declare (in ) mat3 y@0x16c9bf0)\n"
18676 " )\n"
18677 " (\n"
18678 " ))\n"
18679 "\n"
18680 " (signature mat4\n"
18681 " (parameters\n"
18682 " (declare (in ) mat4 x@0x16c9dd0)\n"
18683 " (declare (in ) mat4 y@0x16c9ee0)\n"
18684 " )\n"
18685 " (\n"
18686 " ))\n"
18687 "\n"
18688 " (signature mat2x3\n"
18689 " (parameters\n"
18690 " (declare (in ) mat2x3 x@0x16ca0c0)\n"
18691 " (declare (in ) mat2x3 y@0x16ca1d0)\n"
18692 " )\n"
18693 " (\n"
18694 " ))\n"
18695 "\n"
18696 " (signature mat2x4\n"
18697 " (parameters\n"
18698 " (declare (in ) mat2x4 x@0x16ca3b0)\n"
18699 " (declare (in ) mat2x4 y@0x16ca4c0)\n"
18700 " )\n"
18701 " (\n"
18702 " ))\n"
18703 "\n"
18704 " (signature mat3x2\n"
18705 " (parameters\n"
18706 " (declare (in ) mat3x2 x@0x16ca6a0)\n"
18707 " (declare (in ) mat3x2 y@0x16ca7b0)\n"
18708 " )\n"
18709 " (\n"
18710 " ))\n"
18711 "\n"
18712 " (signature mat3x4\n"
18713 " (parameters\n"
18714 " (declare (in ) mat3x4 x@0x16ca990)\n"
18715 " (declare (in ) mat3x4 y@0x16caaa0)\n"
18716 " )\n"
18717 " (\n"
18718 " ))\n"
18719 "\n"
18720 " (signature mat4x2\n"
18721 " (parameters\n"
18722 " (declare (in ) mat4x2 x@0x16cac80)\n"
18723 " (declare (in ) mat4x2 y@0x16cad90)\n"
18724 " )\n"
18725 " (\n"
18726 " ))\n"
18727 "\n"
18728 " (signature mat4x3\n"
18729 " (parameters\n"
18730 " (declare (in ) mat4x3 x@0x16caf70)\n"
18731 " (declare (in ) mat4x3 y@0x16cb080)\n"
18732 " )\n"
18733 " (\n"
18734 " ))\n"
18735 "\n"
18736 ")\n"
18737 "\n"
18738 "(function outerProduct\n"
18739 " (signature mat2\n"
18740 " (parameters\n"
18741 " (declare (in ) vec2 c@0x16cb260)\n"
18742 " (declare (in ) vec2 r@0x16cb370)\n"
18743 " )\n"
18744 " (\n"
18745 " ))\n"
18746 "\n"
18747 " (signature mat3\n"
18748 " (parameters\n"
18749 " (declare (in ) vec3 c@0x16cb700)\n"
18750 " (declare (in ) vec3 r@0x16cb810)\n"
18751 " )\n"
18752 " (\n"
18753 " ))\n"
18754 "\n"
18755 " (signature mat4\n"
18756 " (parameters\n"
18757 " (declare (in ) vec4 c@0x16cb9f0)\n"
18758 " (declare (in ) vec4 r@0x16cbb00)\n"
18759 " )\n"
18760 " (\n"
18761 " ))\n"
18762 "\n"
18763 " (signature mat2x3\n"
18764 " (parameters\n"
18765 " (declare (in ) vec3 c@0x16cbce0)\n"
18766 " (declare (in ) vec2 r@0x16cbdf0)\n"
18767 " )\n"
18768 " (\n"
18769 " ))\n"
18770 "\n"
18771 " (signature mat3x2\n"
18772 " (parameters\n"
18773 " (declare (in ) vec2 c@0x16cbfd0)\n"
18774 " (declare (in ) vec3 r@0x16cc0e0)\n"
18775 " )\n"
18776 " (\n"
18777 " ))\n"
18778 "\n"
18779 " (signature mat2x4\n"
18780 " (parameters\n"
18781 " (declare (in ) vec4 c@0x16cc2c0)\n"
18782 " (declare (in ) vec2 r@0x16cc3d0)\n"
18783 " )\n"
18784 " (\n"
18785 " ))\n"
18786 "\n"
18787 " (signature mat4x2\n"
18788 " (parameters\n"
18789 " (declare (in ) vec2 c@0x16cc5b0)\n"
18790 " (declare (in ) vec4 r@0x16cc6c0)\n"
18791 " )\n"
18792 " (\n"
18793 " ))\n"
18794 "\n"
18795 " (signature mat3x4\n"
18796 " (parameters\n"
18797 " (declare (in ) vec4 c@0x16cc8a0)\n"
18798 " (declare (in ) vec3 r@0x16cc9b0)\n"
18799 " )\n"
18800 " (\n"
18801 " ))\n"
18802 "\n"
18803 " (signature mat4x3\n"
18804 " (parameters\n"
18805 " (declare (in ) vec3 c@0x16ccb90)\n"
18806 " (declare (in ) vec4 r@0x16ccca0)\n"
18807 " )\n"
18808 " (\n"
18809 " ))\n"
18810 "\n"
18811 ")\n"
18812 "\n"
18813 "(function transpose\n"
18814 " (signature mat2\n"
18815 " (parameters\n"
18816 " (declare (in ) mat2 m@0x16cce80)\n"
18817 " )\n"
18818 " (\n"
18819 " ))\n"
18820 "\n"
18821 " (signature mat3\n"
18822 " (parameters\n"
18823 " (declare (in ) mat3 m@0x16cd210)\n"
18824 " )\n"
18825 " (\n"
18826 " ))\n"
18827 "\n"
18828 " (signature mat4\n"
18829 " (parameters\n"
18830 " (declare (in ) mat4 m@0x16cd3f0)\n"
18831 " )\n"
18832 " (\n"
18833 " ))\n"
18834 "\n"
18835 " (signature mat2x3\n"
18836 " (parameters\n"
18837 " (declare (in ) mat3x2 m@0x16cd5d0)\n"
18838 " )\n"
18839 " (\n"
18840 " ))\n"
18841 "\n"
18842 " (signature mat3x2\n"
18843 " (parameters\n"
18844 " (declare (in ) mat2x3 m@0x16cd7b0)\n"
18845 " )\n"
18846 " (\n"
18847 " ))\n"
18848 "\n"
18849 " (signature mat2x4\n"
18850 " (parameters\n"
18851 " (declare (in ) mat4x2 m@0x16cd990)\n"
18852 " )\n"
18853 " (\n"
18854 " ))\n"
18855 "\n"
18856 " (signature mat4x2\n"
18857 " (parameters\n"
18858 " (declare (in ) mat2x4 m@0x16cdb70)\n"
18859 " )\n"
18860 " (\n"
18861 " ))\n"
18862 "\n"
18863 " (signature mat3x4\n"
18864 " (parameters\n"
18865 " (declare (in ) mat4x3 m@0x16cdd50)\n"
18866 " )\n"
18867 " (\n"
18868 " ))\n"
18869 "\n"
18870 " (signature mat4x3\n"
18871 " (parameters\n"
18872 " (declare (in ) mat3x4 m@0x16cdf30)\n"
18873 " )\n"
18874 " (\n"
18875 " ))\n"
18876 "\n"
18877 ")\n"
18878 "\n"
18879 "(function lessThan\n"
18880 " (signature bvec2\n"
18881 " (parameters\n"
18882 " (declare (in ) vec2 x@0x16ce110)\n"
18883 " (declare (in ) vec2 y@0x16ce220)\n"
18884 " )\n"
18885 " (\n"
18886 " ))\n"
18887 "\n"
18888 " (signature bvec3\n"
18889 " (parameters\n"
18890 " (declare (in ) vec3 x@0x16ce5b0)\n"
18891 " (declare (in ) vec3 y@0x16ce6c0)\n"
18892 " )\n"
18893 " (\n"
18894 " ))\n"
18895 "\n"
18896 " (signature bvec4\n"
18897 " (parameters\n"
18898 " (declare (in ) vec4 x@0x16ce8a0)\n"
18899 " (declare (in ) vec4 y@0x16ce9b0)\n"
18900 " )\n"
18901 " (\n"
18902 " ))\n"
18903 "\n"
18904 " (signature bvec2\n"
18905 " (parameters\n"
18906 " (declare (in ) ivec2 x@0x16ceb90)\n"
18907 " (declare (in ) ivec2 y@0x16ceca0)\n"
18908 " )\n"
18909 " (\n"
18910 " ))\n"
18911 "\n"
18912 " (signature bvec3\n"
18913 " (parameters\n"
18914 " (declare (in ) ivec3 x@0x16cee80)\n"
18915 " (declare (in ) ivec3 y@0x16cef90)\n"
18916 " )\n"
18917 " (\n"
18918 " ))\n"
18919 "\n"
18920 " (signature bvec4\n"
18921 " (parameters\n"
18922 " (declare (in ) ivec4 x@0x16cf170)\n"
18923 " (declare (in ) ivec4 y@0x16cf280)\n"
18924 " )\n"
18925 " (\n"
18926 " ))\n"
18927 "\n"
18928 " (signature bvec2\n"
18929 " (parameters\n"
18930 " (declare (in ) uvec2 x@0x16cf460)\n"
18931 " (declare (in ) uvec2 y@0x16cf570)\n"
18932 " )\n"
18933 " (\n"
18934 " ))\n"
18935 "\n"
18936 " (signature bvec3\n"
18937 " (parameters\n"
18938 " (declare (in ) uvec3 x@0x16cf750)\n"
18939 " (declare (in ) uvec3 y@0x16cf860)\n"
18940 " )\n"
18941 " (\n"
18942 " ))\n"
18943 "\n"
18944 " (signature bvec4\n"
18945 " (parameters\n"
18946 " (declare (in ) uvec4 x@0x16cfa40)\n"
18947 " (declare (in ) uvec4 y@0x16cfb50)\n"
18948 " )\n"
18949 " (\n"
18950 " ))\n"
18951 "\n"
18952 ")\n"
18953 "\n"
18954 "(function lessThanEqual\n"
18955 " (signature bvec2\n"
18956 " (parameters\n"
18957 " (declare (in ) vec2 x@0x16cfd30)\n"
18958 " (declare (in ) vec2 y@0x16cfe40)\n"
18959 " )\n"
18960 " (\n"
18961 " ))\n"
18962 "\n"
18963 " (signature bvec3\n"
18964 " (parameters\n"
18965 " (declare (in ) vec3 x@0x16d01d0)\n"
18966 " (declare (in ) vec3 y@0x16d02e0)\n"
18967 " )\n"
18968 " (\n"
18969 " ))\n"
18970 "\n"
18971 " (signature bvec4\n"
18972 " (parameters\n"
18973 " (declare (in ) vec4 x@0x16d04c0)\n"
18974 " (declare (in ) vec4 y@0x16d05d0)\n"
18975 " )\n"
18976 " (\n"
18977 " ))\n"
18978 "\n"
18979 " (signature bvec2\n"
18980 " (parameters\n"
18981 " (declare (in ) ivec2 x@0x16d07b0)\n"
18982 " (declare (in ) ivec2 y@0x16d08c0)\n"
18983 " )\n"
18984 " (\n"
18985 " ))\n"
18986 "\n"
18987 " (signature bvec3\n"
18988 " (parameters\n"
18989 " (declare (in ) ivec3 x@0x16d0aa0)\n"
18990 " (declare (in ) ivec3 y@0x16d0bb0)\n"
18991 " )\n"
18992 " (\n"
18993 " ))\n"
18994 "\n"
18995 " (signature bvec4\n"
18996 " (parameters\n"
18997 " (declare (in ) ivec4 x@0x16d0d90)\n"
18998 " (declare (in ) ivec4 y@0x16d0ea0)\n"
18999 " )\n"
19000 " (\n"
19001 " ))\n"
19002 "\n"
19003 " (signature bvec2\n"
19004 " (parameters\n"
19005 " (declare (in ) uvec2 x@0x16d1080)\n"
19006 " (declare (in ) uvec2 y@0x16d1190)\n"
19007 " )\n"
19008 " (\n"
19009 " ))\n"
19010 "\n"
19011 " (signature bvec3\n"
19012 " (parameters\n"
19013 " (declare (in ) uvec3 x@0x16d1370)\n"
19014 " (declare (in ) uvec3 y@0x16d1480)\n"
19015 " )\n"
19016 " (\n"
19017 " ))\n"
19018 "\n"
19019 " (signature bvec4\n"
19020 " (parameters\n"
19021 " (declare (in ) uvec4 x@0x16d1660)\n"
19022 " (declare (in ) uvec4 y@0x16d1770)\n"
19023 " )\n"
19024 " (\n"
19025 " ))\n"
19026 "\n"
19027 ")\n"
19028 "\n"
19029 "(function greaterThan\n"
19030 " (signature bvec2\n"
19031 " (parameters\n"
19032 " (declare (in ) vec2 x@0x16d1950)\n"
19033 " (declare (in ) vec2 y@0x16d1a60)\n"
19034 " )\n"
19035 " (\n"
19036 " ))\n"
19037 "\n"
19038 " (signature bvec3\n"
19039 " (parameters\n"
19040 " (declare (in ) vec3 x@0x16d1df0)\n"
19041 " (declare (in ) vec3 y@0x16d1f00)\n"
19042 " )\n"
19043 " (\n"
19044 " ))\n"
19045 "\n"
19046 " (signature bvec4\n"
19047 " (parameters\n"
19048 " (declare (in ) vec4 x@0x16d20e0)\n"
19049 " (declare (in ) vec4 y@0x16d21f0)\n"
19050 " )\n"
19051 " (\n"
19052 " ))\n"
19053 "\n"
19054 " (signature bvec2\n"
19055 " (parameters\n"
19056 " (declare (in ) ivec2 x@0x16d23d0)\n"
19057 " (declare (in ) ivec2 y@0x16d24e0)\n"
19058 " )\n"
19059 " (\n"
19060 " ))\n"
19061 "\n"
19062 " (signature bvec3\n"
19063 " (parameters\n"
19064 " (declare (in ) ivec3 x@0x16d26c0)\n"
19065 " (declare (in ) ivec3 y@0x16d27d0)\n"
19066 " )\n"
19067 " (\n"
19068 " ))\n"
19069 "\n"
19070 " (signature bvec4\n"
19071 " (parameters\n"
19072 " (declare (in ) ivec4 x@0x16d29b0)\n"
19073 " (declare (in ) ivec4 y@0x16d2ac0)\n"
19074 " )\n"
19075 " (\n"
19076 " ))\n"
19077 "\n"
19078 " (signature bvec2\n"
19079 " (parameters\n"
19080 " (declare (in ) uvec2 x@0x16d2ca0)\n"
19081 " (declare (in ) uvec2 y@0x16d2db0)\n"
19082 " )\n"
19083 " (\n"
19084 " ))\n"
19085 "\n"
19086 " (signature bvec3\n"
19087 " (parameters\n"
19088 " (declare (in ) uvec3 x@0x16d2f90)\n"
19089 " (declare (in ) uvec3 y@0x16d30a0)\n"
19090 " )\n"
19091 " (\n"
19092 " ))\n"
19093 "\n"
19094 " (signature bvec4\n"
19095 " (parameters\n"
19096 " (declare (in ) uvec4 x@0x16d3280)\n"
19097 " (declare (in ) uvec4 y@0x16d3390)\n"
19098 " )\n"
19099 " (\n"
19100 " ))\n"
19101 "\n"
19102 ")\n"
19103 "\n"
19104 "(function greaterThanEqual\n"
19105 " (signature bvec2\n"
19106 " (parameters\n"
19107 " (declare (in ) vec2 x@0x16d3570)\n"
19108 " (declare (in ) vec2 y@0x16d3680)\n"
19109 " )\n"
19110 " (\n"
19111 " ))\n"
19112 "\n"
19113 " (signature bvec3\n"
19114 " (parameters\n"
19115 " (declare (in ) vec3 x@0x16d3a10)\n"
19116 " (declare (in ) vec3 y@0x16d3b20)\n"
19117 " )\n"
19118 " (\n"
19119 " ))\n"
19120 "\n"
19121 " (signature bvec4\n"
19122 " (parameters\n"
19123 " (declare (in ) vec4 x@0x16d3d00)\n"
19124 " (declare (in ) vec4 y@0x16d3e10)\n"
19125 " )\n"
19126 " (\n"
19127 " ))\n"
19128 "\n"
19129 " (signature bvec2\n"
19130 " (parameters\n"
19131 " (declare (in ) ivec2 x@0x16d3ff0)\n"
19132 " (declare (in ) ivec2 y@0x16d4100)\n"
19133 " )\n"
19134 " (\n"
19135 " ))\n"
19136 "\n"
19137 " (signature bvec3\n"
19138 " (parameters\n"
19139 " (declare (in ) ivec3 x@0x16d42e0)\n"
19140 " (declare (in ) ivec3 y@0x16d43f0)\n"
19141 " )\n"
19142 " (\n"
19143 " ))\n"
19144 "\n"
19145 " (signature bvec4\n"
19146 " (parameters\n"
19147 " (declare (in ) ivec4 x@0x16d45d0)\n"
19148 " (declare (in ) ivec4 y@0x16d46e0)\n"
19149 " )\n"
19150 " (\n"
19151 " ))\n"
19152 "\n"
19153 " (signature bvec2\n"
19154 " (parameters\n"
19155 " (declare (in ) uvec2 x@0x16d48c0)\n"
19156 " (declare (in ) uvec2 y@0x16d49d0)\n"
19157 " )\n"
19158 " (\n"
19159 " ))\n"
19160 "\n"
19161 " (signature bvec3\n"
19162 " (parameters\n"
19163 " (declare (in ) uvec3 x@0x16d4bb0)\n"
19164 " (declare (in ) uvec3 y@0x16d4cc0)\n"
19165 " )\n"
19166 " (\n"
19167 " ))\n"
19168 "\n"
19169 " (signature bvec4\n"
19170 " (parameters\n"
19171 " (declare (in ) uvec4 x@0x16d4ea0)\n"
19172 " (declare (in ) uvec4 y@0x16d4fb0)\n"
19173 " )\n"
19174 " (\n"
19175 " ))\n"
19176 "\n"
19177 ")\n"
19178 "\n"
19179 "(function equal\n"
19180 " (signature bvec2\n"
19181 " (parameters\n"
19182 " (declare (in ) vec2 x@0x16d5190)\n"
19183 " (declare (in ) vec2 y@0x16d52a0)\n"
19184 " )\n"
19185 " (\n"
19186 " ))\n"
19187 "\n"
19188 " (signature bvec3\n"
19189 " (parameters\n"
19190 " (declare (in ) vec3 x@0x16d5620)\n"
19191 " (declare (in ) vec3 y@0x16d5730)\n"
19192 " )\n"
19193 " (\n"
19194 " ))\n"
19195 "\n"
19196 " (signature bvec4\n"
19197 " (parameters\n"
19198 " (declare (in ) vec4 x@0x16d5910)\n"
19199 " (declare (in ) vec4 y@0x16d5a20)\n"
19200 " )\n"
19201 " (\n"
19202 " ))\n"
19203 "\n"
19204 " (signature bvec2\n"
19205 " (parameters\n"
19206 " (declare (in ) ivec2 x@0x16d5c00)\n"
19207 " (declare (in ) ivec2 y@0x16d5d10)\n"
19208 " )\n"
19209 " (\n"
19210 " ))\n"
19211 "\n"
19212 " (signature bvec3\n"
19213 " (parameters\n"
19214 " (declare (in ) ivec3 x@0x16d5ef0)\n"
19215 " (declare (in ) ivec3 y@0x16d6000)\n"
19216 " )\n"
19217 " (\n"
19218 " ))\n"
19219 "\n"
19220 " (signature bvec4\n"
19221 " (parameters\n"
19222 " (declare (in ) ivec4 x@0x16d61e0)\n"
19223 " (declare (in ) ivec4 y@0x16d62f0)\n"
19224 " )\n"
19225 " (\n"
19226 " ))\n"
19227 "\n"
19228 " (signature bvec2\n"
19229 " (parameters\n"
19230 " (declare (in ) uvec2 x@0x16d64d0)\n"
19231 " (declare (in ) uvec2 y@0x16d65e0)\n"
19232 " )\n"
19233 " (\n"
19234 " ))\n"
19235 "\n"
19236 " (signature bvec3\n"
19237 " (parameters\n"
19238 " (declare (in ) uvec3 x@0x16d67c0)\n"
19239 " (declare (in ) uvec3 y@0x16d68d0)\n"
19240 " )\n"
19241 " (\n"
19242 " ))\n"
19243 "\n"
19244 " (signature bvec4\n"
19245 " (parameters\n"
19246 " (declare (in ) uvec4 x@0x16d6ab0)\n"
19247 " (declare (in ) uvec4 y@0x16d6bc0)\n"
19248 " )\n"
19249 " (\n"
19250 " ))\n"
19251 "\n"
19252 " (signature bvec2\n"
19253 " (parameters\n"
19254 " (declare (in ) bvec2 x@0x16d6da0)\n"
19255 " (declare (in ) bvec2 y@0x16d6eb0)\n"
19256 " )\n"
19257 " (\n"
19258 " ))\n"
19259 "\n"
19260 " (signature bvec3\n"
19261 " (parameters\n"
19262 " (declare (in ) bvec3 x@0x16d7090)\n"
19263 " (declare (in ) bvec3 y@0x16d71a0)\n"
19264 " )\n"
19265 " (\n"
19266 " ))\n"
19267 "\n"
19268 " (signature bvec4\n"
19269 " (parameters\n"
19270 " (declare (in ) bvec4 x@0x16d7380)\n"
19271 " (declare (in ) bvec4 y@0x16d7490)\n"
19272 " )\n"
19273 " (\n"
19274 " ))\n"
19275 "\n"
19276 ")\n"
19277 "\n"
19278 "(function notEqual\n"
19279 " (signature bvec2\n"
19280 " (parameters\n"
19281 " (declare (in ) vec2 x@0x16d7670)\n"
19282 " (declare (in ) vec2 y@0x16d7780)\n"
19283 " )\n"
19284 " (\n"
19285 " ))\n"
19286 "\n"
19287 " (signature bvec3\n"
19288 " (parameters\n"
19289 " (declare (in ) vec3 x@0x16d7b10)\n"
19290 " (declare (in ) vec3 y@0x16d7c20)\n"
19291 " )\n"
19292 " (\n"
19293 " ))\n"
19294 "\n"
19295 " (signature bvec4\n"
19296 " (parameters\n"
19297 " (declare (in ) vec4 x@0x16d7e00)\n"
19298 " (declare (in ) vec4 y@0x16d7f10)\n"
19299 " )\n"
19300 " (\n"
19301 " ))\n"
19302 "\n"
19303 " (signature bvec2\n"
19304 " (parameters\n"
19305 " (declare (in ) ivec2 x@0x16d80f0)\n"
19306 " (declare (in ) ivec2 y@0x16d8200)\n"
19307 " )\n"
19308 " (\n"
19309 " ))\n"
19310 "\n"
19311 " (signature bvec3\n"
19312 " (parameters\n"
19313 " (declare (in ) ivec3 x@0x16d83e0)\n"
19314 " (declare (in ) ivec3 y@0x16d84f0)\n"
19315 " )\n"
19316 " (\n"
19317 " ))\n"
19318 "\n"
19319 " (signature bvec4\n"
19320 " (parameters\n"
19321 " (declare (in ) ivec4 x@0x16d86d0)\n"
19322 " (declare (in ) ivec4 y@0x16d87e0)\n"
19323 " )\n"
19324 " (\n"
19325 " ))\n"
19326 "\n"
19327 " (signature bvec2\n"
19328 " (parameters\n"
19329 " (declare (in ) uvec2 x@0x16d89c0)\n"
19330 " (declare (in ) uvec2 y@0x16d8ad0)\n"
19331 " )\n"
19332 " (\n"
19333 " ))\n"
19334 "\n"
19335 " (signature bvec3\n"
19336 " (parameters\n"
19337 " (declare (in ) uvec3 x@0x16d8cb0)\n"
19338 " (declare (in ) uvec3 y@0x16d8dc0)\n"
19339 " )\n"
19340 " (\n"
19341 " ))\n"
19342 "\n"
19343 " (signature bvec4\n"
19344 " (parameters\n"
19345 " (declare (in ) uvec4 x@0x16d8fa0)\n"
19346 " (declare (in ) uvec4 y@0x16d90b0)\n"
19347 " )\n"
19348 " (\n"
19349 " ))\n"
19350 "\n"
19351 " (signature bvec2\n"
19352 " (parameters\n"
19353 " (declare (in ) bvec2 x@0x16d9290)\n"
19354 " (declare (in ) bvec2 y@0x16d93a0)\n"
19355 " )\n"
19356 " (\n"
19357 " ))\n"
19358 "\n"
19359 " (signature bvec3\n"
19360 " (parameters\n"
19361 " (declare (in ) bvec3 x@0x16d9580)\n"
19362 " (declare (in ) bvec3 y@0x16d9690)\n"
19363 " )\n"
19364 " (\n"
19365 " ))\n"
19366 "\n"
19367 " (signature bvec4\n"
19368 " (parameters\n"
19369 " (declare (in ) bvec4 x@0x16d9870)\n"
19370 " (declare (in ) bvec4 y@0x16d9980)\n"
19371 " )\n"
19372 " (\n"
19373 " ))\n"
19374 "\n"
19375 ")\n"
19376 "\n"
19377 "(function any\n"
19378 " (signature bool\n"
19379 " (parameters\n"
19380 " (declare (in ) bvec2 x@0x16d9b60)\n"
19381 " )\n"
19382 " (\n"
19383 " ))\n"
19384 "\n"
19385 " (signature bool\n"
19386 " (parameters\n"
19387 " (declare (in ) bvec3 x@0x16d9ee0)\n"
19388 " )\n"
19389 " (\n"
19390 " ))\n"
19391 "\n"
19392 " (signature bool\n"
19393 " (parameters\n"
19394 " (declare (in ) bvec4 x@0x16da0c0)\n"
19395 " )\n"
19396 " (\n"
19397 " ))\n"
19398 "\n"
19399 ")\n"
19400 "\n"
19401 "(function all\n"
19402 " (signature bool\n"
19403 " (parameters\n"
19404 " (declare (in ) bvec2 x@0x16da2a0)\n"
19405 " )\n"
19406 " (\n"
19407 " ))\n"
19408 "\n"
19409 " (signature bool\n"
19410 " (parameters\n"
19411 " (declare (in ) bvec3 x@0x16da620)\n"
19412 " )\n"
19413 " (\n"
19414 " ))\n"
19415 "\n"
19416 " (signature bool\n"
19417 " (parameters\n"
19418 " (declare (in ) bvec4 x@0x16da800)\n"
19419 " )\n"
19420 " (\n"
19421 " ))\n"
19422 "\n"
19423 ")\n"
19424 "\n"
19425 "(function not\n"
19426 " (signature bvec2\n"
19427 " (parameters\n"
19428 " (declare (in ) bvec2 x@0x16da9e0)\n"
19429 " )\n"
19430 " (\n"
19431 " ))\n"
19432 "\n"
19433 " (signature bvec3\n"
19434 " (parameters\n"
19435 " (declare (in ) bvec3 x@0x16dad60)\n"
19436 " )\n"
19437 " (\n"
19438 " ))\n"
19439 "\n"
19440 " (signature bvec4\n"
19441 " (parameters\n"
19442 " (declare (in ) bvec4 x@0x16daf40)\n"
19443 " )\n"
19444 " (\n"
19445 " ))\n"
19446 "\n"
19447 ")\n"
19448 "\n"
19449 "(function texture\n"
19450 " (signature vec4\n"
19451 " (parameters\n"
19452 " (declare (in ) sampler1D sampler@0x16db120)\n"
19453 " (declare (in ) float P@0x16db230)\n"
19454 " )\n"
19455 " (\n"
19456 " ))\n"
19457 "\n"
19458 " (signature ivec4\n"
19459 " (parameters\n"
19460 " (declare (in ) isampler1D sampler@0x16db5b0)\n"
19461 " (declare (in ) float P@0x16db6c0)\n"
19462 " )\n"
19463 " (\n"
19464 " ))\n"
19465 "\n"
19466 " (signature uvec4\n"
19467 " (parameters\n"
19468 " (declare (in ) usampler1D sampler@0x16db8a0)\n"
19469 " (declare (in ) float P@0x16db9b0)\n"
19470 " )\n"
19471 " (\n"
19472 " ))\n"
19473 "\n"
19474 " (signature vec4\n"
19475 " (parameters\n"
19476 " (declare (in ) sampler2D sampler@0x16dbb90)\n"
19477 " (declare (in ) vec2 P@0x16dbca0)\n"
19478 " )\n"
19479 " (\n"
19480 " ))\n"
19481 "\n"
19482 " (signature ivec4\n"
19483 " (parameters\n"
19484 " (declare (in ) isampler2D sampler@0x16dbe80)\n"
19485 " (declare (in ) vec2 P@0x16dbf90)\n"
19486 " )\n"
19487 " (\n"
19488 " ))\n"
19489 "\n"
19490 " (signature uvec4\n"
19491 " (parameters\n"
19492 " (declare (in ) usampler2D sampler@0x16dc170)\n"
19493 " (declare (in ) vec2 P@0x16dc280)\n"
19494 " )\n"
19495 " (\n"
19496 " ))\n"
19497 "\n"
19498 " (signature vec4\n"
19499 " (parameters\n"
19500 " (declare (in ) sampler3D sampler@0x16dc460)\n"
19501 " (declare (in ) vec3 P@0x16dc570)\n"
19502 " )\n"
19503 " (\n"
19504 " ))\n"
19505 "\n"
19506 " (signature ivec4\n"
19507 " (parameters\n"
19508 " (declare (in ) isampler3D sampler@0x16dc750)\n"
19509 " (declare (in ) vec3 P@0x16dc860)\n"
19510 " )\n"
19511 " (\n"
19512 " ))\n"
19513 "\n"
19514 " (signature uvec4\n"
19515 " (parameters\n"
19516 " (declare (in ) usampler3D sampler@0x16dca40)\n"
19517 " (declare (in ) vec3 P@0x16dcb50)\n"
19518 " )\n"
19519 " (\n"
19520 " ))\n"
19521 "\n"
19522 " (signature vec4\n"
19523 " (parameters\n"
19524 " (declare (in ) samplerCube sampler@0x16dcd30)\n"
19525 " (declare (in ) vec3 P@0x16dce40)\n"
19526 " )\n"
19527 " (\n"
19528 " ))\n"
19529 "\n"
19530 " (signature ivec4\n"
19531 " (parameters\n"
19532 " (declare (in ) isamplerCube sampler@0x16dd020)\n"
19533 " (declare (in ) vec3 P@0x16dd130)\n"
19534 " )\n"
19535 " (\n"
19536 " ))\n"
19537 "\n"
19538 " (signature uvec4\n"
19539 " (parameters\n"
19540 " (declare (in ) usamplerCube sampler@0x16dd310)\n"
19541 " (declare (in ) vec3 P@0x16dd420)\n"
19542 " )\n"
19543 " (\n"
19544 " ))\n"
19545 "\n"
19546 " (signature float\n"
19547 " (parameters\n"
19548 " (declare (in ) sampler1DShadow sampler@0x16dd600)\n"
19549 " (declare (in ) vec3 P@0x16dd710)\n"
19550 " )\n"
19551 " (\n"
19552 " ))\n"
19553 "\n"
19554 " (signature float\n"
19555 " (parameters\n"
19556 " (declare (in ) sampler2DShadow sampler@0x16dd8f0)\n"
19557 " (declare (in ) vec3 P@0x16dda00)\n"
19558 " )\n"
19559 " (\n"
19560 " ))\n"
19561 "\n"
19562 " (signature float\n"
19563 " (parameters\n"
19564 " (declare (in ) samplerCubeShadow sampler@0x16ddbe0)\n"
19565 " (declare (in ) vec4 P@0x16ddcf0)\n"
19566 " )\n"
19567 " (\n"
19568 " ))\n"
19569 "\n"
19570 " (signature vec4\n"
19571 " (parameters\n"
19572 " (declare (in ) sampler1DArray sampler@0x16dded0)\n"
19573 " (declare (in ) vec2 P@0x16ddfe0)\n"
19574 " )\n"
19575 " (\n"
19576 " ))\n"
19577 "\n"
19578 " (signature ivec4\n"
19579 " (parameters\n"
19580 " (declare (in ) isampler1DArray sampler@0x16de1c0)\n"
19581 " (declare (in ) vec2 P@0x16de2d0)\n"
19582 " )\n"
19583 " (\n"
19584 " ))\n"
19585 "\n"
19586 " (signature uvec4\n"
19587 " (parameters\n"
19588 " (declare (in ) usampler1DArray sampler@0x16de4b0)\n"
19589 " (declare (in ) vec2 P@0x16de5c0)\n"
19590 " )\n"
19591 " (\n"
19592 " ))\n"
19593 "\n"
19594 " (signature vec4\n"
19595 " (parameters\n"
19596 " (declare (in ) sampler2DArray sampler@0x16de7a0)\n"
19597 " (declare (in ) vec3 P@0x16de8b0)\n"
19598 " )\n"
19599 " (\n"
19600 " ))\n"
19601 "\n"
19602 " (signature ivec4\n"
19603 " (parameters\n"
19604 " (declare (in ) isampler2DArray sampler@0x16dea90)\n"
19605 " (declare (in ) vec3 P@0x16deba0)\n"
19606 " )\n"
19607 " (\n"
19608 " ))\n"
19609 "\n"
19610 " (signature uvec4\n"
19611 " (parameters\n"
19612 " (declare (in ) usampler2DArray sampler@0x16ded80)\n"
19613 " (declare (in ) vec3 P@0x16dee90)\n"
19614 " )\n"
19615 " (\n"
19616 " ))\n"
19617 "\n"
19618 " (signature float\n"
19619 " (parameters\n"
19620 " (declare (in ) sampler1DArrayShadow sampler@0x16df070)\n"
19621 " (declare (in ) vec3 P@0x16df180)\n"
19622 " )\n"
19623 " (\n"
19624 " ))\n"
19625 "\n"
19626 " (signature float\n"
19627 " (parameters\n"
19628 " (declare (in ) sampler2DArrayShadow sampler@0x16df360)\n"
19629 " (declare (in ) vec4 P@0x16df470)\n"
19630 " )\n"
19631 " (\n"
19632 " ))\n"
19633 "\n"
19634 " (signature vec4\n"
19635 " (parameters\n"
19636 " (declare (in ) sampler1D sampler@0x16df650)\n"
19637 " (declare (in ) float P@0x16df760)\n"
19638 " (declare (in ) float bias@0x16df870)\n"
19639 " )\n"
19640 " (\n"
19641 " ))\n"
19642 "\n"
19643 " (signature ivec4\n"
19644 " (parameters\n"
19645 " (declare (in ) isampler1D sampler@0x16dfa50)\n"
19646 " (declare (in ) float P@0x16dfb60)\n"
19647 " (declare (in ) float bias@0x16dfc70)\n"
19648 " )\n"
19649 " (\n"
19650 " ))\n"
19651 "\n"
19652 " (signature uvec4\n"
19653 " (parameters\n"
19654 " (declare (in ) usampler1D sampler@0x16dfe50)\n"
19655 " (declare (in ) float P@0x16dff60)\n"
19656 " (declare (in ) float bias@0x16e0070)\n"
19657 " )\n"
19658 " (\n"
19659 " ))\n"
19660 "\n"
19661 " (signature vec4\n"
19662 " (parameters\n"
19663 " (declare (in ) sampler2D sampler@0x16e0250)\n"
19664 " (declare (in ) vec2 P@0x16e0360)\n"
19665 " (declare (in ) float bias@0x16e0470)\n"
19666 " )\n"
19667 " (\n"
19668 " ))\n"
19669 "\n"
19670 " (signature ivec4\n"
19671 " (parameters\n"
19672 " (declare (in ) isampler2D sampler@0x16e0650)\n"
19673 " (declare (in ) vec2 P@0x16e0760)\n"
19674 " (declare (in ) float bias@0x16e0870)\n"
19675 " )\n"
19676 " (\n"
19677 " ))\n"
19678 "\n"
19679 " (signature uvec4\n"
19680 " (parameters\n"
19681 " (declare (in ) usampler2D sampler@0x16e0a50)\n"
19682 " (declare (in ) vec2 P@0x16e0b60)\n"
19683 " (declare (in ) float bias@0x16e0c70)\n"
19684 " )\n"
19685 " (\n"
19686 " ))\n"
19687 "\n"
19688 " (signature vec4\n"
19689 " (parameters\n"
19690 " (declare (in ) sampler3D sampler@0x16e0e50)\n"
19691 " (declare (in ) vec3 P@0x16e0f60)\n"
19692 " (declare (in ) float bias@0x16e1070)\n"
19693 " )\n"
19694 " (\n"
19695 " ))\n"
19696 "\n"
19697 " (signature ivec4\n"
19698 " (parameters\n"
19699 " (declare (in ) isampler3D sampler@0x16e1250)\n"
19700 " (declare (in ) vec3 P@0x16e1360)\n"
19701 " (declare (in ) float bias@0x16e1470)\n"
19702 " )\n"
19703 " (\n"
19704 " ))\n"
19705 "\n"
19706 " (signature uvec4\n"
19707 " (parameters\n"
19708 " (declare (in ) usampler3D sampler@0x16e1650)\n"
19709 " (declare (in ) vec3 P@0x16e1760)\n"
19710 " (declare (in ) float bias@0x16e1870)\n"
19711 " )\n"
19712 " (\n"
19713 " ))\n"
19714 "\n"
19715 " (signature vec4\n"
19716 " (parameters\n"
19717 " (declare (in ) samplerCube sampler@0x16e1a50)\n"
19718 " (declare (in ) vec3 P@0x16e1b60)\n"
19719 " (declare (in ) float bias@0x16e1c70)\n"
19720 " )\n"
19721 " (\n"
19722 " ))\n"
19723 "\n"
19724 " (signature ivec4\n"
19725 " (parameters\n"
19726 " (declare (in ) isamplerCube sampler@0x16e1e50)\n"
19727 " (declare (in ) vec3 P@0x16e1f60)\n"
19728 " (declare (in ) float bias@0x16e2070)\n"
19729 " )\n"
19730 " (\n"
19731 " ))\n"
19732 "\n"
19733 " (signature uvec4\n"
19734 " (parameters\n"
19735 " (declare (in ) usamplerCube sampler@0x16e2250)\n"
19736 " (declare (in ) vec3 P@0x16e2360)\n"
19737 " (declare (in ) float bias@0x16e2470)\n"
19738 " )\n"
19739 " (\n"
19740 " ))\n"
19741 "\n"
19742 " (signature float\n"
19743 " (parameters\n"
19744 " (declare (in ) sampler1DShadow sampler@0x16e2650)\n"
19745 " (declare (in ) vec3 P@0x16e2760)\n"
19746 " (declare (in ) float bias@0x16e2870)\n"
19747 " )\n"
19748 " (\n"
19749 " ))\n"
19750 "\n"
19751 " (signature float\n"
19752 " (parameters\n"
19753 " (declare (in ) sampler2DShadow sampler@0x16e2a50)\n"
19754 " (declare (in ) vec3 P@0x16e2b60)\n"
19755 " (declare (in ) float bias@0x16e2c70)\n"
19756 " )\n"
19757 " (\n"
19758 " ))\n"
19759 "\n"
19760 " (signature float\n"
19761 " (parameters\n"
19762 " (declare (in ) samplerCubeShadow sampler@0x16e2e50)\n"
19763 " (declare (in ) vec4 P@0x16e2f60)\n"
19764 " (declare (in ) float bias@0x16e3070)\n"
19765 " )\n"
19766 " (\n"
19767 " ))\n"
19768 "\n"
19769 " (signature vec4\n"
19770 " (parameters\n"
19771 " (declare (in ) sampler1DArray sampler@0x16e3250)\n"
19772 " (declare (in ) vec2 P@0x16e3360)\n"
19773 " (declare (in ) float bias@0x16e3470)\n"
19774 " )\n"
19775 " (\n"
19776 " ))\n"
19777 "\n"
19778 " (signature ivec4\n"
19779 " (parameters\n"
19780 " (declare (in ) isampler1DArray sampler@0x16e3650)\n"
19781 " (declare (in ) vec2 P@0x16e3760)\n"
19782 " (declare (in ) float bias@0x16e3870)\n"
19783 " )\n"
19784 " (\n"
19785 " ))\n"
19786 "\n"
19787 " (signature uvec4\n"
19788 " (parameters\n"
19789 " (declare (in ) usampler1DArray sampler@0x16e3a50)\n"
19790 " (declare (in ) vec2 P@0x16e3b60)\n"
19791 " (declare (in ) float bias@0x16e3c70)\n"
19792 " )\n"
19793 " (\n"
19794 " ))\n"
19795 "\n"
19796 " (signature vec4\n"
19797 " (parameters\n"
19798 " (declare (in ) sampler2DArray sampler@0x16e3e50)\n"
19799 " (declare (in ) vec3 P@0x16e3f60)\n"
19800 " (declare (in ) float bias@0x16e4070)\n"
19801 " )\n"
19802 " (\n"
19803 " ))\n"
19804 "\n"
19805 " (signature ivec4\n"
19806 " (parameters\n"
19807 " (declare (in ) isampler2DArray sampler@0x16e4250)\n"
19808 " (declare (in ) vec3 P@0x16e4360)\n"
19809 " (declare (in ) float bias@0x16e4470)\n"
19810 " )\n"
19811 " (\n"
19812 " ))\n"
19813 "\n"
19814 " (signature uvec4\n"
19815 " (parameters\n"
19816 " (declare (in ) usampler2DArray sampler@0x16e4650)\n"
19817 " (declare (in ) vec3 P@0x16e4760)\n"
19818 " (declare (in ) float bias@0x16e4870)\n"
19819 " )\n"
19820 " (\n"
19821 " ))\n"
19822 "\n"
19823 " (signature float\n"
19824 " (parameters\n"
19825 " (declare (in ) sampler1DArrayShadow sampler@0x16e4a50)\n"
19826 " (declare (in ) vec3 P@0x16e4b60)\n"
19827 " (declare (in ) float bias@0x16e4c70)\n"
19828 " )\n"
19829 " (\n"
19830 " ))\n"
19831 "\n"
19832 ")\n"
19833 "\n"
19834 "(function textureProj\n"
19835 " (signature vec4\n"
19836 " (parameters\n"
19837 " (declare (in ) sampler1D sampler@0x16e4e50)\n"
19838 " (declare (in ) vec2 P@0x16e4f60)\n"
19839 " )\n"
19840 " (\n"
19841 " ))\n"
19842 "\n"
19843 " (signature ivec4\n"
19844 " (parameters\n"
19845 " (declare (in ) isampler1D sampler@0x16e52f0)\n"
19846 " (declare (in ) vec2 P@0x16e5400)\n"
19847 " )\n"
19848 " (\n"
19849 " ))\n"
19850 "\n"
19851 " (signature uvec4\n"
19852 " (parameters\n"
19853 " (declare (in ) usampler1D sampler@0x16e55e0)\n"
19854 " (declare (in ) vec2 P@0x16e56f0)\n"
19855 " )\n"
19856 " (\n"
19857 " ))\n"
19858 "\n"
19859 " (signature vec4\n"
19860 " (parameters\n"
19861 " (declare (in ) sampler1D sampler@0x16e58d0)\n"
19862 " (declare (in ) vec4 P@0x16e59e0)\n"
19863 " )\n"
19864 " (\n"
19865 " ))\n"
19866 "\n"
19867 " (signature ivec4\n"
19868 " (parameters\n"
19869 " (declare (in ) isampler1D sampler@0x16e5bc0)\n"
19870 " (declare (in ) vec4 P@0x16e5cd0)\n"
19871 " )\n"
19872 " (\n"
19873 " ))\n"
19874 "\n"
19875 " (signature uvec4\n"
19876 " (parameters\n"
19877 " (declare (in ) usampler1D sampler@0x16e5eb0)\n"
19878 " (declare (in ) vec4 P@0x16e5fc0)\n"
19879 " )\n"
19880 " (\n"
19881 " ))\n"
19882 "\n"
19883 " (signature vec4\n"
19884 " (parameters\n"
19885 " (declare (in ) sampler2D sampler@0x16e61a0)\n"
19886 " (declare (in ) vec3 P@0x16e62b0)\n"
19887 " )\n"
19888 " (\n"
19889 " ))\n"
19890 "\n"
19891 " (signature ivec4\n"
19892 " (parameters\n"
19893 " (declare (in ) isampler2D sampler@0x16e6490)\n"
19894 " (declare (in ) vec3 P@0x16e65a0)\n"
19895 " )\n"
19896 " (\n"
19897 " ))\n"
19898 "\n"
19899 " (signature uvec4\n"
19900 " (parameters\n"
19901 " (declare (in ) usampler2D sampler@0x16e6780)\n"
19902 " (declare (in ) vec3 P@0x16e6890)\n"
19903 " )\n"
19904 " (\n"
19905 " ))\n"
19906 "\n"
19907 " (signature vec4\n"
19908 " (parameters\n"
19909 " (declare (in ) sampler2D sampler@0x16e6a70)\n"
19910 " (declare (in ) vec4 P@0x16e6b80)\n"
19911 " )\n"
19912 " (\n"
19913 " ))\n"
19914 "\n"
19915 " (signature ivec4\n"
19916 " (parameters\n"
19917 " (declare (in ) isampler2D sampler@0x16e6d60)\n"
19918 " (declare (in ) vec4 P@0x16e6e70)\n"
19919 " )\n"
19920 " (\n"
19921 " ))\n"
19922 "\n"
19923 " (signature uvec4\n"
19924 " (parameters\n"
19925 " (declare (in ) usampler2D sampler@0x16e7050)\n"
19926 " (declare (in ) vec4 P@0x16e7160)\n"
19927 " )\n"
19928 " (\n"
19929 " ))\n"
19930 "\n"
19931 " (signature vec4\n"
19932 " (parameters\n"
19933 " (declare (in ) sampler3D sampler@0x16e7340)\n"
19934 " (declare (in ) vec4 P@0x16e7450)\n"
19935 " )\n"
19936 " (\n"
19937 " ))\n"
19938 "\n"
19939 " (signature ivec4\n"
19940 " (parameters\n"
19941 " (declare (in ) isampler3D sampler@0x16e7630)\n"
19942 " (declare (in ) vec4 P@0x16e7740)\n"
19943 " )\n"
19944 " (\n"
19945 " ))\n"
19946 "\n"
19947 " (signature uvec4\n"
19948 " (parameters\n"
19949 " (declare (in ) usampler3D sampler@0x16e7920)\n"
19950 " (declare (in ) vec4 P@0x16e7a30)\n"
19951 " )\n"
19952 " (\n"
19953 " ))\n"
19954 "\n"
19955 " (signature float\n"
19956 " (parameters\n"
19957 " (declare (in ) sampler1DShadow sampler@0x16e7c10)\n"
19958 " (declare (in ) vec4 P@0x16e7d20)\n"
19959 " )\n"
19960 " (\n"
19961 " ))\n"
19962 "\n"
19963 " (signature float\n"
19964 " (parameters\n"
19965 " (declare (in ) sampler2DShadow sampler@0x16e7f00)\n"
19966 " (declare (in ) vec4 P@0x16e8010)\n"
19967 " )\n"
19968 " (\n"
19969 " ))\n"
19970 "\n"
19971 " (signature vec4\n"
19972 " (parameters\n"
19973 " (declare (in ) sampler1D sampler@0x16e81f0)\n"
19974 " (declare (in ) vec2 P@0x16e8300)\n"
19975 " (declare (in ) float bias@0x16e8410)\n"
19976 " )\n"
19977 " (\n"
19978 " ))\n"
19979 "\n"
19980 " (signature ivec4\n"
19981 " (parameters\n"
19982 " (declare (in ) isampler1D sampler@0x16e85f0)\n"
19983 " (declare (in ) vec2 P@0x16e8700)\n"
19984 " (declare (in ) float bias@0x16e8810)\n"
19985 " )\n"
19986 " (\n"
19987 " ))\n"
19988 "\n"
19989 " (signature uvec4\n"
19990 " (parameters\n"
19991 " (declare (in ) usampler1D sampler@0x16e89f0)\n"
19992 " (declare (in ) vec2 P@0x16e8b00)\n"
19993 " (declare (in ) float bias@0x16e8c10)\n"
19994 " )\n"
19995 " (\n"
19996 " ))\n"
19997 "\n"
19998 " (signature vec4\n"
19999 " (parameters\n"
20000 " (declare (in ) sampler1D sampler@0x16e8df0)\n"
20001 " (declare (in ) vec4 P@0x16e8f00)\n"
20002 " (declare (in ) float bias@0x16e9010)\n"
20003 " )\n"
20004 " (\n"
20005 " ))\n"
20006 "\n"
20007 " (signature ivec4\n"
20008 " (parameters\n"
20009 " (declare (in ) isampler1D sampler@0x16e91f0)\n"
20010 " (declare (in ) vec4 P@0x16e9300)\n"
20011 " (declare (in ) float bias@0x16e9410)\n"
20012 " )\n"
20013 " (\n"
20014 " ))\n"
20015 "\n"
20016 " (signature uvec4\n"
20017 " (parameters\n"
20018 " (declare (in ) usampler1D sampler@0x16e95f0)\n"
20019 " (declare (in ) vec4 P@0x16e9700)\n"
20020 " (declare (in ) float bias@0x16e9810)\n"
20021 " )\n"
20022 " (\n"
20023 " ))\n"
20024 "\n"
20025 " (signature vec4\n"
20026 " (parameters\n"
20027 " (declare (in ) sampler2D sampler@0x16e99f0)\n"
20028 " (declare (in ) vec3 P@0x16e9b00)\n"
20029 " (declare (in ) float bias@0x16e9c10)\n"
20030 " )\n"
20031 " (\n"
20032 " ))\n"
20033 "\n"
20034 " (signature ivec4\n"
20035 " (parameters\n"
20036 " (declare (in ) isampler2D sampler@0x16e9df0)\n"
20037 " (declare (in ) vec3 P@0x16e9f00)\n"
20038 " (declare (in ) float bias@0x16ea010)\n"
20039 " )\n"
20040 " (\n"
20041 " ))\n"
20042 "\n"
20043 " (signature uvec4\n"
20044 " (parameters\n"
20045 " (declare (in ) usampler2D sampler@0x16ea1f0)\n"
20046 " (declare (in ) vec3 P@0x16ea300)\n"
20047 " (declare (in ) float bias@0x16ea410)\n"
20048 " )\n"
20049 " (\n"
20050 " ))\n"
20051 "\n"
20052 " (signature vec4\n"
20053 " (parameters\n"
20054 " (declare (in ) sampler2D sampler@0x16ea5f0)\n"
20055 " (declare (in ) vec4 P@0x16ea700)\n"
20056 " (declare (in ) float bias@0x16ea810)\n"
20057 " )\n"
20058 " (\n"
20059 " ))\n"
20060 "\n"
20061 " (signature ivec4\n"
20062 " (parameters\n"
20063 " (declare (in ) isampler2D sampler@0x16ea9f0)\n"
20064 " (declare (in ) vec4 P@0x16eab00)\n"
20065 " (declare (in ) float bias@0x16eac10)\n"
20066 " )\n"
20067 " (\n"
20068 " ))\n"
20069 "\n"
20070 " (signature uvec4\n"
20071 " (parameters\n"
20072 " (declare (in ) usampler2D sampler@0x16eadf0)\n"
20073 " (declare (in ) vec4 P@0x16eaf00)\n"
20074 " (declare (in ) float bias@0x16eb010)\n"
20075 " )\n"
20076 " (\n"
20077 " ))\n"
20078 "\n"
20079 " (signature vec4\n"
20080 " (parameters\n"
20081 " (declare (in ) sampler3D sampler@0x16eb1f0)\n"
20082 " (declare (in ) vec4 P@0x16eb300)\n"
20083 " (declare (in ) float bias@0x16eb410)\n"
20084 " )\n"
20085 " (\n"
20086 " ))\n"
20087 "\n"
20088 " (signature ivec4\n"
20089 " (parameters\n"
20090 " (declare (in ) isampler3D sampler@0x16eb5f0)\n"
20091 " (declare (in ) vec4 P@0x16eb700)\n"
20092 " (declare (in ) float bias@0x16eb810)\n"
20093 " )\n"
20094 " (\n"
20095 " ))\n"
20096 "\n"
20097 " (signature uvec4\n"
20098 " (parameters\n"
20099 " (declare (in ) usampler3D sampler@0x16eb9f0)\n"
20100 " (declare (in ) vec4 P@0x16ebb00)\n"
20101 " (declare (in ) float bias@0x16ebc10)\n"
20102 " )\n"
20103 " (\n"
20104 " ))\n"
20105 "\n"
20106 " (signature float\n"
20107 " (parameters\n"
20108 " (declare (in ) sampler1DShadow sampler@0x16ebdf0)\n"
20109 " (declare (in ) vec4 P@0x16ebf00)\n"
20110 " (declare (in ) float bias@0x16ec010)\n"
20111 " )\n"
20112 " (\n"
20113 " ))\n"
20114 "\n"
20115 " (signature float\n"
20116 " (parameters\n"
20117 " (declare (in ) sampler2DShadow sampler@0x16ec1f0)\n"
20118 " (declare (in ) vec4 P@0x16ec300)\n"
20119 " (declare (in ) float bias@0x16ec410)\n"
20120 " )\n"
20121 " (\n"
20122 " ))\n"
20123 "\n"
20124 ")\n"
20125 "\n"
20126 "(function textureLod\n"
20127 " (signature vec4\n"
20128 " (parameters\n"
20129 " (declare (in ) sampler1D sampler@0x16ec5f0)\n"
20130 " (declare (in ) float P@0x16ec700)\n"
20131 " (declare (in ) float lod@0x16ec810)\n"
20132 " )\n"
20133 " (\n"
20134 " ))\n"
20135 "\n"
20136 " (signature ivec4\n"
20137 " (parameters\n"
20138 " (declare (in ) isampler1D sampler@0x16ecba0)\n"
20139 " (declare (in ) float P@0x16eccb0)\n"
20140 " (declare (in ) float lod@0x16ecdc0)\n"
20141 " )\n"
20142 " (\n"
20143 " ))\n"
20144 "\n"
20145 " (signature uvec4\n"
20146 " (parameters\n"
20147 " (declare (in ) usampler1D sampler@0x16ecfa0)\n"
20148 " (declare (in ) float P@0x16ed0b0)\n"
20149 " (declare (in ) float lod@0x16ed1c0)\n"
20150 " )\n"
20151 " (\n"
20152 " ))\n"
20153 "\n"
20154 " (signature vec4\n"
20155 " (parameters\n"
20156 " (declare (in ) sampler2D sampler@0x16ed3a0)\n"
20157 " (declare (in ) vec2 P@0x16ed4b0)\n"
20158 " (declare (in ) float lod@0x16ed5c0)\n"
20159 " )\n"
20160 " (\n"
20161 " ))\n"
20162 "\n"
20163 " (signature ivec4\n"
20164 " (parameters\n"
20165 " (declare (in ) isampler2D sampler@0x16ed7a0)\n"
20166 " (declare (in ) vec2 P@0x16ed8b0)\n"
20167 " (declare (in ) float lod@0x16ed9c0)\n"
20168 " )\n"
20169 " (\n"
20170 " ))\n"
20171 "\n"
20172 " (signature uvec4\n"
20173 " (parameters\n"
20174 " (declare (in ) usampler2D sampler@0x16edba0)\n"
20175 " (declare (in ) vec2 P@0x16edcb0)\n"
20176 " (declare (in ) float lod@0x16eddc0)\n"
20177 " )\n"
20178 " (\n"
20179 " ))\n"
20180 "\n"
20181 " (signature vec4\n"
20182 " (parameters\n"
20183 " (declare (in ) sampler3D sampler@0x16edfa0)\n"
20184 " (declare (in ) vec3 P@0x16ee0b0)\n"
20185 " (declare (in ) float lod@0x16ee1c0)\n"
20186 " )\n"
20187 " (\n"
20188 " ))\n"
20189 "\n"
20190 " (signature ivec4\n"
20191 " (parameters\n"
20192 " (declare (in ) isampler3D sampler@0x16ee3a0)\n"
20193 " (declare (in ) vec3 P@0x16ee4b0)\n"
20194 " (declare (in ) float lod@0x16ee5c0)\n"
20195 " )\n"
20196 " (\n"
20197 " ))\n"
20198 "\n"
20199 " (signature uvec4\n"
20200 " (parameters\n"
20201 " (declare (in ) usampler3D sampler@0x16ee7a0)\n"
20202 " (declare (in ) vec3 P@0x16ee8b0)\n"
20203 " (declare (in ) float lod@0x16ee9c0)\n"
20204 " )\n"
20205 " (\n"
20206 " ))\n"
20207 "\n"
20208 " (signature vec4\n"
20209 " (parameters\n"
20210 " (declare (in ) samplerCube sampler@0x16eeba0)\n"
20211 " (declare (in ) vec3 P@0x16eecb0)\n"
20212 " (declare (in ) float lod@0x16eedc0)\n"
20213 " )\n"
20214 " (\n"
20215 " ))\n"
20216 "\n"
20217 " (signature ivec4\n"
20218 " (parameters\n"
20219 " (declare (in ) isamplerCube sampler@0x16eefa0)\n"
20220 " (declare (in ) vec3 P@0x16ef0b0)\n"
20221 " (declare (in ) float lod@0x16ef1c0)\n"
20222 " )\n"
20223 " (\n"
20224 " ))\n"
20225 "\n"
20226 " (signature uvec4\n"
20227 " (parameters\n"
20228 " (declare (in ) usamplerCube sampler@0x16ef3a0)\n"
20229 " (declare (in ) vec3 P@0x16ef4b0)\n"
20230 " (declare (in ) float lod@0x16ef5c0)\n"
20231 " )\n"
20232 " (\n"
20233 " ))\n"
20234 "\n"
20235 " (signature float\n"
20236 " (parameters\n"
20237 " (declare (in ) sampler1DShadow sampler@0x16ef7a0)\n"
20238 " (declare (in ) vec3 P@0x16ef8b0)\n"
20239 " (declare (in ) float lod@0x16ef9c0)\n"
20240 " )\n"
20241 " (\n"
20242 " ))\n"
20243 "\n"
20244 " (signature float\n"
20245 " (parameters\n"
20246 " (declare (in ) sampler2DShadow sampler@0x16efba0)\n"
20247 " (declare (in ) vec3 P@0x16efcb0)\n"
20248 " (declare (in ) float lod@0x16efdc0)\n"
20249 " )\n"
20250 " (\n"
20251 " ))\n"
20252 "\n"
20253 " (signature vec4\n"
20254 " (parameters\n"
20255 " (declare (in ) sampler1DArray sampler@0x16effa0)\n"
20256 " (declare (in ) vec2 P@0x16f00b0)\n"
20257 " (declare (in ) float lod@0x16f01c0)\n"
20258 " )\n"
20259 " (\n"
20260 " ))\n"
20261 "\n"
20262 " (signature ivec4\n"
20263 " (parameters\n"
20264 " (declare (in ) isampler1DArray sampler@0x16f03a0)\n"
20265 " (declare (in ) vec2 P@0x16f04b0)\n"
20266 " (declare (in ) float lod@0x16f05c0)\n"
20267 " )\n"
20268 " (\n"
20269 " ))\n"
20270 "\n"
20271 " (signature uvec4\n"
20272 " (parameters\n"
20273 " (declare (in ) usampler1DArray sampler@0x16f07a0)\n"
20274 " (declare (in ) vec2 P@0x16f08b0)\n"
20275 " (declare (in ) float lod@0x16f09c0)\n"
20276 " )\n"
20277 " (\n"
20278 " ))\n"
20279 "\n"
20280 " (signature vec4\n"
20281 " (parameters\n"
20282 " (declare (in ) sampler2DArray sampler@0x16f0ba0)\n"
20283 " (declare (in ) vec3 P@0x16f0cb0)\n"
20284 " (declare (in ) float lod@0x16f0dc0)\n"
20285 " )\n"
20286 " (\n"
20287 " ))\n"
20288 "\n"
20289 " (signature ivec4\n"
20290 " (parameters\n"
20291 " (declare (in ) isampler2DArray sampler@0x16f0fa0)\n"
20292 " (declare (in ) vec3 P@0x16f10b0)\n"
20293 " (declare (in ) float lod@0x16f11c0)\n"
20294 " )\n"
20295 " (\n"
20296 " ))\n"
20297 "\n"
20298 " (signature uvec4\n"
20299 " (parameters\n"
20300 " (declare (in ) usampler2DArray sampler@0x16f13a0)\n"
20301 " (declare (in ) vec3 P@0x16f14b0)\n"
20302 " (declare (in ) float lod@0x16f15c0)\n"
20303 " )\n"
20304 " (\n"
20305 " ))\n"
20306 "\n"
20307 " (signature float\n"
20308 " (parameters\n"
20309 " (declare (in ) sampler1DArrayShadow sampler@0x16f17a0)\n"
20310 " (declare (in ) vec3 P@0x16f18b0)\n"
20311 " (declare (in ) float lod@0x16f19c0)\n"
20312 " )\n"
20313 " (\n"
20314 " ))\n"
20315 "\n"
20316 ")\n"
20317 "\n"
20318 "(function texelFetch\n"
20319 " (signature vec4\n"
20320 " (parameters\n"
20321 " (declare (in ) sampler1D sampler@0x16f1ba0)\n"
20322 " (declare (in ) int P@0x16f1cb0)\n"
20323 " (declare (in ) int lod@0x16f1dc0)\n"
20324 " )\n"
20325 " (\n"
20326 " ))\n"
20327 "\n"
20328 " (signature ivec4\n"
20329 " (parameters\n"
20330 " (declare (in ) isampler1D sampler@0x16f2150)\n"
20331 " (declare (in ) int P@0x16f2260)\n"
20332 " (declare (in ) int lod@0x16f2370)\n"
20333 " )\n"
20334 " (\n"
20335 " ))\n"
20336 "\n"
20337 " (signature uvec4\n"
20338 " (parameters\n"
20339 " (declare (in ) usampler1D sampler@0x16f2550)\n"
20340 " (declare (in ) int P@0x16f2660)\n"
20341 " (declare (in ) int lod@0x16f2770)\n"
20342 " )\n"
20343 " (\n"
20344 " ))\n"
20345 "\n"
20346 " (signature vec4\n"
20347 " (parameters\n"
20348 " (declare (in ) sampler2D sampler@0x16f2950)\n"
20349 " (declare (in ) ivec2 P@0x16f2a60)\n"
20350 " (declare (in ) int lod@0x16f2b70)\n"
20351 " )\n"
20352 " (\n"
20353 " ))\n"
20354 "\n"
20355 " (signature ivec4\n"
20356 " (parameters\n"
20357 " (declare (in ) isampler2D sampler@0x16f2d50)\n"
20358 " (declare (in ) ivec2 P@0x16f2e60)\n"
20359 " (declare (in ) int lod@0x16f2f70)\n"
20360 " )\n"
20361 " (\n"
20362 " ))\n"
20363 "\n"
20364 " (signature uvec4\n"
20365 " (parameters\n"
20366 " (declare (in ) usampler2D sampler@0x16f3150)\n"
20367 " (declare (in ) ivec2 P@0x16f3260)\n"
20368 " (declare (in ) int lod@0x16f3370)\n"
20369 " )\n"
20370 " (\n"
20371 " ))\n"
20372 "\n"
20373 " (signature vec4\n"
20374 " (parameters\n"
20375 " (declare (in ) sampler3D sampler@0x16f3550)\n"
20376 " (declare (in ) ivec3 P@0x16f3660)\n"
20377 " (declare (in ) int lod@0x16f3770)\n"
20378 " )\n"
20379 " (\n"
20380 " ))\n"
20381 "\n"
20382 " (signature ivec4\n"
20383 " (parameters\n"
20384 " (declare (in ) isampler3D sampler@0x16f3950)\n"
20385 " (declare (in ) ivec3 P@0x16f3a60)\n"
20386 " (declare (in ) int lod@0x16f3b70)\n"
20387 " )\n"
20388 " (\n"
20389 " ))\n"
20390 "\n"
20391 " (signature uvec4\n"
20392 " (parameters\n"
20393 " (declare (in ) usampler3D sampler@0x16f3d50)\n"
20394 " (declare (in ) ivec3 P@0x16f3e60)\n"
20395 " (declare (in ) int lod@0x16f3f70)\n"
20396 " )\n"
20397 " (\n"
20398 " ))\n"
20399 "\n"
20400 " (signature vec4\n"
20401 " (parameters\n"
20402 " (declare (in ) sampler1DArray sampler@0x16f4150)\n"
20403 " (declare (in ) ivec2 P@0x16f4260)\n"
20404 " (declare (in ) int lod@0x16f4370)\n"
20405 " )\n"
20406 " (\n"
20407 " ))\n"
20408 "\n"
20409 " (signature ivec4\n"
20410 " (parameters\n"
20411 " (declare (in ) isampler1DArray sampler@0x16f4550)\n"
20412 " (declare (in ) ivec2 P@0x16f4660)\n"
20413 " (declare (in ) int lod@0x16f4770)\n"
20414 " )\n"
20415 " (\n"
20416 " ))\n"
20417 "\n"
20418 " (signature uvec4\n"
20419 " (parameters\n"
20420 " (declare (in ) usampler1DArray sampler@0x16f4950)\n"
20421 " (declare (in ) ivec2 P@0x16f4a60)\n"
20422 " (declare (in ) int lod@0x16f4b70)\n"
20423 " )\n"
20424 " (\n"
20425 " ))\n"
20426 "\n"
20427 " (signature vec4\n"
20428 " (parameters\n"
20429 " (declare (in ) sampler2DArray sampler@0x16f4d50)\n"
20430 " (declare (in ) ivec3 P@0x16f4e60)\n"
20431 " (declare (in ) int lod@0x16f4f70)\n"
20432 " )\n"
20433 " (\n"
20434 " ))\n"
20435 "\n"
20436 " (signature ivec4\n"
20437 " (parameters\n"
20438 " (declare (in ) isampler2DArray sampler@0x16f5150)\n"
20439 " (declare (in ) ivec3 P@0x16f5260)\n"
20440 " (declare (in ) int lod@0x16f5370)\n"
20441 " )\n"
20442 " (\n"
20443 " ))\n"
20444 "\n"
20445 " (signature uvec4\n"
20446 " (parameters\n"
20447 " (declare (in ) usampler2DArray sampler@0x16f5550)\n"
20448 " (declare (in ) ivec3 P@0x16f5660)\n"
20449 " (declare (in ) int lod@0x16f5770)\n"
20450 " )\n"
20451 " (\n"
20452 " ))\n"
20453 "\n"
20454 ")\n"
20455 "\n"
20456 "(function textureProjLod\n"
20457 " (signature vec4\n"
20458 " (parameters\n"
20459 " (declare (in ) sampler1D sampler@0x16f5950)\n"
20460 " (declare (in ) vec2 P@0x16f5a60)\n"
20461 " (declare (in ) float lod@0x16f5b70)\n"
20462 " )\n"
20463 " (\n"
20464 " ))\n"
20465 "\n"
20466 " (signature ivec4\n"
20467 " (parameters\n"
20468 " (declare (in ) isampler1D sampler@0x16f5f00)\n"
20469 " (declare (in ) vec2 P@0x16f6010)\n"
20470 " (declare (in ) float lod@0x16f6120)\n"
20471 " )\n"
20472 " (\n"
20473 " ))\n"
20474 "\n"
20475 " (signature uvec4\n"
20476 " (parameters\n"
20477 " (declare (in ) usampler1D sampler@0x16f6300)\n"
20478 " (declare (in ) vec2 P@0x16f6410)\n"
20479 " (declare (in ) float lod@0x16f6520)\n"
20480 " )\n"
20481 " (\n"
20482 " ))\n"
20483 "\n"
20484 " (signature vec4\n"
20485 " (parameters\n"
20486 " (declare (in ) sampler1D sampler@0x16f6700)\n"
20487 " (declare (in ) vec4 P@0x16f6810)\n"
20488 " (declare (in ) float lod@0x16f6920)\n"
20489 " )\n"
20490 " (\n"
20491 " ))\n"
20492 "\n"
20493 " (signature ivec4\n"
20494 " (parameters\n"
20495 " (declare (in ) isampler1D sampler@0x16f6b00)\n"
20496 " (declare (in ) vec4 P@0x16f6c10)\n"
20497 " (declare (in ) float lod@0x16f6d20)\n"
20498 " )\n"
20499 " (\n"
20500 " ))\n"
20501 "\n"
20502 " (signature uvec4\n"
20503 " (parameters\n"
20504 " (declare (in ) usampler1D sampler@0x16f6f00)\n"
20505 " (declare (in ) vec4 P@0x16f7010)\n"
20506 " (declare (in ) float lod@0x16f7120)\n"
20507 " )\n"
20508 " (\n"
20509 " ))\n"
20510 "\n"
20511 " (signature vec4\n"
20512 " (parameters\n"
20513 " (declare (in ) sampler2D sampler@0x16f7300)\n"
20514 " (declare (in ) vec3 P@0x16f7410)\n"
20515 " (declare (in ) float lod@0x16f7520)\n"
20516 " )\n"
20517 " (\n"
20518 " ))\n"
20519 "\n"
20520 " (signature ivec4\n"
20521 " (parameters\n"
20522 " (declare (in ) isampler2D sampler@0x16f7700)\n"
20523 " (declare (in ) vec3 P@0x16f7810)\n"
20524 " (declare (in ) float lod@0x16f7920)\n"
20525 " )\n"
20526 " (\n"
20527 " ))\n"
20528 "\n"
20529 " (signature uvec4\n"
20530 " (parameters\n"
20531 " (declare (in ) usampler2D sampler@0x16f7b00)\n"
20532 " (declare (in ) vec3 P@0x16f7c10)\n"
20533 " (declare (in ) float lod@0x16f7d20)\n"
20534 " )\n"
20535 " (\n"
20536 " ))\n"
20537 "\n"
20538 " (signature vec4\n"
20539 " (parameters\n"
20540 " (declare (in ) sampler2D sampler@0x16f7f00)\n"
20541 " (declare (in ) vec4 P@0x16f8010)\n"
20542 " (declare (in ) float lod@0x16f8120)\n"
20543 " )\n"
20544 " (\n"
20545 " ))\n"
20546 "\n"
20547 " (signature ivec4\n"
20548 " (parameters\n"
20549 " (declare (in ) isampler2D sampler@0x16f8300)\n"
20550 " (declare (in ) vec4 P@0x16f8410)\n"
20551 " (declare (in ) float lod@0x16f8520)\n"
20552 " )\n"
20553 " (\n"
20554 " ))\n"
20555 "\n"
20556 " (signature uvec4\n"
20557 " (parameters\n"
20558 " (declare (in ) usampler2D sampler@0x16f8700)\n"
20559 " (declare (in ) vec4 P@0x16f8810)\n"
20560 " (declare (in ) float lod@0x16f8920)\n"
20561 " )\n"
20562 " (\n"
20563 " ))\n"
20564 "\n"
20565 " (signature vec4\n"
20566 " (parameters\n"
20567 " (declare (in ) sampler3D sampler@0x16f8b00)\n"
20568 " (declare (in ) vec4 P@0x16f8c10)\n"
20569 " (declare (in ) float lod@0x16f8d20)\n"
20570 " )\n"
20571 " (\n"
20572 " ))\n"
20573 "\n"
20574 " (signature ivec4\n"
20575 " (parameters\n"
20576 " (declare (in ) isampler3D sampler@0x16f8f00)\n"
20577 " (declare (in ) vec4 P@0x16f9010)\n"
20578 " (declare (in ) float lod@0x16f9120)\n"
20579 " )\n"
20580 " (\n"
20581 " ))\n"
20582 "\n"
20583 " (signature uvec4\n"
20584 " (parameters\n"
20585 " (declare (in ) usampler3D sampler@0x16f9300)\n"
20586 " (declare (in ) vec4 P@0x16f9410)\n"
20587 " (declare (in ) float lod@0x16f9520)\n"
20588 " )\n"
20589 " (\n"
20590 " ))\n"
20591 "\n"
20592 " (signature float\n"
20593 " (parameters\n"
20594 " (declare (in ) sampler1DShadow sampler@0x16f9700)\n"
20595 " (declare (in ) vec4 P@0x16f9810)\n"
20596 " (declare (in ) float lod@0x16f9920)\n"
20597 " )\n"
20598 " (\n"
20599 " ))\n"
20600 "\n"
20601 " (signature float\n"
20602 " (parameters\n"
20603 " (declare (in ) sampler2DShadow sampler@0x16f9b00)\n"
20604 " (declare (in ) vec4 P@0x16f9c10)\n"
20605 " (declare (in ) float lod@0x16f9d20)\n"
20606 " )\n"
20607 " (\n"
20608 " ))\n"
20609 "\n"
20610 ")\n"
20611 "\n"
20612 "(function textureGrad\n"
20613 " (signature vec4\n"
20614 " (parameters\n"
20615 " (declare (in ) sampler1D sampler@0x16f9f00)\n"
20616 " (declare (in ) float P@0x16fa010)\n"
20617 " (declare (in ) float dPdx@0x16fa120)\n"
20618 " (declare (in ) float dPdy@0x16fa230)\n"
20619 " )\n"
20620 " (\n"
20621 " ))\n"
20622 "\n"
20623 " (signature ivec4\n"
20624 " (parameters\n"
20625 " (declare (in ) isampler1D sampler@0x16fa5c0)\n"
20626 " (declare (in ) float P@0x16fa6d0)\n"
20627 " (declare (in ) float dPdx@0x16fa7e0)\n"
20628 " (declare (in ) float dPdy@0x16fa8f0)\n"
20629 " )\n"
20630 " (\n"
20631 " ))\n"
20632 "\n"
20633 " (signature uvec4\n"
20634 " (parameters\n"
20635 " (declare (in ) usampler1D sampler@0x16faad0)\n"
20636 " (declare (in ) float P@0x16fabe0)\n"
20637 " (declare (in ) float dPdx@0x16facf0)\n"
20638 " (declare (in ) float dPdy@0x16fae00)\n"
20639 " )\n"
20640 " (\n"
20641 " ))\n"
20642 "\n"
20643 " (signature vec4\n"
20644 " (parameters\n"
20645 " (declare (in ) sampler2D sampler@0x16fafe0)\n"
20646 " (declare (in ) vec2 P@0x16fb0f0)\n"
20647 " (declare (in ) vec2 dPdx@0x16fb200)\n"
20648 " (declare (in ) vec2 dPdy@0x16fb310)\n"
20649 " )\n"
20650 " (\n"
20651 " ))\n"
20652 "\n"
20653 " (signature ivec4\n"
20654 " (parameters\n"
20655 " (declare (in ) isampler2D sampler@0x16fb4f0)\n"
20656 " (declare (in ) vec2 P@0x16fb600)\n"
20657 " (declare (in ) vec2 dPdx@0x16fb710)\n"
20658 " (declare (in ) vec2 dPdy@0x16fb820)\n"
20659 " )\n"
20660 " (\n"
20661 " ))\n"
20662 "\n"
20663 " (signature uvec4\n"
20664 " (parameters\n"
20665 " (declare (in ) usampler2D sampler@0x16fba00)\n"
20666 " (declare (in ) vec2 P@0x16fbb10)\n"
20667 " (declare (in ) vec2 dPdx@0x16fbc20)\n"
20668 " (declare (in ) vec2 dPdy@0x16fbd30)\n"
20669 " )\n"
20670 " (\n"
20671 " ))\n"
20672 "\n"
20673 " (signature vec4\n"
20674 " (parameters\n"
20675 " (declare (in ) sampler3D sampler@0x16fbf10)\n"
20676 " (declare (in ) vec3 P@0x16fc020)\n"
20677 " (declare (in ) vec3 dPdx@0x16fc130)\n"
20678 " (declare (in ) vec3 dPdy@0x16fc240)\n"
20679 " )\n"
20680 " (\n"
20681 " ))\n"
20682 "\n"
20683 " (signature ivec4\n"
20684 " (parameters\n"
20685 " (declare (in ) isampler3D sampler@0x16fc420)\n"
20686 " (declare (in ) vec3 P@0x16fc530)\n"
20687 " (declare (in ) vec3 dPdx@0x16fc640)\n"
20688 " (declare (in ) vec3 dPdy@0x16fc750)\n"
20689 " )\n"
20690 " (\n"
20691 " ))\n"
20692 "\n"
20693 " (signature uvec4\n"
20694 " (parameters\n"
20695 " (declare (in ) usampler3D sampler@0x16fc930)\n"
20696 " (declare (in ) vec3 P@0x16fca40)\n"
20697 " (declare (in ) vec3 dPdx@0x16fcb50)\n"
20698 " (declare (in ) vec3 dPdy@0x16fcc60)\n"
20699 " )\n"
20700 " (\n"
20701 " ))\n"
20702 "\n"
20703 " (signature vec4\n"
20704 " (parameters\n"
20705 " (declare (in ) samplerCube sampler@0x16fce40)\n"
20706 " (declare (in ) vec3 P@0x16fcf50)\n"
20707 " (declare (in ) vec3 dPdx@0x16fd060)\n"
20708 " (declare (in ) vec3 dPdy@0x16fd170)\n"
20709 " )\n"
20710 " (\n"
20711 " ))\n"
20712 "\n"
20713 " (signature ivec4\n"
20714 " (parameters\n"
20715 " (declare (in ) isamplerCube sampler@0x16fd350)\n"
20716 " (declare (in ) vec3 P@0x16fd460)\n"
20717 " (declare (in ) vec3 dPdx@0x16fd570)\n"
20718 " (declare (in ) vec3 dPdy@0x16fd680)\n"
20719 " )\n"
20720 " (\n"
20721 " ))\n"
20722 "\n"
20723 " (signature uvec4\n"
20724 " (parameters\n"
20725 " (declare (in ) usamplerCube sampler@0x16fd860)\n"
20726 " (declare (in ) vec3 P@0x16fd970)\n"
20727 " (declare (in ) vec3 dPdx@0x16fda80)\n"
20728 " (declare (in ) vec3 dPdy@0x16fdb90)\n"
20729 " )\n"
20730 " (\n"
20731 " ))\n"
20732 "\n"
20733 " (signature float\n"
20734 " (parameters\n"
20735 " (declare (in ) sampler1DShadow sampler@0x16fdd70)\n"
20736 " (declare (in ) vec3 P@0x16fde80)\n"
20737 " (declare (in ) float dPdx@0x16fdf90)\n"
20738 " (declare (in ) float dPdy@0x16fe0a0)\n"
20739 " )\n"
20740 " (\n"
20741 " ))\n"
20742 "\n"
20743 " (signature float\n"
20744 " (parameters\n"
20745 " (declare (in ) sampler2DShadow sampler@0x16fe280)\n"
20746 " (declare (in ) vec3 P@0x16fe390)\n"
20747 " (declare (in ) vec2 dPdx@0x16fe4a0)\n"
20748 " (declare (in ) vec2 dPdy@0x16fe5b0)\n"
20749 " )\n"
20750 " (\n"
20751 " ))\n"
20752 "\n"
20753 " (signature float\n"
20754 " (parameters\n"
20755 " (declare (in ) samplerCubeShadow sampler@0x16fe790)\n"
20756 " (declare (in ) vec4 P@0x16fe8a0)\n"
20757 " (declare (in ) vec3 dPdx@0x16fe9b0)\n"
20758 " (declare (in ) vec3 dPdy@0x16feac0)\n"
20759 " )\n"
20760 " (\n"
20761 " ))\n"
20762 "\n"
20763 " (signature vec4\n"
20764 " (parameters\n"
20765 " (declare (in ) sampler1DArray sampler@0x16feca0)\n"
20766 " (declare (in ) vec2 P@0x16fedb0)\n"
20767 " (declare (in ) float dPdx@0x16feec0)\n"
20768 " (declare (in ) float dPdy@0x16fefd0)\n"
20769 " )\n"
20770 " (\n"
20771 " ))\n"
20772 "\n"
20773 " (signature ivec4\n"
20774 " (parameters\n"
20775 " (declare (in ) isampler1DArray sampler@0x16ff1b0)\n"
20776 " (declare (in ) vec2 P@0x16ff2c0)\n"
20777 " (declare (in ) float dPdx@0x16ff3d0)\n"
20778 " (declare (in ) float dPdy@0x16ff4e0)\n"
20779 " )\n"
20780 " (\n"
20781 " ))\n"
20782 "\n"
20783 " (signature uvec4\n"
20784 " (parameters\n"
20785 " (declare (in ) usampler1DArray sampler@0x16ff6c0)\n"
20786 " (declare (in ) vec2 P@0x16ff7d0)\n"
20787 " (declare (in ) float dPdx@0x16ff8e0)\n"
20788 " (declare (in ) float dPdy@0x16ff9f0)\n"
20789 " )\n"
20790 " (\n"
20791 " ))\n"
20792 "\n"
20793 " (signature vec4\n"
20794 " (parameters\n"
20795 " (declare (in ) sampler2DArray sampler@0x16ffbd0)\n"
20796 " (declare (in ) vec3 P@0x16ffce0)\n"
20797 " (declare (in ) vec2 dPdx@0x16ffdf0)\n"
20798 " (declare (in ) vec2 dPdy@0x16fff00)\n"
20799 " )\n"
20800 " (\n"
20801 " ))\n"
20802 "\n"
20803 " (signature ivec4\n"
20804 " (parameters\n"
20805 " (declare (in ) isampler2DArray sampler@0x17000e0)\n"
20806 " (declare (in ) vec3 P@0x17001f0)\n"
20807 " (declare (in ) vec2 dPdx@0x1700300)\n"
20808 " (declare (in ) vec2 dPdy@0x1700410)\n"
20809 " )\n"
20810 " (\n"
20811 " ))\n"
20812 "\n"
20813 " (signature uvec4\n"
20814 " (parameters\n"
20815 " (declare (in ) usampler2DArray sampler@0x17005f0)\n"
20816 " (declare (in ) vec3 P@0x1700700)\n"
20817 " (declare (in ) vec2 dPdx@0x1700810)\n"
20818 " (declare (in ) vec2 dPdy@0x1700920)\n"
20819 " )\n"
20820 " (\n"
20821 " ))\n"
20822 "\n"
20823 " (signature float\n"
20824 " (parameters\n"
20825 " (declare (in ) sampler1DArrayShadow sampler@0x1700b00)\n"
20826 " (declare (in ) vec3 P@0x1700c10)\n"
20827 " (declare (in ) float dPdx@0x1700d20)\n"
20828 " (declare (in ) float dPdy@0x1700e30)\n"
20829 " )\n"
20830 " (\n"
20831 " ))\n"
20832 "\n"
20833 " (signature float\n"
20834 " (parameters\n"
20835 " (declare (in ) sampler2DArrayShadow sampler@0x1701010)\n"
20836 " (declare (in ) vec4 P@0x1701120)\n"
20837 " (declare (in ) vec2 dPdx@0x1701230)\n"
20838 " (declare (in ) vec2 dPdy@0x1701340)\n"
20839 " )\n"
20840 " (\n"
20841 " ))\n"
20842 "\n"
20843 ")\n"
20844 "\n"
20845 "(function textureProjGrad\n"
20846 " (signature vec4\n"
20847 " (parameters\n"
20848 " (declare (in ) sampler1D sampler@0x1701520)\n"
20849 " (declare (in ) vec2 P@0x1701630)\n"
20850 " (declare (in ) float dPdx@0x1701740)\n"
20851 " (declare (in ) float dPdy@0x1701850)\n"
20852 " )\n"
20853 " (\n"
20854 " ))\n"
20855 "\n"
20856 " (signature ivec4\n"
20857 " (parameters\n"
20858 " (declare (in ) isampler1D sampler@0x1701be0)\n"
20859 " (declare (in ) vec2 P@0x1701cf0)\n"
20860 " (declare (in ) float dPdx@0x1701e00)\n"
20861 " (declare (in ) float dPdy@0x1701f10)\n"
20862 " )\n"
20863 " (\n"
20864 " ))\n"
20865 "\n"
20866 " (signature uvec4\n"
20867 " (parameters\n"
20868 " (declare (in ) usampler1D sampler@0x17020f0)\n"
20869 " (declare (in ) vec2 P@0x1702200)\n"
20870 " (declare (in ) float dPdx@0x1702310)\n"
20871 " (declare (in ) float dPdy@0x1702420)\n"
20872 " )\n"
20873 " (\n"
20874 " ))\n"
20875 "\n"
20876 " (signature vec4\n"
20877 " (parameters\n"
20878 " (declare (in ) sampler1D sampler@0x1702600)\n"
20879 " (declare (in ) vec4 P@0x1702710)\n"
20880 " (declare (in ) float dPdx@0x1702820)\n"
20881 " (declare (in ) float dPdy@0x1702930)\n"
20882 " )\n"
20883 " (\n"
20884 " ))\n"
20885 "\n"
20886 " (signature ivec4\n"
20887 " (parameters\n"
20888 " (declare (in ) isampler1D sampler@0x1702b10)\n"
20889 " (declare (in ) vec4 P@0x1702c20)\n"
20890 " (declare (in ) float dPdx@0x1702d30)\n"
20891 " (declare (in ) float dPdy@0x1702e40)\n"
20892 " )\n"
20893 " (\n"
20894 " ))\n"
20895 "\n"
20896 " (signature uvec4\n"
20897 " (parameters\n"
20898 " (declare (in ) usampler1D sampler@0x1703020)\n"
20899 " (declare (in ) vec4 P@0x1703130)\n"
20900 " (declare (in ) float dPdx@0x1703240)\n"
20901 " (declare (in ) float dPdy@0x1703350)\n"
20902 " )\n"
20903 " (\n"
20904 " ))\n"
20905 "\n"
20906 " (signature vec4\n"
20907 " (parameters\n"
20908 " (declare (in ) sampler2D sampler@0x1703530)\n"
20909 " (declare (in ) vec3 P@0x1703640)\n"
20910 " (declare (in ) vec2 dPdx@0x1703750)\n"
20911 " (declare (in ) vec2 dPdy@0x1703860)\n"
20912 " )\n"
20913 " (\n"
20914 " ))\n"
20915 "\n"
20916 " (signature ivec4\n"
20917 " (parameters\n"
20918 " (declare (in ) isampler2D sampler@0x1703a40)\n"
20919 " (declare (in ) vec3 P@0x1703b50)\n"
20920 " (declare (in ) vec2 dPdx@0x1703c60)\n"
20921 " (declare (in ) vec2 dPdy@0x1703d70)\n"
20922 " )\n"
20923 " (\n"
20924 " ))\n"
20925 "\n"
20926 " (signature uvec4\n"
20927 " (parameters\n"
20928 " (declare (in ) usampler2D sampler@0x1703f50)\n"
20929 " (declare (in ) vec3 P@0x1704060)\n"
20930 " (declare (in ) vec2 dPdx@0x1704170)\n"
20931 " (declare (in ) vec2 dPdy@0x1704280)\n"
20932 " )\n"
20933 " (\n"
20934 " ))\n"
20935 "\n"
20936 " (signature vec4\n"
20937 " (parameters\n"
20938 " (declare (in ) sampler2D sampler@0x1704460)\n"
20939 " (declare (in ) vec4 P@0x1704570)\n"
20940 " (declare (in ) vec2 dPdx@0x1704680)\n"
20941 " (declare (in ) vec2 dPdy@0x1704790)\n"
20942 " )\n"
20943 " (\n"
20944 " ))\n"
20945 "\n"
20946 " (signature ivec4\n"
20947 " (parameters\n"
20948 " (declare (in ) isampler2D sampler@0x1704970)\n"
20949 " (declare (in ) vec4 P@0x1704a80)\n"
20950 " (declare (in ) vec2 dPdx@0x1704b90)\n"
20951 " (declare (in ) vec2 dPdy@0x1704ca0)\n"
20952 " )\n"
20953 " (\n"
20954 " ))\n"
20955 "\n"
20956 " (signature uvec4\n"
20957 " (parameters\n"
20958 " (declare (in ) usampler2D sampler@0x1704e80)\n"
20959 " (declare (in ) vec4 P@0x1704f90)\n"
20960 " (declare (in ) vec2 dPdx@0x17050a0)\n"
20961 " (declare (in ) vec2 dPdy@0x17051b0)\n"
20962 " )\n"
20963 " (\n"
20964 " ))\n"
20965 "\n"
20966 " (signature vec4\n"
20967 " (parameters\n"
20968 " (declare (in ) sampler3D sampler@0x1705390)\n"
20969 " (declare (in ) vec4 P@0x17054a0)\n"
20970 " (declare (in ) vec3 dPdx@0x17055b0)\n"
20971 " (declare (in ) vec3 dPdy@0x17056c0)\n"
20972 " )\n"
20973 " (\n"
20974 " ))\n"
20975 "\n"
20976 " (signature ivec4\n"
20977 " (parameters\n"
20978 " (declare (in ) isampler3D sampler@0x17058a0)\n"
20979 " (declare (in ) vec4 P@0x17059b0)\n"
20980 " (declare (in ) vec3 dPdx@0x1705ac0)\n"
20981 " (declare (in ) vec3 dPdy@0x1705bd0)\n"
20982 " )\n"
20983 " (\n"
20984 " ))\n"
20985 "\n"
20986 " (signature uvec4\n"
20987 " (parameters\n"
20988 " (declare (in ) usampler3D sampler@0x1705db0)\n"
20989 " (declare (in ) vec4 P@0x1705ec0)\n"
20990 " (declare (in ) vec3 dPdx@0x1705fd0)\n"
20991 " (declare (in ) vec3 dPdy@0x17060e0)\n"
20992 " )\n"
20993 " (\n"
20994 " ))\n"
20995 "\n"
20996 " (signature float\n"
20997 " (parameters\n"
20998 " (declare (in ) sampler1DShadow sampler@0x17062c0)\n"
20999 " (declare (in ) vec4 P@0x17063d0)\n"
21000 " (declare (in ) float dPdx@0x17064e0)\n"
21001 " (declare (in ) float dPdy@0x17065f0)\n"
21002 " )\n"
21003 " (\n"
21004 " ))\n"
21005 "\n"
21006 " (signature float\n"
21007 " (parameters\n"
21008 " (declare (in ) sampler2DShadow sampler@0x17067d0)\n"
21009 " (declare (in ) vec4 P@0x17068e0)\n"
21010 " (declare (in ) vec2 dPdx@0x17069f0)\n"
21011 " (declare (in ) vec2 dPdy@0x1706b00)\n"
21012 " )\n"
21013 " (\n"
21014 " ))\n"
21015 "\n"
21016 ")\n"
21017 "\n"
21018 "(function texture1D\n"
21019 " (signature vec4\n"
21020 " (parameters\n"
21021 " (declare (in ) sampler1D sampler@0x1706ce0)\n"
21022 " (declare (in ) float coord@0x1706df0)\n"
21023 " )\n"
21024 " (\n"
21025 " ))\n"
21026 "\n"
21027 " (signature vec4\n"
21028 " (parameters\n"
21029 " (declare (in ) sampler1D sampler@0x1707910)\n"
21030 " (declare (in ) float coord@0x1707a20)\n"
21031 " (declare (in ) float bias@0x1707b30)\n"
21032 " )\n"
21033 " (\n"
21034 " ))\n"
21035 "\n"
21036 ")\n"
21037 "\n"
21038 "(function texture1DProj\n"
21039 " (signature vec4\n"
21040 " (parameters\n"
21041 " (declare (in ) sampler1D sampler@0x1707180)\n"
21042 " (declare (in ) vec2 coord@0x1707290)\n"
21043 " )\n"
21044 " (\n"
21045 " ))\n"
21046 "\n"
21047 " (signature vec4\n"
21048 " (parameters\n"
21049 " (declare (in ) sampler1D sampler@0x1707620)\n"
21050 " (declare (in ) vec4 coord@0x1707730)\n"
21051 " )\n"
21052 " (\n"
21053 " ))\n"
21054 "\n"
21055 " (signature vec4\n"
21056 " (parameters\n"
21057 " (declare (in ) sampler1D sampler@0x1707d10)\n"
21058 " (declare (in ) vec2 coord@0x1707e20)\n"
21059 " (declare (in ) float bias@0x1707f30)\n"
21060 " )\n"
21061 " (\n"
21062 " ))\n"
21063 "\n"
21064 " (signature vec4\n"
21065 " (parameters\n"
21066 " (declare (in ) sampler1D sampler@0x1708110)\n"
21067 " (declare (in ) vec4 coord@0x1708220)\n"
21068 " (declare (in ) float bias@0x1708330)\n"
21069 " )\n"
21070 " (\n"
21071 " ))\n"
21072 "\n"
21073 ")\n"
21074 "\n"
21075 "(function texture1DLod\n"
21076 " (signature vec4\n"
21077 " (parameters\n"
21078 " (declare (in ) sampler1D sampler@0x1708510)\n"
21079 " (declare (in ) float coord@0x1708620)\n"
21080 " (declare (in ) float lod@0x1708730)\n"
21081 " )\n"
21082 " (\n"
21083 " ))\n"
21084 "\n"
21085 ")\n"
21086 "\n"
21087 "(function texture1DProjLod\n"
21088 " (signature vec4\n"
21089 " (parameters\n"
21090 " (declare (in ) sampler1D sampler@0x1708ac0)\n"
21091 " (declare (in ) vec2 coord@0x1708bd0)\n"
21092 " (declare (in ) float lod@0x1708ce0)\n"
21093 " )\n"
21094 " (\n"
21095 " ))\n"
21096 "\n"
21097 " (signature vec4\n"
21098 " (parameters\n"
21099 " (declare (in ) sampler1D sampler@0x1709070)\n"
21100 " (declare (in ) vec4 coord@0x1709180)\n"
21101 " (declare (in ) float lod@0x1709290)\n"
21102 " )\n"
21103 " (\n"
21104 " ))\n"
21105 "\n"
21106 ")\n"
21107 "\n"
21108 "(function texture2D\n"
21109 " (signature vec4\n"
21110 " (parameters\n"
21111 " (declare (in ) sampler2D sampler@0x1709470)\n"
21112 " (declare (in ) vec2 coord@0x1709580)\n"
21113 " )\n"
21114 " (\n"
21115 " ))\n"
21116 "\n"
21117 " (signature vec4\n"
21118 " (parameters\n"
21119 " (declare (in ) sampler2D sampler@0x170a0a0)\n"
21120 " (declare (in ) vec2 coord@0x170a1b0)\n"
21121 " (declare (in ) float bias@0x170a2c0)\n"
21122 " )\n"
21123 " (\n"
21124 " ))\n"
21125 "\n"
21126 ")\n"
21127 "\n"
21128 "(function texture2DProj\n"
21129 " (signature vec4\n"
21130 " (parameters\n"
21131 " (declare (in ) sampler2D sampler@0x1709910)\n"
21132 " (declare (in ) vec3 coord@0x1709a20)\n"
21133 " )\n"
21134 " (\n"
21135 " ))\n"
21136 "\n"
21137 " (signature vec4\n"
21138 " (parameters\n"
21139 " (declare (in ) sampler2D sampler@0x1709db0)\n"
21140 " (declare (in ) vec4 coord@0x1709ec0)\n"
21141 " )\n"
21142 " (\n"
21143 " ))\n"
21144 "\n"
21145 " (signature vec4\n"
21146 " (parameters\n"
21147 " (declare (in ) sampler2D sampler@0x170a4a0)\n"
21148 " (declare (in ) vec3 coord@0x170a5b0)\n"
21149 " (declare (in ) float bias@0x170a6c0)\n"
21150 " )\n"
21151 " (\n"
21152 " ))\n"
21153 "\n"
21154 " (signature vec4\n"
21155 " (parameters\n"
21156 " (declare (in ) sampler2D sampler@0x170a8a0)\n"
21157 " (declare (in ) vec4 coord@0x170a9b0)\n"
21158 " (declare (in ) float bias@0x170aac0)\n"
21159 " )\n"
21160 " (\n"
21161 " ))\n"
21162 "\n"
21163 ")\n"
21164 "\n"
21165 "(function texture2DLod\n"
21166 " (signature vec4\n"
21167 " (parameters\n"
21168 " (declare (in ) sampler2D sampler@0x170aca0)\n"
21169 " (declare (in ) vec2 coord@0x170adb0)\n"
21170 " (declare (in ) float lod@0x170aec0)\n"
21171 " )\n"
21172 " (\n"
21173 " ))\n"
21174 "\n"
21175 ")\n"
21176 "\n"
21177 "(function texture2DProjLod\n"
21178 " (signature vec4\n"
21179 " (parameters\n"
21180 " (declare (in ) sampler2D sampler@0x170b250)\n"
21181 " (declare (in ) vec3 coord@0x170b360)\n"
21182 " (declare (in ) float lod@0x170b470)\n"
21183 " )\n"
21184 " (\n"
21185 " ))\n"
21186 "\n"
21187 " (signature vec4\n"
21188 " (parameters\n"
21189 " (declare (in ) sampler2D sampler@0x170b800)\n"
21190 " (declare (in ) vec4 coord@0x170b910)\n"
21191 " (declare (in ) float lod@0x170ba20)\n"
21192 " )\n"
21193 " (\n"
21194 " ))\n"
21195 "\n"
21196 ")\n"
21197 "\n"
21198 "(function texture3D\n"
21199 " (signature vec4\n"
21200 " (parameters\n"
21201 " (declare (in ) sampler3D sampler@0x170bc00)\n"
21202 " (declare (in ) vec3 coord@0x170bd10)\n"
21203 " )\n"
21204 " (\n"
21205 " ))\n"
21206 "\n"
21207 " (signature vec4\n"
21208 " (parameters\n"
21209 " (declare (in ) sampler3D sampler@0x170c540)\n"
21210 " (declare (in ) vec3 coord@0x170c650)\n"
21211 " (declare (in ) float bias@0x170c760)\n"
21212 " )\n"
21213 " (\n"
21214 " ))\n"
21215 "\n"
21216 ")\n"
21217 "\n"
21218 "(function texture3DProj\n"
21219 " (signature vec4\n"
21220 " (parameters\n"
21221 " (declare (in ) sampler3D sampler@0x170c0a0)\n"
21222 " (declare (in ) vec4 coord@0x170c1b0)\n"
21223 " )\n"
21224 " (\n"
21225 " ))\n"
21226 "\n"
21227 " (signature vec4\n"
21228 " (parameters\n"
21229 " (declare (in ) sampler3D sampler@0x170c940)\n"
21230 " (declare (in ) vec4 coord@0x170ca50)\n"
21231 " (declare (in ) float bias@0x170cb60)\n"
21232 " )\n"
21233 " (\n"
21234 " ))\n"
21235 "\n"
21236 ")\n"
21237 "\n"
21238 "(function texture3DLod\n"
21239 " (signature vec4\n"
21240 " (parameters\n"
21241 " (declare (in ) sampler3D sampler@0x170cd40)\n"
21242 " (declare (in ) vec3 coord@0x170ce50)\n"
21243 " (declare (in ) float lod@0x170cf60)\n"
21244 " )\n"
21245 " (\n"
21246 " ))\n"
21247 "\n"
21248 ")\n"
21249 "\n"
21250 "(function texture3DProjLod\n"
21251 " (signature vec4\n"
21252 " (parameters\n"
21253 " (declare (in ) sampler3D sampler@0x170d2f0)\n"
21254 " (declare (in ) vec4 coord@0x170d400)\n"
21255 " (declare (in ) float lod@0x170d510)\n"
21256 " )\n"
21257 " (\n"
21258 " ))\n"
21259 "\n"
21260 ")\n"
21261 "\n"
21262 "(function textureCube\n"
21263 " (signature vec4\n"
21264 " (parameters\n"
21265 " (declare (in ) samplerCube sampler@0x170d8a0)\n"
21266 " (declare (in ) vec3 coord@0x170d9b0)\n"
21267 " )\n"
21268 " (\n"
21269 " ))\n"
21270 "\n"
21271 " (signature vec4\n"
21272 " (parameters\n"
21273 " (declare (in ) samplerCube sampler@0x170dd40)\n"
21274 " (declare (in ) vec3 coord@0x170de50)\n"
21275 " (declare (in ) float bias@0x170df60)\n"
21276 " )\n"
21277 " (\n"
21278 " ))\n"
21279 "\n"
21280 ")\n"
21281 "\n"
21282 "(function textureCubeLod\n"
21283 " (signature vec4\n"
21284 " (parameters\n"
21285 " (declare (in ) samplerCube sampler@0x170e140)\n"
21286 " (declare (in ) vec3 coord@0x170e250)\n"
21287 " (declare (in ) float lod@0x170e360)\n"
21288 " )\n"
21289 " (\n"
21290 " ))\n"
21291 "\n"
21292 ")\n"
21293 "\n"
21294 "(function shadow1D\n"
21295 " (signature vec4\n"
21296 " (parameters\n"
21297 " (declare (in ) sampler1DShadow sampler@0x170e6f0)\n"
21298 " (declare (in ) vec3 coord@0x170e800)\n"
21299 " )\n"
21300 " (\n"
21301 " ))\n"
21302 "\n"
21303 " (signature vec4\n"
21304 " (parameters\n"
21305 " (declare (in ) sampler1DShadow sampler@0x170f970)\n"
21306 " (declare (in ) vec3 coord@0x170fa80)\n"
21307 " (declare (in ) float bias@0x170fb90)\n"
21308 " )\n"
21309 " (\n"
21310 " ))\n"
21311 "\n"
21312 ")\n"
21313 "\n"
21314 "(function shadow2D\n"
21315 " (signature vec4\n"
21316 " (parameters\n"
21317 " (declare (in ) sampler2DShadow sampler@0x170eb90)\n"
21318 " (declare (in ) vec3 coord@0x170eca0)\n"
21319 " )\n"
21320 " (\n"
21321 " ))\n"
21322 "\n"
21323 " (signature vec4\n"
21324 " (parameters\n"
21325 " (declare (in ) sampler2DShadow sampler@0x170fd70)\n"
21326 " (declare (in ) vec3 coord@0x170fe80)\n"
21327 " (declare (in ) float bias@0x170ff90)\n"
21328 " )\n"
21329 " (\n"
21330 " ))\n"
21331 "\n"
21332 ")\n"
21333 "\n"
21334 "(function shadow1DProj\n"
21335 " (signature vec4\n"
21336 " (parameters\n"
21337 " (declare (in ) sampler1DShadow sampler@0x170f030)\n"
21338 " (declare (in ) vec4 coord@0x170f140)\n"
21339 " )\n"
21340 " (\n"
21341 " ))\n"
21342 "\n"
21343 " (signature vec4\n"
21344 " (parameters\n"
21345 " (declare (in ) sampler1DShadow sampler@0x1710170)\n"
21346 " (declare (in ) vec4 coord@0x1710280)\n"
21347 " (declare (in ) float bias@0x1710390)\n"
21348 " )\n"
21349 " (\n"
21350 " ))\n"
21351 "\n"
21352 ")\n"
21353 "\n"
21354 "(function shadow2DProj\n"
21355 " (signature vec4\n"
21356 " (parameters\n"
21357 " (declare (in ) sampler2DShadow sampler@0x170f4d0)\n"
21358 " (declare (in ) vec4 coord@0x170f5e0)\n"
21359 " )\n"
21360 " (\n"
21361 " ))\n"
21362 "\n"
21363 " (signature vec4\n"
21364 " (parameters\n"
21365 " (declare (in ) sampler2DShadow sampler@0x1710570)\n"
21366 " (declare (in ) vec4 coord@0x1710680)\n"
21367 " (declare (in ) float bias@0x1710790)\n"
21368 " )\n"
21369 " (\n"
21370 " ))\n"
21371 "\n"
21372 ")\n"
21373 "\n"
21374 "(function shadow1DLod\n"
21375 " (signature vec4\n"
21376 " (parameters\n"
21377 " (declare (in ) sampler1DShadow sampler@0x1710970)\n"
21378 " (declare (in ) vec3 coord@0x1710a80)\n"
21379 " (declare (in ) float lod@0x1710b90)\n"
21380 " )\n"
21381 " (\n"
21382 " ))\n"
21383 "\n"
21384 ")\n"
21385 "\n"
21386 "(function shadow2DLod\n"
21387 " (signature vec4\n"
21388 " (parameters\n"
21389 " (declare (in ) sampler2DShadow sampler@0x1710f20)\n"
21390 " (declare (in ) vec3 coord@0x1711030)\n"
21391 " (declare (in ) float lod@0x1711140)\n"
21392 " )\n"
21393 " (\n"
21394 " ))\n"
21395 "\n"
21396 ")\n"
21397 "\n"
21398 "(function shadow1DProjLod\n"
21399 " (signature vec4\n"
21400 " (parameters\n"
21401 " (declare (in ) sampler1DShadow sampler@0x17114d0)\n"
21402 " (declare (in ) vec4 coord@0x17115e0)\n"
21403 " (declare (in ) float lod@0x17116f0)\n"
21404 " )\n"
21405 " (\n"
21406 " ))\n"
21407 "\n"
21408 ")\n"
21409 "\n"
21410 "(function shadow2DProjLod\n"
21411 " (signature vec4\n"
21412 " (parameters\n"
21413 " (declare (in ) sampler2DShadow sampler@0x1711a80)\n"
21414 " (declare (in ) vec4 coord@0x1711b90)\n"
21415 " (declare (in ) float lod@0x1711ca0)\n"
21416 " )\n"
21417 " (\n"
21418 " ))\n"
21419 "\n"
21420 ")\n"
21421 "\n"
21422 "(function noise1\n"
21423 " (signature float\n"
21424 " (parameters\n"
21425 " (declare (in ) float x@0x1712030)\n"
21426 " )\n"
21427 " (\n"
21428 " ))\n"
21429 "\n"
21430 " (signature float\n"
21431 " (parameters\n"
21432 " (declare (in ) vec2 x@0x17123b0)\n"
21433 " )\n"
21434 " (\n"
21435 " ))\n"
21436 "\n"
21437 " (signature float\n"
21438 " (parameters\n"
21439 " (declare (in ) vec3 x@0x1712590)\n"
21440 " )\n"
21441 " (\n"
21442 " ))\n"
21443 "\n"
21444 " (signature float\n"
21445 " (parameters\n"
21446 " (declare (in ) vec4 x@0x1712770)\n"
21447 " )\n"
21448 " (\n"
21449 " ))\n"
21450 "\n"
21451 ")\n"
21452 "\n"
21453 "(function noise2\n"
21454 " (signature vec2\n"
21455 " (parameters\n"
21456 " (declare (in ) float x@0x1712950)\n"
21457 " )\n"
21458 " (\n"
21459 " ))\n"
21460 "\n"
21461 " (signature vec2\n"
21462 " (parameters\n"
21463 " (declare (in ) vec2 x@0x1712cd0)\n"
21464 " )\n"
21465 " (\n"
21466 " ))\n"
21467 "\n"
21468 " (signature vec2\n"
21469 " (parameters\n"
21470 " (declare (in ) vec3 x@0x1712eb0)\n"
21471 " )\n"
21472 " (\n"
21473 " ))\n"
21474 "\n"
21475 " (signature vec2\n"
21476 " (parameters\n"
21477 " (declare (in ) vec4 x@0x1713090)\n"
21478 " )\n"
21479 " (\n"
21480 " ))\n"
21481 "\n"
21482 ")\n"
21483 "\n"
21484 "(function noise3\n"
21485 " (signature vec3\n"
21486 " (parameters\n"
21487 " (declare (in ) float x@0x1713270)\n"
21488 " )\n"
21489 " (\n"
21490 " ))\n"
21491 "\n"
21492 " (signature vec3\n"
21493 " (parameters\n"
21494 " (declare (in ) vec2 x@0x17135f0)\n"
21495 " )\n"
21496 " (\n"
21497 " ))\n"
21498 "\n"
21499 " (signature vec3\n"
21500 " (parameters\n"
21501 " (declare (in ) vec3 x@0x17137d0)\n"
21502 " )\n"
21503 " (\n"
21504 " ))\n"
21505 "\n"
21506 " (signature vec3\n"
21507 " (parameters\n"
21508 " (declare (in ) vec4 x@0x17139b0)\n"
21509 " )\n"
21510 " (\n"
21511 " ))\n"
21512 "\n"
21513 ")\n"
21514 "\n"
21515 "(function noise4\n"
21516 " (signature vec4\n"
21517 " (parameters\n"
21518 " (declare (in ) float x@0x1713b90)\n"
21519 " )\n"
21520 " (\n"
21521 " ))\n"
21522 "\n"
21523 " (signature vec4\n"
21524 " (parameters\n"
21525 " (declare (in ) vec2 x@0x1713f10)\n"
21526 " )\n"
21527 " (\n"
21528 " ))\n"
21529 "\n"
21530 " (signature vec4\n"
21531 " (parameters\n"
21532 " (declare (in ) vec3 x@0x17140f0)\n"
21533 " )\n"
21534 " (\n"
21535 " ))\n"
21536 "\n"
21537 " (signature vec4\n"
21538 " (parameters\n"
21539 " (declare (in ) vec4 x@0x17142d0)\n"
21540 " )\n"
21541 " (\n"
21542 " ))\n"
21543 "\n"
21544 ")\n"
21545 "\n"
21546 "\n"
21547 ")"
21548;
21549static const char *functions_for_130_vert [] = {
21550 builtin_clamp,
21551 builtin_matrixCompMult,
21552 builtin_textureProj,
21553 builtin_noise2,
21554 builtin_texture3DProjLod,
21555 builtin_pow,
21556 builtin_texture2DProj,
21557 builtin_greaterThanEqual,
21558 builtin_sign,
21559 builtin_texture3DProj,
21560 builtin_textureProjLod,
21561 builtin_texture,
21562 builtin_texture2D,
21563 builtin_equal,
21564 builtin_faceforward,
21565 builtin_tan,
21566 builtin_shadow2DProj,
21567 builtin_shadow1DProjLod,
21568 builtin_any,
21569 builtin_shadow1DProj,
21570 builtin_normalize,
21571 builtin_asin,
21572 builtin_texture1DProj,
21573 builtin_log,
21574 builtin_floor,
21575 builtin_exp2,
21576 builtin_lessThan,
21577 builtin_cross,
21578 builtin_sqrt,
21579 builtin_texture3DLod,
21580 builtin_textureLod,
21581 builtin_fract,
21582 builtin_abs,
21583 builtin_degrees,
21584 builtin_shadow1DLod,
21585 builtin_ftransform,
21586 builtin_sin,
21587 builtin_shadow2D,
21588 builtin_shadow2DLod,
21589 builtin_all,
21590 builtin_log2,
21591 builtin_textureGrad,
21592 builtin_atan,
21593 builtin_notEqual,
21594 builtin_max,
21595 builtin_lessThanEqual,
21596 builtin_transpose,
21597 builtin_outerProduct,
21598 builtin_ceil,
21599 builtin_reflect,
21600 builtin_textureCubeLod,
21601 builtin_step,
21602 builtin_texture1D,
21603 builtin_greaterThan,
21604 builtin_texture3D,
21605 builtin_shadow2DProjLod,
21606 builtin_not,
21607 builtin_texture2DProjLod,
21608 builtin_inversesqrt,
21609 builtin_mod,
21610 builtin_noise4,
21611 builtin_distance,
21612 builtin_cos,
21613 builtin_shadow1D,
21614 builtin_noise1,
21615 builtin_refract,
21616 builtin_noise3,
21617 builtin_texelFetch,
21618 builtin_min,
21619 builtin_radians,
21620 builtin_smoothstep,
21621 builtin_textureProjGrad,
21622 builtin_texture1DProjLod,
21623 builtin_textureCube,
21624 builtin_length,
21625 builtin_texture1DLod,
21626 builtin_texture2DLod,
21627 builtin_exp,
21628 builtin_acos,
21629 builtin_mix,
21630 builtin_dot,
21631};
21632static const char *prototypes_for_ARB_texture_rectangle_frag =
21633 "(\n"
21634 "(function texture2DRect\n"
21635 " (signature vec4\n"
21636 " (parameters\n"
21637 " (declare (in ) sampler2DRect sampler@0x225e0f0)\n"
21638 " (declare (in ) vec2 coord@0x225e200)\n"
21639 " )\n"
21640 " (\n"
21641 " ))\n"
21642 "\n"
21643 ")\n"
21644 "\n"
21645 "(function texture2DRectProj\n"
21646 " (signature vec4\n"
21647 " (parameters\n"
21648 " (declare (in ) sampler2DRect sampler@0x225e590)\n"
21649 " (declare (in ) vec3 coord@0x225e6a0)\n"
21650 " )\n"
21651 " (\n"
21652 " ))\n"
21653 "\n"
21654 " (signature vec4\n"
21655 " (parameters\n"
21656 " (declare (in ) sampler2DRect sampler@0x225ea30)\n"
21657 " (declare (in ) vec4 coord@0x225eb40)\n"
21658 " )\n"
21659 " (\n"
21660 " ))\n"
21661 "\n"
21662 ")\n"
21663 "\n"
21664 "(function shadow2DRect\n"
21665 " (signature vec4\n"
21666 " (parameters\n"
21667 " (declare (in ) sampler2DRectShadow sampler@0x225ed20)\n"
21668 " (declare (in ) vec3 coord@0x225ee30)\n"
21669 " )\n"
21670 " (\n"
21671 " ))\n"
21672 "\n"
21673 ")\n"
21674 "\n"
21675 "(function shadow2DRectProj\n"
21676 " (signature vec4\n"
21677 " (parameters\n"
21678 " (declare (in ) sampler2DRectShadow sampler@0x225f1c0)\n"
21679 " (declare (in ) vec4 coord@0x225f2d0)\n"
21680 " )\n"
21681 " (\n"
21682 " ))\n"
21683 "\n"
21684 ")\n"
21685 "\n"
21686 "\n"
21687 ")"
21688;
21689static const char *functions_for_ARB_texture_rectangle_frag [] = {
21690 builtin_texture2DRect,
21691 builtin_shadow2DRectProj,
21692 builtin_shadow2DRect,
21693 builtin_texture2DRectProj,
21694};
21695static const char *prototypes_for_120_frag =
21696 "(\n"
21697 "(function radians\n"
21698 " (signature float\n"
21699 " (parameters\n"
21700 " (declare (in ) float degrees@0xaf8340)\n"
21701 " )\n"
21702 " (\n"
21703 " ))\n"
21704 "\n"
21705 " (signature vec2\n"
21706 " (parameters\n"
21707 " (declare (in ) vec2 degrees@0xaf86c0)\n"
21708 " )\n"
21709 " (\n"
21710 " ))\n"
21711 "\n"
21712 " (signature vec3\n"
21713 " (parameters\n"
21714 " (declare (in ) vec3 degrees@0xaf88a0)\n"
21715 " )\n"
21716 " (\n"
21717 " ))\n"
21718 "\n"
21719 " (signature vec4\n"
21720 " (parameters\n"
21721 " (declare (in ) vec4 degrees@0xaf8a80)\n"
21722 " )\n"
21723 " (\n"
21724 " ))\n"
21725 "\n"
21726 ")\n"
21727 "\n"
21728 "(function degrees\n"
21729 " (signature float\n"
21730 " (parameters\n"
21731 " (declare (in ) float radians@0xaf8c60)\n"
21732 " )\n"
21733 " (\n"
21734 " ))\n"
21735 "\n"
21736 " (signature vec2\n"
21737 " (parameters\n"
21738 " (declare (in ) vec2 radians@0xaf8fe0)\n"
21739 " )\n"
21740 " (\n"
21741 " ))\n"
21742 "\n"
21743 " (signature vec3\n"
21744 " (parameters\n"
21745 " (declare (in ) vec3 radians@0xaf91c0)\n"
21746 " )\n"
21747 " (\n"
21748 " ))\n"
21749 "\n"
21750 " (signature vec4\n"
21751 " (parameters\n"
21752 " (declare (in ) vec4 radians@0xaf93a0)\n"
21753 " )\n"
21754 " (\n"
21755 " ))\n"
21756 "\n"
21757 ")\n"
21758 "\n"
21759 "(function sin\n"
21760 " (signature float\n"
21761 " (parameters\n"
21762 " (declare (in ) float angle@0xaf9580)\n"
21763 " )\n"
21764 " (\n"
21765 " ))\n"
21766 "\n"
21767 " (signature vec2\n"
21768 " (parameters\n"
21769 " (declare (in ) vec2 angle@0xaf9900)\n"
21770 " )\n"
21771 " (\n"
21772 " ))\n"
21773 "\n"
21774 " (signature vec3\n"
21775 " (parameters\n"
21776 " (declare (in ) vec3 angle@0xaf9ae0)\n"
21777 " )\n"
21778 " (\n"
21779 " ))\n"
21780 "\n"
21781 " (signature vec4\n"
21782 " (parameters\n"
21783 " (declare (in ) vec4 angle@0xaf9cc0)\n"
21784 " )\n"
21785 " (\n"
21786 " ))\n"
21787 "\n"
21788 ")\n"
21789 "\n"
21790 "(function cos\n"
21791 " (signature float\n"
21792 " (parameters\n"
21793 " (declare (in ) float angle@0xaf9ea0)\n"
21794 " )\n"
21795 " (\n"
21796 " ))\n"
21797 "\n"
21798 " (signature vec2\n"
21799 " (parameters\n"
21800 " (declare (in ) vec2 angle@0xafa220)\n"
21801 " )\n"
21802 " (\n"
21803 " ))\n"
21804 "\n"
21805 " (signature vec3\n"
21806 " (parameters\n"
21807 " (declare (in ) vec3 angle@0xafa400)\n"
21808 " )\n"
21809 " (\n"
21810 " ))\n"
21811 "\n"
21812 " (signature vec4\n"
21813 " (parameters\n"
21814 " (declare (in ) vec4 angle@0xafa5e0)\n"
21815 " )\n"
21816 " (\n"
21817 " ))\n"
21818 "\n"
21819 ")\n"
21820 "\n"
21821 "(function tan\n"
21822 " (signature float\n"
21823 " (parameters\n"
21824 " (declare (in ) float angle@0xafa7c0)\n"
21825 " )\n"
21826 " (\n"
21827 " ))\n"
21828 "\n"
21829 " (signature vec2\n"
21830 " (parameters\n"
21831 " (declare (in ) vec2 angle@0xafab40)\n"
21832 " )\n"
21833 " (\n"
21834 " ))\n"
21835 "\n"
21836 " (signature vec3\n"
21837 " (parameters\n"
21838 " (declare (in ) vec3 angle@0xafad20)\n"
21839 " )\n"
21840 " (\n"
21841 " ))\n"
21842 "\n"
21843 " (signature vec4\n"
21844 " (parameters\n"
21845 " (declare (in ) vec4 angle@0xafaf00)\n"
21846 " )\n"
21847 " (\n"
21848 " ))\n"
21849 "\n"
21850 ")\n"
21851 "\n"
21852 "(function asin\n"
21853 " (signature float\n"
21854 " (parameters\n"
21855 " (declare (in ) float angle@0xafb0e0)\n"
21856 " )\n"
21857 " (\n"
21858 " ))\n"
21859 "\n"
21860 " (signature vec2\n"
21861 " (parameters\n"
21862 " (declare (in ) vec2 angle@0xafb460)\n"
21863 " )\n"
21864 " (\n"
21865 " ))\n"
21866 "\n"
21867 " (signature vec3\n"
21868 " (parameters\n"
21869 " (declare (in ) vec3 angle@0xafb640)\n"
21870 " )\n"
21871 " (\n"
21872 " ))\n"
21873 "\n"
21874 " (signature vec4\n"
21875 " (parameters\n"
21876 " (declare (in ) vec4 angle@0xafb820)\n"
21877 " )\n"
21878 " (\n"
21879 " ))\n"
21880 "\n"
21881 ")\n"
21882 "\n"
21883 "(function acos\n"
21884 " (signature float\n"
21885 " (parameters\n"
21886 " (declare (in ) float angle@0xafba00)\n"
21887 " )\n"
21888 " (\n"
21889 " ))\n"
21890 "\n"
21891 " (signature vec2\n"
21892 " (parameters\n"
21893 " (declare (in ) vec2 angle@0xafbd80)\n"
21894 " )\n"
21895 " (\n"
21896 " ))\n"
21897 "\n"
21898 " (signature vec3\n"
21899 " (parameters\n"
21900 " (declare (in ) vec3 angle@0xafbf60)\n"
21901 " )\n"
21902 " (\n"
21903 " ))\n"
21904 "\n"
21905 " (signature vec4\n"
21906 " (parameters\n"
21907 " (declare (in ) vec4 angle@0xafc140)\n"
21908 " )\n"
21909 " (\n"
21910 " ))\n"
21911 "\n"
21912 ")\n"
21913 "\n"
21914 "(function atan\n"
21915 " (signature float\n"
21916 " (parameters\n"
21917 " (declare (in ) float y@0xafc320)\n"
21918 " (declare (in ) float x@0xafc430)\n"
21919 " )\n"
21920 " (\n"
21921 " ))\n"
21922 "\n"
21923 " (signature vec2\n"
21924 " (parameters\n"
21925 " (declare (in ) vec2 y@0xafc7b0)\n"
21926 " (declare (in ) vec2 x@0xafc8c0)\n"
21927 " )\n"
21928 " (\n"
21929 " ))\n"
21930 "\n"
21931 " (signature vec3\n"
21932 " (parameters\n"
21933 " (declare (in ) vec3 y@0xafcaa0)\n"
21934 " (declare (in ) vec3 x@0xafcbb0)\n"
21935 " )\n"
21936 " (\n"
21937 " ))\n"
21938 "\n"
21939 " (signature vec4\n"
21940 " (parameters\n"
21941 " (declare (in ) vec4 y@0xafcd90)\n"
21942 " (declare (in ) vec4 x@0xafcea0)\n"
21943 " )\n"
21944 " (\n"
21945 " ))\n"
21946 "\n"
21947 " (signature float\n"
21948 " (parameters\n"
21949 " (declare (in ) float y_over_x@0xafd080)\n"
21950 " )\n"
21951 " (\n"
21952 " ))\n"
21953 "\n"
21954 " (signature vec2\n"
21955 " (parameters\n"
21956 " (declare (in ) vec2 y_over_x@0xafd270)\n"
21957 " )\n"
21958 " (\n"
21959 " ))\n"
21960 "\n"
21961 " (signature vec3\n"
21962 " (parameters\n"
21963 " (declare (in ) vec3 y_over_x@0xafd460)\n"
21964 " )\n"
21965 " (\n"
21966 " ))\n"
21967 "\n"
21968 " (signature vec4\n"
21969 " (parameters\n"
21970 " (declare (in ) vec4 y_over_x@0xafd650)\n"
21971 " )\n"
21972 " (\n"
21973 " ))\n"
21974 "\n"
21975 ")\n"
21976 "\n"
21977 "(function pow\n"
21978 " (signature float\n"
21979 " (parameters\n"
21980 " (declare (in ) float x@0xafd840)\n"
21981 " (declare (in ) float y@0xafd950)\n"
21982 " )\n"
21983 " (\n"
21984 " ))\n"
21985 "\n"
21986 " (signature vec2\n"
21987 " (parameters\n"
21988 " (declare (in ) vec2 x@0xafdcd0)\n"
21989 " (declare (in ) vec2 y@0xafdde0)\n"
21990 " )\n"
21991 " (\n"
21992 " ))\n"
21993 "\n"
21994 " (signature vec3\n"
21995 " (parameters\n"
21996 " (declare (in ) vec3 x@0xafdfc0)\n"
21997 " (declare (in ) vec3 y@0xafe0d0)\n"
21998 " )\n"
21999 " (\n"
22000 " ))\n"
22001 "\n"
22002 " (signature vec4\n"
22003 " (parameters\n"
22004 " (declare (in ) vec4 x@0xafe2b0)\n"
22005 " (declare (in ) vec4 y@0xafe3c0)\n"
22006 " )\n"
22007 " (\n"
22008 " ))\n"
22009 "\n"
22010 ")\n"
22011 "\n"
22012 "(function exp\n"
22013 " (signature float\n"
22014 " (parameters\n"
22015 " (declare (in ) float x@0xafe5a0)\n"
22016 " )\n"
22017 " (\n"
22018 " ))\n"
22019 "\n"
22020 " (signature vec2\n"
22021 " (parameters\n"
22022 " (declare (in ) vec2 x@0xafe920)\n"
22023 " )\n"
22024 " (\n"
22025 " ))\n"
22026 "\n"
22027 " (signature vec3\n"
22028 " (parameters\n"
22029 " (declare (in ) vec3 x@0xafeb00)\n"
22030 " )\n"
22031 " (\n"
22032 " ))\n"
22033 "\n"
22034 " (signature vec4\n"
22035 " (parameters\n"
22036 " (declare (in ) vec4 x@0xafece0)\n"
22037 " )\n"
22038 " (\n"
22039 " ))\n"
22040 "\n"
22041 ")\n"
22042 "\n"
22043 "(function log\n"
22044 " (signature float\n"
22045 " (parameters\n"
22046 " (declare (in ) float x@0xafeec0)\n"
22047 " )\n"
22048 " (\n"
22049 " ))\n"
22050 "\n"
22051 " (signature vec2\n"
22052 " (parameters\n"
22053 " (declare (in ) vec2 x@0xaff240)\n"
22054 " )\n"
22055 " (\n"
22056 " ))\n"
22057 "\n"
22058 " (signature vec3\n"
22059 " (parameters\n"
22060 " (declare (in ) vec3 x@0xaff420)\n"
22061 " )\n"
22062 " (\n"
22063 " ))\n"
22064 "\n"
22065 " (signature vec4\n"
22066 " (parameters\n"
22067 " (declare (in ) vec4 x@0xaff600)\n"
22068 " )\n"
22069 " (\n"
22070 " ))\n"
22071 "\n"
22072 ")\n"
22073 "\n"
22074 "(function exp2\n"
22075 " (signature float\n"
22076 " (parameters\n"
22077 " (declare (in ) float x@0xaff7e0)\n"
22078 " )\n"
22079 " (\n"
22080 " ))\n"
22081 "\n"
22082 " (signature vec2\n"
22083 " (parameters\n"
22084 " (declare (in ) vec2 x@0xaffb60)\n"
22085 " )\n"
22086 " (\n"
22087 " ))\n"
22088 "\n"
22089 " (signature vec3\n"
22090 " (parameters\n"
22091 " (declare (in ) vec3 x@0xaffd40)\n"
22092 " )\n"
22093 " (\n"
22094 " ))\n"
22095 "\n"
22096 " (signature vec4\n"
22097 " (parameters\n"
22098 " (declare (in ) vec4 x@0xafff20)\n"
22099 " )\n"
22100 " (\n"
22101 " ))\n"
22102 "\n"
22103 ")\n"
22104 "\n"
22105 "(function log2\n"
22106 " (signature float\n"
22107 " (parameters\n"
22108 " (declare (in ) float x@0xb00100)\n"
22109 " )\n"
22110 " (\n"
22111 " ))\n"
22112 "\n"
22113 " (signature vec2\n"
22114 " (parameters\n"
22115 " (declare (in ) vec2 x@0xb00480)\n"
22116 " )\n"
22117 " (\n"
22118 " ))\n"
22119 "\n"
22120 " (signature vec3\n"
22121 " (parameters\n"
22122 " (declare (in ) vec3 x@0xb00660)\n"
22123 " )\n"
22124 " (\n"
22125 " ))\n"
22126 "\n"
22127 " (signature vec4\n"
22128 " (parameters\n"
22129 " (declare (in ) vec4 x@0xb00840)\n"
22130 " )\n"
22131 " (\n"
22132 " ))\n"
22133 "\n"
22134 ")\n"
22135 "\n"
22136 "(function sqrt\n"
22137 " (signature float\n"
22138 " (parameters\n"
22139 " (declare (in ) float x@0xb00a20)\n"
22140 " )\n"
22141 " (\n"
22142 " ))\n"
22143 "\n"
22144 " (signature vec2\n"
22145 " (parameters\n"
22146 " (declare (in ) vec2 x@0xb00da0)\n"
22147 " )\n"
22148 " (\n"
22149 " ))\n"
22150 "\n"
22151 " (signature vec3\n"
22152 " (parameters\n"
22153 " (declare (in ) vec3 x@0xb00f80)\n"
22154 " )\n"
22155 " (\n"
22156 " ))\n"
22157 "\n"
22158 " (signature vec4\n"
22159 " (parameters\n"
22160 " (declare (in ) vec4 x@0xb01160)\n"
22161 " )\n"
22162 " (\n"
22163 " ))\n"
22164 "\n"
22165 ")\n"
22166 "\n"
22167 "(function inversesqrt\n"
22168 " (signature float\n"
22169 " (parameters\n"
22170 " (declare (in ) float x@0xb01340)\n"
22171 " )\n"
22172 " (\n"
22173 " ))\n"
22174 "\n"
22175 " (signature vec2\n"
22176 " (parameters\n"
22177 " (declare (in ) vec2 x@0xb016d0)\n"
22178 " )\n"
22179 " (\n"
22180 " ))\n"
22181 "\n"
22182 " (signature vec3\n"
22183 " (parameters\n"
22184 " (declare (in ) vec3 x@0xb018b0)\n"
22185 " )\n"
22186 " (\n"
22187 " ))\n"
22188 "\n"
22189 " (signature vec4\n"
22190 " (parameters\n"
22191 " (declare (in ) vec4 x@0xb01a90)\n"
22192 " )\n"
22193 " (\n"
22194 " ))\n"
22195 "\n"
22196 ")\n"
22197 "\n"
22198 "(function abs\n"
22199 " (signature float\n"
22200 " (parameters\n"
22201 " (declare (in ) float x@0xb01c70)\n"
22202 " )\n"
22203 " (\n"
22204 " ))\n"
22205 "\n"
22206 " (signature vec2\n"
22207 " (parameters\n"
22208 " (declare (in ) vec2 x@0xb01ff0)\n"
22209 " )\n"
22210 " (\n"
22211 " ))\n"
22212 "\n"
22213 " (signature vec3\n"
22214 " (parameters\n"
22215 " (declare (in ) vec3 x@0xb021d0)\n"
22216 " )\n"
22217 " (\n"
22218 " ))\n"
22219 "\n"
22220 " (signature vec4\n"
22221 " (parameters\n"
22222 " (declare (in ) vec4 x@0xb023b0)\n"
22223 " )\n"
22224 " (\n"
22225 " ))\n"
22226 "\n"
22227 ")\n"
22228 "\n"
22229 "(function sign\n"
22230 " (signature float\n"
22231 " (parameters\n"
22232 " (declare (in ) float x@0xb02590)\n"
22233 " )\n"
22234 " (\n"
22235 " ))\n"
22236 "\n"
22237 " (signature vec2\n"
22238 " (parameters\n"
22239 " (declare (in ) vec2 x@0xb02910)\n"
22240 " )\n"
22241 " (\n"
22242 " ))\n"
22243 "\n"
22244 " (signature vec3\n"
22245 " (parameters\n"
22246 " (declare (in ) vec3 x@0xb02af0)\n"
22247 " )\n"
22248 " (\n"
22249 " ))\n"
22250 "\n"
22251 " (signature vec4\n"
22252 " (parameters\n"
22253 " (declare (in ) vec4 x@0xb02cd0)\n"
22254 " )\n"
22255 " (\n"
22256 " ))\n"
22257 "\n"
22258 ")\n"
22259 "\n"
22260 "(function floor\n"
22261 " (signature float\n"
22262 " (parameters\n"
22263 " (declare (in ) float x@0xb02eb0)\n"
22264 " )\n"
22265 " (\n"
22266 " ))\n"
22267 "\n"
22268 " (signature vec2\n"
22269 " (parameters\n"
22270 " (declare (in ) vec2 x@0xb03230)\n"
22271 " )\n"
22272 " (\n"
22273 " ))\n"
22274 "\n"
22275 " (signature vec3\n"
22276 " (parameters\n"
22277 " (declare (in ) vec3 x@0xb03410)\n"
22278 " )\n"
22279 " (\n"
22280 " ))\n"
22281 "\n"
22282 " (signature vec4\n"
22283 " (parameters\n"
22284 " (declare (in ) vec4 x@0xb035f0)\n"
22285 " )\n"
22286 " (\n"
22287 " ))\n"
22288 "\n"
22289 ")\n"
22290 "\n"
22291 "(function ceil\n"
22292 " (signature float\n"
22293 " (parameters\n"
22294 " (declare (in ) float x@0xb037d0)\n"
22295 " )\n"
22296 " (\n"
22297 " ))\n"
22298 "\n"
22299 " (signature vec2\n"
22300 " (parameters\n"
22301 " (declare (in ) vec2 x@0xb03b50)\n"
22302 " )\n"
22303 " (\n"
22304 " ))\n"
22305 "\n"
22306 " (signature vec3\n"
22307 " (parameters\n"
22308 " (declare (in ) vec3 x@0xb03d30)\n"
22309 " )\n"
22310 " (\n"
22311 " ))\n"
22312 "\n"
22313 " (signature vec4\n"
22314 " (parameters\n"
22315 " (declare (in ) vec4 x@0xb03f10)\n"
22316 " )\n"
22317 " (\n"
22318 " ))\n"
22319 "\n"
22320 ")\n"
22321 "\n"
22322 "(function fract\n"
22323 " (signature float\n"
22324 " (parameters\n"
22325 " (declare (in ) float x@0xb040f0)\n"
22326 " )\n"
22327 " (\n"
22328 " ))\n"
22329 "\n"
22330 " (signature vec2\n"
22331 " (parameters\n"
22332 " (declare (in ) vec2 x@0xb04470)\n"
22333 " )\n"
22334 " (\n"
22335 " ))\n"
22336 "\n"
22337 " (signature vec3\n"
22338 " (parameters\n"
22339 " (declare (in ) vec3 x@0xb04650)\n"
22340 " )\n"
22341 " (\n"
22342 " ))\n"
22343 "\n"
22344 " (signature vec4\n"
22345 " (parameters\n"
22346 " (declare (in ) vec4 x@0xb04830)\n"
22347 " )\n"
22348 " (\n"
22349 " ))\n"
22350 "\n"
22351 ")\n"
22352 "\n"
22353 "(function mod\n"
22354 " (signature float\n"
22355 " (parameters\n"
22356 " (declare (in ) float x@0xb04a10)\n"
22357 " (declare (in ) float y@0xb04b20)\n"
22358 " )\n"
22359 " (\n"
22360 " ))\n"
22361 "\n"
22362 " (signature vec2\n"
22363 " (parameters\n"
22364 " (declare (in ) vec2 x@0xb04ea0)\n"
22365 " (declare (in ) float y@0xb04fb0)\n"
22366 " )\n"
22367 " (\n"
22368 " ))\n"
22369 "\n"
22370 " (signature vec3\n"
22371 " (parameters\n"
22372 " (declare (in ) vec3 x@0xb05190)\n"
22373 " (declare (in ) float y@0xb052a0)\n"
22374 " )\n"
22375 " (\n"
22376 " ))\n"
22377 "\n"
22378 " (signature vec4\n"
22379 " (parameters\n"
22380 " (declare (in ) vec4 x@0xb05480)\n"
22381 " (declare (in ) float y@0xb05590)\n"
22382 " )\n"
22383 " (\n"
22384 " ))\n"
22385 "\n"
22386 " (signature vec2\n"
22387 " (parameters\n"
22388 " (declare (in ) vec2 x@0xb05770)\n"
22389 " (declare (in ) vec2 y@0xb05880)\n"
22390 " )\n"
22391 " (\n"
22392 " ))\n"
22393 "\n"
22394 " (signature vec3\n"
22395 " (parameters\n"
22396 " (declare (in ) vec3 x@0xb05a60)\n"
22397 " (declare (in ) vec3 y@0xb05b70)\n"
22398 " )\n"
22399 " (\n"
22400 " ))\n"
22401 "\n"
22402 " (signature vec4\n"
22403 " (parameters\n"
22404 " (declare (in ) vec4 x@0xb05d50)\n"
22405 " (declare (in ) vec4 y@0xb05e60)\n"
22406 " )\n"
22407 " (\n"
22408 " ))\n"
22409 "\n"
22410 ")\n"
22411 "\n"
22412 "(function min\n"
22413 " (signature float\n"
22414 " (parameters\n"
22415 " (declare (in ) float x@0xb06040)\n"
22416 " (declare (in ) float y@0xb06150)\n"
22417 " )\n"
22418 " (\n"
22419 " ))\n"
22420 "\n"
22421 " (signature vec2\n"
22422 " (parameters\n"
22423 " (declare (in ) vec2 x@0xb064d0)\n"
22424 " (declare (in ) vec2 y@0xb065e0)\n"
22425 " )\n"
22426 " (\n"
22427 " ))\n"
22428 "\n"
22429 " (signature vec3\n"
22430 " (parameters\n"
22431 " (declare (in ) vec3 x@0xb067c0)\n"
22432 " (declare (in ) vec3 y@0xb068d0)\n"
22433 " )\n"
22434 " (\n"
22435 " ))\n"
22436 "\n"
22437 " (signature vec4\n"
22438 " (parameters\n"
22439 " (declare (in ) vec4 x@0xb06ab0)\n"
22440 " (declare (in ) vec4 y@0xb06bc0)\n"
22441 " )\n"
22442 " (\n"
22443 " ))\n"
22444 "\n"
22445 " (signature vec2\n"
22446 " (parameters\n"
22447 " (declare (in ) vec2 x@0xb06da0)\n"
22448 " (declare (in ) float y@0xb06eb0)\n"
22449 " )\n"
22450 " (\n"
22451 " ))\n"
22452 "\n"
22453 " (signature vec3\n"
22454 " (parameters\n"
22455 " (declare (in ) vec3 x@0xb07090)\n"
22456 " (declare (in ) float y@0xb071a0)\n"
22457 " )\n"
22458 " (\n"
22459 " ))\n"
22460 "\n"
22461 " (signature vec4\n"
22462 " (parameters\n"
22463 " (declare (in ) vec4 x@0xb07380)\n"
22464 " (declare (in ) float y@0xb07490)\n"
22465 " )\n"
22466 " (\n"
22467 " ))\n"
22468 "\n"
22469 ")\n"
22470 "\n"
22471 "(function max\n"
22472 " (signature float\n"
22473 " (parameters\n"
22474 " (declare (in ) float x@0xb07670)\n"
22475 " (declare (in ) float y@0xb07780)\n"
22476 " )\n"
22477 " (\n"
22478 " ))\n"
22479 "\n"
22480 " (signature vec2\n"
22481 " (parameters\n"
22482 " (declare (in ) vec2 x@0xb07b00)\n"
22483 " (declare (in ) vec2 y@0xb07c10)\n"
22484 " )\n"
22485 " (\n"
22486 " ))\n"
22487 "\n"
22488 " (signature vec3\n"
22489 " (parameters\n"
22490 " (declare (in ) vec3 x@0xb07df0)\n"
22491 " (declare (in ) vec3 y@0xb07f00)\n"
22492 " )\n"
22493 " (\n"
22494 " ))\n"
22495 "\n"
22496 " (signature vec4\n"
22497 " (parameters\n"
22498 " (declare (in ) vec4 x@0xb080e0)\n"
22499 " (declare (in ) vec4 y@0xb081f0)\n"
22500 " )\n"
22501 " (\n"
22502 " ))\n"
22503 "\n"
22504 " (signature vec2\n"
22505 " (parameters\n"
22506 " (declare (in ) vec2 x@0xb083d0)\n"
22507 " (declare (in ) float y@0xb084e0)\n"
22508 " )\n"
22509 " (\n"
22510 " ))\n"
22511 "\n"
22512 " (signature vec3\n"
22513 " (parameters\n"
22514 " (declare (in ) vec3 x@0xb086c0)\n"
22515 " (declare (in ) float y@0xb087d0)\n"
22516 " )\n"
22517 " (\n"
22518 " ))\n"
22519 "\n"
22520 " (signature vec4\n"
22521 " (parameters\n"
22522 " (declare (in ) vec4 x@0xb089b0)\n"
22523 " (declare (in ) float y@0xb08ac0)\n"
22524 " )\n"
22525 " (\n"
22526 " ))\n"
22527 "\n"
22528 ")\n"
22529 "\n"
22530 "(function clamp\n"
22531 " (signature float\n"
22532 " (parameters\n"
22533 " (declare (in ) float x@0xb08ca0)\n"
22534 " (declare (in ) float minVal@0xb08db0)\n"
22535 " (declare (in ) float maxVal@0xb08ec0)\n"
22536 " )\n"
22537 " (\n"
22538 " ))\n"
22539 "\n"
22540 " (signature vec2\n"
22541 " (parameters\n"
22542 " (declare (in ) vec2 x@0xb09240)\n"
22543 " (declare (in ) vec2 minVal@0xb09350)\n"
22544 " (declare (in ) vec2 maxVal@0xb09460)\n"
22545 " )\n"
22546 " (\n"
22547 " ))\n"
22548 "\n"
22549 " (signature vec3\n"
22550 " (parameters\n"
22551 " (declare (in ) vec3 x@0xb09640)\n"
22552 " (declare (in ) vec3 minVal@0xb09750)\n"
22553 " (declare (in ) vec3 maxVal@0xb09860)\n"
22554 " )\n"
22555 " (\n"
22556 " ))\n"
22557 "\n"
22558 " (signature vec4\n"
22559 " (parameters\n"
22560 " (declare (in ) vec4 x@0xb09a40)\n"
22561 " (declare (in ) vec4 minVal@0xb09b50)\n"
22562 " (declare (in ) vec4 maxVal@0xb09c60)\n"
22563 " )\n"
22564 " (\n"
22565 " ))\n"
22566 "\n"
22567 " (signature vec2\n"
22568 " (parameters\n"
22569 " (declare (in ) vec2 x@0xb09e40)\n"
22570 " (declare (in ) float minVal@0xb09f50)\n"
22571 " (declare (in ) float maxVal@0xb0a060)\n"
22572 " )\n"
22573 " (\n"
22574 " ))\n"
22575 "\n"
22576 " (signature vec3\n"
22577 " (parameters\n"
22578 " (declare (in ) vec3 x@0xb0a240)\n"
22579 " (declare (in ) float minVal@0xb0a350)\n"
22580 " (declare (in ) float maxVal@0xb0a460)\n"
22581 " )\n"
22582 " (\n"
22583 " ))\n"
22584 "\n"
22585 " (signature vec4\n"
22586 " (parameters\n"
22587 " (declare (in ) vec4 x@0xb0a640)\n"
22588 " (declare (in ) float minVal@0xb0a750)\n"
22589 " (declare (in ) float maxVal@0xb0a860)\n"
22590 " )\n"
22591 " (\n"
22592 " ))\n"
22593 "\n"
22594 ")\n"
22595 "\n"
22596 "(function mix\n"
22597 " (signature float\n"
22598 " (parameters\n"
22599 " (declare (in ) float x@0xb0aa40)\n"
22600 " (declare (in ) float y@0xb0ab50)\n"
22601 " (declare (in ) float a@0xb0ac60)\n"
22602 " )\n"
22603 " (\n"
22604 " ))\n"
22605 "\n"
22606 " (signature vec2\n"
22607 " (parameters\n"
22608 " (declare (in ) vec2 x@0xb0afe0)\n"
22609 " (declare (in ) vec2 y@0xb0b0f0)\n"
22610 " (declare (in ) vec2 a@0xb0b200)\n"
22611 " )\n"
22612 " (\n"
22613 " ))\n"
22614 "\n"
22615 " (signature vec3\n"
22616 " (parameters\n"
22617 " (declare (in ) vec3 x@0xb0b3e0)\n"
22618 " (declare (in ) vec3 y@0xb0b4f0)\n"
22619 " (declare (in ) vec3 a@0xb0b600)\n"
22620 " )\n"
22621 " (\n"
22622 " ))\n"
22623 "\n"
22624 " (signature vec4\n"
22625 " (parameters\n"
22626 " (declare (in ) vec4 x@0xb0b7e0)\n"
22627 " (declare (in ) vec4 y@0xb0b8f0)\n"
22628 " (declare (in ) vec4 a@0xb0ba00)\n"
22629 " )\n"
22630 " (\n"
22631 " ))\n"
22632 "\n"
22633 " (signature vec2\n"
22634 " (parameters\n"
22635 " (declare (in ) vec2 x@0xb0bbe0)\n"
22636 " (declare (in ) vec2 y@0xb0bcf0)\n"
22637 " (declare (in ) float a@0xb0be00)\n"
22638 " )\n"
22639 " (\n"
22640 " ))\n"
22641 "\n"
22642 " (signature vec3\n"
22643 " (parameters\n"
22644 " (declare (in ) vec3 x@0xb0bfe0)\n"
22645 " (declare (in ) vec3 y@0xb0c0f0)\n"
22646 " (declare (in ) float a@0xb0c200)\n"
22647 " )\n"
22648 " (\n"
22649 " ))\n"
22650 "\n"
22651 " (signature vec4\n"
22652 " (parameters\n"
22653 " (declare (in ) vec4 x@0xb0c3e0)\n"
22654 " (declare (in ) vec4 y@0xb0c4f0)\n"
22655 " (declare (in ) float a@0xb0c600)\n"
22656 " )\n"
22657 " (\n"
22658 " ))\n"
22659 "\n"
22660 ")\n"
22661 "\n"
22662 "(function step\n"
22663 " (signature float\n"
22664 " (parameters\n"
22665 " (declare (in ) float edge@0xb0c7e0)\n"
22666 " (declare (in ) float x@0xb0c8f0)\n"
22667 " )\n"
22668 " (\n"
22669 " ))\n"
22670 "\n"
22671 " (signature vec2\n"
22672 " (parameters\n"
22673 " (declare (in ) vec2 edge@0xb0cc70)\n"
22674 " (declare (in ) vec2 x@0xb0cd80)\n"
22675 " )\n"
22676 " (\n"
22677 " ))\n"
22678 "\n"
22679 " (signature vec3\n"
22680 " (parameters\n"
22681 " (declare (in ) vec3 edge@0xb0cf60)\n"
22682 " (declare (in ) vec3 x@0xb0d070)\n"
22683 " )\n"
22684 " (\n"
22685 " ))\n"
22686 "\n"
22687 " (signature vec4\n"
22688 " (parameters\n"
22689 " (declare (in ) vec4 edge@0xb0d250)\n"
22690 " (declare (in ) vec4 x@0xb0d360)\n"
22691 " )\n"
22692 " (\n"
22693 " ))\n"
22694 "\n"
22695 " (signature vec2\n"
22696 " (parameters\n"
22697 " (declare (in ) float edge@0xb0d540)\n"
22698 " (declare (in ) vec2 x@0xb0d650)\n"
22699 " )\n"
22700 " (\n"
22701 " ))\n"
22702 "\n"
22703 " (signature vec3\n"
22704 " (parameters\n"
22705 " (declare (in ) float edge@0xb0d830)\n"
22706 " (declare (in ) vec3 x@0xb0d940)\n"
22707 " )\n"
22708 " (\n"
22709 " ))\n"
22710 "\n"
22711 " (signature vec4\n"
22712 " (parameters\n"
22713 " (declare (in ) float edge@0xb0db20)\n"
22714 " (declare (in ) vec4 x@0xb0dc30)\n"
22715 " )\n"
22716 " (\n"
22717 " ))\n"
22718 "\n"
22719 ")\n"
22720 "\n"
22721 "(function smoothstep\n"
22722 " (signature float\n"
22723 " (parameters\n"
22724 " (declare (in ) float edge0@0xb0de10)\n"
22725 " (declare (in ) float edge1@0xb0df20)\n"
22726 " (declare (in ) float x@0xb0e030)\n"
22727 " )\n"
22728 " (\n"
22729 " ))\n"
22730 "\n"
22731 " (signature vec2\n"
22732 " (parameters\n"
22733 " (declare (in ) vec2 edge0@0xb0e3c0)\n"
22734 " (declare (in ) vec2 edge1@0xb0e4d0)\n"
22735 " (declare (in ) vec2 x@0xb0e5e0)\n"
22736 " )\n"
22737 " (\n"
22738 " ))\n"
22739 "\n"
22740 " (signature vec3\n"
22741 " (parameters\n"
22742 " (declare (in ) vec3 edge0@0xb0e7c0)\n"
22743 " (declare (in ) vec3 edge1@0xb0e8d0)\n"
22744 " (declare (in ) vec3 x@0xb0e9e0)\n"
22745 " )\n"
22746 " (\n"
22747 " ))\n"
22748 "\n"
22749 " (signature vec4\n"
22750 " (parameters\n"
22751 " (declare (in ) vec4 edge0@0xb0ebc0)\n"
22752 " (declare (in ) vec4 edge1@0xb0ecd0)\n"
22753 " (declare (in ) vec4 x@0xb0ede0)\n"
22754 " )\n"
22755 " (\n"
22756 " ))\n"
22757 "\n"
22758 " (signature vec2\n"
22759 " (parameters\n"
22760 " (declare (in ) float edge0@0xb0efc0)\n"
22761 " (declare (in ) float edge1@0xb0f0d0)\n"
22762 " (declare (in ) vec2 x@0xb0f1e0)\n"
22763 " )\n"
22764 " (\n"
22765 " ))\n"
22766 "\n"
22767 " (signature vec3\n"
22768 " (parameters\n"
22769 " (declare (in ) float edge0@0xb0f3c0)\n"
22770 " (declare (in ) float edge1@0xb0f4d0)\n"
22771 " (declare (in ) vec3 x@0xb0f5e0)\n"
22772 " )\n"
22773 " (\n"
22774 " ))\n"
22775 "\n"
22776 " (signature vec4\n"
22777 " (parameters\n"
22778 " (declare (in ) float edge0@0xb0f7c0)\n"
22779 " (declare (in ) float edge1@0xb0f8d0)\n"
22780 " (declare (in ) vec4 x@0xb0f9e0)\n"
22781 " )\n"
22782 " (\n"
22783 " ))\n"
22784 "\n"
22785 ")\n"
22786 "\n"
22787 "(function length\n"
22788 " (signature float\n"
22789 " (parameters\n"
22790 " (declare (in ) float x@0xb0fbc0)\n"
22791 " )\n"
22792 " (\n"
22793 " ))\n"
22794 "\n"
22795 " (signature float\n"
22796 " (parameters\n"
22797 " (declare (in ) vec2 x@0xb0ff40)\n"
22798 " )\n"
22799 " (\n"
22800 " ))\n"
22801 "\n"
22802 " (signature float\n"
22803 " (parameters\n"
22804 " (declare (in ) vec3 x@0xb10120)\n"
22805 " )\n"
22806 " (\n"
22807 " ))\n"
22808 "\n"
22809 " (signature float\n"
22810 " (parameters\n"
22811 " (declare (in ) vec4 x@0xb10300)\n"
22812 " )\n"
22813 " (\n"
22814 " ))\n"
22815 "\n"
22816 ")\n"
22817 "\n"
22818 "(function distance\n"
22819 " (signature float\n"
22820 " (parameters\n"
22821 " (declare (in ) float p0@0xb104e0)\n"
22822 " (declare (in ) float p1@0xb105f0)\n"
22823 " )\n"
22824 " (\n"
22825 " ))\n"
22826 "\n"
22827 " (signature float\n"
22828 " (parameters\n"
22829 " (declare (in ) vec2 p0@0xb10980)\n"
22830 " (declare (in ) vec2 p1@0xb10a90)\n"
22831 " )\n"
22832 " (\n"
22833 " ))\n"
22834 "\n"
22835 " (signature float\n"
22836 " (parameters\n"
22837 " (declare (in ) vec3 p0@0xb10c70)\n"
22838 " (declare (in ) vec3 p1@0xb10d80)\n"
22839 " )\n"
22840 " (\n"
22841 " ))\n"
22842 "\n"
22843 " (signature float\n"
22844 " (parameters\n"
22845 " (declare (in ) vec4 p0@0xb10f60)\n"
22846 " (declare (in ) vec4 p1@0xb11070)\n"
22847 " )\n"
22848 " (\n"
22849 " ))\n"
22850 "\n"
22851 ")\n"
22852 "\n"
22853 "(function dot\n"
22854 " (signature float\n"
22855 " (parameters\n"
22856 " (declare (in ) float x@0xb11250)\n"
22857 " (declare (in ) float y@0xb11360)\n"
22858 " )\n"
22859 " (\n"
22860 " ))\n"
22861 "\n"
22862 " (signature float\n"
22863 " (parameters\n"
22864 " (declare (in ) vec2 x@0xb116e0)\n"
22865 " (declare (in ) vec2 y@0xb117f0)\n"
22866 " )\n"
22867 " (\n"
22868 " ))\n"
22869 "\n"
22870 " (signature float\n"
22871 " (parameters\n"
22872 " (declare (in ) vec3 x@0xb119d0)\n"
22873 " (declare (in ) vec3 y@0xb11ae0)\n"
22874 " )\n"
22875 " (\n"
22876 " ))\n"
22877 "\n"
22878 " (signature float\n"
22879 " (parameters\n"
22880 " (declare (in ) vec4 x@0xb11cc0)\n"
22881 " (declare (in ) vec4 y@0xb11dd0)\n"
22882 " )\n"
22883 " (\n"
22884 " ))\n"
22885 "\n"
22886 ")\n"
22887 "\n"
22888 "(function cross\n"
22889 " (signature vec3\n"
22890 " (parameters\n"
22891 " (declare (in ) vec3 x@0xb11fb0)\n"
22892 " (declare (in ) vec3 y@0xb120c0)\n"
22893 " )\n"
22894 " (\n"
22895 " ))\n"
22896 "\n"
22897 ")\n"
22898 "\n"
22899 "(function normalize\n"
22900 " (signature float\n"
22901 " (parameters\n"
22902 " (declare (in ) float x@0xb12440)\n"
22903 " )\n"
22904 " (\n"
22905 " ))\n"
22906 "\n"
22907 " (signature vec2\n"
22908 " (parameters\n"
22909 " (declare (in ) vec2 x@0xb127d0)\n"
22910 " )\n"
22911 " (\n"
22912 " ))\n"
22913 "\n"
22914 " (signature vec3\n"
22915 " (parameters\n"
22916 " (declare (in ) vec3 x@0xb129b0)\n"
22917 " )\n"
22918 " (\n"
22919 " ))\n"
22920 "\n"
22921 " (signature vec4\n"
22922 " (parameters\n"
22923 " (declare (in ) vec4 x@0xb12b90)\n"
22924 " )\n"
22925 " (\n"
22926 " ))\n"
22927 "\n"
22928 ")\n"
22929 "\n"
22930 "(function faceforward\n"
22931 " (signature float\n"
22932 " (parameters\n"
22933 " (declare (in ) float N@0xb12d70)\n"
22934 " (declare (in ) float I@0xb12e80)\n"
22935 " (declare (in ) float Nref@0xb12f90)\n"
22936 " )\n"
22937 " (\n"
22938 " ))\n"
22939 "\n"
22940 " (signature vec2\n"
22941 " (parameters\n"
22942 " (declare (in ) vec2 N@0xb13320)\n"
22943 " (declare (in ) vec2 I@0xb13430)\n"
22944 " (declare (in ) vec2 Nref@0xb13540)\n"
22945 " )\n"
22946 " (\n"
22947 " ))\n"
22948 "\n"
22949 " (signature vec3\n"
22950 " (parameters\n"
22951 " (declare (in ) vec3 N@0xb13720)\n"
22952 " (declare (in ) vec3 I@0xb13830)\n"
22953 " (declare (in ) vec3 Nref@0xb13940)\n"
22954 " )\n"
22955 " (\n"
22956 " ))\n"
22957 "\n"
22958 " (signature vec4\n"
22959 " (parameters\n"
22960 " (declare (in ) vec4 N@0xb13b20)\n"
22961 " (declare (in ) vec4 I@0xb13c30)\n"
22962 " (declare (in ) vec4 Nref@0xb13d40)\n"
22963 " )\n"
22964 " (\n"
22965 " ))\n"
22966 "\n"
22967 ")\n"
22968 "\n"
22969 "(function reflect\n"
22970 " (signature float\n"
22971 " (parameters\n"
22972 " (declare (in ) float I@0xb13f20)\n"
22973 " (declare (in ) float N@0xb14030)\n"
22974 " )\n"
22975 " (\n"
22976 " ))\n"
22977 "\n"
22978 " (signature vec2\n"
22979 " (parameters\n"
22980 " (declare (in ) vec2 I@0xb143b0)\n"
22981 " (declare (in ) vec2 N@0xb144c0)\n"
22982 " )\n"
22983 " (\n"
22984 " ))\n"
22985 "\n"
22986 " (signature vec3\n"
22987 " (parameters\n"
22988 " (declare (in ) vec3 I@0xb146a0)\n"
22989 " (declare (in ) vec3 N@0xb147b0)\n"
22990 " )\n"
22991 " (\n"
22992 " ))\n"
22993 "\n"
22994 " (signature vec4\n"
22995 " (parameters\n"
22996 " (declare (in ) vec4 I@0xb14990)\n"
22997 " (declare (in ) vec4 N@0xb14aa0)\n"
22998 " )\n"
22999 " (\n"
23000 " ))\n"
23001 "\n"
23002 ")\n"
23003 "\n"
23004 "(function refract\n"
23005 " (signature float\n"
23006 " (parameters\n"
23007 " (declare (in ) float I@0xb14c80)\n"
23008 " (declare (in ) float N@0xb14d90)\n"
23009 " (declare (in ) float eta@0xb14ea0)\n"
23010 " )\n"
23011 " (\n"
23012 " ))\n"
23013 "\n"
23014 " (signature vec2\n"
23015 " (parameters\n"
23016 " (declare (in ) vec2 I@0xb15220)\n"
23017 " (declare (in ) vec2 N@0xb15330)\n"
23018 " (declare (in ) float eta@0xb15440)\n"
23019 " )\n"
23020 " (\n"
23021 " ))\n"
23022 "\n"
23023 " (signature vec3\n"
23024 " (parameters\n"
23025 " (declare (in ) vec3 I@0xb15620)\n"
23026 " (declare (in ) vec3 N@0xb15730)\n"
23027 " (declare (in ) float eta@0xb15840)\n"
23028 " )\n"
23029 " (\n"
23030 " ))\n"
23031 "\n"
23032 " (signature vec4\n"
23033 " (parameters\n"
23034 " (declare (in ) vec4 I@0xb15a20)\n"
23035 " (declare (in ) vec4 N@0xb15b30)\n"
23036 " (declare (in ) float eta@0xb15c40)\n"
23037 " )\n"
23038 " (\n"
23039 " ))\n"
23040 "\n"
23041 ")\n"
23042 "\n"
23043 "(function matrixCompMult\n"
23044 " (signature mat2\n"
23045 " (parameters\n"
23046 " (declare (in ) mat2 x@0xb15e20)\n"
23047 " (declare (in ) mat2 y@0xb15f30)\n"
23048 " )\n"
23049 " (\n"
23050 " ))\n"
23051 "\n"
23052 " (signature mat3\n"
23053 " (parameters\n"
23054 " (declare (in ) mat3 x@0xb162c0)\n"
23055 " (declare (in ) mat3 y@0xb163d0)\n"
23056 " )\n"
23057 " (\n"
23058 " ))\n"
23059 "\n"
23060 " (signature mat4\n"
23061 " (parameters\n"
23062 " (declare (in ) mat4 x@0xb165b0)\n"
23063 " (declare (in ) mat4 y@0xb166c0)\n"
23064 " )\n"
23065 " (\n"
23066 " ))\n"
23067 "\n"
23068 " (signature mat2x3\n"
23069 " (parameters\n"
23070 " (declare (in ) mat2x3 x@0xb168a0)\n"
23071 " (declare (in ) mat2x3 y@0xb169b0)\n"
23072 " )\n"
23073 " (\n"
23074 " ))\n"
23075 "\n"
23076 " (signature mat2x4\n"
23077 " (parameters\n"
23078 " (declare (in ) mat2x4 x@0xb16b90)\n"
23079 " (declare (in ) mat2x4 y@0xb16ca0)\n"
23080 " )\n"
23081 " (\n"
23082 " ))\n"
23083 "\n"
23084 " (signature mat3x2\n"
23085 " (parameters\n"
23086 " (declare (in ) mat3x2 x@0xb16e80)\n"
23087 " (declare (in ) mat3x2 y@0xb16f90)\n"
23088 " )\n"
23089 " (\n"
23090 " ))\n"
23091 "\n"
23092 " (signature mat3x4\n"
23093 " (parameters\n"
23094 " (declare (in ) mat3x4 x@0xb17170)\n"
23095 " (declare (in ) mat3x4 y@0xb17280)\n"
23096 " )\n"
23097 " (\n"
23098 " ))\n"
23099 "\n"
23100 " (signature mat4x2\n"
23101 " (parameters\n"
23102 " (declare (in ) mat4x2 x@0xb17460)\n"
23103 " (declare (in ) mat4x2 y@0xb17570)\n"
23104 " )\n"
23105 " (\n"
23106 " ))\n"
23107 "\n"
23108 " (signature mat4x3\n"
23109 " (parameters\n"
23110 " (declare (in ) mat4x3 x@0xb17750)\n"
23111 " (declare (in ) mat4x3 y@0xb17860)\n"
23112 " )\n"
23113 " (\n"
23114 " ))\n"
23115 "\n"
23116 ")\n"
23117 "\n"
23118 "(function outerProduct\n"
23119 " (signature mat2\n"
23120 " (parameters\n"
23121 " (declare (in ) vec2 c@0xb17a40)\n"
23122 " (declare (in ) vec2 r@0xb17b50)\n"
23123 " )\n"
23124 " (\n"
23125 " ))\n"
23126 "\n"
23127 " (signature mat3\n"
23128 " (parameters\n"
23129 " (declare (in ) vec3 c@0xb17ee0)\n"
23130 " (declare (in ) vec3 r@0xb17ff0)\n"
23131 " )\n"
23132 " (\n"
23133 " ))\n"
23134 "\n"
23135 " (signature mat4\n"
23136 " (parameters\n"
23137 " (declare (in ) vec4 c@0xb181d0)\n"
23138 " (declare (in ) vec4 r@0xb182e0)\n"
23139 " )\n"
23140 " (\n"
23141 " ))\n"
23142 "\n"
23143 " (signature mat2x3\n"
23144 " (parameters\n"
23145 " (declare (in ) vec3 c@0xb184c0)\n"
23146 " (declare (in ) vec2 r@0xb185d0)\n"
23147 " )\n"
23148 " (\n"
23149 " ))\n"
23150 "\n"
23151 " (signature mat3x2\n"
23152 " (parameters\n"
23153 " (declare (in ) vec2 c@0xb187b0)\n"
23154 " (declare (in ) vec3 r@0xb188c0)\n"
23155 " )\n"
23156 " (\n"
23157 " ))\n"
23158 "\n"
23159 " (signature mat2x4\n"
23160 " (parameters\n"
23161 " (declare (in ) vec4 c@0xb18aa0)\n"
23162 " (declare (in ) vec2 r@0xb18bb0)\n"
23163 " )\n"
23164 " (\n"
23165 " ))\n"
23166 "\n"
23167 " (signature mat4x2\n"
23168 " (parameters\n"
23169 " (declare (in ) vec2 c@0xb18d90)\n"
23170 " (declare (in ) vec4 r@0xb18ea0)\n"
23171 " )\n"
23172 " (\n"
23173 " ))\n"
23174 "\n"
23175 " (signature mat3x4\n"
23176 " (parameters\n"
23177 " (declare (in ) vec4 c@0xb19080)\n"
23178 " (declare (in ) vec3 r@0xb19190)\n"
23179 " )\n"
23180 " (\n"
23181 " ))\n"
23182 "\n"
23183 " (signature mat4x3\n"
23184 " (parameters\n"
23185 " (declare (in ) vec3 c@0xb19370)\n"
23186 " (declare (in ) vec4 r@0xb19480)\n"
23187 " )\n"
23188 " (\n"
23189 " ))\n"
23190 "\n"
23191 ")\n"
23192 "\n"
23193 "(function transpose\n"
23194 " (signature mat2\n"
23195 " (parameters\n"
23196 " (declare (in ) mat2 m@0xb19660)\n"
23197 " )\n"
23198 " (\n"
23199 " ))\n"
23200 "\n"
23201 " (signature mat3\n"
23202 " (parameters\n"
23203 " (declare (in ) mat3 m@0xb199f0)\n"
23204 " )\n"
23205 " (\n"
23206 " ))\n"
23207 "\n"
23208 " (signature mat4\n"
23209 " (parameters\n"
23210 " (declare (in ) mat4 m@0xb19bd0)\n"
23211 " )\n"
23212 " (\n"
23213 " ))\n"
23214 "\n"
23215 " (signature mat2x3\n"
23216 " (parameters\n"
23217 " (declare (in ) mat3x2 m@0xb19db0)\n"
23218 " )\n"
23219 " (\n"
23220 " ))\n"
23221 "\n"
23222 " (signature mat3x2\n"
23223 " (parameters\n"
23224 " (declare (in ) mat2x3 m@0xb19f90)\n"
23225 " )\n"
23226 " (\n"
23227 " ))\n"
23228 "\n"
23229 " (signature mat2x4\n"
23230 " (parameters\n"
23231 " (declare (in ) mat4x2 m@0xb1a170)\n"
23232 " )\n"
23233 " (\n"
23234 " ))\n"
23235 "\n"
23236 " (signature mat4x2\n"
23237 " (parameters\n"
23238 " (declare (in ) mat2x4 m@0xb1a350)\n"
23239 " )\n"
23240 " (\n"
23241 " ))\n"
23242 "\n"
23243 " (signature mat3x4\n"
23244 " (parameters\n"
23245 " (declare (in ) mat4x3 m@0xb1a530)\n"
23246 " )\n"
23247 " (\n"
23248 " ))\n"
23249 "\n"
23250 " (signature mat4x3\n"
23251 " (parameters\n"
23252 " (declare (in ) mat3x4 m@0xb1a710)\n"
23253 " )\n"
23254 " (\n"
23255 " ))\n"
23256 "\n"
23257 ")\n"
23258 "\n"
23259 "(function lessThan\n"
23260 " (signature bvec2\n"
23261 " (parameters\n"
23262 " (declare (in ) vec2 x@0xb1a8f0)\n"
23263 " (declare (in ) vec2 y@0xb1aa00)\n"
23264 " )\n"
23265 " (\n"
23266 " ))\n"
23267 "\n"
23268 " (signature bvec3\n"
23269 " (parameters\n"
23270 " (declare (in ) vec3 x@0xb1ad90)\n"
23271 " (declare (in ) vec3 y@0xb1aea0)\n"
23272 " )\n"
23273 " (\n"
23274 " ))\n"
23275 "\n"
23276 " (signature bvec4\n"
23277 " (parameters\n"
23278 " (declare (in ) vec4 x@0xb1b080)\n"
23279 " (declare (in ) vec4 y@0xb1b190)\n"
23280 " )\n"
23281 " (\n"
23282 " ))\n"
23283 "\n"
23284 " (signature bvec2\n"
23285 " (parameters\n"
23286 " (declare (in ) ivec2 x@0xb1b370)\n"
23287 " (declare (in ) ivec2 y@0xb1b480)\n"
23288 " )\n"
23289 " (\n"
23290 " ))\n"
23291 "\n"
23292 " (signature bvec3\n"
23293 " (parameters\n"
23294 " (declare (in ) ivec3 x@0xb1b660)\n"
23295 " (declare (in ) ivec3 y@0xb1b770)\n"
23296 " )\n"
23297 " (\n"
23298 " ))\n"
23299 "\n"
23300 " (signature bvec4\n"
23301 " (parameters\n"
23302 " (declare (in ) ivec4 x@0xb1b950)\n"
23303 " (declare (in ) ivec4 y@0xb1ba60)\n"
23304 " )\n"
23305 " (\n"
23306 " ))\n"
23307 "\n"
23308 ")\n"
23309 "\n"
23310 "(function lessThanEqual\n"
23311 " (signature bvec2\n"
23312 " (parameters\n"
23313 " (declare (in ) vec2 x@0xb1bc40)\n"
23314 " (declare (in ) vec2 y@0xb1bd50)\n"
23315 " )\n"
23316 " (\n"
23317 " ))\n"
23318 "\n"
23319 " (signature bvec3\n"
23320 " (parameters\n"
23321 " (declare (in ) vec3 x@0xb1c0e0)\n"
23322 " (declare (in ) vec3 y@0xb1c1f0)\n"
23323 " )\n"
23324 " (\n"
23325 " ))\n"
23326 "\n"
23327 " (signature bvec4\n"
23328 " (parameters\n"
23329 " (declare (in ) vec4 x@0xb1c3d0)\n"
23330 " (declare (in ) vec4 y@0xb1c4e0)\n"
23331 " )\n"
23332 " (\n"
23333 " ))\n"
23334 "\n"
23335 " (signature bvec2\n"
23336 " (parameters\n"
23337 " (declare (in ) ivec2 x@0xb1c6c0)\n"
23338 " (declare (in ) ivec2 y@0xb1c7d0)\n"
23339 " )\n"
23340 " (\n"
23341 " ))\n"
23342 "\n"
23343 " (signature bvec3\n"
23344 " (parameters\n"
23345 " (declare (in ) ivec3 x@0xb1c9b0)\n"
23346 " (declare (in ) ivec3 y@0xb1cac0)\n"
23347 " )\n"
23348 " (\n"
23349 " ))\n"
23350 "\n"
23351 " (signature bvec4\n"
23352 " (parameters\n"
23353 " (declare (in ) ivec4 x@0xb1cca0)\n"
23354 " (declare (in ) ivec4 y@0xb1cdb0)\n"
23355 " )\n"
23356 " (\n"
23357 " ))\n"
23358 "\n"
23359 ")\n"
23360 "\n"
23361 "(function greaterThan\n"
23362 " (signature bvec2\n"
23363 " (parameters\n"
23364 " (declare (in ) vec2 x@0xb1cf90)\n"
23365 " (declare (in ) vec2 y@0xb1d0a0)\n"
23366 " )\n"
23367 " (\n"
23368 " ))\n"
23369 "\n"
23370 " (signature bvec3\n"
23371 " (parameters\n"
23372 " (declare (in ) vec3 x@0xb1d430)\n"
23373 " (declare (in ) vec3 y@0xb1d540)\n"
23374 " )\n"
23375 " (\n"
23376 " ))\n"
23377 "\n"
23378 " (signature bvec4\n"
23379 " (parameters\n"
23380 " (declare (in ) vec4 x@0xb1d720)\n"
23381 " (declare (in ) vec4 y@0xb1d830)\n"
23382 " )\n"
23383 " (\n"
23384 " ))\n"
23385 "\n"
23386 " (signature bvec2\n"
23387 " (parameters\n"
23388 " (declare (in ) ivec2 x@0xb1da10)\n"
23389 " (declare (in ) ivec2 y@0xb1db20)\n"
23390 " )\n"
23391 " (\n"
23392 " ))\n"
23393 "\n"
23394 " (signature bvec3\n"
23395 " (parameters\n"
23396 " (declare (in ) ivec3 x@0xb1dd00)\n"
23397 " (declare (in ) ivec3 y@0xb1de10)\n"
23398 " )\n"
23399 " (\n"
23400 " ))\n"
23401 "\n"
23402 " (signature bvec4\n"
23403 " (parameters\n"
23404 " (declare (in ) ivec4 x@0xb1dff0)\n"
23405 " (declare (in ) ivec4 y@0xb1e100)\n"
23406 " )\n"
23407 " (\n"
23408 " ))\n"
23409 "\n"
23410 ")\n"
23411 "\n"
23412 "(function greaterThanEqual\n"
23413 " (signature bvec2\n"
23414 " (parameters\n"
23415 " (declare (in ) vec2 x@0xb1e2e0)\n"
23416 " (declare (in ) vec2 y@0xb1e3f0)\n"
23417 " )\n"
23418 " (\n"
23419 " ))\n"
23420 "\n"
23421 " (signature bvec3\n"
23422 " (parameters\n"
23423 " (declare (in ) vec3 x@0xb1e780)\n"
23424 " (declare (in ) vec3 y@0xb1e890)\n"
23425 " )\n"
23426 " (\n"
23427 " ))\n"
23428 "\n"
23429 " (signature bvec4\n"
23430 " (parameters\n"
23431 " (declare (in ) vec4 x@0xb1ea70)\n"
23432 " (declare (in ) vec4 y@0xb1eb80)\n"
23433 " )\n"
23434 " (\n"
23435 " ))\n"
23436 "\n"
23437 " (signature bvec2\n"
23438 " (parameters\n"
23439 " (declare (in ) ivec2 x@0xb1ed60)\n"
23440 " (declare (in ) ivec2 y@0xb1ee70)\n"
23441 " )\n"
23442 " (\n"
23443 " ))\n"
23444 "\n"
23445 " (signature bvec3\n"
23446 " (parameters\n"
23447 " (declare (in ) ivec3 x@0xb1f050)\n"
23448 " (declare (in ) ivec3 y@0xb1f160)\n"
23449 " )\n"
23450 " (\n"
23451 " ))\n"
23452 "\n"
23453 " (signature bvec4\n"
23454 " (parameters\n"
23455 " (declare (in ) ivec4 x@0xb1f340)\n"
23456 " (declare (in ) ivec4 y@0xb1f450)\n"
23457 " )\n"
23458 " (\n"
23459 " ))\n"
23460 "\n"
23461 ")\n"
23462 "\n"
23463 "(function equal\n"
23464 " (signature bvec2\n"
23465 " (parameters\n"
23466 " (declare (in ) vec2 x@0xb1f630)\n"
23467 " (declare (in ) vec2 y@0xb1f740)\n"
23468 " )\n"
23469 " (\n"
23470 " ))\n"
23471 "\n"
23472 " (signature bvec3\n"
23473 " (parameters\n"
23474 " (declare (in ) vec3 x@0xb1fac0)\n"
23475 " (declare (in ) vec3 y@0xb1fbd0)\n"
23476 " )\n"
23477 " (\n"
23478 " ))\n"
23479 "\n"
23480 " (signature bvec4\n"
23481 " (parameters\n"
23482 " (declare (in ) vec4 x@0xb1fdb0)\n"
23483 " (declare (in ) vec4 y@0xb1fec0)\n"
23484 " )\n"
23485 " (\n"
23486 " ))\n"
23487 "\n"
23488 " (signature bvec2\n"
23489 " (parameters\n"
23490 " (declare (in ) ivec2 x@0xb200a0)\n"
23491 " (declare (in ) ivec2 y@0xb201b0)\n"
23492 " )\n"
23493 " (\n"
23494 " ))\n"
23495 "\n"
23496 " (signature bvec3\n"
23497 " (parameters\n"
23498 " (declare (in ) ivec3 x@0xb20390)\n"
23499 " (declare (in ) ivec3 y@0xb204a0)\n"
23500 " )\n"
23501 " (\n"
23502 " ))\n"
23503 "\n"
23504 " (signature bvec4\n"
23505 " (parameters\n"
23506 " (declare (in ) ivec4 x@0xb20680)\n"
23507 " (declare (in ) ivec4 y@0xb20790)\n"
23508 " )\n"
23509 " (\n"
23510 " ))\n"
23511 "\n"
23512 " (signature bvec2\n"
23513 " (parameters\n"
23514 " (declare (in ) bvec2 x@0xb20970)\n"
23515 " (declare (in ) bvec2 y@0xb20a80)\n"
23516 " )\n"
23517 " (\n"
23518 " ))\n"
23519 "\n"
23520 " (signature bvec3\n"
23521 " (parameters\n"
23522 " (declare (in ) bvec3 x@0xb20c60)\n"
23523 " (declare (in ) bvec3 y@0xb20d70)\n"
23524 " )\n"
23525 " (\n"
23526 " ))\n"
23527 "\n"
23528 " (signature bvec4\n"
23529 " (parameters\n"
23530 " (declare (in ) bvec4 x@0xb20f50)\n"
23531 " (declare (in ) bvec4 y@0xb21060)\n"
23532 " )\n"
23533 " (\n"
23534 " ))\n"
23535 "\n"
23536 ")\n"
23537 "\n"
23538 "(function notEqual\n"
23539 " (signature bvec2\n"
23540 " (parameters\n"
23541 " (declare (in ) vec2 x@0xb21240)\n"
23542 " (declare (in ) vec2 y@0xb21350)\n"
23543 " )\n"
23544 " (\n"
23545 " ))\n"
23546 "\n"
23547 " (signature bvec3\n"
23548 " (parameters\n"
23549 " (declare (in ) vec3 x@0xb216e0)\n"
23550 " (declare (in ) vec3 y@0xb217f0)\n"
23551 " )\n"
23552 " (\n"
23553 " ))\n"
23554 "\n"
23555 " (signature bvec4\n"
23556 " (parameters\n"
23557 " (declare (in ) vec4 x@0xb219d0)\n"
23558 " (declare (in ) vec4 y@0xb21ae0)\n"
23559 " )\n"
23560 " (\n"
23561 " ))\n"
23562 "\n"
23563 " (signature bvec2\n"
23564 " (parameters\n"
23565 " (declare (in ) ivec2 x@0xb21cc0)\n"
23566 " (declare (in ) ivec2 y@0xb21dd0)\n"
23567 " )\n"
23568 " (\n"
23569 " ))\n"
23570 "\n"
23571 " (signature bvec3\n"
23572 " (parameters\n"
23573 " (declare (in ) ivec3 x@0xb21fb0)\n"
23574 " (declare (in ) ivec3 y@0xb220c0)\n"
23575 " )\n"
23576 " (\n"
23577 " ))\n"
23578 "\n"
23579 " (signature bvec4\n"
23580 " (parameters\n"
23581 " (declare (in ) ivec4 x@0xb222a0)\n"
23582 " (declare (in ) ivec4 y@0xb223b0)\n"
23583 " )\n"
23584 " (\n"
23585 " ))\n"
23586 "\n"
23587 " (signature bvec2\n"
23588 " (parameters\n"
23589 " (declare (in ) bvec2 x@0xb22590)\n"
23590 " (declare (in ) bvec2 y@0xb226a0)\n"
23591 " )\n"
23592 " (\n"
23593 " ))\n"
23594 "\n"
23595 " (signature bvec3\n"
23596 " (parameters\n"
23597 " (declare (in ) bvec3 x@0xb22880)\n"
23598 " (declare (in ) bvec3 y@0xb22990)\n"
23599 " )\n"
23600 " (\n"
23601 " ))\n"
23602 "\n"
23603 " (signature bvec4\n"
23604 " (parameters\n"
23605 " (declare (in ) bvec4 x@0xb22b70)\n"
23606 " (declare (in ) bvec4 y@0xb22c80)\n"
23607 " )\n"
23608 " (\n"
23609 " ))\n"
23610 "\n"
23611 ")\n"
23612 "\n"
23613 "(function any\n"
23614 " (signature bool\n"
23615 " (parameters\n"
23616 " (declare (in ) bvec2 x@0xb22e60)\n"
23617 " )\n"
23618 " (\n"
23619 " ))\n"
23620 "\n"
23621 " (signature bool\n"
23622 " (parameters\n"
23623 " (declare (in ) bvec3 x@0xb231e0)\n"
23624 " )\n"
23625 " (\n"
23626 " ))\n"
23627 "\n"
23628 " (signature bool\n"
23629 " (parameters\n"
23630 " (declare (in ) bvec4 x@0xb233c0)\n"
23631 " )\n"
23632 " (\n"
23633 " ))\n"
23634 "\n"
23635 ")\n"
23636 "\n"
23637 "(function all\n"
23638 " (signature bool\n"
23639 " (parameters\n"
23640 " (declare (in ) bvec2 x@0xb235a0)\n"
23641 " )\n"
23642 " (\n"
23643 " ))\n"
23644 "\n"
23645 " (signature bool\n"
23646 " (parameters\n"
23647 " (declare (in ) bvec3 x@0xb23920)\n"
23648 " )\n"
23649 " (\n"
23650 " ))\n"
23651 "\n"
23652 " (signature bool\n"
23653 " (parameters\n"
23654 " (declare (in ) bvec4 x@0xb23b00)\n"
23655 " )\n"
23656 " (\n"
23657 " ))\n"
23658 "\n"
23659 ")\n"
23660 "\n"
23661 "(function not\n"
23662 " (signature bvec2\n"
23663 " (parameters\n"
23664 " (declare (in ) bvec2 x@0xb23ce0)\n"
23665 " )\n"
23666 " (\n"
23667 " ))\n"
23668 "\n"
23669 " (signature bvec3\n"
23670 " (parameters\n"
23671 " (declare (in ) bvec3 x@0xb24060)\n"
23672 " )\n"
23673 " (\n"
23674 " ))\n"
23675 "\n"
23676 " (signature bvec4\n"
23677 " (parameters\n"
23678 " (declare (in ) bvec4 x@0xb24240)\n"
23679 " )\n"
23680 " (\n"
23681 " ))\n"
23682 "\n"
23683 ")\n"
23684 "\n"
23685 "(function texture1D\n"
23686 " (signature vec4\n"
23687 " (parameters\n"
23688 " (declare (in ) sampler1D sampler@0xb24420)\n"
23689 " (declare (in ) float coord@0xb24530)\n"
23690 " )\n"
23691 " (\n"
23692 " ))\n"
23693 "\n"
23694 " (signature vec4\n"
23695 " (parameters\n"
23696 " (declare (in ) sampler1D sampler@0xb25050)\n"
23697 " (declare (in ) float coord@0xb25160)\n"
23698 " (declare (in ) float bias@0xb25270)\n"
23699 " )\n"
23700 " (\n"
23701 " ))\n"
23702 "\n"
23703 ")\n"
23704 "\n"
23705 "(function texture1DProj\n"
23706 " (signature vec4\n"
23707 " (parameters\n"
23708 " (declare (in ) sampler1D sampler@0xb248c0)\n"
23709 " (declare (in ) vec2 coord@0xb249d0)\n"
23710 " )\n"
23711 " (\n"
23712 " ))\n"
23713 "\n"
23714 " (signature vec4\n"
23715 " (parameters\n"
23716 " (declare (in ) sampler1D sampler@0xb24d60)\n"
23717 " (declare (in ) vec4 coord@0xb24e70)\n"
23718 " )\n"
23719 " (\n"
23720 " ))\n"
23721 "\n"
23722 " (signature vec4\n"
23723 " (parameters\n"
23724 " (declare (in ) sampler1D sampler@0xb25450)\n"
23725 " (declare (in ) vec2 coord@0xb25560)\n"
23726 " (declare (in ) float bias@0xb25670)\n"
23727 " )\n"
23728 " (\n"
23729 " ))\n"
23730 "\n"
23731 " (signature vec4\n"
23732 " (parameters\n"
23733 " (declare (in ) sampler1D sampler@0xb25850)\n"
23734 " (declare (in ) vec4 coord@0xb25960)\n"
23735 " (declare (in ) float bias@0xb25a70)\n"
23736 " )\n"
23737 " (\n"
23738 " ))\n"
23739 "\n"
23740 ")\n"
23741 "\n"
23742 "(function texture2D\n"
23743 " (signature vec4\n"
23744 " (parameters\n"
23745 " (declare (in ) sampler2D sampler@0xb25c50)\n"
23746 " (declare (in ) vec2 coord@0xb25d60)\n"
23747 " )\n"
23748 " (\n"
23749 " ))\n"
23750 "\n"
23751 " (signature vec4\n"
23752 " (parameters\n"
23753 " (declare (in ) sampler2D sampler@0xb26880)\n"
23754 " (declare (in ) vec2 coord@0xb26990)\n"
23755 " (declare (in ) float bias@0xb26aa0)\n"
23756 " )\n"
23757 " (\n"
23758 " ))\n"
23759 "\n"
23760 ")\n"
23761 "\n"
23762 "(function texture2DProj\n"
23763 " (signature vec4\n"
23764 " (parameters\n"
23765 " (declare (in ) sampler2D sampler@0xb260f0)\n"
23766 " (declare (in ) vec3 coord@0xb26200)\n"
23767 " )\n"
23768 " (\n"
23769 " ))\n"
23770 "\n"
23771 " (signature vec4\n"
23772 " (parameters\n"
23773 " (declare (in ) sampler2D sampler@0xb26590)\n"
23774 " (declare (in ) vec4 coord@0xb266a0)\n"
23775 " )\n"
23776 " (\n"
23777 " ))\n"
23778 "\n"
23779 " (signature vec4\n"
23780 " (parameters\n"
23781 " (declare (in ) sampler2D sampler@0xb26c80)\n"
23782 " (declare (in ) vec3 coord@0xb26d90)\n"
23783 " (declare (in ) float bias@0xb26ea0)\n"
23784 " )\n"
23785 " (\n"
23786 " ))\n"
23787 "\n"
23788 " (signature vec4\n"
23789 " (parameters\n"
23790 " (declare (in ) sampler2D sampler@0xb27080)\n"
23791 " (declare (in ) vec4 coord@0xb27190)\n"
23792 " (declare (in ) float bias@0xb272a0)\n"
23793 " )\n"
23794 " (\n"
23795 " ))\n"
23796 "\n"
23797 ")\n"
23798 "\n"
23799 "(function texture3D\n"
23800 " (signature vec4\n"
23801 " (parameters\n"
23802 " (declare (in ) sampler3D sampler@0xb27480)\n"
23803 " (declare (in ) vec3 coord@0xb27590)\n"
23804 " )\n"
23805 " (\n"
23806 " ))\n"
23807 "\n"
23808 " (signature vec4\n"
23809 " (parameters\n"
23810 " (declare (in ) sampler3D sampler@0xb27dc0)\n"
23811 " (declare (in ) vec3 coord@0xb27ed0)\n"
23812 " (declare (in ) float bias@0xb27fe0)\n"
23813 " )\n"
23814 " (\n"
23815 " ))\n"
23816 "\n"
23817 ")\n"
23818 "\n"
23819 "(function texture3DProj\n"
23820 " (signature vec4\n"
23821 " (parameters\n"
23822 " (declare (in ) sampler3D sampler@0xb27920)\n"
23823 " (declare (in ) vec4 coord@0xb27a30)\n"
23824 " )\n"
23825 " (\n"
23826 " ))\n"
23827 "\n"
23828 " (signature vec4\n"
23829 " (parameters\n"
23830 " (declare (in ) sampler3D sampler@0xb281c0)\n"
23831 " (declare (in ) vec4 coord@0xb282d0)\n"
23832 " (declare (in ) float bias@0xb283e0)\n"
23833 " )\n"
23834 " (\n"
23835 " ))\n"
23836 "\n"
23837 ")\n"
23838 "\n"
23839 "(function textureCube\n"
23840 " (signature vec4\n"
23841 " (parameters\n"
23842 " (declare (in ) samplerCube sampler@0xb285c0)\n"
23843 " (declare (in ) vec3 coord@0xb286d0)\n"
23844 " )\n"
23845 " (\n"
23846 " ))\n"
23847 "\n"
23848 " (signature vec4\n"
23849 " (parameters\n"
23850 " (declare (in ) samplerCube sampler@0xb28a60)\n"
23851 " (declare (in ) vec3 coord@0xb28b70)\n"
23852 " (declare (in ) float bias@0xb28c80)\n"
23853 " )\n"
23854 " (\n"
23855 " ))\n"
23856 "\n"
23857 ")\n"
23858 "\n"
23859 "(function shadow1D\n"
23860 " (signature vec4\n"
23861 " (parameters\n"
23862 " (declare (in ) sampler1DShadow sampler@0xb28e60)\n"
23863 " (declare (in ) vec3 coord@0xb28f70)\n"
23864 " )\n"
23865 " (\n"
23866 " ))\n"
23867 "\n"
23868 " (signature vec4\n"
23869 " (parameters\n"
23870 " (declare (in ) sampler1DShadow sampler@0xb2a0e0)\n"
23871 " (declare (in ) vec3 coord@0xb2a1f0)\n"
23872 " (declare (in ) float bias@0xb2a300)\n"
23873 " )\n"
23874 " (\n"
23875 " ))\n"
23876 "\n"
23877 ")\n"
23878 "\n"
23879 "(function shadow2D\n"
23880 " (signature vec4\n"
23881 " (parameters\n"
23882 " (declare (in ) sampler2DShadow sampler@0xb29300)\n"
23883 " (declare (in ) vec3 coord@0xb29410)\n"
23884 " )\n"
23885 " (\n"
23886 " ))\n"
23887 "\n"
23888 " (signature vec4\n"
23889 " (parameters\n"
23890 " (declare (in ) sampler2DShadow sampler@0xb2a4e0)\n"
23891 " (declare (in ) vec3 coord@0xb2a5f0)\n"
23892 " (declare (in ) float bias@0xb2a700)\n"
23893 " )\n"
23894 " (\n"
23895 " ))\n"
23896 "\n"
23897 ")\n"
23898 "\n"
23899 "(function shadow1DProj\n"
23900 " (signature vec4\n"
23901 " (parameters\n"
23902 " (declare (in ) sampler1DShadow sampler@0xb297a0)\n"
23903 " (declare (in ) vec4 coord@0xb298b0)\n"
23904 " )\n"
23905 " (\n"
23906 " ))\n"
23907 "\n"
23908 " (signature vec4\n"
23909 " (parameters\n"
23910 " (declare (in ) sampler1DShadow sampler@0xb2a8e0)\n"
23911 " (declare (in ) vec4 coord@0xb2a9f0)\n"
23912 " (declare (in ) float bias@0xb2ab00)\n"
23913 " )\n"
23914 " (\n"
23915 " ))\n"
23916 "\n"
23917 ")\n"
23918 "\n"
23919 "(function shadow2DProj\n"
23920 " (signature vec4\n"
23921 " (parameters\n"
23922 " (declare (in ) sampler2DShadow sampler@0xb29c40)\n"
23923 " (declare (in ) vec4 coord@0xb29d50)\n"
23924 " )\n"
23925 " (\n"
23926 " ))\n"
23927 "\n"
23928 " (signature vec4\n"
23929 " (parameters\n"
23930 " (declare (in ) sampler2DShadow sampler@0xb2ace0)\n"
23931 " (declare (in ) vec4 coord@0xb2adf0)\n"
23932 " (declare (in ) float bias@0xb2af00)\n"
23933 " )\n"
23934 " (\n"
23935 " ))\n"
23936 "\n"
23937 ")\n"
23938 "\n"
23939 "(function dFdx\n"
23940 " (signature float\n"
23941 " (parameters\n"
23942 " (declare (in ) float p@0xb2b0e0)\n"
23943 " )\n"
23944 " (\n"
23945 " ))\n"
23946 "\n"
23947 " (signature vec2\n"
23948 " (parameters\n"
23949 " (declare (in ) vec2 p@0xb2b460)\n"
23950 " )\n"
23951 " (\n"
23952 " ))\n"
23953 "\n"
23954 " (signature vec3\n"
23955 " (parameters\n"
23956 " (declare (in ) vec3 p@0xb2b640)\n"
23957 " )\n"
23958 " (\n"
23959 " ))\n"
23960 "\n"
23961 " (signature vec4\n"
23962 " (parameters\n"
23963 " (declare (in ) vec4 p@0xb2b820)\n"
23964 " )\n"
23965 " (\n"
23966 " ))\n"
23967 "\n"
23968 ")\n"
23969 "\n"
23970 "(function dFdy\n"
23971 " (signature float\n"
23972 " (parameters\n"
23973 " (declare (in ) float p@0xb2ba00)\n"
23974 " )\n"
23975 " (\n"
23976 " ))\n"
23977 "\n"
23978 " (signature vec2\n"
23979 " (parameters\n"
23980 " (declare (in ) vec2 p@0xb2bd80)\n"
23981 " )\n"
23982 " (\n"
23983 " ))\n"
23984 "\n"
23985 " (signature vec3\n"
23986 " (parameters\n"
23987 " (declare (in ) vec3 p@0xb2bf60)\n"
23988 " )\n"
23989 " (\n"
23990 " ))\n"
23991 "\n"
23992 " (signature vec4\n"
23993 " (parameters\n"
23994 " (declare (in ) vec4 p@0xb2c140)\n"
23995 " )\n"
23996 " (\n"
23997 " ))\n"
23998 "\n"
23999 ")\n"
24000 "\n"
24001 "(function fwidth\n"
24002 " (signature float\n"
24003 " (parameters\n"
24004 " (declare (in ) float p@0xb2c320)\n"
24005 " )\n"
24006 " (\n"
24007 " ))\n"
24008 "\n"
24009 " (signature vec2\n"
24010 " (parameters\n"
24011 " (declare (in ) vec2 p@0xb2c6a0)\n"
24012 " )\n"
24013 " (\n"
24014 " ))\n"
24015 "\n"
24016 " (signature vec3\n"
24017 " (parameters\n"
24018 " (declare (in ) vec3 p@0xb2c880)\n"
24019 " )\n"
24020 " (\n"
24021 " ))\n"
24022 "\n"
24023 " (signature vec4\n"
24024 " (parameters\n"
24025 " (declare (in ) vec4 p@0xb2ca60)\n"
24026 " )\n"
24027 " (\n"
24028 " ))\n"
24029 "\n"
24030 ")\n"
24031 "\n"
24032 "(function noise1\n"
24033 " (signature float\n"
24034 " (parameters\n"
24035 " (declare (in ) float x@0xb2cc40)\n"
24036 " )\n"
24037 " (\n"
24038 " ))\n"
24039 "\n"
24040 " (signature float\n"
24041 " (parameters\n"
24042 " (declare (in ) vec2 x@0xb2cfc0)\n"
24043 " )\n"
24044 " (\n"
24045 " ))\n"
24046 "\n"
24047 " (signature float\n"
24048 " (parameters\n"
24049 " (declare (in ) vec3 x@0xb2d1a0)\n"
24050 " )\n"
24051 " (\n"
24052 " ))\n"
24053 "\n"
24054 " (signature float\n"
24055 " (parameters\n"
24056 " (declare (in ) vec4 x@0xb2d380)\n"
24057 " )\n"
24058 " (\n"
24059 " ))\n"
24060 "\n"
24061 ")\n"
24062 "\n"
24063 "(function noise2\n"
24064 " (signature vec2\n"
24065 " (parameters\n"
24066 " (declare (in ) float x@0xb2d560)\n"
24067 " )\n"
24068 " (\n"
24069 " ))\n"
24070 "\n"
24071 " (signature vec2\n"
24072 " (parameters\n"
24073 " (declare (in ) vec2 x@0xb2d8e0)\n"
24074 " )\n"
24075 " (\n"
24076 " ))\n"
24077 "\n"
24078 " (signature vec2\n"
24079 " (parameters\n"
24080 " (declare (in ) vec3 x@0xb2dac0)\n"
24081 " )\n"
24082 " (\n"
24083 " ))\n"
24084 "\n"
24085 " (signature vec2\n"
24086 " (parameters\n"
24087 " (declare (in ) vec4 x@0xb2dca0)\n"
24088 " )\n"
24089 " (\n"
24090 " ))\n"
24091 "\n"
24092 ")\n"
24093 "\n"
24094 "(function noise3\n"
24095 " (signature vec3\n"
24096 " (parameters\n"
24097 " (declare (in ) float x@0xb2de80)\n"
24098 " )\n"
24099 " (\n"
24100 " ))\n"
24101 "\n"
24102 " (signature vec3\n"
24103 " (parameters\n"
24104 " (declare (in ) vec2 x@0xb2e200)\n"
24105 " )\n"
24106 " (\n"
24107 " ))\n"
24108 "\n"
24109 " (signature vec3\n"
24110 " (parameters\n"
24111 " (declare (in ) vec3 x@0xb2e3e0)\n"
24112 " )\n"
24113 " (\n"
24114 " ))\n"
24115 "\n"
24116 " (signature vec3\n"
24117 " (parameters\n"
24118 " (declare (in ) vec4 x@0xb2e5c0)\n"
24119 " )\n"
24120 " (\n"
24121 " ))\n"
24122 "\n"
24123 ")\n"
24124 "\n"
24125 "(function noise4\n"
24126 " (signature vec4\n"
24127 " (parameters\n"
24128 " (declare (in ) float x@0xb2e7a0)\n"
24129 " )\n"
24130 " (\n"
24131 " ))\n"
24132 "\n"
24133 " (signature vec4\n"
24134 " (parameters\n"
24135 " (declare (in ) vec2 x@0xb2eb20)\n"
24136 " )\n"
24137 " (\n"
24138 " ))\n"
24139 "\n"
24140 " (signature vec4\n"
24141 " (parameters\n"
24142 " (declare (in ) vec3 x@0xb2ed00)\n"
24143 " )\n"
24144 " (\n"
24145 " ))\n"
24146 "\n"
24147 " (signature vec4\n"
24148 " (parameters\n"
24149 " (declare (in ) vec4 x@0xb2eee0)\n"
24150 " )\n"
24151 " (\n"
24152 " ))\n"
24153 "\n"
24154 ")\n"
24155 "\n"
24156 "\n"
24157 ")"
24158;
24159static const char *functions_for_120_frag [] = {
24160 builtin_clamp,
24161 builtin_matrixCompMult,
24162 builtin_noise2,
24163 builtin_pow,
24164 builtin_texture2DProj,
24165 builtin_fwidth,
24166 builtin_greaterThanEqual,
24167 builtin_sign,
24168 builtin_texture3DProj,
24169 builtin_texture2D,
24170 builtin_equal,
24171 builtin_faceforward,
24172 builtin_tan,
24173 builtin_any,
24174 builtin_shadow1DProj,
24175 builtin_normalize,
24176 builtin_asin,
24177 builtin_texture1DProj,
24178 builtin_log,
24179 builtin_floor,
24180 builtin_exp2,
24181 builtin_lessThan,
24182 builtin_cross,
24183 builtin_sqrt,
24184 builtin_shadow2DProj,
24185 builtin_fract,
24186 builtin_abs,
24187 builtin_degrees,
24188 builtin_dFdx,
24189 builtin_sin,
24190 builtin_shadow2D,
24191 builtin_all,
24192 builtin_log2,
24193 builtin_atan,
24194 builtin_notEqual,
24195 builtin_max,
24196 builtin_lessThanEqual,
24197 builtin_transpose,
24198 builtin_outerProduct,
24199 builtin_ceil,
24200 builtin_reflect,
24201 builtin_step,
24202 builtin_texture1D,
24203 builtin_greaterThan,
24204 builtin_texture3D,
24205 builtin_not,
24206 builtin_inversesqrt,
24207 builtin_mod,
24208 builtin_noise4,
24209 builtin_distance,
24210 builtin_cos,
24211 builtin_shadow1D,
24212 builtin_noise1,
24213 builtin_refract,
24214 builtin_noise3,
24215 builtin_min,
24216 builtin_radians,
24217 builtin_smoothstep,
24218 builtin_textureCube,
24219 builtin_length,
24220 builtin_dFdy,
24221 builtin_exp,
24222 builtin_acos,
24223 builtin_mix,
24224 builtin_dot,
24225};
24226
24227void *builtin_mem_ctx = NULL;
24228
24229void
24230_mesa_glsl_release_functions(void)
24231{
24232 talloc_free(builtin_mem_ctx);
24233}
24234
24235void
24236_mesa_glsl_initialize_functions(exec_list *instructions,
24237 struct _mesa_glsl_parse_state *state)
24238{
24239 if (builtin_mem_ctx == NULL)
24240 builtin_mem_ctx = talloc_init("GLSL built-in functions");
24241
24242 state->num_builtins_to_link = 0;
24243
24244 if (state->target == vertex_shader && state->language_version == 120) {
24245 static gl_shader *sh = NULL;
24246 if (sh == NULL) {
24247 sh = read_builtins(GL_VERTEX_SHADER,
24248 prototypes_for_120_vert,
24249 functions_for_120_vert,
24250 Elements(functions_for_120_vert ));
24251 talloc_steal(builtin_mem_ctx, sh);
24252 }
24253
24254 import_prototypes(sh->ir, instructions, state->symbols,
24255 state);
24256 state->builtins_to_link[state->num_builtins_to_link] = sh;
24257 state->num_builtins_to_link++;
24258 }
24259
24260 if (state->target == fragment_shader && state->EXT_texture_array_enable) {
24261 static gl_shader *sh = NULL;
24262 if (sh == NULL) {
24263 sh = read_builtins(GL_VERTEX_SHADER,
24264 prototypes_for_EXT_texture_array_frag,
24265 functions_for_EXT_texture_array_frag,
24266 Elements(functions_for_EXT_texture_array_frag ));
24267 talloc_steal(builtin_mem_ctx, sh);
24268 }
24269
24270 import_prototypes(sh->ir, instructions, state->symbols,
24271 state);
24272 state->builtins_to_link[state->num_builtins_to_link] = sh;
24273 state->num_builtins_to_link++;
24274 }
24275
24276 if (state->target == vertex_shader && state->language_version == 110) {
24277 static gl_shader *sh = NULL;
24278 if (sh == NULL) {
24279 sh = read_builtins(GL_VERTEX_SHADER,
24280 prototypes_for_110_vert,
24281 functions_for_110_vert,
24282 Elements(functions_for_110_vert ));
24283 talloc_steal(builtin_mem_ctx, sh);
24284 }
24285
24286 import_prototypes(sh->ir, instructions, state->symbols,
24287 state);
24288 state->builtins_to_link[state->num_builtins_to_link] = sh;
24289 state->num_builtins_to_link++;
24290 }
24291
24292 if (state->target == fragment_shader && state->language_version == 110) {
24293 static gl_shader *sh = NULL;
24294 if (sh == NULL) {
24295 sh = read_builtins(GL_VERTEX_SHADER,
24296 prototypes_for_110_frag,
24297 functions_for_110_frag,
24298 Elements(functions_for_110_frag ));
24299 talloc_steal(builtin_mem_ctx, sh);
24300 }
24301
24302 import_prototypes(sh->ir, instructions, state->symbols,
24303 state);
24304 state->builtins_to_link[state->num_builtins_to_link] = sh;
24305 state->num_builtins_to_link++;
24306 }
24307
24308 if (state->target == vertex_shader && state->EXT_texture_array_enable) {
24309 static gl_shader *sh = NULL;
24310 if (sh == NULL) {
24311 sh = read_builtins(GL_VERTEX_SHADER,
24312 prototypes_for_EXT_texture_array_vert,
24313 functions_for_EXT_texture_array_vert,
24314 Elements(functions_for_EXT_texture_array_vert ));
24315 talloc_steal(builtin_mem_ctx, sh);
24316 }
24317
24318 import_prototypes(sh->ir, instructions, state->symbols,
24319 state);
24320 state->builtins_to_link[state->num_builtins_to_link] = sh;
24321 state->num_builtins_to_link++;
24322 }
24323
24324 if (state->target == fragment_shader && state->language_version == 130) {
24325 static gl_shader *sh = NULL;
24326 if (sh == NULL) {
24327 sh = read_builtins(GL_VERTEX_SHADER,
24328 prototypes_for_130_frag,
24329 functions_for_130_frag,
24330 Elements(functions_for_130_frag ));
24331 talloc_steal(builtin_mem_ctx, sh);
24332 }
24333
24334 import_prototypes(sh->ir, instructions, state->symbols,
24335 state);
24336 state->builtins_to_link[state->num_builtins_to_link] = sh;
24337 state->num_builtins_to_link++;
24338 }
24339
24340 if (state->target == vertex_shader && state->ARB_texture_rectangle_enable) {
24341 static gl_shader *sh = NULL;
24342 if (sh == NULL) {
24343 sh = read_builtins(GL_VERTEX_SHADER,
24344 prototypes_for_ARB_texture_rectangle_vert,
24345 functions_for_ARB_texture_rectangle_vert,
24346 Elements(functions_for_ARB_texture_rectangle_vert ));
24347 talloc_steal(builtin_mem_ctx, sh);
24348 }
24349
24350 import_prototypes(sh->ir, instructions, state->symbols,
24351 state);
24352 state->builtins_to_link[state->num_builtins_to_link] = sh;
24353 state->num_builtins_to_link++;
24354 }
24355
24356 if (state->target == vertex_shader && state->language_version == 130) {
24357 static gl_shader *sh = NULL;
24358 if (sh == NULL) {
24359 sh = read_builtins(GL_VERTEX_SHADER,
24360 prototypes_for_130_vert,
24361 functions_for_130_vert,
24362 Elements(functions_for_130_vert ));
24363 talloc_steal(builtin_mem_ctx, sh);
24364 }
24365
24366 import_prototypes(sh->ir, instructions, state->symbols,
24367 state);
24368 state->builtins_to_link[state->num_builtins_to_link] = sh;
24369 state->num_builtins_to_link++;
24370 }
24371
24372 if (state->target == fragment_shader && state->ARB_texture_rectangle_enable) {
24373 static gl_shader *sh = NULL;
24374 if (sh == NULL) {
24375 sh = read_builtins(GL_VERTEX_SHADER,
24376 prototypes_for_ARB_texture_rectangle_frag,
24377 functions_for_ARB_texture_rectangle_frag,
24378 Elements(functions_for_ARB_texture_rectangle_frag ));
24379 talloc_steal(builtin_mem_ctx, sh);
24380 }
24381
24382 import_prototypes(sh->ir, instructions, state->symbols,
24383 state);
24384 state->builtins_to_link[state->num_builtins_to_link] = sh;
24385 state->num_builtins_to_link++;
24386 }
24387
24388 if (state->target == fragment_shader && state->language_version == 120) {
24389 static gl_shader *sh = NULL;
24390 if (sh == NULL) {
24391 sh = read_builtins(GL_VERTEX_SHADER,
24392 prototypes_for_120_frag,
24393 functions_for_120_frag,
24394 Elements(functions_for_120_frag ));
24395 talloc_steal(builtin_mem_ctx, sh);
24396 }
24397
24398 import_prototypes(sh->ir, instructions, state->symbols,
24399 state);
24400 state->builtins_to_link[state->num_builtins_to_link] = sh;
24401 state->num_builtins_to_link++;
24402 }
24403
24404}
diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h
new file mode 100644
index 00000000000..7b94aac666b
--- /dev/null
+++ b/src/glsl/builtin_types.h
@@ -0,0 +1,290 @@
1/*
2 * Copyright © 2009 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24const glsl_type glsl_type::_error_type =
25 glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, "");
26
27const glsl_type glsl_type::void_type =
28 glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void");
29
30const glsl_type *const glsl_type::error_type = & glsl_type::_error_type;
31
32/** \name Core built-in types
33 *
34 * These types exist in all versions of GLSL.
35 */
36/*@{*/
37
38const glsl_type glsl_type::builtin_core_types[] = {
39 glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"),
40 glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"),
41 glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"),
42 glsl_type(GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1, "bvec4"),
43 glsl_type(GL_INT, GLSL_TYPE_INT, 1, 1, "int"),
44 glsl_type(GL_INT_VEC2, GLSL_TYPE_INT, 2, 1, "ivec2"),
45 glsl_type(GL_INT_VEC3, GLSL_TYPE_INT, 3, 1, "ivec3"),
46 glsl_type(GL_INT_VEC4, GLSL_TYPE_INT, 4, 1, "ivec4"),
47 glsl_type(GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1, "float"),
48 glsl_type(GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1, "vec2"),
49 glsl_type(GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1, "vec3"),
50 glsl_type(GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1, "vec4"),
51 glsl_type(GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2, "mat2"),
52 glsl_type(GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3, "mat3"),
53 glsl_type(GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4, "mat4"),
54 glsl_type(GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT,
55 "sampler1D"),
56 glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT,
57 "sampler1DShadow"),
58 glsl_type(GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT,
59 "sampler2D"),
60 glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT,
61 "sampler2DShadow"),
62 glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT,
63 "sampler3D"),
64 glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT,
65 "samplerCube"),
66};
67
68const glsl_type *const glsl_type::bool_type = & builtin_core_types[0];
69const glsl_type *const glsl_type::int_type = & builtin_core_types[4];
70const glsl_type *const glsl_type::ivec4_type = & builtin_core_types[7];
71const glsl_type *const glsl_type::float_type = & builtin_core_types[8];
72const glsl_type *const glsl_type::vec2_type = & builtin_core_types[9];
73const glsl_type *const glsl_type::vec3_type = & builtin_core_types[10];
74const glsl_type *const glsl_type::vec4_type = & builtin_core_types[11];
75const glsl_type *const glsl_type::mat2_type = & builtin_core_types[12];
76const glsl_type *const glsl_type::mat3_type = & builtin_core_types[13];
77const glsl_type *const glsl_type::mat4_type = & builtin_core_types[14];
78/*@}*/
79
80/** \name GLSL structures that have not been deprecated.
81 */
82/*@{*/
83
84static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
85 { glsl_type::float_type, "near" },
86 { glsl_type::float_type, "far" },
87 { glsl_type::float_type, "diff" },
88};
89
90const glsl_type glsl_type::builtin_structure_types[] = {
91 glsl_type(gl_DepthRangeParameters_fields,
92 Elements(gl_DepthRangeParameters_fields),
93 "gl_DepthRangeParameters"),
94};
95/*@}*/
96
97/** \name GLSL 1.00 / 1.10 structures that are deprecated in GLSL 1.30
98 */
99/*@{*/
100
101static const struct glsl_struct_field gl_PointParameters_fields[] = {
102 { glsl_type::float_type, "size" },
103 { glsl_type::float_type, "sizeMin" },
104 { glsl_type::float_type, "sizeMax" },
105 { glsl_type::float_type, "fadeThresholdSize" },
106 { glsl_type::float_type, "distanceConstantAttenuation" },
107 { glsl_type::float_type, "distanceLinearAttenuation" },
108 { glsl_type::float_type, "distanceQuadraticAttenuation" },
109};
110
111static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
112 { glsl_type::vec4_type, "emission" },
113 { glsl_type::vec4_type, "ambient" },
114 { glsl_type::vec4_type, "diffuse" },
115 { glsl_type::vec4_type, "specular" },
116 { glsl_type::float_type, "shininess" },
117};
118
119static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
120 { glsl_type::vec4_type, "ambient" },
121 { glsl_type::vec4_type, "diffuse" },
122 { glsl_type::vec4_type, "specular" },
123 { glsl_type::vec4_type, "position" },
124 { glsl_type::vec4_type, "halfVector" },
125 { glsl_type::vec3_type, "spotDirection" },
126 { glsl_type::float_type, "spotExponent" },
127 { glsl_type::float_type, "spotCutoff" },
128 { glsl_type::float_type, "spotCosCutoff" },
129 { glsl_type::float_type, "constantAttenuation" },
130 { glsl_type::float_type, "linearAttenuation" },
131 { glsl_type::float_type, "quadraticAttenuation" },
132};
133
134static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
135 { glsl_type::vec4_type, "ambient" },
136};
137
138static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
139 { glsl_type::vec4_type, "sceneColor" },
140};
141
142static const struct glsl_struct_field gl_LightProducts_fields[] = {
143 { glsl_type::vec4_type, "ambient" },
144 { glsl_type::vec4_type, "diffuse" },
145 { glsl_type::vec4_type, "specular" },
146};
147
148static const struct glsl_struct_field gl_FogParameters_fields[] = {
149 { glsl_type::vec4_type, "color" },
150 { glsl_type::float_type, "density" },
151 { glsl_type::float_type, "start" },
152 { glsl_type::float_type, "end" },
153 { glsl_type::float_type, "scale" },
154};
155
156const glsl_type glsl_type::builtin_110_deprecated_structure_types[] = {
157 glsl_type(gl_PointParameters_fields,
158 Elements(gl_PointParameters_fields),
159 "gl_PointParameters"),
160 glsl_type(gl_MaterialParameters_fields,
161 Elements(gl_MaterialParameters_fields),
162 "gl_MaterialParameters"),
163 glsl_type(gl_LightSourceParameters_fields,
164 Elements(gl_LightSourceParameters_fields),
165 "gl_LightSourceParameters"),
166 glsl_type(gl_LightModelParameters_fields,
167 Elements(gl_LightModelParameters_fields),
168 "gl_LightModelParameters"),
169 glsl_type(gl_LightModelProducts_fields,
170 Elements(gl_LightModelProducts_fields),
171 "gl_LightModelProducts"),
172 glsl_type(gl_LightProducts_fields,
173 Elements(gl_LightProducts_fields),
174 "gl_LightProducts"),
175 glsl_type(gl_FogParameters_fields,
176 Elements(gl_FogParameters_fields),
177 "gl_FogParameters"),
178};
179/*@}*/
180
181/** \name Types added in GLSL 1.20
182 */
183/*@{*/
184
185const glsl_type glsl_type::builtin_120_types[] = {
186 glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"),
187 glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"),
188 glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"),
189 glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"),
190 glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"),
191 glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"),
192};
193const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0];
194const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1];
195const glsl_type *const glsl_type::mat3x2_type = & builtin_120_types[2];
196const glsl_type *const glsl_type::mat3x4_type = & builtin_120_types[3];
197const glsl_type *const glsl_type::mat4x2_type = & builtin_120_types[4];
198const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5];
199/*@}*/
200
201/** \name Types added in GLSL 1.30
202 */
203/*@{*/
204
205const glsl_type glsl_type::builtin_130_types[] = {
206 glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"),
207 glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"),
208 glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"),
209 glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"),
210
211 /* 1D and 2D texture arrays - several of these are included only in
212 * builtin_EXT_texture_array_types.
213 */
214 glsl_type(GL_INT_SAMPLER_1D_ARRAY,
215 GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"),
216 glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY,
217 GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"),
218 glsl_type(GL_INT_SAMPLER_2D_ARRAY,
219 GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"),
220 glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY,
221 GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"),
222
223 /* cube shadow samplers */
224 glsl_type(GL_SAMPLER_CUBE_SHADOW,
225 GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"),
226
227 /* signed and unsigned integer samplers */
228 glsl_type(GL_INT_SAMPLER_1D,
229 GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"),
230 glsl_type(GL_UNSIGNED_INT_SAMPLER_1D,
231 GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"),
232 glsl_type(GL_INT_SAMPLER_2D,
233 GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"),
234 glsl_type(GL_UNSIGNED_INT_SAMPLER_2D,
235 GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"),
236 glsl_type(GL_INT_SAMPLER_3D,
237 GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"),
238 glsl_type(GL_UNSIGNED_INT_SAMPLER_3D,
239 GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"),
240 glsl_type(GL_INT_SAMPLER_CUBE,
241 GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"),
242 glsl_type(GL_INT_SAMPLER_CUBE,
243 GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"),
244};
245
246const glsl_type *const glsl_type::uint_type = & builtin_130_types[0];
247const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3];
248/*@}*/
249
250/** \name Sampler types added by GL_ARB_texture_rectangle
251 */
252/*@{*/
253
254const glsl_type glsl_type::builtin_ARB_texture_rectangle_types[] = {
255 glsl_type(GL_SAMPLER_2D_RECT,
256 GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"),
257 glsl_type(GL_SAMPLER_2D_RECT_SHADOW,
258 GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"),
259};
260/*@}*/
261
262/** \name Sampler types added by GL_EXT_texture_array
263 */
264/*@{*/
265
266const glsl_type glsl_type::builtin_EXT_texture_array_types[] = {
267 glsl_type(GL_SAMPLER_1D_ARRAY,
268 GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"),
269 glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW,
270 GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"),
271 glsl_type(GL_SAMPLER_2D_ARRAY,
272 GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"),
273 glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW,
274 GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"),
275};
276/*@}*/
277
278/** \name Sampler types added by GL_EXT_texture_buffer_object
279 */
280/*@{*/
281
282const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = {
283 glsl_type(GL_SAMPLER_BUFFER,
284 GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"),
285 glsl_type(GL_INT_SAMPLER_BUFFER,
286 GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"),
287 glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER,
288 GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"),
289};
290/*@}*/
diff --git a/src/glsl/builtin_variables.h b/src/glsl/builtin_variables.h
new file mode 100644
index 00000000000..2ec7d621bbf
--- /dev/null
+++ b/src/glsl/builtin_variables.h
@@ -0,0 +1,98 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "main/mtypes.h"
25
26struct builtin_variable {
27 enum ir_variable_mode mode;
28 int slot;
29 const char *type;
30 const char *name;
31};
32
33static const builtin_variable builtin_core_vs_variables[] = {
34 { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" },
35 { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" },
36};
37
38static const builtin_variable builtin_core_fs_variables[] = {
39 { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" },
40 { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" },
41 { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" },
42 { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" },
43};
44
45static const builtin_variable builtin_110_deprecated_fs_variables[] = {
46 { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" },
47 { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" },
48 { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" },
49};
50
51static const builtin_variable builtin_110_deprecated_vs_variables[] = {
52 { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" },
53 { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" },
54 { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" },
55 { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" },
56 { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" },
57 { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" },
58 { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" },
59 { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" },
60 { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" },
61 { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" },
62 { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" },
63 { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" },
64 { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" },
65 { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_ClipVertex" },
66 { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" },
67 { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" },
68 { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" },
69 { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" },
70 { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" },
71};
72
73static const builtin_variable builtin_120_fs_variables[] = {
74 { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" },
75};
76
77static const builtin_variable builtin_130_vs_variables[] = {
78 { ir_var_in, -1, "int", "gl_VertexID" },
79};
80
81static const builtin_variable builtin_110_deprecated_uniforms[] = {
82 { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" },
83 { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" },
84 { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" },
85 { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" },
86 { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" },
87 { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" },
88 { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" },
89 { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" },
90 { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" },
91 { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" },
92 { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" },
93 { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" },
94 { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" },
95 { ir_var_uniform, -1, "float", "gl_NormalScale" },
96 { ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"},
97};
98
diff --git a/src/glsl/builtins/ir/abs b/src/glsl/builtins/ir/abs
new file mode 100644
index 00000000000..904845307c4
--- /dev/null
+++ b/src/glsl/builtins/ir/abs
@@ -0,0 +1,21 @@
1((function abs
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float abs (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 abs (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 abs (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 abs (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/acos b/src/glsl/builtins/ir/acos
new file mode 100644
index 00000000000..d1cfebeff8a
--- /dev/null
+++ b/src/glsl/builtins/ir/acos
@@ -0,0 +1,22 @@
1((function acos
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (expression float - (constant float (1.5707963))
6 (call asin ((var_ref x)))))))
7 (signature vec2
8 (parameters
9 (declare (in) vec2 x))
10 ((return (expression vec2 - (constant float (1.5707963))
11 (call asin ((var_ref x)))))))
12 (signature vec3
13 (parameters
14 (declare (in) vec3 x))
15 ((return (expression vec3 - (constant float (1.5707963))
16 (call asin ((var_ref x)))))))
17 (signature vec4
18 (parameters
19 (declare (in) vec4 x))
20 ((return (expression vec4 - (constant float (1.5707963))
21 (call asin ((var_ref x)))))))
22))
diff --git a/src/glsl/builtins/ir/all b/src/glsl/builtins/ir/all
new file mode 100644
index 00000000000..2cac0dfb684
--- /dev/null
+++ b/src/glsl/builtins/ir/all
@@ -0,0 +1,16 @@
1((function all
2 (signature bool
3 (parameters
4 (declare (in) bvec2 arg0))
5 ((return (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))
6
7 (signature bool
8 (parameters
9 (declare (in) bvec3 arg0))
10 ((return (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))
11
12 (signature bool
13 (parameters
14 (declare (in) bvec4 arg0))
15 ((return (expression bool && (expression bool && (expression bool && (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))
16))
diff --git a/src/glsl/builtins/ir/any b/src/glsl/builtins/ir/any
new file mode 100644
index 00000000000..f10e8a7b478
--- /dev/null
+++ b/src/glsl/builtins/ir/any
@@ -0,0 +1,16 @@
1((function any
2 (signature bool
3 (parameters
4 (declare (in) bvec2 arg0))
5 ((return (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))))))
6
7 (signature bool
8 (parameters
9 (declare (in) bvec3 arg0))
10 ((return (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))))))
11
12 (signature bool
13 (parameters
14 (declare (in) bvec4 arg0))
15 ((return (expression bool || (expression bool || (expression bool || (swiz x (var_ref arg0))(swiz y (var_ref arg0))) (swiz z (var_ref arg0))) (swiz w (var_ref arg0))))))
16))
diff --git a/src/glsl/builtins/ir/asin b/src/glsl/builtins/ir/asin
new file mode 100644
index 00000000000..e230ad614ee
--- /dev/null
+++ b/src/glsl/builtins/ir/asin
@@ -0,0 +1,97 @@
1((function asin
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (expression float *
6 (expression float sign (var_ref x))
7 (expression float -
8 (expression float *
9 (constant float (3.1415926))
10 (constant float (0.5)))
11 (expression float *
12 (expression float sqrt
13 (expression float -
14 (constant float (1.0))
15 (expression float abs (var_ref x))))
16 (expression float +
17 (constant float (1.5707288))
18 (expression float *
19 (expression float abs (var_ref x))
20 (expression float +
21 (constant float (-0.2121144))
22 (expression float *
23 (constant float (0.0742610))
24 (expression float abs (var_ref x))))))))))))
25
26 (signature vec2
27 (parameters
28 (declare (in) vec2 x))
29 ((return (expression vec2 *
30 (expression vec2 sign (var_ref x))
31 (expression vec2 -
32 (expression float *
33 (constant float (3.1415926))
34 (constant float (0.5)))
35 (expression vec2 *
36 (expression vec2 sqrt
37 (expression vec2 -
38 (constant float (1.0))
39 (expression vec2 abs (var_ref x))))
40 (expression vec2 +
41 (constant float (1.5707288))
42 (expression vec2 *
43 (expression vec2 abs (var_ref x))
44 (expression vec2 +
45 (constant float (-0.2121144))
46 (expression vec2 *
47 (constant float (0.0742610))
48 (expression vec2 abs (var_ref x))))))))))))
49
50 (signature vec3
51 (parameters
52 (declare (in) vec3 x))
53 ((return (expression vec3 *
54 (expression vec3 sign (var_ref x))
55 (expression vec3 -
56 (expression float *
57 (constant float (3.1415926))
58 (constant float (0.5)))
59 (expression vec3 *
60 (expression vec3 sqrt
61 (expression vec3 -
62 (constant float (1.0))
63 (expression vec3 abs (var_ref x))))
64 (expression vec3 +
65 (constant float (1.5707288))
66 (expression vec3 *
67 (expression vec3 abs (var_ref x))
68 (expression vec3 +
69 (constant float (-0.2121144))
70 (expression vec3 *
71 (constant float (0.0742610))
72 (expression vec3 abs (var_ref x))))))))))))
73
74 (signature vec4
75 (parameters
76 (declare (in) vec4 x))
77 ((return (expression vec4 *
78 (expression vec4 sign (var_ref x))
79 (expression vec4 -
80 (expression float *
81 (constant float (3.1415926))
82 (constant float (0.5)))
83 (expression vec4 *
84 (expression vec4 sqrt
85 (expression vec4 -
86 (constant float (1.0))
87 (expression vec4 abs (var_ref x))))
88 (expression vec4 +
89 (constant float (1.5707288))
90 (expression vec4 *
91 (expression vec4 abs (var_ref x))
92 (expression vec4 +
93 (constant float (-0.2121144))
94 (expression vec4 *
95 (constant float (0.0742610))
96 (expression vec4 abs (var_ref x))))))))))))
97))
diff --git a/src/glsl/builtins/ir/atan b/src/glsl/builtins/ir/atan
new file mode 100644
index 00000000000..84048293870
--- /dev/null
+++ b/src/glsl/builtins/ir/atan
@@ -0,0 +1,154 @@
1((function atan
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (call asin ((expression float *
6 (var_ref x)
7 (expression float rsq
8 (expression float +
9 (expression float *
10 (var_ref x)
11 (var_ref x))
12 (constant float (1.0))))))))))
13
14 (signature vec2
15 (parameters
16 (declare (in) vec2 y_over_x))
17 ((return (call asin ((expression vec2 *
18 (var_ref y_over_x)
19 (expression vec2 rsq
20 (expression vec2 +
21 (expression vec2 *
22 (var_ref y_over_x)
23 (var_ref y_over_x))
24 (constant float (1.0))))))))))
25
26 (signature vec3
27 (parameters
28 (declare (in) vec3 y_over_x))
29 ((return (call asin ((expression vec3 *
30 (var_ref y_over_x)
31 (expression vec3 rsq
32 (expression vec3 +
33 (expression vec3 *
34 (var_ref y_over_x)
35 (var_ref y_over_x))
36 (constant float (1.0))))))))))
37
38 (signature vec4
39 (parameters
40 (declare (in) vec4 y_over_x))
41 ((return (call asin ((expression vec4 *
42 (var_ref y_over_x)
43 (expression vec4 rsq
44 (expression vec4 +
45 (expression vec4 *
46 (var_ref y_over_x)
47 (var_ref y_over_x))
48 (constant float (1.0))))))))))
49
50 (signature float
51 (parameters
52 (declare (in ) float y)
53 (declare (in ) float x)
54 )
55 (
56 (declare () float r)
57 (declare ( ) float abs_retval)
58 (assign (constant bool (1)) (var_ref abs_retval) (call abs ((var_ref x) ))
59)
60 (if (expression bool > (var_ref abs_retval) (constant float (0.000100)) ) (
61 (declare ( ) float atan_retval)
62 (assign (constant bool (1)) (var_ref atan_retval) (call atan ((expression float / (var_ref y) (var_ref x) ) ))
63)
64 (assign (constant bool (1)) (var_ref r) (var_ref atan_retval) )
65 (if (expression bool < (var_ref x) (constant float (0.000000)) ) (
66 (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (
67 (declare ( ) float assignment_tmp)
68 (assign (constant bool (1)) (var_ref assignment_tmp) (expression float + (var_ref r) (constant float (3.141593)) ) )
69 (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) )
70 )
71 (
72 (declare ( ) float assignment_tmp)
73 (assign (constant bool (1)) (var_ref assignment_tmp) (expression float - (var_ref r) (constant float (3.141593)) ) )
74 (assign (constant bool (1)) (var_ref r) (var_ref assignment_tmp) )
75 ))
76
77 )
78 (
79 ))
80
81 )
82 (
83 (if (expression bool >= (var_ref y) (constant float (0.000000)) ) (
84 (assign (constant bool (1)) (var_ref r) (constant float (1.570796)) )
85 )
86 (
87 (assign (constant bool (1)) (var_ref r) (constant float (-1.570796)) )
88 ))
89
90 ))
91
92 (return (var_ref r) )
93 ))
94
95
96
97 (signature vec2
98 (parameters
99 (declare (in) vec2 y)
100 (declare (in) vec2 x))
101 ((declare () vec2 r)
102 (assign (constant bool (1))
103 (swiz x (var_ref r))
104 (call atan ((swiz x (var_ref y))
105 (swiz x (var_ref x)))))
106 (assign (constant bool (1))
107 (swiz y (var_ref r))
108 (call atan ((swiz y (var_ref y))
109 (swiz y (var_ref x)))))
110 (return (var_ref r))))
111
112 (signature vec3
113 (parameters
114 (declare (in) vec3 y)
115 (declare (in) vec3 x))
116 ((declare () vec3 r)
117 (assign (constant bool (1))
118 (swiz x (var_ref r))
119 (call atan ((swiz x (var_ref y))
120 (swiz x (var_ref x)))))
121 (assign (constant bool (1))
122 (swiz y (var_ref r))
123 (call atan ((swiz y (var_ref y))
124 (swiz y (var_ref x)))))
125 (assign (constant bool (1))
126 (swiz z (var_ref r))
127 (call atan ((swiz z (var_ref y))
128 (swiz z (var_ref x)))))
129 (return (var_ref r))))
130
131 (signature vec4
132 (parameters
133 (declare (in) vec4 y)
134 (declare (in) vec4 x))
135 ((declare () vec4 r)
136 (assign (constant bool (1))
137 (swiz x (var_ref r))
138 (call atan ((swiz x (var_ref y))
139 (swiz x (var_ref x)))))
140 (assign (constant bool (1))
141 (swiz y (var_ref r))
142 (call atan ((swiz y (var_ref y))
143 (swiz y (var_ref x)))))
144 (assign (constant bool (1))
145 (swiz z (var_ref r))
146 (call atan ((swiz z (var_ref y))
147 (swiz z (var_ref x)))))
148 (assign (constant bool (1))
149 (swiz w (var_ref r))
150 (call atan ((swiz w (var_ref y))
151 (swiz w (var_ref x)))))
152 (return (var_ref r)))))
153
154))
diff --git a/src/glsl/builtins/ir/ceil b/src/glsl/builtins/ir/ceil
new file mode 100644
index 00000000000..a26a7750493
--- /dev/null
+++ b/src/glsl/builtins/ir/ceil
@@ -0,0 +1,21 @@
1((function ceil
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float ceil (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 ceil (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 ceil (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 ceil (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/clamp b/src/glsl/builtins/ir/clamp
new file mode 100644
index 00000000000..2bdc466b269
--- /dev/null
+++ b/src/glsl/builtins/ir/clamp
@@ -0,0 +1,148 @@
1((function clamp
2 (signature float
3 (parameters
4 (declare (in) float arg0)
5 (declare (in) float arg1)
6 (declare (in) float arg2))
7 ((return (expression float max (expression float min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
8
9 (signature vec2
10 (parameters
11 (declare (in) vec2 arg0)
12 (declare (in) vec2 arg1)
13 (declare (in) vec2 arg2))
14 ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
15
16 (signature vec3
17 (parameters
18 (declare (in) vec3 arg0)
19 (declare (in) vec3 arg1)
20 (declare (in) vec3 arg2))
21 ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
22
23 (signature vec4
24 (parameters
25 (declare (in) vec4 arg0)
26 (declare (in) vec4 arg1)
27 (declare (in) vec4 arg2))
28 ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
29
30 (signature vec2
31 (parameters
32 (declare (in) vec2 arg0)
33 (declare (in) float arg1)
34 (declare (in) float arg2))
35 ((return (expression vec2 max (expression vec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
36
37 (signature vec3
38 (parameters
39 (declare (in) vec3 arg0)
40 (declare (in) float arg1)
41 (declare (in) float arg2))
42 ((return (expression vec3 max (expression vec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
43
44 (signature vec4
45 (parameters
46 (declare (in) vec4 arg0)
47 (declare (in) float arg1)
48 (declare (in) float arg2))
49 ((return (expression vec4 max (expression vec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
50
51 (signature int
52 (parameters
53 (declare (in) int arg0)
54 (declare (in) int arg1)
55 (declare (in) int arg2))
56 ((return (expression int max (expression int min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
57
58 (signature ivec2
59 (parameters
60 (declare (in) ivec2 arg0)
61 (declare (in) ivec2 arg1)
62 (declare (in) ivec2 arg2))
63 ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
64
65 (signature ivec3
66 (parameters
67 (declare (in) ivec3 arg0)
68 (declare (in) ivec3 arg1)
69 (declare (in) ivec3 arg2))
70 ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
71
72 (signature ivec4
73 (parameters
74 (declare (in) ivec4 arg0)
75 (declare (in) ivec4 arg1)
76 (declare (in) ivec4 arg2))
77 ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
78
79 (signature ivec2
80 (parameters
81 (declare (in) ivec2 arg0)
82 (declare (in) int arg1)
83 (declare (in) int arg2))
84 ((return (expression ivec2 max (expression ivec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
85
86 (signature ivec3
87 (parameters
88 (declare (in) ivec3 arg0)
89 (declare (in) int arg1)
90 (declare (in) int arg2))
91 ((return (expression ivec3 max (expression ivec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
92
93 (signature ivec4
94 (parameters
95 (declare (in) ivec4 arg0)
96 (declare (in) int arg1)
97 (declare (in) int arg2))
98 ((return (expression ivec4 max (expression ivec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
99
100 (signature uint
101 (parameters
102 (declare (in) uint arg0)
103 (declare (in) uint arg1)
104 (declare (in) uint arg2))
105 ((return (expression uint max (expression uint min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
106
107 (signature uvec2
108 (parameters
109 (declare (in) uvec2 arg0)
110 (declare (in) uvec2 arg1)
111 (declare (in) uvec2 arg2))
112 ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
113
114 (signature uvec3
115 (parameters
116 (declare (in) uvec3 arg0)
117 (declare (in) uvec3 arg1)
118 (declare (in) uvec3 arg2))
119 ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
120
121 (signature uvec4
122 (parameters
123 (declare (in) uvec4 arg0)
124 (declare (in) uvec4 arg1)
125 (declare (in) uvec4 arg2))
126 ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
127
128 (signature uvec2
129 (parameters
130 (declare (in) uvec2 arg0)
131 (declare (in) uint arg1)
132 (declare (in) uint arg2))
133 ((return (expression uvec2 max (expression uvec2 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
134
135 (signature uvec3
136 (parameters
137 (declare (in) uvec3 arg0)
138 (declare (in) uint arg1)
139 (declare (in) uint arg2))
140 ((return (expression uvec3 max (expression uvec3 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
141
142 (signature uvec4
143 (parameters
144 (declare (in) uvec4 arg0)
145 (declare (in) uint arg1)
146 (declare (in) uint arg2))
147 ((return (expression uvec4 max (expression uvec4 min (var_ref arg0) (var_ref arg2)) (var_ref arg1)))))
148))
diff --git a/src/glsl/builtins/ir/cos b/src/glsl/builtins/ir/cos
new file mode 100644
index 00000000000..88f266eccbe
--- /dev/null
+++ b/src/glsl/builtins/ir/cos
@@ -0,0 +1,21 @@
1((function cos
2 (signature float
3 (parameters
4 (declare (in) float angle))
5 ((return (expression float cos (var_ref angle)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 angle))
10 ((return (expression vec2 cos (var_ref angle)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 angle))
15 ((return (expression vec3 cos (var_ref angle)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 angle))
20 ((return (expression vec4 cos (var_ref angle)))))
21))
diff --git a/src/glsl/builtins/ir/cosh b/src/glsl/builtins/ir/cosh
new file mode 100644
index 00000000000..45e0ae427d6
--- /dev/null
+++ b/src/glsl/builtins/ir/cosh
@@ -0,0 +1,30 @@
1((function cosh
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (expression float * (constant float (0.5))
6 (expression float +
7 (expression float exp (var_ref x))
8 (expression float exp (expression float neg (var_ref x))))))))
9 (signature vec2
10 (parameters
11 (declare (in) vec2 x))
12 ((return (expression vec2 * (constant vec2 (0.5))
13 (expression vec2 +
14 (expression vec2 exp (var_ref x))
15 (expression vec2 exp (expression vec2 neg (var_ref x))))))))
16 (signature vec3
17 (parameters
18 (declare (in) vec3 x))
19 ((return (expression vec3 * (constant vec3 (0.5))
20 (expression vec3 +
21 (expression vec3 exp (var_ref x))
22 (expression vec3 exp (expression vec3 neg (var_ref x))))))))
23 (signature vec4
24 (parameters
25 (declare (in) vec4 x))
26 ((return (expression vec4 * (constant vec4 (0.5))
27 (expression vec4 +
28 (expression vec4 exp (var_ref x))
29 (expression vec4 exp (expression vec4 neg (var_ref x))))))))
30))
diff --git a/src/glsl/builtins/ir/cross b/src/glsl/builtins/ir/cross
new file mode 100644
index 00000000000..24717a2183d
--- /dev/null
+++ b/src/glsl/builtins/ir/cross
@@ -0,0 +1,7 @@
1((function cross
2 (signature vec3
3 (parameters
4 (declare (in) vec3 arg0)
5 (declare (in) vec3 arg1))
6 ((return (expression vec3 cross (var_ref arg0) (var_ref arg1)))))
7))
diff --git a/src/glsl/builtins/ir/dFdx b/src/glsl/builtins/ir/dFdx
new file mode 100644
index 00000000000..30594d33c74
--- /dev/null
+++ b/src/glsl/builtins/ir/dFdx
@@ -0,0 +1,21 @@
1((function dFdx
2 (signature float
3 (parameters
4 (declare (in) float p))
5 ((return (expression float dFdx (var_ref p)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 p))
10 ((return (expression vec2 dFdx (var_ref p)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 p))
15 ((return (expression vec3 dFdx (var_ref p)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 p))
20 ((return (expression vec4 dFdx (var_ref p)))))
21))
diff --git a/src/glsl/builtins/ir/dFdy b/src/glsl/builtins/ir/dFdy
new file mode 100644
index 00000000000..fb5798d3cbe
--- /dev/null
+++ b/src/glsl/builtins/ir/dFdy
@@ -0,0 +1,21 @@
1((function dFdy
2 (signature float
3 (parameters
4 (declare (in) float p))
5 ((return (expression float dFdy (var_ref p)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 p))
10 ((return (expression vec2 dFdy (var_ref p)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 p))
15 ((return (expression vec3 dFdy (var_ref p)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 p))
20 ((return (expression vec4 dFdy (var_ref p)))))
21))
diff --git a/src/glsl/builtins/ir/degrees b/src/glsl/builtins/ir/degrees
new file mode 100644
index 00000000000..dc0d7b9e20d
--- /dev/null
+++ b/src/glsl/builtins/ir/degrees
@@ -0,0 +1,21 @@
1((function degrees
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float * (var_ref arg0) (constant float (57.295780))))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 * (var_ref arg0) (constant float (57.295780))))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 * (var_ref arg0) (constant float (57.295780))))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 * (var_ref arg0) (constant float (57.295780))))))
21))
diff --git a/src/glsl/builtins/ir/distance b/src/glsl/builtins/ir/distance
new file mode 100644
index 00000000000..a2309c484f9
--- /dev/null
+++ b/src/glsl/builtins/ir/distance
@@ -0,0 +1,33 @@
1((function distance
2 (signature float
3 (parameters
4 (declare (in) float p0)
5 (declare (in) float p1))
6 ((declare () float p)
7 (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))
8 (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
9
10 (signature float
11 (parameters
12 (declare (in) vec2 p0)
13 (declare (in) vec2 p1))
14 ((declare () vec2 p)
15 (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))
16 (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
17
18 (signature float
19 (parameters
20 (declare (in) vec3 p0)
21 (declare (in) vec3 p1))
22 ((declare () vec3 p)
23 (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))
24 (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
25
26 (signature float
27 (parameters
28 (declare (in) vec4 p0)
29 (declare (in) vec4 p1))
30 ((declare () vec4 p)
31 (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))
32 (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
33))
diff --git a/src/glsl/builtins/ir/dot b/src/glsl/builtins/ir/dot
new file mode 100644
index 00000000000..a91a6d2c56d
--- /dev/null
+++ b/src/glsl/builtins/ir/dot
@@ -0,0 +1,25 @@
1((function dot
2 (signature float
3 (parameters
4 (declare (in) float arg0)
5 (declare (in) float arg1))
6 ((return (expression float dot (var_ref arg0) (var_ref arg1)))))
7
8 (signature float
9 (parameters
10 (declare (in) vec2 arg0)
11 (declare (in) vec2 arg1))
12 ((return (expression float dot (var_ref arg0) (var_ref arg1)))))
13
14 (signature float
15 (parameters
16 (declare (in) vec3 arg0)
17 (declare (in) vec3 arg1))
18 ((return (expression float dot (var_ref arg0) (var_ref arg1)))))
19
20 (signature float
21 (parameters
22 (declare (in) vec4 arg0)
23 (declare (in) vec4 arg1))
24 ((return (expression float dot (var_ref arg0) (var_ref arg1)))))
25))
diff --git a/src/glsl/builtins/ir/equal b/src/glsl/builtins/ir/equal
new file mode 100644
index 00000000000..d7a4bc6063f
--- /dev/null
+++ b/src/glsl/builtins/ir/equal
@@ -0,0 +1,91 @@
1((function equal
2 (signature bvec2
3 (parameters
4 (declare (in) vec2 arg0)
5 (declare (in) vec2 arg1))
6 ((declare () bvec2 temp)
7 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
8 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
9 (return (var_ref temp))))
10
11 (signature bvec3
12 (parameters
13 (declare (in) vec3 arg0)
14 (declare (in) vec3 arg1))
15 ((declare () bvec3 temp)
16 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
17 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
18 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
19 (return (var_ref temp))))
20
21 (signature bvec4
22 (parameters
23 (declare (in) vec4 arg0)
24 (declare (in) vec4 arg1))
25 ((declare () bvec4 temp)
26 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
27 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
28 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
29 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
30 (return (var_ref temp))))
31
32 (signature bvec2
33 (parameters
34 (declare (in) ivec2 arg0)
35 (declare (in) ivec2 arg1))
36 ((declare () bvec2 temp)
37 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
38 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
39 (return (var_ref temp))))
40
41 (signature bvec3
42 (parameters
43 (declare (in) ivec3 arg0)
44 (declare (in) ivec3 arg1))
45 ((declare () bvec3 temp)
46 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
47 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
48 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
49 (return (var_ref temp))))
50
51 (signature bvec4
52 (parameters
53 (declare (in) ivec4 arg0)
54 (declare (in) ivec4 arg1))
55 ((declare () bvec4 temp)
56 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
57 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
58 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
59 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
60 (return (var_ref temp))))
61
62 (signature bvec2
63 (parameters
64 (declare (in) uvec2 arg0)
65 (declare (in) uvec2 arg1))
66 ((declare () bvec2 temp)
67 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
68 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
69 (return (var_ref temp))))
70
71 (signature bvec3
72 (parameters
73 (declare (in) uvec3 arg0)
74 (declare (in) uvec3 arg1))
75 ((declare () bvec3 temp)
76 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
77 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
78 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
79 (return (var_ref temp))))
80
81 (signature bvec4
82 (parameters
83 (declare (in) uvec4 arg0)
84 (declare (in) uvec4 arg1))
85 ((declare () bvec4 temp)
86 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool == (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
87 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool == (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
88 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool == (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
89 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool == (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
90 (return (var_ref temp))))
91))
diff --git a/src/glsl/builtins/ir/exp b/src/glsl/builtins/ir/exp
new file mode 100644
index 00000000000..a73bd6a7f84
--- /dev/null
+++ b/src/glsl/builtins/ir/exp
@@ -0,0 +1,21 @@
1((function exp
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float exp (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 exp (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 exp (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 exp (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/exp2 b/src/glsl/builtins/ir/exp2
new file mode 100644
index 00000000000..a842d3fe65b
--- /dev/null
+++ b/src/glsl/builtins/ir/exp2
@@ -0,0 +1,21 @@
1((function exp2
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float exp2 (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 exp2 (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 exp2 (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 exp2 (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/faceforward b/src/glsl/builtins/ir/faceforward
new file mode 100644
index 00000000000..d1703972388
--- /dev/null
+++ b/src/glsl/builtins/ir/faceforward
@@ -0,0 +1,37 @@
1((function faceforward
2 (signature float
3 (parameters
4 (declare (in) float N)
5 (declare (in) float I)
6 (declare (in) float Nref))
7 ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))
8 ((return (var_ref N)))
9 ((return (expression float neg (var_ref N)))))))
10
11 (signature vec2
12 (parameters
13 (declare (in) vec2 N)
14 (declare (in) vec2 I)
15 (declare (in) vec2 Nref))
16 ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))
17 ((return (var_ref N)))
18 ((return (expression vec2 neg (var_ref N)))))))
19
20 (signature vec3
21 (parameters
22 (declare (in) vec3 N)
23 (declare (in) vec3 I)
24 (declare (in) vec3 Nref))
25 ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))
26 ((return (var_ref N)))
27 ((return (expression vec3 neg (var_ref N)))))))
28
29 (signature vec4
30 (parameters
31 (declare (in) vec4 N)
32 (declare (in) vec4 I)
33 (declare (in) vec4 Nref))
34 ((if (expression bool < (expression float dot (var_ref Nref) (var_ref I)) (constant float (0)))
35 ((return (var_ref N)))
36 ((return (expression vec4 neg (var_ref N)))))))
37))
diff --git a/src/glsl/builtins/ir/floor b/src/glsl/builtins/ir/floor
new file mode 100644
index 00000000000..8dd8052799b
--- /dev/null
+++ b/src/glsl/builtins/ir/floor
@@ -0,0 +1,21 @@
1((function floor
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float floor (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 floor (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 floor (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 floor (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/fract b/src/glsl/builtins/ir/fract
new file mode 100644
index 00000000000..3f0763d1b3e
--- /dev/null
+++ b/src/glsl/builtins/ir/fract
@@ -0,0 +1,22 @@
1((function fract
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (expression float fract (var_ref x)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 x))
10 ((return (expression vec2 fract (var_ref x)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 x))
15 ((return (expression vec3 fract (var_ref x)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 x))
20 ((return (expression vec4 fract (var_ref x)))))
21))
22
diff --git a/src/glsl/builtins/ir/ftransform b/src/glsl/builtins/ir/ftransform
new file mode 100644
index 00000000000..9ca63dc1e34
--- /dev/null
+++ b/src/glsl/builtins/ir/ftransform
@@ -0,0 +1,9 @@
1((declare (uniform) mat4 gl_ModelViewProjectionMatrix)
2 (declare (in) vec4 gl_Vertex)
3 (function ftransform
4 (signature vec4
5 (parameters)
6 ((return (expression vec4 *
7 (var_ref gl_ModelViewProjectionMatrix)
8 (var_ref gl_Vertex)))))
9))
diff --git a/src/glsl/builtins/ir/fwidth b/src/glsl/builtins/ir/fwidth
new file mode 100644
index 00000000000..385e05d6a1a
--- /dev/null
+++ b/src/glsl/builtins/ir/fwidth
@@ -0,0 +1,29 @@
1((function fwidth
2 (signature float
3 (parameters
4 (declare (in) float p))
5 ((return (expression float +
6 (expression float abs (expression float dFdx (var_ref p)))
7 (expression float abs (expression float dFdy (var_ref p)))))))
8
9 (signature vec2
10 (parameters
11 (declare (in) vec2 p))
12 ((return (expression vec2 +
13 (expression vec2 abs (expression vec2 dFdx (var_ref p)))
14 (expression vec2 abs (expression vec2 dFdy (var_ref p)))))))
15
16 (signature vec3
17 (parameters
18 (declare (in) vec3 p))
19 ((return (expression vec3 +
20 (expression vec3 abs (expression vec3 dFdx (var_ref p)))
21 (expression vec3 abs (expression vec3 dFdy (var_ref p)))))))
22
23 (signature vec4
24 (parameters
25 (declare (in) vec4 p))
26 ((return (expression vec4 +
27 (expression vec4 abs (expression vec4 dFdx (var_ref p)))
28 (expression vec4 abs (expression vec4 dFdy (var_ref p)))))))
29))
diff --git a/src/glsl/builtins/ir/greaterThan b/src/glsl/builtins/ir/greaterThan
new file mode 100644
index 00000000000..ce7bd29bed8
--- /dev/null
+++ b/src/glsl/builtins/ir/greaterThan
@@ -0,0 +1,91 @@
1((function greaterThan
2 (signature bvec2
3 (parameters
4 (declare (in) vec2 arg0)
5 (declare (in) vec2 arg1))
6 ((declare () bvec2 temp)
7 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
8 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
9 (return (var_ref temp))))
10
11 (signature bvec3
12 (parameters
13 (declare (in) vec3 arg0)
14 (declare (in) vec3 arg1))
15 ((declare () bvec3 temp)
16 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
17 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
18 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
19 (return (var_ref temp))))
20
21 (signature bvec4
22 (parameters
23 (declare (in) vec4 arg0)
24 (declare (in) vec4 arg1))
25 ((declare () bvec4 temp)
26 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
27 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
28 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
29 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
30 (return (var_ref temp))))
31
32 (signature bvec2
33 (parameters
34 (declare (in) ivec2 arg0)
35 (declare (in) ivec2 arg1))
36 ((declare () bvec2 temp)
37 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
38 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
39 (return (var_ref temp))))
40
41 (signature bvec3
42 (parameters
43 (declare (in) ivec3 arg0)
44 (declare (in) ivec3 arg1))
45 ((declare () bvec3 temp)
46 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
47 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
48 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
49 (return (var_ref temp))))
50
51 (signature bvec4
52 (parameters
53 (declare (in) ivec4 arg0)
54 (declare (in) ivec4 arg1))
55 ((declare () bvec4 temp)
56 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
57 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
58 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
59 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
60 (return (var_ref temp))))
61
62 (signature bvec2
63 (parameters
64 (declare (in) uvec2 arg0)
65 (declare (in) uvec2 arg1))
66 ((declare () bvec2 temp)
67 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
68 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
69 (return (var_ref temp))))
70
71 (signature bvec3
72 (parameters
73 (declare (in) uvec3 arg0)
74 (declare (in) uvec3 arg1))
75 ((declare () bvec3 temp)
76 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
77 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
78 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
79 (return (var_ref temp))))
80
81 (signature bvec4
82 (parameters
83 (declare (in) uvec4 arg0)
84 (declare (in) uvec4 arg1))
85 ((declare () bvec4 temp)
86 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool > (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
87 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool > (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
88 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool > (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
89 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool > (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
90 (return (var_ref temp))))
91))
diff --git a/src/glsl/builtins/ir/greaterThanEqual b/src/glsl/builtins/ir/greaterThanEqual
new file mode 100644
index 00000000000..de1a9f9516e
--- /dev/null
+++ b/src/glsl/builtins/ir/greaterThanEqual
@@ -0,0 +1,91 @@
1((function greaterThanEqual
2 (signature bvec2
3 (parameters
4 (declare (in) vec2 arg0)
5 (declare (in) vec2 arg1))
6 ((declare () bvec2 temp)
7 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
8 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
9 (return (var_ref temp))))
10
11 (signature bvec3
12 (parameters
13 (declare (in) vec3 arg0)
14 (declare (in) vec3 arg1))
15 ((declare () bvec3 temp)
16 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
17 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
18 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
19 (return (var_ref temp))))
20
21 (signature bvec4
22 (parameters
23 (declare (in) vec4 arg0)
24 (declare (in) vec4 arg1))
25 ((declare () bvec4 temp)
26 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
27 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
28 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
29 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
30 (return (var_ref temp))))
31
32 (signature bvec2
33 (parameters
34 (declare (in) ivec2 arg0)
35 (declare (in) ivec2 arg1))
36 ((declare () bvec2 temp)
37 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
38 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
39 (return (var_ref temp))))
40
41 (signature bvec3
42 (parameters
43 (declare (in) ivec3 arg0)
44 (declare (in) ivec3 arg1))
45 ((declare () bvec3 temp)
46 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
47 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
48 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
49 (return (var_ref temp))))
50
51 (signature bvec4
52 (parameters
53 (declare (in) ivec4 arg0)
54 (declare (in) ivec4 arg1))
55 ((declare () bvec4 temp)
56 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
57 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
58 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
59 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
60 (return (var_ref temp))))
61
62 (signature bvec2
63 (parameters
64 (declare (in) uvec2 arg0)
65 (declare (in) uvec2 arg1))
66 ((declare () bvec2 temp)
67 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
68 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
69 (return (var_ref temp))))
70
71 (signature bvec3
72 (parameters
73 (declare (in) uvec3 arg0)
74 (declare (in) uvec3 arg1))
75 ((declare () bvec3 temp)
76 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
77 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
78 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
79 (return (var_ref temp))))
80
81 (signature bvec4
82 (parameters
83 (declare (in) uvec4 arg0)
84 (declare (in) uvec4 arg1))
85 ((declare () bvec4 temp)
86 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool >= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
87 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool >= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
88 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool >= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
89 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool >= (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
90 (return (var_ref temp))))
91))
diff --git a/src/glsl/builtins/ir/inversesqrt b/src/glsl/builtins/ir/inversesqrt
new file mode 100644
index 00000000000..5b66d2b3695
--- /dev/null
+++ b/src/glsl/builtins/ir/inversesqrt
@@ -0,0 +1,21 @@
1((function inversesqrt
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float rsq (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 rsq (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 rsq (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 rsq (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/length b/src/glsl/builtins/ir/length
new file mode 100644
index 00000000000..89ff7f3ef12
--- /dev/null
+++ b/src/glsl/builtins/ir/length
@@ -0,0 +1,21 @@
1((function length
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))
6
7 (signature float
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))
11
12 (signature float
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))
16
17 (signature float
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression float sqrt (expression float dot (var_ref arg0) (var_ref arg0))))))
21))
diff --git a/src/glsl/builtins/ir/lessThan b/src/glsl/builtins/ir/lessThan
new file mode 100644
index 00000000000..52113b70466
--- /dev/null
+++ b/src/glsl/builtins/ir/lessThan
@@ -0,0 +1,91 @@
1((function lessThan
2 (signature bvec2
3 (parameters
4 (declare (in) vec2 arg0)
5 (declare (in) vec2 arg1))
6 ((declare () bvec2 temp)
7 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
8 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
9 (return (var_ref temp))))
10
11 (signature bvec3
12 (parameters
13 (declare (in) vec3 arg0)
14 (declare (in) vec3 arg1))
15 ((declare () bvec3 temp)
16 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
17 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
18 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
19 (return (var_ref temp))))
20
21 (signature bvec4
22 (parameters
23 (declare (in) vec4 arg0)
24 (declare (in) vec4 arg1))
25 ((declare () bvec4 temp)
26 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
27 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
28 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
29 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
30 (return (var_ref temp))))
31
32 (signature bvec2
33 (parameters
34 (declare (in) ivec2 arg0)
35 (declare (in) ivec2 arg1))
36 ((declare () bvec2 temp)
37 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
38 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
39 (return (var_ref temp))))
40
41 (signature bvec3
42 (parameters
43 (declare (in) ivec3 arg0)
44 (declare (in) ivec3 arg1))
45 ((declare () bvec3 temp)
46 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
47 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
48 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
49 (return (var_ref temp))))
50
51 (signature bvec4
52 (parameters
53 (declare (in) ivec4 arg0)
54 (declare (in) ivec4 arg1))
55 ((declare () bvec4 temp)
56 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
57 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
58 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
59 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
60 (return (var_ref temp))))
61
62 (signature bvec2
63 (parameters
64 (declare (in) uvec2 arg0)
65 (declare (in) uvec2 arg1))
66 ((declare () bvec2 temp)
67 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
68 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
69 (return (var_ref temp))))
70
71 (signature bvec3
72 (parameters
73 (declare (in) uvec3 arg0)
74 (declare (in) uvec3 arg1))
75 ((declare () bvec3 temp)
76 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
77 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
78 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
79 (return (var_ref temp))))
80
81 (signature bvec4
82 (parameters
83 (declare (in) uvec4 arg0)
84 (declare (in) uvec4 arg1))
85 ((declare () bvec4 temp)
86 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool < (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
87 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool < (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
88 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool < (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
89 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool < (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
90 (return (var_ref temp))))
91))
diff --git a/src/glsl/builtins/ir/lessThanEqual b/src/glsl/builtins/ir/lessThanEqual
new file mode 100644
index 00000000000..4b240be5d19
--- /dev/null
+++ b/src/glsl/builtins/ir/lessThanEqual
@@ -0,0 +1,91 @@
1((function lessThanEqual
2 (signature bvec2
3 (parameters
4 (declare (in) vec2 arg0)
5 (declare (in) vec2 arg1))
6 ((declare () bvec2 temp)
7 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
8 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
9 (return (var_ref temp))))
10
11 (signature bvec3
12 (parameters
13 (declare (in) vec3 arg0)
14 (declare (in) vec3 arg1))
15 ((declare () bvec3 temp)
16 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
17 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
18 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
19 (return (var_ref temp))))
20
21 (signature bvec4
22 (parameters
23 (declare (in) vec4 arg0)
24 (declare (in) vec4 arg1))
25 ((declare () bvec4 temp)
26 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
27 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
28 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
29 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
30 (return (var_ref temp))))
31
32 (signature bvec2
33 (parameters
34 (declare (in) ivec2 arg0)
35 (declare (in) ivec2 arg1))
36 ((declare () bvec2 temp)
37 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
38 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
39 (return (var_ref temp))))
40
41 (signature bvec3
42 (parameters
43 (declare (in) ivec3 arg0)
44 (declare (in) ivec3 arg1))
45 ((declare () bvec3 temp)
46 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
47 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
48 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
49 (return (var_ref temp))))
50
51 (signature bvec4
52 (parameters
53 (declare (in) ivec4 arg0)
54 (declare (in) ivec4 arg1))
55 ((declare () bvec4 temp)
56 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
57 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
58 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
59 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
60 (return (var_ref temp))))
61
62 (signature bvec2
63 (parameters
64 (declare (in) uvec2 arg0)
65 (declare (in) uvec2 arg1))
66 ((declare () bvec2 temp)
67 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
68 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
69 (return (var_ref temp))))
70
71 (signature bvec3
72 (parameters
73 (declare (in) uvec3 arg0)
74 (declare (in) uvec3 arg1))
75 ((declare () bvec3 temp)
76 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
77 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
78 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
79 (return (var_ref temp))))
80
81 (signature bvec4
82 (parameters
83 (declare (in) uvec4 arg0)
84 (declare (in) uvec4 arg1))
85 ((declare () bvec4 temp)
86 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool <= (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
87 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool <= (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
88 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool <= (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
89 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool <= (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
90 (return (var_ref temp))))
91))
diff --git a/src/glsl/builtins/ir/log b/src/glsl/builtins/ir/log
new file mode 100644
index 00000000000..d168abb5a73
--- /dev/null
+++ b/src/glsl/builtins/ir/log
@@ -0,0 +1,21 @@
1((function log
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float log (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 log (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 log (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 log (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/log2 b/src/glsl/builtins/ir/log2
new file mode 100644
index 00000000000..b96c6276f0a
--- /dev/null
+++ b/src/glsl/builtins/ir/log2
@@ -0,0 +1,21 @@
1((function log2
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float log2 (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 log2 (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 log2 (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 log2 (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/matrixCompMult b/src/glsl/builtins/ir/matrixCompMult
new file mode 100644
index 00000000000..538da18a794
--- /dev/null
+++ b/src/glsl/builtins/ir/matrixCompMult
@@ -0,0 +1,91 @@
1((function matrixCompMult
2 (signature mat2
3 (parameters
4 (declare (in) mat2 x)
5 (declare (in) mat2 y))
6 ((declare () mat2 z)
7 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
8 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
9(return (var_ref z))))
10
11 (signature mat3
12 (parameters
13 (declare (in) mat3 x)
14 (declare (in) mat3 y))
15 ((declare () mat3 z)
16 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
17 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
18 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
19(return (var_ref z))))
20
21 (signature mat4
22 (parameters
23 (declare (in) mat4 x)
24 (declare (in) mat4 y))
25 ((declare () mat4 z)
26 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
27 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
28 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
29 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (3))) (expression vec4 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
30(return (var_ref z))))
31
32 (signature mat2x3
33 (parameters
34 (declare (in) mat2x3 x)
35 (declare (in) mat2x3 y))
36 ((declare () mat2x3 z)
37 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
38 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
39(return (var_ref z))))
40
41 (signature mat3x2
42 (parameters
43 (declare (in) mat3x2 x)
44 (declare (in) mat3x2 y))
45 ((declare () mat3x2 z)
46 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
47 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
48 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
49(return (var_ref z))))
50
51 (signature mat2x4
52 (parameters
53 (declare (in) mat2x4 x)
54 (declare (in) mat2x4 y))
55 ((declare () mat2x4 z)
56 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
57 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
58(return (var_ref z))))
59
60 (signature mat4x2
61 (parameters
62 (declare (in) mat4x2 x)
63 (declare (in) mat4x2 y))
64 ((declare () mat4x2 z)
65 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
66 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
67 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
68 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (3))) (expression vec2 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
69(return (var_ref z))))
70
71 (signature mat3x4
72 (parameters
73 (declare (in) mat3x4 x)
74 (declare (in) mat3x4 y))
75 ((declare () mat3x4 z)
76 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
77 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
78 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
79(return (var_ref z))))
80
81 (signature mat4x3
82 (parameters
83 (declare (in) mat4x3 x)
84 (declare (in) mat4x3 y))
85 ((declare () mat4x3 z)
86 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
87 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
88 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
89 (assign (constant bool (1)) (array_ref (var_ref z) (constant int (3))) (expression vec3 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
90(return (var_ref z))))
91))
diff --git a/src/glsl/builtins/ir/max b/src/glsl/builtins/ir/max
new file mode 100644
index 00000000000..2b5a02868cc
--- /dev/null
+++ b/src/glsl/builtins/ir/max
@@ -0,0 +1,127 @@
1((function max
2 (signature float
3 (parameters
4 (declare (in) float arg0)
5 (declare (in) float arg1))
6 ((return (expression float max (var_ref arg0) (var_ref arg1)))))
7
8 (signature vec2
9 (parameters
10 (declare (in) vec2 arg0)
11 (declare (in) vec2 arg1))
12 ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))
13
14 (signature vec3
15 (parameters
16 (declare (in) vec3 arg0)
17 (declare (in) vec3 arg1))
18 ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))
19
20 (signature vec4
21 (parameters
22 (declare (in) vec4 arg0)
23 (declare (in) vec4 arg1))
24 ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))
25
26 (signature vec2
27 (parameters
28 (declare (in) vec2 arg0)
29 (declare (in) float arg1))
30 ((return (expression vec2 max (var_ref arg0) (var_ref arg1)))))
31
32 (signature vec3
33 (parameters
34 (declare (in) vec3 arg0)
35 (declare (in) float arg1))
36 ((return (expression vec3 max (var_ref arg0) (var_ref arg1)))))
37
38 (signature vec4
39 (parameters
40 (declare (in) vec4 arg0)
41 (declare (in) float arg1))
42 ((return (expression vec4 max (var_ref arg0) (var_ref arg1)))))
43
44 (signature int
45 (parameters
46 (declare (in) int arg0)
47 (declare (in) int arg1))
48 ((return (expression int max (var_ref arg0) (var_ref arg1)))))
49
50 (signature ivec2
51 (parameters
52 (declare (in) ivec2 arg0)
53 (declare (in) ivec2 arg1))
54 ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))
55
56 (signature ivec3
57 (parameters
58 (declare (in) ivec3 arg0)
59 (declare (in) ivec3 arg1))
60 ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))
61
62 (signature ivec4
63 (parameters
64 (declare (in) ivec4 arg0)
65 (declare (in) ivec4 arg1))
66 ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))
67
68 (signature ivec2
69 (parameters
70 (declare (in) ivec2 arg0)
71 (declare (in) int arg1))
72 ((return (expression ivec2 max (var_ref arg0) (var_ref arg1)))))
73
74 (signature ivec3
75 (parameters
76 (declare (in) ivec3 arg0)
77 (declare (in) int arg1))
78 ((return (expression ivec3 max (var_ref arg0) (var_ref arg1)))))
79
80 (signature ivec4
81 (parameters
82 (declare (in) ivec4 arg0)
83 (declare (in) int arg1))
84 ((return (expression ivec4 max (var_ref arg0) (var_ref arg1)))))
85
86 (signature uint
87 (parameters
88 (declare (in) uint arg0)
89 (declare (in) uint arg1))
90 ((return (expression uint max (var_ref arg0) (var_ref arg1)))))
91
92 (signature uvec2
93 (parameters
94 (declare (in) uvec2 arg0)
95 (declare (in) uvec2 arg1))
96 ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))
97
98 (signature uvec3
99 (parameters
100 (declare (in) uvec3 arg0)
101 (declare (in) uvec3 arg1))
102 ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))
103
104 (signature uvec4
105 (parameters
106 (declare (in) uvec4 arg0)
107 (declare (in) uvec4 arg1))
108 ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))
109
110 (signature uvec2
111 (parameters
112 (declare (in) uvec2 arg0)
113 (declare (in) uint arg1))
114 ((return (expression uvec2 max (var_ref arg0) (var_ref arg1)))))
115
116 (signature uvec3
117 (parameters
118 (declare (in) uvec3 arg0)
119 (declare (in) uint arg1))
120 ((return (expression uvec3 max (var_ref arg0) (var_ref arg1)))))
121
122 (signature uvec4
123 (parameters
124 (declare (in) uvec4 arg0)
125 (declare (in) uint arg1))
126 ((return (expression uvec4 max (var_ref arg0) (var_ref arg1)))))
127))
diff --git a/src/glsl/builtins/ir/min b/src/glsl/builtins/ir/min
new file mode 100644
index 00000000000..2deef1118a7
--- /dev/null
+++ b/src/glsl/builtins/ir/min
@@ -0,0 +1,127 @@
1((function min
2 (signature float
3 (parameters
4 (declare (in) float arg0)
5 (declare (in) float arg1))
6 ((return (expression float min (var_ref arg0) (var_ref arg1)))))
7
8 (signature vec2
9 (parameters
10 (declare (in) vec2 arg0)
11 (declare (in) vec2 arg1))
12 ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))
13
14 (signature vec3
15 (parameters
16 (declare (in) vec3 arg0)
17 (declare (in) vec3 arg1))
18 ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))
19
20 (signature vec4
21 (parameters
22 (declare (in) vec4 arg0)
23 (declare (in) vec4 arg1))
24 ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))
25
26 (signature vec2
27 (parameters
28 (declare (in) vec2 arg0)
29 (declare (in) float arg1))
30 ((return (expression vec2 min (var_ref arg0) (var_ref arg1)))))
31
32 (signature vec3
33 (parameters
34 (declare (in) vec3 arg0)
35 (declare (in) float arg1))
36 ((return (expression vec3 min (var_ref arg0) (var_ref arg1)))))
37
38 (signature vec4
39 (parameters
40 (declare (in) vec4 arg0)
41 (declare (in) float arg1))
42 ((return (expression vec4 min (var_ref arg0) (var_ref arg1)))))
43
44 (signature int
45 (parameters
46 (declare (in) int arg0)
47 (declare (in) int arg1))
48 ((return (expression int min (var_ref arg0) (var_ref arg1)))))
49
50 (signature ivec2
51 (parameters
52 (declare (in) ivec2 arg0)
53 (declare (in) ivec2 arg1))
54 ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))
55
56 (signature ivec3
57 (parameters
58 (declare (in) ivec3 arg0)
59 (declare (in) ivec3 arg1))
60 ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))
61
62 (signature ivec4
63 (parameters
64 (declare (in) ivec4 arg0)
65 (declare (in) ivec4 arg1))
66 ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))
67
68 (signature ivec2
69 (parameters
70 (declare (in) ivec2 arg0)
71 (declare (in) int arg1))
72 ((return (expression ivec2 min (var_ref arg0) (var_ref arg1)))))
73
74 (signature ivec3
75 (parameters
76 (declare (in) ivec3 arg0)
77 (declare (in) int arg1))
78 ((return (expression ivec3 min (var_ref arg0) (var_ref arg1)))))
79
80 (signature ivec4
81 (parameters
82 (declare (in) ivec4 arg0)
83 (declare (in) int arg1))
84 ((return (expression ivec4 min (var_ref arg0) (var_ref arg1)))))
85
86 (signature uint
87 (parameters
88 (declare (in) uint arg0)
89 (declare (in) uint arg1))
90 ((return (expression uint min (var_ref arg0) (var_ref arg1)))))
91
92 (signature uvec2
93 (parameters
94 (declare (in) uvec2 arg0)
95 (declare (in) uvec2 arg1))
96 ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))
97
98 (signature uvec3
99 (parameters
100 (declare (in) uvec3 arg0)
101 (declare (in) uvec3 arg1))
102 ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))
103
104 (signature uvec4
105 (parameters
106 (declare (in) uvec4 arg0)
107 (declare (in) uvec4 arg1))
108 ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))
109
110 (signature uvec2
111 (parameters
112 (declare (in) uvec2 arg0)
113 (declare (in) uint arg1))
114 ((return (expression uvec2 min (var_ref arg0) (var_ref arg1)))))
115
116 (signature uvec3
117 (parameters
118 (declare (in) uvec3 arg0)
119 (declare (in) uint arg1))
120 ((return (expression uvec3 min (var_ref arg0) (var_ref arg1)))))
121
122 (signature uvec4
123 (parameters
124 (declare (in) uvec4 arg0)
125 (declare (in) uint arg1))
126 ((return (expression uvec4 min (var_ref arg0) (var_ref arg1)))))
127))
diff --git a/src/glsl/builtins/ir/mix b/src/glsl/builtins/ir/mix
new file mode 100644
index 00000000000..6bc6f0a43e8
--- /dev/null
+++ b/src/glsl/builtins/ir/mix
@@ -0,0 +1,88 @@
1((function mix
2 (signature float
3 (parameters
4 (declare (in) float arg0)
5 (declare (in) float arg1)
6 (declare (in) float arg2))
7 ((return (expression float + (expression float * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression float * (var_ref arg1) (var_ref arg2))))))
8
9 (signature vec2
10 (parameters
11 (declare (in) vec2 arg0)
12 (declare (in) vec2 arg1)
13 (declare (in) vec2 arg2))
14 ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression vec2 - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))
15
16 (signature vec3
17 (parameters
18 (declare (in) vec3 arg0)
19 (declare (in) vec3 arg1)
20 (declare (in) vec3 arg2))
21 ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression vec3 - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))
22
23 (signature vec4
24 (parameters
25 (declare (in) vec4 arg0)
26 (declare (in) vec4 arg1)
27 (declare (in) vec4 arg2))
28 ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression vec4 - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))
29
30 (signature vec2
31 (parameters
32 (declare (in) vec2 arg0)
33 (declare (in) vec2 arg1)
34 (declare (in) float arg2))
35 ((return (expression vec2 + (expression vec2 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec2 * (var_ref arg1) (var_ref arg2))))))
36
37 (signature vec3
38 (parameters
39 (declare (in) vec3 arg0)
40 (declare (in) vec3 arg1)
41 (declare (in) float arg2))
42 ((return (expression vec3 + (expression vec3 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec3 * (var_ref arg1) (var_ref arg2))))))
43
44 (signature vec4
45 (parameters
46 (declare (in) vec4 arg0)
47 (declare (in) vec4 arg1)
48 (declare (in) float arg2))
49 ((return (expression vec4 + (expression vec4 * (var_ref arg0) (expression float - (constant float (1.000000)) (var_ref arg2))) (expression vec4 * (var_ref arg1) (var_ref arg2))))))
50
51 (signature float
52 (parameters
53 (declare (in) float v1)
54 (declare (in) float v2)
55 (declare (in) bool a))
56 ((assign (var_ref a) (var_ref v1) (var_ref v2))
57 (return (var_ref v1))))
58
59 (signature vec2
60 (parameters
61 (declare (in) vec2 v1)
62 (declare (in) vec2 v2)
63 (declare (in) bvec2 a))
64 ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))
65 (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))
66 (return (var_ref v1))))
67
68 (signature vec3
69 (parameters
70 (declare (in) vec3 v1)
71 (declare (in) vec3 v2)
72 (declare (in) bvec3 a))
73 ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))
74 (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))
75 (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2)))
76 (return (var_ref v1))))
77
78 (signature vec4
79 (parameters
80 (declare (in) vec4 v1)
81 (declare (in) vec4 v2)
82 (declare (in) bvec4 a))
83 ((assign (swiz x (var_ref a)) (swiz x (var_ref v1)) (swiz x (var_ref v2)))
84 (assign (swiz y (var_ref a)) (swiz y (var_ref v1)) (swiz y (var_ref v2)))
85 (assign (swiz z (var_ref a)) (swiz z (var_ref v1)) (swiz z (var_ref v2)))
86 (assign (swiz w (var_ref a)) (swiz w (var_ref v1)) (swiz w (var_ref v2)))
87 (return (var_ref v1))))
88))
diff --git a/src/glsl/builtins/ir/mod b/src/glsl/builtins/ir/mod
new file mode 100644
index 00000000000..aeaea240e2d
--- /dev/null
+++ b/src/glsl/builtins/ir/mod
@@ -0,0 +1,43 @@
1((function mod
2 (signature float
3 (parameters
4 (declare (in) float arg0)
5 (declare (in) float arg1))
6 ((return (expression float % (var_ref arg0) (var_ref arg1)))))
7
8 (signature vec2
9 (parameters
10 (declare (in) vec2 arg0)
11 (declare (in) vec2 arg1))
12 ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))
13
14 (signature vec3
15 (parameters
16 (declare (in) vec3 arg0)
17 (declare (in) vec3 arg1))
18 ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))
19
20 (signature vec4
21 (parameters
22 (declare (in) vec4 arg0)
23 (declare (in) vec4 arg1))
24 ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))
25
26 (signature vec2
27 (parameters
28 (declare (in) vec2 arg0)
29 (declare (in) float arg1))
30 ((return (expression vec2 % (var_ref arg0) (var_ref arg1)))))
31
32 (signature vec3
33 (parameters
34 (declare (in) vec3 arg0)
35 (declare (in) float arg1))
36 ((return (expression vec3 % (var_ref arg0) (var_ref arg1)))))
37
38 (signature vec4
39 (parameters
40 (declare (in) vec4 arg0)
41 (declare (in) float arg1))
42 ((return (expression vec4 % (var_ref arg0) (var_ref arg1)))))
43))
diff --git a/src/glsl/builtins/ir/noise1 b/src/glsl/builtins/ir/noise1
new file mode 100644
index 00000000000..eb7be358575
--- /dev/null
+++ b/src/glsl/builtins/ir/noise1
@@ -0,0 +1,18 @@
1((function noise1
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (constant float (0)))))
6 (signature float
7 (parameters
8 (declare (in) vec2 x))
9 ((return (constant float (0)))))
10 (signature float
11 (parameters
12 (declare (in) vec3 x))
13 ((return (constant float (0)))))
14 (signature float
15 (parameters
16 (declare (in) vec4 x))
17 ((return (constant float (0)))))
18))
diff --git a/src/glsl/builtins/ir/noise2 b/src/glsl/builtins/ir/noise2
new file mode 100644
index 00000000000..ae4443a704a
--- /dev/null
+++ b/src/glsl/builtins/ir/noise2
@@ -0,0 +1,18 @@
1((function noise2
2 (signature vec2
3 (parameters
4 (declare (in) float x))
5 ((return (constant vec2 (0 0)))))
6 (signature vec2
7 (parameters
8 (declare (in) vec2 x))
9 ((return (constant vec2 (0 0)))))
10 (signature vec2
11 (parameters
12 (declare (in) vec3 x))
13 ((return (constant vec2 (0 0)))))
14 (signature vec2
15 (parameters
16 (declare (in) vec4 x))
17 ((return (constant vec2 (0 0)))))
18))
diff --git a/src/glsl/builtins/ir/noise3 b/src/glsl/builtins/ir/noise3
new file mode 100644
index 00000000000..30d9681890e
--- /dev/null
+++ b/src/glsl/builtins/ir/noise3
@@ -0,0 +1,18 @@
1((function noise3
2 (signature vec3
3 (parameters
4 (declare (in) float x))
5 ((return (constant vec3 (0 0 0)))))
6 (signature vec3
7 (parameters
8 (declare (in) vec2 x))
9 ((return (constant vec3 (0 0 0)))))
10 (signature vec3
11 (parameters
12 (declare (in) vec3 x))
13 ((return (constant vec3 (0 0 0)))))
14 (signature vec3
15 (parameters
16 (declare (in) vec4 x))
17 ((return (constant vec3 (0 0 0)))))
18))
diff --git a/src/glsl/builtins/ir/noise4 b/src/glsl/builtins/ir/noise4
new file mode 100644
index 00000000000..913bef2aa1b
--- /dev/null
+++ b/src/glsl/builtins/ir/noise4
@@ -0,0 +1,18 @@
1((function noise4
2 (signature vec4
3 (parameters
4 (declare (in) float x))
5 ((return (constant vec4 (0 0 0 0)))))
6 (signature vec4
7 (parameters
8 (declare (in) vec2 x))
9 ((return (constant vec4 (0 0 0 0)))))
10 (signature vec4
11 (parameters
12 (declare (in) vec3 x))
13 ((return (constant vec4 (0 0 0 0)))))
14 (signature vec4
15 (parameters
16 (declare (in) vec4 x))
17 ((return (constant vec4 (0 0 0 0)))))
18))
diff --git a/src/glsl/builtins/ir/normalize b/src/glsl/builtins/ir/normalize
new file mode 100644
index 00000000000..be88a9830d1
--- /dev/null
+++ b/src/glsl/builtins/ir/normalize
@@ -0,0 +1,21 @@
1((function normalize
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 * (var_ref arg0) (expression float rsq (expression float dot (var_ref arg0) (var_ref arg0)))))))
21))
diff --git a/src/glsl/builtins/ir/not b/src/glsl/builtins/ir/not
new file mode 100644
index 00000000000..b696b06557f
--- /dev/null
+++ b/src/glsl/builtins/ir/not
@@ -0,0 +1,16 @@
1((function not
2 (signature bvec2
3 (parameters
4 (declare (in) bvec2 arg0))
5 ((return (expression bvec2 ! (var_ref arg0)))))
6
7 (signature bvec3
8 (parameters
9 (declare (in) bvec3 arg0))
10 ((return (expression bvec3 ! (var_ref arg0)))))
11
12 (signature bvec4
13 (parameters
14 (declare (in) bvec4 arg0))
15 ((return (expression bvec4 ! (var_ref arg0)))))
16))
diff --git a/src/glsl/builtins/ir/notEqual b/src/glsl/builtins/ir/notEqual
new file mode 100644
index 00000000000..bcc7339bb6e
--- /dev/null
+++ b/src/glsl/builtins/ir/notEqual
@@ -0,0 +1,91 @@
1((function notEqual
2 (signature bvec2
3 (parameters
4 (declare (in) vec2 arg0)
5 (declare (in) vec2 arg1))
6 ((declare () bvec2 temp)
7 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
8 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
9 (return (var_ref temp))))
10
11 (signature bvec3
12 (parameters
13 (declare (in) vec3 arg0)
14 (declare (in) vec3 arg1))
15 ((declare () bvec3 temp)
16 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
17 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
18 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
19 (return (var_ref temp))))
20
21 (signature bvec4
22 (parameters
23 (declare (in) vec4 arg0)
24 (declare (in) vec4 arg1))
25 ((declare () bvec4 temp)
26 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
27 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
28 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
29 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
30 (return (var_ref temp))))
31
32 (signature bvec2
33 (parameters
34 (declare (in) ivec2 arg0)
35 (declare (in) ivec2 arg1))
36 ((declare () bvec2 temp)
37 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
38 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
39 (return (var_ref temp))))
40
41 (signature bvec3
42 (parameters
43 (declare (in) ivec3 arg0)
44 (declare (in) ivec3 arg1))
45 ((declare () bvec3 temp)
46 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
47 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
48 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
49 (return (var_ref temp))))
50
51 (signature bvec4
52 (parameters
53 (declare (in) ivec4 arg0)
54 (declare (in) ivec4 arg1))
55 ((declare () bvec4 temp)
56 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
57 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
58 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
59 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
60 (return (var_ref temp))))
61
62 (signature bvec2
63 (parameters
64 (declare (in) uvec2 arg0)
65 (declare (in) uvec2 arg1))
66 ((declare () bvec2 temp)
67 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
68 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
69 (return (var_ref temp))))
70
71 (signature bvec3
72 (parameters
73 (declare (in) uvec3 arg0)
74 (declare (in) uvec3 arg1))
75 ((declare () bvec3 temp)
76 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
77 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
78 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
79 (return (var_ref temp))))
80
81 (signature bvec4
82 (parameters
83 (declare (in) uvec4 arg0)
84 (declare (in) uvec4 arg1))
85 ((declare () bvec4 temp)
86 (assign (constant bool (1)) (swiz x (var_ref temp)) (expression bool != (swiz x (var_ref arg0))(swiz x (var_ref arg1))))
87 (assign (constant bool (1)) (swiz y (var_ref temp)) (expression bool != (swiz y (var_ref arg0))(swiz y (var_ref arg1))))
88 (assign (constant bool (1)) (swiz z (var_ref temp)) (expression bool != (swiz z (var_ref arg0))(swiz z (var_ref arg1))))
89 (assign (constant bool (1)) (swiz w (var_ref temp)) (expression bool != (swiz w (var_ref arg0))(swiz w (var_ref arg1))))
90 (return (var_ref temp))))
91))
diff --git a/src/glsl/builtins/ir/outerProduct b/src/glsl/builtins/ir/outerProduct
new file mode 100644
index 00000000000..69ae741e176
--- /dev/null
+++ b/src/glsl/builtins/ir/outerProduct
@@ -0,0 +1,92 @@
1((function outerProduct
2 (signature mat2
3 (parameters
4 (declare (in) vec2 u)
5 (declare (in) vec2 v))
6 ((declare () mat2 m)
7 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
8 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
9 (return (var_ref m))))
10
11 (signature mat2x3
12 (parameters
13 (declare (in) vec3 u)
14 (declare (in) vec2 v))
15 ((declare () mat2x3 m)
16 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
17 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
18 (return (var_ref m))))
19
20 (signature mat2x4
21 (parameters
22 (declare (in) vec4 u)
23 (declare (in) vec2 v))
24 ((declare () mat2x4 m)
25 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
26 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
27 (return (var_ref m))))
28
29 (signature mat3x2
30 (parameters
31 (declare (in) vec2 u)
32 (declare (in) vec3 v))
33 ((declare () mat3x2 m)
34 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
35 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
36 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))
37 (return (var_ref m))
38 ))
39
40 (signature mat3
41 (parameters
42 (declare (in) vec3 u)
43 (declare (in) vec3 v))
44 ((declare () mat3 m)
45 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
46 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
47 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))
48 (return (var_ref m))))
49
50 (signature mat3x4
51 (parameters
52 (declare (in) vec4 u)
53 (declare (in) vec3 v))
54 ((declare () mat3x4 m)
55 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
56 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
57 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))
58 (return (var_ref m))))
59
60 (signature mat4x2
61 (parameters
62 (declare (in) vec2 u)
63 (declare (in) vec4 v))
64 ((declare () mat4x2 m)
65 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
66 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
67 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))
68 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))
69 (return (var_ref m))))
70
71 (signature mat4x3
72 (parameters
73 (declare (in) vec3 u)
74 (declare (in) vec4 v))
75 ((declare () mat4x3 m)
76 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
77 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
78 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))
79 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))
80 (return (var_ref m))))
81
82 (signature mat4
83 (parameters
84 (declare (in) vec4 u)
85 (declare (in) vec4 v))
86 ((declare () mat4 m)
87 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
88 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
89 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))
90 (assign (constant bool (1)) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))
91 (return (var_ref m))))
92))
diff --git a/src/glsl/builtins/ir/pow b/src/glsl/builtins/ir/pow
new file mode 100644
index 00000000000..a61bc4418e3
--- /dev/null
+++ b/src/glsl/builtins/ir/pow
@@ -0,0 +1,25 @@
1((function pow
2 (signature float
3 (parameters
4 (declare (in) float arg0)
5 (declare (in) float arg1))
6 ((return (expression float pow (var_ref arg0) (var_ref arg1)))))
7
8 (signature vec2
9 (parameters
10 (declare (in) vec2 arg0)
11 (declare (in) vec2 arg1))
12 ((return (expression vec2 pow (var_ref arg0) (var_ref arg1)))))
13
14 (signature vec3
15 (parameters
16 (declare (in) vec3 arg0)
17 (declare (in) vec3 arg1))
18 ((return (expression vec3 pow (var_ref arg0) (var_ref arg1)))))
19
20 (signature vec4
21 (parameters
22 (declare (in) vec4 arg0)
23 (declare (in) vec4 arg1))
24 ((return (expression vec4 pow (var_ref arg0) (var_ref arg1)))))
25))
diff --git a/src/glsl/builtins/ir/radians b/src/glsl/builtins/ir/radians
new file mode 100644
index 00000000000..6a0f5d2e219
--- /dev/null
+++ b/src/glsl/builtins/ir/radians
@@ -0,0 +1,21 @@
1((function radians
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float * (var_ref arg0) (constant float (0.017453))))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 * (var_ref arg0) (constant float (0.017453))))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 * (var_ref arg0) (constant float (0.017453))))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 * (var_ref arg0) (constant float (0.017453))))))
21))
diff --git a/src/glsl/builtins/ir/reflect b/src/glsl/builtins/ir/reflect
new file mode 100644
index 00000000000..8238fdc93fd
--- /dev/null
+++ b/src/glsl/builtins/ir/reflect
@@ -0,0 +1,58 @@
1((function reflect
2 (signature float
3 (parameters
4 (declare (in) float i)
5 (declare (in) float n))
6 ((return (expression float -
7 (var_ref i)
8 (expression float *
9 (constant float (2.0))
10 (expression float *
11 (expression float dot
12 (var_ref n)
13 (var_ref i))
14 (var_ref n)))))))
15
16 (signature vec2
17 (parameters
18 (declare (in) vec2 i)
19 (declare (in) vec2 n))
20 ((return (expression vec2 -
21 (var_ref i)
22 (expression vec2 *
23 (constant float (2.0))
24 (expression vec2 *
25 (expression float dot
26 (var_ref n)
27 (var_ref i))
28 (var_ref n)))))))
29
30 (signature vec3
31 (parameters
32 (declare (in) vec3 i)
33 (declare (in) vec3 n))
34 ((return (expression vec3 -
35 (var_ref i)
36 (expression vec3 *
37 (constant float (2.0))
38 (expression vec3 *
39 (expression float dot
40 (var_ref n)
41 (var_ref i))
42 (var_ref n)))))))
43
44 (signature vec4
45 (parameters
46 (declare (in) vec4 i)
47 (declare (in) vec4 n))
48 ((return (expression vec4 -
49 (var_ref i)
50 (expression vec4 *
51 (constant float (2.0))
52 (expression vec4 *
53 (expression float dot
54 (var_ref n)
55 (var_ref i))
56 (var_ref n)))))))
57
58))
diff --git a/src/glsl/builtins/ir/refract b/src/glsl/builtins/ir/refract
new file mode 100644
index 00000000000..522ab411734
--- /dev/null
+++ b/src/glsl/builtins/ir/refract
@@ -0,0 +1,102 @@
1((function refract
2 (signature float
3 (parameters
4 (declare (in) float i)
5 (declare (in) float n)
6 (declare (in) float eta))
7 ((declare () float k)
8 (assign (constant bool (1)) (var_ref k)
9 (expression float - (constant float (1.0))
10 (expression float * (var_ref eta)
11 (expression float * (var_ref eta)
12 (expression float - (constant float (1.0))
13 (expression float *
14 (expression float dot (var_ref n) (var_ref i))
15 (expression float dot (var_ref n) (var_ref i))))))))
16 (if (expression bool < (var_ref k) (constant float (0.0)))
17 ((return (constant float (0.0))))
18 ((return (expression float -
19 (expression float * (var_ref eta) (var_ref i))
20 (expression float *
21 (expression float +
22 (expression float * (var_ref eta)
23 (expression float dot (var_ref n) (var_ref i)))
24 (expression float sqrt (var_ref k)))
25 (var_ref n))))))))
26
27 (signature vec2
28 (parameters
29 (declare (in) vec2 i)
30 (declare (in) vec2 n)
31 (declare (in) float eta))
32 ((declare () float k)
33 (assign (constant bool (1)) (var_ref k)
34 (expression float - (constant float (1.0))
35 (expression float * (var_ref eta)
36 (expression float * (var_ref eta)
37 (expression float - (constant float (1.0))
38 (expression float *
39 (expression float dot (var_ref n) (var_ref i))
40 (expression float dot (var_ref n) (var_ref i))))))))
41 (if (expression bool < (var_ref k) (constant float (0.0)))
42 ((return (constant vec2 (0.0 0.0))))
43 ((return (expression vec2 -
44 (expression vec2 * (var_ref eta) (var_ref i))
45 (expression vec2 *
46 (expression float +
47 (expression float * (var_ref eta)
48 (expression float dot (var_ref n) (var_ref i)))
49 (expression float sqrt (var_ref k)))
50 (var_ref n))))))))
51
52 (signature vec3
53 (parameters
54 (declare (in) vec3 i)
55 (declare (in) vec3 n)
56 (declare (in) float eta))
57 ((declare () float k)
58 (assign (constant bool (1)) (var_ref k)
59 (expression float - (constant float (1.0))
60 (expression float * (var_ref eta)
61 (expression float * (var_ref eta)
62 (expression float - (constant float (1.0))
63 (expression float *
64 (expression float dot (var_ref n) (var_ref i))
65 (expression float dot (var_ref n) (var_ref i))))))))
66 (if (expression bool < (var_ref k) (constant float (0.0)))
67 ((return (constant vec3 (0.0 0.0 0.0))))
68 ((return (expression vec3 -
69 (expression vec3 * (var_ref eta) (var_ref i))
70 (expression vec3 *
71 (expression float +
72 (expression float * (var_ref eta)
73 (expression float dot (var_ref n) (var_ref i)))
74 (expression float sqrt (var_ref k)))
75 (var_ref n))))))))
76
77 (signature vec4
78 (parameters
79 (declare (in) vec4 i)
80 (declare (in) vec4 n)
81 (declare (in) float eta))
82 ((declare () float k)
83 (assign (constant bool (1)) (var_ref k)
84 (expression float - (constant float (1.0))
85 (expression float * (var_ref eta)
86 (expression float * (var_ref eta)
87 (expression float - (constant float (1.0))
88 (expression float *
89 (expression float dot (var_ref n) (var_ref i))
90 (expression float dot (var_ref n) (var_ref i))))))))
91 (if (expression bool < (var_ref k) (constant float (0.0)))
92 ((return (constant vec4 (0.0 0.0 0.0 0.0))))
93 ((return (expression vec4 -
94 (expression vec4 * (var_ref eta) (var_ref i))
95 (expression vec4 *
96 (expression float +
97 (expression float * (var_ref eta)
98 (expression float dot (var_ref n) (var_ref i)))
99 (expression float sqrt (var_ref k)))
100 (var_ref n))))))))
101
102))
diff --git a/src/glsl/builtins/ir/sign b/src/glsl/builtins/ir/sign
new file mode 100644
index 00000000000..1f51718dab1
--- /dev/null
+++ b/src/glsl/builtins/ir/sign
@@ -0,0 +1,42 @@
1((function sign
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (expression float sign (var_ref x)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 x))
10 ((return (expression vec2 sign (var_ref x)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 x))
15 ((return (expression vec3 sign (var_ref x)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 x))
20 ((return (expression vec4 sign (var_ref x)))))
21
22 (signature int
23 (parameters
24 (declare (in) int x))
25 ((return (expression int sign (var_ref x)))))
26
27 (signature ivec2
28 (parameters
29 (declare (in) ivec2 x))
30 ((return (expression ivec2 sign (var_ref x)))))
31
32 (signature ivec3
33 (parameters
34 (declare (in) ivec3 x))
35 ((return (expression ivec3 sign (var_ref x)))))
36
37 (signature ivec4
38 (parameters
39 (declare (in) ivec4 x))
40 ((return (expression ivec4 sign (var_ref x)))))
41))
42
diff --git a/src/glsl/builtins/ir/sin b/src/glsl/builtins/ir/sin
new file mode 100644
index 00000000000..e6009d8ef12
--- /dev/null
+++ b/src/glsl/builtins/ir/sin
@@ -0,0 +1,21 @@
1((function sin
2 (signature float
3 (parameters
4 (declare (in) float angle))
5 ((return (expression float sin (var_ref angle)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 angle))
10 ((return (expression vec2 sin (var_ref angle)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 angle))
15 ((return (expression vec3 sin (var_ref angle)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 angle))
20 ((return (expression vec4 sin (var_ref angle)))))
21))
diff --git a/src/glsl/builtins/ir/sinh b/src/glsl/builtins/ir/sinh
new file mode 100644
index 00000000000..7ad4f58e204
--- /dev/null
+++ b/src/glsl/builtins/ir/sinh
@@ -0,0 +1,30 @@
1((function sinh
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (expression float * (constant float (0.5))
6 (expression float -
7 (expression float exp (var_ref x))
8 (expression float exp (expression float neg (var_ref x))))))))
9 (signature vec2
10 (parameters
11 (declare (in) vec2 x))
12 ((return (expression vec2 * (constant vec2 (0.5))
13 (expression vec2 -
14 (expression vec2 exp (var_ref x))
15 (expression vec2 exp (expression vec2 neg (var_ref x))))))))
16 (signature vec3
17 (parameters
18 (declare (in) vec3 x))
19 ((return (expression vec3 * (constant vec3 (0.5))
20 (expression vec3 -
21 (expression vec3 exp (var_ref x))
22 (expression vec3 exp (expression vec3 neg (var_ref x))))))))
23 (signature vec4
24 (parameters
25 (declare (in) vec4 x))
26 ((return (expression vec4 * (constant vec4 (0.5))
27 (expression vec4 -
28 (expression vec4 exp (var_ref x))
29 (expression vec4 exp (expression vec4 neg (var_ref x))))))))
30))
diff --git a/src/glsl/builtins/ir/smoothstep b/src/glsl/builtins/ir/smoothstep
new file mode 100644
index 00000000000..663eec63419
--- /dev/null
+++ b/src/glsl/builtins/ir/smoothstep
@@ -0,0 +1,153 @@
1((function smoothstep
2 (signature float
3 (parameters
4 (declare (in) float edge0)
5 (declare (in) float edge1)
6 (declare (in) float x))
7 ((declare () float t)
8
9 (assign (constant bool (1)) (var_ref t)
10 (expression float max
11 (expression float min
12 (expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
13 (constant float (1.0)))
14 (constant float (0.0))))
15 (return (expression float * (var_ref t) (expression float * (var_ref t) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (var_ref t))))))))
16
17 (signature vec2
18 (parameters
19 (declare (in) float edge0)
20 (declare (in) float edge1)
21 (declare (in) vec2 x))
22 ((declare () vec2 t)
23 (declare () vec2 retval)
24
25 (assign (constant bool (1)) (swiz x (var_ref t))
26 (expression float max
27 (expression float min
28 (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
29 (constant float (1.0)))
30 (constant float (0.0))))
31 (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))
32
33 (assign (constant bool (1)) (swiz y (var_ref t))
34 (expression float max
35 (expression float min
36 (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
37 (constant float (1.0)))
38 (constant float (0.0))))
39 (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))
40 (return (var_ref retval))
41 ))
42
43 (signature vec3
44 (parameters
45 (declare (in) float edge0)
46 (declare (in) float edge1)
47 (declare (in) vec3 x))
48 ((declare () vec3 t)
49 (declare () vec3 retval)
50
51 (assign (constant bool (1)) (swiz x (var_ref t))
52 (expression float max
53 (expression float min
54 (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
55 (constant float (1.0)))
56 (constant float (0.0))))
57 (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))
58
59 (assign (constant bool (1)) (swiz y (var_ref t))
60 (expression float max
61 (expression float min
62 (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
63 (constant float (1.0)))
64 (constant float (0.0))))
65 (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))
66
67 (assign (constant bool (1)) (swiz z (var_ref t))
68 (expression float max
69 (expression float min
70 (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
71 (constant float (1.0)))
72 (constant float (0.0))))
73 (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))
74 (return (var_ref retval))
75 ))
76
77
78 (signature vec4
79 (parameters
80 (declare (in) float edge0)
81 (declare (in) float edge1)
82 (declare (in) vec4 x))
83 ((declare () vec4 t)
84 (declare () vec4 retval)
85
86 (assign (constant bool (1)) (swiz x (var_ref t))
87 (expression float max
88 (expression float min
89 (expression float / (expression float - (swiz x (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
90 (constant float (1.0)))
91 (constant float (0.0))))
92 (assign (constant bool (1)) (swiz x (var_ref retval)) (expression float * (swiz x (var_ref t)) (expression float * (swiz x (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz x (var_ref t)))))))
93
94 (assign (constant bool (1)) (swiz y (var_ref t))
95 (expression float max
96 (expression float min
97 (expression float / (expression float - (swiz y (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
98 (constant float (1.0)))
99 (constant float (0.0))))
100 (assign (constant bool (1)) (swiz y (var_ref retval)) (expression float * (swiz y (var_ref t)) (expression float * (swiz y (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz y (var_ref t)))))))
101
102 (assign (constant bool (1)) (swiz z (var_ref t))
103 (expression float max
104 (expression float min
105 (expression float / (expression float - (swiz z (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
106 (constant float (1.0)))
107 (constant float (0.0))))
108 (assign (constant bool (1)) (swiz z (var_ref retval)) (expression float * (swiz z (var_ref t)) (expression float * (swiz z (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz z (var_ref t)))))))
109
110 (assign (constant bool (1)) (swiz w (var_ref t))
111 (expression float max
112 (expression float min
113 (expression float / (expression float - (swiz w (var_ref x)) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
114 (constant float (1.0)))
115 (constant float (0.0))))
116 (assign (constant bool (1)) (swiz w (var_ref retval)) (expression float * (swiz w (var_ref t)) (expression float * (swiz w (var_ref t)) (expression float - (constant float (3.000000)) (expression float * (constant float (2.000000)) (swiz w (var_ref t)))))))
117 (return (var_ref retval))
118 ))
119
120 (signature vec2
121 (parameters
122 (declare (in) vec2 edge0)
123 (declare (in) vec2 edge1)
124 (declare (in) vec2 x))
125 ((return (expression vec2 max
126 (expression vec2 min
127 (expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))
128 (constant vec2 (1.0 1.0)))
129 (constant vec2 (0.0 0.0))))))
130
131 (signature vec3
132 (parameters
133 (declare (in) vec3 edge0)
134 (declare (in) vec3 edge1)
135 (declare (in) vec3 x))
136 ((return (expression vec3 max
137 (expression vec3 min
138 (expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))
139 (constant vec3 (1.0 1.0 1.0)))
140 (constant vec3 (0.0 0.0 0.0))))))
141
142 (signature vec4
143 (parameters
144 (declare (in) vec4 edge0)
145 (declare (in) vec4 edge1)
146 (declare (in) vec4 x))
147 ((return (expression vec4 max
148 (expression vec4 min
149 (expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))
150 (constant vec4 (1.0 1.0 1.0 1.0)))
151 (constant vec4 (0.0 0.0 0.0 0.0))))))
152))
153
diff --git a/src/glsl/builtins/ir/sqrt b/src/glsl/builtins/ir/sqrt
new file mode 100644
index 00000000000..0302d164ae5
--- /dev/null
+++ b/src/glsl/builtins/ir/sqrt
@@ -0,0 +1,21 @@
1((function sqrt
2 (signature float
3 (parameters
4 (declare (in) float arg0))
5 ((return (expression float sqrt (var_ref arg0)))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 arg0))
10 ((return (expression vec2 sqrt (var_ref arg0)))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 arg0))
15 ((return (expression vec3 sqrt (var_ref arg0)))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 arg0))
20 ((return (expression vec4 sqrt (var_ref arg0)))))
21))
diff --git a/src/glsl/builtins/ir/step b/src/glsl/builtins/ir/step
new file mode 100644
index 00000000000..ce6f4354228
--- /dev/null
+++ b/src/glsl/builtins/ir/step
@@ -0,0 +1,68 @@
1((function step
2 (signature float
3 (parameters
4 (declare (in) float edge)
5 (declare (in) float x))
6 ((return (expression float b2f (expression bool >= (var_ref x) (var_ref edge))))))
7
8 (signature vec2
9 (parameters
10 (declare (in) float edge)
11 (declare (in) vec2 x))
12 ((declare () vec2 t)
13 (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
14 (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
15 (return (var_ref t))))
16
17 (signature vec3
18 (parameters
19 (declare (in) float edge)
20 (declare (in) vec3 x))
21 ((declare () vec3 t)
22 (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
23 (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
24 (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))
25 (return (var_ref t))))
26
27 (signature vec4
28 (parameters
29 (declare (in) float edge)
30 (declare (in) vec4 x))
31 ((declare () vec4 t)
32 (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
33 (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
34 (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))
35 (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))
36 (return (var_ref t))))
37
38 (signature vec2
39 (parameters
40 (declare (in) vec2 edge)
41 (declare (in) vec2 x))
42 ((declare () vec2 t)
43 (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
44 (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
45 (return (var_ref t))))
46
47 (signature vec3
48 (parameters
49 (declare (in) vec3 edge)
50 (declare (in) vec3 x))
51 ((declare () vec3 t)
52 (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
53 (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
54 (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))
55 (return (var_ref t))))
56
57 (signature vec4
58 (parameters
59 (declare (in) vec4 edge)
60 (declare (in) vec4 x))
61 ((declare () vec4 t)
62 (assign (constant bool (1)) (swiz x (var_ref t)) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
63 (assign (constant bool (1)) (swiz y (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
64 (assign (constant bool (1)) (swiz z (var_ref t)) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz z (var_ref edge)))))
65 (assign (constant bool (1)) (swiz w (var_ref t)) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))
66 (return (var_ref t))))
67))
68
diff --git a/src/glsl/builtins/ir/tan b/src/glsl/builtins/ir/tan
new file mode 100644
index 00000000000..99798631859
--- /dev/null
+++ b/src/glsl/builtins/ir/tan
@@ -0,0 +1,21 @@
1((function tan
2 (signature float
3 (parameters
4 (declare (in) float angle))
5 ((return (expression float / (expression float sin (var_ref angle)) (expression float cos (var_ref angle))))))
6
7 (signature vec2
8 (parameters
9 (declare (in) vec2 angle))
10 ((return (expression vec2 / (expression vec2 sin (var_ref angle)) (expression vec2 cos (var_ref angle))))))
11
12 (signature vec3
13 (parameters
14 (declare (in) vec3 angle))
15 ((return (expression vec3 / (expression vec3 sin (var_ref angle)) (expression vec3 cos (var_ref angle))))))
16
17 (signature vec4
18 (parameters
19 (declare (in) vec4 angle))
20 ((return (expression vec4 / (expression vec4 sin (var_ref angle)) (expression vec4 cos (var_ref angle))))))
21))
diff --git a/src/glsl/builtins/ir/tanh b/src/glsl/builtins/ir/tanh
new file mode 100644
index 00000000000..3b7271bf779
--- /dev/null
+++ b/src/glsl/builtins/ir/tanh
@@ -0,0 +1,42 @@
1((function tanh
2 (signature float
3 (parameters
4 (declare (in) float x))
5 ((return (expression float /
6 (expression float -
7 (expression float exp (var_ref x))
8 (expression float exp (expression float neg (var_ref x))))
9 (expression float +
10 (expression float exp (var_ref x))
11 (expression float exp (expression float neg (var_ref x))))))))
12 (signature vec2
13 (parameters
14 (declare (in) vec2 x))
15 ((return (expression vec2 /
16 (expression vec2 -
17 (expression vec2 exp (var_ref x))
18 (expression vec2 exp (expression vec2 neg (var_ref x))))
19 (expression vec2 +
20 (expression vec2 exp (var_ref x))
21 (expression vec2 exp (expression vec2 neg (var_ref x))))))))
22 (signature vec3
23 (parameters
24 (declare (in) vec3 x))
25 ((return (expression vec3 /
26 (expression vec3 -
27 (expression vec3 exp (var_ref x))
28 (expression vec3 exp (expression vec3 neg (var_ref x))))
29 (expression vec3 +
30 (expression vec3 exp (var_ref x))
31 (expression vec3 exp (expression vec3 neg (var_ref x))))))))
32 (signature vec4
33 (parameters
34 (declare (in) vec4 x))
35 ((return (expression vec4 /
36 (expression vec4 -
37 (expression vec4 exp (var_ref x))
38 (expression vec4 exp (expression vec4 neg (var_ref x))))
39 (expression vec4 +
40 (expression vec4 exp (var_ref x))
41 (expression vec4 exp (expression vec4 neg (var_ref x))))))))
42))
diff --git a/src/glsl/builtins/ir/transpose b/src/glsl/builtins/ir/transpose
new file mode 100644
index 00000000000..416a0ee4677
--- /dev/null
+++ b/src/glsl/builtins/ir/transpose
@@ -0,0 +1,139 @@
1((function transpose
2 (signature mat2
3 (parameters
4 (declare (in) mat2 m))
5 ((declare () mat2 t)
6 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
7 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
8 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
9 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
10(return (var_ref t))))
11
12 (signature mat3x2
13 (parameters
14 (declare (in) mat2x3 m))
15 ((declare () mat3x2 t)
16 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
17 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
18 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0)))))
19 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
20 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
21 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1)))))
22(return (var_ref t))))
23
24 (signature mat4x2
25 (parameters
26 (declare (in) mat2x4 m))
27 ((declare () mat4x2 t)
28 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
29 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
30 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0)))))
31 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0)))))
32 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
33 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
34 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1)))))
35 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1)))))
36(return (var_ref t))))
37
38 (signature mat2x3
39 (parameters
40 (declare (in) mat3x2 m))
41 ((declare () mat2x3 t)
42 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
43 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
44 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
45 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
46 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2)))))
47 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2)))))
48(return (var_ref t))))
49
50 (signature mat3
51 (parameters
52 (declare (in) mat3 m))
53 ((declare () mat3 t)
54 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
55 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
56 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0)))))
57 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
58 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
59 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1)))))
60 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2)))))
61 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2)))))
62 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2)))))
63(return (var_ref t))))
64
65 (signature mat4x3
66 (parameters
67 (declare (in) mat3x4 m))
68 ((declare () mat4x3 t)
69 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
70 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
71 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0)))))
72 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0)))))
73 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
74 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
75 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1)))))
76 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1)))))
77 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2)))))
78 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2)))))
79 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2)))))
80 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2)))))
81(return (var_ref t))))
82
83 (signature mat2x4
84 (parameters
85 (declare (in) mat4x2 m))
86 ((declare () mat2x4 t)
87 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
88 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
89 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
90 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
91 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2)))))
92 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2)))))
93 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3)))))
94 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3)))))
95(return (var_ref t))))
96
97 (signature mat3x4
98 (parameters
99 (declare (in) mat4x3 m))
100 ((declare () mat3x4 t)
101 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
102 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
103 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0)))))
104 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
105 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
106 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1)))))
107 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2)))))
108 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2)))))
109 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2)))))
110 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3)))))
111 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3)))))
112 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3)))))
113(return (var_ref t))))
114
115 (signature mat4
116 (parameters
117 (declare (in) mat4 m))
118 ((declare () mat4 t)
119 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (0)))))
120 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (0)))))
121 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (0)))))
122 (assign (constant bool (1)) (swiz x (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (0)))))
123 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (1)))))
124 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (1)))))
125 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (1)))))
126 (assign (constant bool (1)) (swiz y (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (1)))))
127 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (2)))))
128 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (2)))))
129 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (2)))))
130 (assign (constant bool (1)) (swiz z (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (2)))))
131 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (0)))) (swiz x (array_ref (var_ref m) (constant int (3)))))
132 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (1)))) (swiz y (array_ref (var_ref m) (constant int (3)))))
133 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (2)))) (swiz z (array_ref (var_ref m) (constant int (3)))))
134 (assign (constant bool (1)) (swiz w (array_ref (var_ref t) (constant int (3)))) (swiz w (array_ref (var_ref m) (constant int (3)))))
135(return (var_ref t))))
136)
137
138)
139
diff --git a/src/glsl/builtins/profiles/110.frag b/src/glsl/builtins/profiles/110.frag
new file mode 100644
index 00000000000..25bc62c093c
--- /dev/null
+++ b/src/glsl/builtins/profiles/110.frag
@@ -0,0 +1,364 @@
1#version 110
2/*
3 * 8.1 - Angle and Trigonometry Functions
4 */
5float radians(float degrees);
6vec2 radians(vec2 degrees);
7vec3 radians(vec3 degrees);
8vec4 radians(vec4 degrees);
9
10float degrees(float radians);
11vec2 degrees(vec2 radians);
12vec3 degrees(vec3 radians);
13vec4 degrees(vec4 radians);
14
15float sin(float angle);
16vec2 sin(vec2 angle);
17vec3 sin(vec3 angle);
18vec4 sin(vec4 angle);
19
20float cos(float angle);
21vec2 cos(vec2 angle);
22vec3 cos(vec3 angle);
23vec4 cos(vec4 angle);
24
25float tan(float angle);
26vec2 tan(vec2 angle);
27vec3 tan(vec3 angle);
28vec4 tan(vec4 angle);
29
30float asin(float angle);
31vec2 asin(vec2 angle);
32vec3 asin(vec3 angle);
33vec4 asin(vec4 angle);
34
35float acos(float angle);
36vec2 acos(vec2 angle);
37vec3 acos(vec3 angle);
38vec4 acos(vec4 angle);
39
40float atan(float y, float x);
41vec2 atan(vec2 y, vec2 x);
42vec3 atan(vec3 y, vec3 x);
43vec4 atan(vec4 y, vec4 x);
44
45float atan(float y_over_x);
46vec2 atan(vec2 y_over_x);
47vec3 atan(vec3 y_over_x);
48vec4 atan(vec4 y_over_x);
49
50/*
51 * 8.2 - Exponential Functions
52 */
53float pow(float x, float y);
54vec2 pow(vec2 x, vec2 y);
55vec3 pow(vec3 x, vec3 y);
56vec4 pow(vec4 x, vec4 y);
57
58float exp(float x);
59vec2 exp(vec2 x);
60vec3 exp(vec3 x);
61vec4 exp(vec4 x);
62
63float log(float x);
64vec2 log(vec2 x);
65vec3 log(vec3 x);
66vec4 log(vec4 x);
67
68float exp2(float x);
69vec2 exp2(vec2 x);
70vec3 exp2(vec3 x);
71vec4 exp2(vec4 x);
72
73float log2(float x);
74vec2 log2(vec2 x);
75vec3 log2(vec3 x);
76vec4 log2(vec4 x);
77
78float sqrt(float x);
79vec2 sqrt(vec2 x);
80vec3 sqrt(vec3 x);
81vec4 sqrt(vec4 x);
82
83float inversesqrt(float x);
84vec2 inversesqrt(vec2 x);
85vec3 inversesqrt(vec3 x);
86vec4 inversesqrt(vec4 x);
87
88/*
89 * 8.3 - Common Functions
90 */
91float abs(float x);
92vec2 abs(vec2 x);
93vec3 abs(vec3 x);
94vec4 abs(vec4 x);
95
96float sign(float x);
97vec2 sign(vec2 x);
98vec3 sign(vec3 x);
99vec4 sign(vec4 x);
100
101float floor(float x);
102vec2 floor(vec2 x);
103vec3 floor(vec3 x);
104vec4 floor(vec4 x);
105
106float ceil(float x);
107vec2 ceil(vec2 x);
108vec3 ceil(vec3 x);
109vec4 ceil(vec4 x);
110
111float fract(float x);
112vec2 fract(vec2 x);
113vec3 fract(vec3 x);
114vec4 fract(vec4 x);
115
116float mod(float x, float y);
117vec2 mod(vec2 x, float y);
118vec3 mod(vec3 x, float y);
119vec4 mod(vec4 x, float y);
120
121vec2 mod(vec2 x, vec2 y);
122vec3 mod(vec3 x, vec3 y);
123vec4 mod(vec4 x, vec4 y);
124
125float min(float x, float y);
126vec2 min(vec2 x, vec2 y);
127vec3 min(vec3 x, vec3 y);
128vec4 min(vec4 x, vec4 y);
129
130vec2 min(vec2 x, float y);
131vec3 min(vec3 x, float y);
132vec4 min(vec4 x, float y);
133
134float max(float x, float y);
135vec2 max(vec2 x, vec2 y);
136vec3 max(vec3 x, vec3 y);
137vec4 max(vec4 x, vec4 y);
138
139vec2 max(vec2 x, float y);
140vec3 max(vec3 x, float y);
141vec4 max(vec4 x, float y);
142
143float clamp(float x, float minVal, float maxVal);
144vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
145vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
146vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
147
148vec2 clamp(vec2 x, float minVal, float maxVal);
149vec3 clamp(vec3 x, float minVal, float maxVal);
150vec4 clamp(vec4 x, float minVal, float maxVal);
151
152float mix(float x, float y, float a);
153vec2 mix(vec2 x, vec2 y, vec2 a);
154vec3 mix(vec3 x, vec3 y, vec3 a);
155vec4 mix(vec4 x, vec4 y, vec4 a);
156
157vec2 mix(vec2 x, vec2 y, float a);
158vec3 mix(vec3 x, vec3 y, float a);
159vec4 mix(vec4 x, vec4 y, float a);
160
161float step(float edge, float x);
162vec2 step(vec2 edge, vec2 x);
163vec3 step(vec3 edge, vec3 x);
164vec4 step(vec4 edge, vec4 x);
165
166vec2 step(float edge, vec2 x);
167vec3 step(float edge, vec3 x);
168vec4 step(float edge, vec4 x);
169
170float smoothstep(float edge0, float edge1, float x);
171vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
172vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
173vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
174
175vec2 smoothstep(float edge0, float edge1, vec2 x);
176vec3 smoothstep(float edge0, float edge1, vec3 x);
177vec4 smoothstep(float edge0, float edge1, vec4 x);
178
179/*
180 * 8.4 - Geometric Functions
181 */
182float length(float x);
183float length(vec2 x);
184float length(vec3 x);
185float length(vec4 x);
186
187float distance(float p0, float p1);
188float distance(vec2 p0, vec2 p1);
189float distance(vec3 p0, vec3 p1);
190float distance(vec4 p0, vec4 p1);
191
192float dot(float x, float y);
193float dot(vec2 x, vec2 y);
194float dot(vec3 x, vec3 y);
195float dot(vec4 x, vec4 y);
196
197vec3 cross(vec3 x, vec3 y);
198
199float normalize(float x);
200vec2 normalize(vec2 x);
201vec3 normalize(vec3 x);
202vec4 normalize(vec4 x);
203
204float faceforward(float N, float I, float Nref);
205vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
206vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
207vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
208
209float reflect(float I, float N);
210vec2 reflect(vec2 I, vec2 N);
211vec3 reflect(vec3 I, vec3 N);
212vec4 reflect(vec4 I, vec4 N);
213
214float refract(float I, float N, float eta);
215vec2 refract(vec2 I, vec2 N, float eta);
216vec3 refract(vec3 I, vec3 N, float eta);
217vec4 refract(vec4 I, vec4 N, float eta);
218
219
220/*
221 * 8.5 - Matrix Functions
222 */
223mat2 matrixCompMult(mat2 x, mat2 y);
224mat3 matrixCompMult(mat3 x, mat3 y);
225mat4 matrixCompMult(mat4 x, mat4 y);
226
227/*
228 * 8.6 - Vector Relational Functions
229 */
230bvec2 lessThan( vec2 x, vec2 y);
231bvec3 lessThan( vec3 x, vec3 y);
232bvec4 lessThan( vec4 x, vec4 y);
233bvec2 lessThan(ivec2 x, ivec2 y);
234bvec3 lessThan(ivec3 x, ivec3 y);
235bvec4 lessThan(ivec4 x, ivec4 y);
236
237bvec2 lessThanEqual( vec2 x, vec2 y);
238bvec3 lessThanEqual( vec3 x, vec3 y);
239bvec4 lessThanEqual( vec4 x, vec4 y);
240bvec2 lessThanEqual(ivec2 x, ivec2 y);
241bvec3 lessThanEqual(ivec3 x, ivec3 y);
242bvec4 lessThanEqual(ivec4 x, ivec4 y);
243
244bvec2 greaterThan( vec2 x, vec2 y);
245bvec3 greaterThan( vec3 x, vec3 y);
246bvec4 greaterThan( vec4 x, vec4 y);
247bvec2 greaterThan(ivec2 x, ivec2 y);
248bvec3 greaterThan(ivec3 x, ivec3 y);
249bvec4 greaterThan(ivec4 x, ivec4 y);
250
251bvec2 greaterThanEqual( vec2 x, vec2 y);
252bvec3 greaterThanEqual( vec3 x, vec3 y);
253bvec4 greaterThanEqual( vec4 x, vec4 y);
254bvec2 greaterThanEqual(ivec2 x, ivec2 y);
255bvec3 greaterThanEqual(ivec3 x, ivec3 y);
256bvec4 greaterThanEqual(ivec4 x, ivec4 y);
257
258bvec2 equal( vec2 x, vec2 y);
259bvec3 equal( vec3 x, vec3 y);
260bvec4 equal( vec4 x, vec4 y);
261bvec2 equal(ivec2 x, ivec2 y);
262bvec3 equal(ivec3 x, ivec3 y);
263bvec4 equal(ivec4 x, ivec4 y);
264bvec2 equal(bvec2 x, bvec2 y);
265bvec3 equal(bvec3 x, bvec3 y);
266bvec4 equal(bvec4 x, bvec4 y);
267
268bvec2 notEqual( vec2 x, vec2 y);
269bvec3 notEqual( vec3 x, vec3 y);
270bvec4 notEqual( vec4 x, vec4 y);
271bvec2 notEqual(ivec2 x, ivec2 y);
272bvec3 notEqual(ivec3 x, ivec3 y);
273bvec4 notEqual(ivec4 x, ivec4 y);
274bvec2 notEqual(bvec2 x, bvec2 y);
275bvec3 notEqual(bvec3 x, bvec3 y);
276bvec4 notEqual(bvec4 x, bvec4 y);
277
278bool any(bvec2 x);
279bool any(bvec3 x);
280bool any(bvec4 x);
281
282bool all(bvec2 x);
283bool all(bvec3 x);
284bool all(bvec4 x);
285
286bvec2 not(bvec2 x);
287bvec3 not(bvec3 x);
288bvec4 not(bvec4 x);
289
290/*
291 * 8.7 - Texture Lookup Functions
292 */
293vec4 texture1D (sampler1D sampler, float coord);
294vec4 texture1DProj (sampler1D sampler, vec2 coord);
295vec4 texture1DProj (sampler1D sampler, vec4 coord);
296vec4 texture1D (sampler1D sampler, float coord, float bias);
297vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias);
298vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias);
299
300vec4 texture2D (sampler2D sampler, vec2 coord);
301vec4 texture2DProj (sampler2D sampler, vec3 coord);
302vec4 texture2DProj (sampler2D sampler, vec4 coord);
303vec4 texture2D (sampler2D sampler, vec2 coord, float bias);
304vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias);
305vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias);
306
307vec4 texture3D (sampler3D sampler, vec3 coord);
308vec4 texture3DProj (sampler3D sampler, vec4 coord);
309vec4 texture3D (sampler3D sampler, vec3 coord, float bias);
310vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias);
311
312vec4 textureCube (samplerCube sampler, vec3 coord);
313vec4 textureCube (samplerCube sampler, vec3 coord, float bias);
314
315vec4 shadow1D (sampler1DShadow sampler, vec3 coord);
316vec4 shadow2D (sampler2DShadow sampler, vec3 coord);
317vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord);
318vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord);
319vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias);
320vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias);
321vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias);
322vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias);
323
324
325/*
326 * 8.8 - Fragment Processing Functions
327 */
328float dFdx(float p);
329vec2 dFdx(vec2 p);
330vec3 dFdx(vec3 p);
331vec4 dFdx(vec4 p);
332
333float dFdy(float p);
334vec2 dFdy(vec2 p);
335vec3 dFdy(vec3 p);
336vec4 dFdy(vec4 p);
337
338float fwidth(float p);
339vec2 fwidth(vec2 p);
340vec3 fwidth(vec3 p);
341vec4 fwidth(vec4 p);
342
343/*
344 * 8.9 - Noise Functions
345 */
346float noise1(float x);
347float noise1(vec2 x);
348float noise1(vec3 x);
349float noise1(vec4 x);
350
351vec2 noise2(float x);
352vec2 noise2(vec2 x);
353vec2 noise2(vec3 x);
354vec2 noise2(vec4 x);
355
356vec3 noise3(float x);
357vec3 noise3(vec2 x);
358vec3 noise3(vec3 x);
359vec3 noise3(vec4 x);
360
361vec4 noise4(float x);
362vec4 noise4(vec2 x);
363vec4 noise4(vec3 x);
364vec4 noise4(vec4 x);
diff --git a/src/glsl/builtins/profiles/110.vert b/src/glsl/builtins/profiles/110.vert
new file mode 100644
index 00000000000..545e59c5397
--- /dev/null
+++ b/src/glsl/builtins/profiles/110.vert
@@ -0,0 +1,351 @@
1#version 110
2/*
3 * 8.1 - Angle and Trigonometry Functions
4 */
5float radians(float degrees);
6vec2 radians(vec2 degrees);
7vec3 radians(vec3 degrees);
8vec4 radians(vec4 degrees);
9
10float degrees(float radians);
11vec2 degrees(vec2 radians);
12vec3 degrees(vec3 radians);
13vec4 degrees(vec4 radians);
14
15float sin(float angle);
16vec2 sin(vec2 angle);
17vec3 sin(vec3 angle);
18vec4 sin(vec4 angle);
19
20float cos(float angle);
21vec2 cos(vec2 angle);
22vec3 cos(vec3 angle);
23vec4 cos(vec4 angle);
24
25float tan(float angle);
26vec2 tan(vec2 angle);
27vec3 tan(vec3 angle);
28vec4 tan(vec4 angle);
29
30float asin(float angle);
31vec2 asin(vec2 angle);
32vec3 asin(vec3 angle);
33vec4 asin(vec4 angle);
34
35float acos(float angle);
36vec2 acos(vec2 angle);
37vec3 acos(vec3 angle);
38vec4 acos(vec4 angle);
39
40float atan(float y, float x);
41vec2 atan(vec2 y, vec2 x);
42vec3 atan(vec3 y, vec3 x);
43vec4 atan(vec4 y, vec4 x);
44
45float atan(float y_over_x);
46vec2 atan(vec2 y_over_x);
47vec3 atan(vec3 y_over_x);
48vec4 atan(vec4 y_over_x);
49
50/*
51 * 8.2 - Exponential Functions
52 */
53float pow(float x, float y);
54vec2 pow(vec2 x, vec2 y);
55vec3 pow(vec3 x, vec3 y);
56vec4 pow(vec4 x, vec4 y);
57
58float exp(float x);
59vec2 exp(vec2 x);
60vec3 exp(vec3 x);
61vec4 exp(vec4 x);
62
63float log(float x);
64vec2 log(vec2 x);
65vec3 log(vec3 x);
66vec4 log(vec4 x);
67
68float exp2(float x);
69vec2 exp2(vec2 x);
70vec3 exp2(vec3 x);
71vec4 exp2(vec4 x);
72
73float log2(float x);
74vec2 log2(vec2 x);
75vec3 log2(vec3 x);
76vec4 log2(vec4 x);
77
78float sqrt(float x);
79vec2 sqrt(vec2 x);
80vec3 sqrt(vec3 x);
81vec4 sqrt(vec4 x);
82
83float inversesqrt(float x);
84vec2 inversesqrt(vec2 x);
85vec3 inversesqrt(vec3 x);
86vec4 inversesqrt(vec4 x);
87
88/*
89 * 8.3 - Common Functions
90 */
91float abs(float x);
92vec2 abs(vec2 x);
93vec3 abs(vec3 x);
94vec4 abs(vec4 x);
95
96float sign(float x);
97vec2 sign(vec2 x);
98vec3 sign(vec3 x);
99vec4 sign(vec4 x);
100
101float floor(float x);
102vec2 floor(vec2 x);
103vec3 floor(vec3 x);
104vec4 floor(vec4 x);
105
106float ceil(float x);
107vec2 ceil(vec2 x);
108vec3 ceil(vec3 x);
109vec4 ceil(vec4 x);
110
111float fract(float x);
112vec2 fract(vec2 x);
113vec3 fract(vec3 x);
114vec4 fract(vec4 x);
115
116float mod(float x, float y);
117vec2 mod(vec2 x, float y);
118vec3 mod(vec3 x, float y);
119vec4 mod(vec4 x, float y);
120
121vec2 mod(vec2 x, vec2 y);
122vec3 mod(vec3 x, vec3 y);
123vec4 mod(vec4 x, vec4 y);
124
125float min(float x, float y);
126vec2 min(vec2 x, vec2 y);
127vec3 min(vec3 x, vec3 y);
128vec4 min(vec4 x, vec4 y);
129
130vec2 min(vec2 x, float y);
131vec3 min(vec3 x, float y);
132vec4 min(vec4 x, float y);
133
134float max(float x, float y);
135vec2 max(vec2 x, vec2 y);
136vec3 max(vec3 x, vec3 y);
137vec4 max(vec4 x, vec4 y);
138
139vec2 max(vec2 x, float y);
140vec3 max(vec3 x, float y);
141vec4 max(vec4 x, float y);
142
143float clamp(float x, float minVal, float maxVal);
144vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
145vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
146vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
147
148vec2 clamp(vec2 x, float minVal, float maxVal);
149vec3 clamp(vec3 x, float minVal, float maxVal);
150vec4 clamp(vec4 x, float minVal, float maxVal);
151
152float mix(float x, float y, float a);
153vec2 mix(vec2 x, vec2 y, vec2 a);
154vec3 mix(vec3 x, vec3 y, vec3 a);
155vec4 mix(vec4 x, vec4 y, vec4 a);
156
157vec2 mix(vec2 x, vec2 y, float a);
158vec3 mix(vec3 x, vec3 y, float a);
159vec4 mix(vec4 x, vec4 y, float a);
160
161float step(float edge, float x);
162vec2 step(vec2 edge, vec2 x);
163vec3 step(vec3 edge, vec3 x);
164vec4 step(vec4 edge, vec4 x);
165
166vec2 step(float edge, vec2 x);
167vec3 step(float edge, vec3 x);
168vec4 step(float edge, vec4 x);
169
170float smoothstep(float edge0, float edge1, float x);
171vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
172vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
173vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
174
175vec2 smoothstep(float edge0, float edge1, vec2 x);
176vec3 smoothstep(float edge0, float edge1, vec3 x);
177vec4 smoothstep(float edge0, float edge1, vec4 x);
178
179/*
180 * 8.4 - Geometric Functions
181 */
182float length(float x);
183float length(vec2 x);
184float length(vec3 x);
185float length(vec4 x);
186
187float distance(float p0, float p1);
188float distance(vec2 p0, vec2 p1);
189float distance(vec3 p0, vec3 p1);
190float distance(vec4 p0, vec4 p1);
191
192float dot(float x, float y);
193float dot(vec2 x, vec2 y);
194float dot(vec3 x, vec3 y);
195float dot(vec4 x, vec4 y);
196
197vec3 cross(vec3 x, vec3 y);
198
199float normalize(float x);
200vec2 normalize(vec2 x);
201vec3 normalize(vec3 x);
202vec4 normalize(vec4 x);
203
204vec4 ftransform();
205
206float faceforward(float N, float I, float Nref);
207vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
208vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
209vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
210
211float reflect(float I, float N);
212vec2 reflect(vec2 I, vec2 N);
213vec3 reflect(vec3 I, vec3 N);
214vec4 reflect(vec4 I, vec4 N);
215
216float refract(float I, float N, float eta);
217vec2 refract(vec2 I, vec2 N, float eta);
218vec3 refract(vec3 I, vec3 N, float eta);
219vec4 refract(vec4 I, vec4 N, float eta);
220
221
222/*
223 * 8.5 - Matrix Functions
224 */
225mat2 matrixCompMult(mat2 x, mat2 y);
226mat3 matrixCompMult(mat3 x, mat3 y);
227mat4 matrixCompMult(mat4 x, mat4 y);
228
229/*
230 * 8.6 - Vector Relational Functions
231 */
232bvec2 lessThan( vec2 x, vec2 y);
233bvec3 lessThan( vec3 x, vec3 y);
234bvec4 lessThan( vec4 x, vec4 y);
235bvec2 lessThan(ivec2 x, ivec2 y);
236bvec3 lessThan(ivec3 x, ivec3 y);
237bvec4 lessThan(ivec4 x, ivec4 y);
238
239bvec2 lessThanEqual( vec2 x, vec2 y);
240bvec3 lessThanEqual( vec3 x, vec3 y);
241bvec4 lessThanEqual( vec4 x, vec4 y);
242bvec2 lessThanEqual(ivec2 x, ivec2 y);
243bvec3 lessThanEqual(ivec3 x, ivec3 y);
244bvec4 lessThanEqual(ivec4 x, ivec4 y);
245
246bvec2 greaterThan( vec2 x, vec2 y);
247bvec3 greaterThan( vec3 x, vec3 y);
248bvec4 greaterThan( vec4 x, vec4 y);
249bvec2 greaterThan(ivec2 x, ivec2 y);
250bvec3 greaterThan(ivec3 x, ivec3 y);
251bvec4 greaterThan(ivec4 x, ivec4 y);
252
253bvec2 greaterThanEqual( vec2 x, vec2 y);
254bvec3 greaterThanEqual( vec3 x, vec3 y);
255bvec4 greaterThanEqual( vec4 x, vec4 y);
256bvec2 greaterThanEqual(ivec2 x, ivec2 y);
257bvec3 greaterThanEqual(ivec3 x, ivec3 y);
258bvec4 greaterThanEqual(ivec4 x, ivec4 y);
259
260bvec2 equal( vec2 x, vec2 y);
261bvec3 equal( vec3 x, vec3 y);
262bvec4 equal( vec4 x, vec4 y);
263bvec2 equal(ivec2 x, ivec2 y);
264bvec3 equal(ivec3 x, ivec3 y);
265bvec4 equal(ivec4 x, ivec4 y);
266bvec2 equal(bvec2 x, bvec2 y);
267bvec3 equal(bvec3 x, bvec3 y);
268bvec4 equal(bvec4 x, bvec4 y);
269
270bvec2 notEqual( vec2 x, vec2 y);
271bvec3 notEqual( vec3 x, vec3 y);
272bvec4 notEqual( vec4 x, vec4 y);
273bvec2 notEqual(ivec2 x, ivec2 y);
274bvec3 notEqual(ivec3 x, ivec3 y);
275bvec4 notEqual(ivec4 x, ivec4 y);
276bvec2 notEqual(bvec2 x, bvec2 y);
277bvec3 notEqual(bvec3 x, bvec3 y);
278bvec4 notEqual(bvec4 x, bvec4 y);
279
280bool any(bvec2 x);
281bool any(bvec3 x);
282bool any(bvec4 x);
283
284bool all(bvec2 x);
285bool all(bvec3 x);
286bool all(bvec4 x);
287
288bvec2 not(bvec2 x);
289bvec3 not(bvec3 x);
290bvec4 not(bvec4 x);
291
292/*
293 * 8.7 - Texture Lookup Functions
294 */
295vec4 texture1D (sampler1D sampler, float coord);
296vec4 texture1DProj (sampler1D sampler, vec2 coord);
297vec4 texture1DProj (sampler1D sampler, vec4 coord);
298vec4 texture1DLod (sampler1D sampler, float coord, float lod);
299vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);
300vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);
301
302vec4 texture2D (sampler2D sampler, vec2 coord);
303vec4 texture2DProj (sampler2D sampler, vec3 coord);
304vec4 texture2DProj (sampler2D sampler, vec4 coord);
305vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod);
306vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);
307vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);
308
309vec4 texture3D (sampler3D sampler, vec3 coord);
310vec4 texture3DProj (sampler3D sampler, vec4 coord);
311vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod);
312vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);
313
314vec4 textureCube (samplerCube sampler, vec3 coord);
315vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod);
316
317vec4 shadow1D (sampler1DShadow sampler, vec3 coord);
318vec4 shadow2D (sampler2DShadow sampler, vec3 coord);
319vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord);
320vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord);
321vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod);
322vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod);
323vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);
324vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);
325
326/*
327 * 8.8 - Fragment Processing Functions (none in vertex shader)
328 */
329
330/*
331 * 8.9 - Noise Functions
332 */
333float noise1(float x);
334float noise1(vec2 x);
335float noise1(vec3 x);
336float noise1(vec4 x);
337
338vec2 noise2(float x);
339vec2 noise2(vec2 x);
340vec2 noise2(vec3 x);
341vec2 noise2(vec4 x);
342
343vec3 noise3(float x);
344vec3 noise3(vec2 x);
345vec3 noise3(vec3 x);
346vec3 noise3(vec4 x);
347
348vec4 noise4(float x);
349vec4 noise4(vec2 x);
350vec4 noise4(vec3 x);
351vec4 noise4(vec4 x);
diff --git a/src/glsl/builtins/profiles/120.frag b/src/glsl/builtins/profiles/120.frag
new file mode 100644
index 00000000000..a207435f337
--- /dev/null
+++ b/src/glsl/builtins/profiles/120.frag
@@ -0,0 +1,396 @@
1#version 120
2/*
3 * 8.1 - Angle and Trigonometry Functions
4 */
5float radians(float degrees);
6vec2 radians(vec2 degrees);
7vec3 radians(vec3 degrees);
8vec4 radians(vec4 degrees);
9
10float degrees(float radians);
11vec2 degrees(vec2 radians);
12vec3 degrees(vec3 radians);
13vec4 degrees(vec4 radians);
14
15float sin(float angle);
16vec2 sin(vec2 angle);
17vec3 sin(vec3 angle);
18vec4 sin(vec4 angle);
19
20float cos(float angle);
21vec2 cos(vec2 angle);
22vec3 cos(vec3 angle);
23vec4 cos(vec4 angle);
24
25float tan(float angle);
26vec2 tan(vec2 angle);
27vec3 tan(vec3 angle);
28vec4 tan(vec4 angle);
29
30float asin(float angle);
31vec2 asin(vec2 angle);
32vec3 asin(vec3 angle);
33vec4 asin(vec4 angle);
34
35float acos(float angle);
36vec2 acos(vec2 angle);
37vec3 acos(vec3 angle);
38vec4 acos(vec4 angle);
39
40float atan(float y, float x);
41vec2 atan(vec2 y, vec2 x);
42vec3 atan(vec3 y, vec3 x);
43vec4 atan(vec4 y, vec4 x);
44
45float atan(float y_over_x);
46vec2 atan(vec2 y_over_x);
47vec3 atan(vec3 y_over_x);
48vec4 atan(vec4 y_over_x);
49
50/*
51 * 8.2 - Exponential Functions
52 */
53float pow(float x, float y);
54vec2 pow(vec2 x, vec2 y);
55vec3 pow(vec3 x, vec3 y);
56vec4 pow(vec4 x, vec4 y);
57
58float exp(float x);
59vec2 exp(vec2 x);
60vec3 exp(vec3 x);
61vec4 exp(vec4 x);
62
63float log(float x);
64vec2 log(vec2 x);
65vec3 log(vec3 x);
66vec4 log(vec4 x);
67
68float exp2(float x);
69vec2 exp2(vec2 x);
70vec3 exp2(vec3 x);
71vec4 exp2(vec4 x);
72
73float log2(float x);
74vec2 log2(vec2 x);
75vec3 log2(vec3 x);
76vec4 log2(vec4 x);
77
78float sqrt(float x);
79vec2 sqrt(vec2 x);
80vec3 sqrt(vec3 x);
81vec4 sqrt(vec4 x);
82
83float inversesqrt(float x);
84vec2 inversesqrt(vec2 x);
85vec3 inversesqrt(vec3 x);
86vec4 inversesqrt(vec4 x);
87
88/*
89 * 8.3 - Common Functions
90 */
91float abs(float x);
92vec2 abs(vec2 x);
93vec3 abs(vec3 x);
94vec4 abs(vec4 x);
95
96float sign(float x);
97vec2 sign(vec2 x);
98vec3 sign(vec3 x);
99vec4 sign(vec4 x);
100
101float floor(float x);
102vec2 floor(vec2 x);
103vec3 floor(vec3 x);
104vec4 floor(vec4 x);
105
106float ceil(float x);
107vec2 ceil(vec2 x);
108vec3 ceil(vec3 x);
109vec4 ceil(vec4 x);
110
111float fract(float x);
112vec2 fract(vec2 x);
113vec3 fract(vec3 x);
114vec4 fract(vec4 x);
115
116float mod(float x, float y);
117vec2 mod(vec2 x, float y);
118vec3 mod(vec3 x, float y);
119vec4 mod(vec4 x, float y);
120
121vec2 mod(vec2 x, vec2 y);
122vec3 mod(vec3 x, vec3 y);
123vec4 mod(vec4 x, vec4 y);
124
125float min(float x, float y);
126vec2 min(vec2 x, vec2 y);
127vec3 min(vec3 x, vec3 y);
128vec4 min(vec4 x, vec4 y);
129
130vec2 min(vec2 x, float y);
131vec3 min(vec3 x, float y);
132vec4 min(vec4 x, float y);
133
134float max(float x, float y);
135vec2 max(vec2 x, vec2 y);
136vec3 max(vec3 x, vec3 y);
137vec4 max(vec4 x, vec4 y);
138
139vec2 max(vec2 x, float y);
140vec3 max(vec3 x, float y);
141vec4 max(vec4 x, float y);
142
143float clamp(float x, float minVal, float maxVal);
144vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
145vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
146vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
147
148vec2 clamp(vec2 x, float minVal, float maxVal);
149vec3 clamp(vec3 x, float minVal, float maxVal);
150vec4 clamp(vec4 x, float minVal, float maxVal);
151
152float mix(float x, float y, float a);
153vec2 mix(vec2 x, vec2 y, vec2 a);
154vec3 mix(vec3 x, vec3 y, vec3 a);
155vec4 mix(vec4 x, vec4 y, vec4 a);
156
157vec2 mix(vec2 x, vec2 y, float a);
158vec3 mix(vec3 x, vec3 y, float a);
159vec4 mix(vec4 x, vec4 y, float a);
160
161float step(float edge, float x);
162vec2 step(vec2 edge, vec2 x);
163vec3 step(vec3 edge, vec3 x);
164vec4 step(vec4 edge, vec4 x);
165
166vec2 step(float edge, vec2 x);
167vec3 step(float edge, vec3 x);
168vec4 step(float edge, vec4 x);
169
170float smoothstep(float edge0, float edge1, float x);
171vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
172vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
173vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
174
175vec2 smoothstep(float edge0, float edge1, vec2 x);
176vec3 smoothstep(float edge0, float edge1, vec3 x);
177vec4 smoothstep(float edge0, float edge1, vec4 x);
178
179/*
180 * 8.4 - Geometric Functions
181 */
182float length(float x);
183float length(vec2 x);
184float length(vec3 x);
185float length(vec4 x);
186
187float distance(float p0, float p1);
188float distance(vec2 p0, vec2 p1);
189float distance(vec3 p0, vec3 p1);
190float distance(vec4 p0, vec4 p1);
191
192float dot(float x, float y);
193float dot(vec2 x, vec2 y);
194float dot(vec3 x, vec3 y);
195float dot(vec4 x, vec4 y);
196
197vec3 cross(vec3 x, vec3 y);
198
199float normalize(float x);
200vec2 normalize(vec2 x);
201vec3 normalize(vec3 x);
202vec4 normalize(vec4 x);
203
204float faceforward(float N, float I, float Nref);
205vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
206vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
207vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
208
209float reflect(float I, float N);
210vec2 reflect(vec2 I, vec2 N);
211vec3 reflect(vec3 I, vec3 N);
212vec4 reflect(vec4 I, vec4 N);
213
214float refract(float I, float N, float eta);
215vec2 refract(vec2 I, vec2 N, float eta);
216vec3 refract(vec3 I, vec3 N, float eta);
217vec4 refract(vec4 I, vec4 N, float eta);
218
219
220/*
221 * 8.5 - Matrix Functions
222 */
223mat2 matrixCompMult(mat2 x, mat2 y);
224mat3 matrixCompMult(mat3 x, mat3 y);
225mat4 matrixCompMult(mat4 x, mat4 y);
226mat2x3 matrixCompMult(mat2x3 x, mat2x3 y);
227mat2x4 matrixCompMult(mat2x4 x, mat2x4 y);
228mat3x2 matrixCompMult(mat3x2 x, mat3x2 y);
229mat3x4 matrixCompMult(mat3x4 x, mat3x4 y);
230mat4x2 matrixCompMult(mat4x2 x, mat4x2 y);
231mat4x3 matrixCompMult(mat4x3 x, mat4x3 y);
232
233mat2 outerProduct(vec2 c, vec2 r);
234mat3 outerProduct(vec3 c, vec3 r);
235mat4 outerProduct(vec4 c, vec4 r);
236
237mat2x3 outerProduct(vec3 c, vec2 r);
238mat3x2 outerProduct(vec2 c, vec3 r);
239
240mat2x4 outerProduct(vec4 c, vec2 r);
241mat4x2 outerProduct(vec2 c, vec4 r);
242
243mat3x4 outerProduct(vec4 c, vec3 r);
244mat4x3 outerProduct(vec3 c, vec4 r);
245
246mat2 transpose(mat2 m);
247mat3 transpose(mat3 m);
248mat4 transpose(mat4 m);
249
250mat2x3 transpose(mat3x2 m);
251mat3x2 transpose(mat2x3 m);
252
253mat2x4 transpose(mat4x2 m);
254mat4x2 transpose(mat2x4 m);
255
256mat3x4 transpose(mat4x3 m);
257mat4x3 transpose(mat3x4 m);
258
259/*
260 * 8.6 - Vector Relational Functions
261 */
262bvec2 lessThan( vec2 x, vec2 y);
263bvec3 lessThan( vec3 x, vec3 y);
264bvec4 lessThan( vec4 x, vec4 y);
265bvec2 lessThan(ivec2 x, ivec2 y);
266bvec3 lessThan(ivec3 x, ivec3 y);
267bvec4 lessThan(ivec4 x, ivec4 y);
268
269bvec2 lessThanEqual( vec2 x, vec2 y);
270bvec3 lessThanEqual( vec3 x, vec3 y);
271bvec4 lessThanEqual( vec4 x, vec4 y);
272bvec2 lessThanEqual(ivec2 x, ivec2 y);
273bvec3 lessThanEqual(ivec3 x, ivec3 y);
274bvec4 lessThanEqual(ivec4 x, ivec4 y);
275
276bvec2 greaterThan( vec2 x, vec2 y);
277bvec3 greaterThan( vec3 x, vec3 y);
278bvec4 greaterThan( vec4 x, vec4 y);
279bvec2 greaterThan(ivec2 x, ivec2 y);
280bvec3 greaterThan(ivec3 x, ivec3 y);
281bvec4 greaterThan(ivec4 x, ivec4 y);
282
283bvec2 greaterThanEqual( vec2 x, vec2 y);
284bvec3 greaterThanEqual( vec3 x, vec3 y);
285bvec4 greaterThanEqual( vec4 x, vec4 y);
286bvec2 greaterThanEqual(ivec2 x, ivec2 y);
287bvec3 greaterThanEqual(ivec3 x, ivec3 y);
288bvec4 greaterThanEqual(ivec4 x, ivec4 y);
289
290bvec2 equal( vec2 x, vec2 y);
291bvec3 equal( vec3 x, vec3 y);
292bvec4 equal( vec4 x, vec4 y);
293bvec2 equal(ivec2 x, ivec2 y);
294bvec3 equal(ivec3 x, ivec3 y);
295bvec4 equal(ivec4 x, ivec4 y);
296bvec2 equal(bvec2 x, bvec2 y);
297bvec3 equal(bvec3 x, bvec3 y);
298bvec4 equal(bvec4 x, bvec4 y);
299
300bvec2 notEqual( vec2 x, vec2 y);
301bvec3 notEqual( vec3 x, vec3 y);
302bvec4 notEqual( vec4 x, vec4 y);
303bvec2 notEqual(ivec2 x, ivec2 y);
304bvec3 notEqual(ivec3 x, ivec3 y);
305bvec4 notEqual(ivec4 x, ivec4 y);
306bvec2 notEqual(bvec2 x, bvec2 y);
307bvec3 notEqual(bvec3 x, bvec3 y);
308bvec4 notEqual(bvec4 x, bvec4 y);
309
310bool any(bvec2 x);
311bool any(bvec3 x);
312bool any(bvec4 x);
313
314bool all(bvec2 x);
315bool all(bvec3 x);
316bool all(bvec4 x);
317
318bvec2 not(bvec2 x);
319bvec3 not(bvec3 x);
320bvec4 not(bvec4 x);
321
322/*
323 * 8.7 - Texture Lookup Functions
324 */
325vec4 texture1D (sampler1D sampler, float coord);
326vec4 texture1DProj (sampler1D sampler, vec2 coord);
327vec4 texture1DProj (sampler1D sampler, vec4 coord);
328vec4 texture1D (sampler1D sampler, float coord, float bias);
329vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias);
330vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias);
331
332vec4 texture2D (sampler2D sampler, vec2 coord);
333vec4 texture2DProj (sampler2D sampler, vec3 coord);
334vec4 texture2DProj (sampler2D sampler, vec4 coord);
335vec4 texture2D (sampler2D sampler, vec2 coord, float bias);
336vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias);
337vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias);
338
339vec4 texture3D (sampler3D sampler, vec3 coord);
340vec4 texture3DProj (sampler3D sampler, vec4 coord);
341vec4 texture3D (sampler3D sampler, vec3 coord, float bias);
342vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias);
343
344vec4 textureCube (samplerCube sampler, vec3 coord);
345vec4 textureCube (samplerCube sampler, vec3 coord, float bias);
346
347vec4 shadow1D (sampler1DShadow sampler, vec3 coord);
348vec4 shadow2D (sampler2DShadow sampler, vec3 coord);
349vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord);
350vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord);
351vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias);
352vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias);
353vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias);
354vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias);
355
356
357/*
358 * 8.8 - Fragment Processing Functions
359 */
360float dFdx(float p);
361vec2 dFdx(vec2 p);
362vec3 dFdx(vec3 p);
363vec4 dFdx(vec4 p);
364
365float dFdy(float p);
366vec2 dFdy(vec2 p);
367vec3 dFdy(vec3 p);
368vec4 dFdy(vec4 p);
369
370float fwidth(float p);
371vec2 fwidth(vec2 p);
372vec3 fwidth(vec3 p);
373vec4 fwidth(vec4 p);
374
375/*
376 * 8.9 - Noise Functions
377 */
378float noise1(float x);
379float noise1(vec2 x);
380float noise1(vec3 x);
381float noise1(vec4 x);
382
383vec2 noise2(float x);
384vec2 noise2(vec2 x);
385vec2 noise2(vec3 x);
386vec2 noise2(vec4 x);
387
388vec3 noise3(float x);
389vec3 noise3(vec2 x);
390vec3 noise3(vec3 x);
391vec3 noise3(vec4 x);
392
393vec4 noise4(float x);
394vec4 noise4(vec2 x);
395vec4 noise4(vec3 x);
396vec4 noise4(vec4 x);
diff --git a/src/glsl/builtins/profiles/120.vert b/src/glsl/builtins/profiles/120.vert
new file mode 100644
index 00000000000..e14c931647f
--- /dev/null
+++ b/src/glsl/builtins/profiles/120.vert
@@ -0,0 +1,383 @@
1#version 120
2/*
3 * 8.1 - Angle and Trigonometry Functions
4 */
5float radians(float degrees);
6vec2 radians(vec2 degrees);
7vec3 radians(vec3 degrees);
8vec4 radians(vec4 degrees);
9
10float degrees(float radians);
11vec2 degrees(vec2 radians);
12vec3 degrees(vec3 radians);
13vec4 degrees(vec4 radians);
14
15float sin(float angle);
16vec2 sin(vec2 angle);
17vec3 sin(vec3 angle);
18vec4 sin(vec4 angle);
19
20float cos(float angle);
21vec2 cos(vec2 angle);
22vec3 cos(vec3 angle);
23vec4 cos(vec4 angle);
24
25float tan(float angle);
26vec2 tan(vec2 angle);
27vec3 tan(vec3 angle);
28vec4 tan(vec4 angle);
29
30float asin(float angle);
31vec2 asin(vec2 angle);
32vec3 asin(vec3 angle);
33vec4 asin(vec4 angle);
34
35float acos(float angle);
36vec2 acos(vec2 angle);
37vec3 acos(vec3 angle);
38vec4 acos(vec4 angle);
39
40float atan(float y, float x);
41vec2 atan(vec2 y, vec2 x);
42vec3 atan(vec3 y, vec3 x);
43vec4 atan(vec4 y, vec4 x);
44
45float atan(float y_over_x);
46vec2 atan(vec2 y_over_x);
47vec3 atan(vec3 y_over_x);
48vec4 atan(vec4 y_over_x);
49
50/*
51 * 8.2 - Exponential Functions
52 */
53float pow(float x, float y);
54vec2 pow(vec2 x, vec2 y);
55vec3 pow(vec3 x, vec3 y);
56vec4 pow(vec4 x, vec4 y);
57
58float exp(float x);
59vec2 exp(vec2 x);
60vec3 exp(vec3 x);
61vec4 exp(vec4 x);
62
63float log(float x);
64vec2 log(vec2 x);
65vec3 log(vec3 x);
66vec4 log(vec4 x);
67
68float exp2(float x);
69vec2 exp2(vec2 x);
70vec3 exp2(vec3 x);
71vec4 exp2(vec4 x);
72
73float log2(float x);
74vec2 log2(vec2 x);
75vec3 log2(vec3 x);
76vec4 log2(vec4 x);
77
78float sqrt(float x);
79vec2 sqrt(vec2 x);
80vec3 sqrt(vec3 x);
81vec4 sqrt(vec4 x);
82
83float inversesqrt(float x);
84vec2 inversesqrt(vec2 x);
85vec3 inversesqrt(vec3 x);
86vec4 inversesqrt(vec4 x);
87
88/*
89 * 8.3 - Common Functions
90 */
91float abs(float x);
92vec2 abs(vec2 x);
93vec3 abs(vec3 x);
94vec4 abs(vec4 x);
95
96float sign(float x);
97vec2 sign(vec2 x);
98vec3 sign(vec3 x);
99vec4 sign(vec4 x);
100
101float floor(float x);
102vec2 floor(vec2 x);
103vec3 floor(vec3 x);
104vec4 floor(vec4 x);
105
106float ceil(float x);
107vec2 ceil(vec2 x);
108vec3 ceil(vec3 x);
109vec4 ceil(vec4 x);
110
111float fract(float x);
112vec2 fract(vec2 x);
113vec3 fract(vec3 x);
114vec4 fract(vec4 x);
115
116float mod(float x, float y);
117vec2 mod(vec2 x, float y);
118vec3 mod(vec3 x, float y);
119vec4 mod(vec4 x, float y);
120
121vec2 mod(vec2 x, vec2 y);
122vec3 mod(vec3 x, vec3 y);
123vec4 mod(vec4 x, vec4 y);
124
125float min(float x, float y);
126vec2 min(vec2 x, vec2 y);
127vec3 min(vec3 x, vec3 y);
128vec4 min(vec4 x, vec4 y);
129
130vec2 min(vec2 x, float y);
131vec3 min(vec3 x, float y);
132vec4 min(vec4 x, float y);
133
134float max(float x, float y);
135vec2 max(vec2 x, vec2 y);
136vec3 max(vec3 x, vec3 y);
137vec4 max(vec4 x, vec4 y);
138
139vec2 max(vec2 x, float y);
140vec3 max(vec3 x, float y);
141vec4 max(vec4 x, float y);
142
143float clamp(float x, float minVal, float maxVal);
144vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
145vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
146vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
147
148vec2 clamp(vec2 x, float minVal, float maxVal);
149vec3 clamp(vec3 x, float minVal, float maxVal);
150vec4 clamp(vec4 x, float minVal, float maxVal);
151
152float mix(float x, float y, float a);
153vec2 mix(vec2 x, vec2 y, vec2 a);
154vec3 mix(vec3 x, vec3 y, vec3 a);
155vec4 mix(vec4 x, vec4 y, vec4 a);
156
157vec2 mix(vec2 x, vec2 y, float a);
158vec3 mix(vec3 x, vec3 y, float a);
159vec4 mix(vec4 x, vec4 y, float a);
160
161float step(float edge, float x);
162vec2 step(vec2 edge, vec2 x);
163vec3 step(vec3 edge, vec3 x);
164vec4 step(vec4 edge, vec4 x);
165
166vec2 step(float edge, vec2 x);
167vec3 step(float edge, vec3 x);
168vec4 step(float edge, vec4 x);
169
170float smoothstep(float edge0, float edge1, float x);
171vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
172vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
173vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
174
175vec2 smoothstep(float edge0, float edge1, vec2 x);
176vec3 smoothstep(float edge0, float edge1, vec3 x);
177vec4 smoothstep(float edge0, float edge1, vec4 x);
178
179/*
180 * 8.4 - Geometric Functions
181 */
182float length(float x);
183float length(vec2 x);
184float length(vec3 x);
185float length(vec4 x);
186
187float distance(float p0, float p1);
188float distance(vec2 p0, vec2 p1);
189float distance(vec3 p0, vec3 p1);
190float distance(vec4 p0, vec4 p1);
191
192float dot(float x, float y);
193float dot(vec2 x, vec2 y);
194float dot(vec3 x, vec3 y);
195float dot(vec4 x, vec4 y);
196
197vec3 cross(vec3 x, vec3 y);
198
199float normalize(float x);
200vec2 normalize(vec2 x);
201vec3 normalize(vec3 x);
202vec4 normalize(vec4 x);
203
204vec4 ftransform();
205
206float faceforward(float N, float I, float Nref);
207vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
208vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
209vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
210
211float reflect(float I, float N);
212vec2 reflect(vec2 I, vec2 N);
213vec3 reflect(vec3 I, vec3 N);
214vec4 reflect(vec4 I, vec4 N);
215
216float refract(float I, float N, float eta);
217vec2 refract(vec2 I, vec2 N, float eta);
218vec3 refract(vec3 I, vec3 N, float eta);
219vec4 refract(vec4 I, vec4 N, float eta);
220
221
222/*
223 * 8.5 - Matrix Functions
224 */
225mat2 matrixCompMult(mat2 x, mat2 y);
226mat3 matrixCompMult(mat3 x, mat3 y);
227mat4 matrixCompMult(mat4 x, mat4 y);
228mat2x3 matrixCompMult(mat2x3 x, mat2x3 y);
229mat2x4 matrixCompMult(mat2x4 x, mat2x4 y);
230mat3x2 matrixCompMult(mat3x2 x, mat3x2 y);
231mat3x4 matrixCompMult(mat3x4 x, mat3x4 y);
232mat4x2 matrixCompMult(mat4x2 x, mat4x2 y);
233mat4x3 matrixCompMult(mat4x3 x, mat4x3 y);
234
235mat2 outerProduct(vec2 c, vec2 r);
236mat3 outerProduct(vec3 c, vec3 r);
237mat4 outerProduct(vec4 c, vec4 r);
238
239mat2x3 outerProduct(vec3 c, vec2 r);
240mat3x2 outerProduct(vec2 c, vec3 r);
241
242mat2x4 outerProduct(vec4 c, vec2 r);
243mat4x2 outerProduct(vec2 c, vec4 r);
244
245mat3x4 outerProduct(vec4 c, vec3 r);
246mat4x3 outerProduct(vec3 c, vec4 r);
247
248mat2 transpose(mat2 m);
249mat3 transpose(mat3 m);
250mat4 transpose(mat4 m);
251
252mat2x3 transpose(mat3x2 m);
253mat3x2 transpose(mat2x3 m);
254
255mat2x4 transpose(mat4x2 m);
256mat4x2 transpose(mat2x4 m);
257
258mat3x4 transpose(mat4x3 m);
259mat4x3 transpose(mat3x4 m);
260
261/*
262 * 8.6 - Vector Relational Functions
263 */
264bvec2 lessThan( vec2 x, vec2 y);
265bvec3 lessThan( vec3 x, vec3 y);
266bvec4 lessThan( vec4 x, vec4 y);
267bvec2 lessThan(ivec2 x, ivec2 y);
268bvec3 lessThan(ivec3 x, ivec3 y);
269bvec4 lessThan(ivec4 x, ivec4 y);
270
271bvec2 lessThanEqual( vec2 x, vec2 y);
272bvec3 lessThanEqual( vec3 x, vec3 y);
273bvec4 lessThanEqual( vec4 x, vec4 y);
274bvec2 lessThanEqual(ivec2 x, ivec2 y);
275bvec3 lessThanEqual(ivec3 x, ivec3 y);
276bvec4 lessThanEqual(ivec4 x, ivec4 y);
277
278bvec2 greaterThan( vec2 x, vec2 y);
279bvec3 greaterThan( vec3 x, vec3 y);
280bvec4 greaterThan( vec4 x, vec4 y);
281bvec2 greaterThan(ivec2 x, ivec2 y);
282bvec3 greaterThan(ivec3 x, ivec3 y);
283bvec4 greaterThan(ivec4 x, ivec4 y);
284
285bvec2 greaterThanEqual( vec2 x, vec2 y);
286bvec3 greaterThanEqual( vec3 x, vec3 y);
287bvec4 greaterThanEqual( vec4 x, vec4 y);
288bvec2 greaterThanEqual(ivec2 x, ivec2 y);
289bvec3 greaterThanEqual(ivec3 x, ivec3 y);
290bvec4 greaterThanEqual(ivec4 x, ivec4 y);
291
292bvec2 equal( vec2 x, vec2 y);
293bvec3 equal( vec3 x, vec3 y);
294bvec4 equal( vec4 x, vec4 y);
295bvec2 equal(ivec2 x, ivec2 y);
296bvec3 equal(ivec3 x, ivec3 y);
297bvec4 equal(ivec4 x, ivec4 y);
298bvec2 equal(bvec2 x, bvec2 y);
299bvec3 equal(bvec3 x, bvec3 y);
300bvec4 equal(bvec4 x, bvec4 y);
301
302bvec2 notEqual( vec2 x, vec2 y);
303bvec3 notEqual( vec3 x, vec3 y);
304bvec4 notEqual( vec4 x, vec4 y);
305bvec2 notEqual(ivec2 x, ivec2 y);
306bvec3 notEqual(ivec3 x, ivec3 y);
307bvec4 notEqual(ivec4 x, ivec4 y);
308bvec2 notEqual(bvec2 x, bvec2 y);
309bvec3 notEqual(bvec3 x, bvec3 y);
310bvec4 notEqual(bvec4 x, bvec4 y);
311
312bool any(bvec2 x);
313bool any(bvec3 x);
314bool any(bvec4 x);
315
316bool all(bvec2 x);
317bool all(bvec3 x);
318bool all(bvec4 x);
319
320bvec2 not(bvec2 x);
321bvec3 not(bvec3 x);
322bvec4 not(bvec4 x);
323
324/*
325 * 8.7 - Texture Lookup Functions
326 */
327vec4 texture1D (sampler1D sampler, float coord);
328vec4 texture1DProj (sampler1D sampler, vec2 coord);
329vec4 texture1DProj (sampler1D sampler, vec4 coord);
330vec4 texture1DLod (sampler1D sampler, float coord, float lod);
331vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);
332vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);
333
334vec4 texture2D (sampler2D sampler, vec2 coord);
335vec4 texture2DProj (sampler2D sampler, vec3 coord);
336vec4 texture2DProj (sampler2D sampler, vec4 coord);
337vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod);
338vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);
339vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);
340
341vec4 texture3D (sampler3D sampler, vec3 coord);
342vec4 texture3DProj (sampler3D sampler, vec4 coord);
343vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod);
344vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);
345
346vec4 textureCube (samplerCube sampler, vec3 coord);
347vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod);
348
349vec4 shadow1D (sampler1DShadow sampler, vec3 coord);
350vec4 shadow2D (sampler2DShadow sampler, vec3 coord);
351vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord);
352vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord);
353vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod);
354vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod);
355vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);
356vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);
357
358/*
359 * 8.8 - Fragment Processing Functions (none in vertex shader)
360 */
361
362/*
363 * 8.9 - Noise Functions
364 */
365float noise1(float x);
366float noise1(vec2 x);
367float noise1(vec3 x);
368float noise1(vec4 x);
369
370vec2 noise2(float x);
371vec2 noise2(vec2 x);
372vec2 noise2(vec3 x);
373vec2 noise2(vec4 x);
374
375vec3 noise3(float x);
376vec3 noise3(vec2 x);
377vec3 noise3(vec3 x);
378vec3 noise3(vec4 x);
379
380vec4 noise4(float x);
381vec4 noise4(vec2 x);
382vec4 noise4(vec3 x);
383vec4 noise4(vec4 x);
diff --git a/src/glsl/builtins/profiles/130.frag b/src/glsl/builtins/profiles/130.frag
new file mode 100644
index 00000000000..39c73c4eefa
--- /dev/null
+++ b/src/glsl/builtins/profiles/130.frag
@@ -0,0 +1,999 @@
1#version 130
2/*
3 * 8.1 - Angle and Trigonometry Functions
4 */
5float radians(float degrees);
6vec2 radians(vec2 degrees);
7vec3 radians(vec3 degrees);
8vec4 radians(vec4 degrees);
9
10float degrees(float radians);
11vec2 degrees(vec2 radians);
12vec3 degrees(vec3 radians);
13vec4 degrees(vec4 radians);
14
15float sin(float angle);
16vec2 sin(vec2 angle);
17vec3 sin(vec3 angle);
18vec4 sin(vec4 angle);
19
20float cos(float angle);
21vec2 cos(vec2 angle);
22vec3 cos(vec3 angle);
23vec4 cos(vec4 angle);
24
25float tan(float angle);
26vec2 tan(vec2 angle);
27vec3 tan(vec3 angle);
28vec4 tan(vec4 angle);
29
30float asin(float angle);
31vec2 asin(vec2 angle);
32vec3 asin(vec3 angle);
33vec4 asin(vec4 angle);
34
35float acos(float angle);
36vec2 acos(vec2 angle);
37vec3 acos(vec3 angle);
38vec4 acos(vec4 angle);
39
40float atan(float y, float x);
41vec2 atan(vec2 y, vec2 x);
42vec3 atan(vec3 y, vec3 x);
43vec4 atan(vec4 y, vec4 x);
44
45float atan(float y_over_x);
46vec2 atan(vec2 y_over_x);
47vec3 atan(vec3 y_over_x);
48vec4 atan(vec4 y_over_x);
49
50/*
51 * 8.2 - Exponential Functions
52 */
53float pow(float x, float y);
54vec2 pow(vec2 x, vec2 y);
55vec3 pow(vec3 x, vec3 y);
56vec4 pow(vec4 x, vec4 y);
57
58float exp(float x);
59vec2 exp(vec2 x);
60vec3 exp(vec3 x);
61vec4 exp(vec4 x);
62
63float log(float x);
64vec2 log(vec2 x);
65vec3 log(vec3 x);
66vec4 log(vec4 x);
67
68float exp2(float x);
69vec2 exp2(vec2 x);
70vec3 exp2(vec3 x);
71vec4 exp2(vec4 x);
72
73float log2(float x);
74vec2 log2(vec2 x);
75vec3 log2(vec3 x);
76vec4 log2(vec4 x);
77
78float sqrt(float x);
79vec2 sqrt(vec2 x);
80vec3 sqrt(vec3 x);
81vec4 sqrt(vec4 x);
82
83float inversesqrt(float x);
84vec2 inversesqrt(vec2 x);
85vec3 inversesqrt(vec3 x);
86vec4 inversesqrt(vec4 x);
87
88/*
89 * 8.3 - Common Functions
90 */
91float abs(float x);
92vec2 abs(vec2 x);
93vec3 abs(vec3 x);
94vec4 abs(vec4 x);
95int abs(int x);
96ivec2 abs(ivec2 x);
97ivec3 abs(ivec3 x);
98ivec4 abs(ivec4 x);
99
100float sign(float x);
101vec2 sign(vec2 x);
102vec3 sign(vec3 x);
103vec4 sign(vec4 x);
104int sign(int x);
105ivec2 sign(ivec2 x);
106ivec3 sign(ivec3 x);
107ivec4 sign(ivec4 x);
108
109float floor(float x);
110vec2 floor(vec2 x);
111vec3 floor(vec3 x);
112vec4 floor(vec4 x);
113
114float ceil(float x);
115vec2 ceil(vec2 x);
116vec3 ceil(vec3 x);
117vec4 ceil(vec4 x);
118
119float fract(float x);
120vec2 fract(vec2 x);
121vec3 fract(vec3 x);
122vec4 fract(vec4 x);
123
124float mod(float x, float y);
125vec2 mod(vec2 x, float y);
126vec3 mod(vec3 x, float y);
127vec4 mod(vec4 x, float y);
128
129vec2 mod(vec2 x, vec2 y);
130vec3 mod(vec3 x, vec3 y);
131vec4 mod(vec4 x, vec4 y);
132
133float min(float x, float y);
134vec2 min(vec2 x, vec2 y);
135vec3 min(vec3 x, vec3 y);
136vec4 min(vec4 x, vec4 y);
137
138vec2 min(vec2 x, float y);
139vec3 min(vec3 x, float y);
140vec4 min(vec4 x, float y);
141
142int min(int x, int y);
143ivec2 min(ivec2 x, ivec2 y);
144ivec3 min(ivec3 x, ivec3 y);
145ivec4 min(ivec4 x, ivec4 y);
146
147ivec2 min(ivec2 x, int y);
148ivec3 min(ivec3 x, int y);
149ivec4 min(ivec4 x, int y);
150
151uint min(uint x, uint y);
152uvec2 min(uvec2 x, uvec2 y);
153uvec3 min(uvec3 x, uvec3 y);
154uvec4 min(uvec4 x, uvec4 y);
155
156uvec2 min(uvec2 x, uint y);
157uvec3 min(uvec3 x, uint y);
158uvec4 min(uvec4 x, uint y);
159
160float max(float x, float y);
161vec2 max(vec2 x, vec2 y);
162vec3 max(vec3 x, vec3 y);
163vec4 max(vec4 x, vec4 y);
164
165vec2 max(vec2 x, float y);
166vec3 max(vec3 x, float y);
167vec4 max(vec4 x, float y);
168
169int max(int x, int y);
170ivec2 max(ivec2 x, ivec2 y);
171ivec3 max(ivec3 x, ivec3 y);
172ivec4 max(ivec4 x, ivec4 y);
173
174ivec2 max(ivec2 x, int y);
175ivec3 max(ivec3 x, int y);
176ivec4 max(ivec4 x, int y);
177
178uint max(uint x, uint y);
179uvec2 max(uvec2 x, uvec2 y);
180uvec3 max(uvec3 x, uvec3 y);
181uvec4 max(uvec4 x, uvec4 y);
182
183uvec2 max(uvec2 x, uint y);
184uvec3 max(uvec3 x, uint y);
185uvec4 max(uvec4 x, uint y);
186
187float clamp(float x, float minVal, float maxVal);
188vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
189vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
190vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
191
192vec2 clamp(vec2 x, float minVal, float maxVal);
193vec3 clamp(vec3 x, float minVal, float maxVal);
194vec4 clamp(vec4 x, float minVal, float maxVal);
195
196int clamp(int x, int minVal, int maxVal);
197ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal);
198ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal);
199ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal);
200
201ivec2 clamp(ivec2 x, int minVal, int maxVal);
202ivec3 clamp(ivec3 x, int minVal, int maxVal);
203ivec4 clamp(ivec4 x, int minVal, int maxVal);
204
205uint clamp(uint x, uint minVal, uint maxVal);
206uvec2 clamp(uvec2 x, uvec2 minVal, uvec2 maxVal);
207uvec3 clamp(uvec3 x, uvec3 minVal, uvec3 maxVal);
208uvec4 clamp(uvec4 x, uvec4 minVal, uvec4 maxVal);
209
210uvec2 clamp(uvec2 x, uint minVal, uint maxVal);
211uvec3 clamp(uvec3 x, uint minVal, uint maxVal);
212uvec4 clamp(uvec4 x, uint minVal, uint maxVal);
213
214float mix(float x, float y, float a);
215vec2 mix(vec2 x, vec2 y, vec2 a);
216vec3 mix(vec3 x, vec3 y, vec3 a);
217vec4 mix(vec4 x, vec4 y, vec4 a);
218
219vec2 mix(vec2 x, vec2 y, float a);
220vec3 mix(vec3 x, vec3 y, float a);
221vec4 mix(vec4 x, vec4 y, float a);
222
223float step(float edge, float x);
224vec2 step(vec2 edge, vec2 x);
225vec3 step(vec3 edge, vec3 x);
226vec4 step(vec4 edge, vec4 x);
227
228vec2 step(float edge, vec2 x);
229vec3 step(float edge, vec3 x);
230vec4 step(float edge, vec4 x);
231
232float smoothstep(float edge0, float edge1, float x);
233vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
234vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
235vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
236
237vec2 smoothstep(float edge0, float edge1, vec2 x);
238vec3 smoothstep(float edge0, float edge1, vec3 x);
239vec4 smoothstep(float edge0, float edge1, vec4 x);
240
241#if 0
242bool isnan(float x);
243bvec2 isnan(vec2 x);
244bvec3 isnan(vec3 x);
245bvec4 isnan(vec4 x);
246
247bool isinf(float x);
248bvec2 isinf(vec2 x);
249bvec3 isinf(vec3 x);
250bvec4 isinf(vec4 x);
251#endif
252
253/*
254 * 8.4 - Geometric Functions
255 */
256float length(float x);
257float length(vec2 x);
258float length(vec3 x);
259float length(vec4 x);
260
261float distance(float p0, float p1);
262float distance(vec2 p0, vec2 p1);
263float distance(vec3 p0, vec3 p1);
264float distance(vec4 p0, vec4 p1);
265
266float dot(float x, float y);
267float dot(vec2 x, vec2 y);
268float dot(vec3 x, vec3 y);
269float dot(vec4 x, vec4 y);
270
271vec3 cross(vec3 x, vec3 y);
272
273float normalize(float x);
274vec2 normalize(vec2 x);
275vec3 normalize(vec3 x);
276vec4 normalize(vec4 x);
277
278float faceforward(float N, float I, float Nref);
279vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
280vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
281vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
282
283float reflect(float I, float N);
284vec2 reflect(vec2 I, vec2 N);
285vec3 reflect(vec3 I, vec3 N);
286vec4 reflect(vec4 I, vec4 N);
287
288float refract(float I, float N, float eta);
289vec2 refract(vec2 I, vec2 N, float eta);
290vec3 refract(vec3 I, vec3 N, float eta);
291vec4 refract(vec4 I, vec4 N, float eta);
292
293
294/*
295 * 8.5 - Matrix Functions
296 */
297mat2 matrixCompMult(mat2 x, mat2 y);
298mat3 matrixCompMult(mat3 x, mat3 y);
299mat4 matrixCompMult(mat4 x, mat4 y);
300mat2x3 matrixCompMult(mat2x3 x, mat2x3 y);
301mat2x4 matrixCompMult(mat2x4 x, mat2x4 y);
302mat3x2 matrixCompMult(mat3x2 x, mat3x2 y);
303mat3x4 matrixCompMult(mat3x4 x, mat3x4 y);
304mat4x2 matrixCompMult(mat4x2 x, mat4x2 y);
305mat4x3 matrixCompMult(mat4x3 x, mat4x3 y);
306
307mat2 outerProduct(vec2 c, vec2 r);
308mat3 outerProduct(vec3 c, vec3 r);
309mat4 outerProduct(vec4 c, vec4 r);
310
311mat2x3 outerProduct(vec3 c, vec2 r);
312mat3x2 outerProduct(vec2 c, vec3 r);
313
314mat2x4 outerProduct(vec4 c, vec2 r);
315mat4x2 outerProduct(vec2 c, vec4 r);
316
317mat3x4 outerProduct(vec4 c, vec3 r);
318mat4x3 outerProduct(vec3 c, vec4 r);
319
320mat2 transpose(mat2 m);
321mat3 transpose(mat3 m);
322mat4 transpose(mat4 m);
323
324mat2x3 transpose(mat3x2 m);
325mat3x2 transpose(mat2x3 m);
326
327mat2x4 transpose(mat4x2 m);
328mat4x2 transpose(mat2x4 m);
329
330mat3x4 transpose(mat4x3 m);
331mat4x3 transpose(mat3x4 m);
332
333/*
334 * 8.6 - Vector Relational Functions
335 */
336bvec2 lessThan( vec2 x, vec2 y);
337bvec3 lessThan( vec3 x, vec3 y);
338bvec4 lessThan( vec4 x, vec4 y);
339bvec2 lessThan(ivec2 x, ivec2 y);
340bvec3 lessThan(ivec3 x, ivec3 y);
341bvec4 lessThan(ivec4 x, ivec4 y);
342bvec2 lessThan(uvec2 x, uvec2 y);
343bvec3 lessThan(uvec3 x, uvec3 y);
344bvec4 lessThan(uvec4 x, uvec4 y);
345
346bvec2 lessThanEqual( vec2 x, vec2 y);
347bvec3 lessThanEqual( vec3 x, vec3 y);
348bvec4 lessThanEqual( vec4 x, vec4 y);
349bvec2 lessThanEqual(ivec2 x, ivec2 y);
350bvec3 lessThanEqual(ivec3 x, ivec3 y);
351bvec4 lessThanEqual(ivec4 x, ivec4 y);
352bvec2 lessThanEqual(uvec2 x, uvec2 y);
353bvec3 lessThanEqual(uvec3 x, uvec3 y);
354bvec4 lessThanEqual(uvec4 x, uvec4 y);
355
356bvec2 greaterThan( vec2 x, vec2 y);
357bvec3 greaterThan( vec3 x, vec3 y);
358bvec4 greaterThan( vec4 x, vec4 y);
359bvec2 greaterThan(ivec2 x, ivec2 y);
360bvec3 greaterThan(ivec3 x, ivec3 y);
361bvec4 greaterThan(ivec4 x, ivec4 y);
362bvec2 greaterThan(uvec2 x, uvec2 y);
363bvec3 greaterThan(uvec3 x, uvec3 y);
364bvec4 greaterThan(uvec4 x, uvec4 y);
365
366bvec2 greaterThanEqual( vec2 x, vec2 y);
367bvec3 greaterThanEqual( vec3 x, vec3 y);
368bvec4 greaterThanEqual( vec4 x, vec4 y);
369bvec2 greaterThanEqual(ivec2 x, ivec2 y);
370bvec3 greaterThanEqual(ivec3 x, ivec3 y);
371bvec4 greaterThanEqual(ivec4 x, ivec4 y);
372bvec2 greaterThanEqual(uvec2 x, uvec2 y);
373bvec3 greaterThanEqual(uvec3 x, uvec3 y);
374bvec4 greaterThanEqual(uvec4 x, uvec4 y);
375
376bvec2 equal( vec2 x, vec2 y);
377bvec3 equal( vec3 x, vec3 y);
378bvec4 equal( vec4 x, vec4 y);
379bvec2 equal(ivec2 x, ivec2 y);
380bvec3 equal(ivec3 x, ivec3 y);
381bvec4 equal(ivec4 x, ivec4 y);
382bvec2 equal(uvec2 x, uvec2 y);
383bvec3 equal(uvec3 x, uvec3 y);
384bvec4 equal(uvec4 x, uvec4 y);
385bvec2 equal(bvec2 x, bvec2 y);
386bvec3 equal(bvec3 x, bvec3 y);
387bvec4 equal(bvec4 x, bvec4 y);
388
389bvec2 notEqual( vec2 x, vec2 y);
390bvec3 notEqual( vec3 x, vec3 y);
391bvec4 notEqual( vec4 x, vec4 y);
392bvec2 notEqual(ivec2 x, ivec2 y);
393bvec3 notEqual(ivec3 x, ivec3 y);
394bvec4 notEqual(ivec4 x, ivec4 y);
395bvec2 notEqual(uvec2 x, uvec2 y);
396bvec3 notEqual(uvec3 x, uvec3 y);
397bvec4 notEqual(uvec4 x, uvec4 y);
398bvec2 notEqual(bvec2 x, bvec2 y);
399bvec3 notEqual(bvec3 x, bvec3 y);
400bvec4 notEqual(bvec4 x, bvec4 y);
401
402bool any(bvec2 x);
403bool any(bvec3 x);
404bool any(bvec4 x);
405
406bool all(bvec2 x);
407bool all(bvec3 x);
408bool all(bvec4 x);
409
410bvec2 not(bvec2 x);
411bvec3 not(bvec3 x);
412bvec4 not(bvec4 x);
413
414/*
415 * 8.7 - Texture Lookup Functions
416 */
417
418#if 0
419/* textureSize */
420int textureSize( sampler1D sampler, int lod);
421int textureSize(isampler1D sampler, int lod);
422int textureSize(usampler1D sampler, int lod);
423
424ivec2 textureSize( sampler2D sampler, int lod);
425ivec2 textureSize(isampler2D sampler, int lod);
426ivec2 textureSize(usampler2D sampler, int lod);
427
428ivec3 textureSize( sampler3D sampler, int lod);
429ivec3 textureSize(isampler3D sampler, int lod);
430ivec3 textureSize(usampler3D sampler, int lod);
431
432ivec2 textureSize( samplerCube sampler, int lod);
433ivec2 textureSize(isamplerCube sampler, int lod);
434ivec2 textureSize(usamplerCube sampler, int lod);
435
436int textureSize(sampler1DShadow sampler, int lod);
437ivec2 textureSize(sampler2DShadow sampler, int lod);
438ivec2 textureSize(samplerCubeShadow sampler, int lod);
439
440ivec2 textureSize( sampler1DArray sampler, int lod);
441ivec2 textureSize(isampler1DArray sampler, int lod);
442ivec2 textureSize(usampler1DArray sampler, int lod);
443ivec3 textureSize( sampler2DArray sampler, int lod);
444ivec2 textureSize(isampler2DArray sampler, int lod);
445ivec2 textureSize(usampler2DArray sampler, int lod);
446
447ivec2 textureSize(sampler1DArrayShadow sampler, int lod);
448ivec3 textureSize(sampler2DArrayShadow sampler, int lod);
449#endif
450
451/* texture - no bias */
452 vec4 texture( sampler1D sampler, float P);
453ivec4 texture(isampler1D sampler, float P);
454uvec4 texture(usampler1D sampler, float P);
455
456 vec4 texture( sampler2D sampler, vec2 P);
457ivec4 texture(isampler2D sampler, vec2 P);
458uvec4 texture(usampler2D sampler, vec2 P);
459
460 vec4 texture( sampler3D sampler, vec3 P);
461ivec4 texture(isampler3D sampler, vec3 P);
462uvec4 texture(usampler3D sampler, vec3 P);
463
464 vec4 texture( samplerCube sampler, vec3 P);
465ivec4 texture(isamplerCube sampler, vec3 P);
466uvec4 texture(usamplerCube sampler, vec3 P);
467
468float texture(sampler1DShadow sampler, vec3 P);
469float texture(sampler2DShadow sampler, vec3 P);
470float texture(samplerCubeShadow sampler, vec4 P);
471
472 vec4 texture( sampler1DArray sampler, vec2 P);
473ivec4 texture(isampler1DArray sampler, vec2 P);
474uvec4 texture(usampler1DArray sampler, vec2 P);
475
476 vec4 texture( sampler2DArray sampler, vec3 P);
477ivec4 texture(isampler2DArray sampler, vec3 P);
478uvec4 texture(usampler2DArray sampler, vec3 P);
479
480float texture(sampler1DArrayShadow sampler, vec3 P);
481float texture(sampler2DArrayShadow sampler, vec4 P);
482
483/* texture - bias variants */
484 vec4 texture( sampler1D sampler, float P, float bias);
485ivec4 texture(isampler1D sampler, float P, float bias);
486uvec4 texture(usampler1D sampler, float P, float bias);
487
488 vec4 texture( sampler2D sampler, vec2 P, float bias);
489ivec4 texture(isampler2D sampler, vec2 P, float bias);
490uvec4 texture(usampler2D sampler, vec2 P, float bias);
491
492 vec4 texture( sampler3D sampler, vec3 P, float bias);
493ivec4 texture(isampler3D sampler, vec3 P, float bias);
494uvec4 texture(usampler3D sampler, vec3 P, float bias);
495
496 vec4 texture( samplerCube sampler, vec3 P, float bias);
497ivec4 texture(isamplerCube sampler, vec3 P, float bias);
498uvec4 texture(usamplerCube sampler, vec3 P, float bias);
499
500float texture(sampler1DShadow sampler, vec3 P, float bias);
501float texture(sampler2DShadow sampler, vec3 P, float bias);
502float texture(samplerCubeShadow sampler, vec4 P, float bias);
503
504 vec4 texture( sampler1DArray sampler, vec2 P, float bias);
505ivec4 texture(isampler1DArray sampler, vec2 P, float bias);
506uvec4 texture(usampler1DArray sampler, vec2 P, float bias);
507
508 vec4 texture( sampler2DArray sampler, vec3 P, float bias);
509ivec4 texture(isampler2DArray sampler, vec3 P, float bias);
510uvec4 texture(usampler2DArray sampler, vec3 P, float bias);
511
512float texture(sampler1DArrayShadow sampler, vec3 P, float bias);
513
514/* textureProj - no bias */
515 vec4 textureProj( sampler1D sampler, vec2 P);
516ivec4 textureProj(isampler1D sampler, vec2 P);
517uvec4 textureProj(usampler1D sampler, vec2 P);
518 vec4 textureProj( sampler1D sampler, vec4 P);
519ivec4 textureProj(isampler1D sampler, vec4 P);
520uvec4 textureProj(usampler1D sampler, vec4 P);
521
522 vec4 textureProj( sampler2D sampler, vec3 P);
523ivec4 textureProj(isampler2D sampler, vec3 P);
524uvec4 textureProj(usampler2D sampler, vec3 P);
525 vec4 textureProj( sampler2D sampler, vec4 P);
526ivec4 textureProj(isampler2D sampler, vec4 P);
527uvec4 textureProj(usampler2D sampler, vec4 P);
528
529 vec4 textureProj( sampler3D sampler, vec4 P);
530ivec4 textureProj(isampler3D sampler, vec4 P);
531uvec4 textureProj(usampler3D sampler, vec4 P);
532
533float textureProj(sampler1DShadow sampler, vec4 P);
534float textureProj(sampler2DShadow sampler, vec4 P);
535
536/* textureProj - bias variants */
537 vec4 textureProj( sampler1D sampler, vec2 P, float bias);
538ivec4 textureProj(isampler1D sampler, vec2 P, float bias);
539uvec4 textureProj(usampler1D sampler, vec2 P, float bias);
540 vec4 textureProj( sampler1D sampler, vec4 P, float bias);
541ivec4 textureProj(isampler1D sampler, vec4 P, float bias);
542uvec4 textureProj(usampler1D sampler, vec4 P, float bias);
543
544 vec4 textureProj( sampler2D sampler, vec3 P, float bias);
545ivec4 textureProj(isampler2D sampler, vec3 P, float bias);
546uvec4 textureProj(usampler2D sampler, vec3 P, float bias);
547 vec4 textureProj( sampler2D sampler, vec4 P, float bias);
548ivec4 textureProj(isampler2D sampler, vec4 P, float bias);
549uvec4 textureProj(usampler2D sampler, vec4 P, float bias);
550
551 vec4 textureProj( sampler3D sampler, vec4 P, float bias);
552ivec4 textureProj(isampler3D sampler, vec4 P, float bias);
553uvec4 textureProj(usampler3D sampler, vec4 P, float bias);
554
555float textureProj(sampler1DShadow sampler, vec4 P, float bias);
556float textureProj(sampler2DShadow sampler, vec4 P, float bias);
557
558/* textureLod */
559 vec4 textureLod( sampler1D sampler, float P, float lod);
560ivec4 textureLod(isampler1D sampler, float P, float lod);
561uvec4 textureLod(usampler1D sampler, float P, float lod);
562
563 vec4 textureLod( sampler2D sampler, vec2 P, float lod);
564ivec4 textureLod(isampler2D sampler, vec2 P, float lod);
565uvec4 textureLod(usampler2D sampler, vec2 P, float lod);
566
567 vec4 textureLod( sampler3D sampler, vec3 P, float lod);
568ivec4 textureLod(isampler3D sampler, vec3 P, float lod);
569uvec4 textureLod(usampler3D sampler, vec3 P, float lod);
570
571 vec4 textureLod( samplerCube sampler, vec3 P, float lod);
572ivec4 textureLod(isamplerCube sampler, vec3 P, float lod);
573uvec4 textureLod(usamplerCube sampler, vec3 P, float lod);
574
575float textureLod(sampler1DShadow sampler, vec3 P, float lod);
576float textureLod(sampler2DShadow sampler, vec3 P, float lod);
577
578 vec4 textureLod( sampler1DArray sampler, vec2 P, float lod);
579ivec4 textureLod(isampler1DArray sampler, vec2 P, float lod);
580uvec4 textureLod(usampler1DArray sampler, vec2 P, float lod);
581
582 vec4 textureLod( sampler2DArray sampler, vec3 P, float lod);
583ivec4 textureLod(isampler2DArray sampler, vec3 P, float lod);
584uvec4 textureLod(usampler2DArray sampler, vec3 P, float lod);
585
586float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod);
587
588#if 0
589/* textureOffset - no bias */
590 vec4 textureOffset( sampler1D sampler, float P, int offset);
591ivec4 textureOffset(isampler1D sampler, float P, int offset);
592uvec4 textureOffset(usampler1D sampler, float P, int offset);
593
594 vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset);
595ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset);
596uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset);
597
598 vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset);
599ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset);
600uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset);
601
602float textureOffset(sampler1DShadow sampler, vec3 P, int offset);
603float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset);
604
605 vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset);
606ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset);
607uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset);
608
609 vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset);
610ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset);
611uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset);
612
613float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset);
614
615/* textureOffset - bias variants */
616 vec4 textureOffset( sampler1D sampler, float P, int offset, float bias);
617ivec4 textureOffset(isampler1D sampler, float P, int offset, float bias);
618uvec4 textureOffset(usampler1D sampler, float P, int offset, float bias);
619
620 vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset, float bias);
621ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset, float bias);
622uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset, float bias);
623
624 vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset, float bias);
625ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset, float bias);
626uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset, float bias);
627
628float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias);
629float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias);
630
631 vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset, float bias);
632ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset, float bias);
633uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset, float bias);
634
635 vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset, float bias);
636ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset, float bias);
637uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset, float bias);
638
639float textureOffset(sampler1DArrayShadow samp, vec3 P, int offset, float bias);
640#endif
641
642/* texelFetch */
643 vec4 texelFetch( sampler1D sampler, int P, int lod);
644ivec4 texelFetch(isampler1D sampler, int P, int lod);
645uvec4 texelFetch(usampler1D sampler, int P, int lod);
646
647 vec4 texelFetch( sampler2D sampler, ivec2 P, int lod);
648ivec4 texelFetch(isampler2D sampler, ivec2 P, int lod);
649uvec4 texelFetch(usampler2D sampler, ivec2 P, int lod);
650
651 vec4 texelFetch( sampler3D sampler, ivec3 P, int lod);
652ivec4 texelFetch(isampler3D sampler, ivec3 P, int lod);
653uvec4 texelFetch(usampler3D sampler, ivec3 P, int lod);
654
655 vec4 texelFetch( sampler1DArray sampler, ivec2 P, int lod);
656ivec4 texelFetch(isampler1DArray sampler, ivec2 P, int lod);
657uvec4 texelFetch(usampler1DArray sampler, ivec2 P, int lod);
658
659 vec4 texelFetch( sampler2DArray sampler, ivec3 P, int lod);
660ivec4 texelFetch(isampler2DArray sampler, ivec3 P, int lod);
661uvec4 texelFetch(usampler2DArray sampler, ivec3 P, int lod);
662
663#if 0
664/* texelFetchOffset */
665 vec4 texelFetchOffset( sampler1D sampler, int P, int lod, int offset);
666ivec4 texelFetchOffset(isampler1D sampler, int P, int lod, int offset);
667uvec4 texelFetchOffset(usampler1D sampler, int P, int lod, int offset);
668
669 vec4 texelFetchOffset( sampler2D sampler, ivec2 P, int lod, ivec2 offset);
670ivec4 texelFetchOffset(isampler2D sampler, ivec2 P, int lod, ivec2 offset);
671uvec4 texelFetchOffset(usampler2D sampler, ivec2 P, int lod, ivec2 offset);
672
673 vec4 texelFetchOffset( sampler3D sampler, ivec3 P, int lod, ivec3 offset);
674ivec4 texelFetchOffset(isampler3D sampler, ivec3 P, int lod, ivec3 offset);
675uvec4 texelFetchOffset(usampler3D sampler, ivec3 P, int lod, ivec3 offset);
676
677 vec4 texelFetchOffset( sampler1DArray sampler, ivec2 P, int lod, int offset);
678ivec4 texelFetchOffset(isampler1DArray sampler, ivec2 P, int lod, int offset);
679uvec4 texelFetchOffset(usampler1DArray sampler, ivec2 P, int lod, int offset);
680
681 vec4 texelFetchOffset( sampler2DArray sampler, ivec3 P, int lod, ivec2 offset);
682ivec4 texelFetchOffset(isampler2DArray sampler, ivec3 P, int lod, ivec2 offset);
683uvec4 texelFetchOffset(usampler2DArray sampler, ivec3 P, int lod, ivec2 offset);
684
685/* textureProjOffset - no bias */
686 vec4 textureProj( sampler1D sampler, vec2 P, int offset);
687ivec4 textureProj(isampler1D sampler, vec2 P, int offset);
688uvec4 textureProj(usampler1D sampler, vec2 P, int offset);
689 vec4 textureProj( sampler1D sampler, vec4 P, int offset);
690ivec4 textureProj(isampler1D sampler, vec4 P, int offset);
691uvec4 textureProj(usampler1D sampler, vec4 P, int offset);
692
693 vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset);
694ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset);
695uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset);
696 vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset);
697ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset);
698uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset);
699
700 vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset);
701ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset);
702uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset);
703
704float textureProj(sampler1DShadow sampler, vec4 P, int offset);
705float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset);
706
707/* textureProjOffset - bias variants */
708 vec4 textureProj( sampler1D sampler, vec2 P, int offset, float bias);
709ivec4 textureProj(isampler1D sampler, vec2 P, int offset, float bias);
710uvec4 textureProj(usampler1D sampler, vec2 P, int offset, float bias);
711 vec4 textureProj( sampler1D sampler, vec4 P, int offset, float bias);
712ivec4 textureProj(isampler1D sampler, vec4 P, int offset, float bias);
713uvec4 textureProj(usampler1D sampler, vec4 P, int offset, float bias);
714
715 vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset, float bias);
716ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset, float bias);
717uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset, float bias);
718 vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset, float bias);
719ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset, float bias);
720uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset, float bias);
721
722 vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset, float bias);
723ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset, float bias);
724uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset, float bias);
725
726float textureProj(sampler1DShadow sampler, vec4 P, int offset, float bias);
727float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias);
728
729/* textureLodOffset */
730 vec4 textureLodOffset( sampler1D sampler, float P, float lod, int offset);
731ivec4 textureLodOffset(isampler1D sampler, float P, float lod, int offset);
732uvec4 textureLodOffset(usampler1D sampler, float P, float lod, int offset);
733
734 vec4 textureLodOffset( sampler2D sampler, vec2 P, float lod, ivec2 offset);
735ivec4 textureLodOffset(isampler2D sampler, vec2 P, float lod, ivec2 offset);
736uvec4 textureLodOffset(usampler2D sampler, vec2 P, float lod, ivec2 offset);
737
738 vec4 textureLodOffset( sampler3D sampler, vec3 P, float lod, ivec3 offset);
739ivec4 textureLodOffset(isampler3D sampler, vec3 P, float lod, ivec3 offset);
740uvec4 textureLodOffset(usampler3D sampler, vec3 P, float lod, ivec3 offset);
741
742float textureLodOffset(sampler1DShadow samp, vec3 P, float lod, int offset);
743float textureLodOffset(sampler2DShadow samp, vec3 P, float lod, ivec2 offset);
744
745 vec4 textureLodOffset( sampler1DArray sampler, vec2 P, float lod, int offset);
746ivec4 textureLodOffset(isampler1DArray sampler, vec2 P, float lod, int offset);
747uvec4 textureLodOffset(usampler1DArray sampler, vec2 P, float lod, int offset);
748
749 vec4 textureLodOffset( sampler2DArray samp, vec3 P, float lod, ivec2 offset);
750ivec4 textureLodOffset(isampler2DArray samp, vec3 P, float lod, ivec2 offset);
751uvec4 textureLodOffset(usampler2DArray samp, vec3 P, float lod, ivec2 offset);
752
753float textureLodOffset(sampler1DArrayShadow s, vec3 P, float lod, int offset);
754#endif
755
756/* textureProjLod */
757 vec4 textureProjLod( sampler1D sampler, vec2 P, float lod);
758ivec4 textureProjLod(isampler1D sampler, vec2 P, float lod);
759uvec4 textureProjLod(usampler1D sampler, vec2 P, float lod);
760 vec4 textureProjLod( sampler1D sampler, vec4 P, float lod);
761ivec4 textureProjLod(isampler1D sampler, vec4 P, float lod);
762uvec4 textureProjLod(usampler1D sampler, vec4 P, float lod);
763
764 vec4 textureProjLod( sampler2D sampler, vec3 P, float lod);
765ivec4 textureProjLod(isampler2D sampler, vec3 P, float lod);
766uvec4 textureProjLod(usampler2D sampler, vec3 P, float lod);
767 vec4 textureProjLod( sampler2D sampler, vec4 P, float lod);
768ivec4 textureProjLod(isampler2D sampler, vec4 P, float lod);
769uvec4 textureProjLod(usampler2D sampler, vec4 P, float lod);
770
771 vec4 textureProjLod( sampler3D sampler, vec4 P, float lod);
772ivec4 textureProjLod(isampler3D sampler, vec4 P, float lod);
773uvec4 textureProjLod(usampler3D sampler, vec4 P, float lod);
774
775float textureProjLod(sampler1DShadow sampler, vec4 P, float lod);
776float textureProjLod(sampler2DShadow sampler, vec4 P, float lod);
777
778#if 0
779/* textureProjLodOffset */
780 vec4 textureProjLodOffset( sampler1D sampler, vec2 P, float lod, int offset);
781ivec4 textureProjLodOffset(isampler1D sampler, vec2 P, float lod, int offset);
782uvec4 textureProjLodOffset(usampler1D sampler, vec2 P, float lod, int offset);
783 vec4 textureProjLodOffset( sampler1D sampler, vec4 P, float lod, int offset);
784ivec4 textureProjLodOffset(isampler1D sampler, vec4 P, float lod, int offset);
785uvec4 textureProjLodOffset(usampler1D sampler, vec4 P, float lod, int offset);
786
787 vec4 textureProjLodOffset( sampler2D sampler, vec3 P, float lod, ivec2 offset);
788ivec4 textureProjLodOffset(isampler2D sampler, vec3 P, float lod, ivec2 offset);
789uvec4 textureProjLodOffset(usampler2D sampler, vec3 P, float lod, ivec2 offset);
790 vec4 textureProjLodOffset( sampler2D sampler, vec4 P, float lod, ivec2 offset);
791ivec4 textureProjLodOffset(isampler2D sampler, vec4 P, float lod, ivec2 offset);
792uvec4 textureProjLodOffset(usampler2D sampler, vec4 P, float lod, ivec2 offset);
793
794 vec4 textureProjLodOffset( sampler3D sampler, vec4 P, float lod, ivec3 offset);
795ivec4 textureProjLodOffset(isampler3D sampler, vec4 P, float lod, ivec3 offset);
796uvec4 textureProjLodOffset(usampler3D sampler, vec4 P, float lod, ivec3 offset);
797
798float textureProjLodOffset(sampler1DShadow s, vec4 P, float lod, int offset);
799float textureProjLodOffset(sampler2DShadow s, vec4 P, float lod, ivec2 offset);
800#endif
801
802/* textureGrad */
803 vec4 textureGrad( sampler1D sampler, float P, float dPdx, float dPdy);
804ivec4 textureGrad(isampler1D sampler, float P, float dPdx, float dPdy);
805uvec4 textureGrad(usampler1D sampler, float P, float dPdx, float dPdy);
806
807 vec4 textureGrad( sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);
808ivec4 textureGrad(isampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);
809uvec4 textureGrad(usampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);
810
811 vec4 textureGrad( sampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);
812ivec4 textureGrad(isampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);
813uvec4 textureGrad(usampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);
814
815 vec4 textureGrad( samplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);
816ivec4 textureGrad(isamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);
817uvec4 textureGrad(usamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);
818
819float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy);
820float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy);
821float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy);
822
823 vec4 textureGrad( sampler1DArray sampler, vec2 P, float dPdx, float dPdy);
824ivec4 textureGrad(isampler1DArray sampler, vec2 P, float dPdx, float dPdy);
825uvec4 textureGrad(usampler1DArray sampler, vec2 P, float dPdx, float dPdy);
826
827 vec4 textureGrad( sampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy);
828ivec4 textureGrad(isampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy);
829uvec4 textureGrad(usampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy);
830
831float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy);
832float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy);
833
834#if 0
835/* textureGradOffset */
836 vec4 textureGradOffset( sampler1D s, float P, float dx, float dy, int off);
837ivec4 textureGradOffset(isampler1D s, float P, float dx, float dy, int offset);
838uvec4 textureGradOffset(usampler1D s, float P, float dx, float dy, int offset);
839
840 vec4 textureGradOffset( sampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset);
841ivec4 textureGradOffset(isampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset);
842uvec4 textureGradOffset(usampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset);
843
844 vec4 textureGradOffset( sampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
845ivec4 textureGradOffset(isampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
846uvec4 textureGradOffset(usampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
847
848 vec4 textureGradOffset( samplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
849ivec4 textureGradOffset(isamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
850uvec4 textureGradOffset(usamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
851
852float textureGradOffset(sampler1DShadow s, vec3 P, float dx, float dy, int off);
853float textureGradOffset(sampler2DShadow s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
854
855 vec4 textureGradOffset( sampler1DArray s, vec2 P, float dx, float dy, int off);
856ivec4 textureGradOffset(isampler1DArray s, vec2 P, float dx, float dy, int off);
857uvec4 textureGradOffset(usampler1DArray s, vec2 P, float dx, float dy, int off);
858
859 vec4 textureGradOffset( sampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
860ivec4 textureGradOffset(isampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
861uvec4 textureGradOffset(usampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
862
863float textureGradOffset(sampler1DArrayShadow s, vec3 P, float dx, float dy, int o);
864float textureGradOffset(sampler2DArrayShadow s, vec4 P, vec2 dx, vec2 dy, ivec2 o);
865#endif
866
867/* textureProjGrad */
868 vec4 textureProjGrad( sampler1D sampler, vec2 P, float dPdx, float dPdy);
869ivec4 textureProjGrad(isampler1D sampler, vec2 P, float dPdx, float dPdy);
870uvec4 textureProjGrad(usampler1D sampler, vec2 P, float dPdx, float dPdy);
871 vec4 textureProjGrad( sampler1D sampler, vec4 P, float dPdx, float dPdy);
872ivec4 textureProjGrad(isampler1D sampler, vec4 P, float dPdx, float dPdy);
873uvec4 textureProjGrad(usampler1D sampler, vec4 P, float dPdx, float dPdy);
874
875 vec4 textureProjGrad( sampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy);
876ivec4 textureProjGrad(isampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy);
877uvec4 textureProjGrad(usampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy);
878 vec4 textureProjGrad( sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy);
879ivec4 textureProjGrad(isampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy);
880uvec4 textureProjGrad(usampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy);
881
882 vec4 textureProjGrad( sampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy);
883ivec4 textureProjGrad(isampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy);
884uvec4 textureProjGrad(usampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy);
885
886float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy);
887float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy);
888
889#if 0
890/* textureProjGradOffset */
891 vec4 textureProjGradOffset( sampler1D s, vec2 P, float dx, float dy, int off);
892ivec4 textureProjGradOffset(isampler1D s, vec2 P, float dx, float dy, int off);
893uvec4 textureProjGradOffset(usampler1D s, vec2 P, float dx, float dy, int off);
894 vec4 textureProjGradOffset( sampler1D s, vec4 P, float dx, float dy, int off);
895ivec4 textureProjGradOffset(isampler1D s, vec4 P, float dx, float dy, int off);
896uvec4 textureProjGradOffset(usampler1D s, vec4 P, float dx, float dy, int off);
897
898 vec4 textureProjGradOffset( sampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
899ivec4 textureProjGradOffset(isampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
900uvec4 textureProjGradOffset(usampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
901 vec4 textureProjGradOffset( sampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off);
902ivec4 textureProjGradOffset(isampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off);
903uvec4 textureProjGradOffset(usampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off);
904
905 vec4 textureProjGradOffset( sampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off);
906ivec4 textureProjGradOffset(isampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off);
907uvec4 textureProjGradOffset(usampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off);
908
909float textureProjGradOffset(sampler1DShadow s, vec4 P, float dx, float dy, int o);
910float textureProjGradOffset(sampler2DShadow s, vec4 P, vec2 dx, vec2 dy, vec2 o);
911#endif
912
913/*
914 * The following texture functions are deprecated:
915 */
916vec4 texture1D (sampler1D sampler, float coord);
917vec4 texture1DProj (sampler1D sampler, vec2 coord);
918vec4 texture1DProj (sampler1D sampler, vec4 coord);
919vec4 texture1D (sampler1D sampler, float coord, float bias);
920vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias);
921vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias);
922vec4 texture1DLod (sampler1D sampler, float coord, float lod);
923vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);
924vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);
925
926vec4 texture2D (sampler2D sampler, vec2 coord);
927vec4 texture2DProj (sampler2D sampler, vec3 coord);
928vec4 texture2DProj (sampler2D sampler, vec4 coord);
929vec4 texture2D (sampler2D sampler, vec2 coord, float bias);
930vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias);
931vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias);
932vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod);
933vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);
934vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);
935
936vec4 texture3D (sampler3D sampler, vec3 coord);
937vec4 texture3DProj (sampler3D sampler, vec4 coord);
938vec4 texture3D (sampler3D sampler, vec3 coord, float bias);
939vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias);
940vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod);
941vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);
942
943vec4 textureCube (samplerCube sampler, vec3 coord);
944vec4 textureCube (samplerCube sampler, vec3 coord, float bias);
945vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod);
946
947vec4 shadow1D (sampler1DShadow sampler, vec3 coord);
948vec4 shadow2D (sampler2DShadow sampler, vec3 coord);
949vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord);
950vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord);
951vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias);
952vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias);
953vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias);
954vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias);
955vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod);
956vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod);
957vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);
958vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);
959
960/*
961 * 8.8 - Fragment Processing Functions
962 */
963float dFdx(float p);
964vec2 dFdx(vec2 p);
965vec3 dFdx(vec3 p);
966vec4 dFdx(vec4 p);
967
968float dFdy(float p);
969vec2 dFdy(vec2 p);
970vec3 dFdy(vec3 p);
971vec4 dFdy(vec4 p);
972
973float fwidth(float p);
974vec2 fwidth(vec2 p);
975vec3 fwidth(vec3 p);
976vec4 fwidth(vec4 p);
977
978/*
979 * 8.9 - Noise Functions
980 */
981float noise1(float x);
982float noise1(vec2 x);
983float noise1(vec3 x);
984float noise1(vec4 x);
985
986vec2 noise2(float x);
987vec2 noise2(vec2 x);
988vec2 noise2(vec3 x);
989vec2 noise2(vec4 x);
990
991vec3 noise3(float x);
992vec3 noise3(vec2 x);
993vec3 noise3(vec3 x);
994vec3 noise3(vec4 x);
995
996vec4 noise4(float x);
997vec4 noise4(vec2 x);
998vec4 noise4(vec3 x);
999vec4 noise4(vec4 x);
diff --git a/src/glsl/builtins/profiles/130.vert b/src/glsl/builtins/profiles/130.vert
new file mode 100644
index 00000000000..1aaad190d59
--- /dev/null
+++ b/src/glsl/builtins/profiles/130.vert
@@ -0,0 +1,987 @@
1#version 130
2/*
3 * 8.1 - Angle and Trigonometry Functions
4 */
5float radians(float degrees);
6vec2 radians(vec2 degrees);
7vec3 radians(vec3 degrees);
8vec4 radians(vec4 degrees);
9
10float degrees(float radians);
11vec2 degrees(vec2 radians);
12vec3 degrees(vec3 radians);
13vec4 degrees(vec4 radians);
14
15float sin(float angle);
16vec2 sin(vec2 angle);
17vec3 sin(vec3 angle);
18vec4 sin(vec4 angle);
19
20float cos(float angle);
21vec2 cos(vec2 angle);
22vec3 cos(vec3 angle);
23vec4 cos(vec4 angle);
24
25float tan(float angle);
26vec2 tan(vec2 angle);
27vec3 tan(vec3 angle);
28vec4 tan(vec4 angle);
29
30float asin(float angle);
31vec2 asin(vec2 angle);
32vec3 asin(vec3 angle);
33vec4 asin(vec4 angle);
34
35float acos(float angle);
36vec2 acos(vec2 angle);
37vec3 acos(vec3 angle);
38vec4 acos(vec4 angle);
39
40float atan(float y, float x);
41vec2 atan(vec2 y, vec2 x);
42vec3 atan(vec3 y, vec3 x);
43vec4 atan(vec4 y, vec4 x);
44
45float atan(float y_over_x);
46vec2 atan(vec2 y_over_x);
47vec3 atan(vec3 y_over_x);
48vec4 atan(vec4 y_over_x);
49
50/*
51 * 8.2 - Exponential Functions
52 */
53float pow(float x, float y);
54vec2 pow(vec2 x, vec2 y);
55vec3 pow(vec3 x, vec3 y);
56vec4 pow(vec4 x, vec4 y);
57
58float exp(float x);
59vec2 exp(vec2 x);
60vec3 exp(vec3 x);
61vec4 exp(vec4 x);
62
63float log(float x);
64vec2 log(vec2 x);
65vec3 log(vec3 x);
66vec4 log(vec4 x);
67
68float exp2(float x);
69vec2 exp2(vec2 x);
70vec3 exp2(vec3 x);
71vec4 exp2(vec4 x);
72
73float log2(float x);
74vec2 log2(vec2 x);
75vec3 log2(vec3 x);
76vec4 log2(vec4 x);
77
78float sqrt(float x);
79vec2 sqrt(vec2 x);
80vec3 sqrt(vec3 x);
81vec4 sqrt(vec4 x);
82
83float inversesqrt(float x);
84vec2 inversesqrt(vec2 x);
85vec3 inversesqrt(vec3 x);
86vec4 inversesqrt(vec4 x);
87
88/*
89 * 8.3 - Common Functions
90 */
91float abs(float x);
92vec2 abs(vec2 x);
93vec3 abs(vec3 x);
94vec4 abs(vec4 x);
95int abs(int x);
96ivec2 abs(ivec2 x);
97ivec3 abs(ivec3 x);
98ivec4 abs(ivec4 x);
99
100float sign(float x);
101vec2 sign(vec2 x);
102vec3 sign(vec3 x);
103vec4 sign(vec4 x);
104int sign(int x);
105ivec2 sign(ivec2 x);
106ivec3 sign(ivec3 x);
107ivec4 sign(ivec4 x);
108
109float floor(float x);
110vec2 floor(vec2 x);
111vec3 floor(vec3 x);
112vec4 floor(vec4 x);
113
114float ceil(float x);
115vec2 ceil(vec2 x);
116vec3 ceil(vec3 x);
117vec4 ceil(vec4 x);
118
119float fract(float x);
120vec2 fract(vec2 x);
121vec3 fract(vec3 x);
122vec4 fract(vec4 x);
123
124float mod(float x, float y);
125vec2 mod(vec2 x, float y);
126vec3 mod(vec3 x, float y);
127vec4 mod(vec4 x, float y);
128
129vec2 mod(vec2 x, vec2 y);
130vec3 mod(vec3 x, vec3 y);
131vec4 mod(vec4 x, vec4 y);
132
133float min(float x, float y);
134vec2 min(vec2 x, vec2 y);
135vec3 min(vec3 x, vec3 y);
136vec4 min(vec4 x, vec4 y);
137
138vec2 min(vec2 x, float y);
139vec3 min(vec3 x, float y);
140vec4 min(vec4 x, float y);
141
142int min(int x, int y);
143ivec2 min(ivec2 x, ivec2 y);
144ivec3 min(ivec3 x, ivec3 y);
145ivec4 min(ivec4 x, ivec4 y);
146
147ivec2 min(ivec2 x, int y);
148ivec3 min(ivec3 x, int y);
149ivec4 min(ivec4 x, int y);
150
151uint min(uint x, uint y);
152uvec2 min(uvec2 x, uvec2 y);
153uvec3 min(uvec3 x, uvec3 y);
154uvec4 min(uvec4 x, uvec4 y);
155
156uvec2 min(uvec2 x, uint y);
157uvec3 min(uvec3 x, uint y);
158uvec4 min(uvec4 x, uint y);
159
160float max(float x, float y);
161vec2 max(vec2 x, vec2 y);
162vec3 max(vec3 x, vec3 y);
163vec4 max(vec4 x, vec4 y);
164
165vec2 max(vec2 x, float y);
166vec3 max(vec3 x, float y);
167vec4 max(vec4 x, float y);
168
169int max(int x, int y);
170ivec2 max(ivec2 x, ivec2 y);
171ivec3 max(ivec3 x, ivec3 y);
172ivec4 max(ivec4 x, ivec4 y);
173
174ivec2 max(ivec2 x, int y);
175ivec3 max(ivec3 x, int y);
176ivec4 max(ivec4 x, int y);
177
178uint max(uint x, uint y);
179uvec2 max(uvec2 x, uvec2 y);
180uvec3 max(uvec3 x, uvec3 y);
181uvec4 max(uvec4 x, uvec4 y);
182
183uvec2 max(uvec2 x, uint y);
184uvec3 max(uvec3 x, uint y);
185uvec4 max(uvec4 x, uint y);
186
187float clamp(float x, float minVal, float maxVal);
188vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
189vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
190vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
191
192vec2 clamp(vec2 x, float minVal, float maxVal);
193vec3 clamp(vec3 x, float minVal, float maxVal);
194vec4 clamp(vec4 x, float minVal, float maxVal);
195
196int clamp(int x, int minVal, int maxVal);
197ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal);
198ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal);
199ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal);
200
201ivec2 clamp(ivec2 x, int minVal, int maxVal);
202ivec3 clamp(ivec3 x, int minVal, int maxVal);
203ivec4 clamp(ivec4 x, int minVal, int maxVal);
204
205uint clamp(uint x, uint minVal, uint maxVal);
206uvec2 clamp(uvec2 x, uvec2 minVal, uvec2 maxVal);
207uvec3 clamp(uvec3 x, uvec3 minVal, uvec3 maxVal);
208uvec4 clamp(uvec4 x, uvec4 minVal, uvec4 maxVal);
209
210uvec2 clamp(uvec2 x, uint minVal, uint maxVal);
211uvec3 clamp(uvec3 x, uint minVal, uint maxVal);
212uvec4 clamp(uvec4 x, uint minVal, uint maxVal);
213
214float mix(float x, float y, float a);
215vec2 mix(vec2 x, vec2 y, vec2 a);
216vec3 mix(vec3 x, vec3 y, vec3 a);
217vec4 mix(vec4 x, vec4 y, vec4 a);
218
219vec2 mix(vec2 x, vec2 y, float a);
220vec3 mix(vec3 x, vec3 y, float a);
221vec4 mix(vec4 x, vec4 y, float a);
222
223float step(float edge, float x);
224vec2 step(vec2 edge, vec2 x);
225vec3 step(vec3 edge, vec3 x);
226vec4 step(vec4 edge, vec4 x);
227
228vec2 step(float edge, vec2 x);
229vec3 step(float edge, vec3 x);
230vec4 step(float edge, vec4 x);
231
232float smoothstep(float edge0, float edge1, float x);
233vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
234vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
235vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
236
237vec2 smoothstep(float edge0, float edge1, vec2 x);
238vec3 smoothstep(float edge0, float edge1, vec3 x);
239vec4 smoothstep(float edge0, float edge1, vec4 x);
240
241#if 0
242bool isnan(float x);
243bvec2 isnan(vec2 x);
244bvec3 isnan(vec3 x);
245bvec4 isnan(vec4 x);
246
247bool isinf(float x);
248bvec2 isinf(vec2 x);
249bvec3 isinf(vec3 x);
250bvec4 isinf(vec4 x);
251#endif
252
253/*
254 * 8.4 - Geometric Functions
255 */
256float length(float x);
257float length(vec2 x);
258float length(vec3 x);
259float length(vec4 x);
260
261float distance(float p0, float p1);
262float distance(vec2 p0, vec2 p1);
263float distance(vec3 p0, vec3 p1);
264float distance(vec4 p0, vec4 p1);
265
266float dot(float x, float y);
267float dot(vec2 x, vec2 y);
268float dot(vec3 x, vec3 y);
269float dot(vec4 x, vec4 y);
270
271vec3 cross(vec3 x, vec3 y);
272
273float normalize(float x);
274vec2 normalize(vec2 x);
275vec3 normalize(vec3 x);
276vec4 normalize(vec4 x);
277
278vec4 ftransform();
279
280float faceforward(float N, float I, float Nref);
281vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
282vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
283vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
284
285float reflect(float I, float N);
286vec2 reflect(vec2 I, vec2 N);
287vec3 reflect(vec3 I, vec3 N);
288vec4 reflect(vec4 I, vec4 N);
289
290float refract(float I, float N, float eta);
291vec2 refract(vec2 I, vec2 N, float eta);
292vec3 refract(vec3 I, vec3 N, float eta);
293vec4 refract(vec4 I, vec4 N, float eta);
294
295
296/*
297 * 8.5 - Matrix Functions
298 */
299mat2 matrixCompMult(mat2 x, mat2 y);
300mat3 matrixCompMult(mat3 x, mat3 y);
301mat4 matrixCompMult(mat4 x, mat4 y);
302mat2x3 matrixCompMult(mat2x3 x, mat2x3 y);
303mat2x4 matrixCompMult(mat2x4 x, mat2x4 y);
304mat3x2 matrixCompMult(mat3x2 x, mat3x2 y);
305mat3x4 matrixCompMult(mat3x4 x, mat3x4 y);
306mat4x2 matrixCompMult(mat4x2 x, mat4x2 y);
307mat4x3 matrixCompMult(mat4x3 x, mat4x3 y);
308
309mat2 outerProduct(vec2 c, vec2 r);
310mat3 outerProduct(vec3 c, vec3 r);
311mat4 outerProduct(vec4 c, vec4 r);
312
313mat2x3 outerProduct(vec3 c, vec2 r);
314mat3x2 outerProduct(vec2 c, vec3 r);
315
316mat2x4 outerProduct(vec4 c, vec2 r);
317mat4x2 outerProduct(vec2 c, vec4 r);
318
319mat3x4 outerProduct(vec4 c, vec3 r);
320mat4x3 outerProduct(vec3 c, vec4 r);
321
322mat2 transpose(mat2 m);
323mat3 transpose(mat3 m);
324mat4 transpose(mat4 m);
325
326mat2x3 transpose(mat3x2 m);
327mat3x2 transpose(mat2x3 m);
328
329mat2x4 transpose(mat4x2 m);
330mat4x2 transpose(mat2x4 m);
331
332mat3x4 transpose(mat4x3 m);
333mat4x3 transpose(mat3x4 m);
334
335/*
336 * 8.6 - Vector Relational Functions
337 */
338bvec2 lessThan( vec2 x, vec2 y);
339bvec3 lessThan( vec3 x, vec3 y);
340bvec4 lessThan( vec4 x, vec4 y);
341bvec2 lessThan(ivec2 x, ivec2 y);
342bvec3 lessThan(ivec3 x, ivec3 y);
343bvec4 lessThan(ivec4 x, ivec4 y);
344bvec2 lessThan(uvec2 x, uvec2 y);
345bvec3 lessThan(uvec3 x, uvec3 y);
346bvec4 lessThan(uvec4 x, uvec4 y);
347
348bvec2 lessThanEqual( vec2 x, vec2 y);
349bvec3 lessThanEqual( vec3 x, vec3 y);
350bvec4 lessThanEqual( vec4 x, vec4 y);
351bvec2 lessThanEqual(ivec2 x, ivec2 y);
352bvec3 lessThanEqual(ivec3 x, ivec3 y);
353bvec4 lessThanEqual(ivec4 x, ivec4 y);
354bvec2 lessThanEqual(uvec2 x, uvec2 y);
355bvec3 lessThanEqual(uvec3 x, uvec3 y);
356bvec4 lessThanEqual(uvec4 x, uvec4 y);
357
358bvec2 greaterThan( vec2 x, vec2 y);
359bvec3 greaterThan( vec3 x, vec3 y);
360bvec4 greaterThan( vec4 x, vec4 y);
361bvec2 greaterThan(ivec2 x, ivec2 y);
362bvec3 greaterThan(ivec3 x, ivec3 y);
363bvec4 greaterThan(ivec4 x, ivec4 y);
364bvec2 greaterThan(uvec2 x, uvec2 y);
365bvec3 greaterThan(uvec3 x, uvec3 y);
366bvec4 greaterThan(uvec4 x, uvec4 y);
367
368bvec2 greaterThanEqual( vec2 x, vec2 y);
369bvec3 greaterThanEqual( vec3 x, vec3 y);
370bvec4 greaterThanEqual( vec4 x, vec4 y);
371bvec2 greaterThanEqual(ivec2 x, ivec2 y);
372bvec3 greaterThanEqual(ivec3 x, ivec3 y);
373bvec4 greaterThanEqual(ivec4 x, ivec4 y);
374bvec2 greaterThanEqual(uvec2 x, uvec2 y);
375bvec3 greaterThanEqual(uvec3 x, uvec3 y);
376bvec4 greaterThanEqual(uvec4 x, uvec4 y);
377
378bvec2 equal( vec2 x, vec2 y);
379bvec3 equal( vec3 x, vec3 y);
380bvec4 equal( vec4 x, vec4 y);
381bvec2 equal(ivec2 x, ivec2 y);
382bvec3 equal(ivec3 x, ivec3 y);
383bvec4 equal(ivec4 x, ivec4 y);
384bvec2 equal(uvec2 x, uvec2 y);
385bvec3 equal(uvec3 x, uvec3 y);
386bvec4 equal(uvec4 x, uvec4 y);
387bvec2 equal(bvec2 x, bvec2 y);
388bvec3 equal(bvec3 x, bvec3 y);
389bvec4 equal(bvec4 x, bvec4 y);
390
391bvec2 notEqual( vec2 x, vec2 y);
392bvec3 notEqual( vec3 x, vec3 y);
393bvec4 notEqual( vec4 x, vec4 y);
394bvec2 notEqual(ivec2 x, ivec2 y);
395bvec3 notEqual(ivec3 x, ivec3 y);
396bvec4 notEqual(ivec4 x, ivec4 y);
397bvec2 notEqual(uvec2 x, uvec2 y);
398bvec3 notEqual(uvec3 x, uvec3 y);
399bvec4 notEqual(uvec4 x, uvec4 y);
400bvec2 notEqual(bvec2 x, bvec2 y);
401bvec3 notEqual(bvec3 x, bvec3 y);
402bvec4 notEqual(bvec4 x, bvec4 y);
403
404bool any(bvec2 x);
405bool any(bvec3 x);
406bool any(bvec4 x);
407
408bool all(bvec2 x);
409bool all(bvec3 x);
410bool all(bvec4 x);
411
412bvec2 not(bvec2 x);
413bvec3 not(bvec3 x);
414bvec4 not(bvec4 x);
415
416/*
417 * 8.7 - Texture Lookup Functions
418 */
419
420#if 0
421/* textureSize */
422int textureSize( sampler1D sampler, int lod);
423int textureSize(isampler1D sampler, int lod);
424int textureSize(usampler1D sampler, int lod);
425
426ivec2 textureSize( sampler2D sampler, int lod);
427ivec2 textureSize(isampler2D sampler, int lod);
428ivec2 textureSize(usampler2D sampler, int lod);
429
430ivec3 textureSize( sampler3D sampler, int lod);
431ivec3 textureSize(isampler3D sampler, int lod);
432ivec3 textureSize(usampler3D sampler, int lod);
433
434ivec2 textureSize( samplerCube sampler, int lod);
435ivec2 textureSize(isamplerCube sampler, int lod);
436ivec2 textureSize(usamplerCube sampler, int lod);
437
438int textureSize(sampler1DShadow sampler, int lod);
439ivec2 textureSize(sampler2DShadow sampler, int lod);
440ivec2 textureSize(samplerCubeShadow sampler, int lod);
441
442ivec2 textureSize( sampler1DArray sampler, int lod);
443ivec2 textureSize(isampler1DArray sampler, int lod);
444ivec2 textureSize(usampler1DArray sampler, int lod);
445ivec3 textureSize( sampler2DArray sampler, int lod);
446ivec2 textureSize(isampler2DArray sampler, int lod);
447ivec2 textureSize(usampler2DArray sampler, int lod);
448
449ivec2 textureSize(sampler1DArrayShadow sampler, int lod);
450ivec3 textureSize(sampler2DArrayShadow sampler, int lod);
451#endif
452
453/* texture - no bias */
454 vec4 texture( sampler1D sampler, float P);
455ivec4 texture(isampler1D sampler, float P);
456uvec4 texture(usampler1D sampler, float P);
457
458 vec4 texture( sampler2D sampler, vec2 P);
459ivec4 texture(isampler2D sampler, vec2 P);
460uvec4 texture(usampler2D sampler, vec2 P);
461
462 vec4 texture( sampler3D sampler, vec3 P);
463ivec4 texture(isampler3D sampler, vec3 P);
464uvec4 texture(usampler3D sampler, vec3 P);
465
466 vec4 texture( samplerCube sampler, vec3 P);
467ivec4 texture(isamplerCube sampler, vec3 P);
468uvec4 texture(usamplerCube sampler, vec3 P);
469
470float texture(sampler1DShadow sampler, vec3 P);
471float texture(sampler2DShadow sampler, vec3 P);
472float texture(samplerCubeShadow sampler, vec4 P);
473
474 vec4 texture( sampler1DArray sampler, vec2 P);
475ivec4 texture(isampler1DArray sampler, vec2 P);
476uvec4 texture(usampler1DArray sampler, vec2 P);
477
478 vec4 texture( sampler2DArray sampler, vec3 P);
479ivec4 texture(isampler2DArray sampler, vec3 P);
480uvec4 texture(usampler2DArray sampler, vec3 P);
481
482float texture(sampler1DArrayShadow sampler, vec3 P);
483float texture(sampler2DArrayShadow sampler, vec4 P);
484
485/* texture - bias variants */
486 vec4 texture( sampler1D sampler, float P, float bias);
487ivec4 texture(isampler1D sampler, float P, float bias);
488uvec4 texture(usampler1D sampler, float P, float bias);
489
490 vec4 texture( sampler2D sampler, vec2 P, float bias);
491ivec4 texture(isampler2D sampler, vec2 P, float bias);
492uvec4 texture(usampler2D sampler, vec2 P, float bias);
493
494 vec4 texture( sampler3D sampler, vec3 P, float bias);
495ivec4 texture(isampler3D sampler, vec3 P, float bias);
496uvec4 texture(usampler3D sampler, vec3 P, float bias);
497
498 vec4 texture( samplerCube sampler, vec3 P, float bias);
499ivec4 texture(isamplerCube sampler, vec3 P, float bias);
500uvec4 texture(usamplerCube sampler, vec3 P, float bias);
501
502float texture(sampler1DShadow sampler, vec3 P, float bias);
503float texture(sampler2DShadow sampler, vec3 P, float bias);
504float texture(samplerCubeShadow sampler, vec4 P, float bias);
505
506 vec4 texture( sampler1DArray sampler, vec2 P, float bias);
507ivec4 texture(isampler1DArray sampler, vec2 P, float bias);
508uvec4 texture(usampler1DArray sampler, vec2 P, float bias);
509
510 vec4 texture( sampler2DArray sampler, vec3 P, float bias);
511ivec4 texture(isampler2DArray sampler, vec3 P, float bias);
512uvec4 texture(usampler2DArray sampler, vec3 P, float bias);
513
514float texture(sampler1DArrayShadow sampler, vec3 P, float bias);
515
516/* textureProj - no bias */
517 vec4 textureProj( sampler1D sampler, vec2 P);
518ivec4 textureProj(isampler1D sampler, vec2 P);
519uvec4 textureProj(usampler1D sampler, vec2 P);
520 vec4 textureProj( sampler1D sampler, vec4 P);
521ivec4 textureProj(isampler1D sampler, vec4 P);
522uvec4 textureProj(usampler1D sampler, vec4 P);
523
524 vec4 textureProj( sampler2D sampler, vec3 P);
525ivec4 textureProj(isampler2D sampler, vec3 P);
526uvec4 textureProj(usampler2D sampler, vec3 P);
527 vec4 textureProj( sampler2D sampler, vec4 P);
528ivec4 textureProj(isampler2D sampler, vec4 P);
529uvec4 textureProj(usampler2D sampler, vec4 P);
530
531 vec4 textureProj( sampler3D sampler, vec4 P);
532ivec4 textureProj(isampler3D sampler, vec4 P);
533uvec4 textureProj(usampler3D sampler, vec4 P);
534
535float textureProj(sampler1DShadow sampler, vec4 P);
536float textureProj(sampler2DShadow sampler, vec4 P);
537
538/* textureProj - bias variants */
539 vec4 textureProj( sampler1D sampler, vec2 P, float bias);
540ivec4 textureProj(isampler1D sampler, vec2 P, float bias);
541uvec4 textureProj(usampler1D sampler, vec2 P, float bias);
542 vec4 textureProj( sampler1D sampler, vec4 P, float bias);
543ivec4 textureProj(isampler1D sampler, vec4 P, float bias);
544uvec4 textureProj(usampler1D sampler, vec4 P, float bias);
545
546 vec4 textureProj( sampler2D sampler, vec3 P, float bias);
547ivec4 textureProj(isampler2D sampler, vec3 P, float bias);
548uvec4 textureProj(usampler2D sampler, vec3 P, float bias);
549 vec4 textureProj( sampler2D sampler, vec4 P, float bias);
550ivec4 textureProj(isampler2D sampler, vec4 P, float bias);
551uvec4 textureProj(usampler2D sampler, vec4 P, float bias);
552
553 vec4 textureProj( sampler3D sampler, vec4 P, float bias);
554ivec4 textureProj(isampler3D sampler, vec4 P, float bias);
555uvec4 textureProj(usampler3D sampler, vec4 P, float bias);
556
557float textureProj(sampler1DShadow sampler, vec4 P, float bias);
558float textureProj(sampler2DShadow sampler, vec4 P, float bias);
559
560/* textureLod */
561 vec4 textureLod( sampler1D sampler, float P, float lod);
562ivec4 textureLod(isampler1D sampler, float P, float lod);
563uvec4 textureLod(usampler1D sampler, float P, float lod);
564
565 vec4 textureLod( sampler2D sampler, vec2 P, float lod);
566ivec4 textureLod(isampler2D sampler, vec2 P, float lod);
567uvec4 textureLod(usampler2D sampler, vec2 P, float lod);
568
569 vec4 textureLod( sampler3D sampler, vec3 P, float lod);
570ivec4 textureLod(isampler3D sampler, vec3 P, float lod);
571uvec4 textureLod(usampler3D sampler, vec3 P, float lod);
572
573 vec4 textureLod( samplerCube sampler, vec3 P, float lod);
574ivec4 textureLod(isamplerCube sampler, vec3 P, float lod);
575uvec4 textureLod(usamplerCube sampler, vec3 P, float lod);
576
577float textureLod(sampler1DShadow sampler, vec3 P, float lod);
578float textureLod(sampler2DShadow sampler, vec3 P, float lod);
579
580 vec4 textureLod( sampler1DArray sampler, vec2 P, float lod);
581ivec4 textureLod(isampler1DArray sampler, vec2 P, float lod);
582uvec4 textureLod(usampler1DArray sampler, vec2 P, float lod);
583
584 vec4 textureLod( sampler2DArray sampler, vec3 P, float lod);
585ivec4 textureLod(isampler2DArray sampler, vec3 P, float lod);
586uvec4 textureLod(usampler2DArray sampler, vec3 P, float lod);
587
588float textureLod(sampler1DArrayShadow sampler, vec3 P, float lod);
589
590#if 0
591/* textureOffset - no bias */
592 vec4 textureOffset( sampler1D sampler, float P, int offset);
593ivec4 textureOffset(isampler1D sampler, float P, int offset);
594uvec4 textureOffset(usampler1D sampler, float P, int offset);
595
596 vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset);
597ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset);
598uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset);
599
600 vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset);
601ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset);
602uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset);
603
604float textureOffset(sampler1DShadow sampler, vec3 P, int offset);
605float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset);
606
607 vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset);
608ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset);
609uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset);
610
611 vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset);
612ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset);
613uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset);
614
615float textureOffset(sampler1DArrayShadow sampler, vec3 P, int offset);
616
617/* textureOffset - bias variants */
618 vec4 textureOffset( sampler1D sampler, float P, int offset, float bias);
619ivec4 textureOffset(isampler1D sampler, float P, int offset, float bias);
620uvec4 textureOffset(usampler1D sampler, float P, int offset, float bias);
621
622 vec4 textureOffset( sampler2D sampler, vec2 P, ivec2 offset, float bias);
623ivec4 textureOffset(isampler2D sampler, vec2 P, ivec2 offset, float bias);
624uvec4 textureOffset(usampler2D sampler, vec2 P, ivec2 offset, float bias);
625
626 vec4 textureOffset( sampler3D sampler, vec3 P, ivec3 offset, float bias);
627ivec4 textureOffset(isampler3D sampler, vec3 P, ivec3 offset, float bias);
628uvec4 textureOffset(usampler3D sampler, vec3 P, ivec3 offset, float bias);
629
630float textureOffset(sampler1DShadow sampler, vec3 P, int offset, float bias);
631float textureOffset(sampler2DShadow sampler, vec3 P, ivec2 offset, float bias);
632
633 vec4 textureOffset( sampler1DArray sampler, vec2 P, int offset, float bias);
634ivec4 textureOffset(isampler1DArray sampler, vec2 P, int offset, float bias);
635uvec4 textureOffset(usampler1DArray sampler, vec2 P, int offset, float bias);
636
637 vec4 textureOffset( sampler2DArray sampler, vec3 P, ivec2 offset, float bias);
638ivec4 textureOffset(isampler2DArray sampler, vec3 P, ivec2 offset, float bias);
639uvec4 textureOffset(usampler2DArray sampler, vec3 P, ivec2 offset, float bias);
640
641float textureOffset(sampler1DArrayShadow samp, vec3 P, int offset, float bias);
642#endif
643
644/* texelFetch */
645 vec4 texelFetch( sampler1D sampler, int P, int lod);
646ivec4 texelFetch(isampler1D sampler, int P, int lod);
647uvec4 texelFetch(usampler1D sampler, int P, int lod);
648
649 vec4 texelFetch( sampler2D sampler, ivec2 P, int lod);
650ivec4 texelFetch(isampler2D sampler, ivec2 P, int lod);
651uvec4 texelFetch(usampler2D sampler, ivec2 P, int lod);
652
653 vec4 texelFetch( sampler3D sampler, ivec3 P, int lod);
654ivec4 texelFetch(isampler3D sampler, ivec3 P, int lod);
655uvec4 texelFetch(usampler3D sampler, ivec3 P, int lod);
656
657 vec4 texelFetch( sampler1DArray sampler, ivec2 P, int lod);
658ivec4 texelFetch(isampler1DArray sampler, ivec2 P, int lod);
659uvec4 texelFetch(usampler1DArray sampler, ivec2 P, int lod);
660
661 vec4 texelFetch( sampler2DArray sampler, ivec3 P, int lod);
662ivec4 texelFetch(isampler2DArray sampler, ivec3 P, int lod);
663uvec4 texelFetch(usampler2DArray sampler, ivec3 P, int lod);
664
665#if 0
666/* texelFetchOffset */
667 vec4 texelFetchOffset( sampler1D sampler, int P, int lod, int offset);
668ivec4 texelFetchOffset(isampler1D sampler, int P, int lod, int offset);
669uvec4 texelFetchOffset(usampler1D sampler, int P, int lod, int offset);
670
671 vec4 texelFetchOffset( sampler2D sampler, ivec2 P, int lod, ivec2 offset);
672ivec4 texelFetchOffset(isampler2D sampler, ivec2 P, int lod, ivec2 offset);
673uvec4 texelFetchOffset(usampler2D sampler, ivec2 P, int lod, ivec2 offset);
674
675 vec4 texelFetchOffset( sampler3D sampler, ivec3 P, int lod, ivec3 offset);
676ivec4 texelFetchOffset(isampler3D sampler, ivec3 P, int lod, ivec3 offset);
677uvec4 texelFetchOffset(usampler3D sampler, ivec3 P, int lod, ivec3 offset);
678
679 vec4 texelFetchOffset( sampler1DArray sampler, ivec2 P, int lod, int offset);
680ivec4 texelFetchOffset(isampler1DArray sampler, ivec2 P, int lod, int offset);
681uvec4 texelFetchOffset(usampler1DArray sampler, ivec2 P, int lod, int offset);
682
683 vec4 texelFetchOffset( sampler2DArray sampler, ivec3 P, int lod, ivec2 offset);
684ivec4 texelFetchOffset(isampler2DArray sampler, ivec3 P, int lod, ivec2 offset);
685uvec4 texelFetchOffset(usampler2DArray sampler, ivec3 P, int lod, ivec2 offset);
686
687/* textureProjOffset - no bias */
688 vec4 textureProj( sampler1D sampler, vec2 P, int offset);
689ivec4 textureProj(isampler1D sampler, vec2 P, int offset);
690uvec4 textureProj(usampler1D sampler, vec2 P, int offset);
691 vec4 textureProj( sampler1D sampler, vec4 P, int offset);
692ivec4 textureProj(isampler1D sampler, vec4 P, int offset);
693uvec4 textureProj(usampler1D sampler, vec4 P, int offset);
694
695 vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset);
696ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset);
697uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset);
698 vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset);
699ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset);
700uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset);
701
702 vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset);
703ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset);
704uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset);
705
706float textureProj(sampler1DShadow sampler, vec4 P, int offset);
707float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset);
708
709/* textureProjOffset - bias variants */
710 vec4 textureProj( sampler1D sampler, vec2 P, int offset, float bias);
711ivec4 textureProj(isampler1D sampler, vec2 P, int offset, float bias);
712uvec4 textureProj(usampler1D sampler, vec2 P, int offset, float bias);
713 vec4 textureProj( sampler1D sampler, vec4 P, int offset, float bias);
714ivec4 textureProj(isampler1D sampler, vec4 P, int offset, float bias);
715uvec4 textureProj(usampler1D sampler, vec4 P, int offset, float bias);
716
717 vec4 textureProj( sampler2D sampler, vec3 P, ivec2 offset, float bias);
718ivec4 textureProj(isampler2D sampler, vec3 P, ivec2 offset, float bias);
719uvec4 textureProj(usampler2D sampler, vec3 P, ivec2 offset, float bias);
720 vec4 textureProj( sampler2D sampler, vec4 P, ivec2 offset, float bias);
721ivec4 textureProj(isampler2D sampler, vec4 P, ivec2 offset, float bias);
722uvec4 textureProj(usampler2D sampler, vec4 P, ivec2 offset, float bias);
723
724 vec4 textureProj( sampler3D sampler, vec4 P, ivec3 offset, float bias);
725ivec4 textureProj(isampler3D sampler, vec4 P, ivec3 offset, float bias);
726uvec4 textureProj(usampler3D sampler, vec4 P, ivec3 offset, float bias);
727
728float textureProj(sampler1DShadow sampler, vec4 P, int offset, float bias);
729float textureProj(sampler2DShadow sampler, vec4 P, ivec2 offset, float bias);
730
731/* textureLodOffset */
732 vec4 textureLodOffset( sampler1D sampler, float P, float lod, int offset);
733ivec4 textureLodOffset(isampler1D sampler, float P, float lod, int offset);
734uvec4 textureLodOffset(usampler1D sampler, float P, float lod, int offset);
735
736 vec4 textureLodOffset( sampler2D sampler, vec2 P, float lod, ivec2 offset);
737ivec4 textureLodOffset(isampler2D sampler, vec2 P, float lod, ivec2 offset);
738uvec4 textureLodOffset(usampler2D sampler, vec2 P, float lod, ivec2 offset);
739
740 vec4 textureLodOffset( sampler3D sampler, vec3 P, float lod, ivec3 offset);
741ivec4 textureLodOffset(isampler3D sampler, vec3 P, float lod, ivec3 offset);
742uvec4 textureLodOffset(usampler3D sampler, vec3 P, float lod, ivec3 offset);
743
744float textureLodOffset(sampler1DShadow samp, vec3 P, float lod, int offset);
745float textureLodOffset(sampler2DShadow samp, vec3 P, float lod, ivec2 offset);
746
747 vec4 textureLodOffset( sampler1DArray sampler, vec2 P, float lod, int offset);
748ivec4 textureLodOffset(isampler1DArray sampler, vec2 P, float lod, int offset);
749uvec4 textureLodOffset(usampler1DArray sampler, vec2 P, float lod, int offset);
750
751 vec4 textureLodOffset( sampler2DArray samp, vec3 P, float lod, ivec2 offset);
752ivec4 textureLodOffset(isampler2DArray samp, vec3 P, float lod, ivec2 offset);
753uvec4 textureLodOffset(usampler2DArray samp, vec3 P, float lod, ivec2 offset);
754
755float textureLodOffset(sampler1DArrayShadow s, vec3 P, float lod, int offset);
756#endif
757
758/* textureProjLod */
759 vec4 textureProjLod( sampler1D sampler, vec2 P, float lod);
760ivec4 textureProjLod(isampler1D sampler, vec2 P, float lod);
761uvec4 textureProjLod(usampler1D sampler, vec2 P, float lod);
762 vec4 textureProjLod( sampler1D sampler, vec4 P, float lod);
763ivec4 textureProjLod(isampler1D sampler, vec4 P, float lod);
764uvec4 textureProjLod(usampler1D sampler, vec4 P, float lod);
765
766 vec4 textureProjLod( sampler2D sampler, vec3 P, float lod);
767ivec4 textureProjLod(isampler2D sampler, vec3 P, float lod);
768uvec4 textureProjLod(usampler2D sampler, vec3 P, float lod);
769 vec4 textureProjLod( sampler2D sampler, vec4 P, float lod);
770ivec4 textureProjLod(isampler2D sampler, vec4 P, float lod);
771uvec4 textureProjLod(usampler2D sampler, vec4 P, float lod);
772
773 vec4 textureProjLod( sampler3D sampler, vec4 P, float lod);
774ivec4 textureProjLod(isampler3D sampler, vec4 P, float lod);
775uvec4 textureProjLod(usampler3D sampler, vec4 P, float lod);
776
777float textureProjLod(sampler1DShadow sampler, vec4 P, float lod);
778float textureProjLod(sampler2DShadow sampler, vec4 P, float lod);
779
780#if 0
781/* textureProjLodOffset */
782 vec4 textureProjLodOffset( sampler1D sampler, vec2 P, float lod, int offset);
783ivec4 textureProjLodOffset(isampler1D sampler, vec2 P, float lod, int offset);
784uvec4 textureProjLodOffset(usampler1D sampler, vec2 P, float lod, int offset);
785 vec4 textureProjLodOffset( sampler1D sampler, vec4 P, float lod, int offset);
786ivec4 textureProjLodOffset(isampler1D sampler, vec4 P, float lod, int offset);
787uvec4 textureProjLodOffset(usampler1D sampler, vec4 P, float lod, int offset);
788
789 vec4 textureProjLodOffset( sampler2D sampler, vec3 P, float lod, ivec2 offset);
790ivec4 textureProjLodOffset(isampler2D sampler, vec3 P, float lod, ivec2 offset);
791uvec4 textureProjLodOffset(usampler2D sampler, vec3 P, float lod, ivec2 offset);
792 vec4 textureProjLodOffset( sampler2D sampler, vec4 P, float lod, ivec2 offset);
793ivec4 textureProjLodOffset(isampler2D sampler, vec4 P, float lod, ivec2 offset);
794uvec4 textureProjLodOffset(usampler2D sampler, vec4 P, float lod, ivec2 offset);
795
796 vec4 textureProjLodOffset( sampler3D sampler, vec4 P, float lod, ivec3 offset);
797ivec4 textureProjLodOffset(isampler3D sampler, vec4 P, float lod, ivec3 offset);
798uvec4 textureProjLodOffset(usampler3D sampler, vec4 P, float lod, ivec3 offset);
799
800float textureProjLodOffset(sampler1DShadow s, vec4 P, float lod, int offset);
801float textureProjLodOffset(sampler2DShadow s, vec4 P, float lod, ivec2 offset);
802#endif
803
804/* textureGrad */
805 vec4 textureGrad( sampler1D sampler, float P, float dPdx, float dPdy);
806ivec4 textureGrad(isampler1D sampler, float P, float dPdx, float dPdy);
807uvec4 textureGrad(usampler1D sampler, float P, float dPdx, float dPdy);
808
809 vec4 textureGrad( sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);
810ivec4 textureGrad(isampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);
811uvec4 textureGrad(usampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);
812
813 vec4 textureGrad( sampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);
814ivec4 textureGrad(isampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);
815uvec4 textureGrad(usampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);
816
817 vec4 textureGrad( samplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);
818ivec4 textureGrad(isamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);
819uvec4 textureGrad(usamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);
820
821float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx, float dPdy);
822float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx, vec2 dPdy);
823float textureGrad(samplerCubeShadow sampler, vec4 P, vec3 dPdx, vec3 dPdy);
824
825 vec4 textureGrad( sampler1DArray sampler, vec2 P, float dPdx, float dPdy);
826ivec4 textureGrad(isampler1DArray sampler, vec2 P, float dPdx, float dPdy);
827uvec4 textureGrad(usampler1DArray sampler, vec2 P, float dPdx, float dPdy);
828
829 vec4 textureGrad( sampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy);
830ivec4 textureGrad(isampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy);
831uvec4 textureGrad(usampler2DArray sampler, vec3 P, vec2 dPdx, vec2 dPdy);
832
833float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx, float dPdy);
834float textureGrad(sampler2DArrayShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy);
835
836#if 0
837/* textureGradOffset */
838 vec4 textureGradOffset( sampler1D s, float P, float dx, float dy, int off);
839ivec4 textureGradOffset(isampler1D s, float P, float dx, float dy, int offset);
840uvec4 textureGradOffset(usampler1D s, float P, float dx, float dy, int offset);
841
842 vec4 textureGradOffset( sampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset);
843ivec4 textureGradOffset(isampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset);
844uvec4 textureGradOffset(usampler2D s, vec2 P, vec2 dx, vec2 dy, ivec2 offset);
845
846 vec4 textureGradOffset( sampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
847ivec4 textureGradOffset(isampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
848uvec4 textureGradOffset(usampler3D s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
849
850 vec4 textureGradOffset( samplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
851ivec4 textureGradOffset(isamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
852uvec4 textureGradOffset(usamplerCube s, vec3 P, vec3 dx, vec3 dy, ivec3 offset);
853
854float textureGradOffset(sampler1DShadow s, vec3 P, float dx, float dy, int off);
855float textureGradOffset(sampler2DShadow s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
856
857 vec4 textureGradOffset( sampler1DArray s, vec2 P, float dx, float dy, int off);
858ivec4 textureGradOffset(isampler1DArray s, vec2 P, float dx, float dy, int off);
859uvec4 textureGradOffset(usampler1DArray s, vec2 P, float dx, float dy, int off);
860
861 vec4 textureGradOffset( sampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
862ivec4 textureGradOffset(isampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
863uvec4 textureGradOffset(usampler2DArray s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
864
865float textureGradOffset(sampler1DArrayShadow s, vec3 P, float dx, float dy, int o);
866float textureGradOffset(sampler2DArrayShadow s, vec4 P, vec2 dx, vec2 dy, ivec2 o);
867#endif
868
869/* textureProjGrad */
870 vec4 textureProjGrad( sampler1D sampler, vec2 P, float dPdx, float dPdy);
871ivec4 textureProjGrad(isampler1D sampler, vec2 P, float dPdx, float dPdy);
872uvec4 textureProjGrad(usampler1D sampler, vec2 P, float dPdx, float dPdy);
873 vec4 textureProjGrad( sampler1D sampler, vec4 P, float dPdx, float dPdy);
874ivec4 textureProjGrad(isampler1D sampler, vec4 P, float dPdx, float dPdy);
875uvec4 textureProjGrad(usampler1D sampler, vec4 P, float dPdx, float dPdy);
876
877 vec4 textureProjGrad( sampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy);
878ivec4 textureProjGrad(isampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy);
879uvec4 textureProjGrad(usampler2D sampler, vec3 P, vec2 dPdx, vec2 dPdy);
880 vec4 textureProjGrad( sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy);
881ivec4 textureProjGrad(isampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy);
882uvec4 textureProjGrad(usampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy);
883
884 vec4 textureProjGrad( sampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy);
885ivec4 textureProjGrad(isampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy);
886uvec4 textureProjGrad(usampler3D sampler, vec4 P, vec3 dPdx, vec3 dPdy);
887
888float textureProjGrad(sampler1DShadow sampler, vec4 P, float dPdx, float dPdy);
889float textureProjGrad(sampler2DShadow sampler, vec4 P, vec2 dPdx, vec2 dPdy);
890
891#if 0
892/* textureProjGradOffset */
893 vec4 textureProjGradOffset( sampler1D s, vec2 P, float dx, float dy, int off);
894ivec4 textureProjGradOffset(isampler1D s, vec2 P, float dx, float dy, int off);
895uvec4 textureProjGradOffset(usampler1D s, vec2 P, float dx, float dy, int off);
896 vec4 textureProjGradOffset( sampler1D s, vec4 P, float dx, float dy, int off);
897ivec4 textureProjGradOffset(isampler1D s, vec4 P, float dx, float dy, int off);
898uvec4 textureProjGradOffset(usampler1D s, vec4 P, float dx, float dy, int off);
899
900 vec4 textureProjGradOffset( sampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
901ivec4 textureProjGradOffset(isampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
902uvec4 textureProjGradOffset(usampler2D s, vec3 P, vec2 dx, vec2 dy, ivec2 off);
903 vec4 textureProjGradOffset( sampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off);
904ivec4 textureProjGradOffset(isampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off);
905uvec4 textureProjGradOffset(usampler2D s, vec4 P, vec2 dx, vec2 dy, ivec2 off);
906
907 vec4 textureProjGradOffset( sampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off);
908ivec4 textureProjGradOffset(isampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off);
909uvec4 textureProjGradOffset(usampler3D s, vec4 P, vec3 dx, vec3 dy, ivec3 off);
910
911float textureProjGradOffset(sampler1DShadow s, vec4 P, float dx, float dy, int o);
912float textureProjGradOffset(sampler2DShadow s, vec4 P, vec2 dx, vec2 dy, vec2 o);
913#endif
914
915/*
916 * The following texture functions are deprecated:
917 */
918vec4 texture1D (sampler1D sampler, float coord);
919vec4 texture1DProj (sampler1D sampler, vec2 coord);
920vec4 texture1DProj (sampler1D sampler, vec4 coord);
921vec4 texture1D (sampler1D sampler, float coord, float bias);
922vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias);
923vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias);
924vec4 texture1DLod (sampler1D sampler, float coord, float lod);
925vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);
926vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);
927
928vec4 texture2D (sampler2D sampler, vec2 coord);
929vec4 texture2DProj (sampler2D sampler, vec3 coord);
930vec4 texture2DProj (sampler2D sampler, vec4 coord);
931vec4 texture2D (sampler2D sampler, vec2 coord, float bias);
932vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias);
933vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias);
934vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod);
935vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);
936vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);
937
938vec4 texture3D (sampler3D sampler, vec3 coord);
939vec4 texture3DProj (sampler3D sampler, vec4 coord);
940vec4 texture3D (sampler3D sampler, vec3 coord, float bias);
941vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias);
942vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod);
943vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);
944
945vec4 textureCube (samplerCube sampler, vec3 coord);
946vec4 textureCube (samplerCube sampler, vec3 coord, float bias);
947vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod);
948
949vec4 shadow1D (sampler1DShadow sampler, vec3 coord);
950vec4 shadow2D (sampler2DShadow sampler, vec3 coord);
951vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord);
952vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord);
953vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias);
954vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias);
955vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias);
956vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias);
957vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod);
958vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod);
959vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);
960vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);
961
962/*
963 * 8.8 - Fragment Processing Functions (none in vertex shader)
964 */
965
966/*
967 * 8.9 - Noise Functions
968 */
969float noise1(float x);
970float noise1(vec2 x);
971float noise1(vec3 x);
972float noise1(vec4 x);
973
974vec2 noise2(float x);
975vec2 noise2(vec2 x);
976vec2 noise2(vec3 x);
977vec2 noise2(vec4 x);
978
979vec3 noise3(float x);
980vec3 noise3(vec2 x);
981vec3 noise3(vec3 x);
982vec3 noise3(vec4 x);
983
984vec4 noise4(float x);
985vec4 noise4(vec2 x);
986vec4 noise4(vec3 x);
987vec4 noise4(vec4 x);
diff --git a/src/glsl/builtins/profiles/ARB_texture_rectangle.frag b/src/glsl/builtins/profiles/ARB_texture_rectangle.frag
new file mode 100644
index 00000000000..8938aa3e97c
--- /dev/null
+++ b/src/glsl/builtins/profiles/ARB_texture_rectangle.frag
@@ -0,0 +1,7 @@
1#extension GL_ARB_texture_rectangle : enable
2vec4 texture2DRect(sampler2DRect sampler, vec2 coord);
3vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord);
4vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord);
5
6vec4 shadow2DRect(sampler2DRectShadow sampler, vec3 coord);
7vec4 shadow2DRectProj(sampler2DRectShadow sampler, vec4 coord);
diff --git a/src/glsl/builtins/profiles/ARB_texture_rectangle.vert b/src/glsl/builtins/profiles/ARB_texture_rectangle.vert
new file mode 100644
index 00000000000..8938aa3e97c
--- /dev/null
+++ b/src/glsl/builtins/profiles/ARB_texture_rectangle.vert
@@ -0,0 +1,7 @@
1#extension GL_ARB_texture_rectangle : enable
2vec4 texture2DRect(sampler2DRect sampler, vec2 coord);
3vec4 texture2DRectProj(sampler2DRect sampler, vec3 coord);
4vec4 texture2DRectProj(sampler2DRect sampler, vec4 coord);
5
6vec4 shadow2DRect(sampler2DRectShadow sampler, vec3 coord);
7vec4 shadow2DRectProj(sampler2DRectShadow sampler, vec4 coord);
diff --git a/src/glsl/builtins/profiles/EXT_texture_array.frag b/src/glsl/builtins/profiles/EXT_texture_array.frag
new file mode 100644
index 00000000000..d133132191b
--- /dev/null
+++ b/src/glsl/builtins/profiles/EXT_texture_array.frag
@@ -0,0 +1,11 @@
1#extension GL_EXT_texture_array : enable
2vec4 texture1DArray(sampler1DArray sampler, vec2 coord);
3vec4 texture1DArray(sampler1DArray sampler, vec2 coord, float bias);
4
5vec4 texture2DArray(sampler1DArray sampler, vec2 coord);
6vec4 texture2DArray(sampler1DArray sampler, vec2 coord, float bias);
7
8vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord);
9vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord, float bias);
10
11vec4 shadow2DArray(sampler2DArrayShadow sampler, vec4 coord);
diff --git a/src/glsl/builtins/profiles/EXT_texture_array.vert b/src/glsl/builtins/profiles/EXT_texture_array.vert
new file mode 100644
index 00000000000..4f7b2b5f8b1
--- /dev/null
+++ b/src/glsl/builtins/profiles/EXT_texture_array.vert
@@ -0,0 +1,11 @@
1#extension GL_EXT_texture_array : enable
2vec4 texture1DArray(sampler1DArray sampler, vec2 coord);
3vec4 texture1DArrayLod(sampler1DArray sampler, vec2 coord, float lod);
4
5vec4 texture2DArray(sampler1DArray sampler, vec2 coord);
6vec4 texture2DArrayLod(sampler1DArray sampler, vec2 coord, float lod);
7
8vec4 shadow1DArray(sampler1DArrayShadow sampler, vec3 coord);
9vec4 shadow1DArrayLod(sampler1DArrayShadow sampler, vec3 coord, float lod);
10
11vec4 shadow2DArray(sampler2DArrayShadow sampler, vec4 coord);
diff --git a/src/glsl/builtins/tools/builtin_function.cpp b/src/glsl/builtins/tools/builtin_function.cpp
new file mode 100644
index 00000000000..c44804f2ef7
--- /dev/null
+++ b/src/glsl/builtins/tools/builtin_function.cpp
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <stdio.h>
25#include "glsl_parser_extras.h"
26
27/* A dummy file. When compiling prototypes, we don't care about builtins.
28 * We really don't want to half-compile builtin_functions.cpp and fail, though.
29 */
30void
31_mesa_glsl_release_functions(void)
32{
33}
34
35void
36_mesa_glsl_initialize_functions(exec_list *instructions,
37 struct _mesa_glsl_parse_state *state)
38{
39}
diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py
new file mode 100755
index 00000000000..2eb67e398a6
--- /dev/null
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -0,0 +1,207 @@
1#!/usr/bin/python
2# -*- coding: UTF-8 -*-
3
4import re, glob, sys
5from os import path
6from subprocess import Popen, PIPE
7
8# Local module: generator for texture lookup builtins
9from texture_builtins import generate_texture_functions
10
11builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..")
12
13# Read the files in builtins/ir/*...add them to the supplied dictionary.
14def read_ir_files(fs):
15 for filename in glob.glob(path.join(path.join(builtins_dir, 'ir'), '*')):
16 with open(filename) as f:
17 fs[path.basename(filename)] = f.read()
18
19# Return a dictionary containing all builtin definitions (even generated)
20def get_builtin_definitions():
21 fs = {}
22 generate_texture_functions(fs)
23 read_ir_files(fs)
24 return fs
25
26def stringify(s):
27 t = s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n"\n "')
28 return ' "' + t + '"\n'
29
30def write_function_definitions():
31 fs = get_builtin_definitions()
32 for k, v in fs.iteritems():
33 print 'static const char *builtin_' + k + ' ='
34 print stringify(v), ';'
35
36def run_compiler(args):
37 compiler_path = path.join(path.join(builtins_dir, '..'), 'glsl_compiler')
38 command = [compiler_path, '--dump-lir'] + args
39 p = Popen(command, 1, stdout=PIPE, shell=False)
40 output = p.communicate()[0]
41 return (output, p.returncode)
42
43def write_profile(filename, profile):
44 (proto_ir, returncode) = run_compiler([filename])
45
46 if returncode != 0:
47 print '#error builtins profile', profile, 'failed to compile'
48 return
49
50 # Kill any global variable declarations. We don't want them.
51 kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE);
52 proto_ir = kill_globals.sub('', proto_ir)
53
54 print 'static const char *prototypes_for_' + profile + ' ='
55 print stringify(proto_ir), ';'
56
57 # Print a table of all the functions (not signatures) referenced.
58 # This is done so we can avoid bothering with a hash table in the C++ code.
59
60 function_names = set()
61 for func in re.finditer(r'\(function (.+)\n', proto_ir):
62 function_names.add(func.group(1))
63
64 print 'static const char *functions_for_' + profile + ' [] = {'
65 for func in function_names:
66 print ' builtin_' + func + ','
67 print '};'
68
69def write_profiles():
70 profiles = get_profile_list()
71 for (filename, profile) in profiles:
72 write_profile(filename, profile)
73
74def get_profile_list():
75 profiles = []
76 for pfile in glob.glob(path.join(path.join(builtins_dir, 'profiles'), '*')):
77 profiles.append((pfile, path.basename(pfile).replace('.', '_')))
78 return profiles
79
80if __name__ == "__main__":
81 print """/* DO NOT MODIFY - automatically generated by generate_builtins.py */
82/*
83 * Copyright © 2010 Intel Corporation
84 *
85 * Permission is hereby granted, free of charge, to any person obtaining a
86 * copy of this software and associated documentation files (the "Software"),
87 * to deal in the Software without restriction, including without limitation
88 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
89 * and/or sell copies of the Software, and to permit persons to whom the
90 * Software is furnished to do so, subject to the following conditions:
91 *
92 * The above copyright notice and this permission notice (including the next
93 * paragraph) shall be included in all copies or substantial portions of the
94 * Software.
95 *
96 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
99 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
101 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
102 * DEALINGS IN THE SOFTWARE.
103 */
104
105#include <stdio.h>
106#include "main/compiler.h"
107#include "glsl_parser_extras.h"
108#include "ir_reader.h"
109#include "program.h"
110#include "ast.h"
111
112extern "C" struct gl_shader *
113_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
114
115gl_shader *
116read_builtins(GLenum target, const char *protos, const char **functions, unsigned count)
117{
118 gl_shader *sh = _mesa_new_shader(NULL, 0, target);
119 struct _mesa_glsl_parse_state *st =
120 new(sh) _mesa_glsl_parse_state(NULL, target, sh);
121
122 st->language_version = 130;
123 st->ARB_texture_rectangle_enable = true;
124 st->EXT_texture_array_enable = true;
125 _mesa_glsl_initialize_types(st);
126
127 sh->ir = new(sh) exec_list;
128 sh->symbols = st->symbols;
129
130 /* Read the IR containing the prototypes */
131 _mesa_glsl_read_ir(st, sh->ir, protos, true);
132
133 /* Read ALL the function bodies, telling the IR reader not to scan for
134 * prototypes (we've already created them). The IR reader will skip any
135 * signature that does not already exist as a prototype.
136 */
137 for (unsigned i = 0; i < count; i++) {
138 _mesa_glsl_read_ir(st, sh->ir, functions[i], false);
139
140 if (st->error) {
141 printf("error reading builtin: %.35s ...\\n", functions[i]);
142 talloc_free(sh);
143 return NULL;
144 }
145 }
146
147 reparent_ir(sh->ir, sh);
148 delete st;
149
150 return sh;
151}
152"""
153
154 write_function_definitions()
155 write_profiles()
156
157 print """
158void *builtin_mem_ctx = NULL;
159
160void
161_mesa_glsl_release_functions(void)
162{
163 talloc_free(builtin_mem_ctx);
164}
165
166void
167_mesa_glsl_initialize_functions(exec_list *instructions,
168 struct _mesa_glsl_parse_state *state)
169{
170 if (builtin_mem_ctx == NULL)
171 builtin_mem_ctx = talloc_init("GLSL built-in functions");
172
173 state->num_builtins_to_link = 0;
174"""
175
176 profiles = get_profile_list()
177 for (filename, profile) in profiles:
178 if profile.endswith('_vert'):
179 check = 'state->target == vertex_shader && '
180 elif profile.endswith('_frag'):
181 check = 'state->target == fragment_shader && '
182
183 version = re.sub(r'_(vert|frag)$', '', profile)
184 if version.isdigit():
185 check += 'state->language_version == ' + version
186 else: # an extension name
187 check += 'state->' + version + '_enable'
188
189 print ' if (' + check + ') {'
190 print ' static gl_shader *sh = NULL;'
191 print ' if (sh == NULL) {'
192 print ' sh = read_builtins(GL_VERTEX_SHADER,'
193 print ' prototypes_for_' + profile + ','
194 print ' functions_for_' + profile + ','
195 print ' Elements(functions_for_' + profile,
196 print '));'
197 print ' talloc_steal(builtin_mem_ctx, sh);'
198 print ' }'
199 print
200 print ' import_prototypes(sh->ir, instructions, state->symbols,'
201 print ' state);'
202 print ' state->builtins_to_link[state->num_builtins_to_link] = sh;'
203 print ' state->num_builtins_to_link++;'
204 print ' }'
205 print
206 print '}'
207
diff --git a/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py b/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py
new file mode 100755
index 00000000000..391ad110d37
--- /dev/null
+++ b/src/glsl/builtins/tools/generate_matrixCompMultGLSL.py
@@ -0,0 +1,28 @@
1#!/usr/bin/python
2
3def gen_matrix(x, y = 0):
4 if y == 0:
5 y = x
6 type = "mat" + str(x)
7 if x != y:
8 type = type + "x" + str(y)
9 print type + " matrixCompMult(" + type + " x, " + type + " y)\n{"
10 print " " + type + " z;"
11
12 for i in range(x):
13 print " z[" + str(i) + "] = x[" + str(i) + "] * y[" + str(i) + "];"
14 print " return z;\n}"
15
16print "#version 120"
17# 1.10
18gen_matrix(2)
19gen_matrix(3)
20gen_matrix(4)
21
22# 1.20
23gen_matrix(2,3) # mat2x3 means 2 columns, 3 rows
24gen_matrix(3,2)
25gen_matrix(2,4)
26gen_matrix(4,2)
27gen_matrix(3,4)
28gen_matrix(4,3)
diff --git a/src/glsl/builtins/tools/generate_outerProductGLSL.py b/src/glsl/builtins/tools/generate_outerProductGLSL.py
new file mode 100755
index 00000000000..c561cc3ba14
--- /dev/null
+++ b/src/glsl/builtins/tools/generate_outerProductGLSL.py
@@ -0,0 +1,23 @@
1#!/usr/bin/python
2
3def gen(x, y):
4 type = "mat" + str(x)
5 if x != y:
6 type = type + "x" + str(y)
7 print type + " outerProduct(vec" + str(y) + " u, vec" + str(x) + " v)\n{"
8 print " " + type + " m;"
9
10 for i in range(x):
11 print " m[" + str(i) + "] = u * v[" + str(i) + "];"
12 print " return m;\n}"
13
14print "#version 120"
15gen(2,2)
16gen(2,3) # mat2x3 means 2 columns, 3 rows
17gen(2,4)
18gen(3,2)
19gen(3,3)
20gen(3,4)
21gen(4,2)
22gen(4,3)
23gen(4,4)
diff --git a/src/glsl/builtins/tools/generate_transposeGLSL.py b/src/glsl/builtins/tools/generate_transposeGLSL.py
new file mode 100755
index 00000000000..8f669ce9839
--- /dev/null
+++ b/src/glsl/builtins/tools/generate_transposeGLSL.py
@@ -0,0 +1,28 @@
1#!/usr/bin/python
2
3def gen(x, y):
4 origtype = "mat" + str(x)
5 trantype = "mat" + str(y)
6 if x != y:
7 origtype = origtype + "x" + str(y)
8 trantype = trantype + "x" + str(x)
9 print trantype + " transpose(" + origtype + " m)\n{"
10 print " " + trantype + " t;"
11
12 # The obvious implementation of transpose
13 for i in range(x):
14 for j in range(y):
15 print " t[" + str(j) + "][" + str(i) + "] =",
16 print "m[" + str(i) + "][" + str(j) + "];"
17 print " return t;\n}"
18
19print "#version 120"
20gen(2,2)
21gen(2,3) # mat2x3 means 2 columns, 3 rows
22gen(2,4)
23gen(3,2)
24gen(3,3)
25gen(3,4)
26gen(4,2)
27gen(4,3)
28gen(4,4)
diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py
new file mode 100755
index 00000000000..8bf708b5aac
--- /dev/null
+++ b/src/glsl/builtins/tools/texture_builtins.py
@@ -0,0 +1,349 @@
1#!/usr/bin/python
2
3import sys
4import StringIO
5
6def vec_type(g, size):
7 if size == 1:
8 if g == "i":
9 return "int"
10 elif g == "u":
11 return "uint"
12 return "float"
13 return g + "vec" + str(size)
14
15# Get the base dimension - i.e. sampler3D gives 3
16# Array samplers also get +1 here since the layer is really an extra coordinate
17def get_coord_dim(sampler_type):
18 if sampler_type[0].isdigit():
19 coord_dim = int(sampler_type[0])
20 elif sampler_type.startswith("Cube"):
21 coord_dim = 3
22 else:
23 assert False ("coord_dim: invalid sampler_type: " + sampler_type)
24
25 if sampler_type.find("Array") != -1:
26 coord_dim += 1
27 return coord_dim
28
29# Get the number of extra vector components (i.e. shadow comparitor)
30def get_extra_dim(sampler_type, use_proj, unused_fields):
31 extra_dim = unused_fields
32 if sampler_type.find("Shadow") != -1:
33 extra_dim += 1
34 if use_proj:
35 extra_dim += 1
36 return extra_dim
37
38def generate_sigs(g, tex_inst, sampler_type, use_proj = False, unused_fields = 0):
39 coord_dim = get_coord_dim(sampler_type)
40 extra_dim = get_extra_dim(sampler_type, use_proj, unused_fields)
41
42 # Print parameters
43 print " (signature " + g + "vec4"
44 print " (parameters"
45 print " (declare (in) " + g + "sampler" + sampler_type + " sampler)"
46 print " (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)",
47 if tex_inst == "txb":
48 print "\n (declare (in) float bias)",
49 elif tex_inst == "txl":
50 print "\n (declare (in) float lod)",
51 elif tex_inst == "txf":
52 print "\n (declare (in) int lod)",
53 elif tex_inst == "txd":
54 grad_type = vec_type("", coord_dim)
55 print "\n (declare (in) " + grad_type + " dPdx)",
56 print "\n (declare (in) " + grad_type + " dPdy)",
57
58 print ")\n ((return (" + tex_inst + " (var_ref sampler)",
59
60 # Coordinate
61 if extra_dim > 0:
62 print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))",
63 else:
64 print "(var_ref P)",
65
66 # Offset
67 print "(0 0 0)",
68
69 if tex_inst != "txf":
70 # Projective divisor
71 if use_proj:
72 print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))",
73 else:
74 print "1",
75
76 # Shadow comparitor
77 if sampler_type == "2DArrayShadow": # a special case:
78 print "(swiz w (var_ref P))", # ...array layer is z; shadow is w
79 elif sampler_type.endswith("Shadow"):
80 print "(swiz z (var_ref P))",
81 else:
82 print "()",
83
84 # Bias/explicit LOD/gradient:
85 if tex_inst == "txb":
86 print "(var_ref bias)",
87 elif tex_inst == "txl" or tex_inst == "txf":
88 print "(var_ref lod)",
89 elif tex_inst == "txd":
90 print "((var_ref dPdx) (var_ref dPdy))",
91 print "))))\n"
92
93def generate_fiu_sigs(tex_inst, sampler_type, use_proj = False, unused_fields = 0):
94 generate_sigs("", tex_inst, sampler_type, use_proj, unused_fields)
95 generate_sigs("i", tex_inst, sampler_type, use_proj, unused_fields)
96 generate_sigs("u", tex_inst, sampler_type, use_proj, unused_fields)
97
98def start_function(name):
99 sys.stdout = StringIO.StringIO()
100 print "((function " + name
101
102def end_function(fs, name):
103 print "))"
104 fs[name] = sys.stdout.getvalue();
105 sys.stdout.close()
106
107# Generate all the functions and store them in the supplied dictionary.
108# This is better than writing them to actual files since they should never be
109# edited; it'd also be easy to confuse them with the many hand-generated files.
110#
111# Takes a dictionary as an argument.
112def generate_texture_functions(fs):
113 start_function("texture")
114 generate_fiu_sigs("tex", "1D")
115 generate_fiu_sigs("tex", "2D")
116 generate_fiu_sigs("tex", "3D")
117 generate_fiu_sigs("tex", "Cube")
118 generate_fiu_sigs("tex", "1DArray")
119 generate_fiu_sigs("tex", "2DArray")
120
121 generate_fiu_sigs("txb", "1D")
122 generate_fiu_sigs("txb", "2D")
123 generate_fiu_sigs("txb", "3D")
124 generate_fiu_sigs("txb", "Cube")
125 generate_fiu_sigs("txb", "1DArray")
126 generate_fiu_sigs("txb", "2DArray")
127 end_function(fs, "texture")
128
129 start_function("textureProj")
130 generate_fiu_sigs("tex", "1D", True)
131 generate_fiu_sigs("tex", "1D", True, 2)
132 generate_fiu_sigs("tex", "2D", True)
133 generate_fiu_sigs("tex", "2D", True, 1)
134 generate_fiu_sigs("tex", "3D", True)
135
136 generate_fiu_sigs("txb", "1D", True)
137 generate_fiu_sigs("txb", "1D", True, 2)
138 generate_fiu_sigs("txb", "2D", True)
139 generate_fiu_sigs("txb", "2D", True, 1)
140 generate_fiu_sigs("txb", "3D", True)
141 end_function(fs, "textureProj")
142
143 start_function("textureLod")
144 generate_fiu_sigs("txl", "1D")
145 generate_fiu_sigs("txl", "2D")
146 generate_fiu_sigs("txl", "3D")
147 generate_fiu_sigs("txl", "Cube")
148 generate_fiu_sigs("txl", "1DArray")
149 generate_fiu_sigs("txl", "2DArray")
150 end_function(fs, "textureLod")
151
152 start_function("texelFetch")
153 generate_fiu_sigs("txf", "1D")
154 generate_fiu_sigs("txf", "2D")
155 generate_fiu_sigs("txf", "3D")
156 generate_fiu_sigs("txf", "1DArray")
157 generate_fiu_sigs("txf", "2DArray")
158 end_function(fs, "texelFetch")
159
160 start_function("textureProjLod")
161 generate_fiu_sigs("txl", "1D", True)
162 generate_fiu_sigs("txl", "1D", True, 2)
163 generate_fiu_sigs("txl", "2D", True)
164 generate_fiu_sigs("txl", "2D", True, 1)
165 generate_fiu_sigs("txl", "3D", True)
166 end_function(fs, "textureProjLod")
167
168 start_function("textureGrad")
169 generate_fiu_sigs("txd", "1D")
170 generate_fiu_sigs("txd", "2D")
171 generate_fiu_sigs("txd", "3D")
172 generate_fiu_sigs("txd", "Cube")
173 generate_fiu_sigs("txd", "1DArray")
174 generate_fiu_sigs("txd", "2DArray")
175 end_function(fs, "textureGrad")
176
177 start_function("textureProjGrad")
178 generate_fiu_sigs("txd", "1D", True)
179 generate_fiu_sigs("txd", "1D", True, 2)
180 generate_fiu_sigs("txd", "2D", True)
181 generate_fiu_sigs("txd", "2D", True, 1)
182 generate_fiu_sigs("txd", "3D", True)
183 end_function(fs, "textureProjGrad")
184
185 # ARB_texture_rectangle extension
186 start_function("texture2DRect")
187 generate_sigs("", "tex", "2DRect")
188 end_function(fs, "texture2DRect")
189
190 start_function("texture2DRectProj")
191 generate_sigs("", "tex", "2DRect", True)
192 generate_sigs("", "tex", "2DRect", True, 1)
193 end_function(fs, "texture2DRectProj")
194
195 start_function("shadow2DRect")
196 generate_sigs("", "tex", "2DRectShadow")
197 end_function(fs, "shadow2DRect")
198
199 start_function("shadow2DRectProj")
200 generate_sigs("", "tex", "2DRectShadow", True)
201 end_function(fs, "shadow2DRectProj")
202
203 # EXT_texture_array extension
204 start_function("texture1DArray")
205 generate_sigs("", "tex", "1DArray")
206 generate_sigs("", "txb", "1DArray")
207 end_function(fs, "texture1DArray")
208
209 start_function("texture1DArrayLod")
210 generate_sigs("", "txl", "1DArray")
211 end_function(fs, "texture1DArrayLod")
212
213 start_function("texture2DArray")
214 generate_sigs("", "tex", "2DArray")
215 generate_sigs("", "txb", "2DArray")
216 end_function(fs, "texture2DArray")
217
218 start_function("texture2DArrayLod")
219 generate_sigs("", "txl", "2DArray")
220 end_function(fs, "texture2DArrayLod")
221
222 start_function("shadow1DArray")
223 generate_sigs("", "tex", "1DArrayShadow")
224 generate_sigs("", "txb", "1DArrayShadow")
225 end_function(fs, "shadow1DArray")
226
227 start_function("shadow1DArrayLod")
228 generate_sigs("", "txl", "1DArrayShadow")
229 end_function(fs, "shadow1DArrayLod")
230
231 start_function("shadow2DArray")
232 generate_sigs("", "tex", "2DArrayShadow")
233 end_function(fs, "shadow2DArray")
234
235 # Deprecated (110/120 style) functions with silly names:
236 start_function("texture1D")
237 generate_sigs("", "tex", "1D")
238 generate_sigs("", "txb", "1D")
239 end_function(fs, "texture1D")
240
241 start_function("texture1DLod")
242 generate_sigs("", "txl", "1D")
243 end_function(fs, "texture1DLod")
244
245 start_function("texture1DProj")
246 generate_sigs("", "tex", "1D", True)
247 generate_sigs("", "tex", "1D", True, 2)
248 generate_sigs("", "txb", "1D", True)
249 generate_sigs("", "txb", "1D", True, 2)
250 end_function(fs, "texture1DProj")
251
252 start_function("texture1DProjLod")
253 generate_sigs("", "txl", "1D", True)
254 generate_sigs("", "txl", "1D", True, 2)
255 end_function(fs, "texture1DProjLod")
256
257 start_function("texture2D")
258 generate_sigs("", "tex", "2D")
259 generate_sigs("", "txb", "2D")
260 end_function(fs, "texture2D")
261
262 start_function("texture2DLod")
263 generate_sigs("", "txl", "2D")
264 end_function(fs, "texture2DLod")
265
266 start_function("texture2DProj")
267 generate_sigs("", "tex", "2D", True)
268 generate_sigs("", "tex", "2D", True, 1)
269 generate_sigs("", "txb", "2D", True)
270 generate_sigs("", "txb", "2D", True, 1)
271 end_function(fs, "texture2DProj")
272
273 start_function("texture2DProjLod")
274 generate_sigs("", "txl", "2D", True)
275 generate_sigs("", "txl", "2D", True, 1)
276 end_function(fs, "texture2DProjLod")
277
278 start_function("texture3D")
279 generate_sigs("", "tex", "3D")
280 generate_sigs("", "txb", "3D")
281 end_function(fs, "texture3D")
282
283 start_function("texture3DLod")
284 generate_sigs("", "txl", "3D")
285 end_function(fs, "texture3DLod")
286
287 start_function("texture3DProj")
288 generate_sigs("", "tex", "3D", True)
289 generate_sigs("", "txb", "3D", True)
290 end_function(fs, "texture3DProj")
291
292 start_function("texture3DProjLod")
293 generate_sigs("", "txl", "3D", True)
294 end_function(fs, "texture3DProjLod")
295
296 start_function("textureCube")
297 generate_sigs("", "tex", "Cube")
298 generate_sigs("", "txb", "Cube")
299 end_function(fs, "textureCube")
300
301 start_function("textureCubeLod")
302 generate_sigs("", "txl", "Cube")
303 end_function(fs, "textureCubeLod")
304
305 start_function("shadow1D")
306 generate_sigs("", "tex", "1DShadow", False, 1)
307 generate_sigs("", "txb", "1DShadow", False, 1)
308 end_function(fs, "shadow1D")
309
310 start_function("shadow1DLod")
311 generate_sigs("", "txl", "1DShadow", False, 1)
312 end_function(fs, "shadow1DLod")
313
314 start_function("shadow1DProj")
315 generate_sigs("", "tex", "1DShadow", True, 1)
316 generate_sigs("", "txb", "1DShadow", True, 1)
317 end_function(fs, "shadow1DProj")
318
319 start_function("shadow1DProjLod")
320 generate_sigs("", "txl", "1DShadow", True, 1)
321 end_function(fs, "shadow1DProjLod")
322
323 start_function("shadow2D")
324 generate_sigs("", "tex", "2DShadow")
325 generate_sigs("", "txb", "2DShadow")
326 end_function(fs, "shadow2D")
327
328 start_function("shadow2DLod")
329 generate_sigs("", "txl", "2DShadow")
330 end_function(fs, "shadow2DLod")
331
332 start_function("shadow2DProj")
333 generate_sigs("", "tex", "2DShadow", True)
334 generate_sigs("", "txb", "2DShadow", True)
335 end_function(fs, "shadow2DProj")
336
337 start_function("shadow2DProjLod")
338 generate_sigs("", "txl", "2DShadow", True)
339 end_function(fs, "shadow2DProjLod")
340
341 sys.stdout = sys.__stdout__
342 return fs
343
344# If you actually run this script, it'll print out all the functions.
345if __name__ == "__main__":
346 fs = {}
347 generate_texture_functions(fs);
348 for k, v in fs.iteritems():
349 print v
diff --git a/src/glsl/configure.ac b/src/glsl/configure.ac
new file mode 100644
index 00000000000..73ce67de3d1
--- /dev/null
+++ b/src/glsl/configure.ac
@@ -0,0 +1,69 @@
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.61)
5AC_INIT(glsl, XXXXX, idr@freedesktop.org, glsl)
6AC_CONFIG_SRCDIR([Makefile.am])
7AM_CONFIG_HEADER([config.h])
8AC_CONFIG_FILES([glcpp/Makefile])
9
10AM_INIT_AUTOMAKE
11LT_INIT
12
13AM_MAINTAINER_MODE
14
15# Checks for programs.
16AC_PROG_CXX
17AC_PROG_CC
18AC_PROG_MAKE_SET
19AC_PROG_YACC
20AC_PROG_LEX
21
22m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
23
24# Checks for libraries.
25
26# Checks for header files.
27
28# Checks for typedefs, structures, and compiler characteristics.
29
30# Checks for library functions.
31AC_HEADER_STDC
32
33AH_TOP([#ifndef GLSL_CONFIG_H
34#define GLSL_CONFIG_H])
35AH_BOTTOM([#endif /* GLSL_CONFIG_H */])
36
37PKG_CHECK_MODULES([talloc], [talloc >= 2.0])
38
39AC_ARG_ENABLE([debug],
40 [AS_HELP_STRING([--enable-debug],
41 [use debug compiler flags and macros @<:@default=disabled@:>@])],
42 [enable_debug="$enableval"],
43 [enable_debug=no]
44)
45if test "x$enable_debug" = xyes; then
46 DEFINES="$DEFINES -DDEBUG"
47 if test "x$GCC" = xyes; then
48 # Remove any -g or -O flags from the command line
49 CFLAGS=[`echo $CFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`]
50 CFLAGS="$CFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2"
51 fi
52 if test "x$GXX" = xyes; then
53 # Remove any -g flags from the command line
54 CXXFLAGS=[`echo $CXXFLAGS | sed 's/-g[^ \t]*[ \t]*//g;s/-O[^ \t]*[ \t]*//g'`]
55 CXXFLAGS="$CXXFLAGS -O0 -ggdb3 -fstack-protector -D_FORTIFY_SOURCE=2"
56 fi
57fi
58
59if test "x$GXX" = xyes ; then
60 WARN="-Wall -Wextra -Wunsafe-loop-optimizations -Wstack-protector"
61else
62 WARN=""
63fi
64
65CFLAGS="$CFLAGS $WARN"
66CXXFLAGS="$CXXFLAGS $WARN"
67YFLAGS="-d -v"
68
69AC_OUTPUT([Makefile])
diff --git a/src/glsl/glcpp/.gitignore b/src/glsl/glcpp/.gitignore
new file mode 100644
index 00000000000..dbc37e1926d
--- /dev/null
+++ b/src/glsl/glcpp/.gitignore
@@ -0,0 +1,8 @@
1glcpp
2glcpp-parse.output
3*.o
4*.lo
5*.la
6.libs
7*~
8tests/*.out
diff --git a/src/glsl/glcpp/Makefile.am b/src/glsl/glcpp/Makefile.am
new file mode 100644
index 00000000000..81147e6e12c
--- /dev/null
+++ b/src/glsl/glcpp/Makefile.am
@@ -0,0 +1,44 @@
1# Copyright © 2010 Intel Corporation
2# All Rights Reserved.
3#
4# Permission is hereby granted, free of charge, to any person obtaining a
5# copy of this software and associated documentation files (the "Software"),
6# to deal in the Software without restriction, including without limitation
7# on the rights to use, copy, modify, merge, publish, distribute, sub
8# license, and/or sell copies of the Software, and to permit persons to whom
9# the Software is furnished to do so, subject to the following conditions:
10#
11# The above copyright notice and this permission notice (including the next
12# paragraph) shall be included in all copies or substantial portions of the
13# Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18# AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21# USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23noinst_LTLIBRARIES = libglcpp.la
24libglcpp_la_SOURCES = \
25 glcpp-lex.l \
26 glcpp-parse.y \
27 glcpp.h \
28 pp.c
29
30BUILT_SOURCES = glcpp-parse.h glcpp-parse.c glcpp-lex.c
31CLEANFILES = $(BUILT_SOURCES)
32
33glcpp-parse.h: glcpp-parse.c
34
35bin_PROGRAMS = glcpp
36glcpp_LDADD = libglcpp.la
37glcpp_LDFLAGS = @LDFLAGS@ $(talloc_LIBS)
38glcpp_SOURCES = glcpp.c
39
40.l.c:
41 $(LEXCOMPILE) --outfile="$@" $<
42
43test: glcpp
44 @(cd tests; ./glcpp-test)
diff --git a/src/glsl/glcpp/README b/src/glsl/glcpp/README
new file mode 100644
index 00000000000..ab42a3ffe12
--- /dev/null
+++ b/src/glsl/glcpp/README
@@ -0,0 +1,30 @@
1glcpp -- GLSL "C" preprocessor
2
3This is a simple preprocessor designed to provide the preprocessing
4needs of the GLSL language. The requirements for this preprocessor are
5specified in the GLSL 1.30 specification availble from:
6
7http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.08.pdf
8
9This specification is not precise on some semantics, (for example,
10#define and #if), defining these merely "as is standard for C++
11preprocessors". To fill in these details, I've been using the C99
12standard (for which I had a convenient copy) as available from:
13
14http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
15
16Known limitations
17-----------------
18Macro invocations cannot include embedded newlines.
19
20The __LINE__, __FILE__, and __VERSION__ macros are not yet supported.
21
22The argument of the 'defined' operator cannot yet include enclosing
23parentheses.
24
25The #error, #pragma, #extension, #version, and #line macros are not
26yet supported.
27
28A file that ends with a function-like macro name as the last
29non-whitespace token will result in a parse error, (where it should be
30passed through as is). \ No newline at end of file
diff --git a/src/glsl/glcpp/glcpp-lex.c b/src/glsl/glcpp/glcpp-lex.c
new file mode 100644
index 00000000000..de37c11be8b
--- /dev/null
+++ b/src/glsl/glcpp/glcpp-lex.c
@@ -0,0 +1,2624 @@
1#line 2 "glcpp/glcpp-lex.c"
2
3#line 4 "glcpp/glcpp-lex.c"
4
5#define YY_INT_ALIGNED short int
6
7/* A lexical scanner generated by flex */
8
9#define FLEX_SCANNER
10#define YY_FLEX_MAJOR_VERSION 2
11#define YY_FLEX_MINOR_VERSION 5
12#define YY_FLEX_SUBMINOR_VERSION 35
13#if YY_FLEX_SUBMINOR_VERSION > 0
14#define FLEX_BETA
15#endif
16
17/* First, we deal with platform-specific or compiler-specific issues. */
18
19/* begin standard C headers. */
20#include <stdio.h>
21#include <string.h>
22#include <errno.h>
23#include <stdlib.h>
24
25/* end standard C headers. */
26
27/* flex integer type definitions */
28
29#ifndef FLEXINT_H
30#define FLEXINT_H
31
32/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
35
36/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
38 */
39#ifndef __STDC_LIMIT_MACROS
40#define __STDC_LIMIT_MACROS 1
41#endif
42
43#include <inttypes.h>
44typedef int8_t flex_int8_t;
45typedef uint8_t flex_uint8_t;
46typedef int16_t flex_int16_t;
47typedef uint16_t flex_uint16_t;
48typedef int32_t flex_int32_t;
49typedef uint32_t flex_uint32_t;
50#else
51typedef signed char flex_int8_t;
52typedef short int flex_int16_t;
53typedef int flex_int32_t;
54typedef unsigned char flex_uint8_t;
55typedef unsigned short int flex_uint16_t;
56typedef unsigned int flex_uint32_t;
57#endif /* ! C99 */
58
59/* Limits of integral types. */
60#ifndef INT8_MIN
61#define INT8_MIN (-128)
62#endif
63#ifndef INT16_MIN
64#define INT16_MIN (-32767-1)
65#endif
66#ifndef INT32_MIN
67#define INT32_MIN (-2147483647-1)
68#endif
69#ifndef INT8_MAX
70#define INT8_MAX (127)
71#endif
72#ifndef INT16_MAX
73#define INT16_MAX (32767)
74#endif
75#ifndef INT32_MAX
76#define INT32_MAX (2147483647)
77#endif
78#ifndef UINT8_MAX
79#define UINT8_MAX (255U)
80#endif
81#ifndef UINT16_MAX
82#define UINT16_MAX (65535U)
83#endif
84#ifndef UINT32_MAX
85#define UINT32_MAX (4294967295U)
86#endif
87
88#endif /* ! FLEXINT_H */
89
90#ifdef __cplusplus
91
92/* The "const" storage-class-modifier is valid. */
93#define YY_USE_CONST
94
95#else /* ! __cplusplus */
96
97/* C99 requires __STDC__ to be defined as 1. */
98#if defined (__STDC__)
99
100#define YY_USE_CONST
101
102#endif /* defined (__STDC__) */
103#endif /* ! __cplusplus */
104
105#ifdef YY_USE_CONST
106#define yyconst const
107#else
108#define yyconst
109#endif
110
111/* Returned upon end-of-file. */
112#define YY_NULL 0
113
114/* Promotes a possibly negative, possibly signed char to an unsigned
115 * integer for use as an array index. If the signed char is negative,
116 * we want to instead treat it as an 8-bit unsigned char, hence the
117 * double cast.
118 */
119#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
120
121/* An opaque pointer. */
122#ifndef YY_TYPEDEF_YY_SCANNER_T
123#define YY_TYPEDEF_YY_SCANNER_T
124typedef void* yyscan_t;
125#endif
126
127/* For convenience, these vars (plus the bison vars far below)
128 are macros in the reentrant scanner. */
129#define yyin yyg->yyin_r
130#define yyout yyg->yyout_r
131#define yyextra yyg->yyextra_r
132#define yyleng yyg->yyleng_r
133#define yytext yyg->yytext_r
134#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
135#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
136#define yy_flex_debug yyg->yy_flex_debug_r
137
138/* Enter a start condition. This macro really ought to take a parameter,
139 * but we do it the disgusting crufty way forced on us by the ()-less
140 * definition of BEGIN.
141 */
142#define BEGIN yyg->yy_start = 1 + 2 *
143
144/* Translate the current start state into a value that can be later handed
145 * to BEGIN to return to the state. The YYSTATE alias is for lex
146 * compatibility.
147 */
148#define YY_START ((yyg->yy_start - 1) / 2)
149#define YYSTATE YY_START
150
151/* Action number for EOF rule of a given start state. */
152#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
153
154/* Special action meaning "start processing a new file". */
155#define YY_NEW_FILE glcpp_restart(yyin ,yyscanner )
156
157#define YY_END_OF_BUFFER_CHAR 0
158
159/* Size of default input buffer. */
160#ifndef YY_BUF_SIZE
161#define YY_BUF_SIZE 16384
162#endif
163
164/* The state buf must be large enough to hold one state per character in the main buffer.
165 */
166#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
167
168#ifndef YY_TYPEDEF_YY_BUFFER_STATE
169#define YY_TYPEDEF_YY_BUFFER_STATE
170typedef struct yy_buffer_state *YY_BUFFER_STATE;
171#endif
172
173#define EOB_ACT_CONTINUE_SCAN 0
174#define EOB_ACT_END_OF_FILE 1
175#define EOB_ACT_LAST_MATCH 2
176
177 #define YY_LESS_LINENO(n)
178
179/* Return all but the first "n" matched characters back to the input stream. */
180#define yyless(n) \
181 do \
182 { \
183 /* Undo effects of setting up yytext. */ \
184 int yyless_macro_arg = (n); \
185 YY_LESS_LINENO(yyless_macro_arg);\
186 *yy_cp = yyg->yy_hold_char; \
187 YY_RESTORE_YY_MORE_OFFSET \
188 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
189 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
190 } \
191 while ( 0 )
192
193#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
194
195#ifndef YY_TYPEDEF_YY_SIZE_T
196#define YY_TYPEDEF_YY_SIZE_T
197typedef size_t yy_size_t;
198#endif
199
200#ifndef YY_STRUCT_YY_BUFFER_STATE
201#define YY_STRUCT_YY_BUFFER_STATE
202struct yy_buffer_state
203 {
204 FILE *yy_input_file;
205
206 char *yy_ch_buf; /* input buffer */
207 char *yy_buf_pos; /* current position in input buffer */
208
209 /* Size of input buffer in bytes, not including room for EOB
210 * characters.
211 */
212 yy_size_t yy_buf_size;
213
214 /* Number of characters read into yy_ch_buf, not including EOB
215 * characters.
216 */
217 int yy_n_chars;
218
219 /* Whether we "own" the buffer - i.e., we know we created it,
220 * and can realloc() it to grow it, and should free() it to
221 * delete it.
222 */
223 int yy_is_our_buffer;
224
225 /* Whether this is an "interactive" input source; if so, and
226 * if we're using stdio for input, then we want to use getc()
227 * instead of fread(), to make sure we stop fetching input after
228 * each newline.
229 */
230 int yy_is_interactive;
231
232 /* Whether we're considered to be at the beginning of a line.
233 * If so, '^' rules will be active on the next match, otherwise
234 * not.
235 */
236 int yy_at_bol;
237
238 int yy_bs_lineno; /**< The line count. */
239 int yy_bs_column; /**< The column count. */
240
241 /* Whether to try to fill the input buffer when we reach the
242 * end of it.
243 */
244 int yy_fill_buffer;
245
246 int yy_buffer_status;
247
248#define YY_BUFFER_NEW 0
249#define YY_BUFFER_NORMAL 1
250 /* When an EOF's been seen but there's still some text to process
251 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
252 * shouldn't try reading from the input source any more. We might
253 * still have a bunch of tokens to match, though, because of
254 * possible backing-up.
255 *
256 * When we actually see the EOF, we change the status to "new"
257 * (via glcpp_restart()), so that the user can continue scanning by
258 * just pointing yyin at a new input file.
259 */
260#define YY_BUFFER_EOF_PENDING 2
261
262 };
263#endif /* !YY_STRUCT_YY_BUFFER_STATE */
264
265/* We provide macros for accessing buffer states in case in the
266 * future we want to put the buffer states in a more general
267 * "scanner state".
268 *
269 * Returns the top of the stack, or NULL.
270 */
271#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
272 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
273 : NULL)
274
275/* Same as previous macro, but useful when we know that the buffer stack is not
276 * NULL or when we need an lvalue. For internal use only.
277 */
278#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
279
280void glcpp_restart (FILE *input_file ,yyscan_t yyscanner );
281void glcpp__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
282YY_BUFFER_STATE glcpp__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
283void glcpp__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
284void glcpp__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
285void glcpp_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
286void glcpp_pop_buffer_state (yyscan_t yyscanner );
287
288static void glcpp_ensure_buffer_stack (yyscan_t yyscanner );
289static void glcpp__load_buffer_state (yyscan_t yyscanner );
290static void glcpp__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
291
292#define YY_FLUSH_BUFFER glcpp__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
293
294YY_BUFFER_STATE glcpp__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
295YY_BUFFER_STATE glcpp__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
296YY_BUFFER_STATE glcpp__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
297
298void *glcpp_alloc (yy_size_t ,yyscan_t yyscanner );
299void *glcpp_realloc (void *,yy_size_t ,yyscan_t yyscanner );
300void glcpp_free (void * ,yyscan_t yyscanner );
301
302#define yy_new_buffer glcpp__create_buffer
303
304#define yy_set_interactive(is_interactive) \
305 { \
306 if ( ! YY_CURRENT_BUFFER ){ \
307 glcpp_ensure_buffer_stack (yyscanner); \
308 YY_CURRENT_BUFFER_LVALUE = \
309 glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
310 } \
311 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
312 }
313
314#define yy_set_bol(at_bol) \
315 { \
316 if ( ! YY_CURRENT_BUFFER ){\
317 glcpp_ensure_buffer_stack (yyscanner); \
318 YY_CURRENT_BUFFER_LVALUE = \
319 glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
320 } \
321 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
322 }
323
324#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
325
326/* Begin user sect3 */
327
328#define glcpp_wrap(n) 1
329#define YY_SKIP_YYWRAP
330
331typedef unsigned char YY_CHAR;
332
333typedef int yy_state_type;
334
335#define yytext_ptr yytext_r
336
337static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
338static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
339static int yy_get_next_buffer (yyscan_t yyscanner );
340static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
341
342/* Done after the current pattern has been matched and before the
343 * corresponding action - sets up yytext.
344 */
345#define YY_DO_BEFORE_ACTION \
346 yyg->yytext_ptr = yy_bp; \
347 yyleng = (size_t) (yy_cp - yy_bp); \
348 yyg->yy_hold_char = *yy_cp; \
349 *yy_cp = '\0'; \
350 yyg->yy_c_buf_p = yy_cp;
351
352#define YY_NUM_RULES 41
353#define YY_END_OF_BUFFER 42
354/* This struct is not used in this scanner,
355 but its presence is necessary. */
356struct yy_trans_info
357 {
358 flex_int32_t yy_verify;
359 flex_int32_t yy_nxt;
360 };
361static yyconst flex_int16_t yy_acclist[133] =
362 { 0,
363 3, 3, 42, 37, 41, 38, 41, 39, 41, 41,
364 36, 41, 41, 36, 41, 36, 41, 36, 41, 23,
365 37, 41, 22, 37, 41, 36, 41, 36, 41, 36,
366 41, 35, 37, 41, 35, 37, 41, 36, 41, 38,
367 41, 21, 41, 41, 3, 41, 4, 41, 5, 41,
368 40, 41, 37, 16, 38, 30, 33, 31, 2, 23,
369 37, 23, 37, 37, 22, 37, 22, 37, 25, 27,
370 29, 28, 26, 35, 37, 35, 37, 32, 38, 21,
371 21, 3, 4, 5, 6, 5, 7, 1, 16, 24,
372 37, 35, 37,16396, 24, 37, 35, 37, 16, 35,
373
374 37,16397,16398, 8204, 16, 8204, 35, 37, 8205, 16,
375 8206, 16,16399, 17,16394, 20, 34, 35, 37, 19,
376 8207, 16, 17, 8202, 16,16395,16402, 8203, 16, 9,
377 8, 8210
378 } ;
379
380static yyconst flex_int16_t yy_accept[152] =
381 { 0,
382 1, 1, 1, 1, 1, 2, 3, 3, 3, 4,
383 6, 8, 10, 11, 13, 14, 16, 18, 20, 23,
384 26, 28, 30, 32, 35, 38, 40, 42, 44, 45,
385 47, 49, 51, 53, 54, 54, 55, 56, 57, 58,
386 59, 60, 60, 62, 64, 65, 67, 69, 70, 71,
387 72, 73, 74, 76, 78, 79, 80, 81, 82, 82,
388 82, 82, 82, 82, 82, 83, 84, 85, 86, 87,
389 88, 88, 90, 92, 94, 94, 94, 94, 94, 94,
390 95, 95, 95, 95, 97, 99, 99, 99, 99, 99,
391 99, 99, 99, 100, 100, 100, 100, 100, 100, 102,
392
393 102, 103, 104, 104, 104, 104, 104, 106, 106, 107,
394 107, 107, 107, 107, 107, 109, 109, 109, 111, 111,
395 113, 114, 115, 115, 116, 116, 116, 117, 117, 120,
396 121, 121, 123, 124, 124, 124, 126, 127, 127, 127,
397 128, 128, 128, 130, 131, 132, 132, 132, 133, 133,
398 133
399 } ;
400
401static yyconst flex_int32_t yy_ec[256] =
402 { 0,
403 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
404 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 2, 5, 1, 6, 1, 7, 8, 1, 9,
407 7, 10, 7, 7, 7, 7, 11, 12, 13, 13,
408 13, 13, 13, 13, 13, 14, 14, 1, 7, 15,
409 16, 17, 1, 1, 18, 18, 18, 18, 18, 18,
410 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
411 19, 19, 19, 19, 20, 19, 19, 21, 19, 19,
412 7, 1, 7, 7, 19, 1, 22, 18, 18, 23,
413
414 24, 25, 26, 19, 27, 19, 19, 28, 29, 30,
415 31, 32, 19, 33, 34, 35, 36, 37, 19, 38,
416 19, 19, 7, 39, 7, 7, 1, 1, 1, 1,
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424
425 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 1, 1
431 } ;
432
433static yyconst flex_int32_t yy_meta[40] =
434 { 0,
435 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
436 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
438 1, 1, 1, 1, 1, 1, 1, 1, 1
439 } ;
440
441static yyconst flex_int16_t yy_base[170] =
442 { 0,
443 0, 38, 0, 0, 38, 39, 427, 426, 428, 48,
444 43, 549, 424, 44, 63, 423, 59, 65, 87, 125,
445 58, 67, 68, 164, 203, 40, 75, 241, 549, 422,
446 549, 140, 549, 140, 421, 549, 144, 420, 419, 418,
447 417, 415, 156, 179, 267, 0, 209, 414, 413, 412,
448 411, 410, 388, 124, 408, 153, 404, 403, 154, 198,
449 159, 155, 160, 192, 405, 549, 186, 549, 214, 549,
450 404, 549, 162, 159, 227, 229, 230, 234, 199, 303,
451 232, 235, 236, 262, 56, 243, 237, 247, 245, 252,
452 291, 359, 358, 292, 238, 296, 293, 254, 336, 256,
453
454 356, 355, 298, 294, 263, 354, 549, 352, 549, 299,
455 297, 322, 325, 257, 306, 328, 350, 549, 346, 549,
456 345, 344, 329, 343, 331, 332, 342, 333, 320, 335,
457 340, 549, 337, 338, 248, 549, 246, 197, 336, 366,
458 403, 184, 549, 182, 141, 434, 416, 79, 473, 549,
459 512, 514, 516, 518, 520, 522, 71, 524, 526, 528,
460 530, 532, 534, 536, 538, 540, 542, 544, 546
461 } ;
462
463static yyconst flex_int16_t yy_def[170] =
464 { 0,
465 150, 1, 151, 151, 152, 152, 153, 153, 150, 154,
466 155, 150, 155, 155, 155, 155, 155, 155, 150, 154,
467 155, 155, 155, 156, 156, 155, 155, 155, 150, 157,
468 150, 158, 150, 20, 155, 150, 155, 155, 155, 155,
469 155, 159, 19, 20, 20, 20, 20, 155, 155, 155,
470 155, 155, 25, 25, 155, 155, 28, 28, 155, 155,
471 155, 155, 155, 155, 157, 150, 158, 150, 158, 150,
472 159, 150, 45, 25, 155, 155, 155, 155, 155, 155,
473 155, 155, 155, 20, 25, 155, 155, 155, 155, 155,
474 155, 160, 161, 155, 155, 155, 155, 155, 25, 155,
475
476 162, 163, 155, 155, 155, 160, 150, 161, 150, 155,
477 155, 155, 155, 155, 25, 155, 162, 150, 163, 150,
478 164, 165, 155, 166, 155, 155, 155, 155, 25, 155,
479 164, 150, 165, 155, 166, 150, 167, 168, 155, 150,
480 155, 167, 150, 168, 155, 169, 155, 155, 169, 0,
481 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
482 150, 150, 150, 150, 150, 150, 150, 150, 150
483 } ;
484
485static yyconst flex_int16_t yy_nxt[589] =
486 { 0,
487 10, 11, 12, 13, 14, 15, 16, 17, 16, 16,
488 18, 19, 20, 20, 21, 22, 23, 24, 24, 24,
489 24, 24, 25, 24, 24, 24, 24, 24, 24, 24,
490 24, 24, 24, 24, 24, 24, 24, 24, 26, 27,
491 31, 31, 36, 28, 37, 36, 36, 32, 32, 35,
492 36, 35, 35, 35, 35, 35, 35, 35, 35, 38,
493 36, 36, 35, 35, 35, 36, 40, 36, 39, 36,
494 36, 65, 48, 49, 41, 42, 56, 36, 55, 53,
495 57, 36, 50, 51, 52, 99, 35, 34, 35, 36,
496 35, 35, 35, 35, 35, 35, 35, 35, 43, 43,
497
498 34, 35, 35, 35, 34, 34, 44, 45, 34, 34,
499 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
500 34, 34, 44, 34, 45, 35, 35, 36, 35, 35,
501 35, 35, 35, 35, 35, 35, 46, 46, 46, 35,
502 35, 35, 68, 36, 47, 37, 36, 53, 74, 69,
503 70, 34, 34, 34, 56, 36, 36, 36, 57, 34,
504 47, 36, 36, 35, 34, 35, 36, 35, 35, 35,
505 35, 35, 35, 35, 35, 34, 34, 75, 35, 35,
506 35, 84, 53, 80, 36, 85, 143, 81, 68, 82,
507 34, 34, 34, 34, 36, 150, 150, 84, 34, 36,
508
509 36, 36, 35, 34, 35, 36, 35, 35, 35, 35,
510 35, 35, 35, 35, 34, 83, 68, 35, 35, 35,
511 34, 34, 34, 69, 70, 76, 54, 77, 34, 36,
512 78, 36, 36, 91, 36, 79, 36, 36, 36, 36,
513 36, 35, 58, 36, 34, 36, 39, 36, 143, 36,
514 136, 86, 89, 96, 36, 87, 36, 97, 36, 36,
515 111, 101, 88, 59, 60, 36, 90, 61, 98, 100,
516 102, 103, 62, 34, 34, 34, 63, 64, 73, 73,
517 73, 34, 104, 128, 73, 116, 34, 114, 73, 73,
518 73, 73, 123, 36, 36, 36, 36, 34, 36, 36,
519
520 36, 36, 34, 92, 92, 93, 92, 92, 92, 92,
521 92, 92, 92, 92, 105, 110, 113, 92, 92, 92,
522 125, 112, 121, 124, 36, 94, 122, 36, 129, 53,
523 36, 36, 95, 36, 36, 36, 140, 36, 36, 36,
524 36, 92, 132, 53, 36, 136, 36, 132, 120, 127,
525 126, 130, 118, 138, 109, 137, 107, 120, 118, 115,
526 109, 107, 134, 139, 141, 145, 35, 140, 36, 35,
527 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
528 35, 35, 35, 146, 146, 146, 146, 146, 146, 146,
529 146, 146, 146, 146, 146, 146, 146, 146, 146, 146,
530
531 146, 146, 146, 146, 35, 36, 72, 66, 35, 35,
532 36, 53, 36, 36, 36, 36, 36, 72, 36, 36,
533 36, 36, 36, 36, 66, 36, 36, 150, 29, 29,
534 150, 150, 150, 147, 35, 35, 36, 35, 35, 35,
535 35, 35, 148, 35, 35, 138, 150, 150, 35, 35,
536 35, 150, 150, 150, 150, 150, 150, 150, 150, 150,
537 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
538 150, 150, 35, 35, 35, 36, 35, 35, 35, 35,
539 35, 148, 35, 35, 150, 150, 150, 35, 35, 35,
540 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
541
542 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
543 150, 35, 29, 29, 30, 30, 33, 33, 34, 34,
544 35, 35, 53, 53, 67, 67, 71, 71, 106, 106,
545 108, 108, 117, 117, 119, 119, 131, 131, 133, 133,
546 135, 135, 142, 142, 144, 144, 149, 149, 9, 150,
547 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
548 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
549 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
550 150, 150, 150, 150, 150, 150, 150, 150
551 } ;
552
553static yyconst flex_int16_t yy_chk[589] =
554 { 0,
555 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
556 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
557 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
558 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
559 5, 6, 26, 2, 11, 11, 14, 5, 6, 10,
560 10, 10, 10, 10, 10, 10, 10, 10, 10, 14,
561 21, 17, 10, 10, 10, 15, 17, 18, 15, 22,
562 23, 157, 21, 21, 18, 18, 27, 27, 26, 85,
563 27, 148, 22, 23, 23, 85, 10, 19, 19, 19,
564 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
565
566 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
567 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
568 19, 19, 19, 19, 19, 19, 20, 20, 20, 20,
569 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
570 20, 20, 32, 145, 20, 37, 37, 54, 54, 32,
571 32, 34, 34, 34, 56, 56, 59, 62, 56, 34,
572 20, 61, 63, 20, 24, 24, 24, 24, 24, 24,
573 24, 24, 24, 24, 24, 34, 43, 59, 24, 24,
574 24, 73, 74, 61, 144, 74, 142, 62, 67, 63,
575 44, 44, 44, 43, 64, 67, 67, 73, 44, 138,
576
577 60, 79, 24, 25, 25, 25, 25, 25, 25, 25,
578 25, 25, 25, 25, 44, 64, 69, 25, 25, 25,
579 47, 47, 47, 69, 69, 60, 25, 60, 47, 75,
580 60, 76, 77, 79, 81, 60, 78, 82, 83, 87,
581 95, 25, 28, 28, 47, 86, 28, 89, 137, 88,
582 135, 75, 77, 81, 90, 76, 98, 82, 100, 114,
583 95, 87, 76, 28, 28, 105, 78, 28, 83, 86,
584 88, 89, 28, 84, 84, 84, 28, 28, 45, 45,
585 45, 84, 90, 114, 45, 100, 45, 98, 45, 45,
586 45, 45, 105, 91, 94, 97, 104, 84, 96, 111,
587
588 103, 110, 45, 80, 80, 80, 80, 80, 80, 80,
589 80, 80, 80, 80, 91, 94, 97, 80, 80, 80,
590 111, 96, 103, 110, 112, 80, 104, 113, 115, 115,
591 116, 123, 80, 125, 126, 128, 130, 130, 139, 133,
592 134, 80, 131, 129, 127, 124, 122, 121, 119, 113,
593 112, 116, 117, 126, 108, 125, 106, 102, 101, 99,
594 93, 92, 123, 128, 134, 139, 140, 140, 140, 140,
595 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
596 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
597 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
598
599 140, 140, 140, 140, 140, 141, 71, 65, 58, 57,
600 55, 53, 52, 51, 50, 49, 48, 42, 147, 41,
601 40, 39, 38, 35, 30, 16, 13, 9, 8, 7,
602 0, 0, 0, 141, 146, 146, 146, 146, 146, 146,
603 146, 146, 146, 146, 146, 147, 0, 0, 146, 146,
604 146, 0, 0, 0, 0, 0, 0, 0, 0, 0,
605 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
606 0, 0, 146, 149, 149, 149, 149, 149, 149, 149,
607 149, 149, 149, 149, 0, 0, 0, 149, 149, 149,
608 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
609
610 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
611 0, 149, 151, 151, 152, 152, 153, 153, 154, 154,
612 155, 155, 156, 156, 158, 158, 159, 159, 160, 160,
613 161, 161, 162, 162, 163, 163, 164, 164, 165, 165,
614 166, 166, 167, 167, 168, 168, 169, 169, 150, 150,
615 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
616 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
617 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
618 150, 150, 150, 150, 150, 150, 150, 150
619 } ;
620
621#define YY_TRAILING_MASK 0x2000
622#define YY_TRAILING_HEAD_MASK 0x4000
623#define REJECT \
624{ \
625*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ \
626yy_cp = yyg->yy_full_match; /* restore poss. backed-over text */ \
627yyg->yy_lp = yyg->yy_full_lp; /* restore orig. accepting pos. */ \
628yyg->yy_state_ptr = yyg->yy_full_state; /* restore orig. state */ \
629yy_current_state = *yyg->yy_state_ptr; /* restore curr. state */ \
630++yyg->yy_lp; \
631goto find_rule; \
632}
633
634#define yymore() yymore_used_but_not_detected
635#define YY_MORE_ADJ 0
636#define YY_RESTORE_YY_MORE_OFFSET
637#line 1 "glcpp/glcpp-lex.l"
638#line 2 "glcpp/glcpp-lex.l"
639/*
640 * Copyright © 2010 Intel Corporation
641 *
642 * Permission is hereby granted, free of charge, to any person obtaining a
643 * copy of this software and associated documentation files (the "Software"),
644 * to deal in the Software without restriction, including without limitation
645 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
646 * and/or sell copies of the Software, and to permit persons to whom the
647 * Software is furnished to do so, subject to the following conditions:
648 *
649 * The above copyright notice and this permission notice (including the next
650 * paragraph) shall be included in all copies or substantial portions of the
651 * Software.
652 *
653 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
654 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
655 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
656 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
657 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
658 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
659 * DEALINGS IN THE SOFTWARE.
660 */
661
662#include <stdio.h>
663#include <string.h>
664#include <ctype.h>
665
666#include "glcpp.h"
667#include "glcpp-parse.h"
668
669/* Flex annoyingly generates some functions without making them
670 * static. Let's declare them here. */
671int glcpp_get_column (yyscan_t yyscanner);
672void glcpp_set_column (int column_no , yyscan_t yyscanner);
673
674#define YY_NO_INPUT
675
676#define YY_USER_ACTION \
677 do { \
678 yylloc->source = 0; \
679 yylloc->first_column = yycolumn + 1; \
680 yylloc->first_line = yylineno; \
681 yycolumn += yyleng; \
682 } while(0);
683#define YY_USER_INIT yylineno = 1; yycolumn = 1;
684
685#line 686 "glcpp/glcpp-lex.c"
686
687#define INITIAL 0
688#define DONE 1
689#define COMMENT 2
690#define UNREACHABLE 3
691
692#define YY_EXTRA_TYPE glcpp_parser_t *
693
694/* Holds the entire state of the reentrant scanner. */
695struct yyguts_t
696 {
697
698 /* User-defined. Not touched by flex. */
699 YY_EXTRA_TYPE yyextra_r;
700
701 /* The rest are the same as the globals declared in the non-reentrant scanner. */
702 FILE *yyin_r, *yyout_r;
703 size_t yy_buffer_stack_top; /**< index of top of stack. */
704 size_t yy_buffer_stack_max; /**< capacity of stack. */
705 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
706 char yy_hold_char;
707 int yy_n_chars;
708 int yyleng_r;
709 char *yy_c_buf_p;
710 int yy_init;
711 int yy_start;
712 int yy_did_buffer_switch_on_eof;
713 int yy_start_stack_ptr;
714 int yy_start_stack_depth;
715 int *yy_start_stack;
716 yy_state_type yy_last_accepting_state;
717 char* yy_last_accepting_cpos;
718
719 int yylineno_r;
720 int yy_flex_debug_r;
721
722 yy_state_type *yy_state_buf;
723 yy_state_type *yy_state_ptr;
724 char *yy_full_match;
725 int yy_lp;
726
727 /* These are only needed for trailing context rules,
728 * but there's no conditional variable for that yet. */
729 int yy_looking_for_trail_begin;
730 int yy_full_lp;
731 int *yy_full_state;
732
733 char *yytext_r;
734 int yy_more_flag;
735 int yy_more_len;
736
737 YYSTYPE * yylval_r;
738
739 YYLTYPE * yylloc_r;
740
741 }; /* end struct yyguts_t */
742
743static int yy_init_globals (yyscan_t yyscanner );
744
745 /* This must go here because YYSTYPE and YYLTYPE are included
746 * from bison output in section 1.*/
747 # define yylval yyg->yylval_r
748
749 # define yylloc yyg->yylloc_r
750
751int glcpp_lex_init (yyscan_t* scanner);
752
753int glcpp_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
754
755/* Accessor methods to globals.
756 These are made visible to non-reentrant scanners for convenience. */
757
758int glcpp_lex_destroy (yyscan_t yyscanner );
759
760int glcpp_get_debug (yyscan_t yyscanner );
761
762void glcpp_set_debug (int debug_flag ,yyscan_t yyscanner );
763
764YY_EXTRA_TYPE glcpp_get_extra (yyscan_t yyscanner );
765
766void glcpp_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
767
768FILE *glcpp_get_in (yyscan_t yyscanner );
769
770void glcpp_set_in (FILE * in_str ,yyscan_t yyscanner );
771
772FILE *glcpp_get_out (yyscan_t yyscanner );
773
774void glcpp_set_out (FILE * out_str ,yyscan_t yyscanner );
775
776int glcpp_get_leng (yyscan_t yyscanner );
777
778char *glcpp_get_text (yyscan_t yyscanner );
779
780int glcpp_get_lineno (yyscan_t yyscanner );
781
782void glcpp_set_lineno (int line_number ,yyscan_t yyscanner );
783
784YYSTYPE * glcpp_get_lval (yyscan_t yyscanner );
785
786void glcpp_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
787
788 YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner );
789
790 void glcpp_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
791
792/* Macros after this point can all be overridden by user definitions in
793 * section 1.
794 */
795
796#ifndef YY_SKIP_YYWRAP
797#ifdef __cplusplus
798extern "C" int glcpp_wrap (yyscan_t yyscanner );
799#else
800extern int glcpp_wrap (yyscan_t yyscanner );
801#endif
802#endif
803
804 static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
805
806#ifndef yytext_ptr
807static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
808#endif
809
810#ifdef YY_NEED_STRLEN
811static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
812#endif
813
814#ifndef YY_NO_INPUT
815
816#ifdef __cplusplus
817static int yyinput (yyscan_t yyscanner );
818#else
819static int input (yyscan_t yyscanner );
820#endif
821
822#endif
823
824 static void yy_push_state (int new_state ,yyscan_t yyscanner);
825
826 static void yy_pop_state (yyscan_t yyscanner );
827
828 static int yy_top_state (yyscan_t yyscanner );
829
830/* Amount of stuff to slurp up with each read. */
831#ifndef YY_READ_BUF_SIZE
832#define YY_READ_BUF_SIZE 8192
833#endif
834
835/* Copy whatever the last rule matched to the standard output. */
836#ifndef ECHO
837/* This used to be an fputs(), but since the string might contain NUL's,
838 * we now use fwrite().
839 */
840#define ECHO fwrite( yytext, yyleng, 1, yyout )
841#endif
842
843/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
844 * is returned in "result".
845 */
846#ifndef YY_INPUT
847#define YY_INPUT(buf,result,max_size) \
848 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
849 { \
850 int c = '*'; \
851 int n; \
852 for ( n = 0; n < max_size && \
853 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
854 buf[n] = (char) c; \
855 if ( c == '\n' ) \
856 buf[n++] = (char) c; \
857 if ( c == EOF && ferror( yyin ) ) \
858 YY_FATAL_ERROR( "input in flex scanner failed" ); \
859 result = n; \
860 } \
861 else \
862 { \
863 errno=0; \
864 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
865 { \
866 if( errno != EINTR) \
867 { \
868 YY_FATAL_ERROR( "input in flex scanner failed" ); \
869 break; \
870 } \
871 errno=0; \
872 clearerr(yyin); \
873 } \
874 }\
875\
876
877#endif
878
879/* No semi-colon after return; correct usage is to write "yyterminate();" -
880 * we don't want an extra ';' after the "return" because that will cause
881 * some compilers to complain about unreachable statements.
882 */
883#ifndef yyterminate
884#define yyterminate() return YY_NULL
885#endif
886
887/* Number of entries by which start-condition stack grows. */
888#ifndef YY_START_STACK_INCR
889#define YY_START_STACK_INCR 25
890#endif
891
892/* Report a fatal error. */
893#ifndef YY_FATAL_ERROR
894#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
895#endif
896
897/* end tables serialization structures and prototypes */
898
899/* Default declaration of generated scanner - a define so the user can
900 * easily add parameters.
901 */
902#ifndef YY_DECL
903#define YY_DECL_IS_OURS 1
904
905extern int glcpp_lex \
906 (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
907
908#define YY_DECL int glcpp_lex \
909 (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
910#endif /* !YY_DECL */
911
912/* Code executed at the beginning of each rule, after yytext and yyleng
913 * have been set up.
914 */
915#ifndef YY_USER_ACTION
916#define YY_USER_ACTION
917#endif
918
919/* Code executed at the end of each rule. */
920#ifndef YY_BREAK
921#define YY_BREAK break;
922#endif
923
924#define YY_RULE_SETUP \
925 if ( yyleng > 0 ) \
926 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
927 (yytext[yyleng - 1] == '\n'); \
928 YY_USER_ACTION
929
930/** The main scanner function which does all the work.
931 */
932YY_DECL
933{
934 register yy_state_type yy_current_state;
935 register char *yy_cp, *yy_bp;
936 register int yy_act;
937 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
938
939#line 70 "glcpp/glcpp-lex.l"
940
941
942 /* Single-line comments */
943#line 944 "glcpp/glcpp-lex.c"
944
945 yylval = yylval_param;
946
947 yylloc = yylloc_param;
948
949 if ( !yyg->yy_init )
950 {
951 yyg->yy_init = 1;
952
953#ifdef YY_USER_INIT
954 YY_USER_INIT;
955#endif
956
957 /* Create the reject buffer large enough to save one state per allowed character. */
958 if ( ! yyg->yy_state_buf )
959 yyg->yy_state_buf = (yy_state_type *)glcpp_alloc(YY_STATE_BUF_SIZE ,yyscanner);
960 if ( ! yyg->yy_state_buf )
961 YY_FATAL_ERROR( "out of dynamic memory in glcpp_lex()" );
962
963 if ( ! yyg->yy_start )
964 yyg->yy_start = 1; /* first start state */
965
966 if ( ! yyin )
967 yyin = stdin;
968
969 if ( ! yyout )
970 yyout = stdout;
971
972 if ( ! YY_CURRENT_BUFFER ) {
973 glcpp_ensure_buffer_stack (yyscanner);
974 YY_CURRENT_BUFFER_LVALUE =
975 glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
976 }
977
978 glcpp__load_buffer_state(yyscanner );
979 }
980
981 while ( 1 ) /* loops until end-of-file is reached */
982 {
983 yy_cp = yyg->yy_c_buf_p;
984
985 /* Support of yytext. */
986 *yy_cp = yyg->yy_hold_char;
987
988 /* yy_bp points to the position in yy_ch_buf of the start of
989 * the current run.
990 */
991 yy_bp = yy_cp;
992
993 yy_current_state = yyg->yy_start;
994 yy_current_state += YY_AT_BOL();
995
996 yyg->yy_state_ptr = yyg->yy_state_buf;
997 *yyg->yy_state_ptr++ = yy_current_state;
998
999yy_match:
1000 do
1001 {
1002 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1003 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1004 {
1005 yy_current_state = (int) yy_def[yy_current_state];
1006 if ( yy_current_state >= 151 )
1007 yy_c = yy_meta[(unsigned int) yy_c];
1008 }
1009 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1010 *yyg->yy_state_ptr++ = yy_current_state;
1011 ++yy_cp;
1012 }
1013 while ( yy_current_state != 150 );
1014
1015yy_find_action:
1016 yy_current_state = *--yyg->yy_state_ptr;
1017 yyg->yy_lp = yy_accept[yy_current_state];
1018find_rule: /* we branch to this label when backing up */
1019 for ( ; ; ) /* until we find what rule we matched */
1020 {
1021 if ( yyg->yy_lp && yyg->yy_lp < yy_accept[yy_current_state + 1] )
1022 {
1023 yy_act = yy_acclist[yyg->yy_lp];
1024 if ( yy_act & YY_TRAILING_HEAD_MASK ||
1025 yyg->yy_looking_for_trail_begin )
1026 {
1027 if ( yy_act == yyg->yy_looking_for_trail_begin )
1028 {
1029 yyg->yy_looking_for_trail_begin = 0;
1030 yy_act &= ~YY_TRAILING_HEAD_MASK;
1031 break;
1032 }
1033 }
1034 else if ( yy_act & YY_TRAILING_MASK )
1035 {
1036 yyg->yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK;
1037 yyg->yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK;
1038 yyg->yy_full_match = yy_cp;
1039 yyg->yy_full_state = yyg->yy_state_ptr;
1040 yyg->yy_full_lp = yyg->yy_lp;
1041 }
1042 else
1043 {
1044 yyg->yy_full_match = yy_cp;
1045 yyg->yy_full_state = yyg->yy_state_ptr;
1046 yyg->yy_full_lp = yyg->yy_lp;
1047 break;
1048 }
1049 ++yyg->yy_lp;
1050 goto find_rule;
1051 }
1052 --yy_cp;
1053 yy_current_state = *--yyg->yy_state_ptr;
1054 yyg->yy_lp = yy_accept[yy_current_state];
1055 }
1056
1057 YY_DO_BEFORE_ACTION;
1058
1059do_action: /* This label is used only to access EOF actions. */
1060
1061 switch ( yy_act )
1062 { /* beginning of action switch */
1063case 1:
1064/* rule 1 can match eol */
1065YY_RULE_SETUP
1066#line 73 "glcpp/glcpp-lex.l"
1067{
1068 yylineno++;
1069 yycolumn = 0;
1070 return NEWLINE;
1071}
1072 YY_BREAK
1073/* Multi-line comments */
1074case 2:
1075YY_RULE_SETUP
1076#line 80 "glcpp/glcpp-lex.l"
1077{ yy_push_state(COMMENT, yyscanner); }
1078 YY_BREAK
1079case 3:
1080YY_RULE_SETUP
1081#line 81 "glcpp/glcpp-lex.l"
1082
1083 YY_BREAK
1084case 4:
1085/* rule 4 can match eol */
1086YY_RULE_SETUP
1087#line 82 "glcpp/glcpp-lex.l"
1088{ yylineno++; yycolumn = 0; }
1089 YY_BREAK
1090case 5:
1091YY_RULE_SETUP
1092#line 83 "glcpp/glcpp-lex.l"
1093
1094 YY_BREAK
1095case 6:
1096/* rule 6 can match eol */
1097YY_RULE_SETUP
1098#line 84 "glcpp/glcpp-lex.l"
1099{ yylineno++; yycolumn = 0; }
1100 YY_BREAK
1101case 7:
1102YY_RULE_SETUP
1103#line 85 "glcpp/glcpp-lex.l"
1104{
1105 yy_pop_state(yyscanner);
1106 if (yyextra->space_tokens)
1107 return SPACE;
1108}
1109 YY_BREAK
1110case 8:
1111YY_RULE_SETUP
1112#line 91 "glcpp/glcpp-lex.l"
1113{
1114 yylval->str = talloc_strdup (yyextra, yytext);
1115 yyextra->space_tokens = 0;
1116 return HASH_VERSION;
1117}
1118 YY_BREAK
1119/* glcpp doesn't handle #extension, #version, or #pragma directives.
1120 * Simply pass them through to the main compiler's lexer/parser. */
1121case 9:
1122YY_RULE_SETUP
1123#line 99 "glcpp/glcpp-lex.l"
1124{
1125 yylval->str = talloc_strdup (yyextra, yytext);
1126 yylineno++;
1127 yycolumn = 0;
1128 return OTHER;
1129}
1130 YY_BREAK
1131case 10:
1132/* rule 10 can match eol */
1133YY_RULE_SETUP
1134#line 106 "glcpp/glcpp-lex.l"
1135{
1136 yyextra->lexing_if = 1;
1137 yyextra->space_tokens = 0;
1138 return HASH_IFDEF;
1139}
1140 YY_BREAK
1141case 11:
1142/* rule 11 can match eol */
1143YY_RULE_SETUP
1144#line 112 "glcpp/glcpp-lex.l"
1145{
1146 yyextra->lexing_if = 1;
1147 yyextra->space_tokens = 0;
1148 return HASH_IFNDEF;
1149}
1150 YY_BREAK
1151case 12:
1152/* rule 12 can match eol */
1153YY_RULE_SETUP
1154#line 118 "glcpp/glcpp-lex.l"
1155{
1156 yyextra->lexing_if = 1;
1157 yyextra->space_tokens = 0;
1158 return HASH_IF;
1159}
1160 YY_BREAK
1161case 13:
1162/* rule 13 can match eol */
1163YY_RULE_SETUP
1164#line 124 "glcpp/glcpp-lex.l"
1165{
1166 yyextra->lexing_if = 1;
1167 yyextra->space_tokens = 0;
1168 return HASH_ELIF;
1169}
1170 YY_BREAK
1171case 14:
1172/* rule 14 can match eol */
1173YY_RULE_SETUP
1174#line 130 "glcpp/glcpp-lex.l"
1175{
1176 yyextra->space_tokens = 0;
1177 return HASH_ELSE;
1178}
1179 YY_BREAK
1180case 15:
1181/* rule 15 can match eol */
1182YY_RULE_SETUP
1183#line 135 "glcpp/glcpp-lex.l"
1184{
1185 yyextra->space_tokens = 0;
1186 return HASH_ENDIF;
1187}
1188 YY_BREAK
1189/* When skipping (due to an #if 0 or similar) consume anything
1190 * up to a newline. We do this with less priority than any
1191 * #if-related directive (#if, #elif, #else, #endif), but with
1192 * more priority than any other directive or token to avoid
1193 * any side-effects from skipped content.
1194 *
1195 * We use the lexing_if flag to avoid skipping any part of an
1196 * if conditional expression. */
1197case 16:
1198/* rule 16 can match eol */
1199*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
1200yyg->yy_c_buf_p = yy_cp -= 1;
1201YY_DO_BEFORE_ACTION; /* set up yytext again */
1202YY_RULE_SETUP
1203#line 148 "glcpp/glcpp-lex.l"
1204{
1205 /* Since this rule always matches, YY_USER_ACTION gets called for it,
1206 * wrongly incrementing yycolumn. We undo that effect here. */
1207 yycolumn -= yyleng;
1208 if (yyextra->lexing_if ||
1209 yyextra->skip_stack == NULL ||
1210 yyextra->skip_stack->type == SKIP_NO_SKIP)
1211 {
1212 REJECT;
1213 }
1214}
1215 YY_BREAK
1216case 17:
1217YY_RULE_SETUP
1218#line 160 "glcpp/glcpp-lex.l"
1219{
1220 char *p;
1221 for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */
1222 p += 5; /* skip "error" */
1223 glcpp_error(yylloc, yyextra, "#error%s", p);
1224}
1225 YY_BREAK
1226case 18:
1227YY_RULE_SETUP
1228#line 167 "glcpp/glcpp-lex.l"
1229{
1230 yyextra->space_tokens = 0;
1231 return HASH_DEFINE_FUNC;
1232}
1233 YY_BREAK
1234case 19:
1235YY_RULE_SETUP
1236#line 172 "glcpp/glcpp-lex.l"
1237{
1238 yyextra->space_tokens = 0;
1239 return HASH_DEFINE_OBJ;
1240}
1241 YY_BREAK
1242case 20:
1243YY_RULE_SETUP
1244#line 177 "glcpp/glcpp-lex.l"
1245{
1246 yyextra->space_tokens = 0;
1247 return HASH_UNDEF;
1248}
1249 YY_BREAK
1250case 21:
1251YY_RULE_SETUP
1252#line 182 "glcpp/glcpp-lex.l"
1253{
1254 yyextra->space_tokens = 0;
1255 return HASH;
1256}
1257 YY_BREAK
1258case 22:
1259YY_RULE_SETUP
1260#line 187 "glcpp/glcpp-lex.l"
1261{
1262 yylval->str = talloc_strdup (yyextra, yytext);
1263 return INTEGER_STRING;
1264}
1265 YY_BREAK
1266case 23:
1267YY_RULE_SETUP
1268#line 192 "glcpp/glcpp-lex.l"
1269{
1270 yylval->str = talloc_strdup (yyextra, yytext);
1271 return INTEGER_STRING;
1272}
1273 YY_BREAK
1274case 24:
1275YY_RULE_SETUP
1276#line 197 "glcpp/glcpp-lex.l"
1277{
1278 yylval->str = talloc_strdup (yyextra, yytext);
1279 return INTEGER_STRING;
1280}
1281 YY_BREAK
1282case 25:
1283YY_RULE_SETUP
1284#line 202 "glcpp/glcpp-lex.l"
1285{
1286 return LEFT_SHIFT;
1287}
1288 YY_BREAK
1289case 26:
1290YY_RULE_SETUP
1291#line 206 "glcpp/glcpp-lex.l"
1292{
1293 return RIGHT_SHIFT;
1294}
1295 YY_BREAK
1296case 27:
1297YY_RULE_SETUP
1298#line 210 "glcpp/glcpp-lex.l"
1299{
1300 return LESS_OR_EQUAL;
1301}
1302 YY_BREAK
1303case 28:
1304YY_RULE_SETUP
1305#line 214 "glcpp/glcpp-lex.l"
1306{
1307 return GREATER_OR_EQUAL;
1308}
1309 YY_BREAK
1310case 29:
1311YY_RULE_SETUP
1312#line 218 "glcpp/glcpp-lex.l"
1313{
1314 return EQUAL;
1315}
1316 YY_BREAK
1317case 30:
1318YY_RULE_SETUP
1319#line 222 "glcpp/glcpp-lex.l"
1320{
1321 return NOT_EQUAL;
1322}
1323 YY_BREAK
1324case 31:
1325YY_RULE_SETUP
1326#line 226 "glcpp/glcpp-lex.l"
1327{
1328 return AND;
1329}
1330 YY_BREAK
1331case 32:
1332YY_RULE_SETUP
1333#line 230 "glcpp/glcpp-lex.l"
1334{
1335 return OR;
1336}
1337 YY_BREAK
1338case 33:
1339YY_RULE_SETUP
1340#line 234 "glcpp/glcpp-lex.l"
1341{
1342 return PASTE;
1343}
1344 YY_BREAK
1345case 34:
1346YY_RULE_SETUP
1347#line 238 "glcpp/glcpp-lex.l"
1348{
1349 return DEFINED;
1350}
1351 YY_BREAK
1352case 35:
1353YY_RULE_SETUP
1354#line 242 "glcpp/glcpp-lex.l"
1355{
1356 yylval->str = talloc_strdup (yyextra, yytext);
1357 return IDENTIFIER;
1358}
1359 YY_BREAK
1360case 36:
1361YY_RULE_SETUP
1362#line 247 "glcpp/glcpp-lex.l"
1363{
1364 return yytext[0];
1365}
1366 YY_BREAK
1367case 37:
1368YY_RULE_SETUP
1369#line 251 "glcpp/glcpp-lex.l"
1370{
1371 yylval->str = talloc_strdup (yyextra, yytext);
1372 return OTHER;
1373}
1374 YY_BREAK
1375case 38:
1376YY_RULE_SETUP
1377#line 256 "glcpp/glcpp-lex.l"
1378{
1379 if (yyextra->space_tokens) {
1380 return SPACE;
1381 }
1382}
1383 YY_BREAK
1384case 39:
1385/* rule 39 can match eol */
1386YY_RULE_SETUP
1387#line 262 "glcpp/glcpp-lex.l"
1388{
1389 yyextra->lexing_if = 0;
1390 yylineno++;
1391 yycolumn = 0;
1392 return NEWLINE;
1393}
1394 YY_BREAK
1395/* Handle missing newline at EOF. */
1396case YY_STATE_EOF(INITIAL):
1397#line 270 "glcpp/glcpp-lex.l"
1398{
1399 BEGIN DONE; /* Don't keep matching this rule forever. */
1400 yyextra->lexing_if = 0;
1401 return NEWLINE;
1402}
1403 YY_BREAK
1404/* We don't actually use the UNREACHABLE start condition. We
1405 only have this action here so that we can pretend to call some
1406 generated functions, (to avoid "defined but not used"
1407 warnings. */
1408case 40:
1409YY_RULE_SETUP
1410#line 280 "glcpp/glcpp-lex.l"
1411{
1412 unput('.');
1413 yy_top_state(yyextra);
1414}
1415 YY_BREAK
1416case 41:
1417YY_RULE_SETUP
1418#line 285 "glcpp/glcpp-lex.l"
1419ECHO;
1420 YY_BREAK
1421#line 1422 "glcpp/glcpp-lex.c"
1422 case YY_STATE_EOF(DONE):
1423 case YY_STATE_EOF(COMMENT):
1424 case YY_STATE_EOF(UNREACHABLE):
1425 yyterminate();
1426
1427 case YY_END_OF_BUFFER:
1428 {
1429 /* Amount of text matched not including the EOB char. */
1430 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1431
1432 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1433 *yy_cp = yyg->yy_hold_char;
1434 YY_RESTORE_YY_MORE_OFFSET
1435
1436 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1437 {
1438 /* We're scanning a new file or input source. It's
1439 * possible that this happened because the user
1440 * just pointed yyin at a new source and called
1441 * glcpp_lex(). If so, then we have to assure
1442 * consistency between YY_CURRENT_BUFFER and our
1443 * globals. Here is the right place to do so, because
1444 * this is the first action (other than possibly a
1445 * back-up) that will match for the new input source.
1446 */
1447 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1448 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1449 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1450 }
1451
1452 /* Note that here we test for yy_c_buf_p "<=" to the position
1453 * of the first EOB in the buffer, since yy_c_buf_p will
1454 * already have been incremented past the NUL character
1455 * (since all states make transitions on EOB to the
1456 * end-of-buffer state). Contrast this with the test
1457 * in input().
1458 */
1459 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1460 { /* This was really a NUL. */
1461 yy_state_type yy_next_state;
1462
1463 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1464
1465 yy_current_state = yy_get_previous_state( yyscanner );
1466
1467 /* Okay, we're now positioned to make the NUL
1468 * transition. We couldn't have
1469 * yy_get_previous_state() go ahead and do it
1470 * for us because it doesn't know how to deal
1471 * with the possibility of jamming (and we don't
1472 * want to build jamming into it because then it
1473 * will run more slowly).
1474 */
1475
1476 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1477
1478 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1479
1480 if ( yy_next_state )
1481 {
1482 /* Consume the NUL. */
1483 yy_cp = ++yyg->yy_c_buf_p;
1484 yy_current_state = yy_next_state;
1485 goto yy_match;
1486 }
1487
1488 else
1489 {
1490 yy_cp = yyg->yy_c_buf_p;
1491 goto yy_find_action;
1492 }
1493 }
1494
1495 else switch ( yy_get_next_buffer( yyscanner ) )
1496 {
1497 case EOB_ACT_END_OF_FILE:
1498 {
1499 yyg->yy_did_buffer_switch_on_eof = 0;
1500
1501 if ( glcpp_wrap(yyscanner ) )
1502 {
1503 /* Note: because we've taken care in
1504 * yy_get_next_buffer() to have set up
1505 * yytext, we can now set up
1506 * yy_c_buf_p so that if some total
1507 * hoser (like flex itself) wants to
1508 * call the scanner after we return the
1509 * YY_NULL, it'll still work - another
1510 * YY_NULL will get returned.
1511 */
1512 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1513
1514 yy_act = YY_STATE_EOF(YY_START);
1515 goto do_action;
1516 }
1517
1518 else
1519 {
1520 if ( ! yyg->yy_did_buffer_switch_on_eof )
1521 YY_NEW_FILE;
1522 }
1523 break;
1524 }
1525
1526 case EOB_ACT_CONTINUE_SCAN:
1527 yyg->yy_c_buf_p =
1528 yyg->yytext_ptr + yy_amount_of_matched_text;
1529
1530 yy_current_state = yy_get_previous_state( yyscanner );
1531
1532 yy_cp = yyg->yy_c_buf_p;
1533 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1534 goto yy_match;
1535
1536 case EOB_ACT_LAST_MATCH:
1537 yyg->yy_c_buf_p =
1538 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1539
1540 yy_current_state = yy_get_previous_state( yyscanner );
1541
1542 yy_cp = yyg->yy_c_buf_p;
1543 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1544 goto yy_find_action;
1545 }
1546 break;
1547 }
1548
1549 default:
1550 YY_FATAL_ERROR(
1551 "fatal flex scanner internal error--no action found" );
1552 } /* end of action switch */
1553 } /* end of scanning one token */
1554} /* end of glcpp_lex */
1555
1556/* yy_get_next_buffer - try to read in a new buffer
1557 *
1558 * Returns a code representing an action:
1559 * EOB_ACT_LAST_MATCH -
1560 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1561 * EOB_ACT_END_OF_FILE - end of file
1562 */
1563static int yy_get_next_buffer (yyscan_t yyscanner)
1564{
1565 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1566 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1567 register char *source = yyg->yytext_ptr;
1568 register int number_to_move, i;
1569 int ret_val;
1570
1571 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1572 YY_FATAL_ERROR(
1573 "fatal flex scanner internal error--end of buffer missed" );
1574
1575 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1576 { /* Don't try to fill the buffer, so this is an EOF. */
1577 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1578 {
1579 /* We matched a single character, the EOB, so
1580 * treat this as a final EOF.
1581 */
1582 return EOB_ACT_END_OF_FILE;
1583 }
1584
1585 else
1586 {
1587 /* We matched some text prior to the EOB, first
1588 * process it.
1589 */
1590 return EOB_ACT_LAST_MATCH;
1591 }
1592 }
1593
1594 /* Try to read more data. */
1595
1596 /* First move last chars to start of buffer. */
1597 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1598
1599 for ( i = 0; i < number_to_move; ++i )
1600 *(dest++) = *(source++);
1601
1602 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1603 /* don't do the read, it's not guaranteed to return an EOF,
1604 * just force an EOF
1605 */
1606 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1607
1608 else
1609 {
1610 int num_to_read =
1611 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1612
1613 while ( num_to_read <= 0 )
1614 { /* Not enough room in the buffer - grow it. */
1615
1616 YY_FATAL_ERROR(
1617"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1618
1619 }
1620
1621 if ( num_to_read > YY_READ_BUF_SIZE )
1622 num_to_read = YY_READ_BUF_SIZE;
1623
1624 /* Read in more data. */
1625 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1626 yyg->yy_n_chars, (size_t) num_to_read );
1627
1628 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1629 }
1630
1631 if ( yyg->yy_n_chars == 0 )
1632 {
1633 if ( number_to_move == YY_MORE_ADJ )
1634 {
1635 ret_val = EOB_ACT_END_OF_FILE;
1636 glcpp_restart(yyin ,yyscanner);
1637 }
1638
1639 else
1640 {
1641 ret_val = EOB_ACT_LAST_MATCH;
1642 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1643 YY_BUFFER_EOF_PENDING;
1644 }
1645 }
1646
1647 else
1648 ret_val = EOB_ACT_CONTINUE_SCAN;
1649
1650 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1651 /* Extend the array by 50%, plus the number we really need. */
1652 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1653 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) glcpp_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1654 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1655 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1656 }
1657
1658 yyg->yy_n_chars += number_to_move;
1659 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1660 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1661
1662 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1663
1664 return ret_val;
1665}
1666
1667/* yy_get_previous_state - get the state just before the EOB char was reached */
1668
1669 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1670{
1671 register yy_state_type yy_current_state;
1672 register char *yy_cp;
1673 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1674
1675 yy_current_state = yyg->yy_start;
1676 yy_current_state += YY_AT_BOL();
1677
1678 yyg->yy_state_ptr = yyg->yy_state_buf;
1679 *yyg->yy_state_ptr++ = yy_current_state;
1680
1681 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1682 {
1683 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1684 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1685 {
1686 yy_current_state = (int) yy_def[yy_current_state];
1687 if ( yy_current_state >= 151 )
1688 yy_c = yy_meta[(unsigned int) yy_c];
1689 }
1690 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1691 *yyg->yy_state_ptr++ = yy_current_state;
1692 }
1693
1694 return yy_current_state;
1695}
1696
1697/* yy_try_NUL_trans - try to make a transition on the NUL character
1698 *
1699 * synopsis
1700 * next_state = yy_try_NUL_trans( current_state );
1701 */
1702 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1703{
1704 register int yy_is_jam;
1705 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1706
1707 register YY_CHAR yy_c = 1;
1708 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1709 {
1710 yy_current_state = (int) yy_def[yy_current_state];
1711 if ( yy_current_state >= 151 )
1712 yy_c = yy_meta[(unsigned int) yy_c];
1713 }
1714 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1715 yy_is_jam = (yy_current_state == 150);
1716 if ( ! yy_is_jam )
1717 *yyg->yy_state_ptr++ = yy_current_state;
1718
1719 return yy_is_jam ? 0 : yy_current_state;
1720}
1721
1722 static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
1723{
1724 register char *yy_cp;
1725 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1726
1727 yy_cp = yyg->yy_c_buf_p;
1728
1729 /* undo effects of setting up yytext */
1730 *yy_cp = yyg->yy_hold_char;
1731
1732 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1733 { /* need to shift things up to make room */
1734 /* +2 for EOB chars. */
1735 register int number_to_move = yyg->yy_n_chars + 2;
1736 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1737 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1738 register char *source =
1739 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1740
1741 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1742 *--dest = *--source;
1743
1744 yy_cp += (int) (dest - source);
1745 yy_bp += (int) (dest - source);
1746 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1747 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1748
1749 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1750 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1751 }
1752
1753 *--yy_cp = (char) c;
1754
1755 yyg->yytext_ptr = yy_bp;
1756 yyg->yy_hold_char = *yy_cp;
1757 yyg->yy_c_buf_p = yy_cp;
1758}
1759
1760#ifndef YY_NO_INPUT
1761#ifdef __cplusplus
1762 static int yyinput (yyscan_t yyscanner)
1763#else
1764 static int input (yyscan_t yyscanner)
1765#endif
1766
1767{
1768 int c;
1769 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1770
1771 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1772
1773 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1774 {
1775 /* yy_c_buf_p now points to the character we want to return.
1776 * If this occurs *before* the EOB characters, then it's a
1777 * valid NUL; if not, then we've hit the end of the buffer.
1778 */
1779 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1780 /* This was really a NUL. */
1781 *yyg->yy_c_buf_p = '\0';
1782
1783 else
1784 { /* need more input */
1785 int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
1786 ++yyg->yy_c_buf_p;
1787
1788 switch ( yy_get_next_buffer( yyscanner ) )
1789 {
1790 case EOB_ACT_LAST_MATCH:
1791 /* This happens because yy_g_n_b()
1792 * sees that we've accumulated a
1793 * token and flags that we need to
1794 * try matching the token before
1795 * proceeding. But for input(),
1796 * there's no matching to consider.
1797 * So convert the EOB_ACT_LAST_MATCH
1798 * to EOB_ACT_END_OF_FILE.
1799 */
1800
1801 /* Reset buffer status. */
1802 glcpp_restart(yyin ,yyscanner);
1803
1804 /*FALLTHROUGH*/
1805
1806 case EOB_ACT_END_OF_FILE:
1807 {
1808 if ( glcpp_wrap(yyscanner ) )
1809 return EOF;
1810
1811 if ( ! yyg->yy_did_buffer_switch_on_eof )
1812 YY_NEW_FILE;
1813#ifdef __cplusplus
1814 return yyinput(yyscanner);
1815#else
1816 return input(yyscanner);
1817#endif
1818 }
1819
1820 case EOB_ACT_CONTINUE_SCAN:
1821 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1822 break;
1823 }
1824 }
1825 }
1826
1827 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1828 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1829 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1830
1831 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
1832
1833 return c;
1834}
1835#endif /* ifndef YY_NO_INPUT */
1836
1837/** Immediately switch to a different input stream.
1838 * @param input_file A readable stream.
1839 * @param yyscanner The scanner object.
1840 * @note This function does not reset the start condition to @c INITIAL .
1841 */
1842 void glcpp_restart (FILE * input_file , yyscan_t yyscanner)
1843{
1844 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1845
1846 if ( ! YY_CURRENT_BUFFER ){
1847 glcpp_ensure_buffer_stack (yyscanner);
1848 YY_CURRENT_BUFFER_LVALUE =
1849 glcpp__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1850 }
1851
1852 glcpp__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1853 glcpp__load_buffer_state(yyscanner );
1854}
1855
1856/** Switch to a different input buffer.
1857 * @param new_buffer The new input buffer.
1858 * @param yyscanner The scanner object.
1859 */
1860 void glcpp__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1861{
1862 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1863
1864 /* TODO. We should be able to replace this entire function body
1865 * with
1866 * glcpp_pop_buffer_state();
1867 * glcpp_push_buffer_state(new_buffer);
1868 */
1869 glcpp_ensure_buffer_stack (yyscanner);
1870 if ( YY_CURRENT_BUFFER == new_buffer )
1871 return;
1872
1873 if ( YY_CURRENT_BUFFER )
1874 {
1875 /* Flush out information for old buffer. */
1876 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1877 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1878 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1879 }
1880
1881 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1882 glcpp__load_buffer_state(yyscanner );
1883
1884 /* We don't actually know whether we did this switch during
1885 * EOF (glcpp_wrap()) processing, but the only time this flag
1886 * is looked at is after glcpp_wrap() is called, so it's safe
1887 * to go ahead and always set it.
1888 */
1889 yyg->yy_did_buffer_switch_on_eof = 1;
1890}
1891
1892static void glcpp__load_buffer_state (yyscan_t yyscanner)
1893{
1894 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1895 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1896 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1897 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1898 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1899}
1900
1901/** Allocate and initialize an input buffer state.
1902 * @param file A readable stream.
1903 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1904 * @param yyscanner The scanner object.
1905 * @return the allocated buffer state.
1906 */
1907 YY_BUFFER_STATE glcpp__create_buffer (FILE * file, int size , yyscan_t yyscanner)
1908{
1909 YY_BUFFER_STATE b;
1910
1911 b = (YY_BUFFER_STATE) glcpp_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1912 if ( ! b )
1913 YY_FATAL_ERROR( "out of dynamic memory in glcpp__create_buffer()" );
1914
1915 b->yy_buf_size = size;
1916
1917 /* yy_ch_buf has to be 2 characters longer than the size given because
1918 * we need to put in 2 end-of-buffer characters.
1919 */
1920 b->yy_ch_buf = (char *) glcpp_alloc(b->yy_buf_size + 2 ,yyscanner );
1921 if ( ! b->yy_ch_buf )
1922 YY_FATAL_ERROR( "out of dynamic memory in glcpp__create_buffer()" );
1923
1924 b->yy_is_our_buffer = 1;
1925
1926 glcpp__init_buffer(b,file ,yyscanner);
1927
1928 return b;
1929}
1930
1931/** Destroy the buffer.
1932 * @param b a buffer created with glcpp__create_buffer()
1933 * @param yyscanner The scanner object.
1934 */
1935 void glcpp__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1936{
1937 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1938
1939 if ( ! b )
1940 return;
1941
1942 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1943 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1944
1945 if ( b->yy_is_our_buffer )
1946 glcpp_free((void *) b->yy_ch_buf ,yyscanner );
1947
1948 glcpp_free((void *) b ,yyscanner );
1949}
1950
1951/* Initializes or reinitializes a buffer.
1952 * This function is sometimes called more than once on the same buffer,
1953 * such as during a glcpp_restart() or at EOF.
1954 */
1955 static void glcpp__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1956
1957{
1958 int oerrno = errno;
1959 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1960
1961 glcpp__flush_buffer(b ,yyscanner);
1962
1963 b->yy_input_file = file;
1964 b->yy_fill_buffer = 1;
1965
1966 /* If b is the current buffer, then glcpp__init_buffer was _probably_
1967 * called from glcpp_restart() or through yy_get_next_buffer.
1968 * In that case, we don't want to reset the lineno or column.
1969 */
1970 if (b != YY_CURRENT_BUFFER){
1971 b->yy_bs_lineno = 1;
1972 b->yy_bs_column = 0;
1973 }
1974
1975 b->yy_is_interactive = 0;
1976
1977 errno = oerrno;
1978}
1979
1980/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1981 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1982 * @param yyscanner The scanner object.
1983 */
1984 void glcpp__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1985{
1986 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1987 if ( ! b )
1988 return;
1989
1990 b->yy_n_chars = 0;
1991
1992 /* We always need two end-of-buffer characters. The first causes
1993 * a transition to the end-of-buffer state. The second causes
1994 * a jam in that state.
1995 */
1996 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1997 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1998
1999 b->yy_buf_pos = &b->yy_ch_buf[0];
2000
2001 b->yy_at_bol = 1;
2002 b->yy_buffer_status = YY_BUFFER_NEW;
2003
2004 if ( b == YY_CURRENT_BUFFER )
2005 glcpp__load_buffer_state(yyscanner );
2006}
2007
2008/** Pushes the new state onto the stack. The new state becomes
2009 * the current state. This function will allocate the stack
2010 * if necessary.
2011 * @param new_buffer The new state.
2012 * @param yyscanner The scanner object.
2013 */
2014void glcpp_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2015{
2016 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2017 if (new_buffer == NULL)
2018 return;
2019
2020 glcpp_ensure_buffer_stack(yyscanner);
2021
2022 /* This block is copied from glcpp__switch_to_buffer. */
2023 if ( YY_CURRENT_BUFFER )
2024 {
2025 /* Flush out information for old buffer. */
2026 *yyg->yy_c_buf_p = yyg->yy_hold_char;
2027 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2028 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2029 }
2030
2031 /* Only push if top exists. Otherwise, replace top. */
2032 if (YY_CURRENT_BUFFER)
2033 yyg->yy_buffer_stack_top++;
2034 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2035
2036 /* copied from glcpp__switch_to_buffer. */
2037 glcpp__load_buffer_state(yyscanner );
2038 yyg->yy_did_buffer_switch_on_eof = 1;
2039}
2040
2041/** Removes and deletes the top of the stack, if present.
2042 * The next element becomes the new top.
2043 * @param yyscanner The scanner object.
2044 */
2045void glcpp_pop_buffer_state (yyscan_t yyscanner)
2046{
2047 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2048 if (!YY_CURRENT_BUFFER)
2049 return;
2050
2051 glcpp__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
2052 YY_CURRENT_BUFFER_LVALUE = NULL;
2053 if (yyg->yy_buffer_stack_top > 0)
2054 --yyg->yy_buffer_stack_top;
2055
2056 if (YY_CURRENT_BUFFER) {
2057 glcpp__load_buffer_state(yyscanner );
2058 yyg->yy_did_buffer_switch_on_eof = 1;
2059 }
2060}
2061
2062/* Allocates the stack if it does not exist.
2063 * Guarantees space for at least one push.
2064 */
2065static void glcpp_ensure_buffer_stack (yyscan_t yyscanner)
2066{
2067 int num_to_alloc;
2068 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2069
2070 if (!yyg->yy_buffer_stack) {
2071
2072 /* First allocation is just for 2 elements, since we don't know if this
2073 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2074 * immediate realloc on the next call.
2075 */
2076 num_to_alloc = 1;
2077 yyg->yy_buffer_stack = (struct yy_buffer_state**)glcpp_alloc
2078 (num_to_alloc * sizeof(struct yy_buffer_state*)
2079 , yyscanner);
2080 if ( ! yyg->yy_buffer_stack )
2081 YY_FATAL_ERROR( "out of dynamic memory in glcpp_ensure_buffer_stack()" );
2082
2083 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2084
2085 yyg->yy_buffer_stack_max = num_to_alloc;
2086 yyg->yy_buffer_stack_top = 0;
2087 return;
2088 }
2089
2090 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2091
2092 /* Increase the buffer to prepare for a possible push. */
2093 int grow_size = 8 /* arbitrary grow size */;
2094
2095 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2096 yyg->yy_buffer_stack = (struct yy_buffer_state**)glcpp_realloc
2097 (yyg->yy_buffer_stack,
2098 num_to_alloc * sizeof(struct yy_buffer_state*)
2099 , yyscanner);
2100 if ( ! yyg->yy_buffer_stack )
2101 YY_FATAL_ERROR( "out of dynamic memory in glcpp_ensure_buffer_stack()" );
2102
2103 /* zero only the new slots.*/
2104 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2105 yyg->yy_buffer_stack_max = num_to_alloc;
2106 }
2107}
2108
2109/** Setup the input buffer state to scan directly from a user-specified character buffer.
2110 * @param base the character buffer
2111 * @param size the size in bytes of the character buffer
2112 * @param yyscanner The scanner object.
2113 * @return the newly allocated buffer state object.
2114 */
2115YY_BUFFER_STATE glcpp__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
2116{
2117 YY_BUFFER_STATE b;
2118
2119 if ( size < 2 ||
2120 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2121 base[size-1] != YY_END_OF_BUFFER_CHAR )
2122 /* They forgot to leave room for the EOB's. */
2123 return 0;
2124
2125 b = (YY_BUFFER_STATE) glcpp_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2126 if ( ! b )
2127 YY_FATAL_ERROR( "out of dynamic memory in glcpp__scan_buffer()" );
2128
2129 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
2130 b->yy_buf_pos = b->yy_ch_buf = base;
2131 b->yy_is_our_buffer = 0;
2132 b->yy_input_file = 0;
2133 b->yy_n_chars = b->yy_buf_size;
2134 b->yy_is_interactive = 0;
2135 b->yy_at_bol = 1;
2136 b->yy_fill_buffer = 0;
2137 b->yy_buffer_status = YY_BUFFER_NEW;
2138
2139 glcpp__switch_to_buffer(b ,yyscanner );
2140
2141 return b;
2142}
2143
2144/** Setup the input buffer state to scan a string. The next call to glcpp_lex() will
2145 * scan from a @e copy of @a str.
2146 * @param yystr a NUL-terminated string to scan
2147 * @param yyscanner The scanner object.
2148 * @return the newly allocated buffer state object.
2149 * @note If you want to scan bytes that may contain NUL values, then use
2150 * glcpp__scan_bytes() instead.
2151 */
2152YY_BUFFER_STATE glcpp__scan_string (yyconst char * yystr , yyscan_t yyscanner)
2153{
2154
2155 return glcpp__scan_bytes(yystr,strlen(yystr) ,yyscanner);
2156}
2157
2158/** Setup the input buffer state to scan the given bytes. The next call to glcpp_lex() will
2159 * scan from a @e copy of @a bytes.
2160 * @param bytes the byte buffer to scan
2161 * @param len the number of bytes in the buffer pointed to by @a bytes.
2162 * @param yyscanner The scanner object.
2163 * @return the newly allocated buffer state object.
2164 */
2165YY_BUFFER_STATE glcpp__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
2166{
2167 YY_BUFFER_STATE b;
2168 char *buf;
2169 yy_size_t n;
2170 int i;
2171
2172 /* Get memory for full buffer, including space for trailing EOB's. */
2173 n = _yybytes_len + 2;
2174 buf = (char *) glcpp_alloc(n ,yyscanner );
2175 if ( ! buf )
2176 YY_FATAL_ERROR( "out of dynamic memory in glcpp__scan_bytes()" );
2177
2178 for ( i = 0; i < _yybytes_len; ++i )
2179 buf[i] = yybytes[i];
2180
2181 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2182
2183 b = glcpp__scan_buffer(buf,n ,yyscanner);
2184 if ( ! b )
2185 YY_FATAL_ERROR( "bad buffer in glcpp__scan_bytes()" );
2186
2187 /* It's okay to grow etc. this buffer, and we should throw it
2188 * away when we're done.
2189 */
2190 b->yy_is_our_buffer = 1;
2191
2192 return b;
2193}
2194
2195 static void yy_push_state (int new_state , yyscan_t yyscanner)
2196{
2197 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2198 if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth )
2199 {
2200 yy_size_t new_size;
2201
2202 yyg->yy_start_stack_depth += YY_START_STACK_INCR;
2203 new_size = yyg->yy_start_stack_depth * sizeof( int );
2204
2205 if ( ! yyg->yy_start_stack )
2206 yyg->yy_start_stack = (int *) glcpp_alloc(new_size ,yyscanner );
2207
2208 else
2209 yyg->yy_start_stack = (int *) glcpp_realloc((void *) yyg->yy_start_stack,new_size ,yyscanner );
2210
2211 if ( ! yyg->yy_start_stack )
2212 YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
2213 }
2214
2215 yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;
2216
2217 BEGIN(new_state);
2218}
2219
2220 static void yy_pop_state (yyscan_t yyscanner)
2221{
2222 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2223 if ( --yyg->yy_start_stack_ptr < 0 )
2224 YY_FATAL_ERROR( "start-condition stack underflow" );
2225
2226 BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]);
2227}
2228
2229 static int yy_top_state (yyscan_t yyscanner)
2230{
2231 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2232 return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1];
2233}
2234
2235#ifndef YY_EXIT_FAILURE
2236#define YY_EXIT_FAILURE 2
2237#endif
2238
2239static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
2240{
2241 (void) fprintf( stderr, "%s\n", msg );
2242 exit( YY_EXIT_FAILURE );
2243}
2244
2245/* Redefine yyless() so it works in section 3 code. */
2246
2247#undef yyless
2248#define yyless(n) \
2249 do \
2250 { \
2251 /* Undo effects of setting up yytext. */ \
2252 int yyless_macro_arg = (n); \
2253 YY_LESS_LINENO(yyless_macro_arg);\
2254 yytext[yyleng] = yyg->yy_hold_char; \
2255 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2256 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2257 *yyg->yy_c_buf_p = '\0'; \
2258 yyleng = yyless_macro_arg; \
2259 } \
2260 while ( 0 )
2261
2262/* Accessor methods (get/set functions) to struct members. */
2263
2264/** Get the user-defined data for this scanner.
2265 * @param yyscanner The scanner object.
2266 */
2267YY_EXTRA_TYPE glcpp_get_extra (yyscan_t yyscanner)
2268{
2269 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2270 return yyextra;
2271}
2272
2273/** Get the current line number.
2274 * @param yyscanner The scanner object.
2275 */
2276int glcpp_get_lineno (yyscan_t yyscanner)
2277{
2278 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2279
2280 if (! YY_CURRENT_BUFFER)
2281 return 0;
2282
2283 return yylineno;
2284}
2285
2286/** Get the current column number.
2287 * @param yyscanner The scanner object.
2288 */
2289int glcpp_get_column (yyscan_t yyscanner)
2290{
2291 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2292
2293 if (! YY_CURRENT_BUFFER)
2294 return 0;
2295
2296 return yycolumn;
2297}
2298
2299/** Get the input stream.
2300 * @param yyscanner The scanner object.
2301 */
2302FILE *glcpp_get_in (yyscan_t yyscanner)
2303{
2304 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2305 return yyin;
2306}
2307
2308/** Get the output stream.
2309 * @param yyscanner The scanner object.
2310 */
2311FILE *glcpp_get_out (yyscan_t yyscanner)
2312{
2313 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2314 return yyout;
2315}
2316
2317/** Get the length of the current token.
2318 * @param yyscanner The scanner object.
2319 */
2320int glcpp_get_leng (yyscan_t yyscanner)
2321{
2322 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2323 return yyleng;
2324}
2325
2326/** Get the current token.
2327 * @param yyscanner The scanner object.
2328 */
2329
2330char *glcpp_get_text (yyscan_t yyscanner)
2331{
2332 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2333 return yytext;
2334}
2335
2336/** Set the user-defined data. This data is never touched by the scanner.
2337 * @param user_defined The data to be associated with this scanner.
2338 * @param yyscanner The scanner object.
2339 */
2340void glcpp_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2341{
2342 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2343 yyextra = user_defined ;
2344}
2345
2346/** Set the current line number.
2347 * @param line_number
2348 * @param yyscanner The scanner object.
2349 */
2350void glcpp_set_lineno (int line_number , yyscan_t yyscanner)
2351{
2352 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2353
2354 /* lineno is only valid if an input buffer exists. */
2355 if (! YY_CURRENT_BUFFER )
2356 yy_fatal_error( "glcpp_set_lineno called with no buffer" , yyscanner);
2357
2358 yylineno = line_number;
2359}
2360
2361/** Set the current column.
2362 * @param line_number
2363 * @param yyscanner The scanner object.
2364 */
2365void glcpp_set_column (int column_no , yyscan_t yyscanner)
2366{
2367 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2368
2369 /* column is only valid if an input buffer exists. */
2370 if (! YY_CURRENT_BUFFER )
2371 yy_fatal_error( "glcpp_set_column called with no buffer" , yyscanner);
2372
2373 yycolumn = column_no;
2374}
2375
2376/** Set the input stream. This does not discard the current
2377 * input buffer.
2378 * @param in_str A readable stream.
2379 * @param yyscanner The scanner object.
2380 * @see glcpp__switch_to_buffer
2381 */
2382void glcpp_set_in (FILE * in_str , yyscan_t yyscanner)
2383{
2384 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2385 yyin = in_str ;
2386}
2387
2388void glcpp_set_out (FILE * out_str , yyscan_t yyscanner)
2389{
2390 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2391 yyout = out_str ;
2392}
2393
2394int glcpp_get_debug (yyscan_t yyscanner)
2395{
2396 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2397 return yy_flex_debug;
2398}
2399
2400void glcpp_set_debug (int bdebug , yyscan_t yyscanner)
2401{
2402 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2403 yy_flex_debug = bdebug ;
2404}
2405
2406/* Accessor methods for yylval and yylloc */
2407
2408YYSTYPE * glcpp_get_lval (yyscan_t yyscanner)
2409{
2410 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2411 return yylval;
2412}
2413
2414void glcpp_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
2415{
2416 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2417 yylval = yylval_param;
2418}
2419
2420YYLTYPE *glcpp_get_lloc (yyscan_t yyscanner)
2421{
2422 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2423 return yylloc;
2424}
2425
2426void glcpp_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner)
2427{
2428 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2429 yylloc = yylloc_param;
2430}
2431
2432/* User-visible API */
2433
2434/* glcpp_lex_init is special because it creates the scanner itself, so it is
2435 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2436 * That's why we explicitly handle the declaration, instead of using our macros.
2437 */
2438
2439int glcpp_lex_init(yyscan_t* ptr_yy_globals)
2440
2441{
2442 if (ptr_yy_globals == NULL){
2443 errno = EINVAL;
2444 return 1;
2445 }
2446
2447 *ptr_yy_globals = (yyscan_t) glcpp_alloc ( sizeof( struct yyguts_t ), NULL );
2448
2449 if (*ptr_yy_globals == NULL){
2450 errno = ENOMEM;
2451 return 1;
2452 }
2453
2454 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2455 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2456
2457 return yy_init_globals ( *ptr_yy_globals );
2458}
2459
2460/* glcpp_lex_init_extra has the same functionality as glcpp_lex_init, but follows the
2461 * convention of taking the scanner as the last argument. Note however, that
2462 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2463 * is the reason, too, why this function also must handle its own declaration).
2464 * The user defined value in the first argument will be available to glcpp_alloc in
2465 * the yyextra field.
2466 */
2467
2468int glcpp_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2469
2470{
2471 struct yyguts_t dummy_yyguts;
2472
2473 glcpp_set_extra (yy_user_defined, &dummy_yyguts);
2474
2475 if (ptr_yy_globals == NULL){
2476 errno = EINVAL;
2477 return 1;
2478 }
2479
2480 *ptr_yy_globals = (yyscan_t) glcpp_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2481
2482 if (*ptr_yy_globals == NULL){
2483 errno = ENOMEM;
2484 return 1;
2485 }
2486
2487 /* By setting to 0xAA, we expose bugs in
2488 yy_init_globals. Leave at 0x00 for releases. */
2489 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2490
2491 glcpp_set_extra (yy_user_defined, *ptr_yy_globals);
2492
2493 return yy_init_globals ( *ptr_yy_globals );
2494}
2495
2496static int yy_init_globals (yyscan_t yyscanner)
2497{
2498 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2499 /* Initialization is the same as for the non-reentrant scanner.
2500 * This function is called from glcpp_lex_destroy(), so don't allocate here.
2501 */
2502
2503 yyg->yy_buffer_stack = 0;
2504 yyg->yy_buffer_stack_top = 0;
2505 yyg->yy_buffer_stack_max = 0;
2506 yyg->yy_c_buf_p = (char *) 0;
2507 yyg->yy_init = 0;
2508 yyg->yy_start = 0;
2509
2510 yyg->yy_start_stack_ptr = 0;
2511 yyg->yy_start_stack_depth = 0;
2512 yyg->yy_start_stack = NULL;
2513
2514 yyg->yy_state_buf = 0;
2515 yyg->yy_state_ptr = 0;
2516 yyg->yy_full_match = 0;
2517 yyg->yy_lp = 0;
2518
2519/* Defined in main.c */
2520#ifdef YY_STDINIT
2521 yyin = stdin;
2522 yyout = stdout;
2523#else
2524 yyin = (FILE *) 0;
2525 yyout = (FILE *) 0;
2526#endif
2527
2528 /* For future reference: Set errno on error, since we are called by
2529 * glcpp_lex_init()
2530 */
2531 return 0;
2532}
2533
2534/* glcpp_lex_destroy is for both reentrant and non-reentrant scanners. */
2535int glcpp_lex_destroy (yyscan_t yyscanner)
2536{
2537 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2538
2539 /* Pop the buffer stack, destroying each element. */
2540 while(YY_CURRENT_BUFFER){
2541 glcpp__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2542 YY_CURRENT_BUFFER_LVALUE = NULL;
2543 glcpp_pop_buffer_state(yyscanner);
2544 }
2545
2546 /* Destroy the stack itself. */
2547 glcpp_free(yyg->yy_buffer_stack ,yyscanner);
2548 yyg->yy_buffer_stack = NULL;
2549
2550 /* Destroy the start condition stack. */
2551 glcpp_free(yyg->yy_start_stack ,yyscanner );
2552 yyg->yy_start_stack = NULL;
2553
2554 glcpp_free ( yyg->yy_state_buf , yyscanner);
2555 yyg->yy_state_buf = NULL;
2556
2557 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2558 * glcpp_lex() is called, initialization will occur. */
2559 yy_init_globals( yyscanner);
2560
2561 /* Destroy the main struct (reentrant only). */
2562 glcpp_free ( yyscanner , yyscanner );
2563 yyscanner = NULL;
2564 return 0;
2565}
2566
2567/*
2568 * Internal utility routines.
2569 */
2570
2571#ifndef yytext_ptr
2572static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2573{
2574 register int i;
2575 for ( i = 0; i < n; ++i )
2576 s1[i] = s2[i];
2577}
2578#endif
2579
2580#ifdef YY_NEED_STRLEN
2581static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2582{
2583 register int n;
2584 for ( n = 0; s[n]; ++n )
2585 ;
2586
2587 return n;
2588}
2589#endif
2590
2591void *glcpp_alloc (yy_size_t size , yyscan_t yyscanner)
2592{
2593 return (void *) malloc( size );
2594}
2595
2596void *glcpp_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2597{
2598 /* The cast to (char *) in the following accommodates both
2599 * implementations that use char* generic pointers, and those
2600 * that use void* generic pointers. It works with the latter
2601 * because both ANSI C and C++ allow castless assignment from
2602 * any pointer type to void*, and deal with argument conversions
2603 * as though doing an assignment.
2604 */
2605 return (void *) realloc( (char *) ptr, size );
2606}
2607
2608void glcpp_free (void * ptr , yyscan_t yyscanner)
2609{
2610 free( (char *) ptr ); /* see glcpp_realloc() for (char *) cast */
2611}
2612
2613#define YYTABLES_NAME "yytables"
2614
2615#line 285 "glcpp/glcpp-lex.l"
2616
2617
2618
2619void
2620glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader)
2621{
2622 glcpp__scan_string(shader,parser->scanner);
2623}
2624
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
new file mode 100644
index 00000000000..9187926146a
--- /dev/null
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -0,0 +1,291 @@
1%{
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include <stdio.h>
26#include <string.h>
27#include <ctype.h>
28
29#include "glcpp.h"
30#include "glcpp-parse.h"
31
32/* Flex annoyingly generates some functions without making them
33 * static. Let's declare them here. */
34int glcpp_get_column (yyscan_t yyscanner);
35void glcpp_set_column (int column_no , yyscan_t yyscanner);
36
37#define YY_NO_INPUT
38
39#define YY_USER_ACTION \
40 do { \
41 yylloc->source = 0; \
42 yylloc->first_column = yycolumn + 1; \
43 yylloc->first_line = yylineno; \
44 yycolumn += yyleng; \
45 } while(0);
46#define YY_USER_INIT yylineno = 1; yycolumn = 1;
47%}
48
49%option bison-bridge bison-locations reentrant noyywrap
50%option extra-type="glcpp_parser_t *"
51%option prefix="glcpp_"
52%option stack
53%option never-interactive
54
55%x DONE COMMENT UNREACHABLE
56
57SPACE [[:space:]]
58NONSPACE [^[:space:]]
59NEWLINE [\n]
60HSPACE [ \t]
61HASH ^{HSPACE}*#{HSPACE}*
62IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*
63PUNCTUATION [][(){}.&*~!/%<>^|;,=+-]
64OTHER [^][(){}.&*~!/%<>^|;,=#[:space:]+-]+
65
66DECIMAL_INTEGER [1-9][0-9]*[uU]?
67OCTAL_INTEGER 0[0-7]*[uU]?
68HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
69
70%%
71
72 /* Single-line comments */
73"//"[^\n]*\n {
74 yylineno++;
75 yycolumn = 0;
76 return NEWLINE;
77}
78
79 /* Multi-line comments */
80"/*" { yy_push_state(COMMENT, yyscanner); }
81<COMMENT>[^*\n]*
82<COMMENT>[^*\n]*\n { yylineno++; yycolumn = 0; }
83<COMMENT>"*"+[^*/\n]*
84<COMMENT>"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; }
85<COMMENT>"*"+"/" {
86 yy_pop_state(yyscanner);
87 if (yyextra->space_tokens)
88 return SPACE;
89}
90
91{HASH}version {
92 yylval->str = talloc_strdup (yyextra, yytext);
93 yyextra->space_tokens = 0;
94 return HASH_VERSION;
95}
96
97 /* glcpp doesn't handle #extension, #version, or #pragma directives.
98 * Simply pass them through to the main compiler's lexer/parser. */
99{HASH}(extension|pragma)[^\n]+ {
100 yylval->str = talloc_strdup (yyextra, yytext);
101 yylineno++;
102 yycolumn = 0;
103 return OTHER;
104}
105
106{HASH}ifdef/.*\n {
107 yyextra->lexing_if = 1;
108 yyextra->space_tokens = 0;
109 return HASH_IFDEF;
110}
111
112{HASH}ifndef/.*\n {
113 yyextra->lexing_if = 1;
114 yyextra->space_tokens = 0;
115 return HASH_IFNDEF;
116}
117
118{HASH}if/[^_a-zA-Z0-9].*\n {
119 yyextra->lexing_if = 1;
120 yyextra->space_tokens = 0;
121 return HASH_IF;
122}
123
124{HASH}elif/.*\n {
125 yyextra->lexing_if = 1;
126 yyextra->space_tokens = 0;
127 return HASH_ELIF;
128}
129
130{HASH}else/.*\n {
131 yyextra->space_tokens = 0;
132 return HASH_ELSE;
133}
134
135{HASH}endif/.*\n {
136 yyextra->space_tokens = 0;
137 return HASH_ENDIF;
138}
139
140 /* When skipping (due to an #if 0 or similar) consume anything
141 * up to a newline. We do this with less priority than any
142 * #if-related directive (#if, #elif, #else, #endif), but with
143 * more priority than any other directive or token to avoid
144 * any side-effects from skipped content.
145 *
146 * We use the lexing_if flag to avoid skipping any part of an
147 * if conditional expression. */
148[^\n]+/\n {
149 /* Since this rule always matches, YY_USER_ACTION gets called for it,
150 * wrongly incrementing yycolumn. We undo that effect here. */
151 yycolumn -= yyleng;
152 if (yyextra->lexing_if ||
153 yyextra->skip_stack == NULL ||
154 yyextra->skip_stack->type == SKIP_NO_SKIP)
155 {
156 REJECT;
157 }
158}
159
160{HASH}error.* {
161 char *p;
162 for (p = yytext; !isalpha(p[0]); p++); /* skip " # " */
163 p += 5; /* skip "error" */
164 glcpp_error(yylloc, yyextra, "#error%s", p);
165}
166
167{HASH}define{HSPACE}+/{IDENTIFIER}"(" {
168 yyextra->space_tokens = 0;
169 return HASH_DEFINE_FUNC;
170}
171
172{HASH}define {
173 yyextra->space_tokens = 0;
174 return HASH_DEFINE_OBJ;
175}
176
177{HASH}undef {
178 yyextra->space_tokens = 0;
179 return HASH_UNDEF;
180}
181
182{HASH} {
183 yyextra->space_tokens = 0;
184 return HASH;
185}
186
187{DECIMAL_INTEGER} {
188 yylval->str = talloc_strdup (yyextra, yytext);
189 return INTEGER_STRING;
190}
191
192{OCTAL_INTEGER} {
193 yylval->str = talloc_strdup (yyextra, yytext);
194 return INTEGER_STRING;
195}
196
197{HEXADECIMAL_INTEGER} {
198 yylval->str = talloc_strdup (yyextra, yytext);
199 return INTEGER_STRING;
200}
201
202"<<" {
203 return LEFT_SHIFT;
204}
205
206">>" {
207 return RIGHT_SHIFT;
208}
209
210"<=" {
211 return LESS_OR_EQUAL;
212}
213
214">=" {
215 return GREATER_OR_EQUAL;
216}
217
218"==" {
219 return EQUAL;
220}
221
222"!=" {
223 return NOT_EQUAL;
224}
225
226"&&" {
227 return AND;
228}
229
230"||" {
231 return OR;
232}
233
234"##" {
235 return PASTE;
236}
237
238"defined" {
239 return DEFINED;
240}
241
242{IDENTIFIER} {
243 yylval->str = talloc_strdup (yyextra, yytext);
244 return IDENTIFIER;
245}
246
247{PUNCTUATION} {
248 return yytext[0];
249}
250
251{OTHER}+ {
252 yylval->str = talloc_strdup (yyextra, yytext);
253 return OTHER;
254}
255
256{HSPACE}+ {
257 if (yyextra->space_tokens) {
258 return SPACE;
259 }
260}
261
262\n {
263 yyextra->lexing_if = 0;
264 yylineno++;
265 yycolumn = 0;
266 return NEWLINE;
267}
268
269 /* Handle missing newline at EOF. */
270<INITIAL><<EOF>> {
271 BEGIN DONE; /* Don't keep matching this rule forever. */
272 yyextra->lexing_if = 0;
273 return NEWLINE;
274}
275
276 /* We don't actually use the UNREACHABLE start condition. We
277 only have this action here so that we can pretend to call some
278 generated functions, (to avoid "defined but not used"
279 warnings. */
280<UNREACHABLE>. {
281 unput('.');
282 yy_top_state(yyextra);
283}
284
285%%
286
287void
288glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader)
289{
290 yy_scan_string(shader, parser->scanner);
291}
diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c
new file mode 100644
index 00000000000..a19a02a867d
--- /dev/null
+++ b/src/glsl/glcpp/glcpp-parse.c
@@ -0,0 +1,4055 @@
1/* A Bison parser, made by GNU Bison 2.4.3. */
2
3/* Skeleton implementation for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6 2009, 2010 Free Software Foundation, Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34/* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37/* All symbols defined below should begin with yy or YY, to avoid
38 infringing on user name space. This should be done even for local
39 variables, as they might otherwise be expanded by user macros.
40 There are some unavoidable exceptions within include files to
41 define necessary library symbols; they are noted "INFRINGES ON
42 USER NAME SPACE" below. */
43
44/* Identify Bison output. */
45#define YYBISON 1
46
47/* Bison version. */
48#define YYBISON_VERSION "2.4.3"
49
50/* Skeleton name. */
51#define YYSKELETON_NAME "yacc.c"
52
53/* Pure parsers. */
54#define YYPURE 1
55
56/* Push parsers. */
57#define YYPUSH 0
58
59/* Pull parsers. */
60#define YYPULL 1
61
62/* Using locations. */
63#define YYLSP_NEEDED 1
64
65
66
67/* Copy the first part of user declarations. */
68
69/* Line 189 of yacc.c */
70#line 1 "glcpp/glcpp-parse.y"
71
72/*
73 * Copyright © 2010 Intel Corporation
74 *
75 * Permission is hereby granted, free of charge, to any person obtaining a
76 * copy of this software and associated documentation files (the "Software"),
77 * to deal in the Software without restriction, including without limitation
78 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
79 * and/or sell copies of the Software, and to permit persons to whom the
80 * Software is furnished to do so, subject to the following conditions:
81 *
82 * The above copyright notice and this permission notice (including the next
83 * paragraph) shall be included in all copies or substantial portions of the
84 * Software.
85 *
86 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
87 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
89 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
90 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
92 * DEALINGS IN THE SOFTWARE.
93 */
94
95#include <stdio.h>
96#include <stdlib.h>
97#include <string.h>
98#include <assert.h>
99#include <inttypes.h>
100
101#include "glcpp.h"
102#include "main/mtypes.h"
103
104#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
105#define glcpp_printf(stream, fmt, args, ...) \
106 stream = talloc_asprintf_append(stream, fmt, args)
107
108static void
109yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
110
111static void
112_define_object_macro (glcpp_parser_t *parser,
113 YYLTYPE *loc,
114 const char *macro,
115 token_list_t *replacements);
116
117static void
118_define_function_macro (glcpp_parser_t *parser,
119 YYLTYPE *loc,
120 const char *macro,
121 string_list_t *parameters,
122 token_list_t *replacements);
123
124static string_list_t *
125_string_list_create (void *ctx);
126
127static void
128_string_list_append_item (string_list_t *list, const char *str);
129
130static int
131_string_list_contains (string_list_t *list, const char *member, int *index);
132
133static int
134_string_list_length (string_list_t *list);
135
136static argument_list_t *
137_argument_list_create (void *ctx);
138
139static void
140_argument_list_append (argument_list_t *list, token_list_t *argument);
141
142static int
143_argument_list_length (argument_list_t *list);
144
145static token_list_t *
146_argument_list_member_at (argument_list_t *list, int index);
147
148/* Note: This function talloc_steal()s the str pointer. */
149static token_t *
150_token_create_str (void *ctx, int type, char *str);
151
152static token_t *
153_token_create_ival (void *ctx, int type, int ival);
154
155static token_list_t *
156_token_list_create (void *ctx);
157
158/* Note: This function adds a talloc_reference() to token.
159 *
160 * You may want to talloc_unlink any current reference if you no
161 * longer need it. */
162static void
163_token_list_append (token_list_t *list, token_t *token);
164
165static void
166_token_list_append_list (token_list_t *list, token_list_t *tail);
167
168static active_list_t *
169_active_list_push (active_list_t *list,
170 const char *identifier,
171 token_node_t *marker);
172
173static active_list_t *
174_active_list_pop (active_list_t *list);
175
176int
177_active_list_contains (active_list_t *list, const char *identifier);
178
179static void
180_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list);
181
182static void
183_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
184 token_list_t *list);
185
186static void
187_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
188 token_list_t *list);
189
190static void
191_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
192 int condition);
193
194static void
195_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
196 const char *type, int condition);
197
198static void
199_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
200
201#define yylex glcpp_parser_lex
202
203static int
204glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
205
206static void
207glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
208
209static void
210add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
211
212
213
214/* Line 189 of yacc.c */
215#line 216 "glcpp/glcpp-parse.c"
216
217/* Enabling traces. */
218#ifndef YYDEBUG
219# define YYDEBUG 0
220#endif
221
222/* Enabling verbose error messages. */
223#ifdef YYERROR_VERBOSE
224# undef YYERROR_VERBOSE
225# define YYERROR_VERBOSE 1
226#else
227# define YYERROR_VERBOSE 1
228#endif
229
230/* Enabling the token table. */
231#ifndef YYTOKEN_TABLE
232# define YYTOKEN_TABLE 0
233#endif
234
235
236/* Tokens. */
237#ifndef YYTOKENTYPE
238# define YYTOKENTYPE
239 /* Put the tokens into the symbol table, so that GDB and other debuggers
240 know about them. */
241 enum yytokentype {
242 COMMA_FINAL = 258,
243 DEFINED = 259,
244 ELIF_EXPANDED = 260,
245 HASH = 261,
246 HASH_DEFINE_FUNC = 262,
247 HASH_DEFINE_OBJ = 263,
248 HASH_ELIF = 264,
249 HASH_ELSE = 265,
250 HASH_ENDIF = 266,
251 HASH_IF = 267,
252 HASH_IFDEF = 268,
253 HASH_IFNDEF = 269,
254 HASH_UNDEF = 270,
255 HASH_VERSION = 271,
256 IDENTIFIER = 272,
257 IF_EXPANDED = 273,
258 INTEGER = 274,
259 INTEGER_STRING = 275,
260 NEWLINE = 276,
261 OTHER = 277,
262 PLACEHOLDER = 278,
263 SPACE = 279,
264 PASTE = 280,
265 OR = 281,
266 AND = 282,
267 NOT_EQUAL = 283,
268 EQUAL = 284,
269 GREATER_OR_EQUAL = 285,
270 LESS_OR_EQUAL = 286,
271 RIGHT_SHIFT = 287,
272 LEFT_SHIFT = 288,
273 UNARY = 289
274 };
275#endif
276
277
278
279#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
280
281# define yystype YYSTYPE /* obsolescent; will be withdrawn */
282# define YYSTYPE_IS_DECLARED 1
283#endif
284
285#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
286typedef struct YYLTYPE
287{
288 int first_line;
289 int first_column;
290 int last_line;
291 int last_column;
292} YYLTYPE;
293# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
294# define YYLTYPE_IS_DECLARED 1
295# define YYLTYPE_IS_TRIVIAL 1
296#endif
297
298
299/* Copy the second part of user declarations. */
300
301
302/* Line 264 of yacc.c */
303#line 304 "glcpp/glcpp-parse.c"
304
305#ifdef short
306# undef short
307#endif
308
309#ifdef YYTYPE_UINT8
310typedef YYTYPE_UINT8 yytype_uint8;
311#else
312typedef unsigned char yytype_uint8;
313#endif
314
315#ifdef YYTYPE_INT8
316typedef YYTYPE_INT8 yytype_int8;
317#elif (defined __STDC__ || defined __C99__FUNC__ \
318 || defined __cplusplus || defined _MSC_VER)
319typedef signed char yytype_int8;
320#else
321typedef short int yytype_int8;
322#endif
323
324#ifdef YYTYPE_UINT16
325typedef YYTYPE_UINT16 yytype_uint16;
326#else
327typedef unsigned short int yytype_uint16;
328#endif
329
330#ifdef YYTYPE_INT16
331typedef YYTYPE_INT16 yytype_int16;
332#else
333typedef short int yytype_int16;
334#endif
335
336#ifndef YYSIZE_T
337# ifdef __SIZE_TYPE__
338# define YYSIZE_T __SIZE_TYPE__
339# elif defined size_t
340# define YYSIZE_T size_t
341# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
342 || defined __cplusplus || defined _MSC_VER)
343# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
344# define YYSIZE_T size_t
345# else
346# define YYSIZE_T unsigned int
347# endif
348#endif
349
350#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
351
352#ifndef YY_
353# if defined YYENABLE_NLS && YYENABLE_NLS
354# if ENABLE_NLS
355# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
356# define YY_(msgid) dgettext ("bison-runtime", msgid)
357# endif
358# endif
359# ifndef YY_
360# define YY_(msgid) msgid
361# endif
362#endif
363
364/* Suppress unused-variable warnings by "using" E. */
365#if ! defined lint || defined __GNUC__
366# define YYUSE(e) ((void) (e))
367#else
368# define YYUSE(e) /* empty */
369#endif
370
371/* Identity function, used to suppress warnings about constant conditions. */
372#ifndef lint
373# define YYID(n) (n)
374#else
375#if (defined __STDC__ || defined __C99__FUNC__ \
376 || defined __cplusplus || defined _MSC_VER)
377static int
378YYID (int yyi)
379#else
380static int
381YYID (yyi)
382 int yyi;
383#endif
384{
385 return yyi;
386}
387#endif
388
389#if ! defined yyoverflow || YYERROR_VERBOSE
390
391/* The parser invokes alloca or malloc; define the necessary symbols. */
392
393# ifdef YYSTACK_USE_ALLOCA
394# if YYSTACK_USE_ALLOCA
395# ifdef __GNUC__
396# define YYSTACK_ALLOC __builtin_alloca
397# elif defined __BUILTIN_VA_ARG_INCR
398# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
399# elif defined _AIX
400# define YYSTACK_ALLOC __alloca
401# elif defined _MSC_VER
402# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
403# define alloca _alloca
404# else
405# define YYSTACK_ALLOC alloca
406# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
407 || defined __cplusplus || defined _MSC_VER)
408# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
409# ifndef _STDLIB_H
410# define _STDLIB_H 1
411# endif
412# endif
413# endif
414# endif
415# endif
416
417# ifdef YYSTACK_ALLOC
418 /* Pacify GCC's `empty if-body' warning. */
419# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
420# ifndef YYSTACK_ALLOC_MAXIMUM
421 /* The OS might guarantee only one guard page at the bottom of the stack,
422 and a page size can be as small as 4096 bytes. So we cannot safely
423 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
424 to allow for a few compiler-allocated temporary stack slots. */
425# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
426# endif
427# else
428# define YYSTACK_ALLOC YYMALLOC
429# define YYSTACK_FREE YYFREE
430# ifndef YYSTACK_ALLOC_MAXIMUM
431# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
432# endif
433# if (defined __cplusplus && ! defined _STDLIB_H \
434 && ! ((defined YYMALLOC || defined malloc) \
435 && (defined YYFREE || defined free)))
436# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
437# ifndef _STDLIB_H
438# define _STDLIB_H 1
439# endif
440# endif
441# ifndef YYMALLOC
442# define YYMALLOC malloc
443# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
444 || defined __cplusplus || defined _MSC_VER)
445void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
446# endif
447# endif
448# ifndef YYFREE
449# define YYFREE free
450# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
451 || defined __cplusplus || defined _MSC_VER)
452void free (void *); /* INFRINGES ON USER NAME SPACE */
453# endif
454# endif
455# endif
456#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
457
458
459#if (! defined yyoverflow \
460 && (! defined __cplusplus \
461 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
462 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
463
464/* A type that is properly aligned for any stack member. */
465union yyalloc
466{
467 yytype_int16 yyss_alloc;
468 YYSTYPE yyvs_alloc;
469 YYLTYPE yyls_alloc;
470};
471
472/* The size of the maximum gap between one aligned stack and the next. */
473# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
474
475/* The size of an array large to enough to hold all stacks, each with
476 N elements. */
477# define YYSTACK_BYTES(N) \
478 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
479 + 2 * YYSTACK_GAP_MAXIMUM)
480
481/* Copy COUNT objects from FROM to TO. The source and destination do
482 not overlap. */
483# ifndef YYCOPY
484# if defined __GNUC__ && 1 < __GNUC__
485# define YYCOPY(To, From, Count) \
486 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
487# else
488# define YYCOPY(To, From, Count) \
489 do \
490 { \
491 YYSIZE_T yyi; \
492 for (yyi = 0; yyi < (Count); yyi++) \
493 (To)[yyi] = (From)[yyi]; \
494 } \
495 while (YYID (0))
496# endif
497# endif
498
499/* Relocate STACK from its old location to the new one. The
500 local variables YYSIZE and YYSTACKSIZE give the old and new number of
501 elements in the stack, and YYPTR gives the new location of the
502 stack. Advance YYPTR to a properly aligned location for the next
503 stack. */
504# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
505 do \
506 { \
507 YYSIZE_T yynewbytes; \
508 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
509 Stack = &yyptr->Stack_alloc; \
510 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
511 yyptr += yynewbytes / sizeof (*yyptr); \
512 } \
513 while (YYID (0))
514
515#endif
516
517/* YYFINAL -- State number of the termination state. */
518#define YYFINAL 2
519/* YYLAST -- Last index in YYTABLE. */
520#define YYLAST 606
521
522/* YYNTOKENS -- Number of terminals. */
523#define YYNTOKENS 57
524/* YYNNTS -- Number of nonterminals. */
525#define YYNNTS 17
526/* YYNRULES -- Number of rules. */
527#define YYNRULES 101
528/* YYNRULES -- Number of states. */
529#define YYNSTATES 162
530
531/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
532#define YYUNDEFTOK 2
533#define YYMAXUTOK 289
534
535#define YYTRANSLATE(YYX) \
536 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
537
538/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
539static const yytype_uint8 yytranslate[] =
540{
541 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 47, 2, 2, 2, 43, 30, 2,
545 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
547 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 50, 2, 51, 29, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 52, 28, 53, 48, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
567 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
568 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
569 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
570};
571
572#if YYDEBUG
573/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
574 YYRHS. */
575static const yytype_uint16 yyprhs[] =
576{
577 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
578 24, 29, 36, 44, 48, 52, 55, 60, 65, 69,
579 72, 75, 78, 82, 85, 87, 89, 91, 95, 99,
580 103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
581 143, 147, 151, 155, 159, 163, 166, 169, 172, 175,
582 179, 181, 185, 187, 190, 193, 194, 196, 197, 199,
583 202, 207, 209, 211, 214, 216, 219, 221, 223, 225,
584 227, 229, 231, 233, 235, 237, 239, 241, 243, 245,
585 247, 249, 251, 253, 255, 257, 259, 261, 263, 265,
586 267, 269, 271, 273, 275, 277, 279, 281, 283, 285,
587 287, 289
588};
589
590/* YYRHS -- A `-1'-separated list of the rules' RHS. */
591static const yytype_int8 yyrhs[] =
592{
593 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
594 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
595 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
596 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
597 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
598 21, -1, 12, 21, -1, 13, 17, 68, 21, -1,
599 14, 17, 68, 21, -1, 9, 70, 21, -1, 9,
600 21, -1, 10, 21, -1, 11, 21, -1, 16, 62,
601 21, -1, 6, 21, -1, 20, -1, 19, -1, 62,
602 -1, 63, 26, 63, -1, 63, 27, 63, -1, 63,
603 28, 63, -1, 63, 29, 63, -1, 63, 30, 63,
604 -1, 63, 31, 63, -1, 63, 32, 63, -1, 63,
605 35, 63, -1, 63, 36, 63, -1, 63, 34, 63,
606 -1, 63, 33, 63, -1, 63, 37, 63, -1, 63,
607 38, 63, -1, 63, 40, 63, -1, 63, 39, 63,
608 -1, 63, 43, 63, -1, 63, 42, 63, -1, 63,
609 41, 63, -1, 47, 63, -1, 48, 63, -1, 40,
610 63, -1, 39, 63, -1, 45, 63, 46, -1, 17,
611 -1, 64, 49, 17, -1, 21, -1, 71, 21, -1,
612 71, 21, -1, -1, 71, -1, -1, 71, -1, 4,
613 17, -1, 4, 45, 17, 46, -1, 72, -1, 69,
614 -1, 70, 69, -1, 72, -1, 71, 72, -1, 17,
615 -1, 20, -1, 73, -1, 22, -1, 24, -1, 50,
616 -1, 51, -1, 45, -1, 46, -1, 52, -1, 53,
617 -1, 54, -1, 30, -1, 41, -1, 39, -1, 40,
618 -1, 48, -1, 47, -1, 42, -1, 43, -1, 38,
619 -1, 37, -1, 33, -1, 34, -1, 36, -1, 35,
620 -1, 32, -1, 31, -1, 29, -1, 28, -1, 27,
621 -1, 26, -1, 55, -1, 49, -1, 56, -1, 25,
622 -1
623};
624
625/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
626static const yytype_uint16 yyrline[] =
627{
628 0, 181, 181, 183, 187, 190, 195, 196, 200, 203,
629 209, 212, 215, 218, 226, 245, 255, 260, 265, 284,
630 299, 302, 305, 314, 318, 327, 332, 333, 336, 339,
631 342, 345, 348, 351, 354, 357, 360, 363, 366, 369,
632 372, 375, 378, 381, 384, 387, 390, 393, 396, 399,
633 405, 410, 418, 419, 423, 429, 430, 433, 435, 442,
634 446, 450, 455, 461, 469, 475, 483, 487, 491, 495,
635 499, 506, 507, 508, 509, 510, 511, 512, 513, 514,
636 515, 516, 517, 518, 519, 520, 521, 522, 523, 524,
637 525, 526, 527, 528, 529, 530, 531, 532, 533, 534,
638 535, 536
639};
640#endif
641
642#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
643/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
644 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
645static const char *const yytname[] =
646{
647 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
648 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
649 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
650 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
651 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
652 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
653 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
654 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
655 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
656 "input", "line", "expanded_line", "control_line", "integer_constant",
657 "expression", "identifier_list", "text_line", "non_directive",
658 "replacement_list", "junk", "conditional_token", "conditional_tokens",
659 "pp_tokens", "preprocessing_token", "operator", 0
660};
661#endif
662
663# ifdef YYPRINT
664/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
665 token YYLEX-NUM. */
666static const yytype_uint16 yytoknum[] =
667{
668 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
669 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
670 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
671 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
672 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
673 91, 93, 123, 125, 46, 59, 61
674};
675# endif
676
677/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
678static const yytype_uint8 yyr1[] =
679{
680 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
681 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
682 61, 61, 61, 61, 62, 62, 63, 63, 63, 63,
683 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
684 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
685 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
686 69, 69, 70, 70, 71, 71, 72, 72, 72, 72,
687 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
688 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
689 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
690 73, 73
691};
692
693/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
694static const yytype_uint8 yyr2[] =
695{
696 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
697 4, 6, 7, 3, 3, 2, 4, 4, 3, 2,
698 2, 2, 3, 2, 1, 1, 1, 3, 3, 3,
699 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
700 3, 3, 3, 3, 3, 2, 2, 2, 2, 3,
701 1, 3, 1, 2, 2, 0, 1, 0, 1, 2,
702 4, 1, 1, 2, 1, 2, 1, 1, 1, 1,
703 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
704 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
705 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
706 1, 1
707};
708
709/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
710 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
711 means the default is an error. */
712static const yytype_uint8 yydefact[] =
713{
714 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
715 0, 0, 0, 0, 0, 66, 0, 67, 52, 69,
716 70, 101, 97, 96, 95, 94, 78, 93, 92, 88,
717 89, 91, 90, 87, 86, 80, 81, 79, 84, 85,
718 73, 74, 83, 82, 99, 71, 72, 75, 76, 77,
719 98, 100, 3, 6, 4, 5, 0, 64, 68, 25,
720 24, 0, 0, 0, 0, 0, 26, 0, 23, 7,
721 0, 0, 55, 0, 19, 62, 0, 61, 20, 21,
722 15, 0, 57, 57, 0, 0, 0, 53, 65, 48,
723 47, 0, 45, 46, 9, 0, 0, 0, 0, 0,
724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
725 0, 0, 0, 54, 0, 0, 56, 59, 0, 18,
726 63, 14, 0, 58, 0, 13, 22, 8, 49, 27,
727 28, 29, 30, 31, 32, 33, 37, 36, 34, 35,
728 38, 39, 41, 40, 44, 43, 42, 50, 55, 0,
729 10, 0, 16, 17, 0, 55, 0, 60, 11, 0,
730 51, 12
731};
732
733/* YYDEFGOTO[NTERM-NUM]. */
734static const yytype_int16 yydefgoto[] =
735{
736 -1, 1, 52, 53, 54, 66, 67, 149, 55, 69,
737 115, 122, 75, 76, 116, 57, 58
738};
739
740/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
741 STATE-NUM. */
742#define YYPACT_NINF -147
743static const yytype_int16 yypact[] =
744{
745 -147, 112, -147, 28, -10, 55, 62, 152, -15, 59,
746 192, 85, 86, 87, 51, -147, 28, -147, -147, -147,
747 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
748 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
749 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
750 -147, -147, -147, -147, -147, -147, 312, -147, -147, -147,
751 -147, 28, 28, 28, 28, 28, -147, 428, -147, -147,
752 352, 63, 392, 17, -147, -147, 232, -147, -147, -147,
753 -147, 272, 392, 392, 84, 89, 451, -147, -147, -147,
754 -147, 469, -147, -147, -147, 28, 28, 28, 28, 28,
755 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
756 28, 28, 28, -147, 60, 90, 392, -147, 96, -147,
757 -147, -147, 93, 392, 94, -147, -147, -147, -147, 489,
758 505, 520, 534, 547, 558, 558, 18, 18, 18, 18,
759 563, 563, 23, 23, -147, -147, -147, -147, 392, 32,
760 -147, 61, -147, -147, 110, 392, 118, -147, -147, 149,
761 -147, -147
762};
763
764/* YYPGOTO[NTERM-NUM]. */
765static const yytype_int16 yypgoto[] =
766{
767 -147, -147, -147, -147, -147, 157, -11, -147, -147, -147,
768 -146, 92, -68, 200, 0, -7, -147
769};
770
771/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
772 positive, shift that token. If negative, reduce the rule which
773 number is the opposite. If zero, do what YYDEFACT says.
774 If YYTABLE_NINF, syntax error. */
775#define YYTABLE_NINF -1
776static const yytype_uint8 yytable[] =
777{
778 77, 56, 154, 77, 70, 86, 78, 15, 120, 159,
779 17, 68, 19, 120, 20, 21, 22, 23, 24, 25,
780 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
781 36, 37, 38, 39, 117, 40, 41, 42, 43, 44,
782 45, 46, 47, 48, 49, 50, 51, 59, 60, 88,
783 89, 90, 91, 92, 93, 106, 107, 108, 109, 110,
784 111, 112, 118, 88, 110, 111, 112, 61, 62, 77,
785 59, 60, 71, 63, 77, 64, 65, 147, 155, 72,
786 79, 156, 123, 123, 129, 130, 131, 132, 133, 134,
787 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
788 145, 146, 82, 83, 84, 125, 148, 157, 114, 88,
789 126, 150, 2, 151, 152, 153, 88, 3, 4, 5,
790 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
791 16, 158, 17, 18, 19, 160, 20, 21, 22, 23,
792 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
793 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
794 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
795 161, 85, 17, 74, 19, 124, 20, 21, 22, 23,
796 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
797 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
798 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
799 81, 0, 17, 80, 19, 0, 20, 21, 22, 23,
800 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
801 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
802 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
803 0, 0, 17, 119, 19, 0, 20, 21, 22, 23,
804 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
805 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
806 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
807 0, 0, 17, 121, 19, 0, 20, 21, 22, 23,
808 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
809 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
810 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
811 0, 0, 17, 87, 19, 0, 20, 21, 22, 23,
812 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
813 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
814 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
815 0, 0, 17, 113, 19, 0, 20, 21, 22, 23,
816 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
817 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
818 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
819 0, 0, 17, 0, 19, 0, 20, 21, 22, 23,
820 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
821 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
822 43, 44, 45, 46, 47, 48, 49, 50, 51, 94,
823 0, 0, 0, 0, 95, 96, 97, 98, 99, 100,
824 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
825 111, 112, 127, 0, 0, 0, 0, 95, 96, 97,
826 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
827 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
828 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
829 110, 111, 112, 0, 0, 128, 96, 97, 98, 99,
830 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
831 110, 111, 112, 97, 98, 99, 100, 101, 102, 103,
832 104, 105, 106, 107, 108, 109, 110, 111, 112, 98,
833 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
834 109, 110, 111, 112, 99, 100, 101, 102, 103, 104,
835 105, 106, 107, 108, 109, 110, 111, 112, 100, 101,
836 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
837 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
838 111, 112, 108, 109, 110, 111, 112
839};
840
841static const yytype_int16 yycheck[] =
842{
843 7, 1, 148, 10, 4, 16, 21, 17, 76, 155,
844 20, 21, 22, 81, 24, 25, 26, 27, 28, 29,
845 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
846 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
847 50, 51, 52, 53, 54, 55, 56, 19, 20, 56,
848 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
849 42, 43, 45, 70, 41, 42, 43, 39, 40, 76,
850 19, 20, 17, 45, 81, 47, 48, 17, 46, 17,
851 21, 49, 82, 83, 95, 96, 97, 98, 99, 100,
852 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
853 111, 112, 17, 17, 17, 21, 46, 46, 45, 116,
854 21, 21, 0, 17, 21, 21, 123, 5, 6, 7,
855 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
856 18, 21, 20, 21, 22, 17, 24, 25, 26, 27,
857 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
858 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
859 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
860 21, 14, 20, 21, 22, 83, 24, 25, 26, 27,
861 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
862 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
863 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
864 10, -1, 20, 21, 22, -1, 24, 25, 26, 27,
865 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
866 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
867 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
868 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
869 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
870 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
871 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
872 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
873 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
874 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
875 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
876 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
877 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
878 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
879 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
880 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
881 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
882 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
883 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
884 -1, -1, 20, -1, 22, -1, 24, 25, 26, 27,
885 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
886 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
887 48, 49, 50, 51, 52, 53, 54, 55, 56, 21,
888 -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
889 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
890 42, 43, 21, -1, -1, -1, -1, 26, 27, 28,
891 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
892 39, 40, 41, 42, 43, 26, 27, 28, 29, 30,
893 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
894 41, 42, 43, -1, -1, 46, 27, 28, 29, 30,
895 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
896 41, 42, 43, 28, 29, 30, 31, 32, 33, 34,
897 35, 36, 37, 38, 39, 40, 41, 42, 43, 29,
898 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
899 40, 41, 42, 43, 30, 31, 32, 33, 34, 35,
900 36, 37, 38, 39, 40, 41, 42, 43, 31, 32,
901 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
902 43, 33, 34, 35, 36, 37, 38, 39, 40, 41,
903 42, 43, 39, 40, 41, 42, 43
904};
905
906/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
907 symbol of state STATE-NUM. */
908static const yytype_uint8 yystos[] =
909{
910 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
911 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
912 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
913 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
914 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
915 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
916 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
917 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
918 21, 70, 17, 17, 17, 62, 63, 21, 72, 63,
919 63, 63, 63, 63, 21, 26, 27, 28, 29, 30,
920 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
921 41, 42, 43, 21, 45, 67, 71, 17, 45, 21,
922 69, 21, 68, 71, 68, 21, 21, 21, 46, 63,
923 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
924 63, 63, 63, 63, 63, 63, 63, 17, 46, 64,
925 21, 17, 21, 21, 67, 46, 49, 46, 21, 67,
926 17, 21
927};
928
929#define yyerrok (yyerrstatus = 0)
930#define yyclearin (yychar = YYEMPTY)
931#define YYEMPTY (-2)
932#define YYEOF 0
933
934#define YYACCEPT goto yyacceptlab
935#define YYABORT goto yyabortlab
936#define YYERROR goto yyerrorlab
937
938
939/* Like YYERROR except do call yyerror. This remains here temporarily
940 to ease the transition to the new meaning of YYERROR, for GCC.
941 Once GCC version 2 has supplanted version 1, this can go. However,
942 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
943 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
944 discussed. */
945
946#define YYFAIL goto yyerrlab
947#if defined YYFAIL
948 /* This is here to suppress warnings from the GCC cpp's
949 -Wunused-macros. Normally we don't worry about that warning, but
950 some users do, and we want to make it easy for users to remove
951 YYFAIL uses, which will produce warnings from Bison 2.5. */
952#endif
953
954#define YYRECOVERING() (!!yyerrstatus)
955
956#define YYBACKUP(Token, Value) \
957do \
958 if (yychar == YYEMPTY && yylen == 1) \
959 { \
960 yychar = (Token); \
961 yylval = (Value); \
962 yytoken = YYTRANSLATE (yychar); \
963 YYPOPSTACK (1); \
964 goto yybackup; \
965 } \
966 else \
967 { \
968 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
969 YYERROR; \
970 } \
971while (YYID (0))
972
973
974#define YYTERROR 1
975#define YYERRCODE 256
976
977
978/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
979 If N is 0, then set CURRENT to the empty location which ends
980 the previous symbol: RHS[0] (always defined). */
981
982#define YYRHSLOC(Rhs, K) ((Rhs)[K])
983#ifndef YYLLOC_DEFAULT
984# define YYLLOC_DEFAULT(Current, Rhs, N) \
985 do \
986 if (YYID (N)) \
987 { \
988 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
989 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
990 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
991 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
992 } \
993 else \
994 { \
995 (Current).first_line = (Current).last_line = \
996 YYRHSLOC (Rhs, 0).last_line; \
997 (Current).first_column = (Current).last_column = \
998 YYRHSLOC (Rhs, 0).last_column; \
999 } \
1000 while (YYID (0))
1001#endif
1002
1003
1004/* YY_LOCATION_PRINT -- Print the location on the stream.
1005 This macro was not mandated originally: define only if we know
1006 we won't break user code: when these are the locations we know. */
1007
1008#ifndef YY_LOCATION_PRINT
1009# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1010# define YY_LOCATION_PRINT(File, Loc) \
1011 fprintf (File, "%d.%d-%d.%d", \
1012 (Loc).first_line, (Loc).first_column, \
1013 (Loc).last_line, (Loc).last_column)
1014# else
1015# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1016# endif
1017#endif
1018
1019
1020/* YYLEX -- calling `yylex' with the right arguments. */
1021
1022#ifdef YYLEX_PARAM
1023# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1024#else
1025# define YYLEX yylex (&yylval, &yylloc, parser)
1026#endif
1027
1028/* Enable debugging if requested. */
1029#if YYDEBUG
1030
1031# ifndef YYFPRINTF
1032# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1033# define YYFPRINTF fprintf
1034# endif
1035
1036# define YYDPRINTF(Args) \
1037do { \
1038 if (yydebug) \
1039 YYFPRINTF Args; \
1040} while (YYID (0))
1041
1042# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1043do { \
1044 if (yydebug) \
1045 { \
1046 YYFPRINTF (stderr, "%s ", Title); \
1047 yy_symbol_print (stderr, \
1048 Type, Value, Location, parser); \
1049 YYFPRINTF (stderr, "\n"); \
1050 } \
1051} while (YYID (0))
1052
1053
1054/*--------------------------------.
1055| Print this symbol on YYOUTPUT. |
1056`--------------------------------*/
1057
1058/*ARGSUSED*/
1059#if (defined __STDC__ || defined __C99__FUNC__ \
1060 || defined __cplusplus || defined _MSC_VER)
1061static void
1062yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1063#else
1064static void
1065yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1066 FILE *yyoutput;
1067 int yytype;
1068 YYSTYPE const * const yyvaluep;
1069 YYLTYPE const * const yylocationp;
1070 glcpp_parser_t *parser;
1071#endif
1072{
1073 if (!yyvaluep)
1074 return;
1075 YYUSE (yylocationp);
1076 YYUSE (parser);
1077# ifdef YYPRINT
1078 if (yytype < YYNTOKENS)
1079 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1080# else
1081 YYUSE (yyoutput);
1082# endif
1083 switch (yytype)
1084 {
1085 default:
1086 break;
1087 }
1088}
1089
1090
1091/*--------------------------------.
1092| Print this symbol on YYOUTPUT. |
1093`--------------------------------*/
1094
1095#if (defined __STDC__ || defined __C99__FUNC__ \
1096 || defined __cplusplus || defined _MSC_VER)
1097static void
1098yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1099#else
1100static void
1101yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1102 FILE *yyoutput;
1103 int yytype;
1104 YYSTYPE const * const yyvaluep;
1105 YYLTYPE const * const yylocationp;
1106 glcpp_parser_t *parser;
1107#endif
1108{
1109 if (yytype < YYNTOKENS)
1110 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1111 else
1112 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1113
1114 YY_LOCATION_PRINT (yyoutput, *yylocationp);
1115 YYFPRINTF (yyoutput, ": ");
1116 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
1117 YYFPRINTF (yyoutput, ")");
1118}
1119
1120/*------------------------------------------------------------------.
1121| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1122| TOP (included). |
1123`------------------------------------------------------------------*/
1124
1125#if (defined __STDC__ || defined __C99__FUNC__ \
1126 || defined __cplusplus || defined _MSC_VER)
1127static void
1128yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1129#else
1130static void
1131yy_stack_print (yybottom, yytop)
1132 yytype_int16 *yybottom;
1133 yytype_int16 *yytop;
1134#endif
1135{
1136 YYFPRINTF (stderr, "Stack now");
1137 for (; yybottom <= yytop; yybottom++)
1138 {
1139 int yybot = *yybottom;
1140 YYFPRINTF (stderr, " %d", yybot);
1141 }
1142 YYFPRINTF (stderr, "\n");
1143}
1144
1145# define YY_STACK_PRINT(Bottom, Top) \
1146do { \
1147 if (yydebug) \
1148 yy_stack_print ((Bottom), (Top)); \
1149} while (YYID (0))
1150
1151
1152/*------------------------------------------------.
1153| Report that the YYRULE is going to be reduced. |
1154`------------------------------------------------*/
1155
1156#if (defined __STDC__ || defined __C99__FUNC__ \
1157 || defined __cplusplus || defined _MSC_VER)
1158static void
1159yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
1160#else
1161static void
1162yy_reduce_print (yyvsp, yylsp, yyrule, parser)
1163 YYSTYPE *yyvsp;
1164 YYLTYPE *yylsp;
1165 int yyrule;
1166 glcpp_parser_t *parser;
1167#endif
1168{
1169 int yynrhs = yyr2[yyrule];
1170 int yyi;
1171 unsigned long int yylno = yyrline[yyrule];
1172 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1173 yyrule - 1, yylno);
1174 /* The symbols being reduced. */
1175 for (yyi = 0; yyi < yynrhs; yyi++)
1176 {
1177 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1178 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1179 &(yyvsp[(yyi + 1) - (yynrhs)])
1180 , &(yylsp[(yyi + 1) - (yynrhs)]) , parser);
1181 YYFPRINTF (stderr, "\n");
1182 }
1183}
1184
1185# define YY_REDUCE_PRINT(Rule) \
1186do { \
1187 if (yydebug) \
1188 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1189} while (YYID (0))
1190
1191/* Nonzero means print parse trace. It is left uninitialized so that
1192 multiple parsers can coexist. */
1193int yydebug;
1194#else /* !YYDEBUG */
1195# define YYDPRINTF(Args)
1196# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1197# define YY_STACK_PRINT(Bottom, Top)
1198# define YY_REDUCE_PRINT(Rule)
1199#endif /* !YYDEBUG */
1200
1201
1202/* YYINITDEPTH -- initial size of the parser's stacks. */
1203#ifndef YYINITDEPTH
1204# define YYINITDEPTH 200
1205#endif
1206
1207/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1208 if the built-in stack extension method is used).
1209
1210 Do not make this value too large; the results are undefined if
1211 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1212 evaluated with infinite-precision integer arithmetic. */
1213
1214#ifndef YYMAXDEPTH
1215# define YYMAXDEPTH 10000
1216#endif
1217
1218
1219
1220#if YYERROR_VERBOSE
1221
1222# ifndef yystrlen
1223# if defined __GLIBC__ && defined _STRING_H
1224# define yystrlen strlen
1225# else
1226/* Return the length of YYSTR. */
1227#if (defined __STDC__ || defined __C99__FUNC__ \
1228 || defined __cplusplus || defined _MSC_VER)
1229static YYSIZE_T
1230yystrlen (const char *yystr)
1231#else
1232static YYSIZE_T
1233yystrlen (yystr)
1234 const char *yystr;
1235#endif
1236{
1237 YYSIZE_T yylen;
1238 for (yylen = 0; yystr[yylen]; yylen++)
1239 continue;
1240 return yylen;
1241}
1242# endif
1243# endif
1244
1245# ifndef yystpcpy
1246# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1247# define yystpcpy stpcpy
1248# else
1249/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1250 YYDEST. */
1251#if (defined __STDC__ || defined __C99__FUNC__ \
1252 || defined __cplusplus || defined _MSC_VER)
1253static char *
1254yystpcpy (char *yydest, const char *yysrc)
1255#else
1256static char *
1257yystpcpy (yydest, yysrc)
1258 char *yydest;
1259 const char *yysrc;
1260#endif
1261{
1262 char *yyd = yydest;
1263 const char *yys = yysrc;
1264
1265 while ((*yyd++ = *yys++) != '\0')
1266 continue;
1267
1268 return yyd - 1;
1269}
1270# endif
1271# endif
1272
1273# ifndef yytnamerr
1274/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1275 quotes and backslashes, so that it's suitable for yyerror. The
1276 heuristic is that double-quoting is unnecessary unless the string
1277 contains an apostrophe, a comma, or backslash (other than
1278 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1279 null, do not copy; instead, return the length of what the result
1280 would have been. */
1281static YYSIZE_T
1282yytnamerr (char *yyres, const char *yystr)
1283{
1284 if (*yystr == '"')
1285 {
1286 YYSIZE_T yyn = 0;
1287 char const *yyp = yystr;
1288
1289 for (;;)
1290 switch (*++yyp)
1291 {
1292 case '\'':
1293 case ',':
1294 goto do_not_strip_quotes;
1295
1296 case '\\':
1297 if (*++yyp != '\\')
1298 goto do_not_strip_quotes;
1299 /* Fall through. */
1300 default:
1301 if (yyres)
1302 yyres[yyn] = *yyp;
1303 yyn++;
1304 break;
1305
1306 case '"':
1307 if (yyres)
1308 yyres[yyn] = '\0';
1309 return yyn;
1310 }
1311 do_not_strip_quotes: ;
1312 }
1313
1314 if (! yyres)
1315 return yystrlen (yystr);
1316
1317 return yystpcpy (yyres, yystr) - yyres;
1318}
1319# endif
1320
1321/* Copy into YYRESULT an error message about the unexpected token
1322 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1323 including the terminating null byte. If YYRESULT is null, do not
1324 copy anything; just return the number of bytes that would be
1325 copied. As a special case, return 0 if an ordinary "syntax error"
1326 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1327 size calculation. */
1328static YYSIZE_T
1329yysyntax_error (char *yyresult, int yystate, int yychar)
1330{
1331 int yyn = yypact[yystate];
1332
1333 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1334 return 0;
1335 else
1336 {
1337 int yytype = YYTRANSLATE (yychar);
1338 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1339 YYSIZE_T yysize = yysize0;
1340 YYSIZE_T yysize1;
1341 int yysize_overflow = 0;
1342 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1343 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1344 int yyx;
1345
1346# if 0
1347 /* This is so xgettext sees the translatable formats that are
1348 constructed on the fly. */
1349 YY_("syntax error, unexpected %s");
1350 YY_("syntax error, unexpected %s, expecting %s");
1351 YY_("syntax error, unexpected %s, expecting %s or %s");
1352 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1353 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1354# endif
1355 char *yyfmt;
1356 char const *yyf;
1357 static char const yyunexpected[] = "syntax error, unexpected %s";
1358 static char const yyexpecting[] = ", expecting %s";
1359 static char const yyor[] = " or %s";
1360 char yyformat[sizeof yyunexpected
1361 + sizeof yyexpecting - 1
1362 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1363 * (sizeof yyor - 1))];
1364 char const *yyprefix = yyexpecting;
1365
1366 /* Start YYX at -YYN if negative to avoid negative indexes in
1367 YYCHECK. */
1368 int yyxbegin = yyn < 0 ? -yyn : 0;
1369
1370 /* Stay within bounds of both yycheck and yytname. */
1371 int yychecklim = YYLAST - yyn + 1;
1372 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1373 int yycount = 1;
1374
1375 yyarg[0] = yytname[yytype];
1376 yyfmt = yystpcpy (yyformat, yyunexpected);
1377
1378 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1379 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1380 {
1381 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1382 {
1383 yycount = 1;
1384 yysize = yysize0;
1385 yyformat[sizeof yyunexpected - 1] = '\0';
1386 break;
1387 }
1388 yyarg[yycount++] = yytname[yyx];
1389 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1390 yysize_overflow |= (yysize1 < yysize);
1391 yysize = yysize1;
1392 yyfmt = yystpcpy (yyfmt, yyprefix);
1393 yyprefix = yyor;
1394 }
1395
1396 yyf = YY_(yyformat);
1397 yysize1 = yysize + yystrlen (yyf);
1398 yysize_overflow |= (yysize1 < yysize);
1399 yysize = yysize1;
1400
1401 if (yysize_overflow)
1402 return YYSIZE_MAXIMUM;
1403
1404 if (yyresult)
1405 {
1406 /* Avoid sprintf, as that infringes on the user's name space.
1407 Don't have undefined behavior even if the translation
1408 produced a string with the wrong number of "%s"s. */
1409 char *yyp = yyresult;
1410 int yyi = 0;
1411 while ((*yyp = *yyf) != '\0')
1412 {
1413 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1414 {
1415 yyp += yytnamerr (yyp, yyarg[yyi++]);
1416 yyf += 2;
1417 }
1418 else
1419 {
1420 yyp++;
1421 yyf++;
1422 }
1423 }
1424 }
1425 return yysize;
1426 }
1427}
1428#endif /* YYERROR_VERBOSE */
1429
1430
1431/*-----------------------------------------------.
1432| Release the memory associated to this symbol. |
1433`-----------------------------------------------*/
1434
1435/*ARGSUSED*/
1436#if (defined __STDC__ || defined __C99__FUNC__ \
1437 || defined __cplusplus || defined _MSC_VER)
1438static void
1439yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
1440#else
1441static void
1442yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
1443 const char *yymsg;
1444 int yytype;
1445 YYSTYPE *yyvaluep;
1446 YYLTYPE *yylocationp;
1447 glcpp_parser_t *parser;
1448#endif
1449{
1450 YYUSE (yyvaluep);
1451 YYUSE (yylocationp);
1452 YYUSE (parser);
1453
1454 if (!yymsg)
1455 yymsg = "Deleting";
1456 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1457
1458 switch (yytype)
1459 {
1460
1461 default:
1462 break;
1463 }
1464}
1465
1466/* Prevent warnings from -Wmissing-prototypes. */
1467#ifdef YYPARSE_PARAM
1468#if defined __STDC__ || defined __cplusplus
1469int yyparse (void *YYPARSE_PARAM);
1470#else
1471int yyparse ();
1472#endif
1473#else /* ! YYPARSE_PARAM */
1474#if defined __STDC__ || defined __cplusplus
1475int yyparse (glcpp_parser_t *parser);
1476#else
1477int yyparse ();
1478#endif
1479#endif /* ! YYPARSE_PARAM */
1480
1481
1482
1483
1484
1485/*-------------------------.
1486| yyparse or yypush_parse. |
1487`-------------------------*/
1488
1489#ifdef YYPARSE_PARAM
1490#if (defined __STDC__ || defined __C99__FUNC__ \
1491 || defined __cplusplus || defined _MSC_VER)
1492int
1493yyparse (void *YYPARSE_PARAM)
1494#else
1495int
1496yyparse (YYPARSE_PARAM)
1497 void *YYPARSE_PARAM;
1498#endif
1499#else /* ! YYPARSE_PARAM */
1500#if (defined __STDC__ || defined __C99__FUNC__ \
1501 || defined __cplusplus || defined _MSC_VER)
1502int
1503yyparse (glcpp_parser_t *parser)
1504#else
1505int
1506yyparse (parser)
1507 glcpp_parser_t *parser;
1508#endif
1509#endif
1510{
1511/* The lookahead symbol. */
1512int yychar;
1513
1514/* The semantic value of the lookahead symbol. */
1515YYSTYPE yylval;
1516
1517/* Location data for the lookahead symbol. */
1518YYLTYPE yylloc;
1519
1520 /* Number of syntax errors so far. */
1521 int yynerrs;
1522
1523 int yystate;
1524 /* Number of tokens to shift before error messages enabled. */
1525 int yyerrstatus;
1526
1527 /* The stacks and their tools:
1528 `yyss': related to states.
1529 `yyvs': related to semantic values.
1530 `yyls': related to locations.
1531
1532 Refer to the stacks thru separate pointers, to allow yyoverflow
1533 to reallocate them elsewhere. */
1534
1535 /* The state stack. */
1536 yytype_int16 yyssa[YYINITDEPTH];
1537 yytype_int16 *yyss;
1538 yytype_int16 *yyssp;
1539
1540 /* The semantic value stack. */
1541 YYSTYPE yyvsa[YYINITDEPTH];
1542 YYSTYPE *yyvs;
1543 YYSTYPE *yyvsp;
1544
1545 /* The location stack. */
1546 YYLTYPE yylsa[YYINITDEPTH];
1547 YYLTYPE *yyls;
1548 YYLTYPE *yylsp;
1549
1550 /* The locations where the error started and ended. */
1551 YYLTYPE yyerror_range[3];
1552
1553 YYSIZE_T yystacksize;
1554
1555 int yyn;
1556 int yyresult;
1557 /* Lookahead token as an internal (translated) token number. */
1558 int yytoken;
1559 /* The variables used to return semantic value and location from the
1560 action routines. */
1561 YYSTYPE yyval;
1562 YYLTYPE yyloc;
1563
1564#if YYERROR_VERBOSE
1565 /* Buffer for error messages, and its allocated size. */
1566 char yymsgbuf[128];
1567 char *yymsg = yymsgbuf;
1568 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1569#endif
1570
1571#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1572
1573 /* The number of symbols on the RHS of the reduced rule.
1574 Keep to zero when no symbol should be popped. */
1575 int yylen = 0;
1576
1577 yytoken = 0;
1578 yyss = yyssa;
1579 yyvs = yyvsa;
1580 yyls = yylsa;
1581 yystacksize = YYINITDEPTH;
1582
1583 YYDPRINTF ((stderr, "Starting parse\n"));
1584
1585 yystate = 0;
1586 yyerrstatus = 0;
1587 yynerrs = 0;
1588 yychar = YYEMPTY; /* Cause a token to be read. */
1589
1590 /* Initialize stack pointers.
1591 Waste one element of value and location stack
1592 so that they stay on the same level as the state stack.
1593 The wasted elements are never initialized. */
1594 yyssp = yyss;
1595 yyvsp = yyvs;
1596 yylsp = yyls;
1597
1598#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1599 /* Initialize the default location before parsing starts. */
1600 yylloc.first_line = yylloc.last_line = 1;
1601 yylloc.first_column = yylloc.last_column = 1;
1602#endif
1603
1604/* User initialization code. */
1605
1606/* Line 1251 of yacc.c */
1607#line 148 "glcpp/glcpp-parse.y"
1608{
1609 yylloc.first_line = 1;
1610 yylloc.first_column = 1;
1611 yylloc.last_line = 1;
1612 yylloc.last_column = 1;
1613 yylloc.source = 0;
1614}
1615
1616/* Line 1251 of yacc.c */
1617#line 1618 "glcpp/glcpp-parse.c"
1618 yylsp[0] = yylloc;
1619
1620 goto yysetstate;
1621
1622/*------------------------------------------------------------.
1623| yynewstate -- Push a new state, which is found in yystate. |
1624`------------------------------------------------------------*/
1625 yynewstate:
1626 /* In all cases, when you get here, the value and location stacks
1627 have just been pushed. So pushing a state here evens the stacks. */
1628 yyssp++;
1629
1630 yysetstate:
1631 *yyssp = yystate;
1632
1633 if (yyss + yystacksize - 1 <= yyssp)
1634 {
1635 /* Get the current used size of the three stacks, in elements. */
1636 YYSIZE_T yysize = yyssp - yyss + 1;
1637
1638#ifdef yyoverflow
1639 {
1640 /* Give user a chance to reallocate the stack. Use copies of
1641 these so that the &'s don't force the real ones into
1642 memory. */
1643 YYSTYPE *yyvs1 = yyvs;
1644 yytype_int16 *yyss1 = yyss;
1645 YYLTYPE *yyls1 = yyls;
1646
1647 /* Each stack pointer address is followed by the size of the
1648 data in use in that stack, in bytes. This used to be a
1649 conditional around just the two extra args, but that might
1650 be undefined if yyoverflow is a macro. */
1651 yyoverflow (YY_("memory exhausted"),
1652 &yyss1, yysize * sizeof (*yyssp),
1653 &yyvs1, yysize * sizeof (*yyvsp),
1654 &yyls1, yysize * sizeof (*yylsp),
1655 &yystacksize);
1656
1657 yyls = yyls1;
1658 yyss = yyss1;
1659 yyvs = yyvs1;
1660 }
1661#else /* no yyoverflow */
1662# ifndef YYSTACK_RELOCATE
1663 goto yyexhaustedlab;
1664# else
1665 /* Extend the stack our own way. */
1666 if (YYMAXDEPTH <= yystacksize)
1667 goto yyexhaustedlab;
1668 yystacksize *= 2;
1669 if (YYMAXDEPTH < yystacksize)
1670 yystacksize = YYMAXDEPTH;
1671
1672 {
1673 yytype_int16 *yyss1 = yyss;
1674 union yyalloc *yyptr =
1675 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1676 if (! yyptr)
1677 goto yyexhaustedlab;
1678 YYSTACK_RELOCATE (yyss_alloc, yyss);
1679 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1680 YYSTACK_RELOCATE (yyls_alloc, yyls);
1681# undef YYSTACK_RELOCATE
1682 if (yyss1 != yyssa)
1683 YYSTACK_FREE (yyss1);
1684 }
1685# endif
1686#endif /* no yyoverflow */
1687
1688 yyssp = yyss + yysize - 1;
1689 yyvsp = yyvs + yysize - 1;
1690 yylsp = yyls + yysize - 1;
1691
1692 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1693 (unsigned long int) yystacksize));
1694
1695 if (yyss + yystacksize - 1 <= yyssp)
1696 YYABORT;
1697 }
1698
1699 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1700
1701 if (yystate == YYFINAL)
1702 YYACCEPT;
1703
1704 goto yybackup;
1705
1706/*-----------.
1707| yybackup. |
1708`-----------*/
1709yybackup:
1710
1711 /* Do appropriate processing given the current state. Read a
1712 lookahead token if we need one and don't already have one. */
1713
1714 /* First try to decide what to do without reference to lookahead token. */
1715 yyn = yypact[yystate];
1716 if (yyn == YYPACT_NINF)
1717 goto yydefault;
1718
1719 /* Not known => get a lookahead token if don't already have one. */
1720
1721 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1722 if (yychar == YYEMPTY)
1723 {
1724 YYDPRINTF ((stderr, "Reading a token: "));
1725 yychar = YYLEX;
1726 }
1727
1728 if (yychar <= YYEOF)
1729 {
1730 yychar = yytoken = YYEOF;
1731 YYDPRINTF ((stderr, "Now at end of input.\n"));
1732 }
1733 else
1734 {
1735 yytoken = YYTRANSLATE (yychar);
1736 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1737 }
1738
1739 /* If the proper action on seeing token YYTOKEN is to reduce or to
1740 detect an error, take that action. */
1741 yyn += yytoken;
1742 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1743 goto yydefault;
1744 yyn = yytable[yyn];
1745 if (yyn <= 0)
1746 {
1747 if (yyn == 0 || yyn == YYTABLE_NINF)
1748 goto yyerrlab;
1749 yyn = -yyn;
1750 goto yyreduce;
1751 }
1752
1753 /* Count tokens shifted since error; after three, turn off error
1754 status. */
1755 if (yyerrstatus)
1756 yyerrstatus--;
1757
1758 /* Shift the lookahead token. */
1759 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1760
1761 /* Discard the shifted token. */
1762 yychar = YYEMPTY;
1763
1764 yystate = yyn;
1765 *++yyvsp = yylval;
1766 *++yylsp = yylloc;
1767 goto yynewstate;
1768
1769
1770/*-----------------------------------------------------------.
1771| yydefault -- do the default action for the current state. |
1772`-----------------------------------------------------------*/
1773yydefault:
1774 yyn = yydefact[yystate];
1775 if (yyn == 0)
1776 goto yyerrlab;
1777 goto yyreduce;
1778
1779
1780/*-----------------------------.
1781| yyreduce -- Do a reduction. |
1782`-----------------------------*/
1783yyreduce:
1784 /* yyn is the number of a rule to reduce with. */
1785 yylen = yyr2[yyn];
1786
1787 /* If YYLEN is nonzero, implement the default value of the action:
1788 `$$ = $1'.
1789
1790 Otherwise, the following line sets YYVAL to garbage.
1791 This behavior is undocumented and Bison
1792 users should not rely upon it. Assigning to YYVAL
1793 unconditionally makes the parser a bit smaller, and it avoids a
1794 GCC warning that YYVAL may be used uninitialized. */
1795 yyval = yyvsp[1-yylen];
1796
1797 /* Default location. */
1798 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1799 YY_REDUCE_PRINT (yyn);
1800 switch (yyn)
1801 {
1802 case 4:
1803
1804/* Line 1464 of yacc.c */
1805#line 187 "glcpp/glcpp-parse.y"
1806 {
1807 glcpp_print(parser->output, "\n");
1808 ;}
1809 break;
1810
1811 case 5:
1812
1813/* Line 1464 of yacc.c */
1814#line 190 "glcpp/glcpp-parse.y"
1815 {
1816 _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
1817 glcpp_print(parser->output, "\n");
1818 talloc_free ((yyvsp[(1) - (1)].token_list));
1819 ;}
1820 break;
1821
1822 case 8:
1823
1824/* Line 1464 of yacc.c */
1825#line 200 "glcpp/glcpp-parse.y"
1826 {
1827 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
1828 ;}
1829 break;
1830
1831 case 9:
1832
1833/* Line 1464 of yacc.c */
1834#line 203 "glcpp/glcpp-parse.y"
1835 {
1836 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
1837 ;}
1838 break;
1839
1840 case 10:
1841
1842/* Line 1464 of yacc.c */
1843#line 209 "glcpp/glcpp-parse.y"
1844 {
1845 _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
1846 ;}
1847 break;
1848
1849 case 11:
1850
1851/* Line 1464 of yacc.c */
1852#line 212 "glcpp/glcpp-parse.y"
1853 {
1854 _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
1855 ;}
1856 break;
1857
1858 case 12:
1859
1860/* Line 1464 of yacc.c */
1861#line 215 "glcpp/glcpp-parse.y"
1862 {
1863 _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
1864 ;}
1865 break;
1866
1867 case 13:
1868
1869/* Line 1464 of yacc.c */
1870#line 218 "glcpp/glcpp-parse.y"
1871 {
1872 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
1873 if (macro) {
1874 hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
1875 talloc_free (macro);
1876 }
1877 talloc_free ((yyvsp[(2) - (3)].str));
1878 ;}
1879 break;
1880
1881 case 14:
1882
1883/* Line 1464 of yacc.c */
1884#line 226 "glcpp/glcpp-parse.y"
1885 {
1886 /* Be careful to only evaluate the 'if' expression if
1887 * we are not skipping. When we are skipping, we
1888 * simply push a new 0-valued 'if' onto the skip
1889 * stack.
1890 *
1891 * This avoids generating diagnostics for invalid
1892 * expressions that are being skipped. */
1893 if (parser->skip_stack == NULL ||
1894 parser->skip_stack->type == SKIP_NO_SKIP)
1895 {
1896 _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list));
1897 }
1898 else
1899 {
1900 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0);
1901 parser->skip_stack->type = SKIP_TO_ENDIF;
1902 }
1903 ;}
1904 break;
1905
1906 case 15:
1907
1908/* Line 1464 of yacc.c */
1909#line 245 "glcpp/glcpp-parse.y"
1910 {
1911 /* #if without an expression is only an error if we
1912 * are not skipping */
1913 if (parser->skip_stack == NULL ||
1914 parser->skip_stack->type == SKIP_NO_SKIP)
1915 {
1916 glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression");
1917 }
1918 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0);
1919 ;}
1920 break;
1921
1922 case 16:
1923
1924/* Line 1464 of yacc.c */
1925#line 255 "glcpp/glcpp-parse.y"
1926 {
1927 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1928 talloc_free ((yyvsp[(2) - (4)].str));
1929 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
1930 ;}
1931 break;
1932
1933 case 17:
1934
1935/* Line 1464 of yacc.c */
1936#line 260 "glcpp/glcpp-parse.y"
1937 {
1938 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1939 talloc_free ((yyvsp[(2) - (4)].str));
1940 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
1941 ;}
1942 break;
1943
1944 case 18:
1945
1946/* Line 1464 of yacc.c */
1947#line 265 "glcpp/glcpp-parse.y"
1948 {
1949 /* Be careful to only evaluate the 'elif' expression
1950 * if we are not skipping. When we are skipping, we
1951 * simply change to a 0-valued 'elif' on the skip
1952 * stack.
1953 *
1954 * This avoids generating diagnostics for invalid
1955 * expressions that are being skipped. */
1956 if (parser->skip_stack &&
1957 parser->skip_stack->type == SKIP_TO_ELSE)
1958 {
1959 _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list));
1960 }
1961 else
1962 {
1963 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]),
1964 "elif", 0);
1965 }
1966 ;}
1967 break;
1968
1969 case 19:
1970
1971/* Line 1464 of yacc.c */
1972#line 284 "glcpp/glcpp-parse.y"
1973 {
1974 /* #elif without an expression is an error unless we
1975 * are skipping. */
1976 if (parser->skip_stack &&
1977 parser->skip_stack->type == SKIP_TO_ELSE)
1978 {
1979 glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression");
1980 }
1981 else
1982 {
1983 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]),
1984 "elif", 0);
1985 glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
1986 }
1987 ;}
1988 break;
1989
1990 case 20:
1991
1992/* Line 1464 of yacc.c */
1993#line 299 "glcpp/glcpp-parse.y"
1994 {
1995 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
1996 ;}
1997 break;
1998
1999 case 21:
2000
2001/* Line 1464 of yacc.c */
2002#line 302 "glcpp/glcpp-parse.y"
2003 {
2004 _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
2005 ;}
2006 break;
2007
2008 case 22:
2009
2010/* Line 1464 of yacc.c */
2011#line 305 "glcpp/glcpp-parse.y"
2012 {
2013 macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
2014 if (macro) {
2015 hash_table_remove (parser->defines, "__VERSION__");
2016 talloc_free (macro);
2017 }
2018 add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
2019 glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
2020 ;}
2021 break;
2022
2023 case 24:
2024
2025/* Line 1464 of yacc.c */
2026#line 318 "glcpp/glcpp-parse.y"
2027 {
2028 if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
2029 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
2030 } else if ((yyvsp[(1) - (1)].str)[0] == '0') {
2031 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8);
2032 } else {
2033 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10);
2034 }
2035 ;}
2036 break;
2037
2038 case 25:
2039
2040/* Line 1464 of yacc.c */
2041#line 327 "glcpp/glcpp-parse.y"
2042 {
2043 (yyval.ival) = (yyvsp[(1) - (1)].ival);
2044 ;}
2045 break;
2046
2047 case 27:
2048
2049/* Line 1464 of yacc.c */
2050#line 333 "glcpp/glcpp-parse.y"
2051 {
2052 (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
2053 ;}
2054 break;
2055
2056 case 28:
2057
2058/* Line 1464 of yacc.c */
2059#line 336 "glcpp/glcpp-parse.y"
2060 {
2061 (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
2062 ;}
2063 break;
2064
2065 case 29:
2066
2067/* Line 1464 of yacc.c */
2068#line 339 "glcpp/glcpp-parse.y"
2069 {
2070 (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
2071 ;}
2072 break;
2073
2074 case 30:
2075
2076/* Line 1464 of yacc.c */
2077#line 342 "glcpp/glcpp-parse.y"
2078 {
2079 (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
2080 ;}
2081 break;
2082
2083 case 31:
2084
2085/* Line 1464 of yacc.c */
2086#line 345 "glcpp/glcpp-parse.y"
2087 {
2088 (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
2089 ;}
2090 break;
2091
2092 case 32:
2093
2094/* Line 1464 of yacc.c */
2095#line 348 "glcpp/glcpp-parse.y"
2096 {
2097 (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
2098 ;}
2099 break;
2100
2101 case 33:
2102
2103/* Line 1464 of yacc.c */
2104#line 351 "glcpp/glcpp-parse.y"
2105 {
2106 (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
2107 ;}
2108 break;
2109
2110 case 34:
2111
2112/* Line 1464 of yacc.c */
2113#line 354 "glcpp/glcpp-parse.y"
2114 {
2115 (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
2116 ;}
2117 break;
2118
2119 case 35:
2120
2121/* Line 1464 of yacc.c */
2122#line 357 "glcpp/glcpp-parse.y"
2123 {
2124 (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
2125 ;}
2126 break;
2127
2128 case 36:
2129
2130/* Line 1464 of yacc.c */
2131#line 360 "glcpp/glcpp-parse.y"
2132 {
2133 (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
2134 ;}
2135 break;
2136
2137 case 37:
2138
2139/* Line 1464 of yacc.c */
2140#line 363 "glcpp/glcpp-parse.y"
2141 {
2142 (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
2143 ;}
2144 break;
2145
2146 case 38:
2147
2148/* Line 1464 of yacc.c */
2149#line 366 "glcpp/glcpp-parse.y"
2150 {
2151 (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
2152 ;}
2153 break;
2154
2155 case 39:
2156
2157/* Line 1464 of yacc.c */
2158#line 369 "glcpp/glcpp-parse.y"
2159 {
2160 (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
2161 ;}
2162 break;
2163
2164 case 40:
2165
2166/* Line 1464 of yacc.c */
2167#line 372 "glcpp/glcpp-parse.y"
2168 {
2169 (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
2170 ;}
2171 break;
2172
2173 case 41:
2174
2175/* Line 1464 of yacc.c */
2176#line 375 "glcpp/glcpp-parse.y"
2177 {
2178 (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
2179 ;}
2180 break;
2181
2182 case 42:
2183
2184/* Line 1464 of yacc.c */
2185#line 378 "glcpp/glcpp-parse.y"
2186 {
2187 (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
2188 ;}
2189 break;
2190
2191 case 43:
2192
2193/* Line 1464 of yacc.c */
2194#line 381 "glcpp/glcpp-parse.y"
2195 {
2196 (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
2197 ;}
2198 break;
2199
2200 case 44:
2201
2202/* Line 1464 of yacc.c */
2203#line 384 "glcpp/glcpp-parse.y"
2204 {
2205 (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
2206 ;}
2207 break;
2208
2209 case 45:
2210
2211/* Line 1464 of yacc.c */
2212#line 387 "glcpp/glcpp-parse.y"
2213 {
2214 (yyval.ival) = ! (yyvsp[(2) - (2)].ival);
2215 ;}
2216 break;
2217
2218 case 46:
2219
2220/* Line 1464 of yacc.c */
2221#line 390 "glcpp/glcpp-parse.y"
2222 {
2223 (yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
2224 ;}
2225 break;
2226
2227 case 47:
2228
2229/* Line 1464 of yacc.c */
2230#line 393 "glcpp/glcpp-parse.y"
2231 {
2232 (yyval.ival) = - (yyvsp[(2) - (2)].ival);
2233 ;}
2234 break;
2235
2236 case 48:
2237
2238/* Line 1464 of yacc.c */
2239#line 396 "glcpp/glcpp-parse.y"
2240 {
2241 (yyval.ival) = + (yyvsp[(2) - (2)].ival);
2242 ;}
2243 break;
2244
2245 case 49:
2246
2247/* Line 1464 of yacc.c */
2248#line 399 "glcpp/glcpp-parse.y"
2249 {
2250 (yyval.ival) = (yyvsp[(2) - (3)].ival);
2251 ;}
2252 break;
2253
2254 case 50:
2255
2256/* Line 1464 of yacc.c */
2257#line 405 "glcpp/glcpp-parse.y"
2258 {
2259 (yyval.string_list) = _string_list_create (parser);
2260 _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
2261 talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
2262 ;}
2263 break;
2264
2265 case 51:
2266
2267/* Line 1464 of yacc.c */
2268#line 410 "glcpp/glcpp-parse.y"
2269 {
2270 (yyval.string_list) = (yyvsp[(1) - (3)].string_list);
2271 _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
2272 talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
2273 ;}
2274 break;
2275
2276 case 52:
2277
2278/* Line 1464 of yacc.c */
2279#line 418 "glcpp/glcpp-parse.y"
2280 { (yyval.token_list) = NULL; ;}
2281 break;
2282
2283 case 54:
2284
2285/* Line 1464 of yacc.c */
2286#line 423 "glcpp/glcpp-parse.y"
2287 {
2288 yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
2289 ;}
2290 break;
2291
2292 case 55:
2293
2294/* Line 1464 of yacc.c */
2295#line 429 "glcpp/glcpp-parse.y"
2296 { (yyval.token_list) = NULL; ;}
2297 break;
2298
2299 case 58:
2300
2301/* Line 1464 of yacc.c */
2302#line 435 "glcpp/glcpp-parse.y"
2303 {
2304 glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
2305 ;}
2306 break;
2307
2308 case 59:
2309
2310/* Line 1464 of yacc.c */
2311#line 442 "glcpp/glcpp-parse.y"
2312 {
2313 int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
2314 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2315 ;}
2316 break;
2317
2318 case 60:
2319
2320/* Line 1464 of yacc.c */
2321#line 446 "glcpp/glcpp-parse.y"
2322 {
2323 int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
2324 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2325 ;}
2326 break;
2327
2328 case 62:
2329
2330/* Line 1464 of yacc.c */
2331#line 455 "glcpp/glcpp-parse.y"
2332 {
2333 parser->space_tokens = 1;
2334 (yyval.token_list) = _token_list_create (parser);
2335 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2336 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
2337 ;}
2338 break;
2339
2340 case 63:
2341
2342/* Line 1464 of yacc.c */
2343#line 461 "glcpp/glcpp-parse.y"
2344 {
2345 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2346 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2347 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2348 ;}
2349 break;
2350
2351 case 64:
2352
2353/* Line 1464 of yacc.c */
2354#line 469 "glcpp/glcpp-parse.y"
2355 {
2356 parser->space_tokens = 1;
2357 (yyval.token_list) = _token_list_create (parser);
2358 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2359 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
2360 ;}
2361 break;
2362
2363 case 65:
2364
2365/* Line 1464 of yacc.c */
2366#line 475 "glcpp/glcpp-parse.y"
2367 {
2368 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2369 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2370 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2371 ;}
2372 break;
2373
2374 case 66:
2375
2376/* Line 1464 of yacc.c */
2377#line 483 "glcpp/glcpp-parse.y"
2378 {
2379 (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
2380 (yyval.token)->location = yylloc;
2381 ;}
2382 break;
2383
2384 case 67:
2385
2386/* Line 1464 of yacc.c */
2387#line 487 "glcpp/glcpp-parse.y"
2388 {
2389 (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
2390 (yyval.token)->location = yylloc;
2391 ;}
2392 break;
2393
2394 case 68:
2395
2396/* Line 1464 of yacc.c */
2397#line 491 "glcpp/glcpp-parse.y"
2398 {
2399 (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
2400 (yyval.token)->location = yylloc;
2401 ;}
2402 break;
2403
2404 case 69:
2405
2406/* Line 1464 of yacc.c */
2407#line 495 "glcpp/glcpp-parse.y"
2408 {
2409 (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
2410 (yyval.token)->location = yylloc;
2411 ;}
2412 break;
2413
2414 case 70:
2415
2416/* Line 1464 of yacc.c */
2417#line 499 "glcpp/glcpp-parse.y"
2418 {
2419 (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2420 (yyval.token)->location = yylloc;
2421 ;}
2422 break;
2423
2424 case 71:
2425
2426/* Line 1464 of yacc.c */
2427#line 506 "glcpp/glcpp-parse.y"
2428 { (yyval.ival) = '['; ;}
2429 break;
2430
2431 case 72:
2432
2433/* Line 1464 of yacc.c */
2434#line 507 "glcpp/glcpp-parse.y"
2435 { (yyval.ival) = ']'; ;}
2436 break;
2437
2438 case 73:
2439
2440/* Line 1464 of yacc.c */
2441#line 508 "glcpp/glcpp-parse.y"
2442 { (yyval.ival) = '('; ;}
2443 break;
2444
2445 case 74:
2446
2447/* Line 1464 of yacc.c */
2448#line 509 "glcpp/glcpp-parse.y"
2449 { (yyval.ival) = ')'; ;}
2450 break;
2451
2452 case 75:
2453
2454/* Line 1464 of yacc.c */
2455#line 510 "glcpp/glcpp-parse.y"
2456 { (yyval.ival) = '{'; ;}
2457 break;
2458
2459 case 76:
2460
2461/* Line 1464 of yacc.c */
2462#line 511 "glcpp/glcpp-parse.y"
2463 { (yyval.ival) = '}'; ;}
2464 break;
2465
2466 case 77:
2467
2468/* Line 1464 of yacc.c */
2469#line 512 "glcpp/glcpp-parse.y"
2470 { (yyval.ival) = '.'; ;}
2471 break;
2472
2473 case 78:
2474
2475/* Line 1464 of yacc.c */
2476#line 513 "glcpp/glcpp-parse.y"
2477 { (yyval.ival) = '&'; ;}
2478 break;
2479
2480 case 79:
2481
2482/* Line 1464 of yacc.c */
2483#line 514 "glcpp/glcpp-parse.y"
2484 { (yyval.ival) = '*'; ;}
2485 break;
2486
2487 case 80:
2488
2489/* Line 1464 of yacc.c */
2490#line 515 "glcpp/glcpp-parse.y"
2491 { (yyval.ival) = '+'; ;}
2492 break;
2493
2494 case 81:
2495
2496/* Line 1464 of yacc.c */
2497#line 516 "glcpp/glcpp-parse.y"
2498 { (yyval.ival) = '-'; ;}
2499 break;
2500
2501 case 82:
2502
2503/* Line 1464 of yacc.c */
2504#line 517 "glcpp/glcpp-parse.y"
2505 { (yyval.ival) = '~'; ;}
2506 break;
2507
2508 case 83:
2509
2510/* Line 1464 of yacc.c */
2511#line 518 "glcpp/glcpp-parse.y"
2512 { (yyval.ival) = '!'; ;}
2513 break;
2514
2515 case 84:
2516
2517/* Line 1464 of yacc.c */
2518#line 519 "glcpp/glcpp-parse.y"
2519 { (yyval.ival) = '/'; ;}
2520 break;
2521
2522 case 85:
2523
2524/* Line 1464 of yacc.c */
2525#line 520 "glcpp/glcpp-parse.y"
2526 { (yyval.ival) = '%'; ;}
2527 break;
2528
2529 case 86:
2530
2531/* Line 1464 of yacc.c */
2532#line 521 "glcpp/glcpp-parse.y"
2533 { (yyval.ival) = LEFT_SHIFT; ;}
2534 break;
2535
2536 case 87:
2537
2538/* Line 1464 of yacc.c */
2539#line 522 "glcpp/glcpp-parse.y"
2540 { (yyval.ival) = RIGHT_SHIFT; ;}
2541 break;
2542
2543 case 88:
2544
2545/* Line 1464 of yacc.c */
2546#line 523 "glcpp/glcpp-parse.y"
2547 { (yyval.ival) = '<'; ;}
2548 break;
2549
2550 case 89:
2551
2552/* Line 1464 of yacc.c */
2553#line 524 "glcpp/glcpp-parse.y"
2554 { (yyval.ival) = '>'; ;}
2555 break;
2556
2557 case 90:
2558
2559/* Line 1464 of yacc.c */
2560#line 525 "glcpp/glcpp-parse.y"
2561 { (yyval.ival) = LESS_OR_EQUAL; ;}
2562 break;
2563
2564 case 91:
2565
2566/* Line 1464 of yacc.c */
2567#line 526 "glcpp/glcpp-parse.y"
2568 { (yyval.ival) = GREATER_OR_EQUAL; ;}
2569 break;
2570
2571 case 92:
2572
2573/* Line 1464 of yacc.c */
2574#line 527 "glcpp/glcpp-parse.y"
2575 { (yyval.ival) = EQUAL; ;}
2576 break;
2577
2578 case 93:
2579
2580/* Line 1464 of yacc.c */
2581#line 528 "glcpp/glcpp-parse.y"
2582 { (yyval.ival) = NOT_EQUAL; ;}
2583 break;
2584
2585 case 94:
2586
2587/* Line 1464 of yacc.c */
2588#line 529 "glcpp/glcpp-parse.y"
2589 { (yyval.ival) = '^'; ;}
2590 break;
2591
2592 case 95:
2593
2594/* Line 1464 of yacc.c */
2595#line 530 "glcpp/glcpp-parse.y"
2596 { (yyval.ival) = '|'; ;}
2597 break;
2598
2599 case 96:
2600
2601/* Line 1464 of yacc.c */
2602#line 531 "glcpp/glcpp-parse.y"
2603 { (yyval.ival) = AND; ;}
2604 break;
2605
2606 case 97:
2607
2608/* Line 1464 of yacc.c */
2609#line 532 "glcpp/glcpp-parse.y"
2610 { (yyval.ival) = OR; ;}
2611 break;
2612
2613 case 98:
2614
2615/* Line 1464 of yacc.c */
2616#line 533 "glcpp/glcpp-parse.y"
2617 { (yyval.ival) = ';'; ;}
2618 break;
2619
2620 case 99:
2621
2622/* Line 1464 of yacc.c */
2623#line 534 "glcpp/glcpp-parse.y"
2624 { (yyval.ival) = ','; ;}
2625 break;
2626
2627 case 100:
2628
2629/* Line 1464 of yacc.c */
2630#line 535 "glcpp/glcpp-parse.y"
2631 { (yyval.ival) = '='; ;}
2632 break;
2633
2634 case 101:
2635
2636/* Line 1464 of yacc.c */
2637#line 536 "glcpp/glcpp-parse.y"
2638 { (yyval.ival) = PASTE; ;}
2639 break;
2640
2641
2642
2643/* Line 1464 of yacc.c */
2644#line 2645 "glcpp/glcpp-parse.c"
2645 default: break;
2646 }
2647 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2648
2649 YYPOPSTACK (yylen);
2650 yylen = 0;
2651 YY_STACK_PRINT (yyss, yyssp);
2652
2653 *++yyvsp = yyval;
2654 *++yylsp = yyloc;
2655
2656 /* Now `shift' the result of the reduction. Determine what state
2657 that goes to, based on the state we popped back to and the rule
2658 number reduced by. */
2659
2660 yyn = yyr1[yyn];
2661
2662 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2663 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2664 yystate = yytable[yystate];
2665 else
2666 yystate = yydefgoto[yyn - YYNTOKENS];
2667
2668 goto yynewstate;
2669
2670
2671/*------------------------------------.
2672| yyerrlab -- here on detecting error |
2673`------------------------------------*/
2674yyerrlab:
2675 /* If not already recovering from an error, report this error. */
2676 if (!yyerrstatus)
2677 {
2678 ++yynerrs;
2679#if ! YYERROR_VERBOSE
2680 yyerror (&yylloc, parser, YY_("syntax error"));
2681#else
2682 {
2683 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2684 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2685 {
2686 YYSIZE_T yyalloc = 2 * yysize;
2687 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2688 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2689 if (yymsg != yymsgbuf)
2690 YYSTACK_FREE (yymsg);
2691 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2692 if (yymsg)
2693 yymsg_alloc = yyalloc;
2694 else
2695 {
2696 yymsg = yymsgbuf;
2697 yymsg_alloc = sizeof yymsgbuf;
2698 }
2699 }
2700
2701 if (0 < yysize && yysize <= yymsg_alloc)
2702 {
2703 (void) yysyntax_error (yymsg, yystate, yychar);
2704 yyerror (&yylloc, parser, yymsg);
2705 }
2706 else
2707 {
2708 yyerror (&yylloc, parser, YY_("syntax error"));
2709 if (yysize != 0)
2710 goto yyexhaustedlab;
2711 }
2712 }
2713#endif
2714 }
2715
2716 yyerror_range[1] = yylloc;
2717
2718 if (yyerrstatus == 3)
2719 {
2720 /* If just tried and failed to reuse lookahead token after an
2721 error, discard it. */
2722
2723 if (yychar <= YYEOF)
2724 {
2725 /* Return failure if at end of input. */
2726 if (yychar == YYEOF)
2727 YYABORT;
2728 }
2729 else
2730 {
2731 yydestruct ("Error: discarding",
2732 yytoken, &yylval, &yylloc, parser);
2733 yychar = YYEMPTY;
2734 }
2735 }
2736
2737 /* Else will try to reuse lookahead token after shifting the error
2738 token. */
2739 goto yyerrlab1;
2740
2741
2742/*---------------------------------------------------.
2743| yyerrorlab -- error raised explicitly by YYERROR. |
2744`---------------------------------------------------*/
2745yyerrorlab:
2746
2747 /* Pacify compilers like GCC when the user code never invokes
2748 YYERROR and the label yyerrorlab therefore never appears in user
2749 code. */
2750 if (/*CONSTCOND*/ 0)
2751 goto yyerrorlab;
2752
2753 yyerror_range[1] = yylsp[1-yylen];
2754 /* Do not reclaim the symbols of the rule which action triggered
2755 this YYERROR. */
2756 YYPOPSTACK (yylen);
2757 yylen = 0;
2758 YY_STACK_PRINT (yyss, yyssp);
2759 yystate = *yyssp;
2760 goto yyerrlab1;
2761
2762
2763/*-------------------------------------------------------------.
2764| yyerrlab1 -- common code for both syntax error and YYERROR. |
2765`-------------------------------------------------------------*/
2766yyerrlab1:
2767 yyerrstatus = 3; /* Each real token shifted decrements this. */
2768
2769 for (;;)
2770 {
2771 yyn = yypact[yystate];
2772 if (yyn != YYPACT_NINF)
2773 {
2774 yyn += YYTERROR;
2775 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2776 {
2777 yyn = yytable[yyn];
2778 if (0 < yyn)
2779 break;
2780 }
2781 }
2782
2783 /* Pop the current state because it cannot handle the error token. */
2784 if (yyssp == yyss)
2785 YYABORT;
2786
2787 yyerror_range[1] = *yylsp;
2788 yydestruct ("Error: popping",
2789 yystos[yystate], yyvsp, yylsp, parser);
2790 YYPOPSTACK (1);
2791 yystate = *yyssp;
2792 YY_STACK_PRINT (yyss, yyssp);
2793 }
2794
2795 *++yyvsp = yylval;
2796
2797 yyerror_range[2] = yylloc;
2798 /* Using YYLLOC is tempting, but would change the location of
2799 the lookahead. YYLOC is available though. */
2800 YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
2801 *++yylsp = yyloc;
2802
2803 /* Shift the error token. */
2804 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2805
2806 yystate = yyn;
2807 goto yynewstate;
2808
2809
2810/*-------------------------------------.
2811| yyacceptlab -- YYACCEPT comes here. |
2812`-------------------------------------*/
2813yyacceptlab:
2814 yyresult = 0;
2815 goto yyreturn;
2816
2817/*-----------------------------------.
2818| yyabortlab -- YYABORT comes here. |
2819`-----------------------------------*/
2820yyabortlab:
2821 yyresult = 1;
2822 goto yyreturn;
2823
2824#if !defined(yyoverflow) || YYERROR_VERBOSE
2825/*-------------------------------------------------.
2826| yyexhaustedlab -- memory exhaustion comes here. |
2827`-------------------------------------------------*/
2828yyexhaustedlab:
2829 yyerror (&yylloc, parser, YY_("memory exhausted"));
2830 yyresult = 2;
2831 /* Fall through. */
2832#endif
2833
2834yyreturn:
2835 if (yychar != YYEMPTY)
2836 yydestruct ("Cleanup: discarding lookahead",
2837 yytoken, &yylval, &yylloc, parser);
2838 /* Do not reclaim the symbols of the rule which action triggered
2839 this YYABORT or YYACCEPT. */
2840 YYPOPSTACK (yylen);
2841 YY_STACK_PRINT (yyss, yyssp);
2842 while (yyssp != yyss)
2843 {
2844 yydestruct ("Cleanup: popping",
2845 yystos[*yyssp], yyvsp, yylsp, parser);
2846 YYPOPSTACK (1);
2847 }
2848#ifndef yyoverflow
2849 if (yyss != yyssa)
2850 YYSTACK_FREE (yyss);
2851#endif
2852#if YYERROR_VERBOSE
2853 if (yymsg != yymsgbuf)
2854 YYSTACK_FREE (yymsg);
2855#endif
2856 /* Make sure YYID is used. */
2857 return YYID (yyresult);
2858}
2859
2860
2861
2862/* Line 1684 of yacc.c */
2863#line 539 "glcpp/glcpp-parse.y"
2864
2865
2866string_list_t *
2867_string_list_create (void *ctx)
2868{
2869 string_list_t *list;
2870
2871 list = talloc (ctx, string_list_t);
2872 list->head = NULL;
2873 list->tail = NULL;
2874
2875 return list;
2876}
2877
2878void
2879_string_list_append_item (string_list_t *list, const char *str)
2880{
2881 string_node_t *node;
2882
2883 node = talloc (list, string_node_t);
2884 node->str = talloc_strdup (node, str);
2885
2886 node->next = NULL;
2887
2888 if (list->head == NULL) {
2889 list->head = node;
2890 } else {
2891 list->tail->next = node;
2892 }
2893
2894 list->tail = node;
2895}
2896
2897int
2898_string_list_contains (string_list_t *list, const char *member, int *index)
2899{
2900 string_node_t *node;
2901 int i;
2902
2903 if (list == NULL)
2904 return 0;
2905
2906 for (i = 0, node = list->head; node; i++, node = node->next) {
2907 if (strcmp (node->str, member) == 0) {
2908 if (index)
2909 *index = i;
2910 return 1;
2911 }
2912 }
2913
2914 return 0;
2915}
2916
2917int
2918_string_list_length (string_list_t *list)
2919{
2920 int length = 0;
2921 string_node_t *node;
2922
2923 if (list == NULL)
2924 return 0;
2925
2926 for (node = list->head; node; node = node->next)
2927 length++;
2928
2929 return length;
2930}
2931
2932argument_list_t *
2933_argument_list_create (void *ctx)
2934{
2935 argument_list_t *list;
2936
2937 list = talloc (ctx, argument_list_t);
2938 list->head = NULL;
2939 list->tail = NULL;
2940
2941 return list;
2942}
2943
2944void
2945_argument_list_append (argument_list_t *list, token_list_t *argument)
2946{
2947 argument_node_t *node;
2948
2949 node = talloc (list, argument_node_t);
2950 node->argument = argument;
2951
2952 node->next = NULL;
2953
2954 if (list->head == NULL) {
2955 list->head = node;
2956 } else {
2957 list->tail->next = node;
2958 }
2959
2960 list->tail = node;
2961}
2962
2963int
2964_argument_list_length (argument_list_t *list)
2965{
2966 int length = 0;
2967 argument_node_t *node;
2968
2969 if (list == NULL)
2970 return 0;
2971
2972 for (node = list->head; node; node = node->next)
2973 length++;
2974
2975 return length;
2976}
2977
2978token_list_t *
2979_argument_list_member_at (argument_list_t *list, int index)
2980{
2981 argument_node_t *node;
2982 int i;
2983
2984 if (list == NULL)
2985 return NULL;
2986
2987 node = list->head;
2988 for (i = 0; i < index; i++) {
2989 node = node->next;
2990 if (node == NULL)
2991 break;
2992 }
2993
2994 if (node)
2995 return node->argument;
2996
2997 return NULL;
2998}
2999
3000/* Note: This function talloc_steal()s the str pointer. */
3001token_t *
3002_token_create_str (void *ctx, int type, char *str)
3003{
3004 token_t *token;
3005
3006 token = talloc (ctx, token_t);
3007 token->type = type;
3008 token->value.str = talloc_steal (token, str);
3009
3010 return token;
3011}
3012
3013token_t *
3014_token_create_ival (void *ctx, int type, int ival)
3015{
3016 token_t *token;
3017
3018 token = talloc (ctx, token_t);
3019 token->type = type;
3020 token->value.ival = ival;
3021
3022 return token;
3023}
3024
3025token_list_t *
3026_token_list_create (void *ctx)
3027{
3028 token_list_t *list;
3029
3030 list = talloc (ctx, token_list_t);
3031 list->head = NULL;
3032 list->tail = NULL;
3033 list->non_space_tail = NULL;
3034
3035 return list;
3036}
3037
3038void
3039_token_list_append (token_list_t *list, token_t *token)
3040{
3041 token_node_t *node;
3042
3043 node = talloc (list, token_node_t);
3044 node->token = talloc_reference (list, token);
3045
3046 node->next = NULL;
3047
3048 if (list->head == NULL) {
3049 list->head = node;
3050 } else {
3051 list->tail->next = node;
3052 }
3053
3054 list->tail = node;
3055 if (token->type != SPACE)
3056 list->non_space_tail = node;
3057}
3058
3059void
3060_token_list_append_list (token_list_t *list, token_list_t *tail)
3061{
3062 if (tail == NULL || tail->head == NULL)
3063 return;
3064
3065 if (list->head == NULL) {
3066 list->head = tail->head;
3067 } else {
3068 list->tail->next = tail->head;
3069 }
3070
3071 list->tail = tail->tail;
3072 list->non_space_tail = tail->non_space_tail;
3073}
3074
3075static token_list_t *
3076_token_list_copy (void *ctx, token_list_t *other)
3077{
3078 token_list_t *copy;
3079 token_node_t *node;
3080
3081 if (other == NULL)
3082 return NULL;
3083
3084 copy = _token_list_create (ctx);
3085 for (node = other->head; node; node = node->next)
3086 _token_list_append (copy, node->token);
3087
3088 return copy;
3089}
3090
3091static void
3092_token_list_trim_trailing_space (token_list_t *list)
3093{
3094 token_node_t *tail, *next;
3095
3096 if (list->non_space_tail) {
3097 tail = list->non_space_tail->next;
3098 list->non_space_tail->next = NULL;
3099 list->tail = list->non_space_tail;
3100
3101 while (tail) {
3102 next = tail->next;
3103 talloc_free (tail);
3104 tail = next;
3105 }
3106 }
3107}
3108
3109static void
3110_token_print (char **out, token_t *token)
3111{
3112 if (token->type < 256) {
3113 glcpp_printf (*out, "%c", token->type);
3114 return;
3115 }
3116
3117 switch (token->type) {
3118 case INTEGER:
3119 glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
3120 break;
3121 case IDENTIFIER:
3122 case INTEGER_STRING:
3123 case OTHER:
3124 glcpp_print (*out, token->value.str);
3125 break;
3126 case SPACE:
3127 glcpp_print (*out, " ");
3128 break;
3129 case LEFT_SHIFT:
3130 glcpp_print (*out, "<<");
3131 break;
3132 case RIGHT_SHIFT:
3133 glcpp_print (*out, ">>");
3134 break;
3135 case LESS_OR_EQUAL:
3136 glcpp_print (*out, "<=");
3137 break;
3138 case GREATER_OR_EQUAL:
3139 glcpp_print (*out, ">=");
3140 break;
3141 case EQUAL:
3142 glcpp_print (*out, "==");
3143 break;
3144 case NOT_EQUAL:
3145 glcpp_print (*out, "!=");
3146 break;
3147 case AND:
3148 glcpp_print (*out, "&&");
3149 break;
3150 case OR:
3151 glcpp_print (*out, "||");
3152 break;
3153 case PASTE:
3154 glcpp_print (*out, "##");
3155 break;
3156 case COMMA_FINAL:
3157 glcpp_print (*out, ",");
3158 break;
3159 case PLACEHOLDER:
3160 /* Nothing to print. */
3161 break;
3162 default:
3163 assert(!"Error: Don't know how to print token.");
3164 break;
3165 }
3166}
3167
3168/* Return a new token (talloc()ed off of 'token') formed by pasting
3169 * 'token' and 'other'. Note that this function may return 'token' or
3170 * 'other' directly rather than allocating anything new.
3171 *
3172 * Caution: Only very cursory error-checking is performed to see if
3173 * the final result is a valid single token. */
3174static token_t *
3175_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3176{
3177 token_t *combined = NULL;
3178
3179 /* Pasting a placeholder onto anything makes no change. */
3180 if (other->type == PLACEHOLDER)
3181 return token;
3182
3183 /* When 'token' is a placeholder, just return 'other'. */
3184 if (token->type == PLACEHOLDER)
3185 return other;
3186
3187 /* A very few single-character punctuators can be combined
3188 * with another to form a multi-character punctuator. */
3189 switch (token->type) {
3190 case '<':
3191 if (other->type == '<')
3192 combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
3193 else if (other->type == '=')
3194 combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
3195 break;
3196 case '>':
3197 if (other->type == '>')
3198 combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
3199 else if (other->type == '=')
3200 combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
3201 break;
3202 case '=':
3203 if (other->type == '=')
3204 combined = _token_create_ival (token, EQUAL, EQUAL);
3205 break;
3206 case '!':
3207 if (other->type == '=')
3208 combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
3209 break;
3210 case '&':
3211 if (other->type == '&')
3212 combined = _token_create_ival (token, AND, AND);
3213 break;
3214 case '|':
3215 if (other->type == '|')
3216 combined = _token_create_ival (token, OR, OR);
3217 break;
3218 }
3219
3220 if (combined != NULL) {
3221 /* Inherit the location from the first token */
3222 combined->location = token->location;
3223 return combined;
3224 }
3225
3226 /* Two string-valued tokens can usually just be mashed
3227 * together.
3228 *
3229 * XXX: This isn't actually legitimate. Several things here
3230 * should result in a diagnostic since the result cannot be a
3231 * valid, single pre-processing token. For example, pasting
3232 * "123" and "abc" is not legal, but we don't catch that
3233 * here. */
3234 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
3235 (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
3236 {
3237 char *str;
3238
3239 str = talloc_asprintf (token, "%s%s", token->value.str,
3240 other->value.str);
3241 combined = _token_create_str (token, token->type, str);
3242 combined->location = token->location;
3243 return combined;
3244 }
3245
3246 glcpp_error (&token->location, parser, "");
3247 glcpp_print (parser->info_log, "Pasting \"");
3248 _token_print (&parser->info_log, token);
3249 glcpp_print (parser->info_log, "\" and \"");
3250 _token_print (&parser->info_log, other);
3251 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
3252
3253 return token;
3254}
3255
3256static void
3257_token_list_print (glcpp_parser_t *parser, token_list_t *list)
3258{
3259 token_node_t *node;
3260
3261 if (list == NULL)
3262 return;
3263
3264 for (node = list->head; node; node = node->next)
3265 _token_print (&parser->output, node->token);
3266}
3267
3268void
3269yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
3270{
3271 glcpp_error(locp, parser, "%s", error);
3272}
3273
3274static void add_builtin_define(glcpp_parser_t *parser,
3275 const char *name, int value)
3276{
3277 token_t *tok;
3278 token_list_t *list;
3279
3280 tok = _token_create_ival (parser, INTEGER, value);
3281
3282 list = _token_list_create(parser);
3283 _token_list_append(list, tok);
3284 _define_object_macro(parser, NULL, name, list);
3285
3286 talloc_unlink(parser, tok);
3287}
3288
3289glcpp_parser_t *
3290glcpp_parser_create (const struct gl_extensions *extensions)
3291{
3292 glcpp_parser_t *parser;
3293 int language_version;
3294
3295 parser = talloc (NULL, glcpp_parser_t);
3296
3297 glcpp_lex_init_extra (parser, &parser->scanner);
3298 parser->defines = hash_table_ctor (32, hash_table_string_hash,
3299 hash_table_string_compare);
3300 parser->active = NULL;
3301 parser->lexing_if = 0;
3302 parser->space_tokens = 1;
3303 parser->newline_as_space = 0;
3304 parser->in_control_line = 0;
3305 parser->paren_count = 0;
3306
3307 parser->skip_stack = NULL;
3308
3309 parser->lex_from_list = NULL;
3310 parser->lex_from_node = NULL;
3311
3312 parser->output = talloc_strdup(parser, "");
3313 parser->info_log = talloc_strdup(parser, "");
3314 parser->error = 0;
3315
3316 /* Add pre-defined macros. */
3317 add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
3318 add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
3319
3320 if (extensions != NULL) {
3321 if (extensions->EXT_texture_array) {
3322 add_builtin_define(parser, "GL_EXT_texture_array", 1);
3323 }
3324
3325 if (extensions->ARB_fragment_coord_conventions)
3326 add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
3327 1);
3328 }
3329
3330 language_version = 110;
3331 add_builtin_define(parser, "__VERSION__", language_version);
3332
3333 return parser;
3334}
3335
3336int
3337glcpp_parser_parse (glcpp_parser_t *parser)
3338{
3339 return yyparse (parser);
3340}
3341
3342void
3343glcpp_parser_destroy (glcpp_parser_t *parser)
3344{
3345 glcpp_lex_destroy (parser->scanner);
3346 hash_table_dtor (parser->defines);
3347 talloc_free (parser);
3348}
3349
3350typedef enum function_status
3351{
3352 FUNCTION_STATUS_SUCCESS,
3353 FUNCTION_NOT_A_FUNCTION,
3354 FUNCTION_UNBALANCED_PARENTHESES
3355} function_status_t;
3356
3357/* Find a set of function-like macro arguments by looking for a
3358 * balanced set of parentheses.
3359 *
3360 * When called, 'node' should be the opening-parenthesis token, (or
3361 * perhaps preceeding SPACE tokens). Upon successful return *last will
3362 * be the last consumed node, (corresponding to the closing right
3363 * parenthesis).
3364 *
3365 * Return values:
3366 *
3367 * FUNCTION_STATUS_SUCCESS:
3368 *
3369 * Successfully parsed a set of function arguments.
3370 *
3371 * FUNCTION_NOT_A_FUNCTION:
3372 *
3373 * Macro name not followed by a '('. This is not an error, but
3374 * simply that the macro name should be treated as a non-macro.
3375 *
3376 * FUNCTION_UNBALANCED_PARENTHESES
3377 *
3378 * Macro name is not followed by a balanced set of parentheses.
3379 */
3380static function_status_t
3381_arguments_parse (argument_list_t *arguments,
3382 token_node_t *node,
3383 token_node_t **last)
3384{
3385 token_list_t *argument;
3386 int paren_count;
3387
3388 node = node->next;
3389
3390 /* Ignore whitespace before first parenthesis. */
3391 while (node && node->token->type == SPACE)
3392 node = node->next;
3393
3394 if (node == NULL || node->token->type != '(')
3395 return FUNCTION_NOT_A_FUNCTION;
3396
3397 node = node->next;
3398
3399 argument = _token_list_create (arguments);
3400 _argument_list_append (arguments, argument);
3401
3402 for (paren_count = 1; node; node = node->next) {
3403 if (node->token->type == '(')
3404 {
3405 paren_count++;
3406 }
3407 else if (node->token->type == ')')
3408 {
3409 paren_count--;
3410 if (paren_count == 0)
3411 break;
3412 }
3413
3414 if (node->token->type == ',' &&
3415 paren_count == 1)
3416 {
3417 _token_list_trim_trailing_space (argument);
3418 argument = _token_list_create (arguments);
3419 _argument_list_append (arguments, argument);
3420 }
3421 else {
3422 if (argument->head == NULL) {
3423 /* Don't treat initial whitespace as
3424 * part of the arguement. */
3425 if (node->token->type == SPACE)
3426 continue;
3427 }
3428 _token_list_append (argument, node->token);
3429 }
3430 }
3431
3432 if (paren_count)
3433 return FUNCTION_UNBALANCED_PARENTHESES;
3434
3435 *last = node;
3436
3437 return FUNCTION_STATUS_SUCCESS;
3438}
3439
3440static token_list_t *
3441_token_list_create_with_one_space (void *ctx)
3442{
3443 token_list_t *list;
3444 token_t *space;
3445
3446 list = _token_list_create (ctx);
3447 space = _token_create_ival (list, SPACE, SPACE);
3448 _token_list_append (list, space);
3449
3450 return list;
3451}
3452
3453static void
3454_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list)
3455{
3456 token_list_t *expanded;
3457 token_t *token;
3458
3459 expanded = _token_list_create (parser);
3460 token = _token_create_ival (parser, type, type);
3461 _token_list_append (expanded, token);
3462 _glcpp_parser_expand_token_list (parser, list);
3463 _token_list_append_list (expanded, list);
3464 glcpp_parser_lex_from (parser, expanded);
3465}
3466
3467/* This is a helper function that's essentially part of the
3468 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3469 * except for by that function.
3470 *
3471 * Returns NULL if node is a simple token with no expansion, (that is,
3472 * although 'node' corresponds to an identifier defined as a
3473 * function-like macro, it is not followed with a parenthesized
3474 * argument list).
3475 *
3476 * Compute the complete expansion of node (which is a function-like
3477 * macro) and subsequent nodes which are arguments.
3478 *
3479 * Returns the token list that results from the expansion and sets
3480 * *last to the last node in the list that was consumed by the
3481 * expansion. Specifically, *last will be set as follows: as the
3482 * token of the closing right parenthesis.
3483 */
3484static token_list_t *
3485_glcpp_parser_expand_function (glcpp_parser_t *parser,
3486 token_node_t *node,
3487 token_node_t **last)
3488
3489{
3490 macro_t *macro;
3491 const char *identifier;
3492 argument_list_t *arguments;
3493 function_status_t status;
3494 token_list_t *substituted;
3495 int parameter_index;
3496
3497 identifier = node->token->value.str;
3498
3499 macro = hash_table_find (parser->defines, identifier);
3500
3501 assert (macro->is_function);
3502
3503 arguments = _argument_list_create (parser);
3504 status = _arguments_parse (arguments, node, last);
3505
3506 switch (status) {
3507 case FUNCTION_STATUS_SUCCESS:
3508 break;
3509 case FUNCTION_NOT_A_FUNCTION:
3510 return NULL;
3511 case FUNCTION_UNBALANCED_PARENTHESES:
3512 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3513 return NULL;
3514 }
3515
3516 /* Replace a macro defined as empty with a SPACE token. */
3517 if (macro->replacements == NULL) {
3518 talloc_free (arguments);
3519 return _token_list_create_with_one_space (parser);
3520 }
3521
3522 if (! ((_argument_list_length (arguments) ==
3523 _string_list_length (macro->parameters)) ||
3524 (_string_list_length (macro->parameters) == 0 &&
3525 _argument_list_length (arguments) == 1 &&
3526 arguments->head->argument->head == NULL)))
3527 {
3528 glcpp_error (&node->token->location, parser,
3529 "Error: macro %s invoked with %d arguments (expected %d)\n",
3530 identifier,
3531 _argument_list_length (arguments),
3532 _string_list_length (macro->parameters));
3533 return NULL;
3534 }
3535
3536 /* Perform argument substitution on the replacement list. */
3537 substituted = _token_list_create (arguments);
3538
3539 for (node = macro->replacements->head; node; node = node->next)
3540 {
3541 if (node->token->type == IDENTIFIER &&
3542 _string_list_contains (macro->parameters,
3543 node->token->value.str,
3544 &parameter_index))
3545 {
3546 token_list_t *argument;
3547 argument = _argument_list_member_at (arguments,
3548 parameter_index);
3549 /* Before substituting, we expand the argument
3550 * tokens, or append a placeholder token for
3551 * an empty argument. */
3552 if (argument->head) {
3553 token_list_t *expanded_argument;
3554 expanded_argument = _token_list_copy (parser,
3555 argument);
3556 _glcpp_parser_expand_token_list (parser,
3557 expanded_argument);
3558 _token_list_append_list (substituted,
3559 expanded_argument);
3560 } else {
3561 token_t *new_token;
3562
3563 new_token = _token_create_ival (substituted,
3564 PLACEHOLDER,
3565 PLACEHOLDER);
3566 _token_list_append (substituted, new_token);
3567 }
3568 } else {
3569 _token_list_append (substituted, node->token);
3570 }
3571 }
3572
3573 /* After argument substitution, and before further expansion
3574 * below, implement token pasting. */
3575
3576 _token_list_trim_trailing_space (substituted);
3577
3578 node = substituted->head;
3579 while (node)
3580 {
3581 token_node_t *next_non_space;
3582
3583 /* Look ahead for a PASTE token, skipping space. */
3584 next_non_space = node->next;
3585 while (next_non_space && next_non_space->token->type == SPACE)
3586 next_non_space = next_non_space->next;
3587
3588 if (next_non_space == NULL)
3589 break;
3590
3591 if (next_non_space->token->type != PASTE) {
3592 node = next_non_space;
3593 continue;
3594 }
3595
3596 /* Now find the next non-space token after the PASTE. */
3597 next_non_space = next_non_space->next;
3598 while (next_non_space && next_non_space->token->type == SPACE)
3599 next_non_space = next_non_space->next;
3600
3601 if (next_non_space == NULL) {
3602 yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
3603 return NULL;
3604 }
3605
3606 node->token = _token_paste (parser, node->token, next_non_space->token);
3607 node->next = next_non_space->next;
3608 if (next_non_space == substituted->tail)
3609 substituted->tail = node;
3610
3611 node = node->next;
3612 }
3613
3614 substituted->non_space_tail = substituted->tail;
3615
3616 return substituted;
3617}
3618
3619/* Compute the complete expansion of node, (and subsequent nodes after
3620 * 'node' in the case that 'node' is a function-like macro and
3621 * subsequent nodes are arguments).
3622 *
3623 * Returns NULL if node is a simple token with no expansion.
3624 *
3625 * Otherwise, returns the token list that results from the expansion
3626 * and sets *last to the last node in the list that was consumed by
3627 * the expansion. Specifically, *last will be set as follows:
3628 *
3629 * As 'node' in the case of object-like macro expansion.
3630 *
3631 * As the token of the closing right parenthesis in the case of
3632 * function-like macro expansion.
3633 */
3634static token_list_t *
3635_glcpp_parser_expand_node (glcpp_parser_t *parser,
3636 token_node_t *node,
3637 token_node_t **last)
3638{
3639 token_t *token = node->token;
3640 const char *identifier;
3641 macro_t *macro;
3642
3643 /* We only expand identifiers */
3644 if (token->type != IDENTIFIER) {
3645 /* We change any COMMA into a COMMA_FINAL to prevent
3646 * it being mistaken for an argument separator
3647 * later. */
3648 if (token->type == ',') {
3649 token->type = COMMA_FINAL;
3650 token->value.ival = COMMA_FINAL;
3651 }
3652
3653 return NULL;
3654 }
3655
3656 /* Look up this identifier in the hash table. */
3657 identifier = token->value.str;
3658 macro = hash_table_find (parser->defines, identifier);
3659
3660 /* Not a macro, so no expansion needed. */
3661 if (macro == NULL)
3662 return NULL;
3663
3664 /* Finally, don't expand this macro if we're already actively
3665 * expanding it, (to avoid infinite recursion). */
3666 if (_active_list_contains (parser->active, identifier)) {
3667 /* We change the token type here from IDENTIFIER to
3668 * OTHER to prevent any future expansion of this
3669 * unexpanded token. */
3670 char *str;
3671 token_list_t *expansion;
3672 token_t *final;
3673
3674 str = talloc_strdup (parser, token->value.str);
3675 final = _token_create_str (parser, OTHER, str);
3676 expansion = _token_list_create (parser);
3677 _token_list_append (expansion, final);
3678 *last = node;
3679 return expansion;
3680 }
3681
3682 if (! macro->is_function)
3683 {
3684 *last = node;
3685
3686 /* Replace a macro defined as empty with a SPACE token. */
3687 if (macro->replacements == NULL)
3688 return _token_list_create_with_one_space (parser);
3689
3690 return _token_list_copy (parser, macro->replacements);
3691 }
3692
3693 return _glcpp_parser_expand_function (parser, node, last);
3694}
3695
3696/* Push a new identifier onto the active list, returning the new list.
3697 *
3698 * Here, 'marker' is the token node that appears in the list after the
3699 * expansion of 'identifier'. That is, when the list iterator begins
3700 * examinging 'marker', then it is time to pop this node from the
3701 * active stack.
3702 */
3703active_list_t *
3704_active_list_push (active_list_t *list,
3705 const char *identifier,
3706 token_node_t *marker)
3707{
3708 active_list_t *node;
3709
3710 node = talloc (list, active_list_t);
3711 node->identifier = talloc_strdup (node, identifier);
3712 node->marker = marker;
3713 node->next = list;
3714
3715 return node;
3716}
3717
3718active_list_t *
3719_active_list_pop (active_list_t *list)
3720{
3721 active_list_t *node = list;
3722
3723 if (node == NULL)
3724 return NULL;
3725
3726 node = list->next;
3727 talloc_free (list);
3728
3729 return node;
3730}
3731
3732int
3733_active_list_contains (active_list_t *list, const char *identifier)
3734{
3735 active_list_t *node;
3736
3737 if (list == NULL)
3738 return 0;
3739
3740 for (node = list; node; node = node->next)
3741 if (strcmp (node->identifier, identifier) == 0)
3742 return 1;
3743
3744 return 0;
3745}
3746
3747/* Walk over the token list replacing nodes with their expansion.
3748 * Whenever nodes are expanded the walking will walk over the new
3749 * nodes, continuing to expand as necessary. The results are placed in
3750 * 'list' itself;
3751 */
3752static void
3753_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
3754 token_list_t *list)
3755{
3756 token_node_t *node_prev;
3757 token_node_t *node, *last = NULL;
3758 token_list_t *expansion;
3759
3760 if (list == NULL)
3761 return;
3762
3763 _token_list_trim_trailing_space (list);
3764
3765 node_prev = NULL;
3766 node = list->head;
3767
3768 while (node) {
3769
3770 while (parser->active && parser->active->marker == node)
3771 parser->active = _active_list_pop (parser->active);
3772
3773 /* Find the expansion for node, which will replace all
3774 * nodes from node to last, inclusive. */
3775 expansion = _glcpp_parser_expand_node (parser, node, &last);
3776 if (expansion) {
3777 token_node_t *n;
3778
3779 for (n = node; n != last->next; n = n->next)
3780 while (parser->active &&
3781 parser->active->marker == n)
3782 {
3783 parser->active = _active_list_pop (parser->active);
3784 }
3785
3786 parser->active = _active_list_push (parser->active,
3787 node->token->value.str,
3788 last->next);
3789
3790 /* Splice expansion into list, supporting a
3791 * simple deletion if the expansion is
3792 * empty. */
3793 if (expansion->head) {
3794 if (node_prev)
3795 node_prev->next = expansion->head;
3796 else
3797 list->head = expansion->head;
3798 expansion->tail->next = last->next;
3799 if (last == list->tail)
3800 list->tail = expansion->tail;
3801 } else {
3802 if (node_prev)
3803 node_prev->next = last->next;
3804 else
3805 list->head = last->next;
3806 if (last == list->tail)
3807 list->tail = NULL;
3808 }
3809 } else {
3810 node_prev = node;
3811 }
3812 node = node_prev ? node_prev->next : list->head;
3813 }
3814
3815 while (parser->active)
3816 parser->active = _active_list_pop (parser->active);
3817
3818 list->non_space_tail = list->tail;
3819}
3820
3821void
3822_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
3823 token_list_t *list)
3824{
3825 if (list == NULL)
3826 return;
3827
3828 _glcpp_parser_expand_token_list (parser, list);
3829
3830 _token_list_trim_trailing_space (list);
3831
3832 _token_list_print (parser, list);
3833}
3834
3835static void
3836_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
3837 const char *identifier)
3838{
3839 /* According to the GLSL specification, macro names starting with "__"
3840 * or "GL_" are reserved for future use. So, don't allow them.
3841 */
3842 if (strncmp(identifier, "__", 2) == 0) {
3843 glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
3844 }
3845 if (strncmp(identifier, "GL_", 3) == 0) {
3846 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
3847 }
3848}
3849
3850void
3851_define_object_macro (glcpp_parser_t *parser,
3852 YYLTYPE *loc,
3853 const char *identifier,
3854 token_list_t *replacements)
3855{
3856 macro_t *macro;
3857
3858 if (loc != NULL)
3859 _check_for_reserved_macro_name(parser, loc, identifier);
3860
3861 macro = talloc (parser, macro_t);
3862
3863 macro->is_function = 0;
3864 macro->parameters = NULL;
3865 macro->identifier = talloc_strdup (macro, identifier);
3866 macro->replacements = talloc_steal (macro, replacements);
3867
3868 hash_table_insert (parser->defines, macro, identifier);
3869}
3870
3871void
3872_define_function_macro (glcpp_parser_t *parser,
3873 YYLTYPE *loc,
3874 const char *identifier,
3875 string_list_t *parameters,
3876 token_list_t *replacements)
3877{
3878 macro_t *macro;
3879
3880 _check_for_reserved_macro_name(parser, loc, identifier);
3881
3882 macro = talloc (parser, macro_t);
3883
3884 macro->is_function = 1;
3885 macro->parameters = talloc_steal (macro, parameters);
3886 macro->identifier = talloc_strdup (macro, identifier);
3887 macro->replacements = talloc_steal (macro, replacements);
3888
3889 hash_table_insert (parser->defines, macro, identifier);
3890}
3891
3892static int
3893glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
3894{
3895 token_node_t *node;
3896 int ret;
3897
3898 if (parser->lex_from_list == NULL) {
3899 ret = glcpp_lex (yylval, yylloc, parser->scanner);
3900
3901 /* XXX: This ugly block of code exists for the sole
3902 * purpose of converting a NEWLINE token into a SPACE
3903 * token, but only in the case where we have seen a
3904 * function-like macro name, but have not yet seen its
3905 * closing parenthesis.
3906 *
3907 * There's perhaps a more compact way to do this with
3908 * mid-rule actions in the grammar.
3909 *
3910 * I'm definitely not pleased with the complexity of
3911 * this code here.
3912 */
3913 if (parser->newline_as_space)
3914 {
3915 if (ret == '(') {
3916 parser->paren_count++;
3917 } else if (ret == ')') {
3918 parser->paren_count--;
3919 if (parser->paren_count == 0)
3920 parser->newline_as_space = 0;
3921 } else if (ret == NEWLINE) {
3922 ret = SPACE;
3923 } else if (ret != SPACE) {
3924 if (parser->paren_count == 0)
3925 parser->newline_as_space = 0;
3926 }
3927 }
3928 else if (parser->in_control_line)
3929 {
3930 if (ret == NEWLINE)
3931 parser->in_control_line = 0;
3932 }
3933 else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC ||
3934 ret == HASH_UNDEF || ret == HASH_IF ||
3935 ret == HASH_IFDEF || ret == HASH_IFNDEF ||
3936 ret == HASH_ELIF || ret == HASH_ELSE ||
3937 ret == HASH_ENDIF || ret == HASH)
3938 {
3939 parser->in_control_line = 1;
3940 }
3941 else if (ret == IDENTIFIER)
3942 {
3943 macro_t *macro;
3944 macro = hash_table_find (parser->defines,
3945 yylval->str);
3946 if (macro && macro->is_function) {
3947 parser->newline_as_space = 1;
3948 parser->paren_count = 0;
3949 }
3950 }
3951
3952 return ret;
3953 }
3954
3955 node = parser->lex_from_node;
3956
3957 if (node == NULL) {
3958 talloc_free (parser->lex_from_list);
3959 parser->lex_from_list = NULL;
3960 return NEWLINE;
3961 }
3962
3963 *yylval = node->token->value;
3964 ret = node->token->type;
3965
3966 parser->lex_from_node = node->next;
3967
3968 return ret;
3969}
3970
3971static void
3972glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
3973{
3974 token_node_t *node;
3975
3976 assert (parser->lex_from_list == NULL);
3977
3978 /* Copy list, eliminating any space tokens. */
3979 parser->lex_from_list = _token_list_create (parser);
3980
3981 for (node = list->head; node; node = node->next) {
3982 if (node->token->type == SPACE)
3983 continue;
3984 _token_list_append (parser->lex_from_list, node->token);
3985 }
3986
3987 talloc_free (list);
3988
3989 parser->lex_from_node = parser->lex_from_list->head;
3990
3991 /* It's possible the list consisted of nothing but whitespace. */
3992 if (parser->lex_from_node == NULL) {
3993 talloc_free (parser->lex_from_list);
3994 parser->lex_from_list = NULL;
3995 }
3996}
3997
3998static void
3999_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
4000 int condition)
4001{
4002 skip_type_t current = SKIP_NO_SKIP;
4003 skip_node_t *node;
4004
4005 if (parser->skip_stack)
4006 current = parser->skip_stack->type;
4007
4008 node = talloc (parser, skip_node_t);
4009 node->loc = *loc;
4010
4011 if (current == SKIP_NO_SKIP) {
4012 if (condition)
4013 node->type = SKIP_NO_SKIP;
4014 else
4015 node->type = SKIP_TO_ELSE;
4016 } else {
4017 node->type = SKIP_TO_ENDIF;
4018 }
4019
4020 node->next = parser->skip_stack;
4021 parser->skip_stack = node;
4022}
4023
4024static void
4025_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
4026 const char *type, int condition)
4027{
4028 if (parser->skip_stack == NULL) {
4029 glcpp_error (loc, parser, "%s without #if\n", type);
4030 return;
4031 }
4032
4033 if (parser->skip_stack->type == SKIP_TO_ELSE) {
4034 if (condition)
4035 parser->skip_stack->type = SKIP_NO_SKIP;
4036 } else {
4037 parser->skip_stack->type = SKIP_TO_ENDIF;
4038 }
4039}
4040
4041static void
4042_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
4043{
4044 skip_node_t *node;
4045
4046 if (parser->skip_stack == NULL) {
4047 glcpp_error (loc, parser, "#endif without #if\n");
4048 return;
4049 }
4050
4051 node = parser->skip_stack;
4052 parser->skip_stack = node->next;
4053 talloc_free (node);
4054}
4055
diff --git a/src/glsl/glcpp/glcpp-parse.h b/src/glsl/glcpp/glcpp-parse.h
new file mode 100644
index 00000000000..40556854f38
--- /dev/null
+++ b/src/glsl/glcpp/glcpp-parse.h
@@ -0,0 +1,100 @@
1/* A Bison parser, made by GNU Bison 2.4.3. */
2
3/* Skeleton interface for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
6 2009, 2010 Free Software Foundation, Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21/* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34
35/* Tokens. */
36#ifndef YYTOKENTYPE
37# define YYTOKENTYPE
38 /* Put the tokens into the symbol table, so that GDB and other debuggers
39 know about them. */
40 enum yytokentype {
41 COMMA_FINAL = 258,
42 DEFINED = 259,
43 ELIF_EXPANDED = 260,
44 HASH = 261,
45 HASH_DEFINE_FUNC = 262,
46 HASH_DEFINE_OBJ = 263,
47 HASH_ELIF = 264,
48 HASH_ELSE = 265,
49 HASH_ENDIF = 266,
50 HASH_IF = 267,
51 HASH_IFDEF = 268,
52 HASH_IFNDEF = 269,
53 HASH_UNDEF = 270,
54 HASH_VERSION = 271,
55 IDENTIFIER = 272,
56 IF_EXPANDED = 273,
57 INTEGER = 274,
58 INTEGER_STRING = 275,
59 NEWLINE = 276,
60 OTHER = 277,
61 PLACEHOLDER = 278,
62 SPACE = 279,
63 PASTE = 280,
64 OR = 281,
65 AND = 282,
66 NOT_EQUAL = 283,
67 EQUAL = 284,
68 GREATER_OR_EQUAL = 285,
69 LESS_OR_EQUAL = 286,
70 RIGHT_SHIFT = 287,
71 LEFT_SHIFT = 288,
72 UNARY = 289
73 };
74#endif
75
76
77
78#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
79
80# define yystype YYSTYPE /* obsolescent; will be withdrawn */
81# define YYSTYPE_IS_DECLARED 1
82#endif
83
84
85
86#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
87typedef struct YYLTYPE
88{
89 int first_line;
90 int first_column;
91 int last_line;
92 int last_column;
93} YYLTYPE;
94# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
95# define YYLTYPE_IS_DECLARED 1
96# define YYLTYPE_IS_TRIVIAL 1
97#endif
98
99
100
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
new file mode 100644
index 00000000000..c91da15519e
--- /dev/null
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -0,0 +1,1729 @@
1%{
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <assert.h>
29#include <inttypes.h>
30
31#include "glcpp.h"
32#include "main/mtypes.h"
33
34#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
35#define glcpp_printf(stream, fmt, args, ...) \
36 stream = talloc_asprintf_append(stream, fmt, args)
37
38static void
39yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
40
41static void
42_define_object_macro (glcpp_parser_t *parser,
43 YYLTYPE *loc,
44 const char *macro,
45 token_list_t *replacements);
46
47static void
48_define_function_macro (glcpp_parser_t *parser,
49 YYLTYPE *loc,
50 const char *macro,
51 string_list_t *parameters,
52 token_list_t *replacements);
53
54static string_list_t *
55_string_list_create (void *ctx);
56
57static void
58_string_list_append_item (string_list_t *list, const char *str);
59
60static int
61_string_list_contains (string_list_t *list, const char *member, int *index);
62
63static int
64_string_list_length (string_list_t *list);
65
66static argument_list_t *
67_argument_list_create (void *ctx);
68
69static void
70_argument_list_append (argument_list_t *list, token_list_t *argument);
71
72static int
73_argument_list_length (argument_list_t *list);
74
75static token_list_t *
76_argument_list_member_at (argument_list_t *list, int index);
77
78/* Note: This function talloc_steal()s the str pointer. */
79static token_t *
80_token_create_str (void *ctx, int type, char *str);
81
82static token_t *
83_token_create_ival (void *ctx, int type, int ival);
84
85static token_list_t *
86_token_list_create (void *ctx);
87
88/* Note: This function adds a talloc_reference() to token.
89 *
90 * You may want to talloc_unlink any current reference if you no
91 * longer need it. */
92static void
93_token_list_append (token_list_t *list, token_t *token);
94
95static void
96_token_list_append_list (token_list_t *list, token_list_t *tail);
97
98static active_list_t *
99_active_list_push (active_list_t *list,
100 const char *identifier,
101 token_node_t *marker);
102
103static active_list_t *
104_active_list_pop (active_list_t *list);
105
106int
107_active_list_contains (active_list_t *list, const char *identifier);
108
109static void
110_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list);
111
112static void
113_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
114 token_list_t *list);
115
116static void
117_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
118 token_list_t *list);
119
120static void
121_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
122 int condition);
123
124static void
125_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
126 const char *type, int condition);
127
128static void
129_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
130
131#define yylex glcpp_parser_lex
132
133static int
134glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
135
136static void
137glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
138
139static void
140add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
141
142%}
143
144%pure-parser
145%error-verbose
146
147%locations
148%initial-action {
149 @$.first_line = 1;
150 @$.first_column = 1;
151 @$.last_line = 1;
152 @$.last_column = 1;
153 @$.source = 0;
154}
155
156%parse-param {glcpp_parser_t *parser}
157%lex-param {glcpp_parser_t *parser}
158
159%expect 0
160%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
161%token PASTE
162%type <ival> expression INTEGER operator SPACE integer_constant
163%type <str> IDENTIFIER INTEGER_STRING OTHER
164%type <string_list> identifier_list
165%type <token> preprocessing_token conditional_token
166%type <token_list> pp_tokens replacement_list text_line conditional_tokens
167%left OR
168%left AND
169%left '|'
170%left '^'
171%left '&'
172%left EQUAL NOT_EQUAL
173%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL
174%left LEFT_SHIFT RIGHT_SHIFT
175%left '+' '-'
176%left '*' '/' '%'
177%right UNARY
178
179%%
180
181input:
182 /* empty */
183| input line
184;
185
186line:
187 control_line {
188 glcpp_print(parser->output, "\n");
189 }
190| text_line {
191 _glcpp_parser_print_expanded_token_list (parser, $1);
192 glcpp_print(parser->output, "\n");
193 talloc_free ($1);
194 }
195| expanded_line
196| HASH non_directive
197;
198
199expanded_line:
200 IF_EXPANDED expression NEWLINE {
201 _glcpp_parser_skip_stack_push_if (parser, & @1, $2);
202 }
203| ELIF_EXPANDED expression NEWLINE {
204 _glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2);
205 }
206;
207
208control_line:
209 HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE {
210 _define_object_macro (parser, & @2, $2, $3);
211 }
212| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE {
213 _define_function_macro (parser, & @2, $2, NULL, $5);
214 }
215| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE {
216 _define_function_macro (parser, & @2, $2, $4, $6);
217 }
218| HASH_UNDEF IDENTIFIER NEWLINE {
219 macro_t *macro = hash_table_find (parser->defines, $2);
220 if (macro) {
221 hash_table_remove (parser->defines, $2);
222 talloc_free (macro);
223 }
224 talloc_free ($2);
225 }
226| HASH_IF conditional_tokens NEWLINE {
227 /* Be careful to only evaluate the 'if' expression if
228 * we are not skipping. When we are skipping, we
229 * simply push a new 0-valued 'if' onto the skip
230 * stack.
231 *
232 * This avoids generating diagnostics for invalid
233 * expressions that are being skipped. */
234 if (parser->skip_stack == NULL ||
235 parser->skip_stack->type == SKIP_NO_SKIP)
236 {
237 _glcpp_parser_expand_if (parser, IF_EXPANDED, $2);
238 }
239 else
240 {
241 _glcpp_parser_skip_stack_push_if (parser, & @1, 0);
242 parser->skip_stack->type = SKIP_TO_ENDIF;
243 }
244 }
245| HASH_IF NEWLINE {
246 /* #if without an expression is only an error if we
247 * are not skipping */
248 if (parser->skip_stack == NULL ||
249 parser->skip_stack->type == SKIP_NO_SKIP)
250 {
251 glcpp_error(& @1, parser, "#if with no expression");
252 }
253 _glcpp_parser_skip_stack_push_if (parser, & @1, 0);
254 }
255| HASH_IFDEF IDENTIFIER junk NEWLINE {
256 macro_t *macro = hash_table_find (parser->defines, $2);
257 talloc_free ($2);
258 _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
259 }
260| HASH_IFNDEF IDENTIFIER junk NEWLINE {
261 macro_t *macro = hash_table_find (parser->defines, $2);
262 talloc_free ($2);
263 _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL);
264 }
265| HASH_ELIF conditional_tokens NEWLINE {
266 /* Be careful to only evaluate the 'elif' expression
267 * if we are not skipping. When we are skipping, we
268 * simply change to a 0-valued 'elif' on the skip
269 * stack.
270 *
271 * This avoids generating diagnostics for invalid
272 * expressions that are being skipped. */
273 if (parser->skip_stack &&
274 parser->skip_stack->type == SKIP_TO_ELSE)
275 {
276 _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2);
277 }
278 else
279 {
280 _glcpp_parser_skip_stack_change_if (parser, & @1,
281 "elif", 0);
282 }
283 }
284| HASH_ELIF NEWLINE {
285 /* #elif without an expression is an error unless we
286 * are skipping. */
287 if (parser->skip_stack &&
288 parser->skip_stack->type == SKIP_TO_ELSE)
289 {
290 glcpp_error(& @1, parser, "#elif with no expression");
291 }
292 else
293 {
294 _glcpp_parser_skip_stack_change_if (parser, & @1,
295 "elif", 0);
296 glcpp_warning(& @1, parser, "ignoring illegal #elif without expression");
297 }
298 }
299| HASH_ELSE NEWLINE {
300 _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1);
301 }
302| HASH_ENDIF NEWLINE {
303 _glcpp_parser_skip_stack_pop (parser, & @1);
304 }
305| HASH_VERSION integer_constant NEWLINE {
306 macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
307 if (macro) {
308 hash_table_remove (parser->defines, "__VERSION__");
309 talloc_free (macro);
310 }
311 add_builtin_define (parser, "__VERSION__", $2);
312 glcpp_printf(parser->output, "#version %" PRIiMAX, $2);
313 }
314| HASH NEWLINE
315;
316
317integer_constant:
318 INTEGER_STRING {
319 if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) {
320 $$ = strtoll ($1 + 2, NULL, 16);
321 } else if ($1[0] == '0') {
322 $$ = strtoll ($1, NULL, 8);
323 } else {
324 $$ = strtoll ($1, NULL, 10);
325 }
326 }
327| INTEGER {
328 $$ = $1;
329 }
330
331expression:
332 integer_constant
333| expression OR expression {
334 $$ = $1 || $3;
335 }
336| expression AND expression {
337 $$ = $1 && $3;
338 }
339| expression '|' expression {
340 $$ = $1 | $3;
341 }
342| expression '^' expression {
343 $$ = $1 ^ $3;
344 }
345| expression '&' expression {
346 $$ = $1 & $3;
347 }
348| expression NOT_EQUAL expression {
349 $$ = $1 != $3;
350 }
351| expression EQUAL expression {
352 $$ = $1 == $3;
353 }
354| expression GREATER_OR_EQUAL expression {
355 $$ = $1 >= $3;
356 }
357| expression LESS_OR_EQUAL expression {
358 $$ = $1 <= $3;
359 }
360| expression '>' expression {
361 $$ = $1 > $3;
362 }
363| expression '<' expression {
364 $$ = $1 < $3;
365 }
366| expression RIGHT_SHIFT expression {
367 $$ = $1 >> $3;
368 }
369| expression LEFT_SHIFT expression {
370 $$ = $1 << $3;
371 }
372| expression '-' expression {
373 $$ = $1 - $3;
374 }
375| expression '+' expression {
376 $$ = $1 + $3;
377 }
378| expression '%' expression {
379 $$ = $1 % $3;
380 }
381| expression '/' expression {
382 $$ = $1 / $3;
383 }
384| expression '*' expression {
385 $$ = $1 * $3;
386 }
387| '!' expression %prec UNARY {
388 $$ = ! $2;
389 }
390| '~' expression %prec UNARY {
391 $$ = ~ $2;
392 }
393| '-' expression %prec UNARY {
394 $$ = - $2;
395 }
396| '+' expression %prec UNARY {
397 $$ = + $2;
398 }
399| '(' expression ')' {
400 $$ = $2;
401 }
402;
403
404identifier_list:
405 IDENTIFIER {
406 $$ = _string_list_create (parser);
407 _string_list_append_item ($$, $1);
408 talloc_steal ($$, $1);
409 }
410| identifier_list ',' IDENTIFIER {
411 $$ = $1;
412 _string_list_append_item ($$, $3);
413 talloc_steal ($$, $3);
414 }
415;
416
417text_line:
418 NEWLINE { $$ = NULL; }
419| pp_tokens NEWLINE
420;
421
422non_directive:
423 pp_tokens NEWLINE {
424 yyerror (& @1, parser, "Invalid tokens after #");
425 }
426;
427
428replacement_list:
429 /* empty */ { $$ = NULL; }
430| pp_tokens
431;
432
433junk:
434 /* empty */
435| pp_tokens {
436 glcpp_warning(&@1, parser, "extra tokens at end of directive");
437 }
438;
439
440conditional_token:
441 /* Handle "defined" operator */
442 DEFINED IDENTIFIER {
443 int v = hash_table_find (parser->defines, $2) ? 1 : 0;
444 $$ = _token_create_ival (parser, INTEGER, v);
445 }
446| DEFINED '(' IDENTIFIER ')' {
447 int v = hash_table_find (parser->defines, $3) ? 1 : 0;
448 $$ = _token_create_ival (parser, INTEGER, v);
449 }
450| preprocessing_token
451;
452
453conditional_tokens:
454 /* Exactly the same as pp_tokens, but using conditional_token */
455 conditional_token {
456 parser->space_tokens = 1;
457 $$ = _token_list_create (parser);
458 _token_list_append ($$, $1);
459 talloc_unlink (parser, $1);
460 }
461| conditional_tokens conditional_token {
462 $$ = $1;
463 _token_list_append ($$, $2);
464 talloc_unlink (parser, $2);
465 }
466;
467
468pp_tokens:
469 preprocessing_token {
470 parser->space_tokens = 1;
471 $$ = _token_list_create (parser);
472 _token_list_append ($$, $1);
473 talloc_unlink (parser, $1);
474 }
475| pp_tokens preprocessing_token {
476 $$ = $1;
477 _token_list_append ($$, $2);
478 talloc_unlink (parser, $2);
479 }
480;
481
482preprocessing_token:
483 IDENTIFIER {
484 $$ = _token_create_str (parser, IDENTIFIER, $1);
485 $$->location = yylloc;
486 }
487| INTEGER_STRING {
488 $$ = _token_create_str (parser, INTEGER_STRING, $1);
489 $$->location = yylloc;
490 }
491| operator {
492 $$ = _token_create_ival (parser, $1, $1);
493 $$->location = yylloc;
494 }
495| OTHER {
496 $$ = _token_create_str (parser, OTHER, $1);
497 $$->location = yylloc;
498 }
499| SPACE {
500 $$ = _token_create_ival (parser, SPACE, SPACE);
501 $$->location = yylloc;
502 }
503;
504
505operator:
506 '[' { $$ = '['; }
507| ']' { $$ = ']'; }
508| '(' { $$ = '('; }
509| ')' { $$ = ')'; }
510| '{' { $$ = '{'; }
511| '}' { $$ = '}'; }
512| '.' { $$ = '.'; }
513| '&' { $$ = '&'; }
514| '*' { $$ = '*'; }
515| '+' { $$ = '+'; }
516| '-' { $$ = '-'; }
517| '~' { $$ = '~'; }
518| '!' { $$ = '!'; }
519| '/' { $$ = '/'; }
520| '%' { $$ = '%'; }
521| LEFT_SHIFT { $$ = LEFT_SHIFT; }
522| RIGHT_SHIFT { $$ = RIGHT_SHIFT; }
523| '<' { $$ = '<'; }
524| '>' { $$ = '>'; }
525| LESS_OR_EQUAL { $$ = LESS_OR_EQUAL; }
526| GREATER_OR_EQUAL { $$ = GREATER_OR_EQUAL; }
527| EQUAL { $$ = EQUAL; }
528| NOT_EQUAL { $$ = NOT_EQUAL; }
529| '^' { $$ = '^'; }
530| '|' { $$ = '|'; }
531| AND { $$ = AND; }
532| OR { $$ = OR; }
533| ';' { $$ = ';'; }
534| ',' { $$ = ','; }
535| '=' { $$ = '='; }
536| PASTE { $$ = PASTE; }
537;
538
539%%
540
541string_list_t *
542_string_list_create (void *ctx)
543{
544 string_list_t *list;
545
546 list = talloc (ctx, string_list_t);
547 list->head = NULL;
548 list->tail = NULL;
549
550 return list;
551}
552
553void
554_string_list_append_item (string_list_t *list, const char *str)
555{
556 string_node_t *node;
557
558 node = talloc (list, string_node_t);
559 node->str = talloc_strdup (node, str);
560
561 node->next = NULL;
562
563 if (list->head == NULL) {
564 list->head = node;
565 } else {
566 list->tail->next = node;
567 }
568
569 list->tail = node;
570}
571
572int
573_string_list_contains (string_list_t *list, const char *member, int *index)
574{
575 string_node_t *node;
576 int i;
577
578 if (list == NULL)
579 return 0;
580
581 for (i = 0, node = list->head; node; i++, node = node->next) {
582 if (strcmp (node->str, member) == 0) {
583 if (index)
584 *index = i;
585 return 1;
586 }
587 }
588
589 return 0;
590}
591
592int
593_string_list_length (string_list_t *list)
594{
595 int length = 0;
596 string_node_t *node;
597
598 if (list == NULL)
599 return 0;
600
601 for (node = list->head; node; node = node->next)
602 length++;
603
604 return length;
605}
606
607argument_list_t *
608_argument_list_create (void *ctx)
609{
610 argument_list_t *list;
611
612 list = talloc (ctx, argument_list_t);
613 list->head = NULL;
614 list->tail = NULL;
615
616 return list;
617}
618
619void
620_argument_list_append (argument_list_t *list, token_list_t *argument)
621{
622 argument_node_t *node;
623
624 node = talloc (list, argument_node_t);
625 node->argument = argument;
626
627 node->next = NULL;
628
629 if (list->head == NULL) {
630 list->head = node;
631 } else {
632 list->tail->next = node;
633 }
634
635 list->tail = node;
636}
637
638int
639_argument_list_length (argument_list_t *list)
640{
641 int length = 0;
642 argument_node_t *node;
643
644 if (list == NULL)
645 return 0;
646
647 for (node = list->head; node; node = node->next)
648 length++;
649
650 return length;
651}
652
653token_list_t *
654_argument_list_member_at (argument_list_t *list, int index)
655{
656 argument_node_t *node;
657 int i;
658
659 if (list == NULL)
660 return NULL;
661
662 node = list->head;
663 for (i = 0; i < index; i++) {
664 node = node->next;
665 if (node == NULL)
666 break;
667 }
668
669 if (node)
670 return node->argument;
671
672 return NULL;
673}
674
675/* Note: This function talloc_steal()s the str pointer. */
676token_t *
677_token_create_str (void *ctx, int type, char *str)
678{
679 token_t *token;
680
681 token = talloc (ctx, token_t);
682 token->type = type;
683 token->value.str = talloc_steal (token, str);
684
685 return token;
686}
687
688token_t *
689_token_create_ival (void *ctx, int type, int ival)
690{
691 token_t *token;
692
693 token = talloc (ctx, token_t);
694 token->type = type;
695 token->value.ival = ival;
696
697 return token;
698}
699
700token_list_t *
701_token_list_create (void *ctx)
702{
703 token_list_t *list;
704
705 list = talloc (ctx, token_list_t);
706 list->head = NULL;
707 list->tail = NULL;
708 list->non_space_tail = NULL;
709
710 return list;
711}
712
713void
714_token_list_append (token_list_t *list, token_t *token)
715{
716 token_node_t *node;
717
718 node = talloc (list, token_node_t);
719 node->token = talloc_reference (list, token);
720
721 node->next = NULL;
722
723 if (list->head == NULL) {
724 list->head = node;
725 } else {
726 list->tail->next = node;
727 }
728
729 list->tail = node;
730 if (token->type != SPACE)
731 list->non_space_tail = node;
732}
733
734void
735_token_list_append_list (token_list_t *list, token_list_t *tail)
736{
737 if (tail == NULL || tail->head == NULL)
738 return;
739
740 if (list->head == NULL) {
741 list->head = tail->head;
742 } else {
743 list->tail->next = tail->head;
744 }
745
746 list->tail = tail->tail;
747 list->non_space_tail = tail->non_space_tail;
748}
749
750static token_list_t *
751_token_list_copy (void *ctx, token_list_t *other)
752{
753 token_list_t *copy;
754 token_node_t *node;
755
756 if (other == NULL)
757 return NULL;
758
759 copy = _token_list_create (ctx);
760 for (node = other->head; node; node = node->next)
761 _token_list_append (copy, node->token);
762
763 return copy;
764}
765
766static void
767_token_list_trim_trailing_space (token_list_t *list)
768{
769 token_node_t *tail, *next;
770
771 if (list->non_space_tail) {
772 tail = list->non_space_tail->next;
773 list->non_space_tail->next = NULL;
774 list->tail = list->non_space_tail;
775
776 while (tail) {
777 next = tail->next;
778 talloc_free (tail);
779 tail = next;
780 }
781 }
782}
783
784static void
785_token_print (char **out, token_t *token)
786{
787 if (token->type < 256) {
788 glcpp_printf (*out, "%c", token->type);
789 return;
790 }
791
792 switch (token->type) {
793 case INTEGER:
794 glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
795 break;
796 case IDENTIFIER:
797 case INTEGER_STRING:
798 case OTHER:
799 glcpp_print (*out, token->value.str);
800 break;
801 case SPACE:
802 glcpp_print (*out, " ");
803 break;
804 case LEFT_SHIFT:
805 glcpp_print (*out, "<<");
806 break;
807 case RIGHT_SHIFT:
808 glcpp_print (*out, ">>");
809 break;
810 case LESS_OR_EQUAL:
811 glcpp_print (*out, "<=");
812 break;
813 case GREATER_OR_EQUAL:
814 glcpp_print (*out, ">=");
815 break;
816 case EQUAL:
817 glcpp_print (*out, "==");
818 break;
819 case NOT_EQUAL:
820 glcpp_print (*out, "!=");
821 break;
822 case AND:
823 glcpp_print (*out, "&&");
824 break;
825 case OR:
826 glcpp_print (*out, "||");
827 break;
828 case PASTE:
829 glcpp_print (*out, "##");
830 break;
831 case COMMA_FINAL:
832 glcpp_print (*out, ",");
833 break;
834 case PLACEHOLDER:
835 /* Nothing to print. */
836 break;
837 default:
838 assert(!"Error: Don't know how to print token.");
839 break;
840 }
841}
842
843/* Return a new token (talloc()ed off of 'token') formed by pasting
844 * 'token' and 'other'. Note that this function may return 'token' or
845 * 'other' directly rather than allocating anything new.
846 *
847 * Caution: Only very cursory error-checking is performed to see if
848 * the final result is a valid single token. */
849static token_t *
850_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
851{
852 token_t *combined = NULL;
853
854 /* Pasting a placeholder onto anything makes no change. */
855 if (other->type == PLACEHOLDER)
856 return token;
857
858 /* When 'token' is a placeholder, just return 'other'. */
859 if (token->type == PLACEHOLDER)
860 return other;
861
862 /* A very few single-character punctuators can be combined
863 * with another to form a multi-character punctuator. */
864 switch (token->type) {
865 case '<':
866 if (other->type == '<')
867 combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
868 else if (other->type == '=')
869 combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
870 break;
871 case '>':
872 if (other->type == '>')
873 combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
874 else if (other->type == '=')
875 combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
876 break;
877 case '=':
878 if (other->type == '=')
879 combined = _token_create_ival (token, EQUAL, EQUAL);
880 break;
881 case '!':
882 if (other->type == '=')
883 combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
884 break;
885 case '&':
886 if (other->type == '&')
887 combined = _token_create_ival (token, AND, AND);
888 break;
889 case '|':
890 if (other->type == '|')
891 combined = _token_create_ival (token, OR, OR);
892 break;
893 }
894
895 if (combined != NULL) {
896 /* Inherit the location from the first token */
897 combined->location = token->location;
898 return combined;
899 }
900
901 /* Two string-valued tokens can usually just be mashed
902 * together.
903 *
904 * XXX: This isn't actually legitimate. Several things here
905 * should result in a diagnostic since the result cannot be a
906 * valid, single pre-processing token. For example, pasting
907 * "123" and "abc" is not legal, but we don't catch that
908 * here. */
909 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
910 (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
911 {
912 char *str;
913
914 str = talloc_asprintf (token, "%s%s", token->value.str,
915 other->value.str);
916 combined = _token_create_str (token, token->type, str);
917 combined->location = token->location;
918 return combined;
919 }
920
921 glcpp_error (&token->location, parser, "");
922 glcpp_print (parser->info_log, "Pasting \"");
923 _token_print (&parser->info_log, token);
924 glcpp_print (parser->info_log, "\" and \"");
925 _token_print (&parser->info_log, other);
926 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
927
928 return token;
929}
930
931static void
932_token_list_print (glcpp_parser_t *parser, token_list_t *list)
933{
934 token_node_t *node;
935
936 if (list == NULL)
937 return;
938
939 for (node = list->head; node; node = node->next)
940 _token_print (&parser->output, node->token);
941}
942
943void
944yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
945{
946 glcpp_error(locp, parser, "%s", error);
947}
948
949static void add_builtin_define(glcpp_parser_t *parser,
950 const char *name, int value)
951{
952 token_t *tok;
953 token_list_t *list;
954
955 tok = _token_create_ival (parser, INTEGER, value);
956
957 list = _token_list_create(parser);
958 _token_list_append(list, tok);
959 _define_object_macro(parser, NULL, name, list);
960
961 talloc_unlink(parser, tok);
962}
963
964glcpp_parser_t *
965glcpp_parser_create (const struct gl_extensions *extensions)
966{
967 glcpp_parser_t *parser;
968 int language_version;
969
970 parser = talloc (NULL, glcpp_parser_t);
971
972 glcpp_lex_init_extra (parser, &parser->scanner);
973 parser->defines = hash_table_ctor (32, hash_table_string_hash,
974 hash_table_string_compare);
975 parser->active = NULL;
976 parser->lexing_if = 0;
977 parser->space_tokens = 1;
978 parser->newline_as_space = 0;
979 parser->in_control_line = 0;
980 parser->paren_count = 0;
981
982 parser->skip_stack = NULL;
983
984 parser->lex_from_list = NULL;
985 parser->lex_from_node = NULL;
986
987 parser->output = talloc_strdup(parser, "");
988 parser->info_log = talloc_strdup(parser, "");
989 parser->error = 0;
990
991 /* Add pre-defined macros. */
992 add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
993 add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
994
995 if (extensions != NULL) {
996 if (extensions->EXT_texture_array) {
997 add_builtin_define(parser, "GL_EXT_texture_array", 1);
998 }
999
1000 if (extensions->ARB_fragment_coord_conventions)
1001 add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
1002 1);
1003 }
1004
1005 language_version = 110;
1006 add_builtin_define(parser, "__VERSION__", language_version);
1007
1008 return parser;
1009}
1010
1011int
1012glcpp_parser_parse (glcpp_parser_t *parser)
1013{
1014 return yyparse (parser);
1015}
1016
1017void
1018glcpp_parser_destroy (glcpp_parser_t *parser)
1019{
1020 glcpp_lex_destroy (parser->scanner);
1021 hash_table_dtor (parser->defines);
1022 talloc_free (parser);
1023}
1024
1025typedef enum function_status
1026{
1027 FUNCTION_STATUS_SUCCESS,
1028 FUNCTION_NOT_A_FUNCTION,
1029 FUNCTION_UNBALANCED_PARENTHESES
1030} function_status_t;
1031
1032/* Find a set of function-like macro arguments by looking for a
1033 * balanced set of parentheses.
1034 *
1035 * When called, 'node' should be the opening-parenthesis token, (or
1036 * perhaps preceeding SPACE tokens). Upon successful return *last will
1037 * be the last consumed node, (corresponding to the closing right
1038 * parenthesis).
1039 *
1040 * Return values:
1041 *
1042 * FUNCTION_STATUS_SUCCESS:
1043 *
1044 * Successfully parsed a set of function arguments.
1045 *
1046 * FUNCTION_NOT_A_FUNCTION:
1047 *
1048 * Macro name not followed by a '('. This is not an error, but
1049 * simply that the macro name should be treated as a non-macro.
1050 *
1051 * FUNCTION_UNBALANCED_PARENTHESES
1052 *
1053 * Macro name is not followed by a balanced set of parentheses.
1054 */
1055static function_status_t
1056_arguments_parse (argument_list_t *arguments,
1057 token_node_t *node,
1058 token_node_t **last)
1059{
1060 token_list_t *argument;
1061 int paren_count;
1062
1063 node = node->next;
1064
1065 /* Ignore whitespace before first parenthesis. */
1066 while (node && node->token->type == SPACE)
1067 node = node->next;
1068
1069 if (node == NULL || node->token->type != '(')
1070 return FUNCTION_NOT_A_FUNCTION;
1071
1072 node = node->next;
1073
1074 argument = _token_list_create (arguments);
1075 _argument_list_append (arguments, argument);
1076
1077 for (paren_count = 1; node; node = node->next) {
1078 if (node->token->type == '(')
1079 {
1080 paren_count++;
1081 }
1082 else if (node->token->type == ')')
1083 {
1084 paren_count--;
1085 if (paren_count == 0)
1086 break;
1087 }
1088
1089 if (node->token->type == ',' &&
1090 paren_count == 1)
1091 {
1092 _token_list_trim_trailing_space (argument);
1093 argument = _token_list_create (arguments);
1094 _argument_list_append (arguments, argument);
1095 }
1096 else {
1097 if (argument->head == NULL) {
1098 /* Don't treat initial whitespace as
1099 * part of the arguement. */
1100 if (node->token->type == SPACE)
1101 continue;
1102 }
1103 _token_list_append (argument, node->token);
1104 }
1105 }
1106
1107 if (paren_count)
1108 return FUNCTION_UNBALANCED_PARENTHESES;
1109
1110 *last = node;
1111
1112 return FUNCTION_STATUS_SUCCESS;
1113}
1114
1115static token_list_t *
1116_token_list_create_with_one_space (void *ctx)
1117{
1118 token_list_t *list;
1119 token_t *space;
1120
1121 list = _token_list_create (ctx);
1122 space = _token_create_ival (list, SPACE, SPACE);
1123 _token_list_append (list, space);
1124
1125 return list;
1126}
1127
1128static void
1129_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list)
1130{
1131 token_list_t *expanded;
1132 token_t *token;
1133
1134 expanded = _token_list_create (parser);
1135 token = _token_create_ival (parser, type, type);
1136 _token_list_append (expanded, token);
1137 _glcpp_parser_expand_token_list (parser, list);
1138 _token_list_append_list (expanded, list);
1139 glcpp_parser_lex_from (parser, expanded);
1140}
1141
1142/* This is a helper function that's essentially part of the
1143 * implementation of _glcpp_parser_expand_node. It shouldn't be called
1144 * except for by that function.
1145 *
1146 * Returns NULL if node is a simple token with no expansion, (that is,
1147 * although 'node' corresponds to an identifier defined as a
1148 * function-like macro, it is not followed with a parenthesized
1149 * argument list).
1150 *
1151 * Compute the complete expansion of node (which is a function-like
1152 * macro) and subsequent nodes which are arguments.
1153 *
1154 * Returns the token list that results from the expansion and sets
1155 * *last to the last node in the list that was consumed by the
1156 * expansion. Specifically, *last will be set as follows: as the
1157 * token of the closing right parenthesis.
1158 */
1159static token_list_t *
1160_glcpp_parser_expand_function (glcpp_parser_t *parser,
1161 token_node_t *node,
1162 token_node_t **last)
1163
1164{
1165 macro_t *macro;
1166 const char *identifier;
1167 argument_list_t *arguments;
1168 function_status_t status;
1169 token_list_t *substituted;
1170 int parameter_index;
1171
1172 identifier = node->token->value.str;
1173
1174 macro = hash_table_find (parser->defines, identifier);
1175
1176 assert (macro->is_function);
1177
1178 arguments = _argument_list_create (parser);
1179 status = _arguments_parse (arguments, node, last);
1180
1181 switch (status) {
1182 case FUNCTION_STATUS_SUCCESS:
1183 break;
1184 case FUNCTION_NOT_A_FUNCTION:
1185 return NULL;
1186 case FUNCTION_UNBALANCED_PARENTHESES:
1187 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
1188 return NULL;
1189 }
1190
1191 /* Replace a macro defined as empty with a SPACE token. */
1192 if (macro->replacements == NULL) {
1193 talloc_free (arguments);
1194 return _token_list_create_with_one_space (parser);
1195 }
1196
1197 if (! ((_argument_list_length (arguments) ==
1198 _string_list_length (macro->parameters)) ||
1199 (_string_list_length (macro->parameters) == 0 &&
1200 _argument_list_length (arguments) == 1 &&
1201 arguments->head->argument->head == NULL)))
1202 {
1203 glcpp_error (&node->token->location, parser,
1204 "Error: macro %s invoked with %d arguments (expected %d)\n",
1205 identifier,
1206 _argument_list_length (arguments),
1207 _string_list_length (macro->parameters));
1208 return NULL;
1209 }
1210
1211 /* Perform argument substitution on the replacement list. */
1212 substituted = _token_list_create (arguments);
1213
1214 for (node = macro->replacements->head; node; node = node->next)
1215 {
1216 if (node->token->type == IDENTIFIER &&
1217 _string_list_contains (macro->parameters,
1218 node->token->value.str,
1219 &parameter_index))
1220 {
1221 token_list_t *argument;
1222 argument = _argument_list_member_at (arguments,
1223 parameter_index);
1224 /* Before substituting, we expand the argument
1225 * tokens, or append a placeholder token for
1226 * an empty argument. */
1227 if (argument->head) {
1228 token_list_t *expanded_argument;
1229 expanded_argument = _token_list_copy (parser,
1230 argument);
1231 _glcpp_parser_expand_token_list (parser,
1232 expanded_argument);
1233 _token_list_append_list (substituted,
1234 expanded_argument);
1235 } else {
1236 token_t *new_token;
1237
1238 new_token = _token_create_ival (substituted,
1239 PLACEHOLDER,
1240 PLACEHOLDER);
1241 _token_list_append (substituted, new_token);
1242 }
1243 } else {
1244 _token_list_append (substituted, node->token);
1245 }
1246 }
1247
1248 /* After argument substitution, and before further expansion
1249 * below, implement token pasting. */
1250
1251 _token_list_trim_trailing_space (substituted);
1252
1253 node = substituted->head;
1254 while (node)
1255 {
1256 token_node_t *next_non_space;
1257
1258 /* Look ahead for a PASTE token, skipping space. */
1259 next_non_space = node->next;
1260 while (next_non_space && next_non_space->token->type == SPACE)
1261 next_non_space = next_non_space->next;
1262
1263 if (next_non_space == NULL)
1264 break;
1265
1266 if (next_non_space->token->type != PASTE) {
1267 node = next_non_space;
1268 continue;
1269 }
1270
1271 /* Now find the next non-space token after the PASTE. */
1272 next_non_space = next_non_space->next;
1273 while (next_non_space && next_non_space->token->type == SPACE)
1274 next_non_space = next_non_space->next;
1275
1276 if (next_non_space == NULL) {
1277 yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
1278 return NULL;
1279 }
1280
1281 node->token = _token_paste (parser, node->token, next_non_space->token);
1282 node->next = next_non_space->next;
1283 if (next_non_space == substituted->tail)
1284 substituted->tail = node;
1285
1286 node = node->next;
1287 }
1288
1289 substituted->non_space_tail = substituted->tail;
1290
1291 return substituted;
1292}
1293
1294/* Compute the complete expansion of node, (and subsequent nodes after
1295 * 'node' in the case that 'node' is a function-like macro and
1296 * subsequent nodes are arguments).
1297 *
1298 * Returns NULL if node is a simple token with no expansion.
1299 *
1300 * Otherwise, returns the token list that results from the expansion
1301 * and sets *last to the last node in the list that was consumed by
1302 * the expansion. Specifically, *last will be set as follows:
1303 *
1304 * As 'node' in the case of object-like macro expansion.
1305 *
1306 * As the token of the closing right parenthesis in the case of
1307 * function-like macro expansion.
1308 */
1309static token_list_t *
1310_glcpp_parser_expand_node (glcpp_parser_t *parser,
1311 token_node_t *node,
1312 token_node_t **last)
1313{
1314 token_t *token = node->token;
1315 const char *identifier;
1316 macro_t *macro;
1317
1318 /* We only expand identifiers */
1319 if (token->type != IDENTIFIER) {
1320 /* We change any COMMA into a COMMA_FINAL to prevent
1321 * it being mistaken for an argument separator
1322 * later. */
1323 if (token->type == ',') {
1324 token->type = COMMA_FINAL;
1325 token->value.ival = COMMA_FINAL;
1326 }
1327
1328 return NULL;
1329 }
1330
1331 /* Look up this identifier in the hash table. */
1332 identifier = token->value.str;
1333 macro = hash_table_find (parser->defines, identifier);
1334
1335 /* Not a macro, so no expansion needed. */
1336 if (macro == NULL)
1337 return NULL;
1338
1339 /* Finally, don't expand this macro if we're already actively
1340 * expanding it, (to avoid infinite recursion). */
1341 if (_active_list_contains (parser->active, identifier)) {
1342 /* We change the token type here from IDENTIFIER to
1343 * OTHER to prevent any future expansion of this
1344 * unexpanded token. */
1345 char *str;
1346 token_list_t *expansion;
1347 token_t *final;
1348
1349 str = talloc_strdup (parser, token->value.str);
1350 final = _token_create_str (parser, OTHER, str);
1351 expansion = _token_list_create (parser);
1352 _token_list_append (expansion, final);
1353 *last = node;
1354 return expansion;
1355 }
1356
1357 if (! macro->is_function)
1358 {
1359 *last = node;
1360
1361 /* Replace a macro defined as empty with a SPACE token. */
1362 if (macro->replacements == NULL)
1363 return _token_list_create_with_one_space (parser);
1364
1365 return _token_list_copy (parser, macro->replacements);
1366 }
1367
1368 return _glcpp_parser_expand_function (parser, node, last);
1369}
1370
1371/* Push a new identifier onto the active list, returning the new list.
1372 *
1373 * Here, 'marker' is the token node that appears in the list after the
1374 * expansion of 'identifier'. That is, when the list iterator begins
1375 * examinging 'marker', then it is time to pop this node from the
1376 * active stack.
1377 */
1378active_list_t *
1379_active_list_push (active_list_t *list,
1380 const char *identifier,
1381 token_node_t *marker)
1382{
1383 active_list_t *node;
1384
1385 node = talloc (list, active_list_t);
1386 node->identifier = talloc_strdup (node, identifier);
1387 node->marker = marker;
1388 node->next = list;
1389
1390 return node;
1391}
1392
1393active_list_t *
1394_active_list_pop (active_list_t *list)
1395{
1396 active_list_t *node = list;
1397
1398 if (node == NULL)
1399 return NULL;
1400
1401 node = list->next;
1402 talloc_free (list);
1403
1404 return node;
1405}
1406
1407int
1408_active_list_contains (active_list_t *list, const char *identifier)
1409{
1410 active_list_t *node;
1411
1412 if (list == NULL)
1413 return 0;
1414
1415 for (node = list; node; node = node->next)
1416 if (strcmp (node->identifier, identifier) == 0)
1417 return 1;
1418
1419 return 0;
1420}
1421
1422/* Walk over the token list replacing nodes with their expansion.
1423 * Whenever nodes are expanded the walking will walk over the new
1424 * nodes, continuing to expand as necessary. The results are placed in
1425 * 'list' itself;
1426 */
1427static void
1428_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
1429 token_list_t *list)
1430{
1431 token_node_t *node_prev;
1432 token_node_t *node, *last = NULL;
1433 token_list_t *expansion;
1434
1435 if (list == NULL)
1436 return;
1437
1438 _token_list_trim_trailing_space (list);
1439
1440 node_prev = NULL;
1441 node = list->head;
1442
1443 while (node) {
1444
1445 while (parser->active && parser->active->marker == node)
1446 parser->active = _active_list_pop (parser->active);
1447
1448 /* Find the expansion for node, which will replace all
1449 * nodes from node to last, inclusive. */
1450 expansion = _glcpp_parser_expand_node (parser, node, &last);
1451 if (expansion) {
1452 token_node_t *n;
1453
1454 for (n = node; n != last->next; n = n->next)
1455 while (parser->active &&
1456 parser->active->marker == n)
1457 {
1458 parser->active = _active_list_pop (parser->active);
1459 }
1460
1461 parser->active = _active_list_push (parser->active,
1462 node->token->value.str,
1463 last->next);
1464
1465 /* Splice expansion into list, supporting a
1466 * simple deletion if the expansion is
1467 * empty. */
1468 if (expansion->head) {
1469 if (node_prev)
1470 node_prev->next = expansion->head;
1471 else
1472 list->head = expansion->head;
1473 expansion->tail->next = last->next;
1474 if (last == list->tail)
1475 list->tail = expansion->tail;
1476 } else {
1477 if (node_prev)
1478 node_prev->next = last->next;
1479 else
1480 list->head = last->next;
1481 if (last == list->tail)
1482 list->tail = NULL;
1483 }
1484 } else {
1485 node_prev = node;
1486 }
1487 node = node_prev ? node_prev->next : list->head;
1488 }
1489
1490 while (parser->active)
1491 parser->active = _active_list_pop (parser->active);
1492
1493 list->non_space_tail = list->tail;
1494}
1495
1496void
1497_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
1498 token_list_t *list)
1499{
1500 if (list == NULL)
1501 return;
1502
1503 _glcpp_parser_expand_token_list (parser, list);
1504
1505 _token_list_trim_trailing_space (list);
1506
1507 _token_list_print (parser, list);
1508}
1509
1510static void
1511_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
1512 const char *identifier)
1513{
1514 /* According to the GLSL specification, macro names starting with "__"
1515 * or "GL_" are reserved for future use. So, don't allow them.
1516 */
1517 if (strncmp(identifier, "__", 2) == 0) {
1518 glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
1519 }
1520 if (strncmp(identifier, "GL_", 3) == 0) {
1521 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
1522 }
1523}
1524
1525void
1526_define_object_macro (glcpp_parser_t *parser,
1527 YYLTYPE *loc,
1528 const char *identifier,
1529 token_list_t *replacements)
1530{
1531 macro_t *macro;
1532
1533 if (loc != NULL)
1534 _check_for_reserved_macro_name(parser, loc, identifier);
1535
1536 macro = talloc (parser, macro_t);
1537
1538 macro->is_function = 0;
1539 macro->parameters = NULL;
1540 macro->identifier = talloc_strdup (macro, identifier);
1541 macro->replacements = talloc_steal (macro, replacements);
1542
1543 hash_table_insert (parser->defines, macro, identifier);
1544}
1545
1546void
1547_define_function_macro (glcpp_parser_t *parser,
1548 YYLTYPE *loc,
1549 const char *identifier,
1550 string_list_t *parameters,
1551 token_list_t *replacements)
1552{
1553 macro_t *macro;
1554
1555 _check_for_reserved_macro_name(parser, loc, identifier);
1556
1557 macro = talloc (parser, macro_t);
1558
1559 macro->is_function = 1;
1560 macro->parameters = talloc_steal (macro, parameters);
1561 macro->identifier = talloc_strdup (macro, identifier);
1562 macro->replacements = talloc_steal (macro, replacements);
1563
1564 hash_table_insert (parser->defines, macro, identifier);
1565}
1566
1567static int
1568glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
1569{
1570 token_node_t *node;
1571 int ret;
1572
1573 if (parser->lex_from_list == NULL) {
1574 ret = glcpp_lex (yylval, yylloc, parser->scanner);
1575
1576 /* XXX: This ugly block of code exists for the sole
1577 * purpose of converting a NEWLINE token into a SPACE
1578 * token, but only in the case where we have seen a
1579 * function-like macro name, but have not yet seen its
1580 * closing parenthesis.
1581 *
1582 * There's perhaps a more compact way to do this with
1583 * mid-rule actions in the grammar.
1584 *
1585 * I'm definitely not pleased with the complexity of
1586 * this code here.
1587 */
1588 if (parser->newline_as_space)
1589 {
1590 if (ret == '(') {
1591 parser->paren_count++;
1592 } else if (ret == ')') {
1593 parser->paren_count--;
1594 if (parser->paren_count == 0)
1595 parser->newline_as_space = 0;
1596 } else if (ret == NEWLINE) {
1597 ret = SPACE;
1598 } else if (ret != SPACE) {
1599 if (parser->paren_count == 0)
1600 parser->newline_as_space = 0;
1601 }
1602 }
1603 else if (parser->in_control_line)
1604 {
1605 if (ret == NEWLINE)
1606 parser->in_control_line = 0;
1607 }
1608 else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC ||
1609 ret == HASH_UNDEF || ret == HASH_IF ||
1610 ret == HASH_IFDEF || ret == HASH_IFNDEF ||
1611 ret == HASH_ELIF || ret == HASH_ELSE ||
1612 ret == HASH_ENDIF || ret == HASH)
1613 {
1614 parser->in_control_line = 1;
1615 }
1616 else if (ret == IDENTIFIER)
1617 {
1618 macro_t *macro;
1619 macro = hash_table_find (parser->defines,
1620 yylval->str);
1621 if (macro && macro->is_function) {
1622 parser->newline_as_space = 1;
1623 parser->paren_count = 0;
1624 }
1625 }
1626
1627 return ret;
1628 }
1629
1630 node = parser->lex_from_node;
1631
1632 if (node == NULL) {
1633 talloc_free (parser->lex_from_list);
1634 parser->lex_from_list = NULL;
1635 return NEWLINE;
1636 }
1637
1638 *yylval = node->token->value;
1639 ret = node->token->type;
1640
1641 parser->lex_from_node = node->next;
1642
1643 return ret;
1644}
1645
1646static void
1647glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
1648{
1649 token_node_t *node;
1650
1651 assert (parser->lex_from_list == NULL);
1652
1653 /* Copy list, eliminating any space tokens. */
1654 parser->lex_from_list = _token_list_create (parser);
1655
1656 for (node = list->head; node; node = node->next) {
1657 if (node->token->type == SPACE)
1658 continue;
1659 _token_list_append (parser->lex_from_list, node->token);
1660 }
1661
1662 talloc_free (list);
1663
1664 parser->lex_from_node = parser->lex_from_list->head;
1665
1666 /* It's possible the list consisted of nothing but whitespace. */
1667 if (parser->lex_from_node == NULL) {
1668 talloc_free (parser->lex_from_list);
1669 parser->lex_from_list = NULL;
1670 }
1671}
1672
1673static void
1674_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
1675 int condition)
1676{
1677 skip_type_t current = SKIP_NO_SKIP;
1678 skip_node_t *node;
1679
1680 if (parser->skip_stack)
1681 current = parser->skip_stack->type;
1682
1683 node = talloc (parser, skip_node_t);
1684 node->loc = *loc;
1685
1686 if (current == SKIP_NO_SKIP) {
1687 if (condition)
1688 node->type = SKIP_NO_SKIP;
1689 else
1690 node->type = SKIP_TO_ELSE;
1691 } else {
1692 node->type = SKIP_TO_ENDIF;
1693 }
1694
1695 node->next = parser->skip_stack;
1696 parser->skip_stack = node;
1697}
1698
1699static void
1700_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
1701 const char *type, int condition)
1702{
1703 if (parser->skip_stack == NULL) {
1704 glcpp_error (loc, parser, "%s without #if\n", type);
1705 return;
1706 }
1707
1708 if (parser->skip_stack->type == SKIP_TO_ELSE) {
1709 if (condition)
1710 parser->skip_stack->type = SKIP_NO_SKIP;
1711 } else {
1712 parser->skip_stack->type = SKIP_TO_ENDIF;
1713 }
1714}
1715
1716static void
1717_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
1718{
1719 skip_node_t *node;
1720
1721 if (parser->skip_stack == NULL) {
1722 glcpp_error (loc, parser, "#endif without #if\n");
1723 return;
1724 }
1725
1726 node = parser->skip_stack;
1727 parser->skip_stack = node->next;
1728 talloc_free (node);
1729}
diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c
new file mode 100644
index 00000000000..a245cb54060
--- /dev/null
+++ b/src/glsl/glcpp/glcpp.c
@@ -0,0 +1,85 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <fcntl.h>
27#include <unistd.h>
28#include "glcpp.h"
29
30extern int yydebug;
31
32static char *
33load_text_file(void *ctx, const char *file_name)
34{
35 char *text = NULL;
36 struct stat st;
37 ssize_t total_read = 0;
38 int fd = file_name == NULL ? STDIN_FILENO : open(file_name, O_RDONLY);
39
40 if (fd < 0) {
41 return NULL;
42 }
43
44 if (fstat(fd, & st) == 0) {
45 text = (char *) talloc_size(ctx, st.st_size + 1);
46 if (text != NULL) {
47 do {
48 ssize_t bytes = read(fd, text + total_read,
49 st.st_size - total_read);
50 if (bytes < 0) {
51 text = NULL;
52 break;
53 }
54
55 if (bytes == 0) {
56 break;
57 }
58
59 total_read += bytes;
60 } while (total_read < st.st_size);
61
62 text[total_read] = '\0';
63 }
64 }
65
66 close(fd);
67
68 return text;
69}
70
71int
72main (void)
73{
74 void *ctx = talloc(NULL, void*);
75 const char *shader = load_text_file(ctx, NULL);
76 char *info_log = talloc_strdup(ctx, "");
77 int ret = preprocess(ctx, &shader, &info_log, NULL);
78
79 printf("%s", shader);
80 fprintf(stderr, "%s", info_log);
81
82 talloc_free(ctx);
83
84 return ret;
85}
diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h
new file mode 100644
index 00000000000..0bebdb9ae8c
--- /dev/null
+++ b/src/glsl/glcpp/glcpp.h
@@ -0,0 +1,222 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef GLCPP_H
25#define GLCPP_H
26
27#include <stdint.h>
28
29#include <talloc.h>
30
31#include "program/hash_table.h"
32
33#define yyscan_t void*
34
35/* Some data types used for parser values. */
36
37typedef struct string_node {
38 const char *str;
39 struct string_node *next;
40} string_node_t;
41
42typedef struct string_list {
43 string_node_t *head;
44 string_node_t *tail;
45} string_list_t;
46
47typedef struct token token_t;
48typedef struct token_list token_list_t;
49
50typedef union YYSTYPE
51{
52 intmax_t ival;
53 char *str;
54 string_list_t *string_list;
55 token_t *token;
56 token_list_t *token_list;
57} YYSTYPE;
58
59# define YYSTYPE_IS_TRIVIAL 1
60# define YYSTYPE_IS_DECLARED 1
61
62typedef struct YYLTYPE {
63 int first_line;
64 int first_column;
65 int last_line;
66 int last_column;
67 unsigned source;
68} YYLTYPE;
69# define YYLTYPE_IS_DECLARED 1
70# define YYLTYPE_IS_TRIVIAL 1
71
72# define YYLLOC_DEFAULT(Current, Rhs, N) \
73do { \
74 if (N) \
75 { \
76 (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
77 (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
78 (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
79 (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
80 } \
81 else \
82 { \
83 (Current).first_line = (Current).last_line = \
84 YYRHSLOC(Rhs, 0).last_line; \
85 (Current).first_column = (Current).last_column = \
86 YYRHSLOC(Rhs, 0).last_column; \
87 } \
88 (Current).source = 0; \
89} while (0)
90
91struct token {
92 int type;
93 YYSTYPE value;
94 YYLTYPE location;
95};
96
97typedef struct token_node {
98 token_t *token;
99 struct token_node *next;
100} token_node_t;
101
102struct token_list {
103 token_node_t *head;
104 token_node_t *tail;
105 token_node_t *non_space_tail;
106};
107
108typedef struct argument_node {
109 token_list_t *argument;
110 struct argument_node *next;
111} argument_node_t;
112
113typedef struct argument_list {
114 argument_node_t *head;
115 argument_node_t *tail;
116} argument_list_t;
117
118typedef struct glcpp_parser glcpp_parser_t;
119
120typedef enum {
121 TOKEN_CLASS_IDENTIFIER,
122 TOKEN_CLASS_IDENTIFIER_FINALIZED,
123 TOKEN_CLASS_FUNC_MACRO,
124 TOKEN_CLASS_OBJ_MACRO
125} token_class_t;
126
127token_class_t
128glcpp_parser_classify_token (glcpp_parser_t *parser,
129 const char *identifier,
130 int *parameter_index);
131
132typedef struct {
133 int is_function;
134 string_list_t *parameters;
135 const char *identifier;
136 token_list_t *replacements;
137} macro_t;
138
139typedef struct expansion_node {
140 macro_t *macro;
141 token_node_t *replacements;
142 struct expansion_node *next;
143} expansion_node_t;
144
145typedef enum skip_type {
146 SKIP_NO_SKIP,
147 SKIP_TO_ELSE,
148 SKIP_TO_ENDIF
149} skip_type_t;
150
151typedef struct skip_node {
152 skip_type_t type;
153 YYLTYPE loc; /* location of the initial #if/#elif/... */
154 struct skip_node *next;
155} skip_node_t;
156
157typedef struct active_list {
158 const char *identifier;
159 token_node_t *marker;
160 struct active_list *next;
161} active_list_t;
162
163struct glcpp_parser {
164 yyscan_t scanner;
165 struct hash_table *defines;
166 active_list_t *active;
167 int lexing_if;
168 int space_tokens;
169 int newline_as_space;
170 int in_control_line;
171 int paren_count;
172 skip_node_t *skip_stack;
173 token_list_t *lex_from_list;
174 token_node_t *lex_from_node;
175 char *output;
176 char *info_log;
177 int error;
178};
179
180struct gl_extensions;
181
182glcpp_parser_t *
183glcpp_parser_create (const struct gl_extensions *extensions);
184
185int
186glcpp_parser_parse (glcpp_parser_t *parser);
187
188void
189glcpp_parser_destroy (glcpp_parser_t *parser);
190
191int
192preprocess(void *talloc_ctx, const char **shader, char **info_log,
193 const struct gl_extensions *extensions);
194
195/* Functions for writing to the info log */
196
197void
198glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...);
199
200void
201glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...);
202
203/* Generated by glcpp-lex.l to glcpp-lex.c */
204
205int
206glcpp_lex_init_extra (glcpp_parser_t *parser, yyscan_t* scanner);
207
208void
209glcpp_lex_set_source_string(glcpp_parser_t *parser, const char *shader);
210
211int
212glcpp_lex (YYSTYPE *lvalp, YYLTYPE *llocp, yyscan_t scanner);
213
214int
215glcpp_lex_destroy (yyscan_t scanner);
216
217/* Generated by glcpp-parse.y to glcpp-parse.c */
218
219int
220yyparse (glcpp_parser_t *parser);
221
222#endif
diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c
new file mode 100644
index 00000000000..7672490958d
--- /dev/null
+++ b/src/glsl/glcpp/pp.c
@@ -0,0 +1,166 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <assert.h>
25#include <string.h>
26#include <ctype.h>
27#include "glcpp.h"
28
29void
30glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
31{
32 va_list ap;
33
34 parser->error = 1;
35 parser->info_log = talloc_asprintf_append(parser->info_log,
36 "%u:%u(%u): "
37 "preprocessor error: ",
38 locp->source,
39 locp->first_line,
40 locp->first_column);
41 va_start(ap, fmt);
42 parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
43 va_end(ap);
44 parser->info_log = talloc_strdup_append(parser->info_log, "\n");
45}
46
47void
48glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...)
49{
50 va_list ap;
51
52 parser->info_log = talloc_asprintf_append(parser->info_log,
53 "%u:%u(%u): "
54 "preprocessor warning: ",
55 locp->source,
56 locp->first_line,
57 locp->first_column);
58 va_start(ap, fmt);
59 parser->info_log = talloc_vasprintf_append(parser->info_log, fmt, ap);
60 va_end(ap);
61 parser->info_log = talloc_strdup_append(parser->info_log, "\n");
62}
63
64/* Searches backwards for '^ *#' from a given starting point. */
65static int
66in_directive(const char *shader, const char *ptr)
67{
68 assert(ptr >= shader);
69
70 /* Search backwards for '#'. If we find a \n first, it doesn't count */
71 for (; ptr >= shader && *ptr != '#'; ptr--) {
72 if (*ptr == '\n')
73 return 0;
74 }
75 if (ptr >= shader) {
76 /* Found '#'...look for spaces preceded by a newline */
77 for (ptr--; ptr >= shader && isblank(*ptr); ptr--);
78 // FIXME: I don't think the '\n' case can happen
79 if (ptr < shader || *ptr == '\n')
80 return 1;
81 }
82 return 0;
83}
84
85/* Remove any line continuation characters in preprocessing directives.
86 * However, ignore any in GLSL code, as "There is no line continuation
87 * character" (1.30 page 9) in GLSL.
88 */
89static char *
90remove_line_continuations(glcpp_parser_t *ctx, const char *shader)
91{
92 int in_continued_line = 0;
93 int extra_newlines = 0;
94 char *clean = talloc_strdup(ctx, "");
95 const char *search_start = shader;
96 const char *newline;
97 while ((newline = strchr(search_start, '\n')) != NULL) {
98 const char *backslash = NULL;
99
100 /* # of characters preceding the newline. */
101 int n = newline - shader;
102
103 /* Find the preceding '\', if it exists */
104 if (n >= 1 && newline[-1] == '\\')
105 backslash = newline - 1;
106 else if (n >= 2 && newline[-1] == '\r' && newline[-2] == '\\')
107 backslash = newline - 2;
108
109 /* Double backslashes don't count (the backslash is escaped) */
110 if (backslash != NULL && backslash[-1] == '\\') {
111 backslash = NULL;
112 }
113
114 if (backslash != NULL) {
115 /* We found a line continuation, but do we care? */
116 if (!in_continued_line) {
117 if (in_directive(shader, backslash)) {
118 in_continued_line = 1;
119 extra_newlines = 0;
120 }
121 }
122 if (in_continued_line) {
123 /* Copy everything before the \ */
124 clean = talloc_strndup_append(clean, shader, backslash - shader);
125 shader = newline + 1;
126 extra_newlines++;
127 }
128 } else if (in_continued_line) {
129 /* Copy everything up to and including the \n */
130 clean = talloc_strndup_append(clean, shader, newline - shader + 1);
131 shader = newline + 1;
132 /* Output extra newlines to make line numbers match */
133 for (; extra_newlines > 0; extra_newlines--)
134 clean = talloc_strdup_append(clean, "\n");
135 in_continued_line = 0;
136 }
137 search_start = newline + 1;
138 }
139 clean = talloc_strdup_append(clean, shader);
140 return clean;
141}
142
143extern int
144preprocess(void *talloc_ctx, const char **shader, char **info_log,
145 const struct gl_extensions *extensions)
146{
147 int errors;
148 glcpp_parser_t *parser = glcpp_parser_create (extensions);
149 *shader = remove_line_continuations(parser, *shader);
150
151 glcpp_lex_set_source_string (parser, *shader);
152
153 glcpp_parser_parse (parser);
154
155 if (parser->skip_stack)
156 glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
157
158 *info_log = talloc_strdup_append(*info_log, parser->info_log);
159
160 talloc_steal(talloc_ctx, parser->output);
161 *shader = parser->output;
162
163 errors = parser->error;
164 glcpp_parser_destroy (parser);
165 return errors;
166}
diff --git a/src/glsl/glcpp/tests/000-content-with-spaces.c b/src/glsl/glcpp/tests/000-content-with-spaces.c
new file mode 100644
index 00000000000..696cb3a74fc
--- /dev/null
+++ b/src/glsl/glcpp/tests/000-content-with-spaces.c
@@ -0,0 +1 @@
this is four tokens
diff --git a/src/glsl/glcpp/tests/000-content-with-spaces.c.expected b/src/glsl/glcpp/tests/000-content-with-spaces.c.expected
new file mode 100644
index 00000000000..83f7834d547
--- /dev/null
+++ b/src/glsl/glcpp/tests/000-content-with-spaces.c.expected
@@ -0,0 +1,2 @@
1this is four tokens
2
diff --git a/src/glsl/glcpp/tests/001-define.c b/src/glsl/glcpp/tests/001-define.c
new file mode 100644
index 00000000000..cbf2fee0e75
--- /dev/null
+++ b/src/glsl/glcpp/tests/001-define.c
@@ -0,0 +1,2 @@
1#define foo 1
2foo
diff --git a/src/glsl/glcpp/tests/001-define.c.expected b/src/glsl/glcpp/tests/001-define.c.expected
new file mode 100644
index 00000000000..878fd15d6f8
--- /dev/null
+++ b/src/glsl/glcpp/tests/001-define.c.expected
@@ -0,0 +1,3 @@
1
21
3
diff --git a/src/glsl/glcpp/tests/002-define-chain.c b/src/glsl/glcpp/tests/002-define-chain.c
new file mode 100644
index 00000000000..87d75c68751
--- /dev/null
+++ b/src/glsl/glcpp/tests/002-define-chain.c
@@ -0,0 +1,3 @@
1#define foo 1
2#define bar foo
3bar
diff --git a/src/glsl/glcpp/tests/002-define-chain.c.expected b/src/glsl/glcpp/tests/002-define-chain.c.expected
new file mode 100644
index 00000000000..43d484d7131
--- /dev/null
+++ b/src/glsl/glcpp/tests/002-define-chain.c.expected
@@ -0,0 +1,4 @@
1
2
31
4
diff --git a/src/glsl/glcpp/tests/003-define-chain-reverse.c b/src/glsl/glcpp/tests/003-define-chain-reverse.c
new file mode 100644
index 00000000000..a18b724eca0
--- /dev/null
+++ b/src/glsl/glcpp/tests/003-define-chain-reverse.c
@@ -0,0 +1,3 @@
1#define bar foo
2#define foo 1
3bar
diff --git a/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected b/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected
new file mode 100644
index 00000000000..43d484d7131
--- /dev/null
+++ b/src/glsl/glcpp/tests/003-define-chain-reverse.c.expected
@@ -0,0 +1,4 @@
1
2
31
4
diff --git a/src/glsl/glcpp/tests/004-define-recursive.c b/src/glsl/glcpp/tests/004-define-recursive.c
new file mode 100644
index 00000000000..2ac56ea3dcf
--- /dev/null
+++ b/src/glsl/glcpp/tests/004-define-recursive.c
@@ -0,0 +1,6 @@
1#define foo bar
2#define bar baz
3#define baz foo
4foo
5bar
6baz
diff --git a/src/glsl/glcpp/tests/004-define-recursive.c.expected b/src/glsl/glcpp/tests/004-define-recursive.c.expected
new file mode 100644
index 00000000000..4d2698b7a7f
--- /dev/null
+++ b/src/glsl/glcpp/tests/004-define-recursive.c.expected
@@ -0,0 +1,7 @@
1
2
3
4foo
5bar
6baz
7
diff --git a/src/glsl/glcpp/tests/005-define-composite-chain.c b/src/glsl/glcpp/tests/005-define-composite-chain.c
new file mode 100644
index 00000000000..f5521df968d
--- /dev/null
+++ b/src/glsl/glcpp/tests/005-define-composite-chain.c
@@ -0,0 +1,3 @@
1#define foo 1
2#define bar a foo
3bar
diff --git a/src/glsl/glcpp/tests/005-define-composite-chain.c.expected b/src/glsl/glcpp/tests/005-define-composite-chain.c.expected
new file mode 100644
index 00000000000..c67358f4f69
--- /dev/null
+++ b/src/glsl/glcpp/tests/005-define-composite-chain.c.expected
@@ -0,0 +1,4 @@
1
2
3a 1
4
diff --git a/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c
new file mode 100644
index 00000000000..4bb91a1221a
--- /dev/null
+++ b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c
@@ -0,0 +1,3 @@
1#define bar a foo
2#define foo 1
3bar
diff --git a/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected
new file mode 100644
index 00000000000..c67358f4f69
--- /dev/null
+++ b/src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected
@@ -0,0 +1,4 @@
1
2
3a 1
4
diff --git a/src/glsl/glcpp/tests/007-define-composite-recursive.c b/src/glsl/glcpp/tests/007-define-composite-recursive.c
new file mode 100644
index 00000000000..5784565bdf3
--- /dev/null
+++ b/src/glsl/glcpp/tests/007-define-composite-recursive.c
@@ -0,0 +1,6 @@
1#define foo a bar
2#define bar b baz
3#define baz c foo
4foo
5bar
6baz
diff --git a/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected b/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected
new file mode 100644
index 00000000000..30fe4dc1f62
--- /dev/null
+++ b/src/glsl/glcpp/tests/007-define-composite-recursive.c.expected
@@ -0,0 +1,7 @@
1
2
3
4a b c foo
5b c a bar
6c a b baz
7
diff --git a/src/glsl/glcpp/tests/008-define-empty.c b/src/glsl/glcpp/tests/008-define-empty.c
new file mode 100644
index 00000000000..b1bd17ec215
--- /dev/null
+++ b/src/glsl/glcpp/tests/008-define-empty.c
@@ -0,0 +1,2 @@
1#define foo
2foo
diff --git a/src/glsl/glcpp/tests/008-define-empty.c.expected b/src/glsl/glcpp/tests/008-define-empty.c.expected
new file mode 100644
index 00000000000..c0f53d75c71
--- /dev/null
+++ b/src/glsl/glcpp/tests/008-define-empty.c.expected
@@ -0,0 +1,3 @@
1
2
3
diff --git a/src/glsl/glcpp/tests/009-undef.c b/src/glsl/glcpp/tests/009-undef.c
new file mode 100644
index 00000000000..3fc1fb44243
--- /dev/null
+++ b/src/glsl/glcpp/tests/009-undef.c
@@ -0,0 +1,4 @@
1#define foo 1
2foo
3#undef foo
4foo
diff --git a/src/glsl/glcpp/tests/009-undef.c.expected b/src/glsl/glcpp/tests/009-undef.c.expected
new file mode 100644
index 00000000000..03a7061af03
--- /dev/null
+++ b/src/glsl/glcpp/tests/009-undef.c.expected
@@ -0,0 +1,5 @@
1
21
3
4foo
5
diff --git a/src/glsl/glcpp/tests/010-undef-re-define.c b/src/glsl/glcpp/tests/010-undef-re-define.c
new file mode 100644
index 00000000000..32ff73798b1
--- /dev/null
+++ b/src/glsl/glcpp/tests/010-undef-re-define.c
@@ -0,0 +1,6 @@
1#define foo 1
2foo
3#undef foo
4foo
5#define foo 2
6foo
diff --git a/src/glsl/glcpp/tests/010-undef-re-define.c.expected b/src/glsl/glcpp/tests/010-undef-re-define.c.expected
new file mode 100644
index 00000000000..f4f7efdc2bf
--- /dev/null
+++ b/src/glsl/glcpp/tests/010-undef-re-define.c.expected
@@ -0,0 +1,7 @@
1
21
3
4foo
5
62
7
diff --git a/src/glsl/glcpp/tests/011-define-func-empty.c b/src/glsl/glcpp/tests/011-define-func-empty.c
new file mode 100644
index 00000000000..d9ce13c2284
--- /dev/null
+++ b/src/glsl/glcpp/tests/011-define-func-empty.c
@@ -0,0 +1,2 @@
1#define foo()
2foo()
diff --git a/src/glsl/glcpp/tests/011-define-func-empty.c.expected b/src/glsl/glcpp/tests/011-define-func-empty.c.expected
new file mode 100644
index 00000000000..c0f53d75c71
--- /dev/null
+++ b/src/glsl/glcpp/tests/011-define-func-empty.c.expected
@@ -0,0 +1,3 @@
1
2
3
diff --git a/src/glsl/glcpp/tests/012-define-func-no-args.c b/src/glsl/glcpp/tests/012-define-func-no-args.c
new file mode 100644
index 00000000000..c2bb730b115
--- /dev/null
+++ b/src/glsl/glcpp/tests/012-define-func-no-args.c
@@ -0,0 +1,2 @@
1#define foo() bar
2foo()
diff --git a/src/glsl/glcpp/tests/012-define-func-no-args.c.expected b/src/glsl/glcpp/tests/012-define-func-no-args.c.expected
new file mode 100644
index 00000000000..03537672974
--- /dev/null
+++ b/src/glsl/glcpp/tests/012-define-func-no-args.c.expected
@@ -0,0 +1,3 @@
1
2bar
3
diff --git a/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c
new file mode 100644
index 00000000000..f78fb8b118a
--- /dev/null
+++ b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c
@@ -0,0 +1,2 @@
1#define foo(x) 1
2foo(bar)
diff --git a/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected
new file mode 100644
index 00000000000..878fd15d6f8
--- /dev/null
+++ b/src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected
@@ -0,0 +1,3 @@
1
21
3
diff --git a/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c
new file mode 100644
index 00000000000..11feb2624b7
--- /dev/null
+++ b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c
@@ -0,0 +1,2 @@
1#define foo(x,y) 1
2foo(bar,baz)
diff --git a/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected
new file mode 100644
index 00000000000..878fd15d6f8
--- /dev/null
+++ b/src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected
@@ -0,0 +1,3 @@
1
21
3
diff --git a/src/glsl/glcpp/tests/015-define-object-with-parens.c b/src/glsl/glcpp/tests/015-define-object-with-parens.c
new file mode 100644
index 00000000000..558da9c617b
--- /dev/null
+++ b/src/glsl/glcpp/tests/015-define-object-with-parens.c
@@ -0,0 +1,4 @@
1#define foo ()1
2foo()
3#define bar ()2
4bar()
diff --git a/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected b/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected
new file mode 100644
index 00000000000..d6f8cb9dc61
--- /dev/null
+++ b/src/glsl/glcpp/tests/015-define-object-with-parens.c.expected
@@ -0,0 +1,5 @@
1
2()1()
3
4()2()
5
diff --git a/src/glsl/glcpp/tests/016-define-func-1-arg.c b/src/glsl/glcpp/tests/016-define-func-1-arg.c
new file mode 100644
index 00000000000..a2e2404c7c1
--- /dev/null
+++ b/src/glsl/glcpp/tests/016-define-func-1-arg.c
@@ -0,0 +1,2 @@
1#define foo(x) ((x)+1)
2foo(bar)
diff --git a/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected b/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected
new file mode 100644
index 00000000000..7f1828a3c61
--- /dev/null
+++ b/src/glsl/glcpp/tests/016-define-func-1-arg.c.expected
@@ -0,0 +1,3 @@
1
2((bar)+1)
3
diff --git a/src/glsl/glcpp/tests/017-define-func-2-args.c b/src/glsl/glcpp/tests/017-define-func-2-args.c
new file mode 100644
index 00000000000..c7253835278
--- /dev/null
+++ b/src/glsl/glcpp/tests/017-define-func-2-args.c
@@ -0,0 +1,2 @@
1#define foo(x,y) ((x)*(y))
2foo(bar,baz)
diff --git a/src/glsl/glcpp/tests/017-define-func-2-args.c.expected b/src/glsl/glcpp/tests/017-define-func-2-args.c.expected
new file mode 100644
index 00000000000..9f341dac00a
--- /dev/null
+++ b/src/glsl/glcpp/tests/017-define-func-2-args.c.expected
@@ -0,0 +1,3 @@
1
2((bar)*(baz))
3
diff --git a/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c
new file mode 100644
index 00000000000..668130b8f9b
--- /dev/null
+++ b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c
@@ -0,0 +1,3 @@
1#define x 0
2#define foo(x) x
3foo(1)
diff --git a/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected
new file mode 100644
index 00000000000..43d484d7131
--- /dev/null
+++ b/src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected
@@ -0,0 +1,4 @@
1
2
31
4
diff --git a/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c
new file mode 100644
index 00000000000..c4e62b25508
--- /dev/null
+++ b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c
@@ -0,0 +1,2 @@
1#define foo(x) (x)
2foo(this is more than one word)
diff --git a/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected
new file mode 100644
index 00000000000..4314fc88d83
--- /dev/null
+++ b/src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected
@@ -0,0 +1,3 @@
1
2(this is more than one word)
3
diff --git a/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c
new file mode 100644
index 00000000000..3049ad15465
--- /dev/null
+++ b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c
@@ -0,0 +1,2 @@
1#define foo(x,y) x,two fish,red fish,y
2foo(one fish, blue fish)
diff --git a/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected
new file mode 100644
index 00000000000..5648e4fb9d4
--- /dev/null
+++ b/src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected
@@ -0,0 +1,3 @@
1
2one fish,two fish,red fish,blue fish
3
diff --git a/src/glsl/glcpp/tests/021-define-func-compose.c b/src/glsl/glcpp/tests/021-define-func-compose.c
new file mode 100644
index 00000000000..21ddd0e65f9
--- /dev/null
+++ b/src/glsl/glcpp/tests/021-define-func-compose.c
@@ -0,0 +1,3 @@
1#define bar(x) (1+(x))
2#define foo(y) (2*(y))
3foo(bar(3))
diff --git a/src/glsl/glcpp/tests/021-define-func-compose.c.expected b/src/glsl/glcpp/tests/021-define-func-compose.c.expected
new file mode 100644
index 00000000000..1d62105de4c
--- /dev/null
+++ b/src/glsl/glcpp/tests/021-define-func-compose.c.expected
@@ -0,0 +1,4 @@
1
2
3(2*((1+(3))))
4
diff --git a/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c
new file mode 100644
index 00000000000..c20d73a4a28
--- /dev/null
+++ b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c
@@ -0,0 +1,2 @@
1#define foo(x) (x)
2foo(argument(including parens)for the win)
diff --git a/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected
new file mode 100644
index 00000000000..66c16581758
--- /dev/null
+++ b/src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected
@@ -0,0 +1,3 @@
1
2(argument(including parens)for the win)
3
diff --git a/src/glsl/glcpp/tests/023-define-extra-whitespace.c b/src/glsl/glcpp/tests/023-define-extra-whitespace.c
new file mode 100644
index 00000000000..7ebfed6516c
--- /dev/null
+++ b/src/glsl/glcpp/tests/023-define-extra-whitespace.c
@@ -0,0 +1,8 @@
1#define noargs() 1
2# define onearg(foo) foo
3 # define twoargs( x , y ) x y
4 # define threeargs( a , b , c ) a b c
5noargs ( )
6onearg ( 2 )
7twoargs ( 3 , 4 )
8threeargs ( 5 , 6 , 7 )
diff --git a/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected b/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected
new file mode 100644
index 00000000000..573829c2d69
--- /dev/null
+++ b/src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected
@@ -0,0 +1,9 @@
1
2
3
4
51
62
73 4
85 6 7
9
diff --git a/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c
new file mode 100644
index 00000000000..e788adce30c
--- /dev/null
+++ b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c
@@ -0,0 +1,3 @@
1#define foo foo
2#define bar foo
3bar
diff --git a/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected
new file mode 100644
index 00000000000..ad955fce6ec
--- /dev/null
+++ b/src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected
@@ -0,0 +1,4 @@
1
2
3foo
4
diff --git a/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c
new file mode 100644
index 00000000000..b433671d1bf
--- /dev/null
+++ b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c
@@ -0,0 +1,2 @@
1#define foo(bar) bar
2foo bar
diff --git a/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected
new file mode 100644
index 00000000000..960f44511a9
--- /dev/null
+++ b/src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected
@@ -0,0 +1,3 @@
1
2foo bar
3
diff --git a/src/glsl/glcpp/tests/026-define-func-extra-newlines.c b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c
new file mode 100644
index 00000000000..0d837405309
--- /dev/null
+++ b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c
@@ -0,0 +1,6 @@
1#define foo(a) bar
2
3foo
4(
51
6)
diff --git a/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected
new file mode 100644
index 00000000000..f0888f21b94
--- /dev/null
+++ b/src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected
@@ -0,0 +1,4 @@
1
2
3bar
4
diff --git a/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c
new file mode 100644
index 00000000000..5ccb52caba5
--- /dev/null
+++ b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c
@@ -0,0 +1,3 @@
1#define failure() success
2#define foo failure()
3foo
diff --git a/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected
new file mode 100644
index 00000000000..aef762e1e69
--- /dev/null
+++ b/src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected
@@ -0,0 +1,4 @@
1
2
3success
4
diff --git a/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c
new file mode 100644
index 00000000000..44962a71876
--- /dev/null
+++ b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c
@@ -0,0 +1,3 @@
1#define success() failure
2#define foo success
3foo
diff --git a/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected
new file mode 100644
index 00000000000..aef762e1e69
--- /dev/null
+++ b/src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected
@@ -0,0 +1,4 @@
1
2
3success
4
diff --git a/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c
new file mode 100644
index 00000000000..261f7d28fc2
--- /dev/null
+++ b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c
@@ -0,0 +1,3 @@
1#define bar(failure) failure
2#define foo bar(success)
3foo
diff --git a/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected
new file mode 100644
index 00000000000..aef762e1e69
--- /dev/null
+++ b/src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected
@@ -0,0 +1,4 @@
1
2
3success
4
diff --git a/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c
new file mode 100644
index 00000000000..e56fbefd62d
--- /dev/null
+++ b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c
@@ -0,0 +1,4 @@
1#define baz(failure) failure
2#define bar(failure) failure
3#define foo bar(baz(success))
4foo
diff --git a/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected
new file mode 100644
index 00000000000..729bdd15f80
--- /dev/null
+++ b/src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected
@@ -0,0 +1,5 @@
1
2
3
4success
5
diff --git a/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c
new file mode 100644
index 00000000000..3f4c8744dff
--- /dev/null
+++ b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c
@@ -0,0 +1,4 @@
1#define baz(failure) failure
2#define bar(failure) failure
3#define foo() bar(baz(success))
4foo()
diff --git a/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected
new file mode 100644
index 00000000000..729bdd15f80
--- /dev/null
+++ b/src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected
@@ -0,0 +1,5 @@
1
2
3
4success
5
diff --git a/src/glsl/glcpp/tests/032-define-func-self-recurse.c b/src/glsl/glcpp/tests/032-define-func-self-recurse.c
new file mode 100644
index 00000000000..b3ac70f499c
--- /dev/null
+++ b/src/glsl/glcpp/tests/032-define-func-self-recurse.c
@@ -0,0 +1,2 @@
1#define foo(a) foo(2*(a))
2foo(3)
diff --git a/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected b/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected
new file mode 100644
index 00000000000..541d44db7ab
--- /dev/null
+++ b/src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected
@@ -0,0 +1,3 @@
1
2foo(2*(3))
3
diff --git a/src/glsl/glcpp/tests/033-define-func-self-compose.c b/src/glsl/glcpp/tests/033-define-func-self-compose.c
new file mode 100644
index 00000000000..f65e48286cf
--- /dev/null
+++ b/src/glsl/glcpp/tests/033-define-func-self-compose.c
@@ -0,0 +1,2 @@
1#define foo(a) foo(2*(a))
2foo(foo(3))
diff --git a/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected b/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected
new file mode 100644
index 00000000000..6ea6905d80b
--- /dev/null
+++ b/src/glsl/glcpp/tests/033-define-func-self-compose.c.expected
@@ -0,0 +1,3 @@
1
2foo(2*(foo(2*(3))))
3
diff --git a/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c
new file mode 100644
index 00000000000..209a5f7e07c
--- /dev/null
+++ b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c
@@ -0,0 +1,2 @@
1#define foo(bar) bar
2foo(foo)
diff --git a/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected
new file mode 100644
index 00000000000..24823b1b673
--- /dev/null
+++ b/src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected
@@ -0,0 +1,3 @@
1
2foo
3
diff --git a/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c
new file mode 100644
index 00000000000..c307fbe830f
--- /dev/null
+++ b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c
@@ -0,0 +1,2 @@
1#define foo(bar) bar
2foo(1+foo)
diff --git a/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected
new file mode 100644
index 00000000000..137a9ea2db8
--- /dev/null
+++ b/src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected
@@ -0,0 +1,3 @@
1
21+foo
3
diff --git a/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c
new file mode 100644
index 00000000000..b21ff336738
--- /dev/null
+++ b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c
@@ -0,0 +1,3 @@
1#define bar success
2#define foo(x) x
3foo(more bar)
diff --git a/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected
new file mode 100644
index 00000000000..ff6360bfe4e
--- /dev/null
+++ b/src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected
@@ -0,0 +1,4 @@
1
2
3more success
4
diff --git a/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c
new file mode 100644
index 00000000000..b3a2f37f1b9
--- /dev/null
+++ b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c
@@ -0,0 +1,3 @@
1#define expand(x) expand(x once)
2#define foo(x) x
3foo(expand(just))
diff --git a/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected
new file mode 100644
index 00000000000..cbadee848a5
--- /dev/null
+++ b/src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected
@@ -0,0 +1,4 @@
1
2
3expand(just once)
4
diff --git a/src/glsl/glcpp/tests/038-func-arg-with-commas.c b/src/glsl/glcpp/tests/038-func-arg-with-commas.c
new file mode 100644
index 00000000000..1407c7d6e3c
--- /dev/null
+++ b/src/glsl/glcpp/tests/038-func-arg-with-commas.c
@@ -0,0 +1,2 @@
1#define foo(x) success
2foo(argument (with,embedded , commas) -- tricky)
diff --git a/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected b/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected
new file mode 100644
index 00000000000..5a28fb3b66c
--- /dev/null
+++ b/src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected
@@ -0,0 +1,3 @@
1
2success
3
diff --git a/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c
new file mode 100644
index 00000000000..0f7fe632b56
--- /dev/null
+++ b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c
@@ -0,0 +1,3 @@
1#define foo(a) (a)
2#define bar two,words
3foo(bar)
diff --git a/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected
new file mode 100644
index 00000000000..b73869d0238
--- /dev/null
+++ b/src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected
@@ -0,0 +1,4 @@
1
2
3(two,words)
4
diff --git a/src/glsl/glcpp/tests/040-token-pasting.c b/src/glsl/glcpp/tests/040-token-pasting.c
new file mode 100644
index 00000000000..caab3ba7368
--- /dev/null
+++ b/src/glsl/glcpp/tests/040-token-pasting.c
@@ -0,0 +1,2 @@
1#define paste(a,b) a ## b
2paste(one , token)
diff --git a/src/glsl/glcpp/tests/040-token-pasting.c.expected b/src/glsl/glcpp/tests/040-token-pasting.c.expected
new file mode 100644
index 00000000000..36f66992539
--- /dev/null
+++ b/src/glsl/glcpp/tests/040-token-pasting.c.expected
@@ -0,0 +1,3 @@
1
2onetoken
3
diff --git a/src/glsl/glcpp/tests/041-if-0.c b/src/glsl/glcpp/tests/041-if-0.c
new file mode 100644
index 00000000000..2cab677d3e8
--- /dev/null
+++ b/src/glsl/glcpp/tests/041-if-0.c
@@ -0,0 +1,5 @@
1success_1
2#if 0
3failure
4#endif
5success_2
diff --git a/src/glsl/glcpp/tests/041-if-0.c.expected b/src/glsl/glcpp/tests/041-if-0.c.expected
new file mode 100644
index 00000000000..3800024c6ff
--- /dev/null
+++ b/src/glsl/glcpp/tests/041-if-0.c.expected
@@ -0,0 +1,6 @@
1success_1
2
3
4
5success_2
6
diff --git a/src/glsl/glcpp/tests/042-if-1.c b/src/glsl/glcpp/tests/042-if-1.c
new file mode 100644
index 00000000000..874a25cf41b
--- /dev/null
+++ b/src/glsl/glcpp/tests/042-if-1.c
@@ -0,0 +1,5 @@
1success_1
2#if 1
3success_2
4#endif
5success_3
diff --git a/src/glsl/glcpp/tests/042-if-1.c.expected b/src/glsl/glcpp/tests/042-if-1.c.expected
new file mode 100644
index 00000000000..e591044adbb
--- /dev/null
+++ b/src/glsl/glcpp/tests/042-if-1.c.expected
@@ -0,0 +1,6 @@
1success_1
2
3success_2
4
5success_3
6
diff --git a/src/glsl/glcpp/tests/043-if-0-else.c b/src/glsl/glcpp/tests/043-if-0-else.c
new file mode 100644
index 00000000000..323351f9dbf
--- /dev/null
+++ b/src/glsl/glcpp/tests/043-if-0-else.c
@@ -0,0 +1,7 @@
1success_1
2#if 0
3failure
4#else
5success_2
6#endif
7success_3
diff --git a/src/glsl/glcpp/tests/043-if-0-else.c.expected b/src/glsl/glcpp/tests/043-if-0-else.c.expected
new file mode 100644
index 00000000000..ee9e677096e
--- /dev/null
+++ b/src/glsl/glcpp/tests/043-if-0-else.c.expected
@@ -0,0 +1,8 @@
1success_1
2
3
4
5success_2
6
7success_3
8
diff --git a/src/glsl/glcpp/tests/044-if-1-else.c b/src/glsl/glcpp/tests/044-if-1-else.c
new file mode 100644
index 00000000000..28dfc25c6f0
--- /dev/null
+++ b/src/glsl/glcpp/tests/044-if-1-else.c
@@ -0,0 +1,7 @@
1success_1
2#if 1
3success_2
4#else
5failure
6#endif
7success_3
diff --git a/src/glsl/glcpp/tests/044-if-1-else.c.expected b/src/glsl/glcpp/tests/044-if-1-else.c.expected
new file mode 100644
index 00000000000..129f5c8542e
--- /dev/null
+++ b/src/glsl/glcpp/tests/044-if-1-else.c.expected
@@ -0,0 +1,8 @@
1success_1
2
3success_2
4
5
6
7success_3
8
diff --git a/src/glsl/glcpp/tests/045-if-0-elif.c b/src/glsl/glcpp/tests/045-if-0-elif.c
new file mode 100644
index 00000000000..e50f686d461
--- /dev/null
+++ b/src/glsl/glcpp/tests/045-if-0-elif.c
@@ -0,0 +1,11 @@
1success_1
2#if 0
3failure_1
4#elif 0
5failure_2
6#elif 1
7success_3
8#elif 1
9failure_3
10#endif
11success_4
diff --git a/src/glsl/glcpp/tests/045-if-0-elif.c.expected b/src/glsl/glcpp/tests/045-if-0-elif.c.expected
new file mode 100644
index 00000000000..97a11b4472e
--- /dev/null
+++ b/src/glsl/glcpp/tests/045-if-0-elif.c.expected
@@ -0,0 +1,12 @@
1success_1
2
3
4
5
6
7success_3
8
9
10
11success_4
12
diff --git a/src/glsl/glcpp/tests/046-if-1-elsif.c b/src/glsl/glcpp/tests/046-if-1-elsif.c
new file mode 100644
index 00000000000..130515a01ea
--- /dev/null
+++ b/src/glsl/glcpp/tests/046-if-1-elsif.c
@@ -0,0 +1,11 @@
1success_1
2#if 1
3success_2
4#elif 0
5failure_1
6#elif 1
7failure_2
8#elif 0
9failure_3
10#endif
11success_3
diff --git a/src/glsl/glcpp/tests/046-if-1-elsif.c.expected b/src/glsl/glcpp/tests/046-if-1-elsif.c.expected
new file mode 100644
index 00000000000..b928b917e3d
--- /dev/null
+++ b/src/glsl/glcpp/tests/046-if-1-elsif.c.expected
@@ -0,0 +1,12 @@
1success_1
2
3success_2
4
5
6
7
8
9
10
11success_3
12
diff --git a/src/glsl/glcpp/tests/047-if-elif-else.c b/src/glsl/glcpp/tests/047-if-elif-else.c
new file mode 100644
index 00000000000..e8f0838a9ed
--- /dev/null
+++ b/src/glsl/glcpp/tests/047-if-elif-else.c
@@ -0,0 +1,11 @@
1success_1
2#if 0
3failure_1
4#elif 0
5failure_2
6#elif 0
7failure_3
8#else
9success_2
10#endif
11success_3
diff --git a/src/glsl/glcpp/tests/047-if-elif-else.c.expected b/src/glsl/glcpp/tests/047-if-elif-else.c.expected
new file mode 100644
index 00000000000..e5b53a3fa59
--- /dev/null
+++ b/src/glsl/glcpp/tests/047-if-elif-else.c.expected
@@ -0,0 +1,12 @@
1success_1
2
3
4
5
6
7
8
9success_2
10
11success_3
12
diff --git a/src/glsl/glcpp/tests/048-if-nested.c b/src/glsl/glcpp/tests/048-if-nested.c
new file mode 100644
index 00000000000..fc4679c3be4
--- /dev/null
+++ b/src/glsl/glcpp/tests/048-if-nested.c
@@ -0,0 +1,11 @@
1success_1
2#if 0
3failure_1
4#if 1
5failure_2
6#else
7failure_3
8#endif
9failure_4
10#endif
11success_2
diff --git a/src/glsl/glcpp/tests/048-if-nested.c.expected b/src/glsl/glcpp/tests/048-if-nested.c.expected
new file mode 100644
index 00000000000..c61fd0b3159
--- /dev/null
+++ b/src/glsl/glcpp/tests/048-if-nested.c.expected
@@ -0,0 +1,12 @@
1success_1
2
3
4
5
6
7
8
9
10
11success_2
12
diff --git a/src/glsl/glcpp/tests/049-if-expression-precedence.c b/src/glsl/glcpp/tests/049-if-expression-precedence.c
new file mode 100644
index 00000000000..833ea03882a
--- /dev/null
+++ b/src/glsl/glcpp/tests/049-if-expression-precedence.c
@@ -0,0 +1,5 @@
1#if 1 + 2 * 3 + - (25 % 17 - + 1)
2failure with operator precedence
3#else
4success
5#endif
diff --git a/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected b/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected
new file mode 100644
index 00000000000..569debb0bb6
--- /dev/null
+++ b/src/glsl/glcpp/tests/049-if-expression-precedence.c.expected
@@ -0,0 +1,6 @@
1
2
3
4success
5
6
diff --git a/src/glsl/glcpp/tests/050-if-defined.c b/src/glsl/glcpp/tests/050-if-defined.c
new file mode 100644
index 00000000000..34f0f95140e
--- /dev/null
+++ b/src/glsl/glcpp/tests/050-if-defined.c
@@ -0,0 +1,17 @@
1#if defined foo
2failure_1
3#else
4success_1
5#endif
6#define foo
7#if defined foo
8success_2
9#else
10failure_2
11#endif
12#undef foo
13#if defined foo
14failure_3
15#else
16success_3
17#endif
diff --git a/src/glsl/glcpp/tests/050-if-defined.c.expected b/src/glsl/glcpp/tests/050-if-defined.c.expected
new file mode 100644
index 00000000000..3f01955ee40
--- /dev/null
+++ b/src/glsl/glcpp/tests/050-if-defined.c.expected
@@ -0,0 +1,18 @@
1
2
3
4success_1
5
6
7
8success_2
9
10
11
12
13
14
15
16success_3
17
18
diff --git a/src/glsl/glcpp/tests/051-if-relational.c b/src/glsl/glcpp/tests/051-if-relational.c
new file mode 100644
index 00000000000..c3db488e0de
--- /dev/null
+++ b/src/glsl/glcpp/tests/051-if-relational.c
@@ -0,0 +1,35 @@
1#if 3 < 2
2failure_1
3#else
4success_1
5#endif
6
7#if 3 >= 2
8success_2
9#else
10failure_2
11#endif
12
13#if 2 + 3 <= 5
14success_3
15#else
16failure_3
17#endif
18
19#if 3 - 2 == 1
20success_3
21#else
22failure_3
23#endif
24
25#if 1 > 3
26failure_4
27#else
28success_4
29#endif
30
31#if 1 != 5
32success_5
33#else
34failure_5
35#endif
diff --git a/src/glsl/glcpp/tests/051-if-relational.c.expected b/src/glsl/glcpp/tests/051-if-relational.c.expected
new file mode 100644
index 00000000000..d2b76f14576
--- /dev/null
+++ b/src/glsl/glcpp/tests/051-if-relational.c.expected
@@ -0,0 +1,36 @@
1
2
3
4success_1
5
6
7
8success_2
9
10
11
12
13
14success_3
15
16
17
18
19
20success_3
21
22
23
24
25
26
27
28success_4
29
30
31
32success_5
33
34
35
36
diff --git a/src/glsl/glcpp/tests/052-if-bitwise.c b/src/glsl/glcpp/tests/052-if-bitwise.c
new file mode 100644
index 00000000000..2d8e45eb61e
--- /dev/null
+++ b/src/glsl/glcpp/tests/052-if-bitwise.c
@@ -0,0 +1,20 @@
1#if (0xaaaaaaaa | 0x55555555) != 4294967295
2failure_1
3#else
4success_1
5#endif
6#if (0x12345678 ^ 0xfdecba98) == 4023971040
7success_2
8#else
9failure_2
10#endif
11#if (~ 0xdeadbeef) != -3735928560
12failure_3
13#else
14success_3
15#endif
16#if (0667 & 0733) == 403
17success_4
18#else
19failure_4
20#endif
diff --git a/src/glsl/glcpp/tests/052-if-bitwise.c.expected b/src/glsl/glcpp/tests/052-if-bitwise.c.expected
new file mode 100644
index 00000000000..bb5d92e8d92
--- /dev/null
+++ b/src/glsl/glcpp/tests/052-if-bitwise.c.expected
@@ -0,0 +1,21 @@
1
2
3
4success_1
5
6
7success_2
8
9
10
11
12
13
14success_3
15
16
17success_4
18
19
20
21
diff --git a/src/glsl/glcpp/tests/053-if-divide-and-shift.c b/src/glsl/glcpp/tests/053-if-divide-and-shift.c
new file mode 100644
index 00000000000..d24c54a88d1
--- /dev/null
+++ b/src/glsl/glcpp/tests/053-if-divide-and-shift.c
@@ -0,0 +1,15 @@
1#if (15 / 2) != 7
2failure_1
3#else
4success_1
5#endif
6#if (1 << 12) == 4096
7success_2
8#else
9failure_2
10#endif
11#if (31762 >> 8) != 124
12failure_3
13#else
14success_3
15#endif
diff --git a/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected b/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected
new file mode 100644
index 00000000000..f97e93673cc
--- /dev/null
+++ b/src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected
@@ -0,0 +1,16 @@
1
2
3
4success_1
5
6
7success_2
8
9
10
11
12
13
14success_3
15
16
diff --git a/src/glsl/glcpp/tests/054-if-with-macros.c b/src/glsl/glcpp/tests/054-if-with-macros.c
new file mode 100644
index 00000000000..3da79a0d96e
--- /dev/null
+++ b/src/glsl/glcpp/tests/054-if-with-macros.c
@@ -0,0 +1,34 @@
1#define one 1
2#define two 2
3#define three 3
4#define five 5
5#if five < two
6failure_1
7#else
8success_1
9#endif
10#if three >= two
11success_2
12#else
13failure_2
14#endif
15#if two + three <= five
16success_3
17#else
18failure_3
19#endif
20#if five - two == three
21success_4
22#else
23failure_4
24#endif
25#if one > three
26failure_5
27#else
28success_5
29#endif
30#if one != five
31success_6
32#else
33failure_6
34#endif
diff --git a/src/glsl/glcpp/tests/054-if-with-macros.c.expected b/src/glsl/glcpp/tests/054-if-with-macros.c.expected
new file mode 100644
index 00000000000..27ea4969628
--- /dev/null
+++ b/src/glsl/glcpp/tests/054-if-with-macros.c.expected
@@ -0,0 +1,35 @@
1
2
3
4
5
6
7
8success_1
9
10
11success_2
12
13
14
15
16success_3
17
18
19
20
21success_4
22
23
24
25
26
27
28success_5
29
30
31success_6
32
33
34
35
diff --git a/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c
new file mode 100644
index 00000000000..00f2c2346d6
--- /dev/null
+++ b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c
@@ -0,0 +1,3 @@
1#define failure() success
2#define foo failure
3foo()
diff --git a/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected
new file mode 100644
index 00000000000..aef762e1e69
--- /dev/null
+++ b/src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected
@@ -0,0 +1,4 @@
1
2
3success
4
diff --git a/src/glsl/glcpp/tests/056-macro-argument-with-comma.c b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c
new file mode 100644
index 00000000000..58701d1f25b
--- /dev/null
+++ b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c
@@ -0,0 +1,4 @@
1#define bar with,embedded,commas
2#define function(x) success
3#define foo function
4foo(bar)
diff --git a/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected
new file mode 100644
index 00000000000..729bdd15f80
--- /dev/null
+++ b/src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected
@@ -0,0 +1,5 @@
1
2
3
4success
5
diff --git a/src/glsl/glcpp/tests/057-empty-arguments.c b/src/glsl/glcpp/tests/057-empty-arguments.c
new file mode 100644
index 00000000000..6140232865d
--- /dev/null
+++ b/src/glsl/glcpp/tests/057-empty-arguments.c
@@ -0,0 +1,6 @@
1#define zero() success
2zero()
3#define one(x) success
4one()
5#define two(x,y) success
6two(,)
diff --git a/src/glsl/glcpp/tests/057-empty-arguments.c.expected b/src/glsl/glcpp/tests/057-empty-arguments.c.expected
new file mode 100644
index 00000000000..4e3aad52173
--- /dev/null
+++ b/src/glsl/glcpp/tests/057-empty-arguments.c.expected
@@ -0,0 +1,7 @@
1
2success
3
4success
5
6success
7
diff --git a/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c
new file mode 100644
index 00000000000..8ac260c76b6
--- /dev/null
+++ b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c
@@ -0,0 +1,5 @@
1#define paste(x,y) x ## y
2paste(a,b)
3paste(a,)
4paste(,b)
5paste(,)
diff --git a/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected
new file mode 100644
index 00000000000..a1c34e5c1f8
--- /dev/null
+++ b/src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected
@@ -0,0 +1,6 @@
1
2ab
3a
4b
5
6
diff --git a/src/glsl/glcpp/tests/059-token-pasting-integer.c b/src/glsl/glcpp/tests/059-token-pasting-integer.c
new file mode 100644
index 00000000000..37b895a4237
--- /dev/null
+++ b/src/glsl/glcpp/tests/059-token-pasting-integer.c
@@ -0,0 +1,4 @@
1#define paste(x,y) x ## y
2paste(1,2)
3paste(1,000)
4paste(identifier,2)
diff --git a/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected b/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected
new file mode 100644
index 00000000000..f1a2cd21c13
--- /dev/null
+++ b/src/glsl/glcpp/tests/059-token-pasting-integer.c.expected
@@ -0,0 +1,5 @@
1
212
31000
4identifier2
5
diff --git a/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c
new file mode 100644
index 00000000000..ed80ea879ce
--- /dev/null
+++ b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c
@@ -0,0 +1,3 @@
1#define double(a) a*2
2#define foo double(
3foo 5)
diff --git a/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected
new file mode 100644
index 00000000000..c1f0d24a144
--- /dev/null
+++ b/src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected
@@ -0,0 +1,4 @@
1
2
35*2
4
diff --git a/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c
new file mode 100644
index 00000000000..6dbfd1f62d1
--- /dev/null
+++ b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c
@@ -0,0 +1,5 @@
1#define foo(x) success
2#define bar foo
3#define baz bar
4#define joe baz
5joe (failure)
diff --git a/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected
new file mode 100644
index 00000000000..111f7d10634
--- /dev/null
+++ b/src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected
@@ -0,0 +1,6 @@
1
2
3
4
5success
6
diff --git a/src/glsl/glcpp/tests/062-if-0-skips-garbage.c b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c
new file mode 100644
index 00000000000..d9e439bb890
--- /dev/null
+++ b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c
@@ -0,0 +1,5 @@
1#define foo(a,b)
2#if 0
3foo(bar)
4foo(
5#endif
diff --git a/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected
new file mode 100644
index 00000000000..6fb66a5e2f0
--- /dev/null
+++ b/src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected
@@ -0,0 +1,6 @@
1
2
3
4
5
6
diff --git a/src/glsl/glcpp/tests/063-comments.c b/src/glsl/glcpp/tests/063-comments.c
new file mode 100644
index 00000000000..e641d2f0f9e
--- /dev/null
+++ b/src/glsl/glcpp/tests/063-comments.c
@@ -0,0 +1,20 @@
1/* this is a comment */
2// so is this
3// */
4f = g/**//h;
5/*//*/l();
6m = n//**/o
7+ p;
8/* this
9comment spans
10multiple lines and
11contains *** stars
12and slashes / *** /
13and other stuff.
14****/
15more code here
16/* Test that /* nested
17 comments */
18are not treated like comments.
19/*/ this is a comment */
20/*/*/
diff --git a/src/glsl/glcpp/tests/063-comments.c.expected b/src/glsl/glcpp/tests/063-comments.c.expected
new file mode 100644
index 00000000000..ed4feedd457
--- /dev/null
+++ b/src/glsl/glcpp/tests/063-comments.c.expected
@@ -0,0 +1,14 @@
1
2
3
4f = g /h;
5 l();
6m = n
7+ p;
8
9more code here
10
11are not treated like comments.
12
13
14
diff --git a/src/glsl/glcpp/tests/064-version.c b/src/glsl/glcpp/tests/064-version.c
new file mode 100644
index 00000000000..21326481b87
--- /dev/null
+++ b/src/glsl/glcpp/tests/064-version.c
@@ -0,0 +1,2 @@
1#version 130
2#define FOO
diff --git a/src/glsl/glcpp/tests/064-version.c.expected b/src/glsl/glcpp/tests/064-version.c.expected
new file mode 100644
index 00000000000..1c534672705
--- /dev/null
+++ b/src/glsl/glcpp/tests/064-version.c.expected
@@ -0,0 +1,4 @@
1#version 130
2
3
4
diff --git a/src/glsl/glcpp/tests/065-if-defined-parens.c b/src/glsl/glcpp/tests/065-if-defined-parens.c
new file mode 100644
index 00000000000..48aa0f8c3ef
--- /dev/null
+++ b/src/glsl/glcpp/tests/065-if-defined-parens.c
@@ -0,0 +1,17 @@
1#if defined(foo)
2failure_1
3#else
4success_1
5#endif
6#define foo
7#if defined ( foo )
8success_2
9#else
10failure_2
11#endif
12#undef foo
13#if defined (foo)
14failure_3
15#else
16success_3
17#endif
diff --git a/src/glsl/glcpp/tests/065-if-defined-parens.c.expected b/src/glsl/glcpp/tests/065-if-defined-parens.c.expected
new file mode 100644
index 00000000000..3f01955ee40
--- /dev/null
+++ b/src/glsl/glcpp/tests/065-if-defined-parens.c.expected
@@ -0,0 +1,18 @@
1
2
3
4success_1
5
6
7
8success_2
9
10
11
12
13
14
15
16success_3
17
18
diff --git a/src/glsl/glcpp/tests/066-if-nospace-expression.c b/src/glsl/glcpp/tests/066-if-nospace-expression.c
new file mode 100644
index 00000000000..3b0b47349d0
--- /dev/null
+++ b/src/glsl/glcpp/tests/066-if-nospace-expression.c
@@ -0,0 +1,3 @@
1#if(1)
2success
3#endif
diff --git a/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected b/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected
new file mode 100644
index 00000000000..0e84a7cda39
--- /dev/null
+++ b/src/glsl/glcpp/tests/066-if-nospace-expression.c.expected
@@ -0,0 +1,4 @@
1
2success
3
4
diff --git a/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c
new file mode 100644
index 00000000000..f46cce4e60a
--- /dev/null
+++ b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c
@@ -0,0 +1,40 @@
1#define D1
2#define D2
3
4#define result success
5
6#ifdef U1
7#ifdef U2
8#undef result
9#define result failure
10#endif
11#endif
12result
13
14#ifndef D1
15#ifndef D2
16#undef result
17#define result failure
18#endif
19#endif
20result
21
22#undef result
23#define result failure
24#ifdef D1
25#ifdef D2
26#undef result
27#define result success
28#endif
29#endif
30result
31
32#undef result
33#define result failure
34#ifndef U1
35#ifndef U2
36#undef result
37#define result success
38#endif
39#endif
40result
diff --git a/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected
new file mode 100644
index 00000000000..3340daaa1f9
--- /dev/null
+++ b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected
@@ -0,0 +1,41 @@
1
2
3
4
5
6
7
8
9
10
11
12success
13
14
15
16
17
18
19
20success
21
22
23
24
25
26
27
28
29
30success
31
32
33
34
35
36
37
38
39
40success
41
diff --git a/src/glsl/glcpp/tests/068-accidental-pasting.c b/src/glsl/glcpp/tests/068-accidental-pasting.c
new file mode 100644
index 00000000000..699ac5144e5
--- /dev/null
+++ b/src/glsl/glcpp/tests/068-accidental-pasting.c
@@ -0,0 +1,11 @@
1#define empty
2<empty<
3<empty=
4>empty>
5>empty=
6=empty=
7!empty=
8&empty&
9|empty|
10+empty+
11-empty-
diff --git a/src/glsl/glcpp/tests/068-accidental-pasting.c.expected b/src/glsl/glcpp/tests/068-accidental-pasting.c.expected
new file mode 100644
index 00000000000..ce41cd6e524
--- /dev/null
+++ b/src/glsl/glcpp/tests/068-accidental-pasting.c.expected
@@ -0,0 +1,12 @@
1
2< <
3< =
4> >
5> =
6= =
7! =
8& &
9| |
10+ +
11- -
12
diff --git a/src/glsl/glcpp/tests/069-repeated-argument.c b/src/glsl/glcpp/tests/069-repeated-argument.c
new file mode 100644
index 00000000000..2b46ead294c
--- /dev/null
+++ b/src/glsl/glcpp/tests/069-repeated-argument.c
@@ -0,0 +1,2 @@
1#define double(x) x x
2double(1)
diff --git a/src/glsl/glcpp/tests/069-repeated-argument.c.expected b/src/glsl/glcpp/tests/069-repeated-argument.c.expected
new file mode 100644
index 00000000000..755c4d4b56c
--- /dev/null
+++ b/src/glsl/glcpp/tests/069-repeated-argument.c.expected
@@ -0,0 +1,3 @@
1
21 1
3
diff --git a/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c
new file mode 100644
index 00000000000..b6dc2ba075f
--- /dev/null
+++ b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c
@@ -0,0 +1,2 @@
1#if UNDEFINED_MACRO
2#endif
diff --git a/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected
new file mode 100644
index 00000000000..2bb38a1411e
--- /dev/null
+++ b/src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected
@@ -0,0 +1,2 @@
10:1(21): preprocessor error: syntax error, unexpected IDENTIFIER
2
diff --git a/src/glsl/glcpp/tests/071-punctuator.c b/src/glsl/glcpp/tests/071-punctuator.c
new file mode 100644
index 00000000000..959d6825988
--- /dev/null
+++ b/src/glsl/glcpp/tests/071-punctuator.c
@@ -0,0 +1 @@
a = b
diff --git a/src/glsl/glcpp/tests/071-punctuator.c.expected b/src/glsl/glcpp/tests/071-punctuator.c.expected
new file mode 100644
index 00000000000..fee253b7452
--- /dev/null
+++ b/src/glsl/glcpp/tests/071-punctuator.c.expected
@@ -0,0 +1,2 @@
1a = b
2
diff --git a/src/glsl/glcpp/tests/072-token-pasting-same-line.c b/src/glsl/glcpp/tests/072-token-pasting-same-line.c
new file mode 100644
index 00000000000..e421e9d5e29
--- /dev/null
+++ b/src/glsl/glcpp/tests/072-token-pasting-same-line.c
@@ -0,0 +1,2 @@
1#define paste(x) success_ ## x
2paste(1) paste(2) paste(3)
diff --git a/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected b/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected
new file mode 100644
index 00000000000..c780b43d70f
--- /dev/null
+++ b/src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected
@@ -0,0 +1,3 @@
1
2success_1 success_2 success_3
3
diff --git a/src/glsl/glcpp/tests/073-if-in-ifdef.c b/src/glsl/glcpp/tests/073-if-in-ifdef.c
new file mode 100644
index 00000000000..61a48097ca3
--- /dev/null
+++ b/src/glsl/glcpp/tests/073-if-in-ifdef.c
@@ -0,0 +1,4 @@
1#ifdef UNDEF
2#if UNDEF > 1
3#endif
4#endif
diff --git a/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected b/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected
new file mode 100644
index 00000000000..3f2ff2d6cc8
--- /dev/null
+++ b/src/glsl/glcpp/tests/073-if-in-ifdef.c.expected
@@ -0,0 +1,5 @@
1
2
3
4
5
diff --git a/src/glsl/glcpp/tests/074-elif-undef.c b/src/glsl/glcpp/tests/074-elif-undef.c
new file mode 100644
index 00000000000..67aac8977e0
--- /dev/null
+++ b/src/glsl/glcpp/tests/074-elif-undef.c
@@ -0,0 +1,3 @@
1#ifndef UNDEF
2#elif UNDEF < 0
3#endif
diff --git a/src/glsl/glcpp/tests/074-elif-undef.c.expected b/src/glsl/glcpp/tests/074-elif-undef.c.expected
new file mode 100644
index 00000000000..fd40910d9e7
--- /dev/null
+++ b/src/glsl/glcpp/tests/074-elif-undef.c.expected
@@ -0,0 +1,4 @@
1
2
3
4
diff --git a/src/glsl/glcpp/tests/075-elif-elif-undef.c b/src/glsl/glcpp/tests/075-elif-elif-undef.c
new file mode 100644
index 00000000000..264bc4f10ee
--- /dev/null
+++ b/src/glsl/glcpp/tests/075-elif-elif-undef.c
@@ -0,0 +1,4 @@
1#ifndef UNDEF
2#elif UNDEF < 0
3#elif UNDEF == 3
4#endif
diff --git a/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected b/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected
new file mode 100644
index 00000000000..3f2ff2d6cc8
--- /dev/null
+++ b/src/glsl/glcpp/tests/075-elif-elif-undef.c.expected
@@ -0,0 +1,5 @@
1
2
3
4
5
diff --git a/src/glsl/glcpp/tests/076-elif-undef-nested.c b/src/glsl/glcpp/tests/076-elif-undef-nested.c
new file mode 100644
index 00000000000..ebd550ed005
--- /dev/null
+++ b/src/glsl/glcpp/tests/076-elif-undef-nested.c
@@ -0,0 +1,5 @@
1#ifdef UNDEF
2#if UNDEF == 4
3#elif UNDEF == 5
4#endif
5#endif
diff --git a/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected b/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected
new file mode 100644
index 00000000000..6fb66a5e2f0
--- /dev/null
+++ b/src/glsl/glcpp/tests/076-elif-undef-nested.c.expected
@@ -0,0 +1,6 @@
1
2
3
4
5
6
diff --git a/src/glsl/glcpp/tests/077-else-without-if.c b/src/glsl/glcpp/tests/077-else-without-if.c
new file mode 100644
index 00000000000..81f00bfe278
--- /dev/null
+++ b/src/glsl/glcpp/tests/077-else-without-if.c
@@ -0,0 +1 @@
#else
diff --git a/src/glsl/glcpp/tests/077-else-without-if.c.expected b/src/glsl/glcpp/tests/077-else-without-if.c.expected
new file mode 100644
index 00000000000..d289b363562
--- /dev/null
+++ b/src/glsl/glcpp/tests/077-else-without-if.c.expected
@@ -0,0 +1,4 @@
10:1(2): preprocessor error: else without #if
2
3
4
diff --git a/src/glsl/glcpp/tests/078-elif-without-if.c b/src/glsl/glcpp/tests/078-elif-without-if.c
new file mode 100644
index 00000000000..60466b3890a
--- /dev/null
+++ b/src/glsl/glcpp/tests/078-elif-without-if.c
@@ -0,0 +1 @@
#elif defined FOO
diff --git a/src/glsl/glcpp/tests/078-elif-without-if.c.expected b/src/glsl/glcpp/tests/078-elif-without-if.c.expected
new file mode 100644
index 00000000000..7d41f0ac794
--- /dev/null
+++ b/src/glsl/glcpp/tests/078-elif-without-if.c.expected
@@ -0,0 +1,4 @@
10:1(2): preprocessor error: elif without #if
2
3
4
diff --git a/src/glsl/glcpp/tests/079-endif-without-if.c b/src/glsl/glcpp/tests/079-endif-without-if.c
new file mode 100644
index 00000000000..69331c3ca9d
--- /dev/null
+++ b/src/glsl/glcpp/tests/079-endif-without-if.c
@@ -0,0 +1 @@
#endif
diff --git a/src/glsl/glcpp/tests/079-endif-without-if.c.expected b/src/glsl/glcpp/tests/079-endif-without-if.c.expected
new file mode 100644
index 00000000000..08dd33546f2
--- /dev/null
+++ b/src/glsl/glcpp/tests/079-endif-without-if.c.expected
@@ -0,0 +1,4 @@
10:1(2): preprocessor error: #endif without #if
2
3
4
diff --git a/src/glsl/glcpp/tests/080-if-without-expression.c b/src/glsl/glcpp/tests/080-if-without-expression.c
new file mode 100644
index 00000000000..a27ba36a366
--- /dev/null
+++ b/src/glsl/glcpp/tests/080-if-without-expression.c
@@ -0,0 +1,4 @@
1/* Error message for unskipped #if with no expression. */
2#if
3#endif
4
diff --git a/src/glsl/glcpp/tests/080-if-without-expression.c.expected b/src/glsl/glcpp/tests/080-if-without-expression.c.expected
new file mode 100644
index 00000000000..768ba0f473f
--- /dev/null
+++ b/src/glsl/glcpp/tests/080-if-without-expression.c.expected
@@ -0,0 +1,6 @@
10:2(1): preprocessor error: #if with no expression
2
3
4
5
6
diff --git a/src/glsl/glcpp/tests/081-elif-without-expression.c b/src/glsl/glcpp/tests/081-elif-without-expression.c
new file mode 100644
index 00000000000..79c78663dd3
--- /dev/null
+++ b/src/glsl/glcpp/tests/081-elif-without-expression.c
@@ -0,0 +1,3 @@
1#if 0
2#elif
3#endif
diff --git a/src/glsl/glcpp/tests/081-elif-without-expression.c.expected b/src/glsl/glcpp/tests/081-elif-without-expression.c.expected
new file mode 100644
index 00000000000..974f0f550eb
--- /dev/null
+++ b/src/glsl/glcpp/tests/081-elif-without-expression.c.expected
@@ -0,0 +1,5 @@
10:2(1): preprocessor error: #elif with no expression
2
3
4
5
diff --git a/src/glsl/glcpp/tests/082-invalid-paste.c b/src/glsl/glcpp/tests/082-invalid-paste.c
new file mode 100644
index 00000000000..40bf64411c5
--- /dev/null
+++ b/src/glsl/glcpp/tests/082-invalid-paste.c
@@ -0,0 +1,2 @@
1#define PASTE(x,y) x ## y
2PASTE(<,>)
diff --git a/src/glsl/glcpp/tests/082-invalid-paste.c.expected b/src/glsl/glcpp/tests/082-invalid-paste.c.expected
new file mode 100644
index 00000000000..2c924406b59
--- /dev/null
+++ b/src/glsl/glcpp/tests/082-invalid-paste.c.expected
@@ -0,0 +1,5 @@
10:2(7): preprocessor error:
2Pasting "<" and ">" does not give a valid preprocessing token.
3
4<
5
diff --git a/src/glsl/glcpp/tests/083-unterminated-if.c b/src/glsl/glcpp/tests/083-unterminated-if.c
new file mode 100644
index 00000000000..91806350927
--- /dev/null
+++ b/src/glsl/glcpp/tests/083-unterminated-if.c
@@ -0,0 +1,2 @@
1#if 1
2
diff --git a/src/glsl/glcpp/tests/083-unterminated-if.c.expected b/src/glsl/glcpp/tests/083-unterminated-if.c.expected
new file mode 100644
index 00000000000..a69f8bab582
--- /dev/null
+++ b/src/glsl/glcpp/tests/083-unterminated-if.c.expected
@@ -0,0 +1,5 @@
10:1(7): preprocessor error: Unterminated #if
2
3
4
5
diff --git a/src/glsl/glcpp/tests/084-unbalanced-parentheses.c b/src/glsl/glcpp/tests/084-unbalanced-parentheses.c
new file mode 100644
index 00000000000..0789ba5e525
--- /dev/null
+++ b/src/glsl/glcpp/tests/084-unbalanced-parentheses.c
@@ -0,0 +1,2 @@
1#define FUNC(x) (2*(x))
2FUNC(23
diff --git a/src/glsl/glcpp/tests/085-incorrect-argument-count.c b/src/glsl/glcpp/tests/085-incorrect-argument-count.c
new file mode 100644
index 00000000000..91bea600612
--- /dev/null
+++ b/src/glsl/glcpp/tests/085-incorrect-argument-count.c
@@ -0,0 +1,5 @@
1#define MULT(x,y) ((x)*(y))
2MULT()
3MULT(1)
4MULT(1,2,3)
5
diff --git a/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected b/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected
new file mode 100644
index 00000000000..1df30cbb56f
--- /dev/null
+++ b/src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected
@@ -0,0 +1,12 @@
10:2(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2)
2
30:3(1): preprocessor error: Error: macro MULT invoked with 1 arguments (expected 2)
4
50:4(1): preprocessor error: Error: macro MULT invoked with 3 arguments (expected 2)
6
7
8MULT()
9MULT(1)
10MULT(1,2,3)
11
12
diff --git a/src/glsl/glcpp/tests/086-reserved-macro-names.c b/src/glsl/glcpp/tests/086-reserved-macro-names.c
new file mode 100644
index 00000000000..fd0c29f0c47
--- /dev/null
+++ b/src/glsl/glcpp/tests/086-reserved-macro-names.c
@@ -0,0 +1,2 @@
1#define __BAD reserved
2#define GL_ALSO_BAD() also reserved
diff --git a/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected b/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected
new file mode 100644
index 00000000000..6a9df682685
--- /dev/null
+++ b/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected
@@ -0,0 +1,7 @@
10:1(10): preprocessor error: Macro names starting with "__" are reserved.
2
30:2(9): preprocessor error: Macro names starting with "GL_" are reserved.
4
5
6
7
diff --git a/src/glsl/glcpp/tests/099-c99-example.c b/src/glsl/glcpp/tests/099-c99-example.c
new file mode 100644
index 00000000000..d1976b1f265
--- /dev/null
+++ b/src/glsl/glcpp/tests/099-c99-example.c
@@ -0,0 +1,17 @@
1#define x 3
2#define f(a) f(x * (a))
3#undef x
4#define x 2
5#define g f
6#define z z[0]
7#define h g(~
8#define m(a) a(w)
9#define w 0,1
10#define t(a) a
11#define p() int
12#define q(x) x
13#define r(x,y) x ## y
14f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
15g(x +(3,4)-w) | h 5) & m
16 (f)^m(m);
17p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,)};
diff --git a/src/glsl/glcpp/tests/099-c99-example.c.expected b/src/glsl/glcpp/tests/099-c99-example.c.expected
new file mode 100644
index 00000000000..19be7505552
--- /dev/null
+++ b/src/glsl/glcpp/tests/099-c99-example.c.expected
@@ -0,0 +1,17 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
15f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
16int i[] = { 1, 23, 4, 5, };
17
diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test
new file mode 100755
index 00000000000..6494d0c0e77
--- /dev/null
+++ b/src/glsl/glcpp/tests/glcpp-test
@@ -0,0 +1,49 @@
1#!/bin/sh
2
3trap 'rm $test.valgrind-errors; exit 1' INT QUIT
4
5total=0
6pass=0
7clean=0
8
9echo "====== Testing for correctness ======"
10for test in *.c; do
11 echo -n "Testing $test..."
12 ../glcpp < $test > $test.out 2>&1
13 total=$((total+1))
14 if cmp $test.expected $test.out >/dev/null 2>&1; then
15 echo "PASS"
16 pass=$((pass+1))
17 else
18 echo "FAIL"
19 diff -u $test.expected $test.out
20 fi
21done
22
23echo ""
24echo "$pass/$total tests returned correct results"
25echo ""
26
27echo "====== Testing for valgrind cleanliness ======"
28for test in *.c; do
29 echo -n "Testing $test with valgrind..."
30 if valgrind --error-exitcode=1 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null; then
31 echo "CLEAN"
32 clean=$((clean+1))
33 rm $test.valgrind-errors
34 else
35 echo "ERRORS"
36 cat $test.valgrind-errors
37 fi
38done
39
40echo ""
41echo "$pass/$total tests returned correct results"
42echo "$clean/$total tests are valgrind-clean"
43
44if [ "$pass" = "$total" ] && [ "$clean" = "$total" ]; then
45 exit 0
46else
47 exit 1
48fi
49
diff --git a/src/glsl/glsl_lexer.cpp b/src/glsl/glsl_lexer.cpp
new file mode 100644
index 00000000000..3cdce995e28
--- /dev/null
+++ b/src/glsl/glsl_lexer.cpp
@@ -0,0 +1,3416 @@
1#line 2 "glsl_lexer.cpp"
2
3#line 4 "glsl_lexer.cpp"
4
5#define YY_INT_ALIGNED short int
6
7/* A lexical scanner generated by flex */
8
9#define FLEX_SCANNER
10#define YY_FLEX_MAJOR_VERSION 2
11#define YY_FLEX_MINOR_VERSION 5
12#define YY_FLEX_SUBMINOR_VERSION 35
13#if YY_FLEX_SUBMINOR_VERSION > 0
14#define FLEX_BETA
15#endif
16
17/* First, we deal with platform-specific or compiler-specific issues. */
18
19/* begin standard C headers. */
20#include <stdio.h>
21#include <string.h>
22#include <errno.h>
23#include <stdlib.h>
24
25/* end standard C headers. */
26
27/* flex integer type definitions */
28
29#ifndef FLEXINT_H
30#define FLEXINT_H
31
32/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
35
36/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
38 */
39#ifndef __STDC_LIMIT_MACROS
40#define __STDC_LIMIT_MACROS 1
41#endif
42
43#include <inttypes.h>
44typedef int8_t flex_int8_t;
45typedef uint8_t flex_uint8_t;
46typedef int16_t flex_int16_t;
47typedef uint16_t flex_uint16_t;
48typedef int32_t flex_int32_t;
49typedef uint32_t flex_uint32_t;
50#else
51typedef signed char flex_int8_t;
52typedef short int flex_int16_t;
53typedef int flex_int32_t;
54typedef unsigned char flex_uint8_t;
55typedef unsigned short int flex_uint16_t;
56typedef unsigned int flex_uint32_t;
57
58/* Limits of integral types. */
59#ifndef INT8_MIN
60#define INT8_MIN (-128)
61#endif
62#ifndef INT16_MIN
63#define INT16_MIN (-32767-1)
64#endif
65#ifndef INT32_MIN
66#define INT32_MIN (-2147483647-1)
67#endif
68#ifndef INT8_MAX
69#define INT8_MAX (127)
70#endif
71#ifndef INT16_MAX
72#define INT16_MAX (32767)
73#endif
74#ifndef INT32_MAX
75#define INT32_MAX (2147483647)
76#endif
77#ifndef UINT8_MAX
78#define UINT8_MAX (255U)
79#endif
80#ifndef UINT16_MAX
81#define UINT16_MAX (65535U)
82#endif
83#ifndef UINT32_MAX
84#define UINT32_MAX (4294967295U)
85#endif
86
87#endif /* ! C99 */
88
89#endif /* ! FLEXINT_H */
90
91#ifdef __cplusplus
92
93/* The "const" storage-class-modifier is valid. */
94#define YY_USE_CONST
95
96#else /* ! __cplusplus */
97
98/* C99 requires __STDC__ to be defined as 1. */
99#if defined (__STDC__)
100
101#define YY_USE_CONST
102
103#endif /* defined (__STDC__) */
104#endif /* ! __cplusplus */
105
106#ifdef YY_USE_CONST
107#define yyconst const
108#else
109#define yyconst
110#endif
111
112/* Returned upon end-of-file. */
113#define YY_NULL 0
114
115/* Promotes a possibly negative, possibly signed char to an unsigned
116 * integer for use as an array index. If the signed char is negative,
117 * we want to instead treat it as an 8-bit unsigned char, hence the
118 * double cast.
119 */
120#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
121
122/* An opaque pointer. */
123#ifndef YY_TYPEDEF_YY_SCANNER_T
124#define YY_TYPEDEF_YY_SCANNER_T
125typedef void* yyscan_t;
126#endif
127
128/* For convenience, these vars (plus the bison vars far below)
129 are macros in the reentrant scanner. */
130#define yyin yyg->yyin_r
131#define yyout yyg->yyout_r
132#define yyextra yyg->yyextra_r
133#define yyleng yyg->yyleng_r
134#define yytext yyg->yytext_r
135#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
136#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
137#define yy_flex_debug yyg->yy_flex_debug_r
138
139/* Enter a start condition. This macro really ought to take a parameter,
140 * but we do it the disgusting crufty way forced on us by the ()-less
141 * definition of BEGIN.
142 */
143#define BEGIN yyg->yy_start = 1 + 2 *
144
145/* Translate the current start state into a value that can be later handed
146 * to BEGIN to return to the state. The YYSTATE alias is for lex
147 * compatibility.
148 */
149#define YY_START ((yyg->yy_start - 1) / 2)
150#define YYSTATE YY_START
151
152/* Action number for EOF rule of a given start state. */
153#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
154
155/* Special action meaning "start processing a new file". */
156#define YY_NEW_FILE _mesa_glsl_restart(yyin ,yyscanner )
157
158#define YY_END_OF_BUFFER_CHAR 0
159
160/* Size of default input buffer. */
161#ifndef YY_BUF_SIZE
162#ifdef __ia64__
163/* On IA-64, the buffer size is 16k, not 8k.
164 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
165 * Ditto for the __ia64__ case accordingly.
166 */
167#define YY_BUF_SIZE 32768
168#else
169#define YY_BUF_SIZE 16384
170#endif /* __ia64__ */
171#endif
172
173/* The state buf must be large enough to hold one state per character in the main buffer.
174 */
175#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
176
177#ifndef YY_TYPEDEF_YY_BUFFER_STATE
178#define YY_TYPEDEF_YY_BUFFER_STATE
179typedef struct yy_buffer_state *YY_BUFFER_STATE;
180#endif
181
182#define EOB_ACT_CONTINUE_SCAN 0
183#define EOB_ACT_END_OF_FILE 1
184#define EOB_ACT_LAST_MATCH 2
185
186 #define YY_LESS_LINENO(n)
187
188/* Return all but the first "n" matched characters back to the input stream. */
189#define yyless(n) \
190 do \
191 { \
192 /* Undo effects of setting up yytext. */ \
193 int yyless_macro_arg = (n); \
194 YY_LESS_LINENO(yyless_macro_arg);\
195 *yy_cp = yyg->yy_hold_char; \
196 YY_RESTORE_YY_MORE_OFFSET \
197 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
198 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
199 } \
200 while ( 0 )
201
202#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
203
204#ifndef YY_TYPEDEF_YY_SIZE_T
205#define YY_TYPEDEF_YY_SIZE_T
206typedef size_t yy_size_t;
207#endif
208
209#ifndef YY_STRUCT_YY_BUFFER_STATE
210#define YY_STRUCT_YY_BUFFER_STATE
211struct yy_buffer_state
212 {
213 FILE *yy_input_file;
214
215 char *yy_ch_buf; /* input buffer */
216 char *yy_buf_pos; /* current position in input buffer */
217
218 /* Size of input buffer in bytes, not including room for EOB
219 * characters.
220 */
221 yy_size_t yy_buf_size;
222
223 /* Number of characters read into yy_ch_buf, not including EOB
224 * characters.
225 */
226 int yy_n_chars;
227
228 /* Whether we "own" the buffer - i.e., we know we created it,
229 * and can realloc() it to grow it, and should free() it to
230 * delete it.
231 */
232 int yy_is_our_buffer;
233
234 /* Whether this is an "interactive" input source; if so, and
235 * if we're using stdio for input, then we want to use getc()
236 * instead of fread(), to make sure we stop fetching input after
237 * each newline.
238 */
239 int yy_is_interactive;
240
241 /* Whether we're considered to be at the beginning of a line.
242 * If so, '^' rules will be active on the next match, otherwise
243 * not.
244 */
245 int yy_at_bol;
246
247 int yy_bs_lineno; /**< The line count. */
248 int yy_bs_column; /**< The column count. */
249
250 /* Whether to try to fill the input buffer when we reach the
251 * end of it.
252 */
253 int yy_fill_buffer;
254
255 int yy_buffer_status;
256
257#define YY_BUFFER_NEW 0
258#define YY_BUFFER_NORMAL 1
259 /* When an EOF's been seen but there's still some text to process
260 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
261 * shouldn't try reading from the input source any more. We might
262 * still have a bunch of tokens to match, though, because of
263 * possible backing-up.
264 *
265 * When we actually see the EOF, we change the status to "new"
266 * (via _mesa_glsl_restart()), so that the user can continue scanning by
267 * just pointing yyin at a new input file.
268 */
269#define YY_BUFFER_EOF_PENDING 2
270
271 };
272#endif /* !YY_STRUCT_YY_BUFFER_STATE */
273
274/* We provide macros for accessing buffer states in case in the
275 * future we want to put the buffer states in a more general
276 * "scanner state".
277 *
278 * Returns the top of the stack, or NULL.
279 */
280#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
281 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
282 : NULL)
283
284/* Same as previous macro, but useful when we know that the buffer stack is not
285 * NULL or when we need an lvalue. For internal use only.
286 */
287#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
288
289void _mesa_glsl_restart (FILE *input_file ,yyscan_t yyscanner );
290void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
291YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
292void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
293void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
294void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
295void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner );
296
297static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner );
298static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner );
299static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
300
301#define YY_FLUSH_BUFFER _mesa_glsl__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
302
303YY_BUFFER_STATE _mesa_glsl__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
304YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
305YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
306
307void *_mesa_glsl_alloc (yy_size_t ,yyscan_t yyscanner );
308void *_mesa_glsl_realloc (void *,yy_size_t ,yyscan_t yyscanner );
309void _mesa_glsl_free (void * ,yyscan_t yyscanner );
310
311#define yy_new_buffer _mesa_glsl__create_buffer
312
313#define yy_set_interactive(is_interactive) \
314 { \
315 if ( ! YY_CURRENT_BUFFER ){ \
316 _mesa_glsl_ensure_buffer_stack (yyscanner); \
317 YY_CURRENT_BUFFER_LVALUE = \
318 _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
319 } \
320 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
321 }
322
323#define yy_set_bol(at_bol) \
324 { \
325 if ( ! YY_CURRENT_BUFFER ){\
326 _mesa_glsl_ensure_buffer_stack (yyscanner); \
327 YY_CURRENT_BUFFER_LVALUE = \
328 _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
329 } \
330 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
331 }
332
333#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
334
335/* Begin user sect3 */
336
337#define _mesa_glsl_wrap(n) 1
338#define YY_SKIP_YYWRAP
339
340typedef unsigned char YY_CHAR;
341
342typedef int yy_state_type;
343
344#define yytext_ptr yytext_r
345
346static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
347static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
348static int yy_get_next_buffer (yyscan_t yyscanner );
349static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
350
351/* Done after the current pattern has been matched and before the
352 * corresponding action - sets up yytext.
353 */
354#define YY_DO_BEFORE_ACTION \
355 yyg->yytext_ptr = yy_bp; \
356 yyleng = (size_t) (yy_cp - yy_bp); \
357 yyg->yy_hold_char = *yy_cp; \
358 *yy_cp = '\0'; \
359 yyg->yy_c_buf_p = yy_cp;
360
361#define YY_NUM_RULES 177
362#define YY_END_OF_BUFFER 178
363/* This struct is not used in this scanner,
364 but its presence is necessary. */
365struct yy_trans_info
366 {
367 flex_int32_t yy_verify;
368 flex_int32_t yy_nxt;
369 };
370static yyconst flex_int16_t yy_accept[668] =
371 { 0,
372 0, 0, 9, 9, 178, 176, 1, 14, 176, 176,
373 176, 176, 176, 176, 176, 176, 90, 88, 176, 176,
374 176, 175, 176, 175, 175, 175, 175, 175, 175, 175,
375 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
376 175, 175, 175, 176, 1, 176, 85, 177, 9, 13,
377 177, 12, 10, 11, 1, 74, 81, 75, 84, 78,
378 69, 80, 70, 87, 92, 79, 93, 90, 0, 0,
379 95, 0, 88, 0, 71, 73, 72, 0, 175, 77,
380 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
381 175, 175, 22, 175, 175, 175, 175, 175, 175, 175,
382
383 175, 175, 175, 175, 175, 175, 26, 175, 175, 50,
384 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
385 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
386 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
387 175, 86, 76, 1, 0, 0, 2, 0, 0, 0,
388 0, 9, 8, 12, 11, 0, 92, 91, 0, 93,
389 0, 94, 89, 82, 83, 175, 98, 175, 175, 175,
390 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
391 175, 175, 175, 175, 175, 175, 175, 175, 25, 175,
392 175, 175, 175, 175, 175, 175, 175, 175, 175, 19,
393
394 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
395 51, 175, 175, 175, 175, 175, 175, 175, 175, 175,
396 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
397 175, 175, 175, 175, 175, 175, 175, 175, 0, 0,
398 0, 0, 8, 0, 92, 0, 91, 0, 93, 94,
399 175, 175, 17, 175, 175, 138, 175, 175, 175, 175,
400 175, 175, 175, 175, 175, 24, 101, 175, 175, 175,
401 175, 57, 175, 175, 106, 120, 175, 175, 175, 175,
402 175, 175, 175, 175, 175, 175, 175, 117, 141, 38,
403 39, 40, 175, 175, 175, 175, 175, 175, 175, 175,
404
405 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
406 175, 175, 104, 96, 175, 175, 175, 175, 175, 175,
407 175, 35, 36, 37, 67, 175, 175, 0, 0, 0,
408 0, 0, 91, 175, 175, 20, 29, 30, 31, 175,
409 99, 175, 16, 175, 175, 175, 175, 128, 129, 130,
410 175, 97, 175, 121, 18, 131, 132, 133, 143, 125,
411 126, 127, 175, 175, 175, 52, 123, 175, 175, 32,
412 33, 34, 175, 175, 175, 175, 175, 175, 175, 175,
413 175, 175, 175, 175, 175, 175, 175, 175, 118, 175,
414 175, 175, 175, 175, 175, 175, 175, 175, 175, 100,
415
416 175, 140, 175, 175, 23, 0, 0, 0, 0, 147,
417 175, 175, 145, 175, 175, 175, 119, 114, 150, 175,
418 175, 175, 175, 175, 175, 109, 175, 175, 68, 41,
419 42, 43, 44, 45, 46, 47, 48, 49, 175, 175,
420 175, 175, 124, 105, 175, 175, 112, 28, 175, 175,
421 137, 58, 113, 66, 148, 107, 175, 175, 175, 175,
422 175, 175, 175, 0, 0, 0, 0, 175, 175, 175,
423 108, 27, 175, 175, 175, 175, 175, 175, 151, 152,
424 153, 175, 175, 175, 175, 142, 175, 175, 175, 175,
425 175, 175, 175, 175, 102, 175, 175, 175, 175, 175,
426
427 53, 175, 54, 175, 0, 0, 0, 7, 0, 175,
428 55, 21, 115, 155, 156, 157, 175, 175, 175, 175,
429 175, 175, 175, 175, 175, 175, 175, 110, 175, 175,
430 175, 175, 175, 175, 175, 175, 175, 103, 159, 160,
431 161, 175, 175, 122, 111, 0, 0, 6, 0, 0,
432 0, 3, 15, 175, 175, 175, 175, 175, 175, 175,
433 175, 175, 154, 116, 56, 139, 175, 146, 144, 174,
434 60, 61, 62, 175, 175, 175, 175, 175, 175, 0,
435 0, 0, 0, 175, 175, 175, 158, 175, 175, 175,
436 175, 175, 175, 175, 175, 175, 175, 175, 175, 175,
437
438 175, 175, 162, 4, 0, 5, 0, 0, 0, 175,
439 175, 175, 175, 175, 175, 175, 171, 175, 175, 175,
440 175, 175, 175, 63, 175, 175, 175, 0, 175, 175,
441 172, 163, 175, 164, 175, 175, 175, 175, 175, 175,
442 175, 175, 175, 173, 165, 166, 169, 170, 59, 175,
443 134, 175, 135, 149, 167, 168, 175, 175, 175, 64,
444 175, 65, 175, 175, 175, 136, 0
445 } ;
446
447static yyconst flex_int32_t yy_ec[256] =
448 { 0,
449 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
450 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
451 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
452 1, 2, 5, 1, 6, 1, 7, 8, 1, 1,
453 1, 9, 10, 1, 11, 12, 13, 14, 15, 16,
454 17, 18, 19, 19, 19, 20, 20, 21, 1, 22,
455 23, 24, 1, 1, 25, 26, 27, 28, 29, 30,
456 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
457 31, 32, 33, 31, 31, 31, 31, 34, 31, 31,
458 1, 1, 1, 35, 36, 1, 37, 38, 39, 40,
459
460 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
461 51, 52, 31, 53, 54, 55, 56, 57, 58, 59,
462 60, 61, 1, 62, 1, 1, 1, 1, 1, 1,
463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
464 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
465 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
466 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
467 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
468 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
469 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
470
471 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
472 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
473 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
474 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
475 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
476 1, 1, 1, 1, 1
477 } ;
478
479static yyconst flex_int32_t yy_meta[63] =
480 { 0,
481 1, 2, 3, 1, 1, 1, 1, 1, 1, 1,
482 1, 1, 1, 4, 4, 4, 4, 4, 4, 5,
483 1, 1, 1, 1, 6, 6, 6, 6, 5, 5,
484 7, 7, 7, 8, 1, 7, 6, 6, 6, 6,
485 5, 5, 7, 7, 7, 7, 7, 7, 7, 7,
486 7, 7, 7, 7, 7, 7, 7, 7, 8, 7,
487 7, 1
488 } ;
489
490static yyconst flex_int16_t yy_base[678] =
491 { 0,
492 0, 61, 84, 0, 1012, 1013, 62, 1013, 988, 987,
493 57, 986, 58, 59, 57, 985, 135, 183, 56, 984,
494 133, 0, 971, 119, 109, 130, 134, 111, 135, 954,
495 151, 165, 32, 152, 131, 948, 153, 170, 182, 176,
496 178, 193, 959, 125, 237, 243, 979, 1013, 214, 1013,
497 988, 233, 1013, 0, 231, 1013, 1013, 1013, 1013, 1013,
498 1013, 1013, 1013, 1013, 225, 1013, 227, 224, 289, 260,
499 1013, 0, 0, 977, 1013, 1013, 1013, 976, 0, 1013,
500 943, 948, 941, 944, 953, 952, 938, 941, 953, 155,
501 947, 934, 931, 945, 931, 928, 928, 934, 213, 222,
502
503 928, 939, 924, 930, 934, 935, 0, 926, 937, 237,
504 932, 912, 232, 916, 930, 920, 241, 913, 257, 926,
505 928, 910, 906, 914, 911, 900, 909, 228, 907, 913,
506 908, 911, 899, 902, 904, 257, 907, 898, 911, 215,
507 904, 1013, 1013, 310, 295, 318, 1013, 889, 902, 893,
508 904, 260, 0, 308, 0, 362, 1013, 303, 373, 1013,
509 380, 387, 0, 1013, 1013, 899, 0, 890, 894, 904,
510 901, 884, 883, 883, 887, 280, 898, 895, 895, 893,
511 890, 881, 888, 874, 872, 885, 870, 887, 0, 884,
512 871, 879, 876, 880, 881, 874, 871, 859, 858, 872,
513
514 875, 872, 859, 866, 856, 321, 862, 865, 855, 863,
515 851, 855, 846, 861, 851, 842, 861, 844, 842, 853,
516 842, 837, 835, 849, 834, 836, 833, 845, 844, 847,
517 298, 838, 832, 821, 337, 840, 842, 830, 822, 826,
518 838, 821, 0, 394, 404, 421, 1013, 433, 440, 1013,
519 816, 827, 0, 824, 340, 0, 817, 815, 817, 812,
520 821, 809, 827, 815, 344, 0, 0, 809, 820, 819,
521 819, 0, 803, 347, 0, 0, 805, 351, 813, 814,
522 804, 798, 797, 798, 797, 409, 793, 0, 0, 789,
523 788, 787, 789, 790, 795, 789, 785, 799, 794, 793,
524
525 792, 783, 786, 786, 778, 781, 776, 785, 790, 775,
526 788, 778, 0, 0, 785, 781, 772, 772, 778, 777,
527 774, 0, 0, 0, 0, 763, 776, 775, 774, 771,
528 759, 447, 457, 771, 773, 0, 0, 0, 0, 759,
529 0, 759, 0, 758, 759, 753, 764, 0, 0, 0,
530 754, 0, 750, 0, 0, 0, 0, 0, 0, 0,
531 0, 0, 761, 463, 760, 0, 0, 758, 754, 0,
532 0, 0, 743, 426, 467, 475, 748, 744, 750, 740,
533 738, 752, 736, 736, 750, 738, 750, 745, 0, 743,
534 740, 744, 727, 729, 736, 742, 737, 736, 723, 0,
535
536 725, 0, 724, 728, 0, 722, 769, 721, 724, 0,
537 712, 722, 0, 710, 710, 724, 0, 726, 0, 479,
538 734, 733, 732, 703, 702, 0, 720, 719, 0, 0,
539 0, 0, 0, 0, 0, 0, 0, 0, 703, 717,
540 703, 700, 0, 0, 706, 705, 0, 0, 703, 695,
541 0, 0, 0, 0, 0, 0, 692, 704, 485, 696,
542 703, 700, 694, 687, 501, 703, 688, 683, 697, 695,
543 0, 0, 687, 706, 705, 704, 675, 674, 317, 489,
544 0, 687, 690, 688, 676, 0, 686, 683, 682, 671,
545 670, 669, 508, 678, 0, 690, 689, 688, 659, 658,
546
547 0, 673, 0, 671, 666, 495, 524, 1013, 660, 668,
548 0, 0, 0, 683, 682, 0, 664, 667, 651, 659,
549 649, 657, 658, 658, 657, 642, 655, 0, 656, 644,
550 643, 639, 663, 662, 661, 632, 631, 0, 661, 660,
551 0, 642, 645, 0, 0, 631, 543, 1013, 534, 0,
552 553, 1013, 0, 628, 627, 637, 637, 624, 639, 622,
553 637, 632, 0, 0, 0, 0, 617, 0, 0, 0,
554 638, 353, 638, 627, 630, 614, 613, 623, 623, 613,
555 530, 563, 413, 609, 608, 619, 0, 622, 618, 620,
556 616, 602, 609, 605, 607, 603, 598, 596, 596, 575,
557
558 542, 553, 0, 1013, 466, 1013, 582, 0, 588, 556,
559 555, 535, 527, 535, 516, 524, 0, 517, 510, 492,
560 493, 489, 472, 0, 473, 472, 451, 505, 428, 426,
561 0, 0, 423, 0, 387, 392, 390, 373, 334, 316,
562 298, 288, 286, 0, 0, 0, 0, 0, 0, 290,
563 296, 266, 0, 0, 0, 0, 257, 269, 241, 0,
564 250, 0, 202, 133, 105, 0, 1013, 605, 610, 615,
565 617, 619, 625, 632, 637, 642, 647
566 } ;
567
568static yyconst flex_int16_t yy_def[678] =
569 { 0,
570 667, 1, 667, 3, 667, 667, 667, 667, 667, 667,
571 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
572 667, 668, 667, 668, 668, 668, 668, 668, 668, 668,
573 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
574 668, 668, 668, 667, 667, 667, 667, 667, 667, 667,
575 667, 667, 667, 669, 667, 667, 667, 667, 667, 667,
576 667, 667, 667, 667, 670, 667, 671, 17, 667, 667,
577 667, 672, 18, 667, 667, 667, 667, 667, 668, 667,
578 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
579 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
580
581 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
582 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
583 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
584 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
585 668, 667, 667, 667, 667, 667, 667, 667, 667, 667,
586 667, 667, 673, 667, 669, 667, 667, 671, 667, 667,
587 667, 667, 672, 667, 667, 668, 668, 668, 668, 668,
588 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
589 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
590 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
591
592 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
593 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
594 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
595 668, 668, 668, 668, 668, 668, 668, 668, 667, 667,
596 667, 667, 673, 667, 667, 667, 667, 667, 667, 667,
597 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
598 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
599 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
600 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
601 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
602
603 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
604 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
605 668, 668, 668, 668, 668, 668, 668, 667, 667, 667,
606 667, 667, 667, 668, 668, 668, 668, 668, 668, 668,
607 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
608 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
609 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
610 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
611 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
612 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
613
614 668, 668, 668, 668, 668, 667, 667, 667, 667, 668,
615 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
616 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
617 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
618 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
619 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
620 668, 668, 668, 667, 667, 667, 667, 668, 668, 668,
621 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
622 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
623 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
624
625 668, 668, 668, 668, 667, 674, 667, 667, 667, 668,
626 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
627 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
628 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
629 668, 668, 668, 668, 668, 667, 667, 667, 667, 675,
630 667, 667, 668, 668, 668, 668, 668, 668, 668, 668,
631 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
632 668, 668, 668, 668, 668, 668, 668, 668, 668, 667,
633 676, 667, 675, 668, 668, 668, 668, 668, 668, 668,
634 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
635
636 668, 668, 668, 667, 667, 667, 667, 677, 667, 668,
637 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
638 668, 668, 668, 668, 668, 668, 668, 677, 668, 668,
639 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
640 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
641 668, 668, 668, 668, 668, 668, 668, 668, 668, 668,
642 668, 668, 668, 668, 668, 668, 0, 667, 667, 667,
643 667, 667, 667, 667, 667, 667, 667
644 } ;
645
646static yyconst flex_int16_t yy_nxt[1076] =
647 { 0,
648 6, 7, 8, 7, 9, 6, 10, 11, 12, 13,
649 14, 15, 16, 17, 18, 18, 18, 18, 18, 18,
650 6, 19, 20, 21, 22, 22, 22, 22, 22, 22,
651 22, 22, 22, 22, 23, 22, 24, 25, 26, 27,
652 28, 29, 30, 31, 32, 22, 22, 33, 34, 35,
653 36, 37, 38, 39, 40, 41, 42, 43, 22, 22,
654 22, 44, 45, 55, 58, 55, 46, 61, 112, 63,
655 65, 65, 65, 65, 65, 65, 65, 74, 75, 59,
656 62, 64, 113, 47, 48, 49, 50, 49, 48, 48,
657 48, 48, 48, 48, 48, 48, 51, 48, 52, 52,
658
659 52, 52, 52, 52, 53, 48, 48, 48, 54, 54,
660 54, 54, 54, 54, 54, 54, 54, 54, 48, 54,
661 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
662 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
663 54, 54, 54, 54, 54, 48, 67, 142, 68, 68,
664 68, 68, 68, 68, 69, 77, 78, 81, 95, 84,
665 96, 85, 666, 70, 71, 86, 87, 116, 72, 97,
666 88, 98, 82, 83, 91, 70, 71, 89, 92, 99,
667 90, 117, 100, 665, 93, 101, 143, 104, 114, 119,
668 94, 102, 115, 72, 67, 105, 73, 73, 73, 73,
669
670 73, 73, 73, 175, 176, 120, 107, 106, 121, 108,
671 122, 70, 71, 109, 110, 152, 131, 152, 124, 132,
672 123, 111, 135, 70, 71, 125, 126, 136, 133, 138,
673 127, 137, 55, 139, 55, 134, 128, 129, 144, 130,
674 55, 664, 145, 140, 146, 147, 154, 154, 154, 154,
675 154, 154, 154, 156, 157, 159, 160, 667, 187, 236,
676 185, 152, 237, 152, 222, 156, 157, 159, 160, 161,
677 161, 186, 188, 162, 162, 162, 162, 162, 162, 162,
678 223, 204, 667, 148, 197, 209, 663, 198, 199, 205,
679 149, 200, 210, 201, 150, 212, 146, 147, 662, 151,
680
681 67, 231, 69, 69, 69, 69, 69, 69, 69, 213,
682 232, 144, 661, 55, 660, 145, 659, 70, 71, 146,
683 147, 154, 154, 154, 154, 154, 154, 154, 658, 70,
684 71, 246, 247, 260, 261, 148, 290, 291, 292, 317,
685 657, 519, 149, 246, 247, 656, 150, 655, 318, 520,
686 654, 151, 322, 323, 324, 337, 338, 339, 148, 348,
687 349, 350, 356, 357, 358, 149, 360, 361, 362, 150,
688 653, 244, 244, 652, 151, 245, 245, 245, 245, 245,
689 245, 245, 248, 248, 595, 596, 249, 249, 249, 249,
690 249, 249, 249, 162, 162, 162, 162, 162, 162, 162,
691
692 162, 162, 162, 162, 162, 162, 162, 245, 245, 245,
693 245, 245, 245, 245, 547, 548, 250, 245, 245, 245,
694 245, 245, 245, 245, 370, 371, 372, 651, 250, 650,
695 332, 332, 649, 157, 333, 333, 333, 333, 333, 333,
696 333, 430, 431, 432, 648, 157, 249, 249, 249, 249,
697 249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
698 333, 333, 333, 333, 333, 333, 333, 605, 606, 160,
699 333, 333, 333, 333, 333, 333, 333, 421, 422, 423,
700 647, 160, 433, 434, 435, 646, 247, 645, 424, 425,
701 436, 437, 438, 474, 475, 476, 547, 548, 247, 496,
702
703 497, 498, 465, 644, 477, 478, 605, 606, 643, 642,
704 499, 500, 641, 521, 506, 507, 507, 507, 507, 507,
705 507, 522, 533, 534, 535, 547, 548, 640, 550, 639,
706 638, 605, 606, 536, 537, 547, 548, 551, 551, 551,
707 551, 551, 551, 551, 547, 548, 637, 549, 549, 549,
708 549, 549, 549, 550, 547, 548, 581, 582, 582, 582,
709 582, 582, 582, 608, 605, 606, 551, 551, 551, 551,
710 551, 551, 551, 636, 635, 634, 609, 609, 609, 609,
711 609, 609, 609, 605, 606, 633, 632, 631, 608, 605,
712 606, 630, 629, 627, 626, 607, 607, 607, 607, 607,
713
714 607, 609, 609, 609, 609, 609, 609, 609, 79, 79,
715 79, 79, 79, 155, 155, 155, 155, 155, 65, 65,
716 158, 158, 163, 163, 163, 243, 243, 625, 243, 243,
717 243, 243, 243, 549, 549, 549, 624, 623, 622, 549,
718 583, 583, 583, 607, 607, 607, 621, 620, 619, 607,
719 628, 628, 628, 618, 617, 616, 615, 614, 613, 612,
720 611, 610, 604, 603, 602, 601, 600, 599, 598, 597,
721 594, 593, 592, 591, 590, 589, 588, 587, 586, 585,
722 584, 580, 579, 578, 577, 576, 575, 574, 573, 572,
723 571, 570, 569, 568, 567, 566, 565, 564, 563, 562,
724
725 561, 560, 559, 558, 557, 556, 555, 554, 553, 552,
726 546, 545, 544, 543, 542, 541, 540, 539, 538, 532,
727 531, 530, 529, 528, 527, 526, 525, 524, 523, 518,
728 517, 516, 515, 514, 513, 512, 511, 510, 509, 508,
729 505, 504, 503, 502, 501, 495, 494, 493, 492, 491,
730 490, 489, 488, 487, 486, 485, 484, 483, 482, 481,
731 480, 479, 473, 472, 471, 470, 469, 468, 467, 466,
732 465, 464, 463, 462, 461, 460, 459, 458, 457, 456,
733 455, 454, 453, 452, 451, 450, 449, 448, 447, 446,
734 445, 444, 443, 442, 441, 440, 439, 429, 428, 427,
735
736 426, 420, 419, 418, 417, 416, 415, 414, 413, 412,
737 411, 410, 409, 408, 407, 406, 405, 404, 403, 402,
738 401, 400, 399, 398, 397, 396, 395, 394, 393, 392,
739 391, 390, 389, 388, 387, 386, 385, 384, 383, 382,
740 381, 380, 379, 378, 377, 376, 375, 374, 373, 369,
741 368, 367, 366, 365, 364, 363, 359, 355, 354, 353,
742 352, 351, 347, 346, 345, 344, 343, 342, 341, 340,
743 336, 335, 334, 331, 330, 329, 328, 327, 326, 325,
744 321, 320, 319, 316, 315, 314, 313, 312, 311, 310,
745 309, 308, 307, 306, 305, 304, 303, 302, 301, 300,
746
747 299, 298, 297, 296, 295, 294, 293, 289, 288, 287,
748 286, 285, 284, 283, 282, 281, 280, 279, 278, 277,
749 276, 275, 274, 273, 272, 271, 270, 269, 268, 267,
750 266, 265, 264, 263, 262, 259, 258, 257, 256, 255,
751 254, 253, 252, 251, 242, 241, 240, 239, 238, 235,
752 234, 233, 230, 229, 228, 227, 226, 225, 224, 221,
753 220, 219, 218, 217, 216, 215, 214, 211, 208, 207,
754 206, 203, 202, 196, 195, 194, 193, 192, 191, 190,
755 189, 184, 183, 182, 181, 180, 179, 178, 177, 174,
756 173, 172, 171, 170, 169, 168, 167, 166, 165, 164,
757
758 153, 76, 141, 118, 103, 80, 76, 66, 60, 57,
759 56, 667, 5, 667, 667, 667, 667, 667, 667, 667,
760 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
761 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
762 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
763 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
764 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
765 667, 667, 667, 667, 667
766 } ;
767
768static yyconst flex_int16_t yy_chk[1076] =
769 { 0,
770 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
771 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
772 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
773 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
774 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
775 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
776 1, 1, 2, 7, 11, 7, 2, 13, 33, 14,
777 15, 15, 15, 15, 15, 15, 15, 19, 19, 11,
778 13, 14, 33, 2, 3, 3, 3, 3, 3, 3,
779 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
780
781 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
782 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
783 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
784 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
785 3, 3, 3, 3, 3, 3, 17, 44, 17, 17,
786 17, 17, 17, 17, 17, 21, 21, 24, 28, 25,
787 28, 25, 665, 17, 17, 25, 26, 35, 17, 28,
788 26, 29, 24, 24, 27, 17, 17, 26, 27, 29,
789 26, 35, 29, 664, 27, 29, 44, 31, 34, 37,
790 27, 29, 34, 17, 18, 31, 18, 18, 18, 18,
791
792 18, 18, 18, 90, 90, 37, 32, 31, 37, 32,
793 38, 18, 18, 32, 32, 49, 40, 49, 39, 40,
794 38, 32, 41, 18, 18, 39, 39, 41, 40, 42,
795 39, 41, 55, 42, 55, 40, 39, 39, 45, 39,
796 45, 663, 45, 42, 46, 46, 52, 52, 52, 52,
797 52, 52, 52, 65, 65, 67, 67, 68, 100, 140,
798 99, 152, 140, 152, 128, 65, 65, 67, 67, 70,
799 70, 99, 100, 70, 70, 70, 70, 70, 70, 70,
800 128, 113, 68, 46, 110, 117, 661, 110, 110, 113,
801 46, 110, 117, 110, 46, 119, 145, 145, 659, 46,
802
803 69, 136, 69, 69, 69, 69, 69, 69, 69, 119,
804 136, 144, 658, 144, 657, 144, 652, 69, 69, 146,
805 146, 154, 154, 154, 154, 154, 154, 154, 651, 69,
806 69, 158, 158, 176, 176, 145, 206, 206, 206, 231,
807 650, 479, 145, 158, 158, 643, 145, 642, 231, 479,
808 641, 145, 235, 235, 235, 255, 255, 255, 146, 265,
809 265, 265, 274, 274, 274, 146, 278, 278, 278, 146,
810 640, 156, 156, 639, 146, 156, 156, 156, 156, 156,
811 156, 156, 159, 159, 572, 572, 159, 159, 159, 159,
812 159, 159, 159, 161, 161, 161, 161, 161, 161, 161,
813
814 162, 162, 162, 162, 162, 162, 162, 244, 244, 244,
815 244, 244, 244, 244, 583, 583, 162, 245, 245, 245,
816 245, 245, 245, 245, 286, 286, 286, 638, 162, 637,
817 246, 246, 636, 245, 246, 246, 246, 246, 246, 246,
818 246, 374, 374, 374, 635, 245, 248, 248, 248, 248,
819 248, 248, 248, 249, 249, 249, 249, 249, 249, 249,
820 332, 332, 332, 332, 332, 332, 332, 605, 605, 249,
821 333, 333, 333, 333, 333, 333, 333, 364, 364, 364,
822 633, 249, 375, 375, 375, 630, 333, 629, 364, 364,
823 376, 376, 376, 420, 420, 420, 506, 506, 333, 459,
824
825 459, 459, 465, 627, 420, 420, 628, 628, 626, 625,
826 459, 459, 623, 480, 465, 465, 465, 465, 465, 465,
827 465, 480, 493, 493, 493, 507, 507, 622, 506, 621,
828 620, 581, 581, 493, 493, 549, 549, 507, 507, 507,
829 507, 507, 507, 507, 547, 547, 619, 549, 549, 549,
830 549, 549, 549, 506, 551, 551, 547, 547, 547, 547,
831 547, 547, 547, 581, 582, 582, 551, 551, 551, 551,
832 551, 551, 551, 618, 616, 615, 582, 582, 582, 582,
833 582, 582, 582, 607, 607, 614, 613, 612, 581, 609,
834 609, 611, 610, 602, 601, 607, 607, 607, 607, 607,
835
836 607, 609, 609, 609, 609, 609, 609, 609, 668, 668,
837 668, 668, 668, 669, 669, 669, 669, 669, 670, 670,
838 671, 671, 672, 672, 672, 673, 673, 600, 673, 673,
839 673, 673, 673, 674, 674, 674, 599, 598, 597, 674,
840 675, 675, 675, 676, 676, 676, 596, 595, 594, 676,
841 677, 677, 677, 593, 592, 591, 590, 589, 588, 586,
842 585, 584, 580, 579, 578, 577, 576, 575, 574, 573,
843 571, 567, 562, 561, 560, 559, 558, 557, 556, 555,
844 554, 546, 543, 542, 540, 539, 537, 536, 535, 534,
845 533, 532, 531, 530, 529, 527, 526, 525, 524, 523,
846
847 522, 521, 520, 519, 518, 517, 515, 514, 510, 509,
848 505, 504, 502, 500, 499, 498, 497, 496, 494, 492,
849 491, 490, 489, 488, 487, 485, 484, 483, 482, 478,
850 477, 476, 475, 474, 473, 470, 469, 468, 467, 466,
851 464, 463, 462, 461, 460, 458, 457, 450, 449, 446,
852 445, 442, 441, 440, 439, 428, 427, 425, 424, 423,
853 422, 421, 418, 416, 415, 414, 412, 411, 409, 408,
854 407, 406, 404, 403, 401, 399, 398, 397, 396, 395,
855 394, 393, 392, 391, 390, 388, 387, 386, 385, 384,
856 383, 382, 381, 380, 379, 378, 377, 373, 369, 368,
857
858 365, 363, 353, 351, 347, 346, 345, 344, 342, 340,
859 335, 334, 331, 330, 329, 328, 327, 326, 321, 320,
860 319, 318, 317, 316, 315, 312, 311, 310, 309, 308,
861 307, 306, 305, 304, 303, 302, 301, 300, 299, 298,
862 297, 296, 295, 294, 293, 292, 291, 290, 287, 285,
863 284, 283, 282, 281, 280, 279, 277, 273, 271, 270,
864 269, 268, 264, 263, 262, 261, 260, 259, 258, 257,
865 254, 252, 251, 242, 241, 240, 239, 238, 237, 236,
866 234, 233, 232, 230, 229, 228, 227, 226, 225, 224,
867 223, 222, 221, 220, 219, 218, 217, 216, 215, 214,
868
869 213, 212, 211, 210, 209, 208, 207, 205, 204, 203,
870 202, 201, 200, 199, 198, 197, 196, 195, 194, 193,
871 192, 191, 190, 188, 187, 186, 185, 184, 183, 182,
872 181, 180, 179, 178, 177, 175, 174, 173, 172, 171,
873 170, 169, 168, 166, 151, 150, 149, 148, 141, 139,
874 138, 137, 135, 134, 133, 132, 131, 130, 129, 127,
875 126, 125, 124, 123, 122, 121, 120, 118, 116, 115,
876 114, 112, 111, 109, 108, 106, 105, 104, 103, 102,
877 101, 98, 97, 96, 95, 94, 93, 92, 91, 89,
878 88, 87, 86, 85, 84, 83, 82, 81, 78, 74,
879
880 51, 47, 43, 36, 30, 23, 20, 16, 12, 10,
881 9, 5, 667, 667, 667, 667, 667, 667, 667, 667,
882 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
883 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
884 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
885 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
886 667, 667, 667, 667, 667, 667, 667, 667, 667, 667,
887 667, 667, 667, 667, 667
888 } ;
889
890/* The intent behind this definition is that it'll catch
891 * any uses of REJECT which flex missed.
892 */
893#define REJECT reject_used_but_not_detected
894#define yymore() yymore_used_but_not_detected
895#define YY_MORE_ADJ 0
896#define YY_RESTORE_YY_MORE_OFFSET
897#line 1 "glsl_lexer.lpp"
898#line 2 "glsl_lexer.lpp"
899/*
900 * Copyright © 2008, 2009 Intel Corporation
901 *
902 * Permission is hereby granted, free of charge, to any person obtaining a
903 * copy of this software and associated documentation files (the "Software"),
904 * to deal in the Software without restriction, including without limitation
905 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
906 * and/or sell copies of the Software, and to permit persons to whom the
907 * Software is furnished to do so, subject to the following conditions:
908 *
909 * The above copyright notice and this permission notice (including the next
910 * paragraph) shall be included in all copies or substantial portions of the
911 * Software.
912 *
913 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
914 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
915 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
916 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
917 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
918 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
919 * DEALINGS IN THE SOFTWARE.
920 */
921#include <ctype.h>
922#include "ast.h"
923#include "glsl_parser_extras.h"
924#include "glsl_parser.h"
925
926#define YY_USER_ACTION \
927 do { \
928 yylloc->source = 0; \
929 yylloc->first_column = yycolumn + 1; \
930 yylloc->first_line = yylineno + 1; \
931 yycolumn += yyleng; \
932 } while(0);
933
934#define YY_USER_INIT yylineno = 0; yycolumn = 0;
935
936#define TOKEN_OR_IDENTIFIER(version, token) \
937 do { \
938 if (yyextra->language_version >= version) { \
939 return token; \
940 } else { \
941 yylval->identifier = strdup(yytext); \
942 return IDENTIFIER; \
943 } \
944 } while (0)
945
946#define RESERVED_WORD(version, token) \
947 do { \
948 if (yyextra->language_version >= version) { \
949 return token; \
950 } else { \
951 _mesa_glsl_error(yylloc, yyextra, \
952 "Illegal use of reserved word `%s'", yytext); \
953 return ERROR_TOK; \
954 } \
955 } while (0)
956
957#line 958 "glsl_lexer.cpp"
958
959#define INITIAL 0
960#define PP 1
961
962#define YY_EXTRA_TYPE struct _mesa_glsl_parse_state *
963
964/* Holds the entire state of the reentrant scanner. */
965struct yyguts_t
966 {
967
968 /* User-defined. Not touched by flex. */
969 YY_EXTRA_TYPE yyextra_r;
970
971 /* The rest are the same as the globals declared in the non-reentrant scanner. */
972 FILE *yyin_r, *yyout_r;
973 size_t yy_buffer_stack_top; /**< index of top of stack. */
974 size_t yy_buffer_stack_max; /**< capacity of stack. */
975 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
976 char yy_hold_char;
977 int yy_n_chars;
978 int yyleng_r;
979 char *yy_c_buf_p;
980 int yy_init;
981 int yy_start;
982 int yy_did_buffer_switch_on_eof;
983 int yy_start_stack_ptr;
984 int yy_start_stack_depth;
985 int *yy_start_stack;
986 yy_state_type yy_last_accepting_state;
987 char* yy_last_accepting_cpos;
988
989 int yylineno_r;
990 int yy_flex_debug_r;
991
992 char *yytext_r;
993 int yy_more_flag;
994 int yy_more_len;
995
996 YYSTYPE * yylval_r;
997
998 YYLTYPE * yylloc_r;
999
1000 }; /* end struct yyguts_t */
1001
1002static int yy_init_globals (yyscan_t yyscanner );
1003
1004 /* This must go here because YYSTYPE and YYLTYPE are included
1005 * from bison output in section 1.*/
1006 # define yylval yyg->yylval_r
1007
1008 # define yylloc yyg->yylloc_r
1009
1010int _mesa_glsl_lex_init (yyscan_t* scanner);
1011
1012int _mesa_glsl_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
1013
1014/* Accessor methods to globals.
1015 These are made visible to non-reentrant scanners for convenience. */
1016
1017int _mesa_glsl_lex_destroy (yyscan_t yyscanner );
1018
1019int _mesa_glsl_get_debug (yyscan_t yyscanner );
1020
1021void _mesa_glsl_set_debug (int debug_flag ,yyscan_t yyscanner );
1022
1023YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner );
1024
1025void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
1026
1027FILE *_mesa_glsl_get_in (yyscan_t yyscanner );
1028
1029void _mesa_glsl_set_in (FILE * in_str ,yyscan_t yyscanner );
1030
1031FILE *_mesa_glsl_get_out (yyscan_t yyscanner );
1032
1033void _mesa_glsl_set_out (FILE * out_str ,yyscan_t yyscanner );
1034
1035int _mesa_glsl_get_leng (yyscan_t yyscanner );
1036
1037char *_mesa_glsl_get_text (yyscan_t yyscanner );
1038
1039int _mesa_glsl_get_lineno (yyscan_t yyscanner );
1040
1041void _mesa_glsl_set_lineno (int line_number ,yyscan_t yyscanner );
1042
1043YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner );
1044
1045void _mesa_glsl_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
1046
1047 YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner );
1048
1049 void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
1050
1051/* Macros after this point can all be overridden by user definitions in
1052 * section 1.
1053 */
1054
1055#ifndef YY_SKIP_YYWRAP
1056#ifdef __cplusplus
1057extern "C" int _mesa_glsl_wrap (yyscan_t yyscanner );
1058#else
1059extern int _mesa_glsl_wrap (yyscan_t yyscanner );
1060#endif
1061#endif
1062
1063#ifndef yytext_ptr
1064static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
1065#endif
1066
1067#ifdef YY_NEED_STRLEN
1068static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
1069#endif
1070
1071#ifndef YY_NO_INPUT
1072
1073#ifdef __cplusplus
1074static int yyinput (yyscan_t yyscanner );
1075#else
1076static int input (yyscan_t yyscanner );
1077#endif
1078
1079#endif
1080
1081/* Amount of stuff to slurp up with each read. */
1082#ifndef YY_READ_BUF_SIZE
1083#ifdef __ia64__
1084/* On IA-64, the buffer size is 16k, not 8k */
1085#define YY_READ_BUF_SIZE 16384
1086#else
1087#define YY_READ_BUF_SIZE 8192
1088#endif /* __ia64__ */
1089#endif
1090
1091/* Copy whatever the last rule matched to the standard output. */
1092#ifndef ECHO
1093/* This used to be an fputs(), but since the string might contain NUL's,
1094 * we now use fwrite().
1095 */
1096#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
1097#endif
1098
1099/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
1100 * is returned in "result".
1101 */
1102#ifndef YY_INPUT
1103#define YY_INPUT(buf,result,max_size) \
1104 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1105 { \
1106 int c = '*'; \
1107 size_t n; \
1108 for ( n = 0; n < max_size && \
1109 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1110 buf[n] = (char) c; \
1111 if ( c == '\n' ) \
1112 buf[n++] = (char) c; \
1113 if ( c == EOF && ferror( yyin ) ) \
1114 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1115 result = n; \
1116 } \
1117 else \
1118 { \
1119 errno=0; \
1120 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
1121 { \
1122 if( errno != EINTR) \
1123 { \
1124 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1125 break; \
1126 } \
1127 errno=0; \
1128 clearerr(yyin); \
1129 } \
1130 }\
1131\
1132
1133#endif
1134
1135/* No semi-colon after return; correct usage is to write "yyterminate();" -
1136 * we don't want an extra ';' after the "return" because that will cause
1137 * some compilers to complain about unreachable statements.
1138 */
1139#ifndef yyterminate
1140#define yyterminate() return YY_NULL
1141#endif
1142
1143/* Number of entries by which start-condition stack grows. */
1144#ifndef YY_START_STACK_INCR
1145#define YY_START_STACK_INCR 25
1146#endif
1147
1148/* Report a fatal error. */
1149#ifndef YY_FATAL_ERROR
1150#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1151#endif
1152
1153/* end tables serialization structures and prototypes */
1154
1155/* Default declaration of generated scanner - a define so the user can
1156 * easily add parameters.
1157 */
1158#ifndef YY_DECL
1159#define YY_DECL_IS_OURS 1
1160
1161extern int _mesa_glsl_lex \
1162 (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
1163
1164#define YY_DECL int _mesa_glsl_lex \
1165 (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
1166#endif /* !YY_DECL */
1167
1168/* Code executed at the beginning of each rule, after yytext and yyleng
1169 * have been set up.
1170 */
1171#ifndef YY_USER_ACTION
1172#define YY_USER_ACTION
1173#endif
1174
1175/* Code executed at the end of each rule. */
1176#ifndef YY_BREAK
1177#define YY_BREAK break;
1178#endif
1179
1180#define YY_RULE_SETUP \
1181 if ( yyleng > 0 ) \
1182 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
1183 (yytext[yyleng - 1] == '\n'); \
1184 YY_USER_ACTION
1185
1186/** The main scanner function which does all the work.
1187 */
1188YY_DECL
1189{
1190 register yy_state_type yy_current_state;
1191 register char *yy_cp, *yy_bp;
1192 register int yy_act;
1193 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1194
1195#line 76 "glsl_lexer.lpp"
1196
1197
1198#line 1199 "glsl_lexer.cpp"
1199
1200 yylval = yylval_param;
1201
1202 yylloc = yylloc_param;
1203
1204 if ( !yyg->yy_init )
1205 {
1206 yyg->yy_init = 1;
1207
1208#ifdef YY_USER_INIT
1209 YY_USER_INIT;
1210#endif
1211
1212 if ( ! yyg->yy_start )
1213 yyg->yy_start = 1; /* first start state */
1214
1215 if ( ! yyin )
1216 yyin = stdin;
1217
1218 if ( ! yyout )
1219 yyout = stdout;
1220
1221 if ( ! YY_CURRENT_BUFFER ) {
1222 _mesa_glsl_ensure_buffer_stack (yyscanner);
1223 YY_CURRENT_BUFFER_LVALUE =
1224 _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1225 }
1226
1227 _mesa_glsl__load_buffer_state(yyscanner );
1228 }
1229
1230 while ( 1 ) /* loops until end-of-file is reached */
1231 {
1232 yy_cp = yyg->yy_c_buf_p;
1233
1234 /* Support of yytext. */
1235 *yy_cp = yyg->yy_hold_char;
1236
1237 /* yy_bp points to the position in yy_ch_buf of the start of
1238 * the current run.
1239 */
1240 yy_bp = yy_cp;
1241
1242 yy_current_state = yyg->yy_start;
1243 yy_current_state += YY_AT_BOL();
1244yy_match:
1245 do
1246 {
1247 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1248 if ( yy_accept[yy_current_state] )
1249 {
1250 yyg->yy_last_accepting_state = yy_current_state;
1251 yyg->yy_last_accepting_cpos = yy_cp;
1252 }
1253 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1254 {
1255 yy_current_state = (int) yy_def[yy_current_state];
1256 if ( yy_current_state >= 668 )
1257 yy_c = yy_meta[(unsigned int) yy_c];
1258 }
1259 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1260 ++yy_cp;
1261 }
1262 while ( yy_current_state != 667 );
1263 yy_cp = yyg->yy_last_accepting_cpos;
1264 yy_current_state = yyg->yy_last_accepting_state;
1265
1266yy_find_action:
1267 yy_act = yy_accept[yy_current_state];
1268
1269 YY_DO_BEFORE_ACTION;
1270
1271do_action: /* This label is used only to access EOF actions. */
1272
1273 switch ( yy_act )
1274 { /* beginning of action switch */
1275 case 0: /* must back up */
1276 /* undo the effects of YY_DO_BEFORE_ACTION */
1277 *yy_cp = yyg->yy_hold_char;
1278 yy_cp = yyg->yy_last_accepting_cpos;
1279 yy_current_state = yyg->yy_last_accepting_state;
1280 goto yy_find_action;
1281
1282case 1:
1283YY_RULE_SETUP
1284#line 78 "glsl_lexer.lpp"
1285;
1286 YY_BREAK
1287/* Preprocessor tokens. */
1288case 2:
1289*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
1290yyg->yy_c_buf_p = yy_cp -= 1;
1291YY_DO_BEFORE_ACTION; /* set up yytext again */
1292YY_RULE_SETUP
1293#line 81 "glsl_lexer.lpp"
1294;
1295 YY_BREAK
1296case 3:
1297YY_RULE_SETUP
1298#line 82 "glsl_lexer.lpp"
1299{ BEGIN PP; return VERSION; }
1300 YY_BREAK
1301case 4:
1302YY_RULE_SETUP
1303#line 83 "glsl_lexer.lpp"
1304{ BEGIN PP; return EXTENSION; }
1305 YY_BREAK
1306case 5:
1307*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
1308yyg->yy_c_buf_p = yy_cp -= 1;
1309YY_DO_BEFORE_ACTION; /* set up yytext again */
1310YY_RULE_SETUP
1311#line 84 "glsl_lexer.lpp"
1312{
1313 /* Eat characters until the first digit is
1314 * encountered
1315 */
1316 char *ptr = yytext;
1317 while (!isdigit(*ptr))
1318 ptr++;
1319
1320 /* Subtract one from the line number because
1321 * yylineno is zero-based instead of
1322 * one-based.
1323 */
1324 yylineno = strtol(ptr, &ptr, 0) - 1;
1325 yylloc->source = strtol(ptr, NULL, 0);
1326 }
1327 YY_BREAK
1328case 6:
1329*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
1330yyg->yy_c_buf_p = yy_cp -= 1;
1331YY_DO_BEFORE_ACTION; /* set up yytext again */
1332YY_RULE_SETUP
1333#line 99 "glsl_lexer.lpp"
1334{
1335 /* Eat characters until the first digit is
1336 * encountered
1337 */
1338 char *ptr = yytext;
1339 while (!isdigit(*ptr))
1340 ptr++;
1341
1342 /* Subtract one from the line number because
1343 * yylineno is zero-based instead of
1344 * one-based.
1345 */
1346 yylineno = strtol(ptr, &ptr, 0) - 1;
1347 }
1348 YY_BREAK
1349case 7:
1350YY_RULE_SETUP
1351#line 113 "glsl_lexer.lpp"
1352{ BEGIN PP; return PRAGMA; }
1353 YY_BREAK
1354case 8:
1355YY_RULE_SETUP
1356#line 114 "glsl_lexer.lpp"
1357{ }
1358 YY_BREAK
1359case 9:
1360YY_RULE_SETUP
1361#line 115 "glsl_lexer.lpp"
1362{ }
1363 YY_BREAK
1364case 10:
1365YY_RULE_SETUP
1366#line 116 "glsl_lexer.lpp"
1367return COLON;
1368 YY_BREAK
1369case 11:
1370YY_RULE_SETUP
1371#line 117 "glsl_lexer.lpp"
1372{
1373 yylval->identifier = strdup(yytext);
1374 return IDENTIFIER;
1375 }
1376 YY_BREAK
1377case 12:
1378YY_RULE_SETUP
1379#line 121 "glsl_lexer.lpp"
1380{
1381 yylval->n = strtol(yytext, NULL, 10);
1382 return INTCONSTANT;
1383 }
1384 YY_BREAK
1385case 13:
1386/* rule 13 can match eol */
1387YY_RULE_SETUP
1388#line 125 "glsl_lexer.lpp"
1389{ BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
1390 YY_BREAK
1391case 14:
1392/* rule 14 can match eol */
1393YY_RULE_SETUP
1394#line 127 "glsl_lexer.lpp"
1395{ yylineno++; yycolumn = 0; }
1396 YY_BREAK
1397case 15:
1398YY_RULE_SETUP
1399#line 129 "glsl_lexer.lpp"
1400return ATTRIBUTE;
1401 YY_BREAK
1402case 16:
1403YY_RULE_SETUP
1404#line 130 "glsl_lexer.lpp"
1405return CONST_TOK;
1406 YY_BREAK
1407case 17:
1408YY_RULE_SETUP
1409#line 131 "glsl_lexer.lpp"
1410return BOOL_TOK;
1411 YY_BREAK
1412case 18:
1413YY_RULE_SETUP
1414#line 132 "glsl_lexer.lpp"
1415return FLOAT_TOK;
1416 YY_BREAK
1417case 19:
1418YY_RULE_SETUP
1419#line 133 "glsl_lexer.lpp"
1420return INT_TOK;
1421 YY_BREAK
1422case 20:
1423YY_RULE_SETUP
1424#line 135 "glsl_lexer.lpp"
1425return BREAK;
1426 YY_BREAK
1427case 21:
1428YY_RULE_SETUP
1429#line 136 "glsl_lexer.lpp"
1430return CONTINUE;
1431 YY_BREAK
1432case 22:
1433YY_RULE_SETUP
1434#line 137 "glsl_lexer.lpp"
1435return DO;
1436 YY_BREAK
1437case 23:
1438YY_RULE_SETUP
1439#line 138 "glsl_lexer.lpp"
1440return WHILE;
1441 YY_BREAK
1442case 24:
1443YY_RULE_SETUP
1444#line 139 "glsl_lexer.lpp"
1445return ELSE;
1446 YY_BREAK
1447case 25:
1448YY_RULE_SETUP
1449#line 140 "glsl_lexer.lpp"
1450return FOR;
1451 YY_BREAK
1452case 26:
1453YY_RULE_SETUP
1454#line 141 "glsl_lexer.lpp"
1455return IF;
1456 YY_BREAK
1457case 27:
1458YY_RULE_SETUP
1459#line 142 "glsl_lexer.lpp"
1460return DISCARD;
1461 YY_BREAK
1462case 28:
1463YY_RULE_SETUP
1464#line 143 "glsl_lexer.lpp"
1465return RETURN;
1466 YY_BREAK
1467case 29:
1468YY_RULE_SETUP
1469#line 145 "glsl_lexer.lpp"
1470return BVEC2;
1471 YY_BREAK
1472case 30:
1473YY_RULE_SETUP
1474#line 146 "glsl_lexer.lpp"
1475return BVEC3;
1476 YY_BREAK
1477case 31:
1478YY_RULE_SETUP
1479#line 147 "glsl_lexer.lpp"
1480return BVEC4;
1481 YY_BREAK
1482case 32:
1483YY_RULE_SETUP
1484#line 148 "glsl_lexer.lpp"
1485return IVEC2;
1486 YY_BREAK
1487case 33:
1488YY_RULE_SETUP
1489#line 149 "glsl_lexer.lpp"
1490return IVEC3;
1491 YY_BREAK
1492case 34:
1493YY_RULE_SETUP
1494#line 150 "glsl_lexer.lpp"
1495return IVEC4;
1496 YY_BREAK
1497case 35:
1498YY_RULE_SETUP
1499#line 151 "glsl_lexer.lpp"
1500return VEC2;
1501 YY_BREAK
1502case 36:
1503YY_RULE_SETUP
1504#line 152 "glsl_lexer.lpp"
1505return VEC3;
1506 YY_BREAK
1507case 37:
1508YY_RULE_SETUP
1509#line 153 "glsl_lexer.lpp"
1510return VEC4;
1511 YY_BREAK
1512case 38:
1513YY_RULE_SETUP
1514#line 154 "glsl_lexer.lpp"
1515return MAT2X2;
1516 YY_BREAK
1517case 39:
1518YY_RULE_SETUP
1519#line 155 "glsl_lexer.lpp"
1520return MAT3X3;
1521 YY_BREAK
1522case 40:
1523YY_RULE_SETUP
1524#line 156 "glsl_lexer.lpp"
1525return MAT4X4;
1526 YY_BREAK
1527case 41:
1528YY_RULE_SETUP
1529#line 157 "glsl_lexer.lpp"
1530TOKEN_OR_IDENTIFIER(120, MAT2X2);
1531 YY_BREAK
1532case 42:
1533YY_RULE_SETUP
1534#line 158 "glsl_lexer.lpp"
1535TOKEN_OR_IDENTIFIER(120, MAT2X3);
1536 YY_BREAK
1537case 43:
1538YY_RULE_SETUP
1539#line 159 "glsl_lexer.lpp"
1540TOKEN_OR_IDENTIFIER(120, MAT2X4);
1541 YY_BREAK
1542case 44:
1543YY_RULE_SETUP
1544#line 160 "glsl_lexer.lpp"
1545TOKEN_OR_IDENTIFIER(120, MAT3X2);
1546 YY_BREAK
1547case 45:
1548YY_RULE_SETUP
1549#line 161 "glsl_lexer.lpp"
1550TOKEN_OR_IDENTIFIER(120, MAT3X3);
1551 YY_BREAK
1552case 46:
1553YY_RULE_SETUP
1554#line 162 "glsl_lexer.lpp"
1555TOKEN_OR_IDENTIFIER(120, MAT3X4);
1556 YY_BREAK
1557case 47:
1558YY_RULE_SETUP
1559#line 163 "glsl_lexer.lpp"
1560TOKEN_OR_IDENTIFIER(120, MAT4X2);
1561 YY_BREAK
1562case 48:
1563YY_RULE_SETUP
1564#line 164 "glsl_lexer.lpp"
1565TOKEN_OR_IDENTIFIER(120, MAT4X3);
1566 YY_BREAK
1567case 49:
1568YY_RULE_SETUP
1569#line 165 "glsl_lexer.lpp"
1570TOKEN_OR_IDENTIFIER(120, MAT4X4);
1571 YY_BREAK
1572case 50:
1573YY_RULE_SETUP
1574#line 167 "glsl_lexer.lpp"
1575return IN_TOK;
1576 YY_BREAK
1577case 51:
1578YY_RULE_SETUP
1579#line 168 "glsl_lexer.lpp"
1580return OUT_TOK;
1581 YY_BREAK
1582case 52:
1583YY_RULE_SETUP
1584#line 169 "glsl_lexer.lpp"
1585return INOUT_TOK;
1586 YY_BREAK
1587case 53:
1588YY_RULE_SETUP
1589#line 170 "glsl_lexer.lpp"
1590return UNIFORM;
1591 YY_BREAK
1592case 54:
1593YY_RULE_SETUP
1594#line 171 "glsl_lexer.lpp"
1595return VARYING;
1596 YY_BREAK
1597case 55:
1598YY_RULE_SETUP
1599#line 172 "glsl_lexer.lpp"
1600TOKEN_OR_IDENTIFIER(120, CENTROID);
1601 YY_BREAK
1602case 56:
1603YY_RULE_SETUP
1604#line 173 "glsl_lexer.lpp"
1605TOKEN_OR_IDENTIFIER(120, INVARIANT);
1606 YY_BREAK
1607case 57:
1608YY_RULE_SETUP
1609#line 175 "glsl_lexer.lpp"
1610TOKEN_OR_IDENTIFIER(130, FLAT);
1611 YY_BREAK
1612case 58:
1613YY_RULE_SETUP
1614#line 176 "glsl_lexer.lpp"
1615TOKEN_OR_IDENTIFIER(130, SMOOTH);
1616 YY_BREAK
1617case 59:
1618YY_RULE_SETUP
1619#line 177 "glsl_lexer.lpp"
1620TOKEN_OR_IDENTIFIER(130, NOPERSPECTIVE);
1621 YY_BREAK
1622case 60:
1623YY_RULE_SETUP
1624#line 179 "glsl_lexer.lpp"
1625return SAMPLER1D;
1626 YY_BREAK
1627case 61:
1628YY_RULE_SETUP
1629#line 180 "glsl_lexer.lpp"
1630return SAMPLER2D;
1631 YY_BREAK
1632case 62:
1633YY_RULE_SETUP
1634#line 181 "glsl_lexer.lpp"
1635return SAMPLER3D;
1636 YY_BREAK
1637case 63:
1638YY_RULE_SETUP
1639#line 182 "glsl_lexer.lpp"
1640return SAMPLERCUBE;
1641 YY_BREAK
1642case 64:
1643YY_RULE_SETUP
1644#line 183 "glsl_lexer.lpp"
1645return SAMPLER1DSHADOW;
1646 YY_BREAK
1647case 65:
1648YY_RULE_SETUP
1649#line 184 "glsl_lexer.lpp"
1650return SAMPLER2DSHADOW;
1651 YY_BREAK
1652case 66:
1653YY_RULE_SETUP
1654#line 186 "glsl_lexer.lpp"
1655return STRUCT;
1656 YY_BREAK
1657case 67:
1658YY_RULE_SETUP
1659#line 187 "glsl_lexer.lpp"
1660return VOID_TOK;
1661 YY_BREAK
1662case 68:
1663YY_RULE_SETUP
1664#line 189 "glsl_lexer.lpp"
1665{
1666 if ((yyextra->language_version >= 140)
1667 || (yyextra->ARB_fragment_coord_conventions_enable)){
1668 return LAYOUT_TOK;
1669 } else {
1670 yylval->identifier = strdup(yytext);
1671 return IDENTIFIER;
1672 }
1673 }
1674 YY_BREAK
1675case 69:
1676YY_RULE_SETUP
1677#line 199 "glsl_lexer.lpp"
1678return INC_OP;
1679 YY_BREAK
1680case 70:
1681YY_RULE_SETUP
1682#line 200 "glsl_lexer.lpp"
1683return DEC_OP;
1684 YY_BREAK
1685case 71:
1686YY_RULE_SETUP
1687#line 201 "glsl_lexer.lpp"
1688return LE_OP;
1689 YY_BREAK
1690case 72:
1691YY_RULE_SETUP
1692#line 202 "glsl_lexer.lpp"
1693return GE_OP;
1694 YY_BREAK
1695case 73:
1696YY_RULE_SETUP
1697#line 203 "glsl_lexer.lpp"
1698return EQ_OP;
1699 YY_BREAK
1700case 74:
1701YY_RULE_SETUP
1702#line 204 "glsl_lexer.lpp"
1703return NE_OP;
1704 YY_BREAK
1705case 75:
1706YY_RULE_SETUP
1707#line 205 "glsl_lexer.lpp"
1708return AND_OP;
1709 YY_BREAK
1710case 76:
1711YY_RULE_SETUP
1712#line 206 "glsl_lexer.lpp"
1713return OR_OP;
1714 YY_BREAK
1715case 77:
1716YY_RULE_SETUP
1717#line 207 "glsl_lexer.lpp"
1718return XOR_OP;
1719 YY_BREAK
1720case 78:
1721YY_RULE_SETUP
1722#line 209 "glsl_lexer.lpp"
1723return MUL_ASSIGN;
1724 YY_BREAK
1725case 79:
1726YY_RULE_SETUP
1727#line 210 "glsl_lexer.lpp"
1728return DIV_ASSIGN;
1729 YY_BREAK
1730case 80:
1731YY_RULE_SETUP
1732#line 211 "glsl_lexer.lpp"
1733return ADD_ASSIGN;
1734 YY_BREAK
1735case 81:
1736YY_RULE_SETUP
1737#line 212 "glsl_lexer.lpp"
1738return MOD_ASSIGN;
1739 YY_BREAK
1740case 82:
1741YY_RULE_SETUP
1742#line 213 "glsl_lexer.lpp"
1743return LEFT_ASSIGN;
1744 YY_BREAK
1745case 83:
1746YY_RULE_SETUP
1747#line 214 "glsl_lexer.lpp"
1748return RIGHT_ASSIGN;
1749 YY_BREAK
1750case 84:
1751YY_RULE_SETUP
1752#line 215 "glsl_lexer.lpp"
1753return AND_ASSIGN;
1754 YY_BREAK
1755case 85:
1756YY_RULE_SETUP
1757#line 216 "glsl_lexer.lpp"
1758return XOR_ASSIGN;
1759 YY_BREAK
1760case 86:
1761YY_RULE_SETUP
1762#line 217 "glsl_lexer.lpp"
1763return OR_ASSIGN;
1764 YY_BREAK
1765case 87:
1766YY_RULE_SETUP
1767#line 218 "glsl_lexer.lpp"
1768return SUB_ASSIGN;
1769 YY_BREAK
1770case 88:
1771YY_RULE_SETUP
1772#line 220 "glsl_lexer.lpp"
1773{
1774 yylval->n = strtol(yytext, NULL, 10);
1775 return INTCONSTANT;
1776 }
1777 YY_BREAK
1778case 89:
1779YY_RULE_SETUP
1780#line 224 "glsl_lexer.lpp"
1781{
1782 yylval->n = strtol(yytext + 2, NULL, 16);
1783 return INTCONSTANT;
1784 }
1785 YY_BREAK
1786case 90:
1787YY_RULE_SETUP
1788#line 228 "glsl_lexer.lpp"
1789{
1790 yylval->n = strtol(yytext, NULL, 8);
1791 return INTCONSTANT;
1792 }
1793 YY_BREAK
1794case 91:
1795YY_RULE_SETUP
1796#line 233 "glsl_lexer.lpp"
1797{
1798 yylval->real = strtod(yytext, NULL);
1799 return FLOATCONSTANT;
1800 }
1801 YY_BREAK
1802case 92:
1803YY_RULE_SETUP
1804#line 237 "glsl_lexer.lpp"
1805{
1806 yylval->real = strtod(yytext, NULL);
1807 return FLOATCONSTANT;
1808 }
1809 YY_BREAK
1810case 93:
1811YY_RULE_SETUP
1812#line 241 "glsl_lexer.lpp"
1813{
1814 yylval->real = strtod(yytext, NULL);
1815 return FLOATCONSTANT;
1816 }
1817 YY_BREAK
1818case 94:
1819YY_RULE_SETUP
1820#line 245 "glsl_lexer.lpp"
1821{
1822 yylval->real = strtod(yytext, NULL);
1823 return FLOATCONSTANT;
1824 }
1825 YY_BREAK
1826case 95:
1827YY_RULE_SETUP
1828#line 249 "glsl_lexer.lpp"
1829{
1830 yylval->real = strtod(yytext, NULL);
1831 return FLOATCONSTANT;
1832 }
1833 YY_BREAK
1834case 96:
1835YY_RULE_SETUP
1836#line 254 "glsl_lexer.lpp"
1837{
1838 yylval->n = 1;
1839 return BOOLCONSTANT;
1840 }
1841 YY_BREAK
1842case 97:
1843YY_RULE_SETUP
1844#line 258 "glsl_lexer.lpp"
1845{
1846 yylval->n = 0;
1847 return BOOLCONSTANT;
1848 }
1849 YY_BREAK
1850/* Reserved words in GLSL 1.10. */
1851case 98:
1852YY_RULE_SETUP
1853#line 265 "glsl_lexer.lpp"
1854RESERVED_WORD(999, ASM);
1855 YY_BREAK
1856case 99:
1857YY_RULE_SETUP
1858#line 266 "glsl_lexer.lpp"
1859RESERVED_WORD(999, CLASS);
1860 YY_BREAK
1861case 100:
1862YY_RULE_SETUP
1863#line 267 "glsl_lexer.lpp"
1864RESERVED_WORD(999, UNION);
1865 YY_BREAK
1866case 101:
1867YY_RULE_SETUP
1868#line 268 "glsl_lexer.lpp"
1869RESERVED_WORD(999, ENUM);
1870 YY_BREAK
1871case 102:
1872YY_RULE_SETUP
1873#line 269 "glsl_lexer.lpp"
1874RESERVED_WORD(999, TYPEDEF);
1875 YY_BREAK
1876case 103:
1877YY_RULE_SETUP
1878#line 270 "glsl_lexer.lpp"
1879RESERVED_WORD(999, TEMPLATE);
1880 YY_BREAK
1881case 104:
1882YY_RULE_SETUP
1883#line 271 "glsl_lexer.lpp"
1884RESERVED_WORD(999, THIS);
1885 YY_BREAK
1886case 105:
1887YY_RULE_SETUP
1888#line 272 "glsl_lexer.lpp"
1889RESERVED_WORD(999, PACKED_TOK);
1890 YY_BREAK
1891case 106:
1892YY_RULE_SETUP
1893#line 273 "glsl_lexer.lpp"
1894RESERVED_WORD(999, GOTO);
1895 YY_BREAK
1896case 107:
1897YY_RULE_SETUP
1898#line 274 "glsl_lexer.lpp"
1899RESERVED_WORD(130, SWITCH);
1900 YY_BREAK
1901case 108:
1902YY_RULE_SETUP
1903#line 275 "glsl_lexer.lpp"
1904RESERVED_WORD(130, DEFAULT);
1905 YY_BREAK
1906case 109:
1907YY_RULE_SETUP
1908#line 276 "glsl_lexer.lpp"
1909RESERVED_WORD(999, INLINE_TOK);
1910 YY_BREAK
1911case 110:
1912YY_RULE_SETUP
1913#line 277 "glsl_lexer.lpp"
1914RESERVED_WORD(999, NOINLINE);
1915 YY_BREAK
1916case 111:
1917YY_RULE_SETUP
1918#line 278 "glsl_lexer.lpp"
1919RESERVED_WORD(999, VOLATILE);
1920 YY_BREAK
1921case 112:
1922YY_RULE_SETUP
1923#line 279 "glsl_lexer.lpp"
1924RESERVED_WORD(999, PUBLIC_TOK);
1925 YY_BREAK
1926case 113:
1927YY_RULE_SETUP
1928#line 280 "glsl_lexer.lpp"
1929RESERVED_WORD(999, STATIC);
1930 YY_BREAK
1931case 114:
1932YY_RULE_SETUP
1933#line 281 "glsl_lexer.lpp"
1934RESERVED_WORD(999, EXTERN);
1935 YY_BREAK
1936case 115:
1937YY_RULE_SETUP
1938#line 282 "glsl_lexer.lpp"
1939RESERVED_WORD(999, EXTERNAL);
1940 YY_BREAK
1941case 116:
1942YY_RULE_SETUP
1943#line 283 "glsl_lexer.lpp"
1944RESERVED_WORD(999, INTERFACE);
1945 YY_BREAK
1946case 117:
1947YY_RULE_SETUP
1948#line 284 "glsl_lexer.lpp"
1949RESERVED_WORD(999, LONG_TOK);
1950 YY_BREAK
1951case 118:
1952YY_RULE_SETUP
1953#line 285 "glsl_lexer.lpp"
1954RESERVED_WORD(999, SHORT_TOK);
1955 YY_BREAK
1956case 119:
1957YY_RULE_SETUP
1958#line 286 "glsl_lexer.lpp"
1959RESERVED_WORD(999, DOUBLE_TOK);
1960 YY_BREAK
1961case 120:
1962YY_RULE_SETUP
1963#line 287 "glsl_lexer.lpp"
1964RESERVED_WORD(999, HALF);
1965 YY_BREAK
1966case 121:
1967YY_RULE_SETUP
1968#line 288 "glsl_lexer.lpp"
1969RESERVED_WORD(999, FIXED_TOK);
1970 YY_BREAK
1971case 122:
1972YY_RULE_SETUP
1973#line 289 "glsl_lexer.lpp"
1974RESERVED_WORD(999, UNSIGNED);
1975 YY_BREAK
1976case 123:
1977YY_RULE_SETUP
1978#line 290 "glsl_lexer.lpp"
1979RESERVED_WORD(999, INPUT_TOK);
1980 YY_BREAK
1981case 124:
1982YY_RULE_SETUP
1983#line 291 "glsl_lexer.lpp"
1984RESERVED_WORD(999, OUTPUT);
1985 YY_BREAK
1986case 125:
1987YY_RULE_SETUP
1988#line 292 "glsl_lexer.lpp"
1989RESERVED_WORD(999, HVEC2);
1990 YY_BREAK
1991case 126:
1992YY_RULE_SETUP
1993#line 293 "glsl_lexer.lpp"
1994RESERVED_WORD(999, HVEC3);
1995 YY_BREAK
1996case 127:
1997YY_RULE_SETUP
1998#line 294 "glsl_lexer.lpp"
1999RESERVED_WORD(999, HVEC4);
2000 YY_BREAK
2001case 128:
2002YY_RULE_SETUP
2003#line 295 "glsl_lexer.lpp"
2004RESERVED_WORD(999, DVEC2);
2005 YY_BREAK
2006case 129:
2007YY_RULE_SETUP
2008#line 296 "glsl_lexer.lpp"
2009RESERVED_WORD(999, DVEC3);
2010 YY_BREAK
2011case 130:
2012YY_RULE_SETUP
2013#line 297 "glsl_lexer.lpp"
2014RESERVED_WORD(999, DVEC4);
2015 YY_BREAK
2016case 131:
2017YY_RULE_SETUP
2018#line 298 "glsl_lexer.lpp"
2019RESERVED_WORD(999, FVEC2);
2020 YY_BREAK
2021case 132:
2022YY_RULE_SETUP
2023#line 299 "glsl_lexer.lpp"
2024RESERVED_WORD(999, FVEC3);
2025 YY_BREAK
2026case 133:
2027YY_RULE_SETUP
2028#line 300 "glsl_lexer.lpp"
2029RESERVED_WORD(999, FVEC4);
2030 YY_BREAK
2031case 134:
2032YY_RULE_SETUP
2033#line 301 "glsl_lexer.lpp"
2034return SAMPLER2DRECT;
2035 YY_BREAK
2036case 135:
2037YY_RULE_SETUP
2038#line 302 "glsl_lexer.lpp"
2039RESERVED_WORD(999, SAMPLER3DRECT);
2040 YY_BREAK
2041case 136:
2042YY_RULE_SETUP
2043#line 303 "glsl_lexer.lpp"
2044return SAMPLER2DRECTSHADOW;
2045 YY_BREAK
2046case 137:
2047YY_RULE_SETUP
2048#line 304 "glsl_lexer.lpp"
2049RESERVED_WORD(999, SIZEOF);
2050 YY_BREAK
2051case 138:
2052YY_RULE_SETUP
2053#line 305 "glsl_lexer.lpp"
2054RESERVED_WORD(999, CAST);
2055 YY_BREAK
2056case 139:
2057YY_RULE_SETUP
2058#line 306 "glsl_lexer.lpp"
2059RESERVED_WORD(999, NAMESPACE);
2060 YY_BREAK
2061case 140:
2062YY_RULE_SETUP
2063#line 307 "glsl_lexer.lpp"
2064RESERVED_WORD(999, USING);
2065 YY_BREAK
2066/* Additional reserved words in GLSL 1.20. */
2067case 141:
2068YY_RULE_SETUP
2069#line 310 "glsl_lexer.lpp"
2070TOKEN_OR_IDENTIFIER(120, LOWP);
2071 YY_BREAK
2072case 142:
2073YY_RULE_SETUP
2074#line 311 "glsl_lexer.lpp"
2075TOKEN_OR_IDENTIFIER(120, MEDIUMP);
2076 YY_BREAK
2077case 143:
2078YY_RULE_SETUP
2079#line 312 "glsl_lexer.lpp"
2080TOKEN_OR_IDENTIFIER(120, HIGHP);
2081 YY_BREAK
2082case 144:
2083YY_RULE_SETUP
2084#line 313 "glsl_lexer.lpp"
2085TOKEN_OR_IDENTIFIER(120, PRECISION);
2086 YY_BREAK
2087/* Additional reserved words in GLSL 1.30. */
2088case 145:
2089YY_RULE_SETUP
2090#line 316 "glsl_lexer.lpp"
2091TOKEN_OR_IDENTIFIER(130, COMMON);
2092 YY_BREAK
2093case 146:
2094YY_RULE_SETUP
2095#line 317 "glsl_lexer.lpp"
2096TOKEN_OR_IDENTIFIER(130, PARTITION);
2097 YY_BREAK
2098case 147:
2099YY_RULE_SETUP
2100#line 318 "glsl_lexer.lpp"
2101TOKEN_OR_IDENTIFIER(130, ACTIVE);
2102 YY_BREAK
2103case 148:
2104YY_RULE_SETUP
2105#line 319 "glsl_lexer.lpp"
2106TOKEN_OR_IDENTIFIER(130, SUPERP);
2107 YY_BREAK
2108case 149:
2109YY_RULE_SETUP
2110#line 320 "glsl_lexer.lpp"
2111TOKEN_OR_IDENTIFIER(130, SAMPLERBUFFER);
2112 YY_BREAK
2113case 150:
2114YY_RULE_SETUP
2115#line 321 "glsl_lexer.lpp"
2116TOKEN_OR_IDENTIFIER(130, FILTER);
2117 YY_BREAK
2118case 151:
2119YY_RULE_SETUP
2120#line 322 "glsl_lexer.lpp"
2121TOKEN_OR_IDENTIFIER(130, IMAGE1D);
2122 YY_BREAK
2123case 152:
2124YY_RULE_SETUP
2125#line 323 "glsl_lexer.lpp"
2126TOKEN_OR_IDENTIFIER(130, IMAGE2D);
2127 YY_BREAK
2128case 153:
2129YY_RULE_SETUP
2130#line 324 "glsl_lexer.lpp"
2131TOKEN_OR_IDENTIFIER(130, IMAGE3D);
2132 YY_BREAK
2133case 154:
2134YY_RULE_SETUP
2135#line 325 "glsl_lexer.lpp"
2136TOKEN_OR_IDENTIFIER(130, IMAGECUBE);
2137 YY_BREAK
2138case 155:
2139YY_RULE_SETUP
2140#line 326 "glsl_lexer.lpp"
2141TOKEN_OR_IDENTIFIER(130, IIMAGE1D);
2142 YY_BREAK
2143case 156:
2144YY_RULE_SETUP
2145#line 327 "glsl_lexer.lpp"
2146TOKEN_OR_IDENTIFIER(130, IIMAGE2D);
2147 YY_BREAK
2148case 157:
2149YY_RULE_SETUP
2150#line 328 "glsl_lexer.lpp"
2151TOKEN_OR_IDENTIFIER(130, IIMAGE3D);
2152 YY_BREAK
2153case 158:
2154YY_RULE_SETUP
2155#line 329 "glsl_lexer.lpp"
2156TOKEN_OR_IDENTIFIER(130, IIMAGECUBE);
2157 YY_BREAK
2158case 159:
2159YY_RULE_SETUP
2160#line 330 "glsl_lexer.lpp"
2161TOKEN_OR_IDENTIFIER(130, UIMAGE1D);
2162 YY_BREAK
2163case 160:
2164YY_RULE_SETUP
2165#line 331 "glsl_lexer.lpp"
2166TOKEN_OR_IDENTIFIER(130, UIMAGE2D);
2167 YY_BREAK
2168case 161:
2169YY_RULE_SETUP
2170#line 332 "glsl_lexer.lpp"
2171TOKEN_OR_IDENTIFIER(130, UIMAGE3D);
2172 YY_BREAK
2173case 162:
2174YY_RULE_SETUP
2175#line 333 "glsl_lexer.lpp"
2176TOKEN_OR_IDENTIFIER(130, UIMAGECUBE);
2177 YY_BREAK
2178case 163:
2179YY_RULE_SETUP
2180#line 334 "glsl_lexer.lpp"
2181TOKEN_OR_IDENTIFIER(130, IMAGE1DARRAY);
2182 YY_BREAK
2183case 164:
2184YY_RULE_SETUP
2185#line 335 "glsl_lexer.lpp"
2186TOKEN_OR_IDENTIFIER(130, IMAGE2DARRAY);
2187 YY_BREAK
2188case 165:
2189YY_RULE_SETUP
2190#line 336 "glsl_lexer.lpp"
2191TOKEN_OR_IDENTIFIER(130, IIMAGE1DARRAY);
2192 YY_BREAK
2193case 166:
2194YY_RULE_SETUP
2195#line 337 "glsl_lexer.lpp"
2196TOKEN_OR_IDENTIFIER(130, IIMAGE2DARRAY);
2197 YY_BREAK
2198case 167:
2199YY_RULE_SETUP
2200#line 338 "glsl_lexer.lpp"
2201TOKEN_OR_IDENTIFIER(130, UIMAGE1DARRAY);
2202 YY_BREAK
2203case 168:
2204YY_RULE_SETUP
2205#line 339 "glsl_lexer.lpp"
2206TOKEN_OR_IDENTIFIER(130, UIMAGE2DARRAY);
2207 YY_BREAK
2208case 169:
2209YY_RULE_SETUP
2210#line 340 "glsl_lexer.lpp"
2211TOKEN_OR_IDENTIFIER(130, IMAGE1DSHADOW);
2212 YY_BREAK
2213case 170:
2214YY_RULE_SETUP
2215#line 341 "glsl_lexer.lpp"
2216TOKEN_OR_IDENTIFIER(130, IMAGE2DSHADOW);
2217 YY_BREAK
2218case 171:
2219YY_RULE_SETUP
2220#line 342 "glsl_lexer.lpp"
2221TOKEN_OR_IDENTIFIER(130, IMAGEBUFFER);
2222 YY_BREAK
2223case 172:
2224YY_RULE_SETUP
2225#line 343 "glsl_lexer.lpp"
2226TOKEN_OR_IDENTIFIER(130, IIMAGEBUFFER);
2227 YY_BREAK
2228case 173:
2229YY_RULE_SETUP
2230#line 344 "glsl_lexer.lpp"
2231TOKEN_OR_IDENTIFIER(130, UIMAGEBUFFER);
2232 YY_BREAK
2233case 174:
2234YY_RULE_SETUP
2235#line 345 "glsl_lexer.lpp"
2236TOKEN_OR_IDENTIFIER(130, ROW_MAJOR);
2237 YY_BREAK
2238case 175:
2239YY_RULE_SETUP
2240#line 347 "glsl_lexer.lpp"
2241{
2242 struct _mesa_glsl_parse_state *state = yyextra;
2243 void *ctx = state;
2244 yylval->identifier = talloc_strdup(ctx, yytext);
2245 return IDENTIFIER;
2246 }
2247 YY_BREAK
2248case 176:
2249YY_RULE_SETUP
2250#line 354 "glsl_lexer.lpp"
2251{ return yytext[0]; }
2252 YY_BREAK
2253case 177:
2254YY_RULE_SETUP
2255#line 356 "glsl_lexer.lpp"
2256ECHO;
2257 YY_BREAK
2258#line 2259 "glsl_lexer.cpp"
2259case YY_STATE_EOF(INITIAL):
2260case YY_STATE_EOF(PP):
2261 yyterminate();
2262
2263 case YY_END_OF_BUFFER:
2264 {
2265 /* Amount of text matched not including the EOB char. */
2266 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
2267
2268 /* Undo the effects of YY_DO_BEFORE_ACTION. */
2269 *yy_cp = yyg->yy_hold_char;
2270 YY_RESTORE_YY_MORE_OFFSET
2271
2272 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
2273 {
2274 /* We're scanning a new file or input source. It's
2275 * possible that this happened because the user
2276 * just pointed yyin at a new source and called
2277 * _mesa_glsl_lex(). If so, then we have to assure
2278 * consistency between YY_CURRENT_BUFFER and our
2279 * globals. Here is the right place to do so, because
2280 * this is the first action (other than possibly a
2281 * back-up) that will match for the new input source.
2282 */
2283 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2284 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
2285 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
2286 }
2287
2288 /* Note that here we test for yy_c_buf_p "<=" to the position
2289 * of the first EOB in the buffer, since yy_c_buf_p will
2290 * already have been incremented past the NUL character
2291 * (since all states make transitions on EOB to the
2292 * end-of-buffer state). Contrast this with the test
2293 * in input().
2294 */
2295 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2296 { /* This was really a NUL. */
2297 yy_state_type yy_next_state;
2298
2299 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
2300
2301 yy_current_state = yy_get_previous_state( yyscanner );
2302
2303 /* Okay, we're now positioned to make the NUL
2304 * transition. We couldn't have
2305 * yy_get_previous_state() go ahead and do it
2306 * for us because it doesn't know how to deal
2307 * with the possibility of jamming (and we don't
2308 * want to build jamming into it because then it
2309 * will run more slowly).
2310 */
2311
2312 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
2313
2314 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2315
2316 if ( yy_next_state )
2317 {
2318 /* Consume the NUL. */
2319 yy_cp = ++yyg->yy_c_buf_p;
2320 yy_current_state = yy_next_state;
2321 goto yy_match;
2322 }
2323
2324 else
2325 {
2326 yy_cp = yyg->yy_last_accepting_cpos;
2327 yy_current_state = yyg->yy_last_accepting_state;
2328 goto yy_find_action;
2329 }
2330 }
2331
2332 else switch ( yy_get_next_buffer( yyscanner ) )
2333 {
2334 case EOB_ACT_END_OF_FILE:
2335 {
2336 yyg->yy_did_buffer_switch_on_eof = 0;
2337
2338 if ( _mesa_glsl_wrap(yyscanner ) )
2339 {
2340 /* Note: because we've taken care in
2341 * yy_get_next_buffer() to have set up
2342 * yytext, we can now set up
2343 * yy_c_buf_p so that if some total
2344 * hoser (like flex itself) wants to
2345 * call the scanner after we return the
2346 * YY_NULL, it'll still work - another
2347 * YY_NULL will get returned.
2348 */
2349 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
2350
2351 yy_act = YY_STATE_EOF(YY_START);
2352 goto do_action;
2353 }
2354
2355 else
2356 {
2357 if ( ! yyg->yy_did_buffer_switch_on_eof )
2358 YY_NEW_FILE;
2359 }
2360 break;
2361 }
2362
2363 case EOB_ACT_CONTINUE_SCAN:
2364 yyg->yy_c_buf_p =
2365 yyg->yytext_ptr + yy_amount_of_matched_text;
2366
2367 yy_current_state = yy_get_previous_state( yyscanner );
2368
2369 yy_cp = yyg->yy_c_buf_p;
2370 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2371 goto yy_match;
2372
2373 case EOB_ACT_LAST_MATCH:
2374 yyg->yy_c_buf_p =
2375 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
2376
2377 yy_current_state = yy_get_previous_state( yyscanner );
2378
2379 yy_cp = yyg->yy_c_buf_p;
2380 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2381 goto yy_find_action;
2382 }
2383 break;
2384 }
2385
2386 default:
2387 YY_FATAL_ERROR(
2388 "fatal flex scanner internal error--no action found" );
2389 } /* end of action switch */
2390 } /* end of scanning one token */
2391} /* end of _mesa_glsl_lex */
2392
2393/* yy_get_next_buffer - try to read in a new buffer
2394 *
2395 * Returns a code representing an action:
2396 * EOB_ACT_LAST_MATCH -
2397 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
2398 * EOB_ACT_END_OF_FILE - end of file
2399 */
2400static int yy_get_next_buffer (yyscan_t yyscanner)
2401{
2402 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2403 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
2404 register char *source = yyg->yytext_ptr;
2405 register int number_to_move, i;
2406 int ret_val;
2407
2408 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
2409 YY_FATAL_ERROR(
2410 "fatal flex scanner internal error--end of buffer missed" );
2411
2412 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
2413 { /* Don't try to fill the buffer, so this is an EOF. */
2414 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
2415 {
2416 /* We matched a single character, the EOB, so
2417 * treat this as a final EOF.
2418 */
2419 return EOB_ACT_END_OF_FILE;
2420 }
2421
2422 else
2423 {
2424 /* We matched some text prior to the EOB, first
2425 * process it.
2426 */
2427 return EOB_ACT_LAST_MATCH;
2428 }
2429 }
2430
2431 /* Try to read more data. */
2432
2433 /* First move last chars to start of buffer. */
2434 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
2435
2436 for ( i = 0; i < number_to_move; ++i )
2437 *(dest++) = *(source++);
2438
2439 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2440 /* don't do the read, it's not guaranteed to return an EOF,
2441 * just force an EOF
2442 */
2443 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
2444
2445 else
2446 {
2447 int num_to_read =
2448 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2449
2450 while ( num_to_read <= 0 )
2451 { /* Not enough room in the buffer - grow it. */
2452
2453 /* just a shorter name for the current buffer */
2454 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
2455
2456 int yy_c_buf_p_offset =
2457 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
2458
2459 if ( b->yy_is_our_buffer )
2460 {
2461 int new_size = b->yy_buf_size * 2;
2462
2463 if ( new_size <= 0 )
2464 b->yy_buf_size += b->yy_buf_size / 8;
2465 else
2466 b->yy_buf_size *= 2;
2467
2468 b->yy_ch_buf = (char *)
2469 /* Include room in for 2 EOB chars. */
2470 _mesa_glsl_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
2471 }
2472 else
2473 /* Can't grow it, we don't own it. */
2474 b->yy_ch_buf = 0;
2475
2476 if ( ! b->yy_ch_buf )
2477 YY_FATAL_ERROR(
2478 "fatal error - scanner input buffer overflow" );
2479
2480 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
2481
2482 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2483 number_to_move - 1;
2484
2485 }
2486
2487 if ( num_to_read > YY_READ_BUF_SIZE )
2488 num_to_read = YY_READ_BUF_SIZE;
2489
2490 /* Read in more data. */
2491 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2492 yyg->yy_n_chars, (size_t) num_to_read );
2493
2494 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2495 }
2496
2497 if ( yyg->yy_n_chars == 0 )
2498 {
2499 if ( number_to_move == YY_MORE_ADJ )
2500 {
2501 ret_val = EOB_ACT_END_OF_FILE;
2502 _mesa_glsl_restart(yyin ,yyscanner);
2503 }
2504
2505 else
2506 {
2507 ret_val = EOB_ACT_LAST_MATCH;
2508 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2509 YY_BUFFER_EOF_PENDING;
2510 }
2511 }
2512
2513 else
2514 ret_val = EOB_ACT_CONTINUE_SCAN;
2515
2516 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
2517 /* Extend the array by 50%, plus the number we really need. */
2518 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
2519 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) _mesa_glsl_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
2520 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2521 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
2522 }
2523
2524 yyg->yy_n_chars += number_to_move;
2525 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
2526 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
2527
2528 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2529
2530 return ret_val;
2531}
2532
2533/* yy_get_previous_state - get the state just before the EOB char was reached */
2534
2535 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
2536{
2537 register yy_state_type yy_current_state;
2538 register char *yy_cp;
2539 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2540
2541 yy_current_state = yyg->yy_start;
2542 yy_current_state += YY_AT_BOL();
2543
2544 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
2545 {
2546 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
2547 if ( yy_accept[yy_current_state] )
2548 {
2549 yyg->yy_last_accepting_state = yy_current_state;
2550 yyg->yy_last_accepting_cpos = yy_cp;
2551 }
2552 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2553 {
2554 yy_current_state = (int) yy_def[yy_current_state];
2555 if ( yy_current_state >= 668 )
2556 yy_c = yy_meta[(unsigned int) yy_c];
2557 }
2558 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2559 }
2560
2561 return yy_current_state;
2562}
2563
2564/* yy_try_NUL_trans - try to make a transition on the NUL character
2565 *
2566 * synopsis
2567 * next_state = yy_try_NUL_trans( current_state );
2568 */
2569 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
2570{
2571 register int yy_is_jam;
2572 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
2573 register char *yy_cp = yyg->yy_c_buf_p;
2574
2575 register YY_CHAR yy_c = 1;
2576 if ( yy_accept[yy_current_state] )
2577 {
2578 yyg->yy_last_accepting_state = yy_current_state;
2579 yyg->yy_last_accepting_cpos = yy_cp;
2580 }
2581 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2582 {
2583 yy_current_state = (int) yy_def[yy_current_state];
2584 if ( yy_current_state >= 668 )
2585 yy_c = yy_meta[(unsigned int) yy_c];
2586 }
2587 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2588 yy_is_jam = (yy_current_state == 667);
2589
2590 return yy_is_jam ? 0 : yy_current_state;
2591}
2592
2593#ifndef YY_NO_INPUT
2594#ifdef __cplusplus
2595 static int yyinput (yyscan_t yyscanner)
2596#else
2597 static int input (yyscan_t yyscanner)
2598#endif
2599
2600{
2601 int c;
2602 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2603
2604 *yyg->yy_c_buf_p = yyg->yy_hold_char;
2605
2606 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
2607 {
2608 /* yy_c_buf_p now points to the character we want to return.
2609 * If this occurs *before* the EOB characters, then it's a
2610 * valid NUL; if not, then we've hit the end of the buffer.
2611 */
2612 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2613 /* This was really a NUL. */
2614 *yyg->yy_c_buf_p = '\0';
2615
2616 else
2617 { /* need more input */
2618 int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
2619 ++yyg->yy_c_buf_p;
2620
2621 switch ( yy_get_next_buffer( yyscanner ) )
2622 {
2623 case EOB_ACT_LAST_MATCH:
2624 /* This happens because yy_g_n_b()
2625 * sees that we've accumulated a
2626 * token and flags that we need to
2627 * try matching the token before
2628 * proceeding. But for input(),
2629 * there's no matching to consider.
2630 * So convert the EOB_ACT_LAST_MATCH
2631 * to EOB_ACT_END_OF_FILE.
2632 */
2633
2634 /* Reset buffer status. */
2635 _mesa_glsl_restart(yyin ,yyscanner);
2636
2637 /*FALLTHROUGH*/
2638
2639 case EOB_ACT_END_OF_FILE:
2640 {
2641 if ( _mesa_glsl_wrap(yyscanner ) )
2642 return EOF;
2643
2644 if ( ! yyg->yy_did_buffer_switch_on_eof )
2645 YY_NEW_FILE;
2646#ifdef __cplusplus
2647 return yyinput(yyscanner);
2648#else
2649 return input(yyscanner);
2650#endif
2651 }
2652
2653 case EOB_ACT_CONTINUE_SCAN:
2654 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
2655 break;
2656 }
2657 }
2658 }
2659
2660 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
2661 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
2662 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
2663
2664 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
2665
2666 return c;
2667}
2668#endif /* ifndef YY_NO_INPUT */
2669
2670/** Immediately switch to a different input stream.
2671 * @param input_file A readable stream.
2672 * @param yyscanner The scanner object.
2673 * @note This function does not reset the start condition to @c INITIAL .
2674 */
2675 void _mesa_glsl_restart (FILE * input_file , yyscan_t yyscanner)
2676{
2677 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2678
2679 if ( ! YY_CURRENT_BUFFER ){
2680 _mesa_glsl_ensure_buffer_stack (yyscanner);
2681 YY_CURRENT_BUFFER_LVALUE =
2682 _mesa_glsl__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
2683 }
2684
2685 _mesa_glsl__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
2686 _mesa_glsl__load_buffer_state(yyscanner );
2687}
2688
2689/** Switch to a different input buffer.
2690 * @param new_buffer The new input buffer.
2691 * @param yyscanner The scanner object.
2692 */
2693 void _mesa_glsl__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2694{
2695 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2696
2697 /* TODO. We should be able to replace this entire function body
2698 * with
2699 * _mesa_glsl_pop_buffer_state();
2700 * _mesa_glsl_push_buffer_state(new_buffer);
2701 */
2702 _mesa_glsl_ensure_buffer_stack (yyscanner);
2703 if ( YY_CURRENT_BUFFER == new_buffer )
2704 return;
2705
2706 if ( YY_CURRENT_BUFFER )
2707 {
2708 /* Flush out information for old buffer. */
2709 *yyg->yy_c_buf_p = yyg->yy_hold_char;
2710 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2711 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2712 }
2713
2714 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2715 _mesa_glsl__load_buffer_state(yyscanner );
2716
2717 /* We don't actually know whether we did this switch during
2718 * EOF (_mesa_glsl_wrap()) processing, but the only time this flag
2719 * is looked at is after _mesa_glsl_wrap() is called, so it's safe
2720 * to go ahead and always set it.
2721 */
2722 yyg->yy_did_buffer_switch_on_eof = 1;
2723}
2724
2725static void _mesa_glsl__load_buffer_state (yyscan_t yyscanner)
2726{
2727 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2728 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2729 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2730 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2731 yyg->yy_hold_char = *yyg->yy_c_buf_p;
2732}
2733
2734/** Allocate and initialize an input buffer state.
2735 * @param file A readable stream.
2736 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2737 * @param yyscanner The scanner object.
2738 * @return the allocated buffer state.
2739 */
2740 YY_BUFFER_STATE _mesa_glsl__create_buffer (FILE * file, int size , yyscan_t yyscanner)
2741{
2742 YY_BUFFER_STATE b;
2743
2744 b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2745 if ( ! b )
2746 YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" );
2747
2748 b->yy_buf_size = size;
2749
2750 /* yy_ch_buf has to be 2 characters longer than the size given because
2751 * we need to put in 2 end-of-buffer characters.
2752 */
2753 b->yy_ch_buf = (char *) _mesa_glsl_alloc(b->yy_buf_size + 2 ,yyscanner );
2754 if ( ! b->yy_ch_buf )
2755 YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__create_buffer()" );
2756
2757 b->yy_is_our_buffer = 1;
2758
2759 _mesa_glsl__init_buffer(b,file ,yyscanner);
2760
2761 return b;
2762}
2763
2764/** Destroy the buffer.
2765 * @param b a buffer created with _mesa_glsl__create_buffer()
2766 * @param yyscanner The scanner object.
2767 */
2768 void _mesa_glsl__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
2769{
2770 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2771
2772 if ( ! b )
2773 return;
2774
2775 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2776 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2777
2778 if ( b->yy_is_our_buffer )
2779 _mesa_glsl_free((void *) b->yy_ch_buf ,yyscanner );
2780
2781 _mesa_glsl_free((void *) b ,yyscanner );
2782}
2783
2784/* Initializes or reinitializes a buffer.
2785 * This function is sometimes called more than once on the same buffer,
2786 * such as during a _mesa_glsl_restart() or at EOF.
2787 */
2788 static void _mesa_glsl__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
2789
2790{
2791 int oerrno = errno;
2792 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2793
2794 _mesa_glsl__flush_buffer(b ,yyscanner);
2795
2796 b->yy_input_file = file;
2797 b->yy_fill_buffer = 1;
2798
2799 /* If b is the current buffer, then _mesa_glsl__init_buffer was _probably_
2800 * called from _mesa_glsl_restart() or through yy_get_next_buffer.
2801 * In that case, we don't want to reset the lineno or column.
2802 */
2803 if (b != YY_CURRENT_BUFFER){
2804 b->yy_bs_lineno = 1;
2805 b->yy_bs_column = 0;
2806 }
2807
2808 b->yy_is_interactive = 0;
2809
2810 errno = oerrno;
2811}
2812
2813/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2814 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2815 * @param yyscanner The scanner object.
2816 */
2817 void _mesa_glsl__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
2818{
2819 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2820 if ( ! b )
2821 return;
2822
2823 b->yy_n_chars = 0;
2824
2825 /* We always need two end-of-buffer characters. The first causes
2826 * a transition to the end-of-buffer state. The second causes
2827 * a jam in that state.
2828 */
2829 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2830 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2831
2832 b->yy_buf_pos = &b->yy_ch_buf[0];
2833
2834 b->yy_at_bol = 1;
2835 b->yy_buffer_status = YY_BUFFER_NEW;
2836
2837 if ( b == YY_CURRENT_BUFFER )
2838 _mesa_glsl__load_buffer_state(yyscanner );
2839}
2840
2841/** Pushes the new state onto the stack. The new state becomes
2842 * the current state. This function will allocate the stack
2843 * if necessary.
2844 * @param new_buffer The new state.
2845 * @param yyscanner The scanner object.
2846 */
2847void _mesa_glsl_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2848{
2849 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2850 if (new_buffer == NULL)
2851 return;
2852
2853 _mesa_glsl_ensure_buffer_stack(yyscanner);
2854
2855 /* This block is copied from _mesa_glsl__switch_to_buffer. */
2856 if ( YY_CURRENT_BUFFER )
2857 {
2858 /* Flush out information for old buffer. */
2859 *yyg->yy_c_buf_p = yyg->yy_hold_char;
2860 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2861 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2862 }
2863
2864 /* Only push if top exists. Otherwise, replace top. */
2865 if (YY_CURRENT_BUFFER)
2866 yyg->yy_buffer_stack_top++;
2867 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2868
2869 /* copied from _mesa_glsl__switch_to_buffer. */
2870 _mesa_glsl__load_buffer_state(yyscanner );
2871 yyg->yy_did_buffer_switch_on_eof = 1;
2872}
2873
2874/** Removes and deletes the top of the stack, if present.
2875 * The next element becomes the new top.
2876 * @param yyscanner The scanner object.
2877 */
2878void _mesa_glsl_pop_buffer_state (yyscan_t yyscanner)
2879{
2880 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2881 if (!YY_CURRENT_BUFFER)
2882 return;
2883
2884 _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
2885 YY_CURRENT_BUFFER_LVALUE = NULL;
2886 if (yyg->yy_buffer_stack_top > 0)
2887 --yyg->yy_buffer_stack_top;
2888
2889 if (YY_CURRENT_BUFFER) {
2890 _mesa_glsl__load_buffer_state(yyscanner );
2891 yyg->yy_did_buffer_switch_on_eof = 1;
2892 }
2893}
2894
2895/* Allocates the stack if it does not exist.
2896 * Guarantees space for at least one push.
2897 */
2898static void _mesa_glsl_ensure_buffer_stack (yyscan_t yyscanner)
2899{
2900 int num_to_alloc;
2901 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2902
2903 if (!yyg->yy_buffer_stack) {
2904
2905 /* First allocation is just for 2 elements, since we don't know if this
2906 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2907 * immediate realloc on the next call.
2908 */
2909 num_to_alloc = 1;
2910 yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_alloc
2911 (num_to_alloc * sizeof(struct yy_buffer_state*)
2912 , yyscanner);
2913 if ( ! yyg->yy_buffer_stack )
2914 YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" );
2915
2916 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2917
2918 yyg->yy_buffer_stack_max = num_to_alloc;
2919 yyg->yy_buffer_stack_top = 0;
2920 return;
2921 }
2922
2923 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2924
2925 /* Increase the buffer to prepare for a possible push. */
2926 int grow_size = 8 /* arbitrary grow size */;
2927
2928 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2929 yyg->yy_buffer_stack = (struct yy_buffer_state**)_mesa_glsl_realloc
2930 (yyg->yy_buffer_stack,
2931 num_to_alloc * sizeof(struct yy_buffer_state*)
2932 , yyscanner);
2933 if ( ! yyg->yy_buffer_stack )
2934 YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl_ensure_buffer_stack()" );
2935
2936 /* zero only the new slots.*/
2937 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2938 yyg->yy_buffer_stack_max = num_to_alloc;
2939 }
2940}
2941
2942/** Setup the input buffer state to scan directly from a user-specified character buffer.
2943 * @param base the character buffer
2944 * @param size the size in bytes of the character buffer
2945 * @param yyscanner The scanner object.
2946 * @return the newly allocated buffer state object.
2947 */
2948YY_BUFFER_STATE _mesa_glsl__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
2949{
2950 YY_BUFFER_STATE b;
2951
2952 if ( size < 2 ||
2953 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2954 base[size-1] != YY_END_OF_BUFFER_CHAR )
2955 /* They forgot to leave room for the EOB's. */
2956 return 0;
2957
2958 b = (YY_BUFFER_STATE) _mesa_glsl_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2959 if ( ! b )
2960 YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_buffer()" );
2961
2962 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
2963 b->yy_buf_pos = b->yy_ch_buf = base;
2964 b->yy_is_our_buffer = 0;
2965 b->yy_input_file = 0;
2966 b->yy_n_chars = b->yy_buf_size;
2967 b->yy_is_interactive = 0;
2968 b->yy_at_bol = 1;
2969 b->yy_fill_buffer = 0;
2970 b->yy_buffer_status = YY_BUFFER_NEW;
2971
2972 _mesa_glsl__switch_to_buffer(b ,yyscanner );
2973
2974 return b;
2975}
2976
2977/** Setup the input buffer state to scan a string. The next call to _mesa_glsl_lex() will
2978 * scan from a @e copy of @a str.
2979 * @param yystr a NUL-terminated string to scan
2980 * @param yyscanner The scanner object.
2981 * @return the newly allocated buffer state object.
2982 * @note If you want to scan bytes that may contain NUL values, then use
2983 * _mesa_glsl__scan_bytes() instead.
2984 */
2985YY_BUFFER_STATE _mesa_glsl__scan_string (yyconst char * yystr , yyscan_t yyscanner)
2986{
2987
2988 return _mesa_glsl__scan_bytes(yystr,strlen(yystr) ,yyscanner);
2989}
2990
2991/** Setup the input buffer state to scan the given bytes. The next call to _mesa_glsl_lex() will
2992 * scan from a @e copy of @a bytes.
2993 * @param yybytes the byte buffer to scan
2994 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2995 * @param yyscanner The scanner object.
2996 * @return the newly allocated buffer state object.
2997 */
2998YY_BUFFER_STATE _mesa_glsl__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
2999{
3000 YY_BUFFER_STATE b;
3001 char *buf;
3002 yy_size_t n;
3003 int i;
3004
3005 /* Get memory for full buffer, including space for trailing EOB's. */
3006 n = _yybytes_len + 2;
3007 buf = (char *) _mesa_glsl_alloc(n ,yyscanner );
3008 if ( ! buf )
3009 YY_FATAL_ERROR( "out of dynamic memory in _mesa_glsl__scan_bytes()" );
3010
3011 for ( i = 0; i < _yybytes_len; ++i )
3012 buf[i] = yybytes[i];
3013
3014 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
3015
3016 b = _mesa_glsl__scan_buffer(buf,n ,yyscanner);
3017 if ( ! b )
3018 YY_FATAL_ERROR( "bad buffer in _mesa_glsl__scan_bytes()" );
3019
3020 /* It's okay to grow etc. this buffer, and we should throw it
3021 * away when we're done.
3022 */
3023 b->yy_is_our_buffer = 1;
3024
3025 return b;
3026}
3027
3028#ifndef YY_EXIT_FAILURE
3029#define YY_EXIT_FAILURE 2
3030#endif
3031
3032static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
3033{
3034 (void) fprintf( stderr, "%s\n", msg );
3035 exit( YY_EXIT_FAILURE );
3036}
3037
3038/* Redefine yyless() so it works in section 3 code. */
3039
3040#undef yyless
3041#define yyless(n) \
3042 do \
3043 { \
3044 /* Undo effects of setting up yytext. */ \
3045 int yyless_macro_arg = (n); \
3046 YY_LESS_LINENO(yyless_macro_arg);\
3047 yytext[yyleng] = yyg->yy_hold_char; \
3048 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
3049 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
3050 *yyg->yy_c_buf_p = '\0'; \
3051 yyleng = yyless_macro_arg; \
3052 } \
3053 while ( 0 )
3054
3055/* Accessor methods (get/set functions) to struct members. */
3056
3057/** Get the user-defined data for this scanner.
3058 * @param yyscanner The scanner object.
3059 */
3060YY_EXTRA_TYPE _mesa_glsl_get_extra (yyscan_t yyscanner)
3061{
3062 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3063 return yyextra;
3064}
3065
3066/** Get the current line number.
3067 * @param yyscanner The scanner object.
3068 */
3069int _mesa_glsl_get_lineno (yyscan_t yyscanner)
3070{
3071 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3072
3073 if (! YY_CURRENT_BUFFER)
3074 return 0;
3075
3076 return yylineno;
3077}
3078
3079/** Get the current column number.
3080 * @param yyscanner The scanner object.
3081 */
3082int _mesa_glsl_get_column (yyscan_t yyscanner)
3083{
3084 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3085
3086 if (! YY_CURRENT_BUFFER)
3087 return 0;
3088
3089 return yycolumn;
3090}
3091
3092/** Get the input stream.
3093 * @param yyscanner The scanner object.
3094 */
3095FILE *_mesa_glsl_get_in (yyscan_t yyscanner)
3096{
3097 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3098 return yyin;
3099}
3100
3101/** Get the output stream.
3102 * @param yyscanner The scanner object.
3103 */
3104FILE *_mesa_glsl_get_out (yyscan_t yyscanner)
3105{
3106 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3107 return yyout;
3108}
3109
3110/** Get the length of the current token.
3111 * @param yyscanner The scanner object.
3112 */
3113int _mesa_glsl_get_leng (yyscan_t yyscanner)
3114{
3115 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3116 return yyleng;
3117}
3118
3119/** Get the current token.
3120 * @param yyscanner The scanner object.
3121 */
3122
3123char *_mesa_glsl_get_text (yyscan_t yyscanner)
3124{
3125 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3126 return yytext;
3127}
3128
3129/** Set the user-defined data. This data is never touched by the scanner.
3130 * @param user_defined The data to be associated with this scanner.
3131 * @param yyscanner The scanner object.
3132 */
3133void _mesa_glsl_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
3134{
3135 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3136 yyextra = user_defined ;
3137}
3138
3139/** Set the current line number.
3140 * @param line_number
3141 * @param yyscanner The scanner object.
3142 */
3143void _mesa_glsl_set_lineno (int line_number , yyscan_t yyscanner)
3144{
3145 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3146
3147 /* lineno is only valid if an input buffer exists. */
3148 if (! YY_CURRENT_BUFFER )
3149 yy_fatal_error( "_mesa_glsl_set_lineno called with no buffer" , yyscanner);
3150
3151 yylineno = line_number;
3152}
3153
3154/** Set the current column.
3155 * @param line_number
3156 * @param yyscanner The scanner object.
3157 */
3158void _mesa_glsl_set_column (int column_no , yyscan_t yyscanner)
3159{
3160 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3161
3162 /* column is only valid if an input buffer exists. */
3163 if (! YY_CURRENT_BUFFER )
3164 yy_fatal_error( "_mesa_glsl_set_column called with no buffer" , yyscanner);
3165
3166 yycolumn = column_no;
3167}
3168
3169/** Set the input stream. This does not discard the current
3170 * input buffer.
3171 * @param in_str A readable stream.
3172 * @param yyscanner The scanner object.
3173 * @see _mesa_glsl__switch_to_buffer
3174 */
3175void _mesa_glsl_set_in (FILE * in_str , yyscan_t yyscanner)
3176{
3177 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3178 yyin = in_str ;
3179}
3180
3181void _mesa_glsl_set_out (FILE * out_str , yyscan_t yyscanner)
3182{
3183 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3184 yyout = out_str ;
3185}
3186
3187int _mesa_glsl_get_debug (yyscan_t yyscanner)
3188{
3189 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3190 return yy_flex_debug;
3191}
3192
3193void _mesa_glsl_set_debug (int bdebug , yyscan_t yyscanner)
3194{
3195 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3196 yy_flex_debug = bdebug ;
3197}
3198
3199/* Accessor methods for yylval and yylloc */
3200
3201YYSTYPE * _mesa_glsl_get_lval (yyscan_t yyscanner)
3202{
3203 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3204 return yylval;
3205}
3206
3207void _mesa_glsl_set_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
3208{
3209 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3210 yylval = yylval_param;
3211}
3212
3213YYLTYPE *_mesa_glsl_get_lloc (yyscan_t yyscanner)
3214{
3215 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3216 return yylloc;
3217}
3218
3219void _mesa_glsl_set_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner)
3220{
3221 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3222 yylloc = yylloc_param;
3223}
3224
3225/* User-visible API */
3226
3227/* _mesa_glsl_lex_init is special because it creates the scanner itself, so it is
3228 * the ONLY reentrant function that doesn't take the scanner as the last argument.
3229 * That's why we explicitly handle the declaration, instead of using our macros.
3230 */
3231
3232int _mesa_glsl_lex_init(yyscan_t* ptr_yy_globals)
3233
3234{
3235 if (ptr_yy_globals == NULL){
3236 errno = EINVAL;
3237 return 1;
3238 }
3239
3240 *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), NULL );
3241
3242 if (*ptr_yy_globals == NULL){
3243 errno = ENOMEM;
3244 return 1;
3245 }
3246
3247 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
3248 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
3249
3250 return yy_init_globals ( *ptr_yy_globals );
3251}
3252
3253/* _mesa_glsl_lex_init_extra has the same functionality as _mesa_glsl_lex_init, but follows the
3254 * convention of taking the scanner as the last argument. Note however, that
3255 * this is a *pointer* to a scanner, as it will be allocated by this call (and
3256 * is the reason, too, why this function also must handle its own declaration).
3257 * The user defined value in the first argument will be available to _mesa_glsl_alloc in
3258 * the yyextra field.
3259 */
3260
3261int _mesa_glsl_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
3262
3263{
3264 struct yyguts_t dummy_yyguts;
3265
3266 _mesa_glsl_set_extra (yy_user_defined, &dummy_yyguts);
3267
3268 if (ptr_yy_globals == NULL){
3269 errno = EINVAL;
3270 return 1;
3271 }
3272
3273 *ptr_yy_globals = (yyscan_t) _mesa_glsl_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
3274
3275 if (*ptr_yy_globals == NULL){
3276 errno = ENOMEM;
3277 return 1;
3278 }
3279
3280 /* By setting to 0xAA, we expose bugs in
3281 yy_init_globals. Leave at 0x00 for releases. */
3282 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
3283
3284 _mesa_glsl_set_extra (yy_user_defined, *ptr_yy_globals);
3285
3286 return yy_init_globals ( *ptr_yy_globals );
3287}
3288
3289static int yy_init_globals (yyscan_t yyscanner)
3290{
3291 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3292 /* Initialization is the same as for the non-reentrant scanner.
3293 * This function is called from _mesa_glsl_lex_destroy(), so don't allocate here.
3294 */
3295
3296 yyg->yy_buffer_stack = 0;
3297 yyg->yy_buffer_stack_top = 0;
3298 yyg->yy_buffer_stack_max = 0;
3299 yyg->yy_c_buf_p = (char *) 0;
3300 yyg->yy_init = 0;
3301 yyg->yy_start = 0;
3302
3303 yyg->yy_start_stack_ptr = 0;
3304 yyg->yy_start_stack_depth = 0;
3305 yyg->yy_start_stack = NULL;
3306
3307/* Defined in main.c */
3308#ifdef YY_STDINIT
3309 yyin = stdin;
3310 yyout = stdout;
3311#else
3312 yyin = (FILE *) 0;
3313 yyout = (FILE *) 0;
3314#endif
3315
3316 /* For future reference: Set errno on error, since we are called by
3317 * _mesa_glsl_lex_init()
3318 */
3319 return 0;
3320}
3321
3322/* _mesa_glsl_lex_destroy is for both reentrant and non-reentrant scanners. */
3323int _mesa_glsl_lex_destroy (yyscan_t yyscanner)
3324{
3325 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3326
3327 /* Pop the buffer stack, destroying each element. */
3328 while(YY_CURRENT_BUFFER){
3329 _mesa_glsl__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
3330 YY_CURRENT_BUFFER_LVALUE = NULL;
3331 _mesa_glsl_pop_buffer_state(yyscanner);
3332 }
3333
3334 /* Destroy the stack itself. */
3335 _mesa_glsl_free(yyg->yy_buffer_stack ,yyscanner);
3336 yyg->yy_buffer_stack = NULL;
3337
3338 /* Destroy the start condition stack. */
3339 _mesa_glsl_free(yyg->yy_start_stack ,yyscanner );
3340 yyg->yy_start_stack = NULL;
3341
3342 /* Reset the globals. This is important in a non-reentrant scanner so the next time
3343 * _mesa_glsl_lex() is called, initialization will occur. */
3344 yy_init_globals( yyscanner);
3345
3346 /* Destroy the main struct (reentrant only). */
3347 _mesa_glsl_free ( yyscanner , yyscanner );
3348 yyscanner = NULL;
3349 return 0;
3350}
3351
3352/*
3353 * Internal utility routines.
3354 */
3355
3356#ifndef yytext_ptr
3357static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
3358{
3359 register int i;
3360 for ( i = 0; i < n; ++i )
3361 s1[i] = s2[i];
3362}
3363#endif
3364
3365#ifdef YY_NEED_STRLEN
3366static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
3367{
3368 register int n;
3369 for ( n = 0; s[n]; ++n )
3370 ;
3371
3372 return n;
3373}
3374#endif
3375
3376void *_mesa_glsl_alloc (yy_size_t size , yyscan_t yyscanner)
3377{
3378 return (void *) malloc( size );
3379}
3380
3381void *_mesa_glsl_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
3382{
3383 /* The cast to (char *) in the following accommodates both
3384 * implementations that use char* generic pointers, and those
3385 * that use void* generic pointers. It works with the latter
3386 * because both ANSI C and C++ allow castless assignment from
3387 * any pointer type to void*, and deal with argument conversions
3388 * as though doing an assignment.
3389 */
3390 return (void *) realloc( (char *) ptr, size );
3391}
3392
3393void _mesa_glsl_free (void * ptr , yyscan_t yyscanner)
3394{
3395 free( (char *) ptr ); /* see _mesa_glsl_realloc() for (char *) cast */
3396}
3397
3398#define YYTABLES_NAME "yytables"
3399
3400#line 356 "glsl_lexer.lpp"
3401
3402
3403
3404void
3405_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string)
3406{
3407 _mesa_glsl_lex_init_extra(state,& state->scanner);
3408 _mesa_glsl__scan_string(string,state->scanner);
3409}
3410
3411void
3412_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state)
3413{
3414 _mesa_glsl_lex_destroy(state->scanner);
3415}
3416
diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp
new file mode 100644
index 00000000000..3128cdd3a78
--- /dev/null
+++ b/src/glsl/glsl_lexer.lpp
@@ -0,0 +1,369 @@
1%{
2/*
3 * Copyright © 2008, 2009 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#include <ctype.h>
25#include "ast.h"
26#include "glsl_parser_extras.h"
27#include "glsl_parser.h"
28
29#define YY_USER_ACTION \
30 do { \
31 yylloc->source = 0; \
32 yylloc->first_column = yycolumn + 1; \
33 yylloc->first_line = yylineno + 1; \
34 yycolumn += yyleng; \
35 } while(0);
36
37#define YY_USER_INIT yylineno = 0; yycolumn = 0;
38
39#define TOKEN_OR_IDENTIFIER(version, token) \
40 do { \
41 if (yyextra->language_version >= version) { \
42 return token; \
43 } else { \
44 yylval->identifier = strdup(yytext); \
45 return IDENTIFIER; \
46 } \
47 } while (0)
48
49#define RESERVED_WORD(version, token) \
50 do { \
51 if (yyextra->language_version >= version) { \
52 return token; \
53 } else { \
54 _mesa_glsl_error(yylloc, yyextra, \
55 "Illegal use of reserved word `%s'", yytext); \
56 return ERROR_TOK; \
57 } \
58 } while (0)
59%}
60
61%option bison-bridge bison-locations reentrant noyywrap
62%option nounput noyy_top_state
63%option never-interactive
64%option prefix="_mesa_glsl_"
65%option extra-type="struct _mesa_glsl_parse_state *"
66
67%x PP
68
69DEC_INT [1-9][0-9]*
70HEX_INT 0[xX][0-9a-fA-F]+
71OCT_INT 0[0-7]*
72INT ({DEC_INT}|{HEX_INT}|{OCT_INT})
73SPC [ \t]*
74SPCP [ \t]+
75HASH ^{SPC}#{SPC}
76%%
77
78[ \r\t]+ ;
79
80 /* Preprocessor tokens. */
81^[ \t]*#[ \t]*$ ;
82^[ \t]*#[ \t]*version { BEGIN PP; return VERSION; }
83^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; }
84{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ {
85 /* Eat characters until the first digit is
86 * encountered
87 */
88 char *ptr = yytext;
89 while (!isdigit(*ptr))
90 ptr++;
91
92 /* Subtract one from the line number because
93 * yylineno is zero-based instead of
94 * one-based.
95 */
96 yylineno = strtol(ptr, &ptr, 0) - 1;
97 yylloc->source = strtol(ptr, NULL, 0);
98 }
99{HASH}line{SPCP}{INT}{SPC}$ {
100 /* Eat characters until the first digit is
101 * encountered
102 */
103 char *ptr = yytext;
104 while (!isdigit(*ptr))
105 ptr++;
106
107 /* Subtract one from the line number because
108 * yylineno is zero-based instead of
109 * one-based.
110 */
111 yylineno = strtol(ptr, &ptr, 0) - 1;
112 }
113^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; }
114<PP>\/\/[^\n]* { }
115<PP>[ \t\r]* { }
116<PP>: return COLON;
117<PP>[_a-zA-Z][_a-zA-Z0-9]* {
118 yylval->identifier = strdup(yytext);
119 return IDENTIFIER;
120 }
121<PP>[1-9][0-9]* {
122 yylval->n = strtol(yytext, NULL, 10);
123 return INTCONSTANT;
124 }
125<PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
126
127\n { yylineno++; yycolumn = 0; }
128
129attribute return ATTRIBUTE;
130const return CONST_TOK;
131bool return BOOL_TOK;
132float return FLOAT_TOK;
133int return INT_TOK;
134
135break return BREAK;
136continue return CONTINUE;
137do return DO;
138while return WHILE;
139else return ELSE;
140for return FOR;
141if return IF;
142discard return DISCARD;
143return return RETURN;
144
145bvec2 return BVEC2;
146bvec3 return BVEC3;
147bvec4 return BVEC4;
148ivec2 return IVEC2;
149ivec3 return IVEC3;
150ivec4 return IVEC4;
151vec2 return VEC2;
152vec3 return VEC3;
153vec4 return VEC4;
154mat2 return MAT2X2;
155mat3 return MAT3X3;
156mat4 return MAT4X4;
157mat2x2 TOKEN_OR_IDENTIFIER(120, MAT2X2);
158mat2x3 TOKEN_OR_IDENTIFIER(120, MAT2X3);
159mat2x4 TOKEN_OR_IDENTIFIER(120, MAT2X4);
160mat3x2 TOKEN_OR_IDENTIFIER(120, MAT3X2);
161mat3x3 TOKEN_OR_IDENTIFIER(120, MAT3X3);
162mat3x4 TOKEN_OR_IDENTIFIER(120, MAT3X4);
163mat4x2 TOKEN_OR_IDENTIFIER(120, MAT4X2);
164mat4x3 TOKEN_OR_IDENTIFIER(120, MAT4X3);
165mat4x4 TOKEN_OR_IDENTIFIER(120, MAT4X4);
166
167in return IN_TOK;
168out return OUT_TOK;
169inout return INOUT_TOK;
170uniform return UNIFORM;
171varying return VARYING;
172centroid TOKEN_OR_IDENTIFIER(120, CENTROID);
173invariant TOKEN_OR_IDENTIFIER(120, INVARIANT);
174
175flat TOKEN_OR_IDENTIFIER(130, FLAT);
176smooth TOKEN_OR_IDENTIFIER(130, SMOOTH);
177noperspective TOKEN_OR_IDENTIFIER(130, NOPERSPECTIVE);
178
179sampler1D return SAMPLER1D;
180sampler2D return SAMPLER2D;
181sampler3D return SAMPLER3D;
182samplerCube return SAMPLERCUBE;
183sampler1DShadow return SAMPLER1DSHADOW;
184sampler2DShadow return SAMPLER2DSHADOW;
185
186struct return STRUCT;
187void return VOID_TOK;
188
189layout {
190 if ((yyextra->language_version >= 140)
191 || (yyextra->ARB_fragment_coord_conventions_enable)){
192 return LAYOUT_TOK;
193 } else {
194 yylval->identifier = strdup(yytext);
195 return IDENTIFIER;
196 }
197 }
198
199\+\+ return INC_OP;
200-- return DEC_OP;
201\<= return LE_OP;
202>= return GE_OP;
203== return EQ_OP;
204!= return NE_OP;
205&& return AND_OP;
206\|\| return OR_OP;
207"^^" return XOR_OP;
208
209\*= return MUL_ASSIGN;
210\/= return DIV_ASSIGN;
211\+= return ADD_ASSIGN;
212\%= return MOD_ASSIGN;
213\<\<= return LEFT_ASSIGN;
214>>= return RIGHT_ASSIGN;
215&= return AND_ASSIGN;
216^= return XOR_ASSIGN;
217\|= return OR_ASSIGN;
218-= return SUB_ASSIGN;
219
220[1-9][0-9]* {
221 yylval->n = strtol(yytext, NULL, 10);
222 return INTCONSTANT;
223 }
2240[xX][0-9a-fA-F]+ {
225 yylval->n = strtol(yytext + 2, NULL, 16);
226 return INTCONSTANT;
227 }
2280[0-7]* {
229 yylval->n = strtol(yytext, NULL, 8);
230 return INTCONSTANT;
231 }
232
233[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
234 yylval->real = strtod(yytext, NULL);
235 return FLOATCONSTANT;
236 }
237\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
238 yylval->real = strtod(yytext, NULL);
239 return FLOATCONSTANT;
240 }
241[0-9]+\.([eE][+-]?[0-9]+)?[fF]? {
242 yylval->real = strtod(yytext, NULL);
243 return FLOATCONSTANT;
244 }
245[0-9]+[eE][+-]?[0-9]+[fF]? {
246 yylval->real = strtod(yytext, NULL);
247 return FLOATCONSTANT;
248 }
249[0-9]+[fF] {
250 yylval->real = strtod(yytext, NULL);
251 return FLOATCONSTANT;
252 }
253
254true {
255 yylval->n = 1;
256 return BOOLCONSTANT;
257 }
258false {
259 yylval->n = 0;
260 return BOOLCONSTANT;
261 }
262
263
264 /* Reserved words in GLSL 1.10. */
265asm RESERVED_WORD(999, ASM);
266class RESERVED_WORD(999, CLASS);
267union RESERVED_WORD(999, UNION);
268enum RESERVED_WORD(999, ENUM);
269typedef RESERVED_WORD(999, TYPEDEF);
270template RESERVED_WORD(999, TEMPLATE);
271this RESERVED_WORD(999, THIS);
272packed RESERVED_WORD(999, PACKED_TOK);
273goto RESERVED_WORD(999, GOTO);
274switch RESERVED_WORD(130, SWITCH);
275default RESERVED_WORD(130, DEFAULT);
276inline RESERVED_WORD(999, INLINE_TOK);
277noinline RESERVED_WORD(999, NOINLINE);
278volatile RESERVED_WORD(999, VOLATILE);
279public RESERVED_WORD(999, PUBLIC_TOK);
280static RESERVED_WORD(999, STATIC);
281extern RESERVED_WORD(999, EXTERN);
282external RESERVED_WORD(999, EXTERNAL);
283interface RESERVED_WORD(999, INTERFACE);
284long RESERVED_WORD(999, LONG_TOK);
285short RESERVED_WORD(999, SHORT_TOK);
286double RESERVED_WORD(999, DOUBLE_TOK);
287half RESERVED_WORD(999, HALF);
288fixed RESERVED_WORD(999, FIXED_TOK);
289unsigned RESERVED_WORD(999, UNSIGNED);
290input RESERVED_WORD(999, INPUT_TOK);
291output RESERVED_WORD(999, OUTPUT);
292hvec2 RESERVED_WORD(999, HVEC2);
293hvec3 RESERVED_WORD(999, HVEC3);
294hvec4 RESERVED_WORD(999, HVEC4);
295dvec2 RESERVED_WORD(999, DVEC2);
296dvec3 RESERVED_WORD(999, DVEC3);
297dvec4 RESERVED_WORD(999, DVEC4);
298fvec2 RESERVED_WORD(999, FVEC2);
299fvec3 RESERVED_WORD(999, FVEC3);
300fvec4 RESERVED_WORD(999, FVEC4);
301sampler2DRect return SAMPLER2DRECT;
302sampler3DRect RESERVED_WORD(999, SAMPLER3DRECT);
303sampler2DRectShadow return SAMPLER2DRECTSHADOW;
304sizeof RESERVED_WORD(999, SIZEOF);
305cast RESERVED_WORD(999, CAST);
306namespace RESERVED_WORD(999, NAMESPACE);
307using RESERVED_WORD(999, USING);
308
309 /* Additional reserved words in GLSL 1.20. */
310lowp TOKEN_OR_IDENTIFIER(120, LOWP);
311mediump TOKEN_OR_IDENTIFIER(120, MEDIUMP);
312highp TOKEN_OR_IDENTIFIER(120, HIGHP);
313precision TOKEN_OR_IDENTIFIER(120, PRECISION);
314
315 /* Additional reserved words in GLSL 1.30. */
316common TOKEN_OR_IDENTIFIER(130, COMMON);
317partition TOKEN_OR_IDENTIFIER(130, PARTITION);
318active TOKEN_OR_IDENTIFIER(130, ACTIVE);
319superp TOKEN_OR_IDENTIFIER(130, SUPERP);
320samplerBuffer TOKEN_OR_IDENTIFIER(130, SAMPLERBUFFER);
321filter TOKEN_OR_IDENTIFIER(130, FILTER);
322image1D TOKEN_OR_IDENTIFIER(130, IMAGE1D);
323image2D TOKEN_OR_IDENTIFIER(130, IMAGE2D);
324image3D TOKEN_OR_IDENTIFIER(130, IMAGE3D);
325imageCube TOKEN_OR_IDENTIFIER(130, IMAGECUBE);
326iimage1D TOKEN_OR_IDENTIFIER(130, IIMAGE1D);
327iimage2D TOKEN_OR_IDENTIFIER(130, IIMAGE2D);
328iimage3D TOKEN_OR_IDENTIFIER(130, IIMAGE3D);
329iimageCube TOKEN_OR_IDENTIFIER(130, IIMAGECUBE);
330uimage1D TOKEN_OR_IDENTIFIER(130, UIMAGE1D);
331uimage2D TOKEN_OR_IDENTIFIER(130, UIMAGE2D);
332uimage3D TOKEN_OR_IDENTIFIER(130, UIMAGE3D);
333uimageCube TOKEN_OR_IDENTIFIER(130, UIMAGECUBE);
334image1DArray TOKEN_OR_IDENTIFIER(130, IMAGE1DARRAY);
335image2DArray TOKEN_OR_IDENTIFIER(130, IMAGE2DARRAY);
336iimage1DArray TOKEN_OR_IDENTIFIER(130, IIMAGE1DARRAY);
337iimage2DArray TOKEN_OR_IDENTIFIER(130, IIMAGE2DARRAY);
338uimage1DArray TOKEN_OR_IDENTIFIER(130, UIMAGE1DARRAY);
339uimage2DArray TOKEN_OR_IDENTIFIER(130, UIMAGE2DARRAY);
340image1DShadow TOKEN_OR_IDENTIFIER(130, IMAGE1DSHADOW);
341image2DShadow TOKEN_OR_IDENTIFIER(130, IMAGE2DSHADOW);
342imageBuffer TOKEN_OR_IDENTIFIER(130, IMAGEBUFFER);
343iimageBuffer TOKEN_OR_IDENTIFIER(130, IIMAGEBUFFER);
344uimageBuffer TOKEN_OR_IDENTIFIER(130, UIMAGEBUFFER);
345row_major TOKEN_OR_IDENTIFIER(130, ROW_MAJOR);
346
347[_a-zA-Z][_a-zA-Z0-9]* {
348 struct _mesa_glsl_parse_state *state = yyextra;
349 void *ctx = state;
350 yylval->identifier = talloc_strdup(ctx, yytext);
351 return IDENTIFIER;
352 }
353
354. { return yytext[0]; }
355
356%%
357
358void
359_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string)
360{
361 yylex_init_extra(state, & state->scanner);
362 yy_scan_string(string, state->scanner);
363}
364
365void
366_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state)
367{
368 yylex_destroy(state->scanner);
369}
diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp
new file mode 100644
index 00000000000..7df9e96d16f
--- /dev/null
+++ b/src/glsl/glsl_parser.cpp
@@ -0,0 +1,5245 @@
1
2/* A Bison parser, made by GNU Bison 2.4.1. */
3
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22/* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
31
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
34
35/* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
37
38/* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
44
45/* Identify Bison output. */
46#define YYBISON 1
47
48/* Bison version. */
49#define YYBISON_VERSION "2.4.1"
50
51/* Skeleton name. */
52#define YYSKELETON_NAME "yacc.c"
53
54/* Pure parsers. */
55#define YYPURE 1
56
57/* Push parsers. */
58#define YYPUSH 0
59
60/* Pull parsers. */
61#define YYPULL 1
62
63/* Using locations. */
64#define YYLSP_NEEDED 1
65
66/* Substitute the variable and function names. */
67#define yyparse _mesa_glsl_parse
68#define yylex _mesa_glsl_lex
69#define yyerror _mesa_glsl_error
70#define yylval _mesa_glsl_lval
71#define yychar _mesa_glsl_char
72#define yydebug _mesa_glsl_debug
73#define yynerrs _mesa_glsl_nerrs
74#define yylloc _mesa_glsl_lloc
75
76/* Copy the first part of user declarations. */
77
78/* Line 189 of yacc.c */
79#line 1 "glsl_parser.ypp"
80
81/*
82 * Copyright © 2008, 2009 Intel Corporation
83 *
84 * Permission is hereby granted, free of charge, to any person obtaining a
85 * copy of this software and associated documentation files (the "Software"),
86 * to deal in the Software without restriction, including without limitation
87 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88 * and/or sell copies of the Software, and to permit persons to whom the
89 * Software is furnished to do so, subject to the following conditions:
90 *
91 * The above copyright notice and this permission notice (including the next
92 * paragraph) shall be included in all copies or substantial portions of the
93 * Software.
94 *
95 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
96 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
98 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
99 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
100 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
101 * DEALINGS IN THE SOFTWARE.
102 */
103#include <stdio.h>
104#include <stdlib.h>
105#include <string.h>
106#include <assert.h>
107
108#include "ast.h"
109#include "glsl_parser_extras.h"
110#include "glsl_types.h"
111
112#define YYLEX_PARAM state->scanner
113
114
115
116/* Line 189 of yacc.c */
117#line 118 "glsl_parser.cpp"
118
119/* Enabling traces. */
120#ifndef YYDEBUG
121# define YYDEBUG 0
122#endif
123
124/* Enabling verbose error messages. */
125#ifdef YYERROR_VERBOSE
126# undef YYERROR_VERBOSE
127# define YYERROR_VERBOSE 1
128#else
129# define YYERROR_VERBOSE 1
130#endif
131
132/* Enabling the token table. */
133#ifndef YYTOKEN_TABLE
134# define YYTOKEN_TABLE 0
135#endif
136
137
138/* Tokens. */
139#ifndef YYTOKENTYPE
140# define YYTOKENTYPE
141 /* Put the tokens into the symbol table, so that GDB and other debuggers
142 know about them. */
143 enum yytokentype {
144 ATTRIBUTE = 258,
145 CONST_TOK = 259,
146 BOOL_TOK = 260,
147 FLOAT_TOK = 261,
148 INT_TOK = 262,
149 UINT_TOK = 263,
150 BREAK = 264,
151 CONTINUE = 265,
152 DO = 266,
153 ELSE = 267,
154 FOR = 268,
155 IF = 269,
156 DISCARD = 270,
157 RETURN = 271,
158 SWITCH = 272,
159 CASE = 273,
160 DEFAULT = 274,
161 BVEC2 = 275,
162 BVEC3 = 276,
163 BVEC4 = 277,
164 IVEC2 = 278,
165 IVEC3 = 279,
166 IVEC4 = 280,
167 UVEC2 = 281,
168 UVEC3 = 282,
169 UVEC4 = 283,
170 VEC2 = 284,
171 VEC3 = 285,
172 VEC4 = 286,
173 CENTROID = 287,
174 IN_TOK = 288,
175 OUT_TOK = 289,
176 INOUT_TOK = 290,
177 UNIFORM = 291,
178 VARYING = 292,
179 NOPERSPECTIVE = 293,
180 FLAT = 294,
181 SMOOTH = 295,
182 MAT2X2 = 296,
183 MAT2X3 = 297,
184 MAT2X4 = 298,
185 MAT3X2 = 299,
186 MAT3X3 = 300,
187 MAT3X4 = 301,
188 MAT4X2 = 302,
189 MAT4X3 = 303,
190 MAT4X4 = 304,
191 SAMPLER1D = 305,
192 SAMPLER2D = 306,
193 SAMPLER3D = 307,
194 SAMPLERCUBE = 308,
195 SAMPLER1DSHADOW = 309,
196 SAMPLER2DSHADOW = 310,
197 SAMPLERCUBESHADOW = 311,
198 SAMPLER1DARRAY = 312,
199 SAMPLER2DARRAY = 313,
200 SAMPLER1DARRAYSHADOW = 314,
201 SAMPLER2DARRAYSHADOW = 315,
202 ISAMPLER1D = 316,
203 ISAMPLER2D = 317,
204 ISAMPLER3D = 318,
205 ISAMPLERCUBE = 319,
206 ISAMPLER1DARRAY = 320,
207 ISAMPLER2DARRAY = 321,
208 USAMPLER1D = 322,
209 USAMPLER2D = 323,
210 USAMPLER3D = 324,
211 USAMPLERCUBE = 325,
212 USAMPLER1DARRAY = 326,
213 USAMPLER2DARRAY = 327,
214 STRUCT = 328,
215 VOID_TOK = 329,
216 WHILE = 330,
217 IDENTIFIER = 331,
218 FLOATCONSTANT = 332,
219 INTCONSTANT = 333,
220 UINTCONSTANT = 334,
221 BOOLCONSTANT = 335,
222 FIELD_SELECTION = 336,
223 LEFT_OP = 337,
224 RIGHT_OP = 338,
225 INC_OP = 339,
226 DEC_OP = 340,
227 LE_OP = 341,
228 GE_OP = 342,
229 EQ_OP = 343,
230 NE_OP = 344,
231 AND_OP = 345,
232 OR_OP = 346,
233 XOR_OP = 347,
234 MUL_ASSIGN = 348,
235 DIV_ASSIGN = 349,
236 ADD_ASSIGN = 350,
237 MOD_ASSIGN = 351,
238 LEFT_ASSIGN = 352,
239 RIGHT_ASSIGN = 353,
240 AND_ASSIGN = 354,
241 XOR_ASSIGN = 355,
242 OR_ASSIGN = 356,
243 SUB_ASSIGN = 357,
244 INVARIANT = 358,
245 LOWP = 359,
246 MEDIUMP = 360,
247 HIGHP = 361,
248 SUPERP = 362,
249 PRECISION = 363,
250 VERSION = 364,
251 EXTENSION = 365,
252 LINE = 366,
253 PRAGMA = 367,
254 COLON = 368,
255 EOL = 369,
256 INTERFACE = 370,
257 OUTPUT = 371,
258 LAYOUT_TOK = 372,
259 ASM = 373,
260 CLASS = 374,
261 UNION = 375,
262 ENUM = 376,
263 TYPEDEF = 377,
264 TEMPLATE = 378,
265 THIS = 379,
266 PACKED_TOK = 380,
267 GOTO = 381,
268 INLINE_TOK = 382,
269 NOINLINE = 383,
270 VOLATILE = 384,
271 PUBLIC_TOK = 385,
272 STATIC = 386,
273 EXTERN = 387,
274 EXTERNAL = 388,
275 LONG_TOK = 389,
276 SHORT_TOK = 390,
277 DOUBLE_TOK = 391,
278 HALF = 392,
279 FIXED_TOK = 393,
280 UNSIGNED = 394,
281 INPUT_TOK = 395,
282 OUPTUT = 396,
283 HVEC2 = 397,
284 HVEC3 = 398,
285 HVEC4 = 399,
286 DVEC2 = 400,
287 DVEC3 = 401,
288 DVEC4 = 402,
289 FVEC2 = 403,
290 FVEC3 = 404,
291 FVEC4 = 405,
292 SAMPLER2DRECT = 406,
293 SAMPLER3DRECT = 407,
294 SAMPLER2DRECTSHADOW = 408,
295 SIZEOF = 409,
296 CAST = 410,
297 NAMESPACE = 411,
298 USING = 412,
299 ERROR_TOK = 413,
300 COMMON = 414,
301 PARTITION = 415,
302 ACTIVE = 416,
303 SAMPLERBUFFER = 417,
304 FILTER = 418,
305 IMAGE1D = 419,
306 IMAGE2D = 420,
307 IMAGE3D = 421,
308 IMAGECUBE = 422,
309 IMAGE1DARRAY = 423,
310 IMAGE2DARRAY = 424,
311 IIMAGE1D = 425,
312 IIMAGE2D = 426,
313 IIMAGE3D = 427,
314 IIMAGECUBE = 428,
315 IIMAGE1DARRAY = 429,
316 IIMAGE2DARRAY = 430,
317 UIMAGE1D = 431,
318 UIMAGE2D = 432,
319 UIMAGE3D = 433,
320 UIMAGECUBE = 434,
321 UIMAGE1DARRAY = 435,
322 UIMAGE2DARRAY = 436,
323 IMAGE1DSHADOW = 437,
324 IMAGE2DSHADOW = 438,
325 IMAGEBUFFER = 439,
326 IIMAGEBUFFER = 440,
327 UIMAGEBUFFER = 441,
328 ROW_MAJOR = 442
329 };
330#endif
331
332
333
334#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
335typedef union YYSTYPE
336{
337
338/* Line 214 of yacc.c */
339#line 52 "glsl_parser.ypp"
340
341 int n;
342 float real;
343 char *identifier;
344
345 union {
346 struct ast_type_qualifier q;
347 unsigned i;
348 } type_qualifier;
349
350 ast_node *node;
351 ast_type_specifier *type_specifier;
352 ast_fully_specified_type *fully_specified_type;
353 ast_function *function;
354 ast_parameter_declarator *parameter_declarator;
355 ast_function_definition *function_definition;
356 ast_compound_statement *compound_statement;
357 ast_expression *expression;
358 ast_declarator_list *declarator_list;
359 ast_struct_specifier *struct_specifier;
360 ast_declaration *declaration;
361
362 struct {
363 ast_node *cond;
364 ast_expression *rest;
365 } for_rest_statement;
366
367
368
369/* Line 214 of yacc.c */
370#line 371 "glsl_parser.cpp"
371} YYSTYPE;
372# define YYSTYPE_IS_TRIVIAL 1
373# define yystype YYSTYPE /* obsolescent; will be withdrawn */
374# define YYSTYPE_IS_DECLARED 1
375#endif
376
377#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
378typedef struct YYLTYPE
379{
380 int first_line;
381 int first_column;
382 int last_line;
383 int last_column;
384} YYLTYPE;
385# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
386# define YYLTYPE_IS_DECLARED 1
387# define YYLTYPE_IS_TRIVIAL 1
388#endif
389
390
391/* Copy the second part of user declarations. */
392
393
394/* Line 264 of yacc.c */
395#line 396 "glsl_parser.cpp"
396
397#ifdef short
398# undef short
399#endif
400
401#ifdef YYTYPE_UINT8
402typedef YYTYPE_UINT8 yytype_uint8;
403#else
404typedef unsigned char yytype_uint8;
405#endif
406
407#ifdef YYTYPE_INT8
408typedef YYTYPE_INT8 yytype_int8;
409#elif (defined __STDC__ || defined __C99__FUNC__ \
410 || defined __cplusplus || defined _MSC_VER)
411typedef signed char yytype_int8;
412#else
413typedef short int yytype_int8;
414#endif
415
416#ifdef YYTYPE_UINT16
417typedef YYTYPE_UINT16 yytype_uint16;
418#else
419typedef unsigned short int yytype_uint16;
420#endif
421
422#ifdef YYTYPE_INT16
423typedef YYTYPE_INT16 yytype_int16;
424#else
425typedef short int yytype_int16;
426#endif
427
428#ifndef YYSIZE_T
429# ifdef __SIZE_TYPE__
430# define YYSIZE_T __SIZE_TYPE__
431# elif defined size_t
432# define YYSIZE_T size_t
433# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
434 || defined __cplusplus || defined _MSC_VER)
435# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
436# define YYSIZE_T size_t
437# else
438# define YYSIZE_T unsigned int
439# endif
440#endif
441
442#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
443
444#ifndef YY_
445# if YYENABLE_NLS
446# if ENABLE_NLS
447# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
448# define YY_(msgid) dgettext ("bison-runtime", msgid)
449# endif
450# endif
451# ifndef YY_
452# define YY_(msgid) msgid
453# endif
454#endif
455
456/* Suppress unused-variable warnings by "using" E. */
457#if ! defined lint || defined __GNUC__
458# define YYUSE(e) ((void) (e))
459#else
460# define YYUSE(e) /* empty */
461#endif
462
463/* Identity function, used to suppress warnings about constant conditions. */
464#ifndef lint
465# define YYID(n) (n)
466#else
467#if (defined __STDC__ || defined __C99__FUNC__ \
468 || defined __cplusplus || defined _MSC_VER)
469static int
470YYID (int yyi)
471#else
472static int
473YYID (yyi)
474 int yyi;
475#endif
476{
477 return yyi;
478}
479#endif
480
481#if ! defined yyoverflow || YYERROR_VERBOSE
482
483/* The parser invokes alloca or malloc; define the necessary symbols. */
484
485# ifdef YYSTACK_USE_ALLOCA
486# if YYSTACK_USE_ALLOCA
487# ifdef __GNUC__
488# define YYSTACK_ALLOC __builtin_alloca
489# elif defined __BUILTIN_VA_ARG_INCR
490# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
491# elif defined _AIX
492# define YYSTACK_ALLOC __alloca
493# elif defined _MSC_VER
494# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
495# define alloca _alloca
496# else
497# define YYSTACK_ALLOC alloca
498# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
499 || defined __cplusplus || defined _MSC_VER)
500# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
501# ifndef _STDLIB_H
502# define _STDLIB_H 1
503# endif
504# endif
505# endif
506# endif
507# endif
508
509# ifdef YYSTACK_ALLOC
510 /* Pacify GCC's `empty if-body' warning. */
511# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
512# ifndef YYSTACK_ALLOC_MAXIMUM
513 /* The OS might guarantee only one guard page at the bottom of the stack,
514 and a page size can be as small as 4096 bytes. So we cannot safely
515 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
516 to allow for a few compiler-allocated temporary stack slots. */
517# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
518# endif
519# else
520# define YYSTACK_ALLOC YYMALLOC
521# define YYSTACK_FREE YYFREE
522# ifndef YYSTACK_ALLOC_MAXIMUM
523# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
524# endif
525# if (defined __cplusplus && ! defined _STDLIB_H \
526 && ! ((defined YYMALLOC || defined malloc) \
527 && (defined YYFREE || defined free)))
528# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
529# ifndef _STDLIB_H
530# define _STDLIB_H 1
531# endif
532# endif
533# ifndef YYMALLOC
534# define YYMALLOC malloc
535# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
536 || defined __cplusplus || defined _MSC_VER)
537void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
538# endif
539# endif
540# ifndef YYFREE
541# define YYFREE free
542# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
543 || defined __cplusplus || defined _MSC_VER)
544void free (void *); /* INFRINGES ON USER NAME SPACE */
545# endif
546# endif
547# endif
548#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
549
550
551#if (! defined yyoverflow \
552 && (! defined __cplusplus \
553 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
554 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
555
556/* A type that is properly aligned for any stack member. */
557union yyalloc
558{
559 yytype_int16 yyss_alloc;
560 YYSTYPE yyvs_alloc;
561 YYLTYPE yyls_alloc;
562};
563
564/* The size of the maximum gap between one aligned stack and the next. */
565# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
566
567/* The size of an array large to enough to hold all stacks, each with
568 N elements. */
569# define YYSTACK_BYTES(N) \
570 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
571 + 2 * YYSTACK_GAP_MAXIMUM)
572
573/* Copy COUNT objects from FROM to TO. The source and destination do
574 not overlap. */
575# ifndef YYCOPY
576# if defined __GNUC__ && 1 < __GNUC__
577# define YYCOPY(To, From, Count) \
578 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
579# else
580# define YYCOPY(To, From, Count) \
581 do \
582 { \
583 YYSIZE_T yyi; \
584 for (yyi = 0; yyi < (Count); yyi++) \
585 (To)[yyi] = (From)[yyi]; \
586 } \
587 while (YYID (0))
588# endif
589# endif
590
591/* Relocate STACK from its old location to the new one. The
592 local variables YYSIZE and YYSTACKSIZE give the old and new number of
593 elements in the stack, and YYPTR gives the new location of the
594 stack. Advance YYPTR to a properly aligned location for the next
595 stack. */
596# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
597 do \
598 { \
599 YYSIZE_T yynewbytes; \
600 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
601 Stack = &yyptr->Stack_alloc; \
602 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
603 yyptr += yynewbytes / sizeof (*yyptr); \
604 } \
605 while (YYID (0))
606
607#endif
608
609/* YYFINAL -- State number of the termination state. */
610#define YYFINAL 5
611/* YYLAST -- Last index in YYTABLE. */
612#define YYLAST 4096
613
614/* YYNTOKENS -- Number of terminals. */
615#define YYNTOKENS 212
616/* YYNNTS -- Number of nonterminals. */
617#define YYNNTS 89
618/* YYNRULES -- Number of rules. */
619#define YYNRULES 273
620/* YYNRULES -- Number of states. */
621#define YYNSTATES 410
622
623/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
624#define YYUNDEFTOK 2
625#define YYMAXUTOK 442
626
627#define YYTRANSLATE(YYX) \
628 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
629
630/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
631static const yytype_uint8 yytranslate[] =
632{
633 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
634 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
636 2, 2, 2, 196, 2, 2, 2, 200, 203, 2,
637 188, 189, 198, 194, 193, 195, 192, 199, 2, 2,
638 2, 2, 2, 2, 2, 2, 2, 2, 207, 209,
639 201, 208, 202, 206, 2, 2, 2, 2, 2, 2,
640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
642 2, 190, 2, 191, 204, 2, 2, 2, 2, 2,
643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
645 2, 2, 2, 210, 205, 211, 197, 2, 2, 2,
646 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
647 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
648 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
649 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
650 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
651 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
652 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
653 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
654 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
655 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
656 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
657 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
658 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
659 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
660 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
661 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
662 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
663 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
664 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
665 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
666 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
667 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
668 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
669 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
670 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
671 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
672 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
673 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
674 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
675 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
676 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
677 185, 186, 187
678};
679
680#if YYDEBUG
681/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
682 YYRHS. */
683static const yytype_uint16 yyprhs[] =
684{
685 0, 0, 3, 4, 9, 10, 14, 15, 18, 24,
686 26, 29, 31, 33, 35, 37, 39, 41, 45, 47,
687 52, 54, 58, 61, 64, 66, 68, 70, 74, 77,
688 80, 83, 85, 88, 92, 95, 97, 99, 101, 103,
689 106, 109, 112, 114, 116, 118, 120, 122, 126, 130,
690 134, 136, 140, 144, 146, 150, 154, 156, 160, 164,
691 168, 172, 174, 178, 182, 184, 188, 190, 194, 196,
692 200, 202, 206, 208, 212, 214, 218, 220, 226, 228,
693 232, 234, 236, 238, 240, 242, 244, 246, 248, 250,
694 252, 254, 256, 260, 262, 265, 268, 273, 276, 278,
695 280, 283, 287, 291, 294, 300, 304, 307, 311, 314,
696 315, 317, 319, 321, 323, 325, 329, 335, 342, 350,
697 359, 365, 367, 370, 375, 381, 388, 396, 401, 404,
698 406, 409, 410, 412, 417, 419, 423, 425, 427, 429,
699 431, 433, 435, 438, 441, 443, 445, 448, 451, 454,
700 456, 459, 462, 464, 466, 469, 471, 475, 480, 482,
701 484, 486, 488, 490, 492, 494, 496, 498, 500, 502,
702 504, 506, 508, 510, 512, 514, 516, 518, 520, 522,
703 524, 526, 528, 530, 532, 534, 536, 538, 540, 542,
704 544, 546, 548, 550, 552, 554, 556, 558, 560, 562,
705 564, 566, 568, 570, 572, 574, 576, 578, 580, 582,
706 584, 586, 588, 590, 592, 594, 600, 605, 607, 610,
707 614, 616, 620, 622, 627, 629, 631, 633, 635, 637,
708 639, 641, 643, 645, 647, 649, 651, 653, 655, 658,
709 662, 664, 666, 669, 673, 675, 678, 680, 683, 691,
710 697, 703, 711, 713, 718, 724, 728, 731, 737, 745,
711 752, 754, 756, 758, 759, 762, 766, 769, 772, 775,
712 779, 782, 784, 786
713};
714
715/* YYRHS -- A `-1'-separated list of the rules' RHS. */
716static const yytype_int16 yyrhs[] =
717{
718 213, 0, -1, -1, 215, 216, 214, 218, -1, -1,
719 109, 78, 114, -1, -1, 216, 217, -1, 110, 76,
720 113, 76, 114, -1, 299, -1, 218, 299, -1, 76,
721 -1, 219, -1, 78, -1, 79, -1, 77, -1, 80,
722 -1, 188, 246, 189, -1, 220, -1, 221, 190, 222,
723 191, -1, 223, -1, 221, 192, 76, -1, 221, 84,
724 -1, 221, 85, -1, 246, -1, 224, -1, 225, -1,
725 221, 192, 225, -1, 227, 189, -1, 226, 189, -1,
726 228, 74, -1, 228, -1, 228, 244, -1, 227, 193,
727 244, -1, 229, 188, -1, 268, -1, 76, -1, 81,
728 -1, 221, -1, 84, 230, -1, 85, 230, -1, 231,
729 230, -1, 194, -1, 195, -1, 196, -1, 197, -1,
730 230, -1, 232, 198, 230, -1, 232, 199, 230, -1,
731 232, 200, 230, -1, 232, -1, 233, 194, 232, -1,
732 233, 195, 232, -1, 233, -1, 234, 82, 233, -1,
733 234, 83, 233, -1, 234, -1, 235, 201, 234, -1,
734 235, 202, 234, -1, 235, 86, 234, -1, 235, 87,
735 234, -1, 235, -1, 236, 88, 235, -1, 236, 89,
736 235, -1, 236, -1, 237, 203, 236, -1, 237, -1,
737 238, 204, 237, -1, 238, -1, 239, 205, 238, -1,
738 239, -1, 240, 90, 239, -1, 240, -1, 241, 92,
739 240, -1, 241, -1, 242, 91, 241, -1, 242, -1,
740 242, 206, 246, 207, 244, -1, 243, -1, 230, 245,
741 244, -1, 208, -1, 93, -1, 94, -1, 96, -1,
742 95, -1, 102, -1, 97, -1, 98, -1, 99, -1,
743 100, -1, 101, -1, 244, -1, 246, 193, 244, -1,
744 243, -1, 249, 209, -1, 257, 209, -1, 108, 272,
745 269, 209, -1, 250, 189, -1, 252, -1, 251, -1,
746 252, 254, -1, 251, 193, 254, -1, 259, 76, 188,
747 -1, 268, 76, -1, 268, 76, 190, 247, 191, -1,
748 265, 255, 253, -1, 255, 253, -1, 265, 255, 256,
749 -1, 255, 256, -1, -1, 33, -1, 34, -1, 35,
750 -1, 268, -1, 258, -1, 257, 193, 76, -1, 257,
751 193, 76, 190, 191, -1, 257, 193, 76, 190, 247,
752 191, -1, 257, 193, 76, 190, 191, 208, 278, -1,
753 257, 193, 76, 190, 247, 191, 208, 278, -1, 257,
754 193, 76, 208, 278, -1, 259, -1, 259, 76, -1,
755 259, 76, 190, 191, -1, 259, 76, 190, 247, 191,
756 -1, 259, 76, 190, 191, 208, 278, -1, 259, 76,
757 190, 247, 191, 208, 278, -1, 259, 76, 208, 278,
758 -1, 103, 76, -1, 268, -1, 266, 268, -1, -1,
759 261, -1, 117, 188, 262, 189, -1, 263, -1, 262,
760 193, 263, -1, 76, -1, 40, -1, 39, -1, 38,
761 -1, 4, -1, 267, -1, 264, 266, -1, 103, 266,
762 -1, 4, -1, 3, -1, 260, 37, -1, 32, 37,
763 -1, 260, 33, -1, 34, -1, 32, 33, -1, 32,
764 34, -1, 36, -1, 269, -1, 272, 269, -1, 270,
765 -1, 270, 190, 191, -1, 270, 190, 247, 191, -1,
766 271, -1, 273, -1, 76, -1, 74, -1, 6, -1,
767 7, -1, 8, -1, 5, -1, 29, -1, 30, -1,
768 31, -1, 20, -1, 21, -1, 22, -1, 23, -1,
769 24, -1, 25, -1, 26, -1, 27, -1, 28, -1,
770 41, -1, 42, -1, 43, -1, 44, -1, 45, -1,
771 46, -1, 47, -1, 48, -1, 49, -1, 50, -1,
772 51, -1, 151, -1, 52, -1, 53, -1, 54, -1,
773 55, -1, 153, -1, 56, -1, 57, -1, 58, -1,
774 59, -1, 60, -1, 61, -1, 62, -1, 63, -1,
775 64, -1, 65, -1, 66, -1, 67, -1, 68, -1,
776 69, -1, 70, -1, 71, -1, 72, -1, 106, -1,
777 105, -1, 104, -1, 73, 76, 210, 274, 211, -1,
778 73, 210, 274, 211, -1, 275, -1, 274, 275, -1,
779 268, 276, 209, -1, 277, -1, 276, 193, 277, -1,
780 76, -1, 76, 190, 247, 191, -1, 244, -1, 248,
781 -1, 281, -1, 282, -1, 284, -1, 283, -1, 290,
782 -1, 279, -1, 288, -1, 289, -1, 292, -1, 293,
783 -1, 294, -1, 298, -1, 210, 211, -1, 210, 287,
784 211, -1, 286, -1, 283, -1, 210, 211, -1, 210,
785 287, 211, -1, 280, -1, 287, 280, -1, 209, -1,
786 246, 209, -1, 14, 188, 246, 189, 281, 12, 281,
787 -1, 14, 188, 246, 189, 281, -1, 14, 188, 246,
788 189, 282, -1, 14, 188, 246, 189, 281, 12, 282,
789 -1, 246, -1, 259, 76, 208, 278, -1, 17, 188,
790 246, 189, 284, -1, 18, 246, 207, -1, 19, 207,
791 -1, 75, 188, 291, 189, 285, -1, 11, 280, 75,
792 188, 246, 189, 209, -1, 13, 188, 295, 297, 189,
793 285, -1, 288, -1, 279, -1, 291, -1, -1, 296,
794 209, -1, 296, 209, 246, -1, 10, 209, -1, 9,
795 209, -1, 16, 209, -1, 16, 246, 209, -1, 15,
796 209, -1, 300, -1, 248, -1, 249, 286, -1
797};
798
799/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
800static const yytype_uint16 yyrline[] =
801{
802 0, 209, 209, 208, 217, 220, 237, 239, 243, 252,
803 260, 271, 275, 282, 289, 296, 303, 310, 317, 318,
804 324, 328, 335, 341, 350, 354, 358, 359, 368, 369,
805 373, 374, 378, 384, 396, 400, 406, 413, 424, 425,
806 431, 437, 447, 448, 449, 450, 454, 455, 461, 467,
807 476, 477, 483, 492, 493, 499, 508, 509, 515, 521,
808 527, 536, 537, 543, 552, 553, 562, 563, 572, 573,
809 582, 583, 592, 593, 602, 603, 612, 613, 622, 623,
810 632, 633, 634, 635, 636, 637, 638, 639, 640, 641,
811 642, 646, 650, 666, 670, 674, 678, 692, 696, 697,
812 701, 706, 714, 725, 735, 750, 757, 762, 773, 785,
813 786, 787, 788, 792, 796, 797, 806, 815, 824, 833,
814 842, 855, 866, 875, 884, 893, 902, 911, 920, 934,
815 941, 952, 953, 957, 964, 965, 972, 1006, 1007, 1008,
816 1012, 1016, 1017, 1021, 1029, 1030, 1031, 1032, 1033, 1034,
817 1035, 1036, 1037, 1041, 1042, 1050, 1051, 1057, 1066, 1072,
818 1078, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095,
819 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105,
820 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115,
821 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125,
822 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135,
823 1136, 1137, 1141, 1152, 1163, 1177, 1183, 1192, 1197, 1205,
824 1220, 1225, 1233, 1239, 1248, 1252, 1258, 1259, 1263, 1264,
825 1268, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1282, 1288,
826 1297, 1298, 1302, 1308, 1317, 1327, 1339, 1345, 1354, 1363,
827 1369, 1375, 1384, 1388, 1402, 1406, 1407, 1411, 1418, 1425,
828 1435, 1436, 1440, 1442, 1448, 1453, 1462, 1468, 1474, 1480,
829 1486, 1495, 1496, 1500
830};
831#endif
832
833#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
834/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
835 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
836static const char *const yytname[] =
837{
838 "$end", "error", "$undefined", "ATTRIBUTE", "CONST_TOK", "BOOL_TOK",
839 "FLOAT_TOK", "INT_TOK", "UINT_TOK", "BREAK", "CONTINUE", "DO", "ELSE",
840 "FOR", "IF", "DISCARD", "RETURN", "SWITCH", "CASE", "DEFAULT", "BVEC2",
841 "BVEC3", "BVEC4", "IVEC2", "IVEC3", "IVEC4", "UVEC2", "UVEC3", "UVEC4",
842 "VEC2", "VEC3", "VEC4", "CENTROID", "IN_TOK", "OUT_TOK", "INOUT_TOK",
843 "UNIFORM", "VARYING", "NOPERSPECTIVE", "FLAT", "SMOOTH", "MAT2X2",
844 "MAT2X3", "MAT2X4", "MAT3X2", "MAT3X3", "MAT3X4", "MAT4X2", "MAT4X3",
845 "MAT4X4", "SAMPLER1D", "SAMPLER2D", "SAMPLER3D", "SAMPLERCUBE",
846 "SAMPLER1DSHADOW", "SAMPLER2DSHADOW", "SAMPLERCUBESHADOW",
847 "SAMPLER1DARRAY", "SAMPLER2DARRAY", "SAMPLER1DARRAYSHADOW",
848 "SAMPLER2DARRAYSHADOW", "ISAMPLER1D", "ISAMPLER2D", "ISAMPLER3D",
849 "ISAMPLERCUBE", "ISAMPLER1DARRAY", "ISAMPLER2DARRAY", "USAMPLER1D",
850 "USAMPLER2D", "USAMPLER3D", "USAMPLERCUBE", "USAMPLER1DARRAY",
851 "USAMPLER2DARRAY", "STRUCT", "VOID_TOK", "WHILE", "IDENTIFIER",
852 "FLOATCONSTANT", "INTCONSTANT", "UINTCONSTANT", "BOOLCONSTANT",
853 "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", "DEC_OP", "LE_OP",
854 "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN",
855 "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN",
856 "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "INVARIANT",
857 "LOWP", "MEDIUMP", "HIGHP", "SUPERP", "PRECISION", "VERSION",
858 "EXTENSION", "LINE", "PRAGMA", "COLON", "EOL", "INTERFACE", "OUTPUT",
859 "LAYOUT_TOK", "ASM", "CLASS", "UNION", "ENUM", "TYPEDEF", "TEMPLATE",
860 "THIS", "PACKED_TOK", "GOTO", "INLINE_TOK", "NOINLINE", "VOLATILE",
861 "PUBLIC_TOK", "STATIC", "EXTERN", "EXTERNAL", "LONG_TOK", "SHORT_TOK",
862 "DOUBLE_TOK", "HALF", "FIXED_TOK", "UNSIGNED", "INPUT_TOK", "OUPTUT",
863 "HVEC2", "HVEC3", "HVEC4", "DVEC2", "DVEC3", "DVEC4", "FVEC2", "FVEC3",
864 "FVEC4", "SAMPLER2DRECT", "SAMPLER3DRECT", "SAMPLER2DRECTSHADOW",
865 "SIZEOF", "CAST", "NAMESPACE", "USING", "ERROR_TOK", "COMMON",
866 "PARTITION", "ACTIVE", "SAMPLERBUFFER", "FILTER", "IMAGE1D", "IMAGE2D",
867 "IMAGE3D", "IMAGECUBE", "IMAGE1DARRAY", "IMAGE2DARRAY", "IIMAGE1D",
868 "IIMAGE2D", "IIMAGE3D", "IIMAGECUBE", "IIMAGE1DARRAY", "IIMAGE2DARRAY",
869 "UIMAGE1D", "UIMAGE2D", "UIMAGE3D", "UIMAGECUBE", "UIMAGE1DARRAY",
870 "UIMAGE2DARRAY", "IMAGE1DSHADOW", "IMAGE2DSHADOW", "IMAGEBUFFER",
871 "IIMAGEBUFFER", "UIMAGEBUFFER", "ROW_MAJOR", "'('", "')'", "'['", "']'",
872 "'.'", "','", "'+'", "'-'", "'!'", "'~'", "'*'", "'/'", "'%'", "'<'",
873 "'>'", "'&'", "'^'", "'|'", "'?'", "':'", "'='", "';'", "'{'", "'}'",
874 "$accept", "translation_unit", "$@1", "version_statement",
875 "extension_statement_list", "extension_statement",
876 "external_declaration_list", "variable_identifier", "primary_expression",
877 "postfix_expression", "integer_expression", "function_call",
878 "function_call_or_method", "function_call_generic",
879 "function_call_header_no_parameters",
880 "function_call_header_with_parameters", "function_call_header",
881 "function_identifier", "unary_expression", "unary_operator",
882 "multiplicative_expression", "additive_expression", "shift_expression",
883 "relational_expression", "equality_expression", "and_expression",
884 "exclusive_or_expression", "inclusive_or_expression",
885 "logical_and_expression", "logical_xor_expression",
886 "logical_or_expression", "conditional_expression",
887 "assignment_expression", "assignment_operator", "expression",
888 "constant_expression", "declaration", "function_prototype",
889 "function_declarator", "function_header_with_parameters",
890 "function_header", "parameter_declarator", "parameter_declaration",
891 "parameter_qualifier", "parameter_type_specifier",
892 "init_declarator_list", "single_declaration", "fully_specified_type",
893 "opt_layout_qualifier", "layout_qualifier", "layout_qualifier_id_list",
894 "layout_qualifier_id", "interpolation_qualifier",
895 "parameter_type_qualifier", "type_qualifier", "storage_qualifier",
896 "type_specifier", "type_specifier_no_prec", "type_specifier_nonarray",
897 "basic_type_specifier_nonarray", "precision_qualifier",
898 "struct_specifier", "struct_declaration_list", "struct_declaration",
899 "struct_declarator_list", "struct_declarator", "initializer",
900 "declaration_statement", "statement", "statement_matched",
901 "statement_unmatched", "simple_statement", "compound_statement",
902 "statement_no_new_scope", "compound_statement_no_new_scope",
903 "statement_list", "expression_statement", "selection_statement_matched",
904 "selection_statement_unmatched", "condition", "switch_statement",
905 "case_label", "iteration_statement", "for_init_statement",
906 "conditionopt", "for_rest_statement", "jump_statement",
907 "external_declaration", "function_definition", 0
908};
909#endif
910
911# ifdef YYPRINT
912/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
913 token YYLEX-NUM. */
914static const yytype_uint16 yytoknum[] =
915{
916 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
917 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
918 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
919 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
920 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
921 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
922 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
923 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
924 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
925 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
926 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
927 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
928 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
929 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
930 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
931 405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
932 415, 416, 417, 418, 419, 420, 421, 422, 423, 424,
933 425, 426, 427, 428, 429, 430, 431, 432, 433, 434,
934 435, 436, 437, 438, 439, 440, 441, 442, 40, 41,
935 91, 93, 46, 44, 43, 45, 33, 126, 42, 47,
936 37, 60, 62, 38, 94, 124, 63, 58, 61, 59,
937 123, 125
938};
939# endif
940
941/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
942static const yytype_uint16 yyr1[] =
943{
944 0, 212, 214, 213, 215, 215, 216, 216, 217, 218,
945 218, 219, 220, 220, 220, 220, 220, 220, 221, 221,
946 221, 221, 221, 221, 222, 223, 224, 224, 225, 225,
947 226, 226, 227, 227, 228, 229, 229, 229, 230, 230,
948 230, 230, 231, 231, 231, 231, 232, 232, 232, 232,
949 233, 233, 233, 234, 234, 234, 235, 235, 235, 235,
950 235, 236, 236, 236, 237, 237, 238, 238, 239, 239,
951 240, 240, 241, 241, 242, 242, 243, 243, 244, 244,
952 245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
953 245, 246, 246, 247, 248, 248, 248, 249, 250, 250,
954 251, 251, 252, 253, 253, 254, 254, 254, 254, 255,
955 255, 255, 255, 256, 257, 257, 257, 257, 257, 257,
956 257, 258, 258, 258, 258, 258, 258, 258, 258, 259,
957 259, 260, 260, 261, 262, 262, 263, 264, 264, 264,
958 265, 266, 266, 266, 267, 267, 267, 267, 267, 267,
959 267, 267, 267, 268, 268, 269, 269, 269, 270, 270,
960 270, 271, 271, 271, 271, 271, 271, 271, 271, 271,
961 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
962 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
963 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
964 271, 271, 271, 271, 271, 271, 271, 271, 271, 271,
965 271, 271, 272, 272, 272, 273, 273, 274, 274, 275,
966 276, 276, 277, 277, 278, 279, 280, 280, 281, 281,
967 282, 283, 283, 283, 283, 283, 283, 283, 284, 284,
968 285, 285, 286, 286, 287, 287, 288, 288, 289, 290,
969 290, 290, 291, 291, 292, 293, 293, 294, 294, 294,
970 295, 295, 296, 296, 297, 297, 298, 298, 298, 298,
971 298, 299, 299, 300
972};
973
974/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
975static const yytype_uint8 yyr2[] =
976{
977 0, 2, 0, 4, 0, 3, 0, 2, 5, 1,
978 2, 1, 1, 1, 1, 1, 1, 3, 1, 4,
979 1, 3, 2, 2, 1, 1, 1, 3, 2, 2,
980 2, 1, 2, 3, 2, 1, 1, 1, 1, 2,
981 2, 2, 1, 1, 1, 1, 1, 3, 3, 3,
982 1, 3, 3, 1, 3, 3, 1, 3, 3, 3,
983 3, 1, 3, 3, 1, 3, 1, 3, 1, 3,
984 1, 3, 1, 3, 1, 3, 1, 5, 1, 3,
985 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
986 1, 1, 3, 1, 2, 2, 4, 2, 1, 1,
987 2, 3, 3, 2, 5, 3, 2, 3, 2, 0,
988 1, 1, 1, 1, 1, 3, 5, 6, 7, 8,
989 5, 1, 2, 4, 5, 6, 7, 4, 2, 1,
990 2, 0, 1, 4, 1, 3, 1, 1, 1, 1,
991 1, 1, 2, 2, 1, 1, 2, 2, 2, 1,
992 2, 2, 1, 1, 2, 1, 3, 4, 1, 1,
993 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
994 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
995 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
996 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
997 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
998 1, 1, 1, 1, 1, 5, 4, 1, 2, 3,
999 1, 3, 1, 4, 1, 1, 1, 1, 1, 1,
1000 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1001 1, 1, 2, 3, 1, 2, 1, 2, 7, 5,
1002 5, 7, 1, 4, 5, 3, 2, 5, 7, 6,
1003 1, 1, 1, 0, 2, 3, 2, 2, 2, 3,
1004 2, 1, 1, 2
1005};
1006
1007/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1008 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1009 means the default is an error. */
1010static const yytype_uint16 yydefact[] =
1011{
1012 4, 0, 0, 6, 0, 1, 2, 5, 0, 131,
1013 7, 0, 145, 144, 165, 162, 163, 164, 169, 170,
1014 171, 172, 173, 174, 175, 176, 177, 166, 167, 168,
1015 0, 149, 152, 139, 138, 137, 178, 179, 180, 181,
1016 182, 183, 184, 185, 186, 187, 188, 190, 191, 192,
1017 193, 195, 196, 197, 198, 199, 200, 201, 202, 203,
1018 204, 205, 206, 207, 208, 209, 210, 211, 0, 161,
1019 160, 131, 214, 213, 212, 0, 0, 189, 194, 131,
1020 272, 0, 0, 99, 109, 0, 114, 121, 0, 132,
1021 131, 0, 141, 129, 153, 155, 158, 0, 159, 9,
1022 271, 0, 150, 151, 147, 0, 0, 128, 131, 143,
1023 0, 0, 10, 94, 131, 273, 97, 109, 140, 110,
1024 111, 112, 100, 0, 109, 0, 95, 122, 148, 146,
1025 142, 130, 0, 154, 0, 0, 0, 0, 217, 0,
1026 136, 0, 134, 0, 0, 131, 0, 0, 0, 0,
1027 0, 0, 0, 0, 11, 15, 13, 14, 16, 37,
1028 0, 0, 0, 42, 43, 44, 45, 246, 131, 242,
1029 12, 18, 38, 20, 25, 26, 0, 0, 31, 0,
1030 46, 0, 50, 53, 56, 61, 64, 66, 68, 70,
1031 72, 74, 76, 78, 91, 0, 225, 0, 129, 231,
1032 244, 226, 227, 229, 228, 131, 232, 233, 230, 234,
1033 235, 236, 237, 101, 106, 108, 113, 0, 115, 102,
1034 0, 0, 156, 46, 93, 0, 35, 8, 0, 222,
1035 0, 220, 216, 218, 96, 133, 0, 267, 266, 0,
1036 131, 0, 270, 268, 0, 0, 0, 256, 131, 39,
1037 40, 0, 238, 131, 22, 23, 0, 0, 29, 28,
1038 0, 161, 32, 34, 81, 82, 84, 83, 86, 87,
1039 88, 89, 90, 85, 80, 0, 41, 0, 0, 0,
1040 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1041 0, 0, 0, 0, 0, 0, 0, 0, 247, 243,
1042 245, 103, 105, 107, 0, 0, 123, 0, 224, 127,
1043 157, 215, 0, 0, 219, 135, 0, 261, 260, 131,
1044 0, 269, 0, 255, 252, 0, 0, 17, 239, 0,
1045 24, 21, 27, 33, 79, 47, 48, 49, 51, 52,
1046 54, 55, 59, 60, 57, 58, 62, 63, 65, 67,
1047 69, 71, 73, 75, 0, 92, 0, 116, 0, 120,
1048 0, 124, 0, 221, 0, 262, 0, 0, 131, 0,
1049 0, 131, 19, 0, 0, 0, 117, 125, 0, 223,
1050 0, 264, 131, 249, 250, 254, 0, 0, 241, 257,
1051 240, 77, 104, 118, 0, 126, 0, 265, 259, 131,
1052 253, 0, 119, 258, 248, 251, 0, 131, 0, 131
1053};
1054
1055/* YYDEFGOTO[NTERM-NUM]. */
1056static const yytype_int16 yydefgoto[] =
1057{
1058 -1, 2, 9, 3, 6, 10, 79, 170, 171, 172,
1059 329, 173, 174, 175, 176, 177, 178, 179, 180, 181,
1060 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
1061 192, 193, 194, 275, 195, 225, 196, 197, 82, 83,
1062 84, 214, 122, 123, 215, 85, 86, 87, 88, 89,
1063 141, 142, 90, 124, 91, 92, 226, 94, 95, 96,
1064 97, 98, 137, 138, 230, 231, 309, 199, 200, 201,
1065 202, 203, 204, 389, 390, 205, 206, 207, 208, 326,
1066 209, 210, 211, 319, 366, 367, 212, 99, 100
1067};
1068
1069/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1070 STATE-NUM. */
1071#define YYPACT_NINF -345
1072static const yytype_int16 yypact[] =
1073{
1074 -30, 29, 120, -345, 15, -345, 22, -345, 59, 3758,
1075 -345, 25, -345, -345, -345, -345, -345, -345, -345, -345,
1076 -345, -345, -345, -345, -345, -345, -345, -345, -345, -345,
1077 79, -345, -345, -345, -345, -345, -345, -345, -345, -345,
1078 -345, -345, -345, -345, -345, -345, -345, -345, -345, -345,
1079 -345, -345, -345, -345, -345, -345, -345, -345, -345, -345,
1080 -345, -345, -345, -345, -345, -345, -345, -345, -71, -345,
1081 -345, 130, -345, -345, -345, -79, -42, -345, -345, 3642,
1082 -345, -5, -38, -32, 4, -181, -345, 87, 62, -345,
1083 27, 3871, -345, -345, -345, -25, -345, 3943, -345, -345,
1084 -345, 91, -345, -345, -345, -37, 3871, -345, 27, -345,
1085 3943, 95, -345, -345, 398, -345, -345, 19, -345, -345,
1086 -345, -345, -345, 3871, 0, 119, -345, -128, -345, -345,
1087 -345, -345, 2752, -345, 86, 3871, 131, 2153, -345, 11,
1088 -345, -87, -345, 21, 23, 1234, 40, 50, 36, 2379,
1089 63, 3286, 43, 64, -73, -345, -345, -345, -345, -345,
1090 3286, 3286, 3286, -345, -345, -345, -345, -345, 607, -345,
1091 -345, -345, -67, -345, -345, -345, 78, -62, 3464, 80,
1092 -53, 3286, -1, 20, 140, -80, 136, 66, 67, 65,
1093 182, 181, -82, -345, -345, -173, -345, 103, 125, -345,
1094 -345, -345, -345, -345, -345, 816, -345, -345, -345, -345,
1095 -345, -345, -345, -345, -345, -345, 198, 3871, -140, -345,
1096 2930, 3286, -345, -345, -345, 84, -345, -345, 2266, 124,
1097 -137, -345, -345, -345, -345, -345, 95, -345, -345, 240,
1098 1845, 3286, -345, -345, -118, 3286, -120, -345, 2574, -345,
1099 -345, -48, -345, 1025, -345, -345, 3286, 235, -345, -345,
1100 3286, 128, -345, -345, -345, -345, -345, -345, -345, -345,
1101 -345, -345, -345, -345, -345, 3286, -345, 3286, 3286, 3286,
1102 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286,
1103 3286, 3286, 3286, 3286, 3286, 3286, 3286, 3286, -345, -345,
1104 -345, 129, -345, -345, 3108, 3286, 110, 132, -345, -345,
1105 -345, -345, 3286, 131, -345, -345, 133, -345, -345, 2040,
1106 -46, -345, -36, -345, 127, 246, 135, -345, -345, 134,
1107 127, 138, -345, -345, -345, -345, -345, -345, -1, -1,
1108 20, 20, 140, 140, 140, 140, -80, -80, 136, 66,
1109 67, 65, 182, 181, -117, -345, 3286, 121, 137, -345,
1110 3286, 122, 141, -345, 3286, -345, 118, 142, 1234, 123,
1111 126, 1442, -345, 3286, 144, 3286, 139, -345, 3286, -345,
1112 -35, 3286, 1442, 324, -345, -345, 3286, 149, -345, -345,
1113 -345, -345, -345, -345, 3286, -345, 143, 127, -345, 1234,
1114 -345, 3286, -345, -345, -345, -345, -33, 1650, 326, 1650
1115};
1116
1117/* YYPGOTO[NTERM-NUM]. */
1118static const yytype_int16 yypgoto[] =
1119{
1120 -345, -345, -345, -345, -345, -345, -345, -345, -345, -345,
1121 -345, -345, -345, 85, -345, -345, -345, -345, -103, -345,
1122 -54, -47, -74, -40, 53, 54, 52, 55, 56, 51,
1123 -345, -110, -157, -345, -147, -219, 5, 7, -345, -345,
1124 -345, 146, 232, 227, 147, -345, -345, -238, -345, -345,
1125 -345, 117, -345, -345, -39, -345, -9, -14, -345, -345,
1126 279, -345, 220, -124, -345, 44, -286, 116, -134, -257,
1127 -344, -294, -11, -22, 280, 197, 145, -345, -345, 47,
1128 -345, -345, -345, -345, -345, -345, -345, 288, -345
1129};
1130
1131/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1132 positive, shift that token. If negative, reduce the rule which
1133 number is the opposite. If zero, do what YYDEFACT says.
1134 If YYTABLE_NINF, syntax error. */
1135#define YYTABLE_NINF -264
1136static const yytype_int16 yytable[] =
1137{
1138 93, 307, 244, -160, 246, 105, 284, 285, 118, 295,
1139 325, 239, 125, 233, 80, 251, 81, 254, 255, 359,
1140 297, 262, 224, 118, 384, 72, 73, 74, 126, 223,
1141 12, 13, 109, 119, 120, 121, 298, 119, 120, 121,
1142 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
1143 304, 130, 119, 120, 121, 405, 313, 249, 250, 30,
1144 219, 31, 220, 32, 308, 33, 34, 35, 305, 109,
1145 93, 300, 314, 297, 377, 297, 297, 388, 276, 1,
1146 221, 325, 131, 133, 80, 358, 81, 323, 388, 393,
1147 373, 321, 395, 362, 320, 128, 139, 136, 322, 129,
1148 400, 324, 235, 333, 233, 198, 236, 4, 402, 330,
1149 224, 383, 102, 103, 216, -36, 104, 223, 334, 300,
1150 5, 286, 287, 256, 296, 257, 136, 259, 136, 7,
1151 108, 260, 8, 12, 13, 11, 198, 374, 101, 106,
1152 355, 327, 404, 368, 76, 297, 111, 297, 308, 354,
1153 408, 116, 404, 369, 396, 274, 407, 297, 297, 198,
1154 297, 117, 30, 127, 31, 132, 32, 134, 33, 34,
1155 35, 140, 324, 135, 335, 336, 337, 223, 223, 223,
1156 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
1157 223, 223, 223, -98, 224, 218, 198, 277, 278, 279,
1158 227, 223, 224, 308, 113, 114, 107, 229, 216, 223,
1159 342, 343, 344, 345, 280, 281, 391, 380, 308, 136,
1160 234, 308, 282, 283, 288, 289, 338, 339, 240, 308,
1161 237, 198, 238, 108, 397, 340, 341, 308, 241, 198,
1162 14, 15, 16, 17, 198, 242, 224, 76, 346, 347,
1163 247, 245, 248, 223, 406, 18, 19, 20, 21, 22,
1164 23, 24, 25, 26, 27, 28, 29, 258, 263, 290,
1165 292, 291, 293, 294, 301, 310, 36, 37, 38, 39,
1166 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1167 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1168 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1169 198, 331, 113, -35, 312, 316, 159, -30, 360, 356,
1170 297, 364, 370, 361, 371, 372, -36, 381, 376, 375,
1171 378, 382, 379, 168, 386, 392, 399, 401, 409, 72,
1172 73, 74, 332, 348, 350, 349, 353, 394, 351, 213,
1173 352, 217, 403, 315, 110, 228, 317, 363, 385, 198,
1174 398, 115, 198, 302, 303, 253, 365, 112, 0, 0,
1175 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1176 0, 0, 0, 0, 0, 318, 77, 0, 78, 0,
1177 198, 0, 0, 0, 0, 0, 0, 0, 198, 0,
1178 198, 12, 13, 14, 15, 16, 17, 143, 144, 145,
1179 0, 146, 147, 148, 149, 150, 151, 152, 18, 19,
1180 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
1181 30, 0, 31, 0, 32, 0, 33, 34, 35, 36,
1182 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1183 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1184 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1185 67, 68, 69, 153, 154, 155, 156, 157, 158, 159,
1186 0, 0, 160, 161, 0, 0, 0, 0, 0, 0,
1187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1188 0, 71, 72, 73, 74, 0, 75, 0, 0, 0,
1189 0, 0, 0, 0, 0, 76, 0, 0, 0, 0,
1190 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1191 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1192 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
1193 0, 78, 0, 0, 0, 0, 0, 0, 0, 0,
1194 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1195 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1196 0, 0, 0, 0, 0, 0, 162, 0, 0, 0,
1197 0, 0, 163, 164, 165, 166, 0, 0, 0, 0,
1198 0, 0, 0, 0, 0, 0, 0, 167, 168, 169,
1199 12, 13, 14, 15, 16, 17, 143, 144, 145, 0,
1200 146, 147, 148, 149, 150, 151, 152, 18, 19, 20,
1201 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
1202 0, 31, 0, 32, 0, 33, 34, 35, 36, 37,
1203 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1204 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1205 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1206 68, 69, 153, 154, 155, 156, 157, 158, 159, 0,
1207 0, 160, 161, 0, 0, 0, 0, 0, 0, 0,
1208 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1209 71, 72, 73, 74, 0, 75, 0, 0, 0, 0,
1210 0, 0, 0, 0, 76, 0, 0, 0, 0, 0,
1211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1213 0, 0, 0, 0, 0, 0, 0, 0, 77, 0,
1214 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1215 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1216 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1217 0, 0, 0, 0, 0, 162, 0, 0, 0, 0,
1218 0, 163, 164, 165, 166, 0, 0, 0, 0, 0,
1219 0, 0, 0, 0, 0, 0, 167, 168, 252, 12,
1220 13, 14, 15, 16, 17, 143, 144, 145, 0, 146,
1221 147, 148, 149, 150, 151, 152, 18, 19, 20, 21,
1222 22, 23, 24, 25, 26, 27, 28, 29, 30, 0,
1223 31, 0, 32, 0, 33, 34, 35, 36, 37, 38,
1224 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1225 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1226 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1227 69, 153, 154, 155, 156, 157, 158, 159, 0, 0,
1228 160, 161, 0, 0, 0, 0, 0, 0, 0, 0,
1229 0, 0, 0, 0, 0, 0, 0, 0, 0, 71,
1230 72, 73, 74, 0, 75, 0, 0, 0, 0, 0,
1231 0, 0, 0, 76, 0, 0, 0, 0, 0, 0,
1232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1233 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1234 0, 0, 0, 0, 0, 0, 0, 77, 0, 78,
1235 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1236 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1237 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1238 0, 0, 0, 0, 162, 0, 0, 0, 0, 0,
1239 163, 164, 165, 166, 0, 0, 0, 0, 0, 0,
1240 0, 0, 0, 0, 0, 167, 168, 299, 12, 13,
1241 14, 15, 16, 17, 143, 144, 145, 0, 146, 147,
1242 148, 149, 150, 151, 152, 18, 19, 20, 21, 22,
1243 23, 24, 25, 26, 27, 28, 29, 30, 0, 31,
1244 0, 32, 0, 33, 34, 35, 36, 37, 38, 39,
1245 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1246 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1247 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1248 153, 154, 155, 156, 157, 158, 159, 0, 0, 160,
1249 161, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1250 0, 0, 0, 0, 0, 0, 0, 0, 71, 72,
1251 73, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1252 0, 0, 76, 0, 0, 0, 0, 0, 0, 0,
1253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1254 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1255 0, 0, 0, 0, 0, 0, 77, 0, 78, 0,
1256 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1258 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1259 0, 0, 0, 162, 0, 0, 0, 0, 0, 163,
1260 164, 165, 166, 0, 0, 0, 0, 0, 0, 0,
1261 0, 0, 0, 0, 167, 168, 328, 12, 13, 14,
1262 15, 16, 17, 143, 144, 145, 0, 146, 147, 148,
1263 149, 150, 151, 152, 18, 19, 20, 21, 22, 23,
1264 24, 25, 26, 27, 28, 29, 30, 0, 31, 0,
1265 32, 0, 33, 34, 35, 36, 37, 38, 39, 40,
1266 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1267 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1268 61, 62, 63, 64, 65, 66, 67, 68, 69, 153,
1269 154, 155, 156, 157, 158, 159, 0, 0, 160, 161,
1270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1271 0, 0, 0, 0, 0, 0, 0, 71, 72, 73,
1272 74, 0, 75, 0, 0, 0, 0, 0, 0, 0,
1273 0, 76, 0, 0, 0, 0, 0, 0, 0, 0,
1274 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1275 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1276 0, 0, 0, 0, 0, 77, 0, 78, 0, 0,
1277 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1278 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1279 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1280 0, 0, 162, 0, 0, 0, 0, 0, 163, 164,
1281 165, 166, 0, 0, 0, 0, 0, 0, 0, 0,
1282 0, 0, 0, 167, 168, 12, 13, 14, 15, 16,
1283 17, 143, 144, 145, 0, 146, 387, 148, 149, 150,
1284 151, 152, 18, 19, 20, 21, 22, 23, 24, 25,
1285 26, 27, 28, 29, 30, 0, 31, 0, 32, 0,
1286 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
1287 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
1288 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1289 63, 64, 65, 66, 67, 68, 69, 153, 154, 155,
1290 156, 157, 158, 159, 0, 0, 160, 161, 0, 0,
1291 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1292 0, 0, 0, 0, 0, 71, 72, 73, 74, 0,
1293 75, 0, 0, 0, 0, 0, 0, 0, 0, 76,
1294 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1295 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1296 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1297 0, 0, 0, 77, 0, 78, 0, 0, 0, 0,
1298 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1301 162, 0, 0, 0, 0, 0, 163, 164, 165, 166,
1302 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1303 0, 167, 114, 12, 13, 14, 15, 16, 17, 143,
1304 144, 145, 0, 146, 387, 148, 149, 150, 151, 152,
1305 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1306 28, 29, 30, 0, 31, 0, 32, 0, 33, 34,
1307 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1308 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1309 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1310 65, 66, 67, 68, 69, 153, 154, 155, 156, 157,
1311 158, 159, 0, 0, 160, 161, 0, 0, 0, 0,
1312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1313 0, 0, 0, 71, 72, 73, 74, 0, 75, 0,
1314 0, 0, 0, 0, 0, 0, 0, 76, 0, 0,
1315 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1316 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1317 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1318 0, 77, 0, 78, 0, 0, 0, 0, 0, 0,
1319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1321 0, 0, 0, 0, 0, 0, 0, 0, 162, 0,
1322 0, 0, 0, 0, 163, 164, 165, 166, 12, 13,
1323 14, 15, 16, 17, 0, 0, 0, 0, 0, 167,
1324 168, 0, 0, 0, 0, 18, 19, 20, 21, 22,
1325 23, 24, 25, 26, 27, 28, 29, 30, 0, 31,
1326 0, 32, 0, 33, 34, 35, 36, 37, 38, 39,
1327 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1328 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1329 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1330 0, 154, 155, 156, 157, 158, 159, 0, 0, 160,
1331 161, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1332 0, 0, 0, 0, 0, 0, 0, 0, 71, 72,
1333 73, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1334 0, 0, 76, 0, 0, 0, 0, 0, 0, 0,
1335 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1337 0, 0, 0, 0, 0, 0, 77, 0, 78, 0,
1338 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1341 0, 0, 0, 162, 0, 0, 0, 0, 0, 163,
1342 164, 165, 166, 12, 13, 14, 15, 16, 17, 0,
1343 0, 0, 0, 0, 167, 0, 0, 0, 0, 0,
1344 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1345 28, 29, 30, 0, 31, 0, 32, 0, 33, 34,
1346 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1347 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1348 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1349 65, 66, 67, 68, 69, 0, 154, 155, 156, 157,
1350 158, 159, 0, 0, 160, 161, 0, 0, 0, 0,
1351 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1352 0, 0, 0, 108, 72, 73, 74, 0, 0, 0,
1353 0, 0, 0, 0, 0, 0, 0, 76, 14, 15,
1354 16, 17, 0, 0, 0, 0, 0, 0, 0, 0,
1355 0, 0, 0, 18, 19, 20, 21, 22, 23, 24,
1356 25, 26, 27, 28, 29, 0, 0, 0, 0, 0,
1357 0, 77, 0, 78, 36, 37, 38, 39, 40, 41,
1358 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
1359 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1360 62, 63, 64, 65, 66, 67, 68, 69, 162, 70,
1361 0, 0, 0, 0, 163, 164, 165, 166, 0, 0,
1362 0, 0, 0, 0, 0, 0, 0, 0, 0, -263,
1363 0, 0, 0, 0, 0, 0, 0, 72, 73, 74,
1364 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1365 0, 14, 15, 16, 17, 0, 0, 0, 0, 0,
1366 0, 0, 0, 0, 0, 0, 18, 19, 20, 21,
1367 22, 23, 24, 25, 26, 27, 28, 29, 0, 0,
1368 0, 0, 0, 0, 77, 0, 78, 36, 37, 38,
1369 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1370 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1371 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1372 69, 0, 70, 0, 0, 0, 0, 0, 0, 0,
1373 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1374 0, 0, 0, 0, 232, 0, 0, 0, 0, 0,
1375 72, 73, 74, 0, 0, 0, 0, 0, 0, 0,
1376 0, 0, 0, 0, 14, 15, 16, 17, 0, 0,
1377 0, 0, 0, 0, 0, 0, 0, 0, 0, 18,
1378 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
1379 29, 0, 0, 0, 0, 0, 0, 77, 0, 78,
1380 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
1381 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
1382 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1383 66, 67, 68, 69, 0, 154, 155, 156, 157, 158,
1384 159, 0, 0, 160, 161, 0, 0, 0, 0, 0,
1385 0, 0, 0, 0, 0, 0, 0, 311, 0, 0,
1386 0, 0, 0, 72, 73, 74, 0, 0, 0, 0,
1387 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1388 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1389 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1390 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1391 77, 0, 78, 0, 0, 0, 0, 0, 0, 0,
1392 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1393 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1394 0, 0, 0, 0, 0, 0, 0, 162, 0, 0,
1395 0, 0, 0, 163, 164, 165, 166, 12, 13, 14,
1396 15, 16, 17, 0, 0, 0, 0, 0, 243, 0,
1397 0, 0, 0, 0, 18, 19, 20, 21, 22, 23,
1398 24, 25, 26, 27, 28, 29, 30, 0, 31, 0,
1399 32, 0, 33, 34, 35, 36, 37, 38, 39, 40,
1400 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1401 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1402 61, 62, 63, 64, 65, 66, 67, 68, 69, 0,
1403 154, 155, 156, 157, 158, 159, 0, 0, 160, 161,
1404 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1405 0, 0, 0, 0, 0, 0, 0, 108, 72, 73,
1406 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1407 0, 76, 0, 0, 0, 0, 0, 0, 0, 0,
1408 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1409 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1410 0, 0, 0, 0, 0, 77, 0, 78, 0, 0,
1411 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1412 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1413 0, 0, 0, 0, 0, 0, 0, 14, 15, 16,
1414 17, 0, 162, 0, 0, 0, 0, 0, 163, 164,
1415 165, 166, 18, 19, 20, 21, 22, 23, 24, 25,
1416 26, 27, 28, 29, 0, 0, 0, 0, 0, 0,
1417 0, 0, 0, 36, 37, 38, 39, 40, 41, 42,
1418 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
1419 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1420 63, 64, 65, 66, 67, 68, 69, 0, 154, 155,
1421 156, 157, 158, 159, 0, 0, 160, 161, 0, 0,
1422 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1423 0, 0, 0, 0, 0, 0, 72, 73, 74, 0,
1424 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1425 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1426 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1427 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1428 0, 0, 0, 77, 0, 78, 0, 0, 0, 0,
1429 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1430 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1431 0, 0, 0, 0, 0, 14, 15, 16, 17, 0,
1432 162, 0, 0, 222, 0, 0, 163, 164, 165, 166,
1433 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1434 28, 29, 0, 0, 0, 0, 0, 0, 0, 0,
1435 0, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1436 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1437 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1438 65, 66, 67, 68, 69, 0, 154, 155, 156, 157,
1439 158, 159, 0, 0, 160, 161, 0, 0, 0, 0,
1440 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1441 0, 0, 0, 0, 72, 73, 74, 0, 0, 0,
1442 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1443 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1444 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1446 0, 77, 0, 78, 0, 0, 0, 0, 0, 0,
1447 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1448 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1449 0, 0, 0, 14, 15, 16, 17, 0, 162, 0,
1450 0, 306, 0, 0, 163, 164, 165, 166, 18, 19,
1451 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
1452 0, 0, 0, 0, 0, 0, 0, 0, 0, 36,
1453 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1454 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1455 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1456 67, 68, 69, 0, 154, 155, 156, 157, 158, 159,
1457 0, 0, 160, 161, 0, 0, 0, 0, 0, 0,
1458 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1459 0, 0, 72, 73, 74, 0, 0, 0, 0, 0,
1460 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1461 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1462 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1463 0, 0, 0, 0, 0, 0, 0, 0, 0, 77,
1464 0, 78, 0, 0, 0, 0, 0, 0, 0, 0,
1465 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1466 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1467 0, 14, 15, 16, 17, 0, 162, 0, 0, 357,
1468 0, 0, 163, 164, 165, 166, 18, 19, 20, 21,
1469 22, 23, 24, 25, 26, 27, 28, 29, 0, 0,
1470 0, 0, 0, 0, 0, 0, 0, 36, 37, 38,
1471 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1472 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1473 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1474 69, 0, 154, 155, 156, 157, 158, 159, 0, 0,
1475 160, 161, 0, 0, 0, 0, 0, 0, 0, 0,
1476 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1477 72, 73, 74, 0, 0, 0, 0, 0, 0, 0,
1478 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1479 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1480 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1481 0, 0, 0, 0, 0, 0, 0, 77, 0, 78,
1482 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1483 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1484 0, 0, 0, 0, 0, 0, 0, 0, 0, 14,
1485 15, 16, 17, 0, 162, 0, 0, 0, 0, 0,
1486 163, 164, 165, 166, 18, 19, 20, 21, 22, 23,
1487 24, 25, 26, 27, 28, 29, 0, 0, 0, 0,
1488 0, 0, 0, 0, 0, 36, 37, 38, 39, 40,
1489 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1490 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1491 61, 62, 63, 64, 65, 66, 67, 68, 261, 0,
1492 154, 155, 156, 157, 158, 159, 0, 0, 160, 161,
1493 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1494 0, 0, 0, 0, 0, 0, 0, 0, 72, 73,
1495 74, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1496 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1497 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1498 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1499 0, 0, 0, 0, 0, 77, 0, 78, 0, 0,
1500 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1501 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1502 0, 0, -3, 0, 0, 12, 13, 14, 15, 16,
1503 17, 0, 162, 0, 0, 0, 0, 0, 163, 164,
1504 165, 166, 18, 19, 20, 21, 22, 23, 24, 25,
1505 26, 27, 28, 29, 30, 0, 31, 0, 32, 0,
1506 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
1507 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
1508 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1509 63, 64, 65, 66, 67, 68, 69, 0, 70, 0,
1510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1512 0, 0, 0, 0, 0, 71, 72, 73, 74, 0,
1513 75, 0, 0, 0, 0, 0, 0, 0, 0, 76,
1514 0, 12, 13, 14, 15, 16, 17, 0, 0, 0,
1515 0, 0, 0, 0, 0, 0, 0, 0, 18, 19,
1516 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
1517 30, 0, 31, 77, 32, 78, 33, 34, 35, 36,
1518 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1519 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1520 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1521 67, 68, 69, 0, 70, 0, 0, 0, 0, 0,
1522 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1523 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1524 0, 71, 72, 73, 74, 0, 75, 0, 0, 0,
1525 0, 0, 0, 0, 0, 76, 14, 15, 16, 17,
1526 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1527 0, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1528 27, 28, 29, 0, 0, 0, 0, 0, 0, 77,
1529 0, 78, 36, 37, 38, 39, 40, 41, 42, 43,
1530 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
1531 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
1532 64, 65, 66, 67, 68, 69, 0, 70, 14, 15,
1533 16, 17, 0, 0, 0, 0, 0, 0, 0, 0,
1534 0, 0, 0, 18, 19, 20, 21, 22, 23, 24,
1535 25, 26, 27, 28, 29, 72, 73, 74, 0, 0,
1536 0, 0, 0, 0, 36, 37, 38, 39, 40, 41,
1537 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
1538 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1539 62, 63, 64, 65, 66, 67, 68, 69, 0, 70,
1540 0, 0, 77, 0, 78, 0, 0, 0, 0, 0,
1541 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1542 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1543 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1544 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1545 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1546 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1547 0, 0, 0, 0, 77, 0, 78
1548};
1549
1550static const yytype_int16 yycheck[] =
1551{
1552 9, 220, 149, 76, 151, 76, 86, 87, 4, 91,
1553 248, 145, 193, 137, 9, 162, 9, 84, 85, 305,
1554 193, 178, 132, 4, 368, 104, 105, 106, 209, 132,
1555 3, 4, 71, 33, 34, 35, 209, 33, 34, 35,
1556 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
1557 190, 90, 33, 34, 35, 399, 193, 160, 161, 32,
1558 188, 34, 190, 36, 221, 38, 39, 40, 208, 108,
1559 79, 205, 209, 193, 360, 193, 193, 371, 181, 109,
1560 208, 319, 91, 97, 79, 304, 79, 207, 382, 375,
1561 207, 209, 378, 312, 241, 33, 110, 106, 245, 37,
1562 386, 248, 189, 260, 228, 114, 193, 78, 394, 256,
1563 220, 368, 33, 34, 123, 188, 37, 220, 275, 253,
1564 0, 201, 202, 190, 206, 192, 135, 189, 137, 114,
1565 103, 193, 110, 3, 4, 76, 145, 356, 113, 210,
1566 297, 189, 399, 189, 117, 193, 188, 193, 305, 296,
1567 407, 189, 409, 189, 189, 208, 189, 193, 193, 168,
1568 193, 193, 32, 76, 34, 190, 36, 76, 38, 39,
1569 40, 76, 319, 210, 277, 278, 279, 280, 281, 282,
1570 283, 284, 285, 286, 287, 288, 289, 290, 291, 292,
1571 293, 294, 295, 189, 304, 76, 205, 198, 199, 200,
1572 114, 304, 312, 360, 209, 210, 76, 76, 217, 312,
1573 284, 285, 286, 287, 194, 195, 373, 364, 375, 228,
1574 209, 378, 82, 83, 88, 89, 280, 281, 188, 386,
1575 209, 240, 209, 103, 381, 282, 283, 394, 188, 248,
1576 5, 6, 7, 8, 253, 209, 356, 117, 288, 289,
1577 207, 188, 188, 356, 401, 20, 21, 22, 23, 24,
1578 25, 26, 27, 28, 29, 30, 31, 189, 188, 203,
1579 205, 204, 90, 92, 76, 191, 41, 42, 43, 44,
1580 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1581 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1582 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1583 319, 76, 209, 188, 190, 75, 81, 189, 208, 190,
1584 193, 188, 76, 191, 189, 191, 188, 209, 191, 208,
1585 208, 189, 191, 210, 208, 191, 12, 188, 12, 104,
1586 105, 106, 257, 290, 292, 291, 295, 208, 293, 117,
1587 294, 124, 209, 236, 75, 135, 240, 313, 369, 368,
1588 382, 81, 371, 217, 217, 168, 319, 79, -1, -1,
1589 -1, -1, -1, 382, -1, -1, -1, -1, -1, -1,
1590 -1, -1, -1, -1, -1, 240, 151, -1, 153, -1,
1591 399, -1, -1, -1, -1, -1, -1, -1, 407, -1,
1592 409, 3, 4, 5, 6, 7, 8, 9, 10, 11,
1593 -1, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1594 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
1595 32, -1, 34, -1, 36, -1, 38, 39, 40, 41,
1596 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
1597 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1598 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
1599 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1600 -1, -1, 84, 85, -1, -1, -1, -1, -1, -1,
1601 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1602 -1, 103, 104, 105, 106, -1, 108, -1, -1, -1,
1603 -1, -1, -1, -1, -1, 117, -1, -1, -1, -1,
1604 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1605 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1606 -1, -1, -1, -1, -1, -1, -1, -1, -1, 151,
1607 -1, 153, -1, -1, -1, -1, -1, -1, -1, -1,
1608 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1609 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1610 -1, -1, -1, -1, -1, -1, 188, -1, -1, -1,
1611 -1, -1, 194, 195, 196, 197, -1, -1, -1, -1,
1612 -1, -1, -1, -1, -1, -1, -1, 209, 210, 211,
1613 3, 4, 5, 6, 7, 8, 9, 10, 11, -1,
1614 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1615 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
1616 -1, 34, -1, 36, -1, 38, 39, 40, 41, 42,
1617 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
1618 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1619 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
1620 73, 74, 75, 76, 77, 78, 79, 80, 81, -1,
1621 -1, 84, 85, -1, -1, -1, -1, -1, -1, -1,
1622 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1623 103, 104, 105, 106, -1, 108, -1, -1, -1, -1,
1624 -1, -1, -1, -1, 117, -1, -1, -1, -1, -1,
1625 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1626 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1627 -1, -1, -1, -1, -1, -1, -1, -1, 151, -1,
1628 153, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1629 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1630 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1631 -1, -1, -1, -1, -1, 188, -1, -1, -1, -1,
1632 -1, 194, 195, 196, 197, -1, -1, -1, -1, -1,
1633 -1, -1, -1, -1, -1, -1, 209, 210, 211, 3,
1634 4, 5, 6, 7, 8, 9, 10, 11, -1, 13,
1635 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
1636 24, 25, 26, 27, 28, 29, 30, 31, 32, -1,
1637 34, -1, 36, -1, 38, 39, 40, 41, 42, 43,
1638 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
1639 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
1640 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
1641 74, 75, 76, 77, 78, 79, 80, 81, -1, -1,
1642 84, 85, -1, -1, -1, -1, -1, -1, -1, -1,
1643 -1, -1, -1, -1, -1, -1, -1, -1, -1, 103,
1644 104, 105, 106, -1, 108, -1, -1, -1, -1, -1,
1645 -1, -1, -1, 117, -1, -1, -1, -1, -1, -1,
1646 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1647 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1648 -1, -1, -1, -1, -1, -1, -1, 151, -1, 153,
1649 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1650 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1651 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1652 -1, -1, -1, -1, 188, -1, -1, -1, -1, -1,
1653 194, 195, 196, 197, -1, -1, -1, -1, -1, -1,
1654 -1, -1, -1, -1, -1, 209, 210, 211, 3, 4,
1655 5, 6, 7, 8, 9, 10, 11, -1, 13, 14,
1656 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1657 25, 26, 27, 28, 29, 30, 31, 32, -1, 34,
1658 -1, 36, -1, 38, 39, 40, 41, 42, 43, 44,
1659 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1660 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1661 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1662 75, 76, 77, 78, 79, 80, 81, -1, -1, 84,
1663 85, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1664 -1, -1, -1, -1, -1, -1, -1, -1, 103, 104,
1665 105, 106, -1, 108, -1, -1, -1, -1, -1, -1,
1666 -1, -1, 117, -1, -1, -1, -1, -1, -1, -1,
1667 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1668 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1669 -1, -1, -1, -1, -1, -1, 151, -1, 153, -1,
1670 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1671 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1672 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1673 -1, -1, -1, 188, -1, -1, -1, -1, -1, 194,
1674 195, 196, 197, -1, -1, -1, -1, -1, -1, -1,
1675 -1, -1, -1, -1, 209, 210, 211, 3, 4, 5,
1676 6, 7, 8, 9, 10, 11, -1, 13, 14, 15,
1677 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
1678 26, 27, 28, 29, 30, 31, 32, -1, 34, -1,
1679 36, -1, 38, 39, 40, 41, 42, 43, 44, 45,
1680 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
1681 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1682 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1683 76, 77, 78, 79, 80, 81, -1, -1, 84, 85,
1684 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1685 -1, -1, -1, -1, -1, -1, -1, 103, 104, 105,
1686 106, -1, 108, -1, -1, -1, -1, -1, -1, -1,
1687 -1, 117, -1, -1, -1, -1, -1, -1, -1, -1,
1688 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1689 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1690 -1, -1, -1, -1, -1, 151, -1, 153, -1, -1,
1691 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1692 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1693 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1694 -1, -1, 188, -1, -1, -1, -1, -1, 194, 195,
1695 196, 197, -1, -1, -1, -1, -1, -1, -1, -1,
1696 -1, -1, -1, 209, 210, 3, 4, 5, 6, 7,
1697 8, 9, 10, 11, -1, 13, 14, 15, 16, 17,
1698 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1699 28, 29, 30, 31, 32, -1, 34, -1, 36, -1,
1700 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1701 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1702 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1703 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1704 78, 79, 80, 81, -1, -1, 84, 85, -1, -1,
1705 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1706 -1, -1, -1, -1, -1, 103, 104, 105, 106, -1,
1707 108, -1, -1, -1, -1, -1, -1, -1, -1, 117,
1708 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1709 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1710 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1711 -1, -1, -1, 151, -1, 153, -1, -1, -1, -1,
1712 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1713 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1714 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1715 188, -1, -1, -1, -1, -1, 194, 195, 196, 197,
1716 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1717 -1, 209, 210, 3, 4, 5, 6, 7, 8, 9,
1718 10, 11, -1, 13, 14, 15, 16, 17, 18, 19,
1719 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
1720 30, 31, 32, -1, 34, -1, 36, -1, 38, 39,
1721 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1722 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1723 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1724 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1725 80, 81, -1, -1, 84, 85, -1, -1, -1, -1,
1726 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1727 -1, -1, -1, 103, 104, 105, 106, -1, 108, -1,
1728 -1, -1, -1, -1, -1, -1, -1, 117, -1, -1,
1729 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1730 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1731 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1732 -1, 151, -1, 153, -1, -1, -1, -1, -1, -1,
1733 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1734 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1735 -1, -1, -1, -1, -1, -1, -1, -1, 188, -1,
1736 -1, -1, -1, -1, 194, 195, 196, 197, 3, 4,
1737 5, 6, 7, 8, -1, -1, -1, -1, -1, 209,
1738 210, -1, -1, -1, -1, 20, 21, 22, 23, 24,
1739 25, 26, 27, 28, 29, 30, 31, 32, -1, 34,
1740 -1, 36, -1, 38, 39, 40, 41, 42, 43, 44,
1741 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1742 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1743 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1744 -1, 76, 77, 78, 79, 80, 81, -1, -1, 84,
1745 85, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1746 -1, -1, -1, -1, -1, -1, -1, -1, 103, 104,
1747 105, 106, -1, 108, -1, -1, -1, -1, -1, -1,
1748 -1, -1, 117, -1, -1, -1, -1, -1, -1, -1,
1749 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1750 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1751 -1, -1, -1, -1, -1, -1, 151, -1, 153, -1,
1752 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1753 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1754 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1755 -1, -1, -1, 188, -1, -1, -1, -1, -1, 194,
1756 195, 196, 197, 3, 4, 5, 6, 7, 8, -1,
1757 -1, -1, -1, -1, 209, -1, -1, -1, -1, -1,
1758 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
1759 30, 31, 32, -1, 34, -1, 36, -1, 38, 39,
1760 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1761 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1762 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1763 70, 71, 72, 73, 74, -1, 76, 77, 78, 79,
1764 80, 81, -1, -1, 84, 85, -1, -1, -1, -1,
1765 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1766 -1, -1, -1, 103, 104, 105, 106, -1, -1, -1,
1767 -1, -1, -1, -1, -1, -1, -1, 117, 5, 6,
1768 7, 8, -1, -1, -1, -1, -1, -1, -1, -1,
1769 -1, -1, -1, 20, 21, 22, 23, 24, 25, 26,
1770 27, 28, 29, 30, 31, -1, -1, -1, -1, -1,
1771 -1, 151, -1, 153, 41, 42, 43, 44, 45, 46,
1772 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1773 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1774 67, 68, 69, 70, 71, 72, 73, 74, 188, 76,
1775 -1, -1, -1, -1, 194, 195, 196, 197, -1, -1,
1776 -1, -1, -1, -1, -1, -1, -1, -1, -1, 209,
1777 -1, -1, -1, -1, -1, -1, -1, 104, 105, 106,
1778 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1779 -1, 5, 6, 7, 8, -1, -1, -1, -1, -1,
1780 -1, -1, -1, -1, -1, -1, 20, 21, 22, 23,
1781 24, 25, 26, 27, 28, 29, 30, 31, -1, -1,
1782 -1, -1, -1, -1, 151, -1, 153, 41, 42, 43,
1783 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
1784 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
1785 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
1786 74, -1, 76, -1, -1, -1, -1, -1, -1, -1,
1787 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1788 -1, -1, -1, -1, 211, -1, -1, -1, -1, -1,
1789 104, 105, 106, -1, -1, -1, -1, -1, -1, -1,
1790 -1, -1, -1, -1, 5, 6, 7, 8, -1, -1,
1791 -1, -1, -1, -1, -1, -1, -1, -1, -1, 20,
1792 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
1793 31, -1, -1, -1, -1, -1, -1, 151, -1, 153,
1794 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1795 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
1796 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
1797 71, 72, 73, 74, -1, 76, 77, 78, 79, 80,
1798 81, -1, -1, 84, 85, -1, -1, -1, -1, -1,
1799 -1, -1, -1, -1, -1, -1, -1, 211, -1, -1,
1800 -1, -1, -1, 104, 105, 106, -1, -1, -1, -1,
1801 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1802 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1804 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1805 151, -1, 153, -1, -1, -1, -1, -1, -1, -1,
1806 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1807 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1808 -1, -1, -1, -1, -1, -1, -1, 188, -1, -1,
1809 -1, -1, -1, 194, 195, 196, 197, 3, 4, 5,
1810 6, 7, 8, -1, -1, -1, -1, -1, 209, -1,
1811 -1, -1, -1, -1, 20, 21, 22, 23, 24, 25,
1812 26, 27, 28, 29, 30, 31, 32, -1, 34, -1,
1813 36, -1, 38, 39, 40, 41, 42, 43, 44, 45,
1814 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
1815 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1816 66, 67, 68, 69, 70, 71, 72, 73, 74, -1,
1817 76, 77, 78, 79, 80, 81, -1, -1, 84, 85,
1818 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1819 -1, -1, -1, -1, -1, -1, -1, 103, 104, 105,
1820 106, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1821 -1, 117, -1, -1, -1, -1, -1, -1, -1, -1,
1822 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1823 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1824 -1, -1, -1, -1, -1, 151, -1, 153, -1, -1,
1825 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1826 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1827 -1, -1, -1, -1, -1, -1, -1, 5, 6, 7,
1828 8, -1, 188, -1, -1, -1, -1, -1, 194, 195,
1829 196, 197, 20, 21, 22, 23, 24, 25, 26, 27,
1830 28, 29, 30, 31, -1, -1, -1, -1, -1, -1,
1831 -1, -1, -1, 41, 42, 43, 44, 45, 46, 47,
1832 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1833 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1834 68, 69, 70, 71, 72, 73, 74, -1, 76, 77,
1835 78, 79, 80, 81, -1, -1, 84, 85, -1, -1,
1836 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1837 -1, -1, -1, -1, -1, -1, 104, 105, 106, -1,
1838 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1839 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1840 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1841 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1842 -1, -1, -1, 151, -1, 153, -1, -1, -1, -1,
1843 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1844 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1845 -1, -1, -1, -1, -1, 5, 6, 7, 8, -1,
1846 188, -1, -1, 191, -1, -1, 194, 195, 196, 197,
1847 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
1848 30, 31, -1, -1, -1, -1, -1, -1, -1, -1,
1849 -1, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1850 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1851 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1852 70, 71, 72, 73, 74, -1, 76, 77, 78, 79,
1853 80, 81, -1, -1, 84, 85, -1, -1, -1, -1,
1854 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1855 -1, -1, -1, -1, 104, 105, 106, -1, -1, -1,
1856 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1857 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1858 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1859 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1860 -1, 151, -1, 153, -1, -1, -1, -1, -1, -1,
1861 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1862 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1863 -1, -1, -1, 5, 6, 7, 8, -1, 188, -1,
1864 -1, 191, -1, -1, 194, 195, 196, 197, 20, 21,
1865 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
1866 -1, -1, -1, -1, -1, -1, -1, -1, -1, 41,
1867 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
1868 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1869 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
1870 72, 73, 74, -1, 76, 77, 78, 79, 80, 81,
1871 -1, -1, 84, 85, -1, -1, -1, -1, -1, -1,
1872 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1873 -1, -1, 104, 105, 106, -1, -1, -1, -1, -1,
1874 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1875 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1876 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1877 -1, -1, -1, -1, -1, -1, -1, -1, -1, 151,
1878 -1, 153, -1, -1, -1, -1, -1, -1, -1, -1,
1879 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1880 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1881 -1, 5, 6, 7, 8, -1, 188, -1, -1, 191,
1882 -1, -1, 194, 195, 196, 197, 20, 21, 22, 23,
1883 24, 25, 26, 27, 28, 29, 30, 31, -1, -1,
1884 -1, -1, -1, -1, -1, -1, -1, 41, 42, 43,
1885 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
1886 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
1887 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
1888 74, -1, 76, 77, 78, 79, 80, 81, -1, -1,
1889 84, 85, -1, -1, -1, -1, -1, -1, -1, -1,
1890 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1891 104, 105, 106, -1, -1, -1, -1, -1, -1, -1,
1892 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1893 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1894 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1895 -1, -1, -1, -1, -1, -1, -1, 151, -1, 153,
1896 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1897 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1898 -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1899 6, 7, 8, -1, 188, -1, -1, -1, -1, -1,
1900 194, 195, 196, 197, 20, 21, 22, 23, 24, 25,
1901 26, 27, 28, 29, 30, 31, -1, -1, -1, -1,
1902 -1, -1, -1, -1, -1, 41, 42, 43, 44, 45,
1903 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
1904 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
1905 66, 67, 68, 69, 70, 71, 72, 73, 74, -1,
1906 76, 77, 78, 79, 80, 81, -1, -1, 84, 85,
1907 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1908 -1, -1, -1, -1, -1, -1, -1, -1, 104, 105,
1909 106, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1910 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1911 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1912 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1913 -1, -1, -1, -1, -1, 151, -1, 153, -1, -1,
1914 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1915 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1916 -1, -1, 0, -1, -1, 3, 4, 5, 6, 7,
1917 8, -1, 188, -1, -1, -1, -1, -1, 194, 195,
1918 196, 197, 20, 21, 22, 23, 24, 25, 26, 27,
1919 28, 29, 30, 31, 32, -1, 34, -1, 36, -1,
1920 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1921 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
1922 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
1923 68, 69, 70, 71, 72, 73, 74, -1, 76, -1,
1924 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1925 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1926 -1, -1, -1, -1, -1, 103, 104, 105, 106, -1,
1927 108, -1, -1, -1, -1, -1, -1, -1, -1, 117,
1928 -1, 3, 4, 5, 6, 7, 8, -1, -1, -1,
1929 -1, -1, -1, -1, -1, -1, -1, -1, 20, 21,
1930 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
1931 32, -1, 34, 151, 36, 153, 38, 39, 40, 41,
1932 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
1933 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1934 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
1935 72, 73, 74, -1, 76, -1, -1, -1, -1, -1,
1936 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1937 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1938 -1, 103, 104, 105, 106, -1, 108, -1, -1, -1,
1939 -1, -1, -1, -1, -1, 117, 5, 6, 7, 8,
1940 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1941 -1, 20, 21, 22, 23, 24, 25, 26, 27, 28,
1942 29, 30, 31, -1, -1, -1, -1, -1, -1, 151,
1943 -1, 153, 41, 42, 43, 44, 45, 46, 47, 48,
1944 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1945 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1946 69, 70, 71, 72, 73, 74, -1, 76, 5, 6,
1947 7, 8, -1, -1, -1, -1, -1, -1, -1, -1,
1948 -1, -1, -1, 20, 21, 22, 23, 24, 25, 26,
1949 27, 28, 29, 30, 31, 104, 105, 106, -1, -1,
1950 -1, -1, -1, -1, 41, 42, 43, 44, 45, 46,
1951 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1952 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1953 67, 68, 69, 70, 71, 72, 73, 74, -1, 76,
1954 -1, -1, 151, -1, 153, -1, -1, -1, -1, -1,
1955 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1956 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1957 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1958 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1959 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1960 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1961 -1, -1, -1, -1, 151, -1, 153
1962};
1963
1964/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1965 symbol of state STATE-NUM. */
1966static const yytype_uint16 yystos[] =
1967{
1968 0, 109, 213, 215, 78, 0, 216, 114, 110, 214,
1969 217, 76, 3, 4, 5, 6, 7, 8, 20, 21,
1970 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
1971 32, 34, 36, 38, 39, 40, 41, 42, 43, 44,
1972 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1973 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1974 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1975 76, 103, 104, 105, 106, 108, 117, 151, 153, 218,
1976 248, 249, 250, 251, 252, 257, 258, 259, 260, 261,
1977 264, 266, 267, 268, 269, 270, 271, 272, 273, 299,
1978 300, 113, 33, 34, 37, 76, 210, 76, 103, 266,
1979 272, 188, 299, 209, 210, 286, 189, 193, 4, 33,
1980 34, 35, 254, 255, 265, 193, 209, 76, 33, 37,
1981 266, 268, 190, 269, 76, 210, 268, 274, 275, 269,
1982 76, 262, 263, 9, 10, 11, 13, 14, 15, 16,
1983 17, 18, 19, 75, 76, 77, 78, 79, 80, 81,
1984 84, 85, 188, 194, 195, 196, 197, 209, 210, 211,
1985 219, 220, 221, 223, 224, 225, 226, 227, 228, 229,
1986 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
1987 240, 241, 242, 243, 244, 246, 248, 249, 268, 279,
1988 280, 281, 282, 283, 284, 287, 288, 289, 290, 292,
1989 293, 294, 298, 254, 253, 256, 268, 255, 76, 188,
1990 190, 208, 191, 230, 243, 247, 268, 114, 274, 76,
1991 276, 277, 211, 275, 209, 189, 193, 209, 209, 280,
1992 188, 188, 209, 209, 246, 188, 246, 207, 188, 230,
1993 230, 246, 211, 287, 84, 85, 190, 192, 189, 189,
1994 193, 74, 244, 188, 93, 94, 95, 96, 97, 98,
1995 99, 100, 101, 102, 208, 245, 230, 198, 199, 200,
1996 194, 195, 82, 83, 86, 87, 201, 202, 88, 89,
1997 203, 204, 205, 90, 92, 91, 206, 193, 209, 211,
1998 280, 76, 253, 256, 190, 208, 191, 247, 244, 278,
1999 191, 211, 190, 193, 209, 263, 75, 279, 288, 295,
2000 246, 209, 246, 207, 246, 259, 291, 189, 211, 222,
2001 246, 76, 225, 244, 244, 230, 230, 230, 232, 232,
2002 233, 233, 234, 234, 234, 234, 235, 235, 236, 237,
2003 238, 239, 240, 241, 246, 244, 190, 191, 247, 278,
2004 208, 191, 247, 277, 188, 291, 296, 297, 189, 189,
2005 76, 189, 191, 207, 247, 208, 191, 278, 208, 191,
2006 246, 209, 189, 281, 282, 284, 208, 14, 283, 285,
2007 286, 244, 191, 278, 208, 278, 189, 246, 285, 12,
2008 278, 188, 278, 209, 281, 282, 246, 189, 281, 12
2009};
2010
2011#define yyerrok (yyerrstatus = 0)
2012#define yyclearin (yychar = YYEMPTY)
2013#define YYEMPTY (-2)
2014#define YYEOF 0
2015
2016#define YYACCEPT goto yyacceptlab
2017#define YYABORT goto yyabortlab
2018#define YYERROR goto yyerrorlab
2019
2020
2021/* Like YYERROR except do call yyerror. This remains here temporarily
2022 to ease the transition to the new meaning of YYERROR, for GCC.
2023 Once GCC version 2 has supplanted version 1, this can go. */
2024
2025#define YYFAIL goto yyerrlab
2026
2027#define YYRECOVERING() (!!yyerrstatus)
2028
2029#define YYBACKUP(Token, Value) \
2030do \
2031 if (yychar == YYEMPTY && yylen == 1) \
2032 { \
2033 yychar = (Token); \
2034 yylval = (Value); \
2035 yytoken = YYTRANSLATE (yychar); \
2036 YYPOPSTACK (1); \
2037 goto yybackup; \
2038 } \
2039 else \
2040 { \
2041 yyerror (&yylloc, state, YY_("syntax error: cannot back up")); \
2042 YYERROR; \
2043 } \
2044while (YYID (0))
2045
2046
2047#define YYTERROR 1
2048#define YYERRCODE 256
2049
2050
2051/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2052 If N is 0, then set CURRENT to the empty location which ends
2053 the previous symbol: RHS[0] (always defined). */
2054
2055#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2056#ifndef YYLLOC_DEFAULT
2057# define YYLLOC_DEFAULT(Current, Rhs, N) \
2058 do \
2059 if (YYID (N)) \
2060 { \
2061 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2062 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2063 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2064 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2065 } \
2066 else \
2067 { \
2068 (Current).first_line = (Current).last_line = \
2069 YYRHSLOC (Rhs, 0).last_line; \
2070 (Current).first_column = (Current).last_column = \
2071 YYRHSLOC (Rhs, 0).last_column; \
2072 } \
2073 while (YYID (0))
2074#endif
2075
2076
2077/* YY_LOCATION_PRINT -- Print the location on the stream.
2078 This macro was not mandated originally: define only if we know
2079 we won't break user code: when these are the locations we know. */
2080
2081#ifndef YY_LOCATION_PRINT
2082# if YYLTYPE_IS_TRIVIAL
2083# define YY_LOCATION_PRINT(File, Loc) \
2084 fprintf (File, "%d.%d-%d.%d", \
2085 (Loc).first_line, (Loc).first_column, \
2086 (Loc).last_line, (Loc).last_column)
2087# else
2088# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2089# endif
2090#endif
2091
2092
2093/* YYLEX -- calling `yylex' with the right arguments. */
2094
2095#ifdef YYLEX_PARAM
2096# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
2097#else
2098# define YYLEX yylex (&yylval, &yylloc, scanner)
2099#endif
2100
2101/* Enable debugging if requested. */
2102#if YYDEBUG
2103
2104# ifndef YYFPRINTF
2105# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2106# define YYFPRINTF fprintf
2107# endif
2108
2109# define YYDPRINTF(Args) \
2110do { \
2111 if (yydebug) \
2112 YYFPRINTF Args; \
2113} while (YYID (0))
2114
2115# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2116do { \
2117 if (yydebug) \
2118 { \
2119 YYFPRINTF (stderr, "%s ", Title); \
2120 yy_symbol_print (stderr, \
2121 Type, Value, Location, state); \
2122 YYFPRINTF (stderr, "\n"); \
2123 } \
2124} while (YYID (0))
2125
2126
2127/*--------------------------------.
2128| Print this symbol on YYOUTPUT. |
2129`--------------------------------*/
2130
2131/*ARGSUSED*/
2132#if (defined __STDC__ || defined __C99__FUNC__ \
2133 || defined __cplusplus || defined _MSC_VER)
2134static void
2135yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state)
2136#else
2137static void
2138yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state)
2139 FILE *yyoutput;
2140 int yytype;
2141 YYSTYPE const * const yyvaluep;
2142 YYLTYPE const * const yylocationp;
2143 struct _mesa_glsl_parse_state *state;
2144#endif
2145{
2146 if (!yyvaluep)
2147 return;
2148 YYUSE (yylocationp);
2149 YYUSE (state);
2150# ifdef YYPRINT
2151 if (yytype < YYNTOKENS)
2152 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2153# else
2154 YYUSE (yyoutput);
2155# endif
2156 switch (yytype)
2157 {
2158 default:
2159 break;
2160 }
2161}
2162
2163
2164/*--------------------------------.
2165| Print this symbol on YYOUTPUT. |
2166`--------------------------------*/
2167
2168#if (defined __STDC__ || defined __C99__FUNC__ \
2169 || defined __cplusplus || defined _MSC_VER)
2170static void
2171yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct _mesa_glsl_parse_state *state)
2172#else
2173static void
2174yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, state)
2175 FILE *yyoutput;
2176 int yytype;
2177 YYSTYPE const * const yyvaluep;
2178 YYLTYPE const * const yylocationp;
2179 struct _mesa_glsl_parse_state *state;
2180#endif
2181{
2182 if (yytype < YYNTOKENS)
2183 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2184 else
2185 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2186
2187 YY_LOCATION_PRINT (yyoutput, *yylocationp);
2188 YYFPRINTF (yyoutput, ": ");
2189 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, state);
2190 YYFPRINTF (yyoutput, ")");
2191}
2192
2193/*------------------------------------------------------------------.
2194| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2195| TOP (included). |
2196`------------------------------------------------------------------*/
2197
2198#if (defined __STDC__ || defined __C99__FUNC__ \
2199 || defined __cplusplus || defined _MSC_VER)
2200static void
2201yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
2202#else
2203static void
2204yy_stack_print (yybottom, yytop)
2205 yytype_int16 *yybottom;
2206 yytype_int16 *yytop;
2207#endif
2208{
2209 YYFPRINTF (stderr, "Stack now");
2210 for (; yybottom <= yytop; yybottom++)
2211 {
2212 int yybot = *yybottom;
2213 YYFPRINTF (stderr, " %d", yybot);
2214 }
2215 YYFPRINTF (stderr, "\n");
2216}
2217
2218# define YY_STACK_PRINT(Bottom, Top) \
2219do { \
2220 if (yydebug) \
2221 yy_stack_print ((Bottom), (Top)); \
2222} while (YYID (0))
2223
2224
2225/*------------------------------------------------.
2226| Report that the YYRULE is going to be reduced. |
2227`------------------------------------------------*/
2228
2229#if (defined __STDC__ || defined __C99__FUNC__ \
2230 || defined __cplusplus || defined _MSC_VER)
2231static void
2232yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, struct _mesa_glsl_parse_state *state)
2233#else
2234static void
2235yy_reduce_print (yyvsp, yylsp, yyrule, state)
2236 YYSTYPE *yyvsp;
2237 YYLTYPE *yylsp;
2238 int yyrule;
2239 struct _mesa_glsl_parse_state *state;
2240#endif
2241{
2242 int yynrhs = yyr2[yyrule];
2243 int yyi;
2244 unsigned long int yylno = yyrline[yyrule];
2245 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2246 yyrule - 1, yylno);
2247 /* The symbols being reduced. */
2248 for (yyi = 0; yyi < yynrhs; yyi++)
2249 {
2250 YYFPRINTF (stderr, " $%d = ", yyi + 1);
2251 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2252 &(yyvsp[(yyi + 1) - (yynrhs)])
2253 , &(yylsp[(yyi + 1) - (yynrhs)]) , state);
2254 YYFPRINTF (stderr, "\n");
2255 }
2256}
2257
2258# define YY_REDUCE_PRINT(Rule) \
2259do { \
2260 if (yydebug) \
2261 yy_reduce_print (yyvsp, yylsp, Rule, state); \
2262} while (YYID (0))
2263
2264/* Nonzero means print parse trace. It is left uninitialized so that
2265 multiple parsers can coexist. */
2266int yydebug;
2267#else /* !YYDEBUG */
2268# define YYDPRINTF(Args)
2269# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2270# define YY_STACK_PRINT(Bottom, Top)
2271# define YY_REDUCE_PRINT(Rule)
2272#endif /* !YYDEBUG */
2273
2274
2275/* YYINITDEPTH -- initial size of the parser's stacks. */
2276#ifndef YYINITDEPTH
2277# define YYINITDEPTH 200
2278#endif
2279
2280/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2281 if the built-in stack extension method is used).
2282
2283 Do not make this value too large; the results are undefined if
2284 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2285 evaluated with infinite-precision integer arithmetic. */
2286
2287#ifndef YYMAXDEPTH
2288# define YYMAXDEPTH 10000
2289#endif
2290
2291
2292
2293#if YYERROR_VERBOSE
2294
2295# ifndef yystrlen
2296# if defined __GLIBC__ && defined _STRING_H
2297# define yystrlen strlen
2298# else
2299/* Return the length of YYSTR. */
2300#if (defined __STDC__ || defined __C99__FUNC__ \
2301 || defined __cplusplus || defined _MSC_VER)
2302static YYSIZE_T
2303yystrlen (const char *yystr)
2304#else
2305static YYSIZE_T
2306yystrlen (yystr)
2307 const char *yystr;
2308#endif
2309{
2310 YYSIZE_T yylen;
2311 for (yylen = 0; yystr[yylen]; yylen++)
2312 continue;
2313 return yylen;
2314}
2315# endif
2316# endif
2317
2318# ifndef yystpcpy
2319# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2320# define yystpcpy stpcpy
2321# else
2322/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2323 YYDEST. */
2324#if (defined __STDC__ || defined __C99__FUNC__ \
2325 || defined __cplusplus || defined _MSC_VER)
2326static char *
2327yystpcpy (char *yydest, const char *yysrc)
2328#else
2329static char *
2330yystpcpy (yydest, yysrc)
2331 char *yydest;
2332 const char *yysrc;
2333#endif
2334{
2335 char *yyd = yydest;
2336 const char *yys = yysrc;
2337
2338 while ((*yyd++ = *yys++) != '\0')
2339 continue;
2340
2341 return yyd - 1;
2342}
2343# endif
2344# endif
2345
2346# ifndef yytnamerr
2347/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2348 quotes and backslashes, so that it's suitable for yyerror. The
2349 heuristic is that double-quoting is unnecessary unless the string
2350 contains an apostrophe, a comma, or backslash (other than
2351 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2352 null, do not copy; instead, return the length of what the result
2353 would have been. */
2354static YYSIZE_T
2355yytnamerr (char *yyres, const char *yystr)
2356{
2357 if (*yystr == '"')
2358 {
2359 YYSIZE_T yyn = 0;
2360 char const *yyp = yystr;
2361
2362 for (;;)
2363 switch (*++yyp)
2364 {
2365 case '\'':
2366 case ',':
2367 goto do_not_strip_quotes;
2368
2369 case '\\':
2370 if (*++yyp != '\\')
2371 goto do_not_strip_quotes;
2372 /* Fall through. */
2373 default:
2374 if (yyres)
2375 yyres[yyn] = *yyp;
2376 yyn++;
2377 break;
2378
2379 case '"':
2380 if (yyres)
2381 yyres[yyn] = '\0';
2382 return yyn;
2383 }
2384 do_not_strip_quotes: ;
2385 }
2386
2387 if (! yyres)
2388 return yystrlen (yystr);
2389
2390 return yystpcpy (yyres, yystr) - yyres;
2391}
2392# endif
2393
2394/* Copy into YYRESULT an error message about the unexpected token
2395 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2396 including the terminating null byte. If YYRESULT is null, do not
2397 copy anything; just return the number of bytes that would be
2398 copied. As a special case, return 0 if an ordinary "syntax error"
2399 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2400 size calculation. */
2401static YYSIZE_T
2402yysyntax_error (char *yyresult, int yystate, int yychar)
2403{
2404 int yyn = yypact[yystate];
2405
2406 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2407 return 0;
2408 else
2409 {
2410 int yytype = YYTRANSLATE (yychar);
2411 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2412 YYSIZE_T yysize = yysize0;
2413 YYSIZE_T yysize1;
2414 int yysize_overflow = 0;
2415 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2416 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2417 int yyx;
2418
2419# if 0
2420 /* This is so xgettext sees the translatable formats that are
2421 constructed on the fly. */
2422 YY_("syntax error, unexpected %s");
2423 YY_("syntax error, unexpected %s, expecting %s");
2424 YY_("syntax error, unexpected %s, expecting %s or %s");
2425 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2426 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2427# endif
2428 char *yyfmt;
2429 char const *yyf;
2430 static char const yyunexpected[] = "syntax error, unexpected %s";
2431 static char const yyexpecting[] = ", expecting %s";
2432 static char const yyor[] = " or %s";
2433 char yyformat[sizeof yyunexpected
2434 + sizeof yyexpecting - 1
2435 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2436 * (sizeof yyor - 1))];
2437 char const *yyprefix = yyexpecting;
2438
2439 /* Start YYX at -YYN if negative to avoid negative indexes in
2440 YYCHECK. */
2441 int yyxbegin = yyn < 0 ? -yyn : 0;
2442
2443 /* Stay within bounds of both yycheck and yytname. */
2444 int yychecklim = YYLAST - yyn + 1;
2445 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2446 int yycount = 1;
2447
2448 yyarg[0] = yytname[yytype];
2449 yyfmt = yystpcpy (yyformat, yyunexpected);
2450
2451 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2452 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2453 {
2454 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2455 {
2456 yycount = 1;
2457 yysize = yysize0;
2458 yyformat[sizeof yyunexpected - 1] = '\0';
2459 break;
2460 }
2461 yyarg[yycount++] = yytname[yyx];
2462 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2463 yysize_overflow |= (yysize1 < yysize);
2464 yysize = yysize1;
2465 yyfmt = yystpcpy (yyfmt, yyprefix);
2466 yyprefix = yyor;
2467 }
2468
2469 yyf = YY_(yyformat);
2470 yysize1 = yysize + yystrlen (yyf);
2471 yysize_overflow |= (yysize1 < yysize);
2472 yysize = yysize1;
2473
2474 if (yysize_overflow)
2475 return YYSIZE_MAXIMUM;
2476
2477 if (yyresult)
2478 {
2479 /* Avoid sprintf, as that infringes on the user's name space.
2480 Don't have undefined behavior even if the translation
2481 produced a string with the wrong number of "%s"s. */
2482 char *yyp = yyresult;
2483 int yyi = 0;
2484 while ((*yyp = *yyf) != '\0')
2485 {
2486 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2487 {
2488 yyp += yytnamerr (yyp, yyarg[yyi++]);
2489 yyf += 2;
2490 }
2491 else
2492 {
2493 yyp++;
2494 yyf++;
2495 }
2496 }
2497 }
2498 return yysize;
2499 }
2500}
2501#endif /* YYERROR_VERBOSE */
2502
2503
2504/*-----------------------------------------------.
2505| Release the memory associated to this symbol. |
2506`-----------------------------------------------*/
2507
2508/*ARGSUSED*/
2509#if (defined __STDC__ || defined __C99__FUNC__ \
2510 || defined __cplusplus || defined _MSC_VER)
2511static void
2512yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct _mesa_glsl_parse_state *state)
2513#else
2514static void
2515yydestruct (yymsg, yytype, yyvaluep, yylocationp, state)
2516 const char *yymsg;
2517 int yytype;
2518 YYSTYPE *yyvaluep;
2519 YYLTYPE *yylocationp;
2520 struct _mesa_glsl_parse_state *state;
2521#endif
2522{
2523 YYUSE (yyvaluep);
2524 YYUSE (yylocationp);
2525 YYUSE (state);
2526
2527 if (!yymsg)
2528 yymsg = "Deleting";
2529 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2530
2531 switch (yytype)
2532 {
2533
2534 default:
2535 break;
2536 }
2537}
2538
2539/* Prevent warnings from -Wmissing-prototypes. */
2540#ifdef YYPARSE_PARAM
2541#if defined __STDC__ || defined __cplusplus
2542int yyparse (void *YYPARSE_PARAM);
2543#else
2544int yyparse ();
2545#endif
2546#else /* ! YYPARSE_PARAM */
2547#if defined __STDC__ || defined __cplusplus
2548int yyparse (struct _mesa_glsl_parse_state *state);
2549#else
2550int yyparse ();
2551#endif
2552#endif /* ! YYPARSE_PARAM */
2553
2554
2555
2556
2557
2558/*-------------------------.
2559| yyparse or yypush_parse. |
2560`-------------------------*/
2561
2562#ifdef YYPARSE_PARAM
2563#if (defined __STDC__ || defined __C99__FUNC__ \
2564 || defined __cplusplus || defined _MSC_VER)
2565int
2566yyparse (void *YYPARSE_PARAM)
2567#else
2568int
2569yyparse (YYPARSE_PARAM)
2570 void *YYPARSE_PARAM;
2571#endif
2572#else /* ! YYPARSE_PARAM */
2573#if (defined __STDC__ || defined __C99__FUNC__ \
2574 || defined __cplusplus || defined _MSC_VER)
2575int
2576yyparse (struct _mesa_glsl_parse_state *state)
2577#else
2578int
2579yyparse (state)
2580 struct _mesa_glsl_parse_state *state;
2581#endif
2582#endif
2583{
2584/* The lookahead symbol. */
2585int yychar;
2586
2587/* The semantic value of the lookahead symbol. */
2588YYSTYPE yylval;
2589
2590/* Location data for the lookahead symbol. */
2591YYLTYPE yylloc;
2592
2593 /* Number of syntax errors so far. */
2594 int yynerrs;
2595
2596 int yystate;
2597 /* Number of tokens to shift before error messages enabled. */
2598 int yyerrstatus;
2599
2600 /* The stacks and their tools:
2601 `yyss': related to states.
2602 `yyvs': related to semantic values.
2603 `yyls': related to locations.
2604
2605 Refer to the stacks thru separate pointers, to allow yyoverflow
2606 to reallocate them elsewhere. */
2607
2608 /* The state stack. */
2609 yytype_int16 yyssa[YYINITDEPTH];
2610 yytype_int16 *yyss;
2611 yytype_int16 *yyssp;
2612
2613 /* The semantic value stack. */
2614 YYSTYPE yyvsa[YYINITDEPTH];
2615 YYSTYPE *yyvs;
2616 YYSTYPE *yyvsp;
2617
2618 /* The location stack. */
2619 YYLTYPE yylsa[YYINITDEPTH];
2620 YYLTYPE *yyls;
2621 YYLTYPE *yylsp;
2622
2623 /* The locations where the error started and ended. */
2624 YYLTYPE yyerror_range[2];
2625
2626 YYSIZE_T yystacksize;
2627
2628 int yyn;
2629 int yyresult;
2630 /* Lookahead token as an internal (translated) token number. */
2631 int yytoken;
2632 /* The variables used to return semantic value and location from the
2633 action routines. */
2634 YYSTYPE yyval;
2635 YYLTYPE yyloc;
2636
2637#if YYERROR_VERBOSE
2638 /* Buffer for error messages, and its allocated size. */
2639 char yymsgbuf[128];
2640 char *yymsg = yymsgbuf;
2641 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
2642#endif
2643
2644#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
2645
2646 /* The number of symbols on the RHS of the reduced rule.
2647 Keep to zero when no symbol should be popped. */
2648 int yylen = 0;
2649
2650 yytoken = 0;
2651 yyss = yyssa;
2652 yyvs = yyvsa;
2653 yyls = yylsa;
2654 yystacksize = YYINITDEPTH;
2655
2656 YYDPRINTF ((stderr, "Starting parse\n"));
2657
2658 yystate = 0;
2659 yyerrstatus = 0;
2660 yynerrs = 0;
2661 yychar = YYEMPTY; /* Cause a token to be read. */
2662
2663 /* Initialize stack pointers.
2664 Waste one element of value and location stack
2665 so that they stay on the same level as the state stack.
2666 The wasted elements are never initialized. */
2667 yyssp = yyss;
2668 yyvsp = yyvs;
2669 yylsp = yyls;
2670
2671#if YYLTYPE_IS_TRIVIAL
2672 /* Initialize the default location before parsing starts. */
2673 yylloc.first_line = yylloc.last_line = 1;
2674 yylloc.first_column = yylloc.last_column = 1;
2675#endif
2676
2677/* User initialization code. */
2678
2679/* Line 1242 of yacc.c */
2680#line 41 "glsl_parser.ypp"
2681{
2682 yylloc.first_line = 1;
2683 yylloc.first_column = 1;
2684 yylloc.last_line = 1;
2685 yylloc.last_column = 1;
2686 yylloc.source = 0;
2687}
2688
2689/* Line 1242 of yacc.c */
2690#line 2691 "glsl_parser.cpp"
2691 yylsp[0] = yylloc;
2692
2693 goto yysetstate;
2694
2695/*------------------------------------------------------------.
2696| yynewstate -- Push a new state, which is found in yystate. |
2697`------------------------------------------------------------*/
2698 yynewstate:
2699 /* In all cases, when you get here, the value and location stacks
2700 have just been pushed. So pushing a state here evens the stacks. */
2701 yyssp++;
2702
2703 yysetstate:
2704 *yyssp = yystate;
2705
2706 if (yyss + yystacksize - 1 <= yyssp)
2707 {
2708 /* Get the current used size of the three stacks, in elements. */
2709 YYSIZE_T yysize = yyssp - yyss + 1;
2710
2711#ifdef yyoverflow
2712 {
2713 /* Give user a chance to reallocate the stack. Use copies of
2714 these so that the &'s don't force the real ones into
2715 memory. */
2716 YYSTYPE *yyvs1 = yyvs;
2717 yytype_int16 *yyss1 = yyss;
2718 YYLTYPE *yyls1 = yyls;
2719
2720 /* Each stack pointer address is followed by the size of the
2721 data in use in that stack, in bytes. This used to be a
2722 conditional around just the two extra args, but that might
2723 be undefined if yyoverflow is a macro. */
2724 yyoverflow (YY_("memory exhausted"),
2725 &yyss1, yysize * sizeof (*yyssp),
2726 &yyvs1, yysize * sizeof (*yyvsp),
2727 &yyls1, yysize * sizeof (*yylsp),
2728 &yystacksize);
2729
2730 yyls = yyls1;
2731 yyss = yyss1;
2732 yyvs = yyvs1;
2733 }
2734#else /* no yyoverflow */
2735# ifndef YYSTACK_RELOCATE
2736 goto yyexhaustedlab;
2737# else
2738 /* Extend the stack our own way. */
2739 if (YYMAXDEPTH <= yystacksize)
2740 goto yyexhaustedlab;
2741 yystacksize *= 2;
2742 if (YYMAXDEPTH < yystacksize)
2743 yystacksize = YYMAXDEPTH;
2744
2745 {
2746 yytype_int16 *yyss1 = yyss;
2747 union yyalloc *yyptr =
2748 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2749 if (! yyptr)
2750 goto yyexhaustedlab;
2751 YYSTACK_RELOCATE (yyss_alloc, yyss);
2752 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
2753 YYSTACK_RELOCATE (yyls_alloc, yyls);
2754# undef YYSTACK_RELOCATE
2755 if (yyss1 != yyssa)
2756 YYSTACK_FREE (yyss1);
2757 }
2758# endif
2759#endif /* no yyoverflow */
2760
2761 yyssp = yyss + yysize - 1;
2762 yyvsp = yyvs + yysize - 1;
2763 yylsp = yyls + yysize - 1;
2764
2765 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2766 (unsigned long int) yystacksize));
2767
2768 if (yyss + yystacksize - 1 <= yyssp)
2769 YYABORT;
2770 }
2771
2772 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2773
2774 if (yystate == YYFINAL)
2775 YYACCEPT;
2776
2777 goto yybackup;
2778
2779/*-----------.
2780| yybackup. |
2781`-----------*/
2782yybackup:
2783
2784 /* Do appropriate processing given the current state. Read a
2785 lookahead token if we need one and don't already have one. */
2786
2787 /* First try to decide what to do without reference to lookahead token. */
2788 yyn = yypact[yystate];
2789 if (yyn == YYPACT_NINF)
2790 goto yydefault;
2791
2792 /* Not known => get a lookahead token if don't already have one. */
2793
2794 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
2795 if (yychar == YYEMPTY)
2796 {
2797 YYDPRINTF ((stderr, "Reading a token: "));
2798 yychar = YYLEX;
2799 }
2800
2801 if (yychar <= YYEOF)
2802 {
2803 yychar = yytoken = YYEOF;
2804 YYDPRINTF ((stderr, "Now at end of input.\n"));
2805 }
2806 else
2807 {
2808 yytoken = YYTRANSLATE (yychar);
2809 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2810 }
2811
2812 /* If the proper action on seeing token YYTOKEN is to reduce or to
2813 detect an error, take that action. */
2814 yyn += yytoken;
2815 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2816 goto yydefault;
2817 yyn = yytable[yyn];
2818 if (yyn <= 0)
2819 {
2820 if (yyn == 0 || yyn == YYTABLE_NINF)
2821 goto yyerrlab;
2822 yyn = -yyn;
2823 goto yyreduce;
2824 }
2825
2826 /* Count tokens shifted since error; after three, turn off error
2827 status. */
2828 if (yyerrstatus)
2829 yyerrstatus--;
2830
2831 /* Shift the lookahead token. */
2832 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2833
2834 /* Discard the shifted token. */
2835 yychar = YYEMPTY;
2836
2837 yystate = yyn;
2838 *++yyvsp = yylval;
2839 *++yylsp = yylloc;
2840 goto yynewstate;
2841
2842
2843/*-----------------------------------------------------------.
2844| yydefault -- do the default action for the current state. |
2845`-----------------------------------------------------------*/
2846yydefault:
2847 yyn = yydefact[yystate];
2848 if (yyn == 0)
2849 goto yyerrlab;
2850 goto yyreduce;
2851
2852
2853/*-----------------------------.
2854| yyreduce -- Do a reduction. |
2855`-----------------------------*/
2856yyreduce:
2857 /* yyn is the number of a rule to reduce with. */
2858 yylen = yyr2[yyn];
2859
2860 /* If YYLEN is nonzero, implement the default value of the action:
2861 `$$ = $1'.
2862
2863 Otherwise, the following line sets YYVAL to garbage.
2864 This behavior is undocumented and Bison
2865 users should not rely upon it. Assigning to YYVAL
2866 unconditionally makes the parser a bit smaller, and it avoids a
2867 GCC warning that YYVAL may be used uninitialized. */
2868 yyval = yyvsp[1-yylen];
2869
2870 /* Default location. */
2871 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
2872 YY_REDUCE_PRINT (yyn);
2873 switch (yyn)
2874 {
2875 case 2:
2876
2877/* Line 1455 of yacc.c */
2878#line 209 "glsl_parser.ypp"
2879 {
2880 _mesa_glsl_initialize_types(state);
2881 ;}
2882 break;
2883
2884 case 4:
2885
2886/* Line 1455 of yacc.c */
2887#line 217 "glsl_parser.ypp"
2888 {
2889 state->language_version = 110;
2890 ;}
2891 break;
2892
2893 case 5:
2894
2895/* Line 1455 of yacc.c */
2896#line 221 "glsl_parser.ypp"
2897 {
2898 switch ((yyvsp[(2) - (3)].n)) {
2899 case 110:
2900 case 120:
2901 case 130:
2902 /* FINISHME: Check against implementation support versions. */
2903 state->language_version = (yyvsp[(2) - (3)].n);
2904 break;
2905 default:
2906 _mesa_glsl_error(& (yylsp[(2) - (3)]), state, "Shading language version"
2907 "%u is not supported\n", (yyvsp[(2) - (3)].n));
2908 break;
2909 }
2910 ;}
2911 break;
2912
2913 case 8:
2914
2915/* Line 1455 of yacc.c */
2916#line 244 "glsl_parser.ypp"
2917 {
2918 if (!_mesa_glsl_process_extension((yyvsp[(2) - (5)].identifier), & (yylsp[(2) - (5)]), (yyvsp[(4) - (5)].identifier), & (yylsp[(4) - (5)]), state)) {
2919 YYERROR;
2920 }
2921 ;}
2922 break;
2923
2924 case 9:
2925
2926/* Line 1455 of yacc.c */
2927#line 253 "glsl_parser.ypp"
2928 {
2929 /* FINISHME: The NULL test is only required because 'precision'
2930 * FINISHME: statements are not yet supported.
2931 */
2932 if ((yyvsp[(1) - (1)].node) != NULL)
2933 state->translation_unit.push_tail(& (yyvsp[(1) - (1)].node)->link);
2934 ;}
2935 break;
2936
2937 case 10:
2938
2939/* Line 1455 of yacc.c */
2940#line 261 "glsl_parser.ypp"
2941 {
2942 /* FINISHME: The NULL test is only required because 'precision'
2943 * FINISHME: statements are not yet supported.
2944 */
2945 if ((yyvsp[(2) - (2)].node) != NULL)
2946 state->translation_unit.push_tail(& (yyvsp[(2) - (2)].node)->link);
2947 ;}
2948 break;
2949
2950 case 12:
2951
2952/* Line 1455 of yacc.c */
2953#line 276 "glsl_parser.ypp"
2954 {
2955 void *ctx = state;
2956 (yyval.expression) = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
2957 (yyval.expression)->set_location(yylloc);
2958 (yyval.expression)->primary_expression.identifier = (yyvsp[(1) - (1)].identifier);
2959 ;}
2960 break;
2961
2962 case 13:
2963
2964/* Line 1455 of yacc.c */
2965#line 283 "glsl_parser.ypp"
2966 {
2967 void *ctx = state;
2968 (yyval.expression) = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
2969 (yyval.expression)->set_location(yylloc);
2970 (yyval.expression)->primary_expression.int_constant = (yyvsp[(1) - (1)].n);
2971 ;}
2972 break;
2973
2974 case 14:
2975
2976/* Line 1455 of yacc.c */
2977#line 290 "glsl_parser.ypp"
2978 {
2979 void *ctx = state;
2980 (yyval.expression) = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
2981 (yyval.expression)->set_location(yylloc);
2982 (yyval.expression)->primary_expression.uint_constant = (yyvsp[(1) - (1)].n);
2983 ;}
2984 break;
2985
2986 case 15:
2987
2988/* Line 1455 of yacc.c */
2989#line 297 "glsl_parser.ypp"
2990 {
2991 void *ctx = state;
2992 (yyval.expression) = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
2993 (yyval.expression)->set_location(yylloc);
2994 (yyval.expression)->primary_expression.float_constant = (yyvsp[(1) - (1)].real);
2995 ;}
2996 break;
2997
2998 case 16:
2999
3000/* Line 1455 of yacc.c */
3001#line 304 "glsl_parser.ypp"
3002 {
3003 void *ctx = state;
3004 (yyval.expression) = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
3005 (yyval.expression)->set_location(yylloc);
3006 (yyval.expression)->primary_expression.bool_constant = (yyvsp[(1) - (1)].n);
3007 ;}
3008 break;
3009
3010 case 17:
3011
3012/* Line 1455 of yacc.c */
3013#line 311 "glsl_parser.ypp"
3014 {
3015 (yyval.expression) = (yyvsp[(2) - (3)].expression);
3016 ;}
3017 break;
3018
3019 case 19:
3020
3021/* Line 1455 of yacc.c */
3022#line 319 "glsl_parser.ypp"
3023 {
3024 void *ctx = state;
3025 (yyval.expression) = new(ctx) ast_expression(ast_array_index, (yyvsp[(1) - (4)].expression), (yyvsp[(3) - (4)].expression), NULL);
3026 (yyval.expression)->set_location(yylloc);
3027 ;}
3028 break;
3029
3030 case 20:
3031
3032/* Line 1455 of yacc.c */
3033#line 325 "glsl_parser.ypp"
3034 {
3035 (yyval.expression) = (yyvsp[(1) - (1)].expression);
3036 ;}
3037 break;
3038
3039 case 21:
3040
3041/* Line 1455 of yacc.c */
3042#line 329 "glsl_parser.ypp"
3043 {
3044 void *ctx = state;
3045 (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), NULL, NULL);
3046 (yyval.expression)->set_location(yylloc);
3047 (yyval.expression)->primary_expression.identifier = (yyvsp[(3) - (3)].identifier);
3048 ;}
3049 break;
3050
3051 case 22:
3052
3053/* Line 1455 of yacc.c */
3054#line 336 "glsl_parser.ypp"
3055 {
3056 void *ctx = state;
3057 (yyval.expression) = new(ctx) ast_expression(ast_post_inc, (yyvsp[(1) - (2)].expression), NULL, NULL);
3058 (yyval.expression)->set_location(yylloc);
3059 ;}
3060 break;
3061
3062 case 23:
3063
3064/* Line 1455 of yacc.c */
3065#line 342 "glsl_parser.ypp"
3066 {
3067 void *ctx = state;
3068 (yyval.expression) = new(ctx) ast_expression(ast_post_dec, (yyvsp[(1) - (2)].expression), NULL, NULL);
3069 (yyval.expression)->set_location(yylloc);
3070 ;}
3071 break;
3072
3073 case 27:
3074
3075/* Line 1455 of yacc.c */
3076#line 360 "glsl_parser.ypp"
3077 {
3078 void *ctx = state;
3079 (yyval.expression) = new(ctx) ast_expression(ast_field_selection, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL);
3080 (yyval.expression)->set_location(yylloc);
3081 ;}
3082 break;
3083
3084 case 32:
3085
3086/* Line 1455 of yacc.c */
3087#line 379 "glsl_parser.ypp"
3088 {
3089 (yyval.expression) = (yyvsp[(1) - (2)].expression);
3090 (yyval.expression)->set_location(yylloc);
3091 (yyval.expression)->expressions.push_tail(& (yyvsp[(2) - (2)].expression)->link);
3092 ;}
3093 break;
3094
3095 case 33:
3096
3097/* Line 1455 of yacc.c */
3098#line 385 "glsl_parser.ypp"
3099 {
3100 (yyval.expression) = (yyvsp[(1) - (3)].expression);
3101 (yyval.expression)->set_location(yylloc);
3102 (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link);
3103 ;}
3104 break;
3105
3106 case 35:
3107
3108/* Line 1455 of yacc.c */
3109#line 401 "glsl_parser.ypp"
3110 {
3111 void *ctx = state;
3112 (yyval.expression) = new(ctx) ast_function_expression((yyvsp[(1) - (1)].type_specifier));
3113 (yyval.expression)->set_location(yylloc);
3114 ;}
3115 break;
3116
3117 case 36:
3118
3119/* Line 1455 of yacc.c */
3120#line 407 "glsl_parser.ypp"
3121 {
3122 void *ctx = state;
3123 ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier));
3124 (yyval.expression) = new(ctx) ast_function_expression(callee);
3125 (yyval.expression)->set_location(yylloc);
3126 ;}
3127 break;
3128
3129 case 37:
3130
3131/* Line 1455 of yacc.c */
3132#line 414 "glsl_parser.ypp"
3133 {
3134 void *ctx = state;
3135 ast_expression *callee = new(ctx) ast_expression((yyvsp[(1) - (1)].identifier));
3136 (yyval.expression) = new(ctx) ast_function_expression(callee);
3137 (yyval.expression)->set_location(yylloc);
3138 ;}
3139 break;
3140
3141 case 39:
3142
3143/* Line 1455 of yacc.c */
3144#line 426 "glsl_parser.ypp"
3145 {
3146 void *ctx = state;
3147 (yyval.expression) = new(ctx) ast_expression(ast_pre_inc, (yyvsp[(2) - (2)].expression), NULL, NULL);
3148 (yyval.expression)->set_location(yylloc);
3149 ;}
3150 break;
3151
3152 case 40:
3153
3154/* Line 1455 of yacc.c */
3155#line 432 "glsl_parser.ypp"
3156 {
3157 void *ctx = state;
3158 (yyval.expression) = new(ctx) ast_expression(ast_pre_dec, (yyvsp[(2) - (2)].expression), NULL, NULL);
3159 (yyval.expression)->set_location(yylloc);
3160 ;}
3161 break;
3162
3163 case 41:
3164
3165/* Line 1455 of yacc.c */
3166#line 438 "glsl_parser.ypp"
3167 {
3168 void *ctx = state;
3169 (yyval.expression) = new(ctx) ast_expression((yyvsp[(1) - (2)].n), (yyvsp[(2) - (2)].expression), NULL, NULL);
3170 (yyval.expression)->set_location(yylloc);
3171 ;}
3172 break;
3173
3174 case 42:
3175
3176/* Line 1455 of yacc.c */
3177#line 447 "glsl_parser.ypp"
3178 { (yyval.n) = ast_plus; ;}
3179 break;
3180
3181 case 43:
3182
3183/* Line 1455 of yacc.c */
3184#line 448 "glsl_parser.ypp"
3185 { (yyval.n) = ast_neg; ;}
3186 break;
3187
3188 case 44:
3189
3190/* Line 1455 of yacc.c */
3191#line 449 "glsl_parser.ypp"
3192 { (yyval.n) = ast_logic_not; ;}
3193 break;
3194
3195 case 45:
3196
3197/* Line 1455 of yacc.c */
3198#line 450 "glsl_parser.ypp"
3199 { (yyval.n) = ast_bit_not; ;}
3200 break;
3201
3202 case 47:
3203
3204/* Line 1455 of yacc.c */
3205#line 456 "glsl_parser.ypp"
3206 {
3207 void *ctx = state;
3208 (yyval.expression) = new(ctx) ast_expression_bin(ast_mul, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3209 (yyval.expression)->set_location(yylloc);
3210 ;}
3211 break;
3212
3213 case 48:
3214
3215/* Line 1455 of yacc.c */
3216#line 462 "glsl_parser.ypp"
3217 {
3218 void *ctx = state;
3219 (yyval.expression) = new(ctx) ast_expression_bin(ast_div, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3220 (yyval.expression)->set_location(yylloc);
3221 ;}
3222 break;
3223
3224 case 49:
3225
3226/* Line 1455 of yacc.c */
3227#line 468 "glsl_parser.ypp"
3228 {
3229 void *ctx = state;
3230 (yyval.expression) = new(ctx) ast_expression_bin(ast_mod, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3231 (yyval.expression)->set_location(yylloc);
3232 ;}
3233 break;
3234
3235 case 51:
3236
3237/* Line 1455 of yacc.c */
3238#line 478 "glsl_parser.ypp"
3239 {
3240 void *ctx = state;
3241 (yyval.expression) = new(ctx) ast_expression_bin(ast_add, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3242 (yyval.expression)->set_location(yylloc);
3243 ;}
3244 break;
3245
3246 case 52:
3247
3248/* Line 1455 of yacc.c */
3249#line 484 "glsl_parser.ypp"
3250 {
3251 void *ctx = state;
3252 (yyval.expression) = new(ctx) ast_expression_bin(ast_sub, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3253 (yyval.expression)->set_location(yylloc);
3254 ;}
3255 break;
3256
3257 case 54:
3258
3259/* Line 1455 of yacc.c */
3260#line 494 "glsl_parser.ypp"
3261 {
3262 void *ctx = state;
3263 (yyval.expression) = new(ctx) ast_expression_bin(ast_lshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3264 (yyval.expression)->set_location(yylloc);
3265 ;}
3266 break;
3267
3268 case 55:
3269
3270/* Line 1455 of yacc.c */
3271#line 500 "glsl_parser.ypp"
3272 {
3273 void *ctx = state;
3274 (yyval.expression) = new(ctx) ast_expression_bin(ast_rshift, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3275 (yyval.expression)->set_location(yylloc);
3276 ;}
3277 break;
3278
3279 case 57:
3280
3281/* Line 1455 of yacc.c */
3282#line 510 "glsl_parser.ypp"
3283 {
3284 void *ctx = state;
3285 (yyval.expression) = new(ctx) ast_expression_bin(ast_less, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3286 (yyval.expression)->set_location(yylloc);
3287 ;}
3288 break;
3289
3290 case 58:
3291
3292/* Line 1455 of yacc.c */
3293#line 516 "glsl_parser.ypp"
3294 {
3295 void *ctx = state;
3296 (yyval.expression) = new(ctx) ast_expression_bin(ast_greater, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3297 (yyval.expression)->set_location(yylloc);
3298 ;}
3299 break;
3300
3301 case 59:
3302
3303/* Line 1455 of yacc.c */
3304#line 522 "glsl_parser.ypp"
3305 {
3306 void *ctx = state;
3307 (yyval.expression) = new(ctx) ast_expression_bin(ast_lequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3308 (yyval.expression)->set_location(yylloc);
3309 ;}
3310 break;
3311
3312 case 60:
3313
3314/* Line 1455 of yacc.c */
3315#line 528 "glsl_parser.ypp"
3316 {
3317 void *ctx = state;
3318 (yyval.expression) = new(ctx) ast_expression_bin(ast_gequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3319 (yyval.expression)->set_location(yylloc);
3320 ;}
3321 break;
3322
3323 case 62:
3324
3325/* Line 1455 of yacc.c */
3326#line 538 "glsl_parser.ypp"
3327 {
3328 void *ctx = state;
3329 (yyval.expression) = new(ctx) ast_expression_bin(ast_equal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3330 (yyval.expression)->set_location(yylloc);
3331 ;}
3332 break;
3333
3334 case 63:
3335
3336/* Line 1455 of yacc.c */
3337#line 544 "glsl_parser.ypp"
3338 {
3339 void *ctx = state;
3340 (yyval.expression) = new(ctx) ast_expression_bin(ast_nequal, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3341 (yyval.expression)->set_location(yylloc);
3342 ;}
3343 break;
3344
3345 case 65:
3346
3347/* Line 1455 of yacc.c */
3348#line 554 "glsl_parser.ypp"
3349 {
3350 void *ctx = state;
3351 (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3352 (yyval.expression)->set_location(yylloc);
3353 ;}
3354 break;
3355
3356 case 67:
3357
3358/* Line 1455 of yacc.c */
3359#line 564 "glsl_parser.ypp"
3360 {
3361 void *ctx = state;
3362 (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3363 (yyval.expression)->set_location(yylloc);
3364 ;}
3365 break;
3366
3367 case 69:
3368
3369/* Line 1455 of yacc.c */
3370#line 574 "glsl_parser.ypp"
3371 {
3372 void *ctx = state;
3373 (yyval.expression) = new(ctx) ast_expression_bin(ast_bit_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3374 (yyval.expression)->set_location(yylloc);
3375 ;}
3376 break;
3377
3378 case 71:
3379
3380/* Line 1455 of yacc.c */
3381#line 584 "glsl_parser.ypp"
3382 {
3383 void *ctx = state;
3384 (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_and, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3385 (yyval.expression)->set_location(yylloc);
3386 ;}
3387 break;
3388
3389 case 73:
3390
3391/* Line 1455 of yacc.c */
3392#line 594 "glsl_parser.ypp"
3393 {
3394 void *ctx = state;
3395 (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_xor, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3396 (yyval.expression)->set_location(yylloc);
3397 ;}
3398 break;
3399
3400 case 75:
3401
3402/* Line 1455 of yacc.c */
3403#line 604 "glsl_parser.ypp"
3404 {
3405 void *ctx = state;
3406 (yyval.expression) = new(ctx) ast_expression_bin(ast_logic_or, (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
3407 (yyval.expression)->set_location(yylloc);
3408 ;}
3409 break;
3410
3411 case 77:
3412
3413/* Line 1455 of yacc.c */
3414#line 614 "glsl_parser.ypp"
3415 {
3416 void *ctx = state;
3417 (yyval.expression) = new(ctx) ast_expression(ast_conditional, (yyvsp[(1) - (5)].expression), (yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].expression));
3418 (yyval.expression)->set_location(yylloc);
3419 ;}
3420 break;
3421
3422 case 79:
3423
3424/* Line 1455 of yacc.c */
3425#line 624 "glsl_parser.ypp"
3426 {
3427 void *ctx = state;
3428 (yyval.expression) = new(ctx) ast_expression((yyvsp[(2) - (3)].n), (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression), NULL);
3429 (yyval.expression)->set_location(yylloc);
3430 ;}
3431 break;
3432
3433 case 80:
3434
3435/* Line 1455 of yacc.c */
3436#line 632 "glsl_parser.ypp"
3437 { (yyval.n) = ast_assign; ;}
3438 break;
3439
3440 case 81:
3441
3442/* Line 1455 of yacc.c */
3443#line 633 "glsl_parser.ypp"
3444 { (yyval.n) = ast_mul_assign; ;}
3445 break;
3446
3447 case 82:
3448
3449/* Line 1455 of yacc.c */
3450#line 634 "glsl_parser.ypp"
3451 { (yyval.n) = ast_div_assign; ;}
3452 break;
3453
3454 case 83:
3455
3456/* Line 1455 of yacc.c */
3457#line 635 "glsl_parser.ypp"
3458 { (yyval.n) = ast_mod_assign; ;}
3459 break;
3460
3461 case 84:
3462
3463/* Line 1455 of yacc.c */
3464#line 636 "glsl_parser.ypp"
3465 { (yyval.n) = ast_add_assign; ;}
3466 break;
3467
3468 case 85:
3469
3470/* Line 1455 of yacc.c */
3471#line 637 "glsl_parser.ypp"
3472 { (yyval.n) = ast_sub_assign; ;}
3473 break;
3474
3475 case 86:
3476
3477/* Line 1455 of yacc.c */
3478#line 638 "glsl_parser.ypp"
3479 { (yyval.n) = ast_ls_assign; ;}
3480 break;
3481
3482 case 87:
3483
3484/* Line 1455 of yacc.c */
3485#line 639 "glsl_parser.ypp"
3486 { (yyval.n) = ast_rs_assign; ;}
3487 break;
3488
3489 case 88:
3490
3491/* Line 1455 of yacc.c */
3492#line 640 "glsl_parser.ypp"
3493 { (yyval.n) = ast_and_assign; ;}
3494 break;
3495
3496 case 89:
3497
3498/* Line 1455 of yacc.c */
3499#line 641 "glsl_parser.ypp"
3500 { (yyval.n) = ast_xor_assign; ;}
3501 break;
3502
3503 case 90:
3504
3505/* Line 1455 of yacc.c */
3506#line 642 "glsl_parser.ypp"
3507 { (yyval.n) = ast_or_assign; ;}
3508 break;
3509
3510 case 91:
3511
3512/* Line 1455 of yacc.c */
3513#line 647 "glsl_parser.ypp"
3514 {
3515 (yyval.expression) = (yyvsp[(1) - (1)].expression);
3516 ;}
3517 break;
3518
3519 case 92:
3520
3521/* Line 1455 of yacc.c */
3522#line 651 "glsl_parser.ypp"
3523 {
3524 void *ctx = state;
3525 if ((yyvsp[(1) - (3)].expression)->oper != ast_sequence) {
3526 (yyval.expression) = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
3527 (yyval.expression)->set_location(yylloc);
3528 (yyval.expression)->expressions.push_tail(& (yyvsp[(1) - (3)].expression)->link);
3529 } else {
3530 (yyval.expression) = (yyvsp[(1) - (3)].expression);
3531 }
3532
3533 (yyval.expression)->expressions.push_tail(& (yyvsp[(3) - (3)].expression)->link);
3534 ;}
3535 break;
3536
3537 case 94:
3538
3539/* Line 1455 of yacc.c */
3540#line 671 "glsl_parser.ypp"
3541 {
3542 (yyval.node) = (yyvsp[(1) - (2)].function);
3543 ;}
3544 break;
3545
3546 case 95:
3547
3548/* Line 1455 of yacc.c */
3549#line 675 "glsl_parser.ypp"
3550 {
3551 (yyval.node) = (yyvsp[(1) - (2)].declarator_list);
3552 ;}
3553 break;
3554
3555 case 96:
3556
3557/* Line 1455 of yacc.c */
3558#line 679 "glsl_parser.ypp"
3559 {
3560 if (((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_float)
3561 && ((yyvsp[(3) - (4)].type_specifier)->type_specifier != ast_int)) {
3562 _mesa_glsl_error(& (yylsp[(3) - (4)]), state, "global precision qualifier can "
3563 "only be applied to `int' or `float'\n");
3564 YYERROR;
3565 }
3566
3567 (yyval.node) = NULL; /* FINISHME */
3568 ;}
3569 break;
3570
3571 case 100:
3572
3573/* Line 1455 of yacc.c */
3574#line 702 "glsl_parser.ypp"
3575 {
3576 (yyval.function) = (yyvsp[(1) - (2)].function);
3577 (yyval.function)->parameters.push_tail(& (yyvsp[(2) - (2)].parameter_declarator)->link);
3578 ;}
3579 break;
3580
3581 case 101:
3582
3583/* Line 1455 of yacc.c */
3584#line 707 "glsl_parser.ypp"
3585 {
3586 (yyval.function) = (yyvsp[(1) - (3)].function);
3587 (yyval.function)->parameters.push_tail(& (yyvsp[(3) - (3)].parameter_declarator)->link);
3588 ;}
3589 break;
3590
3591 case 102:
3592
3593/* Line 1455 of yacc.c */
3594#line 715 "glsl_parser.ypp"
3595 {
3596 void *ctx = state;
3597 (yyval.function) = new(ctx) ast_function();
3598 (yyval.function)->set_location(yylloc);
3599 (yyval.function)->return_type = (yyvsp[(1) - (3)].fully_specified_type);
3600 (yyval.function)->identifier = (yyvsp[(2) - (3)].identifier);
3601 ;}
3602 break;
3603
3604 case 103:
3605
3606/* Line 1455 of yacc.c */
3607#line 726 "glsl_parser.ypp"
3608 {
3609 void *ctx = state;
3610 (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator();
3611 (yyval.parameter_declarator)->set_location(yylloc);
3612 (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type();
3613 (yyval.parameter_declarator)->type->set_location(yylloc);
3614 (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (2)].type_specifier);
3615 (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (2)].identifier);
3616 ;}
3617 break;
3618
3619 case 104:
3620
3621/* Line 1455 of yacc.c */
3622#line 736 "glsl_parser.ypp"
3623 {
3624 void *ctx = state;
3625 (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator();
3626 (yyval.parameter_declarator)->set_location(yylloc);
3627 (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type();
3628 (yyval.parameter_declarator)->type->set_location(yylloc);
3629 (yyval.parameter_declarator)->type->specifier = (yyvsp[(1) - (5)].type_specifier);
3630 (yyval.parameter_declarator)->identifier = (yyvsp[(2) - (5)].identifier);
3631 (yyval.parameter_declarator)->is_array = true;
3632 (yyval.parameter_declarator)->array_size = (yyvsp[(4) - (5)].expression);
3633 ;}
3634 break;
3635
3636 case 105:
3637
3638/* Line 1455 of yacc.c */
3639#line 751 "glsl_parser.ypp"
3640 {
3641 (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i;
3642
3643 (yyval.parameter_declarator) = (yyvsp[(3) - (3)].parameter_declarator);
3644 (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier).q;
3645 ;}
3646 break;
3647
3648 case 106:
3649
3650/* Line 1455 of yacc.c */
3651#line 758 "glsl_parser.ypp"
3652 {
3653 (yyval.parameter_declarator) = (yyvsp[(2) - (2)].parameter_declarator);
3654 (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q;
3655 ;}
3656 break;
3657
3658 case 107:
3659
3660/* Line 1455 of yacc.c */
3661#line 763 "glsl_parser.ypp"
3662 {
3663 void *ctx = state;
3664 (yyvsp[(1) - (3)].type_qualifier).i |= (yyvsp[(2) - (3)].type_qualifier).i;
3665
3666 (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator();
3667 (yyval.parameter_declarator)->set_location(yylloc);
3668 (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type();
3669 (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (3)].type_qualifier).q;
3670 (yyval.parameter_declarator)->type->specifier = (yyvsp[(3) - (3)].type_specifier);
3671 ;}
3672 break;
3673
3674 case 108:
3675
3676/* Line 1455 of yacc.c */
3677#line 774 "glsl_parser.ypp"
3678 {
3679 void *ctx = state;
3680 (yyval.parameter_declarator) = new(ctx) ast_parameter_declarator();
3681 (yyval.parameter_declarator)->set_location(yylloc);
3682 (yyval.parameter_declarator)->type = new(ctx) ast_fully_specified_type();
3683 (yyval.parameter_declarator)->type->qualifier = (yyvsp[(1) - (2)].type_qualifier).q;
3684 (yyval.parameter_declarator)->type->specifier = (yyvsp[(2) - (2)].type_specifier);
3685 ;}
3686 break;
3687
3688 case 109:
3689
3690/* Line 1455 of yacc.c */
3691#line 785 "glsl_parser.ypp"
3692 { (yyval.type_qualifier).i = 0; ;}
3693 break;
3694
3695 case 110:
3696
3697/* Line 1455 of yacc.c */
3698#line 786 "glsl_parser.ypp"
3699 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;}
3700 break;
3701
3702 case 111:
3703
3704/* Line 1455 of yacc.c */
3705#line 787 "glsl_parser.ypp"
3706 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;}
3707 break;
3708
3709 case 112:
3710
3711/* Line 1455 of yacc.c */
3712#line 788 "glsl_parser.ypp"
3713 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; (yyval.type_qualifier).q.out = 1; ;}
3714 break;
3715
3716 case 115:
3717
3718/* Line 1455 of yacc.c */
3719#line 798 "glsl_parser.ypp"
3720 {
3721 void *ctx = state;
3722 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (3)].identifier), false, NULL, NULL);
3723 decl->set_location(yylloc);
3724
3725 (yyval.declarator_list) = (yyvsp[(1) - (3)].declarator_list);
3726 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3727 ;}
3728 break;
3729
3730 case 116:
3731
3732/* Line 1455 of yacc.c */
3733#line 807 "glsl_parser.ypp"
3734 {
3735 void *ctx = state;
3736 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), true, NULL, NULL);
3737 decl->set_location(yylloc);
3738
3739 (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list);
3740 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3741 ;}
3742 break;
3743
3744 case 117:
3745
3746/* Line 1455 of yacc.c */
3747#line 816 "glsl_parser.ypp"
3748 {
3749 void *ctx = state;
3750 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (6)].identifier), true, (yyvsp[(5) - (6)].expression), NULL);
3751 decl->set_location(yylloc);
3752
3753 (yyval.declarator_list) = (yyvsp[(1) - (6)].declarator_list);
3754 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3755 ;}
3756 break;
3757
3758 case 118:
3759
3760/* Line 1455 of yacc.c */
3761#line 825 "glsl_parser.ypp"
3762 {
3763 void *ctx = state;
3764 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (7)].identifier), true, NULL, (yyvsp[(7) - (7)].expression));
3765 decl->set_location(yylloc);
3766
3767 (yyval.declarator_list) = (yyvsp[(1) - (7)].declarator_list);
3768 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3769 ;}
3770 break;
3771
3772 case 119:
3773
3774/* Line 1455 of yacc.c */
3775#line 834 "glsl_parser.ypp"
3776 {
3777 void *ctx = state;
3778 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (8)].identifier), true, (yyvsp[(5) - (8)].expression), (yyvsp[(8) - (8)].expression));
3779 decl->set_location(yylloc);
3780
3781 (yyval.declarator_list) = (yyvsp[(1) - (8)].declarator_list);
3782 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3783 ;}
3784 break;
3785
3786 case 120:
3787
3788/* Line 1455 of yacc.c */
3789#line 843 "glsl_parser.ypp"
3790 {
3791 void *ctx = state;
3792 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(3) - (5)].identifier), false, NULL, (yyvsp[(5) - (5)].expression));
3793 decl->set_location(yylloc);
3794
3795 (yyval.declarator_list) = (yyvsp[(1) - (5)].declarator_list);
3796 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3797 ;}
3798 break;
3799
3800 case 121:
3801
3802/* Line 1455 of yacc.c */
3803#line 856 "glsl_parser.ypp"
3804 {
3805 void *ctx = state;
3806 if ((yyvsp[(1) - (1)].fully_specified_type)->specifier->type_specifier != ast_struct) {
3807 _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "empty declaration list\n");
3808 YYERROR;
3809 } else {
3810 (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (1)].fully_specified_type));
3811 (yyval.declarator_list)->set_location(yylloc);
3812 }
3813 ;}
3814 break;
3815
3816 case 122:
3817
3818/* Line 1455 of yacc.c */
3819#line 867 "glsl_parser.ypp"
3820 {
3821 void *ctx = state;
3822 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL);
3823
3824 (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (2)].fully_specified_type));
3825 (yyval.declarator_list)->set_location(yylloc);
3826 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3827 ;}
3828 break;
3829
3830 case 123:
3831
3832/* Line 1455 of yacc.c */
3833#line 876 "glsl_parser.ypp"
3834 {
3835 void *ctx = state;
3836 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), true, NULL, NULL);
3837
3838 (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type));
3839 (yyval.declarator_list)->set_location(yylloc);
3840 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3841 ;}
3842 break;
3843
3844 case 124:
3845
3846/* Line 1455 of yacc.c */
3847#line 885 "glsl_parser.ypp"
3848 {
3849 void *ctx = state;
3850 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (5)].identifier), true, (yyvsp[(4) - (5)].expression), NULL);
3851
3852 (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (5)].fully_specified_type));
3853 (yyval.declarator_list)->set_location(yylloc);
3854 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3855 ;}
3856 break;
3857
3858 case 125:
3859
3860/* Line 1455 of yacc.c */
3861#line 894 "glsl_parser.ypp"
3862 {
3863 void *ctx = state;
3864 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (6)].identifier), true, NULL, (yyvsp[(6) - (6)].expression));
3865
3866 (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (6)].fully_specified_type));
3867 (yyval.declarator_list)->set_location(yylloc);
3868 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3869 ;}
3870 break;
3871
3872 case 126:
3873
3874/* Line 1455 of yacc.c */
3875#line 903 "glsl_parser.ypp"
3876 {
3877 void *ctx = state;
3878 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (7)].identifier), true, (yyvsp[(4) - (7)].expression), (yyvsp[(7) - (7)].expression));
3879
3880 (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (7)].fully_specified_type));
3881 (yyval.declarator_list)->set_location(yylloc);
3882 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3883 ;}
3884 break;
3885
3886 case 127:
3887
3888/* Line 1455 of yacc.c */
3889#line 912 "glsl_parser.ypp"
3890 {
3891 void *ctx = state;
3892 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression));
3893
3894 (yyval.declarator_list) = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type));
3895 (yyval.declarator_list)->set_location(yylloc);
3896 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3897 ;}
3898 break;
3899
3900 case 128:
3901
3902/* Line 1455 of yacc.c */
3903#line 921 "glsl_parser.ypp"
3904 {
3905 void *ctx = state;
3906 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (2)].identifier), false, NULL, NULL);
3907
3908 (yyval.declarator_list) = new(ctx) ast_declarator_list(NULL);
3909 (yyval.declarator_list)->set_location(yylloc);
3910 (yyval.declarator_list)->invariant = true;
3911
3912 (yyval.declarator_list)->declarations.push_tail(&decl->link);
3913 ;}
3914 break;
3915
3916 case 129:
3917
3918/* Line 1455 of yacc.c */
3919#line 935 "glsl_parser.ypp"
3920 {
3921 void *ctx = state;
3922 (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type();
3923 (yyval.fully_specified_type)->set_location(yylloc);
3924 (yyval.fully_specified_type)->specifier = (yyvsp[(1) - (1)].type_specifier);
3925 ;}
3926 break;
3927
3928 case 130:
3929
3930/* Line 1455 of yacc.c */
3931#line 942 "glsl_parser.ypp"
3932 {
3933 void *ctx = state;
3934 (yyval.fully_specified_type) = new(ctx) ast_fully_specified_type();
3935 (yyval.fully_specified_type)->set_location(yylloc);
3936 (yyval.fully_specified_type)->qualifier = (yyvsp[(1) - (2)].type_qualifier).q;
3937 (yyval.fully_specified_type)->specifier = (yyvsp[(2) - (2)].type_specifier);
3938 ;}
3939 break;
3940
3941 case 131:
3942
3943/* Line 1455 of yacc.c */
3944#line 952 "glsl_parser.ypp"
3945 { (yyval.type_qualifier).i = 0; ;}
3946 break;
3947
3948 case 133:
3949
3950/* Line 1455 of yacc.c */
3951#line 958 "glsl_parser.ypp"
3952 {
3953 (yyval.type_qualifier) = (yyvsp[(3) - (4)].type_qualifier);
3954 ;}
3955 break;
3956
3957 case 135:
3958
3959/* Line 1455 of yacc.c */
3960#line 966 "glsl_parser.ypp"
3961 {
3962 (yyval.type_qualifier).i = (yyvsp[(1) - (3)].type_qualifier).i | (yyvsp[(3) - (3)].type_qualifier).i;
3963 ;}
3964 break;
3965
3966 case 136:
3967
3968/* Line 1455 of yacc.c */
3969#line 973 "glsl_parser.ypp"
3970 {
3971 (yyval.type_qualifier).i = 0;
3972
3973 if (state->ARB_fragment_coord_conventions_enable) {
3974 bool got_one = false;
3975
3976 if (strcmp((yyvsp[(1) - (1)].identifier), "origin_upper_left") == 0) {
3977 got_one = true;
3978 (yyval.type_qualifier).q.origin_upper_left = 1;
3979 } else if (strcmp((yyvsp[(1) - (1)].identifier), "pixel_center_integer") == 0) {
3980 got_one = true;
3981 (yyval.type_qualifier).q.pixel_center_integer = 1;
3982 }
3983
3984 if (state->ARB_fragment_coord_conventions_warn && got_one) {
3985 _mesa_glsl_warning(& (yylsp[(1) - (1)]), state,
3986 "GL_ARB_fragment_coord_conventions layout "
3987 "identifier `%s' used\n", (yyvsp[(1) - (1)].identifier));
3988 }
3989 }
3990
3991 /* If the identifier didn't match any known layout identifiers,
3992 * emit an error.
3993 */
3994 if ((yyval.type_qualifier).i == 0) {
3995 _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "unrecognized layout identifier "
3996 "`%s'\n", (yyvsp[(1) - (1)].identifier));
3997 YYERROR;
3998 }
3999 ;}
4000 break;
4001
4002 case 137:
4003
4004/* Line 1455 of yacc.c */
4005#line 1006 "glsl_parser.ypp"
4006 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.smooth = 1; ;}
4007 break;
4008
4009 case 138:
4010
4011/* Line 1455 of yacc.c */
4012#line 1007 "glsl_parser.ypp"
4013 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.flat = 1; ;}
4014 break;
4015
4016 case 139:
4017
4018/* Line 1455 of yacc.c */
4019#line 1008 "glsl_parser.ypp"
4020 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.noperspective = 1; ;}
4021 break;
4022
4023 case 140:
4024
4025/* Line 1455 of yacc.c */
4026#line 1012 "glsl_parser.ypp"
4027 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;}
4028 break;
4029
4030 case 142:
4031
4032/* Line 1455 of yacc.c */
4033#line 1018 "glsl_parser.ypp"
4034 {
4035 (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i | (yyvsp[(2) - (2)].type_qualifier).i;
4036 ;}
4037 break;
4038
4039 case 143:
4040
4041/* Line 1455 of yacc.c */
4042#line 1022 "glsl_parser.ypp"
4043 {
4044 (yyval.type_qualifier) = (yyvsp[(2) - (2)].type_qualifier);
4045 (yyval.type_qualifier).q.invariant = 1;
4046 ;}
4047 break;
4048
4049 case 144:
4050
4051/* Line 1455 of yacc.c */
4052#line 1029 "glsl_parser.ypp"
4053 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.constant = 1; ;}
4054 break;
4055
4056 case 145:
4057
4058/* Line 1455 of yacc.c */
4059#line 1030 "glsl_parser.ypp"
4060 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.attribute = 1; ;}
4061 break;
4062
4063 case 146:
4064
4065/* Line 1455 of yacc.c */
4066#line 1031 "glsl_parser.ypp"
4067 { (yyval.type_qualifier).i = (yyvsp[(1) - (2)].type_qualifier).i; (yyval.type_qualifier).q.varying = 1; ;}
4068 break;
4069
4070 case 147:
4071
4072/* Line 1455 of yacc.c */
4073#line 1032 "glsl_parser.ypp"
4074 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.varying = 1; ;}
4075 break;
4076
4077 case 148:
4078
4079/* Line 1455 of yacc.c */
4080#line 1033 "glsl_parser.ypp"
4081 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.in = 1; ;}
4082 break;
4083
4084 case 149:
4085
4086/* Line 1455 of yacc.c */
4087#line 1034 "glsl_parser.ypp"
4088 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.out = 1; ;}
4089 break;
4090
4091 case 150:
4092
4093/* Line 1455 of yacc.c */
4094#line 1035 "glsl_parser.ypp"
4095 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.in = 1; ;}
4096 break;
4097
4098 case 151:
4099
4100/* Line 1455 of yacc.c */
4101#line 1036 "glsl_parser.ypp"
4102 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.centroid = 1; (yyval.type_qualifier).q.out = 1; ;}
4103 break;
4104
4105 case 152:
4106
4107/* Line 1455 of yacc.c */
4108#line 1037 "glsl_parser.ypp"
4109 { (yyval.type_qualifier).i = 0; (yyval.type_qualifier).q.uniform = 1; ;}
4110 break;
4111
4112 case 154:
4113
4114/* Line 1455 of yacc.c */
4115#line 1043 "glsl_parser.ypp"
4116 {
4117 (yyval.type_specifier) = (yyvsp[(2) - (2)].type_specifier);
4118 (yyval.type_specifier)->precision = (yyvsp[(1) - (2)].n);
4119 ;}
4120 break;
4121
4122 case 156:
4123
4124/* Line 1455 of yacc.c */
4125#line 1052 "glsl_parser.ypp"
4126 {
4127 (yyval.type_specifier) = (yyvsp[(1) - (3)].type_specifier);
4128 (yyval.type_specifier)->is_array = true;
4129 (yyval.type_specifier)->array_size = NULL;
4130 ;}
4131 break;
4132
4133 case 157:
4134
4135/* Line 1455 of yacc.c */
4136#line 1058 "glsl_parser.ypp"
4137 {
4138 (yyval.type_specifier) = (yyvsp[(1) - (4)].type_specifier);
4139 (yyval.type_specifier)->is_array = true;
4140 (yyval.type_specifier)->array_size = (yyvsp[(3) - (4)].expression);
4141 ;}
4142 break;
4143
4144 case 158:
4145
4146/* Line 1455 of yacc.c */
4147#line 1067 "glsl_parser.ypp"
4148 {
4149 void *ctx = state;
4150 (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].n));
4151 (yyval.type_specifier)->set_location(yylloc);
4152 ;}
4153 break;
4154
4155 case 159:
4156
4157/* Line 1455 of yacc.c */
4158#line 1073 "glsl_parser.ypp"
4159 {
4160 void *ctx = state;
4161 (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].struct_specifier));
4162 (yyval.type_specifier)->set_location(yylloc);
4163 ;}
4164 break;
4165
4166 case 160:
4167
4168/* Line 1455 of yacc.c */
4169#line 1079 "glsl_parser.ypp"
4170 {
4171 void *ctx = state;
4172 (yyval.type_specifier) = new(ctx) ast_type_specifier((yyvsp[(1) - (1)].identifier));
4173 (yyval.type_specifier)->set_location(yylloc);
4174 ;}
4175 break;
4176
4177 case 161:
4178
4179/* Line 1455 of yacc.c */
4180#line 1087 "glsl_parser.ypp"
4181 { (yyval.n) = ast_void; ;}
4182 break;
4183
4184 case 162:
4185
4186/* Line 1455 of yacc.c */
4187#line 1088 "glsl_parser.ypp"
4188 { (yyval.n) = ast_float; ;}
4189 break;
4190
4191 case 163:
4192
4193/* Line 1455 of yacc.c */
4194#line 1089 "glsl_parser.ypp"
4195 { (yyval.n) = ast_int; ;}
4196 break;
4197
4198 case 164:
4199
4200/* Line 1455 of yacc.c */
4201#line 1090 "glsl_parser.ypp"
4202 { (yyval.n) = ast_uint; ;}
4203 break;
4204
4205 case 165:
4206
4207/* Line 1455 of yacc.c */
4208#line 1091 "glsl_parser.ypp"
4209 { (yyval.n) = ast_bool; ;}
4210 break;
4211
4212 case 166:
4213
4214/* Line 1455 of yacc.c */
4215#line 1092 "glsl_parser.ypp"
4216 { (yyval.n) = ast_vec2; ;}
4217 break;
4218
4219 case 167:
4220
4221/* Line 1455 of yacc.c */
4222#line 1093 "glsl_parser.ypp"
4223 { (yyval.n) = ast_vec3; ;}
4224 break;
4225
4226 case 168:
4227
4228/* Line 1455 of yacc.c */
4229#line 1094 "glsl_parser.ypp"
4230 { (yyval.n) = ast_vec4; ;}
4231 break;
4232
4233 case 169:
4234
4235/* Line 1455 of yacc.c */
4236#line 1095 "glsl_parser.ypp"
4237 { (yyval.n) = ast_bvec2; ;}
4238 break;
4239
4240 case 170:
4241
4242/* Line 1455 of yacc.c */
4243#line 1096 "glsl_parser.ypp"
4244 { (yyval.n) = ast_bvec3; ;}
4245 break;
4246
4247 case 171:
4248
4249/* Line 1455 of yacc.c */
4250#line 1097 "glsl_parser.ypp"
4251 { (yyval.n) = ast_bvec4; ;}
4252 break;
4253
4254 case 172:
4255
4256/* Line 1455 of yacc.c */
4257#line 1098 "glsl_parser.ypp"
4258 { (yyval.n) = ast_ivec2; ;}
4259 break;
4260
4261 case 173:
4262
4263/* Line 1455 of yacc.c */
4264#line 1099 "glsl_parser.ypp"
4265 { (yyval.n) = ast_ivec3; ;}
4266 break;
4267
4268 case 174:
4269
4270/* Line 1455 of yacc.c */
4271#line 1100 "glsl_parser.ypp"
4272 { (yyval.n) = ast_ivec4; ;}
4273 break;
4274
4275 case 175:
4276
4277/* Line 1455 of yacc.c */
4278#line 1101 "glsl_parser.ypp"
4279 { (yyval.n) = ast_uvec2; ;}
4280 break;
4281
4282 case 176:
4283
4284/* Line 1455 of yacc.c */
4285#line 1102 "glsl_parser.ypp"
4286 { (yyval.n) = ast_uvec3; ;}
4287 break;
4288
4289 case 177:
4290
4291/* Line 1455 of yacc.c */
4292#line 1103 "glsl_parser.ypp"
4293 { (yyval.n) = ast_uvec4; ;}
4294 break;
4295
4296 case 178:
4297
4298/* Line 1455 of yacc.c */
4299#line 1104 "glsl_parser.ypp"
4300 { (yyval.n) = ast_mat2; ;}
4301 break;
4302
4303 case 179:
4304
4305/* Line 1455 of yacc.c */
4306#line 1105 "glsl_parser.ypp"
4307 { (yyval.n) = ast_mat2x3; ;}
4308 break;
4309
4310 case 180:
4311
4312/* Line 1455 of yacc.c */
4313#line 1106 "glsl_parser.ypp"
4314 { (yyval.n) = ast_mat2x4; ;}
4315 break;
4316
4317 case 181:
4318
4319/* Line 1455 of yacc.c */
4320#line 1107 "glsl_parser.ypp"
4321 { (yyval.n) = ast_mat3x2; ;}
4322 break;
4323
4324 case 182:
4325
4326/* Line 1455 of yacc.c */
4327#line 1108 "glsl_parser.ypp"
4328 { (yyval.n) = ast_mat3; ;}
4329 break;
4330
4331 case 183:
4332
4333/* Line 1455 of yacc.c */
4334#line 1109 "glsl_parser.ypp"
4335 { (yyval.n) = ast_mat3x4; ;}
4336 break;
4337
4338 case 184:
4339
4340/* Line 1455 of yacc.c */
4341#line 1110 "glsl_parser.ypp"
4342 { (yyval.n) = ast_mat4x2; ;}
4343 break;
4344
4345 case 185:
4346
4347/* Line 1455 of yacc.c */
4348#line 1111 "glsl_parser.ypp"
4349 { (yyval.n) = ast_mat4x3; ;}
4350 break;
4351
4352 case 186:
4353
4354/* Line 1455 of yacc.c */
4355#line 1112 "glsl_parser.ypp"
4356 { (yyval.n) = ast_mat4; ;}
4357 break;
4358
4359 case 187:
4360
4361/* Line 1455 of yacc.c */
4362#line 1113 "glsl_parser.ypp"
4363 { (yyval.n) = ast_sampler1d; ;}
4364 break;
4365
4366 case 188:
4367
4368/* Line 1455 of yacc.c */
4369#line 1114 "glsl_parser.ypp"
4370 { (yyval.n) = ast_sampler2d; ;}
4371 break;
4372
4373 case 189:
4374
4375/* Line 1455 of yacc.c */
4376#line 1115 "glsl_parser.ypp"
4377 { (yyval.n) = ast_sampler2drect; ;}
4378 break;
4379
4380 case 190:
4381
4382/* Line 1455 of yacc.c */
4383#line 1116 "glsl_parser.ypp"
4384 { (yyval.n) = ast_sampler3d; ;}
4385 break;
4386
4387 case 191:
4388
4389/* Line 1455 of yacc.c */
4390#line 1117 "glsl_parser.ypp"
4391 { (yyval.n) = ast_samplercube; ;}
4392 break;
4393
4394 case 192:
4395
4396/* Line 1455 of yacc.c */
4397#line 1118 "glsl_parser.ypp"
4398 { (yyval.n) = ast_sampler1dshadow; ;}
4399 break;
4400
4401 case 193:
4402
4403/* Line 1455 of yacc.c */
4404#line 1119 "glsl_parser.ypp"
4405 { (yyval.n) = ast_sampler2dshadow; ;}
4406 break;
4407
4408 case 194:
4409
4410/* Line 1455 of yacc.c */
4411#line 1120 "glsl_parser.ypp"
4412 { (yyval.n) = ast_sampler2drectshadow; ;}
4413 break;
4414
4415 case 195:
4416
4417/* Line 1455 of yacc.c */
4418#line 1121 "glsl_parser.ypp"
4419 { (yyval.n) = ast_samplercubeshadow; ;}
4420 break;
4421
4422 case 196:
4423
4424/* Line 1455 of yacc.c */
4425#line 1122 "glsl_parser.ypp"
4426 { (yyval.n) = ast_sampler1darray; ;}
4427 break;
4428
4429 case 197:
4430
4431/* Line 1455 of yacc.c */
4432#line 1123 "glsl_parser.ypp"
4433 { (yyval.n) = ast_sampler2darray; ;}
4434 break;
4435
4436 case 198:
4437
4438/* Line 1455 of yacc.c */
4439#line 1124 "glsl_parser.ypp"
4440 { (yyval.n) = ast_sampler1darrayshadow; ;}
4441 break;
4442
4443 case 199:
4444
4445/* Line 1455 of yacc.c */
4446#line 1125 "glsl_parser.ypp"
4447 { (yyval.n) = ast_sampler2darrayshadow; ;}
4448 break;
4449
4450 case 200:
4451
4452/* Line 1455 of yacc.c */
4453#line 1126 "glsl_parser.ypp"
4454 { (yyval.n) = ast_isampler1d; ;}
4455 break;
4456
4457 case 201:
4458
4459/* Line 1455 of yacc.c */
4460#line 1127 "glsl_parser.ypp"
4461 { (yyval.n) = ast_isampler2d; ;}
4462 break;
4463
4464 case 202:
4465
4466/* Line 1455 of yacc.c */
4467#line 1128 "glsl_parser.ypp"
4468 { (yyval.n) = ast_isampler3d; ;}
4469 break;
4470
4471 case 203:
4472
4473/* Line 1455 of yacc.c */
4474#line 1129 "glsl_parser.ypp"
4475 { (yyval.n) = ast_isamplercube; ;}
4476 break;
4477
4478 case 204:
4479
4480/* Line 1455 of yacc.c */
4481#line 1130 "glsl_parser.ypp"
4482 { (yyval.n) = ast_isampler1darray; ;}
4483 break;
4484
4485 case 205:
4486
4487/* Line 1455 of yacc.c */
4488#line 1131 "glsl_parser.ypp"
4489 { (yyval.n) = ast_isampler2darray; ;}
4490 break;
4491
4492 case 206:
4493
4494/* Line 1455 of yacc.c */
4495#line 1132 "glsl_parser.ypp"
4496 { (yyval.n) = ast_usampler1d; ;}
4497 break;
4498
4499 case 207:
4500
4501/* Line 1455 of yacc.c */
4502#line 1133 "glsl_parser.ypp"
4503 { (yyval.n) = ast_usampler2d; ;}
4504 break;
4505
4506 case 208:
4507
4508/* Line 1455 of yacc.c */
4509#line 1134 "glsl_parser.ypp"
4510 { (yyval.n) = ast_usampler3d; ;}
4511 break;
4512
4513 case 209:
4514
4515/* Line 1455 of yacc.c */
4516#line 1135 "glsl_parser.ypp"
4517 { (yyval.n) = ast_usamplercube; ;}
4518 break;
4519
4520 case 210:
4521
4522/* Line 1455 of yacc.c */
4523#line 1136 "glsl_parser.ypp"
4524 { (yyval.n) = ast_usampler1darray; ;}
4525 break;
4526
4527 case 211:
4528
4529/* Line 1455 of yacc.c */
4530#line 1137 "glsl_parser.ypp"
4531 { (yyval.n) = ast_usampler2darray; ;}
4532 break;
4533
4534 case 212:
4535
4536/* Line 1455 of yacc.c */
4537#line 1141 "glsl_parser.ypp"
4538 {
4539 if (state->language_version < 130)
4540 _mesa_glsl_error(& (yylsp[(1) - (1)]), state,
4541 "precision qualifier forbidden "
4542 "in GLSL %d.%d (1.30 or later "
4543 "required)\n",
4544 state->language_version / 100,
4545 state->language_version % 100);
4546
4547 (yyval.n) = ast_precision_high;
4548 ;}
4549 break;
4550
4551 case 213:
4552
4553/* Line 1455 of yacc.c */
4554#line 1152 "glsl_parser.ypp"
4555 {
4556 if (state->language_version < 130)
4557 _mesa_glsl_error(& (yylsp[(1) - (1)]), state,
4558 "precision qualifier forbidden "
4559 "in GLSL %d.%d (1.30 or later "
4560 "required)\n",
4561 state->language_version / 100,
4562 state->language_version % 100);
4563
4564 (yyval.n) = ast_precision_medium;
4565 ;}
4566 break;
4567
4568 case 214:
4569
4570/* Line 1455 of yacc.c */
4571#line 1163 "glsl_parser.ypp"
4572 {
4573 if (state->language_version < 130)
4574 _mesa_glsl_error(& (yylsp[(1) - (1)]), state,
4575 "precision qualifier forbidden "
4576 "in GLSL %d.%d (1.30 or later "
4577 "required)\n",
4578 state->language_version / 100,
4579 state->language_version % 100);
4580
4581 (yyval.n) = ast_precision_low;
4582 ;}
4583 break;
4584
4585 case 215:
4586
4587/* Line 1455 of yacc.c */
4588#line 1178 "glsl_parser.ypp"
4589 {
4590 void *ctx = state;
4591 (yyval.struct_specifier) = new(ctx) ast_struct_specifier((yyvsp[(2) - (5)].identifier), (yyvsp[(4) - (5)].node));
4592 (yyval.struct_specifier)->set_location(yylloc);
4593 ;}
4594 break;
4595
4596 case 216:
4597
4598/* Line 1455 of yacc.c */
4599#line 1184 "glsl_parser.ypp"
4600 {
4601 void *ctx = state;
4602 (yyval.struct_specifier) = new(ctx) ast_struct_specifier(NULL, (yyvsp[(3) - (4)].node));
4603 (yyval.struct_specifier)->set_location(yylloc);
4604 ;}
4605 break;
4606
4607 case 217:
4608
4609/* Line 1455 of yacc.c */
4610#line 1193 "glsl_parser.ypp"
4611 {
4612 (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].declarator_list);
4613 (yyvsp[(1) - (1)].declarator_list)->link.self_link();
4614 ;}
4615 break;
4616
4617 case 218:
4618
4619/* Line 1455 of yacc.c */
4620#line 1198 "glsl_parser.ypp"
4621 {
4622 (yyval.node) = (ast_node *) (yyvsp[(1) - (2)].node);
4623 (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].declarator_list)->link);
4624 ;}
4625 break;
4626
4627 case 219:
4628
4629/* Line 1455 of yacc.c */
4630#line 1206 "glsl_parser.ypp"
4631 {
4632 void *ctx = state;
4633 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
4634 type->set_location(yylloc);
4635
4636 type->specifier = (yyvsp[(1) - (3)].type_specifier);
4637 (yyval.declarator_list) = new(ctx) ast_declarator_list(type);
4638 (yyval.declarator_list)->set_location(yylloc);
4639
4640 (yyval.declarator_list)->declarations.push_degenerate_list_at_head(& (yyvsp[(2) - (3)].declaration)->link);
4641 ;}
4642 break;
4643
4644 case 220:
4645
4646/* Line 1455 of yacc.c */
4647#line 1221 "glsl_parser.ypp"
4648 {
4649 (yyval.declaration) = (yyvsp[(1) - (1)].declaration);
4650 (yyvsp[(1) - (1)].declaration)->link.self_link();
4651 ;}
4652 break;
4653
4654 case 221:
4655
4656/* Line 1455 of yacc.c */
4657#line 1226 "glsl_parser.ypp"
4658 {
4659 (yyval.declaration) = (yyvsp[(1) - (3)].declaration);
4660 (yyval.declaration)->link.insert_before(& (yyvsp[(3) - (3)].declaration)->link);
4661 ;}
4662 break;
4663
4664 case 222:
4665
4666/* Line 1455 of yacc.c */
4667#line 1234 "glsl_parser.ypp"
4668 {
4669 void *ctx = state;
4670 (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (1)].identifier), false, NULL, NULL);
4671 (yyval.declaration)->set_location(yylloc);
4672 ;}
4673 break;
4674
4675 case 223:
4676
4677/* Line 1455 of yacc.c */
4678#line 1240 "glsl_parser.ypp"
4679 {
4680 void *ctx = state;
4681 (yyval.declaration) = new(ctx) ast_declaration((yyvsp[(1) - (4)].identifier), true, (yyvsp[(3) - (4)].expression), NULL);
4682 (yyval.declaration)->set_location(yylloc);
4683 ;}
4684 break;
4685
4686 case 228:
4687
4688/* Line 1455 of yacc.c */
4689#line 1263 "glsl_parser.ypp"
4690 { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;}
4691 break;
4692
4693 case 234:
4694
4695/* Line 1455 of yacc.c */
4696#line 1275 "glsl_parser.ypp"
4697 { (yyval.node) = NULL; ;}
4698 break;
4699
4700 case 235:
4701
4702/* Line 1455 of yacc.c */
4703#line 1276 "glsl_parser.ypp"
4704 { (yyval.node) = NULL; ;}
4705 break;
4706
4707 case 238:
4708
4709/* Line 1455 of yacc.c */
4710#line 1283 "glsl_parser.ypp"
4711 {
4712 void *ctx = state;
4713 (yyval.compound_statement) = new(ctx) ast_compound_statement(true, NULL);
4714 (yyval.compound_statement)->set_location(yylloc);
4715 ;}
4716 break;
4717
4718 case 239:
4719
4720/* Line 1455 of yacc.c */
4721#line 1289 "glsl_parser.ypp"
4722 {
4723 void *ctx = state;
4724 (yyval.compound_statement) = new(ctx) ast_compound_statement(true, (yyvsp[(2) - (3)].node));
4725 (yyval.compound_statement)->set_location(yylloc);
4726 ;}
4727 break;
4728
4729 case 240:
4730
4731/* Line 1455 of yacc.c */
4732#line 1297 "glsl_parser.ypp"
4733 { (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].compound_statement); ;}
4734 break;
4735
4736 case 242:
4737
4738/* Line 1455 of yacc.c */
4739#line 1303 "glsl_parser.ypp"
4740 {
4741 void *ctx = state;
4742 (yyval.compound_statement) = new(ctx) ast_compound_statement(false, NULL);
4743 (yyval.compound_statement)->set_location(yylloc);
4744 ;}
4745 break;
4746
4747 case 243:
4748
4749/* Line 1455 of yacc.c */
4750#line 1309 "glsl_parser.ypp"
4751 {
4752 void *ctx = state;
4753 (yyval.compound_statement) = new(ctx) ast_compound_statement(false, (yyvsp[(2) - (3)].node));
4754 (yyval.compound_statement)->set_location(yylloc);
4755 ;}
4756 break;
4757
4758 case 244:
4759
4760/* Line 1455 of yacc.c */
4761#line 1318 "glsl_parser.ypp"
4762 {
4763 if ((yyvsp[(1) - (1)].node) == NULL) {
4764 _mesa_glsl_error(& (yylsp[(1) - (1)]), state, "<nil> statement\n");
4765 assert((yyvsp[(1) - (1)].node) != NULL);
4766 }
4767
4768 (yyval.node) = (yyvsp[(1) - (1)].node);
4769 (yyval.node)->link.self_link();
4770 ;}
4771 break;
4772
4773 case 245:
4774
4775/* Line 1455 of yacc.c */
4776#line 1328 "glsl_parser.ypp"
4777 {
4778 if ((yyvsp[(2) - (2)].node) == NULL) {
4779 _mesa_glsl_error(& (yylsp[(2) - (2)]), state, "<nil> statement\n");
4780 assert((yyvsp[(2) - (2)].node) != NULL);
4781 }
4782 (yyval.node) = (yyvsp[(1) - (2)].node);
4783 (yyval.node)->link.insert_before(& (yyvsp[(2) - (2)].node)->link);
4784 ;}
4785 break;
4786
4787 case 246:
4788
4789/* Line 1455 of yacc.c */
4790#line 1340 "glsl_parser.ypp"
4791 {
4792 void *ctx = state;
4793 (yyval.node) = new(ctx) ast_expression_statement(NULL);
4794 (yyval.node)->set_location(yylloc);
4795 ;}
4796 break;
4797
4798 case 247:
4799
4800/* Line 1455 of yacc.c */
4801#line 1346 "glsl_parser.ypp"
4802 {
4803 void *ctx = state;
4804 (yyval.node) = new(ctx) ast_expression_statement((yyvsp[(1) - (2)].expression));
4805 (yyval.node)->set_location(yylloc);
4806 ;}
4807 break;
4808
4809 case 248:
4810
4811/* Line 1455 of yacc.c */
4812#line 1355 "glsl_parser.ypp"
4813 {
4814 void *ctx = state;
4815 (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node));
4816 (yyval.node)->set_location(yylloc);
4817 ;}
4818 break;
4819
4820 case 249:
4821
4822/* Line 1455 of yacc.c */
4823#line 1364 "glsl_parser.ypp"
4824 {
4825 void *ctx = state;
4826 (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL);
4827 (yyval.node)->set_location(yylloc);
4828 ;}
4829 break;
4830
4831 case 250:
4832
4833/* Line 1455 of yacc.c */
4834#line 1370 "glsl_parser.ypp"
4835 {
4836 void *ctx = state;
4837 (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (5)].expression), (yyvsp[(5) - (5)].node), NULL);
4838 (yyval.node)->set_location(yylloc);
4839 ;}
4840 break;
4841
4842 case 251:
4843
4844/* Line 1455 of yacc.c */
4845#line 1376 "glsl_parser.ypp"
4846 {
4847 void *ctx = state;
4848 (yyval.node) = new(ctx) ast_selection_statement((yyvsp[(3) - (7)].expression), (yyvsp[(5) - (7)].node), (yyvsp[(7) - (7)].node));
4849 (yyval.node)->set_location(yylloc);
4850 ;}
4851 break;
4852
4853 case 252:
4854
4855/* Line 1455 of yacc.c */
4856#line 1385 "glsl_parser.ypp"
4857 {
4858 (yyval.node) = (ast_node *) (yyvsp[(1) - (1)].expression);
4859 ;}
4860 break;
4861
4862 case 253:
4863
4864/* Line 1455 of yacc.c */
4865#line 1389 "glsl_parser.ypp"
4866 {
4867 void *ctx = state;
4868 ast_declaration *decl = new(ctx) ast_declaration((yyvsp[(2) - (4)].identifier), false, NULL, (yyvsp[(4) - (4)].expression));
4869 ast_declarator_list *declarator = new(ctx) ast_declarator_list((yyvsp[(1) - (4)].fully_specified_type));
4870 decl->set_location(yylloc);
4871 declarator->set_location(yylloc);
4872
4873 declarator->declarations.push_tail(&decl->link);
4874 (yyval.node) = declarator;
4875 ;}
4876 break;
4877
4878 case 257:
4879
4880/* Line 1455 of yacc.c */
4881#line 1412 "glsl_parser.ypp"
4882 {
4883 void *ctx = state;
4884 (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
4885 NULL, (yyvsp[(3) - (5)].node), NULL, (yyvsp[(5) - (5)].node));
4886 (yyval.node)->set_location(yylloc);
4887 ;}
4888 break;
4889
4890 case 258:
4891
4892/* Line 1455 of yacc.c */
4893#line 1419 "glsl_parser.ypp"
4894 {
4895 void *ctx = state;
4896 (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
4897 NULL, (yyvsp[(5) - (7)].expression), NULL, (yyvsp[(2) - (7)].node));
4898 (yyval.node)->set_location(yylloc);
4899 ;}
4900 break;
4901
4902 case 259:
4903
4904/* Line 1455 of yacc.c */
4905#line 1426 "glsl_parser.ypp"
4906 {
4907 void *ctx = state;
4908 (yyval.node) = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
4909 (yyvsp[(3) - (6)].node), (yyvsp[(4) - (6)].for_rest_statement).cond, (yyvsp[(4) - (6)].for_rest_statement).rest, (yyvsp[(6) - (6)].node));
4910 (yyval.node)->set_location(yylloc);
4911 ;}
4912 break;
4913
4914 case 263:
4915
4916/* Line 1455 of yacc.c */
4917#line 1442 "glsl_parser.ypp"
4918 {
4919 (yyval.node) = NULL;
4920 ;}
4921 break;
4922
4923 case 264:
4924
4925/* Line 1455 of yacc.c */
4926#line 1449 "glsl_parser.ypp"
4927 {
4928 (yyval.for_rest_statement).cond = (yyvsp[(1) - (2)].node);
4929 (yyval.for_rest_statement).rest = NULL;
4930 ;}
4931 break;
4932
4933 case 265:
4934
4935/* Line 1455 of yacc.c */
4936#line 1454 "glsl_parser.ypp"
4937 {
4938 (yyval.for_rest_statement).cond = (yyvsp[(1) - (3)].node);
4939 (yyval.for_rest_statement).rest = (yyvsp[(3) - (3)].expression);
4940 ;}
4941 break;
4942
4943 case 266:
4944
4945/* Line 1455 of yacc.c */
4946#line 1463 "glsl_parser.ypp"
4947 {
4948 void *ctx = state;
4949 (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
4950 (yyval.node)->set_location(yylloc);
4951 ;}
4952 break;
4953
4954 case 267:
4955
4956/* Line 1455 of yacc.c */
4957#line 1469 "glsl_parser.ypp"
4958 {
4959 void *ctx = state;
4960 (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
4961 (yyval.node)->set_location(yylloc);
4962 ;}
4963 break;
4964
4965 case 268:
4966
4967/* Line 1455 of yacc.c */
4968#line 1475 "glsl_parser.ypp"
4969 {
4970 void *ctx = state;
4971 (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
4972 (yyval.node)->set_location(yylloc);
4973 ;}
4974 break;
4975
4976 case 269:
4977
4978/* Line 1455 of yacc.c */
4979#line 1481 "glsl_parser.ypp"
4980 {
4981 void *ctx = state;
4982 (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, (yyvsp[(2) - (3)].expression));
4983 (yyval.node)->set_location(yylloc);
4984 ;}
4985 break;
4986
4987 case 270:
4988
4989/* Line 1455 of yacc.c */
4990#line 1487 "glsl_parser.ypp"
4991 {
4992 void *ctx = state;
4993 (yyval.node) = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
4994 (yyval.node)->set_location(yylloc);
4995 ;}
4996 break;
4997
4998 case 271:
4999
5000/* Line 1455 of yacc.c */
5001#line 1495 "glsl_parser.ypp"
5002 { (yyval.node) = (yyvsp[(1) - (1)].function_definition); ;}
5003 break;
5004
5005 case 272:
5006
5007/* Line 1455 of yacc.c */
5008#line 1496 "glsl_parser.ypp"
5009 { (yyval.node) = (yyvsp[(1) - (1)].node); ;}
5010 break;
5011
5012 case 273:
5013
5014/* Line 1455 of yacc.c */
5015#line 1501 "glsl_parser.ypp"
5016 {
5017 void *ctx = state;
5018 (yyval.function_definition) = new(ctx) ast_function_definition();
5019 (yyval.function_definition)->set_location(yylloc);
5020 (yyval.function_definition)->prototype = (yyvsp[(1) - (2)].function);
5021 (yyval.function_definition)->body = (yyvsp[(2) - (2)].compound_statement);
5022 ;}
5023 break;
5024
5025
5026
5027/* Line 1455 of yacc.c */
5028#line 5029 "glsl_parser.cpp"
5029 default: break;
5030 }
5031 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
5032
5033 YYPOPSTACK (yylen);
5034 yylen = 0;
5035 YY_STACK_PRINT (yyss, yyssp);
5036
5037 *++yyvsp = yyval;
5038 *++yylsp = yyloc;
5039
5040 /* Now `shift' the result of the reduction. Determine what state
5041 that goes to, based on the state we popped back to and the rule
5042 number reduced by. */
5043
5044 yyn = yyr1[yyn];
5045
5046 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5047 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5048 yystate = yytable[yystate];
5049 else
5050 yystate = yydefgoto[yyn - YYNTOKENS];
5051
5052 goto yynewstate;
5053
5054
5055/*------------------------------------.
5056| yyerrlab -- here on detecting error |
5057`------------------------------------*/
5058yyerrlab:
5059 /* If not already recovering from an error, report this error. */
5060 if (!yyerrstatus)
5061 {
5062 ++yynerrs;
5063#if ! YYERROR_VERBOSE
5064 yyerror (&yylloc, state, YY_("syntax error"));
5065#else
5066 {
5067 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
5068 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
5069 {
5070 YYSIZE_T yyalloc = 2 * yysize;
5071 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
5072 yyalloc = YYSTACK_ALLOC_MAXIMUM;
5073 if (yymsg != yymsgbuf)
5074 YYSTACK_FREE (yymsg);
5075 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
5076 if (yymsg)
5077 yymsg_alloc = yyalloc;
5078 else
5079 {
5080 yymsg = yymsgbuf;
5081 yymsg_alloc = sizeof yymsgbuf;
5082 }
5083 }
5084
5085 if (0 < yysize && yysize <= yymsg_alloc)
5086 {
5087 (void) yysyntax_error (yymsg, yystate, yychar);
5088 yyerror (&yylloc, state, yymsg);
5089 }
5090 else
5091 {
5092 yyerror (&yylloc, state, YY_("syntax error"));
5093 if (yysize != 0)
5094 goto yyexhaustedlab;
5095 }
5096 }
5097#endif
5098 }
5099
5100 yyerror_range[0] = yylloc;
5101
5102 if (yyerrstatus == 3)
5103 {
5104 /* If just tried and failed to reuse lookahead token after an
5105 error, discard it. */
5106
5107 if (yychar <= YYEOF)
5108 {
5109 /* Return failure if at end of input. */
5110 if (yychar == YYEOF)
5111 YYABORT;
5112 }
5113 else
5114 {
5115 yydestruct ("Error: discarding",
5116 yytoken, &yylval, &yylloc, state);
5117 yychar = YYEMPTY;
5118 }
5119 }
5120
5121 /* Else will try to reuse lookahead token after shifting the error
5122 token. */
5123 goto yyerrlab1;
5124
5125
5126/*---------------------------------------------------.
5127| yyerrorlab -- error raised explicitly by YYERROR. |
5128`---------------------------------------------------*/
5129yyerrorlab:
5130
5131 /* Pacify compilers like GCC when the user code never invokes
5132 YYERROR and the label yyerrorlab therefore never appears in user
5133 code. */
5134 if (/*CONSTCOND*/ 0)
5135 goto yyerrorlab;
5136
5137 yyerror_range[0] = yylsp[1-yylen];
5138 /* Do not reclaim the symbols of the rule which action triggered
5139 this YYERROR. */
5140 YYPOPSTACK (yylen);
5141 yylen = 0;
5142 YY_STACK_PRINT (yyss, yyssp);
5143 yystate = *yyssp;
5144 goto yyerrlab1;
5145
5146
5147/*-------------------------------------------------------------.
5148| yyerrlab1 -- common code for both syntax error and YYERROR. |
5149`-------------------------------------------------------------*/
5150yyerrlab1:
5151 yyerrstatus = 3; /* Each real token shifted decrements this. */
5152
5153 for (;;)
5154 {
5155 yyn = yypact[yystate];
5156 if (yyn != YYPACT_NINF)
5157 {
5158 yyn += YYTERROR;
5159 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5160 {
5161 yyn = yytable[yyn];
5162 if (0 < yyn)
5163 break;
5164 }
5165 }
5166
5167 /* Pop the current state because it cannot handle the error token. */
5168 if (yyssp == yyss)
5169 YYABORT;
5170
5171 yyerror_range[0] = *yylsp;
5172 yydestruct ("Error: popping",
5173 yystos[yystate], yyvsp, yylsp, state);
5174 YYPOPSTACK (1);
5175 yystate = *yyssp;
5176 YY_STACK_PRINT (yyss, yyssp);
5177 }
5178
5179 *++yyvsp = yylval;
5180
5181 yyerror_range[1] = yylloc;
5182 /* Using YYLLOC is tempting, but would change the location of
5183 the lookahead. YYLOC is available though. */
5184 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
5185 *++yylsp = yyloc;
5186
5187 /* Shift the error token. */
5188 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
5189
5190 yystate = yyn;
5191 goto yynewstate;
5192
5193
5194/*-------------------------------------.
5195| yyacceptlab -- YYACCEPT comes here. |
5196`-------------------------------------*/
5197yyacceptlab:
5198 yyresult = 0;
5199 goto yyreturn;
5200
5201/*-----------------------------------.
5202| yyabortlab -- YYABORT comes here. |
5203`-----------------------------------*/
5204yyabortlab:
5205 yyresult = 1;
5206 goto yyreturn;
5207
5208#if !defined(yyoverflow) || YYERROR_VERBOSE
5209/*-------------------------------------------------.
5210| yyexhaustedlab -- memory exhaustion comes here. |
5211`-------------------------------------------------*/
5212yyexhaustedlab:
5213 yyerror (&yylloc, state, YY_("memory exhausted"));
5214 yyresult = 2;
5215 /* Fall through. */
5216#endif
5217
5218yyreturn:
5219 if (yychar != YYEMPTY)
5220 yydestruct ("Cleanup: discarding lookahead",
5221 yytoken, &yylval, &yylloc, state);
5222 /* Do not reclaim the symbols of the rule which action triggered
5223 this YYABORT or YYACCEPT. */
5224 YYPOPSTACK (yylen);
5225 YY_STACK_PRINT (yyss, yyssp);
5226 while (yyssp != yyss)
5227 {
5228 yydestruct ("Cleanup: popping",
5229 yystos[*yyssp], yyvsp, yylsp, state);
5230 YYPOPSTACK (1);
5231 }
5232#ifndef yyoverflow
5233 if (yyss != yyssa)
5234 YYSTACK_FREE (yyss);
5235#endif
5236#if YYERROR_VERBOSE
5237 if (yymsg != yymsgbuf)
5238 YYSTACK_FREE (yymsg);
5239#endif
5240 /* Make sure YYID is used. */
5241 return YYID (yyresult);
5242}
5243
5244
5245
diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h
new file mode 100644
index 00000000000..48a0a5fb3a3
--- /dev/null
+++ b/src/glsl/glsl_parser.h
@@ -0,0 +1,291 @@
1
2/* A Bison parser, made by GNU Bison 2.4.1. */
3
4/* Skeleton interface for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
8
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22/* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
31
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
34
35
36/* Tokens. */
37#ifndef YYTOKENTYPE
38# define YYTOKENTYPE
39 /* Put the tokens into the symbol table, so that GDB and other debuggers
40 know about them. */
41 enum yytokentype {
42 ATTRIBUTE = 258,
43 CONST_TOK = 259,
44 BOOL_TOK = 260,
45 FLOAT_TOK = 261,
46 INT_TOK = 262,
47 UINT_TOK = 263,
48 BREAK = 264,
49 CONTINUE = 265,
50 DO = 266,
51 ELSE = 267,
52 FOR = 268,
53 IF = 269,
54 DISCARD = 270,
55 RETURN = 271,
56 SWITCH = 272,
57 CASE = 273,
58 DEFAULT = 274,
59 BVEC2 = 275,
60 BVEC3 = 276,
61 BVEC4 = 277,
62 IVEC2 = 278,
63 IVEC3 = 279,
64 IVEC4 = 280,
65 UVEC2 = 281,
66 UVEC3 = 282,
67 UVEC4 = 283,
68 VEC2 = 284,
69 VEC3 = 285,
70 VEC4 = 286,
71 CENTROID = 287,
72 IN_TOK = 288,
73 OUT_TOK = 289,
74 INOUT_TOK = 290,
75 UNIFORM = 291,
76 VARYING = 292,
77 NOPERSPECTIVE = 293,
78 FLAT = 294,
79 SMOOTH = 295,
80 MAT2X2 = 296,
81 MAT2X3 = 297,
82 MAT2X4 = 298,
83 MAT3X2 = 299,
84 MAT3X3 = 300,
85 MAT3X4 = 301,
86 MAT4X2 = 302,
87 MAT4X3 = 303,
88 MAT4X4 = 304,
89 SAMPLER1D = 305,
90 SAMPLER2D = 306,
91 SAMPLER3D = 307,
92 SAMPLERCUBE = 308,
93 SAMPLER1DSHADOW = 309,
94 SAMPLER2DSHADOW = 310,
95 SAMPLERCUBESHADOW = 311,
96 SAMPLER1DARRAY = 312,
97 SAMPLER2DARRAY = 313,
98 SAMPLER1DARRAYSHADOW = 314,
99 SAMPLER2DARRAYSHADOW = 315,
100 ISAMPLER1D = 316,
101 ISAMPLER2D = 317,
102 ISAMPLER3D = 318,
103 ISAMPLERCUBE = 319,
104 ISAMPLER1DARRAY = 320,
105 ISAMPLER2DARRAY = 321,
106 USAMPLER1D = 322,
107 USAMPLER2D = 323,
108 USAMPLER3D = 324,
109 USAMPLERCUBE = 325,
110 USAMPLER1DARRAY = 326,
111 USAMPLER2DARRAY = 327,
112 STRUCT = 328,
113 VOID_TOK = 329,
114 WHILE = 330,
115 IDENTIFIER = 331,
116 FLOATCONSTANT = 332,
117 INTCONSTANT = 333,
118 UINTCONSTANT = 334,
119 BOOLCONSTANT = 335,
120 FIELD_SELECTION = 336,
121 LEFT_OP = 337,
122 RIGHT_OP = 338,
123 INC_OP = 339,
124 DEC_OP = 340,
125 LE_OP = 341,
126 GE_OP = 342,
127 EQ_OP = 343,
128 NE_OP = 344,
129 AND_OP = 345,
130 OR_OP = 346,
131 XOR_OP = 347,
132 MUL_ASSIGN = 348,
133 DIV_ASSIGN = 349,
134 ADD_ASSIGN = 350,
135 MOD_ASSIGN = 351,
136 LEFT_ASSIGN = 352,
137 RIGHT_ASSIGN = 353,
138 AND_ASSIGN = 354,
139 XOR_ASSIGN = 355,
140 OR_ASSIGN = 356,
141 SUB_ASSIGN = 357,
142 INVARIANT = 358,
143 LOWP = 359,
144 MEDIUMP = 360,
145 HIGHP = 361,
146 SUPERP = 362,
147 PRECISION = 363,
148 VERSION = 364,
149 EXTENSION = 365,
150 LINE = 366,
151 PRAGMA = 367,
152 COLON = 368,
153 EOL = 369,
154 INTERFACE = 370,
155 OUTPUT = 371,
156 LAYOUT_TOK = 372,
157 ASM = 373,
158 CLASS = 374,
159 UNION = 375,
160 ENUM = 376,
161 TYPEDEF = 377,
162 TEMPLATE = 378,
163 THIS = 379,
164 PACKED_TOK = 380,
165 GOTO = 381,
166 INLINE_TOK = 382,
167 NOINLINE = 383,
168 VOLATILE = 384,
169 PUBLIC_TOK = 385,
170 STATIC = 386,
171 EXTERN = 387,
172 EXTERNAL = 388,
173 LONG_TOK = 389,
174 SHORT_TOK = 390,
175 DOUBLE_TOK = 391,
176 HALF = 392,
177 FIXED_TOK = 393,
178 UNSIGNED = 394,
179 INPUT_TOK = 395,
180 OUPTUT = 396,
181 HVEC2 = 397,
182 HVEC3 = 398,
183 HVEC4 = 399,
184 DVEC2 = 400,
185 DVEC3 = 401,
186 DVEC4 = 402,
187 FVEC2 = 403,
188 FVEC3 = 404,
189 FVEC4 = 405,
190 SAMPLER2DRECT = 406,
191 SAMPLER3DRECT = 407,
192 SAMPLER2DRECTSHADOW = 408,
193 SIZEOF = 409,
194 CAST = 410,
195 NAMESPACE = 411,
196 USING = 412,
197 ERROR_TOK = 413,
198 COMMON = 414,
199 PARTITION = 415,
200 ACTIVE = 416,
201 SAMPLERBUFFER = 417,
202 FILTER = 418,
203 IMAGE1D = 419,
204 IMAGE2D = 420,
205 IMAGE3D = 421,
206 IMAGECUBE = 422,
207 IMAGE1DARRAY = 423,
208 IMAGE2DARRAY = 424,
209 IIMAGE1D = 425,
210 IIMAGE2D = 426,
211 IIMAGE3D = 427,
212 IIMAGECUBE = 428,
213 IIMAGE1DARRAY = 429,
214 IIMAGE2DARRAY = 430,
215 UIMAGE1D = 431,
216 UIMAGE2D = 432,
217 UIMAGE3D = 433,
218 UIMAGECUBE = 434,
219 UIMAGE1DARRAY = 435,
220 UIMAGE2DARRAY = 436,
221 IMAGE1DSHADOW = 437,
222 IMAGE2DSHADOW = 438,
223 IMAGEBUFFER = 439,
224 IIMAGEBUFFER = 440,
225 UIMAGEBUFFER = 441,
226 ROW_MAJOR = 442
227 };
228#endif
229
230
231
232#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
233typedef union YYSTYPE
234{
235
236/* Line 1676 of yacc.c */
237#line 52 "glsl_parser.ypp"
238
239 int n;
240 float real;
241 char *identifier;
242
243 union {
244 struct ast_type_qualifier q;
245 unsigned i;
246 } type_qualifier;
247
248 ast_node *node;
249 ast_type_specifier *type_specifier;
250 ast_fully_specified_type *fully_specified_type;
251 ast_function *function;
252 ast_parameter_declarator *parameter_declarator;
253 ast_function_definition *function_definition;
254 ast_compound_statement *compound_statement;
255 ast_expression *expression;
256 ast_declarator_list *declarator_list;
257 ast_struct_specifier *struct_specifier;
258 ast_declaration *declaration;
259
260 struct {
261 ast_node *cond;
262 ast_expression *rest;
263 } for_rest_statement;
264
265
266
267/* Line 1676 of yacc.c */
268#line 269 "glsl_parser.h"
269} YYSTYPE;
270# define YYSTYPE_IS_TRIVIAL 1
271# define yystype YYSTYPE /* obsolescent; will be withdrawn */
272# define YYSTYPE_IS_DECLARED 1
273#endif
274
275
276
277#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
278typedef struct YYLTYPE
279{
280 int first_line;
281 int first_column;
282 int last_line;
283 int last_column;
284} YYLTYPE;
285# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
286# define YYLTYPE_IS_DECLARED 1
287# define YYLTYPE_IS_TRIVIAL 1
288#endif
289
290
291
diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp
new file mode 100644
index 00000000000..e0b1d285046
--- /dev/null
+++ b/src/glsl/glsl_parser.ypp
@@ -0,0 +1,1508 @@
1%{
2/*
3 * Copyright © 2008, 2009 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <assert.h>
28
29#include "ast.h"
30#include "glsl_parser_extras.h"
31#include "glsl_types.h"
32
33#define YYLEX_PARAM state->scanner
34
35%}
36
37%pure-parser
38%error-verbose
39
40%locations
41%initial-action {
42 @$.first_line = 1;
43 @$.first_column = 1;
44 @$.last_line = 1;
45 @$.last_column = 1;
46 @$.source = 0;
47}
48
49%lex-param {void *scanner}
50%parse-param {struct _mesa_glsl_parse_state *state}
51
52%union {
53 int n;
54 float real;
55 char *identifier;
56
57 union {
58 struct ast_type_qualifier q;
59 unsigned i;
60 } type_qualifier;
61
62 ast_node *node;
63 ast_type_specifier *type_specifier;
64 ast_fully_specified_type *fully_specified_type;
65 ast_function *function;
66 ast_parameter_declarator *parameter_declarator;
67 ast_function_definition *function_definition;
68 ast_compound_statement *compound_statement;
69 ast_expression *expression;
70 ast_declarator_list *declarator_list;
71 ast_struct_specifier *struct_specifier;
72 ast_declaration *declaration;
73
74 struct {
75 ast_node *cond;
76 ast_expression *rest;
77 } for_rest_statement;
78}
79
80%token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK
81%token BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
82%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4
83%token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING
84%token NOPERSPECTIVE FLAT SMOOTH
85%token MAT2X2 MAT2X3 MAT2X4
86%token MAT3X2 MAT3X3 MAT3X4
87%token MAT4X2 MAT4X3 MAT4X4
88%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW
89%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW
90%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
91%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D
92%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY
93%token STRUCT VOID_TOK WHILE
94%token <identifier> IDENTIFIER
95%token <real> FLOATCONSTANT
96%token <n> INTCONSTANT UINTCONSTANT BOOLCONSTANT
97%token <identifier> FIELD_SELECTION
98%token LEFT_OP RIGHT_OP
99%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
100%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
101%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
102%token SUB_ASSIGN
103%token INVARIANT
104%token LOWP MEDIUMP HIGHP SUPERP PRECISION
105
106%token VERSION EXTENSION LINE PRAGMA COLON EOL INTERFACE OUTPUT
107%token LAYOUT_TOK
108
109 /* Reserved words that are not actually used in the grammar.
110 */
111%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO
112%token INLINE_TOK NOINLINE VOLATILE PUBLIC_TOK STATIC EXTERN EXTERNAL
113%token LONG_TOK SHORT_TOK DOUBLE_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK OUPTUT
114%token HVEC2 HVEC3 HVEC4 DVEC2 DVEC3 DVEC4 FVEC2 FVEC3 FVEC4
115%token SAMPLER2DRECT SAMPLER3DRECT SAMPLER2DRECTSHADOW
116%token SIZEOF CAST NAMESPACE USING
117
118%token ERROR_TOK
119
120%token COMMON PARTITION ACTIVE SAMPLERBUFFER FILTER
121%token IMAGE1D IMAGE2D IMAGE3D IMAGECUBE IMAGE1DARRAY IMAGE2DARRAY
122%token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGECUBE IIMAGE1DARRAY IIMAGE2DARRAY
123%token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGECUBE UIMAGE1DARRAY UIMAGE2DARRAY
124%token IMAGE1DSHADOW IMAGE2DSHADOW IMAGEBUFFER IIMAGEBUFFER UIMAGEBUFFER
125%token ROW_MAJOR
126
127%type <identifier> variable_identifier
128%type <node> statement
129%type <node> statement_list
130%type <node> simple_statement
131%type <node> statement_matched
132%type <node> statement_unmatched
133%type <n> precision_qualifier
134%type <type_qualifier> type_qualifier
135%type <type_qualifier> storage_qualifier
136%type <type_qualifier> interpolation_qualifier
137%type <type_qualifier> opt_layout_qualifier layout_qualifier
138%type <type_qualifier> layout_qualifier_id_list layout_qualifier_id
139%type <type_specifier> type_specifier
140%type <type_specifier> type_specifier_no_prec
141%type <type_specifier> type_specifier_nonarray
142%type <n> basic_type_specifier_nonarray
143%type <fully_specified_type> fully_specified_type
144%type <function> function_prototype
145%type <function> function_header
146%type <function> function_header_with_parameters
147%type <function> function_declarator
148%type <parameter_declarator> parameter_declarator
149%type <parameter_declarator> parameter_declaration
150%type <type_qualifier> parameter_qualifier
151%type <type_qualifier> parameter_type_qualifier
152%type <type_specifier> parameter_type_specifier
153%type <function_definition> function_definition
154%type <compound_statement> compound_statement_no_new_scope
155%type <compound_statement> compound_statement
156%type <node> statement_no_new_scope
157%type <node> expression_statement
158%type <expression> expression
159%type <expression> primary_expression
160%type <expression> assignment_expression
161%type <expression> conditional_expression
162%type <expression> logical_or_expression
163%type <expression> logical_xor_expression
164%type <expression> logical_and_expression
165%type <expression> inclusive_or_expression
166%type <expression> exclusive_or_expression
167%type <expression> and_expression
168%type <expression> equality_expression
169%type <expression> relational_expression
170%type <expression> shift_expression
171%type <expression> additive_expression
172%type <expression> multiplicative_expression
173%type <expression> unary_expression
174%type <expression> constant_expression
175%type <expression> integer_expression
176%type <expression> postfix_expression
177%type <expression> function_call_header_with_parameters
178%type <expression> function_call_header_no_parameters
179%type <expression> function_call_header
180%type <expression> function_call_generic
181%type <expression> function_call_or_method
182%type <expression> function_call
183%type <n> assignment_operator
184%type <n> unary_operator
185%type <expression> function_identifier
186%type <node> external_declaration
187%type <declarator_list> init_declarator_list
188%type <declarator_list> single_declaration
189%type <expression> initializer
190%type <node> declaration
191%type <node> declaration_statement
192%type <node> jump_statement
193%type <struct_specifier> struct_specifier
194%type <node> struct_declaration_list
195%type <declarator_list> struct_declaration
196%type <declaration> struct_declarator
197%type <declaration> struct_declarator_list
198%type <node> selection_statement_matched
199%type <node> selection_statement_unmatched
200%type <node> iteration_statement
201%type <node> condition
202%type <node> conditionopt
203%type <node> for_init_statement
204%type <for_rest_statement> for_rest_statement
205%%
206
207translation_unit:
208 version_statement extension_statement_list
209 {
210 _mesa_glsl_initialize_types(state);
211 }
212 external_declaration_list
213 ;
214
215version_statement:
216 /* blank - no #version specified */
217 {
218 state->language_version = 110;
219 }
220 | VERSION INTCONSTANT EOL
221 {
222 switch ($2) {
223 case 110:
224 case 120:
225 case 130:
226 /* FINISHME: Check against implementation support versions. */
227 state->language_version = $2;
228 break;
229 default:
230 _mesa_glsl_error(& @2, state, "Shading language version"
231 "%u is not supported\n", $2);
232 break;
233 }
234 }
235 ;
236
237extension_statement_list:
238
239 | extension_statement_list extension_statement
240 ;
241
242extension_statement:
243 EXTENSION IDENTIFIER COLON IDENTIFIER EOL
244 {
245 if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) {
246 YYERROR;
247 }
248 }
249 ;
250
251external_declaration_list:
252 external_declaration
253 {
254 /* FINISHME: The NULL test is only required because 'precision'
255 * FINISHME: statements are not yet supported.
256 */
257 if ($1 != NULL)
258 state->translation_unit.push_tail(& $1->link);
259 }
260 | external_declaration_list external_declaration
261 {
262 /* FINISHME: The NULL test is only required because 'precision'
263 * FINISHME: statements are not yet supported.
264 */
265 if ($2 != NULL)
266 state->translation_unit.push_tail(& $2->link);
267 }
268 ;
269
270variable_identifier:
271 IDENTIFIER
272 ;
273
274primary_expression:
275 variable_identifier
276 {
277 void *ctx = state;
278 $$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
279 $$->set_location(yylloc);
280 $$->primary_expression.identifier = $1;
281 }
282 | INTCONSTANT
283 {
284 void *ctx = state;
285 $$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
286 $$->set_location(yylloc);
287 $$->primary_expression.int_constant = $1;
288 }
289 | UINTCONSTANT
290 {
291 void *ctx = state;
292 $$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
293 $$->set_location(yylloc);
294 $$->primary_expression.uint_constant = $1;
295 }
296 | FLOATCONSTANT
297 {
298 void *ctx = state;
299 $$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
300 $$->set_location(yylloc);
301 $$->primary_expression.float_constant = $1;
302 }
303 | BOOLCONSTANT
304 {
305 void *ctx = state;
306 $$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
307 $$->set_location(yylloc);
308 $$->primary_expression.bool_constant = $1;
309 }
310 | '(' expression ')'
311 {
312 $$ = $2;
313 }
314 ;
315
316postfix_expression:
317 primary_expression
318 | postfix_expression '[' integer_expression ']'
319 {
320 void *ctx = state;
321 $$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL);
322 $$->set_location(yylloc);
323 }
324 | function_call
325 {
326 $$ = $1;
327 }
328 | postfix_expression '.' IDENTIFIER
329 {
330 void *ctx = state;
331 $$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL);
332 $$->set_location(yylloc);
333 $$->primary_expression.identifier = $3;
334 }
335 | postfix_expression INC_OP
336 {
337 void *ctx = state;
338 $$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL);
339 $$->set_location(yylloc);
340 }
341 | postfix_expression DEC_OP
342 {
343 void *ctx = state;
344 $$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL);
345 $$->set_location(yylloc);
346 }
347 ;
348
349integer_expression:
350 expression
351 ;
352
353function_call:
354 function_call_or_method
355 ;
356
357function_call_or_method:
358 function_call_generic
359 | postfix_expression '.' function_call_generic
360 {
361 void *ctx = state;
362 $$ = new(ctx) ast_expression(ast_field_selection, $1, $3, NULL);
363 $$->set_location(yylloc);
364 }
365 ;
366
367function_call_generic:
368 function_call_header_with_parameters ')'
369 | function_call_header_no_parameters ')'
370 ;
371
372function_call_header_no_parameters:
373 function_call_header VOID_TOK
374 | function_call_header
375 ;
376
377function_call_header_with_parameters:
378 function_call_header assignment_expression
379 {
380 $$ = $1;
381 $$->set_location(yylloc);
382 $$->expressions.push_tail(& $2->link);
383 }
384 | function_call_header_with_parameters ',' assignment_expression
385 {
386 $$ = $1;
387 $$->set_location(yylloc);
388 $$->expressions.push_tail(& $3->link);
389 }
390 ;
391
392 // Grammar Note: Constructors look like functions, but lexical
393 // analysis recognized most of them as keywords. They are now
394 // recognized through "type_specifier".
395function_call_header:
396 function_identifier '('
397 ;
398
399function_identifier:
400 type_specifier
401 {
402 void *ctx = state;
403 $$ = new(ctx) ast_function_expression($1);
404 $$->set_location(yylloc);
405 }
406 | IDENTIFIER
407 {
408 void *ctx = state;
409 ast_expression *callee = new(ctx) ast_expression($1);
410 $$ = new(ctx) ast_function_expression(callee);
411 $$->set_location(yylloc);
412 }
413 | FIELD_SELECTION
414 {
415 void *ctx = state;
416 ast_expression *callee = new(ctx) ast_expression($1);
417 $$ = new(ctx) ast_function_expression(callee);
418 $$->set_location(yylloc);
419 }
420 ;
421
422 // Grammar Note: No traditional style type casts.
423unary_expression:
424 postfix_expression
425 | INC_OP unary_expression
426 {
427 void *ctx = state;
428 $$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL);
429 $$->set_location(yylloc);
430 }
431 | DEC_OP unary_expression
432 {
433 void *ctx = state;
434 $$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL);
435 $$->set_location(yylloc);
436 }
437 | unary_operator unary_expression
438 {
439 void *ctx = state;
440 $$ = new(ctx) ast_expression($1, $2, NULL, NULL);
441 $$->set_location(yylloc);
442 }
443 ;
444
445 // Grammar Note: No '*' or '&' unary ops. Pointers are not supported.
446unary_operator:
447 '+' { $$ = ast_plus; }
448 | '-' { $$ = ast_neg; }
449 | '!' { $$ = ast_logic_not; }
450 | '~' { $$ = ast_bit_not; }
451 ;
452
453multiplicative_expression:
454 unary_expression
455 | multiplicative_expression '*' unary_expression
456 {
457 void *ctx = state;
458 $$ = new(ctx) ast_expression_bin(ast_mul, $1, $3);
459 $$->set_location(yylloc);
460 }
461 | multiplicative_expression '/' unary_expression
462 {
463 void *ctx = state;
464 $$ = new(ctx) ast_expression_bin(ast_div, $1, $3);
465 $$->set_location(yylloc);
466 }
467 | multiplicative_expression '%' unary_expression
468 {
469 void *ctx = state;
470 $$ = new(ctx) ast_expression_bin(ast_mod, $1, $3);
471 $$->set_location(yylloc);
472 }
473 ;
474
475additive_expression:
476 multiplicative_expression
477 | additive_expression '+' multiplicative_expression
478 {
479 void *ctx = state;
480 $$ = new(ctx) ast_expression_bin(ast_add, $1, $3);
481 $$->set_location(yylloc);
482 }
483 | additive_expression '-' multiplicative_expression
484 {
485 void *ctx = state;
486 $$ = new(ctx) ast_expression_bin(ast_sub, $1, $3);
487 $$->set_location(yylloc);
488 }
489 ;
490
491shift_expression:
492 additive_expression
493 | shift_expression LEFT_OP additive_expression
494 {
495 void *ctx = state;
496 $$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3);
497 $$->set_location(yylloc);
498 }
499 | shift_expression RIGHT_OP additive_expression
500 {
501 void *ctx = state;
502 $$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3);
503 $$->set_location(yylloc);
504 }
505 ;
506
507relational_expression:
508 shift_expression
509 | relational_expression '<' shift_expression
510 {
511 void *ctx = state;
512 $$ = new(ctx) ast_expression_bin(ast_less, $1, $3);
513 $$->set_location(yylloc);
514 }
515 | relational_expression '>' shift_expression
516 {
517 void *ctx = state;
518 $$ = new(ctx) ast_expression_bin(ast_greater, $1, $3);
519 $$->set_location(yylloc);
520 }
521 | relational_expression LE_OP shift_expression
522 {
523 void *ctx = state;
524 $$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3);
525 $$->set_location(yylloc);
526 }
527 | relational_expression GE_OP shift_expression
528 {
529 void *ctx = state;
530 $$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3);
531 $$->set_location(yylloc);
532 }
533 ;
534
535equality_expression:
536 relational_expression
537 | equality_expression EQ_OP relational_expression
538 {
539 void *ctx = state;
540 $$ = new(ctx) ast_expression_bin(ast_equal, $1, $3);
541 $$->set_location(yylloc);
542 }
543 | equality_expression NE_OP relational_expression
544 {
545 void *ctx = state;
546 $$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3);
547 $$->set_location(yylloc);
548 }
549 ;
550
551and_expression:
552 equality_expression
553 | and_expression '&' equality_expression
554 {
555 void *ctx = state;
556 $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
557 $$->set_location(yylloc);
558 }
559 ;
560
561exclusive_or_expression:
562 and_expression
563 | exclusive_or_expression '^' and_expression
564 {
565 void *ctx = state;
566 $$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3);
567 $$->set_location(yylloc);
568 }
569 ;
570
571inclusive_or_expression:
572 exclusive_or_expression
573 | inclusive_or_expression '|' exclusive_or_expression
574 {
575 void *ctx = state;
576 $$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
577 $$->set_location(yylloc);
578 }
579 ;
580
581logical_and_expression:
582 inclusive_or_expression
583 | logical_and_expression AND_OP inclusive_or_expression
584 {
585 void *ctx = state;
586 $$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3);
587 $$->set_location(yylloc);
588 }
589 ;
590
591logical_xor_expression:
592 logical_and_expression
593 | logical_xor_expression XOR_OP logical_and_expression
594 {
595 void *ctx = state;
596 $$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3);
597 $$->set_location(yylloc);
598 }
599 ;
600
601logical_or_expression:
602 logical_xor_expression
603 | logical_or_expression OR_OP logical_xor_expression
604 {
605 void *ctx = state;
606 $$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3);
607 $$->set_location(yylloc);
608 }
609 ;
610
611conditional_expression:
612 logical_or_expression
613 | logical_or_expression '?' expression ':' assignment_expression
614 {
615 void *ctx = state;
616 $$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5);
617 $$->set_location(yylloc);
618 }
619 ;
620
621assignment_expression:
622 conditional_expression
623 | unary_expression assignment_operator assignment_expression
624 {
625 void *ctx = state;
626 $$ = new(ctx) ast_expression($2, $1, $3, NULL);
627 $$->set_location(yylloc);
628 }
629 ;
630
631assignment_operator:
632 '=' { $$ = ast_assign; }
633 | MUL_ASSIGN { $$ = ast_mul_assign; }
634 | DIV_ASSIGN { $$ = ast_div_assign; }
635 | MOD_ASSIGN { $$ = ast_mod_assign; }
636 | ADD_ASSIGN { $$ = ast_add_assign; }
637 | SUB_ASSIGN { $$ = ast_sub_assign; }
638 | LEFT_ASSIGN { $$ = ast_ls_assign; }
639 | RIGHT_ASSIGN { $$ = ast_rs_assign; }
640 | AND_ASSIGN { $$ = ast_and_assign; }
641 | XOR_ASSIGN { $$ = ast_xor_assign; }
642 | OR_ASSIGN { $$ = ast_or_assign; }
643 ;
644
645expression:
646 assignment_expression
647 {
648 $$ = $1;
649 }
650 | expression ',' assignment_expression
651 {
652 void *ctx = state;
653 if ($1->oper != ast_sequence) {
654 $$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
655 $$->set_location(yylloc);
656 $$->expressions.push_tail(& $1->link);
657 } else {
658 $$ = $1;
659 }
660
661 $$->expressions.push_tail(& $3->link);
662 }
663 ;
664
665constant_expression:
666 conditional_expression
667 ;
668
669declaration:
670 function_prototype ';'
671 {
672 $$ = $1;
673 }
674 | init_declarator_list ';'
675 {
676 $$ = $1;
677 }
678 | PRECISION precision_qualifier type_specifier_no_prec ';'
679 {
680 if (($3->type_specifier != ast_float)
681 && ($3->type_specifier != ast_int)) {
682 _mesa_glsl_error(& @3, state, "global precision qualifier can "
683 "only be applied to `int' or `float'\n");
684 YYERROR;
685 }
686
687 $$ = NULL; /* FINISHME */
688 }
689 ;
690
691function_prototype:
692 function_declarator ')'
693 ;
694
695function_declarator:
696 function_header
697 | function_header_with_parameters
698 ;
699
700function_header_with_parameters:
701 function_header parameter_declaration
702 {
703 $$ = $1;
704 $$->parameters.push_tail(& $2->link);
705 }
706 | function_header_with_parameters ',' parameter_declaration
707 {
708 $$ = $1;
709 $$->parameters.push_tail(& $3->link);
710 }
711 ;
712
713function_header:
714 fully_specified_type IDENTIFIER '('
715 {
716 void *ctx = state;
717 $$ = new(ctx) ast_function();
718 $$->set_location(yylloc);
719 $$->return_type = $1;
720 $$->identifier = $2;
721 }
722 ;
723
724parameter_declarator:
725 type_specifier IDENTIFIER
726 {
727 void *ctx = state;
728 $$ = new(ctx) ast_parameter_declarator();
729 $$->set_location(yylloc);
730 $$->type = new(ctx) ast_fully_specified_type();
731 $$->type->set_location(yylloc);
732 $$->type->specifier = $1;
733 $$->identifier = $2;
734 }
735 | type_specifier IDENTIFIER '[' constant_expression ']'
736 {
737 void *ctx = state;
738 $$ = new(ctx) ast_parameter_declarator();
739 $$->set_location(yylloc);
740 $$->type = new(ctx) ast_fully_specified_type();
741 $$->type->set_location(yylloc);
742 $$->type->specifier = $1;
743 $$->identifier = $2;
744 $$->is_array = true;
745 $$->array_size = $4;
746 }
747 ;
748
749parameter_declaration:
750 parameter_type_qualifier parameter_qualifier parameter_declarator
751 {
752 $1.i |= $2.i;
753
754 $$ = $3;
755 $$->type->qualifier = $1.q;
756 }
757 | parameter_qualifier parameter_declarator
758 {
759 $$ = $2;
760 $$->type->qualifier = $1.q;
761 }
762 | parameter_type_qualifier parameter_qualifier parameter_type_specifier
763 {
764 void *ctx = state;
765 $1.i |= $2.i;
766
767 $$ = new(ctx) ast_parameter_declarator();
768 $$->set_location(yylloc);
769 $$->type = new(ctx) ast_fully_specified_type();
770 $$->type->qualifier = $1.q;
771 $$->type->specifier = $3;
772 }
773 | parameter_qualifier parameter_type_specifier
774 {
775 void *ctx = state;
776 $$ = new(ctx) ast_parameter_declarator();
777 $$->set_location(yylloc);
778 $$->type = new(ctx) ast_fully_specified_type();
779 $$->type->qualifier = $1.q;
780 $$->type->specifier = $2;
781 }
782 ;
783
784parameter_qualifier:
785 /* empty */ { $$.i = 0; }
786 | IN_TOK { $$.i = 0; $$.q.in = 1; }
787 | OUT_TOK { $$.i = 0; $$.q.out = 1; }
788 | INOUT_TOK { $$.i = 0; $$.q.in = 1; $$.q.out = 1; }
789 ;
790
791parameter_type_specifier:
792 type_specifier
793 ;
794
795init_declarator_list:
796 single_declaration
797 | init_declarator_list ',' IDENTIFIER
798 {
799 void *ctx = state;
800 ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL);
801 decl->set_location(yylloc);
802
803 $$ = $1;
804 $$->declarations.push_tail(&decl->link);
805 }
806 | init_declarator_list ',' IDENTIFIER '[' ']'
807 {
808 void *ctx = state;
809 ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
810 decl->set_location(yylloc);
811
812 $$ = $1;
813 $$->declarations.push_tail(&decl->link);
814 }
815 | init_declarator_list ',' IDENTIFIER '[' constant_expression ']'
816 {
817 void *ctx = state;
818 ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
819 decl->set_location(yylloc);
820
821 $$ = $1;
822 $$->declarations.push_tail(&decl->link);
823 }
824 | init_declarator_list ',' IDENTIFIER '[' ']' '=' initializer
825 {
826 void *ctx = state;
827 ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
828 decl->set_location(yylloc);
829
830 $$ = $1;
831 $$->declarations.push_tail(&decl->link);
832 }
833 | init_declarator_list ',' IDENTIFIER '[' constant_expression ']' '=' initializer
834 {
835 void *ctx = state;
836 ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
837 decl->set_location(yylloc);
838
839 $$ = $1;
840 $$->declarations.push_tail(&decl->link);
841 }
842 | init_declarator_list ',' IDENTIFIER '=' initializer
843 {
844 void *ctx = state;
845 ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5);
846 decl->set_location(yylloc);
847
848 $$ = $1;
849 $$->declarations.push_tail(&decl->link);
850 }
851 ;
852
853 // Grammar Note: No 'enum', or 'typedef'.
854single_declaration:
855 fully_specified_type
856 {
857 void *ctx = state;
858 if ($1->specifier->type_specifier != ast_struct) {
859 _mesa_glsl_error(& @1, state, "empty declaration list\n");
860 YYERROR;
861 } else {
862 $$ = new(ctx) ast_declarator_list($1);
863 $$->set_location(yylloc);
864 }
865 }
866 | fully_specified_type IDENTIFIER
867 {
868 void *ctx = state;
869 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
870
871 $$ = new(ctx) ast_declarator_list($1);
872 $$->set_location(yylloc);
873 $$->declarations.push_tail(&decl->link);
874 }
875 | fully_specified_type IDENTIFIER '[' ']'
876 {
877 void *ctx = state;
878 ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
879
880 $$ = new(ctx) ast_declarator_list($1);
881 $$->set_location(yylloc);
882 $$->declarations.push_tail(&decl->link);
883 }
884 | fully_specified_type IDENTIFIER '[' constant_expression ']'
885 {
886 void *ctx = state;
887 ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
888
889 $$ = new(ctx) ast_declarator_list($1);
890 $$->set_location(yylloc);
891 $$->declarations.push_tail(&decl->link);
892 }
893 | fully_specified_type IDENTIFIER '[' ']' '=' initializer
894 {
895 void *ctx = state;
896 ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
897
898 $$ = new(ctx) ast_declarator_list($1);
899 $$->set_location(yylloc);
900 $$->declarations.push_tail(&decl->link);
901 }
902 | fully_specified_type IDENTIFIER '[' constant_expression ']' '=' initializer
903 {
904 void *ctx = state;
905 ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
906
907 $$ = new(ctx) ast_declarator_list($1);
908 $$->set_location(yylloc);
909 $$->declarations.push_tail(&decl->link);
910 }
911 | fully_specified_type IDENTIFIER '=' initializer
912 {
913 void *ctx = state;
914 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
915
916 $$ = new(ctx) ast_declarator_list($1);
917 $$->set_location(yylloc);
918 $$->declarations.push_tail(&decl->link);
919 }
920 | INVARIANT IDENTIFIER // Vertex only.
921 {
922 void *ctx = state;
923 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
924
925 $$ = new(ctx) ast_declarator_list(NULL);
926 $$->set_location(yylloc);
927 $$->invariant = true;
928
929 $$->declarations.push_tail(&decl->link);
930 }
931 ;
932
933fully_specified_type:
934 type_specifier
935 {
936 void *ctx = state;
937 $$ = new(ctx) ast_fully_specified_type();
938 $$->set_location(yylloc);
939 $$->specifier = $1;
940 }
941 | type_qualifier type_specifier
942 {
943 void *ctx = state;
944 $$ = new(ctx) ast_fully_specified_type();
945 $$->set_location(yylloc);
946 $$->qualifier = $1.q;
947 $$->specifier = $2;
948 }
949 ;
950
951opt_layout_qualifier:
952 { $$.i = 0; }
953 | layout_qualifier
954 ;
955
956layout_qualifier:
957 LAYOUT_TOK '(' layout_qualifier_id_list ')'
958 {
959 $$ = $3;
960 }
961 ;
962
963layout_qualifier_id_list:
964 layout_qualifier_id
965 | layout_qualifier_id_list ',' layout_qualifier_id
966 {
967 $$.i = $1.i | $3.i;
968 }
969 ;
970
971layout_qualifier_id:
972 IDENTIFIER
973 {
974 $$.i = 0;
975
976 if (state->ARB_fragment_coord_conventions_enable) {
977 bool got_one = false;
978
979 if (strcmp($1, "origin_upper_left") == 0) {
980 got_one = true;
981 $$.q.origin_upper_left = 1;
982 } else if (strcmp($1, "pixel_center_integer") == 0) {
983 got_one = true;
984 $$.q.pixel_center_integer = 1;
985 }
986
987 if (state->ARB_fragment_coord_conventions_warn && got_one) {
988 _mesa_glsl_warning(& @1, state,
989 "GL_ARB_fragment_coord_conventions layout "
990 "identifier `%s' used\n", $1);
991 }
992 }
993
994 /* If the identifier didn't match any known layout identifiers,
995 * emit an error.
996 */
997 if ($$.i == 0) {
998 _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
999 "`%s'\n", $1);
1000 YYERROR;
1001 }
1002 }
1003 ;
1004
1005interpolation_qualifier:
1006 SMOOTH { $$.i = 0; $$.q.smooth = 1; }
1007 | FLAT { $$.i = 0; $$.q.flat = 1; }
1008 | NOPERSPECTIVE { $$.i = 0; $$.q.noperspective = 1; }
1009 ;
1010
1011parameter_type_qualifier:
1012 CONST_TOK { $$.i = 0; $$.q.constant = 1; }
1013 ;
1014
1015type_qualifier:
1016 storage_qualifier
1017 | interpolation_qualifier type_qualifier
1018 {
1019 $$.i = $1.i | $2.i;
1020 }
1021 | INVARIANT type_qualifier
1022 {
1023 $$ = $2;
1024 $$.q.invariant = 1;
1025 }
1026 ;
1027
1028storage_qualifier:
1029 CONST_TOK { $$.i = 0; $$.q.constant = 1; }
1030 | ATTRIBUTE { $$.i = 0; $$.q.attribute = 1; }
1031 | opt_layout_qualifier VARYING { $$.i = $1.i; $$.q.varying = 1; }
1032 | CENTROID VARYING { $$.i = 0; $$.q.centroid = 1; $$.q.varying = 1; }
1033 | opt_layout_qualifier IN_TOK { $$.i = 0; $$.q.in = 1; }
1034 | OUT_TOK { $$.i = 0; $$.q.out = 1; }
1035 | CENTROID IN_TOK { $$.i = 0; $$.q.centroid = 1; $$.q.in = 1; }
1036 | CENTROID OUT_TOK { $$.i = 0; $$.q.centroid = 1; $$.q.out = 1; }
1037 | UNIFORM { $$.i = 0; $$.q.uniform = 1; }
1038 ;
1039
1040type_specifier:
1041 type_specifier_no_prec
1042 | precision_qualifier type_specifier_no_prec
1043 {
1044 $$ = $2;
1045 $$->precision = $1;
1046 }
1047 ;
1048
1049type_specifier_no_prec:
1050 type_specifier_nonarray
1051 | type_specifier_nonarray '[' ']'
1052 {
1053 $$ = $1;
1054 $$->is_array = true;
1055 $$->array_size = NULL;
1056 }
1057 | type_specifier_nonarray '[' constant_expression ']'
1058 {
1059 $$ = $1;
1060 $$->is_array = true;
1061 $$->array_size = $3;
1062 }
1063 ;
1064
1065type_specifier_nonarray:
1066 basic_type_specifier_nonarray
1067 {
1068 void *ctx = state;
1069 $$ = new(ctx) ast_type_specifier($1);
1070 $$->set_location(yylloc);
1071 }
1072 | struct_specifier
1073 {
1074 void *ctx = state;
1075 $$ = new(ctx) ast_type_specifier($1);
1076 $$->set_location(yylloc);
1077 }
1078 | IDENTIFIER
1079 {
1080 void *ctx = state;
1081 $$ = new(ctx) ast_type_specifier($1);
1082 $$->set_location(yylloc);
1083 }
1084 ;
1085
1086basic_type_specifier_nonarray:
1087 VOID_TOK { $$ = ast_void; }
1088 | FLOAT_TOK { $$ = ast_float; }
1089 | INT_TOK { $$ = ast_int; }
1090 | UINT_TOK { $$ = ast_uint; }
1091 | BOOL_TOK { $$ = ast_bool; }
1092 | VEC2 { $$ = ast_vec2; }
1093 | VEC3 { $$ = ast_vec3; }
1094 | VEC4 { $$ = ast_vec4; }
1095 | BVEC2 { $$ = ast_bvec2; }
1096 | BVEC3 { $$ = ast_bvec3; }
1097 | BVEC4 { $$ = ast_bvec4; }
1098 | IVEC2 { $$ = ast_ivec2; }
1099 | IVEC3 { $$ = ast_ivec3; }
1100 | IVEC4 { $$ = ast_ivec4; }
1101 | UVEC2 { $$ = ast_uvec2; }
1102 | UVEC3 { $$ = ast_uvec3; }
1103 | UVEC4 { $$ = ast_uvec4; }
1104 | MAT2X2 { $$ = ast_mat2; }
1105 | MAT2X3 { $$ = ast_mat2x3; }
1106 | MAT2X4 { $$ = ast_mat2x4; }
1107 | MAT3X2 { $$ = ast_mat3x2; }
1108 | MAT3X3 { $$ = ast_mat3; }
1109 | MAT3X4 { $$ = ast_mat3x4; }
1110 | MAT4X2 { $$ = ast_mat4x2; }
1111 | MAT4X3 { $$ = ast_mat4x3; }
1112 | MAT4X4 { $$ = ast_mat4; }
1113 | SAMPLER1D { $$ = ast_sampler1d; }
1114 | SAMPLER2D { $$ = ast_sampler2d; }
1115 | SAMPLER2DRECT { $$ = ast_sampler2drect; }
1116 | SAMPLER3D { $$ = ast_sampler3d; }
1117 | SAMPLERCUBE { $$ = ast_samplercube; }
1118 | SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; }
1119 | SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; }
1120 | SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; }
1121 | SAMPLERCUBESHADOW { $$ = ast_samplercubeshadow; }
1122 | SAMPLER1DARRAY { $$ = ast_sampler1darray; }
1123 | SAMPLER2DARRAY { $$ = ast_sampler2darray; }
1124 | SAMPLER1DARRAYSHADOW { $$ = ast_sampler1darrayshadow; }
1125 | SAMPLER2DARRAYSHADOW { $$ = ast_sampler2darrayshadow; }
1126 | ISAMPLER1D { $$ = ast_isampler1d; }
1127 | ISAMPLER2D { $$ = ast_isampler2d; }
1128 | ISAMPLER3D { $$ = ast_isampler3d; }
1129 | ISAMPLERCUBE { $$ = ast_isamplercube; }
1130 | ISAMPLER1DARRAY { $$ = ast_isampler1darray; }
1131 | ISAMPLER2DARRAY { $$ = ast_isampler2darray; }
1132 | USAMPLER1D { $$ = ast_usampler1d; }
1133 | USAMPLER2D { $$ = ast_usampler2d; }
1134 | USAMPLER3D { $$ = ast_usampler3d; }
1135 | USAMPLERCUBE { $$ = ast_usamplercube; }
1136 | USAMPLER1DARRAY { $$ = ast_usampler1darray; }
1137 | USAMPLER2DARRAY { $$ = ast_usampler2darray; }
1138 ;
1139
1140precision_qualifier:
1141 HIGHP {
1142 if (state->language_version < 130)
1143 _mesa_glsl_error(& @1, state,
1144 "precision qualifier forbidden "
1145 "in GLSL %d.%d (1.30 or later "
1146 "required)\n",
1147 state->language_version / 100,
1148 state->language_version % 100);
1149
1150 $$ = ast_precision_high;
1151 }
1152 | MEDIUMP {
1153 if (state->language_version < 130)
1154 _mesa_glsl_error(& @1, state,
1155 "precision qualifier forbidden "
1156 "in GLSL %d.%d (1.30 or later "
1157 "required)\n",
1158 state->language_version / 100,
1159 state->language_version % 100);
1160
1161 $$ = ast_precision_medium;
1162 }
1163 | LOWP {
1164 if (state->language_version < 130)
1165 _mesa_glsl_error(& @1, state,
1166 "precision qualifier forbidden "
1167 "in GLSL %d.%d (1.30 or later "
1168 "required)\n",
1169 state->language_version / 100,
1170 state->language_version % 100);
1171
1172 $$ = ast_precision_low;
1173 }
1174 ;
1175
1176struct_specifier:
1177 STRUCT IDENTIFIER '{' struct_declaration_list '}'
1178 {
1179 void *ctx = state;
1180 $$ = new(ctx) ast_struct_specifier($2, $4);
1181 $$->set_location(yylloc);
1182 }
1183 | STRUCT '{' struct_declaration_list '}'
1184 {
1185 void *ctx = state;
1186 $$ = new(ctx) ast_struct_specifier(NULL, $3);
1187 $$->set_location(yylloc);
1188 }
1189 ;
1190
1191struct_declaration_list:
1192 struct_declaration
1193 {
1194 $$ = (ast_node *) $1;
1195 $1->link.self_link();
1196 }
1197 | struct_declaration_list struct_declaration
1198 {
1199 $$ = (ast_node *) $1;
1200 $$->link.insert_before(& $2->link);
1201 }
1202 ;
1203
1204struct_declaration:
1205 type_specifier struct_declarator_list ';'
1206 {
1207 void *ctx = state;
1208 ast_fully_specified_type *type = new(ctx) ast_fully_specified_type();
1209 type->set_location(yylloc);
1210
1211 type->specifier = $1;
1212 $$ = new(ctx) ast_declarator_list(type);
1213 $$->set_location(yylloc);
1214
1215 $$->declarations.push_degenerate_list_at_head(& $2->link);
1216 }
1217 ;
1218
1219struct_declarator_list:
1220 struct_declarator
1221 {
1222 $$ = $1;
1223 $1->link.self_link();
1224 }
1225 | struct_declarator_list ',' struct_declarator
1226 {
1227 $$ = $1;
1228 $$->link.insert_before(& $3->link);
1229 }
1230 ;
1231
1232struct_declarator:
1233 IDENTIFIER
1234 {
1235 void *ctx = state;
1236 $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
1237 $$->set_location(yylloc);
1238 }
1239 | IDENTIFIER '[' constant_expression ']'
1240 {
1241 void *ctx = state;
1242 $$ = new(ctx) ast_declaration($1, true, $3, NULL);
1243 $$->set_location(yylloc);
1244 }
1245 ;
1246
1247initializer:
1248 assignment_expression
1249 ;
1250
1251declaration_statement:
1252 declaration
1253 ;
1254
1255 // Grammar Note: labeled statements for SWITCH only; 'goto' is not
1256 // supported.
1257statement:
1258 statement_matched
1259 | statement_unmatched
1260 ;
1261
1262statement_matched:
1263 compound_statement { $$ = (ast_node *) $1; }
1264 | simple_statement
1265 ;
1266
1267statement_unmatched:
1268 selection_statement_unmatched
1269 ;
1270
1271simple_statement:
1272 declaration_statement
1273 | expression_statement
1274 | selection_statement_matched
1275 | switch_statement { $$ = NULL; }
1276 | case_label { $$ = NULL; }
1277 | iteration_statement
1278 | jump_statement
1279 ;
1280
1281compound_statement:
1282 '{' '}'
1283 {
1284 void *ctx = state;
1285 $$ = new(ctx) ast_compound_statement(true, NULL);
1286 $$->set_location(yylloc);
1287 }
1288 | '{' statement_list '}'
1289 {
1290 void *ctx = state;
1291 $$ = new(ctx) ast_compound_statement(true, $2);
1292 $$->set_location(yylloc);
1293 }
1294 ;
1295
1296statement_no_new_scope:
1297 compound_statement_no_new_scope { $$ = (ast_node *) $1; }
1298 | simple_statement
1299 ;
1300
1301compound_statement_no_new_scope:
1302 '{' '}'
1303 {
1304 void *ctx = state;
1305 $$ = new(ctx) ast_compound_statement(false, NULL);
1306 $$->set_location(yylloc);
1307 }
1308 | '{' statement_list '}'
1309 {
1310 void *ctx = state;
1311 $$ = new(ctx) ast_compound_statement(false, $2);
1312 $$->set_location(yylloc);
1313 }
1314 ;
1315
1316statement_list:
1317 statement
1318 {
1319 if ($1 == NULL) {
1320 _mesa_glsl_error(& @1, state, "<nil> statement\n");
1321 assert($1 != NULL);
1322 }
1323
1324 $$ = $1;
1325 $$->link.self_link();
1326 }
1327 | statement_list statement
1328 {
1329 if ($2 == NULL) {
1330 _mesa_glsl_error(& @2, state, "<nil> statement\n");
1331 assert($2 != NULL);
1332 }
1333 $$ = $1;
1334 $$->link.insert_before(& $2->link);
1335 }
1336 ;
1337
1338expression_statement:
1339 ';'
1340 {
1341 void *ctx = state;
1342 $$ = new(ctx) ast_expression_statement(NULL);
1343 $$->set_location(yylloc);
1344 }
1345 | expression ';'
1346 {
1347 void *ctx = state;
1348 $$ = new(ctx) ast_expression_statement($1);
1349 $$->set_location(yylloc);
1350 }
1351 ;
1352
1353selection_statement_matched:
1354 IF '(' expression ')' statement_matched ELSE statement_matched
1355 {
1356 void *ctx = state;
1357 $$ = new(ctx) ast_selection_statement($3, $5, $7);
1358 $$->set_location(yylloc);
1359 }
1360 ;
1361
1362selection_statement_unmatched:
1363 IF '(' expression ')' statement_matched
1364 {
1365 void *ctx = state;
1366 $$ = new(ctx) ast_selection_statement($3, $5, NULL);
1367 $$->set_location(yylloc);
1368 }
1369 | IF '(' expression ')' statement_unmatched
1370 {
1371 void *ctx = state;
1372 $$ = new(ctx) ast_selection_statement($3, $5, NULL);
1373 $$->set_location(yylloc);
1374 }
1375 | IF '(' expression ')' statement_matched ELSE statement_unmatched
1376 {
1377 void *ctx = state;
1378 $$ = new(ctx) ast_selection_statement($3, $5, $7);
1379 $$->set_location(yylloc);
1380 }
1381 ;
1382
1383condition:
1384 expression
1385 {
1386 $$ = (ast_node *) $1;
1387 }
1388 | fully_specified_type IDENTIFIER '=' initializer
1389 {
1390 void *ctx = state;
1391 ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
1392 ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
1393 decl->set_location(yylloc);
1394 declarator->set_location(yylloc);
1395
1396 declarator->declarations.push_tail(&decl->link);
1397 $$ = declarator;
1398 }
1399 ;
1400
1401switch_statement:
1402 SWITCH '(' expression ')' compound_statement
1403 ;
1404
1405case_label:
1406 CASE expression ':'
1407 | DEFAULT ':'
1408 ;
1409
1410iteration_statement:
1411 WHILE '(' condition ')' statement_no_new_scope
1412 {
1413 void *ctx = state;
1414 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
1415 NULL, $3, NULL, $5);
1416 $$->set_location(yylloc);
1417 }
1418 | DO statement WHILE '(' expression ')' ';'
1419 {
1420 void *ctx = state;
1421 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
1422 NULL, $5, NULL, $2);
1423 $$->set_location(yylloc);
1424 }
1425 | FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
1426 {
1427 void *ctx = state;
1428 $$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
1429 $3, $4.cond, $4.rest, $6);
1430 $$->set_location(yylloc);
1431 }
1432 ;
1433
1434for_init_statement:
1435 expression_statement
1436 | declaration_statement
1437 ;
1438
1439conditionopt:
1440 condition
1441 | /* empty */
1442 {
1443 $$ = NULL;
1444 }
1445 ;
1446
1447for_rest_statement:
1448 conditionopt ';'
1449 {
1450 $$.cond = $1;
1451 $$.rest = NULL;
1452 }
1453 | conditionopt ';' expression
1454 {
1455 $$.cond = $1;
1456 $$.rest = $3;
1457 }
1458 ;
1459
1460 // Grammar Note: No 'goto'. Gotos are not supported.
1461jump_statement:
1462 CONTINUE ';'
1463 {
1464 void *ctx = state;
1465 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
1466 $$->set_location(yylloc);
1467 }
1468 | BREAK ';'
1469 {
1470 void *ctx = state;
1471 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
1472 $$->set_location(yylloc);
1473 }
1474 | RETURN ';'
1475 {
1476 void *ctx = state;
1477 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
1478 $$->set_location(yylloc);
1479 }
1480 | RETURN expression ';'
1481 {
1482 void *ctx = state;
1483 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
1484 $$->set_location(yylloc);
1485 }
1486 | DISCARD ';' // Fragment shader only.
1487 {
1488 void *ctx = state;
1489 $$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
1490 $$->set_location(yylloc);
1491 }
1492 ;
1493
1494external_declaration:
1495 function_definition { $$ = $1; }
1496 | declaration { $$ = $1; }
1497 ;
1498
1499function_definition:
1500 function_prototype compound_statement_no_new_scope
1501 {
1502 void *ctx = state;
1503 $$ = new(ctx) ast_function_definition();
1504 $$->set_location(yylloc);
1505 $$->prototype = $1;
1506 $$->body = $2;
1507 }
1508 ;
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
new file mode 100644
index 00000000000..d1bb1ae5ecc
--- /dev/null
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -0,0 +1,743 @@
1/*
2 * Copyright © 2008, 2009 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23#include <stdio.h>
24#include <stdarg.h>
25#include <string.h>
26#include <assert.h>
27
28extern "C" {
29#include <talloc.h>
30#include "main/mtypes.h"
31}
32
33#include "ast.h"
34#include "glsl_parser_extras.h"
35#include "glsl_parser.h"
36#include "ir_optimization.h"
37
38_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct __GLcontextRec *ctx,
39 GLenum target, void *mem_ctx)
40{
41 switch (target) {
42 case GL_VERTEX_SHADER: this->target = vertex_shader; break;
43 case GL_FRAGMENT_SHADER: this->target = fragment_shader; break;
44 case GL_GEOMETRY_SHADER: this->target = geometry_shader; break;
45 }
46
47 this->scanner = NULL;
48 this->translation_unit.make_empty();
49 this->symbols = new(mem_ctx) glsl_symbol_table;
50 this->info_log = talloc_strdup(mem_ctx, "");
51 this->error = false;
52 this->loop_or_switch_nesting = NULL;
53 this->ARB_texture_rectangle_enable = true;
54
55 if (ctx != NULL) {
56 this->extensions = &ctx->Extensions;
57
58 this->Const.MaxLights = ctx->Const.MaxLights;
59 this->Const.MaxClipPlanes = ctx->Const.MaxClipPlanes;
60 this->Const.MaxTextureUnits = ctx->Const.MaxTextureUnits;
61 this->Const.MaxTextureCoords = ctx->Const.MaxTextureCoordUnits;
62 this->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs;
63 this->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents;
64 this->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4;
65 this->Const.MaxVertexTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits;
66 this->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits;
67 this->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits;
68 this->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents;
69
70 this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
71 } else {
72 /* If there is no GL context (standalone compiler), fill in constants
73 * with the minimum required values.
74 */
75 static struct gl_extensions null_extensions;
76
77 memset(&null_extensions, 0, sizeof(null_extensions));
78 null_extensions.ARB_draw_buffers = GL_TRUE;
79 null_extensions.ARB_fragment_coord_conventions = GL_TRUE;
80 null_extensions.EXT_texture_array = GL_TRUE;
81 null_extensions.NV_texture_rectangle = GL_TRUE;
82
83 this->extensions = &null_extensions;
84
85 /* 1.10 minimums. */
86 this->Const.MaxLights = 8;
87 this->Const.MaxClipPlanes = 8;
88 this->Const.MaxTextureUnits = 2;
89
90 /* More than the 1.10 minimum to appease parser tests taken from
91 * apps that (hopefully) already checked the number of coords.
92 */
93 this->Const.MaxTextureCoords = 4;
94
95 this->Const.MaxVertexAttribs = 16;
96 this->Const.MaxVertexUniformComponents = 512;
97 this->Const.MaxVaryingFloats = 32;
98 this->Const.MaxVertexTextureImageUnits = 0;
99 this->Const.MaxCombinedTextureImageUnits = 2;
100 this->Const.MaxTextureImageUnits = 2;
101 this->Const.MaxFragmentUniformComponents = 64;
102
103 this->Const.MaxDrawBuffers = 2;
104 }
105}
106
107const char *
108_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
109{
110 switch (target) {
111 case vertex_shader: return "vertex";
112 case fragment_shader: return "fragment";
113 case geometry_shader: return "geometry";
114 case ir_shader: break;
115 }
116
117 assert(!"Should not get here.");
118 return "unknown";
119}
120
121
122void
123_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
124 const char *fmt, ...)
125{
126 va_list ap;
127
128 state->error = true;
129
130 assert(state->info_log != NULL);
131 state->info_log = talloc_asprintf_append(state->info_log,
132 "%u:%u(%u): error: ",
133 locp->source,
134 locp->first_line,
135 locp->first_column);
136 va_start(ap, fmt);
137 state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
138 va_end(ap);
139 state->info_log = talloc_strdup_append(state->info_log, "\n");
140}
141
142
143void
144_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
145 const char *fmt, ...)
146{
147 va_list ap;
148
149 assert(state->info_log != NULL);
150 state->info_log = talloc_asprintf_append(state->info_log,
151 "%u:%u(%u): warning: ",
152 locp->source,
153 locp->first_line,
154 locp->first_column);
155 va_start(ap, fmt);
156 state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
157 va_end(ap);
158 state->info_log = talloc_strdup_append(state->info_log, "\n");
159}
160
161
162bool
163_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
164 const char *behavior, YYLTYPE *behavior_locp,
165 _mesa_glsl_parse_state *state)
166{
167 enum {
168 extension_disable,
169 extension_enable,
170 extension_require,
171 extension_warn
172 } ext_mode;
173
174 if (strcmp(behavior, "warn") == 0) {
175 ext_mode = extension_warn;
176 } else if (strcmp(behavior, "require") == 0) {
177 ext_mode = extension_require;
178 } else if (strcmp(behavior, "enable") == 0) {
179 ext_mode = extension_enable;
180 } else if (strcmp(behavior, "disable") == 0) {
181 ext_mode = extension_disable;
182 } else {
183 _mesa_glsl_error(behavior_locp, state,
184 "Unknown extension behavior `%s'",
185 behavior);
186 return false;
187 }
188
189 bool unsupported = false;
190
191 if (strcmp(name, "all") == 0) {
192 if ((ext_mode == extension_enable) || (ext_mode == extension_require)) {
193 _mesa_glsl_error(name_locp, state, "Cannot %s all extensions",
194 (ext_mode == extension_enable)
195 ? "enable" : "require");
196 return false;
197 }
198 } else if (strcmp(name, "GL_ARB_draw_buffers") == 0) {
199 /* This extension is only supported in fragment shaders.
200 */
201 if (state->target != fragment_shader) {
202 unsupported = true;
203 } else {
204 state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
205 state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
206 }
207 } else if (strcmp(name, "GL_ARB_fragment_coord_conventions") == 0) {
208 state->ARB_fragment_coord_conventions_enable =
209 (ext_mode != extension_disable);
210 state->ARB_fragment_coord_conventions_warn =
211 (ext_mode == extension_warn);
212
213 unsupported = !state->extensions->ARB_fragment_coord_conventions;
214 } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) {
215 state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
216 state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);
217 } else if (strcmp(name, "GL_EXT_texture_array") == 0) {
218 state->EXT_texture_array_enable = (ext_mode != extension_disable);
219 state->EXT_texture_array_warn = (ext_mode == extension_warn);
220
221 unsupported = !state->extensions->EXT_texture_array;
222 } else {
223 unsupported = true;
224 }
225
226 if (unsupported) {
227 static const char *const fmt = "extension `%s' unsupported in %s shader";
228
229 if (ext_mode == extension_require) {
230 _mesa_glsl_error(name_locp, state, fmt,
231 name, _mesa_glsl_shader_target_name(state->target));
232 return false;
233 } else {
234 _mesa_glsl_warning(name_locp, state, fmt,
235 name, _mesa_glsl_shader_target_name(state->target));
236 }
237 }
238
239 return true;
240}
241
242void
243_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q)
244{
245 if (q->constant)
246 printf("const ");
247
248 if (q->invariant)
249 printf("invariant ");
250
251 if (q->attribute)
252 printf("attribute ");
253
254 if (q->varying)
255 printf("varying ");
256
257 if (q->in && q->out)
258 printf("inout ");
259 else {
260 if (q->in)
261 printf("in ");
262
263 if (q->out)
264 printf("out ");
265 }
266
267 if (q->centroid)
268 printf("centroid ");
269 if (q->uniform)
270 printf("uniform ");
271 if (q->smooth)
272 printf("smooth ");
273 if (q->flat)
274 printf("flat ");
275 if (q->noperspective)
276 printf("noperspective ");
277}
278
279
280void
281ast_node::print(void) const
282{
283 printf("unhandled node ");
284}
285
286
287ast_node::ast_node(void)
288{
289 this->location.source = 0;
290 this->location.line = 0;
291 this->location.column = 0;
292}
293
294
295static void
296ast_opt_array_size_print(bool is_array, const ast_expression *array_size)
297{
298 if (is_array) {
299 printf("[ ");
300
301 if (array_size)
302 array_size->print();
303
304 printf("] ");
305 }
306}
307
308
309void
310ast_compound_statement::print(void) const
311{
312 printf("{\n");
313
314 foreach_list_const(n, &this->statements) {
315 ast_node *ast = exec_node_data(ast_node, n, link);
316 ast->print();
317 }
318
319 printf("}\n");
320}
321
322
323ast_compound_statement::ast_compound_statement(int new_scope,
324 ast_node *statements)
325{
326 this->new_scope = new_scope;
327
328 if (statements != NULL) {
329 this->statements.push_degenerate_list_at_head(&statements->link);
330 }
331}
332
333
334void
335ast_expression::print(void) const
336{
337 switch (oper) {
338 case ast_assign:
339 case ast_mul_assign:
340 case ast_div_assign:
341 case ast_mod_assign:
342 case ast_add_assign:
343 case ast_sub_assign:
344 case ast_ls_assign:
345 case ast_rs_assign:
346 case ast_and_assign:
347 case ast_xor_assign:
348 case ast_or_assign:
349 subexpressions[0]->print();
350 printf("%s ", operator_string(oper));
351 subexpressions[1]->print();
352 break;
353
354 case ast_field_selection:
355 subexpressions[0]->print();
356 printf(". %s ", primary_expression.identifier);
357 break;
358
359 case ast_plus:
360 case ast_neg:
361 case ast_bit_not:
362 case ast_logic_not:
363 case ast_pre_inc:
364 case ast_pre_dec:
365 printf("%s ", operator_string(oper));
366 subexpressions[0]->print();
367 break;
368
369 case ast_post_inc:
370 case ast_post_dec:
371 subexpressions[0]->print();
372 printf("%s ", operator_string(oper));
373 break;
374
375 case ast_conditional:
376 subexpressions[0]->print();
377 printf("? ");
378 subexpressions[1]->print();
379 printf(": ");
380 subexpressions[1]->print();
381 break;
382
383 case ast_array_index:
384 subexpressions[0]->print();
385 printf("[ ");
386 subexpressions[1]->print();
387 printf("] ");
388 break;
389
390 case ast_function_call: {
391 subexpressions[0]->print();
392 printf("( ");
393
394 foreach_list_const (n, &this->expressions) {
395 if (n != this->expressions.get_head())
396 printf(", ");
397
398 ast_node *ast = exec_node_data(ast_node, n, link);
399 ast->print();
400 }
401
402 printf(") ");
403 break;
404 }
405
406 case ast_identifier:
407 printf("%s ", primary_expression.identifier);
408 break;
409
410 case ast_int_constant:
411 printf("%d ", primary_expression.int_constant);
412 break;
413
414 case ast_uint_constant:
415 printf("%u ", primary_expression.uint_constant);
416 break;
417
418 case ast_float_constant:
419 printf("%f ", primary_expression.float_constant);
420 break;
421
422 case ast_bool_constant:
423 printf("%s ",
424 primary_expression.bool_constant
425 ? "true" : "false");
426 break;
427
428 case ast_sequence: {
429 printf("( ");
430 foreach_list_const(n, & this->expressions) {
431 if (n != this->expressions.get_head())
432 printf(", ");
433
434 ast_node *ast = exec_node_data(ast_node, n, link);
435 ast->print();
436 }
437 printf(") ");
438 break;
439 }
440
441 default:
442 assert(0);
443 break;
444 }
445}
446
447ast_expression::ast_expression(int oper,
448 ast_expression *ex0,
449 ast_expression *ex1,
450 ast_expression *ex2)
451{
452 this->oper = ast_operators(oper);
453 this->subexpressions[0] = ex0;
454 this->subexpressions[1] = ex1;
455 this->subexpressions[2] = ex2;
456}
457
458
459void
460ast_expression_statement::print(void) const
461{
462 if (expression)
463 expression->print();
464
465 printf("; ");
466}
467
468
469ast_expression_statement::ast_expression_statement(ast_expression *ex) :
470 expression(ex)
471{
472 /* empty */
473}
474
475
476void
477ast_function::print(void) const
478{
479 return_type->print();
480 printf(" %s (", identifier);
481
482 foreach_list_const(n, & this->parameters) {
483 ast_node *ast = exec_node_data(ast_node, n, link);
484 ast->print();
485 }
486
487 printf(")");
488}
489
490
491ast_function::ast_function(void)
492 : is_definition(false), signature(NULL)
493{
494 /* empty */
495}
496
497
498void
499ast_fully_specified_type::print(void) const
500{
501 _mesa_ast_type_qualifier_print(& qualifier);
502 specifier->print();
503}
504
505
506void
507ast_parameter_declarator::print(void) const
508{
509 type->print();
510 if (identifier)
511 printf("%s ", identifier);
512 ast_opt_array_size_print(is_array, array_size);
513}
514
515
516void
517ast_function_definition::print(void) const
518{
519 prototype->print();
520 body->print();
521}
522
523
524void
525ast_declaration::print(void) const
526{
527 printf("%s ", identifier);
528 ast_opt_array_size_print(is_array, array_size);
529
530 if (initializer) {
531 printf("= ");
532 initializer->print();
533 }
534}
535
536
537ast_declaration::ast_declaration(char *identifier, int is_array,
538 ast_expression *array_size,
539 ast_expression *initializer)
540{
541 this->identifier = identifier;
542 this->is_array = is_array;
543 this->array_size = array_size;
544 this->initializer = initializer;
545}
546
547
548void
549ast_declarator_list::print(void) const
550{
551 assert(type || invariant);
552
553 if (type)
554 type->print();
555 else
556 printf("invariant ");
557
558 foreach_list_const (ptr, & this->declarations) {
559 if (ptr != this->declarations.get_head())
560 printf(", ");
561
562 ast_node *ast = exec_node_data(ast_node, ptr, link);
563 ast->print();
564 }
565
566 printf("; ");
567}
568
569
570ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type)
571{
572 this->type = type;
573 this->invariant = false;
574}
575
576void
577ast_jump_statement::print(void) const
578{
579 switch (mode) {
580 case ast_continue:
581 printf("continue; ");
582 break;
583 case ast_break:
584 printf("break; ");
585 break;
586 case ast_return:
587 printf("return ");
588 if (opt_return_value)
589 opt_return_value->print();
590
591 printf("; ");
592 break;
593 case ast_discard:
594 printf("discard; ");
595 break;
596 }
597}
598
599
600ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value)
601{
602 this->mode = ast_jump_modes(mode);
603
604 if (mode == ast_return)
605 opt_return_value = return_value;
606}
607
608
609void
610ast_selection_statement::print(void) const
611{
612 printf("if ( ");
613 condition->print();
614 printf(") ");
615
616 then_statement->print();
617
618 if (else_statement) {
619 printf("else ");
620 else_statement->print();
621 }
622
623}
624
625
626ast_selection_statement::ast_selection_statement(ast_expression *condition,
627 ast_node *then_statement,
628 ast_node *else_statement)
629{
630 this->condition = condition;
631 this->then_statement = then_statement;
632 this->else_statement = else_statement;
633}
634
635
636void
637ast_iteration_statement::print(void) const
638{
639 switch (mode) {
640 case ast_for:
641 printf("for( ");
642 if (init_statement)
643 init_statement->print();
644 printf("; ");
645
646 if (condition)
647 condition->print();
648 printf("; ");
649
650 if (rest_expression)
651 rest_expression->print();
652 printf(") ");
653
654 body->print();
655 break;
656
657 case ast_while:
658 printf("while ( ");
659 if (condition)
660 condition->print();
661 printf(") ");
662 body->print();
663 break;
664
665 case ast_do_while:
666 printf("do ");
667 body->print();
668 printf("while ( ");
669 if (condition)
670 condition->print();
671 printf("); ");
672 break;
673 }
674}
675
676
677ast_iteration_statement::ast_iteration_statement(int mode,
678 ast_node *init,
679 ast_node *condition,
680 ast_expression *rest_expression,
681 ast_node *body)
682{
683 this->mode = ast_iteration_modes(mode);
684 this->init_statement = init;
685 this->condition = condition;
686 this->rest_expression = rest_expression;
687 this->body = body;
688}
689
690
691void
692ast_struct_specifier::print(void) const
693{
694 printf("struct %s { ", name);
695 foreach_list_const(n, &this->declarations) {
696 ast_node *ast = exec_node_data(ast_node, n, link);
697 ast->print();
698 }
699 printf("} ");
700}
701
702
703ast_struct_specifier::ast_struct_specifier(char *identifier,
704 ast_node *declarator_list)
705{
706 name = identifier;
707 this->declarations.push_degenerate_list_at_head(&declarator_list->link);
708}
709
710bool
711do_common_optimization(exec_list *ir, bool linked)
712{
713 GLboolean progress = GL_FALSE;
714
715 progress = do_sub_to_add_neg(ir) || progress;
716
717 if (linked) {
718 progress = do_function_inlining(ir) || progress;
719 progress = do_dead_functions(ir) || progress;
720 }
721 progress = do_structure_splitting(ir) || progress;
722 progress = do_if_simplification(ir) || progress;
723 progress = do_copy_propagation(ir) || progress;
724 if (linked)
725 progress = do_dead_code(ir) || progress;
726 else
727 progress = do_dead_code_unlinked(ir) || progress;
728 progress = do_dead_code_local(ir) || progress;
729 progress = do_tree_grafting(ir) || progress;
730 progress = do_constant_propagation(ir) || progress;
731 if (linked)
732 progress = do_constant_variable(ir) || progress;
733 else
734 progress = do_constant_variable_unlinked(ir) || progress;
735 progress = do_constant_folding(ir) || progress;
736 progress = do_algebraic(ir) || progress;
737 progress = do_if_return(ir) || progress;
738 progress = do_vec_index_to_swizzle(ir) || progress;
739 progress = do_swizzle_swizzle(ir) || progress;
740 progress = do_noop_swizzle(ir) || progress;
741
742 return progress;
743}
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
new file mode 100644
index 00000000000..3b53ba07f68
--- /dev/null
+++ b/src/glsl/glsl_parser_extras.h
@@ -0,0 +1,214 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#pragma once
25#ifndef GLSL_PARSER_EXTRAS_H
26#define GLSL_PARSER_EXTRAS_H
27
28#include <cstdlib>
29#include "glsl_symbol_table.h"
30
31enum _mesa_glsl_parser_targets {
32 vertex_shader,
33 geometry_shader,
34 fragment_shader,
35 ir_shader
36};
37
38struct __GLcontextRec;
39
40struct _mesa_glsl_parse_state {
41 _mesa_glsl_parse_state(struct __GLcontextRec *ctx, GLenum target,
42 void *mem_ctx);
43
44 /* Callers of this talloc-based new need not call delete. It's
45 * easier to just talloc_free 'ctx' (or any of its ancestors). */
46 static void* operator new(size_t size, void *ctx)
47 {
48 void *mem = talloc_zero_size(ctx, size);
49 assert(mem != NULL);
50
51 return mem;
52 }
53
54 /* If the user *does* call delete, that's OK, we will just
55 * talloc_free in that case. */
56 static void operator delete(void *mem)
57 {
58 talloc_free(mem);
59 }
60
61 void *scanner;
62 exec_list translation_unit;
63 glsl_symbol_table *symbols;
64
65 unsigned language_version;
66 enum _mesa_glsl_parser_targets target;
67
68 /**
69 * Implementation defined limits that affect built-in variables, etc.
70 *
71 * \sa struct gl_constants (in mtypes.h)
72 */
73 struct {
74 /* 1.10 */
75 unsigned MaxLights;
76 unsigned MaxClipPlanes;
77 unsigned MaxTextureUnits;
78 unsigned MaxTextureCoords;
79 unsigned MaxVertexAttribs;
80 unsigned MaxVertexUniformComponents;
81 unsigned MaxVaryingFloats;
82 unsigned MaxVertexTextureImageUnits;
83 unsigned MaxCombinedTextureImageUnits;
84 unsigned MaxTextureImageUnits;
85 unsigned MaxFragmentUniformComponents;
86
87 /* ARB_draw_buffers */
88 unsigned MaxDrawBuffers;
89 } Const;
90
91 /**
92 * During AST to IR conversion, pointer to current IR function
93 *
94 * Will be \c NULL whenever the AST to IR conversion is not inside a
95 * function definition.
96 */
97 class ir_function_signature *current_function;
98
99 /** Have we found a return statement in this function? */
100 bool found_return;
101
102 /** Was there an error during compilation? */
103 bool error;
104
105 /** Loop or switch statement containing the current instructions. */
106 class ir_instruction *loop_or_switch_nesting;
107 class ast_iteration_statement *loop_or_switch_nesting_ast;
108
109 /** List of structures defined in user code. */
110 const glsl_type **user_structures;
111 unsigned num_user_structures;
112
113 char *info_log;
114
115 /**
116 * \name Enable bits for GLSL extensions
117 */
118 /*@{*/
119 unsigned ARB_draw_buffers_enable:1;
120 unsigned ARB_draw_buffers_warn:1;
121 unsigned ARB_fragment_coord_conventions_enable:1;
122 unsigned ARB_fragment_coord_conventions_warn:1;
123 unsigned ARB_texture_rectangle_enable:1;
124 unsigned ARB_texture_rectangle_warn:1;
125 unsigned EXT_texture_array_enable:1;
126 unsigned EXT_texture_array_warn:1;
127 /*@}*/
128
129 /** Extensions supported by the OpenGL implementation. */
130 const struct gl_extensions *extensions;
131
132 /** Shaders containing built-in functions that are used for linking. */
133 struct gl_shader *builtins_to_link[16];
134 unsigned num_builtins_to_link;
135};
136
137typedef struct YYLTYPE {
138 int first_line;
139 int first_column;
140 int last_line;
141 int last_column;
142 unsigned source;
143} YYLTYPE;
144# define YYLTYPE_IS_DECLARED 1
145# define YYLTYPE_IS_TRIVIAL 1
146
147# define YYLLOC_DEFAULT(Current, Rhs, N) \
148do { \
149 if (N) \
150 { \
151 (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
152 (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
153 (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
154 (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
155 } \
156 else \
157 { \
158 (Current).first_line = (Current).last_line = \
159 YYRHSLOC(Rhs, 0).last_line; \
160 (Current).first_column = (Current).last_column = \
161 YYRHSLOC(Rhs, 0).last_column; \
162 } \
163 (Current).source = 0; \
164} while (0)
165
166extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
167 const char *fmt, ...);
168
169/**
170 * Emit a warning to the shader log
171 *
172 * \sa _mesa_glsl_error
173 */
174extern void _mesa_glsl_warning(const YYLTYPE *locp,
175 _mesa_glsl_parse_state *state,
176 const char *fmt, ...);
177
178extern "C" {
179extern int preprocess(void *ctx, const char **shader, char **info_log,
180 const struct gl_extensions *extensions);
181}
182
183extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
184 const char *string);
185
186extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state);
187
188union YYSTYPE;
189extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc,
190 void *scanner);
191
192extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *);
193
194/**
195 * Process elements of the #extension directive
196 *
197 * \return
198 * If \c name and \c behavior are valid, \c true is returned. Otherwise
199 * \c false is returned.
200 */
201extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
202 const char *behavior,
203 YYLTYPE *behavior_locp,
204 _mesa_glsl_parse_state *state);
205
206/**
207 * Get the textual name of the specified shader target
208 */
209extern const char *
210_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target);
211
212void do_ir_to_mesa(exec_list *instructions);
213
214#endif /* GLSL_PARSER_EXTRAS_H */
diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h
new file mode 100644
index 00000000000..4cb7559e9a0
--- /dev/null
+++ b/src/glsl/glsl_symbol_table.h
@@ -0,0 +1,171 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef GLSL_SYMBOL_TABLE
27#define GLSL_SYMBOL_TABLE
28
29#include <new>
30
31extern "C" {
32#include "program/symbol_table.h"
33}
34#include "ir.h"
35#include "glsl_types.h"
36
37/**
38 * Facade class for _mesa_symbol_table
39 *
40 * Wraps the existing \c _mesa_symbol_table data structure to enforce some
41 * type safe and some symbol table invariants.
42 */
43struct glsl_symbol_table {
44private:
45 enum glsl_symbol_name_space {
46 glsl_variable_name_space = 0,
47 glsl_type_name_space = 1,
48 glsl_function_name_space = 2
49 };
50
51 static int
52 _glsl_symbol_table_destructor (glsl_symbol_table *table)
53 {
54 table->~glsl_symbol_table();
55
56 return 0;
57 }
58
59public:
60 /* Callers of this talloc-based new need not call delete. It's
61 * easier to just talloc_free 'ctx' (or any of its ancestors). */
62 static void* operator new(size_t size, void *ctx)
63 {
64 void *table;
65
66 table = talloc_size(ctx, size);
67 assert(table != NULL);
68
69 talloc_set_destructor(table, (int (*)(void*)) _glsl_symbol_table_destructor);
70
71 return table;
72 }
73
74 /* If the user *does* call delete, that's OK, we will just
75 * talloc_free in that case. Here, C++ will have already called the
76 * destructor so tell talloc not to do that again. */
77 static void operator delete(void *table)
78 {
79 talloc_set_destructor(table, NULL);
80 talloc_free(table);
81 }
82
83 glsl_symbol_table()
84 {
85 table = _mesa_symbol_table_ctor();
86 }
87
88 ~glsl_symbol_table()
89 {
90 _mesa_symbol_table_dtor(table);
91 }
92
93 void push_scope()
94 {
95 _mesa_symbol_table_push_scope(table);
96 }
97
98 void pop_scope()
99 {
100 _mesa_symbol_table_pop_scope(table);
101 }
102
103 /**
104 * Determine whether a name was declared at the current scope
105 */
106 bool name_declared_this_scope(const char *name)
107 {
108 return _mesa_symbol_table_symbol_scope(table, -1, name) == 0;
109 }
110
111 /**
112 * \name Methods to add symbols to the table
113 *
114 * There is some temptation to rename all these functions to \c add_symbol
115 * or similar. However, this breaks symmetry with the getter functions and
116 * reduces the clarity of the intention of code that uses these methods.
117 */
118 /*@{*/
119 bool add_variable(const char *name, ir_variable *v)
120 {
121 return _mesa_symbol_table_add_symbol(table, glsl_variable_name_space,
122 name, v) == 0;
123 }
124
125 bool add_type(const char *name, const glsl_type *t)
126 {
127 return _mesa_symbol_table_add_symbol(table, glsl_type_name_space,
128 name, (void *) t) == 0;
129 }
130
131 bool add_function(const char *name, ir_function *f)
132 {
133 return _mesa_symbol_table_add_symbol(table, glsl_function_name_space,
134 name, f) == 0;
135 }
136
137 bool remove_function(const char *name, ir_function *f)
138 {
139 return _mesa_symbol_table_add_symbol(table, glsl_function_name_space,
140 name, f) == 0;
141 }
142 /*@}*/
143
144 /**
145 * \name Methods to get symbols from the table
146 */
147 /*@{*/
148 ir_variable *get_variable(const char *name)
149 {
150 return (ir_variable *)
151 _mesa_symbol_table_find_symbol(table, glsl_variable_name_space, name);
152 }
153
154 glsl_type *get_type(const char *name)
155 {
156 return (glsl_type *)
157 _mesa_symbol_table_find_symbol(table, glsl_type_name_space, name);
158 }
159
160 ir_function *get_function(const char *name)
161 {
162 return (ir_function *)
163 _mesa_symbol_table_find_symbol(table, glsl_function_name_space, name);
164 }
165 /*@}*/
166
167private:
168 struct _mesa_symbol_table *table;
169};
170
171#endif /* GLSL_SYMBOL_TABLE */
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
new file mode 100644
index 00000000000..8e80cf99e96
--- /dev/null
+++ b/src/glsl/glsl_types.cpp
@@ -0,0 +1,550 @@
1/*
2 * Copyright © 2009 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <cstdio>
25#include <stdlib.h>
26#include "main/compiler.h"
27#include "glsl_symbol_table.h"
28#include "glsl_parser_extras.h"
29#include "glsl_types.h"
30#include "builtin_types.h"
31extern "C" {
32#include "program/hash_table.h"
33}
34
35hash_table *glsl_type::array_types = NULL;
36hash_table *glsl_type::record_types = NULL;
37void *glsl_type::mem_ctx = NULL;
38
39void
40glsl_type::init_talloc_type_ctx(void)
41{
42 if (glsl_type::mem_ctx == NULL) {
43 glsl_type::mem_ctx = talloc_init("glsl_type");
44 assert(glsl_type::mem_ctx != NULL);
45 }
46}
47
48glsl_type::glsl_type(GLenum gl_type,
49 unsigned base_type, unsigned vector_elements,
50 unsigned matrix_columns, const char *name) :
51 gl_type(gl_type),
52 base_type(base_type),
53 sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
54 sampler_type(0),
55 vector_elements(vector_elements), matrix_columns(matrix_columns),
56 length(0)
57{
58 init_talloc_type_ctx();
59 this->name = talloc_strdup(this->mem_ctx, name);
60 /* Neither dimension is zero or both dimensions are zero.
61 */
62 assert((vector_elements == 0) == (matrix_columns == 0));
63 memset(& fields, 0, sizeof(fields));
64}
65
66glsl_type::glsl_type(GLenum gl_type,
67 enum glsl_sampler_dim dim, bool shadow, bool array,
68 unsigned type, const char *name) :
69 gl_type(gl_type),
70 base_type(GLSL_TYPE_SAMPLER),
71 sampler_dimensionality(dim), sampler_shadow(shadow),
72 sampler_array(array), sampler_type(type),
73 vector_elements(0), matrix_columns(0),
74 length(0)
75{
76 init_talloc_type_ctx();
77 this->name = talloc_strdup(this->mem_ctx, name);
78 memset(& fields, 0, sizeof(fields));
79}
80
81glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
82 const char *name) :
83 base_type(GLSL_TYPE_STRUCT),
84 sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
85 sampler_type(0),
86 vector_elements(0), matrix_columns(0),
87 length(num_fields)
88{
89 unsigned int i;
90
91 init_talloc_type_ctx();
92 this->name = talloc_strdup(this->mem_ctx, name);
93 this->fields.structure = talloc_array(this->mem_ctx,
94 glsl_struct_field, length);
95 for (i = 0; i < length; i++) {
96 this->fields.structure[i].type = fields[i].type;
97 this->fields.structure[i].name = talloc_strdup(this->fields.structure,
98 fields[i].name);
99 }
100}
101
102static void
103add_types_to_symbol_table(glsl_symbol_table *symtab,
104 const struct glsl_type *types,
105 unsigned num_types, bool warn)
106{
107 (void) warn;
108
109 for (unsigned i = 0; i < num_types; i++) {
110 symtab->add_type(types[i].name, & types[i]);
111 }
112}
113
114
115void
116glsl_type::generate_110_types(glsl_symbol_table *symtab)
117{
118 add_types_to_symbol_table(symtab, builtin_core_types,
119 Elements(builtin_core_types),
120 false);
121 add_types_to_symbol_table(symtab, builtin_structure_types,
122 Elements(builtin_structure_types),
123 false);
124 add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,
125 Elements(builtin_110_deprecated_structure_types),
126 false);
127 add_types_to_symbol_table(symtab, & void_type, 1, false);
128}
129
130
131void
132glsl_type::generate_120_types(glsl_symbol_table *symtab)
133{
134 generate_110_types(symtab);
135
136 add_types_to_symbol_table(symtab, builtin_120_types,
137 Elements(builtin_120_types), false);
138}
139
140
141void
142glsl_type::generate_130_types(glsl_symbol_table *symtab)
143{
144 generate_120_types(symtab);
145
146 add_types_to_symbol_table(symtab, builtin_130_types,
147 Elements(builtin_130_types), false);
148 generate_EXT_texture_array_types(symtab, false);
149}
150
151
152void
153glsl_type::generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab,
154 bool warn)
155{
156 add_types_to_symbol_table(symtab, builtin_ARB_texture_rectangle_types,
157 Elements(builtin_ARB_texture_rectangle_types),
158 warn);
159}
160
161
162void
163glsl_type::generate_EXT_texture_array_types(glsl_symbol_table *symtab,
164 bool warn)
165{
166 add_types_to_symbol_table(symtab, builtin_EXT_texture_array_types,
167 Elements(builtin_EXT_texture_array_types),
168 warn);
169}
170
171
172void
173_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
174{
175 switch (state->language_version) {
176 case 110:
177 glsl_type::generate_110_types(state->symbols);
178 break;
179 case 120:
180 glsl_type::generate_120_types(state->symbols);
181 break;
182 case 130:
183 glsl_type::generate_130_types(state->symbols);
184 break;
185 default:
186 /* error */
187 break;
188 }
189
190 if (state->ARB_texture_rectangle_enable) {
191 glsl_type::generate_ARB_texture_rectangle_types(state->symbols,
192 state->ARB_texture_rectangle_warn);
193 }
194
195 if (state->EXT_texture_array_enable && state->language_version < 130) {
196 // These are already included in 130; don't create twice.
197 glsl_type::generate_EXT_texture_array_types(state->symbols,
198 state->EXT_texture_array_warn);
199 }
200}
201
202
203const glsl_type *glsl_type::get_base_type() const
204{
205 switch (base_type) {
206 case GLSL_TYPE_UINT:
207 return uint_type;
208 case GLSL_TYPE_INT:
209 return int_type;
210 case GLSL_TYPE_FLOAT:
211 return float_type;
212 case GLSL_TYPE_BOOL:
213 return bool_type;
214 default:
215 return error_type;
216 }
217}
218
219
220void
221_mesa_glsl_release_types(void)
222{
223 if (glsl_type::array_types != NULL) {
224 hash_table_dtor(glsl_type::array_types);
225 glsl_type::array_types = NULL;
226 }
227
228 if (glsl_type::record_types != NULL) {
229 hash_table_dtor(glsl_type::record_types);
230 glsl_type::record_types = NULL;
231 }
232
233 if (glsl_type::mem_ctx != NULL) {
234 talloc_free(glsl_type::mem_ctx);
235 glsl_type::mem_ctx = NULL;
236 }
237}
238
239
240ir_function *
241glsl_type::generate_constructor(glsl_symbol_table *symtab) const
242{
243 void *ctx = symtab;
244
245 /* Generate the function name and add it to the symbol table.
246 */
247 ir_function *const f = new(ctx) ir_function(name);
248
249 bool added = symtab->add_function(name, f);
250 assert(added);
251
252 ir_function_signature *const sig = new(ctx) ir_function_signature(this);
253 f->add_signature(sig);
254
255 ir_variable **declarations =
256 (ir_variable **) malloc(sizeof(ir_variable *) * this->length);
257 for (unsigned i = 0; i < length; i++) {
258 char *const param_name = (char *) malloc(10);
259
260 snprintf(param_name, 10, "p%08X", i);
261
262 ir_variable *var = (this->base_type == GLSL_TYPE_ARRAY)
263 ? new(ctx) ir_variable(fields.array, param_name, ir_var_in)
264 : new(ctx) ir_variable(fields.structure[i].type, param_name, ir_var_in);
265
266 declarations[i] = var;
267 sig->parameters.push_tail(var);
268 }
269
270 /* Generate the body of the constructor. The body assigns each of the
271 * parameters to a portion of a local variable called _ret_val that has
272 * the same type as the constructor. After initializing _ret_val,
273 * _ret_val is returned.
274 */
275 ir_variable *retval = new(ctx) ir_variable(this, "_ret_val", ir_var_auto);
276 sig->body.push_tail(retval);
277
278 for (unsigned i = 0; i < length; i++) {
279 ir_dereference *const lhs = (this->base_type == GLSL_TYPE_ARRAY)
280 ? (ir_dereference *) new(ctx) ir_dereference_array(retval,
281 new(ctx) ir_constant(i))
282 : (ir_dereference *) new(ctx) ir_dereference_record(retval,
283 fields.structure[i].name);
284
285 ir_dereference *const rhs = new(ctx) ir_dereference_variable(declarations[i]);
286 ir_instruction *const assign = new(ctx) ir_assignment(lhs, rhs, NULL);
287
288 sig->body.push_tail(assign);
289 }
290
291 free(declarations);
292
293 ir_dereference *const retref = new(ctx) ir_dereference_variable(retval);
294 ir_instruction *const inst = new(ctx) ir_return(retref);
295 sig->body.push_tail(inst);
296
297 return f;
298}
299
300
301glsl_type::glsl_type(const glsl_type *array, unsigned length) :
302 base_type(GLSL_TYPE_ARRAY),
303 sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
304 sampler_type(0),
305 vector_elements(0), matrix_columns(0),
306 name(NULL), length(length)
307{
308 this->fields.array = array;
309 /* Inherit the gl type of the base. The GL type is used for
310 * uniform/statevar handling in Mesa and the arrayness of the type
311 * is represented by the size rather than the type.
312 */
313 this->gl_type = array->gl_type;
314
315 /* Allow a maximum of 10 characters for the array size. This is enough
316 * for 32-bits of ~0. The extra 3 are for the '[', ']', and terminating
317 * NUL.
318 */
319 const unsigned name_length = strlen(array->name) + 10 + 3;
320 char *const n = (char *) talloc_size(this->mem_ctx, name_length);
321
322 if (length == 0)
323 snprintf(n, name_length, "%s[]", array->name);
324 else
325 snprintf(n, name_length, "%s[%u]", array->name, length);
326
327 this->name = n;
328}
329
330
331const glsl_type *
332glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
333{
334 if (base_type == GLSL_TYPE_VOID)
335 return &void_type;
336
337 if ((rows < 1) || (rows > 4) || (columns < 1) || (columns > 4))
338 return error_type;
339
340 /* Treat GLSL vectors as Nx1 matrices.
341 */
342 if (columns == 1) {
343 switch (base_type) {
344 case GLSL_TYPE_UINT:
345 return uint_type + (rows - 1);
346 case GLSL_TYPE_INT:
347 return int_type + (rows - 1);
348 case GLSL_TYPE_FLOAT:
349 return float_type + (rows - 1);
350 case GLSL_TYPE_BOOL:
351 return bool_type + (rows - 1);
352 default:
353 return error_type;
354 }
355 } else {
356 if ((base_type != GLSL_TYPE_FLOAT) || (rows == 1))
357 return error_type;
358
359 /* GLSL matrix types are named mat{COLUMNS}x{ROWS}. Only the following
360 * combinations are valid:
361 *
362 * 1 2 3 4
363 * 1
364 * 2 x x x
365 * 3 x x x
366 * 4 x x x
367 */
368#define IDX(c,r) (((c-1)*3) + (r-1))
369
370 switch (IDX(columns, rows)) {
371 case IDX(2,2): return mat2_type;
372 case IDX(2,3): return mat2x3_type;
373 case IDX(2,4): return mat2x4_type;
374 case IDX(3,2): return mat3x2_type;
375 case IDX(3,3): return mat3_type;
376 case IDX(3,4): return mat3x4_type;
377 case IDX(4,2): return mat4x2_type;
378 case IDX(4,3): return mat4x3_type;
379 case IDX(4,4): return mat4_type;
380 default: return error_type;
381 }
382 }
383
384 assert(!"Should not get here.");
385 return error_type;
386}
387
388
389const glsl_type *
390glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
391{
392
393 if (array_types == NULL) {
394 array_types = hash_table_ctor(64, hash_table_string_hash,
395 hash_table_string_compare);
396 }
397
398 /* Generate a name using the base type pointer in the key. This is
399 * done because the name of the base type may not be unique across
400 * shaders. For example, two shaders may have different record types
401 * named 'foo'.
402 */
403 char key[128];
404 snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size);
405
406 const glsl_type *t = (glsl_type *) hash_table_find(array_types, key);
407 if (t == NULL) {
408 t = new glsl_type(base, array_size);
409
410 hash_table_insert(array_types, (void *) t, talloc_strdup(mem_ctx, key));
411 }
412
413 assert(t->base_type == GLSL_TYPE_ARRAY);
414 assert(t->length == array_size);
415 assert(t->fields.array == base);
416
417 return t;
418}
419
420
421int
422glsl_type::record_key_compare(const void *a, const void *b)
423{
424 const glsl_type *const key1 = (glsl_type *) a;
425 const glsl_type *const key2 = (glsl_type *) b;
426
427 /* Return zero is the types match (there is zero difference) or non-zero
428 * otherwise.
429 */
430 if (strcmp(key1->name, key2->name) != 0)
431 return 1;
432
433 if (key1->length != key2->length)
434 return 1;
435
436 for (unsigned i = 0; i < key1->length; i++) {
437 if (key1->fields.structure[i].type != key2->fields.structure[i].type)
438 return 1;
439 if (strcmp(key1->fields.structure[i].name,
440 key2->fields.structure[i].name) != 0)
441 return 1;
442 }
443
444 return 0;
445}
446
447
448unsigned
449glsl_type::record_key_hash(const void *a)
450{
451 const glsl_type *const key = (glsl_type *) a;
452 char hash_key[128];
453 unsigned size = 0;
454
455 size = snprintf(hash_key, sizeof(hash_key), "%08x", key->length);
456
457 for (unsigned i = 0; i < key->length; i++) {
458 if (size >= sizeof(hash_key))
459 break;
460
461 size += snprintf(& hash_key[size], sizeof(hash_key) - size,
462 "%p", (void *) key->fields.structure[i].type);
463 }
464
465 return hash_table_string_hash(& hash_key);
466}
467
468
469const glsl_type *
470glsl_type::get_record_instance(const glsl_struct_field *fields,
471 unsigned num_fields,
472 const char *name)
473{
474 const glsl_type key(fields, num_fields, name);
475
476 if (record_types == NULL) {
477 record_types = hash_table_ctor(64, record_key_hash, record_key_compare);
478 }
479
480 const glsl_type *t = (glsl_type *) hash_table_find(record_types, & key);
481 if (t == NULL) {
482 t = new glsl_type(fields, num_fields, name);
483
484 hash_table_insert(record_types, (void *) t, t);
485 }
486
487 assert(t->base_type == GLSL_TYPE_STRUCT);
488 assert(t->length == num_fields);
489 assert(strcmp(t->name, name) == 0);
490
491 return t;
492}
493
494
495const glsl_type *
496glsl_type::field_type(const char *name) const
497{
498 if (this->base_type != GLSL_TYPE_STRUCT)
499 return error_type;
500
501 for (unsigned i = 0; i < this->length; i++) {
502 if (strcmp(name, this->fields.structure[i].name) == 0)
503 return this->fields.structure[i].type;
504 }
505
506 return error_type;
507}
508
509
510int
511glsl_type::field_index(const char *name) const
512{
513 if (this->base_type != GLSL_TYPE_STRUCT)
514 return -1;
515
516 for (unsigned i = 0; i < this->length; i++) {
517 if (strcmp(name, this->fields.structure[i].name) == 0)
518 return i;
519 }
520
521 return -1;
522}
523
524
525unsigned
526glsl_type::component_slots() const
527{
528 switch (this->base_type) {
529 case GLSL_TYPE_UINT:
530 case GLSL_TYPE_INT:
531 case GLSL_TYPE_FLOAT:
532 case GLSL_TYPE_BOOL:
533 return this->components();
534
535 case GLSL_TYPE_STRUCT: {
536 unsigned size = 0;
537
538 for (unsigned i = 0; i < this->length; i++)
539 size += this->fields.structure[i].type->component_slots();
540
541 return size;
542 }
543
544 case GLSL_TYPE_ARRAY:
545 return this->length * this->fields.array->component_slots();
546
547 default:
548 return 0;
549 }
550}
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
new file mode 100644
index 00000000000..80cec635d99
--- /dev/null
+++ b/src/glsl/glsl_types.h
@@ -0,0 +1,480 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2009 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef GLSL_TYPES_H
27#define GLSL_TYPES_H
28
29#include <cstring>
30#include <cassert>
31
32extern "C" {
33#include "GL/gl.h"
34#include <talloc.h>
35}
36
37struct _mesa_glsl_parse_state;
38struct glsl_symbol_table;
39
40extern "C" void
41_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
42
43extern "C" void
44_mesa_glsl_release_types(void);
45
46#define GLSL_TYPE_UINT 0
47#define GLSL_TYPE_INT 1
48#define GLSL_TYPE_FLOAT 2
49#define GLSL_TYPE_BOOL 3
50#define GLSL_TYPE_SAMPLER 4
51#define GLSL_TYPE_STRUCT 5
52#define GLSL_TYPE_ARRAY 6
53#define GLSL_TYPE_FUNCTION 7
54#define GLSL_TYPE_VOID 8
55#define GLSL_TYPE_ERROR 9
56
57enum glsl_sampler_dim {
58 GLSL_SAMPLER_DIM_1D = 0,
59 GLSL_SAMPLER_DIM_2D,
60 GLSL_SAMPLER_DIM_3D,
61 GLSL_SAMPLER_DIM_CUBE,
62 GLSL_SAMPLER_DIM_RECT,
63 GLSL_SAMPLER_DIM_BUF
64};
65
66
67struct glsl_type {
68 GLenum gl_type;
69 unsigned base_type:4;
70
71 unsigned sampler_dimensionality:3;
72 unsigned sampler_shadow:1;
73 unsigned sampler_array:1;
74 unsigned sampler_type:2; /**< Type of data returned using this sampler.
75 * only \c GLSL_TYPE_FLOAT, \c GLSL_TYPE_INT,
76 * and \c GLSL_TYPE_UINT are valid.
77 */
78
79 /* Callers of this talloc-based new need not call delete. It's
80 * easier to just talloc_free 'mem_ctx' (or any of its ancestors). */
81 static void* operator new(size_t size)
82 {
83 if (glsl_type::mem_ctx == NULL) {
84 glsl_type::mem_ctx = talloc_init("glsl_type");
85 assert(glsl_type::mem_ctx != NULL);
86 }
87
88 void *type;
89
90 type = talloc_size(glsl_type::mem_ctx, size);
91 assert(type != NULL);
92
93 return type;
94 }
95
96 /* If the user *does* call delete, that's OK, we will just
97 * talloc_free in that case. */
98 static void operator delete(void *type)
99 {
100 talloc_free(type);
101 }
102
103 /**
104 * \name Vector and matrix element counts
105 *
106 * For scalars, each of these values will be 1. For non-numeric types
107 * these will be 0.
108 */
109 /*@{*/
110 unsigned vector_elements:3; /**< 1, 2, 3, or 4 vector elements. */
111 unsigned matrix_columns:3; /**< 1, 2, 3, or 4 matrix columns. */
112 /*@}*/
113
114 /**
115 * Name of the data type
116 *
117 * This may be \c NULL for anonymous structures, for arrays, or for
118 * function types.
119 */
120 const char *name;
121
122 /**
123 * For \c GLSL_TYPE_ARRAY, this is the length of the array. For
124 * \c GLSL_TYPE_STRUCT, it is the number of elements in the structure and
125 * the number of values pointed to by \c fields.structure (below).
126 *
127 * For \c GLSL_TYPE_FUNCTION, it is the number of parameters to the
128 * function. The return value from a function is implicitly the first
129 * parameter. The types of the parameters are stored in
130 * \c fields.parameters (below).
131 */
132 unsigned length;
133
134 /**
135 * Subtype of composite data types.
136 */
137 union {
138 const struct glsl_type *array; /**< Type of array elements. */
139 const struct glsl_type *parameters; /**< Parameters to function. */
140 struct glsl_struct_field *structure; /**< List of struct fields. */
141 } fields;
142
143
144 /**
145 * \name Pointers to various public type singletons
146 */
147 /*@{*/
148 static const glsl_type *const error_type;
149 static const glsl_type *const int_type;
150 static const glsl_type *const ivec4_type;
151 static const glsl_type *const uint_type;
152 static const glsl_type *const uvec4_type;
153 static const glsl_type *const float_type;
154 static const glsl_type *const vec2_type;
155 static const glsl_type *const vec3_type;
156 static const glsl_type *const vec4_type;
157 static const glsl_type *const bool_type;
158 static const glsl_type *const mat2_type;
159 static const glsl_type *const mat2x3_type;
160 static const glsl_type *const mat2x4_type;
161 static const glsl_type *const mat3x2_type;
162 static const glsl_type *const mat3_type;
163 static const glsl_type *const mat3x4_type;
164 static const glsl_type *const mat4x2_type;
165 static const glsl_type *const mat4x3_type;
166 static const glsl_type *const mat4_type;
167 /*@}*/
168
169
170 /**
171 * For numeric and boolean derrived types returns the basic scalar type
172 *
173 * If the type is a numeric or boolean scalar, vector, or matrix type,
174 * this function gets the scalar type of the individual components. For
175 * all other types, including arrays of numeric or boolean types, the
176 * error type is returned.
177 */
178 const glsl_type *get_base_type() const;
179
180 /**
181 * Query the type of elements in an array
182 *
183 * \return
184 * Pointer to the type of elements in the array for array types, or \c NULL
185 * for non-array types.
186 */
187 const glsl_type *element_type() const
188 {
189 return is_array() ? fields.array : NULL;
190 }
191
192 /**
193 * Get the instance of a built-in scalar, vector, or matrix type
194 */
195 static const glsl_type *get_instance(unsigned base_type, unsigned rows,
196 unsigned columns);
197
198 /**
199 * Get the instance of an array type
200 */
201 static const glsl_type *get_array_instance(const glsl_type *base,
202 unsigned elements);
203
204 /**
205 * Get the instance of a record type
206 */
207 static const glsl_type *get_record_instance(const glsl_struct_field *fields,
208 unsigned num_fields,
209 const char *name);
210 /**
211 * Generate the constructor for this type and add it to the symbol table
212 */
213 class ir_function *generate_constructor(glsl_symbol_table *) const;
214
215 /**
216 * Query the total number of scalars that make up a scalar, vector or matrix
217 */
218 unsigned components() const
219 {
220 return vector_elements * matrix_columns;
221 }
222
223 /**
224 * Calculate the number of components slots required to hold this type
225 *
226 * This is used to determine how many uniform or varying locations a type
227 * might occupy.
228 */
229 unsigned component_slots() const;
230
231
232 /**
233 * Query whether or not a type is a scalar (non-vector and non-matrix).
234 */
235 bool is_scalar() const
236 {
237 return (vector_elements == 1)
238 && (base_type >= GLSL_TYPE_UINT)
239 && (base_type <= GLSL_TYPE_BOOL);
240 }
241
242 /**
243 * Query whether or not a type is a vector
244 */
245 bool is_vector() const
246 {
247 return (vector_elements > 1)
248 && (matrix_columns == 1)
249 && (base_type >= GLSL_TYPE_UINT)
250 && (base_type <= GLSL_TYPE_BOOL);
251 }
252
253 /**
254 * Query whether or not a type is a matrix
255 */
256 bool is_matrix() const
257 {
258 /* GLSL only has float matrices. */
259 return (matrix_columns > 1) && (base_type == GLSL_TYPE_FLOAT);
260 }
261
262 /**
263 * Query whether or not a type is a non-array numeric type
264 */
265 bool is_numeric() const
266 {
267 return (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_FLOAT);
268 }
269
270 /**
271 * Query whether or not a type is an integral type
272 */
273 bool is_integer() const
274 {
275 return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT);
276 }
277
278 /**
279 * Query whether or not a type is a float type
280 */
281 bool is_float() const
282 {
283 return base_type == GLSL_TYPE_FLOAT;
284 }
285
286 /**
287 * Query whether or not a type is a non-array boolean type
288 */
289 bool is_boolean() const
290 {
291 return base_type == GLSL_TYPE_BOOL;
292 }
293
294 /**
295 * Query whether or not a type is a sampler
296 */
297 bool is_sampler() const
298 {
299 return base_type == GLSL_TYPE_SAMPLER;
300 }
301
302 /**
303 * Query whether or not a type is an array
304 */
305 bool is_array() const
306 {
307 return base_type == GLSL_TYPE_ARRAY;
308 }
309
310 /**
311 * Query whether or not a type is a record
312 */
313 bool is_record() const
314 {
315 return base_type == GLSL_TYPE_STRUCT;
316 }
317
318 /**
319 * Query whether or not a type is the void type singleton.
320 */
321 bool is_void() const
322 {
323 return base_type == GLSL_TYPE_VOID;
324 }
325
326 /**
327 * Query whether or not a type is the error type singleton.
328 */
329 bool is_error() const
330 {
331 return base_type == GLSL_TYPE_ERROR;
332 }
333
334 /**
335 * Query the full type of a matrix row
336 *
337 * \return
338 * If the type is not a matrix, \c glsl_type::error_type is returned.
339 * Otherwise a type matching the rows of the matrix is returned.
340 */
341 const glsl_type *row_type() const
342 {
343 return is_matrix()
344 ? get_instance(base_type, matrix_columns, 1)
345 : error_type;
346 }
347
348 /**
349 * Query the full type of a matrix column
350 *
351 * \return
352 * If the type is not a matrix, \c glsl_type::error_type is returned.
353 * Otherwise a type matching the columns of the matrix is returned.
354 */
355 const glsl_type *column_type() const
356 {
357 return is_matrix()
358 ? get_instance(base_type, vector_elements, 1)
359 : error_type;
360 }
361
362
363 /**
364 * Get the type of a structure field
365 *
366 * \return
367 * Pointer to the type of the named field. If the type is not a structure
368 * or the named field does not exist, \c glsl_type::error_type is returned.
369 */
370 const glsl_type *field_type(const char *name) const;
371
372
373 /**
374 * Get the location of a filed within a record type
375 */
376 int field_index(const char *name) const;
377
378
379 /**
380 * Query the number of elements in an array type
381 *
382 * \return
383 * The number of elements in the array for array types or -1 for non-array
384 * types. If the number of elements in the array has not yet been declared,
385 * zero is returned.
386 */
387 int array_size() const
388 {
389 return is_array() ? length : -1;
390 }
391
392private:
393 /**
394 * talloc context for all glsl_type allocations
395 *
396 * Set on the first call to \c glsl_type::new.
397 */
398 static void *mem_ctx;
399
400 void init_talloc_type_ctx(void);
401
402 /** Constructor for vector and matrix types */
403 glsl_type(GLenum gl_type,
404 unsigned base_type, unsigned vector_elements,
405 unsigned matrix_columns, const char *name);
406
407 /** Constructor for sampler types */
408 glsl_type(GLenum gl_type,
409 enum glsl_sampler_dim dim, bool shadow, bool array,
410 unsigned type, const char *name);
411
412 /** Constructor for record types */
413 glsl_type(const glsl_struct_field *fields, unsigned num_fields,
414 const char *name);
415
416 /** Constructor for array types */
417 glsl_type(const glsl_type *array, unsigned length);
418
419 /** Hash table containing the known array types. */
420 static struct hash_table *array_types;
421
422 /** Hash table containing the known record types. */
423 static struct hash_table *record_types;
424
425 static int record_key_compare(const void *a, const void *b);
426 static unsigned record_key_hash(const void *key);
427
428 /**
429 * \name Pointers to various type singletons
430 */
431 /*@{*/
432 static const glsl_type _error_type;
433 static const glsl_type void_type;
434 static const glsl_type builtin_core_types[];
435 static const glsl_type builtin_structure_types[];
436 static const glsl_type builtin_110_deprecated_structure_types[];
437 static const glsl_type builtin_120_types[];
438 static const glsl_type builtin_130_types[];
439 static const glsl_type builtin_ARB_texture_rectangle_types[];
440 static const glsl_type builtin_EXT_texture_array_types[];
441 static const glsl_type builtin_EXT_texture_buffer_object_types[];
442 /*@}*/
443
444 /**
445 * \name Methods to populate a symbol table with built-in types.
446 *
447 * \internal
448 * This is one of the truely annoying things about C++. Methods that are
449 * completely internal and private to a type still have to be advertised to
450 * the world in a public header file.
451 */
452 /*@{*/
453 static void generate_110_types(glsl_symbol_table *);
454 static void generate_120_types(glsl_symbol_table *);
455 static void generate_130_types(glsl_symbol_table *);
456 static void generate_ARB_texture_rectangle_types(glsl_symbol_table *,
457 bool);
458 static void generate_EXT_texture_array_types(glsl_symbol_table *,
459 bool);
460 /*@}*/
461
462 /**
463 * \name Friend functions.
464 *
465 * These functions are friends because they must have C linkage and the
466 * need to call various private methods or access various private static
467 * data.
468 */
469 /*@{*/
470 friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *);
471 friend void _mesa_glsl_release_types(void);
472 /*@}*/
473};
474
475struct glsl_struct_field {
476 const struct glsl_type *type;
477 const char *name;
478};
479
480#endif /* GLSL_TYPES_H */
diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp
new file mode 100644
index 00000000000..23045ff1827
--- /dev/null
+++ b/src/glsl/hir_field_selection.cpp
@@ -0,0 +1,103 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "ir.h"
25#include "main/imports.h"
26#include "program/symbol_table.h"
27#include "glsl_parser_extras.h"
28#include "ast.h"
29#include "glsl_types.h"
30
31ir_rvalue *
32_mesa_ast_field_selection_to_hir(const ast_expression *expr,
33 exec_list *instructions,
34 struct _mesa_glsl_parse_state *state)
35{
36 void *ctx = state;
37 ir_rvalue *result = NULL;
38 ir_rvalue *op;
39
40 op = expr->subexpressions[0]->hir(instructions, state);
41
42 /* There are two kinds of field selection. There is the selection of a
43 * specific field from a structure, and there is the selection of a
44 * swizzle / mask from a vector. Which is which is determined entirely
45 * by the base type of the thing to which the field selection operator is
46 * being applied.
47 */
48 YYLTYPE loc = expr->get_location();
49 if (op->type->is_error()) {
50 /* silently propagate the error */
51 } else if (op->type->is_vector()) {
52 ir_swizzle *swiz = ir_swizzle::create(op,
53 expr->primary_expression.identifier,
54 op->type->vector_elements);
55 if (swiz != NULL) {
56 result = swiz;
57 } else {
58 /* FINISHME: Logging of error messages should be moved into
59 * FINISHME: ir_swizzle::create. This allows the generation of more
60 * FINISHME: specific error messages.
61 */
62 _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'",
63 expr->primary_expression.identifier);
64 }
65 } else if (op->type->base_type == GLSL_TYPE_STRUCT) {
66 result = new(ctx) ir_dereference_record(op,
67 expr->primary_expression.identifier);
68
69 if (result->type->is_error()) {
70 _mesa_glsl_error(& loc, state, "Cannot access field `%s' of "
71 "structure",
72 expr->primary_expression.identifier);
73 }
74 } else if (expr->subexpressions[1] != NULL) {
75 /* Handle "method calls" in GLSL 1.20 - namely, array.length() */
76 if (state->language_version < 120)
77 _mesa_glsl_error(&loc, state, "Methods not supported in GLSL 1.10.");
78
79 ast_expression *call = expr->subexpressions[1];
80 assert(call->oper == ast_function_call);
81
82 const char *method;
83 method = call->subexpressions[0]->primary_expression.identifier;
84
85 if (op->type->is_array() && strcmp(method, "length") == 0) {
86 if (!call->expressions.is_empty())
87 _mesa_glsl_error(&loc, state, "length method takes no arguments.");
88
89 if (op->type->array_size() == 0)
90 _mesa_glsl_error(&loc, state, "length called on unsized array.");
91
92 result = new(ctx) ir_constant(op->type->array_size());
93 } else {
94 _mesa_glsl_error(&loc, state, "Unknown method: `%s'.", method);
95 }
96 } else {
97 _mesa_glsl_error(& loc, state, "Cannot access field `%s' of "
98 "non-structure / non-vector.",
99 expr->primary_expression.identifier);
100 }
101
102 return result ? result : ir_call::get_error_instruction(ctx);
103}
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
new file mode 100644
index 00000000000..dd059e470d5
--- /dev/null
+++ b/src/glsl/ir.cpp
@@ -0,0 +1,1062 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23#include <string.h>
24#include "main/imports.h"
25#include "main/macros.h"
26#include "ir.h"
27#include "ir_visitor.h"
28#include "glsl_types.h"
29
30ir_rvalue::ir_rvalue()
31{
32 this->type = glsl_type::error_type;
33}
34
35/**
36 * Modify the swizzle make to move one component to another
37 *
38 * \param m IR swizzle to be modified
39 * \param from Component in the RHS that is to be swizzled
40 * \param to Desired swizzle location of \c from
41 */
42static void
43update_rhs_swizzle(ir_swizzle_mask &m, unsigned from, unsigned to)
44{
45 switch (to) {
46 case 0: m.x = from; break;
47 case 1: m.y = from; break;
48 case 2: m.z = from; break;
49 case 3: m.w = from; break;
50 default: assert(!"Should not get here.");
51 }
52
53 m.num_components = MAX2(m.num_components, (to + 1));
54}
55
56void
57ir_assignment::set_lhs(ir_rvalue *lhs)
58{
59 while (lhs != NULL) {
60 ir_swizzle *swiz = lhs->as_swizzle();
61
62 if (swiz == NULL)
63 break;
64
65 unsigned write_mask = 0;
66 ir_swizzle_mask rhs_swiz = { 0, 0, 0, 0, 0, 0 };
67
68 for (unsigned i = 0; i < swiz->mask.num_components; i++) {
69 unsigned c = 0;
70
71 switch (i) {
72 case 0: c = swiz->mask.x; break;
73 case 1: c = swiz->mask.y; break;
74 case 2: c = swiz->mask.z; break;
75 case 3: c = swiz->mask.w; break;
76 default: assert(!"Should not get here.");
77 }
78
79 write_mask |= (((this->write_mask >> i) & 1) << c);
80 update_rhs_swizzle(rhs_swiz, i, c);
81 }
82
83 this->write_mask = write_mask;
84 lhs = swiz->val;
85
86 this->rhs = new(this) ir_swizzle(this->rhs, rhs_swiz);
87 }
88
89 assert((lhs == NULL) || lhs->as_dereference());
90
91 this->lhs = (ir_dereference *) lhs;
92}
93
94ir_variable *
95ir_assignment::whole_variable_written()
96{
97 ir_variable *v = this->lhs->whole_variable_referenced();
98
99 if (v == NULL)
100 return NULL;
101
102 if (v->type->is_scalar())
103 return v;
104
105 if (v->type->is_vector()) {
106 const unsigned mask = (1U << v->type->vector_elements) - 1;
107
108 if (mask != this->write_mask)
109 return NULL;
110 }
111
112 /* Either all the vector components are assigned or the variable is some
113 * composite type (and the whole thing is assigned.
114 */
115 return v;
116}
117
118ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
119 ir_rvalue *condition, unsigned write_mask)
120{
121 this->ir_type = ir_type_assignment;
122 this->condition = condition;
123 this->rhs = rhs;
124 this->lhs = lhs;
125 this->write_mask = write_mask;
126}
127
128ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
129 ir_rvalue *condition)
130{
131 this->ir_type = ir_type_assignment;
132 this->condition = condition;
133 this->rhs = rhs;
134
135 /* If the RHS is a vector type, assume that all components of the vector
136 * type are being written to the LHS. The write mask comes from the RHS
137 * because we can have a case where the LHS is a vec4 and the RHS is a
138 * vec3. In that case, the assignment is:
139 *
140 * (assign (...) (xyz) (var_ref lhs) (var_ref rhs))
141 */
142 if (rhs->type->is_vector())
143 this->write_mask = (1U << rhs->type->vector_elements) - 1;
144 else if (rhs->type->is_scalar())
145 this->write_mask = 1;
146 else
147 this->write_mask = 0;
148
149 this->set_lhs(lhs);
150}
151
152
153ir_expression::ir_expression(int op, const struct glsl_type *type,
154 ir_rvalue *op0, ir_rvalue *op1)
155{
156 this->ir_type = ir_type_expression;
157 this->type = type;
158 this->operation = ir_expression_operation(op);
159 this->operands[0] = op0;
160 this->operands[1] = op1;
161}
162
163unsigned int
164ir_expression::get_num_operands(ir_expression_operation op)
165{
166/* Update ir_print_visitor.cpp when updating this list. */
167 const int num_operands[] = {
168 1, /* ir_unop_bit_not */
169 1, /* ir_unop_logic_not */
170 1, /* ir_unop_neg */
171 1, /* ir_unop_abs */
172 1, /* ir_unop_sign */
173 1, /* ir_unop_rcp */
174 1, /* ir_unop_rsq */
175 1, /* ir_unop_sqrt */
176 1, /* ir_unop_exp */
177 1, /* ir_unop_log */
178 1, /* ir_unop_exp2 */
179 1, /* ir_unop_log2 */
180 1, /* ir_unop_f2i */
181 1, /* ir_unop_i2f */
182 1, /* ir_unop_f2b */
183 1, /* ir_unop_b2f */
184 1, /* ir_unop_i2b */
185 1, /* ir_unop_b2i */
186 1, /* ir_unop_u2f */
187
188 1, /* ir_unop_trunc */
189 1, /* ir_unop_ceil */
190 1, /* ir_unop_floor */
191 1, /* ir_unop_fract */
192
193 1, /* ir_unop_sin */
194 1, /* ir_unop_cos */
195
196 1, /* ir_unop_dFdx */
197 1, /* ir_unop_dFdy */
198
199 2, /* ir_binop_add */
200 2, /* ir_binop_sub */
201 2, /* ir_binop_mul */
202 2, /* ir_binop_div */
203 2, /* ir_binop_mod */
204
205 2, /* ir_binop_less */
206 2, /* ir_binop_greater */
207 2, /* ir_binop_lequal */
208 2, /* ir_binop_gequal */
209 2, /* ir_binop_equal */
210 2, /* ir_binop_nequal */
211
212 2, /* ir_binop_lshift */
213 2, /* ir_binop_rshift */
214 2, /* ir_binop_bit_and */
215 2, /* ir_binop_bit_xor */
216 2, /* ir_binop_bit_or */
217
218 2, /* ir_binop_logic_and */
219 2, /* ir_binop_logic_xor */
220 2, /* ir_binop_logic_or */
221
222 2, /* ir_binop_dot */
223 2, /* ir_binop_cross */
224 2, /* ir_binop_min */
225 2, /* ir_binop_max */
226
227 2, /* ir_binop_pow */
228 };
229
230 assert(sizeof(num_operands) / sizeof(num_operands[0]) == ir_binop_pow + 1);
231
232 return num_operands[op];
233}
234
235static const char *const operator_strs[] = {
236 "~",
237 "!",
238 "neg",
239 "abs",
240 "sign",
241 "rcp",
242 "rsq",
243 "sqrt",
244 "exp",
245 "log",
246 "exp2",
247 "log2",
248 "f2i",
249 "i2f",
250 "f2b",
251 "b2f",
252 "i2b",
253 "b2i",
254 "u2f",
255 "trunc",
256 "ceil",
257 "floor",
258 "fract",
259 "sin",
260 "cos",
261 "dFdx",
262 "dFdy",
263 "+",
264 "-",
265 "*",
266 "/",
267 "%",
268 "<",
269 ">",
270 "<=",
271 ">=",
272 "==",
273 "!=",
274 "<<",
275 ">>",
276 "&",
277 "^",
278 "|",
279 "&&",
280 "^^",
281 "||",
282 "dot",
283 "cross",
284 "min",
285 "max",
286 "pow",
287};
288
289const char *ir_expression::operator_string()
290{
291 assert((unsigned int) operation <=
292 sizeof(operator_strs) / sizeof(operator_strs[0]));
293 return operator_strs[operation];
294}
295
296ir_expression_operation
297ir_expression::get_operator(const char *str)
298{
299 const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]);
300 for (int op = 0; op < operator_count; op++) {
301 if (strcmp(str, operator_strs[op]) == 0)
302 return (ir_expression_operation) op;
303 }
304 return (ir_expression_operation) -1;
305}
306
307ir_constant::ir_constant()
308{
309 this->ir_type = ir_type_constant;
310}
311
312ir_constant::ir_constant(const struct glsl_type *type,
313 const ir_constant_data *data)
314{
315 assert((type->base_type >= GLSL_TYPE_UINT)
316 && (type->base_type <= GLSL_TYPE_BOOL));
317
318 this->ir_type = ir_type_constant;
319 this->type = type;
320 memcpy(& this->value, data, sizeof(this->value));
321}
322
323ir_constant::ir_constant(float f)
324{
325 this->ir_type = ir_type_constant;
326 this->type = glsl_type::float_type;
327 this->value.f[0] = f;
328}
329
330ir_constant::ir_constant(unsigned int u)
331{
332 this->ir_type = ir_type_constant;
333 this->type = glsl_type::uint_type;
334 this->value.u[0] = u;
335}
336
337ir_constant::ir_constant(int i)
338{
339 this->ir_type = ir_type_constant;
340 this->type = glsl_type::int_type;
341 this->value.i[0] = i;
342}
343
344ir_constant::ir_constant(bool b)
345{
346 this->ir_type = ir_type_constant;
347 this->type = glsl_type::bool_type;
348 this->value.b[0] = b;
349}
350
351ir_constant::ir_constant(const ir_constant *c, unsigned i)
352{
353 this->ir_type = ir_type_constant;
354 this->type = c->type->get_base_type();
355
356 switch (this->type->base_type) {
357 case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break;
358 case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break;
359 case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break;
360 case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break;
361 default: assert(!"Should not get here."); break;
362 }
363}
364
365ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
366{
367 this->ir_type = ir_type_constant;
368 this->type = type;
369
370 assert(type->is_scalar() || type->is_vector() || type->is_matrix()
371 || type->is_record() || type->is_array());
372
373 if (type->is_array()) {
374 this->array_elements = talloc_array(this, ir_constant *, type->length);
375 unsigned i = 0;
376 foreach_list(node, value_list) {
377 ir_constant *value = (ir_constant *) node;
378 assert(value->as_constant() != NULL);
379
380 this->array_elements[i++] = value;
381 }
382 return;
383 }
384
385 /* If the constant is a record, the types of each of the entries in
386 * value_list must be a 1-for-1 match with the structure components. Each
387 * entry must also be a constant. Just move the nodes from the value_list
388 * to the list in the ir_constant.
389 */
390 /* FINISHME: Should there be some type checking and / or assertions here? */
391 /* FINISHME: Should the new constant take ownership of the nodes from
392 * FINISHME: value_list, or should it make copies?
393 */
394 if (type->is_record()) {
395 value_list->move_nodes_to(& this->components);
396 return;
397 }
398
399
400 ir_constant *value = (ir_constant *) (value_list->head);
401
402 /* Use each component from each entry in the value_list to initialize one
403 * component of the constant being constructed.
404 */
405 for (unsigned i = 0; i < type->components(); /* empty */) {
406 assert(value->as_constant() != NULL);
407 assert(!value->is_tail_sentinel());
408
409 for (unsigned j = 0; j < value->type->components(); j++) {
410 switch (type->base_type) {
411 case GLSL_TYPE_UINT:
412 this->value.u[i] = value->get_uint_component(j);
413 break;
414 case GLSL_TYPE_INT:
415 this->value.i[i] = value->get_int_component(j);
416 break;
417 case GLSL_TYPE_FLOAT:
418 this->value.f[i] = value->get_float_component(j);
419 break;
420 case GLSL_TYPE_BOOL:
421 this->value.b[i] = value->get_bool_component(j);
422 break;
423 default:
424 /* FINISHME: What to do? Exceptions are not the answer.
425 */
426 break;
427 }
428
429 i++;
430 if (i >= type->components())
431 break;
432 }
433
434 value = (ir_constant *) value->next;
435 }
436}
437
438ir_constant *
439ir_constant::zero(void *mem_ctx, const glsl_type *type)
440{
441 assert(type->is_numeric());
442
443 ir_constant *c = new(mem_ctx) ir_constant;
444 c->type = type;
445 memset(&c->value, 0, sizeof(c->value));
446
447 return c;
448}
449
450bool
451ir_constant::get_bool_component(unsigned i) const
452{
453 switch (this->type->base_type) {
454 case GLSL_TYPE_UINT: return this->value.u[i] != 0;
455 case GLSL_TYPE_INT: return this->value.i[i] != 0;
456 case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0;
457 case GLSL_TYPE_BOOL: return this->value.b[i];
458 default: assert(!"Should not get here."); break;
459 }
460
461 /* Must return something to make the compiler happy. This is clearly an
462 * error case.
463 */
464 return false;
465}
466
467float
468ir_constant::get_float_component(unsigned i) const
469{
470 switch (this->type->base_type) {
471 case GLSL_TYPE_UINT: return (float) this->value.u[i];
472 case GLSL_TYPE_INT: return (float) this->value.i[i];
473 case GLSL_TYPE_FLOAT: return this->value.f[i];
474 case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0;
475 default: assert(!"Should not get here."); break;
476 }
477
478 /* Must return something to make the compiler happy. This is clearly an
479 * error case.
480 */
481 return 0.0;
482}
483
484int
485ir_constant::get_int_component(unsigned i) const
486{
487 switch (this->type->base_type) {
488 case GLSL_TYPE_UINT: return this->value.u[i];
489 case GLSL_TYPE_INT: return this->value.i[i];
490 case GLSL_TYPE_FLOAT: return (int) this->value.f[i];
491 case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0;
492 default: assert(!"Should not get here."); break;
493 }
494
495 /* Must return something to make the compiler happy. This is clearly an
496 * error case.
497 */
498 return 0;
499}
500
501unsigned
502ir_constant::get_uint_component(unsigned i) const
503{
504 switch (this->type->base_type) {
505 case GLSL_TYPE_UINT: return this->value.u[i];
506 case GLSL_TYPE_INT: return this->value.i[i];
507 case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i];
508 case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0;
509 default: assert(!"Should not get here."); break;
510 }
511
512 /* Must return something to make the compiler happy. This is clearly an
513 * error case.
514 */
515 return 0;
516}
517
518ir_constant *
519ir_constant::get_array_element(unsigned i) const
520{
521 assert(this->type->is_array());
522 assert(i < this->type->length);
523
524 return array_elements[i];
525}
526
527ir_constant *
528ir_constant::get_record_field(const char *name)
529{
530 int idx = this->type->field_index(name);
531
532 if (idx < 0)
533 return NULL;
534
535 if (this->components.is_empty())
536 return NULL;
537
538 exec_node *node = this->components.head;
539 for (int i = 0; i < idx; i++) {
540 node = node->next;
541
542 /* If the end of the list is encountered before the element matching the
543 * requested field is found, return NULL.
544 */
545 if (node->is_tail_sentinel())
546 return NULL;
547 }
548
549 return (ir_constant *) node;
550}
551
552
553bool
554ir_constant::has_value(const ir_constant *c) const
555{
556 if (this->type != c->type)
557 return false;
558
559 if (this->type->is_array()) {
560 for (unsigned i = 0; i < this->type->length; i++) {
561 if (this->array_elements[i]->has_value(c->array_elements[i]))
562 return false;
563 }
564 return true;
565 }
566
567 if (this->type->base_type == GLSL_TYPE_STRUCT) {
568 const exec_node *a_node = this->components.head;
569 const exec_node *b_node = c->components.head;
570
571 while (!a_node->is_tail_sentinel()) {
572 assert(!b_node->is_tail_sentinel());
573
574 const ir_constant *const a_field = (ir_constant *) a_node;
575 const ir_constant *const b_field = (ir_constant *) b_node;
576
577 if (!a_field->has_value(b_field))
578 return false;
579
580 a_node = a_node->next;
581 b_node = b_node->next;
582 }
583
584 return true;
585 }
586
587 for (unsigned i = 0; i < this->type->components(); i++) {
588 switch (this->type->base_type) {
589 case GLSL_TYPE_UINT:
590 if (this->value.u[i] != c->value.u[i])
591 return false;
592 break;
593 case GLSL_TYPE_INT:
594 if (this->value.i[i] != c->value.i[i])
595 return false;
596 break;
597 case GLSL_TYPE_FLOAT:
598 if (this->value.f[i] != c->value.f[i])
599 return false;
600 break;
601 case GLSL_TYPE_BOOL:
602 if (this->value.b[i] != c->value.b[i])
603 return false;
604 break;
605 default:
606 assert(!"Should not get here.");
607 return false;
608 }
609 }
610
611 return true;
612}
613
614ir_dereference_variable::ir_dereference_variable(ir_variable *var)
615{
616 this->ir_type = ir_type_dereference_variable;
617 this->var = var;
618 this->type = (var != NULL) ? var->type : glsl_type::error_type;
619}
620
621
622ir_dereference_array::ir_dereference_array(ir_rvalue *value,
623 ir_rvalue *array_index)
624{
625 this->ir_type = ir_type_dereference_array;
626 this->array_index = array_index;
627 this->set_array(value);
628}
629
630
631ir_dereference_array::ir_dereference_array(ir_variable *var,
632 ir_rvalue *array_index)
633{
634 void *ctx = talloc_parent(var);
635
636 this->ir_type = ir_type_dereference_array;
637 this->array_index = array_index;
638 this->set_array(new(ctx) ir_dereference_variable(var));
639}
640
641
642void
643ir_dereference_array::set_array(ir_rvalue *value)
644{
645 this->array = value;
646 this->type = glsl_type::error_type;
647
648 if (this->array != NULL) {
649 const glsl_type *const vt = this->array->type;
650
651 if (vt->is_array()) {
652 type = vt->element_type();
653 } else if (vt->is_matrix()) {
654 type = vt->column_type();
655 } else if (vt->is_vector()) {
656 type = vt->get_base_type();
657 }
658 }
659}
660
661
662ir_dereference_record::ir_dereference_record(ir_rvalue *value,
663 const char *field)
664{
665 this->ir_type = ir_type_dereference_record;
666 this->record = value;
667 this->field = talloc_strdup(this, field);
668 this->type = (this->record != NULL)
669 ? this->record->type->field_type(field) : glsl_type::error_type;
670}
671
672
673ir_dereference_record::ir_dereference_record(ir_variable *var,
674 const char *field)
675{
676 void *ctx = talloc_parent(var);
677
678 this->ir_type = ir_type_dereference_record;
679 this->record = new(ctx) ir_dereference_variable(var);
680 this->field = talloc_strdup(this, field);
681 this->type = (this->record != NULL)
682 ? this->record->type->field_type(field) : glsl_type::error_type;
683}
684
685
686bool
687ir_dereference::is_lvalue()
688{
689 ir_variable *var = this->variable_referenced();
690
691 /* Every l-value derference chain eventually ends in a variable.
692 */
693 if ((var == NULL) || var->read_only)
694 return false;
695
696 if (this->type->is_array() && !var->array_lvalue)
697 return false;
698
699 return true;
700}
701
702
703const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf" };
704
705const char *ir_texture::opcode_string()
706{
707 assert((unsigned int) op <=
708 sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]));
709 return tex_opcode_strs[op];
710}
711
712ir_texture_opcode
713ir_texture::get_opcode(const char *str)
714{
715 const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]);
716 for (int op = 0; op < count; op++) {
717 if (strcmp(str, tex_opcode_strs[op]) == 0)
718 return (ir_texture_opcode) op;
719 }
720 return (ir_texture_opcode) -1;
721}
722
723
724void
725ir_texture::set_sampler(ir_dereference *sampler)
726{
727 assert(sampler != NULL);
728 this->sampler = sampler;
729
730 switch (sampler->type->sampler_type) {
731 case GLSL_TYPE_FLOAT:
732 this->type = glsl_type::vec4_type;
733 break;
734 case GLSL_TYPE_INT:
735 this->type = glsl_type::ivec4_type;
736 break;
737 case GLSL_TYPE_UINT:
738 this->type = glsl_type::uvec4_type;
739 break;
740 }
741}
742
743
744void
745ir_swizzle::init_mask(const unsigned *comp, unsigned count)
746{
747 assert((count >= 1) && (count <= 4));
748
749 memset(&this->mask, 0, sizeof(this->mask));
750 this->mask.num_components = count;
751
752 unsigned dup_mask = 0;
753 switch (count) {
754 case 4:
755 assert(comp[3] <= 3);
756 dup_mask |= (1U << comp[3])
757 & ((1U << comp[0]) | (1U << comp[1]) | (1U << comp[2]));
758 this->mask.w = comp[3];
759
760 case 3:
761 assert(comp[2] <= 3);
762 dup_mask |= (1U << comp[2])
763 & ((1U << comp[0]) | (1U << comp[1]));
764 this->mask.z = comp[2];
765
766 case 2:
767 assert(comp[1] <= 3);
768 dup_mask |= (1U << comp[1])
769 & ((1U << comp[0]));
770 this->mask.y = comp[1];
771
772 case 1:
773 assert(comp[0] <= 3);
774 this->mask.x = comp[0];
775 }
776
777 this->mask.has_duplicates = dup_mask != 0;
778
779 /* Based on the number of elements in the swizzle and the base type
780 * (i.e., float, int, unsigned, or bool) of the vector being swizzled,
781 * generate the type of the resulting value.
782 */
783 type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1);
784}
785
786ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z,
787 unsigned w, unsigned count)
788 : val(val)
789{
790 const unsigned components[4] = { x, y, z, w };
791 this->ir_type = ir_type_swizzle;
792 this->init_mask(components, count);
793}
794
795ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp,
796 unsigned count)
797 : val(val)
798{
799 this->ir_type = ir_type_swizzle;
800 this->init_mask(comp, count);
801}
802
803ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
804{
805 this->ir_type = ir_type_swizzle;
806 this->val = val;
807 this->mask = mask;
808 this->type = glsl_type::get_instance(val->type->base_type,
809 mask.num_components, 1);
810}
811
812#define X 1
813#define R 5
814#define S 9
815#define I 13
816
817ir_swizzle *
818ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
819{
820 void *ctx = talloc_parent(val);
821
822 /* For each possible swizzle character, this table encodes the value in
823 * \c idx_map that represents the 0th element of the vector. For invalid
824 * swizzle characters (e.g., 'k'), a special value is used that will allow
825 * detection of errors.
826 */
827 static const unsigned char base_idx[26] = {
828 /* a b c d e f g h i j k l m */
829 R, R, I, I, I, I, R, I, I, I, I, I, I,
830 /* n o p q r s t u v w x y z */
831 I, I, S, S, R, S, S, I, I, X, X, X, X
832 };
833
834 /* Each valid swizzle character has an entry in the previous table. This
835 * table encodes the base index encoded in the previous table plus the actual
836 * index of the swizzle character. When processing swizzles, the first
837 * character in the string is indexed in the previous table. Each character
838 * in the string is indexed in this table, and the value found there has the
839 * value form the first table subtracted. The result must be on the range
840 * [0,3].
841 *
842 * For example, the string "wzyx" will get X from the first table. Each of
843 * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After
844 * subtraction, the swizzle values are { 3, 2, 1, 0 }.
845 *
846 * The string "wzrg" will get X from the first table. Each of the characters
847 * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the
848 * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range
849 * [0,3], the error is detected.
850 */
851 static const unsigned char idx_map[26] = {
852 /* a b c d e f g h i j k l m */
853 R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0,
854 /* n o p q r s t u v w x y z */
855 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2
856 };
857
858 int swiz_idx[4] = { 0, 0, 0, 0 };
859 unsigned i;
860
861
862 /* Validate the first character in the swizzle string and look up the base
863 * index value as described above.
864 */
865 if ((str[0] < 'a') || (str[0] > 'z'))
866 return NULL;
867
868 const unsigned base = base_idx[str[0] - 'a'];
869
870
871 for (i = 0; (i < 4) && (str[i] != '\0'); i++) {
872 /* Validate the next character, and, as described above, convert it to a
873 * swizzle index.
874 */
875 if ((str[i] < 'a') || (str[i] > 'z'))
876 return NULL;
877
878 swiz_idx[i] = idx_map[str[i] - 'a'] - base;
879 if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length))
880 return NULL;
881 }
882
883 if (str[i] != '\0')
884 return NULL;
885
886 return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2],
887 swiz_idx[3], i);
888}
889
890#undef X
891#undef R
892#undef S
893#undef I
894
895ir_variable *
896ir_swizzle::variable_referenced()
897{
898 return this->val->variable_referenced();
899}
900
901
902ir_variable::ir_variable(const struct glsl_type *type, const char *name,
903 ir_variable_mode mode)
904 : max_array_access(0), read_only(false), centroid(false), invariant(false),
905 mode(mode), interpolation(ir_var_smooth), array_lvalue(false)
906{
907 this->ir_type = ir_type_variable;
908 this->type = type;
909 this->name = talloc_strdup(this, name);
910 this->location = -1;
911 this->warn_extension = NULL;
912 this->constant_value = NULL;
913 this->origin_upper_left = false;
914 this->pixel_center_integer = false;
915
916 if (type && type->base_type == GLSL_TYPE_SAMPLER)
917 this->read_only = true;
918}
919
920
921const char *
922ir_variable::interpolation_string() const
923{
924 switch (this->interpolation) {
925 case ir_var_smooth: return "smooth";
926 case ir_var_flat: return "flat";
927 case ir_var_noperspective: return "noperspective";
928 }
929
930 assert(!"Should not get here.");
931 return "";
932}
933
934
935unsigned
936ir_variable::component_slots() const
937{
938 /* FINISHME: Sparsely accessed arrays require fewer slots. */
939 return this->type->component_slots();
940}
941
942
943ir_function_signature::ir_function_signature(const glsl_type *return_type)
944 : return_type(return_type), is_defined(false), _function(NULL)
945{
946 this->ir_type = ir_type_function_signature;
947 this->is_built_in = false;
948}
949
950
951const char *
952ir_function_signature::qualifiers_match(exec_list *params)
953{
954 exec_list_iterator iter_a = parameters.iterator();
955 exec_list_iterator iter_b = params->iterator();
956
957 /* check that the qualifiers match. */
958 while (iter_a.has_next()) {
959 ir_variable *a = (ir_variable *)iter_a.get();
960 ir_variable *b = (ir_variable *)iter_b.get();
961
962 if (a->read_only != b->read_only ||
963 a->mode != b->mode ||
964 a->interpolation != b->interpolation ||
965 a->centroid != b->centroid) {
966
967 /* parameter a's qualifiers don't match */
968 return a->name;
969 }
970
971 iter_a.next();
972 iter_b.next();
973 }
974 return NULL;
975}
976
977
978void
979ir_function_signature::replace_parameters(exec_list *new_params)
980{
981 /* Destroy all of the previous parameter information. If the previous
982 * parameter information comes from the function prototype, it may either
983 * specify incorrect parameter names or not have names at all.
984 */
985 foreach_iter(exec_list_iterator, iter, parameters) {
986 assert(((ir_instruction *) iter.get())->as_variable() != NULL);
987
988 iter.remove();
989 }
990
991 new_params->move_nodes_to(&parameters);
992}
993
994
995ir_function::ir_function(const char *name)
996{
997 this->ir_type = ir_type_function;
998 this->name = talloc_strdup(this, name);
999}
1000
1001
1002ir_call *
1003ir_call::get_error_instruction(void *ctx)
1004{
1005 ir_call *call = new(ctx) ir_call;
1006
1007 call->type = glsl_type::error_type;
1008 return call;
1009}
1010
1011void
1012ir_call::set_callee(ir_function_signature *sig)
1013{
1014 assert((this->type == NULL) || (this->type == sig->return_type));
1015
1016 this->callee = sig;
1017}
1018
1019void
1020visit_exec_list(exec_list *list, ir_visitor *visitor)
1021{
1022 foreach_iter(exec_list_iterator, iter, *list) {
1023 ((ir_instruction *)iter.get())->accept(visitor);
1024 }
1025}
1026
1027
1028static void
1029steal_memory(ir_instruction *ir, void *new_ctx)
1030{
1031 ir_variable *var = ir->as_variable();
1032 ir_constant *constant = ir->as_constant();
1033 if (var != NULL && var->constant_value != NULL)
1034 steal_memory(var->constant_value, ir);
1035
1036 /* The components of aggregate constants are not visited by the normal
1037 * visitor, so steal their values by hand.
1038 */
1039 if (constant != NULL) {
1040 if (constant->type->is_record()) {
1041 foreach_iter(exec_list_iterator, iter, constant->components) {
1042 ir_constant *field = (ir_constant *)iter.get();
1043 steal_memory(field, ir);
1044 }
1045 } else if (constant->type->is_array()) {
1046 for (unsigned int i = 0; i < constant->type->length; i++) {
1047 steal_memory(constant->array_elements[i], ir);
1048 }
1049 }
1050 }
1051
1052 talloc_steal(new_ctx, ir);
1053}
1054
1055
1056void
1057reparent_ir(exec_list *list, void *mem_ctx)
1058{
1059 foreach_list(node, list) {
1060 visit_tree((ir_instruction *) node, steal_memory, mem_ctx);
1061 }
1062}
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
new file mode 100644
index 00000000000..b04222893cf
--- /dev/null
+++ b/src/glsl/ir.h
@@ -0,0 +1,1398 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef IR_H
27#define IR_H
28
29#include <cstdio>
30#include <cstdlib>
31
32extern "C" {
33#include <talloc.h>
34}
35
36#include "list.h"
37#include "ir_visitor.h"
38#include "ir_hierarchical_visitor.h"
39
40#ifndef ARRAY_SIZE
41#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
42#endif
43
44enum ir_node_type {
45 ir_type_unset,
46 ir_type_variable,
47 ir_type_assignment,
48 ir_type_call,
49 ir_type_constant,
50 ir_type_dereference_array,
51 ir_type_dereference_record,
52 ir_type_dereference_variable,
53 ir_type_discard,
54 ir_type_expression,
55 ir_type_function,
56 ir_type_function_signature,
57 ir_type_if,
58 ir_type_loop,
59 ir_type_loop_jump,
60 ir_type_return,
61 ir_type_swizzle,
62 ir_type_texture,
63 ir_type_max /**< maximum ir_type enum number, for validation */
64};
65
66/**
67 * Base class of all IR instructions
68 */
69class ir_instruction : public exec_node {
70public:
71 enum ir_node_type ir_type;
72 const struct glsl_type *type;
73
74 /** ir_print_visitor helper for debugging. */
75 void print(void) const;
76
77 virtual void accept(ir_visitor *) = 0;
78 virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0;
79 virtual ir_instruction *clone(void *mem_ctx,
80 struct hash_table *ht) const = 0;
81
82 /**
83 * \name IR instruction downcast functions
84 *
85 * These functions either cast the object to a derived class or return
86 * \c NULL if the object's type does not match the specified derived class.
87 * Additional downcast functions will be added as needed.
88 */
89 /*@{*/
90 virtual class ir_variable * as_variable() { return NULL; }
91 virtual class ir_function * as_function() { return NULL; }
92 virtual class ir_dereference * as_dereference() { return NULL; }
93 virtual class ir_dereference_array * as_dereference_array() { return NULL; }
94 virtual class ir_dereference_variable *as_dereference_variable() { return NULL; }
95 virtual class ir_expression * as_expression() { return NULL; }
96 virtual class ir_rvalue * as_rvalue() { return NULL; }
97 virtual class ir_loop * as_loop() { return NULL; }
98 virtual class ir_assignment * as_assignment() { return NULL; }
99 virtual class ir_call * as_call() { return NULL; }
100 virtual class ir_return * as_return() { return NULL; }
101 virtual class ir_if * as_if() { return NULL; }
102 virtual class ir_swizzle * as_swizzle() { return NULL; }
103 virtual class ir_constant * as_constant() { return NULL; }
104 /*@}*/
105
106protected:
107 ir_instruction()
108 {
109 ir_type = ir_type_unset;
110 type = NULL;
111 }
112};
113
114
115class ir_rvalue : public ir_instruction {
116public:
117 virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const = 0;
118
119 virtual ir_constant *constant_expression_value() = 0;
120
121 virtual ir_rvalue * as_rvalue()
122 {
123 return this;
124 }
125
126 virtual bool is_lvalue()
127 {
128 return false;
129 }
130
131 /**
132 * Get the variable that is ultimately referenced by an r-value
133 */
134 virtual ir_variable *variable_referenced()
135 {
136 return NULL;
137 }
138
139
140 /**
141 * If an r-value is a reference to a whole variable, get that variable
142 *
143 * \return
144 * Pointer to a variable that is completely dereferenced by the r-value. If
145 * the r-value is not a dereference or the dereference does not access the
146 * entire variable (i.e., it's just one array element, struct field), \c NULL
147 * is returned.
148 */
149 virtual ir_variable *whole_variable_referenced()
150 {
151 return NULL;
152 }
153
154protected:
155 ir_rvalue();
156};
157
158
159enum ir_variable_mode {
160 ir_var_auto = 0,
161 ir_var_uniform,
162 ir_var_in,
163 ir_var_out,
164 ir_var_inout,
165 ir_var_temporary /**< Temporary variable generated during compilation. */
166};
167
168enum ir_variable_interpolation {
169 ir_var_smooth = 0,
170 ir_var_flat,
171 ir_var_noperspective
172};
173
174
175class ir_variable : public ir_instruction {
176public:
177 ir_variable(const struct glsl_type *, const char *, ir_variable_mode);
178
179 virtual ir_variable *clone(void *mem_ctx, struct hash_table *ht) const;
180
181 virtual ir_variable *as_variable()
182 {
183 return this;
184 }
185
186 virtual void accept(ir_visitor *v)
187 {
188 v->visit(this);
189 }
190
191 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
192
193
194 /**
195 * Get the string value for the interpolation qualifier
196 *
197 * \return The string that would be used in a shader to specify \c
198 * mode will be returned.
199 *
200 * This function should only be used on a shader input or output variable.
201 */
202 const char *interpolation_string() const;
203
204 /**
205 * Calculate the number of slots required to hold this variable
206 *
207 * This is used to determine how many uniform or varying locations a variable
208 * occupies. The count is in units of floating point components.
209 */
210 unsigned component_slots() const;
211
212 const char *name;
213
214 /**
215 * Highest element accessed with a constant expression array index
216 *
217 * Not used for non-array variables.
218 */
219 unsigned max_array_access;
220
221 unsigned read_only:1;
222 unsigned centroid:1;
223 unsigned invariant:1;
224
225 unsigned mode:3;
226 unsigned interpolation:2;
227
228 /**
229 * Flag that the whole array is assignable
230 *
231 * In GLSL 1.20 and later whole arrays are assignable (and comparable for
232 * equality). This flag enables this behavior.
233 */
234 unsigned array_lvalue:1;
235
236 /* ARB_fragment_coord_conventions */
237 unsigned origin_upper_left:1;
238 unsigned pixel_center_integer:1;
239
240 /**
241 * Storage location of the base of this variable
242 *
243 * The precise meaning of this field depends on the nature of the variable.
244 *
245 * - Vertex shader input: one of the values from \c gl_vert_attrib.
246 * - Vertex shader output: one of the values from \c gl_vert_result.
247 * - Fragment shader input: one of the values from \c gl_frag_attrib.
248 * - Fragment shader output: one of the values from \c gl_frag_result.
249 * - Uniforms: Per-stage uniform slot number.
250 * - Other: This field is not currently used.
251 *
252 * If the variable is a uniform, shader input, or shader output, and the
253 * slot has not been assigned, the value will be -1.
254 */
255 int location;
256
257 /**
258 * Emit a warning if this variable is accessed.
259 */
260 const char *warn_extension;
261
262 /**
263 * Value assigned in the initializer of a variable declared "const"
264 */
265 ir_constant *constant_value;
266};
267
268
269/*@{*/
270/**
271 * The representation of a function instance; may be the full definition or
272 * simply a prototype.
273 */
274class ir_function_signature : public ir_instruction {
275 /* An ir_function_signature will be part of the list of signatures in
276 * an ir_function.
277 */
278public:
279 ir_function_signature(const glsl_type *return_type);
280
281 virtual ir_function_signature *clone(void *mem_ctx,
282 struct hash_table *ht) const;
283
284 virtual void accept(ir_visitor *v)
285 {
286 v->visit(this);
287 }
288
289 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
290
291 /**
292 * Get the name of the function for which this is a signature
293 */
294 const char *function_name() const;
295
296 /**
297 * Get a handle to the function for which this is a signature
298 *
299 * There is no setter function, this function returns a \c const pointer,
300 * and \c ir_function_signature::_function is private for a reason. The
301 * only way to make a connection between a function and function signature
302 * is via \c ir_function::add_signature. This helps ensure that certain
303 * invariants (i.e., a function signature is in the list of signatures for
304 * its \c _function) are met.
305 *
306 * \sa ir_function::add_signature
307 */
308 inline const class ir_function *function() const
309 {
310 return this->_function;
311 }
312
313 /**
314 * Check whether the qualifiers match between this signature's parameters
315 * and the supplied parameter list. If not, returns the name of the first
316 * parameter with mismatched qualifiers (for use in error messages).
317 */
318 const char *qualifiers_match(exec_list *params);
319
320 /**
321 * Replace the current parameter list with the given one. This is useful
322 * if the current information came from a prototype, and either has invalid
323 * or missing parameter names.
324 */
325 void replace_parameters(exec_list *new_params);
326
327 /**
328 * Function return type.
329 *
330 * \note This discards the optional precision qualifier.
331 */
332 const struct glsl_type *return_type;
333
334 /**
335 * List of ir_variable of function parameters.
336 *
337 * This represents the storage. The paramaters passed in a particular
338 * call will be in ir_call::actual_paramaters.
339 */
340 struct exec_list parameters;
341
342 /** Whether or not this function has a body (which may be empty). */
343 unsigned is_defined:1;
344
345 /** Whether or not this function signature is a built-in. */
346 unsigned is_built_in:1;
347
348 /** Body of instructions in the function. */
349 struct exec_list body;
350
351private:
352 /** Function of which this signature is one overload. */
353 class ir_function *_function;
354
355 friend class ir_function;
356};
357
358
359/**
360 * Header for tracking multiple overloaded functions with the same name.
361 * Contains a list of ir_function_signatures representing each of the
362 * actual functions.
363 */
364class ir_function : public ir_instruction {
365public:
366 ir_function(const char *name);
367
368 virtual ir_function *clone(void *mem_ctx, struct hash_table *ht) const;
369
370 virtual ir_function *as_function()
371 {
372 return this;
373 }
374
375 virtual void accept(ir_visitor *v)
376 {
377 v->visit(this);
378 }
379
380 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
381
382 void add_signature(ir_function_signature *sig)
383 {
384 sig->_function = this;
385 this->signatures.push_tail(sig);
386 }
387
388 /**
389 * Get an iterator for the set of function signatures
390 */
391 exec_list_iterator iterator()
392 {
393 return signatures.iterator();
394 }
395
396 /**
397 * Find a signature that matches a set of actual parameters, taking implicit
398 * conversions into account.
399 */
400 ir_function_signature *matching_signature(const exec_list *actual_param);
401
402 /**
403 * Find a signature that exactly matches a set of actual parameters without
404 * any implicit type conversions.
405 */
406 ir_function_signature *exact_matching_signature(const exec_list *actual_ps);
407
408 /**
409 * Name of the function.
410 */
411 const char *name;
412
413 /**
414 * List of ir_function_signature for each overloaded function with this name.
415 */
416 struct exec_list signatures;
417};
418
419inline const char *ir_function_signature::function_name() const
420{
421 return this->_function->name;
422}
423/*@}*/
424
425
426/**
427 * IR instruction representing high-level if-statements
428 */
429class ir_if : public ir_instruction {
430public:
431 ir_if(ir_rvalue *condition)
432 : condition(condition)
433 {
434 ir_type = ir_type_if;
435 }
436
437 virtual ir_if *clone(void *mem_ctx, struct hash_table *ht) const;
438
439 virtual ir_if *as_if()
440 {
441 return this;
442 }
443
444 virtual void accept(ir_visitor *v)
445 {
446 v->visit(this);
447 }
448
449 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
450
451 ir_rvalue *condition;
452 /** List of ir_instruction for the body of the then branch */
453 exec_list then_instructions;
454 /** List of ir_instruction for the body of the else branch */
455 exec_list else_instructions;
456};
457
458
459/**
460 * IR instruction representing a high-level loop structure.
461 */
462class ir_loop : public ir_instruction {
463public:
464 ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL)
465 {
466 ir_type = ir_type_loop;
467 }
468
469 virtual ir_loop *clone(void *mem_ctx, struct hash_table *ht) const;
470
471 virtual void accept(ir_visitor *v)
472 {
473 v->visit(this);
474 }
475
476 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
477
478 virtual ir_loop *as_loop()
479 {
480 return this;
481 }
482
483 /**
484 * Get an iterator for the instructions of the loop body
485 */
486 exec_list_iterator iterator()
487 {
488 return body_instructions.iterator();
489 }
490
491 /** List of ir_instruction that make up the body of the loop. */
492 exec_list body_instructions;
493
494 /**
495 * \name Loop counter and controls
496 */
497 /*@{*/
498 ir_rvalue *from;
499 ir_rvalue *to;
500 ir_rvalue *increment;
501 ir_variable *counter;
502 /*@}*/
503};
504
505
506class ir_assignment : public ir_instruction {
507public:
508 ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, ir_rvalue *condition);
509
510 /**
511 * Construct an assignment with an explicit write mask
512 *
513 * \note
514 * Since a write mask is supplied, the LHS must already be a bare
515 * \c ir_dereference. The cannot be any swizzles in the LHS.
516 */
517 ir_assignment(ir_dereference *lhs, ir_rvalue *rhs, ir_rvalue *condition,
518 unsigned write_mask);
519
520 virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const;
521
522 virtual ir_constant *constant_expression_value();
523
524 virtual void accept(ir_visitor *v)
525 {
526 v->visit(this);
527 }
528
529 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
530
531 virtual ir_assignment * as_assignment()
532 {
533 return this;
534 }
535
536 /**
537 * Get a whole variable written by an assignment
538 *
539 * If the LHS of the assignment writes a whole variable, the variable is
540 * returned. Otherwise \c NULL is returned. Examples of whole-variable
541 * assignment are:
542 *
543 * - Assigning to a scalar
544 * - Assigning to all components of a vector
545 * - Whole array (or matrix) assignment
546 * - Whole structure assignment
547 */
548 ir_variable *whole_variable_written();
549
550 /**
551 * Set the LHS of an assignment
552 */
553 void set_lhs(ir_rvalue *lhs);
554
555 /**
556 * Left-hand side of the assignment.
557 *
558 * This should be treated as read only. If you need to set the LHS of an
559 * assignment, use \c ir_assignment::set_lhs.
560 */
561 ir_dereference *lhs;
562
563 /**
564 * Value being assigned
565 */
566 ir_rvalue *rhs;
567
568 /**
569 * Optional condition for the assignment.
570 */
571 ir_rvalue *condition;
572
573
574 /**
575 * Component mask written
576 *
577 * For non-vector types in the LHS, this field will be zero. For vector
578 * types, a bit will be set for each component that is written. Note that
579 * for \c vec2 and \c vec3 types only the lower bits will ever be set.
580 */
581 unsigned write_mask:4;
582};
583
584/* Update ir_expression::num_operands() and operator_strs when
585 * updating this list.
586 */
587enum ir_expression_operation {
588 ir_unop_bit_not,
589 ir_unop_logic_not,
590 ir_unop_neg,
591 ir_unop_abs,
592 ir_unop_sign,
593 ir_unop_rcp,
594 ir_unop_rsq,
595 ir_unop_sqrt,
596 ir_unop_exp, /**< Log base e on gentype */
597 ir_unop_log, /**< Natural log on gentype */
598 ir_unop_exp2,
599 ir_unop_log2,
600 ir_unop_f2i, /**< Float-to-integer conversion. */
601 ir_unop_i2f, /**< Integer-to-float conversion. */
602 ir_unop_f2b, /**< Float-to-boolean conversion */
603 ir_unop_b2f, /**< Boolean-to-float conversion */
604 ir_unop_i2b, /**< int-to-boolean conversion */
605 ir_unop_b2i, /**< Boolean-to-int conversion */
606 ir_unop_u2f, /**< Unsigned-to-float conversion. */
607
608 /**
609 * \name Unary floating-point rounding operations.
610 */
611 /*@{*/
612 ir_unop_trunc,
613 ir_unop_ceil,
614 ir_unop_floor,
615 ir_unop_fract,
616 /*@}*/
617
618 /**
619 * \name Trigonometric operations.
620 */
621 /*@{*/
622 ir_unop_sin,
623 ir_unop_cos,
624 /*@}*/
625
626 /**
627 * \name Partial derivatives.
628 */
629 /*@{*/
630 ir_unop_dFdx,
631 ir_unop_dFdy,
632 /*@}*/
633
634 ir_binop_add,
635 ir_binop_sub,
636 ir_binop_mul,
637 ir_binop_div,
638
639 /**
640 * Takes one of two combinations of arguments:
641 *
642 * - mod(vecN, vecN)
643 * - mod(vecN, float)
644 *
645 * Does not take integer types.
646 */
647 ir_binop_mod,
648
649 /**
650 * \name Binary comparison operators
651 */
652 /*@{*/
653 ir_binop_less,
654 ir_binop_greater,
655 ir_binop_lequal,
656 ir_binop_gequal,
657 /**
658 * Returns single boolean for whether all components of operands[0]
659 * equal the components of operands[1].
660 */
661 ir_binop_equal,
662 /**
663 * Returns single boolean for whether any component of operands[0]
664 * is not equal to the corresponding component of operands[1].
665 */
666 ir_binop_nequal,
667 /*@}*/
668
669 /**
670 * \name Bit-wise binary operations.
671 */
672 /*@{*/
673 ir_binop_lshift,
674 ir_binop_rshift,
675 ir_binop_bit_and,
676 ir_binop_bit_xor,
677 ir_binop_bit_or,
678 /*@}*/
679
680 ir_binop_logic_and,
681 ir_binop_logic_xor,
682 ir_binop_logic_or,
683
684 ir_binop_dot,
685 ir_binop_cross,
686 ir_binop_min,
687 ir_binop_max,
688
689 ir_binop_pow
690};
691
692class ir_expression : public ir_rvalue {
693public:
694 ir_expression(int op, const struct glsl_type *type,
695 ir_rvalue *, ir_rvalue *);
696
697 virtual ir_expression *as_expression()
698 {
699 return this;
700 }
701
702 virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const;
703
704 virtual ir_constant *constant_expression_value();
705
706 static unsigned int get_num_operands(ir_expression_operation);
707 unsigned int get_num_operands() const
708 {
709 return get_num_operands(operation);
710 }
711
712 /**
713 * Return a string representing this expression's operator.
714 */
715 const char *operator_string();
716
717 /**
718 * Do a reverse-lookup to translate the given string into an operator.
719 */
720 static ir_expression_operation get_operator(const char *);
721
722 virtual void accept(ir_visitor *v)
723 {
724 v->visit(this);
725 }
726
727 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
728
729 ir_expression_operation operation;
730 ir_rvalue *operands[2];
731};
732
733
734/**
735 * IR instruction representing a function call
736 */
737class ir_call : public ir_rvalue {
738public:
739 ir_call(ir_function_signature *callee, exec_list *actual_parameters)
740 : callee(callee)
741 {
742 ir_type = ir_type_call;
743 assert(callee->return_type != NULL);
744 type = callee->return_type;
745 actual_parameters->move_nodes_to(& this->actual_parameters);
746 }
747
748 virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const;
749
750 virtual ir_constant *constant_expression_value();
751
752 virtual ir_call *as_call()
753 {
754 return this;
755 }
756
757 virtual void accept(ir_visitor *v)
758 {
759 v->visit(this);
760 }
761
762 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
763
764 /**
765 * Get a generic ir_call object when an error occurs
766 *
767 * Any allocation will be performed with 'ctx' as talloc owner.
768 */
769 static ir_call *get_error_instruction(void *ctx);
770
771 /**
772 * Get an iterator for the set of acutal parameters
773 */
774 exec_list_iterator iterator()
775 {
776 return actual_parameters.iterator();
777 }
778
779 /**
780 * Get the name of the function being called.
781 */
782 const char *callee_name() const
783 {
784 return callee->function_name();
785 }
786
787 ir_function_signature *get_callee()
788 {
789 return callee;
790 }
791
792 /**
793 * Set the function call target
794 */
795 void set_callee(ir_function_signature *sig);
796
797 /**
798 * Generates an inline version of the function before @ir,
799 * returning the return value of the function.
800 */
801 ir_rvalue *generate_inline(ir_instruction *ir);
802
803 /* List of ir_rvalue of paramaters passed in this call. */
804 exec_list actual_parameters;
805
806private:
807 ir_call()
808 : callee(NULL)
809 {
810 this->ir_type = ir_type_call;
811 }
812
813 ir_function_signature *callee;
814};
815
816
817/**
818 * \name Jump-like IR instructions.
819 *
820 * These include \c break, \c continue, \c return, and \c discard.
821 */
822/*@{*/
823class ir_jump : public ir_instruction {
824protected:
825 ir_jump()
826 {
827 ir_type = ir_type_unset;
828 }
829};
830
831class ir_return : public ir_jump {
832public:
833 ir_return()
834 : value(NULL)
835 {
836 this->ir_type = ir_type_return;
837 }
838
839 ir_return(ir_rvalue *value)
840 : value(value)
841 {
842 this->ir_type = ir_type_return;
843 }
844
845 virtual ir_return *clone(void *mem_ctx, struct hash_table *) const;
846
847 virtual ir_return *as_return()
848 {
849 return this;
850 }
851
852 ir_rvalue *get_value() const
853 {
854 return value;
855 }
856
857 virtual void accept(ir_visitor *v)
858 {
859 v->visit(this);
860 }
861
862 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
863
864 ir_rvalue *value;
865};
866
867
868/**
869 * Jump instructions used inside loops
870 *
871 * These include \c break and \c continue. The \c break within a loop is
872 * different from the \c break within a switch-statement.
873 *
874 * \sa ir_switch_jump
875 */
876class ir_loop_jump : public ir_jump {
877public:
878 enum jump_mode {
879 jump_break,
880 jump_continue
881 };
882
883 ir_loop_jump(jump_mode mode)
884 {
885 this->ir_type = ir_type_loop_jump;
886 this->mode = mode;
887 this->loop = loop;
888 }
889
890 virtual ir_loop_jump *clone(void *mem_ctx, struct hash_table *) const;
891
892 virtual void accept(ir_visitor *v)
893 {
894 v->visit(this);
895 }
896
897 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
898
899 bool is_break() const
900 {
901 return mode == jump_break;
902 }
903
904 bool is_continue() const
905 {
906 return mode == jump_continue;
907 }
908
909 /** Mode selector for the jump instruction. */
910 enum jump_mode mode;
911private:
912 /** Loop containing this break instruction. */
913 ir_loop *loop;
914};
915
916/**
917 * IR instruction representing discard statements.
918 */
919class ir_discard : public ir_jump {
920public:
921 ir_discard()
922 {
923 this->ir_type = ir_type_discard;
924 this->condition = NULL;
925 }
926
927 ir_discard(ir_rvalue *cond)
928 {
929 this->ir_type = ir_type_discard;
930 this->condition = cond;
931 }
932
933 virtual ir_discard *clone(void *mem_ctx, struct hash_table *ht) const;
934
935 virtual void accept(ir_visitor *v)
936 {
937 v->visit(this);
938 }
939
940 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
941
942 ir_rvalue *condition;
943};
944/*@}*/
945
946
947/**
948 * Texture sampling opcodes used in ir_texture
949 */
950enum ir_texture_opcode {
951 ir_tex, /* Regular texture look-up */
952 ir_txb, /* Texture look-up with LOD bias */
953 ir_txl, /* Texture look-up with explicit LOD */
954 ir_txd, /* Texture look-up with partial derivatvies */
955 ir_txf /* Texel fetch with explicit LOD */
956};
957
958
959/**
960 * IR instruction to sample a texture
961 *
962 * The specific form of the IR instruction depends on the \c mode value
963 * selected from \c ir_texture_opcodes. In the printed IR, these will
964 * appear as:
965 *
966 * Texel offset
967 * | Projection divisor
968 * | | Shadow comparitor
969 * | | |
970 * v v v
971 * (tex (sampler) (coordinate) (0 0 0) (1) ( ))
972 * (txb (sampler) (coordinate) (0 0 0) (1) ( ) (bias))
973 * (txl (sampler) (coordinate) (0 0 0) (1) ( ) (lod))
974 * (txd (sampler) (coordinate) (0 0 0) (1) ( ) (dPdx dPdy))
975 * (txf (sampler) (coordinate) (0 0 0) (lod))
976 */
977class ir_texture : public ir_rvalue {
978public:
979 ir_texture(enum ir_texture_opcode op)
980 : op(op), projector(NULL), shadow_comparitor(NULL)
981 {
982 this->ir_type = ir_type_texture;
983 }
984
985 virtual ir_texture *clone(void *mem_ctx, struct hash_table *) const;
986
987 virtual ir_constant *constant_expression_value();
988
989 virtual void accept(ir_visitor *v)
990 {
991 v->visit(this);
992 }
993
994 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
995
996 /**
997 * Return a string representing the ir_texture_opcode.
998 */
999 const char *opcode_string();
1000
1001 /** Set the sampler and infer the type. */
1002 void set_sampler(ir_dereference *sampler);
1003
1004 /**
1005 * Do a reverse-lookup to translate a string into an ir_texture_opcode.
1006 */
1007 static ir_texture_opcode get_opcode(const char *);
1008
1009 enum ir_texture_opcode op;
1010
1011 /** Sampler to use for the texture access. */
1012 ir_dereference *sampler;
1013
1014 /** Texture coordinate to sample */
1015 ir_rvalue *coordinate;
1016
1017 /**
1018 * Value used for projective divide.
1019 *
1020 * If there is no projective divide (the common case), this will be
1021 * \c NULL. Optimization passes should check for this to point to a constant
1022 * of 1.0 and replace that with \c NULL.
1023 */
1024 ir_rvalue *projector;
1025
1026 /**
1027 * Coordinate used for comparison on shadow look-ups.
1028 *
1029 * If there is no shadow comparison, this will be \c NULL. For the
1030 * \c ir_txf opcode, this *must* be \c NULL.
1031 */
1032 ir_rvalue *shadow_comparitor;
1033
1034 /** Explicit texel offsets. */
1035 signed char offsets[3];
1036
1037 union {
1038 ir_rvalue *lod; /**< Floating point LOD */
1039 ir_rvalue *bias; /**< Floating point LOD bias */
1040 struct {
1041 ir_rvalue *dPdx; /**< Partial derivative of coordinate wrt X */
1042 ir_rvalue *dPdy; /**< Partial derivative of coordinate wrt Y */
1043 } grad;
1044 } lod_info;
1045};
1046
1047
1048struct ir_swizzle_mask {
1049 unsigned x:2;
1050 unsigned y:2;
1051 unsigned z:2;
1052 unsigned w:2;
1053
1054 /**
1055 * Number of components in the swizzle.
1056 */
1057 unsigned num_components:3;
1058
1059 /**
1060 * Does the swizzle contain duplicate components?
1061 *
1062 * L-value swizzles cannot contain duplicate components.
1063 */
1064 unsigned has_duplicates:1;
1065};
1066
1067
1068class ir_swizzle : public ir_rvalue {
1069public:
1070 ir_swizzle(ir_rvalue *, unsigned x, unsigned y, unsigned z, unsigned w,
1071 unsigned count);
1072
1073 ir_swizzle(ir_rvalue *val, const unsigned *components, unsigned count);
1074
1075 ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask);
1076
1077 virtual ir_swizzle *clone(void *mem_ctx, struct hash_table *) const;
1078
1079 virtual ir_constant *constant_expression_value();
1080
1081 virtual ir_swizzle *as_swizzle()
1082 {
1083 return this;
1084 }
1085
1086 /**
1087 * Construct an ir_swizzle from the textual representation. Can fail.
1088 */
1089 static ir_swizzle *create(ir_rvalue *, const char *, unsigned vector_length);
1090
1091 virtual void accept(ir_visitor *v)
1092 {
1093 v->visit(this);
1094 }
1095
1096 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
1097
1098 bool is_lvalue()
1099 {
1100 return val->is_lvalue() && !mask.has_duplicates;
1101 }
1102
1103 /**
1104 * Get the variable that is ultimately referenced by an r-value
1105 */
1106 virtual ir_variable *variable_referenced();
1107
1108 ir_rvalue *val;
1109 ir_swizzle_mask mask;
1110
1111private:
1112 /**
1113 * Initialize the mask component of a swizzle
1114 *
1115 * This is used by the \c ir_swizzle constructors.
1116 */
1117 void init_mask(const unsigned *components, unsigned count);
1118};
1119
1120
1121class ir_dereference : public ir_rvalue {
1122public:
1123 virtual ir_dereference *clone(void *mem_ctx, struct hash_table *) const = 0;
1124
1125 virtual ir_dereference *as_dereference()
1126 {
1127 return this;
1128 }
1129
1130 bool is_lvalue();
1131
1132 /**
1133 * Get the variable that is ultimately referenced by an r-value
1134 */
1135 virtual ir_variable *variable_referenced() = 0;
1136};
1137
1138
1139class ir_dereference_variable : public ir_dereference {
1140public:
1141 ir_dereference_variable(ir_variable *var);
1142
1143 virtual ir_dereference_variable *clone(void *mem_ctx,
1144 struct hash_table *) const;
1145
1146 virtual ir_constant *constant_expression_value();
1147
1148 virtual ir_dereference_variable *as_dereference_variable()
1149 {
1150 return this;
1151 }
1152
1153 /**
1154 * Get the variable that is ultimately referenced by an r-value
1155 */
1156 virtual ir_variable *variable_referenced()
1157 {
1158 return this->var;
1159 }
1160
1161 virtual ir_variable *whole_variable_referenced()
1162 {
1163 /* ir_dereference_variable objects always dereference the entire
1164 * variable. However, if this dereference is dereferenced by anything
1165 * else, the complete deferefernce chain is not a whole-variable
1166 * dereference. This method should only be called on the top most
1167 * ir_rvalue in a dereference chain.
1168 */
1169 return this->var;
1170 }
1171
1172 virtual void accept(ir_visitor *v)
1173 {
1174 v->visit(this);
1175 }
1176
1177 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
1178
1179 /**
1180 * Object being dereferenced.
1181 */
1182 ir_variable *var;
1183};
1184
1185
1186class ir_dereference_array : public ir_dereference {
1187public:
1188 ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index);
1189
1190 ir_dereference_array(ir_variable *var, ir_rvalue *array_index);
1191
1192 virtual ir_dereference_array *clone(void *mem_ctx,
1193 struct hash_table *) const;
1194
1195 virtual ir_constant *constant_expression_value();
1196
1197 virtual ir_dereference_array *as_dereference_array()
1198 {
1199 return this;
1200 }
1201
1202 /**
1203 * Get the variable that is ultimately referenced by an r-value
1204 */
1205 virtual ir_variable *variable_referenced()
1206 {
1207 return this->array->variable_referenced();
1208 }
1209
1210 virtual void accept(ir_visitor *v)
1211 {
1212 v->visit(this);
1213 }
1214
1215 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
1216
1217 ir_rvalue *array;
1218 ir_rvalue *array_index;
1219
1220private:
1221 void set_array(ir_rvalue *value);
1222};
1223
1224
1225class ir_dereference_record : public ir_dereference {
1226public:
1227 ir_dereference_record(ir_rvalue *value, const char *field);
1228
1229 ir_dereference_record(ir_variable *var, const char *field);
1230
1231 virtual ir_dereference_record *clone(void *mem_ctx,
1232 struct hash_table *) const;
1233
1234 virtual ir_constant *constant_expression_value();
1235
1236 /**
1237 * Get the variable that is ultimately referenced by an r-value
1238 */
1239 virtual ir_variable *variable_referenced()
1240 {
1241 return this->record->variable_referenced();
1242 }
1243
1244 virtual void accept(ir_visitor *v)
1245 {
1246 v->visit(this);
1247 }
1248
1249 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
1250
1251 ir_rvalue *record;
1252 const char *field;
1253};
1254
1255
1256/**
1257 * Data stored in an ir_constant
1258 */
1259union ir_constant_data {
1260 unsigned u[16];
1261 int i[16];
1262 float f[16];
1263 bool b[16];
1264};
1265
1266
1267class ir_constant : public ir_rvalue {
1268public:
1269 ir_constant(const struct glsl_type *type, const ir_constant_data *data);
1270 ir_constant(bool b);
1271 ir_constant(unsigned int u);
1272 ir_constant(int i);
1273 ir_constant(float f);
1274
1275 /**
1276 * Construct an ir_constant from a list of ir_constant values
1277 */
1278 ir_constant(const struct glsl_type *type, exec_list *values);
1279
1280 /**
1281 * Construct an ir_constant from a scalar component of another ir_constant
1282 *
1283 * The new \c ir_constant inherits the type of the component from the
1284 * source constant.
1285 *
1286 * \note
1287 * In the case of a matrix constant, the new constant is a scalar, \b not
1288 * a vector.
1289 */
1290 ir_constant(const ir_constant *c, unsigned i);
1291
1292 /**
1293 * Return a new ir_constant of the specified type containing all zeros.
1294 */
1295 static ir_constant *zero(void *mem_ctx, const glsl_type *type);
1296
1297 virtual ir_constant *clone(void *mem_ctx, struct hash_table *) const;
1298
1299 virtual ir_constant *constant_expression_value();
1300
1301 virtual ir_constant *as_constant()
1302 {
1303 return this;
1304 }
1305
1306 virtual void accept(ir_visitor *v)
1307 {
1308 v->visit(this);
1309 }
1310
1311 virtual ir_visitor_status accept(ir_hierarchical_visitor *);
1312
1313 /**
1314 * Get a particular component of a constant as a specific type
1315 *
1316 * This is useful, for example, to get a value from an integer constant
1317 * as a float or bool. This appears frequently when constructors are
1318 * called with all constant parameters.
1319 */
1320 /*@{*/
1321 bool get_bool_component(unsigned i) const;
1322 float get_float_component(unsigned i) const;
1323 int get_int_component(unsigned i) const;
1324 unsigned get_uint_component(unsigned i) const;
1325 /*@}*/
1326
1327 ir_constant *get_array_element(unsigned i) const;
1328
1329 ir_constant *get_record_field(const char *name);
1330
1331 /**
1332 * Determine whether a constant has the same value as another constant
1333 */
1334 bool has_value(const ir_constant *) const;
1335
1336 /**
1337 * Value of the constant.
1338 *
1339 * The field used to back the values supplied by the constant is determined
1340 * by the type associated with the \c ir_instruction. Constants may be
1341 * scalars, vectors, or matrices.
1342 */
1343 union ir_constant_data value;
1344
1345 /* Array elements */
1346 ir_constant **array_elements;
1347
1348 /* Structure fields */
1349 exec_list components;
1350
1351private:
1352 /**
1353 * Parameterless constructor only used by the clone method
1354 */
1355 ir_constant(void);
1356};
1357
1358void
1359visit_exec_list(exec_list *list, ir_visitor *visitor);
1360
1361void validate_ir_tree(exec_list *instructions);
1362
1363/**
1364 * Make a clone of each IR instruction in a list
1365 *
1366 * \param in List of IR instructions that are to be cloned
1367 * \param out List to hold the cloned instructions
1368 */
1369void
1370clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in);
1371
1372extern void
1373_mesa_glsl_initialize_variables(exec_list *instructions,
1374 struct _mesa_glsl_parse_state *state);
1375
1376extern void
1377_mesa_glsl_initialize_functions(exec_list *instructions,
1378 struct _mesa_glsl_parse_state *state);
1379
1380extern void
1381_mesa_glsl_release_functions(void);
1382
1383extern void
1384reparent_ir(exec_list *list, void *mem_ctx);
1385
1386struct glsl_symbol_table;
1387
1388extern void
1389import_prototypes(const exec_list *source, exec_list *dest,
1390 struct glsl_symbol_table *symbols, void *mem_ctx);
1391
1392extern bool
1393ir_has_call(ir_instruction *ir);
1394
1395extern void
1396do_set_program_inouts(exec_list *instructions, struct gl_program *prog);
1397
1398#endif /* IR_H */
diff --git a/src/glsl/ir_algebraic.cpp b/src/glsl/ir_algebraic.cpp
new file mode 100644
index 00000000000..a66c820a278
--- /dev/null
+++ b/src/glsl/ir_algebraic.cpp
@@ -0,0 +1,392 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_algebraic.cpp
26 *
27 * Takes advantage of association, commutivity, and other algebraic
28 * properties to simplify expressions.
29 */
30
31#include "ir.h"
32#include "ir_visitor.h"
33#include "ir_rvalue_visitor.h"
34#include "ir_optimization.h"
35#include "glsl_types.h"
36
37/**
38 * Visitor class for replacing expressions with ir_constant values.
39 */
40
41class ir_algebraic_visitor : public ir_rvalue_visitor {
42public:
43 ir_algebraic_visitor()
44 {
45 this->progress = false;
46 }
47
48 virtual ~ir_algebraic_visitor()
49 {
50 }
51
52 ir_rvalue *handle_expression(ir_expression *ir);
53 void handle_rvalue(ir_rvalue **rvalue);
54 bool reassociate_constant(ir_expression *ir1,
55 int const_index,
56 ir_constant *constant,
57 ir_expression *ir2);
58 void reassociate_operands(ir_expression *ir1,
59 int op1,
60 ir_expression *ir2,
61 int op2);
62 bool progress;
63};
64
65static bool
66is_vec_zero(ir_constant *ir)
67{
68 int c;
69
70 if (!ir)
71 return false;
72 if (!ir->type->is_scalar() &&
73 !ir->type->is_vector())
74 return false;
75
76 for (c = 0; c < ir->type->vector_elements; c++) {
77 switch (ir->type->base_type) {
78 case GLSL_TYPE_FLOAT:
79 if (ir->value.f[c] != 0.0)
80 return false;
81 break;
82 case GLSL_TYPE_INT:
83 if (ir->value.i[c] != 0)
84 return false;
85 break;
86 case GLSL_TYPE_UINT:
87 if (ir->value.u[c] != 0)
88 return false;
89 break;
90 case GLSL_TYPE_BOOL:
91 if (ir->value.b[c] != false)
92 return false;
93 break;
94 default:
95 assert(!"bad base type");
96 return false;
97 }
98 }
99
100 return true;
101}
102
103static bool
104is_vec_one(ir_constant *ir)
105{
106 int c;
107
108 if (!ir)
109 return false;
110 if (!ir->type->is_scalar() &&
111 !ir->type->is_vector())
112 return false;
113
114 for (c = 0; c < ir->type->vector_elements; c++) {
115 switch (ir->type->base_type) {
116 case GLSL_TYPE_FLOAT:
117 if (ir->value.f[c] != 1.0)
118 return false;
119 break;
120 case GLSL_TYPE_INT:
121 if (ir->value.i[c] != 1)
122 return false;
123 break;
124 case GLSL_TYPE_UINT:
125 if (ir->value.u[c] != 1)
126 return false;
127 break;
128 case GLSL_TYPE_BOOL:
129 if (ir->value.b[c] != true)
130 return false;
131 break;
132 default:
133 assert(!"bad base type");
134 return false;
135 }
136 }
137
138 return true;
139}
140
141static void
142update_type(ir_expression *ir)
143{
144 if (ir->operands[0]->type->is_vector())
145 ir->type = ir->operands[0]->type;
146 else
147 ir->type = ir->operands[1]->type;
148}
149
150void
151ir_algebraic_visitor::reassociate_operands(ir_expression *ir1,
152 int op1,
153 ir_expression *ir2,
154 int op2)
155{
156 ir_rvalue *temp = ir2->operands[op2];
157 ir2->operands[op2] = ir1->operands[op1];
158 ir1->operands[op1] = temp;
159
160 /* Update the type of ir2. The type of ir1 won't have changed --
161 * base types matched, and at least one of the operands of the 2
162 * binops is still a vector if any of them were.
163 */
164 update_type(ir2);
165
166 this->progress = true;
167}
168
169/**
170 * Reassociates a constant down a tree of adds or multiplies.
171 *
172 * Consider (2 * (a * (b * 0.5))). We want to send up with a * b.
173 */
174bool
175ir_algebraic_visitor::reassociate_constant(ir_expression *ir1, int const_index,
176 ir_constant *constant,
177 ir_expression *ir2)
178{
179 if (!ir2 || ir1->operation != ir2->operation)
180 return false;
181
182 /* Don't want to even think about matrices. */
183 if (ir1->operands[0]->type->is_matrix() ||
184 ir1->operands[0]->type->is_matrix() ||
185 ir2->operands[1]->type->is_matrix() ||
186 ir2->operands[1]->type->is_matrix())
187 return false;
188
189 ir_constant *ir2_const[2];
190 ir2_const[0] = ir2->operands[0]->constant_expression_value();
191 ir2_const[1] = ir2->operands[1]->constant_expression_value();
192
193 if (ir2_const[0] && ir2_const[1])
194 return false;
195
196 if (ir2_const[0]) {
197 reassociate_operands(ir1, const_index, ir2, 1);
198 return true;
199 } else if (ir2_const[1]) {
200 reassociate_operands(ir1, const_index, ir2, 0);
201 return true;
202 }
203
204 if (reassociate_constant(ir1, const_index, constant,
205 ir2->operands[0]->as_expression())) {
206 update_type(ir2);
207 return true;
208 }
209
210 if (reassociate_constant(ir1, const_index, constant,
211 ir2->operands[1]->as_expression())) {
212 update_type(ir2);
213 return true;
214 }
215
216 return false;
217}
218
219ir_rvalue *
220ir_algebraic_visitor::handle_expression(ir_expression *ir)
221{
222 ir_constant *op_const[2] = {NULL, NULL};
223 ir_expression *op_expr[2] = {NULL, NULL};
224 unsigned int i;
225
226 for (i = 0; i < ir->get_num_operands(); i++) {
227 if (ir->operands[i]->type->is_matrix())
228 return ir;
229
230 op_const[i] = ir->operands[i]->constant_expression_value();
231 op_expr[i] = ir->operands[i]->as_expression();
232 }
233
234 switch (ir->operation) {
235 case ir_unop_logic_not: {
236 enum ir_expression_operation new_op = ir_unop_logic_not;
237
238 if (op_expr[0] == NULL)
239 break;
240
241 switch (op_expr[0]->operation) {
242 case ir_binop_less: new_op = ir_binop_gequal; break;
243 case ir_binop_greater: new_op = ir_binop_lequal; break;
244 case ir_binop_lequal: new_op = ir_binop_greater; break;
245 case ir_binop_gequal: new_op = ir_binop_less; break;
246 case ir_binop_equal: new_op = ir_binop_nequal; break;
247 case ir_binop_nequal: new_op = ir_binop_equal; break;
248
249 default:
250 /* The default case handler is here to silence a warning from GCC.
251 */
252 break;
253 }
254
255 if (new_op != ir_unop_logic_not) {
256 this->progress = true;
257 return new(ir) ir_expression(new_op,
258 ir->type,
259 op_expr[0]->operands[0],
260 op_expr[0]->operands[1]);
261 }
262
263 break;
264 }
265
266 case ir_binop_add:
267 if (is_vec_zero(op_const[0])) {
268 this->progress = true;
269 return ir->operands[1];
270 }
271 if (is_vec_zero(op_const[1])) {
272 this->progress = true;
273 return ir->operands[0];
274 }
275
276 /* Reassociate addition of constants so that we can do constant
277 * folding.
278 */
279 if (op_const[0] && !op_const[1])
280 reassociate_constant(ir, 0, op_const[0],
281 ir->operands[1]->as_expression());
282 if (op_const[1] && !op_const[0])
283 reassociate_constant(ir, 1, op_const[1],
284 ir->operands[0]->as_expression());
285 break;
286
287 case ir_binop_sub:
288 if (is_vec_zero(op_const[0])) {
289 this->progress = true;
290 return new(ir) ir_expression(ir_unop_neg,
291 ir->type,
292 ir->operands[1],
293 NULL);
294 }
295 if (is_vec_zero(op_const[1])) {
296 this->progress = true;
297 return ir->operands[0];
298 }
299 break;
300
301 case ir_binop_mul:
302 if (is_vec_one(op_const[0])) {
303 this->progress = true;
304 return ir->operands[1];
305 }
306 if (is_vec_one(op_const[1])) {
307 this->progress = true;
308 return ir->operands[0];
309 }
310
311 if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) {
312 this->progress = true;
313 return ir_constant::zero(ir, ir->type);
314 }
315
316 /* Reassociate multiplication of constants so that we can do
317 * constant folding.
318 */
319 if (op_const[0] && !op_const[1])
320 reassociate_constant(ir, 0, op_const[0],
321 ir->operands[1]->as_expression());
322 if (op_const[1] && !op_const[0])
323 reassociate_constant(ir, 1, op_const[1],
324 ir->operands[0]->as_expression());
325
326 break;
327
328 case ir_binop_div:
329 if (is_vec_one(op_const[0]) && ir->type->base_type == GLSL_TYPE_FLOAT) {
330 this->progress = true;
331 return new(ir) ir_expression(ir_unop_rcp,
332 ir->type,
333 ir->operands[1],
334 NULL);
335 }
336 if (is_vec_one(op_const[1])) {
337 this->progress = true;
338 return ir->operands[0];
339 }
340 break;
341
342 case ir_unop_rcp:
343 if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp) {
344 this->progress = true;
345 return op_expr[0]->operands[0];
346 }
347
348 /* FINISHME: We should do rcp(rsq(x)) -> sqrt(x) for some
349 * backends, except that some backends will have done sqrt ->
350 * rcp(rsq(x)) and we don't want to undo it for them.
351 */
352
353 /* As far as we know, all backends are OK with rsq. */
354 if (op_expr[0] && op_expr[0]->operation == ir_unop_sqrt) {
355 this->progress = true;
356 return new(ir) ir_expression(ir_unop_rsq,
357 ir->type,
358 op_expr[0]->operands[0],
359 NULL);
360 }
361
362 break;
363
364 default:
365 break;
366 }
367
368 return ir;
369}
370
371void
372ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue)
373{
374 if (!*rvalue)
375 return;
376
377 ir_expression *expr = (*rvalue)->as_expression();
378 if (!expr)
379 return;
380
381 *rvalue = handle_expression(expr);
382}
383
384bool
385do_algebraic(exec_list *instructions)
386{
387 ir_algebraic_visitor v;
388
389 visit_list_elements(&v, instructions);
390
391 return v.progress;
392}
diff --git a/src/glsl/ir_basic_block.cpp b/src/glsl/ir_basic_block.cpp
new file mode 100644
index 00000000000..a8338259620
--- /dev/null
+++ b/src/glsl/ir_basic_block.cpp
@@ -0,0 +1,149 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_basic_block.cpp
26 *
27 * Basic block analysis of instruction streams.
28 */
29
30#include "ir.h"
31#include "ir_visitor.h"
32#include "ir_basic_block.h"
33#include "glsl_types.h"
34
35class ir_has_call_visitor : public ir_hierarchical_visitor {
36public:
37 ir_has_call_visitor()
38 {
39 has_call = false;
40 }
41
42 virtual ir_visitor_status visit_enter(ir_call *ir)
43 {
44 (void) ir;
45 has_call = true;
46 return visit_stop;
47 }
48
49 bool has_call;
50};
51
52bool
53ir_has_call(ir_instruction *ir)
54{
55 ir_has_call_visitor v;
56 ir->accept(&v);
57 return v.has_call;
58}
59
60/**
61 * Calls a user function for every basic block in the instruction stream.
62 *
63 * Basic block analysis is pretty easy in our IR thanks to the lack of
64 * unstructured control flow. We've got:
65 *
66 * ir_loop (for () {}, while () {}, do {} while ())
67 * ir_loop_jump (
68 * ir_if () {}
69 * ir_return
70 * ir_call()
71 *
72 * Note that the basic blocks returned by this don't encompass all
73 * operations performed by the program -- for example, if conditions
74 * don't get returned, nor do the assignments that will be generated
75 * for ir_call parameters.
76 */
77void call_for_basic_blocks(exec_list *instructions,
78 void (*callback)(ir_instruction *first,
79 ir_instruction *last,
80 void *data),
81 void *data)
82{
83 ir_instruction *leader = NULL;
84 ir_instruction *last = NULL;
85
86 foreach_iter(exec_list_iterator, iter, *instructions) {
87 ir_instruction *ir = (ir_instruction *)iter.get();
88 ir_if *ir_if;
89 ir_loop *ir_loop;
90 ir_function *ir_function;
91
92 if (!leader)
93 leader = ir;
94
95 if ((ir_if = ir->as_if())) {
96 callback(leader, ir, data);
97 leader = NULL;
98
99 call_for_basic_blocks(&ir_if->then_instructions, callback, data);
100 call_for_basic_blocks(&ir_if->else_instructions, callback, data);
101 } else if ((ir_loop = ir->as_loop())) {
102 callback(leader, ir, data);
103 leader = NULL;
104 call_for_basic_blocks(&ir_loop->body_instructions, callback, data);
105 } else if (ir->as_return() || ir->as_call()) {
106 callback(leader, ir, data);
107 leader = NULL;
108 } else if ((ir_function = ir->as_function())) {
109 /* A function definition doesn't interrupt our basic block
110 * since execution doesn't go into it. We should process the
111 * bodies of its signatures for BBs, though.
112 *
113 * Note that we miss an opportunity for producing more
114 * maximal BBs between the instructions that precede main()
115 * and the body of main(). Perhaps those instructions ought
116 * to live inside of main().
117 */
118 foreach_iter(exec_list_iterator, fun_iter, *ir_function) {
119 ir_function_signature *ir_sig;
120
121 ir_sig = (ir_function_signature *)fun_iter.get();
122
123 call_for_basic_blocks(&ir_sig->body, callback, data);
124 }
125 } else if (ir->as_assignment()) {
126 /* If there's a call in the expression tree being assigned,
127 * then that ends the BB too.
128 *
129 * The assumption is that any consumer of the basic block
130 * walker is fine with the fact that the call is somewhere in
131 * the tree even if portions of the tree may be evaluated
132 * after the call.
133 *
134 * A consumer that has an issue with this could not process
135 * the last instruction of the basic block. If doing so,
136 * expression flattener may be useful before using the basic
137 * block finder to get more maximal basic blocks out.
138 */
139 if (ir_has_call(ir)) {
140 callback(leader, ir, data);
141 leader = NULL;
142 }
143 }
144 last = ir;
145 }
146 if (leader) {
147 callback(leader, last, data);
148 }
149}
diff --git a/src/glsl/ir_basic_block.h b/src/glsl/ir_basic_block.h
new file mode 100644
index 00000000000..dbd678b5c4f
--- /dev/null
+++ b/src/glsl/ir_basic_block.h
@@ -0,0 +1,28 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24void call_for_basic_blocks(exec_list *instructions,
25 void (*callback)(ir_instruction *first,
26 ir_instruction *last,
27 void *data),
28 void *data);
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
new file mode 100644
index 00000000000..0a9e25a295a
--- /dev/null
+++ b/src/glsl/ir_clone.cpp
@@ -0,0 +1,401 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <string.h>
25#include "ir.h"
26#include "glsl_types.h"
27extern "C" {
28#include "program/hash_table.h"
29}
30
31/**
32 * Duplicate an IR variable
33 *
34 * \note
35 * This will probably be made \c virtual and moved to the base class
36 * eventually.
37 */
38ir_variable *
39ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
40{
41 ir_variable *var = new(mem_ctx) ir_variable(this->type, this->name,
42 (ir_variable_mode) this->mode);
43
44 var->max_array_access = this->max_array_access;
45 var->read_only = this->read_only;
46 var->centroid = this->centroid;
47 var->invariant = this->invariant;
48 var->interpolation = this->interpolation;
49 var->array_lvalue = this->array_lvalue;
50 var->location = this->location;
51 var->warn_extension = this->warn_extension;
52 var->origin_upper_left = this->origin_upper_left;
53 var->pixel_center_integer = this->pixel_center_integer;
54
55 if (this->constant_value)
56 var->constant_value = this->constant_value->clone(mem_ctx, ht);
57
58 if (ht) {
59 hash_table_insert(ht, var, (void *)const_cast<ir_variable *>(this));
60 }
61
62 return var;
63}
64
65ir_swizzle *
66ir_swizzle::clone(void *mem_ctx, struct hash_table *ht) const
67{
68 return new(mem_ctx) ir_swizzle(this->val->clone(mem_ctx, ht), this->mask);
69}
70
71ir_return *
72ir_return::clone(void *mem_ctx, struct hash_table *ht) const
73{
74 ir_rvalue *new_value = NULL;
75
76 if (this->value)
77 new_value = this->value->clone(mem_ctx, ht);
78
79 return new(mem_ctx) ir_return(new_value);
80}
81
82ir_discard *
83ir_discard::clone(void *mem_ctx, struct hash_table *ht) const
84{
85 ir_rvalue *new_condition = NULL;
86
87 if (this->condition != NULL)
88 new_condition = this->condition->clone(mem_ctx, ht);
89
90 return new(mem_ctx) ir_discard(new_condition);
91}
92
93ir_loop_jump *
94ir_loop_jump::clone(void *mem_ctx, struct hash_table *ht) const
95{
96 (void)ht;
97
98 return new(mem_ctx) ir_loop_jump(this->mode);
99}
100
101ir_if *
102ir_if::clone(void *mem_ctx, struct hash_table *ht) const
103{
104 ir_if *new_if = new(mem_ctx) ir_if(this->condition->clone(mem_ctx, ht));
105
106 foreach_iter(exec_list_iterator, iter, this->then_instructions) {
107 ir_instruction *ir = (ir_instruction *)iter.get();
108 new_if->then_instructions.push_tail(ir->clone(mem_ctx, ht));
109 }
110
111 foreach_iter(exec_list_iterator, iter, this->else_instructions) {
112 ir_instruction *ir = (ir_instruction *)iter.get();
113 new_if->else_instructions.push_tail(ir->clone(mem_ctx, ht));
114 }
115
116 return new_if;
117}
118
119ir_loop *
120ir_loop::clone(void *mem_ctx, struct hash_table *ht) const
121{
122 ir_loop *new_loop = new(mem_ctx) ir_loop();
123
124 if (this->from)
125 new_loop->from = this->from->clone(mem_ctx, ht);
126 if (this->to)
127 new_loop->to = this->to->clone(mem_ctx, ht);
128 if (this->increment)
129 new_loop->increment = this->increment->clone(mem_ctx, ht);
130 new_loop->counter = counter;
131
132 foreach_iter(exec_list_iterator, iter, this->body_instructions) {
133 ir_instruction *ir = (ir_instruction *)iter.get();
134 new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht));
135 }
136
137 return new_loop;
138}
139
140ir_call *
141ir_call::clone(void *mem_ctx, struct hash_table *ht) const
142{
143 exec_list new_parameters;
144
145 foreach_iter(exec_list_iterator, iter, this->actual_parameters) {
146 ir_instruction *ir = (ir_instruction *)iter.get();
147 new_parameters.push_tail(ir->clone(mem_ctx, ht));
148 }
149
150 return new(mem_ctx) ir_call(this->callee, &new_parameters);
151}
152
153ir_expression *
154ir_expression::clone(void *mem_ctx, struct hash_table *ht) const
155{
156 ir_rvalue *op[2] = {NULL, NULL};
157 unsigned int i;
158
159 for (i = 0; i < get_num_operands(); i++) {
160 op[i] = this->operands[i]->clone(mem_ctx, ht);
161 }
162
163 return new(mem_ctx) ir_expression(this->operation, this->type, op[0], op[1]);
164}
165
166ir_dereference_variable *
167ir_dereference_variable::clone(void *mem_ctx, struct hash_table *ht) const
168{
169 ir_variable *new_var;
170
171 if (ht) {
172 new_var = (ir_variable *)hash_table_find(ht, this->var);
173 if (!new_var)
174 new_var = this->var;
175 } else {
176 new_var = this->var;
177 }
178
179 return new(mem_ctx) ir_dereference_variable(new_var);
180}
181
182ir_dereference_array *
183ir_dereference_array::clone(void *mem_ctx, struct hash_table *ht) const
184{
185 return new(mem_ctx) ir_dereference_array(this->array->clone(mem_ctx, ht),
186 this->array_index->clone(mem_ctx,
187 ht));
188}
189
190ir_dereference_record *
191ir_dereference_record::clone(void *mem_ctx, struct hash_table *ht) const
192{
193 return new(mem_ctx) ir_dereference_record(this->record->clone(mem_ctx, ht),
194 this->field);
195}
196
197ir_texture *
198ir_texture::clone(void *mem_ctx, struct hash_table *ht) const
199{
200 ir_texture *new_tex = new(mem_ctx) ir_texture(this->op);
201 new_tex->type = this->type;
202
203 new_tex->sampler = this->sampler->clone(mem_ctx, ht);
204 new_tex->coordinate = this->coordinate->clone(mem_ctx, ht);
205 if (this->projector)
206 new_tex->projector = this->projector->clone(mem_ctx, ht);
207 if (this->shadow_comparitor) {
208 new_tex->shadow_comparitor = this->shadow_comparitor->clone(mem_ctx, ht);
209 }
210
211 for (int i = 0; i < 3; i++)
212 new_tex->offsets[i] = this->offsets[i];
213
214 switch (this->op) {
215 case ir_tex:
216 break;
217 case ir_txb:
218 new_tex->lod_info.bias = this->lod_info.bias->clone(mem_ctx, ht);
219 break;
220 case ir_txl:
221 case ir_txf:
222 new_tex->lod_info.lod = this->lod_info.lod->clone(mem_ctx, ht);
223 break;
224 case ir_txd:
225 new_tex->lod_info.grad.dPdx = this->lod_info.grad.dPdx->clone(mem_ctx, ht);
226 new_tex->lod_info.grad.dPdy = this->lod_info.grad.dPdy->clone(mem_ctx, ht);
227 break;
228 }
229
230 return new_tex;
231}
232
233ir_assignment *
234ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const
235{
236 ir_rvalue *new_condition = NULL;
237
238 if (this->condition)
239 new_condition = this->condition->clone(mem_ctx, ht);
240
241 return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht),
242 this->rhs->clone(mem_ctx, ht),
243 new_condition,
244 this->write_mask);
245}
246
247ir_function *
248ir_function::clone(void *mem_ctx, struct hash_table *ht) const
249{
250 ir_function *copy = new(mem_ctx) ir_function(this->name);
251
252 foreach_list_const(node, &this->signatures) {
253 const ir_function_signature *const sig =
254 (const ir_function_signature *const) node;
255
256 ir_function_signature *sig_copy = sig->clone(mem_ctx, ht);
257 copy->add_signature(sig_copy);
258
259 if (ht != NULL)
260 hash_table_insert(ht, sig_copy,
261 (void *)const_cast<ir_function_signature *>(sig));
262 }
263
264 return copy;
265}
266
267ir_function_signature *
268ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const
269{
270 ir_function_signature *copy =
271 new(mem_ctx) ir_function_signature(this->return_type);
272
273 copy->is_defined = this->is_defined;
274 copy->is_built_in = this->is_built_in;
275
276 /* Clone the parameter list.
277 */
278 foreach_list_const(node, &this->parameters) {
279 const ir_variable *const param = (const ir_variable *) node;
280
281 assert(const_cast<ir_variable *>(param)->as_variable() != NULL);
282
283 ir_variable *const param_copy = param->clone(mem_ctx, ht);
284 copy->parameters.push_tail(param_copy);
285 }
286
287 /* Clone the instruction list.
288 */
289 foreach_list_const(node, &this->body) {
290 const ir_instruction *const inst = (const ir_instruction *) node;
291
292 ir_instruction *const inst_copy = inst->clone(mem_ctx, ht);
293 copy->body.push_tail(inst_copy);
294 }
295
296 return copy;
297}
298
299ir_constant *
300ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
301{
302 (void)ht;
303
304 switch (this->type->base_type) {
305 case GLSL_TYPE_UINT:
306 case GLSL_TYPE_INT:
307 case GLSL_TYPE_FLOAT:
308 case GLSL_TYPE_BOOL:
309 return new(mem_ctx) ir_constant(this->type, &this->value);
310
311 case GLSL_TYPE_STRUCT: {
312 ir_constant *c = new(mem_ctx) ir_constant;
313
314 c->type = this->type;
315 for (exec_node *node = this->components.head
316 ; !node->is_tail_sentinel()
317 ; node = node->next) {
318 ir_constant *const orig = (ir_constant *) node;
319
320 c->components.push_tail(orig->clone(mem_ctx, NULL));
321 }
322
323 return c;
324 }
325
326 case GLSL_TYPE_ARRAY: {
327 ir_constant *c = new(mem_ctx) ir_constant;
328
329 c->type = this->type;
330 c->array_elements = talloc_array(c, ir_constant *, this->type->length);
331 for (unsigned i = 0; i < this->type->length; i++) {
332 c->array_elements[i] = this->array_elements[i]->clone(mem_ctx, NULL);
333 }
334 return c;
335 }
336
337 default:
338 assert(!"Should not get here.");
339 return NULL;
340 }
341}
342
343
344class fixup_ir_call_visitor : public ir_hierarchical_visitor {
345public:
346 fixup_ir_call_visitor(struct hash_table *ht)
347 {
348 this->ht = ht;
349 }
350
351 virtual ir_visitor_status visit_enter(ir_call *ir)
352 {
353 /* Try to find the function signature referenced by the ir_call in the
354 * table. If it is found, replace it with the value from the table.
355 */
356 ir_function_signature *sig =
357 (ir_function_signature *) hash_table_find(this->ht, ir->get_callee());
358 if (sig != NULL)
359 ir->set_callee(sig);
360
361 /* Since this may be used before function call parameters are flattened,
362 * the children also need to be processed.
363 */
364 return visit_continue;
365 }
366
367private:
368 struct hash_table *ht;
369};
370
371
372static void
373fixup_function_calls(struct hash_table *ht, exec_list *instructions)
374{
375 fixup_ir_call_visitor v(ht);
376 v.run(instructions);
377}
378
379
380void
381clone_ir_list(void *mem_ctx, exec_list *out, const exec_list *in)
382{
383 struct hash_table *ht =
384 hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare);
385
386 foreach_list_const(node, in) {
387 const ir_instruction *const original = (ir_instruction *) node;
388 ir_instruction *copy = original->clone(mem_ctx, ht);
389
390 out->push_tail(copy);
391 }
392
393 /* Make a pass over the cloned tree to fix up ir_call nodes to point to the
394 * cloned ir_function_signature nodes. This cannot be done automatically
395 * during cloning because the ir_call might be a forward reference (i.e.,
396 * the function signature that it references may not have been cloned yet).
397 */
398 fixup_function_calls(ht, out);
399
400 hash_table_dtor(ht);
401}
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
new file mode 100644
index 00000000000..0a924246da1
--- /dev/null
+++ b/src/glsl/ir_constant_expression.cpp
@@ -0,0 +1,1144 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_constant_expression.cpp
26 * Evaluate and process constant valued expressions
27 *
28 * In GLSL, constant valued expressions are used in several places. These
29 * must be processed and evaluated very early in the compilation process.
30 *
31 * * Sizes of arrays
32 * * Initializers for uniforms
33 * * Initializers for \c const variables
34 */
35
36#include <math.h>
37#include "main/macros.h"
38#include "ir.h"
39#include "ir_visitor.h"
40#include "glsl_types.h"
41
42static float
43dot(ir_constant *op0, ir_constant *op1)
44{
45 assert(op0->type->is_float() && op1->type->is_float());
46
47 float result = 0;
48 for (unsigned c = 0; c < op0->type->components(); c++)
49 result += op0->value.f[c] * op1->value.f[c];
50
51 return result;
52}
53
54ir_constant *
55ir_expression::constant_expression_value()
56{
57 ir_constant *op[2] = { NULL, NULL };
58 ir_constant_data data;
59
60 memset(&data, 0, sizeof(data));
61
62 for (unsigned operand = 0; operand < this->get_num_operands(); operand++) {
63 op[operand] = this->operands[operand]->constant_expression_value();
64 if (!op[operand])
65 return NULL;
66 }
67
68 if (op[1] != NULL)
69 assert(op[0]->type->base_type == op[1]->type->base_type);
70
71 bool op0_scalar = op[0]->type->is_scalar();
72 bool op1_scalar = op[1] != NULL && op[1]->type->is_scalar();
73
74 /* When iterating over a vector or matrix's components, we want to increase
75 * the loop counter. However, for scalars, we want to stay at 0.
76 */
77 unsigned c0_inc = op0_scalar ? 0 : 1;
78 unsigned c1_inc = op1_scalar ? 0 : 1;
79 unsigned components;
80 if (op1_scalar || !op[1]) {
81 components = op[0]->type->components();
82 } else {
83 components = op[1]->type->components();
84 }
85
86 void *ctx = talloc_parent(this);
87
88 /* Handle array operations here, rather than below. */
89 if (op[0]->type->is_array()) {
90 assert(op[1] != NULL && op[1]->type->is_array());
91 switch (this->operation) {
92 case ir_binop_equal:
93 return new(ctx) ir_constant(op[0]->has_value(op[1]));
94 case ir_binop_nequal:
95 return new(ctx) ir_constant(!op[0]->has_value(op[1]));
96 default:
97 break;
98 }
99 return NULL;
100 }
101
102 switch (this->operation) {
103 case ir_unop_logic_not:
104 assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
105 for (unsigned c = 0; c < op[0]->type->components(); c++)
106 data.b[c] = !op[0]->value.b[c];
107 break;
108
109 case ir_unop_f2i:
110 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
111 for (unsigned c = 0; c < op[0]->type->components(); c++) {
112 data.i[c] = op[0]->value.f[c];
113 }
114 break;
115 case ir_unop_i2f:
116 assert(op[0]->type->base_type == GLSL_TYPE_INT);
117 for (unsigned c = 0; c < op[0]->type->components(); c++) {
118 data.f[c] = op[0]->value.i[c];
119 }
120 break;
121 case ir_unop_u2f:
122 assert(op[0]->type->base_type == GLSL_TYPE_UINT);
123 for (unsigned c = 0; c < op[0]->type->components(); c++) {
124 data.f[c] = op[0]->value.u[c];
125 }
126 break;
127 case ir_unop_b2f:
128 assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
129 for (unsigned c = 0; c < op[0]->type->components(); c++) {
130 data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0;
131 }
132 break;
133 case ir_unop_f2b:
134 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
135 for (unsigned c = 0; c < op[0]->type->components(); c++) {
136 data.b[c] = bool(op[0]->value.f[c]);
137 }
138 break;
139 case ir_unop_b2i:
140 assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
141 for (unsigned c = 0; c < op[0]->type->components(); c++) {
142 data.u[c] = op[0]->value.b[c] ? 1 : 0;
143 }
144 break;
145 case ir_unop_i2b:
146 assert(op[0]->type->is_integer());
147 for (unsigned c = 0; c < op[0]->type->components(); c++) {
148 data.b[c] = bool(op[0]->value.u[c]);
149 }
150 break;
151
152 case ir_unop_trunc:
153 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
154 for (unsigned c = 0; c < op[0]->type->components(); c++) {
155 data.f[c] = truncf(op[0]->value.f[c]);
156 }
157 break;
158
159 case ir_unop_ceil:
160 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
161 for (unsigned c = 0; c < op[0]->type->components(); c++) {
162 data.f[c] = ceilf(op[0]->value.f[c]);
163 }
164 break;
165
166 case ir_unop_floor:
167 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
168 for (unsigned c = 0; c < op[0]->type->components(); c++) {
169 data.f[c] = floorf(op[0]->value.f[c]);
170 }
171 break;
172
173 case ir_unop_fract:
174 for (unsigned c = 0; c < op[0]->type->components(); c++) {
175 switch (this->type->base_type) {
176 case GLSL_TYPE_UINT:
177 data.u[c] = 0;
178 break;
179 case GLSL_TYPE_INT:
180 data.i[c] = 0;
181 break;
182 case GLSL_TYPE_FLOAT:
183 data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]);
184 break;
185 default:
186 assert(0);
187 }
188 }
189 break;
190
191 case ir_unop_sin:
192 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
193 for (unsigned c = 0; c < op[0]->type->components(); c++) {
194 data.f[c] = sinf(op[0]->value.f[c]);
195 }
196 break;
197
198 case ir_unop_cos:
199 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
200 for (unsigned c = 0; c < op[0]->type->components(); c++) {
201 data.f[c] = cosf(op[0]->value.f[c]);
202 }
203 break;
204
205 case ir_unop_neg:
206 for (unsigned c = 0; c < op[0]->type->components(); c++) {
207 switch (this->type->base_type) {
208 case GLSL_TYPE_UINT:
209 data.u[c] = -op[0]->value.u[c];
210 break;
211 case GLSL_TYPE_INT:
212 data.i[c] = -op[0]->value.i[c];
213 break;
214 case GLSL_TYPE_FLOAT:
215 data.f[c] = -op[0]->value.f[c];
216 break;
217 default:
218 assert(0);
219 }
220 }
221 break;
222
223 case ir_unop_abs:
224 for (unsigned c = 0; c < op[0]->type->components(); c++) {
225 switch (this->type->base_type) {
226 case GLSL_TYPE_UINT:
227 data.u[c] = op[0]->value.u[c];
228 break;
229 case GLSL_TYPE_INT:
230 data.i[c] = op[0]->value.i[c];
231 if (data.i[c] < 0)
232 data.i[c] = -data.i[c];
233 break;
234 case GLSL_TYPE_FLOAT:
235 data.f[c] = fabs(op[0]->value.f[c]);
236 break;
237 default:
238 assert(0);
239 }
240 }
241 break;
242
243 case ir_unop_sign:
244 for (unsigned c = 0; c < op[0]->type->components(); c++) {
245 switch (this->type->base_type) {
246 case GLSL_TYPE_UINT:
247 data.u[c] = op[0]->value.i[c] > 0;
248 break;
249 case GLSL_TYPE_INT:
250 data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0);
251 break;
252 case GLSL_TYPE_FLOAT:
253 data.f[c] = float((op[0]->value.f[c] > 0)-(op[0]->value.f[c] < 0));
254 break;
255 default:
256 assert(0);
257 }
258 }
259 break;
260
261 case ir_unop_rcp:
262 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
263 for (unsigned c = 0; c < op[0]->type->components(); c++) {
264 switch (this->type->base_type) {
265 case GLSL_TYPE_UINT:
266 if (op[0]->value.u[c] != 0.0)
267 data.u[c] = 1 / op[0]->value.u[c];
268 break;
269 case GLSL_TYPE_INT:
270 if (op[0]->value.i[c] != 0.0)
271 data.i[c] = 1 / op[0]->value.i[c];
272 break;
273 case GLSL_TYPE_FLOAT:
274 if (op[0]->value.f[c] != 0.0)
275 data.f[c] = 1.0 / op[0]->value.f[c];
276 break;
277 default:
278 assert(0);
279 }
280 }
281 break;
282
283 case ir_unop_rsq:
284 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
285 for (unsigned c = 0; c < op[0]->type->components(); c++) {
286 data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]);
287 }
288 break;
289
290 case ir_unop_sqrt:
291 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
292 for (unsigned c = 0; c < op[0]->type->components(); c++) {
293 data.f[c] = sqrtf(op[0]->value.f[c]);
294 }
295 break;
296
297 case ir_unop_exp:
298 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
299 for (unsigned c = 0; c < op[0]->type->components(); c++) {
300 data.f[c] = expf(op[0]->value.f[c]);
301 }
302 break;
303
304 case ir_unop_exp2:
305 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
306 for (unsigned c = 0; c < op[0]->type->components(); c++) {
307 data.f[c] = exp2f(op[0]->value.f[c]);
308 }
309 break;
310
311 case ir_unop_log:
312 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
313 for (unsigned c = 0; c < op[0]->type->components(); c++) {
314 data.f[c] = logf(op[0]->value.f[c]);
315 }
316 break;
317
318 case ir_unop_log2:
319 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
320 for (unsigned c = 0; c < op[0]->type->components(); c++) {
321 data.f[c] = log2f(op[0]->value.f[c]);
322 }
323 break;
324
325 case ir_unop_dFdx:
326 case ir_unop_dFdy:
327 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
328 for (unsigned c = 0; c < op[0]->type->components(); c++) {
329 data.f[c] = 0.0;
330 }
331 break;
332
333 case ir_binop_pow:
334 assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
335 for (unsigned c = 0; c < op[0]->type->components(); c++) {
336 data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]);
337 }
338 break;
339
340 case ir_binop_dot:
341 data.f[0] = dot(op[0], op[1]);
342 break;
343
344 case ir_binop_min:
345 assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
346 for (unsigned c = 0, c0 = 0, c1 = 0;
347 c < components;
348 c0 += c0_inc, c1 += c1_inc, c++) {
349
350 switch (op[0]->type->base_type) {
351 case GLSL_TYPE_UINT:
352 data.u[c] = MIN2(op[0]->value.u[c0], op[1]->value.u[c1]);
353 break;
354 case GLSL_TYPE_INT:
355 data.i[c] = MIN2(op[0]->value.i[c0], op[1]->value.i[c1]);
356 break;
357 case GLSL_TYPE_FLOAT:
358 data.f[c] = MIN2(op[0]->value.f[c0], op[1]->value.f[c1]);
359 break;
360 default:
361 assert(0);
362 }
363 }
364
365 break;
366 case ir_binop_max:
367 assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
368 for (unsigned c = 0, c0 = 0, c1 = 0;
369 c < components;
370 c0 += c0_inc, c1 += c1_inc, c++) {
371
372 switch (op[0]->type->base_type) {
373 case GLSL_TYPE_UINT:
374 data.u[c] = MAX2(op[0]->value.u[c0], op[1]->value.u[c1]);
375 break;
376 case GLSL_TYPE_INT:
377 data.i[c] = MAX2(op[0]->value.i[c0], op[1]->value.i[c1]);
378 break;
379 case GLSL_TYPE_FLOAT:
380 data.f[c] = MAX2(op[0]->value.f[c0], op[1]->value.f[c1]);
381 break;
382 default:
383 assert(0);
384 }
385 }
386 break;
387
388 case ir_binop_cross:
389 assert(op[0]->type == glsl_type::vec3_type);
390 assert(op[1]->type == glsl_type::vec3_type);
391 data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] -
392 op[1]->value.f[1] * op[0]->value.f[2]);
393 data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] -
394 op[1]->value.f[2] * op[0]->value.f[0]);
395 data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] -
396 op[1]->value.f[0] * op[0]->value.f[1]);
397 break;
398
399 case ir_binop_add:
400 assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
401 for (unsigned c = 0, c0 = 0, c1 = 0;
402 c < components;
403 c0 += c0_inc, c1 += c1_inc, c++) {
404
405 switch (op[0]->type->base_type) {
406 case GLSL_TYPE_UINT:
407 data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1];
408 break;
409 case GLSL_TYPE_INT:
410 data.i[c] = op[0]->value.i[c0] + op[1]->value.i[c1];
411 break;
412 case GLSL_TYPE_FLOAT:
413 data.f[c] = op[0]->value.f[c0] + op[1]->value.f[c1];
414 break;
415 default:
416 assert(0);
417 }
418 }
419
420 break;
421 case ir_binop_sub:
422 assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
423 for (unsigned c = 0, c0 = 0, c1 = 0;
424 c < components;
425 c0 += c0_inc, c1 += c1_inc, c++) {
426
427 switch (op[0]->type->base_type) {
428 case GLSL_TYPE_UINT:
429 data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1];
430 break;
431 case GLSL_TYPE_INT:
432 data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1];
433 break;
434 case GLSL_TYPE_FLOAT:
435 data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1];
436 break;
437 default:
438 assert(0);
439 }
440 }
441
442 break;
443 case ir_binop_mul:
444 /* Check for equal types, or unequal types involving scalars */
445 if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix())
446 || op0_scalar || op1_scalar) {
447 for (unsigned c = 0, c0 = 0, c1 = 0;
448 c < components;
449 c0 += c0_inc, c1 += c1_inc, c++) {
450
451 switch (op[0]->type->base_type) {
452 case GLSL_TYPE_UINT:
453 data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1];
454 break;
455 case GLSL_TYPE_INT:
456 data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1];
457 break;
458 case GLSL_TYPE_FLOAT:
459 data.f[c] = op[0]->value.f[c0] * op[1]->value.f[c1];
460 break;
461 default:
462 assert(0);
463 }
464 }
465 } else {
466 assert(op[0]->type->is_matrix() || op[1]->type->is_matrix());
467
468 /* Multiply an N-by-M matrix with an M-by-P matrix. Since either
469 * matrix can be a GLSL vector, either N or P can be 1.
470 *
471 * For vec*mat, the vector is treated as a row vector. This
472 * means the vector is a 1-row x M-column matrix.
473 *
474 * For mat*vec, the vector is treated as a column vector. Since
475 * matrix_columns is 1 for vectors, this just works.
476 */
477 const unsigned n = op[0]->type->is_vector()
478 ? 1 : op[0]->type->vector_elements;
479 const unsigned m = op[1]->type->vector_elements;
480 const unsigned p = op[1]->type->matrix_columns;
481 for (unsigned j = 0; j < p; j++) {
482 for (unsigned i = 0; i < n; i++) {
483 for (unsigned k = 0; k < m; k++) {
484 data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j];
485 }
486 }
487 }
488 }
489
490 break;
491 case ir_binop_div:
492 assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
493 for (unsigned c = 0, c0 = 0, c1 = 0;
494 c < components;
495 c0 += c0_inc, c1 += c1_inc, c++) {
496
497 switch (op[0]->type->base_type) {
498 case GLSL_TYPE_UINT:
499 data.u[c] = op[0]->value.u[c0] / op[1]->value.u[c1];
500 break;
501 case GLSL_TYPE_INT:
502 data.i[c] = op[0]->value.i[c0] / op[1]->value.i[c1];
503 break;
504 case GLSL_TYPE_FLOAT:
505 data.f[c] = op[0]->value.f[c0] / op[1]->value.f[c1];
506 break;
507 default:
508 assert(0);
509 }
510 }
511
512 break;
513 case ir_binop_mod:
514 assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
515 for (unsigned c = 0, c0 = 0, c1 = 0;
516 c < components;
517 c0 += c0_inc, c1 += c1_inc, c++) {
518
519 switch (op[0]->type->base_type) {
520 case GLSL_TYPE_UINT:
521 data.u[c] = op[0]->value.u[c0] % op[1]->value.u[c1];
522 break;
523 case GLSL_TYPE_INT:
524 data.i[c] = op[0]->value.i[c0] % op[1]->value.i[c1];
525 break;
526 case GLSL_TYPE_FLOAT:
527 /* We don't use fmod because it rounds toward zero; GLSL specifies
528 * the use of floor.
529 */
530 data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1]
531 * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]);
532 break;
533 default:
534 assert(0);
535 }
536 }
537
538 break;
539
540 case ir_binop_logic_and:
541 assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
542 for (unsigned c = 0; c < op[0]->type->components(); c++)
543 data.b[c] = op[0]->value.b[c] && op[1]->value.b[c];
544 break;
545 case ir_binop_logic_xor:
546 assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
547 for (unsigned c = 0; c < op[0]->type->components(); c++)
548 data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c];
549 break;
550 case ir_binop_logic_or:
551 assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
552 for (unsigned c = 0; c < op[0]->type->components(); c++)
553 data.b[c] = op[0]->value.b[c] || op[1]->value.b[c];
554 break;
555
556 case ir_binop_less:
557 switch (op[0]->type->base_type) {
558 case GLSL_TYPE_UINT:
559 data.b[0] = op[0]->value.u[0] < op[1]->value.u[0];
560 break;
561 case GLSL_TYPE_INT:
562 data.b[0] = op[0]->value.i[0] < op[1]->value.i[0];
563 break;
564 case GLSL_TYPE_FLOAT:
565 data.b[0] = op[0]->value.f[0] < op[1]->value.f[0];
566 break;
567 default:
568 assert(0);
569 }
570 break;
571 case ir_binop_greater:
572 switch (op[0]->type->base_type) {
573 case GLSL_TYPE_UINT:
574 data.b[0] = op[0]->value.u[0] > op[1]->value.u[0];
575 break;
576 case GLSL_TYPE_INT:
577 data.b[0] = op[0]->value.i[0] > op[1]->value.i[0];
578 break;
579 case GLSL_TYPE_FLOAT:
580 data.b[0] = op[0]->value.f[0] > op[1]->value.f[0];
581 break;
582 default:
583 assert(0);
584 }
585 break;
586 case ir_binop_lequal:
587 switch (op[0]->type->base_type) {
588 case GLSL_TYPE_UINT:
589 data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0];
590 break;
591 case GLSL_TYPE_INT:
592 data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0];
593 break;
594 case GLSL_TYPE_FLOAT:
595 data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0];
596 break;
597 default:
598 assert(0);
599 }
600 break;
601 case ir_binop_gequal:
602 switch (op[0]->type->base_type) {
603 case GLSL_TYPE_UINT:
604 data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0];
605 break;
606 case GLSL_TYPE_INT:
607 data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0];
608 break;
609 case GLSL_TYPE_FLOAT:
610 data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0];
611 break;
612 default:
613 assert(0);
614 }
615 break;
616
617 case ir_binop_equal:
618 data.b[0] = op[0]->has_value(op[1]);
619 break;
620 case ir_binop_nequal:
621 data.b[0] = !op[0]->has_value(op[1]);
622 break;
623
624 default:
625 /* FINISHME: Should handle all expression types. */
626 return NULL;
627 }
628
629 return new(ctx) ir_constant(this->type, &data);
630}
631
632
633ir_constant *
634ir_texture::constant_expression_value()
635{
636 /* texture lookups aren't constant expressions */
637 return NULL;
638}
639
640
641ir_constant *
642ir_swizzle::constant_expression_value()
643{
644 ir_constant *v = this->val->constant_expression_value();
645
646 if (v != NULL) {
647 ir_constant_data data;
648
649 const unsigned swiz_idx[4] = {
650 this->mask.x, this->mask.y, this->mask.z, this->mask.w
651 };
652
653 for (unsigned i = 0; i < this->mask.num_components; i++) {
654 switch (v->type->base_type) {
655 case GLSL_TYPE_UINT:
656 case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break;
657 case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break;
658 case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break;
659 default: assert(!"Should not get here."); break;
660 }
661 }
662
663 void *ctx = talloc_parent(this);
664 return new(ctx) ir_constant(this->type, &data);
665 }
666 return NULL;
667}
668
669
670ir_constant *
671ir_dereference_variable::constant_expression_value()
672{
673 /* This may occur during compile and var->type is glsl_type::error_type */
674 if (!var)
675 return NULL;
676
677 /* The constant_value of a uniform variable is its initializer,
678 * not the lifetime constant value of the uniform.
679 */
680 if (var->mode == ir_var_uniform)
681 return NULL;
682
683 if (!var->constant_value)
684 return NULL;
685
686 return var->constant_value->clone(talloc_parent(var), NULL);
687}
688
689
690ir_constant *
691ir_dereference_array::constant_expression_value()
692{
693 ir_constant *array = this->array->constant_expression_value();
694 ir_constant *idx = this->array_index->constant_expression_value();
695
696 if ((array != NULL) && (idx != NULL)) {
697 void *ctx = talloc_parent(this);
698 if (array->type->is_matrix()) {
699 /* Array access of a matrix results in a vector.
700 */
701 const unsigned column = idx->value.u[0];
702
703 const glsl_type *const column_type = array->type->column_type();
704
705 /* Offset in the constant matrix to the first element of the column
706 * to be extracted.
707 */
708 const unsigned mat_idx = column * column_type->vector_elements;
709
710 ir_constant_data data;
711
712 switch (column_type->base_type) {
713 case GLSL_TYPE_UINT:
714 case GLSL_TYPE_INT:
715 for (unsigned i = 0; i < column_type->vector_elements; i++)
716 data.u[i] = array->value.u[mat_idx + i];
717
718 break;
719
720 case GLSL_TYPE_FLOAT:
721 for (unsigned i = 0; i < column_type->vector_elements; i++)
722 data.f[i] = array->value.f[mat_idx + i];
723
724 break;
725
726 default:
727 assert(!"Should not get here.");
728 break;
729 }
730
731 return new(ctx) ir_constant(column_type, &data);
732 } else if (array->type->is_vector()) {
733 const unsigned component = idx->value.u[0];
734
735 return new(ctx) ir_constant(array, component);
736 } else {
737 const unsigned index = idx->value.u[0];
738 return array->get_array_element(index)->clone(ctx, NULL);
739 }
740 }
741 return NULL;
742}
743
744
745ir_constant *
746ir_dereference_record::constant_expression_value()
747{
748 ir_constant *v = this->record->constant_expression_value();
749
750 return (v != NULL) ? v->get_record_field(this->field) : NULL;
751}
752
753
754ir_constant *
755ir_assignment::constant_expression_value()
756{
757 /* FINISHME: Handle CEs involving assignment (return RHS) */
758 return NULL;
759}
760
761
762ir_constant *
763ir_constant::constant_expression_value()
764{
765 return this;
766}
767
768
769ir_constant *
770ir_call::constant_expression_value()
771{
772 if (this->type == glsl_type::error_type)
773 return NULL;
774
775 /* From the GLSL 1.20 spec, page 23:
776 * "Function calls to user-defined functions (non-built-in functions)
777 * cannot be used to form constant expressions."
778 */
779 if (!this->callee->is_built_in)
780 return NULL;
781
782 unsigned num_parameters = 0;
783
784 /* Check if all parameters are constant */
785 ir_constant *op[3];
786 foreach_list(n, &this->actual_parameters) {
787 ir_constant *constant = ((ir_rvalue *) n)->constant_expression_value();
788 if (constant == NULL)
789 return NULL;
790
791 op[num_parameters] = constant;
792
793 assert(num_parameters < 3);
794 num_parameters++;
795 }
796
797 /* Individual cases below can either:
798 * - Assign "expr" a new ir_expression to evaluate (for basic opcodes)
799 * - Fill "data" with appopriate constant data
800 * - Return an ir_constant directly.
801 */
802 void *mem_ctx = talloc_parent(this);
803 ir_expression *expr = NULL;
804
805 ir_constant_data data;
806 memset(&data, 0, sizeof(data));
807
808 const char *callee = this->callee_name();
809 if (strcmp(callee, "abs") == 0) {
810 expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL);
811 } else if (strcmp(callee, "all") == 0) {
812 assert(op[0]->type->is_boolean());
813 for (unsigned c = 0; c < op[0]->type->components(); c++) {
814 if (!op[0]->value.b[c])
815 return new(mem_ctx) ir_constant(false);
816 }
817 return new(mem_ctx) ir_constant(true);
818 } else if (strcmp(callee, "any") == 0) {
819 assert(op[0]->type->is_boolean());
820 for (unsigned c = 0; c < op[0]->type->components(); c++) {
821 if (op[0]->value.b[c])
822 return new(mem_ctx) ir_constant(true);
823 }
824 return new(mem_ctx) ir_constant(false);
825 } else if (strcmp(callee, "acos") == 0) {
826 assert(op[0]->type->is_float());
827 for (unsigned c = 0; c < op[0]->type->components(); c++)
828 data.f[c] = acosf(op[0]->value.f[c]);
829 } else if (strcmp(callee, "asin") == 0) {
830 assert(op[0]->type->is_float());
831 for (unsigned c = 0; c < op[0]->type->components(); c++)
832 data.f[c] = asinf(op[0]->value.f[c]);
833 } else if (strcmp(callee, "atan") == 0) {
834 assert(op[0]->type->is_float());
835 if (num_parameters == 2) {
836 assert(op[1]->type->is_float());
837 for (unsigned c = 0; c < op[0]->type->components(); c++)
838 data.f[c] = atan2f(op[0]->value.f[c], op[1]->value.f[c]);
839 } else {
840 for (unsigned c = 0; c < op[0]->type->components(); c++)
841 data.f[c] = atanf(op[0]->value.f[c]);
842 }
843 } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) {
844 return ir_constant::zero(mem_ctx, this->type);
845 } else if (strcmp(callee, "ceil") == 0) {
846 expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL);
847 } else if (strcmp(callee, "clamp") == 0) {
848 assert(num_parameters == 3);
849 unsigned c1_inc = op[1]->type->is_scalar() ? 0 : 1;
850 unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
851 for (unsigned c = 0, c1 = 0, c2 = 0;
852 c < op[0]->type->components();
853 c1 += c1_inc, c2 += c2_inc, c++) {
854
855 switch (op[0]->type->base_type) {
856 case GLSL_TYPE_UINT:
857 data.u[c] = CLAMP(op[0]->value.u[c], op[1]->value.u[c1],
858 op[2]->value.u[c2]);
859 break;
860 case GLSL_TYPE_INT:
861 data.i[c] = CLAMP(op[0]->value.i[c], op[1]->value.i[c1],
862 op[2]->value.i[c2]);
863 break;
864 case GLSL_TYPE_FLOAT:
865 data.f[c] = CLAMP(op[0]->value.f[c], op[1]->value.f[c1],
866 op[2]->value.f[c2]);
867 break;
868 default:
869 assert(!"Should not get here.");
870 }
871 }
872 } else if (strcmp(callee, "cos") == 0) {
873 expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL);
874 } else if (strcmp(callee, "cosh") == 0) {
875 assert(op[0]->type->is_float());
876 for (unsigned c = 0; c < op[0]->type->components(); c++)
877 data.f[c] = coshf(op[0]->value.f[c]);
878 } else if (strcmp(callee, "cross") == 0) {
879 expr = new(mem_ctx) ir_expression(ir_binop_cross, type, op[0], op[1]);
880 } else if (strcmp(callee, "degrees") == 0) {
881 assert(op[0]->type->is_float());
882 for (unsigned c = 0; c < op[0]->type->components(); c++)
883 data.f[c] = 180.0/M_PI * op[0]->value.f[c];
884 } else if (strcmp(callee, "distance") == 0) {
885 assert(op[0]->type->is_float() && op[1]->type->is_float());
886 float length_squared = 0.0;
887 for (unsigned c = 0; c < op[0]->type->components(); c++) {
888 float t = op[0]->value.f[c] - op[1]->value.f[c];
889 length_squared += t * t;
890 }
891 return new(mem_ctx) ir_constant(sqrtf(length_squared));
892 } else if (strcmp(callee, "dot") == 0) {
893 return new(mem_ctx) ir_constant(dot(op[0], op[1]));
894 } else if (strcmp(callee, "equal") == 0) {
895 assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
896 for (unsigned c = 0; c < op[0]->type->components(); c++) {
897 switch (op[0]->type->base_type) {
898 case GLSL_TYPE_UINT:
899 data.b[c] = op[0]->value.u[c] == op[1]->value.u[c];
900 break;
901 case GLSL_TYPE_INT:
902 data.b[c] = op[0]->value.i[c] == op[1]->value.i[c];
903 break;
904 case GLSL_TYPE_FLOAT:
905 data.b[c] = op[0]->value.f[c] == op[1]->value.f[c];
906 break;
907 default:
908 assert(!"Should not get here.");
909 }
910 }
911 } else if (strcmp(callee, "exp") == 0) {
912 expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL);
913 } else if (strcmp(callee, "exp2") == 0) {
914 expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL);
915 } else if (strcmp(callee, "faceforward") == 0) {
916 if (dot(op[2], op[1]) < 0)
917 return op[0];
918 for (unsigned c = 0; c < op[0]->type->components(); c++)
919 data.f[c] = -op[0]->value.f[c];
920 } else if (strcmp(callee, "floor") == 0) {
921 expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL);
922 } else if (strcmp(callee, "fract") == 0) {
923 expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL);
924 } else if (strcmp(callee, "fwidth") == 0) {
925 return ir_constant::zero(mem_ctx, this->type);
926 } else if (strcmp(callee, "greaterThan") == 0) {
927 assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
928 for (unsigned c = 0; c < op[0]->type->components(); c++) {
929 switch (op[0]->type->base_type) {
930 case GLSL_TYPE_UINT:
931 data.b[c] = op[0]->value.u[c] > op[1]->value.u[c];
932 break;
933 case GLSL_TYPE_INT:
934 data.b[c] = op[0]->value.i[c] > op[1]->value.i[c];
935 break;
936 case GLSL_TYPE_FLOAT:
937 data.b[c] = op[0]->value.f[c] > op[1]->value.f[c];
938 break;
939 default:
940 assert(!"Should not get here.");
941 }
942 }
943 } else if (strcmp(callee, "greaterThanEqual") == 0) {
944 assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
945 for (unsigned c = 0; c < op[0]->type->components(); c++) {
946 switch (op[0]->type->base_type) {
947 case GLSL_TYPE_UINT:
948 data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c];
949 break;
950 case GLSL_TYPE_INT:
951 data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c];
952 break;
953 case GLSL_TYPE_FLOAT:
954 data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c];
955 break;
956 default:
957 assert(!"Should not get here.");
958 }
959 }
960 } else if (strcmp(callee, "inversesqrt") == 0) {
961 expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL);
962 } else if (strcmp(callee, "length") == 0) {
963 return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0])));
964 } else if (strcmp(callee, "lessThan") == 0) {
965 assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
966 for (unsigned c = 0; c < op[0]->type->components(); c++) {
967 switch (op[0]->type->base_type) {
968 case GLSL_TYPE_UINT:
969 data.b[c] = op[0]->value.u[c] < op[1]->value.u[c];
970 break;
971 case GLSL_TYPE_INT:
972 data.b[c] = op[0]->value.i[c] < op[1]->value.i[c];
973 break;
974 case GLSL_TYPE_FLOAT:
975 data.b[c] = op[0]->value.f[c] < op[1]->value.f[c];
976 break;
977 default:
978 assert(!"Should not get here.");
979 }
980 }
981 } else if (strcmp(callee, "lessThanEqual") == 0) {
982 assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
983 for (unsigned c = 0; c < op[0]->type->components(); c++) {
984 switch (op[0]->type->base_type) {
985 case GLSL_TYPE_UINT:
986 data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c];
987 break;
988 case GLSL_TYPE_INT:
989 data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c];
990 break;
991 case GLSL_TYPE_FLOAT:
992 data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c];
993 break;
994 default:
995 assert(!"Should not get here.");
996 }
997 }
998 } else if (strcmp(callee, "log") == 0) {
999 expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL);
1000 } else if (strcmp(callee, "log2") == 0) {
1001 expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL);
1002 } else if (strcmp(callee, "matrixCompMult") == 0) {
1003 assert(op[0]->type->is_float() && op[1]->type->is_float());
1004 for (unsigned c = 0; c < op[0]->type->components(); c++)
1005 data.f[c] = op[0]->value.f[c] * op[1]->value.f[c];
1006 } else if (strcmp(callee, "max") == 0) {
1007 expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]);
1008 } else if (strcmp(callee, "min") == 0) {
1009 expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]);
1010 } else if (strcmp(callee, "mix") == 0) {
1011 assert(op[0]->type->is_float() && op[1]->type->is_float());
1012 if (op[2]->type->is_float()) {
1013 unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
1014 unsigned components = op[0]->type->components();
1015 for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
1016 data.f[c] = op[0]->value.f[c] * (1 - op[2]->value.f[c2]) +
1017 op[1]->value.f[c] * op[2]->value.f[c2];
1018 }
1019 } else {
1020 assert(op[2]->type->is_boolean());
1021 for (unsigned c = 0; c < op[0]->type->components(); c++)
1022 data.f[c] = op[op[2]->value.b[c] ? 1 : 0]->value.f[c];
1023 }
1024 } else if (strcmp(callee, "mod") == 0) {
1025 expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]);
1026 } else if (strcmp(callee, "normalize") == 0) {
1027 assert(op[0]->type->is_float());
1028 float length = sqrtf(dot(op[0], op[0]));
1029
1030 if (length == 0)
1031 return ir_constant::zero(mem_ctx, this->type);
1032
1033 for (unsigned c = 0; c < op[0]->type->components(); c++)
1034 data.f[c] = op[0]->value.f[c] / length;
1035 } else if (strcmp(callee, "not") == 0) {
1036 expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL);
1037 } else if (strcmp(callee, "notEqual") == 0) {
1038 assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1039 for (unsigned c = 0; c < op[0]->type->components(); c++) {
1040 switch (op[0]->type->base_type) {
1041 case GLSL_TYPE_UINT:
1042 data.b[c] = op[0]->value.u[c] != op[1]->value.u[c];
1043 break;
1044 case GLSL_TYPE_INT:
1045 data.b[c] = op[0]->value.i[c] != op[1]->value.i[c];
1046 break;
1047 case GLSL_TYPE_FLOAT:
1048 data.b[c] = op[0]->value.f[c] != op[1]->value.f[c];
1049 break;
1050 default:
1051 assert(!"Should not get here.");
1052 }
1053 }
1054 } else if (strcmp(callee, "outerProduct") == 0) {
1055 assert(op[0]->type->is_vector() && op[1]->type->is_vector());
1056 const unsigned m = op[0]->type->vector_elements;
1057 const unsigned n = op[1]->type->vector_elements;
1058 for (unsigned j = 0; j < n; j++) {
1059 for (unsigned i = 0; i < m; i++) {
1060 data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j];
1061 }
1062 }
1063 } else if (strcmp(callee, "pow") == 0) {
1064 expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]);
1065 } else if (strcmp(callee, "radians") == 0) {
1066 assert(op[0]->type->is_float());
1067 for (unsigned c = 0; c < op[0]->type->components(); c++)
1068 data.f[c] = M_PI/180.0 * op[0]->value.f[c];
1069 } else if (strcmp(callee, "reflect") == 0) {
1070 assert(op[0]->type->is_float());
1071 float dot_NI = dot(op[1], op[0]);
1072 for (unsigned c = 0; c < op[0]->type->components(); c++)
1073 data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c];
1074 } else if (strcmp(callee, "refract") == 0) {
1075 const float eta = op[2]->value.f[0];
1076 const float dot_NI = dot(op[1], op[0]);
1077 const float k = 1.0 - eta * eta * (1.0 - dot_NI * dot_NI);
1078 if (k < 0.0) {
1079 return ir_constant::zero(mem_ctx, this->type);
1080 } else {
1081 for (unsigned c = 0; c < type->components(); c++) {
1082 data.f[c] = eta * op[0]->value.f[c] - (eta * dot_NI + sqrtf(k))
1083 * op[1]->value.f[c];
1084 }
1085 }
1086 } else if (strcmp(callee, "sign") == 0) {
1087 expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL);
1088 } else if (strcmp(callee, "sin") == 0) {
1089 expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL);
1090 } else if (strcmp(callee, "sinh") == 0) {
1091 assert(op[0]->type->is_float());
1092 for (unsigned c = 0; c < op[0]->type->components(); c++)
1093 data.f[c] = sinhf(op[0]->value.f[c]);
1094 } else if (strcmp(callee, "smoothstep") == 0) {
1095 assert(num_parameters == 3);
1096 assert(op[1]->type == op[0]->type);
1097 unsigned edge_inc = op[0]->type->is_scalar() ? 0 : 1;
1098 for (unsigned c = 0, e = 0; c < type->components(); e += edge_inc, c++) {
1099 const float edge0 = op[0]->value.f[e];
1100 const float edge1 = op[1]->value.f[e];
1101 if (edge0 == edge1) {
1102 data.f[c] = 0.0; /* Avoid a crash - results are undefined anyway */
1103 } else {
1104 const float numerator = op[2]->value.f[c] - edge0;
1105 const float denominator = edge1 - edge0;
1106 const float t = CLAMP(numerator/denominator, 0, 1);
1107 data.f[c] = t * t * (3 - 2 * t);
1108 }
1109 }
1110 } else if (strcmp(callee, "sqrt") == 0) {
1111 expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL);
1112 } else if (strcmp(callee, "step") == 0) {
1113 assert(op[0]->type->is_float() && op[1]->type->is_float());
1114 /* op[0] (edge) may be either a scalar or a vector */
1115 const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1;
1116 for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++)
1117 data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0 : 1.0;
1118 } else if (strcmp(callee, "tan") == 0) {
1119 assert(op[0]->type->is_float());
1120 for (unsigned c = 0; c < op[0]->type->components(); c++)
1121 data.f[c] = tanf(op[0]->value.f[c]);
1122 } else if (strcmp(callee, "tanh") == 0) {
1123 assert(op[0]->type->is_float());
1124 for (unsigned c = 0; c < op[0]->type->components(); c++)
1125 data.f[c] = tanhf(op[0]->value.f[c]);
1126 } else if (strcmp(callee, "transpose") == 0) {
1127 assert(op[0]->type->is_matrix());
1128 const unsigned n = op[0]->type->vector_elements;
1129 const unsigned m = op[0]->type->matrix_columns;
1130 for (unsigned j = 0; j < m; j++) {
1131 for (unsigned i = 0; i < n; i++) {
1132 data.f[m*i+j] += op[0]->value.f[i+n*j];
1133 }
1134 }
1135 } else {
1136 /* Unsupported builtin - some are not allowed in constant expressions. */
1137 return NULL;
1138 }
1139
1140 if (expr != NULL)
1141 return expr->constant_expression_value();
1142
1143 return new(mem_ctx) ir_constant(this->type, &data);
1144}
diff --git a/src/glsl/ir_constant_folding.cpp b/src/glsl/ir_constant_folding.cpp
new file mode 100644
index 00000000000..11260423d90
--- /dev/null
+++ b/src/glsl/ir_constant_folding.cpp
@@ -0,0 +1,273 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_constant_folding.cpp
26 * Replace constant-valued expressions with references to constant values.
27 */
28
29#include "ir.h"
30#include "ir_visitor.h"
31#include "ir_optimization.h"
32#include "glsl_types.h"
33
34/**
35 * Visitor class for replacing expressions with ir_constant values.
36 */
37
38class ir_constant_folding_visitor : public ir_visitor {
39public:
40 ir_constant_folding_visitor()
41 {
42 this->progress = false;
43 }
44
45 virtual ~ir_constant_folding_visitor()
46 {
47 /* empty */
48 }
49
50 /**
51 * \name Visit methods
52 *
53 * As typical for the visitor pattern, there must be one \c visit method for
54 * each concrete subclass of \c ir_instruction. Virtual base classes within
55 * the hierarchy should not have \c visit methods.
56 */
57 /*@{*/
58 virtual void visit(ir_variable *);
59 virtual void visit(ir_function_signature *);
60 virtual void visit(ir_function *);
61 virtual void visit(ir_expression *);
62 virtual void visit(ir_texture *);
63 virtual void visit(ir_swizzle *);
64 virtual void visit(ir_dereference_variable *);
65 virtual void visit(ir_dereference_array *);
66 virtual void visit(ir_dereference_record *);
67 virtual void visit(ir_assignment *);
68 virtual void visit(ir_constant *);
69 virtual void visit(ir_call *);
70 virtual void visit(ir_return *);
71 virtual void visit(ir_discard *);
72 virtual void visit(ir_if *);
73 virtual void visit(ir_loop *);
74 virtual void visit(ir_loop_jump *);
75 /*@}*/
76
77 void fold_constant(ir_rvalue **rvalue);
78
79 bool progress;
80};
81
82void
83ir_constant_folding_visitor::fold_constant(ir_rvalue **rvalue)
84{
85 if (*rvalue == NULL || (*rvalue)->ir_type == ir_type_constant)
86 return;
87
88 ir_constant *constant = (*rvalue)->constant_expression_value();
89 if (constant) {
90 *rvalue = constant;
91 this->progress = true;
92 } else {
93 (*rvalue)->accept(this);
94 }
95}
96
97void
98ir_constant_folding_visitor::visit(ir_variable *ir)
99{
100 (void) ir;
101}
102
103
104void
105ir_constant_folding_visitor::visit(ir_function_signature *ir)
106{
107 visit_exec_list(&ir->body, this);
108}
109
110
111void
112ir_constant_folding_visitor::visit(ir_function *ir)
113{
114 foreach_iter(exec_list_iterator, iter, *ir) {
115 ir_function_signature *const sig = (ir_function_signature *) iter.get();
116 sig->accept(this);
117 }
118}
119
120void
121ir_constant_folding_visitor::visit(ir_expression *ir)
122{
123 unsigned int operand;
124
125 for (operand = 0; operand < ir->get_num_operands(); operand++) {
126 fold_constant(&ir->operands[operand]);
127 }
128}
129
130
131void
132ir_constant_folding_visitor::visit(ir_texture *ir)
133{
134 fold_constant(&ir->coordinate);
135 fold_constant(&ir->projector);
136 fold_constant(&ir->shadow_comparitor);
137
138 switch (ir->op) {
139 case ir_tex:
140 break;
141 case ir_txb:
142 fold_constant(&ir->lod_info.bias);
143 break;
144 case ir_txf:
145 case ir_txl:
146 fold_constant(&ir->lod_info.lod);
147 break;
148 case ir_txd:
149 fold_constant(&ir->lod_info.grad.dPdx);
150 fold_constant(&ir->lod_info.grad.dPdy);
151 break;
152 }
153}
154
155
156void
157ir_constant_folding_visitor::visit(ir_swizzle *ir)
158{
159 fold_constant(&ir->val);
160}
161
162
163void
164ir_constant_folding_visitor::visit(ir_dereference_variable *ir)
165{
166 (void) ir;
167}
168
169
170void
171ir_constant_folding_visitor::visit(ir_dereference_array *ir)
172{
173 fold_constant(&ir->array_index);
174 ir->array->accept(this);
175}
176
177
178void
179ir_constant_folding_visitor::visit(ir_dereference_record *ir)
180{
181 ir->record->accept(this);
182}
183
184
185void
186ir_constant_folding_visitor::visit(ir_assignment *ir)
187{
188 fold_constant(&ir->rhs);
189
190 if (ir->condition) {
191 /* If the condition is constant, either remove the condition or
192 * remove the never-executed assignment.
193 */
194 ir_constant *const_val = ir->condition->constant_expression_value();
195 if (const_val) {
196 if (const_val->value.b[0])
197 ir->condition = NULL;
198 else
199 ir->remove();
200 this->progress = true;
201 }
202 }
203}
204
205
206void
207ir_constant_folding_visitor::visit(ir_constant *ir)
208{
209 (void) ir;
210}
211
212
213void
214ir_constant_folding_visitor::visit(ir_call *ir)
215{
216 foreach_iter(exec_list_iterator, iter, *ir) {
217 ir_rvalue *param = (ir_rvalue *)iter.get();
218 ir_rvalue *new_param = param;
219 fold_constant(&new_param);
220
221 if (new_param != param) {
222 param->replace_with(new_param);
223 }
224 }
225}
226
227
228void
229ir_constant_folding_visitor::visit(ir_return *ir)
230{
231 fold_constant(&ir->value);
232}
233
234
235void
236ir_constant_folding_visitor::visit(ir_discard *ir)
237{
238 (void) ir;
239}
240
241
242void
243ir_constant_folding_visitor::visit(ir_if *ir)
244{
245 fold_constant(&ir->condition);
246
247 visit_exec_list(&ir->then_instructions, this);
248 visit_exec_list(&ir->else_instructions, this);
249}
250
251
252void
253ir_constant_folding_visitor::visit(ir_loop *ir)
254{
255 (void) ir;
256}
257
258
259void
260ir_constant_folding_visitor::visit(ir_loop_jump *ir)
261{
262 (void) ir;
263}
264
265bool
266do_constant_folding(exec_list *instructions)
267{
268 ir_constant_folding_visitor constant_folding;
269
270 visit_exec_list(instructions, &constant_folding);
271
272 return constant_folding.progress;
273}
diff --git a/src/glsl/ir_constant_propagation.cpp b/src/glsl/ir_constant_propagation.cpp
new file mode 100644
index 00000000000..76c1ce7013f
--- /dev/null
+++ b/src/glsl/ir_constant_propagation.cpp
@@ -0,0 +1,435 @@
1/*
2 * Constantright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * constant of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, constant, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above constantright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR CONSTANTRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_constant_propagation.cpp
26 *
27 * Tracks assignments of constants to channels of variables, and
28 * usage of those constant channels with direct usage of the constants.
29 *
30 * This can lead to constant folding and algebraic optimizations in
31 * those later expressions, while causing no increase in instruction
32 * count (due to constants being generally free to load from a
33 * constant push buffer or as instruction immediate values) and
34 * possibly reducing register pressure.
35 */
36
37#include "ir.h"
38#include "ir_visitor.h"
39#include "ir_rvalue_visitor.h"
40#include "ir_basic_block.h"
41#include "ir_optimization.h"
42#include "glsl_types.h"
43
44class acp_entry : public exec_node
45{
46public:
47 acp_entry(ir_variable *var, unsigned write_mask, ir_constant *constant)
48 {
49 assert(var);
50 assert(constant);
51 this->var = var;
52 this->write_mask = write_mask;
53 this->constant = constant;
54 }
55
56 ir_variable *var;
57 ir_constant *constant;
58 unsigned write_mask;
59};
60
61
62class kill_entry : public exec_node
63{
64public:
65 kill_entry(ir_variable *var, unsigned write_mask)
66 {
67 assert(var);
68 this->var = var;
69 this->write_mask = write_mask;
70 }
71
72 ir_variable *var;
73 unsigned write_mask;
74};
75
76class ir_constant_propagation_visitor : public ir_rvalue_visitor {
77public:
78 ir_constant_propagation_visitor()
79 {
80 progress = false;
81 mem_ctx = talloc_new(0);
82 this->acp = new(mem_ctx) exec_list;
83 this->kills = new(mem_ctx) exec_list;
84 }
85 ~ir_constant_propagation_visitor()
86 {
87 talloc_free(mem_ctx);
88 }
89
90 virtual ir_visitor_status visit_enter(class ir_loop *);
91 virtual ir_visitor_status visit_enter(class ir_function_signature *);
92 virtual ir_visitor_status visit_enter(class ir_function *);
93 virtual ir_visitor_status visit_enter(class ir_assignment *);
94 virtual ir_visitor_status visit_enter(class ir_call *);
95 virtual ir_visitor_status visit_enter(class ir_if *);
96
97 void add_constant(ir_assignment *ir);
98 void kill(ir_variable *ir, unsigned write_mask);
99 void handle_if_block(exec_list *instructions);
100 void handle_rvalue(ir_rvalue **rvalue);
101
102 /** List of acp_entry: The available constants to propagate */
103 exec_list *acp;
104
105 /**
106 * List of kill_entry: The masks of variables whose values were
107 * killed in this block.
108 */
109 exec_list *kills;
110
111 bool progress;
112
113 bool killed_all;
114
115 void *mem_ctx;
116};
117
118
119void
120ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
121{
122 if (!*rvalue)
123 return;
124
125 const glsl_type *type = (*rvalue)->type;
126 if (!type->is_scalar() && !type->is_vector())
127 return;
128
129 ir_swizzle *swiz = NULL;
130 ir_dereference_variable *deref = (*rvalue)->as_dereference_variable();
131 if (!deref) {
132 swiz = (*rvalue)->as_swizzle();
133 if (!swiz)
134 return;
135
136 deref = swiz->val->as_dereference_variable();
137 if (!deref)
138 return;
139 }
140
141 ir_constant_data data;
142 memset(&data, 0, sizeof(data));
143
144 for (unsigned int i = 0; i < type->components(); i++) {
145 int channel;
146 acp_entry *found = NULL;
147
148 if (swiz) {
149 switch (i) {
150 case 0: channel = swiz->mask.x; break;
151 case 1: channel = swiz->mask.y; break;
152 case 2: channel = swiz->mask.z; break;
153 case 3: channel = swiz->mask.w; break;
154 default: assert(!"shouldn't be reached"); channel = 0; break;
155 }
156 } else {
157 channel = i;
158 }
159
160 foreach_iter(exec_list_iterator, iter, *this->acp) {
161 acp_entry *entry = (acp_entry *)iter.get();
162 if (entry->var == deref->var && entry->write_mask & (1 << channel)) {
163 found = entry;
164 break;
165 }
166 }
167
168 if (!found)
169 return;
170
171 switch (type->base_type) {
172 case GLSL_TYPE_FLOAT:
173 data.f[i] = found->constant->value.f[channel];
174 break;
175 case GLSL_TYPE_INT:
176 data.i[i] = found->constant->value.i[channel];
177 break;
178 case GLSL_TYPE_UINT:
179 data.u[i] = found->constant->value.u[channel];
180 break;
181 case GLSL_TYPE_BOOL:
182 data.b[i] = found->constant->value.b[channel];
183 break;
184 default:
185 assert(!"not reached");
186 break;
187 }
188 }
189
190 *rvalue = new(talloc_parent(deref)) ir_constant(type, &data);
191 this->progress = true;
192}
193
194ir_visitor_status
195ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir)
196{
197 /* Treat entry into a function signature as a completely separate
198 * block. Any instructions at global scope will be shuffled into
199 * main() at link time, so they're irrelevant to us.
200 */
201 exec_list *orig_acp = this->acp;
202 exec_list *orig_kills = this->kills;
203 bool orig_killed_all = this->killed_all;
204
205 this->acp = new(mem_ctx) exec_list;
206 this->kills = new(mem_ctx) exec_list;
207 this->killed_all = false;
208
209 visit_list_elements(this, &ir->body);
210
211 this->kills = orig_kills;
212 this->acp = orig_acp;
213 this->killed_all = orig_killed_all;
214
215 return visit_continue_with_parent;
216}
217
218ir_visitor_status
219ir_constant_propagation_visitor::visit_enter(ir_assignment *ir)
220{
221 /* Inline accepting children, skipping the LHS. */
222 ir->rhs->accept(this);
223 handle_rvalue(&ir->rhs);
224
225 if (ir->condition) {
226 ir->condition->accept(this);
227 handle_rvalue(&ir->condition);
228 }
229
230 kill(ir->lhs->variable_referenced(), ir->write_mask);
231
232 add_constant(ir);
233
234 return visit_continue_with_parent;
235}
236
237ir_visitor_status
238ir_constant_propagation_visitor::visit_enter(ir_function *ir)
239{
240 (void) ir;
241 return visit_continue;
242}
243
244ir_visitor_status
245ir_constant_propagation_visitor::visit_enter(ir_call *ir)
246{
247 /* Do constant propagation on call parameters, but skip any out params */
248 exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator();
249 foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
250 ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
251 ir_rvalue *param = (ir_rvalue *)iter.get();
252 if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) {
253 ir_rvalue *new_param = param;
254 handle_rvalue(&new_param);
255 if (new_param != param)
256 param->replace_with(new_param);
257 else
258 param->accept(this);
259 }
260 sig_param_iter.next();
261 }
262
263 /* Since we're unlinked, we don't (necssarily) know the side effects of
264 * this call. So kill all copies.
265 */
266 acp->make_empty();
267 this->killed_all = true;
268
269 return visit_continue_with_parent;
270}
271
272void
273ir_constant_propagation_visitor::handle_if_block(exec_list *instructions)
274{
275 exec_list *orig_acp = this->acp;
276 exec_list *orig_kills = this->kills;
277 bool orig_killed_all = this->killed_all;
278
279 this->acp = new(mem_ctx) exec_list;
280 this->kills = new(mem_ctx) exec_list;
281 this->killed_all = false;
282
283 /* Populate the initial acp with a constant of the original */
284 foreach_iter(exec_list_iterator, iter, *orig_acp) {
285 acp_entry *a = (acp_entry *)iter.get();
286 this->acp->push_tail(new(this->mem_ctx) acp_entry(a->var, a->write_mask,
287 a->constant));
288 }
289
290 visit_list_elements(this, instructions);
291
292 if (this->killed_all) {
293 orig_acp->make_empty();
294 }
295
296 exec_list *new_kills = this->kills;
297 this->kills = orig_kills;
298 this->acp = orig_acp;
299 this->killed_all = this->killed_all || orig_killed_all;
300
301 foreach_iter(exec_list_iterator, iter, *new_kills) {
302 kill_entry *k = (kill_entry *)iter.get();
303 kill(k->var, k->write_mask);
304 }
305}
306
307ir_visitor_status
308ir_constant_propagation_visitor::visit_enter(ir_if *ir)
309{
310 ir->condition->accept(this);
311 handle_rvalue(&ir->condition);
312
313 handle_if_block(&ir->then_instructions);
314 handle_if_block(&ir->else_instructions);
315
316 /* handle_if_block() already descended into the children. */
317 return visit_continue_with_parent;
318}
319
320ir_visitor_status
321ir_constant_propagation_visitor::visit_enter(ir_loop *ir)
322{
323 exec_list *orig_acp = this->acp;
324 exec_list *orig_kills = this->kills;
325 bool orig_killed_all = this->killed_all;
326
327 /* FINISHME: For now, the initial acp for loops is totally empty.
328 * We could go through once, then go through again with the acp
329 * cloned minus the killed entries after the first run through.
330 */
331 this->acp = new(mem_ctx) exec_list;
332 this->kills = new(mem_ctx) exec_list;
333 this->killed_all = false;
334
335 visit_list_elements(this, &ir->body_instructions);
336
337 if (this->killed_all) {
338 orig_acp->make_empty();
339 }
340
341 exec_list *new_kills = this->kills;
342 this->kills = orig_kills;
343 this->acp = orig_acp;
344 this->killed_all = this->killed_all || orig_killed_all;
345
346 foreach_iter(exec_list_iterator, iter, *new_kills) {
347 kill_entry *k = (kill_entry *)iter.get();
348 kill(k->var, k->write_mask);
349 }
350
351 /* already descended into the children. */
352 return visit_continue_with_parent;
353}
354
355void
356ir_constant_propagation_visitor::kill(ir_variable *var, unsigned write_mask)
357{
358 assert(var != NULL);
359
360 /* We don't track non-vectors. */
361 if (!var->type->is_vector() && !var->type->is_scalar())
362 return;
363
364 /* Remove any entries currently in the ACP for this kill. */
365 foreach_iter(exec_list_iterator, iter, *this->acp) {
366 acp_entry *entry = (acp_entry *)iter.get();
367
368 if (entry->var == var) {
369 entry->write_mask &= ~write_mask;
370 if (entry->write_mask == 0)
371 entry->remove();
372 }
373 }
374
375 /* Add this writemask of the variable to the list of killed
376 * variables in this block.
377 */
378 foreach_iter(exec_list_iterator, iter, *this->kills) {
379 kill_entry *entry = (kill_entry *)iter.get();
380
381 if (entry->var == var) {
382 entry->write_mask |= write_mask;
383 return;
384 }
385 }
386 /* Not already in the list. Make new entry. */
387 this->kills->push_tail(new(this->mem_ctx) kill_entry(var, write_mask));
388}
389
390/**
391 * Adds an entry to the available constant list if it's a plain assignment
392 * of a variable to a variable.
393 */
394void
395ir_constant_propagation_visitor::add_constant(ir_assignment *ir)
396{
397 acp_entry *entry;
398
399 if (ir->condition) {
400 ir_constant *condition = ir->condition->as_constant();
401 if (!condition || !condition->value.b[0])
402 return;
403 }
404
405 if (!ir->write_mask)
406 return;
407
408 ir_dereference_variable *deref = ir->lhs->as_dereference_variable();
409 ir_constant *constant = ir->rhs->as_constant();
410
411 if (!deref || !constant)
412 return;
413
414 /* Only do constant propagation on vectors. Constant matrices,
415 * arrays, or structures would require more work elsewhere.
416 */
417 if (!deref->var->type->is_vector() && !deref->var->type->is_scalar())
418 return;
419
420 entry = new(this->mem_ctx) acp_entry(deref->var, ir->write_mask, constant);
421 this->acp->push_tail(entry);
422}
423
424/**
425 * Does a constant propagation pass on the code present in the instruction stream.
426 */
427bool
428do_constant_propagation(exec_list *instructions)
429{
430 ir_constant_propagation_visitor v;
431
432 visit_list_elements(&v, instructions);
433
434 return v.progress;
435}
diff --git a/src/glsl/ir_constant_variable.cpp b/src/glsl/ir_constant_variable.cpp
new file mode 100644
index 00000000000..1fb73e765e1
--- /dev/null
+++ b/src/glsl/ir_constant_variable.cpp
@@ -0,0 +1,198 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_constant_variable.cpp
26 *
27 * Marks variables assigned a single constant value over the course
28 * of the program as constant.
29 *
30 * The goal here is to trigger further constant folding and then dead
31 * code elimination. This is common with vector/matrix constructors
32 * and calls to builtin functions.
33 */
34
35#include "ir.h"
36#include "ir_visitor.h"
37#include "ir_optimization.h"
38#include "glsl_types.h"
39
40struct assignment_entry {
41 exec_node link;
42 int assignment_count;
43 ir_variable *var;
44 ir_constant *constval;
45 bool our_scope;
46};
47
48class ir_constant_variable_visitor : public ir_hierarchical_visitor {
49public:
50 virtual ir_visitor_status visit_enter(ir_dereference_variable *);
51 virtual ir_visitor_status visit(ir_variable *);
52 virtual ir_visitor_status visit_enter(ir_assignment *);
53 virtual ir_visitor_status visit_enter(ir_call *);
54
55 exec_list list;
56};
57
58static struct assignment_entry *
59get_assignment_entry(ir_variable *var, exec_list *list)
60{
61 struct assignment_entry *entry;
62
63 foreach_list_typed(struct assignment_entry, entry, link, list) {
64 if (entry->var == var)
65 return entry;
66 }
67
68 entry = (struct assignment_entry *)calloc(1, sizeof(*entry));
69 entry->var = var;
70 list->push_head(&entry->link);
71 return entry;
72}
73
74ir_visitor_status
75ir_constant_variable_visitor::visit(ir_variable *ir)
76{
77 struct assignment_entry *entry = get_assignment_entry(ir, &this->list);
78 entry->our_scope = true;
79 return visit_continue;
80}
81
82/* Skip derefs of variables so that we can detect declarations. */
83ir_visitor_status
84ir_constant_variable_visitor::visit_enter(ir_dereference_variable *ir)
85{
86 (void)ir;
87 return visit_continue_with_parent;
88}
89
90ir_visitor_status
91ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
92{
93 ir_constant *constval;
94 struct assignment_entry *entry;
95
96 entry = get_assignment_entry(ir->lhs->variable_referenced(), &this->list);
97 assert(entry);
98 entry->assignment_count++;
99
100 /* If it's already constant, don't do the work. */
101 if (entry->var->constant_value)
102 return visit_continue;
103
104 /* OK, now find if we actually have all the right conditions for
105 * this to be a constant value assigned to the var.
106 */
107 if (ir->condition) {
108 constval = ir->condition->constant_expression_value();
109 if (!constval || !constval->value.b[0])
110 return visit_continue;
111 }
112
113 ir_variable *var = ir->whole_variable_written();
114 if (!var)
115 return visit_continue;
116
117 constval = ir->rhs->constant_expression_value();
118 if (!constval)
119 return visit_continue;
120
121 /* Mark this entry as having a constant assignment (if the
122 * assignment count doesn't go >1). do_constant_variable will fix
123 * up the variable with the constant value later.
124 */
125 entry->constval = constval;
126
127 return visit_continue;
128}
129
130ir_visitor_status
131ir_constant_variable_visitor::visit_enter(ir_call *ir)
132{
133 exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator();
134 foreach_iter(exec_list_iterator, iter, *ir) {
135 ir_rvalue *param_rval = (ir_rvalue *)iter.get();
136 ir_variable *param = (ir_variable *)sig_iter.get();
137
138 if (param->mode == ir_var_out ||
139 param->mode == ir_var_inout) {
140 ir_variable *var = param_rval->variable_referenced();
141 struct assignment_entry *entry;
142
143 assert(var);
144 entry = get_assignment_entry(var, &this->list);
145 entry->assignment_count++;
146 }
147 sig_iter.next();
148 }
149 return visit_continue;
150}
151
152/**
153 * Does a copy propagation pass on the code present in the instruction stream.
154 */
155bool
156do_constant_variable(exec_list *instructions)
157{
158 bool progress = false;
159 ir_constant_variable_visitor v;
160
161 v.run(instructions);
162
163 while (!v.list.is_empty()) {
164
165 struct assignment_entry *entry;
166 entry = exec_node_data(struct assignment_entry, v.list.head, link);
167
168 if (entry->assignment_count == 1 && entry->constval && entry->our_scope) {
169 entry->var->constant_value = entry->constval;
170 progress = true;
171 }
172 entry->link.remove();
173 free(entry);
174 }
175
176 return progress;
177}
178
179bool
180do_constant_variable_unlinked(exec_list *instructions)
181{
182 bool progress = false;
183
184 foreach_iter(exec_list_iterator, iter, *instructions) {
185 ir_instruction *ir = (ir_instruction *)iter.get();
186 ir_function *f = ir->as_function();
187 if (f) {
188 foreach_iter(exec_list_iterator, sigiter, *f) {
189 ir_function_signature *sig =
190 (ir_function_signature *) sigiter.get();
191 if (do_constant_variable(&sig->body))
192 progress = true;
193 }
194 }
195 }
196
197 return progress;
198}
diff --git a/src/glsl/ir_copy_propagation.cpp b/src/glsl/ir_copy_propagation.cpp
new file mode 100644
index 00000000000..6c211f0e70a
--- /dev/null
+++ b/src/glsl/ir_copy_propagation.cpp
@@ -0,0 +1,362 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_copy_propagation.cpp
26 *
27 * Moves usage of recently-copied variables to the previous copy of
28 * the variable.
29 *
30 * This should reduce the number of MOV instructions in the generated
31 * programs unless copy propagation is also done on the LIR, and may
32 * help anyway by triggering other optimizations that live in the HIR.
33 */
34
35#include "ir.h"
36#include "ir_visitor.h"
37#include "ir_basic_block.h"
38#include "ir_optimization.h"
39#include "glsl_types.h"
40
41class acp_entry : public exec_node
42{
43public:
44 acp_entry(ir_variable *lhs, ir_variable *rhs)
45 {
46 assert(lhs);
47 assert(rhs);
48 this->lhs = lhs;
49 this->rhs = rhs;
50 }
51
52 ir_variable *lhs;
53 ir_variable *rhs;
54};
55
56
57class kill_entry : public exec_node
58{
59public:
60 kill_entry(ir_variable *var)
61 {
62 assert(var);
63 this->var = var;
64 }
65
66 ir_variable *var;
67};
68
69class ir_copy_propagation_visitor : public ir_hierarchical_visitor {
70public:
71 ir_copy_propagation_visitor()
72 {
73 progress = false;
74 mem_ctx = talloc_new(0);
75 this->acp = new(mem_ctx) exec_list;
76 this->kills = new(mem_ctx) exec_list;
77 }
78 ~ir_copy_propagation_visitor()
79 {
80 talloc_free(mem_ctx);
81 }
82
83 virtual ir_visitor_status visit(class ir_dereference_variable *);
84 virtual ir_visitor_status visit_enter(class ir_loop *);
85 virtual ir_visitor_status visit_enter(class ir_function_signature *);
86 virtual ir_visitor_status visit_enter(class ir_function *);
87 virtual ir_visitor_status visit_enter(class ir_assignment *);
88 virtual ir_visitor_status visit_enter(class ir_call *);
89 virtual ir_visitor_status visit_enter(class ir_if *);
90
91 void add_copy(ir_assignment *ir);
92 void kill(ir_variable *ir);
93 void handle_if_block(exec_list *instructions);
94
95 /** List of acp_entry: The available copies to propagate */
96 exec_list *acp;
97 /**
98 * List of kill_entry: The variables whose values were killed in this
99 * block.
100 */
101 exec_list *kills;
102
103 bool progress;
104
105 bool killed_all;
106
107 void *mem_ctx;
108};
109
110ir_visitor_status
111ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir)
112{
113 /* Treat entry into a function signature as a completely separate
114 * block. Any instructions at global scope will be shuffled into
115 * main() at link time, so they're irrelevant to us.
116 */
117 exec_list *orig_acp = this->acp;
118 exec_list *orig_kills = this->kills;
119 bool orig_killed_all = this->killed_all;
120
121 this->acp = new(mem_ctx) exec_list;
122 this->kills = new(mem_ctx) exec_list;
123 this->killed_all = false;
124
125 visit_list_elements(this, &ir->body);
126
127 this->kills = orig_kills;
128 this->acp = orig_acp;
129 this->killed_all = orig_killed_all;
130
131 return visit_continue_with_parent;
132}
133
134ir_visitor_status
135ir_copy_propagation_visitor::visit_enter(ir_assignment *ir)
136{
137 ir_visitor_status s;
138
139 /* ir_assignment::accept(ir_hv *v), skipping the LHS so that we can
140 * avoid copy propagating into the LHS.
141 *
142 * Note that this means we won't copy propagate into the derefs of
143 * an array index. Oh well.
144 */
145
146 s = ir->rhs->accept(this);
147 assert(s == visit_continue);
148
149 if (ir->condition) {
150 s = ir->condition->accept(this);
151 assert(s == visit_continue);
152 }
153
154 kill(ir->lhs->variable_referenced());
155
156 add_copy(ir);
157
158 return visit_continue_with_parent;
159}
160
161ir_visitor_status
162ir_copy_propagation_visitor::visit_enter(ir_function *ir)
163{
164 (void) ir;
165 return visit_continue;
166}
167
168/**
169 * Replaces dereferences of ACP RHS variables with ACP LHS variables.
170 *
171 * This is where the actual copy propagation occurs. Note that the
172 * rewriting of ir_dereference means that the ir_dereference instance
173 * must not be shared by multiple IR operations!
174 */
175ir_visitor_status
176ir_copy_propagation_visitor::visit(ir_dereference_variable *ir)
177{
178 ir_variable *var = ir->var;
179
180 foreach_iter(exec_list_iterator, iter, *this->acp) {
181 acp_entry *entry = (acp_entry *)iter.get();
182
183 if (var == entry->lhs) {
184 ir->var = entry->rhs;
185 this->progress = true;
186 break;
187 }
188 }
189
190 return visit_continue;
191}
192
193
194ir_visitor_status
195ir_copy_propagation_visitor::visit_enter(ir_call *ir)
196{
197 /* Do copy propagation on call parameters, but skip any out params */
198 exec_list_iterator sig_param_iter = ir->get_callee()->parameters.iterator();
199 foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
200 ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
201 ir_instruction *ir = (ir_instruction *)iter.get();
202 if (sig_param->mode != ir_var_out && sig_param->mode != ir_var_inout) {
203 ir->accept(this);
204 }
205 sig_param_iter.next();
206 }
207
208 /* Since we're unlinked, we don't (necssarily) know the side effects of
209 * this call. So kill all copies.
210 */
211 acp->make_empty();
212 this->killed_all = true;
213
214 return visit_continue_with_parent;
215}
216
217void
218ir_copy_propagation_visitor::handle_if_block(exec_list *instructions)
219{
220 exec_list *orig_acp = this->acp;
221 exec_list *orig_kills = this->kills;
222 bool orig_killed_all = this->killed_all;
223
224 this->acp = new(mem_ctx) exec_list;
225 this->kills = new(mem_ctx) exec_list;
226 this->killed_all = false;
227
228 /* Populate the initial acp with a copy of the original */
229 foreach_iter(exec_list_iterator, iter, *orig_acp) {
230 acp_entry *a = (acp_entry *)iter.get();
231 this->acp->push_tail(new(this->mem_ctx) acp_entry(a->lhs, a->rhs));
232 }
233
234 visit_list_elements(this, instructions);
235
236 if (this->killed_all) {
237 orig_acp->make_empty();
238 }
239
240 exec_list *new_kills = this->kills;
241 this->kills = orig_kills;
242 this->acp = orig_acp;
243 this->killed_all = this->killed_all || orig_killed_all;
244
245 foreach_iter(exec_list_iterator, iter, *new_kills) {
246 kill_entry *k = (kill_entry *)iter.get();
247 kill(k->var);
248 }
249}
250
251ir_visitor_status
252ir_copy_propagation_visitor::visit_enter(ir_if *ir)
253{
254 ir->condition->accept(this);
255
256 handle_if_block(&ir->then_instructions);
257 handle_if_block(&ir->else_instructions);
258
259 /* handle_if_block() already descended into the children. */
260 return visit_continue_with_parent;
261}
262
263ir_visitor_status
264ir_copy_propagation_visitor::visit_enter(ir_loop *ir)
265{
266 exec_list *orig_acp = this->acp;
267 exec_list *orig_kills = this->kills;
268 bool orig_killed_all = this->killed_all;
269
270 /* FINISHME: For now, the initial acp for loops is totally empty.
271 * We could go through once, then go through again with the acp
272 * cloned minus the killed entries after the first run through.
273 */
274 this->acp = new(mem_ctx) exec_list;
275 this->kills = new(mem_ctx) exec_list;
276 this->killed_all = false;
277
278 visit_list_elements(this, &ir->body_instructions);
279
280 if (this->killed_all) {
281 orig_acp->make_empty();
282 }
283
284 exec_list *new_kills = this->kills;
285 this->kills = orig_kills;
286 this->acp = orig_acp;
287 this->killed_all = this->killed_all || orig_killed_all;
288
289 foreach_iter(exec_list_iterator, iter, *new_kills) {
290 kill_entry *k = (kill_entry *)iter.get();
291 kill(k->var);
292 }
293
294 /* already descended into the children. */
295 return visit_continue_with_parent;
296}
297
298void
299ir_copy_propagation_visitor::kill(ir_variable *var)
300{
301 assert(var != NULL);
302
303 /* Remove any entries currently in the ACP for this kill. */
304 foreach_iter(exec_list_iterator, iter, *acp) {
305 acp_entry *entry = (acp_entry *)iter.get();
306
307 if (entry->lhs == var || entry->rhs == var) {
308 entry->remove();
309 }
310 }
311
312 /* Add the LHS variable to the list of killed variables in this block.
313 */
314 this->kills->push_tail(new(this->mem_ctx) kill_entry(var));
315}
316
317/**
318 * Adds an entry to the available copy list if it's a plain assignment
319 * of a variable to a variable.
320 */
321void
322ir_copy_propagation_visitor::add_copy(ir_assignment *ir)
323{
324 acp_entry *entry;
325
326 if (ir->condition) {
327 ir_constant *condition = ir->condition->as_constant();
328 if (!condition || !condition->value.b[0])
329 return;
330 }
331
332 ir_variable *lhs_var = ir->whole_variable_written();
333 ir_variable *rhs_var = ir->rhs->whole_variable_referenced();
334
335 if ((lhs_var != NULL) && (rhs_var != NULL)) {
336 if (lhs_var == rhs_var) {
337 /* This is a dumb assignment, but we've conveniently noticed
338 * it here. Removing it now would mess up the loop iteration
339 * calling us. Just flag it to not execute, and someone else
340 * will clean up the mess.
341 */
342 ir->condition = new(talloc_parent(ir)) ir_constant(false);
343 this->progress = true;
344 } else {
345 entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var);
346 this->acp->push_tail(entry);
347 }
348 }
349}
350
351/**
352 * Does a copy propagation pass on the code present in the instruction stream.
353 */
354bool
355do_copy_propagation(exec_list *instructions)
356{
357 ir_copy_propagation_visitor v;
358
359 visit_list_elements(&v, instructions);
360
361 return v.progress;
362}
diff --git a/src/glsl/ir_dead_code.cpp b/src/glsl/ir_dead_code.cpp
new file mode 100644
index 00000000000..fce921262f4
--- /dev/null
+++ b/src/glsl/ir_dead_code.cpp
@@ -0,0 +1,135 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_dead_code.cpp
26 *
27 * Eliminates dead assignments and variable declarations from the code.
28 */
29
30#include "ir.h"
31#include "ir_visitor.h"
32#include "ir_variable_refcount.h"
33#include "glsl_types.h"
34
35static bool debug = false;
36
37/**
38 * Do a dead code pass over instructions and everything that instructions
39 * references.
40 *
41 * Note that this will remove assignments to globals, so it is not suitable
42 * for usage on an unlinked instruction stream.
43 */
44bool
45do_dead_code(exec_list *instructions)
46{
47 ir_variable_refcount_visitor v;
48 bool progress = false;
49
50 v.run(instructions);
51
52 foreach_iter(exec_list_iterator, iter, v.variable_list) {
53 variable_entry *entry = (variable_entry *)iter.get();
54
55 /* Since each assignment is a reference, the refereneced count must be
56 * greater than or equal to the assignment count. If they are equal,
57 * then all of the references are assignments, and the variable is
58 * dead.
59 *
60 * Note that if the variable is neither assigned nor referenced, both
61 * counts will be zero and will be caught by the equality test.
62 */
63 assert(entry->referenced_count >= entry->assigned_count);
64
65 if (debug) {
66 printf("%s@%p: %d refs, %d assigns, %sdeclared in our scope\n",
67 entry->var->name, (void *) entry->var,
68 entry->referenced_count, entry->assigned_count,
69 entry->declaration ? "" : "not ");
70 }
71
72 if ((entry->referenced_count > entry->assigned_count)
73 || !entry->declaration)
74 continue;
75
76 if (entry->assign) {
77 /* Remove a single dead assignment to the variable we found.
78 * Don't do so if it's a shader output, though.
79 */
80 if (entry->var->mode != ir_var_out &&
81 entry->var->mode != ir_var_inout &&
82 !ir_has_call(entry->assign)) {
83 entry->assign->remove();
84 progress = true;
85
86 if (debug) {
87 printf("Removed assignment to %s@%p\n",
88 entry->var->name, (void *) entry->var);
89 }
90 }
91 } else {
92 /* If there are no assignments or references to the variable left,
93 * then we can remove its declaration.
94 */
95 entry->var->remove();
96 progress = true;
97
98 if (debug) {
99 printf("Removed declaration of %s@%p\n",
100 entry->var->name, (void *) entry->var);
101 }
102 }
103 }
104 talloc_free(v.mem_ctx);
105
106 return progress;
107}
108
109/**
110 * Does a dead code pass on the functions present in the instruction stream.
111 *
112 * This is suitable for use while the program is not linked, as it will
113 * ignore variable declarations (and the assignments to them) for variables
114 * with global scope.
115 */
116bool
117do_dead_code_unlinked(exec_list *instructions)
118{
119 bool progress = false;
120
121 foreach_iter(exec_list_iterator, iter, *instructions) {
122 ir_instruction *ir = (ir_instruction *)iter.get();
123 ir_function *f = ir->as_function();
124 if (f) {
125 foreach_iter(exec_list_iterator, sigiter, *f) {
126 ir_function_signature *sig =
127 (ir_function_signature *) sigiter.get();
128 if (do_dead_code(&sig->body))
129 progress = true;
130 }
131 }
132 }
133
134 return progress;
135}
diff --git a/src/glsl/ir_dead_code_local.cpp b/src/glsl/ir_dead_code_local.cpp
new file mode 100644
index 00000000000..4bbedf0ff94
--- /dev/null
+++ b/src/glsl/ir_dead_code_local.cpp
@@ -0,0 +1,229 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_dead_code_local.cpp
26 *
27 * Eliminates local dead assignments from the code.
28 *
29 * This operates on basic blocks, tracking assignments and finding if
30 * they're used before the variable is completely reassigned.
31 *
32 * Compare this to ir_dead_code.cpp, which operates globally looking
33 * for assignments to variables that are never read.
34 */
35
36#include "ir.h"
37#include "ir_basic_block.h"
38#include "ir_optimization.h"
39#include "glsl_types.h"
40
41static bool debug = false;
42
43class assignment_entry : public exec_node
44{
45public:
46 assignment_entry(ir_variable *lhs, ir_instruction *ir)
47 {
48 assert(lhs);
49 assert(ir);
50 this->lhs = lhs;
51 this->ir = ir;
52 }
53
54 ir_variable *lhs;
55 ir_instruction *ir;
56};
57
58class kill_for_derefs_visitor : public ir_hierarchical_visitor {
59public:
60 kill_for_derefs_visitor(exec_list *assignments)
61 {
62 this->assignments = assignments;
63 }
64
65 virtual ir_visitor_status visit(ir_dereference_variable *ir)
66 {
67 ir_variable *const var = ir->variable_referenced();
68
69 foreach_iter(exec_list_iterator, iter, *this->assignments) {
70 assignment_entry *entry = (assignment_entry *)iter.get();
71
72 if (entry->lhs == var) {
73 if (debug)
74 printf("kill %s\n", entry->lhs->name);
75 entry->remove();
76 }
77 }
78
79 return visit_continue;
80 }
81
82private:
83 exec_list *assignments;
84};
85
86class array_index_visit : public ir_hierarchical_visitor {
87public:
88 array_index_visit(ir_hierarchical_visitor *v)
89 {
90 this->visitor = v;
91 }
92
93 virtual ir_visitor_status visit_enter(class ir_dereference_array *ir)
94 {
95 ir->array_index->accept(visitor);
96 return visit_continue;
97 }
98
99 static void run(ir_instruction *ir, ir_hierarchical_visitor *v)
100 {
101 array_index_visit top_visit(v);
102 ir->accept(& top_visit);
103 }
104
105 ir_hierarchical_visitor *visitor;
106};
107
108
109/**
110 * Adds an entry to the available copy list if it's a plain assignment
111 * of a variable to a variable.
112 */
113static bool
114process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
115{
116 ir_variable *var = NULL;
117 bool progress = false;
118 kill_for_derefs_visitor v(assignments);
119
120 /* Kill assignment entries for things used to produce this assignment. */
121 ir->rhs->accept(&v);
122 if (ir->condition) {
123 ir->condition->accept(&v);
124 }
125
126 /* Kill assignment enties used as array indices.
127 */
128 array_index_visit::run(ir->lhs, &v);
129 var = ir->lhs->variable_referenced();
130 assert(var);
131
132 bool always_assign = true;
133 if (ir->condition) {
134 ir_constant *condition = ir->condition->as_constant();
135 if (!condition || !condition->value.b[0])
136 always_assign = false;
137 }
138
139 /* Now, check if we did a whole-variable assignment. */
140 if (always_assign && (ir->whole_variable_written() != NULL)) {
141 /* We did a whole-variable assignment. So, any instruction in
142 * the assignment list with the same LHS is dead.
143 */
144 if (debug)
145 printf("looking for %s to remove\n", var->name);
146 foreach_iter(exec_list_iterator, iter, *assignments) {
147 assignment_entry *entry = (assignment_entry *)iter.get();
148
149 if (entry->lhs == var) {
150 if (debug)
151 printf("removing %s\n", var->name);
152 entry->ir->remove();
153 entry->remove();
154 progress = true;
155 }
156 }
157 }
158
159 /* Add this instruction to the assignment list available to be removed.
160 * But not if the assignment has other side effects.
161 */
162 if (ir_has_call(ir))
163 return progress;
164
165 assignment_entry *entry = new(ctx) assignment_entry(var, ir);
166 assignments->push_tail(entry);
167
168 if (debug) {
169 printf("add %s\n", var->name);
170
171 printf("current entries\n");
172 foreach_iter(exec_list_iterator, iter, *assignments) {
173 assignment_entry *entry = (assignment_entry *)iter.get();
174
175 printf(" %s\n", entry->lhs->name);
176 }
177 }
178
179 return progress;
180}
181
182static void
183dead_code_local_basic_block(ir_instruction *first,
184 ir_instruction *last,
185 void *data)
186{
187 ir_instruction *ir, *ir_next;
188 /* List of avaialble_copy */
189 exec_list assignments;
190 bool *out_progress = (bool *)data;
191 bool progress = false;
192
193 void *ctx = talloc_new(NULL);
194 /* Safe looping, since process_assignment */
195 for (ir = first, ir_next = (ir_instruction *)first->next;;
196 ir = ir_next, ir_next = (ir_instruction *)ir->next) {
197 ir_assignment *ir_assign = ir->as_assignment();
198
199 if (debug) {
200 ir->print();
201 printf("\n");
202 }
203
204 if (ir_assign) {
205 progress = process_assignment(ctx, ir_assign, &assignments) || progress;
206 } else {
207 kill_for_derefs_visitor kill(&assignments);
208 ir->accept(&kill);
209 }
210
211 if (ir == last)
212 break;
213 }
214 *out_progress = progress;
215 talloc_free(ctx);
216}
217
218/**
219 * Does a copy propagation pass on the code present in the instruction stream.
220 */
221bool
222do_dead_code_local(exec_list *instructions)
223{
224 bool progress = false;
225
226 call_for_basic_blocks(instructions, dead_code_local_basic_block, &progress);
227
228 return progress;
229}
diff --git a/src/glsl/ir_dead_functions.cpp b/src/glsl/ir_dead_functions.cpp
new file mode 100644
index 00000000000..26554441d3a
--- /dev/null
+++ b/src/glsl/ir_dead_functions.cpp
@@ -0,0 +1,151 @@
1 /*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 /**
25 * \file ir_dead_functions.cpp
26 *
27 * Eliminates unused functions from the linked program.
28 */
29
30 #include "ir.h"
31 #include "ir_visitor.h"
32 #include "ir_expression_flattening.h"
33 #include "glsl_types.h"
34
35 class signature_entry : public exec_node
36 {
37 public:
38 signature_entry(ir_function_signature *sig)
39 {
40 this->signature = sig;
41 this->used = false;
42 }
43
44 ir_function_signature *signature;
45 bool used;
46 };
47
48 class ir_dead_functions_visitor : public ir_hierarchical_visitor {
49 public:
50 ir_dead_functions_visitor()
51 {
52 this->mem_ctx = talloc_new(NULL);
53 }
54
55 ~ir_dead_functions_visitor()
56 {
57 talloc_free(this->mem_ctx);
58 }
59
60 virtual ir_visitor_status visit_enter(ir_function_signature *);
61 virtual ir_visitor_status visit_enter(ir_call *);
62
63 signature_entry *get_signature_entry(ir_function_signature *var);
64
65 bool (*predicate)(ir_instruction *ir);
66
67 /* List of signature_entry */
68 exec_list signature_list;
69 void *mem_ctx;
70 };
71
72
73 signature_entry *
74 ir_dead_functions_visitor::get_signature_entry(ir_function_signature *sig)
75 {
76 foreach_iter(exec_list_iterator, iter, this->signature_list) {
77 signature_entry *entry = (signature_entry *)iter.get();
78 if (entry->signature == sig)
79 return entry;
80 }
81
82 signature_entry *entry = new(mem_ctx) signature_entry(sig);
83 this->signature_list.push_tail(entry);
84 return entry;
85 }
86
87
88 ir_visitor_status
89 ir_dead_functions_visitor::visit_enter(ir_function_signature *ir)
90 {
91 signature_entry *entry = this->get_signature_entry(ir);
92
93 if (strcmp(ir->function_name(), "main") == 0) {
94 entry->used = true;
95 }
96
97 return visit_continue;
98 }
99
100
101 ir_visitor_status
102 ir_dead_functions_visitor::visit_enter(ir_call *ir)
103 {
104 signature_entry *entry = this->get_signature_entry(ir->get_callee());
105
106 entry->used = true;
107
108 return visit_continue;
109}
110
111bool
112do_dead_functions(exec_list *instructions)
113{
114 ir_dead_functions_visitor v;
115 bool progress = false;
116
117 visit_list_elements(&v, instructions);
118
119 /* Now that we've figured out which function signatures are used, remove
120 * the unused ones, and remove function definitions that have no more
121 * signatures.
122 */
123 foreach_iter(exec_list_iterator, iter, v.signature_list) {
124 signature_entry *entry = (signature_entry *)iter.get();
125
126 if (!entry->used) {
127 entry->signature->remove();
128 progress = true;
129 }
130 delete(entry);
131 }
132
133 /* We don't just do this above when we nuked a signature because of
134 * const pointers.
135 */
136 foreach_iter(exec_list_iterator, iter, *instructions) {
137 ir_instruction *ir = (ir_instruction *)iter.get();
138 ir_function *func = ir->as_function();
139
140 if (func && func->signatures.is_empty()) {
141 /* At this point (post-linking), the symbol table is no
142 * longer in use, so not removing the function from the
143 * symbol table should be OK.
144 */
145 func->remove();
146 progress = true;
147 }
148 }
149
150 return progress;
151}
diff --git a/src/glsl/ir_div_to_mul_rcp.cpp b/src/glsl/ir_div_to_mul_rcp.cpp
new file mode 100644
index 00000000000..640d5d64f98
--- /dev/null
+++ b/src/glsl/ir_div_to_mul_rcp.cpp
@@ -0,0 +1,115 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_div_to_mul_rcp.cpp
26 *
27 * Breaks an ir_unop_div expression down to op0 * (rcp(op1)).
28 *
29 * Many GPUs don't have a divide instruction (945 and 965 included),
30 * but they do have an RCP instruction to compute an approximate
31 * reciprocal. By breaking the operation down, constant reciprocals
32 * can get constant folded.
33 */
34
35#include "ir.h"
36#include "glsl_types.h"
37
38class ir_div_to_mul_rcp_visitor : public ir_hierarchical_visitor {
39public:
40 ir_div_to_mul_rcp_visitor()
41 {
42 this->made_progress = false;
43 }
44
45 ir_visitor_status visit_leave(ir_expression *);
46
47 bool made_progress;
48};
49
50bool
51do_div_to_mul_rcp(exec_list *instructions)
52{
53 ir_div_to_mul_rcp_visitor v;
54
55 visit_list_elements(&v, instructions);
56 return v.made_progress;
57}
58
59ir_visitor_status
60ir_div_to_mul_rcp_visitor::visit_leave(ir_expression *ir)
61{
62 if (ir->operation != ir_binop_div)
63 return visit_continue;
64
65 if (ir->operands[1]->type->base_type != GLSL_TYPE_INT &&
66 ir->operands[1]->type->base_type != GLSL_TYPE_UINT) {
67 /* New expression for the 1.0 / op1 */
68 ir_rvalue *expr;
69 expr = new(ir) ir_expression(ir_unop_rcp,
70 ir->operands[1]->type,
71 ir->operands[1],
72 NULL);
73
74 /* op0 / op1 -> op0 * (1.0 / op1) */
75 ir->operation = ir_binop_mul;
76 ir->operands[1] = expr;
77 } else {
78 /* Be careful with integer division -- we need to do it as a
79 * float and re-truncate, since rcp(n > 1) of an integer would
80 * just be 0.
81 */
82 ir_rvalue *op0, *op1;
83 const struct glsl_type *vec_type;
84
85 vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
86 ir->operands[1]->type->vector_elements,
87 ir->operands[1]->type->matrix_columns);
88
89 if (ir->operands[1]->type->base_type == GLSL_TYPE_INT)
90 op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL);
91 else
92 op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL);
93
94 op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL);
95
96 vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
97 ir->operands[0]->type->vector_elements,
98 ir->operands[0]->type->matrix_columns);
99
100 if (ir->operands[0]->type->base_type == GLSL_TYPE_INT)
101 op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL);
102 else
103 op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL);
104
105 op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
106
107 ir->operation = ir_unop_f2i;
108 ir->operands[0] = op0;
109 ir->operands[1] = NULL;
110 }
111
112 this->made_progress = true;
113
114 return visit_continue;
115}
diff --git a/src/glsl/ir_explog_to_explog2.cpp b/src/glsl/ir_explog_to_explog2.cpp
new file mode 100644
index 00000000000..4fe1daaee91
--- /dev/null
+++ b/src/glsl/ir_explog_to_explog2.cpp
@@ -0,0 +1,85 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_explog_to_explog2.cpp
26 *
27 * Many GPUs don't have a base e log or exponent instruction, but they
28 * do have base 2 versions, so this pass converts exp and log to exp2
29 * and log2 operations.
30 */
31
32#include <math.h>
33#include "ir.h"
34#include "glsl_types.h"
35
36class ir_explog_to_explog2_visitor : public ir_hierarchical_visitor {
37public:
38 ir_explog_to_explog2_visitor()
39 {
40 this->progress = false;
41 }
42
43 ir_visitor_status visit_leave(ir_expression *);
44
45 bool progress;
46};
47
48bool
49do_explog_to_explog2(exec_list *instructions)
50{
51 ir_explog_to_explog2_visitor v;
52
53 visit_list_elements(&v, instructions);
54 return v.progress;
55}
56
57ir_visitor_status
58ir_explog_to_explog2_visitor::visit_leave(ir_expression *ir)
59{
60 if (ir->operation == ir_unop_exp) {
61 void *mem_ctx = talloc_parent(ir);
62 ir_constant *log2_e = new(mem_ctx) ir_constant(log2f(M_E));
63
64 ir->operation = ir_unop_exp2;
65 ir->operands[0] = new(mem_ctx) ir_expression(ir_binop_mul,
66 ir->operands[0]->type,
67 ir->operands[0],
68 log2_e);
69 this->progress = true;
70 }
71
72 if (ir->operation == ir_unop_log) {
73 void *mem_ctx = talloc_parent(ir);
74
75 ir->operation = ir_binop_mul;
76 ir->operands[0] = new(mem_ctx) ir_expression(ir_unop_log2,
77 ir->operands[0]->type,
78 ir->operands[0],
79 NULL);
80 ir->operands[1] = new(mem_ctx) ir_constant(1.0f / log2f(M_E));
81 this->progress = true;
82 }
83
84 return visit_continue;
85}
diff --git a/src/glsl/ir_expression_flattening.cpp b/src/glsl/ir_expression_flattening.cpp
new file mode 100644
index 00000000000..ccb2e2bce9e
--- /dev/null
+++ b/src/glsl/ir_expression_flattening.cpp
@@ -0,0 +1,188 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_expression_flattening.cpp
26 *
27 * Takes the leaves of expression trees and makes them dereferences of
28 * assignments of the leaves to temporaries, according to a predicate.
29 *
30 * This is used for automatic function inlining, where we want to take
31 * an expression containing a call and move the call out to its own
32 * assignment so that we can inline it at the appropriate place in the
33 * instruction stream.
34 */
35
36#include "ir.h"
37#include "ir_visitor.h"
38#include "ir_expression_flattening.h"
39#include "glsl_types.h"
40
41class ir_expression_flattening_visitor : public ir_hierarchical_visitor {
42public:
43 ir_expression_flattening_visitor(ir_instruction *base_ir,
44 bool (*predicate)(ir_instruction *ir))
45 {
46 this->base_ir = base_ir;
47 this->predicate = predicate;
48 }
49
50 virtual ~ir_expression_flattening_visitor()
51 {
52 /* empty */
53 }
54
55 virtual ir_visitor_status visit_enter(ir_call *);
56 virtual ir_visitor_status visit_enter(ir_return *);
57 virtual ir_visitor_status visit_enter(ir_function_signature *);
58 virtual ir_visitor_status visit_enter(ir_if *);
59 virtual ir_visitor_status visit_enter(ir_loop *);
60 virtual ir_visitor_status visit_leave(ir_assignment *);
61 virtual ir_visitor_status visit_leave(ir_expression *);
62 virtual ir_visitor_status visit_leave(ir_swizzle *);
63
64 ir_rvalue *operand_to_temp(ir_rvalue *val);
65 bool (*predicate)(ir_instruction *ir);
66 ir_instruction *base_ir;
67};
68
69void
70do_expression_flattening(exec_list *instructions,
71 bool (*predicate)(ir_instruction *ir))
72{
73 foreach_iter(exec_list_iterator, iter, *instructions) {
74 ir_instruction *ir = (ir_instruction *)iter.get();
75
76 ir_expression_flattening_visitor v(ir, predicate);
77 ir->accept(&v);
78 }
79}
80
81
82ir_rvalue *
83ir_expression_flattening_visitor::operand_to_temp(ir_rvalue *ir)
84{
85 void *ctx = base_ir;
86 ir_variable *var;
87 ir_assignment *assign;
88
89 if (!this->predicate(ir))
90 return ir;
91
92 var = new(ctx) ir_variable(ir->type, "flattening_tmp", ir_var_temporary);
93 base_ir->insert_before(var);
94
95 assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var),
96 ir,
97 NULL);
98 base_ir->insert_before(assign);
99
100 return new(ctx) ir_dereference_variable(var);
101}
102
103ir_visitor_status
104ir_expression_flattening_visitor::visit_enter(ir_function_signature *ir)
105{
106 do_expression_flattening(&ir->body, this->predicate);
107
108 return visit_continue_with_parent;
109}
110
111ir_visitor_status
112ir_expression_flattening_visitor::visit_enter(ir_loop *ir)
113{
114 do_expression_flattening(&ir->body_instructions, this->predicate);
115
116 return visit_continue_with_parent;
117}
118
119ir_visitor_status
120ir_expression_flattening_visitor::visit_enter(ir_if *ir)
121{
122 ir->condition->accept(this);
123
124 do_expression_flattening(&ir->then_instructions, this->predicate);
125 do_expression_flattening(&ir->else_instructions, this->predicate);
126
127 return visit_continue_with_parent;
128}
129
130ir_visitor_status
131ir_expression_flattening_visitor::visit_leave(ir_expression *ir)
132{
133 unsigned int operand;
134
135 for (operand = 0; operand < ir->get_num_operands(); operand++) {
136 /* If the operand matches the predicate, then we'll assign its
137 * value to a temporary and deref the temporary as the operand.
138 */
139 ir->operands[operand] = operand_to_temp(ir->operands[operand]);
140 }
141
142 return visit_continue;
143}
144
145ir_visitor_status
146ir_expression_flattening_visitor::visit_leave(ir_assignment *ir)
147{
148 ir->rhs = operand_to_temp(ir->rhs);
149 if (ir->condition)
150 ir->condition = operand_to_temp(ir->condition);
151
152 return visit_continue;
153}
154
155ir_visitor_status
156ir_expression_flattening_visitor::visit_leave(ir_swizzle *ir)
157{
158 if (this->predicate(ir->val)) {
159 ir->val = operand_to_temp(ir->val);
160 }
161
162 return visit_continue;
163}
164
165ir_visitor_status
166ir_expression_flattening_visitor::visit_enter(ir_call *ir)
167{
168 /* Reminder: iterating ir_call iterates its parameters. */
169 foreach_iter(exec_list_iterator, iter, *ir) {
170 ir_rvalue *ir = (ir_rvalue *)iter.get();
171 ir_rvalue *new_ir = operand_to_temp(ir);
172
173 if (new_ir != ir) {
174 ir->replace_with(new_ir);
175 }
176 }
177
178 return visit_continue;
179}
180
181
182ir_visitor_status
183ir_expression_flattening_visitor::visit_enter(ir_return *ir)
184{
185 if (ir->value)
186 ir->value = operand_to_temp(ir->value);
187 return visit_continue;
188}
diff --git a/src/glsl/ir_expression_flattening.h b/src/glsl/ir_expression_flattening.h
new file mode 100644
index 00000000000..2eda1590001
--- /dev/null
+++ b/src/glsl/ir_expression_flattening.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24
25/**
26 * \file ir_expression_flattening.h
27 *
28 * Takes the leaves of expression trees and makes them dereferences of
29 * assignments of the leaves to temporaries, according to a predicate.
30 *
31 * This is used for automatic function inlining, where we want to take
32 * an expression containing a call and move the call out to its own
33 * assignment so that we can inline it at the appropriate place in the
34 * instruction stream.
35 */
36
37void do_expression_flattening(exec_list *instructions,
38 bool (*predicate)(ir_instruction *ir));
diff --git a/src/glsl/ir_function.cpp b/src/glsl/ir_function.cpp
new file mode 100644
index 00000000000..0a97e014244
--- /dev/null
+++ b/src/glsl/ir_function.cpp
@@ -0,0 +1,224 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "glsl_types.h"
25#include "ir.h"
26
27int
28type_compare(const glsl_type *a, const glsl_type *b)
29{
30 /* If the types are the same, they trivially match.
31 */
32 if (a == b)
33 return 0;
34
35 switch (a->base_type) {
36 case GLSL_TYPE_UINT:
37 case GLSL_TYPE_INT:
38 case GLSL_TYPE_BOOL:
39 /* There is no implicit conversion to or from integer types or bool.
40 */
41 if ((a->is_integer() != b->is_integer())
42 || (a->is_boolean() != b->is_boolean()))
43 return -1;
44
45 /* FALLTHROUGH */
46
47 case GLSL_TYPE_FLOAT:
48 if ((a->vector_elements != b->vector_elements)
49 || (a->matrix_columns != b->matrix_columns))
50 return -1;
51
52 return 1;
53
54 case GLSL_TYPE_SAMPLER:
55 case GLSL_TYPE_STRUCT:
56 /* Samplers and structures must match exactly.
57 */
58 return -1;
59
60 case GLSL_TYPE_ARRAY:
61 if ((b->base_type != GLSL_TYPE_ARRAY)
62 || (a->length != b->length))
63 return -1;
64
65 /* From GLSL 1.50 spec, page 27 (page 33 of the PDF):
66 * "There are no implicit array or structure conversions."
67 *
68 * If the comparison of the array element types detects that a conversion
69 * would be required, the array types do not match.
70 */
71 return (type_compare(a->fields.array, b->fields.array) == 0) ? 0 : -1;
72
73 case GLSL_TYPE_FUNCTION:
74 case GLSL_TYPE_VOID:
75 case GLSL_TYPE_ERROR:
76 default:
77 /* These are all error conditions. It is invalid for a parameter to
78 * a function to be declared as error, void, or a function.
79 */
80 return -1;
81 }
82
83 /* This point should be unreachable.
84 */
85 assert(0);
86}
87
88
89static int
90parameter_lists_match(const exec_list *list_a, const exec_list *list_b)
91{
92 const exec_node *node_a = list_a->head;
93 const exec_node *node_b = list_b->head;
94 int total_score = 0;
95
96 for (/* empty */
97 ; !node_a->is_tail_sentinel()
98 ; node_a = node_a->next, node_b = node_b->next) {
99 /* If all of the parameters from the other parameter list have been
100 * exhausted, the lists have different length and, by definition,
101 * do not match.
102 */
103 if (node_b->is_tail_sentinel())
104 return -1;
105
106
107 const ir_variable *const param = (ir_variable *) node_a;
108 const ir_instruction *const actual = (ir_instruction *) node_b;
109
110 /* Determine whether or not the types match. If the types are an
111 * exact match, the match score is zero. If the types don't match
112 * but the actual parameter can be coerced to the type of the declared
113 * parameter, the match score is one.
114 */
115 int score;
116 switch ((enum ir_variable_mode)(param->mode)) {
117 case ir_var_auto:
118 case ir_var_uniform:
119 case ir_var_temporary:
120 /* These are all error conditions. It is invalid for a parameter to
121 * a function to be declared as auto (not in, out, or inout) or
122 * as uniform.
123 */
124 assert(0);
125 return -1;
126
127 case ir_var_in:
128 score = type_compare(param->type, actual->type);
129 break;
130
131 case ir_var_out:
132 score = type_compare(actual->type, param->type);
133 break;
134
135 case ir_var_inout:
136 /* Since there are no bi-directional automatic conversions (e.g.,
137 * there is int -> float but no float -> int), inout parameters must
138 * be exact matches.
139 */
140 score = (type_compare(actual->type, param->type) == 0) ? 0 : -1;
141 break;
142 }
143
144 if (score < 0)
145 return -1;
146
147 total_score += score;
148 }
149
150 /* If all of the parameters from the other parameter list have been
151 * exhausted, the lists have different length and, by definition, do not
152 * match.
153 */
154 if (!node_b->is_tail_sentinel())
155 return -1;
156
157 return total_score;
158}
159
160
161ir_function_signature *
162ir_function::matching_signature(const exec_list *actual_parameters)
163{
164 ir_function_signature *match = NULL;
165
166 foreach_iter(exec_list_iterator, iter, signatures) {
167 ir_function_signature *const sig =
168 (ir_function_signature *) iter.get();
169
170 const int score = parameter_lists_match(& sig->parameters,
171 actual_parameters);
172
173 if (score == 0)
174 return sig;
175
176 if (score > 0) {
177 if (match != NULL)
178 return NULL;
179
180 match = sig;
181 }
182 }
183
184 return match;
185}
186
187
188static bool
189parameter_lists_match_exact(const exec_list *list_a, const exec_list *list_b)
190{
191 const exec_node *node_a = list_a->head;
192 const exec_node *node_b = list_b->head;
193
194 for (/* empty */
195 ; !node_a->is_tail_sentinel() && !node_b->is_tail_sentinel()
196 ; node_a = node_a->next, node_b = node_b->next) {
197 ir_variable *a = (ir_variable *) node_a;
198 ir_variable *b = (ir_variable *) node_b;
199
200 /* If the types of the parameters do not match, the parameters lists
201 * are different.
202 */
203 if (a->type != b->type)
204 return false;
205 }
206
207 /* Unless both lists are exhausted, they differ in length and, by
208 * definition, do not match.
209 */
210 return (node_a->is_tail_sentinel() == node_b->is_tail_sentinel());
211}
212
213ir_function_signature *
214ir_function::exact_matching_signature(const exec_list *actual_parameters)
215{
216 foreach_iter(exec_list_iterator, iter, signatures) {
217 ir_function_signature *const sig =
218 (ir_function_signature *) iter.get();
219
220 if (parameter_lists_match_exact(&sig->parameters, actual_parameters))
221 return sig;
222 }
223 return NULL;
224}
diff --git a/src/glsl/ir_function_can_inline.cpp b/src/glsl/ir_function_can_inline.cpp
new file mode 100644
index 00000000000..8bb8e0d9ed7
--- /dev/null
+++ b/src/glsl/ir_function_can_inline.cpp
@@ -0,0 +1,71 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_function_can_inline.cpp
26 *
27 * Determines if we can inline a function call using ir_function_inlining.cpp.
28 *
29 * The primary restriction is that we can't return from the function
30 * other than as the last instruction. We could potentially work
31 * around this for some constructs by flattening control flow and
32 * moving the return to the end, or by using breaks from a do {} while
33 * (0) loop surrounding the function body.
34 */
35
36#include "ir.h"
37
38class ir_function_can_inline_visitor : public ir_hierarchical_visitor {
39public:
40 ir_function_can_inline_visitor()
41 {
42 this->num_returns = 0;
43 }
44
45 virtual ir_visitor_status visit_enter(ir_return *);
46
47 int num_returns;
48};
49
50ir_visitor_status
51ir_function_can_inline_visitor::visit_enter(ir_return *ir)
52{
53 (void) ir;
54 this->num_returns++;
55 return visit_continue;
56}
57
58bool
59can_inline(ir_call *call)
60{
61 ir_function_can_inline_visitor v;
62 const ir_function_signature *callee = call->get_callee();
63
64 v.run((exec_list *) &callee->body);
65
66 ir_instruction *last = (ir_instruction *)callee->body.get_tail();
67 if (last && !last->as_return())
68 v.num_returns++;
69
70 return v.num_returns == 1;
71}
diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp
new file mode 100644
index 00000000000..874602c84f2
--- /dev/null
+++ b/src/glsl/ir_function_inlining.cpp
@@ -0,0 +1,417 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_function_inlining.cpp
26 *
27 * Replaces calls to functions with the body of the function.
28 */
29
30#include <inttypes.h>
31#include "ir.h"
32#include "ir_visitor.h"
33#include "ir_function_inlining.h"
34#include "ir_expression_flattening.h"
35#include "glsl_types.h"
36#include "program/hash_table.h"
37
38static void
39do_sampler_replacement(exec_list *instructions,
40 ir_variable *sampler,
41 ir_dereference *deref);
42
43class ir_function_inlining_visitor : public ir_hierarchical_visitor {
44public:
45 ir_function_inlining_visitor()
46 {
47 progress = false;
48 }
49
50 virtual ~ir_function_inlining_visitor()
51 {
52 /* empty */
53 }
54
55 virtual ir_visitor_status visit_enter(ir_expression *);
56 virtual ir_visitor_status visit_enter(ir_call *);
57 virtual ir_visitor_status visit_enter(ir_assignment *);
58 virtual ir_visitor_status visit_enter(ir_return *);
59 virtual ir_visitor_status visit_enter(ir_texture *);
60 virtual ir_visitor_status visit_enter(ir_swizzle *);
61
62 bool progress;
63};
64
65
66bool
67automatic_inlining_predicate(ir_instruction *ir)
68{
69 ir_call *call = ir->as_call();
70
71 if (call && can_inline(call))
72 return true;
73
74 return false;
75}
76
77bool
78do_function_inlining(exec_list *instructions)
79{
80 ir_function_inlining_visitor v;
81
82 do_expression_flattening(instructions, automatic_inlining_predicate);
83
84 v.run(instructions);
85
86 return v.progress;
87}
88
89static void
90replace_return_with_assignment(ir_instruction *ir, void *data)
91{
92 void *ctx = talloc_parent(ir);
93 ir_variable *retval = (ir_variable *)data;
94 ir_return *ret = ir->as_return();
95
96 if (ret) {
97 if (ret->value) {
98 ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval);
99 ret->replace_with(new(ctx) ir_assignment(lhs, ret->value, NULL));
100 } else {
101 /* un-valued return has to be the last return, or we shouldn't
102 * have reached here. (see can_inline()).
103 */
104 assert(ret->next->is_tail_sentinel());
105 ret->remove();
106 }
107 }
108}
109
110ir_rvalue *
111ir_call::generate_inline(ir_instruction *next_ir)
112{
113 void *ctx = talloc_parent(this);
114 ir_variable **parameters;
115 int num_parameters;
116 int i;
117 ir_variable *retval = NULL;
118 struct hash_table *ht;
119
120 ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare);
121
122 num_parameters = 0;
123 foreach_iter(exec_list_iterator, iter_sig, this->callee->parameters)
124 num_parameters++;
125
126 parameters = new ir_variable *[num_parameters];
127
128 /* Generate storage for the return value. */
129 if (this->callee->return_type) {
130 retval = new(ctx) ir_variable(this->callee->return_type, "_ret_val",
131 ir_var_auto);
132 next_ir->insert_before(retval);
133 }
134
135 /* Generate the declarations for the parameters to our inlined code,
136 * and set up the mapping of real function body variables to ours.
137 */
138 i = 0;
139 exec_list_iterator sig_param_iter = this->callee->parameters.iterator();
140 exec_list_iterator param_iter = this->actual_parameters.iterator();
141 for (i = 0; i < num_parameters; i++) {
142 ir_variable *sig_param = (ir_variable *) sig_param_iter.get();
143 ir_rvalue *param = (ir_rvalue *) param_iter.get();
144
145 /* Generate a new variable for the parameter. */
146 if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) {
147 /* For samplers, we want the inlined sampler references
148 * referencing the passed in sampler variable, since that
149 * will have the location information, which an assignment of
150 * a sampler wouldn't. Fix it up below.
151 */
152 parameters[i] = NULL;
153 } else {
154 parameters[i] = sig_param->clone(ctx, ht);
155 parameters[i]->mode = ir_var_auto;
156 next_ir->insert_before(parameters[i]);
157 }
158
159 /* Move the actual param into our param variable if it's an 'in' type. */
160 if (parameters[i] && (sig_param->mode == ir_var_in ||
161 sig_param->mode == ir_var_inout)) {
162 ir_assignment *assign;
163
164 assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]),
165 param, NULL);
166 next_ir->insert_before(assign);
167 }
168
169 sig_param_iter.next();
170 param_iter.next();
171 }
172
173 exec_list new_instructions;
174
175 /* Generate the inlined body of the function to a new list */
176 foreach_iter(exec_list_iterator, iter, callee->body) {
177 ir_instruction *ir = (ir_instruction *)iter.get();
178 ir_instruction *new_ir = ir->clone(ctx, ht);
179
180 new_instructions.push_tail(new_ir);
181 visit_tree(new_ir, replace_return_with_assignment, retval);
182 }
183
184 /* If any samplers were passed in, replace any deref of the sampler
185 * with a deref of the sampler argument.
186 */
187 param_iter = this->actual_parameters.iterator();
188 sig_param_iter = this->callee->parameters.iterator();
189 for (i = 0; i < num_parameters; i++) {
190 ir_instruction *const param = (ir_instruction *) param_iter.get();
191 ir_variable *sig_param = (ir_variable *) sig_param_iter.get();
192
193 if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) {
194 ir_dereference *deref = param->as_dereference();
195
196 assert(deref);
197 do_sampler_replacement(&new_instructions, sig_param, deref);
198 }
199 param_iter.next();
200 sig_param_iter.next();
201 }
202
203 /* Now push those new instructions in. */
204 foreach_iter(exec_list_iterator, iter, new_instructions) {
205 ir_instruction *ir = (ir_instruction *)iter.get();
206 next_ir->insert_before(ir);
207 }
208
209 /* Copy back the value of any 'out' parameters from the function body
210 * variables to our own.
211 */
212 i = 0;
213 param_iter = this->actual_parameters.iterator();
214 sig_param_iter = this->callee->parameters.iterator();
215 for (i = 0; i < num_parameters; i++) {
216 ir_instruction *const param = (ir_instruction *) param_iter.get();
217 const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get();
218
219 /* Move our param variable into the actual param if it's an 'out' type. */
220 if (parameters[i] && (sig_param->mode == ir_var_out ||
221 sig_param->mode == ir_var_inout)) {
222 ir_assignment *assign;
223
224 assign = new(ctx) ir_assignment(param->clone(ctx, NULL)->as_rvalue(),
225 new(ctx) ir_dereference_variable(parameters[i]),
226 NULL);
227 next_ir->insert_before(assign);
228 }
229
230 param_iter.next();
231 sig_param_iter.next();
232 }
233
234 delete [] parameters;
235
236 hash_table_dtor(ht);
237
238 if (retval)
239 return new(ctx) ir_dereference_variable(retval);
240 else
241 return NULL;
242}
243
244
245ir_visitor_status
246ir_function_inlining_visitor::visit_enter(ir_expression *ir)
247{
248 (void) ir;
249 return visit_continue_with_parent;
250}
251
252
253ir_visitor_status
254ir_function_inlining_visitor::visit_enter(ir_return *ir)
255{
256 (void) ir;
257 return visit_continue_with_parent;
258}
259
260
261ir_visitor_status
262ir_function_inlining_visitor::visit_enter(ir_texture *ir)
263{
264 (void) ir;
265 return visit_continue_with_parent;
266}
267
268
269ir_visitor_status
270ir_function_inlining_visitor::visit_enter(ir_swizzle *ir)
271{
272 (void) ir;
273 return visit_continue_with_parent;
274}
275
276
277ir_visitor_status
278ir_function_inlining_visitor::visit_enter(ir_call *ir)
279{
280 if (can_inline(ir)) {
281 /* If the call was part of some tree, then it should have been
282 * flattened out or we shouldn't have seen it because of a
283 * visit_continue_with_parent in this visitor.
284 */
285 assert(ir == base_ir);
286
287 (void) ir->generate_inline(ir);
288 ir->remove();
289 this->progress = true;
290 }
291
292 return visit_continue;
293}
294
295
296ir_visitor_status
297ir_function_inlining_visitor::visit_enter(ir_assignment *ir)
298{
299 ir_call *call = ir->rhs->as_call();
300 if (!call || !can_inline(call))
301 return visit_continue;
302
303 /* generates the parameter setup, function body, and returns the return
304 * value of the function
305 */
306 ir_rvalue *rhs = call->generate_inline(ir);
307 assert(rhs);
308
309 ir->rhs = rhs;
310 this->progress = true;
311
312 return visit_continue;
313}
314
315/**
316 * Replaces references to the "sampler" variable with a clone of "deref."
317 *
318 * From the spec, samplers can appear in the tree as function
319 * (non-out) parameters and as the result of array indexing and
320 * structure field selection. In our builtin implementation, they
321 * also appear in the sampler field of an ir_tex instruction.
322 */
323
324class ir_sampler_replacement_visitor : public ir_hierarchical_visitor {
325public:
326 ir_sampler_replacement_visitor(ir_variable *sampler, ir_dereference *deref)
327 {
328 this->sampler = sampler;
329 this->deref = deref;
330 }
331
332 virtual ~ir_sampler_replacement_visitor()
333 {
334 }
335
336 virtual ir_visitor_status visit_leave(ir_call *);
337 virtual ir_visitor_status visit_leave(ir_dereference_array *);
338 virtual ir_visitor_status visit_leave(ir_dereference_record *);
339 virtual ir_visitor_status visit_leave(ir_texture *);
340
341 void replace_deref(ir_dereference **deref);
342 void replace_rvalue(ir_rvalue **rvalue);
343
344 ir_variable *sampler;
345 ir_dereference *deref;
346};
347
348void
349ir_sampler_replacement_visitor::replace_deref(ir_dereference **deref)
350{
351 ir_dereference_variable *deref_var = (*deref)->as_dereference_variable();
352 if (deref_var && deref_var->var == this->sampler) {
353 *deref = this->deref->clone(talloc_parent(*deref), NULL);
354 }
355}
356
357void
358ir_sampler_replacement_visitor::replace_rvalue(ir_rvalue **rvalue)
359{
360 if (!*rvalue)
361 return;
362
363 ir_dereference *deref = (*rvalue)->as_dereference();
364
365 if (!deref)
366 return;
367
368 replace_deref(&deref);
369 *rvalue = deref;
370}
371
372ir_visitor_status
373ir_sampler_replacement_visitor::visit_leave(ir_texture *ir)
374{
375 replace_deref(&ir->sampler);
376
377 return visit_continue;
378}
379
380ir_visitor_status
381ir_sampler_replacement_visitor::visit_leave(ir_dereference_array *ir)
382{
383 replace_rvalue(&ir->array);
384 return visit_continue;
385}
386
387ir_visitor_status
388ir_sampler_replacement_visitor::visit_leave(ir_dereference_record *ir)
389{
390 replace_rvalue(&ir->record);
391 return visit_continue;
392}
393
394ir_visitor_status
395ir_sampler_replacement_visitor::visit_leave(ir_call *ir)
396{
397 foreach_iter(exec_list_iterator, iter, *ir) {
398 ir_rvalue *param = (ir_rvalue *)iter.get();
399 ir_rvalue *new_param = param;
400 replace_rvalue(&new_param);
401
402 if (new_param != param) {
403 param->replace_with(new_param);
404 }
405 }
406 return visit_continue;
407}
408
409static void
410do_sampler_replacement(exec_list *instructions,
411 ir_variable *sampler,
412 ir_dereference *deref)
413{
414 ir_sampler_replacement_visitor v(sampler, deref);
415
416 visit_list_elements(&v, instructions);
417}
diff --git a/src/glsl/ir_function_inlining.h b/src/glsl/ir_function_inlining.h
new file mode 100644
index 00000000000..6db011bbcae
--- /dev/null
+++ b/src/glsl/ir_function_inlining.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_function_inlining.h
26 *
27 * Replaces calls to functions with the body of the function.
28 */
29
30bool can_inline(ir_call *call);
diff --git a/src/glsl/ir_hierarchical_visitor.cpp b/src/glsl/ir_hierarchical_visitor.cpp
new file mode 100644
index 00000000000..d475df62fce
--- /dev/null
+++ b/src/glsl/ir_hierarchical_visitor.cpp
@@ -0,0 +1,295 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "ir.h"
25#include "ir_hierarchical_visitor.h"
26
27ir_hierarchical_visitor::ir_hierarchical_visitor()
28{
29 this->callback = NULL;
30 this->data = NULL;
31}
32
33ir_visitor_status
34ir_hierarchical_visitor::visit(ir_variable *ir)
35{
36 if (this->callback != NULL)
37 this->callback(ir, this->data);
38
39 return visit_continue;
40}
41
42ir_visitor_status
43ir_hierarchical_visitor::visit(ir_constant *ir)
44{
45 if (this->callback != NULL)
46 this->callback(ir, this->data);
47
48 return visit_continue;
49}
50
51ir_visitor_status
52ir_hierarchical_visitor::visit(ir_loop_jump *ir)
53{
54 if (this->callback != NULL)
55 this->callback(ir, this->data);
56
57 return visit_continue;
58}
59
60ir_visitor_status
61ir_hierarchical_visitor::visit(ir_dereference_variable *ir)
62{
63 if (this->callback != NULL)
64 this->callback(ir, this->data);
65
66 return visit_continue;
67}
68
69ir_visitor_status
70ir_hierarchical_visitor::visit_enter(ir_loop *ir)
71{
72 if (this->callback != NULL)
73 this->callback(ir, this->data);
74
75 return visit_continue;
76}
77
78ir_visitor_status
79ir_hierarchical_visitor::visit_leave(ir_loop *ir)
80{
81 (void) ir;
82 return visit_continue;
83}
84
85ir_visitor_status
86ir_hierarchical_visitor::visit_enter(ir_function_signature *ir)
87{
88 if (this->callback != NULL)
89 this->callback(ir, this->data);
90
91 return visit_continue;
92}
93
94ir_visitor_status
95ir_hierarchical_visitor::visit_leave(ir_function_signature *ir)
96{
97 (void) ir;
98 return visit_continue;
99}
100
101ir_visitor_status
102ir_hierarchical_visitor::visit_enter(ir_function *ir)
103{
104 if (this->callback != NULL)
105 this->callback(ir, this->data);
106
107 return visit_continue;
108}
109
110ir_visitor_status
111ir_hierarchical_visitor::visit_leave(ir_function *ir)
112{
113 (void) ir;
114 return visit_continue;
115}
116
117ir_visitor_status
118ir_hierarchical_visitor::visit_enter(ir_expression *ir)
119{
120 if (this->callback != NULL)
121 this->callback(ir, this->data);
122
123 return visit_continue;
124}
125
126ir_visitor_status
127ir_hierarchical_visitor::visit_leave(ir_expression *ir)
128{
129 (void) ir;
130 return visit_continue;
131}
132
133ir_visitor_status
134ir_hierarchical_visitor::visit_enter(ir_texture *ir)
135{
136 if (this->callback != NULL)
137 this->callback(ir, this->data);
138
139 return visit_continue;
140}
141
142ir_visitor_status
143ir_hierarchical_visitor::visit_leave(ir_texture *ir)
144{
145 (void) ir;
146 return visit_continue;
147}
148
149ir_visitor_status
150ir_hierarchical_visitor::visit_enter(ir_swizzle *ir)
151{
152 if (this->callback != NULL)
153 this->callback(ir, this->data);
154
155 return visit_continue;
156}
157
158ir_visitor_status
159ir_hierarchical_visitor::visit_leave(ir_swizzle *ir)
160{
161 (void) ir;
162 return visit_continue;
163}
164
165ir_visitor_status
166ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir)
167{
168 if (this->callback != NULL)
169 this->callback(ir, this->data);
170
171 return visit_continue;
172}
173
174ir_visitor_status
175ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir)
176{
177 (void) ir;
178 return visit_continue;
179}
180
181ir_visitor_status
182ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir)
183{
184 if (this->callback != NULL)
185 this->callback(ir, this->data);
186
187 return visit_continue;
188}
189
190ir_visitor_status
191ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir)
192{
193 (void) ir;
194 return visit_continue;
195}
196
197ir_visitor_status
198ir_hierarchical_visitor::visit_enter(ir_assignment *ir)
199{
200 if (this->callback != NULL)
201 this->callback(ir, this->data);
202
203 return visit_continue;
204}
205
206ir_visitor_status
207ir_hierarchical_visitor::visit_leave(ir_assignment *ir)
208{
209 (void) ir;
210 return visit_continue;
211}
212
213ir_visitor_status
214ir_hierarchical_visitor::visit_enter(ir_call *ir)
215{
216 if (this->callback != NULL)
217 this->callback(ir, this->data);
218
219 return visit_continue;
220}
221
222ir_visitor_status
223ir_hierarchical_visitor::visit_leave(ir_call *ir)
224{
225 (void) ir;
226 return visit_continue;
227}
228
229ir_visitor_status
230ir_hierarchical_visitor::visit_enter(ir_return *ir)
231{
232 if (this->callback != NULL)
233 this->callback(ir, this->data);
234
235 return visit_continue;
236}
237
238ir_visitor_status
239ir_hierarchical_visitor::visit_leave(ir_return *ir)
240{
241 (void) ir;
242 return visit_continue;
243}
244
245ir_visitor_status
246ir_hierarchical_visitor::visit_enter(ir_discard *ir)
247{
248 if (this->callback != NULL)
249 this->callback(ir, this->data);
250
251 return visit_continue;
252}
253
254ir_visitor_status
255ir_hierarchical_visitor::visit_leave(ir_discard *ir)
256{
257 (void) ir;
258 return visit_continue;
259}
260
261ir_visitor_status
262ir_hierarchical_visitor::visit_enter(ir_if *ir)
263{
264 if (this->callback != NULL)
265 this->callback(ir, this->data);
266
267 return visit_continue;
268}
269
270ir_visitor_status
271ir_hierarchical_visitor::visit_leave(ir_if *ir)
272{
273 (void) ir;
274 return visit_continue;
275}
276
277void
278ir_hierarchical_visitor::run(exec_list *instructions)
279{
280 visit_list_elements(this, instructions);
281}
282
283
284void
285visit_tree(ir_instruction *ir,
286 void (*callback)(class ir_instruction *ir, void *data),
287 void *data)
288{
289 ir_hierarchical_visitor v;
290
291 v.callback = callback;
292 v.data = data;
293
294 ir->accept(&v);
295}
diff --git a/src/glsl/ir_hierarchical_visitor.h b/src/glsl/ir_hierarchical_visitor.h
new file mode 100644
index 00000000000..afa780dc912
--- /dev/null
+++ b/src/glsl/ir_hierarchical_visitor.h
@@ -0,0 +1,176 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef IR_HIERARCHICAL_VISITOR_H
27#define IR_HIERARCHICAL_VISITOR_H
28
29/**
30 * Enumeration values returned by visit methods to guide processing
31 */
32enum ir_visitor_status {
33 visit_continue, /**< Continue visiting as normal. */
34 visit_continue_with_parent, /**< Don't visit siblings, continue w/parent. */
35 visit_stop /**< Stop visiting immediately. */
36};
37
38
39/**
40 * Base class of hierarchical visitors of IR instruction trees
41 *
42 * Hierarchical visitors differ from traditional visitors in a couple of
43 * important ways. Rather than having a single \c visit method for each
44 * subclass in the composite, there are three kinds of visit methods.
45 * Leaf-node classes have a traditional \c visit method. Internal-node
46 * classes have a \c visit_enter method, which is invoked just before
47 * processing child nodes, and a \c visit_leave method which is invoked just
48 * after processing child nodes.
49 *
50 * In addition, each visit method and the \c accept methods in the composite
51 * have a return value which guides the navigation. Any of the visit methods
52 * can choose to continue visiting the tree as normal (by returning \c
53 * visit_continue), terminate visiting any further nodes immediately (by
54 * returning \c visit_stop), or stop visiting sibling nodes (by returning \c
55 * visit_continue_with_parent).
56 *
57 * These two changes combine to allow nagivation of children to be implemented
58 * in the composite's \c accept method. The \c accept method for a leaf-node
59 * class will simply call the \c visit method, as usual, and pass its return
60 * value on. The \c accept method for internal-node classes will call the \c
61 * visit_enter method, call the \c accpet method of each child node, and,
62 * finally, call the \c visit_leave method. If any of these return a value
63 * other that \c visit_continue, the correct action must be taken.
64 *
65 * The final benefit is that the hierarchical visitor base class need not be
66 * abstract. Default implementations of every \c visit, \c visit_enter, and
67 * \c visit_leave method can be provided. By default each of these methods
68 * simply returns \c visit_continue. This allows a significant reduction in
69 * derived class code.
70 *
71 * For more information about hierarchical visitors, see:
72 *
73 * http://c2.com/cgi/wiki?HierarchicalVisitorPattern
74 * http://c2.com/cgi/wiki?HierarchicalVisitorDiscussion
75 */
76
77class ir_hierarchical_visitor {
78public:
79 ir_hierarchical_visitor();
80
81 /**
82 * \name Visit methods for leaf-node classes
83 */
84 /*@{*/
85 virtual ir_visitor_status visit(class ir_variable *);
86 virtual ir_visitor_status visit(class ir_constant *);
87 virtual ir_visitor_status visit(class ir_loop_jump *);
88
89 /**
90 * ir_dereference_variable isn't technically a leaf, but it is treated as a
91 * leaf here for a couple reasons. By not automatically visiting the one
92 * child ir_variable node from the ir_dereference_variable, ir_variable
93 * nodes can always be handled as variable declarations. Code that used
94 * non-hierarchical visitors had to set an "in a dereference" flag to
95 * determine how to handle an ir_variable. By forcing the visitor to
96 * handle the ir_variable within the ir_dereference_variable visitor, this
97 * kludge can be avoided.
98 *
99 * In addition, I can envision no use for having separate enter and leave
100 * methods. Anything that could be done in the enter and leave methods
101 * that couldn't just be done in the visit method.
102 */
103 virtual ir_visitor_status visit(class ir_dereference_variable *);
104 /*@}*/
105
106 /**
107 * \name Visit methods for internal-node classes
108 */
109 /*@{*/
110 virtual ir_visitor_status visit_enter(class ir_loop *);
111 virtual ir_visitor_status visit_leave(class ir_loop *);
112 virtual ir_visitor_status visit_enter(class ir_function_signature *);
113 virtual ir_visitor_status visit_leave(class ir_function_signature *);
114 virtual ir_visitor_status visit_enter(class ir_function *);
115 virtual ir_visitor_status visit_leave(class ir_function *);
116 virtual ir_visitor_status visit_enter(class ir_expression *);
117 virtual ir_visitor_status visit_leave(class ir_expression *);
118 virtual ir_visitor_status visit_enter(class ir_texture *);
119 virtual ir_visitor_status visit_leave(class ir_texture *);
120 virtual ir_visitor_status visit_enter(class ir_swizzle *);
121 virtual ir_visitor_status visit_leave(class ir_swizzle *);
122 virtual ir_visitor_status visit_enter(class ir_dereference_array *);
123 virtual ir_visitor_status visit_leave(class ir_dereference_array *);
124 virtual ir_visitor_status visit_enter(class ir_dereference_record *);
125 virtual ir_visitor_status visit_leave(class ir_dereference_record *);
126 virtual ir_visitor_status visit_enter(class ir_assignment *);
127 virtual ir_visitor_status visit_leave(class ir_assignment *);
128 virtual ir_visitor_status visit_enter(class ir_call *);
129 virtual ir_visitor_status visit_leave(class ir_call *);
130 virtual ir_visitor_status visit_enter(class ir_return *);
131 virtual ir_visitor_status visit_leave(class ir_return *);
132 virtual ir_visitor_status visit_enter(class ir_discard *);
133 virtual ir_visitor_status visit_leave(class ir_discard *);
134 virtual ir_visitor_status visit_enter(class ir_if *);
135 virtual ir_visitor_status visit_leave(class ir_if *);
136 /*@}*/
137
138
139 /**
140 * Utility function to process a linked list of instructions with a visitor
141 */
142 void run(struct exec_list *instructions);
143
144 /* Some visitors may need to insert new variable declarations and
145 * assignments for portions of a subtree, which means they need a
146 * pointer to the current instruction in the stream, not just their
147 * node in the tree rooted at that instruction.
148 *
149 * This is implemented by visit_list_elements -- if the visitor is
150 * not called by it, nothing good will happen.
151 */
152 class ir_instruction *base_ir;
153
154 /**
155 * Callback function that is invoked on entry to each node visited.
156 *
157 * \warning
158 * Visitor classes derived from \c ir_hierarchical_visitor \b may \b not
159 * invoke this function. This can be used, for example, to cause the
160 * callback to be invoked on every node type execpt one.
161 */
162 void (*callback)(class ir_instruction *ir, void *data);
163
164 /**
165 * Extra data parameter passed to the per-node callback function
166 */
167 void *data;
168};
169
170void visit_tree(ir_instruction *ir,
171 void (*callback)(class ir_instruction *ir, void *data),
172 void *data);
173
174ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l);
175
176#endif /* IR_HIERARCHICAL_VISITOR_H */
diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp
new file mode 100644
index 00000000000..6dae4ed2f3f
--- /dev/null
+++ b/src/glsl/ir_hv_accept.cpp
@@ -0,0 +1,369 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "ir.h"
25
26/**
27 * \file ir_hv_accept.cpp
28 * Implementations of all hierarchical visitor accept methods for IR
29 * instructions.
30 */
31
32/**
33 * Process a list of nodes using a hierarchical vistor
34 *
35 * \warning
36 * This function will operate correctly if a node being processed is removed
37 * from the list. However, if nodes are added to the list after the node being
38 * processed, some of the added nodes may not be processed.
39 */
40ir_visitor_status
41visit_list_elements(ir_hierarchical_visitor *v, exec_list *l)
42{
43 ir_instruction *prev_base_ir = v->base_ir;
44
45 foreach_list_safe(n, l) {
46 ir_instruction *const ir = (ir_instruction *) n;
47 v->base_ir = ir;
48 ir_visitor_status s = ir->accept(v);
49
50 if (s != visit_continue)
51 return s;
52 }
53 v->base_ir = prev_base_ir;
54
55 return visit_continue;
56}
57
58
59ir_visitor_status
60ir_variable::accept(ir_hierarchical_visitor *v)
61{
62 return v->visit(this);
63}
64
65
66ir_visitor_status
67ir_loop::accept(ir_hierarchical_visitor *v)
68{
69 ir_visitor_status s = v->visit_enter(this);
70
71 if (s != visit_continue)
72 return (s == visit_continue_with_parent) ? visit_continue : s;
73
74 s = visit_list_elements(v, &this->body_instructions);
75 if (s == visit_stop)
76 return s;
77
78 if (s != visit_continue_with_parent) {
79 if (this->from) {
80 s = this->from->accept(v);
81 if (s != visit_continue)
82 return (s == visit_continue_with_parent) ? visit_continue : s;
83 }
84
85 if (this->to) {
86 s = this->to->accept(v);
87 if (s != visit_continue)
88 return (s == visit_continue_with_parent) ? visit_continue : s;
89 }
90
91 if (this->increment) {
92 s = this->increment->accept(v);
93 if (s != visit_continue)
94 return (s == visit_continue_with_parent) ? visit_continue : s;
95 }
96 }
97
98 return v->visit_leave(this);
99}
100
101
102ir_visitor_status
103ir_loop_jump::accept(ir_hierarchical_visitor *v)
104{
105 return v->visit(this);
106}
107
108
109ir_visitor_status
110ir_function_signature::accept(ir_hierarchical_visitor *v)
111{
112 ir_visitor_status s = v->visit_enter(this);
113 if (s != visit_continue)
114 return (s == visit_continue_with_parent) ? visit_continue : s;
115
116 s = visit_list_elements(v, &this->parameters);
117 if (s == visit_stop)
118 return s;
119
120 s = visit_list_elements(v, &this->body);
121 return (s == visit_stop) ? s : v->visit_leave(this);
122}
123
124
125ir_visitor_status
126ir_function::accept(ir_hierarchical_visitor *v)
127{
128 ir_visitor_status s = v->visit_enter(this);
129 if (s != visit_continue)
130 return (s == visit_continue_with_parent) ? visit_continue : s;
131
132 s = visit_list_elements(v, &this->signatures);
133 return (s == visit_stop) ? s : v->visit_leave(this);
134}
135
136
137ir_visitor_status
138ir_expression::accept(ir_hierarchical_visitor *v)
139{
140 ir_visitor_status s = v->visit_enter(this);
141
142 if (s != visit_continue)
143 return (s == visit_continue_with_parent) ? visit_continue : s;
144
145 for (unsigned i = 0; i < this->get_num_operands(); i++) {
146 switch (this->operands[i]->accept(v)) {
147 case visit_continue:
148 break;
149
150 case visit_continue_with_parent:
151 // I wish for Java's labeled break-statement here.
152 goto done;
153
154 case visit_stop:
155 return s;
156 }
157 }
158
159done:
160 return v->visit_leave(this);
161}
162
163ir_visitor_status
164ir_texture::accept(ir_hierarchical_visitor *v)
165{
166 ir_visitor_status s = v->visit_enter(this);
167 if (s != visit_continue)
168 return (s == visit_continue_with_parent) ? visit_continue : s;
169
170 s = this->sampler->accept(v);
171 if (s != visit_continue)
172 return (s == visit_continue_with_parent) ? visit_continue : s;
173
174 s = this->coordinate->accept(v);
175 if (s != visit_continue)
176 return (s == visit_continue_with_parent) ? visit_continue : s;
177
178 if (this->projector) {
179 s = this->projector->accept(v);
180 if (s != visit_continue)
181 return (s == visit_continue_with_parent) ? visit_continue : s;
182 }
183
184 if (this->shadow_comparitor) {
185 s = this->shadow_comparitor->accept(v);
186 if (s != visit_continue)
187 return (s == visit_continue_with_parent) ? visit_continue : s;
188 }
189
190 switch (this->op) {
191 case ir_tex:
192 break;
193 case ir_txb:
194 s = this->lod_info.bias->accept(v);
195 if (s != visit_continue)
196 return (s == visit_continue_with_parent) ? visit_continue : s;
197 break;
198 case ir_txl:
199 case ir_txf:
200 s = this->lod_info.lod->accept(v);
201 if (s != visit_continue)
202 return (s == visit_continue_with_parent) ? visit_continue : s;
203 break;
204 case ir_txd:
205 s = this->lod_info.grad.dPdx->accept(v);
206 if (s != visit_continue)
207 return (s == visit_continue_with_parent) ? visit_continue : s;
208
209 s = this->lod_info.grad.dPdy->accept(v);
210 if (s != visit_continue)
211 return (s == visit_continue_with_parent) ? visit_continue : s;
212 break;
213 }
214
215 return (s == visit_stop) ? s : v->visit_leave(this);
216}
217
218
219ir_visitor_status
220ir_swizzle::accept(ir_hierarchical_visitor *v)
221{
222 ir_visitor_status s = v->visit_enter(this);
223 if (s != visit_continue)
224 return (s == visit_continue_with_parent) ? visit_continue : s;
225
226 s = this->val->accept(v);
227 return (s == visit_stop) ? s : v->visit_leave(this);
228}
229
230
231ir_visitor_status
232ir_dereference_variable::accept(ir_hierarchical_visitor *v)
233{
234 return v->visit(this);
235}
236
237
238ir_visitor_status
239ir_dereference_array::accept(ir_hierarchical_visitor *v)
240{
241 ir_visitor_status s = v->visit_enter(this);
242 if (s != visit_continue)
243 return (s == visit_continue_with_parent) ? visit_continue : s;
244
245 s = this->array_index->accept(v);
246 if (s != visit_continue)
247 return (s == visit_continue_with_parent) ? visit_continue : s;
248
249 s = this->array->accept(v);
250 return (s == visit_stop) ? s : v->visit_leave(this);
251}
252
253
254ir_visitor_status
255ir_dereference_record::accept(ir_hierarchical_visitor *v)
256{
257 ir_visitor_status s = v->visit_enter(this);
258 if (s != visit_continue)
259 return (s == visit_continue_with_parent) ? visit_continue : s;
260
261 s = this->record->accept(v);
262 return (s == visit_stop) ? s : v->visit_leave(this);
263}
264
265
266ir_visitor_status
267ir_assignment::accept(ir_hierarchical_visitor *v)
268{
269 ir_visitor_status s = v->visit_enter(this);
270 if (s != visit_continue)
271 return (s == visit_continue_with_parent) ? visit_continue : s;
272
273 s = this->lhs->accept(v);
274 if (s != visit_continue)
275 return (s == visit_continue_with_parent) ? visit_continue : s;
276
277 s = this->rhs->accept(v);
278 if (s != visit_continue)
279 return (s == visit_continue_with_parent) ? visit_continue : s;
280
281 if (this->condition)
282 s = this->condition->accept(v);
283
284 return (s == visit_stop) ? s : v->visit_leave(this);
285}
286
287
288ir_visitor_status
289ir_constant::accept(ir_hierarchical_visitor *v)
290{
291 return v->visit(this);
292}
293
294
295ir_visitor_status
296ir_call::accept(ir_hierarchical_visitor *v)
297{
298 ir_visitor_status s = v->visit_enter(this);
299 if (s != visit_continue)
300 return (s == visit_continue_with_parent) ? visit_continue : s;
301
302 s = visit_list_elements(v, &this->actual_parameters);
303 if (s == visit_stop)
304 return s;
305
306 return v->visit_leave(this);
307}
308
309
310ir_visitor_status
311ir_return::accept(ir_hierarchical_visitor *v)
312{
313 ir_visitor_status s = v->visit_enter(this);
314 if (s != visit_continue)
315 return (s == visit_continue_with_parent) ? visit_continue : s;
316
317 ir_rvalue *val = this->get_value();
318 if (val) {
319 s = val->accept(v);
320 if (s != visit_continue)
321 return (s == visit_continue_with_parent) ? visit_continue : s;
322 }
323
324 return v->visit_leave(this);
325}
326
327
328ir_visitor_status
329ir_discard::accept(ir_hierarchical_visitor *v)
330{
331 ir_visitor_status s = v->visit_enter(this);
332 if (s != visit_continue)
333 return (s == visit_continue_with_parent) ? visit_continue : s;
334
335 if (this->condition != NULL) {
336 s = this->condition->accept(v);
337 if (s != visit_continue)
338 return (s == visit_continue_with_parent) ? visit_continue : s;
339 }
340
341 return v->visit_leave(this);
342}
343
344
345ir_visitor_status
346ir_if::accept(ir_hierarchical_visitor *v)
347{
348 ir_visitor_status s = v->visit_enter(this);
349 if (s != visit_continue)
350 return (s == visit_continue_with_parent) ? visit_continue : s;
351
352 s = this->condition->accept(v);
353 if (s != visit_continue)
354 return (s == visit_continue_with_parent) ? visit_continue : s;
355
356 if (s != visit_continue_with_parent) {
357 s = visit_list_elements(v, &this->then_instructions);
358 if (s == visit_stop)
359 return s;
360 }
361
362 if (s != visit_continue_with_parent) {
363 s = visit_list_elements(v, &this->else_instructions);
364 if (s == visit_stop)
365 return s;
366 }
367
368 return v->visit_leave(this);
369}
diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp
new file mode 100644
index 00000000000..5ab8759958f
--- /dev/null
+++ b/src/glsl/ir_if_return.cpp
@@ -0,0 +1,246 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_if_return.cpp
26 *
27 * This pass tries to normalize functions to always return from one
28 * place by moving around blocks of code in if statements.
29 *
30 * This helps on hardware with no branching support, and may even be a
31 * useful transform on hardware supporting control flow by turning
32 * masked returns into normal returns.
33 */
34
35#include <string.h>
36#include "glsl_types.h"
37#include "ir.h"
38
39class ir_if_return_visitor : public ir_hierarchical_visitor {
40public:
41 ir_if_return_visitor()
42 {
43 this->progress = false;
44 }
45
46 ir_visitor_status visit_enter(ir_function_signature *);
47 ir_visitor_status visit_leave(ir_if *);
48
49 ir_visitor_status move_outer_block_inside(ir_instruction *ir,
50 exec_list *inner_block);
51 void move_returns_after_block(ir_instruction *ir,
52 ir_return *then_return,
53 ir_return *else_return);
54 bool progress;
55};
56
57bool
58do_if_return(exec_list *instructions)
59{
60 ir_if_return_visitor v;
61
62 do {
63 v.progress = false;
64 visit_list_elements(&v, instructions);
65 } while (v.progress);
66
67 return v.progress;
68}
69
70/**
71 * Removes any instructions after a (unconditional) return, since they will
72 * never be executed.
73 */
74static void
75truncate_after_instruction(ir_instruction *ir)
76{
77 if (!ir)
78 return;
79
80 while (!ir->get_next()->is_tail_sentinel())
81 ((ir_instruction *)ir->get_next())->remove();
82}
83
84/**
85 * Returns an ir_instruction of the first ir_return in the exec_list, or NULL.
86 */
87static ir_return *
88find_return_in_block(exec_list *instructions)
89{
90 foreach_iter(exec_list_iterator, iter, *instructions) {
91 ir_instruction *ir = (ir_instruction *)iter.get();
92 if (ir->ir_type == ir_type_return)
93 return (ir_return *)ir;
94 }
95
96 return NULL;
97}
98
99void
100ir_if_return_visitor::move_returns_after_block(ir_instruction *ir,
101 ir_return *then_return,
102 ir_return *else_return)
103{
104
105 if (!then_return->value) {
106 then_return->remove();
107 else_return->remove();
108 ir->insert_after(new(ir) ir_return(NULL));
109 } else {
110 ir_assignment *assign;
111 ir_variable *new_var = new(ir) ir_variable(then_return->value->type,
112 "if_return_tmp",
113 ir_var_temporary);
114 ir->insert_before(new_var);
115
116 assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(new_var),
117 then_return->value, NULL);
118 then_return->replace_with(assign);
119
120 assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(new_var),
121 else_return->value, NULL);
122 else_return->replace_with(assign);
123
124 ir_dereference_variable *deref = new(ir) ir_dereference_variable(new_var);
125 ir->insert_after(new(ir) ir_return(deref));
126 }
127 this->progress = true;
128}
129
130ir_visitor_status
131ir_if_return_visitor::move_outer_block_inside(ir_instruction *ir,
132 exec_list *inner_block)
133{
134 if (!ir->get_next()->is_tail_sentinel()) {
135 while (!ir->get_next()->is_tail_sentinel()) {
136 ir_instruction *move_ir = (ir_instruction *)ir->get_next();
137
138 move_ir->remove();
139 inner_block->push_tail(move_ir);
140 }
141
142 /* If we move the instructions following ir inside the block, it
143 * will confuse the exec_list iteration in the parent that visited
144 * us. So stop the visit at this point.
145 */
146 return visit_stop;
147 } else {
148 return visit_continue;
149 }
150}
151
152/* Normalize a function to always have a return statement at the end.
153 *
154 * This avoids the ir_if handler needing to know whether it is at the
155 * top level of the function to know if there's an implicit return at
156 * the end of the outer block.
157 */
158ir_visitor_status
159ir_if_return_visitor::visit_enter(ir_function_signature *ir)
160{
161 ir_return *ret;
162
163 if (!ir->is_defined)
164 return visit_continue_with_parent;
165 if (strcmp(ir->function_name(), "main") == 0)
166 return visit_continue_with_parent;
167
168 ret = find_return_in_block(&ir->body);
169
170 if (ret) {
171 truncate_after_instruction(ret);
172 } else {
173 if (ir->return_type->is_void()) {
174 ir->body.push_tail(new(ir) ir_return(NULL));
175 } else {
176 /* Probably, if we've got a function with a return value
177 * hitting this point, it's something like:
178 *
179 * float reduce_below_half(float val)
180 * {
181 * while () {
182 * if (val >= 0.5)
183 * val /= 2.0;
184 * else
185 * return val;
186 * }
187 * }
188 *
189 * So we gain a junk return statement of an undefined value
190 * at the end that never gets executed. However, a backend
191 * using this pass is probably desperate to get rid of
192 * function calls, so go ahead and do it for their sake in
193 * case it fixes apps.
194 */
195 ir_variable *undef = new(ir) ir_variable(ir->return_type,
196 "if_return_undef",
197 ir_var_temporary);
198 ir->body.push_tail(undef);
199
200 ir_dereference_variable *deref = new(ir) ir_dereference_variable(undef);
201 ir->body.push_tail(new(ir) ir_return(deref));
202 }
203 }
204
205 return visit_continue;
206}
207
208ir_visitor_status
209ir_if_return_visitor::visit_leave(ir_if *ir)
210{
211 ir_return *then_return;
212 ir_return *else_return;
213
214 then_return = find_return_in_block(&ir->then_instructions);
215 else_return = find_return_in_block(&ir->else_instructions);
216 if (!then_return && !else_return)
217 return visit_continue;
218
219 /* Trim off any trailing instructions after the return statements
220 * on both sides.
221 */
222 truncate_after_instruction(then_return);
223 truncate_after_instruction(else_return);
224
225 /* If both sides return, then we can move the returns to a single
226 * one outside the if statement.
227 */
228 if (then_return && else_return) {
229 move_returns_after_block(ir, then_return, else_return);
230 return visit_continue;
231 }
232
233 /* If only one side returns, then the block of code after the "if"
234 * is only executed by the other side, so those instructions don't
235 * need to be anywhere but that other side.
236 *
237 * This will usually pull a return statement up into the other
238 * side, so we'll trigger the above case on the next pass.
239 */
240 if (then_return) {
241 return move_outer_block_inside(ir, &ir->else_instructions);
242 } else {
243 assert(else_return);
244 return move_outer_block_inside(ir, &ir->then_instructions);
245 }
246}
diff --git a/src/glsl/ir_if_simplification.cpp b/src/glsl/ir_if_simplification.cpp
new file mode 100644
index 00000000000..6882ef72b95
--- /dev/null
+++ b/src/glsl/ir_if_simplification.cpp
@@ -0,0 +1,84 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_function_inlining.cpp
26 *
27 * Moves constant branches of if statements out to the surrounding
28 * instruction stream.
29 */
30
31#include "ir.h"
32
33class ir_if_simplification_visitor : public ir_hierarchical_visitor {
34public:
35 ir_if_simplification_visitor()
36 {
37 this->made_progress = false;
38 }
39
40 ir_visitor_status visit_leave(ir_if *);
41
42 bool made_progress;
43};
44
45bool
46do_if_simplification(exec_list *instructions)
47{
48 ir_if_simplification_visitor v;
49
50 v.run(instructions);
51 return v.made_progress;
52}
53
54
55ir_visitor_status
56ir_if_simplification_visitor::visit_leave(ir_if *ir)
57{
58 /* FINISHME: Ideally there would be a way to note that the condition results
59 * FINISHME: in a constant before processing both of the other subtrees.
60 * FINISHME: This can probably be done with some flags, but it would take
61 * FINISHME: some work to get right.
62 */
63 ir_constant *condition_constant = ir->condition->constant_expression_value();
64 if (condition_constant) {
65 /* Move the contents of the one branch of the conditional
66 * that matters out.
67 */
68 if (condition_constant->value.b[0]) {
69 foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) {
70 ir_instruction *then_ir = (ir_instruction *)then_iter.get();
71 ir->insert_before(then_ir);
72 }
73 } else {
74 foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) {
75 ir_instruction *else_ir = (ir_instruction *)else_iter.get();
76 ir->insert_before(else_ir);
77 }
78 }
79 ir->remove();
80 this->made_progress = true;
81 }
82
83 return visit_continue;
84}
diff --git a/src/glsl/ir_if_to_cond_assign.cpp b/src/glsl/ir_if_to_cond_assign.cpp
new file mode 100644
index 00000000000..0b87413941a
--- /dev/null
+++ b/src/glsl/ir_if_to_cond_assign.cpp
@@ -0,0 +1,168 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_if_to_cond_assign.cpp
26 *
27 * This attempts to flatten all if statements to conditional
28 * assignments for GPUs that don't do control flow.
29 *
30 * It can't handle other control flow being inside of its block, such
31 * as calls or loops. Hopefully loop unrolling and inlining will take
32 * care of those.
33 */
34
35#include "glsl_types.h"
36#include "ir.h"
37
38class ir_if_to_cond_assign_visitor : public ir_hierarchical_visitor {
39public:
40 ir_if_to_cond_assign_visitor()
41 {
42 this->progress = false;
43 }
44
45 ir_visitor_status visit_leave(ir_if *);
46
47 bool progress;
48};
49
50bool
51do_if_to_cond_assign(exec_list *instructions)
52{
53 ir_if_to_cond_assign_visitor v;
54
55 visit_list_elements(&v, instructions);
56
57 return v.progress;
58}
59
60void
61check_control_flow(ir_instruction *ir, void *data)
62{
63 bool *found_control_flow = (bool *)data;
64 switch (ir->ir_type) {
65 case ir_type_call:
66 case ir_type_discard:
67 case ir_type_loop:
68 case ir_type_loop_jump:
69 case ir_type_return:
70 *found_control_flow = true;
71 break;
72 default:
73 break;
74 }
75}
76
77void
78move_block_to_cond_assign(void *mem_ctx,
79 ir_if *if_ir, ir_variable *cond_var, bool then)
80{
81 exec_list *instructions;
82
83 if (then) {
84 instructions = &if_ir->then_instructions;
85 } else {
86 instructions = &if_ir->else_instructions;
87 }
88
89 foreach_iter(exec_list_iterator, iter, *instructions) {
90 ir_instruction *ir = (ir_instruction *)iter.get();
91
92 if (ir->ir_type == ir_type_assignment) {
93 ir_assignment *assign = (ir_assignment *)ir;
94 ir_rvalue *cond_expr;
95 ir_dereference *deref = new(mem_ctx) ir_dereference_variable(cond_var);
96
97 if (then) {
98 cond_expr = deref;
99 } else {
100 cond_expr = new(mem_ctx) ir_expression(ir_unop_logic_not,
101 glsl_type::bool_type,
102 deref,
103 NULL);
104 }
105
106 if (!assign->condition) {
107 assign->condition = cond_expr;
108 } else {
109 assign->condition = new(mem_ctx) ir_expression(ir_binop_logic_and,
110 glsl_type::bool_type,
111 cond_expr,
112 assign->condition);
113 }
114 }
115
116 /* Now, move from the if block to the block surrounding it. */
117 ir->remove();
118 if_ir->insert_before(ir);
119 }
120}
121
122ir_visitor_status
123ir_if_to_cond_assign_visitor::visit_leave(ir_if *ir)
124{
125 bool found_control_flow = false;
126 ir_variable *cond_var;
127 ir_assignment *assign;
128 ir_dereference_variable *deref;
129
130 /* Check that both blocks don't contain anything we can't support. */
131 foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) {
132 ir_instruction *then_ir = (ir_instruction *)then_iter.get();
133 visit_tree(then_ir, check_control_flow, &found_control_flow);
134 }
135 foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) {
136 ir_instruction *else_ir = (ir_instruction *)else_iter.get();
137 visit_tree(else_ir, check_control_flow, &found_control_flow);
138 }
139 if (found_control_flow)
140 return visit_continue;
141
142 void *mem_ctx = talloc_parent(ir);
143
144 /* Store the condition to a variable so the assignment conditions are
145 * simpler.
146 */
147 cond_var = new(mem_ctx) ir_variable(glsl_type::bool_type,
148 "if_to_cond_assign_condition",
149 ir_var_temporary);
150 ir->insert_before(cond_var);
151
152 deref = new(mem_ctx) ir_dereference_variable(cond_var);
153 assign = new(mem_ctx) ir_assignment(deref,
154 ir->condition, NULL);
155 ir->insert_before(assign);
156
157 /* Now, move all of the instructions out of the if blocks, putting
158 * conditions on assignments.
159 */
160 move_block_to_cond_assign(mem_ctx, ir, cond_var, true);
161 move_block_to_cond_assign(mem_ctx, ir, cond_var, false);
162
163 ir->remove();
164
165 this->progress = true;
166
167 return visit_continue;
168}
diff --git a/src/glsl/ir_import_prototypes.cpp b/src/glsl/ir_import_prototypes.cpp
new file mode 100644
index 00000000000..e553e12a491
--- /dev/null
+++ b/src/glsl/ir_import_prototypes.cpp
@@ -0,0 +1,138 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_import_prototypes.cpp
26 * Import function prototypes from one IR tree into another.
27 *
28 * \author Ian Romanick
29 */
30#include <cstdio>
31#include "ir.h"
32#include "glsl_symbol_table.h"
33
34/**
35 * Visitor used to import function prototypes
36 *
37 * Normally the \c clone method of either \c ir_function or
38 * \c ir_function_signature could be used. However, we don't want a complete
39 * clone of the \c ir_function_signature. We want everything \b except the
40 * body of the function.
41 */
42class import_prototype_visitor : public ir_hierarchical_visitor {
43public:
44 /**
45 */
46 import_prototype_visitor(exec_list *list, glsl_symbol_table *symbols,
47 void *mem_ctx)
48 {
49 this->mem_ctx = mem_ctx;
50 this->list = list;
51 this->symbols = symbols;
52 this->function = NULL;
53 }
54
55 virtual ir_visitor_status visit_enter(ir_function *ir)
56 {
57 assert(this->function == NULL);
58
59 this->function = this->symbols->get_function(ir->name);
60 if (!this->function) {
61 this->function = new(this->mem_ctx) ir_function(ir->name);
62
63 list->push_tail(this->function);
64
65 /* Add the new function to the symbol table.
66 */
67 this->symbols->add_function(this->function->name, this->function);
68 }
69 return visit_continue;
70 }
71
72 virtual ir_visitor_status visit_leave(ir_function *ir)
73 {
74 (void) ir;
75 assert(this->function != NULL);
76
77 this->function = NULL;
78 return visit_continue;
79 }
80
81 ir_visitor_status visit_enter(ir_function_signature *ir)
82 {
83 assert(this->function != NULL);
84
85 ir_function_signature *copy =
86 new(mem_ctx) ir_function_signature(ir->return_type);
87
88 copy->is_defined = false;
89 copy->is_built_in = ir->is_built_in;
90
91 /* Clone the parameter list, but NOT the body.
92 */
93 foreach_list_const(node, &ir->parameters) {
94 const ir_variable *const param = (const ir_variable *) node;
95
96 assert(const_cast<ir_variable *>(param)->as_variable() != NULL);
97
98 ir_variable *const param_copy = param->clone(mem_ctx, NULL);
99 copy->parameters.push_tail(param_copy);
100 }
101
102 this->function->add_signature(copy);
103
104 /* Do not process child nodes of the ir_function_signature. There can
105 * never be any nodes inside the ir_function_signature that we care
106 * about. Instead continue with the next sibling.
107 */
108 return visit_continue_with_parent;
109 }
110
111private:
112 exec_list *list;
113 ir_function *function;
114 glsl_symbol_table *symbols;
115 void *mem_ctx;
116};
117
118
119/**
120 * Import function prototypes from one IR tree into another
121 *
122 * \param source Source instruction stream containing functions whose
123 * prototypes are to be imported
124 * \param dest Destination instruction stream where new \c ir_function and
125 * \c ir_function_signature nodes will be stored
126 * \param symbols Symbol table where new functions will be stored
127 * \param mem_ctx talloc memory context used for new allocations
128 */
129void
130import_prototypes(const exec_list *source, exec_list *dest,
131 glsl_symbol_table *symbols, void *mem_ctx)
132{
133 import_prototype_visitor v(dest, symbols, mem_ctx);
134
135 /* Making source be const is just extra documentation.
136 */
137 v.run(const_cast<exec_list *>(source));
138}
diff --git a/src/glsl/ir_mat_op_to_vec.cpp b/src/glsl/ir_mat_op_to_vec.cpp
new file mode 100644
index 00000000000..80e05799861
--- /dev/null
+++ b/src/glsl/ir_mat_op_to_vec.cpp
@@ -0,0 +1,397 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_mat_op_to_vec.cpp
26 *
27 * Breaks matrix operation expressions down to a series of vector operations.
28 *
29 * Generally this is how we have to codegen matrix operations for a
30 * GPU, so this gives us the chance to constant fold operations on a
31 * column or row.
32 */
33
34#include "ir.h"
35#include "ir_expression_flattening.h"
36#include "glsl_types.h"
37
38class ir_mat_op_to_vec_visitor : public ir_hierarchical_visitor {
39public:
40 ir_mat_op_to_vec_visitor()
41 {
42 this->made_progress = false;
43 }
44
45 ir_visitor_status visit_leave(ir_assignment *);
46
47 ir_dereference *get_column(ir_variable *var, int col);
48 ir_rvalue *get_element(ir_variable *var, int col, int row);
49
50 void do_mul_mat_mat(ir_variable *result_var,
51 ir_variable *a_var, ir_variable *b_var);
52 void do_mul_mat_vec(ir_variable *result_var,
53 ir_variable *a_var, ir_variable *b_var);
54 void do_mul_vec_mat(ir_variable *result_var,
55 ir_variable *a_var, ir_variable *b_var);
56 void do_mul_mat_scalar(ir_variable *result_var,
57 ir_variable *a_var, ir_variable *b_var);
58
59 bool made_progress;
60};
61
62static bool
63mat_op_to_vec_predicate(ir_instruction *ir)
64{
65 ir_expression *expr = ir->as_expression();
66 unsigned int i;
67
68 if (!expr)
69 return false;
70
71 for (i = 0; i < expr->get_num_operands(); i++) {
72 if (expr->operands[i]->type->is_matrix())
73 return true;
74 }
75
76 return false;
77}
78
79bool
80do_mat_op_to_vec(exec_list *instructions)
81{
82 ir_mat_op_to_vec_visitor v;
83
84 /* Pull out any matrix expression to a separate assignment to a
85 * temp. This will make our handling of the breakdown to
86 * operations on the matrix's vector components much easier.
87 */
88 do_expression_flattening(instructions, mat_op_to_vec_predicate);
89
90 visit_list_elements(&v, instructions);
91
92 return v.made_progress;
93}
94
95ir_rvalue *
96ir_mat_op_to_vec_visitor::get_element(ir_variable *var, int col, int row)
97{
98 ir_dereference *deref;
99
100 deref = new(base_ir) ir_dereference_variable(var);
101
102 if (var->type->is_matrix()) {
103 deref = new(base_ir) ir_dereference_array(var,
104 new(base_ir) ir_constant(col));
105 } else {
106 assert(col == 0);
107 }
108
109 return new(base_ir) ir_swizzle(deref, row, 0, 0, 0, 1);
110}
111
112ir_dereference *
113ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int row)
114{
115 ir_dereference *deref;
116
117 if (!var->type->is_matrix()) {
118 deref = new(base_ir) ir_dereference_variable(var);
119 } else {
120 deref = new(base_ir) ir_dereference_variable(var);
121 deref = new(base_ir) ir_dereference_array(deref,
122 new(base_ir) ir_constant(row));
123 }
124
125 return deref;
126}
127
128void
129ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_variable *result_var,
130 ir_variable *a_var,
131 ir_variable *b_var)
132{
133 int b_col, i;
134 ir_assignment *assign;
135 ir_expression *expr;
136
137 for (b_col = 0; b_col < b_var->type->matrix_columns; b_col++) {
138 ir_rvalue *a = get_column(a_var, 0);
139 ir_rvalue *b = get_element(b_var, b_col, 0);
140
141 /* first column */
142 expr = new(base_ir) ir_expression(ir_binop_mul,
143 a->type,
144 a,
145 b);
146
147 /* following columns */
148 for (i = 1; i < a_var->type->matrix_columns; i++) {
149 ir_expression *mul_expr;
150
151 a = get_column(a_var, i);
152 b = get_element(b_var, b_col, i);
153
154 mul_expr = new(base_ir) ir_expression(ir_binop_mul,
155 a->type,
156 a,
157 b);
158 expr = new(base_ir) ir_expression(ir_binop_add,
159 a->type,
160 expr,
161 mul_expr);
162 }
163
164 ir_rvalue *result = get_column(result_var, b_col);
165 assign = new(base_ir) ir_assignment(result,
166 expr,
167 NULL);
168 base_ir->insert_before(assign);
169 }
170}
171
172void
173ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_variable *result_var,
174 ir_variable *a_var,
175 ir_variable *b_var)
176{
177 int i;
178 ir_rvalue *a = get_column(a_var, 0);
179 ir_rvalue *b = get_element(b_var, 0, 0);
180 ir_assignment *assign;
181 ir_expression *expr;
182
183 /* first column */
184 expr = new(base_ir) ir_expression(ir_binop_mul,
185 result_var->type,
186 a,
187 b);
188
189 /* following columns */
190 for (i = 1; i < a_var->type->matrix_columns; i++) {
191 ir_expression *mul_expr;
192
193 a = get_column(a_var, i);
194 b = get_element(b_var, 0, i);
195
196 mul_expr = new(base_ir) ir_expression(ir_binop_mul,
197 result_var->type,
198 a,
199 b);
200 expr = new(base_ir) ir_expression(ir_binop_add,
201 result_var->type,
202 expr,
203 mul_expr);
204 }
205
206 ir_rvalue *result = new(base_ir) ir_dereference_variable(result_var);
207 assign = new(base_ir) ir_assignment(result,
208 expr,
209 NULL);
210 base_ir->insert_before(assign);
211}
212
213void
214ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result_var,
215 ir_variable *a_var,
216 ir_variable *b_var)
217{
218 int i;
219
220 for (i = 0; i < b_var->type->matrix_columns; i++) {
221 ir_rvalue *a = new(base_ir) ir_dereference_variable(a_var);
222 ir_rvalue *b = get_column(b_var, i);
223 ir_rvalue *result;
224 ir_expression *column_expr;
225 ir_assignment *column_assign;
226
227 result = new(base_ir) ir_dereference_variable(result_var);
228 result = new(base_ir) ir_swizzle(result, i, 0, 0, 0, 1);
229
230 column_expr = new(base_ir) ir_expression(ir_binop_dot,
231 result->type,
232 a,
233 b);
234
235 column_assign = new(base_ir) ir_assignment(result,
236 column_expr,
237 NULL);
238 base_ir->insert_before(column_assign);
239 }
240}
241
242void
243ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result_var,
244 ir_variable *a_var,
245 ir_variable *b_var)
246{
247 int i;
248
249 for (i = 0; i < a_var->type->matrix_columns; i++) {
250 ir_rvalue *a = get_column(a_var, i);
251 ir_rvalue *b = new(base_ir) ir_dereference_variable(b_var);
252 ir_rvalue *result = get_column(result_var, i);
253 ir_expression *column_expr;
254 ir_assignment *column_assign;
255
256 column_expr = new(base_ir) ir_expression(ir_binop_mul,
257 result->type,
258 a,
259 b);
260
261 column_assign = new(base_ir) ir_assignment(result,
262 column_expr,
263 NULL);
264 base_ir->insert_before(column_assign);
265 }
266}
267
268ir_visitor_status
269ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign)
270{
271 ir_expression *expr = assign->rhs->as_expression();
272 bool found_matrix = false;
273 unsigned int i, matrix_columns = 1;
274 ir_variable *op_var[2];
275
276 if (!expr)
277 return visit_continue;
278
279 for (i = 0; i < expr->get_num_operands(); i++) {
280 if (expr->operands[i]->type->is_matrix()) {
281 found_matrix = true;
282 matrix_columns = expr->operands[i]->type->matrix_columns;
283 break;
284 }
285 }
286 if (!found_matrix)
287 return visit_continue;
288
289 ir_dereference_variable *lhs_deref = assign->lhs->as_dereference_variable();
290 assert(lhs_deref);
291
292 ir_variable *result_var = lhs_deref->var;
293
294 /* Store the expression operands in temps so we can use them
295 * multiple times.
296 */
297 for (i = 0; i < expr->get_num_operands(); i++) {
298 ir_assignment *assign;
299
300 op_var[i] = new(base_ir) ir_variable(expr->operands[i]->type,
301 "mat_op_to_vec",
302 ir_var_temporary);
303 base_ir->insert_before(op_var[i]);
304
305 lhs_deref = new(base_ir) ir_dereference_variable(op_var[i]);
306 assign = new(base_ir) ir_assignment(lhs_deref,
307 expr->operands[i],
308 NULL);
309 base_ir->insert_before(assign);
310 }
311
312 /* OK, time to break down this matrix operation. */
313 switch (expr->operation) {
314 case ir_unop_neg: {
315 const unsigned mask = (1U << result_var->type->vector_elements) - 1;
316
317 /* Apply the operation to each column.*/
318 for (i = 0; i < matrix_columns; i++) {
319 ir_rvalue *op0 = get_column(op_var[0], i);
320 ir_dereference *result = get_column(result_var, i);
321 ir_expression *column_expr;
322 ir_assignment *column_assign;
323
324 column_expr = new(base_ir) ir_expression(expr->operation,
325 result->type,
326 op0,
327 NULL);
328
329 column_assign = new(base_ir) ir_assignment(result,
330 column_expr,
331 NULL,
332 mask);
333 assert(column_assign->write_mask != 0);
334 base_ir->insert_before(column_assign);
335 }
336 break;
337 }
338 case ir_binop_add:
339 case ir_binop_sub:
340 case ir_binop_div:
341 case ir_binop_mod: {
342 const unsigned mask = (1U << result_var->type->vector_elements) - 1;
343
344 /* For most operations, the matrix version is just going
345 * column-wise through and applying the operation to each column
346 * if available.
347 */
348 for (i = 0; i < matrix_columns; i++) {
349 ir_rvalue *op0 = get_column(op_var[0], i);
350 ir_rvalue *op1 = get_column(op_var[1], i);
351 ir_dereference *result = get_column(result_var, i);
352 ir_expression *column_expr;
353 ir_assignment *column_assign;
354
355 column_expr = new(base_ir) ir_expression(expr->operation,
356 result->type,
357 op0,
358 op1);
359
360 column_assign = new(base_ir) ir_assignment(result,
361 column_expr,
362 NULL,
363 mask);
364 assert(column_assign->write_mask != 0);
365 base_ir->insert_before(column_assign);
366 }
367 break;
368 }
369 case ir_binop_mul:
370 if (op_var[0]->type->is_matrix()) {
371 if (op_var[1]->type->is_matrix()) {
372 do_mul_mat_mat(result_var, op_var[0], op_var[1]);
373 } else if (op_var[1]->type->is_vector()) {
374 do_mul_mat_vec(result_var, op_var[0], op_var[1]);
375 } else {
376 assert(op_var[1]->type->is_scalar());
377 do_mul_mat_scalar(result_var, op_var[0], op_var[1]);
378 }
379 } else {
380 assert(op_var[1]->type->is_matrix());
381 if (op_var[0]->type->is_vector()) {
382 do_mul_vec_mat(result_var, op_var[0], op_var[1]);
383 } else {
384 assert(op_var[0]->type->is_scalar());
385 do_mul_mat_scalar(result_var, op_var[1], op_var[0]);
386 }
387 }
388 break;
389 default:
390 printf("FINISHME: Handle matrix operation for %s\n", expr->operator_string());
391 abort();
392 }
393 assign->remove();
394 this->made_progress = true;
395
396 return visit_continue;
397}
diff --git a/src/glsl/ir_mod_to_fract.cpp b/src/glsl/ir_mod_to_fract.cpp
new file mode 100644
index 00000000000..71c9472b12b
--- /dev/null
+++ b/src/glsl/ir_mod_to_fract.cpp
@@ -0,0 +1,90 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_mod_to_floor.cpp
26 *
27 * Breaks an ir_unop_mod expression down to (op1 * fract(op0 / op1))
28 *
29 * Many GPUs don't have a MOD instruction (945 and 965 included), and
30 * if we have to break it down like this anyway, it gives an
31 * opportunity to do things like constant fold the (1.0 / op1) easily.
32 */
33
34#include "ir.h"
35
36class ir_mod_to_fract_visitor : public ir_hierarchical_visitor {
37public:
38 ir_mod_to_fract_visitor()
39 {
40 this->made_progress = false;
41 }
42
43 ir_visitor_status visit_leave(ir_expression *);
44
45 bool made_progress;
46};
47
48bool
49do_mod_to_fract(exec_list *instructions)
50{
51 ir_mod_to_fract_visitor v;
52
53 visit_list_elements(&v, instructions);
54 return v.made_progress;
55}
56
57ir_visitor_status
58ir_mod_to_fract_visitor::visit_leave(ir_expression *ir)
59{
60 if (ir->operation != ir_binop_mod)
61 return visit_continue;
62
63 ir_variable *temp = new(ir) ir_variable(ir->operands[1]->type, "mod_b",
64 ir_var_temporary);
65 this->base_ir->insert_before(temp);
66
67 ir_assignment *assign;
68 ir_rvalue *expr;
69
70 assign = new(ir) ir_assignment(new(ir) ir_dereference_variable(temp),
71 ir->operands[1], NULL);
72 this->base_ir->insert_before(assign);
73
74 expr = new(ir) ir_expression(ir_binop_div,
75 ir->operands[0]->type,
76 ir->operands[0],
77 new(ir) ir_dereference_variable(temp));
78
79 expr = new(ir) ir_expression(ir_unop_fract,
80 ir->operands[0]->type,
81 expr,
82 NULL);
83
84 ir->operation = ir_binop_mul;
85 ir->operands[0] = new(ir) ir_dereference_variable(temp);
86 ir->operands[1] = expr;
87 this->made_progress = true;
88
89 return visit_continue;
90}
diff --git a/src/glsl/ir_noop_swizzle.cpp b/src/glsl/ir_noop_swizzle.cpp
new file mode 100644
index 00000000000..b78c87b47f3
--- /dev/null
+++ b/src/glsl/ir_noop_swizzle.cpp
@@ -0,0 +1,80 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_noop_swizzle.cpp
26 *
27 * If a swizzle doesn't change the order or count of components, then
28 * remove the swizzle so that other optimization passes see the value
29 * behind it.
30 */
31
32#include "ir.h"
33#include "ir_visitor.h"
34#include "ir_rvalue_visitor.h"
35#include "ir_print_visitor.h"
36#include "glsl_types.h"
37
38class ir_noop_swizzle_visitor : public ir_rvalue_visitor {
39public:
40 ir_noop_swizzle_visitor()
41 {
42 this->progress = false;
43 }
44
45 void handle_rvalue(ir_rvalue **rvalue);
46 bool progress;
47};
48
49void
50ir_noop_swizzle_visitor::handle_rvalue(ir_rvalue **rvalue)
51{
52 if (!*rvalue)
53 return;
54
55 ir_swizzle *swiz = (*rvalue)->as_swizzle();
56 if (!swiz || swiz->type != swiz->val->type)
57 return;
58
59 int elems = swiz->val->type->vector_elements;
60 if (swiz->mask.x != 0)
61 return;
62 if (elems >= 2 && swiz->mask.y != 1)
63 return;
64 if (elems >= 3 && swiz->mask.z != 1)
65 return;
66 if (elems >= 4 && swiz->mask.w != 1)
67 return;
68
69 this->progress = true;
70 *rvalue = swiz->val;
71}
72
73bool
74do_noop_swizzle(exec_list *instructions)
75{
76 ir_noop_swizzle_visitor v;
77 visit_list_elements(&v, instructions);
78
79 return v.progress;
80}
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
new file mode 100644
index 00000000000..33f4bc78f79
--- /dev/null
+++ b/src/glsl/ir_optimization.h
@@ -0,0 +1,57 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24
25/**
26 * \file ir_optimization.h
27 *
28 * Prototypes for optimization passes to be called by the compiler and drivers.
29 */
30
31bool do_common_optimization(exec_list *ir, bool linked);
32
33bool do_algebraic(exec_list *instructions);
34bool do_constant_folding(exec_list *instructions);
35bool do_constant_variable(exec_list *instructions);
36bool do_constant_variable_unlinked(exec_list *instructions);
37bool do_copy_propagation(exec_list *instructions);
38bool do_constant_propagation(exec_list *instructions);
39bool do_dead_code(exec_list *instructions);
40bool do_dead_code_local(exec_list *instructions);
41bool do_dead_code_unlinked(exec_list *instructions);
42bool do_dead_functions(exec_list *instructions);
43bool do_div_to_mul_rcp(exec_list *instructions);
44bool do_explog_to_explog2(exec_list *instructions);
45bool do_function_inlining(exec_list *instructions);
46bool do_if_return(exec_list *instructions);
47bool do_if_simplification(exec_list *instructions);
48bool do_if_to_cond_assign(exec_list *instructions);
49bool do_mat_op_to_vec(exec_list *instructions);
50bool do_mod_to_fract(exec_list *instructions);
51bool do_noop_swizzle(exec_list *instructions);
52bool do_structure_splitting(exec_list *instructions);
53bool do_sub_to_add_neg(exec_list *instructions);
54bool do_swizzle_swizzle(exec_list *instructions);
55bool do_tree_grafting(exec_list *instructions);
56bool do_vec_index_to_cond_assign(exec_list *instructions);
57bool do_vec_index_to_swizzle(exec_list *instructions);
diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp
new file mode 100644
index 00000000000..83e64032723
--- /dev/null
+++ b/src/glsl/ir_print_visitor.cpp
@@ -0,0 +1,465 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "ir_print_visitor.h"
25#include "glsl_types.h"
26#include "glsl_parser_extras.h"
27
28static void print_type(const glsl_type *t);
29
30void
31ir_instruction::print(void) const
32{
33 ir_instruction *deconsted = const_cast<ir_instruction *>(this);
34
35 ir_print_visitor v;
36 deconsted->accept(&v);
37}
38
39void
40_mesa_print_ir(exec_list *instructions,
41 struct _mesa_glsl_parse_state *state)
42{
43 if (state) {
44 for (unsigned i = 0; i < state->num_user_structures; i++) {
45 const glsl_type *const s = state->user_structures[i];
46
47 printf("(structure (%s) (%s@%p) (%u) (\n",
48 s->name, s->name, (void *) s, s->length);
49
50 for (unsigned j = 0; j < s->length; j++) {
51 printf("\t((");
52 print_type(s->fields.structure[j].type);
53 printf(")(%s))\n", s->fields.structure[j].name);
54 }
55
56 printf(")\n");
57 }
58 }
59
60 printf("(\n");
61 foreach_iter(exec_list_iterator, iter, *instructions) {
62 ir_instruction *ir = (ir_instruction *)iter.get();
63 ir->print();
64 if (ir->ir_type != ir_type_function)
65 printf("\n");
66 }
67 printf("\n)");
68}
69
70
71void ir_print_visitor::indent(void)
72{
73 for (int i = 0; i < indentation; i++)
74 printf(" ");
75}
76
77static void
78print_type(const glsl_type *t)
79{
80 if (t->base_type == GLSL_TYPE_ARRAY) {
81 printf("(array ");
82 print_type(t->fields.array);
83 printf(" %u)", t->length);
84 } else if ((t->base_type == GLSL_TYPE_STRUCT)
85 && (strncmp("gl_", t->name, 3) != 0)) {
86 printf("%s@%p", t->name, (void *) t);
87 } else {
88 printf("%s", t->name);
89 }
90}
91
92
93void ir_print_visitor::visit(ir_variable *ir)
94{
95 printf("(declare ");
96
97 const char *const cent = (ir->centroid) ? "centroid " : "";
98 const char *const inv = (ir->invariant) ? "invariant " : "";
99 const char *const mode[] = { "", "uniform ", "in ", "out ", "inout ",
100 "temporary " };
101 const char *const interp[] = { "", "flat", "noperspective" };
102
103 printf("(%s%s%s%s) ",
104 cent, inv, mode[ir->mode], interp[ir->interpolation]);
105
106 print_type(ir->type);
107 printf(" %s@%p)", ir->name, (void *) ir);
108}
109
110
111void ir_print_visitor::visit(ir_function_signature *ir)
112{
113 printf("(signature ");
114 indentation++;
115
116 print_type(ir->return_type);
117 printf("\n");
118 indent();
119
120 printf("(parameters\n");
121 indentation++;
122
123 foreach_iter(exec_list_iterator, iter, ir->parameters) {
124 ir_variable *const inst = (ir_variable *) iter.get();
125
126 indent();
127 inst->accept(this);
128 printf("\n");
129 }
130 indentation--;
131
132 indent();
133 printf(")\n");
134
135 indent();
136
137 printf("(\n");
138 indentation++;
139
140 foreach_iter(exec_list_iterator, iter, ir->body) {
141 ir_instruction *const inst = (ir_instruction *) iter.get();
142
143 indent();
144 inst->accept(this);
145 printf("\n");
146 }
147 indentation--;
148 indent();
149 printf("))\n");
150 indentation--;
151}
152
153
154void ir_print_visitor::visit(ir_function *ir)
155{
156 bool found_non_builtin_proto = false;
157
158 foreach_iter(exec_list_iterator, iter, *ir) {
159 ir_function_signature *const sig = (ir_function_signature *) iter.get();
160 if (sig->is_defined || !sig->is_built_in)
161 found_non_builtin_proto = true;
162 }
163 if (!found_non_builtin_proto)
164 return;
165
166 printf("(function %s\n", ir->name);
167 indentation++;
168 foreach_iter(exec_list_iterator, iter, *ir) {
169 ir_function_signature *const sig = (ir_function_signature *) iter.get();
170
171 indent();
172 sig->accept(this);
173 printf("\n");
174 }
175 indentation--;
176 indent();
177 printf(")\n\n");
178}
179
180
181void ir_print_visitor::visit(ir_expression *ir)
182{
183 printf("(expression ");
184
185 print_type(ir->type);
186
187 printf(" %s ", ir->operator_string());
188
189 if (ir->operands[0])
190 ir->operands[0]->accept(this);
191
192 if (ir->operands[1])
193 ir->operands[1]->accept(this);
194 printf(") ");
195}
196
197
198void ir_print_visitor::visit(ir_texture *ir)
199{
200 printf("(%s ", ir->opcode_string());
201
202 ir->sampler->accept(this);
203 printf(" ");
204
205 ir->coordinate->accept(this);
206
207 printf(" (%d %d %d) ", ir->offsets[0], ir->offsets[1], ir->offsets[2]);
208
209 if (ir->op != ir_txf) {
210 if (ir->projector)
211 ir->projector->accept(this);
212 else
213 printf("1");
214
215 if (ir->shadow_comparitor) {
216 printf(" ");
217 ir->shadow_comparitor->accept(this);
218 } else {
219 printf(" ()");
220 }
221 }
222
223 printf(" ");
224 switch (ir->op)
225 {
226 case ir_tex:
227 break;
228 case ir_txb:
229 ir->lod_info.bias->accept(this);
230 break;
231 case ir_txl:
232 case ir_txf:
233 ir->lod_info.lod->accept(this);
234 break;
235 case ir_txd:
236 printf("(");
237 ir->lod_info.grad.dPdx->accept(this);
238 printf(" ");
239 ir->lod_info.grad.dPdy->accept(this);
240 printf(")");
241 break;
242 };
243 printf(")");
244}
245
246
247void ir_print_visitor::visit(ir_swizzle *ir)
248{
249 const unsigned swiz[4] = {
250 ir->mask.x,
251 ir->mask.y,
252 ir->mask.z,
253 ir->mask.w,
254 };
255
256 printf("(swiz ");
257 for (unsigned i = 0; i < ir->mask.num_components; i++) {
258 printf("%c", "xyzw"[swiz[i]]);
259 }
260 printf(" ");
261 ir->val->accept(this);
262 printf(")");
263}
264
265
266void ir_print_visitor::visit(ir_dereference_variable *ir)
267{
268 ir_variable *var = ir->variable_referenced();
269 printf("(var_ref %s@%p) ", var->name, (void *) var);
270}
271
272
273void ir_print_visitor::visit(ir_dereference_array *ir)
274{
275 printf("(array_ref ");
276 ir->array->accept(this);
277 ir->array_index->accept(this);
278 printf(") ");
279}
280
281
282void ir_print_visitor::visit(ir_dereference_record *ir)
283{
284 printf("(record_ref ");
285 ir->record->accept(this);
286 printf(" %s) ", ir->field);
287}
288
289
290void ir_print_visitor::visit(ir_assignment *ir)
291{
292 printf("(assign ");
293
294 if (ir->condition)
295 ir->condition->accept(this);
296 else
297 printf("(constant bool (1))");
298
299
300 char mask[5];
301 unsigned j = 0;
302
303 for (unsigned i = 0; i < 4; i++) {
304 if ((ir->write_mask & (1 << i)) != 0) {
305 mask[j] = "xyzw"[i];
306 j++;
307 }
308 }
309 mask[j] = '\0';
310
311 printf(" (%s) ", mask);
312
313 ir->lhs->accept(this);
314
315 printf(" ");
316
317 ir->rhs->accept(this);
318 printf(") ");
319}
320
321
322void ir_print_visitor::visit(ir_constant *ir)
323{
324 const glsl_type *const base_type = ir->type->get_base_type();
325
326 printf("(constant ");
327 print_type(ir->type);
328 printf(" (");
329
330 if (ir->type->is_array()) {
331 for (unsigned i = 0; i < ir->type->length; i++)
332 ir->get_array_element(i)->accept(this);
333 } else {
334 for (unsigned i = 0; i < ir->type->components(); i++) {
335 if (i != 0)
336 printf(" ");
337 switch (base_type->base_type) {
338 case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break;
339 case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break;
340 case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break;
341 case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break;
342 default: assert(0);
343 }
344 }
345 }
346 printf(")) ");
347}
348
349
350void
351ir_print_visitor::visit(ir_call *ir)
352{
353 printf("(call %s (", ir->callee_name());
354 foreach_iter(exec_list_iterator, iter, *ir) {
355 ir_instruction *const inst = (ir_instruction *) iter.get();
356
357 inst->accept(this);
358 }
359 printf("))\n");
360}
361
362
363void
364ir_print_visitor::visit(ir_return *ir)
365{
366 printf("(return");
367
368 ir_rvalue *const value = ir->get_value();
369 if (value) {
370 printf(" ");
371 value->accept(this);
372 }
373
374 printf(")");
375}
376
377
378void
379ir_print_visitor::visit(ir_discard *ir)
380{
381 printf("(discard ");
382
383 if (ir->condition != NULL) {
384 printf(" ");
385 ir->condition->accept(this);
386 }
387
388 printf(")");
389}
390
391
392void
393ir_print_visitor::visit(ir_if *ir)
394{
395 printf("(if ");
396 ir->condition->accept(this);
397
398 printf("(\n");
399 indentation++;
400
401 foreach_iter(exec_list_iterator, iter, ir->then_instructions) {
402 ir_instruction *const inst = (ir_instruction *) iter.get();
403
404 indent();
405 inst->accept(this);
406 printf("\n");
407 }
408
409 indentation--;
410 indent();
411 printf(")\n");
412
413 indent();
414 printf("(\n");
415 indentation++;
416
417 foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
418 ir_instruction *const inst = (ir_instruction *) iter.get();
419
420 indent();
421 inst->accept(this);
422 printf("\n");
423 }
424 indentation--;
425 indent();
426 printf("))\n");
427}
428
429
430void
431ir_print_visitor::visit(ir_loop *ir)
432{
433 printf("(loop (");
434 if (ir->counter != NULL)
435 ir->counter->accept(this);
436 printf(") (");
437 if (ir->from != NULL)
438 ir->from->accept(this);
439 printf(") (");
440 if (ir->to != NULL)
441 ir->to->accept(this);
442 printf(") (");
443 if (ir->increment != NULL)
444 ir->increment->accept(this);
445 printf(") (\n");
446 indentation++;
447
448 foreach_iter(exec_list_iterator, iter, ir->body_instructions) {
449 ir_instruction *const inst = (ir_instruction *) iter.get();
450
451 indent();
452 inst->accept(this);
453 printf("\n");
454 }
455 indentation--;
456 indent();
457 printf("))\n");
458}
459
460
461void
462ir_print_visitor::visit(ir_loop_jump *ir)
463{
464 printf("%s", ir->is_break() ? "break" : "continue");
465}
diff --git a/src/glsl/ir_print_visitor.h b/src/glsl/ir_print_visitor.h
new file mode 100644
index 00000000000..4feeb8c184d
--- /dev/null
+++ b/src/glsl/ir_print_visitor.h
@@ -0,0 +1,83 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef IR_PRINT_VISITOR_H
27#define IR_PRINT_VISITOR_H
28
29#include "ir.h"
30#include "ir_visitor.h"
31
32extern void _mesa_print_ir(exec_list *instructions,
33 struct _mesa_glsl_parse_state *state);
34
35/**
36 * Abstract base class of visitors of IR instruction trees
37 */
38class ir_print_visitor : public ir_visitor {
39public:
40 ir_print_visitor()
41 {
42 indentation = 0;
43 }
44
45 virtual ~ir_print_visitor()
46 {
47 /* empty */
48 }
49
50 void indent(void);
51
52 /**
53 * \name Visit methods
54 *
55 * As typical for the visitor pattern, there must be one \c visit method for
56 * each concrete subclass of \c ir_instruction. Virtual base classes within
57 * the hierarchy should not have \c visit methods.
58 */
59 /*@{*/
60 virtual void visit(ir_variable *);
61 virtual void visit(ir_function_signature *);
62 virtual void visit(ir_function *);
63 virtual void visit(ir_expression *);
64 virtual void visit(ir_texture *);
65 virtual void visit(ir_swizzle *);
66 virtual void visit(ir_dereference_variable *);
67 virtual void visit(ir_dereference_array *);
68 virtual void visit(ir_dereference_record *);
69 virtual void visit(ir_assignment *);
70 virtual void visit(ir_constant *);
71 virtual void visit(ir_call *);
72 virtual void visit(ir_return *);
73 virtual void visit(ir_discard *);
74 virtual void visit(ir_if *);
75 virtual void visit(ir_loop *);
76 virtual void visit(ir_loop_jump *);
77 /*@}*/
78
79private:
80 int indentation;
81};
82
83#endif /* IR_PRINT_VISITOR_H */
diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
new file mode 100644
index 00000000000..3e221c0e5ff
--- /dev/null
+++ b/src/glsl/ir_reader.cpp
@@ -0,0 +1,1088 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <cstdarg>
25
26extern "C" {
27#include <talloc.h>
28}
29
30#include "ir_reader.h"
31#include "glsl_parser_extras.h"
32#include "glsl_types.h"
33#include "s_expression.h"
34
35static void ir_read_error(_mesa_glsl_parse_state *, s_expression *,
36 const char *fmt, ...);
37static const glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *);
38
39static void scan_for_prototypes(_mesa_glsl_parse_state *, exec_list *,
40 s_expression *);
41static ir_function *read_function(_mesa_glsl_parse_state *, s_list *,
42 bool skip_body);
43static void read_function_sig(_mesa_glsl_parse_state *, ir_function *,
44 s_list *, bool skip_body);
45
46static void read_instructions(_mesa_glsl_parse_state *, exec_list *,
47 s_expression *, ir_loop *);
48static ir_instruction *read_instruction(_mesa_glsl_parse_state *,
49 s_expression *, ir_loop *);
50static ir_variable *read_declaration(_mesa_glsl_parse_state *, s_list *);
51static ir_if *read_if(_mesa_glsl_parse_state *, s_list *, ir_loop *);
52static ir_loop *read_loop(_mesa_glsl_parse_state *st, s_list *list);
53static ir_return *read_return(_mesa_glsl_parse_state *, s_list *);
54
55static ir_rvalue *read_rvalue(_mesa_glsl_parse_state *, s_expression *);
56static ir_assignment *read_assignment(_mesa_glsl_parse_state *, s_list *);
57static ir_expression *read_expression(_mesa_glsl_parse_state *, s_list *);
58static ir_call *read_call(_mesa_glsl_parse_state *, s_list *);
59static ir_swizzle *read_swizzle(_mesa_glsl_parse_state *, s_list *);
60static ir_constant *read_constant(_mesa_glsl_parse_state *, s_list *);
61static ir_texture *read_texture(_mesa_glsl_parse_state *, s_list *);
62
63static ir_dereference *read_dereference(_mesa_glsl_parse_state *,
64 s_expression *);
65static ir_dereference *read_var_ref(_mesa_glsl_parse_state *, s_list *);
66static ir_dereference *read_array_ref(_mesa_glsl_parse_state *, s_list *);
67static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *);
68
69void
70_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
71 const char *src, bool scan_for_protos)
72{
73 s_expression *expr = s_expression::read_expression(state, src);
74 if (expr == NULL) {
75 ir_read_error(state, NULL, "couldn't parse S-Expression.");
76 return;
77 }
78
79 if (scan_for_protos) {
80 scan_for_prototypes(state, instructions, expr);
81 if (state->error)
82 return;
83 }
84
85 read_instructions(state, instructions, expr, NULL);
86 talloc_free(expr);
87}
88
89static void
90ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr,
91 const char *fmt, ...)
92{
93 va_list ap;
94
95 state->error = true;
96
97 state->info_log = talloc_strdup_append(state->info_log, "error: ");
98
99 va_start(ap, fmt);
100 state->info_log = talloc_vasprintf_append(state->info_log, fmt, ap);
101 va_end(ap);
102 state->info_log = talloc_strdup_append(state->info_log, "\n");
103
104 if (expr != NULL) {
105 state->info_log = talloc_strdup_append(state->info_log,
106 "...in this context:\n ");
107 expr->print();
108 state->info_log = talloc_strdup_append(state->info_log, "\n\n");
109 }
110}
111
112static const glsl_type *
113read_type(_mesa_glsl_parse_state *st, s_expression *expr)
114{
115 s_list *list = SX_AS_LIST(expr);
116 if (list != NULL) {
117 s_symbol *type_sym = SX_AS_SYMBOL(list->subexpressions.get_head());
118 if (type_sym == NULL) {
119 ir_read_error(st, expr, "expected type (array ...) or (struct ...)");
120 return NULL;
121 }
122 if (strcmp(type_sym->value(), "array") == 0) {
123 if (list->length() != 3) {
124 ir_read_error(st, expr, "expected type (array <type> <int>)");
125 return NULL;
126 }
127
128 // Read base type
129 s_expression *base_expr = (s_expression*) type_sym->next;
130 const glsl_type *base_type = read_type(st, base_expr);
131 if (base_type == NULL) {
132 ir_read_error(st, NULL, "when reading base type of array");
133 return NULL;
134 }
135
136 // Read array size
137 s_int *size = SX_AS_INT(base_expr->next);
138 if (size == NULL) {
139 ir_read_error(st, expr, "found non-integer array size");
140 return NULL;
141 }
142
143 return glsl_type::get_array_instance(base_type, size->value());
144 } else if (strcmp(type_sym->value(), "struct") == 0) {
145 assert(false); // FINISHME
146 } else {
147 ir_read_error(st, expr, "expected (array ...) or (struct ...); "
148 "found (%s ...)", type_sym->value());
149 return NULL;
150 }
151 }
152
153 s_symbol *type_sym = SX_AS_SYMBOL(expr);
154 if (type_sym == NULL) {
155 ir_read_error(st, expr, "expected <type> (symbol or list)");
156 return NULL;
157 }
158
159 const glsl_type *type = st->symbols->get_type(type_sym->value());
160 if (type == NULL)
161 ir_read_error(st, expr, "invalid type: %s", type_sym->value());
162
163 return type;
164}
165
166
167static void
168scan_for_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions,
169 s_expression *expr)
170{
171 s_list *list = SX_AS_LIST(expr);
172 if (list == NULL) {
173 ir_read_error(st, expr, "Expected (<instruction> ...); found an atom.");
174 return;
175 }
176
177 foreach_iter(exec_list_iterator, it, list->subexpressions) {
178 s_list *sub = SX_AS_LIST(it.get());
179 if (sub == NULL)
180 continue; // not a (function ...); ignore it.
181
182 s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head());
183 if (tag == NULL || strcmp(tag->value(), "function") != 0)
184 continue; // not a (function ...); ignore it.
185
186 ir_function *f = read_function(st, sub, true);
187 if (f == NULL)
188 return;
189 instructions->push_tail(f);
190 }
191}
192
193static ir_function *
194read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body)
195{
196 void *ctx = st;
197 bool added = false;
198 if (list->length() < 3) {
199 ir_read_error(st, list, "Expected (function <name> (signature ...) ...)");
200 return NULL;
201 }
202
203 s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next);
204 if (name == NULL) {
205 ir_read_error(st, list, "Expected (function <name> ...)");
206 return NULL;
207 }
208
209 ir_function *f = st->symbols->get_function(name->value());
210 if (f == NULL) {
211 f = new(ctx) ir_function(name->value());
212 added = st->symbols->add_function(f->name, f);
213 assert(added);
214 }
215
216 exec_list_iterator it = list->subexpressions.iterator();
217 it.next(); // skip "function" tag
218 it.next(); // skip function name
219 for (/* nothing */; it.has_next(); it.next()) {
220 s_list *siglist = SX_AS_LIST(it.get());
221 if (siglist == NULL) {
222 ir_read_error(st, list, "Expected (function (signature ...) ...)");
223 return NULL;
224 }
225
226 s_symbol *tag = SX_AS_SYMBOL(siglist->subexpressions.get_head());
227 if (tag == NULL || strcmp(tag->value(), "signature") != 0) {
228 ir_read_error(st, siglist, "Expected (signature ...)");
229 return NULL;
230 }
231
232 read_function_sig(st, f, siglist, skip_body);
233 }
234 return added ? f : NULL;
235}
236
237static void
238read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
239 bool skip_body)
240{
241 void *ctx = st;
242 if (list->length() != 4) {
243 ir_read_error(st, list, "Expected (signature <type> (parameters ...) "
244 "(<instruction> ...))");
245 return;
246 }
247
248 s_expression *type_expr = (s_expression*) list->subexpressions.head->next;
249 const glsl_type *return_type = read_type(st, type_expr);
250 if (return_type == NULL)
251 return;
252
253 s_list *paramlist = SX_AS_LIST(type_expr->next);
254 s_list *body_list = SX_AS_LIST(paramlist->next);
255 if (paramlist == NULL || body_list == NULL) {
256 ir_read_error(st, list, "Expected (signature <type> (parameters ...) "
257 "(<instruction> ...))");
258 return;
259 }
260 s_symbol *paramtag = SX_AS_SYMBOL(paramlist->subexpressions.get_head());
261 if (paramtag == NULL || strcmp(paramtag->value(), "parameters") != 0) {
262 ir_read_error(st, paramlist, "Expected (parameters ...)");
263 return;
264 }
265
266 // Read the parameters list into a temporary place.
267 exec_list hir_parameters;
268 st->symbols->push_scope();
269
270 exec_list_iterator it = paramlist->subexpressions.iterator();
271 for (it.next() /* skip "parameters" */; it.has_next(); it.next()) {
272 s_list *decl = SX_AS_LIST(it.get());
273 ir_variable *var = read_declaration(st, decl);
274 if (var == NULL)
275 return;
276
277 hir_parameters.push_tail(var);
278 }
279
280 ir_function_signature *sig = f->exact_matching_signature(&hir_parameters);
281 if (sig == NULL && skip_body) {
282 /* If scanning for prototypes, generate a new signature. */
283 sig = new(ctx) ir_function_signature(return_type);
284 sig->is_built_in = true;
285 f->add_signature(sig);
286 } else if (sig != NULL) {
287 const char *badvar = sig->qualifiers_match(&hir_parameters);
288 if (badvar != NULL) {
289 ir_read_error(st, list, "function `%s' parameter `%s' qualifiers "
290 "don't match prototype", f->name, badvar);
291 return;
292 }
293
294 if (sig->return_type != return_type) {
295 ir_read_error(st, list, "function `%s' return type doesn't "
296 "match prototype", f->name);
297 return;
298 }
299 } else {
300 /* No prototype for this body exists - skip it. */
301 st->symbols->pop_scope();
302 return;
303 }
304 assert(sig != NULL);
305
306 sig->replace_parameters(&hir_parameters);
307
308 if (!skip_body && !body_list->subexpressions.is_empty()) {
309 if (sig->is_defined) {
310 ir_read_error(st, list, "function %s redefined", f->name);
311 return;
312 }
313 read_instructions(st, &sig->body, body_list, NULL);
314 sig->is_defined = true;
315 }
316
317 st->symbols->pop_scope();
318}
319
320static void
321read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions,
322 s_expression *expr, ir_loop *loop_ctx)
323{
324 // Read in a list of instructions
325 s_list *list = SX_AS_LIST(expr);
326 if (list == NULL) {
327 ir_read_error(st, expr, "Expected (<instruction> ...); found an atom.");
328 return;
329 }
330
331 foreach_iter(exec_list_iterator, it, list->subexpressions) {
332 s_expression *sub = (s_expression*) it.get();
333 ir_instruction *ir = read_instruction(st, sub, loop_ctx);
334 if (ir != NULL)
335 instructions->push_tail(ir);
336 }
337}
338
339
340static ir_instruction *
341read_instruction(_mesa_glsl_parse_state *st, s_expression *expr,
342 ir_loop *loop_ctx)
343{
344 void *ctx = st;
345 s_symbol *symbol = SX_AS_SYMBOL(expr);
346 if (symbol != NULL) {
347 if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL)
348 return new(ctx) ir_loop_jump(ir_loop_jump::jump_break);
349 if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL)
350 return new(ctx) ir_loop_jump(ir_loop_jump::jump_continue);
351 }
352
353 s_list *list = SX_AS_LIST(expr);
354 if (list == NULL || list->subexpressions.is_empty()) {
355 ir_read_error(st, expr, "Invalid instruction.\n");
356 return NULL;
357 }
358
359 s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head());
360 if (tag == NULL) {
361 ir_read_error(st, expr, "expected instruction tag");
362 return NULL;
363 }
364
365 ir_instruction *inst = NULL;
366 if (strcmp(tag->value(), "declare") == 0) {
367 inst = read_declaration(st, list);
368 } else if (strcmp(tag->value(), "assign") == 0) {
369 inst = read_assignment(st, list);
370 } else if (strcmp(tag->value(), "if") == 0) {
371 inst = read_if(st, list, loop_ctx);
372 } else if (strcmp(tag->value(), "loop") == 0) {
373 inst = read_loop(st, list);
374 } else if (strcmp(tag->value(), "return") == 0) {
375 inst = read_return(st, list);
376 } else if (strcmp(tag->value(), "function") == 0) {
377 inst = read_function(st, list, false);
378 } else {
379 inst = read_rvalue(st, list);
380 if (inst == NULL)
381 ir_read_error(st, NULL, "when reading instruction");
382 }
383 return inst;
384}
385
386
387static ir_variable *
388read_declaration(_mesa_glsl_parse_state *st, s_list *list)
389{
390 void *ctx = st;
391 if (list->length() != 4) {
392 ir_read_error(st, list, "expected (declare (<qualifiers>) <type> "
393 "<name>)");
394 return NULL;
395 }
396
397 s_list *quals = SX_AS_LIST(list->subexpressions.head->next);
398 if (quals == NULL) {
399 ir_read_error(st, list, "expected a list of variable qualifiers");
400 return NULL;
401 }
402
403 s_expression *type_expr = (s_expression*) quals->next;
404 const glsl_type *type = read_type(st, type_expr);
405 if (type == NULL)
406 return NULL;
407
408 s_symbol *var_name = SX_AS_SYMBOL(type_expr->next);
409 if (var_name == NULL) {
410 ir_read_error(st, list, "expected variable name, found non-symbol");
411 return NULL;
412 }
413
414 ir_variable *var = new(ctx) ir_variable(type, var_name->value(),
415 ir_var_auto);
416
417 foreach_iter(exec_list_iterator, it, quals->subexpressions) {
418 s_symbol *qualifier = SX_AS_SYMBOL(it.get());
419 if (qualifier == NULL) {
420 ir_read_error(st, list, "qualifier list must contain only symbols");
421 delete var;
422 return NULL;
423 }
424
425 // FINISHME: Check for duplicate/conflicting qualifiers.
426 if (strcmp(qualifier->value(), "centroid") == 0) {
427 var->centroid = 1;
428 } else if (strcmp(qualifier->value(), "invariant") == 0) {
429 var->invariant = 1;
430 } else if (strcmp(qualifier->value(), "uniform") == 0) {
431 var->mode = ir_var_uniform;
432 } else if (strcmp(qualifier->value(), "auto") == 0) {
433 var->mode = ir_var_auto;
434 } else if (strcmp(qualifier->value(), "in") == 0) {
435 var->mode = ir_var_in;
436 } else if (strcmp(qualifier->value(), "out") == 0) {
437 var->mode = ir_var_out;
438 } else if (strcmp(qualifier->value(), "inout") == 0) {
439 var->mode = ir_var_inout;
440 } else if (strcmp(qualifier->value(), "smooth") == 0) {
441 var->interpolation = ir_var_smooth;
442 } else if (strcmp(qualifier->value(), "flat") == 0) {
443 var->interpolation = ir_var_flat;
444 } else if (strcmp(qualifier->value(), "noperspective") == 0) {
445 var->interpolation = ir_var_noperspective;
446 } else {
447 ir_read_error(st, list, "unknown qualifier: %s", qualifier->value());
448 delete var;
449 return NULL;
450 }
451 }
452
453 // Add the variable to the symbol table
454 st->symbols->add_variable(var->name, var);
455
456 return var;
457}
458
459
460static ir_if *
461read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx)
462{
463 void *ctx = st;
464 if (list->length() != 4) {
465 ir_read_error(st, list, "expected (if <condition> (<then> ...) "
466 "(<else> ...))");
467 return NULL;
468 }
469
470 s_expression *cond_expr = (s_expression*) list->subexpressions.head->next;
471 ir_rvalue *condition = read_rvalue(st, cond_expr);
472 if (condition == NULL) {
473 ir_read_error(st, NULL, "when reading condition of (if ...)");
474 return NULL;
475 }
476
477 s_expression *then_expr = (s_expression*) cond_expr->next;
478 s_expression *else_expr = (s_expression*) then_expr->next;
479
480 ir_if *iff = new(ctx) ir_if(condition);
481
482 read_instructions(st, &iff->then_instructions, then_expr, loop_ctx);
483 read_instructions(st, &iff->else_instructions, else_expr, loop_ctx);
484 if (st->error) {
485 delete iff;
486 iff = NULL;
487 }
488 return iff;
489}
490
491
492static ir_loop *
493read_loop(_mesa_glsl_parse_state *st, s_list *list)
494{
495 void *ctx = st;
496 if (list->length() != 6) {
497 ir_read_error(st, list, "expected (loop <counter> <from> <to> "
498 "<increment> <body>)");
499 return NULL;
500 }
501
502 s_expression *count_expr = (s_expression*) list->subexpressions.head->next;
503 s_expression *from_expr = (s_expression*) count_expr->next;
504 s_expression *to_expr = (s_expression*) from_expr->next;
505 s_expression *inc_expr = (s_expression*) to_expr->next;
506 s_expression *body_expr = (s_expression*) inc_expr->next;
507
508 // FINISHME: actually read the count/from/to fields.
509
510 ir_loop *loop = new(ctx) ir_loop;
511 read_instructions(st, &loop->body_instructions, body_expr, loop);
512 if (st->error) {
513 delete loop;
514 loop = NULL;
515 }
516 return loop;
517}
518
519
520static ir_return *
521read_return(_mesa_glsl_parse_state *st, s_list *list)
522{
523 void *ctx = st;
524 if (list->length() != 2) {
525 ir_read_error(st, list, "expected (return <rvalue>)");
526 return NULL;
527 }
528
529 s_expression *expr = (s_expression*) list->subexpressions.head->next;
530
531 ir_rvalue *retval = read_rvalue(st, expr);
532 if (retval == NULL) {
533 ir_read_error(st, NULL, "when reading return value");
534 return NULL;
535 }
536
537 return new(ctx) ir_return(retval);
538}
539
540
541static ir_rvalue *
542read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr)
543{
544 s_list *list = SX_AS_LIST(expr);
545 if (list == NULL || list->subexpressions.is_empty())
546 return NULL;
547
548 s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head());
549 if (tag == NULL) {
550 ir_read_error(st, expr, "expected rvalue tag");
551 return NULL;
552 }
553
554 ir_rvalue *rvalue = read_dereference(st, list);
555 if (rvalue != NULL || st->error)
556 return rvalue;
557 else if (strcmp(tag->value(), "swiz") == 0) {
558 rvalue = read_swizzle(st, list);
559 } else if (strcmp(tag->value(), "expression") == 0) {
560 rvalue = read_expression(st, list);
561 } else if (strcmp(tag->value(), "call") == 0) {
562 rvalue = read_call(st, list);
563 } else if (strcmp(tag->value(), "constant") == 0) {
564 rvalue = read_constant(st, list);
565 } else {
566 rvalue = read_texture(st, list);
567 if (rvalue == NULL && !st->error)
568 ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value());
569 }
570
571 return rvalue;
572}
573
574static ir_assignment *
575read_assignment(_mesa_glsl_parse_state *st, s_list *list)
576{
577 void *ctx = st;
578 if (list->length() != 4) {
579 ir_read_error(st, list, "expected (assign <condition> <lhs> <rhs>)");
580 return NULL;
581 }
582
583 s_expression *cond_expr = (s_expression*) list->subexpressions.head->next;
584 s_expression *lhs_expr = (s_expression*) cond_expr->next;
585 s_expression *rhs_expr = (s_expression*) lhs_expr->next;
586
587 // FINISHME: Deal with "true" condition
588 ir_rvalue *condition = read_rvalue(st, cond_expr);
589 if (condition == NULL) {
590 ir_read_error(st, NULL, "when reading condition of assignment");
591 return NULL;
592 }
593
594 ir_rvalue *lhs = read_rvalue(st, lhs_expr);
595 if (lhs == NULL) {
596 ir_read_error(st, NULL, "when reading left-hand side of assignment");
597 return NULL;
598 }
599
600 ir_rvalue *rhs = read_rvalue(st, rhs_expr);
601 if (rhs == NULL) {
602 ir_read_error(st, NULL, "when reading right-hand side of assignment");
603 return NULL;
604 }
605
606 return new(ctx) ir_assignment(lhs, rhs, condition);
607}
608
609static ir_call *
610read_call(_mesa_glsl_parse_state *st, s_list *list)
611{
612 void *ctx = st;
613 if (list->length() != 3) {
614 ir_read_error(st, list, "expected (call <name> (<param> ...))");
615 return NULL;
616 }
617
618 s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next);
619 s_list *params = SX_AS_LIST(name->next);
620 if (name == NULL || params == NULL) {
621 ir_read_error(st, list, "expected (call <name> (<param> ...))");
622 return NULL;
623 }
624
625 exec_list parameters;
626
627 foreach_iter(exec_list_iterator, it, params->subexpressions) {
628 s_expression *expr = (s_expression*) it.get();
629 ir_rvalue *param = read_rvalue(st, expr);
630 if (param == NULL) {
631 ir_read_error(st, list, "when reading parameter to function call");
632 return NULL;
633 }
634 parameters.push_tail(param);
635 }
636
637 ir_function *f = st->symbols->get_function(name->value());
638 if (f == NULL) {
639 ir_read_error(st, list, "found call to undefined function %s",
640 name->value());
641 return NULL;
642 }
643
644 ir_function_signature *callee = f->matching_signature(&parameters);
645 if (callee == NULL) {
646 ir_read_error(st, list, "couldn't find matching signature for function "
647 "%s", name->value());
648 return NULL;
649 }
650
651 return new(ctx) ir_call(callee, &parameters);
652}
653
654static ir_expression *
655read_expression(_mesa_glsl_parse_state *st, s_list *list)
656{
657 void *ctx = st;
658 const unsigned list_length = list->length();
659 if (list_length < 4) {
660 ir_read_error(st, list, "expected (expression <type> <operator> "
661 "<operand> [<operand>])");
662 return NULL;
663 }
664
665 s_expression *type_expr = (s_expression*) list->subexpressions.head->next;
666 const glsl_type *type = read_type(st, type_expr);
667 if (type == NULL)
668 return NULL;
669
670 /* Read the operator */
671 s_symbol *op_sym = SX_AS_SYMBOL(type_expr->next);
672 if (op_sym == NULL) {
673 ir_read_error(st, list, "expected operator, found non-symbol");
674 return NULL;
675 }
676
677 ir_expression_operation op = ir_expression::get_operator(op_sym->value());
678 if (op == (ir_expression_operation) -1) {
679 ir_read_error(st, list, "invalid operator: %s", op_sym->value());
680 return NULL;
681 }
682
683 /* Now that we know the operator, check for the right number of operands */
684 if (ir_expression::get_num_operands(op) == 2) {
685 if (list_length != 5) {
686 ir_read_error(st, list, "expected (expression <type> %s <operand> "
687 " <operand>)", op_sym->value());
688 return NULL;
689 }
690 } else {
691 if (list_length != 4) {
692 ir_read_error(st, list, "expected (expression <type> %s <operand>)",
693 op_sym->value());
694 return NULL;
695 }
696 }
697
698 s_expression *exp1 = (s_expression*) (op_sym->next);
699 ir_rvalue *arg1 = read_rvalue(st, exp1);
700 if (arg1 == NULL) {
701 ir_read_error(st, NULL, "when reading first operand of %s",
702 op_sym->value());
703 return NULL;
704 }
705
706 ir_rvalue *arg2 = NULL;
707 if (ir_expression::get_num_operands(op) == 2) {
708 s_expression *exp2 = (s_expression*) (exp1->next);
709 arg2 = read_rvalue(st, exp2);
710 if (arg2 == NULL) {
711 ir_read_error(st, NULL, "when reading second operand of %s",
712 op_sym->value());
713 return NULL;
714 }
715 }
716
717 return new(ctx) ir_expression(op, type, arg1, arg2);
718}
719
720static ir_swizzle *
721read_swizzle(_mesa_glsl_parse_state *st, s_list *list)
722{
723 if (list->length() != 3) {
724 ir_read_error(st, list, "expected (swiz <swizzle> <rvalue>)");
725 return NULL;
726 }
727
728 s_symbol *swiz = SX_AS_SYMBOL(list->subexpressions.head->next);
729 if (swiz == NULL) {
730 ir_read_error(st, list, "expected a valid swizzle; found non-symbol");
731 return NULL;
732 }
733
734 if (strlen(swiz->value()) > 4) {
735 ir_read_error(st, list, "expected a valid swizzle; found %s",
736 swiz->value());
737 return NULL;
738 }
739
740 s_expression *sub = (s_expression*) swiz->next;
741 if (sub == NULL) {
742 ir_read_error(st, list, "expected rvalue: (swizzle %s <rvalue>)",
743 swiz->value());
744 return NULL;
745 }
746
747 ir_rvalue *rvalue = read_rvalue(st, sub);
748 if (rvalue == NULL)
749 return NULL;
750
751 ir_swizzle *ir = ir_swizzle::create(rvalue, swiz->value(),
752 rvalue->type->vector_elements);
753 if (ir == NULL)
754 ir_read_error(st, list, "invalid swizzle");
755
756 return ir;
757}
758
759static ir_constant *
760read_constant(_mesa_glsl_parse_state *st, s_list *list)
761{
762 void *ctx = st;
763 if (list->length() != 3) {
764 ir_read_error(st, list, "expected (constant <type> (...))");
765 return NULL;
766 }
767
768 s_expression *type_expr = (s_expression*) list->subexpressions.head->next;
769 const glsl_type *type = read_type(st, type_expr);
770 if (type == NULL)
771 return NULL;
772
773 s_list *values = SX_AS_LIST(type_expr->next);
774 if (values == NULL) {
775 ir_read_error(st, list, "expected (constant <type> (...))");
776 return NULL;
777 }
778
779 if (type->is_array()) {
780 const unsigned elements_supplied = values->length();
781 if (elements_supplied != type->length) {
782 ir_read_error(st, values, "expected exactly %u array elements, "
783 "given %u", type->length, elements_supplied);
784 return NULL;
785 }
786
787 exec_list elements;
788 foreach_iter(exec_list_iterator, it, values->subexpressions) {
789 s_expression *expr = (s_expression *) it.get();
790 s_list *elt = SX_AS_LIST(expr);
791 if (elt == NULL) {
792 ir_read_error(st, expr, "expected (constant ...) array element");
793 return NULL;
794 }
795
796 ir_constant *ir_elt = read_constant(st, elt);
797 if (ir_elt == NULL)
798 return NULL;
799 elements.push_tail(ir_elt);
800 }
801 return new(ctx) ir_constant(type, &elements);
802 }
803
804 const glsl_type *const base_type = type->get_base_type();
805
806 ir_constant_data data;
807
808 // Read in list of values (at most 16).
809 int k = 0;
810 foreach_iter(exec_list_iterator, it, values->subexpressions) {
811 if (k >= 16) {
812 ir_read_error(st, values, "expected at most 16 numbers");
813 return NULL;
814 }
815
816 s_expression *expr = (s_expression*) it.get();
817
818 if (base_type->base_type == GLSL_TYPE_FLOAT) {
819 s_number *value = SX_AS_NUMBER(expr);
820 if (value == NULL) {
821 ir_read_error(st, values, "expected numbers");
822 return NULL;
823 }
824 data.f[k] = value->fvalue();
825 } else {
826 s_int *value = SX_AS_INT(expr);
827 if (value == NULL) {
828 ir_read_error(st, values, "expected integers");
829 return NULL;
830 }
831
832 switch (base_type->base_type) {
833 case GLSL_TYPE_UINT: {
834 data.u[k] = value->value();
835 break;
836 }
837 case GLSL_TYPE_INT: {
838 data.i[k] = value->value();
839 break;
840 }
841 case GLSL_TYPE_BOOL: {
842 data.b[k] = value->value();
843 break;
844 }
845 default:
846 ir_read_error(st, values, "unsupported constant type");
847 return NULL;
848 }
849 }
850 ++k;
851 }
852
853 return new(ctx) ir_constant(type, &data);
854}
855
856static ir_dereference *
857read_dereference(_mesa_glsl_parse_state *st, s_expression *expr)
858{
859 s_list *list = SX_AS_LIST(expr);
860 if (list == NULL || list->subexpressions.is_empty())
861 return NULL;
862
863 s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head);
864 assert(tag != NULL);
865
866 if (strcmp(tag->value(), "var_ref") == 0)
867 return read_var_ref(st, list);
868 if (strcmp(tag->value(), "array_ref") == 0)
869 return read_array_ref(st, list);
870 if (strcmp(tag->value(), "record_ref") == 0)
871 return read_record_ref(st, list);
872 return NULL;
873}
874
875static ir_dereference *
876read_var_ref(_mesa_glsl_parse_state *st, s_list *list)
877{
878 void *ctx = st;
879 if (list->length() != 2) {
880 ir_read_error(st, list, "expected (var_ref <variable name>)");
881 return NULL;
882 }
883 s_symbol *var_name = SX_AS_SYMBOL(list->subexpressions.head->next);
884 if (var_name == NULL) {
885 ir_read_error(st, list, "expected (var_ref <variable name>)");
886 return NULL;
887 }
888
889 ir_variable *var = st->symbols->get_variable(var_name->value());
890 if (var == NULL) {
891 ir_read_error(st, list, "undeclared variable: %s", var_name->value());
892 return NULL;
893 }
894
895 return new(ctx) ir_dereference_variable(var);
896}
897
898static ir_dereference *
899read_array_ref(_mesa_glsl_parse_state *st, s_list *list)
900{
901 void *ctx = st;
902 if (list->length() != 3) {
903 ir_read_error(st, list, "expected (array_ref <rvalue> <index>)");
904 return NULL;
905 }
906
907 s_expression *subj_expr = (s_expression*) list->subexpressions.head->next;
908 ir_rvalue *subject = read_rvalue(st, subj_expr);
909 if (subject == NULL) {
910 ir_read_error(st, NULL, "when reading the subject of an array_ref");
911 return NULL;
912 }
913
914 s_expression *idx_expr = (s_expression*) subj_expr->next;
915 ir_rvalue *idx = read_rvalue(st, idx_expr);
916 return new(ctx) ir_dereference_array(subject, idx);
917}
918
919static ir_dereference *
920read_record_ref(_mesa_glsl_parse_state *st, s_list *list)
921{
922 void *ctx = st;
923 if (list->length() != 3) {
924 ir_read_error(st, list, "expected (record_ref <rvalue> <field>)");
925 return NULL;
926 }
927
928 s_expression *subj_expr = (s_expression*) list->subexpressions.head->next;
929 ir_rvalue *subject = read_rvalue(st, subj_expr);
930 if (subject == NULL) {
931 ir_read_error(st, NULL, "when reading the subject of a record_ref");
932 return NULL;
933 }
934
935 s_symbol *field = SX_AS_SYMBOL(subj_expr->next);
936 if (field == NULL) {
937 ir_read_error(st, list, "expected (record_ref ... <field name>)");
938 return NULL;
939 }
940 return new(ctx) ir_dereference_record(subject, field->value());
941}
942
943static bool
944valid_texture_list_length(ir_texture_opcode op, s_list *list)
945{
946 unsigned required_length = 7;
947 if (op == ir_txf)
948 required_length = 5;
949 else if (op == ir_tex)
950 required_length = 6;
951
952 return list->length() == required_length;
953}
954
955static ir_texture *
956read_texture(_mesa_glsl_parse_state *st, s_list *list)
957{
958 void *ctx = st;
959 s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head);
960 assert(tag != NULL);
961
962 ir_texture_opcode op = ir_texture::get_opcode(tag->value());
963 if (op == (ir_texture_opcode) -1)
964 return NULL;
965
966 if (!valid_texture_list_length(op, list)) {
967 ir_read_error(st, NULL, "invalid list size in (%s ...)", tag->value());
968 return NULL;
969 }
970
971 ir_texture *tex = new(ctx) ir_texture(op);
972
973 // Read sampler (must be a deref)
974 s_expression *sampler_expr = (s_expression *) tag->next;
975 ir_dereference *sampler = read_dereference(st, sampler_expr);
976 if (sampler == NULL) {
977 ir_read_error(st, NULL, "when reading sampler in (%s ...)", tag->value());
978 return NULL;
979 }
980 tex->set_sampler(sampler);
981
982 // Read coordinate (any rvalue)
983 s_expression *coordinate_expr = (s_expression *) sampler_expr->next;
984 tex->coordinate = read_rvalue(st, coordinate_expr);
985 if (tex->coordinate == NULL) {
986 ir_read_error(st, NULL, "when reading coordinate in (%s ...)",
987 tag->value());
988 return NULL;
989 }
990
991 // Read texel offset, i.e. (0 0 0)
992 s_list *offset_list = SX_AS_LIST(coordinate_expr->next);
993 if (offset_list == NULL || offset_list->length() != 3) {
994 ir_read_error(st, offset_list, "expected (<int> <int> <int>)");
995 return NULL;
996 }
997 s_int *offset_x = SX_AS_INT(offset_list->subexpressions.head);
998 s_int *offset_y = SX_AS_INT(offset_x->next);
999 s_int *offset_z = SX_AS_INT(offset_y->next);
1000 if (offset_x == NULL || offset_y == NULL || offset_z == NULL) {
1001 ir_read_error(st, offset_list, "expected (<int> <int> <int>)");
1002 return NULL;
1003 }
1004 tex->offsets[0] = offset_x->value();
1005 tex->offsets[1] = offset_y->value();
1006 tex->offsets[2] = offset_z->value();
1007
1008 if (op == ir_txf) {
1009 s_expression *lod_expr = (s_expression *) offset_list->next;
1010 tex->lod_info.lod = read_rvalue(st, lod_expr);
1011 if (tex->lod_info.lod == NULL) {
1012 ir_read_error(st, NULL, "when reading LOD in (txf ...)");
1013 return NULL;
1014 }
1015 } else {
1016 s_expression *proj_expr = (s_expression *) offset_list->next;
1017 s_int *proj_as_int = SX_AS_INT(proj_expr);
1018 if (proj_as_int && proj_as_int->value() == 1) {
1019 tex->projector = NULL;
1020 } else {
1021 tex->projector = read_rvalue(st, proj_expr);
1022 if (tex->projector == NULL) {
1023 ir_read_error(st, NULL, "when reading projective divide in (%s ..)",
1024 tag->value());
1025 return NULL;
1026 }
1027 }
1028
1029 s_list *shadow_list = SX_AS_LIST(proj_expr->next);
1030 if (shadow_list == NULL) {
1031 ir_read_error(st, NULL, "shadow comparitor must be a list");
1032 return NULL;
1033 }
1034 if (shadow_list->subexpressions.is_empty()) {
1035 tex->shadow_comparitor= NULL;
1036 } else {
1037 tex->shadow_comparitor = read_rvalue(st, shadow_list);
1038 if (tex->shadow_comparitor == NULL) {
1039 ir_read_error(st, NULL, "when reading shadow comparitor in (%s ..)",
1040 tag->value());
1041 return NULL;
1042 }
1043 }
1044 s_expression *lod_expr = (s_expression *) shadow_list->next;
1045
1046 switch (op) {
1047 case ir_txb:
1048 tex->lod_info.bias = read_rvalue(st, lod_expr);
1049 if (tex->lod_info.bias == NULL) {
1050 ir_read_error(st, NULL, "when reading LOD bias in (txb ...)");
1051 return NULL;
1052 }
1053 break;
1054 case ir_txl:
1055 tex->lod_info.lod = read_rvalue(st, lod_expr);
1056 if (tex->lod_info.lod == NULL) {
1057 ir_read_error(st, NULL, "when reading LOD in (txl ...)");
1058 return NULL;
1059 }
1060 break;
1061 case ir_txd: {
1062 s_list *lod_list = SX_AS_LIST(lod_expr);
1063 if (lod_list->length() != 2) {
1064 ir_read_error(st, lod_expr, "expected (dPdx dPdy) in (txd ...)");
1065 return NULL;
1066 }
1067 s_expression *dx_expr = (s_expression *) lod_list->subexpressions.head;
1068 s_expression *dy_expr = (s_expression *) dx_expr->next;
1069
1070 tex->lod_info.grad.dPdx = read_rvalue(st, dx_expr);
1071 if (tex->lod_info.grad.dPdx == NULL) {
1072 ir_read_error(st, NULL, "when reading dPdx in (txd ...)");
1073 return NULL;
1074 }
1075 tex->lod_info.grad.dPdy = read_rvalue(st, dy_expr);
1076 if (tex->lod_info.grad.dPdy == NULL) {
1077 ir_read_error(st, NULL, "when reading dPdy in (txd ...)");
1078 return NULL;
1079 }
1080 break;
1081 }
1082 default:
1083 // tex doesn't have any extra parameters and txf was handled earlier.
1084 break;
1085 };
1086 }
1087 return tex;
1088}
diff --git a/src/glsl/ir_reader.h b/src/glsl/ir_reader.h
new file mode 100644
index 00000000000..aef2ca23bd2
--- /dev/null
+++ b/src/glsl/ir_reader.h
@@ -0,0 +1,34 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef IR_READER_H
27#define IR_READER_H
28
29#include "ir.h"
30
31void _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
32 const char *src, bool scan_for_prototypes);
33
34#endif /* IR_READER_H */
diff --git a/src/glsl/ir_rvalue_visitor.cpp b/src/glsl/ir_rvalue_visitor.cpp
new file mode 100644
index 00000000000..613b07c3029
--- /dev/null
+++ b/src/glsl/ir_rvalue_visitor.cpp
@@ -0,0 +1,134 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_rvalue_visitor.cpp
26 *
27 * Generic class to implement the common pattern we have of wanting to
28 * visit each ir_rvalue * and possibly change that node to a different
29 * class.
30 */
31
32#include "ir.h"
33#include "ir_visitor.h"
34#include "ir_rvalue_visitor.h"
35#include "ir_print_visitor.h"
36#include "glsl_types.h"
37
38ir_visitor_status
39ir_rvalue_visitor::visit_leave(ir_expression *ir)
40{
41 unsigned int operand;
42
43 for (operand = 0; operand < ir->get_num_operands(); operand++) {
44 handle_rvalue(&ir->operands[operand]);
45 }
46
47 return visit_continue;
48}
49
50ir_visitor_status
51ir_rvalue_visitor::visit_leave(ir_texture *ir)
52{
53 handle_rvalue(&ir->coordinate);
54 handle_rvalue(&ir->projector);
55 handle_rvalue(&ir->shadow_comparitor);
56
57 switch (ir->op) {
58 case ir_tex:
59 break;
60 case ir_txb:
61 handle_rvalue(&ir->lod_info.bias);
62 break;
63 case ir_txf:
64 case ir_txl:
65 handle_rvalue(&ir->lod_info.lod);
66 break;
67 case ir_txd:
68 handle_rvalue(&ir->lod_info.grad.dPdx);
69 handle_rvalue(&ir->lod_info.grad.dPdy);
70 break;
71 }
72
73 return visit_continue;
74}
75
76ir_visitor_status
77ir_rvalue_visitor::visit_leave(ir_swizzle *ir)
78{
79 handle_rvalue(&ir->val);
80 return visit_continue;
81}
82
83ir_visitor_status
84ir_rvalue_visitor::visit_leave(ir_dereference_array *ir)
85{
86 handle_rvalue(&ir->array_index);
87 handle_rvalue(&ir->array);
88 return visit_continue;
89}
90
91ir_visitor_status
92ir_rvalue_visitor::visit_leave(ir_dereference_record *ir)
93{
94 handle_rvalue(&ir->record);
95 return visit_continue;
96}
97
98ir_visitor_status
99ir_rvalue_visitor::visit_leave(ir_assignment *ir)
100{
101 handle_rvalue(&ir->rhs);
102 handle_rvalue(&ir->condition);
103
104 return visit_continue;
105}
106
107ir_visitor_status
108ir_rvalue_visitor::visit_leave(ir_call *ir)
109{
110 foreach_iter(exec_list_iterator, iter, *ir) {
111 ir_rvalue *param = (ir_rvalue *)iter.get();
112 ir_rvalue *new_param = param;
113 handle_rvalue(&new_param);
114
115 if (new_param != param) {
116 param->replace_with(new_param);
117 }
118 }
119 return visit_continue;
120}
121
122ir_visitor_status
123ir_rvalue_visitor::visit_leave(ir_return *ir)
124{
125 handle_rvalue(&ir->value);;
126 return visit_continue;
127}
128
129ir_visitor_status
130ir_rvalue_visitor::visit_leave(ir_if *ir)
131{
132 handle_rvalue(&ir->condition);
133 return visit_continue;
134}
diff --git a/src/glsl/ir_rvalue_visitor.h b/src/glsl/ir_rvalue_visitor.h
new file mode 100644
index 00000000000..31a56beb9b8
--- /dev/null
+++ b/src/glsl/ir_rvalue_visitor.h
@@ -0,0 +1,47 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_rvalue_visitor.h
26 *
27 * Generic class to implement the common pattern we have of wanting to
28 * visit each ir_rvalue * and possibly change that node to a different
29 * class. Just implement handle_rvalue() and you will be called with
30 * a pointer to each rvalue in the tree.
31 */
32
33class ir_rvalue_visitor : public ir_hierarchical_visitor {
34public:
35
36 virtual ir_visitor_status visit_leave(ir_assignment *);
37 virtual ir_visitor_status visit_leave(ir_call *);
38 virtual ir_visitor_status visit_leave(ir_dereference_array *);
39 virtual ir_visitor_status visit_leave(ir_dereference_record *);
40 virtual ir_visitor_status visit_leave(ir_expression *);
41 virtual ir_visitor_status visit_leave(ir_if *);
42 virtual ir_visitor_status visit_leave(ir_return *);
43 virtual ir_visitor_status visit_leave(ir_swizzle *);
44 virtual ir_visitor_status visit_leave(ir_texture *);
45
46 virtual void handle_rvalue(ir_rvalue **rvalue) = 0;
47};
diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp
new file mode 100644
index 00000000000..658637775a4
--- /dev/null
+++ b/src/glsl/ir_set_program_inouts.cpp
@@ -0,0 +1,167 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_set_program_inouts.cpp
26 *
27 * Sets the InputsRead and OutputsWritten of Mesa programs.
28 *
29 * Mesa programs (gl_program, not gl_shader_program) have a set of
30 * flags indicating which varyings are read and written. Computing
31 * which are actually read from some sort of backend code can be
32 * tricky when variable array indexing involved. So this pass
33 * provides support for setting InputsRead and OutputsWritten right
34 * from the GLSL IR.
35 */
36
37extern "C" {
38#include "main/mtypes.h"
39#include "program/hash_table.h"
40}
41#include "ir.h"
42#include "ir_visitor.h"
43#include "glsl_types.h"
44
45class ir_set_program_inouts_visitor : public ir_hierarchical_visitor {
46public:
47 ir_set_program_inouts_visitor(struct gl_program *prog)
48 {
49 this->prog = prog;
50 this->ht = hash_table_ctor(0,
51 hash_table_pointer_hash,
52 hash_table_pointer_compare);
53 }
54 ir_set_program_inouts_visitor()
55 {
56 hash_table_dtor(this->ht);
57 }
58
59 virtual ir_visitor_status visit_enter(ir_dereference_array *);
60 virtual ir_visitor_status visit_enter(ir_function_signature *);
61 virtual ir_visitor_status visit(ir_dereference_variable *);
62 virtual ir_visitor_status visit(ir_variable *);
63
64 struct gl_program *prog;
65 struct hash_table *ht;
66};
67
68static void
69mark(struct gl_program *prog, ir_variable *var, int index)
70{
71 /* As of GLSL 1.20, varyings can only be floats, floating-point
72 * vectors or matrices, or arrays of them. For Mesa programs using
73 * InputsRead/OutputsWritten, everything but matrices uses one
74 * slot, while matrices use a slot per column. Presumably
75 * something doing a more clever packing would use something other
76 * than InputsRead/OutputsWritten.
77 */
78 const glsl_type *element_type;
79 int element_size;
80
81 if (var->type->is_array())
82 element_type = var->type->fields.array;
83 else
84 element_type = var->type;
85
86 if (element_type->is_matrix())
87 element_size = element_type->matrix_columns;
88 else
89 element_size = 1;
90
91 index *= element_size;
92 for (int i = 0; i < element_size; i++) {
93 if (var->mode == ir_var_in)
94 prog->InputsRead |= BITFIELD64_BIT(var->location + index + i);
95 else
96 prog->OutputsWritten |= BITFIELD64_BIT(var->location + index + i);
97 }
98}
99
100/* Default handler: Mark all the locations in the variable as used. */
101ir_visitor_status
102ir_set_program_inouts_visitor::visit(ir_dereference_variable *ir)
103{
104 if (hash_table_find(this->ht, ir->var) == NULL)
105 return visit_continue;
106
107 if (ir->type->is_array()) {
108 for (unsigned int i = 0; i < ir->type->length; i++) {
109 mark(this->prog, ir->var, i);
110 }
111 } else {
112 mark(this->prog, ir->var, 0);
113 }
114
115 return visit_continue;
116}
117
118ir_visitor_status
119ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir)
120{
121 ir_dereference_variable *deref_var;
122 ir_constant *index = ir->array_index->as_constant();
123 deref_var = ir->array->as_dereference_variable();
124 ir_variable *var = NULL;
125
126 /* Check that we're dereferencing a shader in or out */
127 if (deref_var)
128 var = (ir_variable *)hash_table_find(this->ht, deref_var->var);
129
130 if (index && var) {
131 mark(this->prog, var, index->value.i[0]);
132 return visit_continue_with_parent;
133 }
134
135 return visit_continue;
136}
137
138ir_visitor_status
139ir_set_program_inouts_visitor::visit(ir_variable *ir)
140{
141 if (ir->mode == ir_var_in ||
142 ir->mode == ir_var_out) {
143 hash_table_insert(this->ht, ir, ir);
144 }
145
146 return visit_continue;
147}
148
149ir_visitor_status
150ir_set_program_inouts_visitor::visit_enter(ir_function_signature *ir)
151{
152 /* We don't want to descend into the function parameters and
153 * consider them as shader inputs or outputs.
154 */
155 visit_list_elements(this, &ir->body);
156 return visit_continue_with_parent;
157}
158
159void
160do_set_program_inouts(exec_list *instructions, struct gl_program *prog)
161{
162 ir_set_program_inouts_visitor v(prog);
163
164 prog->InputsRead = 0;
165 prog->OutputsWritten = 0;
166 visit_list_elements(&v, instructions);
167}
diff --git a/src/glsl/ir_structure_splitting.cpp b/src/glsl/ir_structure_splitting.cpp
new file mode 100644
index 00000000000..91f6dac23e0
--- /dev/null
+++ b/src/glsl/ir_structure_splitting.cpp
@@ -0,0 +1,356 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_structure_splitting.cpp
26 *
27 * If a structure is only ever referenced by its components, then
28 * split those components out to individual variables so they can be
29 * handled normally by other optimization passes.
30 *
31 * This skips structures like uniforms, which need to be accessible as
32 * structures for their access by the GL.
33 */
34
35#include "ir.h"
36#include "ir_visitor.h"
37#include "ir_print_visitor.h"
38#include "ir_rvalue_visitor.h"
39#include "glsl_types.h"
40
41static bool debug = false;
42
43class variable_entry : public exec_node
44{
45public:
46 variable_entry(ir_variable *var)
47 {
48 this->var = var;
49 this->whole_structure_access = 0;
50 this->declaration = false;
51 this->components = NULL;
52 this->mem_ctx = NULL;
53 }
54
55 ir_variable *var; /* The key: the variable's pointer. */
56
57 /** Number of times the variable is referenced, including assignments. */
58 unsigned whole_structure_access;
59
60 bool declaration; /* If the variable had a decl in the instruction stream */
61
62 ir_variable **components;
63
64 /** talloc_parent(this->var) -- the shader's talloc context. */
65 void *mem_ctx;
66};
67
68class ir_structure_reference_visitor : public ir_hierarchical_visitor {
69public:
70 ir_structure_reference_visitor(void)
71 {
72 this->mem_ctx = talloc_new(NULL);
73 this->variable_list.make_empty();
74 }
75
76 ~ir_structure_reference_visitor(void)
77 {
78 talloc_free(mem_ctx);
79 }
80
81 virtual ir_visitor_status visit(ir_variable *);
82 virtual ir_visitor_status visit(ir_dereference_variable *);
83 virtual ir_visitor_status visit_enter(ir_dereference_record *);
84 virtual ir_visitor_status visit_enter(ir_assignment *);
85 virtual ir_visitor_status visit_enter(ir_function_signature *);
86
87 variable_entry *get_variable_entry(ir_variable *var);
88
89 /* List of variable_entry */
90 exec_list variable_list;
91
92 void *mem_ctx;
93};
94
95variable_entry *
96ir_structure_reference_visitor::get_variable_entry(ir_variable *var)
97{
98 assert(var);
99
100 if (!var->type->is_record() || var->mode == ir_var_uniform)
101 return NULL;
102
103 foreach_iter(exec_list_iterator, iter, this->variable_list) {
104 variable_entry *entry = (variable_entry *)iter.get();
105 if (entry->var == var)
106 return entry;
107 }
108
109 variable_entry *entry = new(mem_ctx) variable_entry(var);
110 this->variable_list.push_tail(entry);
111 return entry;
112}
113
114
115ir_visitor_status
116ir_structure_reference_visitor::visit(ir_variable *ir)
117{
118 variable_entry *entry = this->get_variable_entry(ir);
119
120 if (entry)
121 entry->declaration = true;
122
123 return visit_continue;
124}
125
126ir_visitor_status
127ir_structure_reference_visitor::visit(ir_dereference_variable *ir)
128{
129 ir_variable *const var = ir->variable_referenced();
130 variable_entry *entry = this->get_variable_entry(var);
131
132 if (entry)
133 entry->whole_structure_access++;
134
135 return visit_continue;
136}
137
138ir_visitor_status
139ir_structure_reference_visitor::visit_enter(ir_dereference_record *ir)
140{
141 (void) ir;
142 /* Don't descend into the ir_dereference_variable below. */
143 return visit_continue_with_parent;
144}
145
146ir_visitor_status
147ir_structure_reference_visitor::visit_enter(ir_assignment *ir)
148{
149 if (ir->lhs->as_dereference_variable() &&
150 ir->rhs->as_dereference_variable() &&
151 !ir->condition) {
152 /* We'll split copies of a structure to copies of components, so don't
153 * descend to the ir_dereference_variables.
154 */
155 return visit_continue_with_parent;
156 }
157 return visit_continue;
158}
159
160ir_visitor_status
161ir_structure_reference_visitor::visit_enter(ir_function_signature *ir)
162{
163 /* We don't want to descend into the function parameters and
164 * dead-code eliminate them, so just accept the body here.
165 */
166 visit_list_elements(this, &ir->body);
167 return visit_continue_with_parent;
168}
169
170class ir_structure_splitting_visitor : public ir_rvalue_visitor {
171public:
172 ir_structure_splitting_visitor(exec_list *vars)
173 {
174 this->variable_list = vars;
175 }
176
177 virtual ~ir_structure_splitting_visitor()
178 {
179 }
180
181 virtual ir_visitor_status visit_leave(ir_assignment *);
182
183 void split_deref(ir_dereference **deref);
184 void handle_rvalue(ir_rvalue **rvalue);
185 variable_entry *get_splitting_entry(ir_variable *var);
186
187 exec_list *variable_list;
188 void *mem_ctx;
189};
190
191variable_entry *
192ir_structure_splitting_visitor::get_splitting_entry(ir_variable *var)
193{
194 assert(var);
195
196 if (!var->type->is_record())
197 return NULL;
198
199 foreach_iter(exec_list_iterator, iter, *this->variable_list) {
200 variable_entry *entry = (variable_entry *)iter.get();
201 if (entry->var == var) {
202 return entry;
203 }
204 }
205
206 return NULL;
207}
208
209void
210ir_structure_splitting_visitor::split_deref(ir_dereference **deref)
211{
212 if ((*deref)->ir_type != ir_type_dereference_record)
213 return;
214
215 ir_dereference_record *deref_record = (ir_dereference_record *)*deref;
216 ir_dereference_variable *deref_var = deref_record->record->as_dereference_variable();
217 if (!deref_var)
218 return;
219
220 variable_entry *entry = get_splitting_entry(deref_var->var);
221 if (!entry)
222 return;
223
224 unsigned int i;
225 for (i = 0; i < entry->var->type->length; i++) {
226 if (strcmp(deref_record->field,
227 entry->var->type->fields.structure[i].name) == 0)
228 break;
229 }
230 assert(i != entry->var->type->length);
231
232 *deref = new(entry->mem_ctx) ir_dereference_variable(entry->components[i]);
233}
234
235void
236ir_structure_splitting_visitor::handle_rvalue(ir_rvalue **rvalue)
237{
238 if (!*rvalue)
239 return;
240
241 ir_dereference *deref = (*rvalue)->as_dereference();
242
243 if (!deref)
244 return;
245
246 split_deref(&deref);
247 *rvalue = deref;
248}
249
250ir_visitor_status
251ir_structure_splitting_visitor::visit_leave(ir_assignment *ir)
252{
253 ir_dereference_variable *lhs_deref = ir->lhs->as_dereference_variable();
254 ir_dereference_variable *rhs_deref = ir->rhs->as_dereference_variable();
255 variable_entry *lhs_entry = lhs_deref ? get_splitting_entry(lhs_deref->var) : NULL;
256 variable_entry *rhs_entry = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL;
257 const glsl_type *type = ir->rhs->type;
258
259 if ((lhs_entry || rhs_entry) && !ir->condition) {
260 for (unsigned int i = 0; i < type->length; i++) {
261 ir_dereference *new_lhs, *new_rhs;
262 void *mem_ctx = lhs_entry ? lhs_entry->mem_ctx : rhs_entry->mem_ctx;
263
264 if (lhs_entry) {
265 new_lhs = new(mem_ctx) ir_dereference_variable(lhs_entry->components[i]);
266 } else {
267 new_lhs = new(mem_ctx)
268 ir_dereference_record(ir->lhs->clone(mem_ctx, NULL),
269 type->fields.structure[i].name);
270 }
271
272 if (rhs_entry) {
273 new_rhs = new(mem_ctx) ir_dereference_variable(rhs_entry->components[i]);
274 } else {
275 new_rhs = new(mem_ctx)
276 ir_dereference_record(ir->rhs->clone(mem_ctx, NULL),
277 type->fields.structure[i].name);
278 }
279
280 ir->insert_before(new(mem_ctx) ir_assignment(new_lhs,
281 new_rhs,
282 NULL));
283 }
284 ir->remove();
285 } else {
286 handle_rvalue(&ir->rhs);
287 split_deref(&ir->lhs);
288 }
289
290 handle_rvalue(&ir->condition);
291
292 return visit_continue;
293}
294
295bool
296do_structure_splitting(exec_list *instructions)
297{
298 ir_structure_reference_visitor refs;
299
300 visit_list_elements(&refs, instructions);
301
302 /* Trim out variables we can't split. */
303 foreach_iter(exec_list_iterator, iter, refs.variable_list) {
304 variable_entry *entry = (variable_entry *)iter.get();
305
306 if (debug) {
307 printf("structure %s@%p: decl %d, whole_access %d\n",
308 entry->var->name, (void *) entry->var, entry->declaration,
309 entry->whole_structure_access);
310 }
311
312 if (!entry->declaration || entry->whole_structure_access) {
313 entry->remove();
314 }
315 }
316
317 if (refs.variable_list.is_empty())
318 return false;
319
320 void *mem_ctx = talloc_new(NULL);
321
322 /* Replace the decls of the structures to be split with their split
323 * components.
324 */
325 foreach_iter(exec_list_iterator, iter, refs.variable_list) {
326 variable_entry *entry = (variable_entry *)iter.get();
327 const struct glsl_type *type = entry->var->type;
328
329 entry->mem_ctx = talloc_parent(entry->var);
330
331 entry->components = talloc_array(mem_ctx,
332 ir_variable *,
333 type->length);
334
335 for (unsigned int i = 0; i < entry->var->type->length; i++) {
336 const char *name = talloc_asprintf(mem_ctx, "%s_%s",
337 entry->var->name,
338 type->fields.structure[i].name);
339
340 entry->components[i] =
341 new(entry->mem_ctx) ir_variable(type->fields.structure[i].type,
342 name,
343 ir_var_temporary);
344 entry->var->insert_before(entry->components[i]);
345 }
346
347 entry->var->remove();
348 }
349
350 ir_structure_splitting_visitor split(&refs.variable_list);
351 visit_list_elements(&split, instructions);
352
353 talloc_free(mem_ctx);
354
355 return true;
356}
diff --git a/src/glsl/ir_sub_to_add_neg.cpp b/src/glsl/ir_sub_to_add_neg.cpp
new file mode 100644
index 00000000000..7ed8c1495e3
--- /dev/null
+++ b/src/glsl/ir_sub_to_add_neg.cpp
@@ -0,0 +1,76 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_sub_to_add_neg.cpp
26 *
27 * Breaks an ir_binop_sub expression down to add(op0, neg(op1))
28 *
29 * This simplifies expression reassociation, and for many backends
30 * there is no subtract operation separate from adding the negation.
31 * For backends with native subtract operations, they will probably
32 * want to recognize add(op0, neg(op1)) or the other way around to
33 * produce a subtract anyway.
34 */
35
36#include "ir.h"
37
38class ir_sub_to_add_neg_visitor : public ir_hierarchical_visitor {
39public:
40 ir_sub_to_add_neg_visitor()
41 {
42 this->progress = false;
43 }
44
45 ir_visitor_status visit_leave(ir_expression *);
46
47 bool progress;
48};
49
50bool
51do_sub_to_add_neg(exec_list *instructions)
52{
53 ir_sub_to_add_neg_visitor v;
54
55 visit_list_elements(&v, instructions);
56 return v.progress;
57}
58
59ir_visitor_status
60ir_sub_to_add_neg_visitor::visit_leave(ir_expression *ir)
61{
62 if (ir->operation != ir_binop_sub)
63 return visit_continue;
64
65 void *mem_ctx = talloc_parent(ir);
66
67 ir->operation = ir_binop_add;
68 ir->operands[1] = new(mem_ctx) ir_expression(ir_unop_neg,
69 ir->operands[1]->type,
70 ir->operands[1],
71 NULL);
72
73 this->progress = true;
74
75 return visit_continue;
76}
diff --git a/src/glsl/ir_swizzle_swizzle.cpp b/src/glsl/ir_swizzle_swizzle.cpp
new file mode 100644
index 00000000000..0ffb4fa3133
--- /dev/null
+++ b/src/glsl/ir_swizzle_swizzle.cpp
@@ -0,0 +1,93 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_swizzle_swizzle.cpp
26 *
27 * Eliminates the second swizzle in a swizzle chain.
28 */
29
30#include "ir.h"
31#include "ir_visitor.h"
32#include "ir_optimization.h"
33#include "glsl_types.h"
34
35class ir_swizzle_swizzle_visitor : public ir_hierarchical_visitor {
36public:
37 ir_swizzle_swizzle_visitor()
38 {
39 progress = false;
40 }
41
42 virtual ir_visitor_status visit_enter(ir_swizzle *);
43
44 bool progress;
45};
46
47ir_visitor_status
48ir_swizzle_swizzle_visitor::visit_enter(ir_swizzle *ir)
49{
50 int mask2[4];
51
52 ir_swizzle *swiz2 = ir->val->as_swizzle();
53 if (!swiz2)
54 return visit_continue;
55
56 memset(&mask2, 0, sizeof(mask2));
57 if (swiz2->mask.num_components >= 1)
58 mask2[0] = swiz2->mask.x;
59 if (swiz2->mask.num_components >= 2)
60 mask2[1] = swiz2->mask.y;
61 if (swiz2->mask.num_components >= 3)
62 mask2[2] = swiz2->mask.z;
63 if (swiz2->mask.num_components >= 4)
64 mask2[3] = swiz2->mask.w;
65
66 if (ir->mask.num_components >= 1)
67 ir->mask.x = mask2[ir->mask.x];
68 if (ir->mask.num_components >= 2)
69 ir->mask.y = mask2[ir->mask.y];
70 if (ir->mask.num_components >= 3)
71 ir->mask.z = mask2[ir->mask.z];
72 if (ir->mask.num_components >= 4)
73 ir->mask.w = mask2[ir->mask.w];
74
75 ir->val = swiz2->val;
76
77 this->progress = true;
78
79 return visit_continue;
80}
81
82/**
83 * Does a copy propagation pass on the code present in the instruction stream.
84 */
85bool
86do_swizzle_swizzle(exec_list *instructions)
87{
88 ir_swizzle_swizzle_visitor v;
89
90 v.run(instructions);
91
92 return v.progress;
93}
diff --git a/src/glsl/ir_tree_grafting.cpp b/src/glsl/ir_tree_grafting.cpp
new file mode 100644
index 00000000000..6acc5b86c51
--- /dev/null
+++ b/src/glsl/ir_tree_grafting.cpp
@@ -0,0 +1,361 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_tree_grafting.cpp
26 *
27 * Takes assignments to variables that are dereferenced only once and
28 * pastes the RHS expression into where the variable is dereferenced.
29 *
30 * In the process of various operations like function inlining and
31 * tertiary op handling, we'll end up with our expression trees having
32 * been chopped up into a series of assignments of short expressions
33 * to temps. Other passes like ir_algebraic.cpp would prefer to see
34 * the deepest expression trees they can to try to optimize them.
35 *
36 * This is a lot like copy propagaton. In comparison, copy
37 * propagation only acts on plain copies, not arbitrary expressions on
38 * the RHS. Generally, we wouldn't want to go pasting some
39 * complicated expression everywhere it got used, though, so we don't
40 * handle expressions in that pass.
41 *
42 * The hard part is making sure we don't move an expression across
43 * some other assignments that would change the value of the
44 * expression. So we split this into two passes: First, find the
45 * variables in our scope which are written to once and read once, and
46 * then go through basic blocks seeing if we find an opportunity to
47 * move those expressions safely.
48 */
49
50#include "ir.h"
51#include "ir_visitor.h"
52#include "ir_variable_refcount.h"
53#include "ir_basic_block.h"
54#include "ir_optimization.h"
55#include "glsl_types.h"
56
57static bool debug = false;
58
59class ir_tree_grafting_visitor : public ir_hierarchical_visitor {
60public:
61 ir_tree_grafting_visitor(ir_assignment *graft_assign,
62 ir_variable *graft_var)
63 {
64 this->progress = false;
65 this->graft_assign = graft_assign;
66 this->graft_var = graft_var;
67 }
68
69 virtual ir_visitor_status visit_leave(class ir_assignment *);
70 virtual ir_visitor_status visit_enter(class ir_call *);
71 virtual ir_visitor_status visit_enter(class ir_expression *);
72 virtual ir_visitor_status visit_enter(class ir_function *);
73 virtual ir_visitor_status visit_enter(class ir_function_signature *);
74 virtual ir_visitor_status visit_enter(class ir_if *);
75 virtual ir_visitor_status visit_enter(class ir_loop *);
76 virtual ir_visitor_status visit_enter(class ir_swizzle *);
77 virtual ir_visitor_status visit_enter(class ir_texture *);
78
79 bool do_graft(ir_rvalue **rvalue);
80
81 bool progress;
82 ir_variable *graft_var;
83 ir_assignment *graft_assign;
84};
85
86struct find_deref_info {
87 ir_variable *var;
88 bool found;
89};
90
91void
92dereferences_variable_callback(ir_instruction *ir, void *data)
93{
94 struct find_deref_info *info = (struct find_deref_info *)data;
95 ir_dereference_variable *deref = ir->as_dereference_variable();
96
97 if (deref && deref->var == info->var)
98 info->found = true;
99}
100
101static bool
102dereferences_variable(ir_instruction *ir, ir_variable *var)
103{
104 struct find_deref_info info;
105
106 info.var = var;
107 info.found = false;
108
109 visit_tree(ir, dereferences_variable_callback, &info);
110
111 return info.found;
112}
113
114bool
115ir_tree_grafting_visitor::do_graft(ir_rvalue **rvalue)
116{
117 if (!*rvalue)
118 return false;
119
120 ir_dereference_variable *deref = (*rvalue)->as_dereference_variable();
121
122 if (!deref || deref->var != this->graft_var)
123 return false;
124
125 if (debug) {
126 printf("GRAFTING:\n");
127 this->graft_assign->print();
128 printf("\n");
129 printf("TO:\n");
130 (*rvalue)->print();
131 printf("\n");
132 }
133
134 this->graft_assign->remove();
135 *rvalue = this->graft_assign->rhs;
136
137 this->progress = true;
138 return true;
139}
140
141ir_visitor_status
142ir_tree_grafting_visitor::visit_enter(ir_loop *ir)
143{
144 (void)ir;
145 /* Do not traverse into the body of the loop since that is a
146 * different basic block.
147 */
148 return visit_stop;
149}
150
151ir_visitor_status
152ir_tree_grafting_visitor::visit_leave(ir_assignment *ir)
153{
154 if (do_graft(&ir->rhs) ||
155 do_graft(&ir->condition))
156 return visit_stop;
157
158 /* If this assignment updates a variable used in the assignment
159 * we're trying to graft, then we're done.
160 */
161 if (dereferences_variable(this->graft_assign->rhs,
162 ir->lhs->variable_referenced())) {
163 if (debug) {
164 printf("graft killed by: ");
165 ir->print();
166 printf("\n");
167 }
168 return visit_stop;
169 }
170
171 return visit_continue;
172}
173
174ir_visitor_status
175ir_tree_grafting_visitor::visit_enter(ir_function *ir)
176{
177 (void) ir;
178 return visit_continue_with_parent;
179}
180
181ir_visitor_status
182ir_tree_grafting_visitor::visit_enter(ir_function_signature *ir)
183{
184 (void)ir;
185 return visit_continue_with_parent;
186}
187
188ir_visitor_status
189ir_tree_grafting_visitor::visit_enter(ir_call *ir)
190{
191 /* Reminder: iterating ir_call iterates its parameters. */
192 foreach_iter(exec_list_iterator, iter, *ir) {
193 ir_rvalue *ir = (ir_rvalue *)iter.get();
194 ir_rvalue *new_ir = ir;
195
196 if (do_graft(&new_ir)) {
197 ir->replace_with(new_ir);
198 return visit_stop;
199 }
200 }
201
202 return visit_continue;
203}
204
205ir_visitor_status
206ir_tree_grafting_visitor::visit_enter(ir_expression *ir)
207{
208 for (unsigned int i = 0; i < ir->get_num_operands(); i++) {
209 if (do_graft(&ir->operands[i]))
210 return visit_stop;
211 }
212
213 return visit_continue;
214}
215
216ir_visitor_status
217ir_tree_grafting_visitor::visit_enter(ir_if *ir)
218{
219 if (do_graft(&ir->condition))
220 return visit_stop;
221
222 /* Do not traverse into the body of the if-statement since that is a
223 * different basic block.
224 */
225 return visit_continue_with_parent;
226}
227
228ir_visitor_status
229ir_tree_grafting_visitor::visit_enter(ir_swizzle *ir)
230{
231 if (do_graft(&ir->val))
232 return visit_stop;
233
234 return visit_continue;
235}
236
237ir_visitor_status
238ir_tree_grafting_visitor::visit_enter(ir_texture *ir)
239{
240 if (do_graft(&ir->coordinate) ||
241 do_graft(&ir->projector) ||
242 do_graft(&ir->shadow_comparitor))
243 return visit_stop;
244
245 switch (ir->op) {
246 case ir_tex:
247 break;
248 case ir_txb:
249 if (do_graft(&ir->lod_info.bias))
250 return visit_stop;
251 break;
252 case ir_txf:
253 case ir_txl:
254 if (do_graft(&ir->lod_info.lod))
255 return visit_stop;
256 break;
257 case ir_txd:
258 if (do_graft(&ir->lod_info.grad.dPdx) ||
259 do_graft(&ir->lod_info.grad.dPdy))
260 return visit_stop;
261 break;
262 }
263
264 return visit_continue;
265}
266
267struct tree_grafting_info {
268 ir_variable_refcount_visitor *refs;
269 bool progress;
270};
271
272static bool
273try_tree_grafting(ir_assignment *start,
274 ir_variable *lhs_var,
275 ir_instruction *bb_last)
276{
277 ir_tree_grafting_visitor v(start, lhs_var);
278
279 if (debug) {
280 printf("trying to graft: ");
281 lhs_var->print();
282 printf("\n");
283 }
284
285 for (ir_instruction *ir = (ir_instruction *)start->next;
286 ir != bb_last->next;
287 ir = (ir_instruction *)ir->next) {
288
289 if (debug) {
290 printf("- ");
291 ir->print();
292 printf("\n");
293 }
294
295 ir_visitor_status s = ir->accept(&v);
296 if (s == visit_stop)
297 return v.progress;
298 }
299
300 return false;
301}
302
303static void
304tree_grafting_basic_block(ir_instruction *bb_first,
305 ir_instruction *bb_last,
306 void *data)
307{
308 struct tree_grafting_info *info = (struct tree_grafting_info *)data;
309 ir_instruction *ir, *next;
310
311 for (ir = bb_first, next = (ir_instruction *)ir->next;
312 ir != bb_last->next;
313 ir = next, next = (ir_instruction *)ir->next) {
314 ir_assignment *assign = ir->as_assignment();
315
316 if (!assign)
317 continue;
318
319 ir_variable *lhs_var = assign->whole_variable_written();
320 if (!lhs_var)
321 continue;
322
323 if (lhs_var->mode == ir_var_out ||
324 lhs_var->mode == ir_var_inout)
325 continue;
326
327 variable_entry *entry = info->refs->get_variable_entry(lhs_var);
328
329 if (!entry->declaration ||
330 entry->assigned_count != 1 ||
331 entry->referenced_count != 2)
332 continue;
333
334 assert(assign == entry->assign);
335
336 /* Found a possibly graftable assignment. Now, walk through the
337 * rest of the BB seeing if the deref is here, and if nothing interfered with
338 * pasting its expression's values in between.
339 */
340 info->progress |= try_tree_grafting(assign, lhs_var, bb_last);
341 }
342}
343
344/**
345 * Does a copy propagation pass on the code present in the instruction stream.
346 */
347bool
348do_tree_grafting(exec_list *instructions)
349{
350 ir_variable_refcount_visitor refs;
351 struct tree_grafting_info info;
352
353 info.progress = false;
354 info.refs = &refs;
355
356 visit_list_elements(info.refs, instructions);
357
358 call_for_basic_blocks(instructions, tree_grafting_basic_block, &info);
359
360 return info.progress;
361}
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
new file mode 100644
index 00000000000..6e08fa4025a
--- /dev/null
+++ b/src/glsl/ir_validate.cpp
@@ -0,0 +1,397 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_validate.cpp
26 *
27 * Attempts to verify that various invariants of the IR tree are true.
28 *
29 * In particular, at the moment it makes sure that no single
30 * ir_instruction node except for ir_variable appears multiple times
31 * in the ir tree. ir_variable does appear multiple times: Once as a
32 * declaration in an exec_list, and multiple times as the endpoint of
33 * a dereference chain.
34 */
35
36#include <inttypes.h>
37#include "ir.h"
38#include "ir_hierarchical_visitor.h"
39#include "program/hash_table.h"
40#include "glsl_types.h"
41
42class ir_validate : public ir_hierarchical_visitor {
43public:
44 ir_validate()
45 {
46 this->ht = hash_table_ctor(0, hash_table_pointer_hash,
47 hash_table_pointer_compare);
48
49 this->current_function = NULL;
50
51 this->callback = ir_validate::validate_ir;
52 this->data = ht;
53 }
54
55 ~ir_validate()
56 {
57 hash_table_dtor(this->ht);
58 }
59
60 virtual ir_visitor_status visit(ir_variable *v);
61 virtual ir_visitor_status visit(ir_dereference_variable *ir);
62 virtual ir_visitor_status visit(ir_if *ir);
63
64 virtual ir_visitor_status visit_enter(ir_function *ir);
65 virtual ir_visitor_status visit_leave(ir_function *ir);
66 virtual ir_visitor_status visit_enter(ir_function_signature *ir);
67
68 virtual ir_visitor_status visit_leave(ir_expression *ir);
69
70 virtual ir_visitor_status visit_enter(ir_assignment *ir);
71
72 static void validate_ir(ir_instruction *ir, void *data);
73
74 ir_function *current_function;
75
76 struct hash_table *ht;
77};
78
79
80ir_visitor_status
81ir_validate::visit(ir_dereference_variable *ir)
82{
83 if ((ir->var == NULL) || (ir->var->as_variable() == NULL)) {
84 printf("ir_dereference_variable @ %p does not specify a variable %p\n",
85 (void *) ir, (void *) ir->var);
86 abort();
87 }
88
89 if (hash_table_find(ht, ir->var) == NULL) {
90 printf("ir_dereference_variable @ %p specifies undeclared variable "
91 "`%s' @ %p\n",
92 (void *) ir, ir->var->name, (void *) ir->var);
93 abort();
94 }
95
96 this->validate_ir(ir, this->data);
97
98 return visit_continue;
99}
100
101ir_visitor_status
102ir_validate::visit(ir_if *ir)
103{
104 if (ir->condition->type != glsl_type::bool_type) {
105 printf("ir_if condition %s type instead of bool.\n",
106 ir->condition->type->name);
107 ir->print();
108 printf("\n");
109 abort();
110 }
111
112 return visit_continue;
113}
114
115
116ir_visitor_status
117ir_validate::visit_enter(ir_function *ir)
118{
119 /* Function definitions cannot be nested.
120 */
121 if (this->current_function != NULL) {
122 printf("Function definition nested inside another function "
123 "definition:\n");
124 printf("%s %p inside %s %p\n",
125 ir->name, (void *) ir,
126 this->current_function->name, (void *) this->current_function);
127 abort();
128 }
129
130 /* Store the current function hierarchy being traversed. This is used
131 * by the function signature visitor to ensure that the signatures are
132 * linked with the correct functions.
133 */
134 this->current_function = ir;
135
136 this->validate_ir(ir, this->data);
137
138 return visit_continue;
139}
140
141ir_visitor_status
142ir_validate::visit_leave(ir_function *ir)
143{
144 assert(talloc_parent(ir->name) == ir);
145
146 this->current_function = NULL;
147 return visit_continue;
148}
149
150ir_visitor_status
151ir_validate::visit_enter(ir_function_signature *ir)
152{
153 if (this->current_function != ir->function()) {
154 printf("Function signature nested inside wrong function "
155 "definition:\n");
156 printf("%p inside %s %p instead of %s %p\n",
157 (void *) ir,
158 this->current_function->name, (void *) this->current_function,
159 ir->function_name(), (void *) ir->function());
160 abort();
161 }
162
163 this->validate_ir(ir, this->data);
164
165 return visit_continue;
166}
167
168ir_visitor_status
169ir_validate::visit_leave(ir_expression *ir)
170{
171 switch (ir->operation) {
172 case ir_unop_bit_not:
173 assert(ir->operands[0]->type == ir->type);
174 break;
175 case ir_unop_logic_not:
176 assert(ir->type->base_type == GLSL_TYPE_BOOL);
177 assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
178 break;
179
180 case ir_unop_neg:
181 case ir_unop_abs:
182 case ir_unop_sign:
183 case ir_unop_rcp:
184 case ir_unop_rsq:
185 case ir_unop_sqrt:
186 assert(ir->type == ir->operands[0]->type);
187 break;
188
189 case ir_unop_exp:
190 case ir_unop_log:
191 case ir_unop_exp2:
192 case ir_unop_log2:
193 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
194 assert(ir->type == ir->operands[0]->type);
195 break;
196
197 case ir_unop_f2i:
198 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
199 assert(ir->type->base_type == GLSL_TYPE_INT);
200 break;
201 case ir_unop_i2f:
202 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
203 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
204 break;
205 case ir_unop_f2b:
206 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
207 assert(ir->type->base_type == GLSL_TYPE_BOOL);
208 break;
209 case ir_unop_b2f:
210 assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
211 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
212 break;
213 case ir_unop_i2b:
214 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
215 assert(ir->type->base_type == GLSL_TYPE_BOOL);
216 break;
217 case ir_unop_b2i:
218 assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
219 assert(ir->type->base_type == GLSL_TYPE_INT);
220 break;
221 case ir_unop_u2f:
222 assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
223 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
224 break;
225
226 case ir_unop_trunc:
227 case ir_unop_ceil:
228 case ir_unop_floor:
229 case ir_unop_fract:
230 case ir_unop_sin:
231 case ir_unop_cos:
232 case ir_unop_dFdx:
233 case ir_unop_dFdy:
234 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
235 assert(ir->operands[0]->type == ir->type);
236 break;
237
238 case ir_binop_add:
239 case ir_binop_sub:
240 case ir_binop_mul:
241 case ir_binop_div:
242 case ir_binop_mod:
243 case ir_binop_min:
244 case ir_binop_max:
245 case ir_binop_pow:
246 if (ir->operands[0]->type->is_scalar())
247 assert(ir->operands[1]->type == ir->type);
248 else if (ir->operands[1]->type->is_scalar())
249 assert(ir->operands[0]->type == ir->type);
250 else if (ir->operands[0]->type->is_vector() &&
251 ir->operands[1]->type->is_vector()) {
252 assert(ir->operands[0]->type == ir->operands[1]->type);
253 assert(ir->operands[0]->type == ir->type);
254 }
255 break;
256 case ir_binop_less:
257 case ir_binop_greater:
258 case ir_binop_lequal:
259 case ir_binop_gequal:
260 /* GLSL < > <= >= operators take scalar floats/ints, but in the
261 * IR we may want to do them for vectors instead to support the
262 * lessEqual() and friends builtins.
263 */
264 assert(ir->type == glsl_type::bool_type);
265 assert(ir->operands[0]->type == ir->operands[1]->type);
266 break;
267
268 case ir_binop_equal:
269 case ir_binop_nequal:
270 /* GLSL == and != operate on vectors and return a bool, and the
271 * IR matches that. We may want to switch up the IR to work on
272 * vectors and return a bvec and make the operators break down
273 * to ANDing/ORing the results of the vector comparison.
274 */
275 assert(ir->type == glsl_type::bool_type);
276 assert(ir->operands[0]->type == ir->operands[1]->type);
277 break;
278
279 case ir_binop_lshift:
280 case ir_binop_rshift:
281 case ir_binop_bit_and:
282 case ir_binop_bit_xor:
283 case ir_binop_bit_or:
284 assert(ir->operands[0]->type == ir->operands[1]->type);
285 assert(ir->type == ir->operands[0]->type);
286 assert(ir->type->base_type == GLSL_TYPE_INT ||
287 ir->type->base_type == GLSL_TYPE_UINT);
288 break;
289
290 case ir_binop_logic_and:
291 case ir_binop_logic_xor:
292 case ir_binop_logic_or:
293 assert(ir->type == glsl_type::bool_type);
294 assert(ir->operands[0]->type == glsl_type::bool_type);
295 assert(ir->operands[1]->type == glsl_type::bool_type);
296 break;
297
298 case ir_binop_dot:
299 assert(ir->type == glsl_type::float_type);
300 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
301 assert(ir->operands[0]->type == ir->operands[1]->type);
302 break;
303
304 case ir_binop_cross:
305 assert(ir->operands[0]->type == glsl_type::vec3_type);
306 assert(ir->operands[1]->type == glsl_type::vec3_type);
307 assert(ir->type == glsl_type::vec3_type);
308 break;
309 }
310
311 return visit_continue;
312}
313
314ir_visitor_status
315ir_validate::visit(ir_variable *ir)
316{
317 /* An ir_variable is the one thing that can (and will) appear multiple times
318 * in an IR tree. It is added to the hashtable so that it can be used
319 * in the ir_dereference_variable handler to ensure that a variable is
320 * declared before it is dereferenced.
321 */
322 if (ir->name)
323 assert(talloc_parent(ir->name) == ir);
324
325 hash_table_insert(ht, ir, ir);
326 return visit_continue;
327}
328
329ir_visitor_status
330ir_validate::visit_enter(ir_assignment *ir)
331{
332 const ir_dereference *const lhs = ir->lhs;
333 if (lhs->type->is_scalar() || lhs->type->is_vector()) {
334 if (ir->write_mask == 0) {
335 printf("Assignment LHS is %s, but write mask is 0:\n",
336 lhs->type->is_scalar() ? "scalar" : "vector");
337 ir->print();
338 abort();
339 }
340
341 /* Mask of fields that do not exist in the destination. These should
342 * not be written by the assignment.
343 */
344 const unsigned invalid_mask = ~((1U << lhs->type->components()) - 1);
345
346 if ((invalid_mask & ir->write_mask) != 0) {
347 printf("Assignment write mask enables invalid components for "
348 "type %s:\n", lhs->type->name);
349 ir->print();
350 abort();
351 }
352 }
353
354 this->validate_ir(ir, this->data);
355
356 return visit_continue;
357}
358
359void
360ir_validate::validate_ir(ir_instruction *ir, void *data)
361{
362 struct hash_table *ht = (struct hash_table *) data;
363
364 if (hash_table_find(ht, ir)) {
365 printf("Instruction node present twice in ir tree:\n");
366 ir->print();
367 printf("\n");
368 abort();
369 }
370 hash_table_insert(ht, ir, ir);
371}
372
373void
374check_node_type(ir_instruction *ir, void *data)
375{
376 (void) data;
377
378 if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) {
379 printf("Instruction node with unset type\n");
380 ir->print(); printf("\n");
381 }
382 assert(ir->type != glsl_type::error_type);
383}
384
385void
386validate_ir_tree(exec_list *instructions)
387{
388 ir_validate v;
389
390 v.run(instructions);
391
392 foreach_iter(exec_list_iterator, iter, *instructions) {
393 ir_instruction *ir = (ir_instruction *)iter.get();
394
395 visit_tree(ir, check_node_type, NULL);
396 }
397}
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
new file mode 100644
index 00000000000..917c06743b4
--- /dev/null
+++ b/src/glsl/ir_variable.cpp
@@ -0,0 +1,416 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include "main/compiler.h"
25#include "ir.h"
26#include "glsl_parser_extras.h"
27#include "glsl_symbol_table.h"
28#include "builtin_variables.h"
29
30static void generate_ARB_draw_buffers_variables(exec_list *,
31 struct _mesa_glsl_parse_state *,
32 bool, _mesa_glsl_parser_targets);
33
34static ir_variable *
35add_variable(const char *name, enum ir_variable_mode mode, int slot,
36 const glsl_type *type, exec_list *instructions,
37 glsl_symbol_table *symtab)
38{
39 ir_variable *var = new(symtab) ir_variable(type, name, mode);
40
41 switch (var->mode) {
42 case ir_var_auto:
43 case ir_var_in:
44 case ir_var_uniform:
45 var->read_only = true;
46 break;
47 case ir_var_inout:
48 case ir_var_out:
49 break;
50 default:
51 assert(0);
52 break;
53 }
54
55 var->location = slot;
56
57 /* Once the variable is created an initialized, add it to the symbol table
58 * and add the declaration to the IR stream.
59 */
60 instructions->push_tail(var);
61
62 symtab->add_variable(var->name, var);
63 return var;
64}
65
66static ir_variable *
67add_uniform(exec_list *instructions,
68 struct _mesa_glsl_parse_state *state,
69 const char *name, const glsl_type *type)
70{
71 return add_variable(name, ir_var_uniform, -1, type, instructions,
72 state->symbols);
73}
74
75static void
76add_builtin_variable(const builtin_variable *proto, exec_list *instructions,
77 glsl_symbol_table *symtab)
78{
79 /* Create a new variable declaration from the description supplied by
80 * the caller.
81 */
82 const glsl_type *const type = symtab->get_type(proto->type);
83
84 assert(type != NULL);
85
86 add_variable(proto->name, proto->mode, proto->slot, type, instructions,
87 symtab);
88}
89
90static void
91add_builtin_constant(exec_list *instructions,
92 struct _mesa_glsl_parse_state *state,
93 const char *name, int value)
94{
95 ir_variable *const var = add_variable(name, ir_var_auto,
96 -1, glsl_type::int_type,
97 instructions, state->symbols);
98 var->constant_value = new(var) ir_constant(value);
99}
100
101static void
102generate_110_uniforms(exec_list *instructions,
103 struct _mesa_glsl_parse_state *state)
104{
105 for (unsigned i = 0
106 ; i < Elements(builtin_110_deprecated_uniforms)
107 ; i++) {
108 add_builtin_variable(& builtin_110_deprecated_uniforms[i],
109 instructions, state->symbols);
110 }
111
112 add_builtin_constant(instructions, state, "gl_MaxLights",
113 state->Const.MaxLights);
114 add_builtin_constant(instructions, state, "gl_MaxClipPlanes",
115 state->Const.MaxClipPlanes);
116 add_builtin_constant(instructions, state, "gl_MaxTextureUnits",
117 state->Const.MaxTextureUnits);
118 add_builtin_constant(instructions, state, "gl_MaxTextureCoords",
119 state->Const.MaxTextureCoords);
120 add_builtin_constant(instructions, state, "gl_MaxVertexAttribs",
121 state->Const.MaxVertexAttribs);
122 add_builtin_constant(instructions, state, "gl_MaxVertexUniformComponents",
123 state->Const.MaxVertexUniformComponents);
124 add_builtin_constant(instructions, state, "gl_MaxVaryingFloats",
125 state->Const.MaxVaryingFloats);
126 add_builtin_constant(instructions, state, "gl_MaxVertexTextureImageUnits",
127 state->Const.MaxVertexTextureImageUnits);
128 add_builtin_constant(instructions, state, "gl_MaxCombinedTextureImageUnits",
129 state->Const.MaxCombinedTextureImageUnits);
130 add_builtin_constant(instructions, state, "gl_MaxTextureImageUnits",
131 state->Const.MaxTextureImageUnits);
132 add_builtin_constant(instructions, state, "gl_MaxFragmentUniformComponents",
133 state->Const.MaxFragmentUniformComponents);
134
135 const glsl_type *const mat4_array_type =
136 glsl_type::get_array_instance(glsl_type::mat4_type,
137 state->Const.MaxTextureCoords);
138
139 add_uniform(instructions, state, "gl_TextureMatrix", mat4_array_type);
140
141 add_uniform(instructions, state, "gl_DepthRange",
142 state->symbols->get_type("gl_DepthRangeParameters"));
143
144 add_uniform(instructions, state, "gl_ClipPlane",
145 glsl_type::get_array_instance(glsl_type::vec4_type,
146 state->Const.MaxClipPlanes));
147 add_uniform(instructions, state, "gl_Point",
148 state->symbols->get_type("gl_PointParameters"));
149
150 const glsl_type *const material_parameters_type =
151 state->symbols->get_type("gl_MaterialParameters");
152 add_uniform(instructions, state, "gl_FrontMaterial", material_parameters_type);
153 add_uniform(instructions, state, "gl_BackMaterial", material_parameters_type);
154
155 const glsl_type *const light_source_array_type =
156 glsl_type::get_array_instance(state->symbols->get_type("gl_LightSourceParameters"), state->Const.MaxLights);
157
158 add_uniform(instructions, state, "gl_LightSource", light_source_array_type);
159
160 const glsl_type *const light_model_products_type =
161 state->symbols->get_type("gl_LightModelProducts");
162 add_uniform(instructions, state, "gl_FrontLightModelProduct",
163 light_model_products_type);
164 add_uniform(instructions, state, "gl_BackLightModelProduct",
165 light_model_products_type);
166
167 const glsl_type *const light_products_type =
168 glsl_type::get_array_instance(state->symbols->get_type("gl_LightProducts"),
169 state->Const.MaxLights);
170 add_uniform(instructions, state, "gl_FrontLightProduct", light_products_type);
171 add_uniform(instructions, state, "gl_BackLightProduct", light_products_type);
172
173 add_uniform(instructions, state, "gl_TextureEnvColor",
174 glsl_type::get_array_instance(glsl_type::vec4_type,
175 state->Const.MaxTextureUnits));
176
177 const glsl_type *const texcoords_vec4 =
178 glsl_type::get_array_instance(glsl_type::vec4_type,
179 state->Const.MaxTextureCoords);
180 add_uniform(instructions, state, "gl_EyePlaneS", texcoords_vec4);
181 add_uniform(instructions, state, "gl_EyePlaneT", texcoords_vec4);
182 add_uniform(instructions, state, "gl_EyePlaneR", texcoords_vec4);
183 add_uniform(instructions, state, "gl_EyePlaneQ", texcoords_vec4);
184 add_uniform(instructions, state, "gl_ObjectPlaneS", texcoords_vec4);
185 add_uniform(instructions, state, "gl_ObjectPlaneT", texcoords_vec4);
186 add_uniform(instructions, state, "gl_ObjectPlaneR", texcoords_vec4);
187 add_uniform(instructions, state, "gl_ObjectPlaneQ", texcoords_vec4);
188
189 add_uniform(instructions, state, "gl_Fog",
190 state->symbols->get_type("gl_FogParameters"));
191}
192
193static void
194generate_110_vs_variables(exec_list *instructions,
195 struct _mesa_glsl_parse_state *state)
196{
197 for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) {
198 add_builtin_variable(& builtin_core_vs_variables[i],
199 instructions, state->symbols);
200 }
201
202 for (unsigned i = 0
203 ; i < Elements(builtin_110_deprecated_vs_variables)
204 ; i++) {
205 add_builtin_variable(& builtin_110_deprecated_vs_variables[i],
206 instructions, state->symbols);
207 }
208 generate_110_uniforms(instructions, state);
209
210 /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
211 *
212 * "As with all arrays, indices used to subscript gl_TexCoord must
213 * either be an integral constant expressions, or this array must be
214 * re-declared by the shader with a size. The size can be at most
215 * gl_MaxTextureCoords. Using indexes close to 0 may aid the
216 * implementation in preserving varying resources."
217 */
218 const glsl_type *const vec4_array_type =
219 glsl_type::get_array_instance(glsl_type::vec4_type, 0);
220
221 add_variable("gl_TexCoord", ir_var_out, VERT_RESULT_TEX0, vec4_array_type,
222 instructions, state->symbols);
223
224 generate_ARB_draw_buffers_variables(instructions, state, false,
225 vertex_shader);
226}
227
228
229static void
230generate_120_vs_variables(exec_list *instructions,
231 struct _mesa_glsl_parse_state *state)
232{
233 /* GLSL version 1.20 did not add any built-in variables in the vertex
234 * shader.
235 */
236 generate_110_vs_variables(instructions, state);
237}
238
239
240static void
241generate_130_vs_variables(exec_list *instructions,
242 struct _mesa_glsl_parse_state *state)
243{
244 generate_120_vs_variables(instructions, state);
245
246 for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) {
247 add_builtin_variable(& builtin_130_vs_variables[i],
248 instructions, state->symbols);
249 }
250
251 const glsl_type *const clip_distance_array_type =
252 glsl_type::get_array_instance(glsl_type::float_type,
253 state->Const.MaxClipPlanes);
254
255 /* FINISHME: gl_ClipDistance needs a real location assigned. */
256 add_variable("gl_ClipDistance", ir_var_out, -1, clip_distance_array_type,
257 instructions, state->symbols);
258
259}
260
261
262static void
263initialize_vs_variables(exec_list *instructions,
264 struct _mesa_glsl_parse_state *state)
265{
266
267 switch (state->language_version) {
268 case 110:
269 generate_110_vs_variables(instructions, state);
270 break;
271 case 120:
272 generate_120_vs_variables(instructions, state);
273 break;
274 case 130:
275 generate_130_vs_variables(instructions, state);
276 break;
277 }
278}
279
280static void
281generate_110_fs_variables(exec_list *instructions,
282 struct _mesa_glsl_parse_state *state)
283{
284 for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) {
285 add_builtin_variable(& builtin_core_fs_variables[i],
286 instructions, state->symbols);
287 }
288
289 for (unsigned i = 0
290 ; i < Elements(builtin_110_deprecated_fs_variables)
291 ; i++) {
292 add_builtin_variable(& builtin_110_deprecated_fs_variables[i],
293 instructions, state->symbols);
294 }
295 generate_110_uniforms(instructions, state);
296
297 /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
298 *
299 * "As with all arrays, indices used to subscript gl_TexCoord must
300 * either be an integral constant expressions, or this array must be
301 * re-declared by the shader with a size. The size can be at most
302 * gl_MaxTextureCoords. Using indexes close to 0 may aid the
303 * implementation in preserving varying resources."
304 */
305 const glsl_type *const vec4_array_type =
306 glsl_type::get_array_instance(glsl_type::vec4_type, 0);
307
308 add_variable("gl_TexCoord", ir_var_in, FRAG_ATTRIB_TEX0, vec4_array_type,
309 instructions, state->symbols);
310
311 generate_ARB_draw_buffers_variables(instructions, state, false,
312 fragment_shader);
313}
314
315
316static void
317generate_ARB_draw_buffers_variables(exec_list *instructions,
318 struct _mesa_glsl_parse_state *state,
319 bool warn, _mesa_glsl_parser_targets target)
320{
321 /* gl_MaxDrawBuffers is available in all shader stages.
322 */
323 ir_variable *const mdb =
324 add_variable("gl_MaxDrawBuffers", ir_var_auto, -1,
325 glsl_type::int_type, instructions, state->symbols);
326
327 if (warn)
328 mdb->warn_extension = "GL_ARB_draw_buffers";
329
330 mdb->constant_value = new(mdb)
331 ir_constant(int(state->Const.MaxDrawBuffers));
332
333
334 /* gl_FragData is only available in the fragment shader.
335 */
336 if (target == fragment_shader) {
337 const glsl_type *const vec4_array_type =
338 glsl_type::get_array_instance(glsl_type::vec4_type,
339 state->Const.MaxDrawBuffers);
340
341 ir_variable *const fd =
342 add_variable("gl_FragData", ir_var_out, FRAG_RESULT_DATA0,
343 vec4_array_type, instructions, state->symbols);
344
345 if (warn)
346 fd->warn_extension = "GL_ARB_draw_buffers";
347 }
348}
349
350
351static void
352generate_120_fs_variables(exec_list *instructions,
353 struct _mesa_glsl_parse_state *state)
354{
355 generate_110_fs_variables(instructions, state);
356
357 for (unsigned i = 0
358 ; i < Elements(builtin_120_fs_variables)
359 ; i++) {
360 add_builtin_variable(& builtin_120_fs_variables[i],
361 instructions, state->symbols);
362 }
363}
364
365static void
366generate_130_fs_variables(exec_list *instructions,
367 struct _mesa_glsl_parse_state *state)
368{
369 generate_120_fs_variables(instructions, state);
370
371 const glsl_type *const clip_distance_array_type =
372 glsl_type::get_array_instance(glsl_type::float_type,
373 state->Const.MaxClipPlanes);
374
375 /* FINISHME: gl_ClipDistance needs a real location assigned. */
376 add_variable("gl_ClipDistance", ir_var_in, -1, clip_distance_array_type,
377 instructions, state->symbols);
378}
379
380static void
381initialize_fs_variables(exec_list *instructions,
382 struct _mesa_glsl_parse_state *state)
383{
384
385 switch (state->language_version) {
386 case 110:
387 generate_110_fs_variables(instructions, state);
388 break;
389 case 120:
390 generate_120_fs_variables(instructions, state);
391 break;
392 case 130:
393 generate_130_fs_variables(instructions, state);
394 break;
395 }
396}
397
398void
399_mesa_glsl_initialize_variables(exec_list *instructions,
400 struct _mesa_glsl_parse_state *state)
401{
402 switch (state->target) {
403 case vertex_shader:
404 initialize_vs_variables(instructions, state);
405 break;
406 case geometry_shader:
407 break;
408 case fragment_shader:
409 initialize_fs_variables(instructions, state);
410 break;
411 case ir_shader:
412 fprintf(stderr, "ir reader has no builtin variables");
413 exit(1);
414 break;
415 }
416}
diff --git a/src/glsl/ir_variable_refcount.cpp b/src/glsl/ir_variable_refcount.cpp
new file mode 100644
index 00000000000..20c2f6602bf
--- /dev/null
+++ b/src/glsl/ir_variable_refcount.cpp
@@ -0,0 +1,100 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_variable_refcount.cpp
26 *
27 * Provides a visitor which produces a list of variables referenced,
28 * how many times they were referenced and assigned, and whether they
29 * were defined in the scope.
30 */
31
32#include "ir.h"
33#include "ir_visitor.h"
34#include "ir_variable_refcount.h"
35#include "glsl_types.h"
36
37variable_entry *
38ir_variable_refcount_visitor::get_variable_entry(ir_variable *var)
39{
40 assert(var);
41 foreach_iter(exec_list_iterator, iter, this->variable_list) {
42 variable_entry *entry = (variable_entry *)iter.get();
43 if (entry->var == var)
44 return entry;
45 }
46
47 variable_entry *entry = new(mem_ctx) variable_entry(var);
48 this->variable_list.push_tail(entry);
49 return entry;
50}
51
52
53ir_visitor_status
54ir_variable_refcount_visitor::visit(ir_variable *ir)
55{
56 variable_entry *entry = this->get_variable_entry(ir);
57 if (entry)
58 entry->declaration = true;
59
60 return visit_continue;
61}
62
63
64ir_visitor_status
65ir_variable_refcount_visitor::visit(ir_dereference_variable *ir)
66{
67 ir_variable *const var = ir->variable_referenced();
68 variable_entry *entry = this->get_variable_entry(var);
69
70 if (entry)
71 entry->referenced_count++;
72
73 return visit_continue;
74}
75
76
77ir_visitor_status
78ir_variable_refcount_visitor::visit_enter(ir_function_signature *ir)
79{
80 /* We don't want to descend into the function parameters and
81 * dead-code eliminate them, so just accept the body here.
82 */
83 visit_list_elements(this, &ir->body);
84 return visit_continue_with_parent;
85}
86
87
88ir_visitor_status
89ir_variable_refcount_visitor::visit_leave(ir_assignment *ir)
90{
91 variable_entry *entry;
92 entry = this->get_variable_entry(ir->lhs->variable_referenced());
93 if (entry) {
94 entry->assigned_count++;
95 if (entry->assign == NULL)
96 entry->assign = ir;
97 }
98
99 return visit_continue;
100}
diff --git a/src/glsl/ir_variable_refcount.h b/src/glsl/ir_variable_refcount.h
new file mode 100644
index 00000000000..30dd2bd587e
--- /dev/null
+++ b/src/glsl/ir_variable_refcount.h
@@ -0,0 +1,85 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_variable_refcount.h
26 *
27 * Provides a visitor which produces a list of variables referenced,
28 * how many times they were referenced and assigned, and whether they
29 * were defined in the scope.
30 */
31
32#include "ir.h"
33#include "ir_visitor.h"
34#include "glsl_types.h"
35
36class variable_entry : public exec_node
37{
38public:
39 variable_entry(ir_variable *var)
40 {
41 this->var = var;
42 assign = NULL;
43 referenced_count = 0;
44 assigned_count = 0;
45 declaration = false;
46 }
47
48 ir_variable *var; /* The key: the variable's pointer. */
49 ir_assignment *assign; /* An assignment to the variable, if any */
50
51 /** Number of times the variable is referenced, including assignments. */
52 unsigned referenced_count;
53
54 /** Number of times the variable is assigned. */
55 unsigned assigned_count;
56
57 bool declaration; /* If the variable had a decl in the instruction stream */
58};
59
60class ir_variable_refcount_visitor : public ir_hierarchical_visitor {
61public:
62 ir_variable_refcount_visitor(void)
63 {
64 this->mem_ctx = talloc_new(NULL);
65 this->variable_list.make_empty();
66 }
67
68 ~ir_variable_refcount_visitor(void)
69 {
70 this->mem_ctx = talloc_new(NULL);
71 }
72
73 virtual ir_visitor_status visit(ir_variable *);
74 virtual ir_visitor_status visit(ir_dereference_variable *);
75
76 virtual ir_visitor_status visit_enter(ir_function_signature *);
77 virtual ir_visitor_status visit_leave(ir_assignment *);
78
79 variable_entry *get_variable_entry(ir_variable *var);
80
81 /* List of variable_entry */
82 exec_list variable_list;
83
84 void *mem_ctx;
85};
diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp
new file mode 100644
index 00000000000..cd8dedf2fe1
--- /dev/null
+++ b/src/glsl/ir_vec_index_to_cond_assign.cpp
@@ -0,0 +1,258 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_vec_index_to_cond_assign.cpp
26 *
27 * Turns indexing into vector types to a series of conditional moves
28 * of each channel's swizzle into a temporary.
29 *
30 * Most GPUs don't have a native way to do this operation, and this
31 * works around that. For drivers using both this pass and
32 * ir_vec_index_to_swizzle, there's a risk that this pass will happen
33 * before sufficient constant folding to find that the array index is
34 * constant. However, we hope that other optimization passes,
35 * particularly constant folding of assignment conditions and copy
36 * propagation, will result in the same code in the end.
37 */
38
39#include "ir.h"
40#include "ir_visitor.h"
41#include "ir_optimization.h"
42#include "glsl_types.h"
43
44/**
45 * Visitor class for replacing expressions with ir_constant values.
46 */
47
48class ir_vec_index_to_cond_assign_visitor : public ir_hierarchical_visitor {
49public:
50 ir_vec_index_to_cond_assign_visitor()
51 {
52 progress = false;
53 }
54
55 ir_rvalue *convert_vec_index_to_cond_assign(ir_rvalue *val);
56
57 virtual ir_visitor_status visit_enter(ir_expression *);
58 virtual ir_visitor_status visit_enter(ir_swizzle *);
59 virtual ir_visitor_status visit_leave(ir_assignment *);
60 virtual ir_visitor_status visit_enter(ir_return *);
61 virtual ir_visitor_status visit_enter(ir_call *);
62 virtual ir_visitor_status visit_enter(ir_if *);
63
64 bool progress;
65};
66
67ir_rvalue *
68ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue *ir)
69{
70 ir_dereference_array *orig_deref = ir->as_dereference_array();
71 ir_assignment *assign;
72 ir_variable *index, *var;
73 ir_dereference *deref;
74 ir_expression *condition;
75 ir_swizzle *swizzle;
76 int i;
77
78 if (!orig_deref)
79 return ir;
80
81 if (orig_deref->array->type->is_matrix() ||
82 orig_deref->array->type->is_array())
83 return ir;
84
85 void *mem_ctx = talloc_parent(ir);
86
87 assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
88
89 /* Store the index to a temporary to avoid reusing its tree. */
90 index = new(base_ir) ir_variable(glsl_type::int_type,
91 "vec_index_tmp_i",
92 ir_var_temporary);
93 base_ir->insert_before(index);
94 deref = new(base_ir) ir_dereference_variable(index);
95 assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL);
96 base_ir->insert_before(assign);
97
98 /* Temporary where we store whichever value we swizzle out. */
99 var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v",
100 ir_var_temporary);
101 base_ir->insert_before(var);
102
103 /* Generate a conditional move of each vector element to the temp. */
104 for (i = 0; i < orig_deref->array->type->vector_elements; i++) {
105 deref = new(base_ir) ir_dereference_variable(index);
106 condition = new(base_ir) ir_expression(ir_binop_equal,
107 glsl_type::bool_type,
108 deref,
109 new(base_ir) ir_constant(i));
110
111 /* Just clone the rest of the deref chain when trying to get at the
112 * underlying variable.
113 */
114 swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL),
115 i, 0, 0, 0, 1);
116
117 deref = new(base_ir) ir_dereference_variable(var);
118 assign = new(base_ir) ir_assignment(deref, swizzle, condition);
119 base_ir->insert_before(assign);
120 }
121
122 this->progress = true;
123 return new(base_ir) ir_dereference_variable(var);
124}
125
126ir_visitor_status
127ir_vec_index_to_cond_assign_visitor::visit_enter(ir_expression *ir)
128{
129 unsigned int i;
130
131 for (i = 0; i < ir->get_num_operands(); i++) {
132 ir->operands[i] = convert_vec_index_to_cond_assign(ir->operands[i]);
133 }
134
135 return visit_continue;
136}
137
138ir_visitor_status
139ir_vec_index_to_cond_assign_visitor::visit_enter(ir_swizzle *ir)
140{
141 /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which
142 * the result of indexing a vector is. But maybe at some point we'll end up
143 * using swizzling of scalars for vector construction.
144 */
145 ir->val = convert_vec_index_to_cond_assign(ir->val);
146
147 return visit_continue;
148}
149
150ir_visitor_status
151ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir)
152{
153 ir_variable *index, *var;
154 ir_dereference_variable *deref;
155 ir_assignment *assign;
156 int i;
157
158 ir->rhs = convert_vec_index_to_cond_assign(ir->rhs);
159 if (ir->condition)
160 ir->condition = convert_vec_index_to_cond_assign(ir->condition);
161
162 /* Last, handle the LHS */
163 ir_dereference_array *orig_deref = ir->lhs->as_dereference_array();
164
165 if (!orig_deref ||
166 orig_deref->array->type->is_matrix() ||
167 orig_deref->array->type->is_array())
168 return visit_continue;
169
170 void *mem_ctx = talloc_parent(ir);
171
172 assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
173
174 /* Store the index to a temporary to avoid reusing its tree. */
175 index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i",
176 ir_var_temporary);
177 ir->insert_before(index);
178 deref = new(ir) ir_dereference_variable(index);
179 assign = new(ir) ir_assignment(deref, orig_deref->array_index, NULL);
180 ir->insert_before(assign);
181
182 /* Store the RHS to a temporary to avoid reusing its tree. */
183 var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v",
184 ir_var_temporary);
185 ir->insert_before(var);
186 deref = new(ir) ir_dereference_variable(var);
187 assign = new(ir) ir_assignment(deref, ir->rhs, NULL);
188 ir->insert_before(assign);
189
190 /* Generate a conditional move of each vector element to the temp. */
191 for (i = 0; i < orig_deref->array->type->vector_elements; i++) {
192 ir_rvalue *condition, *swizzle;
193
194 deref = new(ir) ir_dereference_variable(index);
195 condition = new(ir) ir_expression(ir_binop_equal,
196 glsl_type::bool_type,
197 deref,
198 new(ir) ir_constant(i));
199
200 /* Just clone the rest of the deref chain when trying to get at the
201 * underlying variable.
202 */
203 swizzle = new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL),
204 i, 0, 0, 0, 1);
205
206 deref = new(ir) ir_dereference_variable(var);
207 assign = new(ir) ir_assignment(swizzle, deref, condition);
208 ir->insert_before(assign);
209 }
210 ir->remove();
211
212 this->progress = true;
213
214 return visit_continue;
215}
216
217ir_visitor_status
218ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir)
219{
220 foreach_iter(exec_list_iterator, iter, *ir) {
221 ir_rvalue *param = (ir_rvalue *)iter.get();
222 ir_rvalue *new_param = convert_vec_index_to_cond_assign(param);
223
224 if (new_param != param) {
225 param->replace_with(new_param);
226 }
227 }
228
229 return visit_continue;
230}
231
232ir_visitor_status
233ir_vec_index_to_cond_assign_visitor::visit_enter(ir_return *ir)
234{
235 if (ir->value) {
236 ir->value = convert_vec_index_to_cond_assign(ir->value);
237 }
238
239 return visit_continue;
240}
241
242ir_visitor_status
243ir_vec_index_to_cond_assign_visitor::visit_enter(ir_if *ir)
244{
245 ir->condition = convert_vec_index_to_cond_assign(ir->condition);
246
247 return visit_continue;
248}
249
250bool
251do_vec_index_to_cond_assign(exec_list *instructions)
252{
253 ir_vec_index_to_cond_assign_visitor v;
254
255 visit_list_elements(&v, instructions);
256
257 return v.progress;
258}
diff --git a/src/glsl/ir_vec_index_to_swizzle.cpp b/src/glsl/ir_vec_index_to_swizzle.cpp
new file mode 100644
index 00000000000..969dc8f94a2
--- /dev/null
+++ b/src/glsl/ir_vec_index_to_swizzle.cpp
@@ -0,0 +1,157 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file ir_vec_index_to_swizzle.cpp
26 *
27 * Turns constant indexing into vector types to swizzles. This will
28 * let other swizzle-aware optimization passes catch these constructs,
29 * and codegen backends not have to worry about this case.
30 */
31
32#include "ir.h"
33#include "ir_visitor.h"
34#include "ir_optimization.h"
35#include "glsl_types.h"
36
37/**
38 * Visitor class for replacing expressions with ir_constant values.
39 */
40
41class ir_vec_index_to_swizzle_visitor : public ir_hierarchical_visitor {
42public:
43 ir_vec_index_to_swizzle_visitor()
44 {
45 progress = false;
46 }
47
48 ir_rvalue *convert_vec_index_to_swizzle(ir_rvalue *val);
49
50 virtual ir_visitor_status visit_enter(ir_expression *);
51 virtual ir_visitor_status visit_enter(ir_swizzle *);
52 virtual ir_visitor_status visit_enter(ir_assignment *);
53 virtual ir_visitor_status visit_enter(ir_return *);
54 virtual ir_visitor_status visit_enter(ir_call *);
55 virtual ir_visitor_status visit_enter(ir_if *);
56
57 bool progress;
58};
59
60ir_rvalue *
61ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir)
62{
63 ir_dereference_array *deref = ir->as_dereference_array();
64 ir_constant *ir_constant;
65
66 if (!deref)
67 return ir;
68
69 if (deref->array->type->is_matrix() || deref->array->type->is_array())
70 return ir;
71
72 assert(deref->array_index->type->base_type == GLSL_TYPE_INT);
73 ir_constant = deref->array_index->constant_expression_value();
74 if (!ir_constant)
75 return ir;
76
77 void *ctx = talloc_parent(ir);
78 this->progress = true;
79 return new(ctx) ir_swizzle(deref->array,
80 ir_constant->value.i[0], 0, 0, 0, 1);
81}
82
83ir_visitor_status
84ir_vec_index_to_swizzle_visitor::visit_enter(ir_expression *ir)
85{
86 unsigned int i;
87
88 for (i = 0; i < ir->get_num_operands(); i++) {
89 ir->operands[i] = convert_vec_index_to_swizzle(ir->operands[i]);
90 }
91
92 return visit_continue;
93}
94
95ir_visitor_status
96ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir)
97{
98 /* Can't be hit from normal GLSL, since you can't swizzle a scalar (which
99 * the result of indexing a vector is. But maybe at some point we'll end up
100 * using swizzling of scalars for vector construction.
101 */
102 ir->val = convert_vec_index_to_swizzle(ir->val);
103
104 return visit_continue;
105}
106
107ir_visitor_status
108ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir)
109{
110 ir->set_lhs(convert_vec_index_to_swizzle(ir->lhs));
111 ir->rhs = convert_vec_index_to_swizzle(ir->rhs);
112
113 return visit_continue;
114}
115
116ir_visitor_status
117ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir)
118{
119 foreach_iter(exec_list_iterator, iter, *ir) {
120 ir_rvalue *param = (ir_rvalue *)iter.get();
121 ir_rvalue *new_param = convert_vec_index_to_swizzle(param);
122
123 if (new_param != param) {
124 param->replace_with(new_param);
125 }
126 }
127
128 return visit_continue;
129}
130
131ir_visitor_status
132ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir)
133{
134 if (ir->value) {
135 ir->value = convert_vec_index_to_swizzle(ir->value);
136 }
137
138 return visit_continue;
139}
140
141ir_visitor_status
142ir_vec_index_to_swizzle_visitor::visit_enter(ir_if *ir)
143{
144 ir->condition = convert_vec_index_to_swizzle(ir->condition);
145
146 return visit_continue;
147}
148
149bool
150do_vec_index_to_swizzle(exec_list *instructions)
151{
152 ir_vec_index_to_swizzle_visitor v;
153
154 v.run(instructions);
155
156 return v.progress;
157}
diff --git a/src/glsl/ir_visitor.h b/src/glsl/ir_visitor.h
new file mode 100644
index 00000000000..b87d7373180
--- /dev/null
+++ b/src/glsl/ir_visitor.h
@@ -0,0 +1,67 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef IR_VISITOR_H
27#define IR_VISITOR_H
28
29/**
30 * Abstract base class of visitors of IR instruction trees
31 */
32class ir_visitor {
33public:
34 virtual ~ir_visitor()
35 {
36 /* empty */
37 }
38
39 /**
40 * \name Visit methods
41 *
42 * As typical for the visitor pattern, there must be one \c visit method for
43 * each concrete subclass of \c ir_instruction. Virtual base classes within
44 * the hierarchy should not have \c visit methods.
45 */
46 /*@{*/
47 virtual void visit(class ir_variable *) = 0;
48 virtual void visit(class ir_function_signature *) = 0;
49 virtual void visit(class ir_function *) = 0;
50 virtual void visit(class ir_expression *) = 0;
51 virtual void visit(class ir_texture *) = 0;
52 virtual void visit(class ir_swizzle *) = 0;
53 virtual void visit(class ir_dereference_variable *) = 0;
54 virtual void visit(class ir_dereference_array *) = 0;
55 virtual void visit(class ir_dereference_record *) = 0;
56 virtual void visit(class ir_assignment *) = 0;
57 virtual void visit(class ir_constant *) = 0;
58 virtual void visit(class ir_call *) = 0;
59 virtual void visit(class ir_return *) = 0;
60 virtual void visit(class ir_discard *) = 0;
61 virtual void visit(class ir_if *) = 0;
62 virtual void visit(class ir_loop *) = 0;
63 virtual void visit(class ir_loop_jump *) = 0;
64 /*@}*/
65};
66
67#endif /* IR_VISITOR_H */
diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp
new file mode 100644
index 00000000000..dfda05fcbe5
--- /dev/null
+++ b/src/glsl/link_functions.cpp
@@ -0,0 +1,262 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <cstdlib>
25#include <cstdio>
26#include <cstdarg>
27
28extern "C" {
29#include <talloc.h>
30}
31
32#include "main/mtypes.h"
33#include "glsl_symbol_table.h"
34#include "glsl_parser_extras.h"
35#include "ir.h"
36#include "program.h"
37#include "program/hash_table.h"
38#include "linker.h"
39
40static ir_function_signature *
41find_matching_signature(const char *name, const exec_list *actual_parameters,
42 gl_shader **shader_list, unsigned num_shaders);
43
44class call_link_visitor : public ir_hierarchical_visitor {
45public:
46 call_link_visitor(gl_shader_program *prog, gl_shader *linked,
47 gl_shader **shader_list, unsigned num_shaders)
48 {
49 this->prog = prog;
50 this->shader_list = shader_list;
51 this->num_shaders = num_shaders;
52 this->success = true;
53 this->linked = linked;
54
55 this->locals = hash_table_ctor(0, hash_table_pointer_hash,
56 hash_table_pointer_compare);
57 }
58
59 ~call_link_visitor()
60 {
61 hash_table_dtor(this->locals);
62 }
63
64 virtual ir_visitor_status visit(ir_variable *ir)
65 {
66 hash_table_insert(locals, ir, ir);
67 return visit_continue;
68 }
69
70 virtual ir_visitor_status visit_enter(ir_call *ir)
71 {
72 /* If ir is an ir_call from a function that was imported from another
73 * shader callee will point to an ir_function_signature in the original
74 * shader. In this case the function signature MUST NOT BE MODIFIED.
75 * Doing so will modify the original shader. This may prevent that
76 * shader from being linkable in other programs.
77 */
78 const ir_function_signature *const callee = ir->get_callee();
79 assert(callee != NULL);
80 const char *const name = callee->function_name();
81
82 /* Determine if the requested function signature already exists in the
83 * final linked shader. If it does, use it as the target of the call.
84 */
85 ir_function_signature *sig =
86 find_matching_signature(name, &callee->parameters, &linked, 1);
87 if (sig != NULL) {
88 ir->set_callee(sig);
89 return visit_continue;
90 }
91
92 /* Try to find the signature in one of the other shaders that is being
93 * linked. If it's not found there, return an error.
94 */
95 sig = find_matching_signature(name, &ir->actual_parameters, shader_list,
96 num_shaders);
97 if (sig == NULL) {
98 /* FINISHME: Log the full signature of unresolved function.
99 */
100 linker_error_printf(this->prog, "unresolved reference to function "
101 "`%s'\n", name);
102 this->success = false;
103 return visit_stop;
104 }
105
106 /* Find the prototype information in the linked shader. Generate any
107 * details that may be missing.
108 */
109 ir_function *f = linked->symbols->get_function(name);
110 if (f == NULL)
111 f = new(linked) ir_function(name);
112
113 ir_function_signature *linked_sig =
114 f->matching_signature(&callee->parameters);
115 if (linked_sig == NULL) {
116 linked_sig = new(linked) ir_function_signature(callee->return_type);
117 f->add_signature(linked_sig);
118 }
119
120 /* At this point linked_sig and called may be the same. If ir is an
121 * ir_call from linked then linked_sig and callee will be
122 * ir_function_signatures that have no definitions (is_defined is false).
123 */
124 assert(!linked_sig->is_defined);
125 assert(linked_sig->body.is_empty());
126
127 /* Create an in-place clone of the function definition. This multistep
128 * process introduces some complexity here, but it has some advantages.
129 * The parameter list and the and function body are cloned separately.
130 * The clone of the parameter list is used to prime the hashtable used
131 * to replace variable references in the cloned body.
132 *
133 * The big advantage is that the ir_function_signature does not change.
134 * This means that we don't have to process the rest of the IR tree to
135 * patch ir_call nodes. In addition, there is no way to remove or
136 * replace signature stored in a function. One could easily be added,
137 * but this avoids the need.
138 */
139 struct hash_table *ht = hash_table_ctor(0, hash_table_pointer_hash,
140 hash_table_pointer_compare);
141 exec_list formal_parameters;
142 foreach_list_const(node, &sig->parameters) {
143 const ir_instruction *const original = (ir_instruction *) node;
144 assert(const_cast<ir_instruction *>(original)->as_variable());
145
146 ir_instruction *copy = original->clone(linked, ht);
147 formal_parameters.push_tail(copy);
148 }
149
150 linked_sig->replace_parameters(&formal_parameters);
151
152 foreach_list_const(node, &sig->body) {
153 const ir_instruction *const original = (ir_instruction *) node;
154
155 ir_instruction *copy = original->clone(linked, ht);
156 linked_sig->body.push_tail(copy);
157 }
158
159 linked_sig->is_defined = true;
160 hash_table_dtor(ht);
161
162 /* Patch references inside the function to things outside the function
163 * (i.e., function calls and global variables).
164 */
165 linked_sig->accept(this);
166
167 ir->set_callee(linked_sig);
168
169 return visit_continue;
170 }
171
172 virtual ir_visitor_status visit(ir_dereference_variable *ir)
173 {
174 if (hash_table_find(locals, ir->var) == NULL) {
175 /* The non-function variable must be a global, so try to find the
176 * variable in the shader's symbol table. If the variable is not
177 * found, then it's a global that *MUST* be defined in the original
178 * shader.
179 */
180 ir_variable *var = linked->symbols->get_variable(ir->var->name);
181 if (var == NULL) {
182 /* Clone the ir_variable that the dereference already has and add
183 * it to the linked shader.
184 */
185 var = ir->var->clone(linked, NULL);
186 linked->symbols->add_variable(var->name, var);
187 linked->ir->push_head(var);
188 }
189
190 ir->var = var;
191 }
192
193 return visit_continue;
194 }
195
196 /** Was function linking successful? */
197 bool success;
198
199private:
200 /**
201 * Shader program being linked
202 *
203 * This is only used for logging error messages.
204 */
205 gl_shader_program *prog;
206
207 /** List of shaders available for linking. */
208 gl_shader **shader_list;
209
210 /** Number of shaders available for linking. */
211 unsigned num_shaders;
212
213 /**
214 * Final linked shader
215 *
216 * This is used two ways. It is used to find global variables in the
217 * linked shader that are accessed by the function. It is also used to add
218 * global variables from the shader where the function originated.
219 */
220 gl_shader *linked;
221
222 /**
223 * Table of variables local to the function.
224 */
225 hash_table *locals;
226};
227
228
229/**
230 * Searches a list of shaders for a particular function definition
231 */
232ir_function_signature *
233find_matching_signature(const char *name, const exec_list *actual_parameters,
234 gl_shader **shader_list, unsigned num_shaders)
235{
236 for (unsigned i = 0; i < num_shaders; i++) {
237 ir_function *const f = shader_list[i]->symbols->get_function(name);
238
239 if (f == NULL)
240 continue;
241
242 ir_function_signature *sig = f->matching_signature(actual_parameters);
243
244 if ((sig == NULL) || !sig->is_defined)
245 continue;
246
247 return sig;
248 }
249
250 return NULL;
251}
252
253
254bool
255link_function_calls(gl_shader_program *prog, gl_shader *main,
256 gl_shader **shader_list, unsigned num_shaders)
257{
258 call_link_visitor v(prog, main, shader_list, num_shaders);
259
260 v.run(main->ir);
261 return v.success;
262}
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
new file mode 100644
index 00000000000..22cdd76015a
--- /dev/null
+++ b/src/glsl/linker.cpp
@@ -0,0 +1,1341 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file linker.cpp
26 * GLSL linker implementation
27 *
28 * Given a set of shaders that are to be linked to generate a final program,
29 * there are three distinct stages.
30 *
31 * In the first stage shaders are partitioned into groups based on the shader
32 * type. All shaders of a particular type (e.g., vertex shaders) are linked
33 * together.
34 *
35 * - Undefined references in each shader are resolve to definitions in
36 * another shader.
37 * - Types and qualifiers of uniforms, outputs, and global variables defined
38 * in multiple shaders with the same name are verified to be the same.
39 * - Initializers for uniforms and global variables defined
40 * in multiple shaders with the same name are verified to be the same.
41 *
42 * The result, in the terminology of the GLSL spec, is a set of shader
43 * executables for each processing unit.
44 *
45 * After the first stage is complete, a series of semantic checks are performed
46 * on each of the shader executables.
47 *
48 * - Each shader executable must define a \c main function.
49 * - Each vertex shader executable must write to \c gl_Position.
50 * - Each fragment shader executable must write to either \c gl_FragData or
51 * \c gl_FragColor.
52 *
53 * In the final stage individual shader executables are linked to create a
54 * complete exectuable.
55 *
56 * - Types of uniforms defined in multiple shader stages with the same name
57 * are verified to be the same.
58 * - Initializers for uniforms defined in multiple shader stages with the
59 * same name are verified to be the same.
60 * - Types and qualifiers of outputs defined in one stage are verified to
61 * be the same as the types and qualifiers of inputs defined with the same
62 * name in a later stage.
63 *
64 * \author Ian Romanick <ian.d.romanick@intel.com>
65 */
66#include <cstdlib>
67#include <cstdio>
68#include <cstdarg>
69#include <climits>
70
71extern "C" {
72#include <talloc.h>
73}
74
75#include "main/compiler.h"
76#include "main/mtypes.h"
77#include "main/macros.h"
78#include "main/shaderobj.h"
79#include "glsl_symbol_table.h"
80#include "ir.h"
81#include "program.h"
82#include "program/hash_table.h"
83#include "linker.h"
84#include "ir_optimization.h"
85
86/**
87 * Visitor that determines whether or not a variable is ever written.
88 */
89class find_assignment_visitor : public ir_hierarchical_visitor {
90public:
91 find_assignment_visitor(const char *name)
92 : name(name), found(false)
93 {
94 /* empty */
95 }
96
97 virtual ir_visitor_status visit_enter(ir_assignment *ir)
98 {
99 ir_variable *const var = ir->lhs->variable_referenced();
100
101 if (strcmp(name, var->name) == 0) {
102 found = true;
103 return visit_stop;
104 }
105
106 return visit_continue_with_parent;
107 }
108
109 bool variable_found()
110 {
111 return found;
112 }
113
114private:
115 const char *name; /**< Find writes to a variable with this name. */
116 bool found; /**< Was a write to the variable found? */
117};
118
119
120/**
121 * Visitor that determines whether or not a variable is ever read.
122 */
123class find_deref_visitor : public ir_hierarchical_visitor {
124public:
125 find_deref_visitor(const char *name)
126 : name(name), found(false)
127 {
128 /* empty */
129 }
130
131 virtual ir_visitor_status visit(ir_dereference_variable *ir)
132 {
133 if (strcmp(this->name, ir->var->name) == 0) {
134 this->found = true;
135 return visit_stop;
136 }
137
138 return visit_continue;
139 }
140
141 bool variable_found() const
142 {
143 return this->found;
144 }
145
146private:
147 const char *name; /**< Find writes to a variable with this name. */
148 bool found; /**< Was a write to the variable found? */
149};
150
151
152void
153linker_error_printf(gl_shader_program *prog, const char *fmt, ...)
154{
155 va_list ap;
156
157 prog->InfoLog = talloc_strdup_append(prog->InfoLog, "error: ");
158 va_start(ap, fmt);
159 prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, ap);
160 va_end(ap);
161}
162
163
164void
165invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode,
166 int generic_base)
167{
168 foreach_list(node, sh->ir) {
169 ir_variable *const var = ((ir_instruction *) node)->as_variable();
170
171 if ((var == NULL) || (var->mode != (unsigned) mode))
172 continue;
173
174 /* Only assign locations for generic attributes / varyings / etc.
175 */
176 if (var->location >= generic_base)
177 var->location = -1;
178 }
179}
180
181
182/**
183 * Determine the number of attribute slots required for a particular type
184 *
185 * This code is here because it implements the language rules of a specific
186 * GLSL version. Since it's a property of the language and not a property of
187 * types in general, it doesn't really belong in glsl_type.
188 */
189unsigned
190count_attribute_slots(const glsl_type *t)
191{
192 /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec:
193 *
194 * "A scalar input counts the same amount against this limit as a vec4,
195 * so applications may want to consider packing groups of four
196 * unrelated float inputs together into a vector to better utilize the
197 * capabilities of the underlying hardware. A matrix input will use up
198 * multiple locations. The number of locations used will equal the
199 * number of columns in the matrix."
200 *
201 * The spec does not explicitly say how arrays are counted. However, it
202 * should be safe to assume the total number of slots consumed by an array
203 * is the number of entries in the array multiplied by the number of slots
204 * consumed by a single element of the array.
205 */
206
207 if (t->is_array())
208 return t->array_size() * count_attribute_slots(t->element_type());
209
210 if (t->is_matrix())
211 return t->matrix_columns;
212
213 return 1;
214}
215
216
217/**
218 * Verify that a vertex shader executable meets all semantic requirements
219 *
220 * \param shader Vertex shader executable to be verified
221 */
222bool
223validate_vertex_shader_executable(struct gl_shader_program *prog,
224 struct gl_shader *shader)
225{
226 if (shader == NULL)
227 return true;
228
229 find_assignment_visitor find("gl_Position");
230 find.run(shader->ir);
231 if (!find.variable_found()) {
232 linker_error_printf(prog,
233 "vertex shader does not write to `gl_Position'\n");
234 return false;
235 }
236
237 return true;
238}
239
240
241/**
242 * Verify that a fragment shader executable meets all semantic requirements
243 *
244 * \param shader Fragment shader executable to be verified
245 */
246bool
247validate_fragment_shader_executable(struct gl_shader_program *prog,
248 struct gl_shader *shader)
249{
250 if (shader == NULL)
251 return true;
252
253 find_assignment_visitor frag_color("gl_FragColor");
254 find_assignment_visitor frag_data("gl_FragData");
255
256 frag_color.run(shader->ir);
257 frag_data.run(shader->ir);
258
259 if (frag_color.variable_found() && frag_data.variable_found()) {
260 linker_error_printf(prog, "fragment shader writes to both "
261 "`gl_FragColor' and `gl_FragData'\n");
262 return false;
263 }
264
265 return true;
266}
267
268
269/**
270 * Generate a string describing the mode of a variable
271 */
272static const char *
273mode_string(const ir_variable *var)
274{
275 switch (var->mode) {
276 case ir_var_auto:
277 return (var->read_only) ? "global constant" : "global variable";
278
279 case ir_var_uniform: return "uniform";
280 case ir_var_in: return "shader input";
281 case ir_var_out: return "shader output";
282 case ir_var_inout: return "shader inout";
283
284 case ir_var_temporary:
285 default:
286 assert(!"Should not get here.");
287 return "invalid variable";
288 }
289}
290
291
292/**
293 * Perform validation of global variables used across multiple shaders
294 */
295bool
296cross_validate_globals(struct gl_shader_program *prog,
297 struct gl_shader **shader_list,
298 unsigned num_shaders,
299 bool uniforms_only)
300{
301 /* Examine all of the uniforms in all of the shaders and cross validate
302 * them.
303 */
304 glsl_symbol_table variables;
305 for (unsigned i = 0; i < num_shaders; i++) {
306 foreach_list(node, shader_list[i]->ir) {
307 ir_variable *const var = ((ir_instruction *) node)->as_variable();
308
309 if (var == NULL)
310 continue;
311
312 if (uniforms_only && (var->mode != ir_var_uniform))
313 continue;
314
315 /* Don't cross validate temporaries that are at global scope. These
316 * will eventually get pulled into the shaders 'main'.
317 */
318 if (var->mode == ir_var_temporary)
319 continue;
320
321 /* If a global with this name has already been seen, verify that the
322 * new instance has the same type. In addition, if the globals have
323 * initializers, the values of the initializers must be the same.
324 */
325 ir_variable *const existing = variables.get_variable(var->name);
326 if (existing != NULL) {
327 if (var->type != existing->type) {
328 linker_error_printf(prog, "%s `%s' declared as type "
329 "`%s' and type `%s'\n",
330 mode_string(var),
331 var->name, var->type->name,
332 existing->type->name);
333 return false;
334 }
335
336 /* FINISHME: Handle non-constant initializers.
337 */
338 if (var->constant_value != NULL) {
339 if (existing->constant_value != NULL) {
340 if (!var->constant_value->has_value(existing->constant_value)) {
341 linker_error_printf(prog, "initializers for %s "
342 "`%s' have differing values\n",
343 mode_string(var), var->name);
344 return false;
345 }
346 } else
347 /* If the first-seen instance of a particular uniform did not
348 * have an initializer but a later instance does, copy the
349 * initializer to the version stored in the symbol table.
350 */
351 /* FINISHME: This is wrong. The constant_value field should
352 * FINISHME: not be modified! Imagine a case where a shader
353 * FINISHME: without an initializer is linked in two different
354 * FINISHME: programs with shaders that have differing
355 * FINISHME: initializers. Linking with the first will
356 * FINISHME: modify the shader, and linking with the second
357 * FINISHME: will fail.
358 */
359 existing->constant_value =
360 var->constant_value->clone(talloc_parent(existing), NULL);
361 }
362 } else
363 variables.add_variable(var->name, var);
364 }
365 }
366
367 return true;
368}
369
370
371/**
372 * Perform validation of uniforms used across multiple shader stages
373 */
374bool
375cross_validate_uniforms(struct gl_shader_program *prog)
376{
377 return cross_validate_globals(prog, prog->_LinkedShaders,
378 prog->_NumLinkedShaders, true);
379}
380
381
382/**
383 * Validate that outputs from one stage match inputs of another
384 */
385bool
386cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
387 gl_shader *producer, gl_shader *consumer)
388{
389 glsl_symbol_table parameters;
390 /* FINISHME: Figure these out dynamically. */
391 const char *const producer_stage = "vertex";
392 const char *const consumer_stage = "fragment";
393
394 /* Find all shader outputs in the "producer" stage.
395 */
396 foreach_list(node, producer->ir) {
397 ir_variable *const var = ((ir_instruction *) node)->as_variable();
398
399 /* FINISHME: For geometry shaders, this should also look for inout
400 * FINISHME: variables.
401 */
402 if ((var == NULL) || (var->mode != ir_var_out))
403 continue;
404
405 parameters.add_variable(var->name, var);
406 }
407
408
409 /* Find all shader inputs in the "consumer" stage. Any variables that have
410 * matching outputs already in the symbol table must have the same type and
411 * qualifiers.
412 */
413 foreach_list(node, consumer->ir) {
414 ir_variable *const input = ((ir_instruction *) node)->as_variable();
415
416 /* FINISHME: For geometry shaders, this should also look for inout
417 * FINISHME: variables.
418 */
419 if ((input == NULL) || (input->mode != ir_var_in))
420 continue;
421
422 ir_variable *const output = parameters.get_variable(input->name);
423 if (output != NULL) {
424 /* Check that the types match between stages.
425 */
426 if (input->type != output->type) {
427 linker_error_printf(prog,
428 "%s shader output `%s' delcared as "
429 "type `%s', but %s shader input declared "
430 "as type `%s'\n",
431 producer_stage, output->name,
432 output->type->name,
433 consumer_stage, input->type->name);
434 return false;
435 }
436
437 /* Check that all of the qualifiers match between stages.
438 */
439 if (input->centroid != output->centroid) {
440 linker_error_printf(prog,
441 "%s shader output `%s' %s centroid qualifier, "
442 "but %s shader input %s centroid qualifier\n",
443 producer_stage,
444 output->name,
445 (output->centroid) ? "has" : "lacks",
446 consumer_stage,
447 (input->centroid) ? "has" : "lacks");
448 return false;
449 }
450
451 if (input->invariant != output->invariant) {
452 linker_error_printf(prog,
453 "%s shader output `%s' %s invariant qualifier, "
454 "but %s shader input %s invariant qualifier\n",
455 producer_stage,
456 output->name,
457 (output->invariant) ? "has" : "lacks",
458 consumer_stage,
459 (input->invariant) ? "has" : "lacks");
460 return false;
461 }
462
463 if (input->interpolation != output->interpolation) {
464 linker_error_printf(prog,
465 "%s shader output `%s' specifies %s "
466 "interpolation qualifier, "
467 "but %s shader input specifies %s "
468 "interpolation qualifier\n",
469 producer_stage,
470 output->name,
471 output->interpolation_string(),
472 consumer_stage,
473 input->interpolation_string());
474 return false;
475 }
476 }
477 }
478
479 return true;
480}
481
482
483/**
484 * Populates a shaders symbol table with all global declarations
485 */
486static void
487populate_symbol_table(gl_shader *sh)
488{
489 sh->symbols = new(sh) glsl_symbol_table;
490
491 foreach_list(node, sh->ir) {
492 ir_instruction *const inst = (ir_instruction *) node;
493 ir_variable *var;
494 ir_function *func;
495
496 if ((func = inst->as_function()) != NULL) {
497 sh->symbols->add_function(func->name, func);
498 } else if ((var = inst->as_variable()) != NULL) {
499 sh->symbols->add_variable(var->name, var);
500 }
501 }
502}
503
504
505/**
506 * Remap variables referenced in an instruction tree
507 *
508 * This is used when instruction trees are cloned from one shader and placed in
509 * another. These trees will contain references to \c ir_variable nodes that
510 * do not exist in the target shader. This function finds these \c ir_variable
511 * references and replaces the references with matching variables in the target
512 * shader.
513 *
514 * If there is no matching variable in the target shader, a clone of the
515 * \c ir_variable is made and added to the target shader. The new variable is
516 * added to \b both the instruction stream and the symbol table.
517 *
518 * \param inst IR tree that is to be processed.
519 * \param symbols Symbol table containing global scope symbols in the
520 * linked shader.
521 * \param instructions Instruction stream where new variable declarations
522 * should be added.
523 */
524void
525remap_variables(ir_instruction *inst, struct gl_shader *target,
526 hash_table *temps)
527{
528 class remap_visitor : public ir_hierarchical_visitor {
529 public:
530 remap_visitor(struct gl_shader *target,
531 hash_table *temps)
532 {
533 this->target = target;
534 this->symbols = target->symbols;
535 this->instructions = target->ir;
536 this->temps = temps;
537 }
538
539 virtual ir_visitor_status visit(ir_dereference_variable *ir)
540 {
541 if (ir->var->mode == ir_var_temporary) {
542 ir_variable *var = (ir_variable *) hash_table_find(temps, ir->var);
543
544 assert(var != NULL);
545 ir->var = var;
546 return visit_continue;
547 }
548
549 ir_variable *const existing =
550 this->symbols->get_variable(ir->var->name);
551 if (existing != NULL)
552 ir->var = existing;
553 else {
554 ir_variable *copy = ir->var->clone(this->target, NULL);
555
556 this->symbols->add_variable(copy->name, copy);
557 this->instructions->push_head(copy);
558 ir->var = copy;
559 }
560
561 return visit_continue;
562 }
563
564 private:
565 struct gl_shader *target;
566 glsl_symbol_table *symbols;
567 exec_list *instructions;
568 hash_table *temps;
569 };
570
571 remap_visitor v(target, temps);
572
573 inst->accept(&v);
574}
575
576
577/**
578 * Move non-declarations from one instruction stream to another
579 *
580 * The intended usage pattern of this function is to pass the pointer to the
581 * head sentinel of a list (i.e., a pointer to the list cast to an \c exec_node
582 * pointer) for \c last and \c false for \c make_copies on the first
583 * call. Successive calls pass the return value of the previous call for
584 * \c last and \c true for \c make_copies.
585 *
586 * \param instructions Source instruction stream
587 * \param last Instruction after which new instructions should be
588 * inserted in the target instruction stream
589 * \param make_copies Flag selecting whether instructions in \c instructions
590 * should be copied (via \c ir_instruction::clone) into the
591 * target list or moved.
592 *
593 * \return
594 * The new "last" instruction in the target instruction stream. This pointer
595 * is suitable for use as the \c last parameter of a later call to this
596 * function.
597 */
598exec_node *
599move_non_declarations(exec_list *instructions, exec_node *last,
600 bool make_copies, gl_shader *target)
601{
602 hash_table *temps = NULL;
603
604 if (make_copies)
605 temps = hash_table_ctor(0, hash_table_pointer_hash,
606 hash_table_pointer_compare);
607
608 foreach_list_safe(node, instructions) {
609 ir_instruction *inst = (ir_instruction *) node;
610
611 if (inst->as_function())
612 continue;
613
614 ir_variable *var = inst->as_variable();
615 if ((var != NULL) && (var->mode != ir_var_temporary))
616 continue;
617
618 assert(inst->as_assignment()
619 || ((var != NULL) && (var->mode == ir_var_temporary)));
620
621 if (make_copies) {
622 inst = inst->clone(target, NULL);
623
624 if (var != NULL)
625 hash_table_insert(temps, inst, var);
626 else
627 remap_variables(inst, target, temps);
628 } else {
629 inst->remove();
630 }
631
632 last->insert_after(inst);
633 last = inst;
634 }
635
636 if (make_copies)
637 hash_table_dtor(temps);
638
639 return last;
640}
641
642/**
643 * Get the function signature for main from a shader
644 */
645static ir_function_signature *
646get_main_function_signature(gl_shader *sh)
647{
648 ir_function *const f = sh->symbols->get_function("main");
649 if (f != NULL) {
650 exec_list void_parameters;
651
652 /* Look for the 'void main()' signature and ensure that it's defined.
653 * This keeps the linker from accidentally pick a shader that just
654 * contains a prototype for main.
655 *
656 * We don't have to check for multiple definitions of main (in multiple
657 * shaders) because that would have already been caught above.
658 */
659 ir_function_signature *sig = f->matching_signature(&void_parameters);
660 if ((sig != NULL) && sig->is_defined) {
661 return sig;
662 }
663 }
664
665 return NULL;
666}
667
668
669/**
670 * Combine a group of shaders for a single stage to generate a linked shader
671 *
672 * \note
673 * If this function is supplied a single shader, it is cloned, and the new
674 * shader is returned.
675 */
676static struct gl_shader *
677link_intrastage_shaders(struct gl_shader_program *prog,
678 struct gl_shader **shader_list,
679 unsigned num_shaders)
680{
681 /* Check that global variables defined in multiple shaders are consistent.
682 */
683 if (!cross_validate_globals(prog, shader_list, num_shaders, false))
684 return NULL;
685
686 /* Check that there is only a single definition of each function signature
687 * across all shaders.
688 */
689 for (unsigned i = 0; i < (num_shaders - 1); i++) {
690 foreach_list(node, shader_list[i]->ir) {
691 ir_function *const f = ((ir_instruction *) node)->as_function();
692
693 if (f == NULL)
694 continue;
695
696 for (unsigned j = i + 1; j < num_shaders; j++) {
697 ir_function *const other =
698 shader_list[j]->symbols->get_function(f->name);
699
700 /* If the other shader has no function (and therefore no function
701 * signatures) with the same name, skip to the next shader.
702 */
703 if (other == NULL)
704 continue;
705
706 foreach_iter (exec_list_iterator, iter, *f) {
707 ir_function_signature *sig =
708 (ir_function_signature *) iter.get();
709
710 if (!sig->is_defined || sig->is_built_in)
711 continue;
712
713 ir_function_signature *other_sig =
714 other->exact_matching_signature(& sig->parameters);
715
716 if ((other_sig != NULL) && other_sig->is_defined
717 && !other_sig->is_built_in) {
718 linker_error_printf(prog,
719 "function `%s' is multiply defined",
720 f->name);
721 return NULL;
722 }
723 }
724 }
725 }
726 }
727
728 /* Find the shader that defines main, and make a clone of it.
729 *
730 * Starting with the clone, search for undefined references. If one is
731 * found, find the shader that defines it. Clone the reference and add
732 * it to the shader. Repeat until there are no undefined references or
733 * until a reference cannot be resolved.
734 */
735 gl_shader *main = NULL;
736 for (unsigned i = 0; i < num_shaders; i++) {
737 if (get_main_function_signature(shader_list[i]) != NULL) {
738 main = shader_list[i];
739 break;
740 }
741 }
742
743 if (main == NULL) {
744 linker_error_printf(prog, "%s shader lacks `main'\n",
745 (shader_list[0]->Type == GL_VERTEX_SHADER)
746 ? "vertex" : "fragment");
747 return NULL;
748 }
749
750 gl_shader *const linked = _mesa_new_shader(NULL, 0, main->Type);
751 linked->ir = new(linked) exec_list;
752 clone_ir_list(linked, linked->ir, main->ir);
753
754 populate_symbol_table(linked);
755
756 /* The a pointer to the main function in the final linked shader (i.e., the
757 * copy of the original shader that contained the main function).
758 */
759 ir_function_signature *const main_sig = get_main_function_signature(linked);
760
761 /* Move any instructions other than variable declarations or function
762 * declarations into main.
763 */
764 exec_node *insertion_point =
765 move_non_declarations(linked->ir, (exec_node *) &main_sig->body, false,
766 linked);
767
768 for (unsigned i = 0; i < num_shaders; i++) {
769 if (shader_list[i] == main)
770 continue;
771
772 insertion_point = move_non_declarations(shader_list[i]->ir,
773 insertion_point, true, linked);
774 }
775
776 /* Resolve initializers for global variables in the linked shader.
777 */
778 unsigned num_linking_shaders = num_shaders;
779 for (unsigned i = 0; i < num_shaders; i++)
780 num_linking_shaders += shader_list[i]->num_builtins_to_link;
781
782 gl_shader **linking_shaders =
783 (gl_shader **) calloc(num_linking_shaders, sizeof(gl_shader *));
784
785 memcpy(linking_shaders, shader_list,
786 sizeof(linking_shaders[0]) * num_shaders);
787
788 unsigned idx = num_shaders;
789 for (unsigned i = 0; i < num_shaders; i++) {
790 memcpy(&linking_shaders[idx], shader_list[i]->builtins_to_link,
791 sizeof(linking_shaders[0]) * shader_list[i]->num_builtins_to_link);
792 idx += shader_list[i]->num_builtins_to_link;
793 }
794
795 assert(idx == num_linking_shaders);
796
797 link_function_calls(prog, linked, linking_shaders, num_linking_shaders);
798
799 free(linking_shaders);
800
801 return linked;
802}
803
804
805struct uniform_node {
806 exec_node link;
807 struct gl_uniform *u;
808 unsigned slots;
809};
810
811void
812assign_uniform_locations(struct gl_shader_program *prog)
813{
814 /* */
815 exec_list uniforms;
816 unsigned total_uniforms = 0;
817 hash_table *ht = hash_table_ctor(32, hash_table_string_hash,
818 hash_table_string_compare);
819
820 for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
821 unsigned next_position = 0;
822
823 foreach_list(node, prog->_LinkedShaders[i]->ir) {
824 ir_variable *const var = ((ir_instruction *) node)->as_variable();
825
826 if ((var == NULL) || (var->mode != ir_var_uniform))
827 continue;
828
829 const unsigned vec4_slots = (var->component_slots() + 3) / 4;
830 if (vec4_slots == 0) {
831 /* If we've got a sampler or an aggregate of them, the size can
832 * end up zero. Don't allocate any space.
833 */
834 continue;
835 }
836
837 uniform_node *n = (uniform_node *) hash_table_find(ht, var->name);
838 if (n == NULL) {
839 n = (uniform_node *) calloc(1, sizeof(struct uniform_node));
840 n->u = (gl_uniform *) calloc(vec4_slots, sizeof(struct gl_uniform));
841 n->slots = vec4_slots;
842
843 n->u[0].Name = strdup(var->name);
844 for (unsigned j = 1; j < vec4_slots; j++)
845 n->u[j].Name = n->u[0].Name;
846
847 hash_table_insert(ht, n, n->u[0].Name);
848 uniforms.push_tail(& n->link);
849 total_uniforms += vec4_slots;
850 }
851
852 if (var->constant_value != NULL)
853 for (unsigned j = 0; j < vec4_slots; j++)
854 n->u[j].Initialized = true;
855
856 var->location = next_position;
857
858 for (unsigned j = 0; j < vec4_slots; j++) {
859 switch (prog->_LinkedShaders[i]->Type) {
860 case GL_VERTEX_SHADER:
861 n->u[j].VertPos = next_position;
862 break;
863 case GL_FRAGMENT_SHADER:
864 n->u[j].FragPos = next_position;
865 break;
866 case GL_GEOMETRY_SHADER:
867 /* FINISHME: Support geometry shaders. */
868 assert(prog->_LinkedShaders[i]->Type != GL_GEOMETRY_SHADER);
869 break;
870 }
871
872 next_position++;
873 }
874 }
875 }
876
877 gl_uniform_list *ul = (gl_uniform_list *)
878 calloc(1, sizeof(gl_uniform_list));
879
880 ul->Size = total_uniforms;
881 ul->NumUniforms = total_uniforms;
882 ul->Uniforms = (gl_uniform *) calloc(total_uniforms, sizeof(gl_uniform));
883
884 unsigned idx = 0;
885 uniform_node *next;
886 for (uniform_node *node = (uniform_node *) uniforms.head
887 ; node->link.next != NULL
888 ; node = next) {
889 next = (uniform_node *) node->link.next;
890
891 node->link.remove();
892 memcpy(&ul->Uniforms[idx], node->u, sizeof(gl_uniform) * node->slots);
893 idx += node->slots;
894
895 free(node->u);
896 free(node);
897 }
898
899 hash_table_dtor(ht);
900
901 prog->Uniforms = ul;
902}
903
904
905/**
906 * Find a contiguous set of available bits in a bitmask
907 *
908 * \param used_mask Bits representing used (1) and unused (0) locations
909 * \param needed_count Number of contiguous bits needed.
910 *
911 * \return
912 * Base location of the available bits on success or -1 on failure.
913 */
914int
915find_available_slots(unsigned used_mask, unsigned needed_count)
916{
917 unsigned needed_mask = (1 << needed_count) - 1;
918 const int max_bit_to_test = (8 * sizeof(used_mask)) - needed_count;
919
920 /* The comparison to 32 is redundant, but without it GCC emits "warning:
921 * cannot optimize possibly infinite loops" for the loop below.
922 */
923 if ((needed_count == 0) || (max_bit_to_test < 0) || (max_bit_to_test > 32))
924 return -1;
925
926 for (int i = 0; i <= max_bit_to_test; i++) {
927 if ((needed_mask & ~used_mask) == needed_mask)
928 return i;
929
930 needed_mask <<= 1;
931 }
932
933 return -1;
934}
935
936
937bool
938assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index)
939{
940 /* Mark invalid attribute locations as being used.
941 */
942 unsigned used_locations = (max_attribute_index >= 32)
943 ? ~0 : ~((1 << max_attribute_index) - 1);
944
945 gl_shader *const sh = prog->_LinkedShaders[0];
946 assert(sh->Type == GL_VERTEX_SHADER);
947
948 /* Operate in a total of four passes.
949 *
950 * 1. Invalidate the location assignments for all vertex shader inputs.
951 *
952 * 2. Assign locations for inputs that have user-defined (via
953 * glBindVertexAttribLocation) locatoins.
954 *
955 * 3. Sort the attributes without assigned locations by number of slots
956 * required in decreasing order. Fragmentation caused by attribute
957 * locations assigned by the application may prevent large attributes
958 * from having enough contiguous space.
959 *
960 * 4. Assign locations to any inputs without assigned locations.
961 */
962
963 invalidate_variable_locations(sh, ir_var_in, VERT_ATTRIB_GENERIC0);
964
965 if (prog->Attributes != NULL) {
966 for (unsigned i = 0; i < prog->Attributes->NumParameters; i++) {
967 ir_variable *const var =
968 sh->symbols->get_variable(prog->Attributes->Parameters[i].Name);
969
970 /* Note: attributes that occupy multiple slots, such as arrays or
971 * matrices, may appear in the attrib array multiple times.
972 */
973 if ((var == NULL) || (var->location != -1))
974 continue;
975
976 /* From page 61 of the OpenGL 4.0 spec:
977 *
978 * "LinkProgram will fail if the attribute bindings assigned by
979 * BindAttribLocation do not leave not enough space to assign a
980 * location for an active matrix attribute or an active attribute
981 * array, both of which require multiple contiguous generic
982 * attributes."
983 *
984 * Previous versions of the spec contain similar language but omit the
985 * bit about attribute arrays.
986 *
987 * Page 61 of the OpenGL 4.0 spec also says:
988 *
989 * "It is possible for an application to bind more than one
990 * attribute name to the same location. This is referred to as
991 * aliasing. This will only work if only one of the aliased
992 * attributes is active in the executable program, or if no path
993 * through the shader consumes more than one attribute of a set
994 * of attributes aliased to the same location. A link error can
995 * occur if the linker determines that every path through the
996 * shader consumes multiple aliased attributes, but
997 * implementations are not required to generate an error in this
998 * case."
999 *
1000 * These two paragraphs are either somewhat contradictory, or I don't
1001 * fully understand one or both of them.
1002 */
1003 /* FINISHME: The code as currently written does not support attribute
1004 * FINISHME: location aliasing (see comment above).
1005 */
1006 const int attr = prog->Attributes->Parameters[i].StateIndexes[0];
1007 const unsigned slots = count_attribute_slots(var->type);
1008
1009 /* Mask representing the contiguous slots that will be used by this
1010 * attribute.
1011 */
1012 const unsigned use_mask = (1 << slots) - 1;
1013
1014 /* Generate a link error if the set of bits requested for this
1015 * attribute overlaps any previously allocated bits.
1016 */
1017 if ((~(use_mask << attr) & used_locations) != used_locations) {
1018 linker_error_printf(prog,
1019 "insufficient contiguous attribute locations "
1020 "available for vertex shader input `%s'",
1021 var->name);
1022 return false;
1023 }
1024
1025 var->location = VERT_ATTRIB_GENERIC0 + attr;
1026 used_locations |= (use_mask << attr);
1027 }
1028 }
1029
1030 /* Temporary storage for the set of attributes that need locations assigned.
1031 */
1032 struct temp_attr {
1033 unsigned slots;
1034 ir_variable *var;
1035
1036 /* Used below in the call to qsort. */
1037 static int compare(const void *a, const void *b)
1038 {
1039 const temp_attr *const l = (const temp_attr *) a;
1040 const temp_attr *const r = (const temp_attr *) b;
1041
1042 /* Reversed because we want a descending order sort below. */
1043 return r->slots - l->slots;
1044 }
1045 } to_assign[16];
1046
1047 unsigned num_attr = 0;
1048
1049 foreach_list(node, sh->ir) {
1050 ir_variable *const var = ((ir_instruction *) node)->as_variable();
1051
1052 if ((var == NULL) || (var->mode != ir_var_in))
1053 continue;
1054
1055 /* The location was explicitly assigned, nothing to do here.
1056 */
1057 if (var->location != -1)
1058 continue;
1059
1060 to_assign[num_attr].slots = count_attribute_slots(var->type);
1061 to_assign[num_attr].var = var;
1062 num_attr++;
1063 }
1064
1065 /* If all of the attributes were assigned locations by the application (or
1066 * are built-in attributes with fixed locations), return early. This should
1067 * be the common case.
1068 */
1069 if (num_attr == 0)
1070 return true;
1071
1072 qsort(to_assign, num_attr, sizeof(to_assign[0]), temp_attr::compare);
1073
1074 /* VERT_ATTRIB_GENERIC0 is a psdueo-alias for VERT_ATTRIB_POS. It can only
1075 * be explicitly assigned by via glBindAttribLocation. Mark it as reserved
1076 * to prevent it from being automatically allocated below.
1077 */
1078 find_deref_visitor find("gl_Vertex");
1079 find.run(sh->ir);
1080 if (find.variable_found())
1081 used_locations |= (1 << 0);
1082
1083 for (unsigned i = 0; i < num_attr; i++) {
1084 /* Mask representing the contiguous slots that will be used by this
1085 * attribute.
1086 */
1087 const unsigned use_mask = (1 << to_assign[i].slots) - 1;
1088
1089 int location = find_available_slots(used_locations, to_assign[i].slots);
1090
1091 if (location < 0) {
1092 linker_error_printf(prog,
1093 "insufficient contiguous attribute locations "
1094 "available for vertex shader input `%s'",
1095 to_assign[i].var->name);
1096 return false;
1097 }
1098
1099 to_assign[i].var->location = VERT_ATTRIB_GENERIC0 + location;
1100 used_locations |= (use_mask << location);
1101 }
1102
1103 return true;
1104}
1105
1106
1107void
1108assign_varying_locations(struct gl_shader_program *prog,
1109 gl_shader *producer, gl_shader *consumer)
1110{
1111 /* FINISHME: Set dynamically when geometry shader support is added. */
1112 unsigned output_index = VERT_RESULT_VAR0;
1113 unsigned input_index = FRAG_ATTRIB_VAR0;
1114
1115 /* Operate in a total of three passes.
1116 *
1117 * 1. Assign locations for any matching inputs and outputs.
1118 *
1119 * 2. Mark output variables in the producer that do not have locations as
1120 * not being outputs. This lets the optimizer eliminate them.
1121 *
1122 * 3. Mark input variables in the consumer that do not have locations as
1123 * not being inputs. This lets the optimizer eliminate them.
1124 */
1125
1126 invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0);
1127 invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0);
1128
1129 foreach_list(node, producer->ir) {
1130 ir_variable *const output_var = ((ir_instruction *) node)->as_variable();
1131
1132 if ((output_var == NULL) || (output_var->mode != ir_var_out)
1133 || (output_var->location != -1))
1134 continue;
1135
1136 ir_variable *const input_var =
1137 consumer->symbols->get_variable(output_var->name);
1138
1139 if ((input_var == NULL) || (input_var->mode != ir_var_in))
1140 continue;
1141
1142 assert(input_var->location == -1);
1143
1144 /* FINISHME: Location assignment will need some changes when arrays,
1145 * FINISHME: matrices, and structures are allowed as shader inputs /
1146 * FINISHME: outputs.
1147 */
1148 output_var->location = output_index;
1149 input_var->location = input_index;
1150
1151 output_index++;
1152 input_index++;
1153 }
1154
1155 foreach_list(node, producer->ir) {
1156 ir_variable *const var = ((ir_instruction *) node)->as_variable();
1157
1158 if ((var == NULL) || (var->mode != ir_var_out))
1159 continue;
1160
1161 /* An 'out' variable is only really a shader output if its value is read
1162 * by the following stage.
1163 */
1164 if (var->location == -1) {
1165 var->mode = ir_var_auto;
1166 }
1167 }
1168
1169 foreach_list(node, consumer->ir) {
1170 ir_variable *const var = ((ir_instruction *) node)->as_variable();
1171
1172 if ((var == NULL) || (var->mode != ir_var_in))
1173 continue;
1174
1175 if (var->location == -1) {
1176 if (prog->Version <= 120) {
1177 /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec:
1178 *
1179 * Only those varying variables used (i.e. read) in
1180 * the fragment shader executable must be written to
1181 * by the vertex shader executable; declaring
1182 * superfluous varying variables in a vertex shader is
1183 * permissible.
1184 *
1185 * We interpret this text as meaning that the VS must
1186 * write the variable for the FS to read it. See
1187 * "glsl1-varying read but not written" in piglit.
1188 */
1189
1190 linker_error_printf(prog, "fragment shader varying %s not written "
1191 "by vertex shader\n.", var->name);
1192 prog->LinkStatus = false;
1193 }
1194
1195 /* An 'in' variable is only really a shader input if its
1196 * value is written by the previous stage.
1197 */
1198 var->mode = ir_var_auto;
1199 }
1200 }
1201}
1202
1203
1204void
1205link_shaders(struct gl_shader_program *prog)
1206{
1207 prog->LinkStatus = false;
1208 prog->Validated = false;
1209 prog->_Used = false;
1210
1211 if (prog->InfoLog != NULL)
1212 talloc_free(prog->InfoLog);
1213
1214 prog->InfoLog = talloc_strdup(NULL, "");
1215
1216 /* Separate the shaders into groups based on their type.
1217 */
1218 struct gl_shader **vert_shader_list;
1219 unsigned num_vert_shaders = 0;
1220 struct gl_shader **frag_shader_list;
1221 unsigned num_frag_shaders = 0;
1222
1223 vert_shader_list = (struct gl_shader **)
1224 calloc(2 * prog->NumShaders, sizeof(struct gl_shader *));
1225 frag_shader_list = &vert_shader_list[prog->NumShaders];
1226
1227 unsigned min_version = UINT_MAX;
1228 unsigned max_version = 0;
1229 for (unsigned i = 0; i < prog->NumShaders; i++) {
1230 min_version = MIN2(min_version, prog->Shaders[i]->Version);
1231 max_version = MAX2(max_version, prog->Shaders[i]->Version);
1232
1233 switch (prog->Shaders[i]->Type) {
1234 case GL_VERTEX_SHADER:
1235 vert_shader_list[num_vert_shaders] = prog->Shaders[i];
1236 num_vert_shaders++;
1237 break;
1238 case GL_FRAGMENT_SHADER:
1239 frag_shader_list[num_frag_shaders] = prog->Shaders[i];
1240 num_frag_shaders++;
1241 break;
1242 case GL_GEOMETRY_SHADER:
1243 /* FINISHME: Support geometry shaders. */
1244 assert(prog->Shaders[i]->Type != GL_GEOMETRY_SHADER);
1245 break;
1246 }
1247 }
1248
1249 /* Previous to GLSL version 1.30, different compilation units could mix and
1250 * match shading language versions. With GLSL 1.30 and later, the versions
1251 * of all shaders must match.
1252 */
1253 assert(min_version >= 110);
1254 assert(max_version <= 130);
1255 if ((max_version >= 130) && (min_version != max_version)) {
1256 linker_error_printf(prog, "all shaders must use same shading "
1257 "language version\n");
1258 goto done;
1259 }
1260
1261 prog->Version = max_version;
1262
1263 /* Link all shaders for a particular stage and validate the result.
1264 */
1265 prog->_NumLinkedShaders = 0;
1266 if (num_vert_shaders > 0) {
1267 gl_shader *const sh =
1268 link_intrastage_shaders(prog, vert_shader_list, num_vert_shaders);
1269
1270 if (sh == NULL)
1271 goto done;
1272
1273 if (!validate_vertex_shader_executable(prog, sh))
1274 goto done;
1275
1276 prog->_LinkedShaders[prog->_NumLinkedShaders] = sh;
1277 prog->_NumLinkedShaders++;
1278 }
1279
1280 if (num_frag_shaders > 0) {
1281 gl_shader *const sh =
1282 link_intrastage_shaders(prog, frag_shader_list, num_frag_shaders);
1283
1284 if (sh == NULL)
1285 goto done;
1286
1287 if (!validate_fragment_shader_executable(prog, sh))
1288 goto done;
1289
1290 prog->_LinkedShaders[prog->_NumLinkedShaders] = sh;
1291 prog->_NumLinkedShaders++;
1292 }
1293
1294 /* Here begins the inter-stage linking phase. Some initial validation is
1295 * performed, then locations are assigned for uniforms, attributes, and
1296 * varyings.
1297 */
1298 if (cross_validate_uniforms(prog)) {
1299 /* Validate the inputs of each stage with the output of the preceeding
1300 * stage.
1301 */
1302 for (unsigned i = 1; i < prog->_NumLinkedShaders; i++) {
1303 if (!cross_validate_outputs_to_inputs(prog,
1304 prog->_LinkedShaders[i - 1],
1305 prog->_LinkedShaders[i]))
1306 goto done;
1307 }
1308
1309 prog->LinkStatus = true;
1310 }
1311
1312 /* Do common optimization before assigning storage for attributes,
1313 * uniforms, and varyings. Later optimization could possibly make
1314 * some of that unused.
1315 */
1316 for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
1317 while (do_common_optimization(prog->_LinkedShaders[i]->ir, true))
1318 ;
1319 }
1320
1321 assign_uniform_locations(prog);
1322
1323 if (prog->_LinkedShaders[0]->Type == GL_VERTEX_SHADER)
1324 /* FINISHME: The value of the max_attribute_index parameter is
1325 * FINISHME: implementation dependent based on the value of
1326 * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be
1327 * FINISHME: at least 16, so hardcode 16 for now.
1328 */
1329 if (!assign_attribute_locations(prog, 16))
1330 goto done;
1331
1332 for (unsigned i = 1; i < prog->_NumLinkedShaders; i++)
1333 assign_varying_locations(prog,
1334 prog->_LinkedShaders[i - 1],
1335 prog->_LinkedShaders[i]);
1336
1337 /* FINISHME: Assign fragment shader output locations. */
1338
1339done:
1340 free(vert_shader_list);
1341}
diff --git a/src/glsl/linker.h b/src/glsl/linker.h
new file mode 100644
index 00000000000..a8ce16a7ec1
--- /dev/null
+++ b/src/glsl/linker.h
@@ -0,0 +1,35 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#pragma once
25#ifndef GLSL_LINKER_H
26#define GLSL_LINKER_H
27
28extern void
29linker_error_printf(gl_shader_program *prog, const char *fmt, ...);
30
31extern bool
32link_function_calls(gl_shader_program *prog, gl_shader *main,
33 gl_shader **shader_list, unsigned num_shaders);
34
35#endif /* GLSL_LINKER_H */
diff --git a/src/glsl/list.h b/src/glsl/list.h
new file mode 100644
index 00000000000..a70b79d571f
--- /dev/null
+++ b/src/glsl/list.h
@@ -0,0 +1,465 @@
1/*
2 * Copyright © 2008, 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24/**
25 * \file list.h
26 * \brief Doubly-linked list abstract container type.
27 *
28 * Each doubly-linked list has a sentinel head and tail node. These nodes
29 * contain no data. The head sentinel can be identified by its \c prev
30 * pointer being \c NULL. The tail sentinel can be identified by its
31 * \c next pointer being \c NULL.
32 *
33 * A list is empty if either the head sentinel's \c next pointer points to the
34 * tail sentinel or the tail sentinel's \c prev poiner points to the head
35 * sentinel.
36 *
37 * Instead of tracking two separate \c node structures and a \c list structure
38 * that points to them, the sentinel nodes are in a single structure. Noting
39 * that each sentinel node always has one \c NULL pointer, the \c NULL
40 * pointers occupy the same memory location. In the \c list structure
41 * contains a the following:
42 *
43 * - A \c head pointer that represents the \c next pointer of the
44 * head sentinel node.
45 * - A \c tail pointer that represents the \c prev pointer of the head
46 * sentinel node and the \c next pointer of the tail sentinel node. This
47 * pointer is \b always \c NULL.
48 * - A \c tail_prev pointer that represents the \c prev pointer of the
49 * tail sentinel node.
50 *
51 * Therefore, if \c head->next is \c NULL or \c tail_prev->prev is \c NULL,
52 * the list is empty.
53 *
54 * To anyone familiar with "exec lists" on the Amiga, this structure should
55 * be immediately recognizable. See the following link for the original Amiga
56 * operating system documentation on the subject.
57 *
58 * http://www.natami.net/dev/Libraries_Manual_guide/node02D7.html
59 *
60 * \author Ian Romanick <ian.d.romanick@intel.com>
61 */
62
63#pragma once
64#ifndef LIST_CONTAINER_H
65#define LIST_CONTAINER_H
66
67#ifndef __cplusplus
68#include <stddef.h>
69#include <talloc.h>
70#else
71extern "C" {
72#include <talloc.h>
73}
74#endif
75
76#include <assert.h>
77
78struct exec_node {
79 struct exec_node *next;
80 struct exec_node *prev;
81
82#ifdef __cplusplus
83 /* Callers of this talloc-based new need not call delete. It's
84 * easier to just talloc_free 'ctx' (or any of its ancestors). */
85 static void* operator new(size_t size, void *ctx)
86 {
87 void *node;
88
89 node = talloc_size(ctx, size);
90 assert(node != NULL);
91
92 return node;
93 }
94
95 /* If the user *does* call delete, that's OK, we will just
96 * talloc_free in that case. */
97 static void operator delete(void *node)
98 {
99 talloc_free(node);
100 }
101
102 exec_node() : next(NULL), prev(NULL)
103 {
104 /* empty */
105 }
106
107 const exec_node *get_next() const
108 {
109 return next;
110 }
111
112 exec_node *get_next()
113 {
114 return next;
115 }
116
117 const exec_node *get_prev() const
118 {
119 return prev;
120 }
121
122 exec_node *get_prev()
123 {
124 return prev;
125 }
126
127 void remove()
128 {
129 next->prev = prev;
130 prev->next = next;
131 next = NULL;
132 prev = NULL;
133 }
134
135 /**
136 * Link a node with itself
137 *
138 * This creates a sort of degenerate list that is occasionally useful.
139 */
140 void self_link()
141 {
142 next = this;
143 prev = this;
144 }
145
146 /**
147 * Insert a node in the list after the current node
148 */
149 void insert_after(exec_node *after)
150 {
151 after->next = this->next;
152 after->prev = this;
153
154 this->next->prev = after;
155 this->next = after;
156 }
157 /**
158 * Insert a node in the list before the current node
159 */
160 void insert_before(exec_node *before)
161 {
162 before->next = this;
163 before->prev = this->prev;
164
165 this->prev->next = before;
166 this->prev = before;
167 }
168 /**
169 * Replace the current node with the given node.
170 */
171 void replace_with(exec_node *replacement)
172 {
173 replacement->prev = this->prev;
174 replacement->next = this->next;
175
176 this->prev->next = replacement;
177 this->next->prev = replacement;
178 }
179
180 /**
181 * Is this the sentinel at the tail of the list?
182 */
183 bool is_tail_sentinel() const
184 {
185 return this->next == NULL;
186 }
187
188 /**
189 * Is this the sentinel at the head of the list?
190 */
191 bool is_head_sentinel() const
192 {
193 return this->prev == NULL;
194 }
195#endif
196};
197
198
199#ifdef __cplusplus
200/* This macro will not work correctly if `t' uses virtual inheritance. If you
201 * are using virtual inheritance, you deserve a slow and painful death. Enjoy!
202 */
203#define exec_list_offsetof(t, f, p) \
204 (((char *) &((t *) p)->f) - ((char *) p))
205#else
206#define exec_list_offsetof(t, f, p) offsetof(t, f)
207#endif
208
209/**
210 * Get a pointer to the structure containing an exec_node
211 *
212 * Given a pointer to an \c exec_node embedded in a structure, get a pointer to
213 * the containing structure.
214 *
215 * \param type Base type of the structure containing the node
216 * \param node Pointer to the \c exec_node
217 * \param field Name of the field in \c type that is the embedded \c exec_node
218 */
219#define exec_node_data(type, node, field) \
220 ((type *) (((char *) node) - exec_list_offsetof(type, field, node)))
221
222#ifdef __cplusplus
223struct exec_node;
224
225class iterator {
226public:
227 void next()
228 {
229 }
230
231 void *get()
232 {
233 return NULL;
234 }
235
236 bool has_next() const
237 {
238 return false;
239 }
240};
241
242class exec_list_iterator : public iterator {
243public:
244 exec_list_iterator(exec_node *n) : node(n), _next(n->next)
245 {
246 /* empty */
247 }
248
249 void next()
250 {
251 node = _next;
252 _next = node->next;
253 }
254
255 void remove()
256 {
257 node->remove();
258 }
259
260 exec_node *get()
261 {
262 return node;
263 }
264
265 bool has_next() const
266 {
267 return _next != NULL;
268 }
269
270private:
271 exec_node *node;
272 exec_node *_next;
273};
274
275#define foreach_iter(iter_type, iter, container) \
276 for (iter_type iter = (container) . iterator(); iter.has_next(); iter.next())
277#endif
278
279
280struct exec_list {
281 struct exec_node *head;
282 struct exec_node *tail;
283 struct exec_node *tail_pred;
284
285#ifdef __cplusplus
286 /* Callers of this talloc-based new need not call delete. It's
287 * easier to just talloc_free 'ctx' (or any of its ancestors). */
288 static void* operator new(size_t size, void *ctx)
289 {
290 void *node;
291
292 node = talloc_size(ctx, size);
293 assert(node != NULL);
294
295 return node;
296 }
297
298 /* If the user *does* call delete, that's OK, we will just
299 * talloc_free in that case. */
300 static void operator delete(void *node)
301 {
302 talloc_free(node);
303 }
304
305 exec_list()
306 {
307 make_empty();
308 }
309
310 void make_empty()
311 {
312 head = (exec_node *) & tail;
313 tail = NULL;
314 tail_pred = (exec_node *) & head;
315 }
316
317 bool is_empty() const
318 {
319 /* There are three ways to test whether a list is empty or not.
320 *
321 * - Check to see if the \c head points to the \c tail.
322 * - Check to see if the \c tail_pred points to the \c head.
323 * - Check to see if the \c head is the sentinel node by test whether its
324 * \c next pointer is \c NULL.
325 *
326 * The first two methods tend to generate better code on modern systems
327 * because they save a pointer dereference.
328 */
329 return head == (exec_node *) &tail;
330 }
331
332 const exec_node *get_head() const
333 {
334 return !is_empty() ? head : NULL;
335 }
336
337 exec_node *get_head()
338 {
339 return !is_empty() ? head : NULL;
340 }
341
342 const exec_node *get_tail() const
343 {
344 return !is_empty() ? tail_pred : NULL;
345 }
346
347 exec_node *get_tail()
348 {
349 return !is_empty() ? tail_pred : NULL;
350 }
351
352 void push_head(exec_node *n)
353 {
354 n->next = head;
355 n->prev = (exec_node *) &head;
356
357 n->next->prev = n;
358 head = n;
359 }
360
361 void push_tail(exec_node *n)
362 {
363 n->next = (exec_node *) &tail;
364 n->prev = tail_pred;
365
366 n->prev->next = n;
367 tail_pred = n;
368 }
369
370 void push_degenerate_list_at_head(exec_node *n)
371 {
372 assert(n->prev->next == n);
373
374 n->prev->next = head;
375 head->prev = n->prev;
376 n->prev = (exec_node *) &head;
377 head = n;
378 }
379
380 /**
381 * Move all of the nodes from this list to the target list
382 */
383 void move_nodes_to(exec_list *target)
384 {
385 if (is_empty()) {
386 target->make_empty();
387 } else {
388 target->head = head;
389 target->tail = NULL;
390 target->tail_pred = tail_pred;
391
392 target->head->prev = (exec_node *) &target->head;
393 target->tail_pred->next = (exec_node *) &target->tail;
394
395 make_empty();
396 }
397 }
398
399 /**
400 * Append all nodes from the source list to the target list
401 */
402 void
403 append_list(exec_list *source)
404 {
405 if (source->is_empty())
406 return;
407
408 /* Link the first node of the source with the last node of the target list.
409 */
410 this->tail_pred->next = source->head;
411 source->head->prev = this->tail_pred;
412
413 /* Make the tail of the source list be the tail of the target list.
414 */
415 this->tail_pred = source->tail_pred;
416 this->tail_pred->next = (exec_node *) &this->tail;
417
418 /* Make the source list empty for good measure.
419 */
420 source->make_empty();
421 }
422
423 exec_list_iterator iterator()
424 {
425 return exec_list_iterator(head);
426 }
427
428 exec_list_iterator iterator() const
429 {
430 return exec_list_iterator((exec_node *) head);
431 }
432#endif
433};
434
435/**
436 * This version is safe even if the current node is removed.
437 */
438#define foreach_list_safe(__node, __list) \
439 for (exec_node * __node = (__list)->head, * __next = __node->next \
440 ; __next != NULL \
441 ; __node = __next, __next = __next->next)
442
443#define foreach_list(__node, __list) \
444 for (exec_node * __node = (__list)->head \
445 ; (__node)->next != NULL \
446 ; (__node) = (__node)->next)
447
448#define foreach_list_const(__node, __list) \
449 for (const exec_node * __node = (__list)->head \
450 ; (__node)->next != NULL \
451 ; (__node) = (__node)->next)
452
453#define foreach_list_typed(__type, __node, __field, __list) \
454 for (__type * __node = \
455 exec_node_data(__type, (__list)->head, __field); \
456 (__node)->__field.next != NULL; \
457 (__node) = exec_node_data(__type, (__node)->__field.next, __field))
458
459#define foreach_list_typed_const(__type, __node, __field, __list) \
460 for (const __type * __node = \
461 exec_node_data(__type, (__list)->head, __field); \
462 (__node)->__field.next != NULL; \
463 (__node) = exec_node_data(__type, (__node)->__field.next, __field))
464
465#endif /* LIST_CONTAINER_H */
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
new file mode 100644
index 00000000000..24d6076d07b
--- /dev/null
+++ b/src/glsl/main.cpp
@@ -0,0 +1,283 @@
1/*
2 * Copyright © 2008, 2009 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23#include <cstdlib>
24#include <cstdio>
25#include <getopt.h>
26
27#include <sys/types.h>
28#include <sys/stat.h>
29#include <fcntl.h>
30#include <unistd.h>
31
32#include "ast.h"
33#include "glsl_parser_extras.h"
34#include "glsl_parser.h"
35#include "ir_optimization.h"
36#include "ir_print_visitor.h"
37#include "program.h"
38
39extern "C" struct gl_shader *
40_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
41
42/* Copied from shader_api.c for the stand-alone compiler.
43 */
44struct gl_shader *
45_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type)
46{
47 struct gl_shader *shader;
48
49 (void) ctx;
50
51 assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
52 shader = talloc_zero(NULL, struct gl_shader);
53 if (shader) {
54 shader->Type = type;
55 shader->Name = name;
56 shader->RefCount = 1;
57 }
58 return shader;
59}
60
61/* Returned string will have 'ctx' as its talloc owner. */
62static char *
63load_text_file(void *ctx, const char *file_name)
64{
65 char *text = NULL;
66 struct stat st;
67 ssize_t total_read = 0;
68 int fd = open(file_name, O_RDONLY);
69
70 if (fd < 0) {
71 return NULL;
72 }
73
74 if (fstat(fd, & st) == 0) {
75 text = (char *) talloc_size(ctx, st.st_size + 1);
76 if (text != NULL) {
77 do {
78 ssize_t bytes = read(fd, text + total_read,
79 st.st_size - total_read);
80 if (bytes < 0) {
81 free(text);
82 text = NULL;
83 break;
84 }
85
86 if (bytes == 0) {
87 break;
88 }
89
90 total_read += bytes;
91 } while (total_read < st.st_size);
92
93 text[total_read] = '\0';
94 }
95 }
96
97 close(fd);
98
99 return text;
100}
101
102
103void
104usage_fail(const char *name)
105{
106 printf("%s <filename.frag|filename.vert>\n", name);
107 exit(EXIT_FAILURE);
108}
109
110
111int dump_ast = 0;
112int dump_hir = 0;
113int dump_lir = 0;
114int do_link = 0;
115
116const struct option compiler_opts[] = {
117 { "dump-ast", 0, &dump_ast, 1 },
118 { "dump-hir", 0, &dump_hir, 1 },
119 { "dump-lir", 0, &dump_lir, 1 },
120 { "link", 0, &do_link, 1 },
121 { NULL, 0, NULL, 0 }
122};
123
124void
125compile_shader(struct gl_shader *shader)
126{
127 struct _mesa_glsl_parse_state *state =
128 new(shader) _mesa_glsl_parse_state(NULL, shader->Type, shader);
129
130 const char *source = shader->Source;
131 state->error = preprocess(state, &source, &state->info_log,
132 state->extensions);
133
134 if (!state->error) {
135 _mesa_glsl_lexer_ctor(state, source);
136 _mesa_glsl_parse(state);
137 _mesa_glsl_lexer_dtor(state);
138 }
139
140 if (dump_ast) {
141 foreach_list_const(n, &state->translation_unit) {
142 ast_node *ast = exec_node_data(ast_node, n, link);
143 ast->print();
144 }
145 printf("\n\n");
146 }
147
148 shader->ir = new(shader) exec_list;
149 if (!state->error && !state->translation_unit.is_empty())
150 _mesa_ast_to_hir(shader->ir, state);
151
152 /* Print out the unoptimized IR. */
153 if (!state->error && dump_hir) {
154 validate_ir_tree(shader->ir);
155 _mesa_print_ir(shader->ir, state);
156 }
157
158 /* Optimization passes */
159 if (!state->error && !shader->ir->is_empty()) {
160 bool progress;
161 do {
162 progress = false;
163
164 progress = do_function_inlining(shader->ir) || progress;
165 progress = do_if_simplification(shader->ir) || progress;
166 progress = do_copy_propagation(shader->ir) || progress;
167 progress = do_dead_code_local(shader->ir) || progress;
168 progress = do_dead_code_unlinked(shader->ir) || progress;
169 progress = do_tree_grafting(shader->ir) || progress;
170 progress = do_constant_propagation(shader->ir) || progress;
171 progress = do_constant_variable_unlinked(shader->ir) || progress;
172 progress = do_constant_folding(shader->ir) || progress;
173 progress = do_algebraic(shader->ir) || progress;
174 progress = do_vec_index_to_swizzle(shader->ir) || progress;
175 progress = do_vec_index_to_cond_assign(shader->ir) || progress;
176 progress = do_swizzle_swizzle(shader->ir) || progress;
177 } while (progress);
178
179 validate_ir_tree(shader->ir);
180 }
181
182
183 /* Print out the resulting IR */
184 if (!state->error && dump_lir) {
185 _mesa_print_ir(shader->ir, state);
186 }
187
188 shader->symbols = state->symbols;
189 shader->CompileStatus = !state->error;
190 shader->Version = state->language_version;
191 memcpy(shader->builtins_to_link, state->builtins_to_link,
192 sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link);
193 shader->num_builtins_to_link = state->num_builtins_to_link;
194
195 if (shader->InfoLog)
196 talloc_free(shader->InfoLog);
197
198 shader->InfoLog = state->info_log;
199
200 /* Retain any live IR, but trash the rest. */
201 reparent_ir(shader->ir, shader);
202
203 talloc_free(state);
204
205 return;
206}
207
208int
209main(int argc, char **argv)
210{
211 int status = EXIT_SUCCESS;
212
213 int c;
214 int idx = 0;
215 while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1)
216 /* empty */ ;
217
218
219 if (argc <= optind)
220 usage_fail(argv[0]);
221
222 struct gl_shader_program *whole_program;
223
224 whole_program = talloc_zero (NULL, struct gl_shader_program);
225 assert(whole_program != NULL);
226
227 for (/* empty */; argc > optind; optind++) {
228 whole_program->Shaders = (struct gl_shader **)
229 talloc_realloc(whole_program, whole_program->Shaders,
230 struct gl_shader *, whole_program->NumShaders + 1);
231 assert(whole_program->Shaders != NULL);
232
233 struct gl_shader *shader = talloc_zero(whole_program, gl_shader);
234
235 whole_program->Shaders[whole_program->NumShaders] = shader;
236 whole_program->NumShaders++;
237
238 const unsigned len = strlen(argv[optind]);
239 if (len < 6)
240 usage_fail(argv[0]);
241
242 const char *const ext = & argv[optind][len - 5];
243 if (strncmp(".vert", ext, 5) == 0)
244 shader->Type = GL_VERTEX_SHADER;
245 else if (strncmp(".geom", ext, 5) == 0)
246 shader->Type = GL_GEOMETRY_SHADER;
247 else if (strncmp(".frag", ext, 5) == 0)
248 shader->Type = GL_FRAGMENT_SHADER;
249 else
250 usage_fail(argv[0]);
251
252 shader->Source = load_text_file(whole_program, argv[optind]);
253 if (shader->Source == NULL) {
254 printf("File \"%s\" does not exist.\n", argv[optind]);
255 exit(EXIT_FAILURE);
256 }
257
258 compile_shader(shader);
259
260 if (!shader->CompileStatus) {
261 printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog);
262 status = EXIT_FAILURE;
263 break;
264 }
265 }
266
267 if ((status == EXIT_SUCCESS) && do_link) {
268 link_shaders(whole_program);
269 status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
270
271 if (strlen(whole_program->InfoLog) > 0)
272 printf("Info log for linking:\n%s\n", whole_program->InfoLog);
273 }
274
275 for (unsigned i = 0; i < whole_program->_NumLinkedShaders; i++)
276 talloc_free(whole_program->_LinkedShaders[i]);
277
278 talloc_free(whole_program);
279 _mesa_glsl_release_types();
280 _mesa_glsl_release_functions();
281
282 return status;
283}
diff --git a/src/glsl/program.h b/src/glsl/program.h
new file mode 100644
index 00000000000..0a49203d4b2
--- /dev/null
+++ b/src/glsl/program.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
3 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
4 * Copyright © 2010 Intel Corporation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#include <GL/gl.h>
25#include "main/mtypes.h"
26
27extern "C" {
28#include "program/prog_parameter.h"
29#include "program/prog_uniform.h"
30}
31
32extern void
33link_shaders(struct gl_shader_program *prog);
diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp
new file mode 100644
index 00000000000..26be23ea8fa
--- /dev/null
+++ b/src/glsl/s_expression.cpp
@@ -0,0 +1,131 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include <cstdio>
26#include <cstdlib>
27#include <cstring>
28#include <assert.h>
29#include "s_expression.h"
30
31s_symbol::s_symbol(const char *tmp)
32{
33 this->str = talloc_strdup (this, tmp);
34 assert(this->str != NULL);
35}
36
37s_list::s_list()
38{
39}
40
41unsigned
42s_list::length() const
43{
44 unsigned i = 0;
45 foreach_iter(exec_list_iterator, it, this->subexpressions) {
46 i++;
47 }
48 return i;
49}
50
51static s_expression *
52read_atom(void *ctx, const char *& src)
53{
54 char buf[101];
55 int n;
56 if (sscanf(src, " %100[^( \v\t\r\n)]%n", buf, &n) != 1)
57 return NULL; // no atom
58 src += n;
59
60 // Check if the atom is a number.
61 char *float_end = NULL;
62 double f = strtod(buf, &float_end);
63 if (float_end != buf) {
64 char *int_end = NULL;
65 int i = strtol(buf, &int_end, 10);
66 // If strtod matched more characters, it must have a decimal part
67 if (float_end > int_end)
68 return new(ctx) s_float(f);
69
70 return new(ctx) s_int(i);
71 }
72 // Not a number; return a symbol.
73 return new(ctx) s_symbol(buf);
74}
75
76s_expression *
77s_expression::read_expression(void *ctx, const char *&src)
78{
79 assert(src != NULL);
80
81 s_expression *atom = read_atom(ctx, src);
82 if (atom != NULL)
83 return atom;
84
85 char c;
86 int n;
87 if (sscanf(src, " %c%n", &c, &n) == 1 && c == '(') {
88 src += n;
89
90 s_list *list = new(ctx) s_list;
91 s_expression *expr;
92
93 while ((expr = read_expression(ctx, src)) != NULL) {
94 list->subexpressions.push_tail(expr);
95 }
96 if (sscanf(src, " %c%n", &c, &n) != 1 || c != ')') {
97 printf("Unclosed expression (check your parenthesis).\n");
98 return NULL;
99 }
100 src += n;
101 return list;
102 }
103 return NULL;
104}
105
106void s_int::print()
107{
108 printf("%d", this->val);
109}
110
111void s_float::print()
112{
113 printf("%f", this->val);
114}
115
116void s_symbol::print()
117{
118 printf("%s", this->str);
119}
120
121void s_list::print()
122{
123 printf("(");
124 foreach_iter(exec_list_iterator, it, this->subexpressions) {
125 s_expression *expr = (s_expression*) it.get();
126 expr->print();
127 printf(" ");
128 }
129 printf(")");
130}
131
diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h
new file mode 100644
index 00000000000..1a0c03c2189
--- /dev/null
+++ b/src/glsl/s_expression.h
@@ -0,0 +1,142 @@
1/* -*- c++ -*- */
2/*
3 * Copyright © 2010 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#pragma once
26#ifndef S_EXPRESSION_H
27#define S_EXPRESSION_H
28
29#include "list.h"
30
31#define SX_AS_(t,x) ((x) && ((s_expression*) x)->is_##t()) ? ((s_##t*) (x)) \
32 : NULL
33#define SX_AS_LIST(x) SX_AS_(list, x)
34#define SX_AS_SYMBOL(x) SX_AS_(symbol, x)
35#define SX_AS_NUMBER(x) SX_AS_(number, x)
36#define SX_AS_INT(x) SX_AS_(int, x)
37
38/* For our purposes, S-Expressions are:
39 * - <int>
40 * - <float>
41 * - symbol
42 * - (expr1 expr2 ... exprN) where exprN is an S-Expression
43 *
44 * Unlike LISP/Scheme, we do not support (foo . bar) pairs.
45 */
46class s_expression : public exec_node
47{
48public:
49 /**
50 * Read an S-Expression from the given string.
51 * Advances the supplied pointer to just after the expression read.
52 *
53 * Any allocation will be performed with 'ctx' as the talloc owner.
54 */
55 static s_expression *read_expression(void *ctx, const char *&src);
56
57 /**
58 * Print out an S-Expression. Useful for debugging.
59 */
60 virtual void print() = 0;
61
62 virtual bool is_list() const { return false; }
63 virtual bool is_symbol() const { return false; }
64 virtual bool is_number() const { return false; }
65 virtual bool is_int() const { return false; }
66
67protected:
68 s_expression() { }
69};
70
71/* Atoms */
72
73class s_number : public s_expression
74{
75public:
76 bool is_number() const { return true; }
77
78 virtual float fvalue() = 0;
79
80protected:
81 s_number() { }
82};
83
84class s_int : public s_number
85{
86public:
87 s_int(int x) : val(x) { }
88
89 bool is_int() const { return true; }
90
91 float fvalue() { return float(this->val); }
92 int value() { return this->val; }
93
94 void print();
95
96private:
97 int val;
98};
99
100class s_float : public s_number
101{
102public:
103 s_float(float x) : val(x) { }
104
105 float fvalue() { return this->val; }
106
107 void print();
108
109private:
110 float val;
111};
112
113class s_symbol : public s_expression
114{
115public:
116 s_symbol(const char *);
117
118 bool is_symbol() const { return true; }
119
120 const char *value() { return this->str; }
121
122 void print();
123
124private:
125 char *str;
126};
127
128/* Lists of expressions: (expr1 ... exprN) */
129class s_list : public s_expression
130{
131public:
132 s_list();
133
134 virtual bool is_list() const { return true; }
135 unsigned length() const;
136
137 void print();
138
139 exec_list subexpressions;
140};
141
142#endif /* S_EXPRESSION_H */
diff --git a/src/glsl/tests/array-01.glsl b/src/glsl/tests/array-01.glsl
new file mode 100644
index 00000000000..d14135fb3a8
--- /dev/null
+++ b/src/glsl/tests/array-01.glsl
@@ -0,0 +1,3 @@
1#version 120
2/* FAIL - array size type must be int */
3uniform vec4 [3.2] a;
diff --git a/src/glsl/tests/array-02.glsl b/src/glsl/tests/array-02.glsl
new file mode 100644
index 00000000000..d743617158d
--- /dev/null
+++ b/src/glsl/tests/array-02.glsl
@@ -0,0 +1,3 @@
1#version 120
2/* FAIL - array size type must be scalar */
3uniform vec4 [ivec4(3)] a;
diff --git a/src/glsl/tests/array-03.glsl b/src/glsl/tests/array-03.glsl
new file mode 100644
index 00000000000..0026913f019
--- /dev/null
+++ b/src/glsl/tests/array-03.glsl
@@ -0,0 +1,3 @@
1#version 120
2/* PASS */
3uniform vec4 [3] a;
diff --git a/src/glsl/tests/array-04.glsl b/src/glsl/tests/array-04.glsl
new file mode 100644
index 00000000000..70f434d8ab6
--- /dev/null
+++ b/src/glsl/tests/array-04.glsl
@@ -0,0 +1,2 @@
1/* FAIL - array size type must be int */
2uniform vec4 a[3.2];
diff --git a/src/glsl/tests/array-05.glsl b/src/glsl/tests/array-05.glsl
new file mode 100644
index 00000000000..168704096b0
--- /dev/null
+++ b/src/glsl/tests/array-05.glsl
@@ -0,0 +1,2 @@
1/* FAIL - array size type must be scalar */
2uniform vec4 a[ivec4(3)];
diff --git a/src/glsl/tests/array-06.glsl b/src/glsl/tests/array-06.glsl
new file mode 100644
index 00000000000..46b43795be1
--- /dev/null
+++ b/src/glsl/tests/array-06.glsl
@@ -0,0 +1,2 @@
1/* PASS */
2uniform vec4 a[3];
diff --git a/src/glsl/tests/array-07.glsl b/src/glsl/tests/array-07.glsl
new file mode 100644
index 00000000000..161ffbf2f2e
--- /dev/null
+++ b/src/glsl/tests/array-07.glsl
@@ -0,0 +1,2 @@
1/* FAIL - array size must be > 0 */
2uniform vec4 a[0];
diff --git a/src/glsl/tests/array-08.glsl b/src/glsl/tests/array-08.glsl
new file mode 100644
index 00000000000..4bf0c6bd513
--- /dev/null
+++ b/src/glsl/tests/array-08.glsl
@@ -0,0 +1,2 @@
1/* FAIL - array size must be > 0 */
2uniform vec4 a[-1];
diff --git a/src/glsl/tests/array-09.glsl b/src/glsl/tests/array-09.glsl
new file mode 100644
index 00000000000..cad6d0e54ec
--- /dev/null
+++ b/src/glsl/tests/array-09.glsl
@@ -0,0 +1,9 @@
1#version 120
2/* PASS */
3
4void main()
5{
6 vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0));
7
8 gl_Position = gl_Vertex;
9}
diff --git a/src/glsl/tests/array-10.glsl b/src/glsl/tests/array-10.glsl
new file mode 100644
index 00000000000..019aa21150f
--- /dev/null
+++ b/src/glsl/tests/array-10.glsl
@@ -0,0 +1,11 @@
1/* FAIL - array constructors forbidden in GLSL 1.10
2 *
3 * This can also generate an error because the 'vec4[]' style syntax is
4 * illegal in GLSL 1.10.
5 */
6void main()
7{
8 vec4 a[2] = vec4 [2] (vec4(1.0), vec4(2.0));
9
10 gl_Position = gl_Vertex;
11}
diff --git a/src/glsl/tests/array-11.glsl b/src/glsl/tests/array-11.glsl
new file mode 100644
index 00000000000..51d94e94773
--- /dev/null
+++ b/src/glsl/tests/array-11.glsl
@@ -0,0 +1,9 @@
1#version 120
2/* PASS */
3
4void main()
5{
6 vec4 a[] = vec4 [] (vec4(1.0), vec4(2.0));
7
8 gl_Position = gl_Vertex;
9}
diff --git a/src/glsl/tests/array-12.glsl b/src/glsl/tests/array-12.glsl
new file mode 100644
index 00000000000..7fc9579452f
--- /dev/null
+++ b/src/glsl/tests/array-12.glsl
@@ -0,0 +1,11 @@
1#version 120
2/* FAIL - array must have an implicit or explicit size */
3
4void main()
5{
6 vec4 a[];
7
8 a = vec4 [2] (vec4(1.0), vec4(2.0));
9
10 gl_Position = gl_Vertex;
11}
diff --git a/src/glsl/tests/array-13.glsl b/src/glsl/tests/array-13.glsl
new file mode 100644
index 00000000000..cc7e29a5f76
--- /dev/null
+++ b/src/glsl/tests/array-13.glsl
@@ -0,0 +1,11 @@
1#version 120
2/* PASS */
3
4void main()
5{
6 vec4 a[2];
7
8 a = vec4 [] (vec4(1.0), vec4(2.0));
9
10 gl_Position = gl_Vertex;
11}
diff --git a/src/glsl/tests/attribute-01.glsl b/src/glsl/tests/attribute-01.glsl
new file mode 100644
index 00000000000..18e9e4468aa
--- /dev/null
+++ b/src/glsl/tests/attribute-01.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type int */
2attribute int i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-02.glsl b/src/glsl/tests/attribute-02.glsl
new file mode 100644
index 00000000000..6b6df74d252
--- /dev/null
+++ b/src/glsl/tests/attribute-02.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type ivec2 */
2attribute ivec2 i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-03.glsl b/src/glsl/tests/attribute-03.glsl
new file mode 100644
index 00000000000..870de9e8148
--- /dev/null
+++ b/src/glsl/tests/attribute-03.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type ivec3 */
2attribute ivec3 i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-04.glsl b/src/glsl/tests/attribute-04.glsl
new file mode 100644
index 00000000000..14af2fcaadd
--- /dev/null
+++ b/src/glsl/tests/attribute-04.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type ivec4 */
2attribute ivec4 i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-05.glsl b/src/glsl/tests/attribute-05.glsl
new file mode 100644
index 00000000000..18822c78541
--- /dev/null
+++ b/src/glsl/tests/attribute-05.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type bool */
2attribute bool i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-06.glsl b/src/glsl/tests/attribute-06.glsl
new file mode 100644
index 00000000000..f18027b81af
--- /dev/null
+++ b/src/glsl/tests/attribute-06.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type bvec2 */
2attribute bvec2 i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-07.glsl b/src/glsl/tests/attribute-07.glsl
new file mode 100644
index 00000000000..0af13ba84bf
--- /dev/null
+++ b/src/glsl/tests/attribute-07.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type bvec3 */
2attribute bvec3 i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-08.glsl b/src/glsl/tests/attribute-08.glsl
new file mode 100644
index 00000000000..b069c04d1b4
--- /dev/null
+++ b/src/glsl/tests/attribute-08.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have type bvec4 */
2attribute bvec4 i;
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-09.glsl b/src/glsl/tests/attribute-09.glsl
new file mode 100644
index 00000000000..6a607244b9a
--- /dev/null
+++ b/src/glsl/tests/attribute-09.glsl
@@ -0,0 +1,7 @@
1/* FAIL - attribute cannot have array type in GLSL 1.10 */
2attribute vec4 i[10];
3
4void main()
5{
6 gl_Position = vec4(1.0);
7}
diff --git a/src/glsl/tests/attribute-10.glsl b/src/glsl/tests/attribute-10.glsl
new file mode 100644
index 00000000000..6f5ef63a015
--- /dev/null
+++ b/src/glsl/tests/attribute-10.glsl
@@ -0,0 +1,8 @@
1#version 120
2/* FAIL - attribute cannot have array type in GLSL 1.20 */
3attribute vec4 i[10];
4
5void main()
6{
7 gl_Position = vec4(1.0);
8}
diff --git a/src/glsl/tests/attribute-11.glsl b/src/glsl/tests/attribute-11.glsl
new file mode 100644
index 00000000000..47cb5a05833
--- /dev/null
+++ b/src/glsl/tests/attribute-11.glsl
@@ -0,0 +1,8 @@
1#version 130
2/* FAIL - attribute cannot have array type in GLSL 1.30 */
3attribute vec4 i[10];
4
5void main()
6{
7 gl_Position = vec4(1.0);
8}
diff --git a/src/glsl/tests/condition-01.glsl b/src/glsl/tests/condition-01.glsl
new file mode 100644
index 00000000000..d89c313117e
--- /dev/null
+++ b/src/glsl/tests/condition-01.glsl
@@ -0,0 +1,8 @@
1/* FAIL - :? condition is not bool scalar */
2
3uniform bvec4 a;
4
5void main()
6{
7 gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0);
8}
diff --git a/src/glsl/tests/condition-02.glsl b/src/glsl/tests/condition-02.glsl
new file mode 100644
index 00000000000..cbd0e18d9a8
--- /dev/null
+++ b/src/glsl/tests/condition-02.glsl
@@ -0,0 +1,8 @@
1/* FAIL - :? condition is not bool scalar */
2
3uniform float a;
4
5void main()
6{
7 gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0);
8}
diff --git a/src/glsl/tests/condition-03.glsl b/src/glsl/tests/condition-03.glsl
new file mode 100644
index 00000000000..9af5d7aa470
--- /dev/null
+++ b/src/glsl/tests/condition-03.glsl
@@ -0,0 +1,8 @@
1/* PASS */
2
3uniform bool a;
4
5void main()
6{
7 gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0);
8}
diff --git a/src/glsl/tests/condition-04.glsl b/src/glsl/tests/condition-04.glsl
new file mode 100644
index 00000000000..f440b7e9955
--- /dev/null
+++ b/src/glsl/tests/condition-04.glsl
@@ -0,0 +1,8 @@
1/* FAIL - type of second two operands must match */
2
3uniform bool a;
4
5void main()
6{
7 gl_Position = (a) ? vec4(1.0, 0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);
8}
diff --git a/src/glsl/tests/condition-05.glsl b/src/glsl/tests/condition-05.glsl
new file mode 100644
index 00000000000..3dff18f519d
--- /dev/null
+++ b/src/glsl/tests/condition-05.glsl
@@ -0,0 +1,13 @@
1#version 120
2/* PASS */
3
4uniform bool a;
5uniform int b;
6
7void main()
8{
9 float x;
10
11 x = (a) ? 2.0 : b;
12 gl_Position = vec4(x);
13}
diff --git a/src/glsl/tests/constructor-01.glsl b/src/glsl/tests/constructor-01.glsl
new file mode 100644
index 00000000000..fdfaf898663
--- /dev/null
+++ b/src/glsl/tests/constructor-01.glsl
@@ -0,0 +1,6 @@
1/* PASS */
2
3void main()
4{
5 gl_Position = vec4(1.0, 1.0, 1.0, 0.0);;
6}
diff --git a/src/glsl/tests/constructor-02.glsl b/src/glsl/tests/constructor-02.glsl
new file mode 100644
index 00000000000..47acbe9db14
--- /dev/null
+++ b/src/glsl/tests/constructor-02.glsl
@@ -0,0 +1,7 @@
1/* FAIL - cannot construct samplers */
2void main()
3{
4 int i;
5
6 i = sampler2D(0);
7}
diff --git a/src/glsl/tests/constructor-03.glsl b/src/glsl/tests/constructor-03.glsl
new file mode 100644
index 00000000000..07ec225633a
--- /dev/null
+++ b/src/glsl/tests/constructor-03.glsl
@@ -0,0 +1,12 @@
1/* FAIL - cannot construct a matrix from a matrix in GLSL 1.10 */
2
3uniform mat2 a;
4
5void main()
6{
7 mat2 b;
8
9 b = mat2(a);
10
11 gl_Position = gl_Vertex;
12}
diff --git a/src/glsl/tests/constructor-04.glsl b/src/glsl/tests/constructor-04.glsl
new file mode 100644
index 00000000000..19d5e011dea
--- /dev/null
+++ b/src/glsl/tests/constructor-04.glsl
@@ -0,0 +1,14 @@
1#version 120
2/* FAIL - matrix must be only parameter to matrix constructor */
3
4uniform mat2 a;
5uniform float x;
6
7void main()
8{
9 mat2 b;
10
11 b = mat2(a, x);
12
13 gl_Position = gl_Vertex;
14}
diff --git a/src/glsl/tests/constructor-05.glsl b/src/glsl/tests/constructor-05.glsl
new file mode 100644
index 00000000000..9c74f75a404
--- /dev/null
+++ b/src/glsl/tests/constructor-05.glsl
@@ -0,0 +1,13 @@
1/* FAIL - too few components supplied to constructor */
2
3uniform vec2 a;
4uniform float x;
5
6void main()
7{
8 mat2 b;
9
10 b = mat2(a, x);
11
12 gl_Position = gl_Vertex;
13}
diff --git a/src/glsl/tests/constructor-06.glsl b/src/glsl/tests/constructor-06.glsl
new file mode 100644
index 00000000000..d77a5f9e892
--- /dev/null
+++ b/src/glsl/tests/constructor-06.glsl
@@ -0,0 +1,13 @@
1#version 120
2/* PASS */
3
4uniform mat2 a;
5
6void main()
7{
8 mat2 b;
9
10 b = mat2(a);
11
12 gl_Position = gl_Vertex;
13}
diff --git a/src/glsl/tests/constructor-07.glsl b/src/glsl/tests/constructor-07.glsl
new file mode 100644
index 00000000000..92322506ed1
--- /dev/null
+++ b/src/glsl/tests/constructor-07.glsl
@@ -0,0 +1,13 @@
1/* PASS */
2
3uniform ivec2 a;
4uniform ivec2 b;
5
6void main()
7{
8 mat2 c;
9
10 c = mat2(a, b);
11
12 gl_Position = gl_Vertex;
13}
diff --git a/src/glsl/tests/constructor-08.glsl b/src/glsl/tests/constructor-08.glsl
new file mode 100644
index 00000000000..27153f0cda1
--- /dev/null
+++ b/src/glsl/tests/constructor-08.glsl
@@ -0,0 +1,13 @@
1/* PASS */
2
3uniform float a;
4uniform float b;
5
6void main()
7{
8 ivec2 c;
9
10 c = ivec2(a, b);
11
12 gl_Position = gl_Vertex;
13}
diff --git a/src/glsl/tests/constructor-09.glsl b/src/glsl/tests/constructor-09.glsl
new file mode 100644
index 00000000000..1985699b305
--- /dev/null
+++ b/src/glsl/tests/constructor-09.glsl
@@ -0,0 +1,26 @@
1/* PASS */
2
3uniform int a;
4uniform float b;
5uniform bool c;
6
7void main()
8{
9 float x;
10 int y;
11 bool z;
12
13 x = float(a);
14 x = float(b);
15 x = float(c);
16
17 y = int(a);
18 y = int(b);
19 y = int(c);
20
21 z = bool(a);
22 z = bool(b);
23 z = bool(c);
24
25 gl_Position = gl_Vertex;
26}
diff --git a/src/glsl/tests/function-01.glsl b/src/glsl/tests/function-01.glsl
new file mode 100644
index 00000000000..0eaa2397ab6
--- /dev/null
+++ b/src/glsl/tests/function-01.glsl
@@ -0,0 +1,16 @@
1/* FAIL - no function named 'foo' exists */
2
3vec4 bar(float x, float y, float z, float w)
4{
5 vec4 v;
6 v.x = x;
7 v.y = y;
8 v.z = z;
9 v.w = w;
10 return v;
11}
12
13void main()
14{
15 gl_Position = foo(1.0, 1.0, 1.0, 0.0);
16}
diff --git a/src/glsl/tests/function-02.glsl b/src/glsl/tests/function-02.glsl
new file mode 100644
index 00000000000..941fcc1ef7b
--- /dev/null
+++ b/src/glsl/tests/function-02.glsl
@@ -0,0 +1,16 @@
1/* FAIL - no version of 'foo' matches the call to 'foo' */
2
3vec4 foo(float x, float y, float z, float w)
4{
5 vec4 v;
6 v.x = x;
7 v.y = y;
8 v.z = z;
9 v.w = w;
10 return v;
11}
12
13void main()
14{
15 gl_Position = foo(1.0, 1.0, 1.0);
16}
diff --git a/src/glsl/tests/function-03.glsl b/src/glsl/tests/function-03.glsl
new file mode 100644
index 00000000000..b0da42f8e96
--- /dev/null
+++ b/src/glsl/tests/function-03.glsl
@@ -0,0 +1,16 @@
1/* PASS */
2
3vec4 foo(in float x, in float y, float z, float w)
4{
5 vec4 v;
6 v.x = x;
7 v.y = y;
8 v.z = z;
9 v.w = w;
10 return v;
11}
12
13void main()
14{
15 gl_Position = foo(1.0, 1.0, 1.0, 0.0);
16}
diff --git a/src/glsl/tests/function-04.glsl b/src/glsl/tests/function-04.glsl
new file mode 100644
index 00000000000..dfc0d2b7a6c
--- /dev/null
+++ b/src/glsl/tests/function-04.glsl
@@ -0,0 +1,15 @@
1/* FAIL - type mismatch in assignment */
2
3vec3 foo(float x, float y, float z)
4{
5 vec3 v;
6 v.x = x;
7 v.y = y;
8 v.z = z;
9 return v;
10}
11
12void main()
13{
14 gl_Position = foo(1.0, 1.0, 1.0);
15}
diff --git a/src/glsl/tests/function-05.glsl b/src/glsl/tests/function-05.glsl
new file mode 100644
index 00000000000..43365bf6062
--- /dev/null
+++ b/src/glsl/tests/function-05.glsl
@@ -0,0 +1,26 @@
1/* PASS */
2
3vec4 foo(in float x, in float y, float z, float w)
4{
5 vec4 v;
6 v.x = x;
7 v.y = y;
8 v.z = z;
9 v.w = w;
10 return v;
11}
12
13vec4 foo(in float x)
14{
15 vec4 v;
16 v.x = x;
17 v.y = x;
18 v.z = x;
19 v.w = x;
20}
21
22void main()
23{
24 gl_Position = foo(1.0, 1.0, 1.0, 0.0);
25 gl_Position = foo(2.0);
26}
diff --git a/src/glsl/tests/if-01.glsl b/src/glsl/tests/if-01.glsl
new file mode 100644
index 00000000000..ca9abd54f75
--- /dev/null
+++ b/src/glsl/tests/if-01.glsl
@@ -0,0 +1,11 @@
1/* FAIL - if-statement condition is not bool scalar */
2
3uniform bvec4 a;
4
5void main()
6{
7 if (a)
8 gl_Position = vec4(1.0, 0.0, 0.0, 1.0);
9 else
10 gl_Position = vec4(0.0, 1.0, 0.0, 1.0);
11}
diff --git a/src/glsl/tests/if-02.glsl b/src/glsl/tests/if-02.glsl
new file mode 100644
index 00000000000..7adccea0432
--- /dev/null
+++ b/src/glsl/tests/if-02.glsl
@@ -0,0 +1,11 @@
1/* FAIL - if-statement condition is not bool scalar */
2
3uniform float a;
4
5void main()
6{
7 if (a)
8 gl_Position = vec4(1.0, 0.0, 0.0, 1.0);
9 else
10 gl_Position = vec4(0.0, 1.0, 0.0, 1.0);
11}
diff --git a/src/glsl/tests/if-03.glsl b/src/glsl/tests/if-03.glsl
new file mode 100644
index 00000000000..179618c716e
--- /dev/null
+++ b/src/glsl/tests/if-03.glsl
@@ -0,0 +1,11 @@
1/* PASS */
2
3uniform bool a;
4
5void main()
6{
7 if (a)
8 gl_Position = vec4(1.0, 0.0, 0.0, 1.0);
9 else
10 gl_Position = vec4(0.0, 1.0, 0.0, 1.0);
11}
diff --git a/src/glsl/tests/if-04.glsl b/src/glsl/tests/if-04.glsl
new file mode 100644
index 00000000000..7b711fb7edf
--- /dev/null
+++ b/src/glsl/tests/if-04.glsl
@@ -0,0 +1,11 @@
1/* PASS */
2
3uniform bvec4 a;
4
5void main()
6{
7 if (a.x)
8 gl_Position = vec4(1.0, 0.0, 0.0, 1.0);
9 else
10 gl_Position = vec4(0.0, 1.0, 0.0, 1.0);
11}
diff --git a/src/glsl/tests/matrix-01.glsl b/src/glsl/tests/matrix-01.glsl
new file mode 100644
index 00000000000..f46416c8f67
--- /dev/null
+++ b/src/glsl/tests/matrix-01.glsl
@@ -0,0 +1,6 @@
1/* FAIL - non-square matrices are not available in GLSL 1.10 */
2
3void main()
4{
5 mat2x3 m;
6}
diff --git a/src/glsl/tests/matrix-02.glsl b/src/glsl/tests/matrix-02.glsl
new file mode 100644
index 00000000000..0630722b795
--- /dev/null
+++ b/src/glsl/tests/matrix-02.glsl
@@ -0,0 +1,6 @@
1/* FAIL - non-square matrices are not available in GLSL 1.10 */
2
3void main()
4{
5 mat2x4 m;
6}
diff --git a/src/glsl/tests/matrix-03.glsl b/src/glsl/tests/matrix-03.glsl
new file mode 100644
index 00000000000..925dc806258
--- /dev/null
+++ b/src/glsl/tests/matrix-03.glsl
@@ -0,0 +1,6 @@
1/* FAIL - non-square matrices are not available in GLSL 1.10 */
2
3void main()
4{
5 mat3x2 m;
6}
diff --git a/src/glsl/tests/matrix-04.glsl b/src/glsl/tests/matrix-04.glsl
new file mode 100644
index 00000000000..5275619b319
--- /dev/null
+++ b/src/glsl/tests/matrix-04.glsl
@@ -0,0 +1,6 @@
1/* FAIL - non-square matrices are not available in GLSL 1.10 */
2
3void main()
4{
5 mat3x4 m;
6}
diff --git a/src/glsl/tests/matrix-05.glsl b/src/glsl/tests/matrix-05.glsl
new file mode 100644
index 00000000000..74e1fd25148
--- /dev/null
+++ b/src/glsl/tests/matrix-05.glsl
@@ -0,0 +1,6 @@
1/* FAIL - non-square matrices are not available in GLSL 1.10 */
2
3void main()
4{
5 mat4x2 m;
6}
diff --git a/src/glsl/tests/matrix-06.glsl b/src/glsl/tests/matrix-06.glsl
new file mode 100644
index 00000000000..0a512b85234
--- /dev/null
+++ b/src/glsl/tests/matrix-06.glsl
@@ -0,0 +1,6 @@
1/* FAIL - non-square matrices are not available in GLSL 1.10 */
2
3void main()
4{
5 mat4x3 m;
6}
diff --git a/src/glsl/tests/matrix-07.glsl b/src/glsl/tests/matrix-07.glsl
new file mode 100644
index 00000000000..0b59aa69d50
--- /dev/null
+++ b/src/glsl/tests/matrix-07.glsl
@@ -0,0 +1,27 @@
1/* PASS */
2
3uniform mat2 a;
4uniform mat2 b;
5uniform mat2 c;
6uniform mat2 d;
7uniform mat3 e;
8uniform mat3 f;
9uniform mat3 g;
10uniform mat3 h;
11uniform mat4 i;
12uniform mat4 j;
13uniform mat4 k;
14uniform mat4 l;
15
16void main()
17{
18 mat2 x;
19 mat3 y;
20 mat4 z;
21
22 x = a * b + c / d;
23 y = e * f + g / h;
24 z = i * j + k / l;
25
26 gl_Position = gl_Vertex;
27}
diff --git a/src/glsl/tests/matrix-08.glsl b/src/glsl/tests/matrix-08.glsl
new file mode 100644
index 00000000000..38138d22de4
--- /dev/null
+++ b/src/glsl/tests/matrix-08.glsl
@@ -0,0 +1,19 @@
1#version 120
2/* PASS */
3
4uniform mat2x3 a;
5uniform mat3x2 b;
6uniform mat3x3 c;
7uniform mat3x3 d;
8
9void main()
10{
11 mat3x3 x;
12
13 /* Multiplying a 2 column, 3 row matrix with a 3 column, 2 row matrix
14 * results in a 3 column, 3 row matrix.
15 */
16 x = (a * b) + c / d;
17
18 gl_Position = gl_Vertex;
19}
diff --git a/src/glsl/tests/matrix-09.glsl b/src/glsl/tests/matrix-09.glsl
new file mode 100644
index 00000000000..18afbcacea7
--- /dev/null
+++ b/src/glsl/tests/matrix-09.glsl
@@ -0,0 +1,11 @@
1/* FAIL - matrix-to-matrix constructors are not available in GLSL 1.10 */
2
3uniform mat3 a;
4
5void main()
6{
7 mat2 m;
8
9 m = mat2(a);
10 gl_Position = gl_Vertex;
11}
diff --git a/src/glsl/tests/matrix-10.glsl b/src/glsl/tests/matrix-10.glsl
new file mode 100644
index 00000000000..20b55180cbb
--- /dev/null
+++ b/src/glsl/tests/matrix-10.glsl
@@ -0,0 +1,12 @@
1#version 120
2/* PASS */
3
4uniform mat3 a;
5
6void main()
7{
8 mat2 m;
9
10 m = mat2(a);
11 gl_Position = gl_Vertex;
12}
diff --git a/src/glsl/tests/parameters-01.glsl b/src/glsl/tests/parameters-01.glsl
new file mode 100644
index 00000000000..b485106e9d7
--- /dev/null
+++ b/src/glsl/tests/parameters-01.glsl
@@ -0,0 +1,11 @@
1/* FAIL: redefinition of a() */
2
3void a()
4{
5 ;
6}
7
8void a()
9{
10 ;
11}
diff --git a/src/glsl/tests/parameters-02.glsl b/src/glsl/tests/parameters-02.glsl
new file mode 100644
index 00000000000..7ff5f59ab79
--- /dev/null
+++ b/src/glsl/tests/parameters-02.glsl
@@ -0,0 +1,11 @@
1/* PASS */
2
3void a()
4{
5 ;
6}
7
8void a(float x)
9{
10 ;
11}
diff --git a/src/glsl/tests/parameters-03.glsl b/src/glsl/tests/parameters-03.glsl
new file mode 100644
index 00000000000..7ec30f80cc6
--- /dev/null
+++ b/src/glsl/tests/parameters-03.glsl
@@ -0,0 +1,9 @@
1/* FAIL - x is redeclared in the function body at the same scope as the
2 * parameter
3 */
4void a(float x, float y)
5{
6 float x;
7
8 x = y;
9}
diff --git a/src/glsl/tests/qualifier-01.glsl b/src/glsl/tests/qualifier-01.glsl
new file mode 100644
index 00000000000..54ec3572a24
--- /dev/null
+++ b/src/glsl/tests/qualifier-01.glsl
@@ -0,0 +1,3 @@
1#version 130
2/* FAIL - inout only allowed in parameter list */
3inout vec4 foo;
diff --git a/src/glsl/tests/qualifier-02.glsl b/src/glsl/tests/qualifier-02.glsl
new file mode 100644
index 00000000000..b635d52aa2a
--- /dev/null
+++ b/src/glsl/tests/qualifier-02.glsl
@@ -0,0 +1,2 @@
1/* FAIL - in only allowed in parameter list in GLSL 1.10 */
2in foo;
diff --git a/src/glsl/tests/qualifier-03.glsl b/src/glsl/tests/qualifier-03.glsl
new file mode 100644
index 00000000000..7e448034a7c
--- /dev/null
+++ b/src/glsl/tests/qualifier-03.glsl
@@ -0,0 +1,2 @@
1/* FAIL - out only allowed in parameter list in GLSL 1.10 */
2out vec4 foo;
diff --git a/src/glsl/tests/qualifier-04.glsl b/src/glsl/tests/qualifier-04.glsl
new file mode 100644
index 00000000000..d03cafc1db2
--- /dev/null
+++ b/src/glsl/tests/qualifier-04.glsl
@@ -0,0 +1,3 @@
1#version 130
2/* PASS */
3in vec4 foo;
diff --git a/src/glsl/tests/qualifier-05.glsl b/src/glsl/tests/qualifier-05.glsl
new file mode 100644
index 00000000000..15281f33840
--- /dev/null
+++ b/src/glsl/tests/qualifier-05.glsl
@@ -0,0 +1,3 @@
1#version 130
2/* PASS */
3out vec4 foo;
diff --git a/src/glsl/tests/qualifier-06.glsl b/src/glsl/tests/qualifier-06.glsl
new file mode 100644
index 00000000000..1907a087c8e
--- /dev/null
+++ b/src/glsl/tests/qualifier-06.glsl
@@ -0,0 +1,7 @@
1/* FAIL - in only allowed in parameter list in GLSL 1.10 */
2void main()
3{
4 in vec4 foo;
5
6 gl_Position = gl_Vertex;
7}
diff --git a/src/glsl/tests/qualifier-07.glsl b/src/glsl/tests/qualifier-07.glsl
new file mode 100644
index 00000000000..12568a57dbc
--- /dev/null
+++ b/src/glsl/tests/qualifier-07.glsl
@@ -0,0 +1,7 @@
1/* FAIL - out only allowed in parameter list in GLSL 1.10 */
2void main()
3{
4 out vec4 foo;
5
6 gl_Position = gl_Vertex;
7}
diff --git a/src/glsl/tests/swiz-01.glsl b/src/glsl/tests/swiz-01.glsl
new file mode 100644
index 00000000000..3268fa178c1
--- /dev/null
+++ b/src/glsl/tests/swiz-01.glsl
@@ -0,0 +1,11 @@
1/* PASS */
2#version 120
3
4void main()
5{
6 float a;
7 vec4 b;
8
9 b.x = 6.0;
10 a = b.x;
11}
diff --git a/src/glsl/tests/swiz-02.glsl b/src/glsl/tests/swiz-02.glsl
new file mode 100644
index 00000000000..e3f043c47bd
--- /dev/null
+++ b/src/glsl/tests/swiz-02.glsl
@@ -0,0 +1,11 @@
1/* FAIL: assignment of a vec2 to a float */
2#version 120
3
4void main()
5{
6 float a;
7 vec4 b;
8
9 b.x = 6.0;
10 a = b.xy;
11}
diff --git a/src/glsl/tests/void-01.glsl b/src/glsl/tests/void-01.glsl
new file mode 100644
index 00000000000..5719edc0b6c
--- /dev/null
+++ b/src/glsl/tests/void-01.glsl
@@ -0,0 +1,2 @@
1/* FAIL - cannot declare a variable as having type `void' */
2void foo;
diff --git a/src/mesa/Makefile b/src/mesa/Makefile
index 7073c92240b..f97720093c8 100644
--- a/src/mesa/Makefile
+++ b/src/mesa/Makefile
@@ -42,16 +42,26 @@ MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS))
42MESA_INCLUDES := $(INCLUDE_DIRS) 42MESA_INCLUDES := $(INCLUDE_DIRS)
43ES1_INCLUDES := -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS) 43ES1_INCLUDES := -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS)
44ES2_INCLUDES := -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS) 44ES2_INCLUDES := -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS)
45 45MESA_INCLUDES := -I$(TOP)/src/glsl $(MESA_INCLUDES)
46# For symbol_table.h in glsl compiler headers.
47MESA_INCLUDES := -I$(TOP)/src/mesa/shader $(MESA_INCLUDES)
46 48
47define mesa-cc-c 49define mesa-cc-c
48 @mkdir -p $(dir $@) 50 @mkdir -p $(dir $@)
49 $(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CFLAGS) 51 $(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CFLAGS)
50endef 52endef
51 53
54define mesa-cxx-c
55 @mkdir -p $(dir $@)
56 $(CXX) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CXXFLAGS)
57endef
58
52$(MESA_OBJ_DIR)/%.o: %.c 59$(MESA_OBJ_DIR)/%.o: %.c
53 $(call mesa-cc-c,MESA) 60 $(call mesa-cc-c,MESA)
54 61
62$(MESA_OBJ_DIR)/%.o: %.cpp
63 $(call mesa-cxx-c,MESA)
64
55$(MESA_OBJ_DIR)/%.o: %.S 65$(MESA_OBJ_DIR)/%.o: %.S
56 $(call mesa-cc-c,MESA) 66 $(call mesa-cc-c,MESA)
57 67
@@ -70,7 +80,7 @@ $(ES2_OBJ_DIR)/%.o: %.S
70 80
71# Default: build dependencies, then asm_subdirs, GLSL built-in lib, 81# Default: build dependencies, then asm_subdirs, GLSL built-in lib,
72# then convenience libs (.a) and finally the device drivers: 82# then convenience libs (.a) and finally the device drivers:
73default: $(DEPENDS) asm_subdirs glsl_builtin \ 83default: $(DEPENDS) asm_subdirs \
74 $(MESA_LIBS) $(ES1_LIBS) $(ES2_LIBS) driver_subdirs 84 $(MESA_LIBS) $(ES1_LIBS) $(ES2_LIBS) driver_subdirs
75 85
76main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py 86main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py
@@ -121,12 +131,6 @@ asm_subdirs:
121 131
122 132
123###################################################################### 133######################################################################
124# GLSL built-in library
125glsl_builtin:
126 (cd slang/library && $(MAKE)) || exit 1 ;
127
128
129######################################################################
130# Dependency generation 134# Dependency generation
131 135
132depend: $(ALL_SOURCES) 136depend: $(ALL_SOURCES)
@@ -241,7 +245,6 @@ clean: clean-es1 clean-es2
241 -rm -f depend depend.bak libmesa.a libmesagallium.a 245 -rm -f depend depend.bak libmesa.a libmesagallium.a
242 -rm -f drivers/*/*.o 246 -rm -f drivers/*/*.o
243 -rm -f *.pc 247 -rm -f *.pc
244 -rm -f slang/library/*_gc.h
245 -@cd drivers/dri && $(MAKE) clean 248 -@cd drivers/dri && $(MAKE) clean
246 -@cd drivers/x11 && $(MAKE) clean 249 -@cd drivers/x11 && $(MAKE) clean
247 -@cd drivers/osmesa && $(MAKE) clean 250 -@cd drivers/osmesa && $(MAKE) clean
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index d31b957234b..5c02abc914f 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -10,6 +10,7 @@ if env['platform'] != 'winddk':
10 10
11 env.Append(CPPPATH = [ 11 env.Append(CPPPATH = [
12 '#/src/mapi', 12 '#/src/mapi',
13 '#/src/glsl',
13 '#/src/mesa', 14 '#/src/mesa',
14 ]) 15 ])
15 16
@@ -19,6 +20,7 @@ if env['platform'] != 'winddk':
19 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers 20 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
20 'WIN32_THREADS', # use Win32 thread API 21 'WIN32_THREADS', # use Win32 thread API
21 ]) 22 ])
23 env.Prepend(CPPPATH = ['#src/talloc'])
22 24
23 # 25 #
24 # Source files 26 # Source files
@@ -201,6 +203,7 @@ if env['platform'] != 'winddk':
201 program_sources = [ 203 program_sources = [
202 'program/arbprogparse.c', 204 'program/arbprogparse.c',
203 'program/hash_table.c', 205 'program/hash_table.c',
206 'program/ir_to_mesa.cpp',
204 'program/lex.yy.c', 207 'program/lex.yy.c',
205 'program/nvfragparse.c', 208 'program/nvfragparse.c',
206 'program/nvvertparse.c', 209 'program/nvvertparse.c',
@@ -249,8 +252,7 @@ if env['platform'] != 'winddk':
249 program_sources + 252 program_sources +
250 vbo_sources + 253 vbo_sources +
251 vf_sources + 254 vf_sources +
252 statetracker_sources + 255 statetracker_sources
253 slang_sources
254 ) 256 )
255 257
256 # 258 #
@@ -328,7 +330,7 @@ if env['platform'] != 'winddk':
328 # build dir) to the include path 330 # build dir) to the include path
329 env.Append(CPPPATH = [matypes[0].dir]) 331 env.Append(CPPPATH = [matypes[0].dir])
330 332
331 SConscript('slang/library/SConscript') 333 #SConscript('slang/library/SConscript')
332 334
333 # 335 #
334 # Libraries 336 # Libraries
diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template
index 8cb25439e48..35daacfacdc 100644
--- a/src/mesa/drivers/dri/Makefile.template
+++ b/src/mesa/drivers/dri/Makefile.template
@@ -54,9 +54,9 @@ lib: symlinks subdirs depend
54 54
55$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ 55$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \
56 $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o 56 $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o
57 $(MKLIB) -o $@.tmp -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ 57 $(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
58 $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) 58 $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS)
59 $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) 59 $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
60 @rm -f $@.test 60 @rm -f $@.test
61 mv -f $@.tmp $@ 61 mv -f $@.tmp $@
62 62
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index bc647ff8130..e2fcdaa6389 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -513,7 +513,11 @@ struct __DRIscreenRec {
513 * 513 *
514 * This pointer is never touched by the DRI layer. 514 * This pointer is never touched by the DRI layer.
515 */ 515 */
516#ifdef __cplusplus
517 void *priv;
518#else
516 void *private; 519 void *private;
520#endif
517 521
518 /* Extensions provided by the loader. */ 522 /* Extensions provided by the loader. */
519 const __DRIgetDrawableInfoExtension *getDrawableInfo; 523 const __DRIgetDrawableInfoExtension *getDrawableInfo;
diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index b3fe1c05d66..d8715cf026d 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -174,6 +174,8 @@ i915CreateContext(int api,
174 174
175 ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; 175 ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
176 176
177 ctx->Shader.EmitNoIfs = GL_TRUE;
178
177 ctx->Const.MaxDrawBuffers = 1; 179 ctx->Const.MaxDrawBuffers = 1;
178 180
179 _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, 181 _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 4b08d2599bc..c6d11fed064 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -36,6 +36,7 @@
36#include "program/program.h" 36#include "program/program.h"
37#include "program/programopt.h" 37#include "program/programopt.h"
38#include "tnl/tnl.h" 38#include "tnl/tnl.h"
39#include "talloc.h"
39 40
40#include "brw_context.h" 41#include "brw_context.h"
41#include "brw_wm.h" 42#include "brw_wm.h"
@@ -114,10 +115,7 @@ shader_error(GLcontext *ctx, struct gl_program *prog, const char *msg)
114 shader = _mesa_lookup_shader_program(ctx, prog->Id); 115 shader = _mesa_lookup_shader_program(ctx, prog->Id);
115 116
116 if (shader) { 117 if (shader) {
117 if (shader->InfoLog) { 118 shader->InfoLog = talloc_strdup_append(shader->InfoLog, msg);
118 free(shader->InfoLog);
119 }
120 shader->InfoLog = _mesa_strdup(msg);
121 shader->LinkStatus = GL_FALSE; 119 shader->LinkStatus = GL_FALSE;
122 } 120 }
123} 121}
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 9a832af9a97..9f90e1e5e5c 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -75,10 +75,10 @@ static void do_vs_prog( struct brw_context *brw,
75 c.prog_data.outputs_written |= BITFIELD64_BIT(VERT_RESULT_TEX0 + i); 75 c.prog_data.outputs_written |= BITFIELD64_BIT(VERT_RESULT_TEX0 + i);
76 } 76 }
77 77
78 if (0) 78 if (0) {
79 _mesa_print_program(&c.vp->program.Base); 79 _mesa_fprint_program_opt(stdout, &c.vp->program.Base, PROG_PRINT_DEBUG,
80 80 GL_TRUE);
81 81 }
82 82
83 /* Emit GEN4 code. 83 /* Emit GEN4 code.
84 */ 84 */
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index b6b558e9a69..fab6b4f3d5a 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -502,6 +502,23 @@ static void emit_cmp( struct brw_compile *p,
502 brw_set_predicate_control(p, BRW_PREDICATE_NONE); 502 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
503} 503}
504 504
505static void emit_sign(struct brw_vs_compile *c,
506 struct brw_reg dst,
507 struct brw_reg arg0)
508{
509 struct brw_compile *p = &c->func;
510
511 brw_MOV(p, dst, brw_imm_f(0));
512
513 brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, brw_imm_f(0));
514 brw_MOV(p, dst, brw_imm_f(-1.0));
515 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
516
517 brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, arg0, brw_imm_f(0));
518 brw_MOV(p, dst, brw_imm_f(1.0));
519 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
520}
521
505static void emit_max( struct brw_compile *p, 522static void emit_max( struct brw_compile *p,
506 struct brw_reg dst, 523 struct brw_reg dst,
507 struct brw_reg arg0, 524 struct brw_reg arg0,
@@ -1547,7 +1564,8 @@ void brw_vs_emit(struct brw_vs_compile *c )
1547 1564
1548 if (INTEL_DEBUG & DEBUG_VS) { 1565 if (INTEL_DEBUG & DEBUG_VS) {
1549 printf("vs-mesa:\n"); 1566 printf("vs-mesa:\n");
1550 _mesa_print_program(&c->vp->program.Base); 1567 _mesa_fprint_program_opt(stdout, &c->vp->program.Base, PROG_PRINT_DEBUG,
1568 GL_TRUE);
1551 printf("\n"); 1569 printf("\n");
1552 } 1570 }
1553 1571
@@ -1732,6 +1750,9 @@ void brw_vs_emit(struct brw_vs_compile *c )
1732 case OPCODE_SLE: 1750 case OPCODE_SLE:
1733 unalias2(c, dst, args[0], args[1], emit_sle); 1751 unalias2(c, dst, args[0], args[1], emit_sle);
1734 break; 1752 break;
1753 case OPCODE_SSG:
1754 unalias1(c, dst, args[0], emit_sign);
1755 break;
1735 case OPCODE_SUB: 1756 case OPCODE_SUB:
1736 brw_ADD(p, dst, args[0], negate(args[1])); 1757 brw_ADD(p, dst, args[0], negate(args[1]));
1737 break; 1758 break;
@@ -1903,7 +1924,7 @@ void brw_vs_emit(struct brw_vs_compile *c )
1903 1924
1904 printf("vs-native:\n"); 1925 printf("vs-native:\n");
1905 for (i = 0; i < p->nr_insn; i++) 1926 for (i = 0; i < p->nr_insn; i++)
1906 brw_disasm(stderr, &p->store[i], intel->gen); 1927 brw_disasm(stdout, &p->store[i], intel->gen);
1907 printf("\n"); 1928 printf("\n");
1908 } 1929 }
1909} 1930}
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index e182fc32029..34cefeea32a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -32,7 +32,7 @@
32#include "brw_context.h" 32#include "brw_context.h"
33#include "brw_wm.h" 33#include "brw_wm.h"
34#include "brw_state.h" 34#include "brw_state.h"
35 35#include "main/formats.h"
36 36
37/** Return number of src args for given instruction */ 37/** Return number of src args for given instruction */
38GLuint brw_wm_nr_args( GLuint opcode ) 38GLuint brw_wm_nr_args( GLuint opcode )
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index f40977fab8d..40f51c21c95 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -343,6 +343,11 @@ void emit_delta_xy(struct brw_compile *p,
343 const struct brw_reg *dst, 343 const struct brw_reg *dst,
344 GLuint mask, 344 GLuint mask,
345 const struct brw_reg *arg0); 345 const struct brw_reg *arg0);
346void emit_dp2(struct brw_compile *p,
347 const struct brw_reg *dst,
348 GLuint mask,
349 const struct brw_reg *arg0,
350 const struct brw_reg *arg1);
346void emit_dp3(struct brw_compile *p, 351void emit_dp3(struct brw_compile *p,
347 const struct brw_reg *dst, 352 const struct brw_reg *dst,
348 GLuint mask, 353 GLuint mask,
@@ -425,6 +430,10 @@ void emit_sop(struct brw_compile *p,
425 GLuint cond, 430 GLuint cond,
426 const struct brw_reg *arg0, 431 const struct brw_reg *arg0,
427 const struct brw_reg *arg1); 432 const struct brw_reg *arg1);
433void emit_sign(struct brw_compile *p,
434 const struct brw_reg *dst,
435 GLuint mask,
436 const struct brw_reg *arg0);
428void emit_tex(struct brw_wm_compile *c, 437void emit_tex(struct brw_wm_compile *c,
429 struct brw_reg *dst, 438 struct brw_reg *dst,
430 GLuint dst_flags, 439 GLuint dst_flags,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c
index d9fa2e63354..053cf13a011 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c
@@ -668,6 +668,28 @@ void emit_cmp(struct brw_compile *p,
668 } 668 }
669} 669}
670 670
671void emit_sign(struct brw_compile *p,
672 const struct brw_reg *dst,
673 GLuint mask,
674 const struct brw_reg *arg0)
675{
676 GLuint i;
677
678 for (i = 0; i < 4; i++) {
679 if (mask & (1<<i)) {
680 brw_MOV(p, dst[i], brw_imm_f(0.0));
681
682 brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0[i], brw_imm_f(0));
683 brw_MOV(p, dst[i], brw_imm_f(-1.0));
684 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
685
686 brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, arg0[i], brw_imm_f(0));
687 brw_MOV(p, dst[i], brw_imm_f(1.0));
688 brw_set_predicate_control(p, BRW_PREDICATE_NONE);
689 }
690 }
691}
692
671void emit_max(struct brw_compile *p, 693void emit_max(struct brw_compile *p,
672 const struct brw_reg *dst, 694 const struct brw_reg *dst,
673 GLuint mask, 695 GLuint mask,
@@ -709,6 +731,27 @@ void emit_min(struct brw_compile *p,
709} 731}
710 732
711 733
734void emit_dp2(struct brw_compile *p,
735 const struct brw_reg *dst,
736 GLuint mask,
737 const struct brw_reg *arg0,
738 const struct brw_reg *arg1)
739{
740 int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
741
742 if (!(mask & WRITEMASK_XYZW))
743 return; /* Do not emit dead code */
744
745 assert(is_power_of_two(mask & WRITEMASK_XYZW));
746
747 brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
748
749 brw_set_saturate(p, (mask & SATURATE) ? 1 : 0);
750 brw_MAC(p, dst[dst_chan], arg0[1], arg1[1]);
751 brw_set_saturate(p, 0);
752}
753
754
712void emit_dp3(struct brw_compile *p, 755void emit_dp3(struct brw_compile *p,
713 const struct brw_reg *dst, 756 const struct brw_reg *dst,
714 GLuint mask, 757 GLuint mask,
@@ -1562,6 +1605,10 @@ void brw_wm_emit( struct brw_wm_compile *c )
1562 emit_ddxy(p, dst, dst_flags, GL_FALSE, args[0]); 1605 emit_ddxy(p, dst, dst_flags, GL_FALSE, args[0]);
1563 break; 1606 break;
1564 1607
1608 case OPCODE_DP2:
1609 emit_dp2(p, dst, dst_flags, args[0], args[1]);
1610 break;
1611
1565 case OPCODE_DP3: 1612 case OPCODE_DP3:
1566 emit_dp3(p, dst, dst_flags, args[0], args[1]); 1613 emit_dp3(p, dst, dst_flags, args[0], args[1]);
1567 break; 1614 break;
@@ -1673,6 +1720,10 @@ void brw_wm_emit( struct brw_wm_compile *c )
1673 emit_sne(p, dst, dst_flags, args[0], args[1]); 1720 emit_sne(p, dst, dst_flags, args[0], args[1]);
1674 break; 1721 break;
1675 1722
1723 case OPCODE_SSG:
1724 emit_sign(p, dst, dst_flags, args[0]);
1725 break;
1726
1676 case OPCODE_LIT: 1727 case OPCODE_LIT:
1677 emit_lit(c, dst, dst_flags, args[0]); 1728 emit_lit(c, dst, dst_flags, args[0]);
1678 break; 1729 break;
@@ -1724,7 +1775,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
1724 1775
1725 printf("wm-native:\n"); 1776 printf("wm-native:\n");
1726 for (i = 0; i < p->nr_insn; i++) 1777 for (i = 0; i < p->nr_insn; i++)
1727 brw_disasm(stderr, &p->store[i], p->brw->intel.gen); 1778 brw_disasm(stdout, &p->store[i], p->brw->intel.gen);
1728 printf("\n"); 1779 printf("\n");
1729 } 1780 }
1730} 1781}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c
index 0bef874b887..3870bf10fcb 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_fp.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c
@@ -88,6 +88,7 @@ static struct prog_src_register src_reg(GLuint file, GLuint idx)
88 reg.RelAddr = 0; 88 reg.RelAddr = 0;
89 reg.Negate = NEGATE_NONE; 89 reg.Negate = NEGATE_NONE;
90 reg.Abs = 0; 90 reg.Abs = 0;
91 reg.HasIndex2 = 0;
91 return reg; 92 return reg;
92} 93}
93 94
@@ -1036,13 +1037,12 @@ static void print_insns( const struct prog_instruction *insn,
1036 for (i = 0; i < nr; i++, insn++) { 1037 for (i = 0; i < nr; i++, insn++) {
1037 printf("%3d: ", i); 1038 printf("%3d: ", i);
1038 if (insn->Opcode < MAX_OPCODE) 1039 if (insn->Opcode < MAX_OPCODE)
1039 _mesa_print_instruction(insn); 1040 _mesa_fprint_instruction_opt(stdout, insn, 0, PROG_PRINT_DEBUG, NULL);
1040 else if (insn->Opcode < MAX_WM_OPCODE) { 1041 else if (insn->Opcode < MAX_WM_OPCODE) {
1041 GLuint idx = insn->Opcode - MAX_OPCODE; 1042 GLuint idx = insn->Opcode - MAX_OPCODE;
1042 1043
1043 _mesa_print_alu_instruction(insn, 1044 _mesa_fprint_alu_instruction(stdout, insn, wm_opcode_strings[idx],
1044 wm_opcode_strings[idx], 1045 3, PROG_PRINT_DEBUG, NULL);
1045 3);
1046 } 1046 }
1047 else 1047 else
1048 printf("965 Opcode %d\n", insn->Opcode); 1048 printf("965 Opcode %d\n", insn->Opcode);
@@ -1061,7 +1061,8 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
1061 1061
1062 if (INTEL_DEBUG & DEBUG_WM) { 1062 if (INTEL_DEBUG & DEBUG_WM) {
1063 printf("pre-fp:\n"); 1063 printf("pre-fp:\n");
1064 _mesa_print_program(&fp->program.Base); 1064 _mesa_fprint_program_opt(stdout, &fp->program.Base, PROG_PRINT_DEBUG,
1065 GL_TRUE);
1065 printf("\n"); 1066 printf("\n");
1066 } 1067 }
1067 1068
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
index 575f89b17fa..f13b0aaf957 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
@@ -1903,6 +1903,9 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
1903 case OPCODE_SWZ: 1903 case OPCODE_SWZ:
1904 emit_alu1(p, brw_MOV, dst, dst_flags, args[0]); 1904 emit_alu1(p, brw_MOV, dst, dst_flags, args[0]);
1905 break; 1905 break;
1906 case OPCODE_DP2:
1907 emit_dp2(p, dst, dst_flags, args[0], args[1]);
1908 break;
1906 case OPCODE_DP3: 1909 case OPCODE_DP3:
1907 emit_dp3(p, dst, dst_flags, args[0], args[1]); 1910 emit_dp3(p, dst, dst_flags, args[0], args[1]);
1908 break; 1911 break;
@@ -1971,6 +1974,9 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
1971 emit_sop(p, dst, dst_flags, 1974 emit_sop(p, dst, dst_flags,
1972 BRW_CONDITIONAL_NEQ, args[0], args[1]); 1975 BRW_CONDITIONAL_NEQ, args[0], args[1]);
1973 break; 1976 break;
1977 case OPCODE_SSG:
1978 emit_sign(p, dst, dst_flags, args[0]);
1979 break;
1974 case OPCODE_MUL: 1980 case OPCODE_MUL:
1975 emit_alu2(p, brw_MUL, dst, dst_flags, args[0], args[1]); 1981 emit_alu2(p, brw_MUL, dst, dst_flags, args[0], args[1]);
1976 break; 1982 break;
@@ -2111,7 +2117,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
2111 if (INTEL_DEBUG & DEBUG_WM) { 2117 if (INTEL_DEBUG & DEBUG_WM) {
2112 printf("wm-native:\n"); 2118 printf("wm-native:\n");
2113 for (i = 0; i < p->nr_insn; i++) 2119 for (i = 0; i < p->nr_insn; i++)
2114 brw_disasm(stderr, &p->store[i], intel->gen); 2120 brw_disasm(stdout, &p->store[i], intel->gen);
2115 printf("\n"); 2121 printf("\n");
2116 } 2122 }
2117} 2123}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass1.c b/src/mesa/drivers/dri/i965/brw_wm_pass1.c
index b4493940292..962515a99e9 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_pass1.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_pass1.c
@@ -158,6 +158,7 @@ void brw_wm_pass1( struct brw_wm_compile *c )
158 case OPCODE_FLR: 158 case OPCODE_FLR:
159 case OPCODE_FRC: 159 case OPCODE_FRC:
160 case OPCODE_MOV: 160 case OPCODE_MOV:
161 case OPCODE_SSG:
161 case OPCODE_SWZ: 162 case OPCODE_SWZ:
162 case OPCODE_TRUNC: 163 case OPCODE_TRUNC:
163 read0 = writemask; 164 read0 = writemask;
@@ -254,6 +255,11 @@ void brw_wm_pass1( struct brw_wm_compile *c )
254 read2 = WRITEMASK_W; /* pixel w */ 255 read2 = WRITEMASK_W; /* pixel w */
255 break; 256 break;
256 257
258 case OPCODE_DP2:
259 read0 = WRITEMASK_XY;
260 read1 = WRITEMASK_XY;
261 break;
262
257 case OPCODE_DP3: 263 case OPCODE_DP3:
258 read0 = WRITEMASK_XYZ; 264 read0 = WRITEMASK_XYZ;
259 read1 = WRITEMASK_XYZ; 265 read1 = WRITEMASK_XYZ;
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index c7ac2de01e6..f245ba843bd 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -32,7 +32,6 @@
32 32
33#include "main/mtypes.h" 33#include "main/mtypes.h"
34#include "main/mm.h" 34#include "main/mm.h"
35#include "texmem.h"
36#include "dri_metaops.h" 35#include "dri_metaops.h"
37#include "drm.h" 36#include "drm.h"
38#include "intel_bufmgr.h" 37#include "intel_bufmgr.h"
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 39ac0205fa1..42adb4cb4a7 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -30,6 +30,7 @@
30#include "intel_regions.h" 30#include "intel_regions.h"
31#include "intel_tex_layout.h" 31#include "intel_tex_layout.h"
32#include "main/enums.h" 32#include "main/enums.h"
33#include "main/formats.h"
33 34
34#define FILE_DEBUG_FLAG DEBUG_MIPTREE 35#define FILE_DEBUG_FLAG DEBUG_MIPTREE
35 36
diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h
index 4bb012dc65e..cd77dd5b8e4 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.h
+++ b/src/mesa/drivers/dri/intel/intel_tex.h
@@ -31,8 +31,6 @@
31#include "main/mtypes.h" 31#include "main/mtypes.h"
32#include "main/formats.h" 32#include "main/formats.h"
33#include "intel_context.h" 33#include "intel_context.h"
34#include "texmem.h"
35
36 34
37void intelInitTextureFuncs(struct dd_function_table *functions); 35void intelInitTextureFuncs(struct dd_function_table *functions);
38 36
diff --git a/src/mesa/drivers/osmesa/Makefile b/src/mesa/drivers/osmesa/Makefile
index c6b4a040851..091e6f66d9b 100644
--- a/src/mesa/drivers/osmesa/Makefile
+++ b/src/mesa/drivers/osmesa/Makefile
@@ -23,8 +23,7 @@ INCLUDE_DIRS = \
23CORE_MESA = \ 23CORE_MESA = \
24 $(TOP)/src/mesa/libmesa.a \ 24 $(TOP)/src/mesa/libmesa.a \
25 $(TOP)/src/mapi/glapi/libglapi.a \ 25 $(TOP)/src/mapi/glapi/libglapi.a \
26 $(TOP)/src/glsl/cl/libglslcl.a \ 26 $(TOP)/src/glsl/libglsl.a
27 $(TOP)/src/glsl/pp/libglslpp.a
28 27
29.c.o: 28.c.o:
30 $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ 29 $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 825073ca886..71d0f570e4b 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -595,6 +595,27 @@ struct dd_function_table {
595 595
596 /*@}*/ 596 /*@}*/
597 597
598 /**
599 * \name GLSL shader/program functions.
600 */
601 /*@{*/
602 /**
603 * Called when a shader is compiled.
604 *
605 * Note that not all shader objects get ShaderCompile called on
606 * them. Notably, the shaders containing builtin functions do not
607 * have CompileShader() called, so if lowering passes are done they
608 * need to also be performed in LinkShader().
609 */
610 GLboolean (*CompileShader)(GLcontext *ctx, struct gl_shader *shader);
611 /**
612 * Called when a shader program is linked.
613 *
614 * This gives drivers an opportunity to clone the IR and make their
615 * own transformations on it for the purposes of code generation.
616 */
617 GLboolean (*LinkShader)(GLcontext *ctx, struct gl_shader_program *shader);
618 /*@}*/
598 619
599 /** 620 /**
600 * \name State-changing functions. 621 * \name State-changing functions.
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 9c2ffd66d69..e967b147311 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -116,6 +116,35 @@ typedef union { GLfloat f; GLint i; } fi_type;
116#endif 116#endif
117 117
118 118
119/**
120 * \name Work-arounds for platforms that lack C99 math functions
121 */
122/*@{*/
123#if (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \
124 && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \
125 && (!defined(_MSC_VER) || (_MSC_VER < 1400))
126#define acosf(f) ((float) acos(f))
127#define asinf(f) ((float) asin(f))
128#define atan2f(x,y) ((float) atan2(x,y))
129#define atanf(f) ((float) atan(f))
130#define cielf(f) ((float) ciel(f))
131#define cosf(f) ((float) cos(f))
132#define coshf(f) ((float) cosh(f))
133#define expf(f) ((float) exp(f))
134#define exp2f(f) ((float) exp2(f))
135#define floorf(f) ((float) floor(f))
136#define logf(f) ((float) log(f))
137#define log2f(f) ((float) log2(f))
138#define powf(x,y) ((float) pow(x,y))
139#define sinf(f) ((float) sin(f))
140#define sinhf(f) ((float) sinh(f))
141#define sqrtf(f) ((float) sqrt(f))
142#define tanf(f) ((float) tan(f))
143#define tanhf(f) ((float) tanh(f))
144#define truncf(f) ((float) trunc(f))
145#endif
146/*@}*/
147
119/*** 148/***
120 *** LOG2: Log base 2 of float 149 *** LOG2: Log base 2 of float
121 ***/ 150 ***/
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8d92892ad7d..b8bcda56bfa 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2084,6 +2084,15 @@ struct gl_shader
2084 struct gl_program *Program; /**< Post-compile assembly code */ 2084 struct gl_program *Program; /**< Post-compile assembly code */
2085 GLchar *InfoLog; 2085 GLchar *InfoLog;
2086 struct gl_sl_pragmas Pragmas; 2086 struct gl_sl_pragmas Pragmas;
2087
2088 unsigned Version; /**< GLSL version used for linking */
2089
2090 struct exec_list *ir;
2091 struct glsl_symbol_table *symbols;
2092
2093 /** Shaders containing built-in functions that are used for linking. */
2094 struct gl_shader *builtins_to_link[16];
2095 unsigned num_builtins_to_link;
2087}; 2096};
2088 2097
2089 2098
@@ -2129,6 +2138,16 @@ struct gl_shader_program
2129 GLboolean Validated; 2138 GLboolean Validated;
2130 GLboolean _Used; /**< Ever used for drawing? */ 2139 GLboolean _Used; /**< Ever used for drawing? */
2131 GLchar *InfoLog; 2140 GLchar *InfoLog;
2141
2142 unsigned Version; /**< GLSL version used for linking */
2143
2144 /**
2145 * Per-stage shaders resulting from the first stage of linking.
2146 */
2147 /*@{*/
2148 GLuint _NumLinkedShaders;
2149 struct gl_shader *_LinkedShaders[2];
2150 /*@}*/
2132}; 2151};
2133 2152
2134 2153
@@ -2154,6 +2173,11 @@ struct gl_shader_state
2154 GLboolean EmitCondCodes; /**< Use condition codes? */ 2173 GLboolean EmitCondCodes; /**< Use condition codes? */
2155 GLboolean EmitComments; /**< Annotated instructions */ 2174 GLboolean EmitComments; /**< Annotated instructions */
2156 GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */ 2175 GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */
2176 /**
2177 * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't
2178 * support control flow.
2179 */
2180 GLboolean EmitNoIfs;
2157 void *MemPool; 2181 void *MemPool;
2158 GLbitfield Flags; /**< Mask of GLSL_x flags */ 2182 GLbitfield Flags; /**< Mask of GLSL_x flags */
2159 struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ 2183 struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 9cb2391035d..89b9557e84f 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -48,6 +48,7 @@
48#include "program/prog_uniform.h" 48#include "program/prog_uniform.h"
49#include "slang/slang_compile.h" 49#include "slang/slang_compile.h"
50#include "slang/slang_link.h" 50#include "slang/slang_link.h"
51#include "talloc.h"
51 52
52 53
53/** Define this to enable shader substitution (see below) */ 54/** Define this to enable shader substitution (see below) */
@@ -99,6 +100,7 @@ _mesa_init_shader_state(GLcontext *ctx)
99 ctx->Shader.EmitContReturn = GL_TRUE; 100 ctx->Shader.EmitContReturn = GL_TRUE;
100 ctx->Shader.EmitCondCodes = GL_FALSE; 101 ctx->Shader.EmitCondCodes = GL_FALSE;
101 ctx->Shader.EmitComments = GL_FALSE; 102 ctx->Shader.EmitComments = GL_FALSE;
103 ctx->Shader.EmitNoIfs = GL_FALSE;
102 ctx->Shader.Flags = get_shader_flags(); 104 ctx->Shader.Flags = get_shader_flags();
103 105
104 /* Default pragma settings */ 106 /* Default pragma settings */
@@ -800,7 +802,7 @@ compile_shader(GLcontext *ctx, GLuint shaderObj)
800 /* this call will set the sh->CompileStatus field to indicate if 802 /* this call will set the sh->CompileStatus field to indicate if
801 * compilation was successful. 803 * compilation was successful.
802 */ 804 */
803 (void) _slang_compile(ctx, sh); 805 _mesa_glsl_compile_shader(ctx, sh);
804} 806}
805 807
806 808
@@ -826,7 +828,7 @@ link_program(GLcontext *ctx, GLuint program)
826 828
827 FLUSH_VERTICES(ctx, _NEW_PROGRAM); 829 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
828 830
829 _slang_link(ctx, program, shProg); 831 _mesa_glsl_link_shader(ctx, shProg);
830 832
831 /* debug code */ 833 /* debug code */
832 if (0) { 834 if (0) {
@@ -1051,9 +1053,9 @@ validate_program(GLcontext *ctx, GLuint program)
1051 if (!shProg->Validated) { 1053 if (!shProg->Validated) {
1052 /* update info log */ 1054 /* update info log */
1053 if (shProg->InfoLog) { 1055 if (shProg->InfoLog) {
1054 free(shProg->InfoLog); 1056 talloc_free(shProg->InfoLog);
1055 } 1057 }
1056 shProg->InfoLog = _mesa_strdup(errMsg); 1058 shProg->InfoLog = talloc_strdup(shProg, errMsg);
1057 } 1059 }
1058} 1060}
1059 1061
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 14bbb2e4bc3..863d50fbe55 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -36,7 +36,7 @@
36#include "program/program.h" 36#include "program/program.h"
37#include "program/prog_parameter.h" 37#include "program/prog_parameter.h"
38#include "program/prog_uniform.h" 38#include "program/prog_uniform.h"
39 39#include "talloc.h"
40 40
41/**********************************************************************/ 41/**********************************************************************/
42/*** Shader object functions ***/ 42/*** Shader object functions ***/
@@ -92,13 +92,13 @@ _mesa_reference_shader(GLcontext *ctx, struct gl_shader **ptr,
92 * Allocate a new gl_shader object, initialize it. 92 * Allocate a new gl_shader object, initialize it.
93 * Called via ctx->Driver.NewShader() 93 * Called via ctx->Driver.NewShader()
94 */ 94 */
95static struct gl_shader * 95struct gl_shader *
96_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type) 96_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type)
97{ 97{
98 struct gl_shader *shader; 98 struct gl_shader *shader;
99 assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER || 99 assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER ||
100 type == GL_GEOMETRY_SHADER_ARB); 100 type == GL_GEOMETRY_SHADER_ARB);
101 shader = CALLOC_STRUCT(gl_shader); 101 shader = talloc_zero(NULL, struct gl_shader);
102 if (shader) { 102 if (shader) {
103 shader->Type = type; 103 shader->Type = type;
104 shader->Name = name; 104 shader->Name = name;
@@ -117,10 +117,8 @@ __mesa_delete_shader(GLcontext *ctx, struct gl_shader *sh)
117{ 117{
118 if (sh->Source) 118 if (sh->Source)
119 free((void *) sh->Source); 119 free((void *) sh->Source);
120 if (sh->InfoLog)
121 free(sh->InfoLog);
122 _mesa_reference_program(ctx, &sh->Program, NULL); 120 _mesa_reference_program(ctx, &sh->Program, NULL);
123 free(sh); 121 talloc_free(sh);
124} 122}
125 123
126 124
@@ -235,7 +233,7 @@ static struct gl_shader_program *
235_mesa_new_shader_program(GLcontext *ctx, GLuint name) 233_mesa_new_shader_program(GLcontext *ctx, GLuint name)
236{ 234{
237 struct gl_shader_program *shProg; 235 struct gl_shader_program *shProg;
238 shProg = CALLOC_STRUCT(gl_shader_program); 236 shProg = talloc_zero(NULL, struct gl_shader_program);
239 if (shProg) { 237 if (shProg) {
240 shProg->Type = GL_SHADER_PROGRAM_MESA; 238 shProg->Type = GL_SHADER_PROGRAM_MESA;
241 shProg->Name = name; 239 shProg->Name = name;
@@ -305,7 +303,7 @@ _mesa_free_shader_program_data(GLcontext *ctx,
305 } 303 }
306 304
307 if (shProg->InfoLog) { 305 if (shProg->InfoLog) {
308 free(shProg->InfoLog); 306 talloc_free(shProg->InfoLog);
309 shProg->InfoLog = NULL; 307 shProg->InfoLog = NULL;
310 } 308 }
311 309
@@ -328,7 +326,7 @@ __mesa_delete_shader_program(GLcontext *ctx, struct gl_shader_program *shProg)
328{ 326{
329 _mesa_free_shader_program_data(ctx, shProg); 327 _mesa_free_shader_program_data(ctx, shProg);
330 328
331 free(shProg); 329 talloc_free(shProg);
332} 330}
333 331
334 332
@@ -389,4 +387,6 @@ _mesa_init_shader_object_functions(struct dd_function_table *driver)
389 driver->DeleteShader = __mesa_delete_shader; 387 driver->DeleteShader = __mesa_delete_shader;
390 driver->NewShaderProgram = _mesa_new_shader_program; 388 driver->NewShaderProgram = _mesa_new_shader_program;
391 driver->DeleteShaderProgram = __mesa_delete_shader_program; 389 driver->DeleteShaderProgram = __mesa_delete_shader_program;
390 driver->CompileShader = _mesa_ir_compile_shader;
391 driver->LinkShader = _mesa_ir_link_shader;
392} 392}
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index d6b37b45963..1b96316b67b 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -27,8 +27,22 @@
27#define SHADEROBJ_H 27#define SHADEROBJ_H
28 28
29 29
30#include "glheader.h" 30#include "main/glheader.h"
31#include "mtypes.h" 31#include "main/mtypes.h"
32#include "program/ir_to_mesa.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37/**
38 * Internal functions
39 */
40
41extern void
42_mesa_init_shader_state(GLcontext * ctx);
43
44extern void
45_mesa_free_shader_state(GLcontext *ctx);
32 46
33 47
34extern void 48extern void
@@ -48,6 +62,9 @@ _mesa_reference_shader_program(GLcontext *ctx,
48 struct gl_shader_program **ptr, 62 struct gl_shader_program **ptr,
49 struct gl_shader_program *shProg); 63 struct gl_shader_program *shProg);
50 64
65extern struct gl_shader *
66_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
67
51extern struct gl_shader_program * 68extern struct gl_shader_program *
52_mesa_lookup_shader_program(GLcontext *ctx, GLuint name); 69_mesa_lookup_shader_program(GLcontext *ctx, GLuint name);
53 70
@@ -74,5 +91,8 @@ _mesa_init_shader_state(GLcontext *ctx);
74extern void 91extern void
75_mesa_free_shader_state(GLcontext *ctx); 92_mesa_free_shader_state(GLcontext *ctx);
76 93
94#ifdef __cplusplus
95}
96#endif
77 97
78#endif /* SHADEROBJ_H */ 98#endif /* SHADEROBJ_H */
diff --git a/src/mesa/program/hash_table.c b/src/mesa/program/hash_table.c
index fa6ba2bfdfc..f7ef366c1a0 100644
--- a/src/mesa/program/hash_table.c
+++ b/src/mesa/program/hash_table.c
@@ -142,6 +142,23 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key)
142 insert_at_head(& ht->buckets[bucket], & node->link); 142 insert_at_head(& ht->buckets[bucket], & node->link);
143} 143}
144 144
145void
146hash_table_remove(struct hash_table *ht, const void *key)
147{
148 const unsigned hash_value = (*ht->hash)(key);
149 const unsigned bucket = hash_value % ht->num_buckets;
150 struct node *node;
151
152 foreach(node, & ht->buckets[bucket]) {
153 struct hash_node *hn = (struct hash_node *) node;
154
155 if ((*ht->compare)(hn->key, key) == 0) {
156 remove_from_list(node);
157 free(node);
158 return;
159 }
160 }
161}
145 162
146unsigned 163unsigned
147hash_table_string_hash(const void *key) 164hash_table_string_hash(const void *key)
@@ -157,3 +174,17 @@ hash_table_string_hash(const void *key)
157 174
158 return hash; 175 return hash;
159} 176}
177
178
179unsigned
180hash_table_pointer_hash(const void *key)
181{
182 return (unsigned)((uintptr_t) key / sizeof(void *));
183}
184
185
186int
187hash_table_pointer_compare(const void *key1, const void *key2)
188{
189 return key1 == key2 ? 0 : 1;
190}
diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h
index e750906f961..f1c4fdcd1fa 100644
--- a/src/mesa/program/hash_table.h
+++ b/src/mesa/program/hash_table.h
@@ -36,6 +36,10 @@ struct hash_table;
36typedef unsigned (*hash_func_t)(const void *key); 36typedef unsigned (*hash_func_t)(const void *key);
37typedef int (*hash_compare_func_t)(const void *key1, const void *key2); 37typedef int (*hash_compare_func_t)(const void *key1, const void *key2);
38 38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
39/** 43/**
40 * Hash table constructor 44 * Hash table constructor
41 * 45 *
@@ -88,6 +92,10 @@ extern void *hash_table_find(struct hash_table *ht, const void *key);
88extern void hash_table_insert(struct hash_table *ht, void *data, 92extern void hash_table_insert(struct hash_table *ht, void *data,
89 const void *key); 93 const void *key);
90 94
95/**
96 * Remove a specific element from a hash table.
97 */
98extern void hash_table_remove(struct hash_table *ht, const void *key);
91 99
92/** 100/**
93 * Compute hash value of a string 101 * Compute hash value of a string
@@ -112,4 +120,31 @@ extern unsigned hash_table_string_hash(const void *key);
112 */ 120 */
113#define hash_table_string_compare ((hash_compare_func_t) strcmp) 121#define hash_table_string_compare ((hash_compare_func_t) strcmp)
114 122
123
124/**
125 * Compute hash value of a pointer
126 *
127 * \param key Pointer to be used as a hash key
128 *
129 * \note
130 * The memory pointed to by \c key is \b never accessed. The value of \c key
131 * itself is used as the hash key
132 *
133 * \sa hash_table_pointer_compare
134 */
135unsigned
136hash_table_pointer_hash(const void *key);
137
138
139/**
140 * Compare two pointers used as keys
141 *
142 * \sa hash_table_pointer_hash
143 */
144int
145hash_table_pointer_compare(const void *key1, const void *key2);
146
147#ifdef __cplusplus
148}
149#endif
115#endif /* HASH_TABLE_H */ 150#endif /* HASH_TABLE_H */
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
new file mode 100644
index 00000000000..1fb578516ce
--- /dev/null
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -0,0 +1,2725 @@
1/*
2 * Copyright (C) 2005-2007 Brian Paul All Rights Reserved.
3 * Copyright (C) 2008 VMware, Inc. All Rights Reserved.
4 * Copyright © 2010 Intel Corporation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26/**
27 * \file ir_to_mesa.cpp
28 *
29 * Translates the IR to ARB_fragment_program text if possible,
30 * printing the result
31 */
32
33#include <stdio.h>
34#include "main/compiler.h"
35#include "ir.h"
36#include "ir_visitor.h"
37#include "ir_print_visitor.h"
38#include "ir_expression_flattening.h"
39#include "glsl_types.h"
40#include "glsl_parser_extras.h"
41#include "../glsl/program.h"
42#include "ir_optimization.h"
43#include "ast.h"
44
45extern "C" {
46#include "main/mtypes.h"
47#include "main/shaderapi.h"
48#include "main/shaderobj.h"
49#include "main/uniforms.h"
50#include "program/hash_table.h"
51#include "program/prog_instruction.h"
52#include "program/prog_optimize.h"
53#include "program/prog_print.h"
54#include "program/program.h"
55#include "program/prog_uniform.h"
56#include "program/prog_parameter.h"
57}
58
59static int swizzle_for_size(int size);
60
61/**
62 * This struct is a corresponding struct to Mesa prog_src_register, with
63 * wider fields.
64 */
65typedef struct ir_to_mesa_src_reg {
66 ir_to_mesa_src_reg(int file, int index, const glsl_type *type)
67 {
68 this->file = file;
69 this->index = index;
70 if (type && (type->is_scalar() || type->is_vector() || type->is_matrix()))
71 this->swizzle = swizzle_for_size(type->vector_elements);
72 else
73 this->swizzle = SWIZZLE_XYZW;
74 this->negate = 0;
75 this->reladdr = NULL;
76 }
77
78 ir_to_mesa_src_reg()
79 {
80 this->file = PROGRAM_UNDEFINED;
81 }
82
83 int file; /**< PROGRAM_* from Mesa */
84 int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */
85 GLuint swizzle; /**< SWIZZLE_XYZWONEZERO swizzles from Mesa. */
86 int negate; /**< NEGATE_XYZW mask from mesa */
87 /** Register index should be offset by the integer in this reg. */
88 ir_to_mesa_src_reg *reladdr;
89} ir_to_mesa_src_reg;
90
91typedef struct ir_to_mesa_dst_reg {
92 int file; /**< PROGRAM_* from Mesa */
93 int index; /**< temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */
94 int writemask; /**< Bitfield of WRITEMASK_[XYZW] */
95 GLuint cond_mask:4;
96 /** Register index should be offset by the integer in this reg. */
97 ir_to_mesa_src_reg *reladdr;
98} ir_to_mesa_dst_reg;
99
100extern ir_to_mesa_src_reg ir_to_mesa_undef;
101
102class ir_to_mesa_instruction : public exec_node {
103public:
104 enum prog_opcode op;
105 ir_to_mesa_dst_reg dst_reg;
106 ir_to_mesa_src_reg src_reg[3];
107 /** Pointer to the ir source this tree came from for debugging */
108 ir_instruction *ir;
109 GLboolean cond_update;
110 int sampler; /**< sampler index */
111 int tex_target; /**< One of TEXTURE_*_INDEX */
112 GLboolean tex_shadow;
113
114 class function_entry *function; /* Set on OPCODE_CAL or OPCODE_BGNSUB */
115};
116
117class variable_storage : public exec_node {
118public:
119 variable_storage(ir_variable *var, int file, int index)
120 : file(file), index(index), var(var)
121 {
122 /* empty */
123 }
124
125 int file;
126 int index;
127 ir_variable *var; /* variable that maps to this, if any */
128};
129
130class function_entry : public exec_node {
131public:
132 ir_function_signature *sig;
133
134 /**
135 * identifier of this function signature used by the program.
136 *
137 * At the point that Mesa instructions for function calls are
138 * generated, we don't know the address of the first instruction of
139 * the function body. So we make the BranchTarget that is called a
140 * small integer and rewrite them during set_branchtargets().
141 */
142 int sig_id;
143
144 /**
145 * Pointer to first instruction of the function body.
146 *
147 * Set during function body emits after main() is processed.
148 */
149 ir_to_mesa_instruction *bgn_inst;
150
151 /**
152 * Index of the first instruction of the function body in actual
153 * Mesa IR.
154 *
155 * Set after convertion from ir_to_mesa_instruction to prog_instruction.
156 */
157 int inst;
158
159 /** Storage for the return value. */
160 ir_to_mesa_src_reg return_reg;
161};
162
163class ir_to_mesa_visitor : public ir_visitor {
164public:
165 ir_to_mesa_visitor();
166 ~ir_to_mesa_visitor();
167
168 function_entry *current_function;
169
170 GLcontext *ctx;
171 struct gl_program *prog;
172
173 int next_temp;
174
175 variable_storage *find_variable_storage(ir_variable *var);
176
177 function_entry *get_function_signature(ir_function_signature *sig);
178
179 ir_to_mesa_src_reg get_temp(const glsl_type *type);
180 void reladdr_to_temp(ir_instruction *ir,
181 ir_to_mesa_src_reg *reg, int *num_reladdr);
182
183 struct ir_to_mesa_src_reg src_reg_for_float(float val);
184
185 /**
186 * \name Visit methods
187 *
188 * As typical for the visitor pattern, there must be one \c visit method for
189 * each concrete subclass of \c ir_instruction. Virtual base classes within
190 * the hierarchy should not have \c visit methods.
191 */
192 /*@{*/
193 virtual void visit(ir_variable *);
194 virtual void visit(ir_loop *);
195 virtual void visit(ir_loop_jump *);
196 virtual void visit(ir_function_signature *);
197 virtual void visit(ir_function *);
198 virtual void visit(ir_expression *);
199 virtual void visit(ir_swizzle *);
200 virtual void visit(ir_dereference_variable *);
201 virtual void visit(ir_dereference_array *);
202 virtual void visit(ir_dereference_record *);
203 virtual void visit(ir_assignment *);
204 virtual void visit(ir_constant *);
205 virtual void visit(ir_call *);
206 virtual void visit(ir_return *);
207 virtual void visit(ir_discard *);
208 virtual void visit(ir_texture *);
209 virtual void visit(ir_if *);
210 /*@}*/
211
212 struct ir_to_mesa_src_reg result;
213
214 /** List of variable_storage */
215 exec_list variables;
216
217 /** List of function_entry */
218 exec_list function_signatures;
219 int next_signature_id;
220
221 /** List of ir_to_mesa_instruction */
222 exec_list instructions;
223
224 ir_to_mesa_instruction *ir_to_mesa_emit_op0(ir_instruction *ir,
225 enum prog_opcode op);
226
227 ir_to_mesa_instruction *ir_to_mesa_emit_op1(ir_instruction *ir,
228 enum prog_opcode op,
229 ir_to_mesa_dst_reg dst,
230 ir_to_mesa_src_reg src0);
231
232 ir_to_mesa_instruction *ir_to_mesa_emit_op2(ir_instruction *ir,
233 enum prog_opcode op,
234 ir_to_mesa_dst_reg dst,
235 ir_to_mesa_src_reg src0,
236 ir_to_mesa_src_reg src1);
237
238 ir_to_mesa_instruction *ir_to_mesa_emit_op3(ir_instruction *ir,
239 enum prog_opcode op,
240 ir_to_mesa_dst_reg dst,
241 ir_to_mesa_src_reg src0,
242 ir_to_mesa_src_reg src1,
243 ir_to_mesa_src_reg src2);
244
245 void ir_to_mesa_emit_scalar_op1(ir_instruction *ir,
246 enum prog_opcode op,
247 ir_to_mesa_dst_reg dst,
248 ir_to_mesa_src_reg src0);
249
250 void ir_to_mesa_emit_scalar_op2(ir_instruction *ir,
251 enum prog_opcode op,
252 ir_to_mesa_dst_reg dst,
253 ir_to_mesa_src_reg src0,
254 ir_to_mesa_src_reg src1);
255
256 GLboolean try_emit_mad(ir_expression *ir,
257 int mul_operand);
258
259 int add_uniform(const char *name,
260 const glsl_type *type,
261 ir_constant *constant);
262 void add_aggregate_uniform(ir_instruction *ir,
263 const char *name,
264 const struct glsl_type *type,
265 ir_constant *constant,
266 struct ir_to_mesa_dst_reg temp);
267
268 struct hash_table *sampler_map;
269
270 void set_sampler_location(ir_variable *sampler, int location);
271 int get_sampler_location(ir_variable *sampler);
272
273 void *mem_ctx;
274};
275
276ir_to_mesa_src_reg ir_to_mesa_undef = ir_to_mesa_src_reg(PROGRAM_UNDEFINED, 0, NULL);
277
278ir_to_mesa_dst_reg ir_to_mesa_undef_dst = {
279 PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, COND_TR, NULL,
280};
281
282ir_to_mesa_dst_reg ir_to_mesa_address_reg = {
283 PROGRAM_ADDRESS, 0, WRITEMASK_X, COND_TR, NULL
284};
285
286static int swizzle_for_size(int size)
287{
288 int size_swizzles[4] = {
289 MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
290 MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
291 MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z),
292 MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W),
293 };
294
295 return size_swizzles[size - 1];
296}
297
298ir_to_mesa_instruction *
299ir_to_mesa_visitor::ir_to_mesa_emit_op3(ir_instruction *ir,
300 enum prog_opcode op,
301 ir_to_mesa_dst_reg dst,
302 ir_to_mesa_src_reg src0,
303 ir_to_mesa_src_reg src1,
304 ir_to_mesa_src_reg src2)
305{
306 ir_to_mesa_instruction *inst = new(mem_ctx) ir_to_mesa_instruction();
307 int num_reladdr = 0;
308
309 /* If we have to do relative addressing, we want to load the ARL
310 * reg directly for one of the regs, and preload the other reladdr
311 * sources into temps.
312 */
313 num_reladdr += dst.reladdr != NULL;
314 num_reladdr += src0.reladdr != NULL;
315 num_reladdr += src1.reladdr != NULL;
316 num_reladdr += src2.reladdr != NULL;
317
318 reladdr_to_temp(ir, &src2, &num_reladdr);
319 reladdr_to_temp(ir, &src1, &num_reladdr);
320 reladdr_to_temp(ir, &src0, &num_reladdr);
321
322 if (dst.reladdr) {
323 ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg,
324 *dst.reladdr);
325
326 num_reladdr--;
327 }
328 assert(num_reladdr == 0);
329
330 inst->op = op;
331 inst->dst_reg = dst;
332 inst->src_reg[0] = src0;
333 inst->src_reg[1] = src1;
334 inst->src_reg[2] = src2;
335 inst->ir = ir;
336
337 inst->function = NULL;
338
339 this->instructions.push_tail(inst);
340
341 return inst;
342}
343
344
345ir_to_mesa_instruction *
346ir_to_mesa_visitor::ir_to_mesa_emit_op2(ir_instruction *ir,
347 enum prog_opcode op,
348 ir_to_mesa_dst_reg dst,
349 ir_to_mesa_src_reg src0,
350 ir_to_mesa_src_reg src1)
351{
352 return ir_to_mesa_emit_op3(ir, op, dst, src0, src1, ir_to_mesa_undef);
353}
354
355ir_to_mesa_instruction *
356ir_to_mesa_visitor::ir_to_mesa_emit_op1(ir_instruction *ir,
357 enum prog_opcode op,
358 ir_to_mesa_dst_reg dst,
359 ir_to_mesa_src_reg src0)
360{
361 assert(dst.writemask != 0);
362 return ir_to_mesa_emit_op3(ir, op, dst,
363 src0, ir_to_mesa_undef, ir_to_mesa_undef);
364}
365
366ir_to_mesa_instruction *
367ir_to_mesa_visitor::ir_to_mesa_emit_op0(ir_instruction *ir,
368 enum prog_opcode op)
369{
370 return ir_to_mesa_emit_op3(ir, op, ir_to_mesa_undef_dst,
371 ir_to_mesa_undef,
372 ir_to_mesa_undef,
373 ir_to_mesa_undef);
374}
375
376void
377ir_to_mesa_visitor::set_sampler_location(ir_variable *sampler, int location)
378{
379 if (this->sampler_map == NULL) {
380 this->sampler_map = hash_table_ctor(0, hash_table_pointer_hash,
381 hash_table_pointer_compare);
382 }
383
384 hash_table_insert(this->sampler_map, (void *)(uintptr_t)location, sampler);
385}
386
387int
388ir_to_mesa_visitor::get_sampler_location(ir_variable *sampler)
389{
390 void *result = hash_table_find(this->sampler_map, sampler);
391
392 return (int)(uintptr_t)result;
393}
394
395inline ir_to_mesa_dst_reg
396ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg)
397{
398 ir_to_mesa_dst_reg dst_reg;
399
400 dst_reg.file = reg.file;
401 dst_reg.index = reg.index;
402 dst_reg.writemask = WRITEMASK_XYZW;
403 dst_reg.cond_mask = COND_TR;
404 dst_reg.reladdr = reg.reladdr;
405
406 return dst_reg;
407}
408
409inline ir_to_mesa_src_reg
410ir_to_mesa_src_reg_from_dst(ir_to_mesa_dst_reg reg)
411{
412 return ir_to_mesa_src_reg(reg.file, reg.index, NULL);
413}
414
415/**
416 * Emits Mesa scalar opcodes to produce unique answers across channels.
417 *
418 * Some Mesa opcodes are scalar-only, like ARB_fp/vp. The src X
419 * channel determines the result across all channels. So to do a vec4
420 * of this operation, we want to emit a scalar per source channel used
421 * to produce dest channels.
422 */
423void
424ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op2(ir_instruction *ir,
425 enum prog_opcode op,
426 ir_to_mesa_dst_reg dst,
427 ir_to_mesa_src_reg orig_src0,
428 ir_to_mesa_src_reg orig_src1)
429{
430 int i, j;
431 int done_mask = ~dst.writemask;
432
433 /* Mesa RCP is a scalar operation splatting results to all channels,
434 * like ARB_fp/vp. So emit as many RCPs as necessary to cover our
435 * dst channels.
436 */
437 for (i = 0; i < 4; i++) {
438 GLuint this_mask = (1 << i);
439 ir_to_mesa_instruction *inst;
440 ir_to_mesa_src_reg src0 = orig_src0;
441 ir_to_mesa_src_reg src1 = orig_src1;
442
443 if (done_mask & this_mask)
444 continue;
445
446 GLuint src0_swiz = GET_SWZ(src0.swizzle, i);
447 GLuint src1_swiz = GET_SWZ(src1.swizzle, i);
448 for (j = i + 1; j < 4; j++) {
449 if (!(done_mask & (1 << j)) &&
450 GET_SWZ(src0.swizzle, j) == src0_swiz &&
451 GET_SWZ(src1.swizzle, j) == src1_swiz) {
452 this_mask |= (1 << j);
453 }
454 }
455 src0.swizzle = MAKE_SWIZZLE4(src0_swiz, src0_swiz,
456 src0_swiz, src0_swiz);
457 src1.swizzle = MAKE_SWIZZLE4(src1_swiz, src1_swiz,
458 src1_swiz, src1_swiz);
459
460 inst = ir_to_mesa_emit_op2(ir, op,
461 dst,
462 src0,
463 src1);
464 inst->dst_reg.writemask = this_mask;
465 done_mask |= this_mask;
466 }
467}
468
469void
470ir_to_mesa_visitor::ir_to_mesa_emit_scalar_op1(ir_instruction *ir,
471 enum prog_opcode op,
472 ir_to_mesa_dst_reg dst,
473 ir_to_mesa_src_reg src0)
474{
475 ir_to_mesa_src_reg undef = ir_to_mesa_undef;
476
477 undef.swizzle = SWIZZLE_XXXX;
478
479 ir_to_mesa_emit_scalar_op2(ir, op, dst, src0, undef);
480}
481
482struct ir_to_mesa_src_reg
483ir_to_mesa_visitor::src_reg_for_float(float val)
484{
485 ir_to_mesa_src_reg src_reg(PROGRAM_CONSTANT, -1, NULL);
486
487 src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters,
488 &val, 1, &src_reg.swizzle);
489
490 return src_reg;
491}
492
493static int
494type_size(const struct glsl_type *type)
495{
496 unsigned int i;
497 int size;
498
499 switch (type->base_type) {
500 case GLSL_TYPE_UINT:
501 case GLSL_TYPE_INT:
502 case GLSL_TYPE_FLOAT:
503 case GLSL_TYPE_BOOL:
504 if (type->is_matrix()) {
505 return type->matrix_columns;
506 } else {
507 /* Regardless of size of vector, it gets a vec4. This is bad
508 * packing for things like floats, but otherwise arrays become a
509 * mess. Hopefully a later pass over the code can pack scalars
510 * down if appropriate.
511 */
512 return 1;
513 }
514 case GLSL_TYPE_ARRAY:
515 return type_size(type->fields.array) * type->length;
516 case GLSL_TYPE_STRUCT:
517 size = 0;
518 for (i = 0; i < type->length; i++) {
519 size += type_size(type->fields.structure[i].type);
520 }
521 return size;
522 case GLSL_TYPE_SAMPLER:
523 /* Samplers take up no register space, since they're baked in at
524 * link time.
525 */
526 return 0;
527 default:
528 assert(0);
529 return 0;
530 }
531}
532
533/**
534 * In the initial pass of codegen, we assign temporary numbers to
535 * intermediate results. (not SSA -- variable assignments will reuse
536 * storage). Actual register allocation for the Mesa VM occurs in a
537 * pass over the Mesa IR later.
538 */
539ir_to_mesa_src_reg
540ir_to_mesa_visitor::get_temp(const glsl_type *type)
541{
542 ir_to_mesa_src_reg src_reg;
543 int swizzle[4];
544 int i;
545
546 src_reg.file = PROGRAM_TEMPORARY;
547 src_reg.index = next_temp;
548 src_reg.reladdr = NULL;
549 next_temp += type_size(type);
550
551 if (type->is_array() || type->is_record()) {
552 src_reg.swizzle = SWIZZLE_NOOP;
553 } else {
554 for (i = 0; i < type->vector_elements; i++)
555 swizzle[i] = i;
556 for (; i < 4; i++)
557 swizzle[i] = type->vector_elements - 1;
558 src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0], swizzle[1],
559 swizzle[2], swizzle[3]);
560 }
561 src_reg.negate = 0;
562
563 return src_reg;
564}
565
566variable_storage *
567ir_to_mesa_visitor::find_variable_storage(ir_variable *var)
568{
569
570 variable_storage *entry;
571
572 foreach_iter(exec_list_iterator, iter, this->variables) {
573 entry = (variable_storage *)iter.get();
574
575 if (entry->var == var)
576 return entry;
577 }
578
579 return NULL;
580}
581
582void
583ir_to_mesa_visitor::visit(ir_variable *ir)
584{
585 if (strcmp(ir->name, "gl_FragCoord") == 0) {
586 struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
587
588 fp->OriginUpperLeft = ir->origin_upper_left;
589 fp->PixelCenterInteger = ir->pixel_center_integer;
590 }
591}
592
593void
594ir_to_mesa_visitor::visit(ir_loop *ir)
595{
596 assert(!ir->from);
597 assert(!ir->to);
598 assert(!ir->increment);
599 assert(!ir->counter);
600
601 ir_to_mesa_emit_op0(NULL, OPCODE_BGNLOOP);
602 visit_exec_list(&ir->body_instructions, this);
603 ir_to_mesa_emit_op0(NULL, OPCODE_ENDLOOP);
604}
605
606void
607ir_to_mesa_visitor::visit(ir_loop_jump *ir)
608{
609 switch (ir->mode) {
610 case ir_loop_jump::jump_break:
611 ir_to_mesa_emit_op0(NULL, OPCODE_BRK);
612 break;
613 case ir_loop_jump::jump_continue:
614 ir_to_mesa_emit_op0(NULL, OPCODE_CONT);
615 break;
616 }
617}
618
619
620void
621ir_to_mesa_visitor::visit(ir_function_signature *ir)
622{
623 assert(0);
624 (void)ir;
625}
626
627void
628ir_to_mesa_visitor::visit(ir_function *ir)
629{
630 /* Ignore function bodies other than main() -- we shouldn't see calls to
631 * them since they should all be inlined before we get to ir_to_mesa.
632 */
633 if (strcmp(ir->name, "main") == 0) {
634 const ir_function_signature *sig;
635 exec_list empty;
636
637 sig = ir->matching_signature(&empty);
638
639 assert(sig);
640
641 foreach_iter(exec_list_iterator, iter, sig->body) {
642 ir_instruction *ir = (ir_instruction *)iter.get();
643
644 ir->accept(this);
645 }
646 }
647}
648
649GLboolean
650ir_to_mesa_visitor::try_emit_mad(ir_expression *ir, int mul_operand)
651{
652 int nonmul_operand = 1 - mul_operand;
653 ir_to_mesa_src_reg a, b, c;
654
655 ir_expression *expr = ir->operands[mul_operand]->as_expression();
656 if (!expr || expr->operation != ir_binop_mul)
657 return false;
658
659 expr->operands[0]->accept(this);
660 a = this->result;
661 expr->operands[1]->accept(this);
662 b = this->result;
663 ir->operands[nonmul_operand]->accept(this);
664 c = this->result;
665
666 this->result = get_temp(ir->type);
667 ir_to_mesa_emit_op3(ir, OPCODE_MAD,
668 ir_to_mesa_dst_reg_from_src(this->result), a, b, c);
669
670 return true;
671}
672
673void
674ir_to_mesa_visitor::reladdr_to_temp(ir_instruction *ir,
675 ir_to_mesa_src_reg *reg, int *num_reladdr)
676{
677 if (!reg->reladdr)
678 return;
679
680 ir_to_mesa_emit_op1(ir, OPCODE_ARL, ir_to_mesa_address_reg, *reg->reladdr);
681
682 if (*num_reladdr != 1) {
683 ir_to_mesa_src_reg temp = get_temp(glsl_type::vec4_type);
684
685 ir_to_mesa_emit_op1(ir, OPCODE_MOV,
686 ir_to_mesa_dst_reg_from_src(temp), *reg);
687 *reg = temp;
688 }
689
690 (*num_reladdr)--;
691}
692
693void
694ir_to_mesa_visitor::visit(ir_expression *ir)
695{
696 unsigned int operand;
697 struct ir_to_mesa_src_reg op[2];
698 struct ir_to_mesa_src_reg result_src;
699 struct ir_to_mesa_dst_reg result_dst;
700 const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1);
701 const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1);
702 const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1);
703
704 /* Quick peephole: Emit OPCODE_MAD(a, b, c) instead of ADD(MUL(a, b), c)
705 */
706 if (ir->operation == ir_binop_add) {
707 if (try_emit_mad(ir, 1))
708 return;
709 if (try_emit_mad(ir, 0))
710 return;
711 }
712
713 for (operand = 0; operand < ir->get_num_operands(); operand++) {
714 this->result.file = PROGRAM_UNDEFINED;
715 ir->operands[operand]->accept(this);
716 if (this->result.file == PROGRAM_UNDEFINED) {
717 ir_print_visitor v;
718 printf("Failed to get tree for expression operand:\n");
719 ir->operands[operand]->accept(&v);
720 exit(1);
721 }
722 op[operand] = this->result;
723
724 /* Matrix expression operands should have been broken down to vector
725 * operations already.
726 */
727 assert(!ir->operands[operand]->type->is_matrix());
728 }
729
730 this->result.file = PROGRAM_UNDEFINED;
731
732 /* Storage for our result. Ideally for an assignment we'd be using
733 * the actual storage for the result here, instead.
734 */
735 result_src = get_temp(ir->type);
736 /* convenience for the emit functions below. */
737 result_dst = ir_to_mesa_dst_reg_from_src(result_src);
738 /* Limit writes to the channels that will be used by result_src later.
739 * This does limit this temp's use as a temporary for multi-instruction
740 * sequences.
741 */
742 result_dst.writemask = (1 << ir->type->vector_elements) - 1;
743
744 switch (ir->operation) {
745 case ir_unop_logic_not:
746 ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst,
747 op[0], src_reg_for_float(0.0));
748 break;
749 case ir_unop_neg:
750 op[0].negate = ~op[0].negate;
751 result_src = op[0];
752 break;
753 case ir_unop_abs:
754 ir_to_mesa_emit_op1(ir, OPCODE_ABS, result_dst, op[0]);
755 break;
756 case ir_unop_sign:
757 ir_to_mesa_emit_op1(ir, OPCODE_SSG, result_dst, op[0]);
758 break;
759 case ir_unop_rcp:
760 ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, op[0]);
761 break;
762
763 case ir_unop_exp2:
764 ir_to_mesa_emit_scalar_op1(ir, OPCODE_EX2, result_dst, op[0]);
765 break;
766 case ir_unop_exp:
767 case ir_unop_log:
768 assert(!"not reached: should be handled by ir_explog_to_explog2");
769 break;
770 case ir_unop_log2:
771 ir_to_mesa_emit_scalar_op1(ir, OPCODE_LG2, result_dst, op[0]);
772 break;
773 case ir_unop_sin:
774 ir_to_mesa_emit_scalar_op1(ir, OPCODE_SIN, result_dst, op[0]);
775 break;
776 case ir_unop_cos:
777 ir_to_mesa_emit_scalar_op1(ir, OPCODE_COS, result_dst, op[0]);
778 break;
779
780 case ir_unop_dFdx:
781 ir_to_mesa_emit_op1(ir, OPCODE_DDX, result_dst, op[0]);
782 break;
783 case ir_unop_dFdy:
784 ir_to_mesa_emit_op1(ir, OPCODE_DDY, result_dst, op[0]);
785 break;
786
787 case ir_binop_add:
788 ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]);
789 break;
790 case ir_binop_sub:
791 ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]);
792 break;
793
794 case ir_binop_mul:
795 ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, op[0], op[1]);
796 break;
797 case ir_binop_div:
798 assert(!"not reached: should be handled by ir_div_to_mul_rcp");
799 case ir_binop_mod:
800 assert(!"ir_binop_mod should have been converted to b * fract(a/b)");
801 break;
802
803 case ir_binop_less:
804 ir_to_mesa_emit_op2(ir, OPCODE_SLT, result_dst, op[0], op[1]);
805 break;
806 case ir_binop_greater:
807 ir_to_mesa_emit_op2(ir, OPCODE_SGT, result_dst, op[0], op[1]);
808 break;
809 case ir_binop_lequal:
810 ir_to_mesa_emit_op2(ir, OPCODE_SLE, result_dst, op[0], op[1]);
811 break;
812 case ir_binop_gequal:
813 ir_to_mesa_emit_op2(ir, OPCODE_SGE, result_dst, op[0], op[1]);
814 break;
815 case ir_binop_equal:
816 ir_to_mesa_emit_op2(ir, OPCODE_SEQ, result_dst, op[0], op[1]);
817 break;
818 case ir_binop_logic_xor:
819 case ir_binop_nequal:
820 ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst, op[0], op[1]);
821 break;
822
823 case ir_binop_logic_or:
824 /* This could be a saturated add and skip the SNE. */
825 ir_to_mesa_emit_op2(ir, OPCODE_ADD,
826 result_dst,
827 op[0], op[1]);
828
829 ir_to_mesa_emit_op2(ir, OPCODE_SNE,
830 result_dst,
831 result_src, src_reg_for_float(0.0));
832 break;
833
834 case ir_binop_logic_and:
835 /* the bool args are stored as float 0.0 or 1.0, so "mul" gives us "and". */
836 ir_to_mesa_emit_op2(ir, OPCODE_MUL,
837 result_dst,
838 op[0], op[1]);
839 break;
840
841 case ir_binop_dot:
842 if (ir->operands[0]->type == vec4_type) {
843 assert(ir->operands[1]->type == vec4_type);
844 ir_to_mesa_emit_op2(ir, OPCODE_DP4,
845 result_dst,
846 op[0], op[1]);
847 } else if (ir->operands[0]->type == vec3_type) {
848 assert(ir->operands[1]->type == vec3_type);
849 ir_to_mesa_emit_op2(ir, OPCODE_DP3,
850 result_dst,
851 op[0], op[1]);
852 } else if (ir->operands[0]->type == vec2_type) {
853 assert(ir->operands[1]->type == vec2_type);
854 ir_to_mesa_emit_op2(ir, OPCODE_DP2,
855 result_dst,
856 op[0], op[1]);
857 }
858 break;
859
860 case ir_binop_cross:
861 ir_to_mesa_emit_op2(ir, OPCODE_XPD, result_dst, op[0], op[1]);
862 break;
863
864 case ir_unop_sqrt:
865 ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);
866 ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, result_src);
867 /* For incoming channels < 0, set the result to 0. */
868 ir_to_mesa_emit_op3(ir, OPCODE_CMP, result_dst,
869 op[0], src_reg_for_float(0.0), result_src);
870 break;
871 case ir_unop_rsq:
872 ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);
873 break;
874 case ir_unop_i2f:
875 case ir_unop_b2f:
876 case ir_unop_b2i:
877 /* Mesa IR lacks types, ints are stored as truncated floats. */
878 result_src = op[0];
879 break;
880 case ir_unop_f2i:
881 ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]);
882 break;
883 case ir_unop_f2b:
884 case ir_unop_i2b:
885 ir_to_mesa_emit_op2(ir, OPCODE_SNE, result_dst,
886 result_src, src_reg_for_float(0.0));
887 break;
888 case ir_unop_trunc:
889 ir_to_mesa_emit_op1(ir, OPCODE_TRUNC, result_dst, op[0]);
890 break;
891 case ir_unop_ceil:
892 op[0].negate = ~op[0].negate;
893 ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]);
894 result_src.negate = ~result_src.negate;
895 break;
896 case ir_unop_floor:
897 ir_to_mesa_emit_op1(ir, OPCODE_FLR, result_dst, op[0]);
898 break;
899 case ir_unop_fract:
900 ir_to_mesa_emit_op1(ir, OPCODE_FRC, result_dst, op[0]);
901 break;
902
903 case ir_binop_min:
904 ir_to_mesa_emit_op2(ir, OPCODE_MIN, result_dst, op[0], op[1]);
905 break;
906 case ir_binop_max:
907 ir_to_mesa_emit_op2(ir, OPCODE_MAX, result_dst, op[0], op[1]);
908 break;
909 case ir_binop_pow:
910 ir_to_mesa_emit_scalar_op2(ir, OPCODE_POW, result_dst, op[0], op[1]);
911 break;
912
913 case ir_unop_bit_not:
914 case ir_unop_u2f:
915 case ir_binop_lshift:
916 case ir_binop_rshift:
917 case ir_binop_bit_and:
918 case ir_binop_bit_xor:
919 case ir_binop_bit_or:
920 assert(!"GLSL 1.30 features unsupported");
921 break;
922 }
923
924 this->result = result_src;
925}
926
927
928void
929ir_to_mesa_visitor::visit(ir_swizzle *ir)
930{
931 ir_to_mesa_src_reg src_reg;
932 int i;
933 int swizzle[4];
934
935 /* Note that this is only swizzles in expressions, not those on the left
936 * hand side of an assignment, which do write masking. See ir_assignment
937 * for that.
938 */
939
940 ir->val->accept(this);
941 src_reg = this->result;
942 assert(src_reg.file != PROGRAM_UNDEFINED);
943
944 for (i = 0; i < 4; i++) {
945 if (i < ir->type->vector_elements) {
946 switch (i) {
947 case 0:
948 swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.x);
949 break;
950 case 1:
951 swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.y);
952 break;
953 case 2:
954 swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.z);
955 break;
956 case 3:
957 swizzle[i] = GET_SWZ(src_reg.swizzle, ir->mask.w);
958 break;
959 }
960 } else {
961 /* If the type is smaller than a vec4, replicate the last
962 * channel out.
963 */
964 swizzle[i] = swizzle[ir->type->vector_elements - 1];
965 }
966 }
967
968 src_reg.swizzle = MAKE_SWIZZLE4(swizzle[0],
969 swizzle[1],
970 swizzle[2],
971 swizzle[3]);
972
973 this->result = src_reg;
974}
975
976static const struct {
977 const char *name;
978 const char *field;
979 int tokens[STATE_LENGTH];
980 int swizzle;
981 bool array_indexed;
982} statevars[] = {
983 {"gl_DepthRange", "near",
984 {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX, false},
985 {"gl_DepthRange", "far",
986 {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY, false},
987 {"gl_DepthRange", "diff",
988 {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_ZZZZ, false},
989
990 {"gl_ClipPlane", NULL,
991 {STATE_CLIPPLANE, 0, 0}, SWIZZLE_XYZW, true}
992,
993 {"gl_Point", "size",
994 {STATE_POINT_SIZE}, SWIZZLE_XXXX, false},
995 {"gl_Point", "sizeMin",
996 {STATE_POINT_SIZE}, SWIZZLE_YYYY, false},
997 {"gl_Point", "sizeMax",
998 {STATE_POINT_SIZE}, SWIZZLE_ZZZZ, false},
999 {"gl_Point", "fadeThresholdSize",
1000 {STATE_POINT_SIZE}, SWIZZLE_WWWW, false},
1001 {"gl_Point", "distanceConstantAttenuation",
1002 {STATE_POINT_ATTENUATION}, SWIZZLE_XXXX, false},
1003 {"gl_Point", "distanceLinearAttenuation",
1004 {STATE_POINT_ATTENUATION}, SWIZZLE_YYYY, false},
1005 {"gl_Point", "distanceQuadraticAttenuation",
1006 {STATE_POINT_ATTENUATION}, SWIZZLE_ZZZZ, false},
1007
1008 {"gl_FrontMaterial", "emission",
1009 {STATE_MATERIAL, 0, STATE_EMISSION}, SWIZZLE_XYZW, false},
1010 {"gl_FrontMaterial", "ambient",
1011 {STATE_MATERIAL, 0, STATE_AMBIENT}, SWIZZLE_XYZW, false},
1012 {"gl_FrontMaterial", "diffuse",
1013 {STATE_MATERIAL, 0, STATE_DIFFUSE}, SWIZZLE_XYZW, false},
1014 {"gl_FrontMaterial", "specular",
1015 {STATE_MATERIAL, 0, STATE_SPECULAR}, SWIZZLE_XYZW, false},
1016 {"gl_FrontMaterial", "shininess",
1017 {STATE_MATERIAL, 0, STATE_SHININESS}, SWIZZLE_XXXX, false},
1018
1019 {"gl_BackMaterial", "emission",
1020 {STATE_MATERIAL, 1, STATE_EMISSION}, SWIZZLE_XYZW, false},
1021 {"gl_BackMaterial", "ambient",
1022 {STATE_MATERIAL, 1, STATE_AMBIENT}, SWIZZLE_XYZW, false},
1023 {"gl_BackMaterial", "diffuse",
1024 {STATE_MATERIAL, 1, STATE_DIFFUSE}, SWIZZLE_XYZW, false},
1025 {"gl_BackMaterial", "specular",
1026 {STATE_MATERIAL, 1, STATE_SPECULAR}, SWIZZLE_XYZW, false},
1027 {"gl_BackMaterial", "shininess",
1028 {STATE_MATERIAL, 1, STATE_SHININESS}, SWIZZLE_XXXX, false},
1029
1030 {"gl_LightSource", "ambient",
1031 {STATE_LIGHT, 0, STATE_AMBIENT}, SWIZZLE_XYZW, true},
1032 {"gl_LightSource", "diffuse",
1033 {STATE_LIGHT, 0, STATE_DIFFUSE}, SWIZZLE_XYZW, true},
1034 {"gl_LightSource", "specular",
1035 {STATE_LIGHT, 0, STATE_SPECULAR}, SWIZZLE_XYZW, true},
1036 {"gl_LightSource", "position",
1037 {STATE_LIGHT, 0, STATE_POSITION}, SWIZZLE_XYZW, true},
1038 {"gl_LightSource", "halfVector",
1039 {STATE_LIGHT, 0, STATE_HALF_VECTOR}, SWIZZLE_XYZW, true},
1040 {"gl_LightSource", "spotDirection",
1041 {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_XYZW, true},
1042 {"gl_LightSource", "spotCosCutoff",
1043 {STATE_LIGHT, 0, STATE_SPOT_DIRECTION}, SWIZZLE_WWWW, true},
1044 {"gl_LightSource", "spotCutoff",
1045 {STATE_LIGHT, 0, STATE_SPOT_CUTOFF}, SWIZZLE_XXXX, true},
1046 {"gl_LightSource", "spotExponent",
1047 {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_WWWW, true},
1048 {"gl_LightSource", "constantAttenuation",
1049 {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_XXXX, true},
1050 {"gl_LightSource", "linearAttenuation",
1051 {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_YYYY, true},
1052 {"gl_LightSource", "quadraticAttenuation",
1053 {STATE_LIGHT, 0, STATE_ATTENUATION}, SWIZZLE_ZZZZ, true},
1054
1055 {"gl_LightModel", NULL,
1056 {STATE_LIGHTMODEL_AMBIENT, 0}, SWIZZLE_XYZW, false},
1057
1058 {"gl_FrontLightModelProduct", NULL,
1059 {STATE_LIGHTMODEL_SCENECOLOR, 0}, SWIZZLE_XYZW, false},
1060 {"gl_BackLightModelProduct", NULL,
1061 {STATE_LIGHTMODEL_SCENECOLOR, 1}, SWIZZLE_XYZW, false},
1062
1063 {"gl_FrontLightProduct", "ambient",
1064 {STATE_LIGHTPROD, 0, 0, STATE_AMBIENT}, SWIZZLE_XYZW, true},
1065 {"gl_FrontLightProduct", "diffuse",
1066 {STATE_LIGHTPROD, 0, 0, STATE_DIFFUSE}, SWIZZLE_XYZW, true},
1067 {"gl_FrontLightProduct", "specular",
1068 {STATE_LIGHTPROD, 0, 0, STATE_SPECULAR}, SWIZZLE_XYZW, true},
1069
1070 {"gl_BackLightProduct", "ambient",
1071 {STATE_LIGHTPROD, 0, 1, STATE_AMBIENT}, SWIZZLE_XYZW, true},
1072 {"gl_BackLightProduct", "diffuse",
1073 {STATE_LIGHTPROD, 0, 1, STATE_DIFFUSE}, SWIZZLE_XYZW, true},
1074 {"gl_BackLightProduct", "specular",
1075 {STATE_LIGHTPROD, 0, 1, STATE_SPECULAR}, SWIZZLE_XYZW, true},
1076
1077 {"gl_TextureEnvColor", "ambient",
1078 {STATE_TEXENV_COLOR, 0}, SWIZZLE_XYZW, true},
1079
1080 {"gl_EyePlaneS", NULL,
1081 {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_S}, SWIZZLE_XYZW, true},
1082 {"gl_EyePlaneT", NULL,
1083 {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_T}, SWIZZLE_XYZW, true},
1084 {"gl_EyePlaneR", NULL,
1085 {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_R}, SWIZZLE_XYZW, true},
1086 {"gl_EyePlaneQ", NULL,
1087 {STATE_TEXGEN, 0, STATE_TEXGEN_EYE_Q}, SWIZZLE_XYZW, true},
1088
1089 {"gl_ObjectPlaneS", NULL,
1090 {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_S}, SWIZZLE_XYZW, true},
1091 {"gl_ObjectPlaneT", NULL,
1092 {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_T}, SWIZZLE_XYZW, true},
1093 {"gl_ObjectPlaneR", NULL,
1094 {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_R}, SWIZZLE_XYZW, true},
1095 {"gl_ObjectPlaneQ", NULL,
1096 {STATE_TEXGEN, 0, STATE_TEXGEN_OBJECT_Q}, SWIZZLE_XYZW, true},
1097
1098 {"gl_Fog", "color",
1099 {STATE_FOG_COLOR}, SWIZZLE_XYZW, false},
1100 {"gl_Fog", "density",
1101 {STATE_FOG_PARAMS}, SWIZZLE_XXXX, false},
1102 {"gl_Fog", "start",
1103 {STATE_FOG_PARAMS}, SWIZZLE_YYYY, false},
1104 {"gl_Fog", "end",
1105 {STATE_FOG_PARAMS}, SWIZZLE_ZZZZ, false},
1106 {"gl_Fog", "scale",
1107 {STATE_FOG_PARAMS}, SWIZZLE_WWWW, false},
1108};
1109
1110static ir_to_mesa_src_reg
1111get_builtin_uniform_reg(struct gl_program *prog,
1112 const char *name, int array_index, const char *field)
1113{
1114 unsigned int i;
1115 ir_to_mesa_src_reg src_reg;
1116 int tokens[STATE_LENGTH];
1117
1118 for (i = 0; i < Elements(statevars); i++) {
1119 if (strcmp(statevars[i].name, name) != 0)
1120 continue;
1121 if (!field && statevars[i].field) {
1122 assert(!"FINISHME: whole-structure state var dereference");
1123 }
1124 if (field && strcmp(statevars[i].field, field) != 0)
1125 continue;
1126 break;
1127 }
1128
1129 if (i == Elements(statevars)) {
1130 printf("builtin uniform %s%s%s not found\n",
1131 name,
1132 field ? "." : "",
1133 field ? field : "");
1134 abort();
1135 }
1136
1137 memcpy(&tokens, statevars[i].tokens, sizeof(tokens));
1138 if (statevars[i].array_indexed)
1139 tokens[1] = array_index;
1140
1141 src_reg.file = PROGRAM_STATE_VAR;
1142 src_reg.index = _mesa_add_state_reference(prog->Parameters,
1143 (gl_state_index *)tokens);
1144 src_reg.swizzle = statevars[i].swizzle;
1145 src_reg.negate = 0;
1146 src_reg.reladdr = false;
1147
1148 return src_reg;
1149}
1150
1151static int
1152add_matrix_ref(struct gl_program *prog, int *tokens)
1153{
1154 int base_pos = -1;
1155 int i;
1156
1157 /* Add a ref for each column. It looks like the reason we do
1158 * it this way is that _mesa_add_state_reference doesn't work
1159 * for things that aren't vec4s, so the tokens[2]/tokens[3]
1160 * range has to be equal.
1161 */
1162 for (i = 0; i < 4; i++) {
1163 tokens[2] = i;
1164 tokens[3] = i;
1165 int pos = _mesa_add_state_reference(prog->Parameters,
1166 (gl_state_index *)tokens);
1167 if (base_pos == -1)
1168 base_pos = pos;
1169 else
1170 assert(base_pos + i == pos);
1171 }
1172
1173 return base_pos;
1174}
1175
1176static variable_storage *
1177get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var,
1178 ir_rvalue *array_index)
1179{
1180 /*
1181 * NOTE: The ARB_vertex_program extension specified that matrices get
1182 * loaded in registers in row-major order. With GLSL, we want column-
1183 * major order. So, we need to transpose all matrices here...
1184 */
1185 static const struct {
1186 const char *name;
1187 int matrix;
1188 int modifier;
1189 } matrices[] = {
1190 { "gl_ModelViewMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE },
1191 { "gl_ModelViewMatrixInverse", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVTRANS },
1192 { "gl_ModelViewMatrixTranspose", STATE_MODELVIEW_MATRIX, 0 },
1193 { "gl_ModelViewMatrixInverseTranspose", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE },
1194
1195 { "gl_ProjectionMatrix", STATE_PROJECTION_MATRIX, STATE_MATRIX_TRANSPOSE },
1196 { "gl_ProjectionMatrixInverse", STATE_PROJECTION_MATRIX, STATE_MATRIX_INVTRANS },
1197 { "gl_ProjectionMatrixTranspose", STATE_PROJECTION_MATRIX, 0 },
1198 { "gl_ProjectionMatrixInverseTranspose", STATE_PROJECTION_MATRIX, STATE_MATRIX_INVERSE },
1199
1200 { "gl_ModelViewProjectionMatrix", STATE_MVP_MATRIX, STATE_MATRIX_TRANSPOSE },
1201 { "gl_ModelViewProjectionMatrixInverse", STATE_MVP_MATRIX, STATE_MATRIX_INVTRANS },
1202 { "gl_ModelViewProjectionMatrixTranspose", STATE_MVP_MATRIX, 0 },
1203 { "gl_ModelViewProjectionMatrixInverseTranspose", STATE_MVP_MATRIX, STATE_MATRIX_INVERSE },
1204
1205 { "gl_TextureMatrix", STATE_TEXTURE_MATRIX, STATE_MATRIX_TRANSPOSE },
1206 { "gl_TextureMatrixInverse", STATE_TEXTURE_MATRIX, STATE_MATRIX_INVTRANS },
1207 { "gl_TextureMatrixTranspose", STATE_TEXTURE_MATRIX, 0 },
1208 { "gl_TextureMatrixInverseTranspose", STATE_TEXTURE_MATRIX, STATE_MATRIX_INVERSE },
1209
1210 { "gl_NormalMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE },
1211
1212 };
1213 unsigned int i;
1214 variable_storage *entry;
1215
1216 /* C++ gets angry when we try to use an int as a gl_state_index, so we use
1217 * ints for gl_state_index. Make sure they're compatible.
1218 */
1219 assert(sizeof(gl_state_index) == sizeof(int));
1220
1221 for (i = 0; i < Elements(matrices); i++) {
1222 if (strcmp(var->name, matrices[i].name) == 0) {
1223 int tokens[STATE_LENGTH];
1224 int base_pos = -1;
1225
1226 tokens[0] = matrices[i].matrix;
1227 tokens[4] = matrices[i].modifier;
1228 if (matrices[i].matrix == STATE_TEXTURE_MATRIX) {
1229 ir_constant *index = array_index->constant_expression_value();
1230 if (index) {
1231 tokens[1] = index->value.i[0];
1232 base_pos = add_matrix_ref(prog, tokens);
1233 } else {
1234 for (i = 0; i < var->type->length; i++) {
1235 tokens[1] = i;
1236 int pos = add_matrix_ref(prog, tokens);
1237 if (base_pos == -1)
1238 base_pos = pos;
1239 else
1240 assert(base_pos + (int)i * 4 == pos);
1241 }
1242 }
1243 } else {
1244 tokens[1] = 0; /* unused array index */
1245 base_pos = add_matrix_ref(prog, tokens);
1246 }
1247 tokens[4] = matrices[i].modifier;
1248
1249 entry = new(mem_ctx) variable_storage(var,
1250 PROGRAM_STATE_VAR,
1251 base_pos);
1252
1253 return entry;
1254 }
1255 }
1256
1257 return NULL;
1258}
1259
1260int
1261ir_to_mesa_visitor::add_uniform(const char *name,
1262 const glsl_type *type,
1263 ir_constant *constant)
1264{
1265 int len;
1266
1267 if (type->is_vector() ||
1268 type->is_scalar()) {
1269 len = type->vector_elements;
1270 } else {
1271 len = type_size(type) * 4;
1272 }
1273
1274 float *values = NULL;
1275 if (constant && type->is_array()) {
1276 values = (float *)malloc(type->length * 4 * sizeof(float));
1277
1278 assert(type->fields.array->is_scalar() ||
1279 type->fields.array->is_vector() ||
1280 !"FINISHME: uniform array initializers for non-vector");
1281
1282 for (unsigned int i = 0; i < type->length; i++) {
1283 ir_constant *element = constant->array_elements[i];
1284 unsigned int c;
1285
1286 for (c = 0; c < type->fields.array->vector_elements; c++) {
1287 switch (type->fields.array->base_type) {
1288 case GLSL_TYPE_FLOAT:
1289 values[4 * i + c] = element->value.f[c];
1290 break;
1291 case GLSL_TYPE_INT:
1292 values[4 * i + c] = element->value.i[c];
1293 break;
1294 case GLSL_TYPE_UINT:
1295 values[4 * i + c] = element->value.u[c];
1296 break;
1297 case GLSL_TYPE_BOOL:
1298 values[4 * i + c] = element->value.b[c];
1299 break;
1300 default:
1301 assert(!"not reached");
1302 }
1303 }
1304 }
1305 } else if (constant) {
1306 values = (float *)malloc(16 * sizeof(float));
1307 for (unsigned int i = 0; i < type->components(); i++) {
1308 switch (type->base_type) {
1309 case GLSL_TYPE_FLOAT:
1310 values[i] = constant->value.f[i];
1311 break;
1312 case GLSL_TYPE_INT:
1313 values[i] = constant->value.i[i];
1314 break;
1315 case GLSL_TYPE_UINT:
1316 values[i] = constant->value.u[i];
1317 break;
1318 case GLSL_TYPE_BOOL:
1319 values[i] = constant->value.b[i];
1320 break;
1321 default:
1322 assert(!"not reached");
1323 }
1324 }
1325 }
1326
1327 int loc = _mesa_add_uniform(this->prog->Parameters,
1328 name,
1329 len,
1330 type->gl_type,
1331 values);
1332 free(values);
1333
1334 return loc;
1335}
1336
1337/* Recursively add all the members of the aggregate uniform as uniform names
1338 * to Mesa, moving those uniforms to our structured temporary.
1339 */
1340void
1341ir_to_mesa_visitor::add_aggregate_uniform(ir_instruction *ir,
1342 const char *name,
1343 const struct glsl_type *type,
1344 ir_constant *constant,
1345 struct ir_to_mesa_dst_reg temp)
1346{
1347 int loc;
1348
1349 if (type->is_record()) {
1350 void *mem_ctx = talloc_new(NULL);
1351 ir_constant *field_constant = NULL;
1352
1353 if (constant)
1354 field_constant = (ir_constant *)constant->components.get_head();
1355
1356 for (unsigned int i = 0; i < type->length; i++) {
1357 const glsl_type *field_type = type->fields.structure[i].type;
1358
1359 add_aggregate_uniform(ir,
1360 talloc_asprintf(mem_ctx, "%s.%s", name,
1361 type->fields.structure[i].name),
1362 field_type, field_constant, temp);
1363 temp.index += type_size(field_type);
1364
1365 if (constant)
1366 field_constant = (ir_constant *)field_constant->next;
1367 }
1368
1369 talloc_free(mem_ctx);
1370
1371 return;
1372 }
1373
1374 assert(type->is_vector() || type->is_scalar() || !"FINISHME: other types");
1375
1376 loc = add_uniform(name, type, constant);
1377
1378 ir_to_mesa_src_reg uniform(PROGRAM_UNIFORM, loc, type);
1379
1380 for (int i = 0; i < type_size(type); i++) {
1381 ir_to_mesa_emit_op1(ir, OPCODE_MOV, temp, uniform);
1382 temp.index++;
1383 uniform.index++;
1384 }
1385}
1386
1387
1388void
1389ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
1390{
1391 variable_storage *entry = find_variable_storage(ir->var);
1392 unsigned int loc;
1393
1394 if (!entry) {
1395 switch (ir->var->mode) {
1396 case ir_var_uniform:
1397 entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, ir->var,
1398 NULL);
1399 if (entry)
1400 break;
1401
1402 /* FINISHME: Fix up uniform name for arrays and things */
1403 if (ir->var->type->base_type == GLSL_TYPE_SAMPLER ||
1404 (ir->var->type->base_type == GLSL_TYPE_ARRAY &&
1405 ir->var->type->fields.array->base_type == GLSL_TYPE_SAMPLER)) {
1406 int array_length;
1407
1408 if (ir->var->type->base_type == GLSL_TYPE_ARRAY)
1409 array_length = ir->var->type->length;
1410 else
1411 array_length = 1;
1412 int sampler = _mesa_add_sampler(this->prog->Parameters,
1413 ir->var->name,
1414 ir->var->type->gl_type,
1415 array_length);
1416 set_sampler_location(ir->var, sampler);
1417
1418 entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_SAMPLER,
1419 sampler);
1420 this->variables.push_tail(entry);
1421 break;
1422 }
1423
1424 assert(ir->var->type->gl_type != 0 &&
1425 ir->var->type->gl_type != GL_INVALID_ENUM);
1426
1427 /* Oh, the joy of aggregate types in Mesa. Like constants,
1428 * we can only really do vec4s. So, make a temp, chop the
1429 * aggregate up into vec4s, and move those vec4s to the temp.
1430 */
1431 if (ir->var->type->is_record()) {
1432 ir_to_mesa_src_reg temp = get_temp(ir->var->type);
1433
1434 entry = new(mem_ctx) variable_storage(ir->var,
1435 temp.file,
1436 temp.index);
1437 this->variables.push_tail(entry);
1438
1439 add_aggregate_uniform(ir->var, ir->var->name, ir->var->type,
1440 ir->var->constant_value,
1441 ir_to_mesa_dst_reg_from_src(temp));
1442 break;
1443 }
1444
1445 loc = add_uniform(ir->var->name,
1446 ir->var->type,
1447 ir->var->constant_value);
1448
1449 /* Always mark the uniform used at this point. If it isn't
1450 * used, dead code elimination should have nuked the decl already.
1451 */
1452 this->prog->Parameters->Parameters[loc].Used = GL_TRUE;
1453
1454 entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_UNIFORM, loc);
1455 this->variables.push_tail(entry);
1456 break;
1457 case ir_var_in:
1458 case ir_var_out:
1459 case ir_var_inout:
1460 /* The linker assigns locations for varyings and attributes,
1461 * including deprecated builtins (like gl_Color), user-assign
1462 * generic attributes (glBindVertexLocation), and
1463 * user-defined varyings.
1464 *
1465 * FINISHME: We would hit this path for function arguments. Fix!
1466 */
1467 assert(ir->var->location != -1);
1468 if (ir->var->mode == ir_var_in ||
1469 ir->var->mode == ir_var_inout) {
1470 entry = new(mem_ctx) variable_storage(ir->var,
1471 PROGRAM_INPUT,
1472 ir->var->location);
1473
1474 if (this->prog->Target == GL_VERTEX_PROGRAM_ARB &&
1475 ir->var->location >= VERT_ATTRIB_GENERIC0) {
1476 _mesa_add_attribute(prog->Attributes,
1477 ir->var->name,
1478 _mesa_sizeof_glsl_type(ir->var->type->gl_type),
1479 ir->var->type->gl_type,
1480 ir->var->location - VERT_ATTRIB_GENERIC0);
1481 }
1482 } else {
1483 entry = new(mem_ctx) variable_storage(ir->var,
1484 PROGRAM_OUTPUT,
1485 ir->var->location);
1486 }
1487
1488 break;
1489 case ir_var_auto:
1490 case ir_var_temporary:
1491 entry = new(mem_ctx) variable_storage(ir->var, PROGRAM_TEMPORARY,
1492 this->next_temp);
1493 this->variables.push_tail(entry);
1494
1495 next_temp += type_size(ir->var->type);
1496 break;
1497 }
1498
1499 if (!entry) {
1500 printf("Failed to make storage for %s\n", ir->var->name);
1501 exit(1);
1502 }
1503 }
1504
1505 this->result = ir_to_mesa_src_reg(entry->file, entry->index, ir->var->type);
1506}
1507
1508void
1509ir_to_mesa_visitor::visit(ir_dereference_array *ir)
1510{
1511 ir_variable *var = ir->variable_referenced();
1512 ir_constant *index;
1513 ir_to_mesa_src_reg src_reg;
1514 ir_dereference_variable *deref_var = ir->array->as_dereference_variable();
1515 int element_size = type_size(ir->type);
1516
1517 index = ir->array_index->constant_expression_value();
1518
1519 if (deref_var && strncmp(deref_var->var->name,
1520 "gl_TextureMatrix",
1521 strlen("gl_TextureMatrix")) == 0) {
1522 struct variable_storage *entry;
1523
1524 entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, deref_var->var,
1525 ir->array_index);
1526 assert(entry);
1527
1528 ir_to_mesa_src_reg src_reg(entry->file, entry->index, ir->type);
1529
1530 if (index) {
1531 src_reg.reladdr = NULL;
1532 } else {
1533 ir_to_mesa_src_reg index_reg = get_temp(glsl_type::float_type);
1534
1535 ir->array_index->accept(this);
1536 ir_to_mesa_emit_op2(ir, OPCODE_MUL,
1537 ir_to_mesa_dst_reg_from_src(index_reg),
1538 this->result, src_reg_for_float(element_size));
1539
1540 src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg);
1541 memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg));
1542 }
1543
1544 this->result = src_reg;
1545 return;
1546 }
1547
1548 if (strncmp(var->name, "gl_", 3) == 0 && var->mode == ir_var_uniform &&
1549 !var->type->is_matrix()) {
1550 ir_dereference_record *record = NULL;
1551 if (ir->array->ir_type == ir_type_dereference_record)
1552 record = (ir_dereference_record *)ir->array;
1553
1554 assert(index || !"FINISHME: variable-indexed builtin uniform access");
1555
1556 this->result = get_builtin_uniform_reg(prog,
1557 var->name,
1558 index->value.i[0],
1559 record ? record->field : NULL);
1560 }
1561
1562 ir->array->accept(this);
1563 src_reg = this->result;
1564
1565 if (index) {
1566 src_reg.index += index->value.i[0] * element_size;
1567 } else {
1568 ir_to_mesa_src_reg array_base = this->result;
1569 /* Variable index array dereference. It eats the "vec4" of the
1570 * base of the array and an index that offsets the Mesa register
1571 * index.
1572 */
1573 ir->array_index->accept(this);
1574
1575 ir_to_mesa_src_reg index_reg;
1576
1577 if (element_size == 1) {
1578 index_reg = this->result;
1579 } else {
1580 index_reg = get_temp(glsl_type::float_type);
1581
1582 ir_to_mesa_emit_op2(ir, OPCODE_MUL,
1583 ir_to_mesa_dst_reg_from_src(index_reg),
1584 this->result, src_reg_for_float(element_size));
1585 }
1586
1587 src_reg.reladdr = talloc(mem_ctx, ir_to_mesa_src_reg);
1588 memcpy(src_reg.reladdr, &index_reg, sizeof(index_reg));
1589 }
1590
1591 /* If the type is smaller than a vec4, replicate the last channel out. */
1592 if (ir->type->is_scalar() || ir->type->is_vector())
1593 src_reg.swizzle = swizzle_for_size(ir->type->vector_elements);
1594 else
1595 src_reg.swizzle = SWIZZLE_NOOP;
1596
1597 this->result = src_reg;
1598}
1599
1600void
1601ir_to_mesa_visitor::visit(ir_dereference_record *ir)
1602{
1603 unsigned int i;
1604 const glsl_type *struct_type = ir->record->type;
1605 int offset = 0;
1606 ir_variable *var = ir->record->variable_referenced();
1607
1608 if (strncmp(var->name, "gl_", 3) == 0 && var->mode == ir_var_uniform) {
1609 assert(var);
1610
1611 this->result = get_builtin_uniform_reg(prog,
1612 var->name,
1613 0,
1614 ir->field);
1615 return;
1616 }
1617
1618 ir->record->accept(this);
1619
1620 for (i = 0; i < struct_type->length; i++) {
1621 if (strcmp(struct_type->fields.structure[i].name, ir->field) == 0)
1622 break;
1623 offset += type_size(struct_type->fields.structure[i].type);
1624 }
1625 this->result.swizzle = swizzle_for_size(ir->type->vector_elements);
1626 this->result.index += offset;
1627}
1628
1629/**
1630 * We want to be careful in assignment setup to hit the actual storage
1631 * instead of potentially using a temporary like we might with the
1632 * ir_dereference handler.
1633 */
1634static struct ir_to_mesa_dst_reg
1635get_assignment_lhs(ir_dereference *ir, ir_to_mesa_visitor *v)
1636{
1637 /* The LHS must be a dereference. If the LHS is a variable indexed array
1638 * access of a vector, it must be separated into a series conditional moves
1639 * before reaching this point (see ir_vec_index_to_cond_assign).
1640 */
1641 assert(ir->as_dereference());
1642 ir_dereference_array *deref_array = ir->as_dereference_array();
1643 if (deref_array) {
1644 assert(!deref_array->array->type->is_vector());
1645 }
1646
1647 /* Use the rvalue deref handler for the most part. We'll ignore
1648 * swizzles in it and write swizzles using writemask, though.
1649 */
1650 ir->accept(v);
1651 return ir_to_mesa_dst_reg_from_src(v->result);
1652}
1653
1654void
1655ir_to_mesa_visitor::visit(ir_assignment *ir)
1656{
1657 struct ir_to_mesa_dst_reg l;
1658 struct ir_to_mesa_src_reg r;
1659 int i;
1660
1661 ir->rhs->accept(this);
1662 r = this->result;
1663
1664 l = get_assignment_lhs(ir->lhs, this);
1665
1666 /* FINISHME: This should really set to the correct maximal writemask for each
1667 * FINISHME: component written (in the loops below). This case can only
1668 * FINISHME: occur for matrices, arrays, and structures.
1669 */
1670 if (ir->write_mask == 0) {
1671 assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
1672 l.writemask = WRITEMASK_XYZW;
1673 } else if (ir->lhs->type->is_scalar()) {
1674 /* FINISHME: This hack makes writing to gl_FragData, which lives in the
1675 * FINISHME: W component of fragment shader output zero, work correctly.
1676 */
1677 l.writemask = WRITEMASK_XYZW;
1678 } else {
1679 assert(ir->lhs->type->is_vector());
1680 l.writemask = ir->write_mask;
1681 }
1682
1683 assert(l.file != PROGRAM_UNDEFINED);
1684 assert(r.file != PROGRAM_UNDEFINED);
1685
1686 if (ir->condition) {
1687 ir_to_mesa_src_reg condition;
1688
1689 ir->condition->accept(this);
1690 condition = this->result;
1691
1692 /* We use the OPCODE_CMP (a < 0 ? b : c) for conditional moves,
1693 * and the condition we produced is 0.0 or 1.0. By flipping the
1694 * sign, we can choose which value OPCODE_CMP produces without
1695 * an extra computing the condition.
1696 */
1697 condition.negate = ~condition.negate;
1698 for (i = 0; i < type_size(ir->lhs->type); i++) {
1699 ir_to_mesa_emit_op3(ir, OPCODE_CMP, l,
1700 condition, r, ir_to_mesa_src_reg_from_dst(l));
1701 l.index++;
1702 r.index++;
1703 }
1704 } else {
1705 for (i = 0; i < type_size(ir->lhs->type); i++) {
1706 ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r);
1707 l.index++;
1708 r.index++;
1709 }
1710 }
1711}
1712
1713
1714void
1715ir_to_mesa_visitor::visit(ir_constant *ir)
1716{
1717 ir_to_mesa_src_reg src_reg;
1718 GLfloat stack_vals[4];
1719 GLfloat *values = stack_vals;
1720 unsigned int i;
1721
1722 /* Unfortunately, 4 floats is all we can get into
1723 * _mesa_add_unnamed_constant. So, make a temp to store an
1724 * aggregate constant and move each constant value into it. If we
1725 * get lucky, copy propagation will eliminate the extra moves.
1726 */
1727
1728 if (ir->type->base_type == GLSL_TYPE_STRUCT) {
1729 ir_to_mesa_src_reg temp_base = get_temp(ir->type);
1730 ir_to_mesa_dst_reg temp = ir_to_mesa_dst_reg_from_src(temp_base);
1731
1732 foreach_iter(exec_list_iterator, iter, ir->components) {
1733 ir_constant *field_value = (ir_constant *)iter.get();
1734 int size = type_size(field_value->type);
1735
1736 assert(size > 0);
1737
1738 field_value->accept(this);
1739 src_reg = this->result;
1740
1741 for (i = 0; i < (unsigned int)size; i++) {
1742 ir_to_mesa_emit_op1(ir, OPCODE_MOV, temp, src_reg);
1743
1744 src_reg.index++;
1745 temp.index++;
1746 }
1747 }
1748 this->result = temp_base;
1749 return;
1750 }
1751
1752 if (ir->type->is_array()) {
1753 ir_to_mesa_src_reg temp_base = get_temp(ir->type);
1754 ir_to_mesa_dst_reg temp = ir_to_mesa_dst_reg_from_src(temp_base);
1755 int size = type_size(ir->type->fields.array);
1756
1757 assert(size > 0);
1758
1759 for (i = 0; i < ir->type->length; i++) {
1760 ir->array_elements[i]->accept(this);
1761 src_reg = this->result;
1762 for (int j = 0; j < size; j++) {
1763 ir_to_mesa_emit_op1(ir, OPCODE_MOV, temp, src_reg);
1764
1765 src_reg.index++;
1766 temp.index++;
1767 }
1768 }
1769 this->result = temp_base;
1770 return;
1771 }
1772
1773 if (ir->type->is_matrix()) {
1774 ir_to_mesa_src_reg mat = get_temp(ir->type);
1775 ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat);
1776
1777 for (i = 0; i < ir->type->matrix_columns; i++) {
1778 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
1779 values = &ir->value.f[i * ir->type->vector_elements];
1780
1781 src_reg = ir_to_mesa_src_reg(PROGRAM_CONSTANT, -1, NULL);
1782 src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters,
1783 values,
1784 ir->type->vector_elements,
1785 &src_reg.swizzle);
1786 ir_to_mesa_emit_op1(ir, OPCODE_MOV, mat_column, src_reg);
1787
1788 mat_column.index++;
1789 }
1790
1791 this->result = mat;
1792 }
1793
1794 src_reg.file = PROGRAM_CONSTANT;
1795 switch (ir->type->base_type) {
1796 case GLSL_TYPE_FLOAT:
1797 values = &ir->value.f[0];
1798 break;
1799 case GLSL_TYPE_UINT:
1800 for (i = 0; i < ir->type->vector_elements; i++) {
1801 values[i] = ir->value.u[i];
1802 }
1803 break;
1804 case GLSL_TYPE_INT:
1805 for (i = 0; i < ir->type->vector_elements; i++) {
1806 values[i] = ir->value.i[i];
1807 }
1808 break;
1809 case GLSL_TYPE_BOOL:
1810 for (i = 0; i < ir->type->vector_elements; i++) {
1811 values[i] = ir->value.b[i];
1812 }
1813 break;
1814 default:
1815 assert(!"Non-float/uint/int/bool constant");
1816 }
1817
1818 this->result = ir_to_mesa_src_reg(PROGRAM_CONSTANT, -1, ir->type);
1819 this->result.index = _mesa_add_unnamed_constant(this->prog->Parameters,
1820 values,
1821 ir->type->vector_elements,
1822 &this->result.swizzle);
1823}
1824
1825function_entry *
1826ir_to_mesa_visitor::get_function_signature(ir_function_signature *sig)
1827{
1828 function_entry *entry;
1829
1830 foreach_iter(exec_list_iterator, iter, this->function_signatures) {
1831 entry = (function_entry *)iter.get();
1832
1833 if (entry->sig == sig)
1834 return entry;
1835 }
1836
1837 entry = talloc(mem_ctx, function_entry);
1838 entry->sig = sig;
1839 entry->sig_id = this->next_signature_id++;
1840 entry->bgn_inst = NULL;
1841
1842 /* Allocate storage for all the parameters. */
1843 foreach_iter(exec_list_iterator, iter, sig->parameters) {
1844 ir_variable *param = (ir_variable *)iter.get();
1845 variable_storage *storage;
1846
1847 storage = find_variable_storage(param);
1848 assert(!storage);
1849
1850 storage = new(mem_ctx) variable_storage(param, PROGRAM_TEMPORARY,
1851 this->next_temp);
1852 this->variables.push_tail(storage);
1853
1854 this->next_temp += type_size(param->type);
1855 }
1856
1857 if (!sig->return_type->is_void()) {
1858 entry->return_reg = get_temp(sig->return_type);
1859 } else {
1860 entry->return_reg = ir_to_mesa_undef;
1861 }
1862
1863 this->function_signatures.push_tail(entry);
1864 return entry;
1865}
1866
1867void
1868ir_to_mesa_visitor::visit(ir_call *ir)
1869{
1870 ir_to_mesa_instruction *call_inst;
1871 ir_function_signature *sig = ir->get_callee();
1872 function_entry *entry = get_function_signature(sig);
1873 int i;
1874
1875 /* Process in parameters. */
1876 exec_list_iterator sig_iter = sig->parameters.iterator();
1877 foreach_iter(exec_list_iterator, iter, *ir) {
1878 ir_rvalue *param_rval = (ir_rvalue *)iter.get();
1879 ir_variable *param = (ir_variable *)sig_iter.get();
1880
1881 if (param->mode == ir_var_in ||
1882 param->mode == ir_var_inout) {
1883 variable_storage *storage = find_variable_storage(param);
1884 assert(storage);
1885
1886 param_rval->accept(this);
1887 ir_to_mesa_src_reg r = this->result;
1888
1889 ir_to_mesa_dst_reg l;
1890 l.file = storage->file;
1891 l.index = storage->index;
1892 l.reladdr = NULL;
1893 l.writemask = WRITEMASK_XYZW;
1894 l.cond_mask = COND_TR;
1895
1896 for (i = 0; i < type_size(param->type); i++) {
1897 ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r);
1898 l.index++;
1899 r.index++;
1900 }
1901 }
1902
1903 sig_iter.next();
1904 }
1905 assert(!sig_iter.has_next());
1906
1907 /* Emit call instruction */
1908 call_inst = ir_to_mesa_emit_op1(ir, OPCODE_CAL,
1909 ir_to_mesa_undef_dst, ir_to_mesa_undef);
1910 call_inst->function = entry;
1911
1912 /* Process out parameters. */
1913 sig_iter = sig->parameters.iterator();
1914 foreach_iter(exec_list_iterator, iter, *ir) {
1915 ir_rvalue *param_rval = (ir_rvalue *)iter.get();
1916 ir_variable *param = (ir_variable *)sig_iter.get();
1917
1918 if (param->mode == ir_var_out ||
1919 param->mode == ir_var_inout) {
1920 variable_storage *storage = find_variable_storage(param);
1921 assert(storage);
1922
1923 ir_to_mesa_src_reg r;
1924 r.file = storage->file;
1925 r.index = storage->index;
1926 r.reladdr = NULL;
1927 r.swizzle = SWIZZLE_NOOP;
1928 r.negate = 0;
1929
1930 param_rval->accept(this);
1931 ir_to_mesa_dst_reg l = ir_to_mesa_dst_reg_from_src(this->result);
1932
1933 for (i = 0; i < type_size(param->type); i++) {
1934 ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r);
1935 l.index++;
1936 r.index++;
1937 }
1938 }
1939
1940 sig_iter.next();
1941 }
1942 assert(!sig_iter.has_next());
1943
1944 /* Process return value. */
1945 this->result = entry->return_reg;
1946}
1947
1948
1949void
1950ir_to_mesa_visitor::visit(ir_texture *ir)
1951{
1952 ir_to_mesa_src_reg result_src, coord, lod_info, projector;
1953 ir_to_mesa_dst_reg result_dst, coord_dst;
1954 ir_to_mesa_instruction *inst = NULL;
1955 prog_opcode opcode = OPCODE_NOP;
1956
1957 ir->coordinate->accept(this);
1958
1959 /* Put our coords in a temp. We'll need to modify them for shadow,
1960 * projection, or LOD, so the only case we'd use it as is is if
1961 * we're doing plain old texturing. Mesa IR optimization should
1962 * handle cleaning up our mess in that case.
1963 */
1964 coord = get_temp(glsl_type::vec4_type);
1965 coord_dst = ir_to_mesa_dst_reg_from_src(coord);
1966 ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst,
1967 this->result);
1968
1969 if (ir->projector) {
1970 ir->projector->accept(this);
1971 projector = this->result;
1972 }
1973
1974 /* Storage for our result. Ideally for an assignment we'd be using
1975 * the actual storage for the result here, instead.
1976 */
1977 result_src = get_temp(glsl_type::vec4_type);
1978 result_dst = ir_to_mesa_dst_reg_from_src(result_src);
1979
1980 switch (ir->op) {
1981 case ir_tex:
1982 opcode = OPCODE_TEX;
1983 break;
1984 case ir_txb:
1985 opcode = OPCODE_TXB;
1986 ir->lod_info.bias->accept(this);
1987 lod_info = this->result;
1988 break;
1989 case ir_txl:
1990 opcode = OPCODE_TXL;
1991 ir->lod_info.lod->accept(this);
1992 lod_info = this->result;
1993 break;
1994 case ir_txd:
1995 case ir_txf:
1996 assert(!"GLSL 1.30 features unsupported");
1997 break;
1998 }
1999
2000 if (ir->projector) {
2001 if (opcode == OPCODE_TEX) {
2002 /* Slot the projector in as the last component of the coord. */
2003 coord_dst.writemask = WRITEMASK_W;
2004 ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst, projector);
2005 coord_dst.writemask = WRITEMASK_XYZW;
2006 opcode = OPCODE_TXP;
2007 } else {
2008 ir_to_mesa_src_reg coord_w = coord;
2009 coord_w.swizzle = SWIZZLE_WWWW;
2010
2011 /* For the other TEX opcodes there's no projective version
2012 * since the last slot is taken up by lod info. Do the
2013 * projective divide now.
2014 */
2015 coord_dst.writemask = WRITEMASK_W;
2016 ir_to_mesa_emit_op1(ir, OPCODE_RCP, coord_dst, projector);
2017
2018 coord_dst.writemask = WRITEMASK_XYZ;
2019 ir_to_mesa_emit_op2(ir, OPCODE_MUL, coord_dst, coord, coord_w);
2020
2021 coord_dst.writemask = WRITEMASK_XYZW;
2022 coord.swizzle = SWIZZLE_XYZW;
2023 }
2024 }
2025
2026 if (ir->shadow_comparitor) {
2027 /* Slot the shadow value in as the second to last component of the
2028 * coord.
2029 */
2030 ir->shadow_comparitor->accept(this);
2031 coord_dst.writemask = WRITEMASK_Z;
2032 ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst, this->result);
2033 coord_dst.writemask = WRITEMASK_XYZW;
2034 }
2035
2036 if (opcode == OPCODE_TXL || opcode == OPCODE_TXB) {
2037 /* Mesa IR stores lod or lod bias in the last channel of the coords. */
2038 coord_dst.writemask = WRITEMASK_W;
2039 ir_to_mesa_emit_op1(ir, OPCODE_MOV, coord_dst, lod_info);
2040 coord_dst.writemask = WRITEMASK_XYZW;
2041 }
2042
2043 inst = ir_to_mesa_emit_op1(ir, opcode, result_dst, coord);
2044
2045 if (ir->shadow_comparitor)
2046 inst->tex_shadow = GL_TRUE;
2047
2048 ir_variable *sampler = ir->sampler->variable_referenced();
2049
2050 /* generate the mapping, remove when we generate storage at
2051 * declaration time
2052 */
2053 ir->sampler->accept(this);
2054
2055 inst->sampler = get_sampler_location(sampler);
2056
2057 ir_dereference_array *sampler_array = ir->sampler->as_dereference_array();
2058 if (sampler_array) {
2059 ir_constant *array_index =
2060 sampler_array->array_index->constant_expression_value();
2061
2062 /* GLSL 1.10 and 1.20 allowed variable sampler array indices,
2063 * while GLSL 1.30 requires that the array indices be constant
2064 * integer expressions. We don't expect any driver to actually
2065 * work with a really variable array index, and in 1.20 all that
2066 * would work would be an unrolled loop counter, so assert that
2067 * we ended up with a constant at least..
2068 */
2069 assert(array_index);
2070 inst->sampler += array_index->value.i[0];
2071 }
2072
2073 const glsl_type *sampler_type = sampler->type;
2074 while (sampler_type->base_type == GLSL_TYPE_ARRAY)
2075 sampler_type = sampler_type->fields.array;
2076
2077 switch (sampler_type->sampler_dimensionality) {
2078 case GLSL_SAMPLER_DIM_1D:
2079 inst->tex_target = (sampler_type->sampler_array)
2080 ? TEXTURE_1D_ARRAY_INDEX : TEXTURE_1D_INDEX;
2081 break;
2082 case GLSL_SAMPLER_DIM_2D:
2083 inst->tex_target = (sampler_type->sampler_array)
2084 ? TEXTURE_2D_ARRAY_INDEX : TEXTURE_2D_INDEX;
2085 break;
2086 case GLSL_SAMPLER_DIM_3D:
2087 inst->tex_target = TEXTURE_3D_INDEX;
2088 break;
2089 case GLSL_SAMPLER_DIM_CUBE:
2090 inst->tex_target = TEXTURE_CUBE_INDEX;
2091 break;
2092 case GLSL_SAMPLER_DIM_RECT:
2093 inst->tex_target = TEXTURE_RECT_INDEX;
2094 break;
2095 case GLSL_SAMPLER_DIM_BUF:
2096 assert(!"FINISHME: Implement ARB_texture_buffer_object");
2097 break;
2098 default:
2099 assert(!"Should not get here.");
2100 }
2101
2102 this->result = result_src;
2103}
2104
2105void
2106ir_to_mesa_visitor::visit(ir_return *ir)
2107{
2108 assert(current_function);
2109
2110 if (ir->get_value()) {
2111 ir_to_mesa_dst_reg l;
2112 int i;
2113
2114 ir->get_value()->accept(this);
2115 ir_to_mesa_src_reg r = this->result;
2116
2117 l = ir_to_mesa_dst_reg_from_src(current_function->return_reg);
2118
2119 for (i = 0; i < type_size(current_function->sig->return_type); i++) {
2120 ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r);
2121 l.index++;
2122 r.index++;
2123 }
2124 }
2125
2126 ir_to_mesa_emit_op0(ir, OPCODE_RET);
2127}
2128
2129void
2130ir_to_mesa_visitor::visit(ir_discard *ir)
2131{
2132 assert(ir->condition == NULL); /* FINISHME */
2133
2134 ir_to_mesa_emit_op0(ir, OPCODE_KIL_NV);
2135}
2136
2137void
2138ir_to_mesa_visitor::visit(ir_if *ir)
2139{
2140 ir_to_mesa_instruction *cond_inst, *if_inst, *else_inst = NULL;
2141 ir_to_mesa_instruction *prev_inst;
2142
2143 prev_inst = (ir_to_mesa_instruction *)this->instructions.get_tail();
2144
2145 ir->condition->accept(this);
2146 assert(this->result.file != PROGRAM_UNDEFINED);
2147
2148 if (ctx->Shader.EmitCondCodes) {
2149 cond_inst = (ir_to_mesa_instruction *)this->instructions.get_tail();
2150
2151 /* See if we actually generated any instruction for generating
2152 * the condition. If not, then cook up a move to a temp so we
2153 * have something to set cond_update on.
2154 */
2155 if (cond_inst == prev_inst) {
2156 ir_to_mesa_src_reg temp = get_temp(glsl_type::bool_type);
2157 cond_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_MOV,
2158 ir_to_mesa_dst_reg_from_src(temp),
2159 result);
2160 }
2161 cond_inst->cond_update = GL_TRUE;
2162
2163 if_inst = ir_to_mesa_emit_op0(ir->condition, OPCODE_IF);
2164 if_inst->dst_reg.cond_mask = COND_NE;
2165 } else {
2166 if_inst = ir_to_mesa_emit_op1(ir->condition,
2167 OPCODE_IF, ir_to_mesa_undef_dst,
2168 this->result);
2169 }
2170
2171 this->instructions.push_tail(if_inst);
2172
2173 visit_exec_list(&ir->then_instructions, this);
2174
2175 if (!ir->else_instructions.is_empty()) {
2176 else_inst = ir_to_mesa_emit_op0(ir->condition, OPCODE_ELSE);
2177 visit_exec_list(&ir->else_instructions, this);
2178 }
2179
2180 if_inst = ir_to_mesa_emit_op1(ir->condition, OPCODE_ENDIF,
2181 ir_to_mesa_undef_dst, ir_to_mesa_undef);
2182}
2183
2184ir_to_mesa_visitor::ir_to_mesa_visitor()
2185{
2186 result.file = PROGRAM_UNDEFINED;
2187 next_temp = 1;
2188 next_signature_id = 1;
2189 sampler_map = NULL;
2190 current_function = NULL;
2191}
2192
2193ir_to_mesa_visitor::~ir_to_mesa_visitor()
2194{
2195 if (this->sampler_map)
2196 hash_table_dtor(this->sampler_map);
2197}
2198
2199static struct prog_src_register
2200mesa_src_reg_from_ir_src_reg(ir_to_mesa_src_reg reg)
2201{
2202 struct prog_src_register mesa_reg;
2203
2204 mesa_reg.File = reg.file;
2205 assert(reg.index < (1 << INST_INDEX_BITS) - 1);
2206 mesa_reg.Index = reg.index;
2207 mesa_reg.Swizzle = reg.swizzle;
2208 mesa_reg.RelAddr = reg.reladdr != NULL;
2209 mesa_reg.Negate = reg.negate;
2210 mesa_reg.Abs = 0;
2211 mesa_reg.HasIndex2 = GL_FALSE;
2212
2213 return mesa_reg;
2214}
2215
2216static void
2217set_branchtargets(ir_to_mesa_visitor *v,
2218 struct prog_instruction *mesa_instructions,
2219 int num_instructions)
2220{
2221 int if_count = 0, loop_count = 0;
2222 int *if_stack, *loop_stack;
2223 int if_stack_pos = 0, loop_stack_pos = 0;
2224 int i, j;
2225
2226 for (i = 0; i < num_instructions; i++) {
2227 switch (mesa_instructions[i].Opcode) {
2228 case OPCODE_IF:
2229 if_count++;
2230 break;
2231 case OPCODE_BGNLOOP:
2232 loop_count++;
2233 break;
2234 case OPCODE_BRK:
2235 case OPCODE_CONT:
2236 mesa_instructions[i].BranchTarget = -1;
2237 break;
2238 default:
2239 break;
2240 }
2241 }
2242
2243 if_stack = (int *)calloc(if_count, sizeof(*if_stack));
2244 loop_stack = (int *)calloc(loop_count, sizeof(*loop_stack));
2245
2246 for (i = 0; i < num_instructions; i++) {
2247 switch (mesa_instructions[i].Opcode) {
2248 case OPCODE_IF:
2249 if_stack[if_stack_pos] = i;
2250 if_stack_pos++;
2251 break;
2252 case OPCODE_ELSE:
2253 mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i;
2254 if_stack[if_stack_pos - 1] = i;
2255 break;
2256 case OPCODE_ENDIF:
2257 mesa_instructions[if_stack[if_stack_pos - 1]].BranchTarget = i;
2258 if_stack_pos--;
2259 break;
2260 case OPCODE_BGNLOOP:
2261 loop_stack[loop_stack_pos] = i;
2262 loop_stack_pos++;
2263 break;
2264 case OPCODE_ENDLOOP:
2265 loop_stack_pos--;
2266 /* Rewrite any breaks/conts at this nesting level (haven't
2267 * already had a BranchTarget assigned) to point to the end
2268 * of the loop.
2269 */
2270 for (j = loop_stack[loop_stack_pos]; j < i; j++) {
2271 if (mesa_instructions[j].Opcode == OPCODE_BRK ||
2272 mesa_instructions[j].Opcode == OPCODE_CONT) {
2273 if (mesa_instructions[j].BranchTarget == -1) {
2274 mesa_instructions[j].BranchTarget = i;
2275 }
2276 }
2277 }
2278 /* The loop ends point at each other. */
2279 mesa_instructions[i].BranchTarget = loop_stack[loop_stack_pos];
2280 mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i;
2281 break;
2282 case OPCODE_CAL:
2283 foreach_iter(exec_list_iterator, iter, v->function_signatures) {
2284 function_entry *entry = (function_entry *)iter.get();
2285
2286 if (entry->sig_id == mesa_instructions[i].BranchTarget) {
2287 mesa_instructions[i].BranchTarget = entry->inst;
2288 break;
2289 }
2290 }
2291 break;
2292 default:
2293 break;
2294 }
2295 }
2296
2297 free(if_stack);
2298}
2299
2300static void
2301print_program(struct prog_instruction *mesa_instructions,
2302 ir_instruction **mesa_instruction_annotation,
2303 int num_instructions)
2304{
2305 ir_instruction *last_ir = NULL;
2306 int i;
2307 int indent = 0;
2308
2309 for (i = 0; i < num_instructions; i++) {
2310 struct prog_instruction *mesa_inst = mesa_instructions + i;
2311 ir_instruction *ir = mesa_instruction_annotation[i];
2312
2313 fprintf(stdout, "%3d: ", i);
2314
2315 if (last_ir != ir && ir) {
2316 int j;
2317
2318 for (j = 0; j < indent; j++) {
2319 fprintf(stdout, " ");
2320 }
2321 ir->print();
2322 printf("\n");
2323 last_ir = ir;
2324
2325 fprintf(stdout, " "); /* line number spacing. */
2326 }
2327
2328 indent = _mesa_fprint_instruction_opt(stdout, mesa_inst, indent,
2329 PROG_PRINT_DEBUG, NULL);
2330 }
2331}
2332
2333static void
2334count_resources(struct gl_program *prog)
2335{
2336 unsigned int i;
2337
2338 prog->SamplersUsed = 0;
2339
2340 for (i = 0; i < prog->NumInstructions; i++) {
2341 struct prog_instruction *inst = &prog->Instructions[i];
2342
2343 /* Instead of just using the uniform's value to map to a
2344 * sampler, Mesa first allocates a separate number for the
2345 * sampler (_mesa_add_sampler), then we reindex it down to a
2346 * small integer (sampler_map[], SamplersUsed), then that gets
2347 * mapped to the uniform's value, and we get an actual sampler.
2348 */
2349 if (_mesa_is_tex_instruction(inst->Opcode)) {
2350 prog->SamplerTargets[inst->TexSrcUnit] =
2351 (gl_texture_index)inst->TexSrcTarget;
2352 prog->SamplersUsed |= 1 << inst->TexSrcUnit;
2353 if (inst->TexShadow) {
2354 prog->ShadowSamplers |= 1 << inst->TexSrcUnit;
2355 }
2356 }
2357 }
2358
2359 _mesa_update_shader_textures_used(prog);
2360}
2361
2362/* Each stage has some uniforms in its Parameters list. The Uniforms
2363 * list for the linked shader program has a pointer to these uniforms
2364 * in each of the stage's Parameters list, so that their values can be
2365 * updated when a uniform is set.
2366 */
2367static void
2368link_uniforms_to_shared_uniform_list(struct gl_uniform_list *uniforms,
2369 struct gl_program *prog)
2370{
2371 unsigned int i;
2372
2373 for (i = 0; i < prog->Parameters->NumParameters; i++) {
2374 const struct gl_program_parameter *p = prog->Parameters->Parameters + i;
2375
2376 if (p->Type == PROGRAM_UNIFORM || p->Type == PROGRAM_SAMPLER) {
2377 struct gl_uniform *uniform =
2378 _mesa_append_uniform(uniforms, p->Name, prog->Target, i);
2379 if (uniform)
2380 uniform->Initialized = p->Initialized;
2381 }
2382 }
2383}
2384
2385struct gl_program *
2386get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
2387 struct gl_shader *shader)
2388{
2389 void *mem_ctx = shader_program;
2390 ir_to_mesa_visitor v;
2391 struct prog_instruction *mesa_instructions, *mesa_inst;
2392 ir_instruction **mesa_instruction_annotation;
2393 int i;
2394 struct gl_program *prog;
2395 GLenum target;
2396 const char *target_string;
2397 GLboolean progress;
2398
2399 switch (shader->Type) {
2400 case GL_VERTEX_SHADER:
2401 target = GL_VERTEX_PROGRAM_ARB;
2402 target_string = "vertex";
2403 break;
2404 case GL_FRAGMENT_SHADER:
2405 target = GL_FRAGMENT_PROGRAM_ARB;
2406 target_string = "fragment";
2407 break;
2408 default:
2409 assert(!"should not be reached");
2410 break;
2411 }
2412
2413 validate_ir_tree(shader->ir);
2414
2415 prog = ctx->Driver.NewProgram(ctx, target, shader_program->Name);
2416 if (!prog)
2417 return NULL;
2418 prog->Parameters = _mesa_new_parameter_list();
2419 prog->Varying = _mesa_new_parameter_list();
2420 prog->Attributes = _mesa_new_parameter_list();
2421 v.ctx = ctx;
2422 v.prog = prog;
2423
2424 v.mem_ctx = talloc_new(NULL);
2425
2426 /* Emit Mesa IR for main(). */
2427 visit_exec_list(shader->ir, &v);
2428 v.ir_to_mesa_emit_op0(NULL, OPCODE_END);
2429
2430 /* Now emit bodies for any functions that were used. */
2431 do {
2432 progress = GL_FALSE;
2433
2434 foreach_iter(exec_list_iterator, iter, v.function_signatures) {
2435 function_entry *entry = (function_entry *)iter.get();
2436
2437 if (!entry->bgn_inst) {
2438 v.current_function = entry;
2439
2440 entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_BGNSUB);
2441 entry->bgn_inst->function = entry;
2442
2443 visit_exec_list(&entry->sig->body, &v);
2444
2445 ir_to_mesa_instruction *last;
2446 last = (ir_to_mesa_instruction *)v.instructions.get_tail();
2447 if (last->op != OPCODE_RET)
2448 v.ir_to_mesa_emit_op0(NULL, OPCODE_RET);
2449
2450 ir_to_mesa_instruction *end;
2451 end = v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB);
2452 end->function = entry;
2453
2454 progress = GL_TRUE;
2455 }
2456 }
2457 } while (progress);
2458
2459 prog->NumTemporaries = v.next_temp;
2460
2461 int num_instructions = 0;
2462 foreach_iter(exec_list_iterator, iter, v.instructions) {
2463 num_instructions++;
2464 }
2465
2466 mesa_instructions =
2467 (struct prog_instruction *)calloc(num_instructions,
2468 sizeof(*mesa_instructions));
2469 mesa_instruction_annotation = talloc_array(mem_ctx, ir_instruction *,
2470 num_instructions);
2471
2472 mesa_inst = mesa_instructions;
2473 i = 0;
2474 foreach_iter(exec_list_iterator, iter, v.instructions) {
2475 ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get();
2476
2477 mesa_inst->Opcode = inst->op;
2478 mesa_inst->CondUpdate = inst->cond_update;
2479 mesa_inst->DstReg.File = inst->dst_reg.file;
2480 mesa_inst->DstReg.Index = inst->dst_reg.index;
2481 mesa_inst->DstReg.CondMask = inst->dst_reg.cond_mask;
2482 mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask;
2483 mesa_inst->DstReg.RelAddr = inst->dst_reg.reladdr != NULL;
2484 mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]);
2485 mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]);
2486 mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]);
2487 mesa_inst->TexSrcUnit = inst->sampler;
2488 mesa_inst->TexSrcTarget = inst->tex_target;
2489 mesa_inst->TexShadow = inst->tex_shadow;
2490 mesa_instruction_annotation[i] = inst->ir;
2491
2492 if (ctx->Shader.EmitNoIfs && mesa_inst->Opcode == OPCODE_IF) {
2493 shader_program->InfoLog =
2494 talloc_asprintf_append(shader_program->InfoLog,
2495 "Couldn't flatten if statement\n");
2496 shader_program->LinkStatus = false;
2497 }
2498
2499 switch (mesa_inst->Opcode) {
2500 case OPCODE_BGNSUB:
2501 inst->function->inst = i;
2502 mesa_inst->Comment = strdup(inst->function->sig->function_name());
2503 break;
2504 case OPCODE_ENDSUB:
2505 mesa_inst->Comment = strdup(inst->function->sig->function_name());
2506 break;
2507 case OPCODE_CAL:
2508 mesa_inst->BranchTarget = inst->function->sig_id; /* rewritten later */
2509 break;
2510 case OPCODE_ARL:
2511 prog->NumAddressRegs = 1;
2512 break;
2513 default:
2514 break;
2515 }
2516
2517 mesa_inst++;
2518 i++;
2519 }
2520
2521 set_branchtargets(&v, mesa_instructions, num_instructions);
2522
2523 if (ctx->Shader.Flags & GLSL_DUMP) {
2524 printf("\n");
2525 printf("GLSL IR for linked %s program %d:\n", target_string,
2526 shader_program->Name);
2527 _mesa_print_ir(shader->ir, NULL);
2528 printf("\n");
2529 printf("\n");
2530 printf("Mesa IR for linked %s program %d:\n", target_string,
2531 shader_program->Name);
2532 print_program(mesa_instructions, mesa_instruction_annotation,
2533 num_instructions);
2534 }
2535
2536 prog->Instructions = mesa_instructions;
2537 prog->NumInstructions = num_instructions;
2538
2539 do_set_program_inouts(shader->ir, prog);
2540 count_resources(prog);
2541
2542 _mesa_reference_program(ctx, &shader->Program, prog);
2543
2544 if ((ctx->Shader.Flags & GLSL_NO_OPT) == 0) {
2545 _mesa_optimize_program(ctx, prog);
2546 }
2547
2548 return prog;
2549}
2550
2551extern "C" {
2552GLboolean
2553_mesa_ir_compile_shader(GLcontext *ctx, struct gl_shader *shader)
2554{
2555 assert(shader->CompileStatus);
2556 (void) ctx;
2557
2558 return GL_TRUE;
2559}
2560
2561GLboolean
2562_mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
2563{
2564 assert(prog->LinkStatus);
2565
2566 for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
2567 bool progress;
2568 exec_list *ir = prog->_LinkedShaders[i]->ir;
2569
2570 do {
2571 progress = false;
2572
2573 /* Lowering */
2574 do_mat_op_to_vec(ir);
2575 do_mod_to_fract(ir);
2576 do_div_to_mul_rcp(ir);
2577 do_explog_to_explog2(ir);
2578
2579 progress = do_common_optimization(ir, true) || progress;
2580
2581 if (ctx->Shader.EmitNoIfs)
2582 progress = do_if_to_cond_assign(ir) || progress;
2583
2584 progress = do_vec_index_to_cond_assign(ir) || progress;
2585 } while (progress);
2586
2587 validate_ir_tree(ir);
2588 }
2589
2590 for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
2591 struct gl_program *linked_prog;
2592 bool ok = true;
2593
2594 linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
2595
2596 link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog);
2597
2598 switch (prog->_LinkedShaders[i]->Type) {
2599 case GL_VERTEX_SHADER:
2600 _mesa_reference_vertprog(ctx, &prog->VertexProgram,
2601 (struct gl_vertex_program *)linked_prog);
2602 ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
2603 linked_prog);
2604 break;
2605 case GL_FRAGMENT_SHADER:
2606 _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
2607 (struct gl_fragment_program *)linked_prog);
2608 ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
2609 linked_prog);
2610 break;
2611 }
2612 if (!ok) {
2613 return GL_FALSE;
2614 }
2615 }
2616
2617 return GL_TRUE;
2618}
2619
2620void
2621_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
2622{
2623 struct _mesa_glsl_parse_state *state =
2624 new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
2625
2626 const char *source = shader->Source;
2627 state->error = preprocess(state, &source, &state->info_log,
2628 &ctx->Extensions);
2629
2630 if (!state->error) {
2631 _mesa_glsl_lexer_ctor(state, source);
2632 _mesa_glsl_parse(state);
2633 _mesa_glsl_lexer_dtor(state);
2634 }
2635
2636 shader->ir = new(shader) exec_list;
2637 if (!state->error && !state->translation_unit.is_empty())
2638 _mesa_ast_to_hir(shader->ir, state);
2639
2640 if (!state->error && !shader->ir->is_empty()) {
2641 validate_ir_tree(shader->ir);
2642
2643 /* Do some optimization at compile time to reduce shader IR size
2644 * and reduce later work if the same shader is linked multiple times
2645 */
2646 while (do_common_optimization(shader->ir, false))
2647 ;
2648
2649 validate_ir_tree(shader->ir);
2650 }
2651
2652 shader->symbols = state->symbols;
2653
2654 shader->CompileStatus = !state->error;
2655 shader->InfoLog = state->info_log;
2656 shader->Version = state->language_version;
2657 memcpy(shader->builtins_to_link, state->builtins_to_link,
2658 sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link);
2659 shader->num_builtins_to_link = state->num_builtins_to_link;
2660
2661 if (ctx->Shader.Flags & GLSL_LOG) {
2662 _mesa_write_shader_to_file(shader);
2663 }
2664
2665 if (ctx->Shader.Flags & GLSL_DUMP) {
2666 printf("GLSL source for shader %d:\n", shader->Name);
2667 printf("%s\n", shader->Source);
2668
2669 if (shader->CompileStatus) {
2670 printf("GLSL IR for shader %d:\n", shader->Name);
2671 _mesa_print_ir(shader->ir, NULL);
2672 printf("\n\n");
2673 }
2674 }
2675
2676 /* Retain any live IR, but trash the rest. */
2677 reparent_ir(shader->ir, shader);
2678
2679 talloc_free(state);
2680
2681 if (shader->CompileStatus) {
2682 if (!ctx->Driver.CompileShader(ctx, shader))
2683 shader->CompileStatus = GL_FALSE;
2684 }
2685}
2686
2687void
2688_mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
2689{
2690 unsigned int i;
2691
2692 _mesa_clear_shader_program_data(ctx, prog);
2693
2694 prog->LinkStatus = GL_TRUE;
2695
2696 for (i = 0; i < prog->NumShaders; i++) {
2697 if (!prog->Shaders[i]->CompileStatus) {
2698 prog->InfoLog =
2699 talloc_asprintf_append(prog->InfoLog,
2700 "linking with uncompiled shader");
2701 prog->LinkStatus = GL_FALSE;
2702 }
2703 }
2704
2705 prog->Varying = _mesa_new_parameter_list();
2706 _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
2707 _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
2708
2709 if (prog->LinkStatus) {
2710 link_shaders(prog);
2711
2712 /* We don't use the linker's uniforms list, and cook up our own at
2713 * generate time.
2714 */
2715 free(prog->Uniforms);
2716 prog->Uniforms = _mesa_new_uniform_list();
2717 }
2718
2719 if (prog->LinkStatus) {
2720 if (!ctx->Driver.LinkShader(ctx, prog))
2721 prog->LinkStatus = GL_FALSE;
2722 }
2723}
2724
2725} /* extern "C" */
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
new file mode 100644
index 00000000000..ecaacde4bb0
--- /dev/null
+++ b/src/mesa/program/ir_to_mesa.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright © 2010 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include "main/config.h"
29#include "main/mtypes.h"
30
31void _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *sh);
32void _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog);
33GLboolean _mesa_ir_compile_shader(GLcontext *ctx, struct gl_shader *shader);
34GLboolean _mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog);
35
36#ifdef __cplusplus
37}
38#endif
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 1670c91b6ad..1222a0f4c8c 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -1842,7 +1842,11 @@ _mesa_execute_program(GLcontext * ctx,
1842 1842
1843 numExec++; 1843 numExec++;
1844 if (numExec > maxExec) { 1844 if (numExec > maxExec) {
1845 _mesa_problem(ctx, "Infinite loop detected in fragment program"); 1845 static GLboolean reported = GL_FALSE;
1846 if (!reported) {
1847 _mesa_problem(ctx, "Infinite loop detected in fragment program");
1848 reported = GL_TRUE;
1849 }
1846 return GL_TRUE; 1850 return GL_TRUE;
1847 } 1851 }
1848 1852
diff --git a/src/mesa/program/prog_instruction.h b/src/mesa/program/prog_instruction.h
index 098b366ab56..ca90de7ce1c 100644
--- a/src/mesa/program/prog_instruction.h
+++ b/src/mesa/program/prog_instruction.h
@@ -401,7 +401,7 @@ struct prog_instruction
401 /** 401 /**
402 * For BRA and CAL instructions, the location to jump to. 402 * For BRA and CAL instructions, the location to jump to.
403 * For BGNLOOP, points to ENDLOOP (and vice-versa). 403 * For BGNLOOP, points to ENDLOOP (and vice-versa).
404 * For BRK, points to BGNLOOP (which points to ENDLOOP). 404 * For BRK, points to ENDLOOP
405 * For IF, points to ELSE or ENDIF. 405 * For IF, points to ELSE or ENDIF.
406 * For ELSE, points to ENDIF. 406 * For ELSE, points to ENDIF.
407 */ 407 */
diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optimize.c
index c78187c983d..ab878755e25 100644
--- a/src/mesa/program/prog_optimize.c
+++ b/src/mesa/program/prog_optimize.c
@@ -34,7 +34,12 @@
34 34
35 35
36#define MAX_LOOP_NESTING 50 36#define MAX_LOOP_NESTING 50
37 37/* MAX_PROGRAM_TEMPS is a low number (256), and we want to be able to
38 * register allocate many temporary values into that small number of
39 * temps. So allow large temporary indices coming into the register
40 * allocator.
41 */
42#define REG_ALLOCATE_MAX_PROGRAM_TEMPS ((1 << INST_INDEX_BITS) - 1)
38 43
39static GLboolean dbg = GL_FALSE; 44static GLboolean dbg = GL_FALSE;
40 45
@@ -233,7 +238,7 @@ replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[])
233static GLboolean 238static GLboolean
234_mesa_remove_dead_code_global(struct gl_program *prog) 239_mesa_remove_dead_code_global(struct gl_program *prog)
235{ 240{
236 GLboolean tempRead[MAX_PROGRAM_TEMPS][4]; 241 GLboolean tempRead[REG_ALLOCATE_MAX_PROGRAM_TEMPS][4];
237 GLboolean *removeInst; /* per-instruction removal flag */ 242 GLboolean *removeInst; /* per-instruction removal flag */
238 GLuint i, rem = 0, comp; 243 GLuint i, rem = 0, comp;
239 244
@@ -258,7 +263,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog)
258 if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) { 263 if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
259 const GLuint index = inst->SrcReg[j].Index; 264 const GLuint index = inst->SrcReg[j].Index;
260 GLuint read_mask; 265 GLuint read_mask;
261 ASSERT(index < MAX_PROGRAM_TEMPS); 266 ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
262 read_mask = get_src_arg_mask(inst, j, NO_MASK); 267 read_mask = get_src_arg_mask(inst, j, NO_MASK);
263 268
264 if (inst->SrcReg[j].RelAddr) { 269 if (inst->SrcReg[j].RelAddr) {
@@ -281,7 +286,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog)
281 /* check dst reg */ 286 /* check dst reg */
282 if (inst->DstReg.File == PROGRAM_TEMPORARY) { 287 if (inst->DstReg.File == PROGRAM_TEMPORARY) {
283 const GLuint index = inst->DstReg.Index; 288 const GLuint index = inst->DstReg.Index;
284 ASSERT(index < MAX_PROGRAM_TEMPS); 289 ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
285 290
286 if (inst->DstReg.RelAddr) { 291 if (inst->DstReg.RelAddr) {
287 if (dbg) 292 if (dbg)
@@ -826,7 +831,7 @@ struct interval
826struct interval_list 831struct interval_list
827{ 832{
828 GLuint Num; 833 GLuint Num;
829 struct interval Intervals[MAX_PROGRAM_TEMPS]; 834 struct interval Intervals[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
830}; 835};
831 836
832 837
@@ -913,15 +918,33 @@ sort_interval_list_by_start(struct interval_list *list)
913#endif 918#endif
914} 919}
915 920
921struct loop_info
922{
923 GLuint Start, End; /**< Start, end instructions of loop */
924};
916 925
917/** 926/**
918 * Update the intermediate interval info for register 'index' and 927 * Update the intermediate interval info for register 'index' and
919 * instruction 'ic'. 928 * instruction 'ic'.
920 */ 929 */
921static void 930static void
922update_interval(GLint intBegin[], GLint intEnd[], GLuint index, GLuint ic) 931update_interval(GLint intBegin[], GLint intEnd[],
932 struct loop_info *loopStack, GLuint loopStackDepth,
933 GLuint index, GLuint ic)
923{ 934{
924 ASSERT(index < MAX_PROGRAM_TEMPS); 935 int i;
936
937 /* If the register is used in a loop, extend its lifetime through the end
938 * of the outermost loop that doesn't contain its definition.
939 */
940 for (i = 0; i < loopStackDepth; i++) {
941 if (intBegin[index] < loopStack[i].Start) {
942 ic = loopStack[i].End;
943 break;
944 }
945 }
946
947 ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS);
925 if (intBegin[index] == -1) { 948 if (intBegin[index] == -1) {
926 ASSERT(intEnd[index] == -1); 949 ASSERT(intEnd[index] == -1);
927 intBegin[index] = intEnd[index] = ic; 950 intBegin[index] = intEnd[index] = ic;
@@ -938,18 +961,14 @@ update_interval(GLint intBegin[], GLint intEnd[], GLuint index, GLuint ic)
938GLboolean 961GLboolean
939_mesa_find_temp_intervals(const struct prog_instruction *instructions, 962_mesa_find_temp_intervals(const struct prog_instruction *instructions,
940 GLuint numInstructions, 963 GLuint numInstructions,
941 GLint intBegin[MAX_PROGRAM_TEMPS], 964 GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS],
942 GLint intEnd[MAX_PROGRAM_TEMPS]) 965 GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
943{ 966{
944 struct loop_info
945 {
946 GLuint Start, End; /**< Start, end instructions of loop */
947 };
948 struct loop_info loopStack[MAX_LOOP_NESTING]; 967 struct loop_info loopStack[MAX_LOOP_NESTING];
949 GLuint loopStackDepth = 0; 968 GLuint loopStackDepth = 0;
950 GLuint i; 969 GLuint i;
951 970
952 for (i = 0; i < MAX_PROGRAM_TEMPS; i++){ 971 for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
953 intBegin[i] = intEnd[i] = -1; 972 intBegin[i] = intEnd[i] = -1;
954 } 973 }
955 974
@@ -975,24 +994,16 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions,
975 const GLuint index = inst->SrcReg[j].Index; 994 const GLuint index = inst->SrcReg[j].Index;
976 if (inst->SrcReg[j].RelAddr) 995 if (inst->SrcReg[j].RelAddr)
977 return GL_FALSE; 996 return GL_FALSE;
978 update_interval(intBegin, intEnd, index, i); 997 update_interval(intBegin, intEnd, loopStack, loopStackDepth,
979 if (loopStackDepth > 0) { 998 index, i);
980 /* extend temp register's interval to end of loop */
981 GLuint loopEnd = loopStack[loopStackDepth - 1].End;
982 update_interval(intBegin, intEnd, index, loopEnd);
983 }
984 } 999 }
985 } 1000 }
986 if (inst->DstReg.File == PROGRAM_TEMPORARY) { 1001 if (inst->DstReg.File == PROGRAM_TEMPORARY) {
987 const GLuint index = inst->DstReg.Index; 1002 const GLuint index = inst->DstReg.Index;
988 if (inst->DstReg.RelAddr) 1003 if (inst->DstReg.RelAddr)
989 return GL_FALSE; 1004 return GL_FALSE;
990 update_interval(intBegin, intEnd, index, i); 1005 update_interval(intBegin, intEnd, loopStack, loopStackDepth,
991 if (loopStackDepth > 0) { 1006 index, i);
992 /* extend temp register's interval to end of loop */
993 GLuint loopEnd = loopStack[loopStackDepth - 1].End;
994 update_interval(intBegin, intEnd, index, loopEnd);
995 }
996 } 1007 }
997 } 1008 }
998 } 1009 }
@@ -1012,7 +1023,8 @@ static GLboolean
1012find_live_intervals(struct gl_program *prog, 1023find_live_intervals(struct gl_program *prog,
1013 struct interval_list *liveIntervals) 1024 struct interval_list *liveIntervals)
1014{ 1025{
1015 GLint intBegin[MAX_PROGRAM_TEMPS], intEnd[MAX_PROGRAM_TEMPS]; 1026 GLint intBegin[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
1027 GLint intEnd[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
1016 GLuint i; 1028 GLuint i;
1017 1029
1018 /* 1030 /*
@@ -1032,7 +1044,7 @@ find_live_intervals(struct gl_program *prog,
1032 1044
1033 /* Build live intervals list from intermediate arrays */ 1045 /* Build live intervals list from intermediate arrays */
1034 liveIntervals->Num = 0; 1046 liveIntervals->Num = 0;
1035 for (i = 0; i < MAX_PROGRAM_TEMPS; i++) { 1047 for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++) {
1036 if (intBegin[i] >= 0) { 1048 if (intBegin[i] >= 0) {
1037 struct interval inv; 1049 struct interval inv;
1038 inv.Reg = i; 1050 inv.Reg = i;
@@ -1068,10 +1080,10 @@ find_live_intervals(struct gl_program *prog,
1068 1080
1069/** Scan the array of used register flags to find free entry */ 1081/** Scan the array of used register flags to find free entry */
1070static GLint 1082static GLint
1071alloc_register(GLboolean usedRegs[MAX_PROGRAM_TEMPS]) 1083alloc_register(GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS])
1072{ 1084{
1073 GLuint k; 1085 GLuint k;
1074 for (k = 0; k < MAX_PROGRAM_TEMPS; k++) { 1086 for (k = 0; k < REG_ALLOCATE_MAX_PROGRAM_TEMPS; k++) {
1075 if (!usedRegs[k]) { 1087 if (!usedRegs[k]) {
1076 usedRegs[k] = GL_TRUE; 1088 usedRegs[k] = GL_TRUE;
1077 return k; 1089 return k;
@@ -1093,8 +1105,8 @@ static void
1093_mesa_reallocate_registers(struct gl_program *prog) 1105_mesa_reallocate_registers(struct gl_program *prog)
1094{ 1106{
1095 struct interval_list liveIntervals; 1107 struct interval_list liveIntervals;
1096 GLint registerMap[MAX_PROGRAM_TEMPS]; 1108 GLint registerMap[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
1097 GLboolean usedRegs[MAX_PROGRAM_TEMPS]; 1109 GLboolean usedRegs[REG_ALLOCATE_MAX_PROGRAM_TEMPS];
1098 GLuint i; 1110 GLuint i;
1099 GLint maxTemp = -1; 1111 GLint maxTemp = -1;
1100 1112
@@ -1103,7 +1115,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
1103 _mesa_print_program(prog); 1115 _mesa_print_program(prog);
1104 } 1116 }
1105 1117
1106 for (i = 0; i < MAX_PROGRAM_TEMPS; i++){ 1118 for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){
1107 registerMap[i] = -1; 1119 registerMap[i] = -1;
1108 usedRegs[i] = GL_FALSE; 1120 usedRegs[i] = GL_FALSE;
1109 } 1121 }
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
index aac488c79ab..fa5deaf127d 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -344,18 +344,19 @@ _mesa_use_uniform(struct gl_program_parameter_list *paramList,
344 */ 344 */
345GLint 345GLint
346_mesa_add_sampler(struct gl_program_parameter_list *paramList, 346_mesa_add_sampler(struct gl_program_parameter_list *paramList,
347 const char *name, GLenum datatype) 347 const char *name, GLenum datatype, int array_length)
348{ 348{
349 GLint i = _mesa_lookup_parameter_index(paramList, -1, name); 349 GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
350 if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) { 350 if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) {
351 ASSERT(paramList->Parameters[i].Size == 1); 351 ASSERT(paramList->Parameters[i].Size == 4 * array_length);
352 ASSERT(paramList->Parameters[i].DataType == datatype); 352 ASSERT(paramList->Parameters[i].DataType == datatype);
353 /* already in list */ 353 /* already in list */
354 return (GLint) paramList->ParameterValues[i][0]; 354 return (GLint) paramList->ParameterValues[i][0];
355 } 355 }
356 else { 356 else {
357 GLuint i; 357 GLuint i;
358 const GLint size = 1; /* a sampler is basically a texture unit number */ 358 /* One integer texture unit number goes in each parameter location. */
359 const GLint size = 4 * array_length;
359 GLfloat value[4]; 360 GLfloat value[4];
360 GLint numSamplers = 0; 361 GLint numSamplers = 0;
361 for (i = 0; i < paramList->NumParameters; i++) { 362 for (i = 0; i < paramList->NumParameters; i++) {
@@ -591,7 +592,7 @@ _mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
591 if (vSize == 1) { 592 if (vSize == 1) {
592 /* look for v[0] anywhere within float[4] value */ 593 /* look for v[0] anywhere within float[4] value */
593 GLuint j; 594 GLuint j;
594 for (j = 0; j < 4; j++) { 595 for (j = 0; j < list->Parameters[i].Size; j++) {
595 if (list->ParameterValues[i][j] == v[0]) { 596 if (list->ParameterValues[i][j] == v[0]) {
596 /* found it */ 597 /* found it */
597 *posOut = i; 598 *posOut = i;
diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h
index cc3378ae201..1860f312879 100644
--- a/src/mesa/program/prog_parameter.h
+++ b/src/mesa/program/prog_parameter.h
@@ -142,7 +142,7 @@ _mesa_use_uniform(struct gl_program_parameter_list *paramList,
142 142
143extern GLint 143extern GLint
144_mesa_add_sampler(struct gl_program_parameter_list *paramList, 144_mesa_add_sampler(struct gl_program_parameter_list *paramList,
145 const char *name, GLenum datatype); 145 const char *name, GLenum datatype, int array_length);
146 146
147extern GLint 147extern GLint
148_mesa_add_varying(struct gl_program_parameter_list *paramList, 148_mesa_add_varying(struct gl_program_parameter_list *paramList,
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index 6056c459e4c..00aa6de963b 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -540,12 +540,12 @@ fprint_comment(FILE *f, const struct prog_instruction *inst)
540} 540}
541 541
542 542
543static void 543void
544fprint_alu_instruction(FILE *f, 544_mesa_fprint_alu_instruction(FILE *f,
545 const struct prog_instruction *inst, 545 const struct prog_instruction *inst,
546 const char *opcode_string, GLuint numRegs, 546 const char *opcode_string, GLuint numRegs,
547 gl_prog_print_mode mode, 547 gl_prog_print_mode mode,
548 const struct gl_program *prog) 548 const struct gl_program *prog)
549{ 549{
550 GLuint j; 550 GLuint j;
551 551
@@ -582,8 +582,8 @@ void
582_mesa_print_alu_instruction(const struct prog_instruction *inst, 582_mesa_print_alu_instruction(const struct prog_instruction *inst,
583 const char *opcode_string, GLuint numRegs) 583 const char *opcode_string, GLuint numRegs)
584{ 584{
585 fprint_alu_instruction(stderr, inst, opcode_string, 585 _mesa_fprint_alu_instruction(stderr, inst, opcode_string,
586 numRegs, PROG_PRINT_DEBUG, NULL); 586 numRegs, PROG_PRINT_DEBUG, NULL);
587} 587}
588 588
589 589
@@ -791,16 +791,16 @@ _mesa_fprint_instruction_opt(FILE *f,
791 default: 791 default:
792 if (inst->Opcode < MAX_OPCODE) { 792 if (inst->Opcode < MAX_OPCODE) {
793 /* typical alu instruction */ 793 /* typical alu instruction */
794 fprint_alu_instruction(f, inst, 794 _mesa_fprint_alu_instruction(f, inst,
795 _mesa_opcode_string(inst->Opcode), 795 _mesa_opcode_string(inst->Opcode),
796 _mesa_num_inst_src_regs(inst->Opcode), 796 _mesa_num_inst_src_regs(inst->Opcode),
797 mode, prog); 797 mode, prog);
798 } 798 }
799 else { 799 else {
800 fprint_alu_instruction(f, inst, 800 _mesa_fprint_alu_instruction(f, inst,
801 _mesa_opcode_string(inst->Opcode), 801 _mesa_opcode_string(inst->Opcode),
802 3/*_mesa_num_inst_src_regs(inst->Opcode)*/, 802 3/*_mesa_num_inst_src_regs(inst->Opcode)*/,
803 mode, prog); 803 mode, prog);
804 } 804 }
805 break; 805 break;
806 } 806 }
@@ -1033,11 +1033,11 @@ _mesa_write_shader_to_file(const struct gl_shader *shader)
1033 1033
1034 fprintf(f, "/* Compile status: %s */\n", 1034 fprintf(f, "/* Compile status: %s */\n",
1035 shader->CompileStatus ? "ok" : "fail"); 1035 shader->CompileStatus ? "ok" : "fail");
1036 if (!shader->CompileStatus) { 1036 fprintf(f, "/* Log Info: */\n");
1037 fprintf(f, "/* Log Info: */\n"); 1037 if (shader->InfoLog) {
1038 fputs(shader->InfoLog, f); 1038 fputs(shader->InfoLog, f);
1039 } 1039 }
1040 else { 1040 if (shader->CompileStatus && shader->Program) {
1041 fprintf(f, "/* GPU code */\n"); 1041 fprintf(f, "/* GPU code */\n");
1042 fprintf(f, "/*\n"); 1042 fprintf(f, "/*\n");
1043 _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE); 1043 _mesa_fprint_program_opt(f, shader->Program, PROG_PRINT_DEBUG, GL_TRUE);
diff --git a/src/mesa/program/prog_print.h b/src/mesa/program/prog_print.h
index 4667373f379..78b90aeb4d6 100644
--- a/src/mesa/program/prog_print.h
+++ b/src/mesa/program/prog_print.h
@@ -66,6 +66,13 @@ extern void
66_mesa_print_swizzle(GLuint swizzle); 66_mesa_print_swizzle(GLuint swizzle);
67 67
68extern void 68extern void
69_mesa_fprint_alu_instruction(FILE *f,
70 const struct prog_instruction *inst,
71 const char *opcode_string, GLuint numRegs,
72 gl_prog_print_mode mode,
73 const struct gl_program *prog);
74
75extern void
69_mesa_print_alu_instruction(const struct prog_instruction *inst, 76_mesa_print_alu_instruction(const struct prog_instruction *inst,
70 const char *opcode_string, GLuint numRegs); 77 const char *opcode_string, GLuint numRegs);
71 78
diff --git a/src/mesa/program/symbol_table.c b/src/mesa/program/symbol_table.c
index 6a5d6868974..09e7cb44ef3 100644
--- a/src/mesa/program/symbol_table.c
+++ b/src/mesa/program/symbol_table.c
@@ -58,7 +58,9 @@ struct symbol {
58 */ 58 */
59 int name_space; 59 int name_space;
60 60
61 61 /** Scope depth where this symbol was defined. */
62 unsigned depth;
63
62 /** 64 /**
63 * Arbitrary user supplied data. 65 * Arbitrary user supplied data.
64 */ 66 */
@@ -73,7 +75,7 @@ struct symbol_header {
73 struct symbol_header *next; 75 struct symbol_header *next;
74 76
75 /** Symbol name. */ 77 /** Symbol name. */
76 const char *name; 78 char *name;
77 79
78 /** Linked list of symbols with the same name. */ 80 /** Linked list of symbols with the same name. */
79 struct symbol *symbols; 81 struct symbol *symbols;
@@ -104,6 +106,9 @@ struct _mesa_symbol_table {
104 106
105 /** List of all symbol headers in the table. */ 107 /** List of all symbol headers in the table. */
106 struct symbol_header *hdr; 108 struct symbol_header *hdr;
109
110 /** Current scope depth. */
111 unsigned depth;
107}; 112};
108 113
109 114
@@ -157,6 +162,7 @@ _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table)
157 struct symbol *sym = scope->symbols; 162 struct symbol *sym = scope->symbols;
158 163
159 table->current_scope = scope->next; 164 table->current_scope = scope->next;
165 table->depth--;
160 166
161 free(scope); 167 free(scope);
162 168
@@ -184,6 +190,7 @@ _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table)
184 190
185 scope->next = table->current_scope; 191 scope->next = table->current_scope;
186 table->current_scope = scope; 192 table->current_scope = scope;
193 table->depth++;
187} 194}
188 195
189 196
@@ -261,6 +268,36 @@ _mesa_symbol_table_iterator_next(struct _mesa_symbol_table_iterator *iter)
261} 268}
262 269
263 270
271/**
272 * Determine the scope "distance" of a symbol from the current scope
273 *
274 * \return
275 * A non-negative number for the number of scopes between the current scope
276 * and the scope where a symbol was defined. A value of zero means the current
277 * scope. A negative number if the symbol does not exist.
278 */
279int
280_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table,
281 int name_space, const char *name)
282{
283 struct symbol_header *const hdr = find_symbol(table, name);
284 struct symbol *sym;
285
286 if (hdr != NULL) {
287 for (sym = hdr->symbols; sym != NULL; sym = sym->next_with_same_name) {
288 assert(sym->hdr == hdr);
289
290 if ((name_space == -1) || (sym->name_space == name_space)) {
291 assert(sym->depth <= table->depth);
292 return sym->depth - table->depth;
293 }
294 }
295 }
296
297 return -1;
298}
299
300
264void * 301void *
265_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table, 302_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table,
266 int name_space, const char *name) 303 int name_space, const char *name)
@@ -300,21 +337,34 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table,
300 337
301 if (hdr == NULL) { 338 if (hdr == NULL) {
302 hdr = calloc(1, sizeof(*hdr)); 339 hdr = calloc(1, sizeof(*hdr));
303 hdr->name = name; 340 hdr->name = strdup(name);
304 341
305 hash_table_insert(table->ht, hdr, name); 342 hash_table_insert(table->ht, hdr, hdr->name);
306 hdr->next = table->hdr; 343 hdr->next = table->hdr;
307 table->hdr = hdr; 344 table->hdr = hdr;
308 } 345 }
309 346
310 check_symbol_table(table); 347 check_symbol_table(table);
311 348
349 /* If the symbol already exists in this namespace at this scope, it cannot
350 * be added to the table.
351 */
352 for (sym = hdr->symbols
353 ; (sym != NULL) && (sym->name_space != name_space)
354 ; sym = sym->next_with_same_name) {
355 /* empty */
356 }
357
358 if (sym && (sym->depth == table->depth))
359 return -1;
360
312 sym = calloc(1, sizeof(*sym)); 361 sym = calloc(1, sizeof(*sym));
313 sym->next_with_same_name = hdr->symbols; 362 sym->next_with_same_name = hdr->symbols;
314 sym->next_with_same_scope = table->current_scope->symbols; 363 sym->next_with_same_scope = table->current_scope->symbols;
315 sym->hdr = hdr; 364 sym->hdr = hdr;
316 sym->name_space = name_space; 365 sym->name_space = name_space;
317 sym->data = declaration; 366 sym->data = declaration;
367 sym->depth = table->depth;
318 368
319 assert(sym->hdr == hdr); 369 assert(sym->hdr == hdr);
320 370
@@ -354,6 +404,7 @@ _mesa_symbol_table_dtor(struct _mesa_symbol_table *table)
354 404
355 for (hdr = table->hdr; hdr != NULL; hdr = next) { 405 for (hdr = table->hdr; hdr != NULL; hdr = next) {
356 next = hdr->next; 406 next = hdr->next;
407 free(hdr->name);
357 free(hdr); 408 free(hdr);
358 } 409 }
359 410
diff --git a/src/mesa/program/symbol_table.h b/src/mesa/program/symbol_table.h
index 0c054ef1396..1d570fc1a09 100644
--- a/src/mesa/program/symbol_table.h
+++ b/src/mesa/program/symbol_table.h
@@ -33,6 +33,9 @@ extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table);
33extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab, 33extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab,
34 int name_space, const char *name, void *declaration); 34 int name_space, const char *name, void *declaration);
35 35
36extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table,
37 int name_space, const char *name);
38
36extern void *_mesa_symbol_table_find_symbol( 39extern void *_mesa_symbol_table_find_symbol(
37 struct _mesa_symbol_table *symtab, int name_space, const char *name); 40 struct _mesa_symbol_table *symtab, int name_space, const char *name);
38 41
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index f01b60c4fc8..373f1b50d05 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -250,6 +250,9 @@ PROGRAM_SOURCES = \
250 program/programopt.c \ 250 program/programopt.c \
251 program/symbol_table.c 251 program/symbol_table.c
252 252
253SHADER_CXX_SOURCES = \
254 program/ir_to_mesa.cpp
255
253SLANG_SOURCES = \ 256SLANG_SOURCES = \
254 slang/slang_builtin.c \ 257 slang/slang_builtin.c \
255 slang/slang_codegen.c \ 258 slang/slang_codegen.c \
@@ -324,8 +327,10 @@ MESA_SOURCES = \
324 $(SWRAST_SOURCES) \ 327 $(SWRAST_SOURCES) \
325 $(SWRAST_SETUP_SOURCES) \ 328 $(SWRAST_SETUP_SOURCES) \
326 $(COMMON_DRIVER_SOURCES)\ 329 $(COMMON_DRIVER_SOURCES)\
327 $(ASM_C_SOURCES) \ 330 $(ASM_C_SOURCES)
328 $(SLANG_SOURCES) 331
332MESA_CXX_SOURCES = \
333 $(SHADER_CXX_SOURCES)
329 334
330# Sources for building Gallium drivers 335# Sources for building Gallium drivers
331MESA_GALLIUM_SOURCES = \ 336MESA_GALLIUM_SOURCES = \
@@ -335,12 +340,15 @@ MESA_GALLIUM_SOURCES = \
335 $(STATETRACKER_SOURCES) \ 340 $(STATETRACKER_SOURCES) \
336 $(PROGRAM_SOURCES) \ 341 $(PROGRAM_SOURCES) \
337 ppc/common_ppc.c \ 342 ppc/common_ppc.c \
338 x86/common_x86.c \ 343 x86/common_x86.c
339 $(SLANG_SOURCES) 344
345MESA_GALLIUM_CXX_SOURCES = \
346 $(SHADER_CXX_SOURCES)
340 347
341# All the core C sources, for dependency checking 348# All the core C sources, for dependency checking
342ALL_SOURCES = \ 349ALL_SOURCES = \
343 $(MESA_SOURCES) \ 350 $(MESA_SOURCES) \
351 $(MESA_CXX_SOURCES) \
344 $(MESA_ASM_SOURCES) \ 352 $(MESA_ASM_SOURCES) \
345 $(STATETRACKER_SOURCES) 353 $(STATETRACKER_SOURCES)
346 354
@@ -349,10 +357,12 @@ ALL_SOURCES = \
349 357
350MESA_OBJECTS = \ 358MESA_OBJECTS = \
351 $(MESA_SOURCES:.c=.o) \ 359 $(MESA_SOURCES:.c=.o) \
360 $(MESA_CXX_SOURCES:.cpp=.o) \
352 $(MESA_ASM_SOURCES:.S=.o) 361 $(MESA_ASM_SOURCES:.S=.o)
353 362
354MESA_GALLIUM_OBJECTS = \ 363MESA_GALLIUM_OBJECTS = \
355 $(MESA_GALLIUM_SOURCES:.c=.o) \ 364 $(MESA_GALLIUM_SOURCES:.c=.o) \
365 $(MESA_GALLIUM_CXX_SOURCES:.cpp=.o) \
356 $(MESA_ASM_SOURCES:.S=.o) 366 $(MESA_ASM_SOURCES:.S=.o)
357 367
358 368
@@ -362,8 +372,7 @@ COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o)
362### Other archives/libraries 372### Other archives/libraries
363 373
364GLSL_LIBS = \ 374GLSL_LIBS = \
365 $(TOP)/src/glsl/pp/libglslpp.a \ 375 $(TOP)/src/glsl/libglsl.a
366 $(TOP)/src/glsl/cl/libglslcl.a
367 376
368 377
369### Include directories 378### Include directories
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 91528c227b2..8c2d8b6154b 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -207,6 +207,9 @@ st_translate_vertex_program(struct st_context *st,
207 enum pipe_error error; 207 enum pipe_error error;
208 unsigned num_outputs; 208 unsigned num_outputs;
209 209
210 _mesa_remove_output_reads(&stvp->Base.Base, PROGRAM_OUTPUT);
211 _mesa_remove_output_reads(&stvp->Base.Base, PROGRAM_VARYING);
212
210 ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); 213 ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
211 if (ureg == NULL) { 214 if (ureg == NULL) {
212 FREE(vpv); 215 FREE(vpv);
@@ -298,6 +301,8 @@ st_translate_fragment_program(struct st_context *st,
298 ubyte fs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; 301 ubyte fs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
299 uint fs_num_outputs = 0; 302 uint fs_num_outputs = 0;
300 303
304 _mesa_remove_output_reads(&stfp->Base.Base, PROGRAM_OUTPUT);
305
301 /* 306 /*
302 * Convert Mesa program inputs to TGSI input register semantics. 307 * Convert Mesa program inputs to TGSI input register semantics.
303 */ 308 */
@@ -485,6 +490,9 @@ st_translate_geometry_program(struct st_context *st,
485 GLuint maxSlot = 0; 490 GLuint maxSlot = 0;
486 struct ureg_program *ureg; 491 struct ureg_program *ureg;
487 492
493 _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_OUTPUT);
494 _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_VARYING);
495
488 ureg = ureg_create( TGSI_PROCESSOR_GEOMETRY ); 496 ureg = ureg_create( TGSI_PROCESSOR_GEOMETRY );
489 if (ureg == NULL) { 497 if (ureg == NULL) {
490 return; 498 return;
diff --git a/src/talloc/SConscript b/src/talloc/SConscript
new file mode 100644
index 00000000000..a4861a932e5
--- /dev/null
+++ b/src/talloc/SConscript
@@ -0,0 +1,20 @@
1Import('*')
2
3if env['platform'] != 'windows':
4 Return()
5
6env = env.Clone()
7
8talloc = env.SharedLibrary(
9 target = 'talloc',
10 source = ['talloc.c', 'talloc.def'],
11)
12
13env.InstallSharedLibrary(talloc)
14
15if env['platform'] != 'windows':
16 talloc = env.FindIxes(talloc, 'LIBPREFIX', 'LIBSUFFIX')
17else:
18 talloc = env.FindIxes(talloc, 'SHLIBPREFIX', 'SHLIBSUFFIX')
19
20Export('talloc')
diff --git a/src/talloc/gpl-3.0.txt b/src/talloc/gpl-3.0.txt
new file mode 100644
index 00000000000..94a9ed024d3
--- /dev/null
+++ b/src/talloc/gpl-3.0.txt
@@ -0,0 +1,674 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 Preamble
9
10 The GNU General Public License is a free, copyleft license for
11software and other kinds of works.
12
13 The licenses for most software and other practical works are designed
14to take away your freedom to share and change the works. By contrast,
15the GNU General Public License is intended to guarantee your freedom to
16share and change all versions of a program--to make sure it remains free
17software for all its users. We, the Free Software Foundation, use the
18GNU General Public License for most of our software; it applies also to
19any other work released this way by its authors. You can apply it to
20your programs, too.
21
22 When we speak of free software, we are referring to freedom, not
23price. Our General Public Licenses are designed to make sure that you
24have the freedom to distribute copies of free software (and charge for
25them if you wish), that you receive source code or can get it if you
26want it, that you can change the software or use pieces of it in new
27free programs, and that you know you can do these things.
28
29 To protect your rights, we need to prevent others from denying you
30these rights or asking you to surrender the rights. Therefore, you have
31certain responsibilities if you distribute copies of the software, or if
32you modify it: responsibilities to respect the freedom of others.
33
34 For example, if you distribute copies of such a program, whether
35gratis or for a fee, you must pass on to the recipients the same
36freedoms that you received. You must make sure that they, too, receive
37or can get the source code. And you must show them these terms so they
38know their rights.
39
40 Developers that use the GNU GPL protect your rights with two steps:
41(1) assert copyright on the software, and (2) offer you this License
42giving you legal permission to copy, distribute and/or modify it.
43
44 For the developers' and authors' protection, the GPL clearly explains
45that there is no warranty for this free software. For both users' and
46authors' sake, the GPL requires that modified versions be marked as
47changed, so that their problems will not be attributed erroneously to
48authors of previous versions.
49
50 Some devices are designed to deny users access to install or run
51modified versions of the software inside them, although the manufacturer
52can do so. This is fundamentally incompatible with the aim of
53protecting users' freedom to change the software. The systematic
54pattern of such abuse occurs in the area of products for individuals to
55use, which is precisely where it is most unacceptable. Therefore, we
56have designed this version of the GPL to prohibit the practice for those
57products. If such problems arise substantially in other domains, we
58stand ready to extend this provision to those domains in future versions
59of the GPL, as needed to protect the freedom of users.
60
61 Finally, every program is threatened constantly by software patents.
62States should not allow patents to restrict development and use of
63software on general-purpose computers, but in those that do, we wish to
64avoid the special danger that patents applied to a free program could
65make it effectively proprietary. To prevent this, the GPL assures that
66patents cannot be used to render the program non-free.
67
68 The precise terms and conditions for copying, distribution and
69modification follow.
70
71 TERMS AND CONDITIONS
72
73 0. Definitions.
74
75 "This License" refers to version 3 of the GNU General Public License.
76
77 "Copyright" also means copyright-like laws that apply to other kinds of
78works, such as semiconductor masks.
79
80 "The Program" refers to any copyrightable work licensed under this
81License. Each licensee is addressed as "you". "Licensees" and
82"recipients" may be individuals or organizations.
83
84 To "modify" a work means to copy from or adapt all or part of the work
85in a fashion requiring copyright permission, other than the making of an
86exact copy. The resulting work is called a "modified version" of the
87earlier work or a work "based on" the earlier work.
88
89 A "covered work" means either the unmodified Program or a work based
90on the Program.
91
92 To "propagate" a work means to do anything with it that, without
93permission, would make you directly or secondarily liable for
94infringement under applicable copyright law, except executing it on a
95computer or modifying a private copy. Propagation includes copying,
96distribution (with or without modification), making available to the
97public, and in some countries other activities as well.
98
99 To "convey" a work means any kind of propagation that enables other
100parties to make or receive copies. Mere interaction with a user through
101a computer network, with no transfer of a copy, is not conveying.
102
103 An interactive user interface displays "Appropriate Legal Notices"
104to the extent that it includes a convenient and prominently visible
105feature that (1) displays an appropriate copyright notice, and (2)
106tells the user that there is no warranty for the work (except to the
107extent that warranties are provided), that licensees may convey the
108work under this License, and how to view a copy of this License. If
109the interface presents a list of user commands or options, such as a
110menu, a prominent item in the list meets this criterion.
111
112 1. Source Code.
113
114 The "source code" for a work means the preferred form of the work
115for making modifications to it. "Object code" means any non-source
116form of a work.
117
118 A "Standard Interface" means an interface that either is an official
119standard defined by a recognized standards body, or, in the case of
120interfaces specified for a particular programming language, one that
121is widely used among developers working in that language.
122
123 The "System Libraries" of an executable work include anything, other
124than the work as a whole, that (a) is included in the normal form of
125packaging a Major Component, but which is not part of that Major
126Component, and (b) serves only to enable use of the work with that
127Major Component, or to implement a Standard Interface for which an
128implementation is available to the public in source code form. A
129"Major Component", in this context, means a major essential component
130(kernel, window system, and so on) of the specific operating system
131(if any) on which the executable work runs, or a compiler used to
132produce the work, or an object code interpreter used to run it.
133
134 The "Corresponding Source" for a work in object code form means all
135the source code needed to generate, install, and (for an executable
136work) run the object code and to modify the work, including scripts to
137control those activities. However, it does not include the work's
138System Libraries, or general-purpose tools or generally available free
139programs which are used unmodified in performing those activities but
140which are not part of the work. For example, Corresponding Source
141includes interface definition files associated with source files for
142the work, and the source code for shared libraries and dynamically
143linked subprograms that the work is specifically designed to require,
144such as by intimate data communication or control flow between those
145subprograms and other parts of the work.
146
147 The Corresponding Source need not include anything that users
148can regenerate automatically from other parts of the Corresponding
149Source.
150
151 The Corresponding Source for a work in source code form is that
152same work.
153
154 2. Basic Permissions.
155
156 All rights granted under this License are granted for the term of
157copyright on the Program, and are irrevocable provided the stated
158conditions are met. This License explicitly affirms your unlimited
159permission to run the unmodified Program. The output from running a
160covered work is covered by this License only if the output, given its
161content, constitutes a covered work. This License acknowledges your
162rights of fair use or other equivalent, as provided by copyright law.
163
164 You may make, run and propagate covered works that you do not
165convey, without conditions so long as your license otherwise remains
166in force. You may convey covered works to others for the sole purpose
167of having them make modifications exclusively for you, or provide you
168with facilities for running those works, provided that you comply with
169the terms of this License in conveying all material for which you do
170not control copyright. Those thus making or running the covered works
171for you must do so exclusively on your behalf, under your direction
172and control, on terms that prohibit them from making any copies of
173your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176the conditions stated below. Sublicensing is not allowed; section 10
177makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182measure under any applicable law fulfilling obligations under article
18311 of the WIPO copyright treaty adopted on 20 December 1996, or
184similar laws prohibiting or restricting circumvention of such
185measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188circumvention of technological measures to the extent such circumvention
189is effected by exercising rights under this License with respect to
190the covered work, and you disclaim any intention to limit operation or
191modification of the work as a means of enforcing, against the work's
192users, your or third parties' legal rights to forbid circumvention of
193technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198receive it, in any medium, provided that you conspicuously and
199appropriately publish on each copy an appropriate copyright notice;
200keep intact all notices stating that this License and any
201non-permissive terms added in accord with section 7 apply to the code;
202keep intact all notices of the absence of any warranty; and give all
203recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211produce it from the Program, in the form of source code under the
212terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236works, which are not by their nature extensions of the covered work,
237and which are not combined with it such as to form a larger program,
238in or on a volume of a storage or distribution medium, is called an
239"aggregate" if the compilation and its resulting copyright are not
240used to limit the access or legal rights of the compilation's users
241beyond what the individual works permit. Inclusion of a covered work
242in an aggregate does not cause this License to apply to the other
243parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248of sections 4 and 5, provided that you also convey the
249machine-readable Corresponding Source under the terms of this License,
250in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294from the Corresponding Source as a System Library, need not be
295included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298tangible personal property which is normally used for personal, family,
299or household purposes, or (2) anything designed or sold for incorporation
300into a dwelling. In determining whether a product is a consumer product,
301doubtful cases shall be resolved in favor of coverage. For a particular
302product received by a particular user, "normally used" refers to a
303typical or common use of that class of product, regardless of the status
304of the particular user or of the way in which the particular user
305actually uses, or expects or is expected to use, the product. A product
306is a consumer product regardless of whether the product has substantial
307commercial, industrial or non-consumer uses, unless such uses represent
308the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311procedures, authorization keys, or other information required to install
312and execute modified versions of a covered work in that User Product from
313a modified version of its Corresponding Source. The information must
314suffice to ensure that the continued functioning of the modified object
315code is in no case prevented or interfered with solely because
316modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319specifically for use in, a User Product, and the conveying occurs as
320part of a transaction in which the right of possession and use of the
321User Product is transferred to the recipient in perpetuity or for a
322fixed term (regardless of how the transaction is characterized), the
323Corresponding Source conveyed under this section must be accompanied
324by the Installation Information. But this requirement does not apply
325if neither you nor any third party retains the ability to install
326modified object code on the User Product (for example, the work has
327been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330requirement to continue to provide support service, warranty, or updates
331for a work that has been modified or installed by the recipient, or for
332the User Product in which it has been modified or installed. Access to a
333network may be denied when the modification itself materially and
334adversely affects the operation of the network or violates the rules and
335protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338in accord with this section must be in a format that is publicly
339documented (and with an implementation available to the public in
340source code form), and must require no special password or key for
341unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346License by making exceptions from one or more of its conditions.
347Additional permissions that are applicable to the entire Program shall
348be treated as though they were included in this License, to the extent
349that they are valid under applicable law. If additional permissions
350apply only to part of the Program, that part may be used separately
351under those permissions, but the entire Program remains governed by
352this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355remove any additional permissions from that copy, or from any part of
356it. (Additional permissions may be written to require their own
357removal in certain cases when you modify the work.) You may place
358additional permissions on material, added by you to a covered work,
359for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362add to a covered work, you may (if authorized by the copyright holders of
363that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389restrictions" within the meaning of section 10. If the Program as you
390received it, or any part of it, contains a notice stating that it is
391governed by this License along with a term that is a further
392restriction, you may remove that term. If a license document contains
393a further restriction but permits relicensing or conveying under this
394License, you may add to a covered work material governed by the terms
395of that license document, provided that the further restriction does
396not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399must place, in the relevant source files, a statement of the
400additional terms that apply to those files, or a notice indicating
401where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404form of a separately written license, or stated as exceptions;
405the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410provided under this License. Any attempt otherwise to propagate or
411modify it is void, and will automatically terminate your rights under
412this License (including any patent licenses granted under the third
413paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416license from a particular copyright holder is reinstated (a)
417provisionally, unless and until the copyright holder explicitly and
418finally terminates your license, and (b) permanently, if the copyright
419holder fails to notify you of the violation by some reasonable means
420prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423reinstated permanently if the copyright holder notifies you of the
424violation by some reasonable means, this is the first time you have
425received notice of violation of this License (for any work) from that
426copyright holder, and you cure the violation prior to 30 days after
427your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430licenses of parties who have received copies or rights from you under
431this License. If your rights have been terminated and not permanently
432reinstated, you do not qualify to receive new licenses for the same
433material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438run a copy of the Program. Ancillary propagation of a covered work
439occurring solely as a consequence of using peer-to-peer transmission
440to receive a copy likewise does not require acceptance. However,
441nothing other than this License grants you permission to propagate or
442modify any covered work. These actions infringe copyright if you do
443not accept this License. Therefore, by modifying or propagating a
444covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449receives a license from the original licensors, to run, modify and
450propagate that work, subject to this License. You are not responsible
451for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454organization, or substantially all assets of one, or subdividing an
455organization, or merging organizations. If propagation of a covered
456work results from an entity transaction, each party to that
457transaction who receives a copy of the work also receives whatever
458licenses to the work the party's predecessor in interest had or could
459give under the previous paragraph, plus a right to possession of the
460Corresponding Source of the work from the predecessor in interest, if
461the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464rights granted or affirmed under this License. For example, you may
465not impose a license fee, royalty, or other charge for exercise of
466rights granted under this License, and you may not initiate litigation
467(including a cross-claim or counterclaim in a lawsuit) alleging that
468any patent claim is infringed by making, using, selling, offering for
469sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474License of the Program or a work on which the Program is based. The
475work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478owned or controlled by the contributor, whether already acquired or
479hereafter acquired, that would be infringed by some manner, permitted
480by this License, of making, using, or selling its contributor version,
481but do not include claims that would be infringed only as a
482consequence of further modification of the contributor version. For
483purposes of this definition, "control" includes the right to grant
484patent sublicenses in a manner consistent with the requirements of
485this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488patent license under the contributor's essential patent claims, to
489make, use, sell, offer for sale, import and otherwise run, modify and
490propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493agreement or commitment, however denominated, not to enforce a patent
494(such as an express permission to practice a patent or covenant not to
495sue for patent infringement). To "grant" such a patent license to a
496party means to make such an agreement or commitment not to enforce a
497patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500and the Corresponding Source of the work is not available for anyone
501to copy, free of charge and under the terms of this License, through a
502publicly available network server or other readily accessible means,
503then you must either (1) cause the Corresponding Source to be so
504available, or (2) arrange to deprive yourself of the benefit of the
505patent license for this particular work, or (3) arrange, in a manner
506consistent with the requirements of this License, to extend the patent
507license to downstream recipients. "Knowingly relying" means you have
508actual knowledge that, but for the patent license, your conveying the
509covered work in a country, or your recipient's use of the covered work
510in a country, would infringe one or more identifiable patents in that
511country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514arrangement, you convey, or propagate by procuring conveyance of, a
515covered work, and grant a patent license to some of the parties
516receiving the covered work authorizing them to use, propagate, modify
517or convey a specific copy of the covered work, then the patent license
518you grant is automatically extended to all recipients of the covered
519work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522the scope of its coverage, prohibits the exercise of, or is
523conditioned on the non-exercise of one or more of the rights that are
524specifically granted under this License. You may not convey a covered
525work if you are a party to an arrangement with a third party that is
526in the business of distributing software, under which you make payment
527to the third party based on the extent of your activity of conveying
528the work, and under which the third party grants, to any of the
529parties who would receive the covered work from you, a discriminatory
530patent license (a) in connection with copies of the covered work
531conveyed by you (or copies made from those copies), or (b) primarily
532for and in connection with specific products or compilations that
533contain the covered work, unless you entered into that arrangement,
534or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537any implied license or other defenses to infringement that may
538otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543otherwise) that contradict the conditions of this License, they do not
544excuse you from the conditions of this License. If you cannot convey a
545covered work so as to satisfy simultaneously your obligations under this
546License and any other pertinent obligations, then as a consequence you may
547not convey it at all. For example, if you agree to terms that obligate you
548to collect a royalty for further conveying from those to whom you convey
549the Program, the only way you could satisfy both those terms and this
550License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555permission to link or combine any covered work with a work licensed
556under version 3 of the GNU Affero General Public License into a single
557combined work, and to convey the resulting work. The terms of this
558License will continue to apply to the part which is the covered work,
559but the special requirements of the GNU Affero General Public License,
560section 13, concerning interaction through a network will apply to the
561combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566the GNU General Public License from time to time. Such new versions will
567be similar in spirit to the present version, but may differ in detail to
568address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571Program specifies that a certain numbered version of the GNU General
572Public License "or any later version" applies to it, you have the
573option of following the terms and conditions either of that numbered
574version or of any later version published by the Free Software
575Foundation. If the Program does not specify a version number of the
576GNU General Public License, you may choose any version ever published
577by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580versions of the GNU General Public License can be used, that proxy's
581public statement of acceptance of a version permanently authorizes you
582to choose that version for the Program.
583
584 Later license versions may give you additional or different
585permissions. However, no additional obligations are imposed on any
586author or copyright holder as a result of your choosing to follow a
587later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615above cannot be given local legal effect according to their terms,
616reviewing courts shall apply local law that most closely approximates
617an absolute waiver of all civil liability in connection with the
618Program, unless a warranty or assumption of liability accompanies a
619copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626possible use to the public, the best way to achieve this is to make it
627free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630to attach them to the start of each source file to most effectively
631state the exclusion of warranty; and each file should have at least
632the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <http://www.gnu.org/licenses/>.
649
650Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660The hypothetical commands `show w' and `show c' should show the appropriate
661parts of the General Public License. Of course, your program's commands
662might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665if any, to sign a "copyright disclaimer" for the program, if necessary.
666For more information on this, and how to apply and follow the GNU GPL, see
667<http://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670into proprietary programs. If your program is a subroutine library, you
671may consider it more useful to permit linking proprietary applications with
672the library. If this is what you want to do, use the GNU Lesser General
673Public License instead of this License. But first, please read
674<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/src/talloc/lgpl-3.0.txt b/src/talloc/lgpl-3.0.txt
new file mode 100644
index 00000000000..65c5ca88a67
--- /dev/null
+++ b/src/talloc/lgpl-3.0.txt
@@ -0,0 +1,165 @@
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8
9 This version of the GNU Lesser General Public License incorporates
10the terms and conditions of version 3 of the GNU General Public
11License, supplemented by the additional permissions listed below.
12
13 0. Additional Definitions.
14
15 As used herein, "this License" refers to version 3 of the GNU Lesser
16General Public License, and the "GNU GPL" refers to version 3 of the GNU
17General Public License.
18
19 "The Library" refers to a covered work governed by this License,
20other than an Application or a Combined Work as defined below.
21
22 An "Application" is any work that makes use of an interface provided
23by the Library, but which is not otherwise based on the Library.
24Defining a subclass of a class defined by the Library is deemed a mode
25of using an interface provided by the Library.
26
27 A "Combined Work" is a work produced by combining or linking an
28Application with the Library. The particular version of the Library
29with which the Combined Work was made is also called the "Linked
30Version".
31
32 The "Minimal Corresponding Source" for a Combined Work means the
33Corresponding Source for the Combined Work, excluding any source code
34for portions of the Combined Work that, considered in isolation, are
35based on the Application, and not on the Linked Version.
36
37 The "Corresponding Application Code" for a Combined Work means the
38object code and/or source code for the Application, including any data
39and utility programs needed for reproducing the Combined Work from the
40Application, but excluding the System Libraries of the Combined Work.
41
42 1. Exception to Section 3 of the GNU GPL.
43
44 You may convey a covered work under sections 3 and 4 of this License
45without being bound by section 3 of the GNU GPL.
46
47 2. Conveying Modified Versions.
48
49 If you modify a copy of the Library, and, in your modifications, a
50facility refers to a function or data to be supplied by an Application
51that uses the facility (other than as an argument passed when the
52facility is invoked), then you may convey a copy of the modified
53version:
54
55 a) under this License, provided that you make a good faith effort to
56 ensure that, in the event an Application does not supply the
57 function or data, the facility still operates, and performs
58 whatever part of its purpose remains meaningful, or
59
60 b) under the GNU GPL, with none of the additional permissions of
61 this License applicable to that copy.
62
63 3. Object Code Incorporating Material from Library Header Files.
64
65 The object code form of an Application may incorporate material from
66a header file that is part of the Library. You may convey such object
67code under terms of your choice, provided that, if the incorporated
68material is not limited to numerical parameters, data structure
69layouts and accessors, or small macros, inline functions and templates
70(ten or fewer lines in length), you do both of the following:
71
72 a) Give prominent notice with each copy of the object code that the
73 Library is used in it and that the Library and its use are
74 covered by this License.
75
76 b) Accompany the object code with a copy of the GNU GPL and this license
77 document.
78
79 4. Combined Works.
80
81 You may convey a Combined Work under terms of your choice that,
82taken together, effectively do not restrict modification of the
83portions of the Library contained in the Combined Work and reverse
84engineering for debugging such modifications, if you also do each of
85the following:
86
87 a) Give prominent notice with each copy of the Combined Work that
88 the Library is used in it and that the Library and its use are
89 covered by this License.
90
91 b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 document.
93
94 c) For a Combined Work that displays copyright notices during
95 execution, include the copyright notice for the Library among
96 these notices, as well as a reference directing the user to the
97 copies of the GNU GPL and this license document.
98
99 d) Do one of the following:
100
101 0) Convey the Minimal Corresponding Source under the terms of this
102 License, and the Corresponding Application Code in a form
103 suitable for, and under terms that permit, the user to
104 recombine or relink the Application with a modified version of
105 the Linked Version to produce a modified Combined Work, in the
106 manner specified by section 6 of the GNU GPL for conveying
107 Corresponding Source.
108
109 1) Use a suitable shared library mechanism for linking with the
110 Library. A suitable mechanism is one that (a) uses at run time
111 a copy of the Library already present on the user's computer
112 system, and (b) will operate properly with a modified version
113 of the Library that is interface-compatible with the Linked
114 Version.
115
116 e) Provide Installation Information, but only if you would otherwise
117 be required to provide such information under section 6 of the
118 GNU GPL, and only to the extent that such information is
119 necessary to install and execute a modified version of the
120 Combined Work produced by recombining or relinking the
121 Application with a modified version of the Linked Version. (If
122 you use option 4d0, the Installation Information must accompany
123 the Minimal Corresponding Source and Corresponding Application
124 Code. If you use option 4d1, you must provide the Installation
125 Information in the manner specified by section 6 of the GNU GPL
126 for conveying Corresponding Source.)
127
128 5. Combined Libraries.
129
130 You may place library facilities that are a work based on the
131Library side by side in a single library together with other library
132facilities that are not Applications and are not covered by this
133License, and convey such a combined library under terms of your
134choice, if you do both of the following:
135
136 a) Accompany the combined library with a copy of the same work based
137 on the Library, uncombined with any other library facilities,
138 conveyed under the terms of this License.
139
140 b) Give prominent notice with the combined library that part of it
141 is a work based on the Library, and explaining where to find the
142 accompanying uncombined form of the same work.
143
144 6. Revised Versions of the GNU Lesser General Public License.
145
146 The Free Software Foundation may publish revised and/or new versions
147of the GNU Lesser General Public License from time to time. Such new
148versions will be similar in spirit to the present version, but may
149differ in detail to address new problems or concerns.
150
151 Each version is given a distinguishing version number. If the
152Library as you received it specifies that a certain numbered version
153of the GNU Lesser General Public License "or any later version"
154applies to it, you have the option of following the terms and
155conditions either of that published version or of any later version
156published by the Free Software Foundation. If the Library as you
157received it does not specify a version number of the GNU Lesser
158General Public License, you may choose any version of the GNU Lesser
159General Public License ever published by the Free Software Foundation.
160
161 If the Library as you received it specifies that a proxy can decide
162whether future versions of the GNU Lesser General Public License shall
163apply, that proxy's public statement of acceptance of any version is
164permanent authorization for you to choose that version for the
165Library.
diff --git a/src/talloc/talloc.c b/src/talloc/talloc.c
new file mode 100644
index 00000000000..cc01346a7f0
--- /dev/null
+++ b/src/talloc/talloc.c
@@ -0,0 +1,2034 @@
1/*
2 Samba Unix SMB/CIFS implementation.
3
4 Samba trivial allocation library - new interface
5
6 NOTE: Please read talloc_guide.txt for full documentation
7
8 Copyright (C) Andrew Tridgell 2004
9 Copyright (C) Stefan Metzmacher 2006
10
11 ** NOTE! The following LGPL license applies to the talloc
12 ** library. This does NOT imply that all of Samba is released
13 ** under the LGPL
14
15 This library is free software; you can redistribute it and/or
16 modify it under the terms of the GNU Lesser General Public
17 License as published by the Free Software Foundation; either
18 version 3 of the License, or (at your option) any later version.
19
20 This library is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 Lesser General Public License for more details.
24
25 You should have received a copy of the GNU Lesser General Public
26 License along with this library; if not, see <http://www.gnu.org/licenses/>.
27*/
28
29/*
30 inspired by http://swapped.cc/halloc/
31*/
32
33#include "talloc.h"
34#include <string.h>
35
36#define TALLOC_MIN(a,b) ((a)<(b)?(a):(b))
37
38/* Visual C++ 2008 compatibility */
39#if defined(_MSC_VER) && !defined(_cplusplus)
40typedef size_t ssize_t;
41#define inline __inline
42#endif
43
44/* Xcode/gcc4.0 compatibility */
45#if defined(__APPLE__) || defined(__MINGW32__)
46static size_t strnlen (const char* s, size_t n)
47{
48 size_t i;
49 for (i = 0; i < n; ++i)
50 {
51 if (s[i] == '\0')
52 break;
53 }
54 return i;
55}
56#endif
57
58/* Visual C++ 2008 & Xcode/gcc4.0 compatibility */
59#if !defined(_cplusplus) && (defined(WIN32) || defined(__APPLE__))
60typedef int bool;
61#define false 0
62#define true 1
63#endif
64
65
66#ifdef TALLOC_BUILD_VERSION_MAJOR
67#if (TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR)
68#error "TALLOC_VERSION_MAJOR != TALLOC_BUILD_VERSION_MAJOR"
69#endif
70#endif
71
72#ifdef TALLOC_BUILD_VERSION_MINOR
73#if (TALLOC_VERSION_MINOR != TALLOC_BUILD_VERSION_MINOR)
74#error "TALLOC_VERSION_MINOR != TALLOC_BUILD_VERSION_MINOR"
75#endif
76#endif
77
78/* use this to force every realloc to change the pointer, to stress test
79 code that might not cope */
80#define ALWAYS_REALLOC 0
81
82
83#define MAX_TALLOC_SIZE 0x10000000
84#define TALLOC_MAGIC_BASE 0xe814ec70
85#define TALLOC_MAGIC ( \
86 TALLOC_MAGIC_BASE + \
87 (TALLOC_VERSION_MAJOR << 12) + \
88 (TALLOC_VERSION_MINOR << 4) \
89)
90
91#define TALLOC_FLAG_FREE 0x01
92#define TALLOC_FLAG_LOOP 0x02
93#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */
94#define TALLOC_FLAG_POOLMEM 0x08 /* This is allocated in a pool */
95#define TALLOC_MAGIC_REFERENCE ((const char *)1)
96
97/* by default we abort when given a bad pointer (such as when talloc_free() is called
98 on a pointer that came from malloc() */
99#ifndef TALLOC_ABORT
100#define TALLOC_ABORT(reason) abort()
101#endif
102
103#ifndef discard_const_p
104#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
105# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr)))
106#else
107# define discard_const_p(type, ptr) ((type *)(ptr))
108#endif
109#endif
110
111/* these macros gain us a few percent of speed on gcc */
112#if (__GNUC__ >= 3)
113/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1
114 as its first argument */
115#ifndef likely
116#define likely(x) __builtin_expect(!!(x), 1)
117#endif
118#ifndef unlikely
119#define unlikely(x) __builtin_expect(!!(x), 0)
120#endif
121#else
122#ifndef likely
123#define likely(x) (x)
124#endif
125#ifndef unlikely
126#define unlikely(x) (x)
127#endif
128#endif
129
130/* this null_context is only used if talloc_enable_leak_report() or
131 talloc_enable_leak_report_full() is called, otherwise it remains
132 NULL
133*/
134static void *null_context;
135static void *autofree_context;
136
137struct talloc_reference_handle {
138 struct talloc_reference_handle *next, *prev;
139 void *ptr;
140 const char *location;
141};
142
143typedef int (*talloc_destructor_t)(void *);
144
145struct talloc_chunk {
146 struct talloc_chunk *next, *prev;
147 struct talloc_chunk *parent, *child;
148 struct talloc_reference_handle *refs;
149 talloc_destructor_t destructor;
150 const char *name;
151 size_t size;
152 unsigned flags;
153
154 /*
155 * "pool" has dual use:
156 *
157 * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool"
158 * marks the end of the currently allocated area.
159 *
160 * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
161 * is a pointer to the struct talloc_chunk of the pool that it was
162 * allocated from. This way children can quickly find the pool to chew
163 * from.
164 */
165 void *pool;
166};
167
168/* 16 byte alignment seems to keep everyone happy */
169#define TC_HDR_SIZE ((sizeof(struct talloc_chunk)+15)&~15)
170#define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc))
171
172int talloc_version_major(void)
173{
174 return TALLOC_VERSION_MAJOR;
175}
176
177int talloc_version_minor(void)
178{
179 return TALLOC_VERSION_MINOR;
180}
181
182static void (*talloc_log_fn)(const char *message);
183
184void talloc_set_log_fn(void (*log_fn)(const char *message))
185{
186 talloc_log_fn = log_fn;
187}
188
189static void talloc_log(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
190static void talloc_log(const char *fmt, ...)
191{
192 va_list ap;
193 char *message;
194
195 if (!talloc_log_fn) {
196 return;
197 }
198
199 va_start(ap, fmt);
200 message = talloc_vasprintf(NULL, fmt, ap);
201 va_end(ap);
202
203 talloc_log_fn(message);
204 talloc_free(message);
205}
206
207static void talloc_log_stderr(const char *message)
208{
209 fprintf(stderr, "%s", message);
210}
211
212void talloc_set_log_stderr(void)
213{
214 talloc_set_log_fn(talloc_log_stderr);
215}
216
217static void (*talloc_abort_fn)(const char *reason);
218
219void talloc_set_abort_fn(void (*abort_fn)(const char *reason))
220{
221 talloc_abort_fn = abort_fn;
222}
223
224static void talloc_abort(const char *reason)
225{
226 talloc_log("%s\n", reason);
227
228 if (!talloc_abort_fn) {
229 TALLOC_ABORT(reason);
230 }
231
232 talloc_abort_fn(reason);
233}
234
235static void talloc_abort_magic(unsigned magic)
236{
237 unsigned striped = magic - TALLOC_MAGIC_BASE;
238 unsigned major = (striped & 0xFFFFF000) >> 12;
239 unsigned minor = (striped & 0x00000FF0) >> 4;
240 talloc_log("Bad talloc magic[0x%08X/%u/%u] expected[0x%08X/%u/%u]\n",
241 magic, major, minor,
242 TALLOC_MAGIC, TALLOC_VERSION_MAJOR, TALLOC_VERSION_MINOR);
243 talloc_abort("Bad talloc magic value - wrong talloc version used/mixed");
244}
245
246static void talloc_abort_double_free(void)
247{
248 talloc_abort("Bad talloc magic value - double free");
249}
250
251static void talloc_abort_unknown_value(void)
252{
253 talloc_abort("Bad talloc magic value - unknown value");
254}
255
256/* panic if we get a bad magic value */
257static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr)
258{
259 const char *pp = (const char *)ptr;
260 struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE);
261 if (unlikely((tc->flags & (TALLOC_FLAG_FREE | ~0xF)) != TALLOC_MAGIC)) {
262 if ((tc->flags & (~0xFFF)) == TALLOC_MAGIC_BASE) {
263 talloc_abort_magic(tc->flags & (~0xF));
264 return NULL;
265 }
266
267 if (tc->flags & TALLOC_FLAG_FREE) {
268 talloc_log("talloc: double free error - first free may be at %s\n", tc->name);
269 talloc_abort_double_free();
270 return NULL;
271 } else {
272 talloc_abort_unknown_value();
273 return NULL;
274 }
275 }
276 return tc;
277}
278
279/* hook into the front of the list */
280#define _TLIST_ADD(list, p) \
281do { \
282 if (!(list)) { \
283 (list) = (p); \
284 (p)->next = (p)->prev = NULL; \
285 } else { \
286 (list)->prev = (p); \
287 (p)->next = (list); \
288 (p)->prev = NULL; \
289 (list) = (p); \
290 }\
291} while (0)
292
293/* remove an element from a list - element doesn't have to be in list. */
294#define _TLIST_REMOVE(list, p) \
295do { \
296 if ((p) == (list)) { \
297 (list) = (p)->next; \
298 if (list) (list)->prev = NULL; \
299 } else { \
300 if ((p)->prev) (p)->prev->next = (p)->next; \
301 if ((p)->next) (p)->next->prev = (p)->prev; \
302 } \
303 if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
304} while (0)
305
306
307/*
308 return the parent chunk of a pointer
309*/
310static inline struct talloc_chunk *talloc_parent_chunk(const void *ptr)
311{
312 struct talloc_chunk *tc;
313
314 if (unlikely(ptr == NULL)) {
315 return NULL;
316 }
317
318 tc = talloc_chunk_from_ptr(ptr);
319 while (tc->prev) tc=tc->prev;
320
321 return tc->parent;
322}
323
324void *talloc_parent(const void *ptr)
325{
326 struct talloc_chunk *tc = talloc_parent_chunk(ptr);
327 return tc? TC_PTR_FROM_CHUNK(tc) : NULL;
328}
329
330/*
331 find parents name
332*/
333const char *talloc_parent_name(const void *ptr)
334{
335 struct talloc_chunk *tc = talloc_parent_chunk(ptr);
336 return tc? tc->name : NULL;
337}
338
339/*
340 A pool carries an in-pool object count count in the first 16 bytes.
341 bytes. This is done to support talloc_steal() to a parent outside of the
342 pool. The count includes the pool itself, so a talloc_free() on a pool will
343 only destroy the pool if the count has dropped to zero. A talloc_free() of a
344 pool member will reduce the count, and eventually also call free(3) on the
345 pool memory.
346
347 The object count is not put into "struct talloc_chunk" because it is only
348 relevant for talloc pools and the alignment to 16 bytes would increase the
349 memory footprint of each talloc chunk by those 16 bytes.
350*/
351
352#define TALLOC_POOL_HDR_SIZE 16
353
354static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc)
355{
356 return (unsigned int *)((char *)tc + sizeof(struct talloc_chunk));
357}
358
359/*
360 Allocate from a pool
361*/
362
363static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
364 size_t size)
365{
366 struct talloc_chunk *pool_ctx = NULL;
367 size_t space_left;
368 struct talloc_chunk *result;
369 size_t chunk_size;
370
371 if (parent == NULL) {
372 return NULL;
373 }
374
375 if (parent->flags & TALLOC_FLAG_POOL) {
376 pool_ctx = parent;
377 }
378 else if (parent->flags & TALLOC_FLAG_POOLMEM) {
379 pool_ctx = (struct talloc_chunk *)parent->pool;
380 }
381
382 if (pool_ctx == NULL) {
383 return NULL;
384 }
385
386 space_left = ((char *)pool_ctx + TC_HDR_SIZE + pool_ctx->size)
387 - ((char *)pool_ctx->pool);
388
389 /*
390 * Align size to 16 bytes
391 */
392 chunk_size = ((size + 15) & ~15);
393
394 if (space_left < chunk_size) {
395 return NULL;
396 }
397
398 result = (struct talloc_chunk *)pool_ctx->pool;
399
400#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
401 VALGRIND_MAKE_MEM_UNDEFINED(result, size);
402#endif
403
404 pool_ctx->pool = (void *)((char *)result + chunk_size);
405
406 result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
407 result->pool = pool_ctx;
408
409 *talloc_pool_objectcount(pool_ctx) += 1;
410
411 return result;
412}
413
414/*
415 Allocate a bit of memory as a child of an existing pointer
416*/
417static inline void *__talloc(const void *context, size_t size)
418{
419 struct talloc_chunk *tc = NULL;
420
421 if (unlikely(context == NULL)) {
422 context = null_context;
423 }
424
425 if (unlikely(size >= MAX_TALLOC_SIZE)) {
426 return NULL;
427 }
428
429 if (context != NULL) {
430 tc = talloc_alloc_pool(talloc_chunk_from_ptr(context),
431 TC_HDR_SIZE+size);
432 }
433
434 if (tc == NULL) {
435 tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
436 if (unlikely(tc == NULL)) return NULL;
437 tc->flags = TALLOC_MAGIC;
438 tc->pool = NULL;
439 }
440
441 tc->size = size;
442 tc->destructor = NULL;
443 tc->child = NULL;
444 tc->name = NULL;
445 tc->refs = NULL;
446
447 if (likely(context)) {
448 struct talloc_chunk *parent = talloc_chunk_from_ptr(context);
449
450 if (parent->child) {
451 parent->child->parent = NULL;
452 tc->next = parent->child;
453 tc->next->prev = tc;
454 } else {
455 tc->next = NULL;
456 }
457 tc->parent = parent;
458 tc->prev = NULL;
459 parent->child = tc;
460 } else {
461 tc->next = tc->prev = tc->parent = NULL;
462 }
463
464 return TC_PTR_FROM_CHUNK(tc);
465}
466
467/*
468 * Create a talloc pool
469 */
470
471void *talloc_pool(const void *context, size_t size)
472{
473 void *result = __talloc(context, size + TALLOC_POOL_HDR_SIZE);
474 struct talloc_chunk *tc;
475
476 if (unlikely(result == NULL)) {
477 return NULL;
478 }
479
480 tc = talloc_chunk_from_ptr(result);
481
482 tc->flags |= TALLOC_FLAG_POOL;
483 tc->pool = (char *)result + TALLOC_POOL_HDR_SIZE;
484
485 *talloc_pool_objectcount(tc) = 1;
486
487#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
488 VALGRIND_MAKE_MEM_NOACCESS(tc->pool, size);
489#endif
490
491 return result;
492}
493
494/*
495 setup a destructor to be called on free of a pointer
496 the destructor should return 0 on success, or -1 on failure.
497 if the destructor fails then the free is failed, and the memory can
498 be continued to be used
499*/
500void _talloc_set_destructor(const void *ptr, int (*destructor)(void *))
501{
502 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
503 tc->destructor = destructor;
504}
505
506/*
507 increase the reference count on a piece of memory.
508*/
509int talloc_increase_ref_count(const void *ptr)
510{
511 if (unlikely(!talloc_reference(null_context, ptr))) {
512 return -1;
513 }
514 return 0;
515}
516
517/*
518 helper for talloc_reference()
519
520 this is referenced by a function pointer and should not be inline
521*/
522static int talloc_reference_destructor(struct talloc_reference_handle *handle)
523{
524 struct talloc_chunk *ptr_tc = talloc_chunk_from_ptr(handle->ptr);
525 _TLIST_REMOVE(ptr_tc->refs, handle);
526 return 0;
527}
528
529/*
530 more efficient way to add a name to a pointer - the name must point to a
531 true string constant
532*/
533static inline void _talloc_set_name_const(const void *ptr, const char *name)
534{
535 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
536 tc->name = name;
537}
538
539/*
540 internal talloc_named_const()
541*/
542static inline void *_talloc_named_const(const void *context, size_t size, const char *name)
543{
544 void *ptr;
545
546 ptr = __talloc(context, size);
547 if (unlikely(ptr == NULL)) {
548 return NULL;
549 }
550
551 _talloc_set_name_const(ptr, name);
552
553 return ptr;
554}
555
556/*
557 make a secondary reference to a pointer, hanging off the given context.
558 the pointer remains valid until both the original caller and this given
559 context are freed.
560
561 the major use for this is when two different structures need to reference the
562 same underlying data, and you want to be able to free the two instances separately,
563 and in either order
564*/
565void *_talloc_reference_loc(const void *context, const void *ptr, const char *location)
566{
567 struct talloc_chunk *tc;
568 struct talloc_reference_handle *handle;
569 if (unlikely(ptr == NULL)) return NULL;
570
571 tc = talloc_chunk_from_ptr(ptr);
572 handle = (struct talloc_reference_handle *)_talloc_named_const(context,
573 sizeof(struct talloc_reference_handle),
574 TALLOC_MAGIC_REFERENCE);
575 if (unlikely(handle == NULL)) return NULL;
576
577 /* note that we hang the destructor off the handle, not the
578 main context as that allows the caller to still setup their
579 own destructor on the context if they want to */
580 talloc_set_destructor(handle, talloc_reference_destructor);
581 handle->ptr = discard_const_p(void, ptr);
582 handle->location = location;
583 _TLIST_ADD(tc->refs, handle);
584 return handle->ptr;
585}
586
587static void *_talloc_steal_internal(const void *new_ctx, const void *ptr);
588
589/*
590 internal talloc_free call
591*/
592static inline int _talloc_free_internal(void *ptr, const char *location)
593{
594 struct talloc_chunk *tc;
595
596 if (unlikely(ptr == NULL)) {
597 return -1;
598 }
599
600 tc = talloc_chunk_from_ptr(ptr);
601
602 if (unlikely(tc->refs)) {
603 int is_child;
604 /* check this is a reference from a child or grantchild
605 * back to it's parent or grantparent
606 *
607 * in that case we need to remove the reference and
608 * call another instance of talloc_free() on the current
609 * pointer.
610 */
611 is_child = talloc_is_parent(tc->refs, ptr);
612 _talloc_free_internal(tc->refs, location);
613 if (is_child) {
614 return _talloc_free_internal(ptr, location);
615 }
616 return -1;
617 }
618
619 if (unlikely(tc->flags & TALLOC_FLAG_LOOP)) {
620 /* we have a free loop - stop looping */
621 return 0;
622 }
623
624 if (unlikely(tc->destructor)) {
625 talloc_destructor_t d = tc->destructor;
626 if (d == (talloc_destructor_t)-1) {
627 return -1;
628 }
629 tc->destructor = (talloc_destructor_t)-1;
630 if (d(ptr) == -1) {
631 tc->destructor = d;
632 return -1;
633 }
634 tc->destructor = NULL;
635 }
636
637 if (tc->parent) {
638 _TLIST_REMOVE(tc->parent->child, tc);
639 if (tc->parent->child) {
640 tc->parent->child->parent = tc->parent;
641 }
642 } else {
643 if (tc->prev) tc->prev->next = tc->next;
644 if (tc->next) tc->next->prev = tc->prev;
645 }
646
647 tc->flags |= TALLOC_FLAG_LOOP;
648
649 while (tc->child) {
650 /* we need to work out who will own an abandoned child
651 if it cannot be freed. In priority order, the first
652 choice is owner of any remaining reference to this
653 pointer, the second choice is our parent, and the
654 final choice is the null context. */
655 void *child = TC_PTR_FROM_CHUNK(tc->child);
656 const void *new_parent = null_context;
657 if (unlikely(tc->child->refs)) {
658 struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs);
659 if (p) new_parent = TC_PTR_FROM_CHUNK(p);
660 }
661 if (unlikely(_talloc_free_internal(child, location) == -1)) {
662 if (new_parent == null_context) {
663 struct talloc_chunk *p = talloc_parent_chunk(ptr);
664 if (p) new_parent = TC_PTR_FROM_CHUNK(p);
665 }
666 _talloc_steal_internal(new_parent, child);
667 }
668 }
669
670 tc->flags |= TALLOC_FLAG_FREE;
671
672 /* we mark the freed memory with where we called the free
673 * from. This means on a double free error we can report where
674 * the first free came from
675 */
676 tc->name = location;
677
678 if (tc->flags & (TALLOC_FLAG_POOL|TALLOC_FLAG_POOLMEM)) {
679 struct talloc_chunk *pool;
680 unsigned int *pool_object_count;
681
682 pool = (tc->flags & TALLOC_FLAG_POOL)
683 ? tc : (struct talloc_chunk *)tc->pool;
684
685 pool_object_count = talloc_pool_objectcount(pool);
686
687 if (*pool_object_count == 0) {
688 talloc_abort("Pool object count zero!");
689 return 0;
690 }
691
692 *pool_object_count -= 1;
693
694 if (*pool_object_count == 0) {
695 free(pool);
696 }
697 }
698 else {
699 free(tc);
700 }
701 return 0;
702}
703
704/*
705 move a lump of memory from one talloc context to another return the
706 ptr on success, or NULL if it could not be transferred.
707 passing NULL as ptr will always return NULL with no side effects.
708*/
709static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
710{
711 struct talloc_chunk *tc, *new_tc;
712
713 if (unlikely(!ptr)) {
714 return NULL;
715 }
716
717 if (unlikely(new_ctx == NULL)) {
718 new_ctx = null_context;
719 }
720
721 tc = talloc_chunk_from_ptr(ptr);
722
723 if (unlikely(new_ctx == NULL)) {
724 if (tc->parent) {
725 _TLIST_REMOVE(tc->parent->child, tc);
726 if (tc->parent->child) {
727 tc->parent->child->parent = tc->parent;
728 }
729 } else {
730 if (tc->prev) tc->prev->next = tc->next;
731 if (tc->next) tc->next->prev = tc->prev;
732 }
733
734 tc->parent = tc->next = tc->prev = NULL;
735 return discard_const_p(void, ptr);
736 }
737
738 new_tc = talloc_chunk_from_ptr(new_ctx);
739
740 if (unlikely(tc == new_tc || tc->parent == new_tc)) {
741 return discard_const_p(void, ptr);
742 }
743
744 if (tc->parent) {
745 _TLIST_REMOVE(tc->parent->child, tc);
746 if (tc->parent->child) {
747 tc->parent->child->parent = tc->parent;
748 }
749 } else {
750 if (tc->prev) tc->prev->next = tc->next;
751 if (tc->next) tc->next->prev = tc->prev;
752 }
753
754 tc->parent = new_tc;
755 if (new_tc->child) new_tc->child->parent = NULL;
756 _TLIST_ADD(new_tc->child, tc);
757
758 return discard_const_p(void, ptr);
759}
760
761/*
762 move a lump of memory from one talloc context to another return the
763 ptr on success, or NULL if it could not be transferred.
764 passing NULL as ptr will always return NULL with no side effects.
765*/
766void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location)
767{
768 struct talloc_chunk *tc;
769
770 if (unlikely(ptr == NULL)) {
771 return NULL;
772 }
773
774 tc = talloc_chunk_from_ptr(ptr);
775
776 if (unlikely(tc->refs != NULL) && talloc_parent(ptr) != new_ctx) {
777 struct talloc_reference_handle *h;
778
779 talloc_log("WARNING: talloc_steal with references at %s\n",
780 location);
781
782 for (h=tc->refs; h; h=h->next) {
783 talloc_log("\treference at %s\n",
784 h->location);
785 }
786 }
787
788 return _talloc_steal_internal(new_ctx, ptr);
789}
790
791/*
792 this is like a talloc_steal(), but you must supply the old
793 parent. This resolves the ambiguity in a talloc_steal() which is
794 called on a context that has more than one parent (via references)
795
796 The old parent can be either a reference or a parent
797*/
798void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr)
799{
800 struct talloc_chunk *tc;
801 struct talloc_reference_handle *h;
802
803 if (unlikely(ptr == NULL)) {
804 return NULL;
805 }
806
807 if (old_parent == talloc_parent(ptr)) {
808 return _talloc_steal_internal(new_parent, ptr);
809 }
810
811 tc = talloc_chunk_from_ptr(ptr);
812 for (h=tc->refs;h;h=h->next) {
813 if (talloc_parent(h) == old_parent) {
814 if (_talloc_steal_internal(new_parent, h) != h) {
815 return NULL;
816 }
817 return discard_const_p(void, ptr);
818 }
819 }
820
821 /* it wasn't a parent */
822 return NULL;
823}
824
825/*
826 remove a secondary reference to a pointer. This undo's what
827 talloc_reference() has done. The context and pointer arguments
828 must match those given to a talloc_reference()
829*/
830static inline int talloc_unreference(const void *context, const void *ptr)
831{
832 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
833 struct talloc_reference_handle *h;
834
835 if (unlikely(context == NULL)) {
836 context = null_context;
837 }
838
839 for (h=tc->refs;h;h=h->next) {
840 struct talloc_chunk *p = talloc_parent_chunk(h);
841 if (p == NULL) {
842 if (context == NULL) break;
843 } else if (TC_PTR_FROM_CHUNK(p) == context) {
844 break;
845 }
846 }
847 if (h == NULL) {
848 return -1;
849 }
850
851 return _talloc_free_internal(h, __location__);
852}
853
854/*
855 remove a specific parent context from a pointer. This is a more
856 controlled varient of talloc_free()
857*/
858int talloc_unlink(const void *context, void *ptr)
859{
860 struct talloc_chunk *tc_p, *new_p;
861 void *new_parent;
862
863 if (ptr == NULL) {
864 return -1;
865 }
866
867 if (context == NULL) {
868 context = null_context;
869 }
870
871 if (talloc_unreference(context, ptr) == 0) {
872 return 0;
873 }
874
875 if (context == NULL) {
876 if (talloc_parent_chunk(ptr) != NULL) {
877 return -1;
878 }
879 } else {
880 if (talloc_chunk_from_ptr(context) != talloc_parent_chunk(ptr)) {
881 return -1;
882 }
883 }
884
885 tc_p = talloc_chunk_from_ptr(ptr);
886
887 if (tc_p->refs == NULL) {
888 return _talloc_free_internal(ptr, __location__);
889 }
890
891 new_p = talloc_parent_chunk(tc_p->refs);
892 if (new_p) {
893 new_parent = TC_PTR_FROM_CHUNK(new_p);
894 } else {
895 new_parent = NULL;
896 }
897
898 if (talloc_unreference(new_parent, ptr) != 0) {
899 return -1;
900 }
901
902 _talloc_steal_internal(new_parent, ptr);
903
904 return 0;
905}
906
907/*
908 add a name to an existing pointer - va_list version
909*/
910static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
911
912static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap)
913{
914 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
915 tc->name = talloc_vasprintf(ptr, fmt, ap);
916 if (likely(tc->name)) {
917 _talloc_set_name_const(tc->name, ".name");
918 }
919 return tc->name;
920}
921
922/*
923 add a name to an existing pointer
924*/
925const char *talloc_set_name(const void *ptr, const char *fmt, ...)
926{
927 const char *name;
928 va_list ap;
929 va_start(ap, fmt);
930 name = talloc_set_name_v(ptr, fmt, ap);
931 va_end(ap);
932 return name;
933}
934
935
936/*
937 create a named talloc pointer. Any talloc pointer can be named, and
938 talloc_named() operates just like talloc() except that it allows you
939 to name the pointer.
940*/
941void *talloc_named(const void *context, size_t size, const char *fmt, ...)
942{
943 va_list ap;
944 void *ptr;
945 const char *name;
946
947 ptr = __talloc(context, size);
948 if (unlikely(ptr == NULL)) return NULL;
949
950 va_start(ap, fmt);
951 name = talloc_set_name_v(ptr, fmt, ap);
952 va_end(ap);
953
954 if (unlikely(name == NULL)) {
955 _talloc_free_internal(ptr, __location__);
956 return NULL;
957 }
958
959 return ptr;
960}
961
962/*
963 return the name of a talloc ptr, or "UNNAMED"
964*/
965const char *talloc_get_name(const void *ptr)
966{
967 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
968 if (unlikely(tc->name == TALLOC_MAGIC_REFERENCE)) {
969 return ".reference";
970 }
971 if (likely(tc->name)) {
972 return tc->name;
973 }
974 return "UNNAMED";
975}
976
977
978/*
979 check if a pointer has the given name. If it does, return the pointer,
980 otherwise return NULL
981*/
982void *talloc_check_name(const void *ptr, const char *name)
983{
984 const char *pname;
985 if (unlikely(ptr == NULL)) return NULL;
986 pname = talloc_get_name(ptr);
987 if (likely(pname == name || strcmp(pname, name) == 0)) {
988 return discard_const_p(void, ptr);
989 }
990 return NULL;
991}
992
993static void talloc_abort_type_missmatch(const char *location,
994 const char *name,
995 const char *expected)
996{
997 const char *reason;
998
999 reason = talloc_asprintf(NULL,
1000 "%s: Type mismatch: name[%s] expected[%s]",
1001 location,
1002 name?name:"NULL",
1003 expected);
1004 if (!reason) {
1005 reason = "Type mismatch";
1006 }
1007
1008 talloc_abort(reason);
1009}
1010
1011void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location)
1012{
1013 const char *pname;
1014
1015 if (unlikely(ptr == NULL)) {
1016 talloc_abort_type_missmatch(location, NULL, name);
1017 return NULL;
1018 }
1019
1020 pname = talloc_get_name(ptr);
1021 if (likely(pname == name || strcmp(pname, name) == 0)) {
1022 return discard_const_p(void, ptr);
1023 }
1024
1025 talloc_abort_type_missmatch(location, pname, name);
1026 return NULL;
1027}
1028
1029/*
1030 this is for compatibility with older versions of talloc
1031*/
1032void *talloc_init(const char *fmt, ...)
1033{
1034 va_list ap;
1035 void *ptr;
1036 const char *name;
1037
1038 /*
1039 * samba3 expects talloc_report_depth_cb(NULL, ...)
1040 * reports all talloc'ed memory, so we need to enable
1041 * null_tracking
1042 */
1043 talloc_enable_null_tracking();
1044
1045 ptr = __talloc(NULL, 0);
1046 if (unlikely(ptr == NULL)) return NULL;
1047
1048 va_start(ap, fmt);
1049 name = talloc_set_name_v(ptr, fmt, ap);
1050 va_end(ap);
1051
1052 if (unlikely(name == NULL)) {
1053 _talloc_free_internal(ptr, __location__);
1054 return NULL;
1055 }
1056
1057 return ptr;
1058}
1059
1060/*
1061 this is a replacement for the Samba3 talloc_destroy_pool functionality. It
1062 should probably not be used in new code. It's in here to keep the talloc
1063 code consistent across Samba 3 and 4.
1064*/
1065void talloc_free_children(void *ptr)
1066{
1067 struct talloc_chunk *tc;
1068
1069 if (unlikely(ptr == NULL)) {
1070 return;
1071 }
1072
1073 tc = talloc_chunk_from_ptr(ptr);
1074
1075 while (tc->child) {
1076 /* we need to work out who will own an abandoned child
1077 if it cannot be freed. In priority order, the first
1078 choice is owner of any remaining reference to this
1079 pointer, the second choice is our parent, and the
1080 final choice is the null context. */
1081 void *child = TC_PTR_FROM_CHUNK(tc->child);
1082 const void *new_parent = null_context;
1083 if (unlikely(tc->child->refs)) {
1084 struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs);
1085 if (p) new_parent = TC_PTR_FROM_CHUNK(p);
1086 }
1087 if (unlikely(talloc_free(child) == -1)) {
1088 if (new_parent == null_context) {
1089 struct talloc_chunk *p = talloc_parent_chunk(ptr);
1090 if (p) new_parent = TC_PTR_FROM_CHUNK(p);
1091 }
1092 _talloc_steal_internal(new_parent, child);
1093 }
1094 }
1095
1096 if ((tc->flags & TALLOC_FLAG_POOL)
1097 && (*talloc_pool_objectcount(tc) == 1)) {
1098 tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE);
1099#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
1100 VALGRIND_MAKE_MEM_NOACCESS(
1101 tc->pool, tc->size - TALLOC_POOL_HDR_SIZE);
1102#endif
1103 }
1104}
1105
1106/*
1107 Allocate a bit of memory as a child of an existing pointer
1108*/
1109void *_talloc(const void *context, size_t size)
1110{
1111 return __talloc(context, size);
1112}
1113
1114/*
1115 externally callable talloc_set_name_const()
1116*/
1117void talloc_set_name_const(const void *ptr, const char *name)
1118{
1119 _talloc_set_name_const(ptr, name);
1120}
1121
1122/*
1123 create a named talloc pointer. Any talloc pointer can be named, and
1124 talloc_named() operates just like talloc() except that it allows you
1125 to name the pointer.
1126*/
1127void *talloc_named_const(const void *context, size_t size, const char *name)
1128{
1129 return _talloc_named_const(context, size, name);
1130}
1131
1132/*
1133 free a talloc pointer. This also frees all child pointers of this
1134 pointer recursively
1135
1136 return 0 if the memory is actually freed, otherwise -1. The memory
1137 will not be freed if the ref_count is > 1 or the destructor (if
1138 any) returns non-zero
1139*/
1140int _talloc_free(void *ptr, const char *location)
1141{
1142 struct talloc_chunk *tc;
1143
1144 if (unlikely(ptr == NULL)) {
1145 return -1;
1146 }
1147
1148 tc = talloc_chunk_from_ptr(ptr);
1149
1150 if (unlikely(tc->refs != NULL)) {
1151 struct talloc_reference_handle *h;
1152
1153 talloc_log("ERROR: talloc_free with references at %s\n",
1154 location);
1155
1156 for (h=tc->refs; h; h=h->next) {
1157 talloc_log("\treference at %s\n",
1158 h->location);
1159 }
1160 return -1;
1161 }
1162
1163 return _talloc_free_internal(ptr, location);
1164}
1165
1166
1167
1168/*
1169 A talloc version of realloc. The context argument is only used if
1170 ptr is NULL
1171*/
1172void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name)
1173{
1174 struct talloc_chunk *tc;
1175 void *new_ptr;
1176 bool malloced = false;
1177
1178 /* size zero is equivalent to free() */
1179 if (unlikely(size == 0)) {
1180 talloc_unlink(context, ptr);
1181 return NULL;
1182 }
1183
1184 if (unlikely(size >= MAX_TALLOC_SIZE)) {
1185 return NULL;
1186 }
1187
1188 /* realloc(NULL) is equivalent to malloc() */
1189 if (ptr == NULL) {
1190 return _talloc_named_const(context, size, name);
1191 }
1192
1193 tc = talloc_chunk_from_ptr(ptr);
1194
1195 /* don't allow realloc on referenced pointers */
1196 if (unlikely(tc->refs)) {
1197 return NULL;
1198 }
1199
1200 /* don't let anybody try to realloc a talloc_pool */
1201 if (unlikely(tc->flags & TALLOC_FLAG_POOL)) {
1202 return NULL;
1203 }
1204
1205 /* don't shrink if we have less than 1k to gain */
1206 if ((size < tc->size) && ((tc->size - size) < 1024)) {
1207 tc->size = size;
1208 return ptr;
1209 }
1210
1211 /* by resetting magic we catch users of the old memory */
1212 tc->flags |= TALLOC_FLAG_FREE;
1213
1214#if ALWAYS_REALLOC
1215 new_ptr = malloc(size + TC_HDR_SIZE);
1216 if (new_ptr) {
1217 memcpy(new_ptr, tc, tc->size + TC_HDR_SIZE);
1218 free(tc);
1219 }
1220#else
1221 if (tc->flags & TALLOC_FLAG_POOLMEM) {
1222
1223 new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE);
1224 *talloc_pool_objectcount((struct talloc_chunk *)
1225 (tc->pool)) -= 1;
1226
1227 if (new_ptr == NULL) {
1228 new_ptr = malloc(TC_HDR_SIZE+size);
1229 malloced = true;
1230 }
1231
1232 if (new_ptr) {
1233 memcpy(new_ptr, tc, TALLOC_MIN(tc->size,size) + TC_HDR_SIZE);
1234 }
1235 }
1236 else {
1237 new_ptr = realloc(tc, size + TC_HDR_SIZE);
1238 }
1239#endif
1240 if (unlikely(!new_ptr)) {
1241 tc->flags &= ~TALLOC_FLAG_FREE;
1242 return NULL;
1243 }
1244
1245 tc = (struct talloc_chunk *)new_ptr;
1246 tc->flags &= ~TALLOC_FLAG_FREE;
1247 if (malloced) {
1248 tc->flags &= ~TALLOC_FLAG_POOLMEM;
1249 }
1250 if (tc->parent) {
1251 tc->parent->child = tc;
1252 }
1253 if (tc->child) {
1254 tc->child->parent = tc;
1255 }
1256
1257 if (tc->prev) {
1258 tc->prev->next = tc;
1259 }
1260 if (tc->next) {
1261 tc->next->prev = tc;
1262 }
1263
1264 tc->size = size;
1265 _talloc_set_name_const(TC_PTR_FROM_CHUNK(tc), name);
1266
1267 return TC_PTR_FROM_CHUNK(tc);
1268}
1269
1270/*
1271 a wrapper around talloc_steal() for situations where you are moving a pointer
1272 between two structures, and want the old pointer to be set to NULL
1273*/
1274void *_talloc_move(const void *new_ctx, const void *_pptr)
1275{
1276 const void **pptr = discard_const_p(const void *,_pptr);
1277 void *ret = talloc_steal(new_ctx, discard_const_p(void, *pptr));
1278 (*pptr) = NULL;
1279 return ret;
1280}
1281
1282/*
1283 return the total size of a talloc pool (subtree)
1284*/
1285size_t talloc_total_size(const void *ptr)
1286{
1287 size_t total = 0;
1288 struct talloc_chunk *c, *tc;
1289
1290 if (ptr == NULL) {
1291 ptr = null_context;
1292 }
1293 if (ptr == NULL) {
1294 return 0;
1295 }
1296
1297 tc = talloc_chunk_from_ptr(ptr);
1298
1299 if (tc->flags & TALLOC_FLAG_LOOP) {
1300 return 0;
1301 }
1302
1303 tc->flags |= TALLOC_FLAG_LOOP;
1304
1305 if (likely(tc->name != TALLOC_MAGIC_REFERENCE)) {
1306 total = tc->size;
1307 }
1308 for (c=tc->child;c;c=c->next) {
1309 total += talloc_total_size(TC_PTR_FROM_CHUNK(c));
1310 }
1311
1312 tc->flags &= ~TALLOC_FLAG_LOOP;
1313
1314 return total;
1315}
1316
1317/*
1318 return the total number of blocks in a talloc pool (subtree)
1319*/
1320size_t talloc_total_blocks(const void *ptr)
1321{
1322 size_t total = 0;
1323 struct talloc_chunk *c, *tc;
1324
1325 if (ptr == NULL) {
1326 ptr = null_context;
1327 }
1328 if (ptr == NULL) {
1329 return 0;
1330 }
1331
1332 tc = talloc_chunk_from_ptr(ptr);
1333
1334 if (tc->flags & TALLOC_FLAG_LOOP) {
1335 return 0;
1336 }
1337
1338 tc->flags |= TALLOC_FLAG_LOOP;
1339
1340 total++;
1341 for (c=tc->child;c;c=c->next) {
1342 total += talloc_total_blocks(TC_PTR_FROM_CHUNK(c));
1343 }
1344
1345 tc->flags &= ~TALLOC_FLAG_LOOP;
1346
1347 return total;
1348}
1349
1350/*
1351 return the number of external references to a pointer
1352*/
1353size_t talloc_reference_count(const void *ptr)
1354{
1355 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
1356 struct talloc_reference_handle *h;
1357 size_t ret = 0;
1358
1359 for (h=tc->refs;h;h=h->next) {
1360 ret++;
1361 }
1362 return ret;
1363}
1364
1365/*
1366 report on memory usage by all children of a pointer, giving a full tree view
1367*/
1368void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
1369 void (*callback)(const void *ptr,
1370 int depth, int max_depth,
1371 int is_ref,
1372 void *private_data),
1373 void *private_data)
1374{
1375 struct talloc_chunk *c, *tc;
1376
1377 if (ptr == NULL) {
1378 ptr = null_context;
1379 }
1380 if (ptr == NULL) return;
1381
1382 tc = talloc_chunk_from_ptr(ptr);
1383
1384 if (tc->flags & TALLOC_FLAG_LOOP) {
1385 return;
1386 }
1387
1388 callback(ptr, depth, max_depth, 0, private_data);
1389
1390 if (max_depth >= 0 && depth >= max_depth) {
1391 return;
1392 }
1393
1394 tc->flags |= TALLOC_FLAG_LOOP;
1395 for (c=tc->child;c;c=c->next) {
1396 if (c->name == TALLOC_MAGIC_REFERENCE) {
1397 struct talloc_reference_handle *h = (struct talloc_reference_handle *)TC_PTR_FROM_CHUNK(c);
1398 callback(h->ptr, depth + 1, max_depth, 1, private_data);
1399 } else {
1400 talloc_report_depth_cb(TC_PTR_FROM_CHUNK(c), depth + 1, max_depth, callback, private_data);
1401 }
1402 }
1403 tc->flags &= ~TALLOC_FLAG_LOOP;
1404}
1405
1406static void talloc_report_depth_FILE_helper(const void *ptr, int depth, int max_depth, int is_ref, void *_f)
1407{
1408 const char *name = talloc_get_name(ptr);
1409 FILE *f = (FILE *)_f;
1410
1411 if (is_ref) {
1412 fprintf(f, "%*sreference to: %s\n", depth*4, "", name);
1413 return;
1414 }
1415
1416 if (depth == 0) {
1417 fprintf(f,"%stalloc report on '%s' (total %6lu bytes in %3lu blocks)\n",
1418 (max_depth < 0 ? "full " :""), name,
1419 (unsigned long)talloc_total_size(ptr),
1420 (unsigned long)talloc_total_blocks(ptr));
1421 return;
1422 }
1423
1424 fprintf(f, "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n",
1425 depth*4, "",
1426 name,
1427 (unsigned long)talloc_total_size(ptr),
1428 (unsigned long)talloc_total_blocks(ptr),
1429 (int)talloc_reference_count(ptr), ptr);
1430
1431#if 0
1432 fprintf(f, "content: ");
1433 if (talloc_total_size(ptr)) {
1434 int tot = talloc_total_size(ptr);
1435 int i;
1436
1437 for (i = 0; i < tot; i++) {
1438 if ((((char *)ptr)[i] > 31) && (((char *)ptr)[i] < 126)) {
1439 fprintf(f, "%c", ((char *)ptr)[i]);
1440 } else {
1441 fprintf(f, "~%02x", ((char *)ptr)[i]);
1442 }
1443 }
1444 }
1445 fprintf(f, "\n");
1446#endif
1447}
1448
1449/*
1450 report on memory usage by all children of a pointer, giving a full tree view
1451*/
1452void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f)
1453{
1454 if (f) {
1455 talloc_report_depth_cb(ptr, depth, max_depth, talloc_report_depth_FILE_helper, f);
1456 fflush(f);
1457 }
1458}
1459
1460/*
1461 report on memory usage by all children of a pointer, giving a full tree view
1462*/
1463void talloc_report_full(const void *ptr, FILE *f)
1464{
1465 talloc_report_depth_file(ptr, 0, -1, f);
1466}
1467
1468/*
1469 report on memory usage by all children of a pointer
1470*/
1471void talloc_report(const void *ptr, FILE *f)
1472{
1473 talloc_report_depth_file(ptr, 0, 1, f);
1474}
1475
1476/*
1477 report on any memory hanging off the null context
1478*/
1479static void talloc_report_null(void)
1480{
1481 if (talloc_total_size(null_context) != 0) {
1482 talloc_report(null_context, stderr);
1483 }
1484}
1485
1486/*
1487 report on any memory hanging off the null context
1488*/
1489static void talloc_report_null_full(void)
1490{
1491 if (talloc_total_size(null_context) != 0) {
1492 talloc_report_full(null_context, stderr);
1493 }
1494}
1495
1496/*
1497 enable tracking of the NULL context
1498*/
1499void talloc_enable_null_tracking(void)
1500{
1501 if (null_context == NULL) {
1502 null_context = _talloc_named_const(NULL, 0, "null_context");
1503 if (autofree_context != NULL) {
1504 talloc_reparent(NULL, null_context, autofree_context);
1505 }
1506 }
1507}
1508
1509/*
1510 enable tracking of the NULL context, not moving the autofree context
1511 into the NULL context. This is needed for the talloc testsuite
1512*/
1513void talloc_enable_null_tracking_no_autofree(void)
1514{
1515 if (null_context == NULL) {
1516 null_context = _talloc_named_const(NULL, 0, "null_context");
1517 }
1518}
1519
1520/*
1521 disable tracking of the NULL context
1522*/
1523void talloc_disable_null_tracking(void)
1524{
1525 if (null_context != NULL) {
1526 /* we have to move any children onto the real NULL
1527 context */
1528 struct talloc_chunk *tc, *tc2;
1529 tc = talloc_chunk_from_ptr(null_context);
1530 for (tc2 = tc->child; tc2; tc2=tc2->next) {
1531 if (tc2->parent == tc) tc2->parent = NULL;
1532 if (tc2->prev == tc) tc2->prev = NULL;
1533 }
1534 for (tc2 = tc->next; tc2; tc2=tc2->next) {
1535 if (tc2->parent == tc) tc2->parent = NULL;
1536 if (tc2->prev == tc) tc2->prev = NULL;
1537 }
1538 tc->child = NULL;
1539 tc->next = NULL;
1540 }
1541 talloc_free(null_context);
1542 null_context = NULL;
1543}
1544
1545/*
1546 enable leak reporting on exit
1547*/
1548void talloc_enable_leak_report(void)
1549{
1550 talloc_enable_null_tracking();
1551 atexit(talloc_report_null);
1552}
1553
1554/*
1555 enable full leak reporting on exit
1556*/
1557void talloc_enable_leak_report_full(void)
1558{
1559 talloc_enable_null_tracking();
1560 atexit(talloc_report_null_full);
1561}
1562
1563/*
1564 talloc and zero memory.
1565*/
1566void *_talloc_zero(const void *ctx, size_t size, const char *name)
1567{
1568 void *p = _talloc_named_const(ctx, size, name);
1569
1570 if (p) {
1571 memset(p, '\0', size);
1572 }
1573
1574 return p;
1575}
1576
1577/*
1578 memdup with a talloc.
1579*/
1580void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name)
1581{
1582 void *newp = _talloc_named_const(t, size, name);
1583
1584 if (likely(newp)) {
1585 memcpy(newp, p, size);
1586 }
1587
1588 return newp;
1589}
1590
1591static inline char *__talloc_strlendup(const void *t, const char *p, size_t len)
1592{
1593 char *ret;
1594
1595 ret = (char *)__talloc(t, len + 1);
1596 if (unlikely(!ret)) return NULL;
1597
1598 memcpy(ret, p, len);
1599 ret[len] = 0;
1600
1601 _talloc_set_name_const(ret, ret);
1602 return ret;
1603}
1604
1605/*
1606 strdup with a talloc
1607*/
1608char *talloc_strdup(const void *t, const char *p)
1609{
1610 if (unlikely(!p)) return NULL;
1611 return __talloc_strlendup(t, p, strlen(p));
1612}
1613
1614/*
1615 strndup with a talloc
1616*/
1617char *talloc_strndup(const void *t, const char *p, size_t n)
1618{
1619 if (unlikely(!p)) return NULL;
1620 return __talloc_strlendup(t, p, strnlen(p, n));
1621}
1622
1623static inline char *__talloc_strlendup_append(char *s, size_t slen,
1624 const char *a, size_t alen)
1625{
1626 char *ret;
1627
1628 ret = talloc_realloc(NULL, s, char, slen + alen + 1);
1629 if (unlikely(!ret)) return NULL;
1630
1631 /* append the string and the trailing \0 */
1632 memcpy(&ret[slen], a, alen);
1633 ret[slen+alen] = 0;
1634
1635 _talloc_set_name_const(ret, ret);
1636 return ret;
1637}
1638
1639/*
1640 * Appends at the end of the string.
1641 */
1642char *talloc_strdup_append(char *s, const char *a)
1643{
1644 if (unlikely(!s)) {
1645 return talloc_strdup(NULL, a);
1646 }
1647
1648 if (unlikely(!a)) {
1649 return s;
1650 }
1651
1652 return __talloc_strlendup_append(s, strlen(s), a, strlen(a));
1653}
1654
1655/*
1656 * Appends at the end of the talloc'ed buffer,
1657 * not the end of the string.
1658 */
1659char *talloc_strdup_append_buffer(char *s, const char *a)
1660{
1661 size_t slen;
1662
1663 if (unlikely(!s)) {
1664 return talloc_strdup(NULL, a);
1665 }
1666
1667 if (unlikely(!a)) {
1668 return s;
1669 }
1670
1671 slen = talloc_get_size(s);
1672 if (likely(slen > 0)) {
1673 slen--;
1674 }
1675
1676 return __talloc_strlendup_append(s, slen, a, strlen(a));
1677}
1678
1679/*
1680 * Appends at the end of the string.
1681 */
1682char *talloc_strndup_append(char *s, const char *a, size_t n)
1683{
1684 if (unlikely(!s)) {
1685 return talloc_strdup(NULL, a);
1686 }
1687
1688 if (unlikely(!a)) {
1689 return s;
1690 }
1691
1692 return __talloc_strlendup_append(s, strlen(s), a, strnlen(a, n));
1693}
1694
1695/*
1696 * Appends at the end of the talloc'ed buffer,
1697 * not the end of the string.
1698 */
1699char *talloc_strndup_append_buffer(char *s, const char *a, size_t n)
1700{
1701 size_t slen;
1702
1703 if (unlikely(!s)) {
1704 return talloc_strdup(NULL, a);
1705 }
1706
1707 if (unlikely(!a)) {
1708 return s;
1709 }
1710
1711 slen = talloc_get_size(s);
1712 if (likely(slen > 0)) {
1713 slen--;
1714 }
1715
1716 return __talloc_strlendup_append(s, slen, a, strnlen(a, n));
1717}
1718
1719#ifndef va_copy
1720#ifdef HAVE___VA_COPY
1721#define va_copy(dest, src) __va_copy(dest, src)
1722#else
1723#define va_copy(dest, src) (dest) = (src)
1724#endif
1725#endif
1726
1727char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
1728{
1729 int len;
1730 char *ret;
1731 va_list ap2;
1732 char c;
1733
1734 /* this call looks strange, but it makes it work on older solaris boxes */
1735 va_copy(ap2, ap);
1736 #ifdef _MSC_VER
1737 /* MSVC runtime needs to use _vcsprintf to return buffer size; vsnprintf would return -1 */
1738 len = _vscprintf(fmt, ap2);
1739 #else
1740 len = vsnprintf(&c, 1, fmt, ap2);
1741 #endif
1742 va_end(ap2);
1743 if (unlikely(len < 0)) {
1744 return NULL;
1745 }
1746
1747 ret = (char *)__talloc(t, len+1);
1748 if (unlikely(!ret)) return NULL;
1749
1750 va_copy(ap2, ap);
1751 vsnprintf(ret, len+1, fmt, ap2);
1752 va_end(ap2);
1753
1754 _talloc_set_name_const(ret, ret);
1755 return ret;
1756}
1757
1758
1759/*
1760 Perform string formatting, and return a pointer to newly allocated
1761 memory holding the result, inside a memory pool.
1762 */
1763char *talloc_asprintf(const void *t, const char *fmt, ...)
1764{
1765 va_list ap;
1766 char *ret;
1767
1768 va_start(ap, fmt);
1769 ret = talloc_vasprintf(t, fmt, ap);
1770 va_end(ap);
1771 return ret;
1772}
1773
1774static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
1775 const char *fmt, va_list ap)
1776 PRINTF_ATTRIBUTE(3,0);
1777
1778static inline char *__talloc_vaslenprintf_append(char *s, size_t slen,
1779 const char *fmt, va_list ap)
1780{
1781 ssize_t alen;
1782 va_list ap2;
1783 char c;
1784
1785 va_copy(ap2, ap);
1786 #ifdef _MSC_VER
1787 /* MSVC runtime needs to use _vcsprintf to return buffer size; vsnprintf would return -1 */
1788 alen = _vscprintf(fmt, ap2);
1789 #else
1790 alen = vsnprintf(&c, 1, fmt, ap2);
1791 #endif
1792 va_end(ap2);
1793
1794 if (alen <= 0) {
1795 /* Either the vsnprintf failed or the format resulted in
1796 * no characters being formatted. In the former case, we
1797 * ought to return NULL, in the latter we ought to return
1798 * the original string. Most current callers of this
1799 * function expect it to never return NULL.
1800 */
1801 return s;
1802 }
1803
1804 s = talloc_realloc(NULL, s, char, slen + alen + 1);
1805 if (!s) return NULL;
1806
1807 va_copy(ap2, ap);
1808 vsnprintf(s + slen, alen + 1, fmt, ap2);
1809 va_end(ap2);
1810
1811 _talloc_set_name_const(s, s);
1812 return s;
1813}
1814
1815/**
1816 * Realloc @p s to append the formatted result of @p fmt and @p ap,
1817 * and return @p s, which may have moved. Good for gradually
1818 * accumulating output into a string buffer. Appends at the end
1819 * of the string.
1820 **/
1821char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
1822{
1823 if (unlikely(!s)) {
1824 return talloc_vasprintf(NULL, fmt, ap);
1825 }
1826
1827 return __talloc_vaslenprintf_append(s, strlen(s), fmt, ap);
1828}
1829
1830/**
1831 * Realloc @p s to append the formatted result of @p fmt and @p ap,
1832 * and return @p s, which may have moved. Always appends at the
1833 * end of the talloc'ed buffer, not the end of the string.
1834 **/
1835char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap)
1836{
1837 size_t slen;
1838
1839 if (unlikely(!s)) {
1840 return talloc_vasprintf(NULL, fmt, ap);
1841 }
1842
1843 slen = talloc_get_size(s);
1844 if (likely(slen > 0)) {
1845 slen--;
1846 }
1847
1848 return __talloc_vaslenprintf_append(s, slen, fmt, ap);
1849}
1850
1851/*
1852 Realloc @p s to append the formatted result of @p fmt and return @p
1853 s, which may have moved. Good for gradually accumulating output
1854 into a string buffer.
1855 */
1856char *talloc_asprintf_append(char *s, const char *fmt, ...)
1857{
1858 va_list ap;
1859
1860 va_start(ap, fmt);
1861 s = talloc_vasprintf_append(s, fmt, ap);
1862 va_end(ap);
1863 return s;
1864}
1865
1866/*
1867 Realloc @p s to append the formatted result of @p fmt and return @p
1868 s, which may have moved. Good for gradually accumulating output
1869 into a buffer.
1870 */
1871char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...)
1872{
1873 va_list ap;
1874
1875 va_start(ap, fmt);
1876 s = talloc_vasprintf_append_buffer(s, fmt, ap);
1877 va_end(ap);
1878 return s;
1879}
1880
1881/*
1882 alloc an array, checking for integer overflow in the array size
1883*/
1884void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
1885{
1886 if (count >= MAX_TALLOC_SIZE/el_size) {
1887 return NULL;
1888 }
1889 return _talloc_named_const(ctx, el_size * count, name);
1890}
1891
1892/*
1893 alloc an zero array, checking for integer overflow in the array size
1894*/
1895void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
1896{
1897 if (count >= MAX_TALLOC_SIZE/el_size) {
1898 return NULL;
1899 }
1900 return _talloc_zero(ctx, el_size * count, name);
1901}
1902
1903/*
1904 realloc an array, checking for integer overflow in the array size
1905*/
1906void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name)
1907{
1908 if (count >= MAX_TALLOC_SIZE/el_size) {
1909 return NULL;
1910 }
1911 return _talloc_realloc(ctx, ptr, el_size * count, name);
1912}
1913
1914/*
1915 a function version of talloc_realloc(), so it can be passed as a function pointer
1916 to libraries that want a realloc function (a realloc function encapsulates
1917 all the basic capabilities of an allocation library, which is why this is useful)
1918*/
1919void *talloc_realloc_fn(const void *context, void *ptr, size_t size)
1920{
1921 return _talloc_realloc(context, ptr, size, NULL);
1922}
1923
1924
1925static int talloc_autofree_destructor(void *ptr)
1926{
1927 autofree_context = NULL;
1928 return 0;
1929}
1930
1931static void talloc_autofree(void)
1932{
1933 talloc_free(autofree_context);
1934}
1935
1936/*
1937 return a context which will be auto-freed on exit
1938 this is useful for reducing the noise in leak reports
1939*/
1940void *talloc_autofree_context(void)
1941{
1942 if (autofree_context == NULL) {
1943 autofree_context = _talloc_named_const(NULL, 0, "autofree_context");
1944 talloc_set_destructor(autofree_context, talloc_autofree_destructor);
1945 atexit(talloc_autofree);
1946 }
1947 return autofree_context;
1948}
1949
1950size_t talloc_get_size(const void *context)
1951{
1952 struct talloc_chunk *tc;
1953
1954 if (context == NULL) {
1955 context = null_context;
1956 }
1957 if (context == NULL) {
1958 return 0;
1959 }
1960
1961 tc = talloc_chunk_from_ptr(context);
1962
1963 return tc->size;
1964}
1965
1966/*
1967 find a parent of this context that has the given name, if any
1968*/
1969void *talloc_find_parent_byname(const void *context, const char *name)
1970{
1971 struct talloc_chunk *tc;
1972
1973 if (context == NULL) {
1974 return NULL;
1975 }
1976
1977 tc = talloc_chunk_from_ptr(context);
1978 while (tc) {
1979 if (tc->name && strcmp(tc->name, name) == 0) {
1980 return TC_PTR_FROM_CHUNK(tc);
1981 }
1982 while (tc && tc->prev) tc = tc->prev;
1983 if (tc) {
1984 tc = tc->parent;
1985 }
1986 }
1987 return NULL;
1988}
1989
1990/*
1991 show the parentage of a context
1992*/
1993void talloc_show_parents(const void *context, FILE *file)
1994{
1995 struct talloc_chunk *tc;
1996
1997 if (context == NULL) {
1998 fprintf(file, "talloc no parents for NULL\n");
1999 return;
2000 }
2001
2002 tc = talloc_chunk_from_ptr(context);
2003 fprintf(file, "talloc parents of '%s'\n", talloc_get_name(context));
2004 while (tc) {
2005 fprintf(file, "\t'%s'\n", talloc_get_name(TC_PTR_FROM_CHUNK(tc)));
2006 while (tc && tc->prev) tc = tc->prev;
2007 if (tc) {
2008 tc = tc->parent;
2009 }
2010 }
2011 fflush(file);
2012}
2013
2014/*
2015 return 1 if ptr is a parent of context
2016*/
2017int talloc_is_parent(const void *context, const void *ptr)
2018{
2019 struct talloc_chunk *tc;
2020
2021 if (context == NULL) {
2022 return 0;
2023 }
2024
2025 tc = talloc_chunk_from_ptr(context);
2026 while (tc) {
2027 if (TC_PTR_FROM_CHUNK(tc) == ptr) return 1;
2028 while (tc && tc->prev) tc = tc->prev;
2029 if (tc) {
2030 tc = tc->parent;
2031 }
2032 }
2033 return 0;
2034}
diff --git a/src/talloc/talloc.def b/src/talloc/talloc.def
new file mode 100644
index 00000000000..13d7a159cef
--- /dev/null
+++ b/src/talloc/talloc.def
@@ -0,0 +1,63 @@
1EXPORTS
2 _talloc
3 _talloc_array
4 _talloc_free
5 _talloc_get_type_abort
6 _talloc_memdup
7 _talloc_move
8 _talloc_realloc
9 _talloc_realloc_array
10 _talloc_reference_loc
11 _talloc_set_destructor
12 _talloc_steal_loc
13 _talloc_zero
14 _talloc_zero_array
15 talloc_asprintf
16 talloc_asprintf_append
17 talloc_asprintf_append_buffer
18 talloc_autofree_context
19 talloc_check_name
20 talloc_disable_null_tracking
21 talloc_enable_leak_report
22 talloc_enable_leak_report_full
23 talloc_enable_null_tracking
24 talloc_enable_null_tracking_no_autofree
25 talloc_find_parent_byname
26 talloc_free_children
27 talloc_get_name
28 talloc_get_size
29 talloc_increase_ref_count
30 talloc_init
31 talloc_is_parent
32 talloc_named
33 talloc_named_const
34 talloc_parent
35 talloc_parent_name
36 talloc_pool
37 talloc_realloc_fn
38 talloc_reference_count
39 talloc_reparent
40 talloc_report
41 talloc_report_depth_cb
42 talloc_report_depth_file
43 talloc_report_full
44 talloc_set_abort_fn
45 talloc_set_log_fn
46 talloc_set_log_stderr
47 talloc_set_name
48 talloc_set_name_const
49 talloc_show_parents
50 talloc_strdup
51 talloc_strdup_append
52 talloc_strdup_append_buffer
53 talloc_strndup
54 talloc_strndup_append
55 talloc_strndup_append_buffer
56 talloc_total_blocks
57 talloc_total_size
58 talloc_unlink
59 talloc_vasprintf
60 talloc_vasprintf_append
61 talloc_vasprintf_append_buffer
62 talloc_version_major
63 talloc_version_minor
diff --git a/src/talloc/talloc.h b/src/talloc/talloc.h
new file mode 100644
index 00000000000..f549a17fba2
--- /dev/null
+++ b/src/talloc/talloc.h
@@ -0,0 +1,202 @@
1#ifndef _TALLOC_H_
2#define _TALLOC_H_
3/*
4 Unix SMB/CIFS implementation.
5 Samba temporary memory allocation functions
6
7 Copyright (C) Andrew Tridgell 2004-2005
8 Copyright (C) Stefan Metzmacher 2006
9
10 ** NOTE! The following LGPL license applies to the talloc
11 ** library. This does NOT imply that all of Samba is released
12 ** under the LGPL
13
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 3 of the License, or (at your option) any later version.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, see <http://www.gnu.org/licenses/>.
26*/
27
28#include <stdlib.h>
29#include <stdio.h>
30#include <stdarg.h>
31
32#define TALLOC_VERSION_MAJOR 2
33#define TALLOC_VERSION_MINOR 0
34
35int talloc_version_major(void);
36int talloc_version_minor(void);
37
38/* this is only needed for compatibility with the old talloc */
39typedef void TALLOC_CTX;
40
41/*
42 this uses a little trick to allow __LINE__ to be stringified
43*/
44#ifndef __location__
45#define __TALLOC_STRING_LINE1__(s) #s
46#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s)
47#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__)
48#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__
49#endif
50
51#ifndef TALLOC_DEPRECATED
52#define TALLOC_DEPRECATED 0
53#endif
54
55#ifndef PRINTF_ATTRIBUTE
56#if (__GNUC__ >= 3)
57/** Use gcc attribute to check printf fns. a1 is the 1-based index of
58 * the parameter containing the format, and a2 the index of the first
59 * argument. Note that some gcc 2.x versions don't handle this
60 * properly **/
61#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
62#else
63#define PRINTF_ATTRIBUTE(a1, a2)
64#endif
65#endif
66
67/* try to make talloc_set_destructor() and talloc_steal() type safe,
68 if we have a recent gcc */
69#if (__GNUC__ >= 3)
70#define _TALLOC_TYPEOF(ptr) __typeof__(ptr)
71#define talloc_set_destructor(ptr, function) \
72 do { \
73 int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \
74 _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \
75 } while(0)
76/* this extremely strange macro is to avoid some braindamaged warning
77 stupidity in gcc 4.1.x */
78#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__); __talloc_steal_ret; })
79#else
80#define talloc_set_destructor(ptr, function) \
81 _talloc_set_destructor((ptr), (int (*)(void *))(function))
82#define _TALLOC_TYPEOF(ptr) void *
83#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__)
84#endif
85
86#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference_loc((ctx),(ptr), __location__)
87#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr))
88
89/* useful macros for creating type checked pointers */
90#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
91#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
92#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr)))
93
94#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
95
96#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
97#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
98
99#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
100#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
101#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
102#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count)
103#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx))
104
105#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type)
106#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
107
108#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
109
110#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type)
111#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type)
112#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__)
113
114#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type)
115#define talloc_free(ctx) _talloc_free(ctx, __location__)
116
117
118#if TALLOC_DEPRECATED
119#define talloc_zero_p(ctx, type) talloc_zero(ctx, type)
120#define talloc_p(ctx, type) talloc(ctx, type)
121#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count)
122#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count)
123#define talloc_destroy(ctx) talloc_free(ctx)
124#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a))
125#endif
126
127#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
128
129/* The following definitions come from talloc.c */
130void *_talloc(const void *context, size_t size);
131void *talloc_pool(const void *context, size_t size);
132void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *));
133int talloc_increase_ref_count(const void *ptr);
134size_t talloc_reference_count(const void *ptr);
135void *_talloc_reference_loc(const void *context, const void *ptr, const char *location);
136int talloc_unlink(const void *context, void *ptr);
137const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
138void talloc_set_name_const(const void *ptr, const char *name);
139void *talloc_named(const void *context, size_t size,
140 const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
141void *talloc_named_const(const void *context, size_t size, const char *name);
142const char *talloc_get_name(const void *ptr);
143void *talloc_check_name(const void *ptr, const char *name);
144void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location);
145void *talloc_parent(const void *ptr);
146const char *talloc_parent_name(const void *ptr);
147void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
148int _talloc_free(void *ptr, const char *location);
149void talloc_free_children(void *ptr);
150void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name);
151void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location);
152void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr);
153void *_talloc_move(const void *new_ctx, const void *pptr);
154size_t talloc_total_size(const void *ptr);
155size_t talloc_total_blocks(const void *ptr);
156void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
157 void (*callback)(const void *ptr,
158 int depth, int max_depth,
159 int is_ref,
160 void *private_data),
161 void *private_data);
162void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f);
163void talloc_report_full(const void *ptr, FILE *f);
164void talloc_report(const void *ptr, FILE *f);
165void talloc_enable_null_tracking(void);
166void talloc_enable_null_tracking_no_autofree(void);
167void talloc_disable_null_tracking(void);
168void talloc_enable_leak_report(void);
169void talloc_enable_leak_report_full(void);
170void *_talloc_zero(const void *ctx, size_t size, const char *name);
171void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name);
172void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
173void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
174void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
175void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
176void *talloc_autofree_context(void);
177size_t talloc_get_size(const void *ctx);
178void *talloc_find_parent_byname(const void *ctx, const char *name);
179void talloc_show_parents(const void *context, FILE *file);
180int talloc_is_parent(const void *context, const void *ptr);
181
182char *talloc_strdup(const void *t, const char *p);
183char *talloc_strdup_append(char *s, const char *a);
184char *talloc_strdup_append_buffer(char *s, const char *a);
185
186char *talloc_strndup(const void *t, const char *p, size_t n);
187char *talloc_strndup_append(char *s, const char *a, size_t n);
188char *talloc_strndup_append_buffer(char *s, const char *a, size_t n);
189
190char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
191char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
192char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
193
194char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
195char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
196char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
197
198void talloc_set_abort_fn(void (*abort_fn)(const char *reason));
199void talloc_set_log_fn(void (*log_fn)(const char *message));
200void talloc_set_log_stderr(void);
201
202#endif
diff --git a/src/talloc/talloc_guide.txt b/src/talloc/talloc_guide.txt
new file mode 100644
index 00000000000..01de806662d
--- /dev/null
+++ b/src/talloc/talloc_guide.txt
@@ -0,0 +1,757 @@
1Using talloc in Samba4
2======================
3
4.. contents::
5
6Andrew Tridgell
7August 2009
8
9The most current version of this document is available at
10 http://samba.org/ftp/unpacked/talloc/talloc_guide.txt
11
12If you are used to the "old" talloc from Samba3 before 3.0.20 then please read
13this carefully, as talloc has changed a lot. With 3.0.20 (or 3.0.14?) the
14Samba4 talloc has been ported back to Samba3, so this guide applies to both.
15
16The new talloc is a hierarchical, reference counted memory pool system
17with destructors. Quite a mouthful really, but not too bad once you
18get used to it.
19
20Perhaps the biggest change from Samba3 is that there is no distinction
21between a "talloc context" and a "talloc pointer". Any pointer
22returned from talloc() is itself a valid talloc context. This means
23you can do this::
24
25 struct foo *X = talloc(mem_ctx, struct foo);
26 X->name = talloc_strdup(X, "foo");
27
28and the pointer X->name would be a "child" of the talloc context "X"
29which is itself a child of mem_ctx. So if you do talloc_free(mem_ctx)
30then it is all destroyed, whereas if you do talloc_free(X) then just X
31and X->name are destroyed, and if you do talloc_free(X->name) then
32just the name element of X is destroyed.
33
34If you think about this, then what this effectively gives you is an
35n-ary tree, where you can free any part of the tree with
36talloc_free().
37
38If you find this confusing, then I suggest you run the testsuite to
39watch talloc in action. You may also like to add your own tests to
40testsuite.c to clarify how some particular situation is handled.
41
42
43Performance
44-----------
45
46All the additional features of talloc() over malloc() do come at a
47price. We have a simple performance test in Samba4 that measures
48talloc() versus malloc() performance, and it seems that talloc() is
49about 4% slower than malloc() on my x86 Debian Linux box. For Samba,
50the great reduction in code complexity that we get by using talloc
51makes this worthwhile, especially as the total overhead of
52talloc/malloc in Samba is already quite small.
53
54
55talloc API
56----------
57
58The following is a complete guide to the talloc API. Read it all at
59least twice.
60
61Multi-threading
62---------------
63
64talloc itself does not deal with threads. It is thread-safe (assuming
65the underlying "malloc" is), as long as each thread uses different
66memory contexts.
67If two threads uses the same context then they need to synchronize in
68order to be safe. In particular:
69- when using talloc_enable_leak_report(), giving directly NULL as a
70parent context implicitly refers to a hidden "null context" global
71variable, so this should not be used in a multi-threaded environment
72without proper synchronization ;
73- the context returned by talloc_autofree_context() is also global so
74shouldn't be used by several threads simultaneously without
75synchronization.
76
77
78=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
79(type *)talloc(const void *context, type);
80
81The talloc() macro is the core of the talloc library. It takes a
82memory context and a type, and returns a pointer to a new area of
83memory of the given type.
84
85The returned pointer is itself a talloc context, so you can use it as
86the context argument to more calls to talloc if you wish.
87
88The returned pointer is a "child" of the supplied context. This means
89that if you talloc_free() the context then the new child disappears as
90well. Alternatively you can free just the child.
91
92The context argument to talloc() can be NULL, in which case a new top
93level context is created.
94
95
96=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
97void *talloc_size(const void *context, size_t size);
98
99The function talloc_size() should be used when you don't have a
100convenient type to pass to talloc(). Unlike talloc(), it is not type
101safe (as it returns a void *), so you are on your own for type checking.
102
103=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
104(typeof(ptr)) talloc_ptrtype(const void *ctx, ptr);
105
106The talloc_ptrtype() macro should be used when you have a pointer and
107want to allocate memory to point at with this pointer. When compiling
108with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_size()
109and talloc_get_name() will return the current location in the source file.
110and not the type.
111
112=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
113int talloc_free(void *ptr);
114
115The talloc_free() function frees a piece of talloc memory, and all its
116children. You can call talloc_free() on any pointer returned by
117talloc().
118
119The return value of talloc_free() indicates success or failure, with 0
120returned for success and -1 for failure. The only possible failure
121condition is if the pointer had a destructor attached to it and the
122destructor returned -1. See talloc_set_destructor() for details on
123destructors.
124
125If this pointer has an additional parent when talloc_free() is called
126then the memory is not actually released, but instead the most
127recently established parent is destroyed. See talloc_reference() for
128details on establishing additional parents.
129
130For more control on which parent is removed, see talloc_unlink()
131
132talloc_free() operates recursively on its children.
133
134From the 2.0 version of talloc, as a special case, talloc_free() is
135refused on pointers that have more than one parent, as talloc would
136have no way of knowing which parent should be removed. To free a
137pointer that has more than one parent please use talloc_unlink().
138
139To help you find problems in your code caused by this behaviour, if
140you do try and free a pointer with more than one parent then the
141talloc logging function will be called to give output like this:
142
143 ERROR: talloc_free with references at some_dir/source/foo.c:123
144 reference at some_dir/source/other.c:325
145 reference at some_dir/source/third.c:121
146
147Please see the documentation for talloc_set_log_fn() and
148talloc_set_log_stderr() for more information on talloc logging
149functions.
150
151=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
152int talloc_free_children(void *ptr);
153
154The talloc_free_children() walks along the list of all children of a
155talloc context and talloc_free()s only the children, not the context
156itself.
157
158
159=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
160void *talloc_reference(const void *context, const void *ptr);
161
162The talloc_reference() function makes "context" an additional parent
163of "ptr".
164
165The return value of talloc_reference() is always the original pointer
166"ptr", unless talloc ran out of memory in creating the reference in
167which case it will return NULL (each additional reference consumes
168around 48 bytes of memory on intel x86 platforms).
169
170If "ptr" is NULL, then the function is a no-op, and simply returns NULL.
171
172After creating a reference you can free it in one of the following
173ways:
174
175 - you can talloc_free() any parent of the original pointer. That
176 will reduce the number of parents of this pointer by 1, and will
177 cause this pointer to be freed if it runs out of parents.
178
179 - you can talloc_free() the pointer itself. That will destroy the
180 most recently established parent to the pointer and leave the
181 pointer as a child of its current parent.
182
183For more control on which parent to remove, see talloc_unlink()
184
185
186=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
187int talloc_unlink(const void *context, const void *ptr);
188
189The talloc_unlink() function removes a specific parent from ptr. The
190context passed must either be a context used in talloc_reference()
191with this pointer, or must be a direct parent of ptr.
192
193Note that if the parent has already been removed using talloc_free()
194then this function will fail and will return -1. Likewise, if "ptr"
195is NULL, then the function will make no modifications and return -1.
196
197Usually you can just use talloc_free() instead of talloc_unlink(), but
198sometimes it is useful to have the additional control on which parent
199is removed.
200
201
202=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
203void talloc_set_destructor(const void *ptr, int (*destructor)(void *));
204
205The function talloc_set_destructor() sets the "destructor" for the
206pointer "ptr". A destructor is a function that is called when the
207memory used by a pointer is about to be released. The destructor
208receives the pointer as an argument, and should return 0 for success
209and -1 for failure.
210
211The destructor can do anything it wants to, including freeing other
212pieces of memory. A common use for destructors is to clean up
213operating system resources (such as open file descriptors) contained
214in the structure the destructor is placed on.
215
216You can only place one destructor on a pointer. If you need more than
217one destructor then you can create a zero-length child of the pointer
218and place an additional destructor on that.
219
220To remove a destructor call talloc_set_destructor() with NULL for the
221destructor.
222
223If your destructor attempts to talloc_free() the pointer that it is
224the destructor for then talloc_free() will return -1 and the free will
225be ignored. This would be a pointless operation anyway, as the
226destructor is only called when the memory is just about to go away.
227
228
229=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
230int talloc_increase_ref_count(const void *ptr);
231
232The talloc_increase_ref_count(ptr) function is exactly equivalent to:
233
234 talloc_reference(NULL, ptr);
235
236You can use either syntax, depending on which you think is clearer in
237your code.
238
239It returns 0 on success and -1 on failure.
240
241=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
242size_t talloc_reference_count(const void *ptr);
243
244Return the number of references to the pointer.
245
246=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
247void talloc_set_name(const void *ptr, const char *fmt, ...);
248
249Each talloc pointer has a "name". The name is used principally for
250debugging purposes, although it is also possible to set and get the
251name on a pointer in as a way of "marking" pointers in your code.
252
253The main use for names on pointer is for "talloc reports". See
254talloc_report() and talloc_report_full() for details. Also see
255talloc_enable_leak_report() and talloc_enable_leak_report_full().
256
257The talloc_set_name() function allocates memory as a child of the
258pointer. It is logically equivalent to:
259 talloc_set_name_const(ptr, talloc_asprintf(ptr, fmt, ...));
260
261Note that multiple calls to talloc_set_name() will allocate more
262memory without releasing the name. All of the memory is released when
263the ptr is freed using talloc_free().
264
265
266=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
267void talloc_set_name_const(const void *ptr, const char *name);
268
269The function talloc_set_name_const() is just like talloc_set_name(),
270but it takes a string constant, and is much faster. It is extensively
271used by the "auto naming" macros, such as talloc_p().
272
273This function does not allocate any memory. It just copies the
274supplied pointer into the internal representation of the talloc
275ptr. This means you must not pass a name pointer to memory that will
276disappear before the ptr is freed with talloc_free().
277
278
279=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
280void *talloc_named(const void *context, size_t size, const char *fmt, ...);
281
282The talloc_named() function creates a named talloc pointer. It is
283equivalent to:
284
285 ptr = talloc_size(context, size);
286 talloc_set_name(ptr, fmt, ....);
287
288
289=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
290void *talloc_named_const(const void *context, size_t size, const char *name);
291
292This is equivalent to::
293
294 ptr = talloc_size(context, size);
295 talloc_set_name_const(ptr, name);
296
297
298=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
299const char *talloc_get_name(const void *ptr);
300
301This returns the current name for the given talloc pointer. See
302talloc_set_name() for details.
303
304
305=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
306void *talloc_init(const char *fmt, ...);
307
308This function creates a zero length named talloc context as a top
309level context. It is equivalent to::
310
311 talloc_named(NULL, 0, fmt, ...);
312
313
314=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
315void *talloc_new(void *ctx);
316
317This is a utility macro that creates a new memory context hanging
318off an exiting context, automatically naming it "talloc_new: __location__"
319where __location__ is the source line it is called from. It is
320particularly useful for creating a new temporary working context.
321
322
323=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
324(type *)talloc_realloc(const void *context, void *ptr, type, count);
325
326The talloc_realloc() macro changes the size of a talloc
327pointer. The "count" argument is the number of elements of type "type"
328that you want the resulting pointer to hold.
329
330talloc_realloc() has the following equivalences::
331
332 talloc_realloc(context, NULL, type, 1) ==> talloc(context, type);
333 talloc_realloc(context, NULL, type, N) ==> talloc_array(context, type, N);
334 talloc_realloc(context, ptr, type, 0) ==> talloc_free(ptr);
335
336The "context" argument is only used if "ptr" is NULL, otherwise it is
337ignored.
338
339talloc_realloc() returns the new pointer, or NULL on failure. The call
340will fail either due to a lack of memory, or because the pointer has
341more than one parent (see talloc_reference()).
342
343
344=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
345void *talloc_realloc_size(const void *context, void *ptr, size_t size);
346
347the talloc_realloc_size() function is useful when the type is not
348known so the typesafe talloc_realloc() cannot be used.
349
350
351=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
352void *talloc_steal(const void *new_ctx, const void *ptr);
353
354The talloc_steal() function changes the parent context of a talloc
355pointer. It is typically used when the context that the pointer is
356currently a child of is going to be freed and you wish to keep the
357memory for a longer time.
358
359The talloc_steal() function returns the pointer that you pass it. It
360does not have any failure modes.
361
362NOTE: It is possible to produce loops in the parent/child relationship
363if you are not careful with talloc_steal(). No guarantees are provided
364as to your sanity or the safety of your data if you do this.
365
366talloc_steal (new_ctx, NULL) will return NULL with no sideeffects.
367
368Note that if you try and call talloc_steal() on a pointer that has
369more than one parent then the result is ambiguous. Talloc will choose
370to remove the parent that is currently indicated by talloc_parent()
371and replace it with the chosen parent. You will also get a message
372like this via the talloc logging functions:
373
374 WARNING: talloc_steal with references at some_dir/source/foo.c:123
375 reference at some_dir/source/other.c:325
376 reference at some_dir/source/third.c:121
377
378To unambiguously change the parent of a pointer please see the
379function talloc_reparent(). See the talloc_set_log_fn() documentation
380for more information on talloc logging.
381
382=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
383void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr);
384
385The talloc_reparent() function changes the parent context of a talloc
386pointer. It is typically used when the context that the pointer is
387currently a child of is going to be freed and you wish to keep the
388memory for a longer time.
389
390The talloc_reparent() function returns the pointer that you pass it. It
391does not have any failure modes.
392
393The difference between talloc_reparent() and talloc_steal() is that
394talloc_reparent() can specify which parent you wish to change. This is
395useful when a pointer has multiple parents via references.
396
397=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
398void *talloc_parent(const void *ptr);
399
400The talloc_parent() function returns the current talloc parent. This
401is usually the pointer under which this memory was originally created,
402but it may have changed due to a talloc_steal() or talloc_reparent()
403
404=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
405size_t talloc_total_size(const void *ptr);
406
407The talloc_total_size() function returns the total size in bytes used
408by this pointer and all child pointers. Mostly useful for debugging.
409
410Passing NULL is allowed, but it will only give a meaningful result if
411talloc_enable_leak_report() or talloc_enable_leak_report_full() has
412been called.
413
414
415=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
416size_t talloc_total_blocks(const void *ptr);
417
418The talloc_total_blocks() function returns the total memory block
419count used by this pointer and all child pointers. Mostly useful for
420debugging.
421
422Passing NULL is allowed, but it will only give a meaningful result if
423talloc_enable_leak_report() or talloc_enable_leak_report_full() has
424been called.
425
426=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
427void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
428 void (*callback)(const void *ptr,
429 int depth, int max_depth,
430 int is_ref,
431 void *priv),
432 void *priv);
433
434This provides a more flexible reports than talloc_report(). It
435will recursively call the callback for the entire tree of memory
436referenced by the pointer. References in the tree are passed with
437is_ref = 1 and the pointer that is referenced.
438
439You can pass NULL for the pointer, in which case a report is
440printed for the top level memory context, but only if
441talloc_enable_leak_report() or talloc_enable_leak_report_full()
442has been called.
443
444The recursion is stopped when depth >= max_depth.
445max_depth = -1 means only stop at leaf nodes.
446
447
448=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
449void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f);
450
451This provides a more flexible reports than talloc_report(). It
452will let you specify the depth and max_depth.
453
454
455=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
456void talloc_report(const void *ptr, FILE *f);
457
458The talloc_report() function prints a summary report of all memory
459used by ptr. One line of report is printed for each immediate child of
460ptr, showing the total memory and number of blocks used by that child.
461
462You can pass NULL for the pointer, in which case a report is printed
463for the top level memory context, but only if
464talloc_enable_leak_report() or talloc_enable_leak_report_full() has
465been called.
466
467
468=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
469void talloc_report_full(const void *ptr, FILE *f);
470
471This provides a more detailed report than talloc_report(). It will
472recursively print the ensire tree of memory referenced by the
473pointer. References in the tree are shown by giving the name of the
474pointer that is referenced.
475
476You can pass NULL for the pointer, in which case a report is printed
477for the top level memory context, but only if
478talloc_enable_leak_report() or talloc_enable_leak_report_full() has
479been called.
480
481
482=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
483void talloc_enable_leak_report(void);
484
485This enables calling of talloc_report(NULL, stderr) when the program
486exits. In Samba4 this is enabled by using the --leak-report command
487line option.
488
489For it to be useful, this function must be called before any other
490talloc function as it establishes a "null context" that acts as the
491top of the tree. If you don't call this function first then passing
492NULL to talloc_report() or talloc_report_full() won't give you the
493full tree printout.
494
495Here is a typical talloc report:
496
497talloc report on 'null_context' (total 267 bytes in 15 blocks)
498 libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
499 libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
500 iconv(UTF8,CP850) contains 42 bytes in 2 blocks
501 libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
502 iconv(CP850,UTF8) contains 42 bytes in 2 blocks
503 iconv(UTF8,UTF-16LE) contains 45 bytes in 2 blocks
504 iconv(UTF-16LE,UTF8) contains 45 bytes in 2 blocks
505
506
507=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
508void talloc_enable_leak_report_full(void);
509
510This enables calling of talloc_report_full(NULL, stderr) when the
511program exits. In Samba4 this is enabled by using the
512--leak-report-full command line option.
513
514For it to be useful, this function must be called before any other
515talloc function as it establishes a "null context" that acts as the
516top of the tree. If you don't call this function first then passing
517NULL to talloc_report() or talloc_report_full() won't give you the
518full tree printout.
519
520Here is a typical full report:
521
522full talloc report on 'root' (total 18 bytes in 8 blocks)
523 p1 contains 18 bytes in 7 blocks (ref 0)
524 r1 contains 13 bytes in 2 blocks (ref 0)
525 reference to: p2
526 p2 contains 1 bytes in 1 blocks (ref 1)
527 x3 contains 1 bytes in 1 blocks (ref 0)
528 x2 contains 1 bytes in 1 blocks (ref 0)
529 x1 contains 1 bytes in 1 blocks (ref 0)
530
531
532=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
533void talloc_enable_null_tracking(void);
534
535This enables tracking of the NULL memory context without enabling leak
536reporting on exit. Useful for when you want to do your own leak
537reporting call via talloc_report_null_full();
538
539=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
540void talloc_disable_null_tracking(void);
541
542This disables tracking of the NULL memory context.
543
544=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
545(type *)talloc_zero(const void *ctx, type);
546
547The talloc_zero() macro is equivalent to::
548
549 ptr = talloc(ctx, type);
550 if (ptr) memset(ptr, 0, sizeof(type));
551
552
553=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
554void *talloc_zero_size(const void *ctx, size_t size)
555
556The talloc_zero_size() function is useful when you don't have a known type
557
558
559=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
560void *talloc_memdup(const void *ctx, const void *p, size_t size);
561
562The talloc_memdup() function is equivalent to::
563
564 ptr = talloc_size(ctx, size);
565 if (ptr) memcpy(ptr, p, size);
566
567
568=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
569char *talloc_strdup(const void *ctx, const char *p);
570
571The talloc_strdup() function is equivalent to::
572
573 ptr = talloc_size(ctx, strlen(p)+1);
574 if (ptr) memcpy(ptr, p, strlen(p)+1);
575
576This functions sets the name of the new pointer to the passed
577string. This is equivalent to::
578
579 talloc_set_name_const(ptr, ptr)
580
581=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
582char *talloc_strndup(const void *t, const char *p, size_t n);
583
584The talloc_strndup() function is the talloc equivalent of the C
585library function strndup()
586
587This functions sets the name of the new pointer to the passed
588string. This is equivalent to:
589 talloc_set_name_const(ptr, ptr)
590
591=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
592char *talloc_append_string(const void *t, char *orig, const char *append);
593
594The talloc_append_string() function appends the given formatted
595string to the given string.
596
597This function sets the name of the new pointer to the new
598string. This is equivalent to::
599
600 talloc_set_name_const(ptr, ptr)
601
602=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
603char *talloc_vasprintf(const void *t, const char *fmt, va_list ap);
604
605The talloc_vasprintf() function is the talloc equivalent of the C
606library function vasprintf()
607
608This functions sets the name of the new pointer to the new
609string. This is equivalent to::
610
611 talloc_set_name_const(ptr, ptr)
612
613
614=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
615char *talloc_asprintf(const void *t, const char *fmt, ...);
616
617The talloc_asprintf() function is the talloc equivalent of the C
618library function asprintf()
619
620This functions sets the name of the new pointer to the new
621string. This is equivalent to::
622
623 talloc_set_name_const(ptr, ptr)
624
625
626=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
627char *talloc_asprintf_append(char *s, const char *fmt, ...);
628
629The talloc_asprintf_append() function appends the given formatted
630string to the given string.
631Use this varient when the string in the current talloc buffer may
632have been truncated in length.
633
634This functions sets the name of the new pointer to the new
635string. This is equivalent to::
636
637 talloc_set_name_const(ptr, ptr)
638
639
640=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
641char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...);
642
643The talloc_asprintf_append() function appends the given formatted
644string to the end of the currently allocated talloc buffer.
645Use this varient when the string in the current talloc buffer has
646not been changed.
647
648This functions sets the name of the new pointer to the new
649string. This is equivalent to::
650
651 talloc_set_name_const(ptr, ptr)
652
653
654=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
655((type *)talloc_array(const void *ctx, type, uint_t count);
656
657The talloc_array() macro is equivalent to::
658
659 (type *)talloc_size(ctx, sizeof(type) * count);
660
661except that it provides integer overflow protection for the multiply,
662returning NULL if the multiply overflows.
663
664
665=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
666void *talloc_array_size(const void *ctx, size_t size, uint_t count);
667
668The talloc_array_size() function is useful when the type is not
669known. It operates in the same way as talloc_array(), but takes a size
670instead of a type.
671
672=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
673(typeof(ptr)) talloc_array_ptrtype(const void *ctx, ptr, uint_t count);
674
675The talloc_ptrtype() macro should be used when you have a pointer to an array
676and want to allocate memory of an array to point at with this pointer. When compiling
677with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_array_size()
678and talloc_get_name() will return the current location in the source file.
679and not the type.
680
681=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
682void *talloc_realloc_fn(const void *ctx, void *ptr, size_t size);
683
684This is a non-macro version of talloc_realloc(), which is useful
685as libraries sometimes want a ralloc function pointer. A realloc()
686implementation encapsulates the functionality of malloc(), free() and
687realloc() in one call, which is why it is useful to be able to pass
688around a single function pointer.
689
690
691=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
692void *talloc_autofree_context(void);
693
694This is a handy utility function that returns a talloc context
695which will be automatically freed on program exit. This can be used
696to reduce the noise in memory leak reports.
697
698
699=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
700void *talloc_check_name(const void *ptr, const char *name);
701
702This function checks if a pointer has the specified name. If it does
703then the pointer is returned. It it doesn't then NULL is returned.
704
705
706=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
707(type *)talloc_get_type(const void *ptr, type);
708
709This macro allows you to do type checking on talloc pointers. It is
710particularly useful for void* private pointers. It is equivalent to
711this::
712
713 (type *)talloc_check_name(ptr, #type)
714
715
716=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
717talloc_set_type(const void *ptr, type);
718
719This macro allows you to force the name of a pointer to be a
720particular type. This can be used in conjunction with
721talloc_get_type() to do type checking on void* pointers.
722
723It is equivalent to this::
724
725 talloc_set_name_const(ptr, #type)
726
727=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
728talloc_get_size(const void *ctx);
729
730This function lets you know the amount of memory alloced so far by
731this context. It does NOT account for subcontext memory.
732This can be used to calculate the size of an array.
733
734=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
735void *talloc_find_parent_byname(const void *ctx, const char *name);
736
737Find a parent memory context of the current context that has the given
738name. This can be very useful in complex programs where it may be
739difficult to pass all information down to the level you need, but you
740know the structure you want is a parent of another context.
741
742=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
743(type *)talloc_find_parent_bytype(ctx, type);
744
745Like talloc_find_parent_byname() but takes a type, making it typesafe.
746
747=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
748void talloc_set_log_fn(void (*log_fn)(const char *message));
749
750This function sets a logging function that talloc will use for
751warnings and errors. By default talloc will not print any warnings or
752errors.
753
754=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
755void talloc_set_log_stderr(void)
756
757This sets the talloc log function to write log messages to stderr