diff --git a/src/Ryujinx.Graphics.Gpu/Image/BitMap.cs b/src/Ryujinx.Graphics.Gpu/Image/BitMap.cs
index d901610a8..b1287b87a 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/BitMap.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/BitMap.cs
@@ -1,4 +1,5 @@
using System.Numerics;
+using System.Threading;
namespace Ryujinx.Graphics.Gpu.Image
{
@@ -139,35 +140,12 @@ namespace Ryujinx.Graphics.Gpu.Image
public void BeginIterating()
{
_iterIndex = 0;
- _iterMask = _masks.Length != 0 ? _masks[0] : 0;
- }
+ _iterMask = 0UL;
- ///
- /// Gets the next bit set to 1.
- ///
- /// Index of the bit, or -1 if none found
- public int GetNext()
- {
- if (_iterIndex >= _masks.Length)
+ if (_masks.Length != 0)
{
- return -1;
+ _iterMask = Interlocked.Exchange(ref _masks[0], 0UL);
}
-
- while (_iterMask == 0 && _iterIndex + 1 < _masks.Length)
- {
- _iterMask = _masks[++_iterIndex];
- }
-
- if (_iterMask == 0)
- {
- return -1;
- }
-
- int bit = BitOperations.TrailingZeroCount(_iterMask);
-
- _iterMask &= ~(1UL << bit);
-
- return _iterIndex * IntSize + bit;
}
///
@@ -181,23 +159,19 @@ namespace Ryujinx.Graphics.Gpu.Image
return -1;
}
- ulong mask = _masks[_iterIndex];
-
- while (mask == 0 && _iterIndex + 1 < _masks.Length)
+ while (_iterMask == 0 && _iterIndex + 1 < _masks.Length)
{
- mask = _masks[++_iterIndex];
+ _iterMask = Interlocked.Exchange(ref _masks[++_iterIndex], 0UL);
}
- if (mask == 0)
+ if (_iterMask == 0)
{
return -1;
}
- int bit = BitOperations.TrailingZeroCount(mask);
+ int bit = BitOperations.TrailingZeroCount(_iterMask);
- mask &= ~(1UL << bit);
-
- _masks[_iterIndex] = mask;
+ _iterMask &= ~(1UL << bit);
return _iterIndex * IntSize + bit;
}
diff --git a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs
index 6d883658e..7c9a1c61a 100644
--- a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs
+++ b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs
@@ -505,7 +505,7 @@ namespace Ryujinx.Graphics.Shader.Translation
Operand id = context.BitwiseAnd(nvHandle, Const(0xfffff));
Operand tableIndex = context.ShiftRightU32(id, Const(8));
Operand scaleIndex = context.Load(StorageKind.ConstantBuffer, bindlessTableBinding, Const(0), tableIndex, Const(0));
- Operand scale = context.Load(StorageKind.ConstantBuffer, bindlessScalesBinding, Const(0), scaleIndex);
+ Operand scale = context.Load(StorageKind.StorageBuffer, bindlessScalesBinding, Const(0), scaleIndex);
return scale;
}