aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation/UInt128.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2022-03-06 16:42:13 -0300
committerGitHub <noreply@github.com>2022-03-06 20:42:13 +0100
commit0bcbe32367eeada2a5aa7e6bb2edccc22cababa3 (patch)
tree08b9ac95b8db21a5f505493fdf099c7d80da0c4a /Ryujinx.Graphics.Shader/Translation/UInt128.cs
parentb97ff4da5eb67b68400fa1c187524f53407dbb71 (diff)
Only initialize shader outputs that are actually used on the next stage (#3054)
* Only initialize shader outputs that are actually used on the next stage * Shader cache version bump
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/UInt128.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/UInt128.cs74
1 files changed, 74 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/UInt128.cs b/Ryujinx.Graphics.Shader/Translation/UInt128.cs
new file mode 100644
index 00000000..590f7690
--- /dev/null
+++ b/Ryujinx.Graphics.Shader/Translation/UInt128.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Numerics;
+
+namespace Ryujinx.Graphics.Shader.Translation
+{
+ struct UInt128 : IEquatable<UInt128>
+ {
+ public static UInt128 Zero => new UInt128() { _v0 = 0, _v1 = 0 };
+
+ private ulong _v0;
+ private ulong _v1;
+
+ public int TrailingZeroCount()
+ {
+ int count = BitOperations.TrailingZeroCount(_v0);
+ if (count == 64)
+ {
+ count += BitOperations.TrailingZeroCount(_v1);
+ }
+
+ return count;
+ }
+
+ public static UInt128 Pow2(int x)
+ {
+ if (x >= 64)
+ {
+ return new UInt128() { _v0 = 0, _v1 = 1UL << (x - 64 ) };
+ }
+
+ return new UInt128() { _v0 = 1UL << x, _v1 = 0 };
+ }
+
+ public static UInt128 operator ~(UInt128 x)
+ {
+ return new UInt128() { _v0 = ~x._v0, _v1 = ~x._v1 };
+ }
+
+ public static UInt128 operator &(UInt128 x, UInt128 y)
+ {
+ return new UInt128() { _v0 = x._v0 & y._v0, _v1 = x._v1 & y._v1 };
+ }
+
+ public static UInt128 operator |(UInt128 x, UInt128 y)
+ {
+ return new UInt128() { _v0 = x._v0 | y._v0, _v1 = x._v1 | y._v1 };
+ }
+
+ public static bool operator ==(UInt128 x, UInt128 y)
+ {
+ return x.Equals(y);
+ }
+
+ public static bool operator !=(UInt128 x, UInt128 y)
+ {
+ return !x.Equals(y);
+ }
+
+ public override bool Equals(object obj)
+ {
+ return obj is UInt128 other && Equals(other);
+ }
+
+ public bool Equals(UInt128 other)
+ {
+ return _v0 == other._v0 && _v1 == other._v1;
+ }
+
+ public override int GetHashCode()
+ {
+ return HashCode.Combine(_v0, _v1);
+ }
+ }
+} \ No newline at end of file