forked from Mirror/Ryujinx
Use dispatch params shared memory size when available
This commit is contained in:
parent
0d9672f3ae
commit
66d91cbc6c
5 changed files with 19 additions and 5 deletions
|
@ -22,6 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
|
||||
ComputeShader cs = _shaderCache.GetComputeShader(
|
||||
shaderGpuVa,
|
||||
dispatchParams.SharedMemorySize & 0xffff,
|
||||
dispatchParams.UnpackBlockSizeX(),
|
||||
dispatchParams.UnpackBlockSizeY(),
|
||||
dispatchParams.UnpackBlockSizeZ());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue