src/compiler/translator/ValidateAST.cpp


Log

Author Commit Date CI Message
Shahbaz Youssefi 6a997ce2 2025-10-03T00:03:25 Vulkan: SPIR-V Gen: Use unique id instead of pointer Bug: angleproject:349994211 Change-Id: I66d6c3cf58f1e7d850fb19def7aa863774d918a9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7007612 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 1f3b482f 2025-10-02T12:05:44 Translator: Fix UNREACHABLE() on gl_DepthRange compile error Bug: angleproject:349994211 Change-Id: I1918c8390de3fa4a5c7542b044e91e8d5e944b3a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7002886 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Kimmo Kinnunen 8e9dc1a6 2024-11-19T11:08:31 Validate anonymous struct names with namespace Consider GLSL: struct { vec4 e; } g; struct sbbf { vec4 f; }; The struct name validation would fail if user chosen struct name would clash with a symbol name that ANGLE internally gave to an anonymous struct. Fix by importing Name abstraction from MSL backend. A symbol name is a pair (namespace, string). Move operator<<(std::ostream &os, const ImmutableString &str) to sh namespace because that is more natural for operator overloading name resolution. MSVC works with this. Bug: angleproject:379758201 Change-Id: Icc9b02aa8cb532e1d925e2fba4c45468f01b9144 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6035029 Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen 7ba69645 2024-11-14T10:07:31 Fix unnamed outs w/ initializeUninitializedLocals Fix translator initializeUninitializedLocals pass for anonymous out parameters. The parameters should be initialized to zero, similar to named but unassigned parameters. Initialization would be skipped on GLSL output, assert on Metal. Functions need to be replaced if their parameter names change. In case the function had a prototype declaration, that has to be replaced too. All calls to old functions must be replaced with calls to new function. Bug: angleproject:378584780 Change-Id: I9a990fa3840f6e26cd30f35bf6c99d9a8816f272 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6020245 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen b8d546b2 2024-10-30T15:40:58 Fix immutable string concats with ints `BuildConcatenatedImmutableString("a", 10, "b")` would construct "a\nb" because the implementation lacked int overloads and ints would be promoted to chars implicitly. Fix by implementing simpler way to calculate digits for numbers and then add useful overloads. Remove ImmutableStringBuilder::appendDecimal() since the code is already expecting << for all other types, and the bug was due to this expectation. Bug: angleproject:376417347 Change-Id: Iea5e14a6e2fede068b704754b9203db794dd5bf0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5972641 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Shahbaz Youssefi a8138547 2024-10-09T23:33:24 Translator: Support GL_ARM_shader_framebuffer_fetch_depth_stencil Bug: angleproject:352364582 Change-Id: I46ce6d75a76bdf04a9e8feea1a480e8a0badba2a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5924140 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi d193d51b 2024-06-17T22:46:08 Replace issue ids post migration to new issue tracker This change replaces anglebug.com/NNNN links. Bug: None Change-Id: I8ac3aec8d2a8a844b3d7b99fc0a6b2be8da31761 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5637912 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 5137eb99 2024-05-27T01:38:23 Translator: Fix internal inconsistency with output init When creating "zero" nodes, this transformation directly takes the TType's from the variables being initialized. This means that qualifiers such as invariant, as well as any associations with interface blocks are retained in these constructors, which is not valid. This can trip up the SPIR-V generator which does not expect constructors to be qualified as such (i.e. assumes the TypeSpec to be the default). Bug: angleproject:342866364 Bug: angleproject:342866374 Bug: angleproject:343011429 Change-Id: If5c38e18ce977bd0eb1a48e41c59f6199eb7d2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5570155 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 96f44329 2024-03-25T14:16:10 Revert "Remove few redundant ImmutableString to std::string conversions" This reverts commit ebb94b807f184f2d36cb0843c429667cd80e0675. Reason for revert: Needs a different implementation of std::string::size() to pass C++17 compilers. Original change's description: > Remove few redundant ImmutableString to std::string conversions > > Maybe removes few strlen calls. > > Bug: angleproject:8614 > Change-Id: I4fbb5f6abb8e8d21ff44a34975bab379127a0a11 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5372715 > Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> > Commit-Queue: Geoff Lang <geofflang@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> Bug: angleproject:8614 Change-Id: I1a635b74674a2e1b635972bb4372c43340527a2f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5391900 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Kimmo Kinnunen ebb94b80 2024-03-16T09:11:51 Remove few redundant ImmutableString to std::string conversions Maybe removes few strlen calls. Bug: angleproject:8614 Change-Id: I4fbb5f6abb8e8d21ff44a34975bab379127a0a11 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5372715 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Dan Glastonbury 5a4bfd61 2024-01-12T17:15:39 Metal: Separate struct definition from function return The EmitMetal pass in shader translator does not handle writing the defintion of a structure that is declared in the return type of a function, such as: struct Foo { float val; } foo() { ... } This change adds a new pass, SeparateStructFromFunctionDeclarations, to separate the definition and declaration of struct variables in function prototypes into two statements, such as: struct Foo { float val; } foo(); struct Bar { int val; } bar() { ... } void main() { ... } Foo foo() { ... } into: struct Foo { float val; }; Foo foo(); struct Bar { int val; }; Bar bar() { ... } void main() { ... } Foo foo() { ... } Fixed: angleproject:8302 Change-Id: Id8b6ba256d3c8375dd889facd70e4715261c1ca3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5191644 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Alexey Knyazev ad52f12e 2023-03-21T00:00:00 Implement EXT_conservative_depth Added translator frontend and GLSL backend support for gl_FragDepth redeclaration and layout qualifiers. Added mappings to DepthGreater, DepthLess, and DepthUnchanged SPIR-V execution modes. Bug: angleproject:8046 Change-Id: I23f19ff54380741107970a44055ea269eef179f6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4355028 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 7586f8c8 2023-02-20T22:10:55 Translator: Validate correct op usage in nodes Bug: angleproject:2733 Change-Id: Id555398cd6633ce38e1d4d900c7b739fd9990ad1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4274045 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Sean Risser b96d1955 2023-01-20T16:06:34 Implement GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch allows fragment shaders to read gl_LastFragColorARM. The extension is similar to GL_EXT_shader_framebuffer_fetch, but is more limited in its capabilities. GL_ARM_shader_framebuffer_fetch was removed from HasFramebufferFetch() because it acts differently from GL_EXT_shader_framebuffer_fetch in significant enough ways that it should not be included in that single-use function. Tests: FramebufferFetchES31.*_ARM Bug: b/242419750 Bug: angleproject:7882 Change-Id: Id3a25c8ee50ca3e2a4c30a2261f507b0b53511ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4083108 Commit-Queue: Sean Risser <srisser@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 8474a95e 2022-08-05T22:15:04 Translator: Don't validate structs on non-root nodes Struct validation needs to know about structs that may have been defined outside the scope of the node, so this validation (similar to variable and function call validation) is disabled when validation a subtree of the AST. Bug: angleproject:7531 Bug: b/239207278 Change-Id: Id6dcee041a40f09f0c36a9ef3bfc238433b69c58 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3812047 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Lingfeng Yang b860fa45 2022-07-14T13:14:06 Vulkan: account for yuvCscStandard in switch validation The previous condition only accounted for ints, but needs to account for yuvCscStandard in order to support the new emulated yuv<->rgb builtins. Bug: b/223456677 Change-Id: I25e0c88b9c8eb5f8caf3e7640fe391a9b9c10bf1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3764431 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Lingfeng Yang <lfy@google.com>
Shahbaz Youssefi 79185677 2022-06-22T16:22:35 Translator: Fix validation of struct with same-name struct field In the following: ``` struct S { S s; }; ``` The `S` in the field refers to a previous declaration of `S` in an outer scope. The validation code mistakenly attempted to ensure it refers to the same `S` being declared. Bug: chromium:1337628 Change-Id: I86184be63bc59e608fe5b24369cd4c40b3bb3b31 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3716965 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 98c2e169 2022-05-20T16:17:49 Vulkan: Reduce pre-rotation spec const to bool The specialization constant now only dictates whether x and y should be swapped. The complete 8 possible states of rotation and y-flip are achieved by using this swap in combination with a driver uniform for x and y flip. Swapping is still a specialization constant to avoid degrading performance of dFdx/dFdy which otherwise would need both to be evaluated instead of one. On platforms which don't support pre-rotation, the specialization constant will never change and driver uniforms entirely govern y-flip. On platforms that do support pre-rotation, only two variations of the pipeline are needed. Bug: angleproject:7366 Change-Id: I73f84e89fa9349d2098fa5b21573aee57d93a30c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3663151 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Lubosz Sarnecki 039660a0 2022-04-14T13:32:33 Translator: Drop const from opaque parameter types `const` is ineffective on opaque types like sampler2D. That qualifier is now dropped as it was tripping SPIR-V gen up. New validation is added to make sure such parameters are not reintroduced. Test credit of Lubosz Sarnecki <lubosz.sarnecki@collabora.com> Test: angle_end2end_tests --gtest_filter="GLSLTest.ConstSamplerParameter*/*_Vulkan" Bug: angleproject:7201 Bug: angleproject:7205 Change-Id: I310a47a8eb162ddafb2ab44682520f546f8a5512 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3587345 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 8dc9e83e 2022-02-16T21:48:53 Translator: Fix RunAtTheEndOfShader w.r.t discard RunAtTheEndOfShader wrapped main() if it ended in discard. However, it didn't account for the fact that the discard instruction could be wrapped in a block. This change makes RunAtTheEndOfShader more conservative w.r.t discard and has it wrap main() on any encounter of discard. The change additionally adds AST validation to ensure transformations don't generate dead code after branches. Test credit to Cody Northrop. Test: GLSLTest_ES3.ConstantConditionGuardingDiscard Test: GLSLTest_ES3.NestedUnconditionalDiscards Bug: angleproject:7033 Change-Id: Ie9d5210a5cfbb13449720a8a3f44666df9443d98 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3471014 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Brandon Schade 06edae72 2022-01-11T11:13:20 Vulkan: Allow duplicated block name in different shader interface In OpenGL ES 3.2 Shading Language specification(4.3.9), A block name is allowed to have different definitions in different shader interfaces within the same shader. Bug: angleproject:5557 Test: KHR-GLES32.core.tessellation_shader.single.max_patch_vertices Change-Id: I49f149cfd8f6f063fc5045aa154cc401d3e38cfb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3429684 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Brandon Schade <b.schade@samsung.com>
Shahbaz Youssefi 665ddccd 2021-12-09T23:06:39 Vulkan: Emulate dithering Dithering in OpenGL is vaguely defined, to the extent that no dithering is also a valid dithering algorithm. Dithering is enabled by default, but emulating it has a non-negligible cost. Similarly to some other GLES drivers, ANGLE enables dithering only on low-bit formats where visual banding is particularly common; namely RGBA4444, RGBA5551 and RGB565. Dithering is emulated in the fragment shader and is controlled by a spec constant. Every 2 bits of the spec constant correspond to one attachment, with the value indicating: - 00: No dithering - 01: Dither for RGBA4444 - 10: Dither for RGBA5551 - 11: Dither for RGB565 The translator appends code to the shader that, based on the format specified by the specialization constant, adds dithering to each color attachment output. A 2x2 Bayer matrix is used for dithering, indexed by gl_FragCoord.xy % 2. Bug: angleproject:6755 Change-Id: Ib45da5938e299b6626bff921119d63e7357dd353 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3374261 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 46149c0e 2021-09-17T15:38:47 Translator: Fix pruning functions that declare a struct When pruning unused functions, the entire declaration of the function is removed. If the function declares a struct as part of its return value, the declaration of that struct was lost. This change makes sure that declaration survives the pruning. For example: struct S { vec4 v; } unused_func() { ... } is now replaced with: struct S { vec4 v; }; This change also makes struct usage validation more stringent. Bug: chromium:1248753 Change-Id: Idd9a87fd2e785135775cfea62995fd33adaf3c09 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3169691 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 800e82c6 2021-08-23T11:05:23 Translator: Validate precisions When declaring a variable, a struct field, function parameter etc, there's a precision necessarily applied to the entity being declared. AST Validation is added to enforce this. Intermediate nodes derive their precision from these entities automatically. Consistency of intermediate nodes is not validated. This is because AST transformations replace a node with a transformed one, and that may not have the same precision. Take the following code: mediump float x = ...; mediump float y = ...; ... x + y ... and assume is transformed as such: highp float driver_uniform; ... (x * driver_uniform) + y ... The addition was originally done in mediump, but would seemingly need to be done in highp after transformation. There are a number of options here: - Make sure that when nodes are replaced, the precision is unaffected. This can be intrusive, requiring temp variables. - Bubble up the new precision - Accept the discrepancy ANGLE opts for the last option, which actually respects the original shader's intended precision for operations, even if some transformation needs to temporarily evaluate an expression at a higher precision. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Ibcde3a230de159157783b1c6d5ef1cd63ceb4d8f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3114027 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 798c5200 2021-07-31T22:17:48 Translator: Make precise-ness a property of AST nodes Instead of creating a "set of precise nodes", the nodes themselves are marked precise. This change is preparation for another change that overhauls precision propagation through the nodes, and which would also be storing the promoted precision in the nodes. Bug: angleproject:4889 Change-Id: Ieec8864be5cd2e95ed6fb4d90b367946d9f33fa1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3065569 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi ebe943e2 2021-07-29T11:19:33 Vulkan: SPIR-V Gen: Fix gl_Clip/CullDistance These built-ins can be redeclared in the shader. The translator took these redeclarations (and gl_LastFragData) as UserDefined symbols. There were a number of hacks such as in name generation and CollectVariables, to special-case these redeclarations. This change instead makes sure that these variables continue to be considered built-ins with the appropriate qualifiers. A number of fixes are made accordingly: - Hacks are removed. - In fragment shaders, ANGLEClipDistance was initialized with gl_ClipDistance for further use by the shader. The code generation however mistakenly produced `gl_ClipDistance[0] = ANGLEClipDistance[0];`, which caused compilation failures by glslang, but passed the tests accidentally because they expected link failures (see next item). - CollectVariables is fixed to correctly collect gl_Clip/CullDistance in fragment shaders; previously they were collected as output varyings, and therefore the aforementioned link error was not produced in the tests after the compilation error was fixed. Additional fixes: - The transformation of gl_Clip/CullDistance was always ever done on one of them due to misplaced breaks in the loop that detected their presence. - The transformation of gl_CullDistance was skipped when it was not redeclared. Validation is added to make sure these built-ins always have the correct qualifier even when redeclared. SPIR-V gen support for these variables have been fixed as well. Bug: angleproject:4889 Change-Id: Ic8bf2c508357035cb937ef41a28ae22ffc533ebe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3059921 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Kenneth Russell aec5e65c 2021-07-28T00:36:12 Get direct-to-Metal backend to run angle_end2end_tests. Cherry-pick nameless struct fix from Apple in https://bugs.webkit.org/show_bug.cgi?id=227482 . Fix SeparateCompoundStructDeclarations pass to stop generating multiple declarations; thanks syoussefi@ for advice. Incorporate additional passes from TranslatorVulkan (MonomorphizeUnsupportedFunctionsInVulkanGLSL, RewriteArrayOfArrayOfOpaqueUniforms, SeparateStructFromUniformDeclarations) needed by RewriteStructSamplers pass in TranslatorMetalDirect. Fixes many assertion failures in GLSL tests. Moved these passes out of tree_ops/vulkan. Thanks again to syoussefi@ for advice and help. Disable a validation check related to the RewritePipelines pass. Skip two tests that were failing for other reasons. With these changes, angle_end2end_tests runs to completion when the direct-to-Metal backend is turned on. There are still ~1300 failures of the ~4000 tests which will be investigated next. Bug: angleproject:5505 Change-Id: Ibca77822543e8e8e8d2a8c862e92cdf74bfa3545 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3058524 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Shahbaz Youssefi 7c6da493 2021-07-26T21:24:25 Translator: Make sure built-in variables are consistent Some transformations left the tree in an inconsistent state, for example if it used gl_SampleMask from ES3.1+OES_sample_variables and the transformation added a usage of gl_SampleMask from ES3.2. The offending transformations are fixed and AST validation is improved to catch such errors. Bug: angleproject:4889 Change-Id: I9d9ea5bb43a9408dd4c6dc3e89ec20d60dfeff73 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3054613 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 7f199d75 2021-07-20T00:11:23 Vulkan: SPIR-V Gen: Support geometry shaders Geometry shader built-ins are implemented. A bug in DeclarePerVertexBlocks is fixed w.r.t to gl_PerVertex arrays and a new AST validation option is added to catch that sort of error. Bug: angleproject:4889 Change-Id: I40b2929e450eac8ae840bbf1a1583e6c4c047c88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3041623 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 0e1c90cf 2021-07-21T10:24:26 Translator: Validate function parameter qualifiers This change cleans up a confusion in EvqConst and EvqConstReadOnly, where the former was frequently used instead of the latter for function parameters. The change makes the following renames to make the intent of the relevant qualifiers clearer: EvqIn -> EvqParamIn EvqOut -> EvqParamOut EvqInOut -> EvqParamInOut EvqConstReadOnly -> EvqParamConst Bug: angleproject:4889 Change-Id: Idedd32c08a91de069b91b1657d6b783dddece04a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3041622 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi a3df80ea 2021-07-19T17:15:13 Translator: Validate AST consistency w.r.t function calls This ensures that tree transformations don't create invalid function calls. Additionally, it's validated that no raw function calls are issued, as that's deprecated. Bug: angleproject:4889 Change-Id: Iabbb493dcc0a5654bbb5f930e402bf3492c89979 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3040119 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
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 64ca25f1 2021-06-08T17:15:49 Vulkan: SPIR-V Gen: Unary operators The line raster emulation coded uses round() which was previously not translated. This change implements all operations supported by TIntermUnary nodes. Bresenham line emulation is now allowed. Bug: angleproject:4889 Change-Id: I1ffbe3f9bf0299f7efa2c6d1e8f011fefdbb2ddb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2951624 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 31641b8e 2021-06-05T02:17:47 Declare specialization constants in the AST A new qualifier (EvqSpecConst) is added so that specialization constants can be declared in tree. This enables TVariable references to specialization constants to be validated, which were in fact invalid as every reference declared a new variable. That is fixed. Bug: angleproject:4889 Change-Id: I1711e41cbc5a1260843d2d004d3568bdae11e963 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2941451 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi df977aaf 2021-06-08T01:04:32 Translator: Validate global qualifier declaration's symbol Global qualifier declarations (invariant, precise) apply to already-declared variables. This is now validated. Bug: angleproject:4889 Change-Id: I9889f2d68dcd6a2fc0de2b20a1291899397982d0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2946114 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi daeac238 2021-05-08T22:09:38 Translator: Ensure structs and blocks are uniquely defined A new AST validation is added to ensure that the same TStructure or TInterfaceBlock is not redundantly defined. This helps with SPIR-V generation by allowing the id to be used as key in a hash map that looks up the corresponding SPIR-V type id. A bug is fixed where the Vulkan driver uniform declaration created two identical declarations for ANGLEDepthRangeParams. A number of other bugs are also fixed in this change, where if a variable declaration is eliminated (for example due to constant folding, or inactive interface variable removal) and it contained a struct specifier, the struct declaration was also removed. OutputGLSLBase had a hack where structs were declared on first encounter, which was incorrect as the scope of the declaration could change. Those bugs are fixed and this hack is removed. Bug: angleproject:2733 Bug: angleproject:4889 Bug: angleproject:5936 Change-Id: I8e13748c0bf552ae8b052249282769a1f0775603 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2881942 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi c2d1a464 2021-04-09T16:53:30 Translator: Track nameless interface block field indices in type Fields of nameless interface blocks are stored as TVariables and referenced through a TIntermSymbols (unlike named blocks which use EOpIndexDirectInterfaceBlock with a constant field indices). With this change, the field index is stored in the variable's type which let's the TField of the TInterfaceBlock be directly accessible (and not need a search by name). This will be helpful in translation to SPIR-V as interface block members are accessed by field index. Bug: angleproject:4889 Change-Id: If3ab45b1e5f5f9576721dc52e2bdf1161882514f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2818242 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 58eabfd7 2021-04-08T23:57:04 Translator: Validate consistent variable references Some transformations change variable declarations. This validation ensures that all references to said variables are appropriately replaced as well. Bug: angleproject:2733 Change-Id: I6c2873968eeed4cba66e70069f84eb69a1f77074 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2818140 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi a7b60f13 2021-04-08T23:13:21 Translator: Validate multi-declarations are separated Many transformations only look at the first variable in a TIntermDeclaration. This change validates that once the SeparateDeclarations transformation has been run, multi-declarations are not reintroduced. Bug: angleproject:2733 Change-Id: If5f96689cbdd28817c479dd7c495b91535f87199 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2815565 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 249cb200 2019-12-03T11:10:06 Translator: Rename TIntermInvariantDeclaration to ..GlobalQualifier.. This is to support the upcoming `precise` keyword. Bug: angleproject:3569 Change-Id: Idbcc8fd6f261757dbbf81b381e7a2dae938d8101 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1947451 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 91d469aa 2018-08-27T10:47:25 Initial support for compiler AST validation This is to be able to catch issues introduced through AST manipulation earlier than shader compilation time, improving debuggability. Bug: angleproject:2733 Change-Id: Ic57bc72f2ab438e60f32553d602074f3d72cc4f5 Reviewed-on: https://chromium-review.googlesource.com/c/1199922 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>