src/common/mathutil_unittest.cpp


Log

Author Commit Date CI Message
Mohan Maiya 3bdbfbf8 2022-03-25T16:34:51 Vulkan: Adjust border color Some border color tests used to fail due to either unclamped color values or not accounting for depth, stencil or luma formats. We now adjust the border color value according to the sampler's format. Test: dEQP-GLES31.functional.texture.border_clamp.* Bug: angleproject:3577 Bug: angleproject:6213 Change-Id: Ib38ce2374622bfafde69fe3fa2d7227d60043954 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3551895 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill cfc21345 2021-04-21T09:42:51 Add first() and last() to BitSetArray. These helper functions return the bounds of the 1 bits in the array. Also required implementing ScanReverse the same way we implemented ScanForward. Bug: angleproject:5736 Change-Id: Ied945c57cd85ca7bc91dcc7a1168a74b3a59fce4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2842347 Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Carl Woffenden 679d1187 2021-01-12T18:25:39 Fix to build with VS2019 When building with VS2019 (using is_clang=false) multiples of the following error are given: ../../src/common/mathutil.cpp(75): error C4244: '=': conversion from 'double' to 'float', possible loss of data (This is due to pow(), when passed an int for the second param, widens the first param to a double then returns a double). Since the code was being changed the opportunity was taken to: - add missing unit tests for the two 999E5 conversions - optimise out the common pow() functions The unit tests were written against the original implementation, then the optimisations added and verified against the original results. Bug: angleproject:5521, dawn:602 Change-Id: Ic9e5eaedbe3fc7ceeed697898823b76dffcd989a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2624888 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tobin Ehlis d7276586 2020-08-26T11:27:13 Vulkan:Use roundUpPow2 where possible Utility function roundUpPow2 is more optimal than roundUp so use it. Bug: b/166462979 Change-Id: I616fa9f487b818137b1b496d93e292c3bd1f428c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2377119 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
Alexey Knyazev 31e36a63 2020-03-14T21:40:58 Reland "Refactor BitCount" This is a reland of baecb7d55c692a93a29a46939029b8262174ca62 Directly use NEON instructions on ARM/ARM64 on MSVC. Original change's description: > Refactor BitCount > > POPCNT intrinsics cannot be used without hardware support, so a CPUID > check and polyfills are required for some CPUs when using MSVC to > avoid runtime failure. > > Other changes include: > - Clang: use builtins on all platforms to provide exact intent to the > compiler; > - MSVC on ARM: use dedicated intrinsics; > - x86/x64 fallback is now branchless and works in constant time. > > Bug: angleproject:4462 > Change-Id: I00fcabda1c842677d8cb4bfd280d932d0d10c0a5 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2102811 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Geoff Lang <geofflang@chromium.org> Bug: angleproject:4462 Change-Id: Ia58ae00fa4230f77d981d4ba393fa3481806c5b0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2113570 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 26f8f1a9 2020-03-20T14:54:11 Revert "Refactor BitCount" This reverts commit baecb7d55c692a93a29a46939029b8262174ca62. Reason for revert: Broke Skia Win/ARM builder. See issue for details. Original change's description: > Refactor BitCount > > POPCNT intrinsics cannot be used without hardware support, so a CPUID > check and polyfills are required for some CPUs when using MSVC to > avoid runtime failure. > > Other changes include: > - Clang: use builtins on all platforms to provide exact intent to the > compiler; > - MSVC on ARM: use dedicated intrinsics; > - x86/x64 fallback is now branchless and works in constant time. > > Bug: angleproject:4462 > Change-Id: I00fcabda1c842677d8cb4bfd280d932d0d10c0a5 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2102811 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Geoff Lang <geofflang@chromium.org> TBR=geofflang@chromium.org,jmadill@chromium.org,lexa.knyazev@gmail.com Change-Id: Ia1756abdf7da2aa9574149eb388915f97758bba0 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:4462 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2112276 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Alexey Knyazev baecb7d5 2020-03-14T21:40:58 Refactor BitCount POPCNT intrinsics cannot be used without hardware support, so a CPUID check and polyfills are required for some CPUs when using MSVC to avoid runtime failure. Other changes include: - Clang: use builtins on all platforms to provide exact intent to the compiler; - MSVC on ARM: use dedicated intrinsics; - x86/x64 fallback is now branchless and works in constant time. Bug: angleproject:4462 Change-Id: I00fcabda1c842677d8cb4bfd280d932d0d10c0a5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2102811 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Alexey Knyazev e6519445 2020-03-12T19:02:03 Implement ScanForward64 on 32-bit platforms This unlocks opt-in usage of BitSet64 on 32-bit platforms. It is slightly faster than IterableBitSet when the amount of bits is greater than 32. Bug: angleproject:4473 Change-Id: I230784acc871e13b1f94c87503f6bb869dcd3a68 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2100969 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Tim Van Patten db990834 2019-06-26T16:05:02 Support NaN conversion in Float32ToFloat16 Add NaN support to Float32ToFloat16. This follows Dawn's implementation: https://dawn-review.googlesource.com/c/dawn/+/8361 Bug: 3612 Test: angle_unittests Change-Id: I624bee2fc48c46b8a69cd38654679ac3cbd7c09f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1678407 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill ba319ba3 2018-12-29T10:29:33 Re-land "Load entry points dynamically in tests and samples." Fixes the Android/ChromeOS/Fuchsia builds by using consistent EGL headers. This CL adds a dynamic loader generator based on XML files. It also refactors the entry point generation script to move the XML parsing into a helper class. Additionally this includes a new GLES 1.0 base header. The new header allows for function pointer types and hiding prototypes. All tests and samples now load ANGLE dynamically. In the future this will be extended to load entry points from the driver directly when possible. This will allow us to perform more accurate A/B testing. The new build configuration leads to some tests having more warnings applied. The CL includes fixes for the new warnings. Bug: angleproject:2995 Change-Id: I5a8772f41a0f89570b3736b785f44b7de1539b57 Reviewed-on: https://chromium-review.googlesource.com/c/1392382 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Yuly Novikov 9f088621 2018-12-29T20:46:15 Revert "Load entry points dynamically in tests and samples." This reverts commit 03923558a7103827ffec6a4d2a1453ed91f01c6f. Reason for revert: fails compilation on Android, ChromeOS and Fuchsia during roll https://chromium-review.googlesource.com/c/chromium/src/+/1392624 Original change's description: > Load entry points dynamically in tests and samples. > > This CL adds a dynamic loader generator based on XML files. It also > refactors the entry point generation script to move the XML parsing > into a helper class. > > Additionally this includes a new GLES 1.0 base header. The new > header allows for function pointer types and hiding prototypes. > > All tests and samples now load ANGLE dynamically. In the future this > will be extended to load entry points from the driver directly when > possible. This will allow us to perform more accurate A/B testing. > > The new build configuration leads to some tests having more warnings > applied. The CL includes fixes for the new warnings. > > Bug: angleproject:2995 > Change-Id: I6726d4163f7a6e54d2482f094c0a952f59702a05 > Reviewed-on: https://chromium-review.googlesource.com/c/1359516 > Commit-Queue: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> TBR=ynovikov@chromium.org,jmadill@chromium.org,syoussefi@chromium.org Change-Id: I902bec2d733c2b879be29c02ab52a0b7d4eaa077 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:2995 Reviewed-on: https://chromium-review.googlesource.com/c/1392381 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Jamie Madill 03923558 2018-12-29T10:29:33 Load entry points dynamically in tests and samples. This CL adds a dynamic loader generator based on XML files. It also refactors the entry point generation script to move the XML parsing into a helper class. Additionally this includes a new GLES 1.0 base header. The new header allows for function pointer types and hiding prototypes. All tests and samples now load ANGLE dynamically. In the future this will be extended to load entry points from the driver directly when possible. This will allow us to perform more accurate A/B testing. The new build configuration leads to some tests having more warnings applied. The CL includes fixes for the new warnings. Bug: angleproject:2995 Change-Id: I6726d4163f7a6e54d2482f094c0a952f59702a05 Reviewed-on: https://chromium-review.googlesource.com/c/1359516 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Yuly Novikov c4f1dd83 2017-10-25T17:02:29 Use angle::BitSetIterator optimizations on arm64 as well Previously were enabled only on x86_64. Also change from using target_cpu to current_cpu, as the doc recommends. BUG=angleproject:1814 Change-Id: Ia7e8e930c76aab5cfb47b75e0ec78902ab313237 Reviewed-on: https://chromium-review.googlesource.com/737438 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Jamie Madill 982f6e01 2017-06-07T14:33:04 Improvements to the gl::Range class. Make this a proper class, fix the extends method (previously did not work as expected), add a contains method, and add tests. Also add an iterator helper class so we can iterate over the range with range-for loops. This also fixes the shader resource unsetting code, which was not actually unsetting all the possible applied textures. BUG=angleproject:2052 Change-Id: I2a6fa97f96ccb612ad01a5e3f24dc869c54c967b Reviewed-on: https://chromium-review.googlesource.com/527318 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 6de51858 2017-04-12T09:53:01 Optimize angle::BitSetIterator. Adds a new custom bitset template to handle packing as many bits as possible into a single variable. Intelligently select the right class depending on platform features and bit sizes. For now, always use a packed 64-bit set on 64-bit, instead of using a 32-bit set for smaller bitsets. BUG=angleproject:1814 Change-Id: I3ffef815c15515555833f6fc9302d8a4eee5423b Reviewed-on: https://chromium-review.googlesource.com/471827 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 74da73fe 2017-02-01T15:37:48 Add ESSL 3.10 ldexp/frexp builtins This adds new built-ins found in ESSL 3.10 section 8.3 Common Functions. This includes constant folding support for ldexp and support for both GLSL and HLSL output. In HLSL these functions need to be emulated. BUG=angleproject:1730 TEST=angle_unittests Change-Id: I1330e69978b0cf53efbc3416150194764414e96c Reviewed-on: https://chromium-review.googlesource.com/435342 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 25aef453 2017-01-29T16:15:44 Add new ESSL 3.10 pack/unpack builtins This adds new built-ins found in ESSL 3.10 section 8.4 Floating-Point Pack and Unpack Functions. This includes constant folding support and support for both GLSL and HLSL output. In HLSL all of these functions need to be emulated. BUG=angleproject:1730 TEST=angle_unittests TEST=dEQP-GLES31.functional.shaders.*pack*norm4x8* Change-Id: Ibed60286a366cd35c4faafd405e79af562a02a06 Reviewed-on: https://chromium-review.googlesource.com/434170 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 9250cb24 2017-01-21T10:51:27 Add ESSL 3.10 integer math built-ins This adds built-ins found in ESSL 3.10 section 8.8 Integer functions. This includes constant folding support for functions that may be constant folded, and support for both GLSL and HLSL output. In HLSL several of the functions need to be emulated. The precision qualification for the return value of some of these functions is determined by special rules, that are now part of type promotion for TIntermUnary nodes and determining the type of TIntermAggregate nodes. BUG=angleproject:1730 TEST=angle_unittests TEST=dEQP-GLES31.functional.shaders.builtin_functions.integer.* Change-Id: Ib0056c17671c42b6496c2f0ef059b99f8f25c122 Reviewed-on: https://chromium-review.googlesource.com/431310 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill e2e406c3 2016-06-02T13:04:10 Add base::numerics for safe math and conversions. This replaces are "IsUnsignedXXXSafe" family of methods. Also add overflow checks to unpack block sizes. BUG=angleproject:1397 Change-Id: Ib47be149b0486c70f795b0d0f8899441faac9340 Reviewed-on: https://chromium-review.googlesource.com/348062 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 0f2b1560 2016-05-13T16:15:35 Fix GenerateMipmap when base level or max level are set According to GLES 3.0.4 section 3.8.10, GenerateMipmap should generate levels based on the base level, and generate them at most up to the max level. Levels outside the base/max level range should be unchanged by GenerateMipmap. The Texture class is fixed so that the image descs are set only for the changed mipmap range when GenerateMipmap is called. The D3D backend is fixed so that mipmap generation is correctly started from the base level instead of level 0, and making sure that mipmaps are generated only up to the max level. Generating mipmaps for array textures is also fixed for cases where the base level depth >= max(width, height) * 2. The GL backend is fixed to sync texture state before GenerateMipmap is called, so that base level and max level are set correctly in the driver. The GenerateMipmap entry point is refactored so that it has a separate validation function and a context function which does the work. Validation for out-of-range base levels is added. New tests are added to verify the functionality. One corner case in the tests fails on NVIDIA GL drivers likely due to a driver bug - similar rules for GenerateMipmap are found from newer GLES specs and also OpenGL specs (checked versions 3.3 and 4.4). BUG=angleproject:596 TEST=angle_end2end_tests Change-Id: Ifc7b4126281967fc4f6dc4f9452e5b01e39f83d7 Reviewed-on: https://chromium-review.googlesource.com/344514 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Arun Patole 551279e5 2015-07-07T18:18:23 Support constant folding of more common built-ins This change adds const folding support for below mentioned common built-ins: - isnan, ininf, floatBitsToInt, floatBitsToUint, intBitsToFloat and uintBitsToFloat BUG=angleproject:913 TEST=angle_unittests(new: MathUtilTest.isNan/inInf), dEQP Tests dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.common.* (20 more tests started passing with this change) Change-Id: Ifdedb251cd8b183b4999314c0f5de857bc20702f Reviewed-on: https://chromium-review.googlesource.com/283767 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Arun Patole cdfa8f50 2015-06-30T17:48:25 Constant fold float pack/unpack functions This change adds constant folding support for following floating point pack and unpack functions: - packSnorm2x16, unpackSnorm2x16, packUnorm2x16, unpackUnorm2x16, packHalf2x16, and unpackHalf2x16. BUG=angleproject:913 TEST=angle_unittests(new: MathUtilTest.packAndUnpack*), dEQP Tests dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions.float_pack_unpack.* (all 10 tests started passing with this change) Change-Id: I2b69faebee4127e5e13900b3a9485b7145950277 Reviewed-on: https://chromium-review.googlesource.com/282683 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>