aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-02-02 00:25:52 -0300
committerGitHub <noreply@github.com>2020-02-02 14:25:52 +1100
commit796e5d14b4fadc15439d273f8ff8f9e9afc4033a (patch)
treee45cbac1f155d939941bdb0aebeb29222e92abe4 /Ryujinx.Graphics.Shader
parentea14a955243705b5d5b22868c30c174e6524b4d3 (diff)
Use correct shader local memory size instead of a hardcoded size (#914)
* Use correct shader local size instead of a hardcoded size * Remove unused uniform block * Update XML doc * Local memory size has 23 bits on maxwell * Generate compute QMD struct from nv open doc header * Remove dummy arrays when shared or local memory is not used, other improvements
Diffstat (limited to 'Ryujinx.Graphics.Shader')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs34
-rw-r--r--Ryujinx.Graphics.Shader/QueryInfoName.cs1
-rw-r--r--Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs6
3 files changed, 29 insertions, 12 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
index 200569c4..2e7f9f1b 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
@@ -47,25 +47,35 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
context.AppendLine();
}
- context.AppendLine("layout (std140) uniform Extra");
-
- context.EnterScope();
+ if (context.Config.Stage == ShaderStage.Compute)
+ {
+ int localMemorySize = BitUtils.DivRoundUp(context.Config.QueryInfo(QueryInfoName.ComputeLocalMemorySize), 4);
- context.AppendLine("vec2 flip;");
- context.AppendLine("int instance;");
+ if (localMemorySize != 0)
+ {
+ string localMemorySizeStr = NumberFormatter.FormatInt(localMemorySize);
- context.LeaveScope(";");
+ context.AppendLine($"uint {DefaultNames.LocalMemoryName}[{localMemorySizeStr}];");
+ context.AppendLine();
+ }
- context.AppendLine();
+ int sharedMemorySize = BitUtils.DivRoundUp(context.Config.QueryInfo(QueryInfoName.ComputeSharedMemorySize), 4);
- context.AppendLine($"uint {DefaultNames.LocalMemoryName}[0x100];");
- context.AppendLine();
+ if (sharedMemorySize != 0)
+ {
+ string sharedMemorySizeStr = NumberFormatter.FormatInt(sharedMemorySize);
- if (context.Config.Stage == ShaderStage.Compute)
+ context.AppendLine($"shared uint {DefaultNames.SharedMemoryName}[{sharedMemorySizeStr}];");
+ context.AppendLine();
+ }
+ }
+ else if (context.Config.LocalMemorySize != 0)
{
- string size = NumberFormatter.FormatInt(BitUtils.DivRoundUp(context.Config.QueryInfo(QueryInfoName.ComputeSharedMemorySize), 4));
+ int localMemorySize = BitUtils.DivRoundUp(context.Config.LocalMemorySize, 4);
+
+ string localMemorySizeStr = NumberFormatter.FormatInt(localMemorySize);
- context.AppendLine($"shared uint {DefaultNames.SharedMemoryName}[{size}];");
+ context.AppendLine($"uint {DefaultNames.LocalMemoryName}[{localMemorySizeStr}];");
context.AppendLine();
}
diff --git a/Ryujinx.Graphics.Shader/QueryInfoName.cs b/Ryujinx.Graphics.Shader/QueryInfoName.cs
index c4f2cb6c..887c0d7d 100644
--- a/Ryujinx.Graphics.Shader/QueryInfoName.cs
+++ b/Ryujinx.Graphics.Shader/QueryInfoName.cs
@@ -5,6 +5,7 @@ namespace Ryujinx.Graphics.Shader
ComputeLocalSizeX,
ComputeLocalSizeY,
ComputeLocalSizeZ,
+ ComputeLocalMemorySize,
ComputeSharedMemorySize,
IsTextureBuffer,
IsTextureRectangle,
diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
index 8a0f25fe..e3708b41 100644
--- a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
+++ b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
@@ -10,6 +10,8 @@ namespace Ryujinx.Graphics.Shader.Translation
public int MaxOutputVertices { get; }
+ public int LocalMemorySize { get; }
+
public OutputMapTarget[] OmapTargets { get; }
public bool OmapSampleMask { get; }
public bool OmapDepth { get; }
@@ -23,6 +25,7 @@ namespace Ryujinx.Graphics.Shader.Translation
Stage = ShaderStage.Compute;
OutputTopology = OutputTopology.PointList;
MaxOutputVertices = 0;
+ LocalMemorySize = 0;
OmapTargets = null;
OmapSampleMask = false;
OmapDepth = false;
@@ -35,6 +38,7 @@ namespace Ryujinx.Graphics.Shader.Translation
Stage = header.Stage;
OutputTopology = header.OutputTopology;
MaxOutputVertices = header.MaxOutputVertexCount;
+ LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize;
OmapTargets = header.OmapTargets;
OmapSampleMask = header.OmapSampleMask;
OmapDepth = header.OmapDepth;
@@ -80,6 +84,8 @@ namespace Ryujinx.Graphics.Shader.Translation
case QueryInfoName.ComputeLocalSizeY:
case QueryInfoName.ComputeLocalSizeZ:
return 1;
+ case QueryInfoName.ComputeLocalMemorySize:
+ return 0x1000;
case QueryInfoName.ComputeSharedMemorySize:
return 0xc000;
case QueryInfoName.IsTextureBuffer: