Archived
1
0
Fork 0
forked from Mirror/Ryujinx

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> /// <summary>
/// Version of the codegen (to be changed when codegen or guest format change). /// Version of the codegen (to be changed when codegen or guest format change).
/// </summary> /// </summary>
private const ulong ShaderCodeGenVersion = 2546; private const ulong ShaderCodeGenVersion = 2605;
// Progress reporting helpers // Progress reporting helpers
private volatile int _shaderCount; 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 maxThreadId = minThreadId | (clamp & ~segMask);
uint srcThreadId = (index & ~segMask) | minThreadId; uint srcThreadId = (index & ~segMask) | minThreadId;
valid = srcThreadId <= maxThreadId; 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 maxThreadId = minThreadId | (clamp & ~segMask);
uint srcThreadId = gl_SubGroupInvocationARB + index; uint srcThreadId = gl_SubGroupInvocationARB + index;
valid = srcThreadId <= maxThreadId; 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) float Helper_ShuffleUp(float x, uint index, uint mask, out bool valid)
{ {
uint clamp = mask & 0x1fu;
uint segMask = (mask >> 8) & 0x1fu; uint segMask = (mask >> 8) & 0x1fu;
uint minThreadId = gl_SubGroupInvocationARB & segMask; uint minThreadId = gl_SubGroupInvocationARB & segMask;
uint srcThreadId = gl_SubGroupInvocationARB - index; uint srcThreadId = gl_SubGroupInvocationARB - index;
valid = srcThreadId >= minThreadId; valid = int(srcThreadId) >= int(minThreadId);
return valid ? readInvocationARB(x, srcThreadId) : x; 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 maxThreadId = minThreadId | (clamp & ~segMask);
uint srcThreadId = gl_SubGroupInvocationARB ^ index; uint srcThreadId = gl_SubGroupInvocationARB ^ index;
valid = srcThreadId <= maxThreadId; valid = srcThreadId <= maxThreadId;
return valid ? readInvocationARB(x, srcThreadId) : x; float v = readInvocationARB(x, srcThreadId);
return valid ? v : x;
} }