Skip to content

Commit

Permalink
Fix bindless scales using wrong buffer type, and a infinite loop upda…
Browse files Browse the repository at this point in the history
…ting bindless
  • Loading branch information
gdkchan committed Nov 18, 2023
1 parent 3beb7a5 commit 13fe92d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 36 deletions.
44 changes: 9 additions & 35 deletions src/Ryujinx.Graphics.Gpu/Image/BitMap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using System.Threading;

namespace Ryujinx.Graphics.Gpu.Image
{
Expand Down Expand Up @@ -139,35 +140,12 @@ public int FindFirstUnset()
public void BeginIterating()
{
_iterIndex = 0;
_iterMask = _masks.Length != 0 ? _masks[0] : 0;
}

/// <summary>
/// Gets the next bit set to 1.
/// </summary>
/// <returns>Index of the bit, or -1 if none found</returns>
public int GetNext()
{
if (_iterIndex >= _masks.Length)
{
return -1;
}

while (_iterMask == 0 && _iterIndex + 1 < _masks.Length)
{
_iterMask = _masks[++_iterIndex];
}
_iterMask = 0UL;

if (_iterMask == 0)
if (_masks.Length != 0)
{
return -1;
_iterMask = Interlocked.Exchange(ref _masks[0], 0UL);
}

int bit = BitOperations.TrailingZeroCount(_iterMask);

_iterMask &= ~(1UL << bit);

return _iterIndex * IntSize + bit;
}

/// <summary>
Expand All @@ -181,23 +159,19 @@ public int GetNextAndClear()
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);

mask &= ~(1UL << bit);
int bit = BitOperations.TrailingZeroCount(_iterMask);

_masks[_iterIndex] = mask;
_iterMask &= ~(1UL << bit);

return _iterIndex * IntSize + bit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ private static Operand GetBindlessScale(EmitterContext context, Operand nvHandle
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;
}
Expand Down

0 comments on commit 13fe92d

Please sign in to comment.