src/compiler/translator/tree_ops/RewriteDfdy.cpp


Log

Author Commit Date CI Message
Shahbaz Youssefi f355e2b3 2025-04-15T18:58:25 Vulkan: Remove preferDriverUniformOverSpecConst This was practically true for every vendor on Android (where rotation matters). For Qualcomm, it was also true due to a bug in version checking and didn't seem to be causing any concerns. Where pre-rotation is supported, it is better to enable this feature to avoid excessive pipeline creation. This change removes the feature and makes sure ANGLE always uses uniforms for rotation instead of spec consts. While technically this may have an adverse effect on platforms that never need pre-rotation, the ability is retained for all vendors since pre-rotation is finding its way into more platforms and would likely eventually be needed everywhere anyway. Bug: angleproject:42265878 Bug: angleproject:42262166 Change-Id: I4b64c04da46db08cfdd44b60789b66d93d8e8b17 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6459025 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: mohan maiya <m.maiya@samsung.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Neil Zhang 0d1478f3 2025-03-27T18:40:05 Fix dFdx() dFdy() in frag shader not work as expected When render to FBO0, Y axis will flipping, Angle's compile module will handle this, but only when glsl version > 300, that's a mistake as glsl 100 also have dFdx/dFdy when have GL_OES_standard_derivatives. Bug: angleproject:406819301 Change-Id: I656cfcfdeff1e80db374cfa083578adda6064e69 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6407233 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Auto-Submit: Neil Zhang <Neil.Zhang@arm.com> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi d193d51b 2024-06-17T22:46:08 Replace issue ids post migration to new issue tracker This change replaces anglebug.com/NNNN links. Bug: None Change-Id: I8ac3aec8d2a8a844b3d7b99fc0a6b2be8da31761 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5637912 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 9b63700b 2023-07-11T10:25:40 Translator: Reorganize files This change makes the translator files more organized by: - Grouping files that are specific to a certain output under their own directory, - Moving transformations under tree_ops - Removing Direct from metal translation now that that SPIR-V Cross path is removed Bug: angleproject:6394 Change-Id: Iaf5bb8d5604b84748dece029821b1f77b2813967 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4678780 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 2df17a12 2022-05-25T16:18:37 Vulkan: Pack driver uniforms Previously 5 vec4s were used for driver uniforms + 2 vec4s if specialization constants couldn't be supported. The driver uniforms are rearranged and packed such that only 2 vec4s are normally used, which include fallback for specialization constants as well. In the future, most of the specialization constants may turn into uniforms, and this change prepares for that. Additional uniforms are used (3 vec4s) only if common extensions are missing; transform feedback and bresenham lines. This change makes it more practical for driver uniforms to be turned into push constants. Additionally, these uniforms could potentially be loaded and cached at the beginning of the shader for more efficient memory access. On Pixel6, with this change, the traces show no difference in wall time. On most traces, CPU time shows up to ~7% improvement. Bug: angleproject:7366 Change-Id: I0f47f863955af06a19c69d1f1d7c45b97d95476e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3668151 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 98c2e169 2022-05-20T16:17:49 Vulkan: Reduce pre-rotation spec const to bool The specialization constant now only dictates whether x and y should be swapped. The complete 8 possible states of rotation and y-flip are achieved by using this swap in combination with a driver uniform for x and y flip. Swapping is still a specialization constant to avoid degrading performance of dFdx/dFdy which otherwise would need both to be evaluated instead of one. On platforms which don't support pre-rotation, the specialization constant will never change and driver uniforms entirely govern y-flip. On platforms that do support pre-rotation, only two variations of the pipeline are needed. Bug: angleproject:7366 Change-Id: I73f84e89fa9349d2098fa5b21573aee57d93a30c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3663151 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 061188a7 2021-08-04T10:07:47 Translator: General clean up General clean up done as part of other changes, split to simplify review. Bug: angleproject:4889 Bug: angleproject:6132 Change-Id: Iade9954d187a759be9edd0e3754be007f4133c56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3071598 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 8b869a95 2021-06-13T01:09:27 Translator: Generate Ops for all built-in functions EOpCallBuiltInFunction is removed in this change, as well as the "op": "auto" property in builtin_function_declarations.txt. Instead, gen_builtin_symbols.py automatically generates Ops for every built-in function and generates the TOperator enum accordingly. This simplifies SPIR-V code generation by allowing switches to be used on operators instead of string comparisons. Bug: angleproject:4589 Bug: angleproject:4889 Change-Id: Ia351524400b0e12a10a5572e27e9b88c6ec2e61c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2958869 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 29227eef 2021-06-05T22:25:01 Vulkan: SPIR-V Gen: Specialization constants With specialization constant qualifier and ids set in the node types, the SPIR-V generation for these variables are trivially handled. This is in preparation for enabling line raster emulation as well as fragment shaders in general. Bug: angleproject:4889 Change-Id: Ie4d4e47b222ac66d1e0eee29f55ac09990313580 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939337 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@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>
Shahbaz Youssefi 382bf288 2020-12-24T23:56:39 Organize AST transforms per backend Most of the AST transforms are written as a workaround to an issue that affects a single backend. This change identifies such transforms and organizes them by backend. They are then only built if the respective backend is. Additionally, about half of the GL transforms are due to mac workarounds, including the large RewriteRowMajorMatrices transform. Mac-specific workarounds are additionally only built on said platform. This change reduces the ANGLE binary size: - 106KB in a Vulkan-only build on Linux - 27KB in a GL-only build on Android (60KB on Linux) Bug: chromium:1084580 Bug: chromium:1161513 Change-Id: I64b334332c0d4f848756c6538af0d8d96864c7e9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2601346 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao c75473c2 2020-11-23T14:26:32 Vulkan: Generalize FlipRotationSpecConst to SpecializationConstant Specialization constant are used not just for flip/rotation. It also used for other things. This CL merges all specialization constant usage (lineRasterEmulation, flip, rotation, halfRenderArea) into one class and rename FlipRotationSpecConst to SpecConst. Bug: b/173800146 Change-Id: I8dc3354b6caedbb183cec29855fc1c301ec8872a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2555812 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 995493cc 2020-11-18T20:33:33 Revert "Vulkan: Remove rotation related data from driver uniform" This reverts commit fd97c3343e9ff23677124b7528ec945bca65796a. Reason for revert: The specialization constant for rotation causes performance regression with older qualcomm driver. We need to keep the driver uniform code path for the older driver. Original change's description: > Vulkan: Remove rotation related data from driver uniform > > Rotation is now handled in the shader compiler with specialization > constant, it should be removed from driver uniforms. Since Metal is > using the flipXY, flipXY/negFlipXY are still kept in the shader side > implementation, but have moved to TranslatorMetal in this CL. > > Bug: b/171750979 > Change-Id: Ie8d15ef227cb52a6e19e4319ecc9f09bda42e667 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2519863 > Reviewed-by: Ian Elliott <ianelliott@google.com> > Reviewed-by: Tim Van Patten <timvp@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Charlie Lao <cclao@google.com> TBR=ianelliott@google.com,timvp@google.com,jmadill@chromium.org,cclao@google.com Bug: b/171750979 Change-Id: Iff9cffb28851ade1d9c5cd23fde73910a19867ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2547808 Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao fd97c334 2020-11-12T11:05:40 Vulkan: Remove rotation related data from driver uniform Rotation is now handled in the shader compiler with specialization constant, it should be removed from driver uniforms. Since Metal is using the flipXY, flipXY/negFlipXY are still kept in the shader side implementation, but have moved to TranslatorMetal in this CL. Bug: b/171750979 Change-Id: Ie8d15ef227cb52a6e19e4319ecc9f09bda42e667 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2519863 Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 3a1838a1 2020-11-10T20:30:43 Vulkan: Let RewriteInterpolateAtOffset use FlipRotateSpecConst Instead of using uniform, use flip/rotation specialization constant when available. This allows matrix multiplication calculated at compile time instead of shader execution time. Bug: angleproject:4901 Bug: angleproject:3589 Change-Id: I5a8a82b1cffbbbeba2617cb7e9a0ec38f9984d50 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2530457 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Charlie Lao 15ead5d5 2020-11-02T12:25:32 Reland "Vulkan: Let shader use rotation specialized constant" This is a reland of 47b3db22be33213eea4ad58f2453ee1088324ceb Original change's description: > Vulkan: Let shader use rotation specialized constant > > If use rotation specialized constant is enabled via compiler options, > this CL will use rotation specialized constant to generate flipXY, > rotation matrix and negFlipXY. This allows the driver to optimize for > the minimum instructions for rotation. > > Bug: b/171750979 > Change-Id: I9851ac999d4d35b9f230f796e5445bca0dcb1e77 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2514773 > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Ian Elliott <ianelliott@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> Bug: b/171750979 Change-Id: I9efde40eb138bacb161cce483a30ec01fee0983b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2533933 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tim Van Patten c3607098 2020-11-11T16:06:51 Revert "Vulkan: Let shader use rotation specialized constant" This reverts commit 47b3db22be33213eea4ad58f2453ee1088324ceb. Reason for revert: Broke the ANGLE roll into Chromium: https://chromium-review.googlesource.com/c/chromium/src/+/2531069 [1875/27343] SOLINK ./libGLESv2.so FAILED: libGLESv2.so libGLESv2.so.TOC /b/s/w/ir/cipd_bin_packages/cpython/bin/python "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libGLESv2.so" --tocfile="./libGLESv2.so.TOC" --output="./libGLESv2.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname="libGLESv2.so" -Wl,--fatal-warnings -Wl,--build-id -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--color-diagnostics -Wl,--no-call-graph-profile-sort -m64 -Werror -nostdlib++ --sysroot=../../build/linux/debian_sid_amd64-sysroot -L../../build/linux/debian_sid_amd64-sysroot/usr/local/lib/x86_64-linux-gnu -L../../build/linux/debian_sid_amd64-sysroot/lib/x86_64-linux-gnu -L../../build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu -Wl,-rpath=\$ORIGIN -Wl,--export-dynamic -Wl,-rpath=\$ORIGIN -o "./libGLESv2.so" @"./libGLESv2.so.rsp" ld.lld: error: undefined symbol: sh::TranslatorVulkan::GetDriverUniformFlipXYRef(sh::TVariable const*) >>> referenced by RewriteDfdy.cpp:134 (../../third_party/angle/src/compiler/translator/tree_ops/RewriteDfdy.cpp:134) >>> translator/RewriteDfdy.o:(sh::(anonymous namespace)::Traverser::visitUnaryWithRotation(sh::Visit, sh::TIntermUnary*)) in archive obj/third_party/angle/libtranslator.a >>> referenced by RewriteDfdy.cpp:200 (../../third_party/angle/src/compiler/translator/tree_ops/RewriteDfdy.cpp:200) >>> translator/RewriteDfdy.o:(sh::(anonymous namespace)::Traverser::visitUnaryWithoutRotation(sh::Visit, sh::TIntermUnary*)) in archive obj/third_party/angle/libtranslator.a ld.lld: error: undefined symbol: sh::TranslatorVulkan::GetDriverUniformFragRotationMatrixRef(sh::TVariable const*) >>> referenced by RewriteDfdy.cpp:136 (../../third_party/angle/src/compiler/translator/tree_ops/RewriteDfdy.cpp:136) >>> translator/RewriteDfdy.o:(sh::(anonymous namespace)::Traverser::visitUnaryWithRotation(sh::Visit, sh::TIntermUnary*)) in archive obj/third_party/angle/libtranslator.a clang: error: linker command failed with exit code 1 (use -v to see invocation) Original change's description: > Vulkan: Let shader use rotation specialized constant > > If use rotation specialized constant is enabled via compiler options, > this CL will use rotation specialized constant to generate flipXY, > rotation matrix and negFlipXY. This allows the driver to optimize for > the minimum instructions for rotation. > > Bug: b/171750979 > Change-Id: I9851ac999d4d35b9f230f796e5445bca0dcb1e77 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2514773 > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Ian Elliott <ianelliott@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> TBR=ianelliott@google.com,timvp@google.com,syoussefi@chromium.org,jmadill@chromium.org,cclao@google.com Change-Id: Id3976259d1f4049aa62b679ad5b25c2ac337c92b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: b/171750979 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2532702 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Charlie Lao 47b3db22 2020-11-02T12:25:32 Vulkan: Let shader use rotation specialized constant If use rotation specialized constant is enabled via compiler options, this CL will use rotation specialized constant to generate flipXY, rotation matrix and negFlipXY. This allows the driver to optimize for the minimum instructions for rotation. Bug: b/171750979 Change-Id: I9851ac999d4d35b9f230f796e5445bca0dcb1e77 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2514773 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Le Hoang Quyen cbd5bee8 2020-07-13T20:31:29 Disable shader's pre-rotation code on Metal & non-Android. Pre-rotation code were added to transform gl_Position, gl_FragCoords, gl_PointCoords, dFdX, dFdY in shader. However, it is only useful for android's surface pre-rotation and completely un-needed in Metal back-end. This CL disables these pre-rotation code if the platform is not android. Bug: angleproject:4678 Change-Id: I89c42fcf24b49896f4ed9c2f9465da521beaf25f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2295000 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Ian Elliott 11d7b952 2020-06-02T16:58:26 Vulkan: Pre-rotate dFdx() & dFdy() for Android Test: angle_deqp_gles3_tests --gtest_filter=dEQP.GLES3/functional_shaders_derivate Test: angle_end2end_tests --gtest_filter=*EGLPreRotationSurfaceTest.OrientedWindow Bug: b/157476241 Change-Id: I7b60b7a33313ba91731755d289792bd0968515c6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2222825 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Ian Elliott 4d7a3993 2020-05-27T14:08:20 Vulkan: Rotate gl_PointCoord for Android pre-rotation This extends the current y-flip that's done for gl_PointCoord. Now, gl_PointCoord is rotated and then flips both the x and y-axis (similar to gl_FragCoord). The tests used to reproduce the problem and the fix are: angle_deqp_gles2_tests --local-output --gtest_filter=dEQP.GLES2/functional_shaders_builtin_variable_pointcoord* --use-angle=vulkan angle_end2end_tests --local-output --gtest_filter=*GLSLTest.PointCoordConsistency*Vulkan* Bug: b/157476696 Change-Id: Iada8680eda8322f7382ff242e4a9422a66114f07 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2216700 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 472c74c6 2019-08-19T16:32:13 Translator: Allow tree validation in children of TCompiler This is to be able to perform validation inside TranslatorVulkan, even if it's through ASSERTs. Additionally, every transformation is changed such that they do their validation themselves. TIntermTraverser::updateTree() performs the validation, which indirectly validates many of three tree transformations. Some of the more ancient transformations that don't use this function directly call TCompiler::validateAST. Bug: angleproject:2733 Change-Id: Ie4af029d34e053c5ad1dc8c2c2568eecd625d344 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1761149 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 17f26865 2019-08-22T22:11:39 Vulkan: Fix missing deepCopy() from dFdy transform Bug: angleproject:2733 Change-Id: Id1375618e6d91eb1d577abf2f8c707a63ab17b57 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1767364 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 6d37651a 2019-06-26T13:13:09 Vulkan: dFdy is incorrect when the framebuffer is flipped To account for framebuffer flipping, `dFdy()` expressions must be changed to: dFdy() * ANGLEUniforms.viewportYScale Bug: angleproject:3487 Test: dEQP-GLES3.functional.shaders.derivate.dfdy.* Change-Id: I38f25ba37fb8c5ae61cee5ac911df88ec4a93fef Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1678404 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>