src/tests/compiler_tests/MSLOutput_test.cpp


Log

Author Commit Date CI Message
Kimmo Kinnunen eccfec93 2024-11-01T11:49:11 Metal: gl_ClipDistance fails validation Failure is "Found child with two parents". Result from reusing gl_ClipDistance in: float gl_ClipDistance[8]; ClipDistance_0 = gl_ClipDistance[0]; ... Fix by creating new node for each symbol access. Bug: angleproject:376718272 Change-Id: I7a866a10e389cc25d0cff4e6f18ae9c70ab376e0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5979781 Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen b03f0148 2024-11-01T10:26:04 Metal: interpolateAtOffset fails validation Fix validation error Found function prototype with an invalid qualifier. The offset parameter was created with "global" qualifier. Bug: angleproject:376718268 Change-Id: I6f314a42fe1d35d54bb673cfa7d58eba526c9ea5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5979778 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Kimmo Kinnunen 2156cd6e 2024-10-31T14:22:31 Metal: Fix rewritten array variables clashes It was possible to generate MSL name clashes by declaring arrays, such as in: mat3 a[1] mat2 a_0; Complex GLSL outputs need to be linearized into primitive MSL types. This would happen for struct outputs, arrays and matrices. For these new MSL variables, the translator needs to invent new names that match, generated from both VS and FS. The clashes were due to the encoding scheme: For arrays, the MSL vertex output variable was named with _0 suffix for the array and _0 for the matrix row 0. In the example above, this would create a clash since also non-array mat would be linearized row-wise. For structs, field `a.b` would be encoded as `a_b`. By selecting different a and b, clashes could be generated trivially. It is redundant to encode named semantics in the out variable names. The only needed element is the discriminator which associates VS variables to FS variables. Currently this is done by using the user-provided root field name. Fix by encoding only the root variable name to the MSL variable name. The rest of the field discriminators are just a running number. Each GLSL name `a` is unique. MSL names get fixed suffix form `a_X`, and thus all of them are unique too. This is a continuation of following fixes that turned out to be incomplete: 6fe8a399dd Metal: Fix rewritten out variables with underscores 27423bffff Metal: Generate names for rewritten inputs Bug: angleproject:376417347 Change-Id: I407db373d201b3e321c6d8414bafdbecfd82cf19 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5979774 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen 4397ff2f 2024-10-25T16:55:30 Metal: SeparateCompoundStructDeclarations fails validation Consider GLSL: struct S { int i; } s; s=s; SeparateCompoundStructDeclarations would rewrite this to: struct S { int i; }; S s'; s=s; The interm rewrite would rewrite the specification and declaration of s, but not the use sites. The use sites would use the old type, and thus something that was not in the tree anymore. This would fail the validation. This kind of bug was previously fixed for SeparateDeclarations in commit 18fa02bebf901dd8501de3176f6052ae4ce984be. Fix by adding the logic to SeparateDeclarations, as it is already doing almost the exact task, separating `struct S { ..} a, b`. The separation is tested in GLSLTests.StructInShader and various other draw tests. These pass with MSL, but these would also fail validation if that was enabled. Bug: angleproject:375523825 Change-Id: I1697103d0ba47616dbd3159f36f9e71cb2831c4b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5964899 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen 898a1c12 2024-10-24T13:09:36 Metal: Fix ToposortStructs validation == failures ToposortStructs would convert mat, vec, struct == to ANGLE_equals() calls. However, the functions called were not in AST. This would cause "Found node calling previously undeclared function <validateFunctionCall>" validation error and ASSERT. Mat, vec equality calls would use prelude ANGLE_equals implementations. The MSL emit already does the conversion from == to ANGLE_equals for these builtins. For user-defined structs the logic would be: - collect struct decls, structs, create equality functions - toposort - for each sorted struct: - insert struct decl - insert equality function Move the equality function creation after the toposort: - collect struct decls, structs - toposort - for each sorted struct: - insert struct decl - create equality function - insert equality function This way the sort ensures that nested struct equality functions can refer to previously introduced equality functions. Bug: angleproject:375352601 Change-Id: I59efed98bca6d99b198abc2b5c7577cf5d1d5d83 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5961281 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.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>
Erica Li 3b650ffa 2024-03-19T09:53:06 Metal: Assert while using gl_VertexID as ivec Metal [vertex_id] is uint while gl_VertexID is int. Replacing gl_VertexID with gl_VertexIDMetal without rewrites of the expressions would cause invalid expressions. Fix by casting uint kgl_VertexIDMetal to int kgl_VertexID instead of replacing variable during compile. Bug: angleproject:8597 Change-Id: I76acdb2a0ab5982aa05181175925b3359068e901 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5376498 Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Alexey Knyazev 490ff869 2024-03-14T00:00:00 Always redeclare clip/cull distance built-ins When clip or cull distance built-in arrays are implicitly sized, various pruning passes may produce an inconsistent AST state thus causing translation or linking failures. Adjusted the dedicated validation pass to inject an explicit declaration thus bypassing the issue. Additional updates: * Ensured that API clip distance state emulation is applied when a variable is declared but not assigned * Reverted previous clip/cull distance related changes to TIntermBinary::hasSideEffects as they are redundant now * Fixed failing AST validation for MSL varying emulation * Aligned linking error messages with the specifications * Updated tests and cleaned-up obsolete code Fixed: angleproject:8591 Change-Id: Ic8cfaf37778b8532bbab32ab998d5350b85d67ef Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5372714 Reviewed-by: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Kimmo Kinnunen 27423bff 2024-03-05T17:57:24 Metal: Generate names for rewritten inputs When expanding multi-component fields to multiple single-component fields, use AngleInternal namespace for the new names. The names are generated with form "someField_0" where _0 is the component index. If these are not created in AngleInternal, caller is able to create a name clash by introducing single-component field "someField_0". Fixes an assert where the vec4(a_) + vec4(a) would assert on size mismatch because the variable lookup for "a_" would find a rewritten variable for the expanded matrix row of "a". Bug: angleproject:8558 Change-Id: I64b7a755d7d534543fdb0f4c43008dd5c63f4aad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5323060 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kyle Piddington <kpiddington@apple.com>
Kimmo Kinnunen 2b1ef00a 2024-02-20T15:45:34 Metal: Fix validation for anonymous struct arrays Fix validation failure for accessing an element of array of anonymous struct. SeparateCompoundStructDeclarations would create new Structures to name unnamed structures. The Structure instance of the array index accessor node was incorrect, it was the old Structure. Use same pattern as in SeparateStructFromUniformDeclarations. Bug: angleproject:8551 Change-Id: I04684e5ad99cc2b9038a0cc21c7eefcc6cf247df Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5310074 Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen 197beb4d 2024-02-13T15:47:32 Metal: Crash if for loop body is optimized away Loops might have their bodies optimized away. For case like `for(;;) if(false);` the constant pruning happens at parse phase. The else branch (e.e. no else branch, nullptr) would be selected as the body. Some code treated the body as optional, some code treated it as required. Define it as required, and remove all conditional code related to the loop body. Bug: angleproject:8532 Change-Id: Ic35f1bf78e63ceb2cee7b96ba99e788efc282e6f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5291554 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Jonah Ryan-Davis 1ab5d01d 2023-08-29T13:31:07 Metal: Fix dropped out arguments from functions with many args. RewriteOutArgs has an early-exit if it spots a potentially aliased arg. It's also responsible for marking out args as references, which caused an issue in Google Earth. Removing the early-exit fixes both issues. Bug: chromium:1474736 Change-Id: Ib68dd3f3e2e0a1e773e4e09edcdfa3a4bdfc1ef2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4823006 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jonah Ryan-Davis 280e79e1 2023-08-10T14:08:00 Rescope globals only used in one function to function-local. We can demote global variables when they are only used in one function. This has performance implications on Metal. Bug: angleproject:8311 Change-Id: Id666e6b167be771c14768cd73efa61fdacd897d4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4771215 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 02e7f967 2023-05-25T14:54:49 Translator: Remove the "variables" option Variable collection is invariably enabled by the front-end as well as other major users of ANGLE such as Firefox. All translator backends except GLSL force-enable variable collection either way. This change removes this compile option and enables variable collection unconditionally. The flag itself remains in ShCompileOptions until references to it are removed from Chromium. Bug: chromium:1447314 Change-Id: I4d3b30c1bfbd345c5ad269abc62c0a6a59de2f56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4568524 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
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>
Kenneth Russell da3db87e 2021-07-06T14:00:58 Upstream latest changes to Metal backend from Apple to 7/1/2021 This CL merges in the ANGLE changes between these two WebKit commits: https://git.webkit.org/?p=WebKit.git;a=commit;h=8648b353ab1d7730438c2e08319e1a4d64982c31 https://git.webkit.org/?p=WebKit.git;a=commit;h=166e4924a52971d6a32ad48247a439b16c00e062 Include provoking vertex buffer out of bounds fix from https://bugs.webkit.org/show_bug.cgi?id=230107 Fix bad merge of resetting of dirty bits, breaking DepthStencilFormatsTest.DepthTextureRender test and perhaps others. Disable GL_APPLE_clip_distance when the direct-to-Metal compiler is active. It can not yet handle the gl_ClipDistance array. Disable use of rectangular textures for IOSurfaces. Metal can bind IOSurfaces to 2D textures, and this was passing all tests in the SPIR-V Metal backend. Introducing rectangular textures breaks the SPIR-V Metal backend, and the tests currently fail on the direct-to-Metal backend. Fix several bugs with ProvokingVertex, which was causing both the SpirV and Direct backends to incorrectly draw indices. (https://bugs.webkit.org/show_bug.cgi?id=230107) Skip the following tests on the Metal backend which is still failing RobustResourceInitTestES3.BlitDepthStencilAfterClearBuffer GLSLTest_ES3.GLVertexIDIntegerTextureDrawArrays/ES3_Metal With these changes, angle_end2end_tests again runs to completion. Bug: angleproject:6395 Change-Id: I3cc58f531426a95fc8f177a4ad87f56c1855a546 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3167010 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kyle Piddington <kpiddington@apple.com>
Kyle Piddington d33a2222 2021-04-26T16:56:15 Upstream Apple's direct-to-Metal backend: compile libANGLE. This change is meant to merge the metal backend changes from Apple's direct-to-Metal backend. Taken from Kyle Piddington's CL: https://chromium-review.googlesource.com/c/angle/angle/+/2857366/ The goal of this CL is to merge the metal backend code in a state that compiles, but not to switch the Metal backend over to using the direct-to-metal backend yet. Bug: angleproject:5505 Bug: angleproject:6127 Change-Id: If6783e06e0086b3a1dd25c6f53caca5cfc96cb86 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2950067 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Kyle Piddington d7aa0130 2021-04-26T16:56:15 Upstream Apple's direct-to-Metal backend: compile translator. This change is meant to merge the translator changes from Apple's direct-to-Metal backend. Taken from Kyle Piddington's CL: https://chromium-review.googlesource.com/c/angle/angle/+/2857366/ The goal of this CL is to merge the translator code in a state that compiles, but not to switch the Metal backend over to use this translator backend yet. Bug: angleproject:5505 Change-Id: I68a6354604498cd5fd1eb96c13fc56f3b38f2bd0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2897536 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>