1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-10 07:21:43 +00:00

Use dispatch params shared memory size when available

This commit is contained in:
gdkchan 2019-12-09 01:00:56 -03:00 committed by Thog
parent 0d9672f3ae
commit 66d91cbc6c
5 changed files with 19 additions and 5 deletions

View file

@ -22,6 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
ComputeShader cs = _shaderCache.GetComputeShader(
shaderGpuVa,
dispatchParams.SharedMemorySize & 0xffff,
dispatchParams.UnpackBlockSizeX(),
dispatchParams.UnpackBlockSizeY(),
dispatchParams.UnpackBlockSizeZ());

View file

@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
public int Unknown14;
public int Unknown15;
public int Unknown16;
public int Unknown17;
public int SharedMemorySize;
public int BlockSizeX;
public int BlockSizeYZ;
public int UniformBuffersConfig;

View file

@ -32,7 +32,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
_gpPrograms = new Dictionary<ShaderAddresses, List<GraphicsShader>>();
}
public ComputeShader GetComputeShader(ulong gpuVa, int localSizeX, int localSizeY, int localSizeZ)
public ComputeShader GetComputeShader(ulong gpuVa, int sharedMemorySize, int localSizeX, int localSizeY, int localSizeZ)
{
bool isCached = _cpPrograms.TryGetValue(gpuVa, out List<ComputeShader> list);
@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
CachedShader shader = TranslateComputeShader(gpuVa, localSizeX, localSizeY, localSizeZ);
CachedShader shader = TranslateComputeShader(gpuVa, sharedMemorySize, localSizeX, localSizeY, localSizeZ);
IShader hostShader = _context.Renderer.CompileShader(shader.Program);
@ -192,7 +192,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
return false;
}
private CachedShader TranslateComputeShader(ulong gpuVa, int localSizeX, int localSizeY, int localSizeZ)
private CachedShader TranslateComputeShader(ulong gpuVa, int sharedMemorySize, int localSizeX, int localSizeY, int localSizeZ)
{
if (gpuVa == 0)
{
@ -212,6 +212,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
int[] codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();
program.Replace(DefineNames.SharedMemorySize, sharedMemorySize.ToString(CultureInfo.InvariantCulture));
program.Replace(DefineNames.LocalSizeX, localSizeX.ToString(CultureInfo.InvariantCulture));
program.Replace(DefineNames.LocalSizeY, localSizeY.ToString(CultureInfo.InvariantCulture));
program.Replace(DefineNames.LocalSizeZ, localSizeZ.ToString(CultureInfo.InvariantCulture));

View file

@ -75,7 +75,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
if (context.Config.Stage == ShaderStage.Compute)
{
string size = NumberFormatter.FormatInt(context.Config.Capabilities.MaximumComputeSharedMemorySize / 4);
string size;
if ((context.Config.Flags & TranslationFlags.Unspecialized) != 0)
{
size = DefineNames.SharedMemorySize;
}
else
{
size = NumberFormatter.FormatInt(context.Config.Capabilities.MaximumComputeSharedMemorySize / 4);
}
context.AppendLine($"shared uint {DefaultNames.SharedMemoryName}[{size}];");
context.AppendLine();

View file

@ -6,6 +6,8 @@ namespace Ryujinx.Graphics.Shader
public const string OutQualifierPrefixName = "S_OUT_QUALIFIER";
public const string SharedMemorySize = "S_SHARED_MEMORY_SIZE";
public const string LocalSizeX = "S_LOCAL_SIZE_X";
public const string LocalSizeY = "S_LOCAL_SIZE_Y";
public const string LocalSizeZ = "S_LOCAL_SIZE_Z";