src/compiler/translator


Log

Author Commit Date CI Message
Kyle Piddington db83279a 2021-10-27T10:45:23 Metal: Use 'fast' normalize to match DEQP expectations Normalize' has a fast math option that more conformantly deals with INF in normalize functions. Use metal::fast::normalize instead of metal::normalize This also matches SPIRV-Cross behavior for normalization Bug: angleproject:6629 Change-Id: I61392ecd6f61b612d21f2832e07a135e26b53ad6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3248145 Commit-Queue: Kyle Piddington <kpiddington@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Gregg Tavares <gman@chromium.org>
Shahbaz Youssefi 55bd8d8f 2021-10-26T10:38:28 Translator: Fix precision bug in HLSL generation Bug: chromium:1263487 Change-Id: I60bc3dc93867e4269756b6f54eb39cf29ad77d5f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3244887 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 066fb91b 2021-10-18T15:31:27 Vulkan: SPIR-V Gen: Handle scalar(const) produced by index clamp Normally scalar(const) is folded into a constant. The index clamp transformation may produce such a code where the index looks dynamic at first (for example `false ? uniform_value : constant`), but becomes constant after folding. This change makes SPIR-V generation robust in that case. A potential future change could avoid the clamp entirely by making FoldExpressions adjust the op of the EOpIndexIndirect node whose index is being replaced with a constant with EOpIndexDirect (and apply the clamp on the argument). Bug: chromium:1260651 Change-Id: I552b7527d821d1cb52e0e53212cc481285674861 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3226311 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi ef237faf 2021-10-18T16:22:40 Translator: Validate precision for function args In fragment shaders, float does not have a default precision. Any declaration of this type must therefore specify the precision if a default one is not provided. This was not validated for function arguments. Bug: chromium:1255089 Change-Id: I0d17e226ec88610692ec7dd18793cf4d471f12e7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3226314 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 7f87a326 2021-10-18T13:06:29 Vulkan: SPIR-V Gen: Fix crash in array of struct constant Bug: chromium:1260690 Change-Id: I51fe85a2ebc23c3fcaa3c961c4ebf84688bbed31 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3226309 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 57b73c07 2021-10-14T15:51:18 Vulkan: SPIR-V Gen: TODO clean up This change removes a number of stale TODOs. Bug: angleproject:4889 Change-Id: If21d55717e61383ffdd58a7f88da5961988e035f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3223643 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi b3d77208 2021-10-14T15:38:51 Vulkan: SPIR-V Gen: Make unfolded constants SPIR-V constants If a constant is not folded by the translator, for example because it's an array, this change makes sure that it becomes a constant in SPIR-V anyway. This is particularly important to support cases where a constant is required, for example as argument to textureGatherOffsets(). Bug: angleproject:4889 Bug: angleproject:5362 Change-Id: Ic43e4be13a8917bb100ea64902ba90048cfbb9ee Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3223642 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi f3d5dac3 2021-08-23T17:25:15 Vulkan: SPIR-V Gen: Drop dependency to glslang The SPIR-V gen path is now made default. Compilation through glslang is still supported for debugging, and is enabled on the GLSL* end2end tests for smoke testing. On release builds, glslang is not supported. To test with glslang, add the following gn arg (only necessary if dcheck is disabled): angle_enable_spirv_gen_through_glslang = true Then enable the generateSPIRVThroughGlslang feature. This can be done by setting an environment variable: ANGLE_FEATURE_OVERRIDES_ENABLED=generateSPIRVThroughGlslang ./angle_deqp_gles2_tests Binary size saving: - 1.3MB on Linux (SPIR-V gen itself: 240KB) - 730KB on Android (SPIR-V gen itself: 140KB) Perf tests: - LinkProgramBenchmark.Run/vulkan_compile_single_thread * Through glslang: truncated mean: 1287033.36 * Direct SPIR-V Gen: truncated mean: 244495.91 (~80% reduction) - LinkProgramBenchmark.Run/vulkan_compile_multi_thread * Through glslang: truncated mean: 4565894.83 * Direct SPIR-V Gen: truncated mean: 1158164.10 (~75% reduction) Bug: angleproject:4889 Bug: angleproject:6210 Change-Id: I486342702977c8114e90073b97183aba115a8b2d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3115140 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Steven Noonan 01341f94 2021-10-11T19:26:07 D3D11: implement EXT_clip_control This implements EXT_clip_control for the D3D11 renderer, so that I can use a reversed-Z depth buffer with ANGLE. Tested with angle_deqp_gles2_tests.exe --deqp-egl-display-type=angle-d3d11 --deqp-case=dEQP-GLES2.functional.clip_control.* and angle_end2end_tests.exe --gtest_filter=*D3D11* Bug: angleproject:6554 Change-Id: I1d11cd04a6654c28530b11104470f0cad0009abe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3218659 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi bcc89703 2021-10-07T11:26:42 Translator: Remove disableValidateFunctionCall from transformation This validation is disabled in three transformations and re-enabled afterwards. Two of these benefit from the simplicity it brings, and this change removes it from the other transformation. Bug: angleproject:6506 Change-Id: I946b547ed0e2ed39062914a7771e9635ff5e406d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3212289 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Tim Van Patten 4349703b 2021-10-06T11:00:53 Compiler: Remove unnecessary TODO Remove the TODO related to removing the global pool allocator, since that work won't be chased any further. For more details in this area, see: http://anglebug.com/1286 Bug: angleproject:6497 Change-Id: Ie9952e1c0e481c8d553cfdcf4a1d8ded8b64a95b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3208510 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Lingfeng Yang 9ba5dcf6 2021-10-07T06:56:14 Vulkan: Fix inconsistency in half render area width/height The half render area rotation matrix should be removed. DrawableArea is constant over rotations. The frag coord rotation matrix is still needed because the frag coord generated by GPU is still rotated. Test: DISPLAY=:0 out/Debug/angle_deqp_gles3_rotate90_tests Using test config with: linux nvidia debug vulkan prerotation prerotation270 Test: Cuttlefish SwANGLE ./cts-tradefed run cts -m CtsDeqpTestCases -t dEQP-GLES3.functional.shaders.builtin_variable.fragcoord_xyz Bug: angleproject:6504 Change-Id: I37a6308fdb7586200b19a6138affc78c2c329a96 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3212427 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi daaaba0a 2021-10-04T22:28:56 Translator: Fix uniform/struct separation for anonymous arrays When a uniform array of anonymous structs was separated into a struct declaration and uniform array, the uniform symbol was being replaced, but not the intermediate nodes that index it. This caused an AST validation error. Bug: angleproject:4740 Change-Id: Ib9d0115bd01c39d1a007f644e46b5e35c12c9304 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3204590 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi dde409be 2021-10-04T22:05:47 Translator: Produce error on func(void, int) If void is specified, another parameter cannot follow. This change ensures that this produces an error. Bug: angleproject:6338 Change-Id: I18602ea4b52c96e498f4f2dc627d4ba2210d6fa7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3203795 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Kyle Piddington 54d4bfe5 2021-09-28T17:27:57 Update ANGLE Metal to Webkit at Sept 29 2021 This commit merges changes from Webkit into ANGLE upstream. The following commits were used: Current: https://git.webkit.org/?p=WebKit.git;a=commit;h=e01d0bda8f4b7dc2fd834b92802d15d8c15735f Previous: https://git.webkit.org/?p=WebKit.git;a=commit;h=492f078198748e8ff248eea0bb979cf79e5f5adfj The following commits were merged in from the Webkit Repository: (Hashes from git://git.webkit.org/WebKit-https.git) 03ea44c78ce5665d4ec9add271260121cbc7bc6c Problems with drawElements in some conditions https://bugs.webkit.org/show_bug.cgi?id=230107 c8dc8e0c4d1109d39a62eb197b45e95132380290 ANGLE Metal: single-component swizzles do not compile https://bugs.webkit.org/show_bug.cgi?id=230472 7285dbaaf5af15877d6c332b30ef7a4d67225460 webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal https://bugs.webkit.org/show_bug.cgi?id=229941 4c72f92967ecd2a095666fef431384c4f5f60fb4 fragcolor-fragdata-invariant.html fails https://bugs.webkit.org/show_bug.cgi?id=223317 cd943145467f54e5928793c0dd3dfa2313c007dd ANGLE Metal index buffer restart range cache could be maintained.. https://bugs.webkit.org/show_bug.cgi?id=227451 f075ff77e592eabd54dd659a8e13617cc5faedc8 ANGLE Metal infinities and NaNs generated with incorrect syntax https://bugs.webkit.org/show_bug.cgi?id=229439 5862073269122f4b2d43d96d3922757557755e86 [Metal ANGLE] Fix over-autorelease of rx::DisplayMtl::getMetalDeviceMatchingAttribute()... <https://webkit.org/b/229128> 85f797ad31db048cb82cbafd428ef77f0b839312 ANGLE Cocoa compiles.... https://bugs.webkit.org/show_bug.cgi?id=228987 a67918ba279ad4842b6ae84a79c3f1c0cdc35ace Avoid infinite recursion... https://bugs.webkit.org/show_bug.cgi?id=228978 d341f67de0033adcf1ec6373ace6a54b06c4a031 Cherry-pick ANGLE: Revise WebGL's shaderSource validation https://bugs.webkit.org/show_bug.cgi?id=228951 1e2714d981e97de8234ba055570dfdf56e8b6944 3.5 MB system-wide footprint impact due to thread-locals... https://bugs.webkit.org/show_bug.cgi?id=228240 d32e5cca34081997d32504b0b56c18b9703ff3be Build Default Metal library offline https://bugs.webkit.org/show_bug.cgi?id=227333 33702279faccfd4c8d1c8a6d549925f9ca9a4e8f WebGL2 demo doesn't work due to failing compilation.... https://bugs.webkit.org/show_bug.cgi?id=226865 0a075885d242db38c4e435a6597173dc3b082173 rAF driven WebGL submits excessive amount of GPU work... https://bugs.webkit.org/show_bug.cgi?id=227059 f38a92b3e7c17efda269caa7066e7ffe2f828e72 WebGL shader link error in iOS 15 beta: "Internal error..." https://bugs.webkit.org/show_bug.cgi?id=227723 98d48f011d561531470d97f26a022767b5452fb7 REGRESSION (r279466): [Big Sur] webgl/1.0.3/conformance &... https://bugs.webkit.org/show_bug.cgi?id=227596 Bug: angleproject:6471 Change-Id: I07166d0dc4b5c3579d98353485b3245b81c7b882 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3194322 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Kyle Piddington <kpiddington@apple.com>
Kyle Piddington d3764f08 2021-09-30T13:46:15 Fix dEQP.GLES3/functional_fragment_out_array* on Direct to Metal Fragment arrays with locations assigned were not being correctly transformed. Fix ModifyStruct to handle the changing location when locations are set Bug: angleproject:6477 Change-Id: Icbacd50e265abdbaff3be230b2ec201eaa868a14 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3198807 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 32d6e806 2021-09-24T23:50:54 Vulkan: Fix rotation of interpolateAtOffset interpolateAtOffset's offset was multiplied by flipXY*rotationMatrix, which is a vector. This was unable to actually apply rotation to the offset. The multiplier is changed to a matrix. Can be tested by running interpolate_at_offset*default_framebuffer tests in deqp gles3.1 together with pre-rotation: ./angle_deqp_gles31_tests --deqp-case=dEQP.GLES31/functional_shaders_multisample_interpolation_interpolate_at_offset_no_qualifiers_default_framebuffer --emulated-pre-rotation=90 Bug: angleproject:5843 Change-Id: I9727371375e999f07463b69153df3fd8b28c2a71 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3183108 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com> Commit-Queue: 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>
Shahbaz Youssefi 1a0a0764 2021-09-27T12:56:57 Translator: Fix outputting anonymous struct types Anonymous struct types have an "empty" symbol name, so instead of outputting their name, it's specified that they are anonymous. Bug: chromium:1253208 Change-Id: Ic70767ba32bda6ceb214dfc3d0b4928173665d81 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3187810 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi bc8fe7dd 2021-09-24T22:50:32 Translator: Fix removing inactive output vs SH_INIT_OUTPUT_VARIABLES The code that SH_INIT_OUTPUT_VARIABLES adds for inactive outputs is also removed with this change. Bug: chromium:1253016 Change-Id: I3caeb628487354de943f7b53f7462f58baa3eca8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3183107 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Gregg Tavares d71dc819 2021-09-22T16:01:06 Fixes for RowMajor test failures row_major matrices get translated to column major matrices and the expressions rewritten. To do this temporary variables that contain the column and row index expressions are moved to separte statements before the matrix expression itself. When this happens it breaks side effects and short circuits in the expression. The solution is to call SeparateCompoundExpressions before calling RewriteRowMajorMatrices. Bug: angleproject:6386 Change-Id: I4d819ade959e2a875495f62733e11d86560d3fab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3177337 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Gregg Tavares 6106da49 2021-09-22T16:18:21 Indent Generated GLSL Before: in vec4 _ua_position; void main(){ (gl_Position = vec4(0.0, 0.0, 0.0, 0.0)); (gl_Position = _ua_position); } layout(shared) uniform _uG{ float _ufoobar; } _ug; struct _uS { int _ufoo; float _ubar; }; layout(shared) uniform _uT{ _uS _us; float _um; } _ut; float _ufunc(in _uS _ustructVar){ return _ustructVar._ubar; } out vec4 _uoutColor; void main(){ float _uv = 0.0; for (int _ui = 0; (_ui < _ut._us._ufoo); (++_ui)) { int _uk = 0; while ((_uk < _ut._us._ufoo)) { (_uv += _ufunc(_ut._us)); if ((_uv > 100.0)) { break; } else { (_uv += 5.0); } switch (_uk) { case (0): (_uv += 3.0); break; case (1): (_uv += 1.0); break; default: (_uv -= 2.0); break; } } } (_uoutColor = (vec4(_uv) + vec4(_ug._ufoobar))); } After: in vec4 _ua_position; void main(){ (gl_Position = vec4(0.0, 0.0, 0.0, 0.0)); (gl_Position = _ua_position); } layout(shared) uniform _uG{ float _ufoobar; } _ug; struct _uS { int _ufoo; float _ubar; }; layout(shared) uniform _uT{ _uS _us; float _um; } _ut; float _ufunc(in _uS _ustructVar){ return _ustructVar._ubar; } out vec4 _uoutColor; void main(){ float _uv = 0.0; for (int _ui = 0; (_ui < _ut._us._ufoo); (++_ui)) { int _uk = 0; while ((_uk < _ut._us._ufoo)) { (_uv += _ufunc(_ut._us)); if ((_uv > 100.0)) { break; } else { (_uv += 5.0); } switch (_uk) { case (0): (_uv += 3.0); break; case (1): (_uv += 1.0); break; default: (_uv -= 2.0); break; } } } (_uoutColor = (vec4(_uv) + vec4(_ug._ufoobar))); } Bug: angleproject:6428 Change-Id: Ica25151e68eb0defd85a3b6241db442d8eb84743 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3177339 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Shahbaz Youssefi e1a9af6a 2021-09-20T10:42:03 Translator: Fix HLSL vs for loop's init not having initializer The handleExcessiveLoop code expected that if a for loop has an init expression that it must necessarily have an initializer as well. That is not true in (fuzzer-produced) code such as following: for (int i; ...; ...) Bug: chromium:1238182 Change-Id: Id761e937a34a6b2feac1266e22207350a3bd616c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3170114 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Kyle Piddington f6616c71 2021-09-14T17:42:22 Reimplement transform feedback on direct-to-Metal backend Connect the Transform Feedback code generation from Webkit ANGLE to the shader specialization code. Bug: angleproject:6393 Change-Id: I090c44c6ee97e8e0af8c38433bfb74c2080784f9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3161455 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Gregg Tavares <gman@chromium.org> Commit-Queue: Kenneth Russell <kbr@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>
Alexis Hetu 158ef351 2021-09-15T13:40:28 Fix integer overflow in BlockLayoutEncoder BlockLayoutEncoder::mCurrentOffset's computation had the possibility of causing integer overflows in multiple places, so this CL adds CheckedNumeric variables in a number of these occurrences in order to prevent integer overflows and causing issues. The issue in this case was an integer overflow causing the code in ValidateTypeSizeLimitations.cpp to use an invalid result from "layoutEncoder.getCurrentOffset()", which ended up compiling a shader which would later cause an OOM error. Bug: chromium:1248665 Change-Id: I688d669f21c6dc2957e43bdf91f8f8f08180a6f7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3163356 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexis Hétu <sugoi@chromium.org>
Shahbaz Youssefi 9112b1a9 2021-09-13T15:39:53 Vulkan: SPIR-V Gen: Fix precision of findMsb In GLSL, findMsb operates on a highp operand, while returning a lowp result. In SPIR-V, RelaxedPrecision cannot be applied on the FindSMsb instruction as that affects the operand as well. This change makes sure RelaxedPrecision is not applied to a FindSMsb instruction. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: I6a0defbbd53ec703c7ecbad5cd5c79d215b11c32 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3158506 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Gregg Tavares 9c6f6c39 2021-09-10T14:46:18 nullptr_t to std::nullptr_t The Skia build requires std::nullptr_t Bug: angleproject:6377 Change-Id: Ic41955e1dfefcf24bc39240d164ad938f523717c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3154997 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Gregg Tavares 2795866c 2021-09-10T02:08:40 Fix ConvertUnsupportedConstructorsToFunctionCalls The code was not hanlding nested expressions. For example: mat4(vec4(mat2x2), ...) Switched to using TIntermRebuild Bug: angleproject:5505 Change-Id: I845d94326324ac48d7489225d42d0c6e38622492 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3152168 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Gregg Tavares 958dce52 2021-09-09T14:36:37 Move IntermRebuild.h/cpp to tree_util Bug: angleproject:5505 Change-Id: I7b68057fff0a0eb0d86c1aed01599fa9dbb7db3b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3152167 Commit-Queue: Gregg Tavares <gman@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 13e9817b 2021-09-08T11:57:00 Translator: Fix assert in ScalarizeVecAndMatConstructorArgs This transformation assumed that precision can be derived for constants in every possible scenario, but that's not true. The fuzzer produced the following code: void main() { mat4 m; mat2(0, bvec3(m)); } In the above, the constant 0 legimitately has no precision. The assert was in a function that attempted to make a temporary out of the constant, which this commit changes to use the original constant as-is. Bug: chromium:1246781 Change-Id: I6f247264e5213cfd9449fdfb1dc312d02b99f2f1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3149191 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Gregg Tavares fa9f4cf3 2021-09-08T12:58:59 Fix AST validation error with gl_FragCoord Bug: angleproject:6370 Change-Id: Ia575e0329da74c84365b74b39398551b572b91a5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3149725 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Gregg Tavares c9acd799 2021-09-07T22:25:23 Only rewrite constructors for scalars/vectors/matrices Bug: angleproject:5505 Change-Id: I50b3a9a585b2eec6e4d7bd9b3197206a973d4400 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3147071 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Shahbaz Youssefi 8b2fd983 2021-09-08T11:36:17 Translator: Fix validation failure in RemoveDynamicIndexing This transformation adds function definitions to the tree after the fact, so function call validation is disabled until the transformation is complete. Bug: chromium:1246686 Change-Id: I40f77cb25cf272d5ebc42ece572371ce5161e819 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3148850 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 0bb3fcbb 2021-09-07T14:28:09 Translator: Fix precision of gl_PointSize on ES3+ In ESSL100, gl_PointSize is declared as mediump. In ESSL300+, it's declared as highp. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Ie904a12fdaaca04e2507f1796d9d0fe34b154eab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3145615 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi ae555e85 2021-09-05T21:43:03 Translator: Fix uninitialized TStructure::mAtGlobalScope This flag was not set in SeparateDeclarations when creating a struct. Bug: chromium:1246301 Change-Id: I673a7158bcc8ead0fd36a5b00696dd990950a8c0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3139663 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Gregg Tavares ab187c35 2021-09-02T14:46:29 Handle comparing arrays of scalars/vectors/matrices Fixes: UniformBlockWithOneLargeArrayMemberTest.MemberArrayOperations/ES3_Metal Bug: angleproject:5505 Change-Id: Ife35db2146ac8ce8c0880cdb98df57dc75cb35cb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3140712 Commit-Queue: Gregg Tavares <gman@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 8bb3c827 2021-07-22T19:06:40 Fix Multithreaded eglDestroyContext()/eglTerminate() The following EGL calls can lead to a crash in eglMakeCurrent(): Thread A: eglMakeCurrent(context A) Thread B: eglDestroyContext(context A) B: eglTerminate() <<--- this release context A Thread A: eglMakeCurrent(context B) The eglMakeCurrent(context B) call will assert when attempting to unMakeCurrent(), since thread A doesn't know that context A was already destroyed by thread B. To fix this: 1.) A Context will only be released once there are no Threads that currently have a reference to it (no longer have the Context current). - Context::mIsCurrent is being removed, since it was inaccurate and not thread-safe. For example, when eglTerminate() was called, the eglTerminate()'ing-Thread would "steal" the Context that was current on another Thread to destroy it. 2.) A Display will only be fully terminated and its resources released once all Contexts have been destroyed and are no longer current. Otherwise, Display::terminate() will return if any Contexts are still in use by a Thread. EGL 1.5 Specification 3.2 Initialization If contexts or surfaces, created with respect to dpy are current (see section 3.7.3) to any thread, then they are not actually destroyed while they remain current. If other resources created with respect to dpy are in use by any current context or surface, then they are also not destroyed until the corresponding context or surface is no longer current. With this fix, the app com.netmarble.sknightsmmo can start. This also exposed an issue with GlslangFinalize(), since glslang can only be initialized/finalized once per process. Otherwise, the following EGL commands will call GlslangFinalize() without ever being able to GlslangInitialize() again, leading to crashes since GlslangFinalize() cleans up glslang for the entire process. dpy1 = eglGetPlatformDisplay() | eglInitialize(dpy1) | GlslangInitialize() dpy2 = eglGetPlatformDisplay() | eglInitialize(dpy2) | GlslangInitialize() eglTerminate(dpy2) | GlslangFinalize() eglInitialize(dpy1) | isInitialized() == true Since Display::isInitialized() == true, the rest of Display::initialize() is skipped and GlslangInitialize() is not called. Later, the next test that attempts to compile a program will crash due to glslang no longer being initialized. Finally, this exposed the following tests leaking EGLContext handles: - EGLSurfaceTest::initializeContext() - EGLContextSharingTest.DisplayShareGroupContextCreation - EGLCreateContextAttribsTest.IMGContextPriorityExtension - EGLMultiContextTest.TestContextDestroySimple Other tests were failing to reset the context, preventing the Display from being terminated since there were still references to Contexts owned by the display: eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); Bug: angleproject:6208 Bug: angleproject:6304 Bug: angleproject:6322 Test: EGLContextSharingTest.EglTerminateMultiThreaded Test: EGLContextSharingTestNoFixture.EglDestoryContextManyTimesSameContext Test: Load com.netmarble.sknightsmmo Change-Id: I160922af93db6cabe0ed396be77762fa8dfc7656 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3046961 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi fefbc3fb 2021-09-01T16:26:20 Vulkan: SPIR-V Gen: Re-fix precision of constructors In f3aea7447eae7f5a4a5ad1425ab375b66048ba3f, the precision of constructors was changed such that it would be derived from its operands, but also be able to be promoted based on neighboring operands. Based on https://gitlab.khronos.org/opengl/GLSL/-/issues/58 this is incorrect, and indeed the precision of the constructor (when possible) solely depends on its own operands. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Ic2560d17973f56d4d836e3c7112d6649197a306c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3138534 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Gregg Tavares e02753fc 2021-08-31T21:09:45 Convert constructors to function calls where needed. MSL does not do as many conversions between types and has more strict constructors than GLSL so convert to function calls where necessary. Fixes: GLSLTest_ES3.AmbiguousConstructorCall2x2/ES3_Metal GLSLTest_ES3.AmbiguousConstructorCall2x3/ES3_Metal GLSLTest_ES3.ConstructMatrixFromNonFloat/ES3_Metal GLSLTest_ES3.ConstructNonFloatVectorFromMatrix/ES3_Metal GLSLTest_ES3.ScalarConstructor/ES3_Metal UniformBufferTest.Std140UniformBlockWithRowMajorQualifier/ES3_Metal UniformBufferTest.Std140UniformBlockWithPerMemberRowMajorQualifier/ES3_Metal UniformBufferTest.Std140UniformBlockWithPerMemberColumnMajorQualifier/ES3_Metal UniformBufferTest.Std140UniformBlockWithRowMajorQualifierOnStruct/ES3_Metal SimpleUniformTest.FloatMatrix2UniformStateQuery/ES2_Metal SimpleUniformTest.FloatMatrix2UniformStateQuery/ES3_Metal SimpleUniformTest.FloatMatrix3UniformStateQuery/ES2_Metal SimpleUniformTest.FloatMatrix3UniformStateQuery/ES3_Metal SimpleUniformTest.ArrayOfMat3UniformStateQuery/ES2_Metal SimpleUniformTest.ArrayOfMat3UniformStateQuery/ES3_Metal UniformTestES3.MatrixArrayUniformStateQuery/ES3_Metal Bug: angleproject:6306 Change-Id: Iea8a9a261f94f121f482c2ea9678192ca056570c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3134963 Commit-Queue: Gregg Tavares <gman@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Shahbaz Youssefi 9d0e2851 2021-09-01T00:42:58 Fix SeparateDeclarations vs struct specifiers Bug: chromium:1237696 Change-Id: I3b00f3797800e814ca83226a8e4f25b2a43cc641 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3133824 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi f3aea744 2021-08-25T22:09:58 Vulkan: SPIR-V Gen: Fix precision of constructors According to the spec, constructors don't have a precision (and thus their precision is derived from the operands they are used in. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: I557386764abf5493fbe59803dc8e260312c04b48 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3119352 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi fbdd0516 2021-08-27T00:04:11 Vulkan: SPIR-V Gen: Fix precision of imageLoad According to the spec, imageLoad should return highp. However, glslang produces the same precision as the image (which makes more sense). This seems to be a spec bug per the discussion in this issue: https://gitlab.khronos.org/opengl/GLSL/-/issues/57 This change aligns ANGLE with glslang w.r.t to the precision of imageLoad. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Ia0ce493a0deab21810458da6b48fdf51dfbd41a2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3122317 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill a29b07d8 2021-08-26T13:11:29 InitializeVariables: Init shader IO block outputs. These variables were not handled in the pass because we had no prior test coverage of them. Some frame capture testing uncovered this gap. The variables must be initialized field-by-field, since there seems to be no defined way to initialize an entire block at once. Bug: angleproject:6326 Change-Id: Ib7aecfb76b97b4236d786b44b3dfb706c573e221 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3123228 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Gregg Tavares 4c56534f 2021-08-25T15:56:59 Include globals when defering global initializers Fixes these tests: GLSLTest.StructWithInitializer/ES2_Metal GLSLTest.StructWithInitializer/ES3_Metal GLSLTest.StructWithUniformInitializer/ES2_Metal GLSLTest.StructWithUniformInitializer/ES3_Metal GLSLTest_ES3.SequenceOperatorEvaluationOrderDynamicVectorIndexingInLValue/ES3_Metal WebGL2GLSLTest.InitUninitializedLocals/ES3_Metal Bug: angleproject:5505 Change-Id: Ib8258898c60b9e9ffbb71f0024f8189dc6cf4d5b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3120093 Commit-Queue: Gregg Tavares <gman@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Shahbaz Youssefi 9c271645 2021-08-27T13:07:06 Vulkan: SPIR-V Gen: Fix gl_PerVertex without clip/cull support When the clip/cull distance extension is not supported, the gl_ClipDistances and gl_CullDistances arrays were given a size of 0, which made them translate as OpRuntimeArray. This change makes sure that these arrays always have a non-zero size. Bug: angleproject:4889 Change-Id: I8d2ffe3a7c1df9316e91eebc2aa53bdc2c87ccc1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3123354 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi f9d261f5 2021-08-25T10:23:48 Translator: Don't promote precision from initializer Take the following GLSL code: precision mediump float; uniform highp float u; float x = u; When `x` is declared, its precision is mediump due to `precision mediump float`. Its initializer (`u`) however is highp. Previously, ANGLE generated the following code to ensure the precision of the initializer is applied to the variable: highp float x = u; Compiling the same code with glslang and looking at the SPIR-V (both SPIR-V for OpenGL and SPIR-V for Vulkan), such a promotion is not done. The generated SPIR-V is equivalent to: mediump float x = u; This change aligns ANGLE's output with glslang's by outputting the precision of the variable itself instead of the precision of the assignment (which is highp due to promotion from the two operands). Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: I6f338a865c0a7710329fc13bc171fd245dd30b31 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3118965 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 3408ea3e 2021-08-24T11:41:42 Translator: Fix precision of gl_FragCoord on ES3+ In ESSL100, gl_FragCoord is declared as mediump. In ESSL300+, it's declared as highp. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: I42583d07fb745421f195be95fa404c617227b02e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3116307 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 a08b667d 2021-08-24T12:13:23 Translator: Stabilize autogenerated builtin function parameters When pruning the list of builtin function parameters, sorted() is used to stabilize the result. This makes reviews of changes to the autogenerated output easier. Bug: angleproject:4889 Change-Id: I97afc31de2a62b34a0a8183bb5a47eab9e62d9fc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3116306 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Gregg Tavares 411137bf 2021-08-24T11:46:51 Emit INFINITY for infinite constants GLSL had `v = 1.0e40` which was output as `v = inff` in MSL. Changed to output `v = INFINITY`. Fixes Tests: GLSLTest_ES3.LiteralInfinityOutput/ES3_Metal GLSLTest_ES3.LiteralNegativeInfinityOutput/ES3_Metal Bug: angleproject:5505 Change-Id: Ib651583e608351784dcd49d602a23b5ecb8475cb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3116548 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Shahbaz Youssefi 210773db 2021-08-05T10:41:59 Translator: Be more explicit about precisions GLSL ES requires that every symbol (variable, block member, function parameter and return value) is appropriately qualified with a precision, either individually or through the global precision specifier. Some tree transformations however produced symbols with EbpUndefined precision. In text GLSL output, these would produce unqualified symbols which was often incorrect. In this change, the transformations are made to produce explicit / more consistent precisions. The validation (that caught these issues) is not included in this change as there are still a few corner cases left to address. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Icca8a0a5476f8646226e7243aa8f501f44acc164 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3075127 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill b196eec0 2021-08-20T12:32:03 translator: Fix InitializeVariables with gl_ClipDistance. The extension allows for the shader to redeclare this variable with a different size. This would sometimes put the tree in an inconsistent state when used with the InitializeVariables feature. Fix this by using the user declaration of gl_ClipDistance when available. Found when working on trace validation, where using the init output variables option in the compiler would then cause tree validation to fail for one specific test. Test: ClipDistanceTest.ThreeClipDistancesRedeclared Bug: angleproject:5133 Change-Id: I42c9bfbe313826ac5d391068d9fc18eb5793375f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3110752 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 49af677a 2021-08-16T07:59:18 Capture/Replay: Update serialization logic. - Uses more common toString methods instead of custom ones. - Uses enum to string in more places intsead of numeric enums. - Adds missing group scopes in several places. - Skips serializing empty image levels. Bug: angleproject:5133 Change-Id: I2c9523981aba4ec0afb5f0623cb34154db263e6b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3097805 Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Gregg Tavares 5ca0953d 2021-08-18T13:22:22 Use the correct attribute locations in Metal Fixes these tests: BlendIntegerTest.MRTSigned/ES3_Metal BlendIntegerTest.MRTUnsigned/ES3_Metal DrawBuffersTest.Gaps/ES3_Metal DrawBuffersTest.BlendWithGaps/ES3_Metal DrawBuffersTest.FirstAndLast/ES3_Metal DrawBuffersTest.FirstHalfNULL/ES3_Metal DrawBuffersWebGL2Test.TwoProgramsWithDifferentOutputsAndClear/ES3_Metal WebGLCompatibilityTest.DrawBuffers/ES3_Metal Bug: angleproject:5505 Change-Id: I9ea82a8c7a0c5bbc78eb69eb92552909e3f437f3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3105439 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Gregg Tavares 63bb0e53 2021-08-16T16:30:32 Add depth fix to convert from GL to Metal Vertex shaders need to convert from GL's -1 to +1 z range to Metal's 0 to +1 z range with: z = (z + w) * 0.5 This code is being upstreamed from WebKit. It fixes these end to end tests. BlitFramebufferTest.MultisampleDepthClear/ES3_Metal BlitFramebufferTest.MultisampleDepthClear/ES3_Metal_NoStencilOutput BlitFramebufferTest.BlitDepthStencilPixelByPixel/ES3_Metal BlitFramebufferTest.BlitDepthStencilPixelByPixel/ES3_Metal_NoStencilOutput ClearTest.ClearStencilMask/ES2_Metal ClearTest.ClearStencilMask/ES3_Metal ClearTestES3.ClearMultipleAttachmentsIndividually/ES3_Metal ClearTestES3.MaskedClearHeterogeneousAttachments/ES3_Metal ClearTestES3.ScissoredClearHeterogeneousAttachments/ES3_Metal ClearTestES3.ClearBufferivStencilMask/ES3_Metal ClearTestES3.ClearBufferfiNoStencilAttachment/ES3_Metal MaskedScissoredClearTest.Test/ES2_Metal__clear_s MaskedScissoredClearTest.Test/ES2_Metal__clear_s_mask_s MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_s_mask_s MaskedScissoredClearTest.Test/ES2_Metal__clear_d MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_d MaskedScissoredClearTest.Test/ES2_Metal__clear_ds MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_ds MaskedScissoredClearTest.Test/ES2_Metal__clear_ds_mask_s MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_ds_mask_s MaskedScissoredClearTest.Test/ES2_Metal__clear_cs MaskedScissoredClearTest.Test/ES2_Metal__clear_cs_mask_s MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cs_mask_s MaskedScissoredClearTest.Test/ES2_Metal__clear_cd MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cd MaskedScissoredClearTest.Test/ES2_Metal__clear_cds MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cds MaskedScissoredClearTest.Test/ES2_Metal__clear_cds_mask_s MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cds_mask_s MaskedScissoredClearTest.Test/ES2_Metal__clear_cs_mask_cs MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cs_mask_cs MaskedScissoredClearTest.Test/ES2_Metal__clear_cd_mask_c MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cd_mask_c MaskedScissoredClearTest.Test/ES2_Metal__clear_cds_mask_c MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cds_mask_c MaskedScissoredClearTest.Test/ES2_Metal__clear_cds_mask_cs MaskedScissoredClearTest.Test/ES2_Metal__scissored_clear_cds_mask_cs MaskedScissoredClearTest.Test/ES3_Metal__clear_s MaskedScissoredClearTest.Test/ES3_Metal__clear_s_mask_s MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_s_mask_s MaskedScissoredClearTest.Test/ES3_Metal__clear_d MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_d MaskedScissoredClearTest.Test/ES3_Metal__clear_ds MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_ds MaskedScissoredClearTest.Test/ES3_Metal__clear_ds_mask_s MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_ds_mask_s MaskedScissoredClearTest.Test/ES3_Metal__clear_cs MaskedScissoredClearTest.Test/ES3_Metal__clear_cs_mask_s MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cs_mask_s MaskedScissoredClearTest.Test/ES3_Metal__clear_cd MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cd MaskedScissoredClearTest.Test/ES3_Metal__clear_cds MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cds MaskedScissoredClearTest.Test/ES3_Metal__clear_cds_mask_s MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cds_mask_s MaskedScissoredClearTest.Test/ES3_Metal__clear_cs_mask_cs MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cs_mask_cs MaskedScissoredClearTest.Test/ES3_Metal__clear_cd_mask_c MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cd_mask_c MaskedScissoredClearTest.Test/ES3_Metal__clear_cds_mask_c MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cds_mask_c MaskedScissoredClearTest.Test/ES3_Metal__clear_cds_mask_cs MaskedScissoredClearTest.Test/ES3_Metal__scissored_clear_cds_mask_cs DepthStencilFormatsTest.DepthTextureRender/ES2_Metal DepthStencilFormatsTest.DepthBuffer16/ES2_Metal DepthStencilFormatsTest.DepthBuffer24/ES2_Metal DepthStencilFormatsTest.VerifyDepth32UploadData/ES2_Metal DepthStencilFormatsTest.VerifyDepth16UploadData/ES2_Metal TinyDepthStencilWorkaroundTest.DepthTexturesStick/ES3_Metal DiscardFramebufferEXTTest.ClearDepthThenDrawWithDepthTestThenDiscard/ES2_Metal DiscardFramebufferEXTTest.ClearDepthThenDrawWithDepthTestThenDiscard/ES3_Metal Bug: angleproject:5505 Change-Id: I9b52bb46569678636afc6a243bfa8779f101b6af Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3097161 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Shahbaz Youssefi d20afde4 2021-08-05T23:06:44 Vulkan: Retain precision of uniform variables When gathering in a uniform block, the precision of default uniforms was dropped. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Ie6a8e2e7cef7cd3808cee08d20f886fc4e762cd5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3076124 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Kenneth Russell 1654537d 2021-08-06T17:49:52 Fix default and driver uniforms' binding indices. These abstractions were introduced in the SymbolTable during upstreaming of the direct-to-Metal compiler and were accidentally swapped, leading to widespread test failures. Fix the comment reference in ContextMtl's DriverUniforms struct. Add missing emulatedInstance field, and add a TODO about its missing support in direct-to-Metal translator. Define it in SPIR-V Metal translator; the driver uniforms for the two must match. Bug: angleproject:6259 Change-Id: I0330ab4efca5b64a749b9cca90564fdbc84d7a80 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3078998 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Kenneth Russell d191bc32 2021-08-06T12:59:39 Reintroduce TType::isRank0. This concept was used in the direct-to-Metal compiler, and its replacement with isScalar wasn't completely correct. Fixes several assertion failures in tests. Bug: angleproject:4889 Bug: angleproject:5505 Change-Id: I9b8800ed50591560c8e53faa81eca581c4f07a02 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3078474 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Shahbaz Youssefi 63248e7f 2021-08-05T23:49:23 Translator: Fix dead-code-elimination corner case The DCE code had a corner case bug where a switch case containing multiple DCE'ed `break`s followed by another case would cause some of the DCE'ed statements in the first case to be doubly pruned, failing on an assertion. This was due to the fact that visitBlock() was asking traversal to continue if a new case was visited while pruning nodes, but the traversal does not take into account that some statements need to be skipped and so would also visit the pruned statements. If the pruned statements contain a branch instruction, they get re-pruned. The visitBlock() function that does the pruning is reworked so that it more clearly traverses the statements. Bug: chromium:1237200 Change-Id: Ib078c2ea73ade756c7d7ef5a5c489fa53c39f352 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3077659 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 0cd99779 2021-08-05T10:35:10 Translator: Propagate precision to children nodes Similarly to glslang, when the precision of a node is determined, propagate that precision to any of its children that doesn't already have a precision. Ultimately these should only include TIntermConstantUnion nodes. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: I121231d04c7cf92fc3f07716019ffe88eca48b88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3075126 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 2e8a2d3c 2021-08-04T11:04:44 Translator: Helpers to derive precision Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: I75e2084c76139ccb24b266f262d5e5597d8aa4ca Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3071599 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
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 6fe91881 2021-08-02T11:13:13 Translator: Simplify RecordConstantPrecision Just before ESSL output, this transformation made some constants specified through temp variables such that their precision can be specified. This was done in cases where the precision actually affected the expression being evaluated. This transformation is simplified by declaring constants more conservatively as variables, and not stringently attempting to identify whether that's necessary. This is still not done in trivial cases. This change is in preparation for another change that overhauls precision propagation through the nodes. This change removes all references to TIntermTyped::getPrecision() outside the precision promotion code itself. Bug: angleproject:4889 Change-Id: I135b2b3241aa2f76219b209241c3844f1d09ccd2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3067948 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> 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 1ce78397 2021-07-30T16:51:45 Remove support for WEBGL_debug_shader_precision This extension was rejected, and the implementation was hacky. This clean up is part of an ongoing work to improve precision handling. Bug: angleproject:6059 Change-Id: If08581ec6f19cf1698ffa3dd6d248dc5e68a1d31 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3064303 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 09d5047b 2021-08-03T01:31:03 GL: Remove the rewriteVectorScalarArithmetic workaround This workaround was implemented for a bug in Nvidia driver 387 which is end-of-life. More recent driver branches (390 and 4XX) are fixed, and so this workaround is no longer required. The implementation of the workaround itself could introduce bugs. Bug: chromium:772651 Bug: chromium:1201084 Change-Id: I3db179eb90d9124235bdad2daacc712302906d8e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3067952 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Brandon Schade 217acac2 2021-07-21T12:42:56 Vulkan: Add support for EXT_primitive_bounding_box 1. Added support for EXT_primitive_bounding_box extension 2. Renamed shader variable gl_BoundingBoxEXT[] to ANGLEBoundingBox[] Bug: angleproject:3576 Test: dEQP-GLES31.functional.primitive_bounding_box.* Change-Id: I15fa9af50c6fd8e86d225670ddd8eb39f6e65d35 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3053618 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi f9942640 2021-08-03T11:45:31 Translator: Fix fuzzer crashing on assertion An assertion was triggered by the fuzzer when generating an invalid shader that redeclared a built-in. The assertion itself was unnecessary and the parser would appropriately generate an error if that assertion would have fired. Bug: angleproject:4889 Bug: chromium:1235229 Change-Id: I294b2e329491c75d4e87622b602570252555869f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3063910 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi a65b4056 2021-07-30T23:00:57 Reland "Translator: Clean up type cloning" This is a reland of f016c4352f5203c10511df078b1ed5359afc1b35 Original change's description: > Translator: Clean up type cloning > > TType has a constructor that aids cloning + helpers to convert between > types. A number of places where a type is constructed from the > information gathered from another type is changed to clone the type and > then use one of these helpers. > > This clean up is part of an ongoing work to improve precision handling. > This change removes many references to TType::getPrecision(). > > Bug: angleproject:4889 > Change-Id: Ib85659ab5363b56ad298f8648fca856edc1ebf8b > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3063944 > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> Bug: angleproject:4889 Change-Id: I35772f178eb4f6cf2b64bfeb37a4a144acdb4daf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3067802 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Austin Eng c5c8a25a 2021-08-03T14:40:33 Revert "Translator: Clean up type cloning" This reverts commit f016c4352f5203c10511df078b1ed5359afc1b35. Reason for revert: Suspect for crbug.com/1236060 Original change's description: > Translator: Clean up type cloning > > TType has a constructor that aids cloning + helpers to convert between > types. A number of places where a type is constructed from the > information gathered from another type is changed to clone the type and > then use one of these helpers. > > This clean up is part of an ongoing work to improve precision handling. > This change removes many references to TType::getPrecision(). > > Bug: angleproject:4889 > Change-Id: Ib85659ab5363b56ad298f8648fca856edc1ebf8b > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3063944 > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> Bug: angleproject:4889 Change-Id: I9b5ecacc410b41be382232292ceae2f7ea7906c7 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3064393 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Austin Eng <enga@chromium.org>
Shahbaz Youssefi f016c435 2021-07-30T23:00:57 Translator: Clean up type cloning TType has a constructor that aids cloning + helpers to convert between types. A number of places where a type is constructed from the information gathered from another type is changed to clone the type and then use one of these helpers. This clean up is part of an ongoing work to improve precision handling. This change removes many references to TType::getPrecision(). Bug: angleproject:4889 Change-Id: Ib85659ab5363b56ad298f8648fca856edc1ebf8b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3063944 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi aca9f2e2 2021-07-29T17:49:26 Vulkan: SPIR-V Gen: Fix constructors with uniform parameters When the constructor contains parameters from interface blocks, they may have SPIR-V type specializations that was not previously accounted for. The code is made more robust by retrieving the column/component types when generating constructors through TTypes instead of modifying SpirvTypes directly. Bug was caught by the WebGL CTS. Bug: angleproject:4889 Change-Id: I6c9df17a97fac8622dea55ed67c7bae1ce16d1bd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3061640 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Peter Kasting d4d6c23c 2021-07-31T11:41:29 Fix a recently-introduced case of -Wunreachable-code-aggressive. Also enable this and -Wunused-but-set-variable to avoid regressing them. Bug: chromium:1066980 Change-Id: I1fd7a57c2bf14513d657b69b70e35ad727c75ffd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3065355 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi ae8ef039 2021-07-30T00:43:14 Translator: Correctly respect precision of gl_FragColor/Data These builtins are declared with a mediump precision. However, during translation to Vulkan GLSL, the precision was not output and as such glslang treated them as highp. Discovered through comparison with SPIR-V output from ANGLE which included more RelaxedPrecision operations. Bug: angleproject:4889 Change-Id: I7974478e87ad20115345d679f8f035492be1f349 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3062204 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 8fb5c2f2 2021-07-29T23:41:08 Vulkan: SPIR-V Gen: Fix OpImage* on multisampled images Lod should not be implicitly specified on multisampled images per spec. This change fixes a crash on Intel/Mesa with the TextureSampleShadingTest.Basic/ES3_1_Vulkan test. Old spirv-val catches this bug, but ToT has regressed this: https://github.com/KhronosGroup/SPIRV-Tools/issues/4424 Bug: angleproject:4889 Change-Id: Ic2a661ce5264beb1f47f4e52706fe6556176628d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3062203 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@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>
Shahbaz Youssefi a83c9108 2021-07-29T17:13:41 Vulkan: SPIR-V Gen: Fix nested ternary operators The OpPhi instruction used to implement ternaries referenced to the blocks pregenerated for the true and false cases. However, if there were other code nested inside that could generate blocks (other ternary expressions or short-circuits), that would be wrong. Instead, the last block id is taken every time the true or false case is entirely visited (similar to how it's done in the short-circuit implementation). Bug was caught by the WebGL CTS. Bug: angleproject:4899 Change-Id: I71be86989dfe9596a13940ce657a7e67849e86bf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3061639 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 2b23aae4 2021-07-29T16:39:28 Vulkan: SPIR-V Gen: Support vec(..., mat) Matrices specified in vector constructor arguments were not correctly handled w.r.t to casting (caught by the WebGL CTS). Bug: angleproject:4889 Change-Id: I70253f049a651fc5f439b56d1e4d8f785813b605 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3061638 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 96ccf3f4 2021-07-29T12:38:21 Translator: Consolidate EvqFragDepth and EvqFragDepthEXT They were the same thing. Fixes SPIR-V generation which only handled EvqFragDepth. Bug: angleproject:4889 Change-Id: Id2c35f4c5a26e43ad16a420cc0306756a1add082 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3059922 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 3036e090 2021-07-29T15:55:39 Vulkan: Direct SPIR-V Gen: Support the precise keyword The precise keyword is different in GLSL in that it defines what arithmetic operations _that have led to the value being assigned to a variable_ should be done precisely (i.e. not "contracted"). A tree traverser is implemented that detects precise access chains and applies precise-ness to the right hand side of assignment expressions to said access chains. This is only done if the shader uses the precise keyword in the first place. The algorithm for this is inspired by the implementation in glslang. This change additionally: - Fixes parser to allow precise on function parameters - Fixes GLSL code generation to output precise on struct members and function parameters. Bug: angleproject:4889 Change-Id: Ie3808c3c8c08da308e88af20f5f90379d9d14d47 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3056369 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@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 c8c9e15b 2021-07-26T22:51:49 Translator: Fix sizing of tessellation shader arrays If layout(vertices=N) is specified after implicitly sized array declarations, the correct size was not being specified on them. Bug: angleproject:4889 Change-Id: I86ccf45a7f264b493a137b87316eff744079ed6c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3054614 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Peter Kasting 5bda5f91 2021-07-26T20:37:52 Fix some instances of -Wunreachable-code-aggressive. Bug: chromium:1066980 Change-Id: I1e769b78c51d939067e8855beab32ec7c006c00e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3055794 Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Nico Weber <thakis@chromium.org>
Shahbaz Youssefi b8d6f8aa 2021-07-22T22:31:29 Translator: Facilitate integration in FireFox Instead of relying on is_apple to build workarounds applied on apple hardware, a new build argument is added for this purpose. This allows FireFox to more easily include these files in their build system (which builds every workaround on every platform). The workarounds are reorganized too and moved from tree_ops/gl/mac to tree_ops/apple. RewriteRowMajorMatrices is moved there too as it's now used by both gl and metal. This workaround is large, and removing it from non-apple builds improves binary size (~40KB on Linux). Bug: angleproject:6188 Change-Id: I8e1dab44d0235bb6b8341d53721bdd0d157d46c6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3047385 Reviewed-by: Jeff Gilbert <jgilbert@mozilla.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi dbe986d7 2021-07-26T01:43:44 Vulkan: SPIR-V Gen: Fixes to tessellation shader support - TCS barrier() built-in is correctly looked up - Patch decorations are fixed Bug: angleproject:4889 Change-Id: I1befcaca85a965c9d46b1b41ec74597de44bf2b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052687 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi acfd63a4 2021-07-26T01:02:11 Translator: Remove GLSL rules from the ESSL-only symbol table Shaves ~36KB off of ANGLE's binary size on Android. Bug: chromium:1084580 Change-Id: I4711c6bd28437a43b7dc63be4cfcdaed7ae11ba2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052686 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 63fa7080 2021-07-25T23:19:02 Vulkan: SPIR-V Gen: Fix bugs with ES3.1 texture* builtins - Add missing ImageCubeArray capability for image cube arrays - Remove extra Lod image operand for sampler/image buffers Bug: angleproject:4889 Change-Id: I96545092528b7dcecf902561e194b17636217ef4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052683 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 715bab1f 2021-07-25T23:35:17 Vulkan: SPIR-V Gen: Fixes to geometry shader support - max_vertices=0 is invalid in SPIR-V and is fixed (similarly to anglebug.com/5411) - gl_PrimitiveID used in fragment shaders requires the Geometry capability. Bug: angleproject:4889 Change-Id: If8c6a9d455d0582d61c3c52b5f773bcb5ca64b53 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052684 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi ff7eafb5 2021-07-25T23:05:26 Vulkan: SPIR-V Gen: Fix .length() vs ssbo arrays Bug: angleproject:4889 Change-Id: Ib490a46fabf058064fc1b18d2c084a4bc5f9277d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052682 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi b19fbbda 2021-07-25T21:57:12 Vulkan: SPIR-V Gen: Support multiview Bug: angleproject:4889 Change-Id: Ibe66f53357473dbb4435af58775b524d83ed250b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3052675 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 939ea5f4 2021-07-23T15:53:17 Vulkan: SPIR-V Gen: Fixes to tessellation builtins On TCS, TES and FS, gl_PrimitiveID is actually an input. Additionally, `patch` variables (including gl_TessLevel* built-ins) need to be decorated with Patch. Bug: angleproject:4889 Change-Id: I326ec4b0c011fe8eaafbad4f8bcb0f537005f96f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048320 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 9416e84e 2021-07-23T14:53:43 Vulkan: SPIR-V Gen: Add missing DepthReplacing execution mode Shaders writing to gl_FragDepth need this execution mode specified. Bug: angleproject:4889 Change-Id: I315c90f9161f4d3d51b1c856f1364fb26a4bd404 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048317 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi de8dc2c9 2021-07-23T15:45:28 Vulkan: SPIR-V Gen: Support OES_sample_variables Built-ins from this extension are now decorated. Bug: angleproject:4889 Change-Id: I12f80d67e3595f94fc64bdc8cb3031d36b98c279 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048319 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 8bf2e5ec 2021-07-23T16:54:16 Vulkan: SPIR-V Gen: Fix switch with default at the end A minor bug was making a switch with default at the end to jump to the merge block instead of the default block. Bug: angleproject:4889 Change-Id: Ied434fab949b10d45a0db1242c1b8535a5f4f773 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048321 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 82d7d888 2021-07-22T21:46:21 Vulkan: SPIR-V Gen: Fix bugs with texture* builtins With this change, deqp ES3 tests pass. Bug: angleproject:4889 Change-Id: Ica158d4e9012c7bb3e458da62b4a7f92aee5c6de Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3047380 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 31bc9226 2021-07-23T15:16:27 Vulkan: SPIR-V Gen: Fix unpack* built-ins The parameter to these built-ins was getting extended to a vector. Bug: angleproject:4889 Change-Id: Idddce008c9b4f6bf9205b1e20f6e89ef657ea3a1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3048318 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 6b5cec15 2021-07-22T17:01:41 Vulkan: SPIR-V Gen: Fixes to scalar->vector promotion With the ternary operator, the condition may be a bool-in-interface block that needs to be cast. This cast is now part of createConstructorVectorFromScalar so it can't be missed. Bug: angleproject:4889 Change-Id: I0e24cd4127301d33a3ac677ccaf560c4468e0799 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3047379 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi d0c03ff4 2021-07-22T14:55:51 Vulkan: SPIR-V Gen: Fix lvalues passed to in/inout parameters In GLSL, these values are semantically copied when passed to a function as an in or inout parameter. For example in: bool f(inout vec4 a, inout vec4 b) { a = vec4(0); return all(equal(a, b)); } var = vec4(1); bool result = f(var, var); result is expected to be false. In SPIR-V, every parameter is semantically passed by "reference". glslang conservatively uses temporaries to pass to functions. An optimization in ANGLE didn't create temporaries for unindexed lvalues, which did not take into account the above fact. This optimization is limited to out parameters now. Bug: angleproject:4889 Change-Id: Ie1b4b1cecba847ba63d5810d01d0856823b89ddc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3046103 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>