src/tests/test_utils/compiler_test.cpp


Log

Author Commit Date CI Message
Shahbaz Youssefi 02ae054c 2025-04-07T13:48:29 Translator: Fix init of inactive output variables Bug: chromium:398401939 Change-Id: I0df494b945b8d0e805a62cf7645d06bf233f36ca Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6438495 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen 12584049 2024-10-21T14:04:55 Make SimplifyLoopConditions testable Add ShCompileOptions::simplifyLoopConditions, so that tests can turn it on. Later edits to simplify loop condition logic are simpler to review when the testing related edits are landed separately. Test the feature by having ESSL as the input and ESSL as the natural output, to reflect how AST changes. To make the test expectations more deterministic across code changes, change SymbolTable::kLastBuiltInId to SymbolTable::kFirstUserDefinedSymbolId. This is simpler as no code needs to know exact last built in id, so we can just ensure that the user defined symbol ids do not clash with the builtin ids. Bug: angleproject:374585769 Change-Id: Iea0efb8ac2878691d0fd5ff5cfe9a49ac754515d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5946724 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Shahbaz Youssefi 6f80f0f0 2022-08-06T02:29:19 Translator: Clean up the compile flag passing interface Historically, compile flags were sent to the translator as a bitmask. Recently, we were getting close to running out of bits. Additionally, direct-to-metal work had started to introduce constants to be passed to the translator, which were misplaced in ShBuiltInResources and Caps. Recent work on Pixel Local Storage adds even more constants, aggravating the situation. In this change, the interface to passing compile flags is reworked. A struct is passed (instead of a bitmask) that has one bit for each flag. This can be indefinitely extended. Additionally, the constants needed by metal and PLS are also placed in this struct. In turn, the backends can set these options directly, and don't have to hack them into Caps to further get hacked into ShBuiltInResources. Bug: angleproject:7559 Change-Id: If93f1e1b8818ad3a0ac708ab04ab93b4b397d114 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3812562 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 061188a7 2021-08-04T10:07:47 Translator: General clean up General clean up done as part of other changes, split to simplify review. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Iade9954d187a759be9edd0e3754be007f4133c56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3071598 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 8b869a95 2021-06-13T01:09:27 Translator: Generate Ops for all built-in functions EOpCallBuiltInFunction is removed in this change, as well as the "op": "auto" property in builtin_function_declarations.txt. Instead, gen_builtin_symbols.py automatically generates Ops for every built-in function and generates the TOperator enum accordingly. This simplifies SPIR-V code generation by allowing switches to be used on operators instead of string comparisons. Bug: angleproject:4589 Bug: angleproject:4889 Change-Id: Ia351524400b0e12a10a5572e27e9b88c6ec2e61c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2958869 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 776c6015 2021-02-26T00:00:57 Vulkan: Call glslang at compile time With this change, the ANGLE translator immediately compiles the generated GLSL into SPIR-V with glslang and discards the source. This is in preparation for generating SPIR-V directly, by making the frontend and backend already able to digest it. This change also allows the expensive glslang calls to be parallelized, improving the following perf test by about 20%: LinkProgramBenchmark.Run/vulkan_compile_and_link_multi_thread Previously, the test was run as such in the Vulkan backend: Main Thread 1 Thread 2 Compile1 ---> Compile2 ---------------------> Translator Translator <--- <--------------------- Link glslang for shader1 glslang for shader2 Done With this change, it is run as such: Main Thread 1 Thread 2 Compile1 ---> Compile2 ---------------------> Translator Translator glslang glslang <--- <--------------------- Link Done glslang_wrapper_utils no longer interacts with glslang! A rename will follow. Bug: angleproject:4889 Change-Id: If4303e8ba0ba43b1a2f47f8c0a9133d0bee1a19a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2721195 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Stuart Morgan 9d737966 2019-08-14T12:25:12 Standardize copyright notices to project style For all "ANGLE Project" copyrights, standardize to the format specified by the style guide. Changes: - "Copyright (c)" and "Copyright(c)" changed to just "Copyright". - Removed the second half of date ranges ("Y1Y1-Y2Y2"->"Y1Y1"). - Fixed a small number of files that had no copyright date using the initial commit year from the version control history. - Fixed one instance of copyright being "The ANGLE Project" rather than "The ANGLE Project Authors" These changes are applied both to the copyright of source file, and where applicable to copyright statements that are generated by templates. BUG=angleproject:3811 Change-Id: I973dd65e4ef9deeba232d5be74c768256a0eb2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1754397 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
shrekshao be3d2d98 2019-06-25T17:52:17 More HLSL tests with regex Replace some more HLSL hardcoded unique id tests suffix with regex Bug: angleproject:3551 Change-Id: I4ed54092f9b2dda27702ba9412959ec3fb93a455 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1677408 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
shrekshao b937093e 2019-06-21T11:02:17 HLSL tests with regex HLSL adds a unique id suffix to user defined variable and these numbers are currently hardcoded in tests. It could easily fail if new tokens are added to angle builtin variables. Introduce C++11 regex feature into the foundInHLSLCode to avoid over strict tests. Bug: angleproject:3551 Change-Id: Ia3052afec667a7ac11198be31b5c1d03c856a723 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1670581 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shrek Shao <shrekshao@google.com>
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Olli Etuaho c26214de 2018-03-16T10:43:11 Move AST utilities to a subdirectory Move AST related utilities to compiler/translator/tree_util. BUG=angleproject:2409 TEST=angle_unittests Change-Id: I7567c2f6f2710292029263257c7ac26e2a144ac8 Reviewed-on: https://chromium-review.googlesource.com/966032 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho fbb1c792 2018-01-19T16:26:59 Store symbol names as a ImmutableString This will enable compile-time initialization of built-in symbols as well as reducing copying strings. Most of the code that deals with names is changed to use ImmutableString where it makes sense to avoid conversions. The lexer/parser now allocate const char pointers into pool memory instead of allocating TStrings. These are then converted to ImmutableString upon entering TParseContext. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: I244d6271ea1ecf7150d4f89dfa388a7745a1150c Reviewed-on: https://chromium-review.googlesource.com/881561 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 95ed1947 2018-02-01T14:01:19 Add a class for function lookups Using a purpose-built class for function lookups instead of using a combination of TFunction and a struct container for the this node and arguments makes the code clearer. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I3f345d836abeaa7f84cc46b4b840fd06c7e2e1a7 Reviewed-on: https://chromium-review.googlesource.com/897363 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 18841310 2017-11-28T12:48:47 Clean up MatchOutputCodeTest usage It's cleaner to use a generic function to test that a sequence of strings is found in a specific order rather than fetching and comparing string locations in test case code. Also make sure that string occurrences can't overlap when looking for a specific number of occurrences of the same string. TEST=angle_unittests Change-Id: I8ca66c73c7aaa5be8469ded466f51d97a36c801b Reviewed-on: https://chromium-review.googlesource.com/793041 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ae04e1e4 2017-11-27T16:00:39 Fix scalarizing vec and mat constructor args Scalarizing vec and mat constructor args can generate new statements in the parent block of the constructor. To preserve the correct execution order of expressions, scalarized vector and matrix constructors need to be first moved out from inside loop conditions and sequence operators. This is done whenever the compiler flag to scalarize args is on. BUG=chromium:772653 TEST=angle_unittests Change-Id: Id40f8d848a9d087e186ef2e680c8e4cd440221d9 Reviewed-on: https://chromium-review.googlesource.com/790412 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiawei Shao 65c56dd9 2017-10-13T16:18:57 Fix incorrect hashing on built-in interface block fields This patch intends to fix an error in translating built-in interface block fields. Any field of a built-in interface block should be kept and cannot be hashed. This patch can fix a bug in handling the interface block gl_in when we try to output the translated geometry shader string. BUG=angleproject:1941 TEST=angle_unittest Change-Id: Iebfba4b6a30c8942ed0f66131ad30d12ad96c62a Reviewed-on: https://chromium-review.googlesource.com/719454 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Martin Radev 70c95fa6 2017-07-07T18:45:49 Add function in MatchOutputCodeTest to find occurrence of a string The patch adds a function in MatchOutputCodeTest to get the position of the first occurrence of an expression in the translated output code. This can help design more complicated tests like a test which checks for the order of simple expressions. BUG=angleproject:2062 TEST=angle_unittests Change-Id: I1249d4762c247848c4eec64ecb8c1357b5e8d40a Reviewed-on: https://chromium-review.googlesource.com/563659 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho cccf2b00 2017-07-05T14:50:54 Reorganize AST traversal utility code Define TIntermTraverser and TIntermLValueTrackingTraverser in a separate header file. hash() function is moved out from TIntermTraverser as it is not related to the core functionality of traversing and transforming ASTs. Also reorganize some traversers to follow common conventions: - Intermediate output is now in OutputTree.h/.cpp - Max tree depth check is now in IsASTDepthBelowLimit.h/.cpp BUG=angleproject:1490 TEST=angle_unittests Change-Id: Id4968aa9d4e24d0c5bac90dc147fc9f310de0184 Reviewed-on: https://chromium-review.googlesource.com/559531 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho f2209f74 2017-04-01T12:45:55 Clean up function name mangling code Fix a few incorrect comments about mangled names, and refactor generating mangled names from function call nodes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I3ee68c4c0982f1a9c28d8e87aafa19f19559bbf8 Reviewed-on: https://chromium-review.googlesource.com/465826 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho ec9232bd 2017-03-27T17:01:37 Store unmangled function names in the AST This makes the code simpler across the board. There are a few cases where mangled names still need to be generated in AST traversers, but they are outweighed by much leaner output code for all function nodes. BUG=angleproject:1490 TEST=angle_unittests, angle_end2end_tests Change-Id: Id3638e0fca6019bbbe6fc5e1b7763870591da2d8 Reviewed-on: https://chromium-review.googlesource.com/461077 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 1ecd14b8 2017-01-26T13:54:15 Fold user-definedness of function nodes into TOperator Whether a function call is user-defined is not orthogonal to TOperator associated with the call node - other ops than function calls can't be user-defined. Because of this it makes sense to store the user- definedness by having different TOperator enums for different types of calls. This patch also tags internal helper functions that have a raw definition outside the AST with a separate TOperator enum. This way they can be handled with logic that is easy to understand. Before this, function calls like this left the user-defined bit unset, despite not really being built-ins either. The EmulatePrecision traverser uses this. This is also something that could be used to clean up built-in emulation in the future. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I597fcd9789d0cc22b689ef3ce5a0cc3f621d4859 Reviewed-on: https://chromium-review.googlesource.com/433443 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 09b04a2f 2016-12-15T13:30:26 Add shader translator support for OVR_multiview The OVR_multiview and OVR_multiview2 extensions add gl_ViewID_OVR to shaders. gl_ViewID_OVR can be translated either as is in GLSL output or as a uniform by setting the SH_TRANSLATE_VIEWID_OVR_AS_UNIFORM compiler flag. If WebGL output is selected, the shaders will be validated according to proposed rules in the WEBGL_multiview spec. BUG=angleproject:1669 TEST=angle_unittests Change-Id: I19ea3a6c8b4edb78be03f1a50a96bfef018870d0 Reviewed-on: https://chromium-review.googlesource.com/422848 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 45bcc784 2016-11-07T13:58:48 translator: Scope all classes with "sh". I was seeing an odd problem with our PoolAlloc conflicting with the glslang/Vulkan TIntermNode, so the fix was to move everything to a separate namespace. The bison grammars are also regenerated. No functional changes. BUG=angleproject:1576 Change-Id: I959c7afe4c092f0d458432c07b4dcee4d39513f3 Reviewed-on: https://chromium-review.googlesource.com/408267 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill acb4b81a 2016-11-07T13:50:29 translator: Put ShaderLang APIs in "sh" namespace. Working with glslang in Vulkan means we are static linking libANGLE with functions that have the same name as our translator APIs. We can fix this by scoping our APIs. We don't need to scope the types of the file, since they don't conflict. This will require a follow-up patch to remove the unscoped APIs once we switch over Chromium. We also scope TCompiler and some related classes to avoid multiply defined link errors with glslang. BUG=angleproject:1576 Change-Id: I729b19467d2ff7d374a82044b16dbebdf2dc8f16 Reviewed-on: https://chromium-review.googlesource.com/408337 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Martin Radev 2cc85b3b 2016-08-05T16:22:53 Add support for images in the compiler The patch adds support for GLSL ES 3.1 image types. Internal format layout qualifiers for images are added. Support for the readonly and writeonly qualifiers are added. The other memory qualifiers are omitted as to make the patch simpler. Tests are added which check for correct and incorrect usage of images, internal format layout and memory qualifiers. BUG=angleproject:1442 TEST=angle_unittests TEST=angle_end2end_tests Change-Id: Ie4d3acb2a195de11b405ad54110a04c4c1de0b7e Reviewed-on: https://chromium-review.googlesource.com/378855 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Qiankun Miao 7ebb97fc 2016-09-08T18:01:50 Use 64-bits compile options BUG=chromium:645071 Change-Id: I31825123bf4cb45fb37a93f538e8936487beb5ff Reviewed-on: https://chromium-review.googlesource.com/382712 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 613b959d 2016-09-05T12:05:53 Clean up qualification order checks Move determining whether qualification order checks are relaxed to QualifierTypes.cpp. The ParseContext only needs to construct TTypeQualifierBuilder with the shader version as a parameter, and it will make the decision based on that. ParseContext still passes diagnostics to the TTypeQualifierBuilder functions that return variable qualification to make it more explicit when errors are generated. Also encapsulate looking for symbols in the AST inside compiler_test.cpp. BUG=angleproject:1442 TEST=angle_unittests Change-Id: I4190e6a680ace0cc0568a517e86353a95cc63c08 Reviewed-on: https://chromium-review.googlesource.com/380556 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Geoff Lang 91d56945 2015-07-21T18:56:48 Emulate the pack/unpack functions for unorms. BUG=angleproject:1044 Change-Id: I2cfb792de43d3a6fddd750100c74f948948dc1f6 Reviewed-on: https://chromium-review.googlesource.com/287290 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Olli Etuaho 10fcd9be 2016-06-30T12:24:09 Add a helper class for compiler string matching tests The MatchOutputCodeTest class makes it easier to implement tests that do string matching on compiler output. Inheriting test classes set the compiler settings, tests then call compile() with the shader string and can call foundInCode() to check if the output code contains a given string. Various compiler unit tests that already did string matching are refactored to make use of this new helper class. Some tests now use SH_GLES3_SPEC instead of SH_GLES2_SPEC - this should not have a significant impact on test coverage. Some compileTestShader function variants that are now unused can be removed from the code. BUG=angleproject:1430 TEST=angle_unittests Change-Id: I1fd3529d5a1c6ab192f95ace800cf162604e68e7 Reviewed-on: https://chromium-review.googlesource.com/357800 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho a6996685 2015-10-12T14:32:30 Automatically enable highp in fragment shaders on ESSL3 Most code using the translator already enables highp with the resources flag when a shader spec that accepts ESSL3 is used, but for example the shader_translator utility doesn't. This fix makes sure that highp is always enabled when a fragment shader written in ESSL3 or newer is being compiled. This will make shader_translator easier to use for testing ESSL3 shaders. BUG=541550 TEST=angle_unittests Change-Id: Ia1911677c55f3c5d921829a8cbb808847ac8b636 Reviewed-on: https://chromium-review.googlesource.com/305190 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 7adfb184 2015-06-09T15:49:41 Refactor common compiler test functionality into helper functions Refactor translating a ESSL shader string into a target language so that compiler initialization and cleanup code can be reused between test classes. BUG=angleproject:817 TEST=angle_unittests Change-Id: Idb229dceb9e17b13ed6ad2a68ab55ed5c968780e Reviewed-on: https://chromium-review.googlesource.com/275814 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>