Fix bindless scales using wrong buffer type, and a infinite loop updating bindless

This commit is contained in:
Gabriel A 2023-11-18 12:31:30 -03:00
parent 3beb7a5461
commit 13fe92d91c
2 changed files with 10 additions and 36 deletions

View file

@ -1,4 +1,5 @@
using System.Numerics; using System.Numerics;
using System.Threading;
namespace Ryujinx.Graphics.Gpu.Image namespace Ryujinx.Graphics.Gpu.Image
{ {
@ -139,35 +140,12 @@ namespace Ryujinx.Graphics.Gpu.Image
public void BeginIterating() public void BeginIterating()
{ {
_iterIndex = 0; _iterIndex = 0;
_iterMask = _masks.Length != 0 ? _masks[0] : 0; _iterMask = 0UL;
}
/// <summary> if (_masks.Length != 0)
/// 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) _iterMask = Interlocked.Exchange(ref _masks[0], 0UL);
{
return -1;
} }
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;
} }
/// <summary> /// <summary>
@ -181,23 +159,19 @@ namespace Ryujinx.Graphics.Gpu.Image
return -1; return -1;
} }
ulong mask = _masks[_iterIndex]; while (_iterMask == 0 && _iterIndex + 1 < _masks.Length)
while (mask == 0 && _iterIndex + 1 < _masks.Length)
{ {
mask = _masks[++_iterIndex]; _iterMask = Interlocked.Exchange(ref _masks[++_iterIndex], 0UL);
} }
if (mask == 0) if (_iterMask == 0)
{ {
return -1; return -1;
} }
int bit = BitOperations.TrailingZeroCount(mask); int bit = BitOperations.TrailingZeroCount(_iterMask);
mask &= ~(1UL << bit); _iterMask &= ~(1UL << bit);
_masks[_iterIndex] = mask;
return _iterIndex * IntSize + bit; return _iterIndex * IntSize + bit;
} }

View file

@ -505,7 +505,7 @@ namespace Ryujinx.Graphics.Shader.Translation
Operand id = context.BitwiseAnd(nvHandle, Const(0xfffff)); Operand id = context.BitwiseAnd(nvHandle, Const(0xfffff));
Operand tableIndex = context.ShiftRightU32(id, Const(8)); Operand tableIndex = context.ShiftRightU32(id, Const(8));
Operand scaleIndex = context.Load(StorageKind.ConstantBuffer, bindlessTableBinding, Const(0), tableIndex, Const(0)); 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; return scale;
} }