Commit Graph

56 Commits

Author SHA1 Message Date
Léo Lam b82b0683d5
MathUtil: Mark IntLog2 as constexpr
Mostly everything else was already marked as constexpr, and the only
function IntLog2 calls (CountLeadingZeros) is already constexpr.
2021-07-06 15:01:38 +02:00
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Léo Lam 48712168b8
MathUtil: Add SaturatingCast to cast floats more safely 2021-04-06 23:27:23 +02:00
MerryMage d695fcb126 BitUtils: Add CountLeadingZeros 2020-12-27 22:56:43 +00:00
Jordan Woyak 1063c4e940 MathUtil: Add Population (vs Sample) versions of Variance and StandardDeviation to RunningVariance. 2020-09-28 18:09:33 -05:00
Léo Lam 07ab79db64 MathUtil: Fix Rectangle::GetWidth/Height for unsigned types
`std::abs(x - y)` where x and y are unsigned integers fails to compile
with an "call of overloaded 'abs(unsigned int)' is ambiguous" error
on GCC, and even if it did compile, that expression still wouldn't
give the correct result since `x - y` is unsigned.
2020-05-03 14:41:58 +02:00
Jordan Woyak 9efcd08ea3 MathUtil: Add RunningMean/RunningVariance classes. 2020-02-17 15:57:43 -06:00
Jordan Woyak 4f47cccd9f Cleanup: Use std::abs instead of abs. 2020-02-08 18:21:14 -06:00
Jordan Woyak 1180c231a6 InputCommon: Detect when evdev exposes acceleration/gyroscope data. 2019-11-09 13:34:29 -06:00
Léo Lam ab9ece9bca Replace MathUtil::Clamp with std::clamp 2019-05-04 23:12:17 +02:00
Jordan Woyak ba1b335118 WiimoteEmu: Improve emulated swing. 2019-04-23 19:02:41 -05:00
Jordan Woyak b9a00a40a9 Common: Move Matrix classes out of MathUtil into their own files and make their interface more friendly. 2019-02-03 11:35:31 -06:00
Jordan Woyak ceb28a2302 Add ability to reshape analog sticks from square/circle to octagon and make the analog stick mapping indicator pretty. 2018-12-27 18:31:46 -06:00
Lioncash ba01f6dba3 CommonFuncs: Convert ROUND_UP_POW2 macro to a function
Also move it to MathUtils where it belongs with the rest of the
power-of-two functions. This gets rid of pollution of the current scope
of any translation unit with b<value> macros that aren't intended to be
used directly.
2018-05-10 19:42:20 -04:00
Lioncash 86018b503b Common: Move floating-point utility functions to FloatUtils.h/.cpp
Keeps all of the floating-point utility functions in their own file to
keep them all together. This also provides a place for other
general-purpose floating-point functions to be added in the future,
which will be necessary when improving the flag-setting within the
interpreter.
2018-05-07 02:56:32 -04:00
Lioncash 79f40fb8d7
MathUtil: Generify IsPow2
This will allow it to also be used in the AArch64 emitter.
2018-03-23 09:50:49 -04:00
Shawn Hoffman e1a3e41bf3 fix various instances of -1 being assigned to unsigned types 2017-06-07 19:52:07 -07:00
MerryMage f7ed979e30 Jit64AsmCommon: Make frsqrte and fres PIE-compliant 2017-04-11 20:25:18 +01:00
Florent Castelli b69d3f13cb common: Don't include intrin.h in a namespace
Fixes compilation with VS2017
2017-03-08 06:55:06 +01:00
Phil Christensen 2ed61b0ee1 C++ conformance fixes (MSVC /permissive-)
We (the Microsoft C++ team) use the dolphin project as part of our "Real world code" tests.
I noticed a few issues in windows specific code when building dolphin with the MSVC compiler
in its conformance mode (/permissive-).  For more information on /permissive- see our blog
https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/.

These changes are to address 3 different types of issues:

1) Use of qualified names in member declarations

    struct A {
        void A::f() { } // error C4596: illegal qualified name in member declaration
                        // remove redundant 'A::' to fix
    };

2) Binding a non-const reference to a temporary

    struct S{};
  
    // If arg is in 'in' parameter, then it should be made const.
    void func(S& arg){}
  
    int main() {
      //error C2664: 'void func(S &)': cannot convert argument 1 from 'S' to 'S &'
      //note: A non-const reference may only be bound to an lvalue
      func( S() );
   
      //Work around this by creating a local, and using it to call the function
      S s;
      func( s );
    }

3) Add missing #include <intrin.h>

Because of the workaround you are using in the code you will need to include
this.  This is because of changes in the libraries and not /permissive-
2017-02-15 20:37:04 -08:00
BhaaL 23d99f2f2c specify custom brace style to fix unions
BreakBeforeBraces: Allman apparently includes all styles,
except for AfterUnion (which is false) when using clang-format -dump-config
2017-01-05 12:55:13 +01:00
Léo Lam 31ccfffd38 Common: Add alignment header
Gets rid of duplicated alignment code.
2016-12-06 20:33:53 +01:00
Pierre Bourdon 3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Lioncash 8d9221a71e MathUtilTest: Fix tests on MSVC - Document compiler bug
MSVC's implementation of numeric_limits currently generates incorrect
signaling NaNs. The resulting values are actually quiet NaNs instead.

