src/compiler/translator/ParseContext.cpp


Log

Author Commit Date CI Message
Olli Etuaho fc1806e1 2015-03-17T13:03:11 Move most of addBinaryMath from Intermediate to ParseContext Some type checks for binary math will be different based on the shading language version, which is easily accessible in ParseContext. Because of this and also for architectural simplicity it makes more sense to have the checks in ParseContext. BUG=angle:941 TEST=angle_unittests, WebGL conformance tests Change-Id: I92a499f47e1cbc6a7b6391ce0fa04284803e7140 Reviewed-on: https://chromium-review.googlesource.com/260570 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 72ba85bf 2015-03-04T14:23:26 Fix regression in addFunctionCallOrMethod Fix a crash when parsing a shader with incorrect constructor arguments. BUG=angleproject:911 TEST=WebGL conformance tests Change-Id: I3459612f36185db861a361fa916cc6b671795037 Reviewed-on: https://chromium-review.googlesource.com/255870 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho c4ba3bef 2015-03-02T14:42:24 Refactor addFunctionCallOrMethod out of glslang.y TEST=angle_unittests BUG=angle:911 Change-Id: I6d4c0f0bfbf9e6252e241ae5bb1b6acdb463fce6 Reviewed-on: https://chromium-review.googlesource.com/255451 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho ac5274df 2015-02-20T10:19:08 Add validation for the structure of switch statements Implement a traverser to check for the following errors: -More than one default or replicated constant expression -No statement between a label and the end of a switch statement -Statements in a switch statement before the first case statement -Mismatch between the type of init-expression and type of a case label -Case or default label nested inside other control flow nested within the corresponding switch Tested by manually disabling shading language version checks for switch and by manually enabling case statements in a Chromium build and checking that the expected errors are generated. BUG=angle:921 Change-Id: I99c49c17c8b520849adbe4d8521e46cb10e20e41 Reviewed-on: https://chromium-review.googlesource.com/251524 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 53f076fa 2015-02-20T10:55:14 Add basic error checks for switch and case Check that the case labels have constant scalar integers, and that switch statements are initialized with scalar integers. Also check that case and default labels do not exist outside switch statements. Allow break statements inside switch statements. Tested by manually disabling shading language version checks for switch in a Chromium build and checking that the expected errors are generated. BUG=angle:921 Change-Id: Ibe83d0db52958c493ded5640d4babf670dc02d55 Reviewed-on: https://chromium-review.googlesource.com/251523 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho a3a36664 2015-02-17T13:46:51 Implement parsing switch statements Put in some groundwork for parsing switch statements and case labels in the parser, including definitions for IntermNode classes. Intermediate functions for adding the statements are stubbed to only generate errors for now. Tested by manually disabling shading language version checks for switch in a Chromium build and checking that the expected errors are generated. BUG=angle:921 Change-Id: I064b3e0c4c1b724a083cf5bc78eebfdd3794eb1b Reviewed-on: https://chromium-review.googlesource.com/250380 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 49300865 2015-02-20T14:54:49 Refactor validating jump statements out of glslang.y Move the logic to ParseContext. This will simplify changing the logic for the break statement that is needed to implement switch. BUG=angle:921, angle:911 TEST=WebGL conformance tests Change-Id: Ib8bbc7075c05d345e90377202b5446fb3307f94c Reviewed-on: https://chromium-review.googlesource.com/251522 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho b6e07a6a 2015-02-16T12:22:10 Implement ESSL3 modf This is the first built-in function that has an out parameter, so l-value checks are added for built-ins. BUG=angle:918 Change-Id: Ifd5befe955224f706f864e25107879c9cdce9e9f Reviewed-on: https://chromium-review.googlesource.com/250780 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 09b22474 2015-02-11T11:47:26 Add addBinaryMath and addUnaryMath helpers to ParseContext This refactoring reduces code duplication and moves functionality that is not immediately related to the language grammar out of glslang.y. BUG=angle:911 Change-Id: If5e225461890ed542dee01905829df1c9a6f5e27 Reviewed-on: https://chromium-review.googlesource.com/248570 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 9b82084f 2015-02-12T10:40:10 Fix HLSL varying struct linking. We would always expand a struct name to always include its symbol ID. This fixes the workaround to only affect scoped structs. We can leave global structs, which are by definition uniquely named, without decorating them with a symbol ID. This fixes several tests in dEQP's shader.linkage.varying.struct. Re-land with GLSL translator bug fixed. BUG=angle:910 Change-Id: I23a932bd1dadea5e9aafabde697e6a2af9a43f2b Reviewed-on: https://chromium-review.googlesource.com/249134 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill b960cc4a 2015-02-12T15:33:20 Revert "Allow varying structs to match between stages." This patch has a bug which breaks the GLSL to GLSL translator. See broken GPU FYI bot builds on the Chromium waterfall: http://build.chromium.org/p/chromium.gpu.fyi/builders/Win7%20Release%20%28NVIDIA%29/builds/13074 This reverts commit 489ffc4d69656c2dbfdbe07e3fa6e38baeb3e072. Change-Id: I8241c6d658f4f31af91b89af1141d3d778ff7c70 Reviewed-on: https://chromium-review.googlesource.com/249131 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 489ffc4d 2015-02-11T16:33:07 Allow varying structs to match between stages. We would always expand a struct name to always include its symbol ID. This workaround fixed scoped structs with the same name. It would also block any possiblity of linking the structs successfully. Instead we can use the workaround only on inner-scoped structs, and leave global structs, which are by definition uniquely named, as they are. This fixes several tests in dEQP's shader.linkage.varying.struct. BUG=angle:910 Change-Id: I81b8dadc7ea493152aff0c44d607114eaaabb142 Reviewed-on: https://chromium-review.googlesource.com/247242 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Austin Kinross 3ae6465f 2015-01-26T15:51:39 Fix lots of variable shadowing in ANGLE BUG=angle:877 Change-Id: I3df0fffb19f5ecbe439fbc2a8d6d239a5dc6b638 Reviewed-on: https://chromium-review.googlesource.com/243334 Tested-by: Austin Kinross <aukinros@microsoft.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 74cafab1 2015-01-23T23:17:32 Revert "Fix lots of variable shadowing in ANGLE" Caused WebGL CTS failures on the texture-npot test: https://www.khronos.org/registry/webgl/sdk/tests/conformance/textures/texture-npot.html This reverts commit c67e6e9fade44ef8938724e82db11db725e9c8e5. Change-Id: I089e99859231e0d657084ac3647257c650a9da92 Reviewed-on: https://chromium-review.googlesource.com/243041 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Austin Kinross c67e6e9f 2015-01-21T16:01:07 Fix lots of variable shadowing in ANGLE BUG=angle:877 Change-Id: I15168ae32605b26aee08274464ffe68adb5a7e87 Reviewed-on: https://chromium-review.googlesource.com/242351 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Austin Kinross <aukinros@microsoft.com>
Jamie Madill 21c1e456 2014-12-29T11:33:41 Fix a translator crash with index expressions. This crash happened with certain bad shaders which used temporary values as array (or other) index expresisons. Fixes the crash covered in the WebGL test "conformance/bugs/undefined-index-should-not-crash" BUG=angle:857 Change-Id: I13e2ba6d5f1ab0846ac902021bc0b57cbb37d759 Reviewed-on: https://chromium-review.googlesource.com/237460 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 2c43325d 2014-12-03T12:36:54 Fix double delete with invariant varyings. The compiler would leave some TString variables lying around after the pool gets released, leading to a potential crash. BUG=angle:846 Change-Id: I484ed9b14bba9bf653f6ed4001ae79f87791b0dd Reviewed-on: https://chromium-review.googlesource.com/232780 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Erik Dahlström ea7a2121 2014-11-17T16:15:57 Add GLSL/ESSL validator/translator support for GL_EXT_shader_framebuffer_fetch. BUG=angle:834 Change-Id: I2d4e25909a8e1266b9bb7f1d4421324143157c8a Reviewed-on: https://chromium-review.googlesource.com/231032 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Erik Dahlström <ed@opera.com>
Olli Etuaho 21203702 2014-11-13T16:16:21 Fix precision tracking of constructor return values Precision should be set for constructor return values if they are of a built-in type. Structs should not be precision qualified. BUG=angle:787 Change-Id: Ie5efd5be25a788ff6f01c5b989254572c00231eb Reviewed-on: https://chromium-review.googlesource.com/229560 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Zhenyao Mo 94ac7b78 2014-10-15T18:22:08 Invariant related processing. * Fix a bug in PreProcessor for STDGL pragma. * Record all invariant settings and set them in ShaderVariable. * Write #pragma STDGL invariant(all) in GL BUG=angle:776 TEST=https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/shaders-with-invariance.html Change-Id: Ie28b75480deed79f0c9f26e3b98f1778d1290182 Reviewed-on: https://chromium-review.googlesource.com/223610 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 3b5c2dae 2014-08-19T15:23:32 Add a new invariant declaration operator. BUG=angle:711 Change-Id: I54a48b636a68c317b8d44ee2d578847b80095289 Reviewed-on: https://chromium-review.googlesource.com/213500 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens ffd7387a 2014-08-21T13:49:16 Prevent accessing more arguments than provided. BUG=390111 Change-Id: Iecc2ac2354a82cca937a823e5c588c662264e36c Reviewed-on: https://chromium-review.googlesource.com/213551 Tested-by: Nicolas Capens <capn@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 47e3ec08 2014-08-20T16:38:33 Add a helper method to parse invariant declarations. This pulls out more functionality from the grammar into simple c++ source files. BUG=angle:711 Change-Id: I19121d710dc1543585361cb53a0deb2ea0479db9 Reviewed-on: https://chromium-review.googlesource.com/212938 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Jamie Madill 5c09702f 2014-08-20T16:38:32 Add a getNamedVariable helper method to TParseContext. This method will be useful in more than one place, since we need to get a TType from an indentifier when parsing invariant declarations. BUG=angle:711 Change-Id: I1c1befbdcc93ea626428fb4e313b8c6326c158f6 Reviewed-on: https://chromium-review.googlesource.com/212937 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <capn@chromium.org>
Zhenyao Mo e40d1e9c 2014-07-16T17:40:36 Fix style violations. BUG=angle:650 TEST=no behavior change Change-Id: I3096615a181b1ec2c18ce60566c3d6249975b84e Reviewed-on: https://chromium-review.googlesource.com/208569 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens adfffe46 2014-06-17T02:13:36 Duplicate reused symbol table entries. BUG=angle:651 Change-Id: Ifce3c19d41a0a5a5ca5ee90ede528adf397d1da5 Reviewed-on: https://chromium-review.googlesource.com/204290 Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Nicolas Capens 16004fca 2014-06-11T11:29:11 Eliminate conversion operations. They've been replaced by using constructor nodes, so any code handling conversion operators can be removed. BUG=380353 Change-Id: I70413179e7443efccbf997a5dd0f053c23689589 Reviewed-on: https://chromium-review.googlesource.com/203453 Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Nicolas Capens 6ed8d8af 2014-06-11T11:25:20 Produce constructors instead of conversions. GLSL only supports explicit conversion through constructors. Therefore the conversion nodes are redundant. BUG=380353 Change-Id: Id871c34750191dac431bf72aac9afed7b0db7f8e Reviewed-on: https://chromium-review.googlesource.com/203452 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Nicolas Capens 906744ac 2014-06-06T15:18:07 Restrict the size of shader arrays. This prevents overflow issues in the HLSL translator and some drivers. The limit it hard-coded to 65536 to be larger than the Shader Model 5 register limit (4096) to account for register allocation optimizations and future hardware. BUG=379799 Change-Id: I20f05c9dd230fbfc1c92af52533cd2b50f2ff994 Reviewed-on: https://chromium-review.googlesource.com/202939 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Jamie Madill bfa91f47 2014-06-05T15:45:18 Redesign HLSL scoped structures to a unique ID. A unique ID gives a more flexible renaming scheme than our current method of using nested scope identifiers. The reduced complexity allows for fewer points of breakage and fixes an outstanding bug with scoped structures (with added test). BUG=angle:618 Change-Id: I6551248bb9fa2d185ab67248721f898dd50151f0 Reviewed-on: https://chromium-review.googlesource.com/202183 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 10567260 2014-04-17T16:40:00 Fix build with Clang. Clang's validation is a bit more thorough than GCC's or MSVC's and picked up a few new errors and warnings. We missed a few default cases in switches and used an improper type for default arguments. BUG=angle:568 Change-Id: I34239c6c5c785ad1e62917fc37c3243f4c5b5f1b Reviewed-on: https://chromium-review.googlesource.com/195472 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 41a49272 2014-03-18T16:10:13 Fixed error message for exceeding maximum struct nesting. It got broken in r2423. We were referring to field-name as struct-name. This patch fixes the regression and also improves the error message by adding the field-name. BUG=angle:459 R=kbr@chromium.org Review URL: https://codereview.appspot.com/12891043 Change-Id: I9ac9a8dafcad1857f7d39e6d494e457d1fc50f70 Reviewed-on: https://chromium-review.googlesource.com/190530 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 5508f39d 2014-02-20T13:31:36 Fix breaking the build with missing GetGlobalMaxTokenSize. Because the preprocessor is used independently from the compiler, we need a way to track max token size when we don't have access to the parse context with the current spec. BUG=angle:550 Change-Id: Idf5035ec2c001ee75f264151ab3c4e92f3cd44d7 Reviewed-on: https://chromium-review.googlesource.com/187140 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Geoff Lang c6856732 2014-02-11T09:38:55 Fix wrong enum type being compared. Change-Id: I020bbf8179c08574f5fc0a207db03d7456eeeba1 Reviewed-on: https://chromium-review.googlesource.com/185860 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Brendan Long eaa84061 2013-12-08T18:26:50 Remove unnecessary int cast in ParseContext. BUG=angle:536 Change-Id: I72287f5ce9736cd48fc241022e09446db717cf92 Reviewed-on: https://chromium-review.googlesource.com/181770 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Commit-Queue: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shannon Woods 7f2d7945 2013-11-19T15:07:58 Manual merge of Ehsan Akhgari's patch to rename Diagnostics enums to avoid collision with Windows.h (See https://chromium-review.googlesource.com/#/c/177181/3) Change-Id: I2978d06ec96789b3ee1696b65a84c2a9f31f7ba4
Jamie Madill 6b9cb259 2013-10-17T10:45:47 Rename ParseHelper.cpp/h to ParseContext.cpp/h. TRAC #24002 Signed-off-by: Shannon Woods Signed-off-by: Geoff Lang