1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-04 19:02:01 +00:00

Fix out-of-bounds shader thread shuffle (#2605)

* Fix out-of-bounds shader thread shuffle

* Shader cache version bump
This commit is contained in:
gdkchan 2021-08-30 14:02:40 -03:00 committed by GitHub
parent 82cefc8dd3
commit 416dc8fde4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 7 deletions

View file

@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Version of the codegen (to be changed when codegen or guest format change).
/// </summary>
private const ulong ShaderCodeGenVersion = 2546;
private const ulong ShaderCodeGenVersion = 2605;
// Progress reporting helpers
private volatile int _shaderCount;

View file

@ -6,5 +6,6 @@ float Helper_Shuffle(float x, uint index, uint mask, out bool valid)
uint maxThreadId = minThreadId | (clamp & ~segMask);
uint srcThreadId = (index & ~segMask) | minThreadId;
valid = srcThreadId <= maxThreadId;
return valid ? readInvocationARB(x, srcThreadId) : x;
float v = readInvocationARB(x, srcThreadId);
return valid ? v : x;
}

View file

@ -6,5 +6,6 @@ float Helper_ShuffleDown(float x, uint index, uint mask, out bool valid)
uint maxThreadId = minThreadId | (clamp & ~segMask);
uint srcThreadId = gl_SubGroupInvocationARB + index;
valid = srcThreadId <= maxThreadId;
return valid ? readInvocationARB(x, srcThreadId) : x;
float v = readInvocationARB(x, srcThreadId);
return valid ? v : x;
}

View file

@ -1,9 +1,9 @@
float Helper_ShuffleUp(float x, uint index, uint mask, out bool valid)
{
uint clamp = mask & 0x1fu;
uint segMask = (mask >> 8) & 0x1fu;
uint minThreadId = gl_SubGroupInvocationARB & segMask;
uint srcThreadId = gl_SubGroupInvocationARB - index;
valid = srcThreadId >= minThreadId;
return valid ? readInvocationARB(x, srcThreadId) : x;
valid = int(srcThreadId) >= int(minThreadId);
float v = readInvocationARB(x, srcThreadId);
return valid ? v : x;
}

View file

@ -6,5 +6,6 @@ float Helper_ShuffleXor(float x, uint index, uint mask, out bool valid)
uint maxThreadId = minThreadId | (clamp & ~segMask);
uint srcThreadId = gl_SubGroupInvocationARB ^ index;
valid = srcThreadId <= maxThreadId;
return valid ? readInvocationARB(x, srcThreadId) : x;
float v = readInvocationARB(x, srcThreadId);
return valid ? v : x;
}