This commit is based off of a solution by shuffle2. The only
difference is a template specialization for floats is also added
to cover all bases
2016-04-03 19:16:47 -04:00
mathieui f15ffda5a7 Correct ampersands as well 2016-01-21 21:27:56 +01:00
Lioncash 10c1fd7f38 MathUtil: Make Rectangle constructors and equality operator constexpr 2015-10-20 20:30:36 -04:00
Lioncash 09641ec313 MathUtil: Default initialize Rectangle class data members
Puts Rectangles into a valid state upon creation
2015-10-20 20:30:16 -04:00
Lioncash 3f4852a03d MathUtil: Convert IsPow2 into a constexpr function 2015-09-12 01:26:05 -04:00
Lioncash b9e360df7b MathUtil: Convert Clamp into a constexpr function 2015-09-12 01:18:28 -04:00
Lioncash caec42135d MathUtil: Remove IsNAN and IsINF
These aren't necessary, since the stdlib provides equivalents.
2015-08-21 15:05:43 -04:00
Tillmann Karras 30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00
Tillmann Karras cefcb0ace9 Update license headers to GPLv2+ 2015-05-25 13:22:31 +02:00
magumagu 863a4c9ce0 Fix clamping for rectangles.
Clamping a rectangle correctly requires fully clamping all four
coordinates in the general case.

This should fix issue 6923, sort of; at least, it fixes the part where a
rectangle ends up with a nonsensical height after being clamped.
2015-03-04 17:15:29 -08:00
Jules Blok f6ea293027 VertexShaderManager: Compute stereoscopy projection matrices. 2014-11-23 14:23:41 +01:00
Ryan Houdek 71cb09f1ca Merge pull request #1027 from rohit-n/change-include
Include CommonTypes.h instead of Common.h.
2014-09-10 00:35:16 -05:00
Fiora 94c20db369 Rename Log2 and add IsPow2 to MathUtils for future use
Also remove unused pow2/pow2f functions.
2014-09-08 20:15:45 -07:00
Rohit Nirmal fbc64984ca Include CommonTypes.h instead of Common.h. 2014-09-08 15:39:58 -04:00
Fiora 07e0c917c6 Revert "JIT64: optimize CA calculations" 2014-09-05 10:26:30 -07:00
comex 97420c6ec6 Merge pull request #852 from FioraAeterna/optimizeca
JIT64: optimize CA calculations
2014-09-05 11:52:02 -04:00
comex aa1df21bb6 Merge pull request #947 from FioraAeterna/rsqrte
JIT: implement frsqte
2014-09-05 11:48:00 -04:00
Fiora 1b50f9df14 JIT: implement fres
Mostly a straightforward translation of the interpreter code, with a few
tricksy optimizations and fallbacks for rare paths.
2014-09-03 12:15:30 -07:00
Fiora c72a133206 JIT: implement frsqrte
Mostly a straightforward translation of the interpreter code, with a few
tricksy optimizations and fallbacks for rare paths.
2014-09-03 11:21:04 -07:00
lioncash f69e6ef16f Common: Remove unnecessary define check in Log2 2014-09-03 13:04:48 -04:00
Fiora b51aa4fa89 Rename Log2 and add IsPow2 to MathUtils for future use
Also remove unused pow2/pow2f functions.
2014-09-01 20:41:07 -07:00
Scott Mansell b8695a57da Fix incorrect clamping in SWRenderer.
A previous PR changed a whole lot of min/maxes to std::min/std::max
but made a mistake here and used a templated min which cast it's
arguments to unsigned instead of casting return value.

This resulted in glitchy artifacts in bright areas (See issue 7439)

I rewrote the code to use a proper clamping function so it's cleaner
to read.
2014-07-15 21:15:49 +12:00
Tillmann Karras af525266d4 MathUtil: add constructors to IntFloat/IntDouble 2014-03-24 16:14:22 +01:00
Tillmann Karras 9ef64245fa MathUtil: fix IsQNAN()
The constants were one nibble too short and the lower 51 bits don't
actually have to be zero.
2014-03-09 19:34:58 +01:00
Ryan Houdek 4f02132f93 Make our architecture defines less stupid.
Our defines were never clear between what meant 64bit or x86_64
This makes a clear cut between bitness and architecture.
This commit also has the side effect of bringing up aarch64 compiling support.
2014-03-04 09:36:59 -06:00
degasus 94da4e1aa2 MathUtil: Change Log2 return value to int
Log2(u64) can't be bigger than 63, so there is no need in forcing a 64 bit value.
So just using a common int seems more natural.
2014-02-26 11:37:28 +01:00
Pierre Bourdon 83b7bb64aa Make Common/ mostly IWYU clean (and fix errors in rest of the project detected by this change). 2014-02-22 23:37:29 +01:00