aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-11-19 11:41:45 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit3ca675223a495f7d0a9d2130b8d88d9c5c79747e (patch)
tree72b36c06b9429be939f084e91a942516e42165d8
parent6a8ba6d60080ca15fc25a6812998b19e63171610 (diff)
Remove TranslatorConfig struct
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs10
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Constants.cs2
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs2
-rw-r--r--Ryujinx.Graphics.Shader/ShaderConfig.cs3
-rw-r--r--Ryujinx.Graphics.Shader/Translation/TranslationConfig.cs25
-rw-r--r--Ryujinx.Graphics.Shader/Translation/Translator.cs16
-rw-r--r--Ryujinx.ShaderTools/Program.cs4
7 files changed, 14 insertions, 48 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 3fdd28b9..dd40bb72 100644
--- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -197,11 +197,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
TranslationFlags.DebugMode |
TranslationFlags.Unspecialized;
- TranslationConfig translationConfig = new TranslationConfig(0x10000, _dumper.CurrentDumpIndex, flags);
-
Span<byte> code = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize);
- program = Translator.Translate(code, translationConfig);
+ program = Translator.Translate(code, flags);
int[] codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();
@@ -233,8 +231,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
TranslationFlags.DebugMode |
TranslationFlags.Unspecialized;
- TranslationConfig translationConfig = new TranslationConfig(0x10000, _dumper.CurrentDumpIndex, flags);
-
int[] codeCached = null;
if (gpuVaA != 0)
@@ -242,7 +238,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
Span<byte> codeA = _context.MemoryAccessor.Read(gpuVaA, MaxProgramSize);
Span<byte> codeB = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize);
- program = Translator.Translate(codeA, codeB, translationConfig);
+ program = Translator.Translate(codeA, codeB, flags);
// TODO: We should also check "codeA" into account.
codeCached = MemoryMarshal.Cast<byte, int>(codeB.Slice(0, program.Size)).ToArray();
@@ -262,7 +258,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
Span<byte> code = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize);
- program = Translator.Translate(code, translationConfig);
+ program = Translator.Translate(code, flags);
codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Constants.cs b/Ryujinx.Graphics.Shader/CodeGen/Constants.cs
index 10c22c60..59e9f145 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Constants.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Constants.cs
@@ -3,5 +3,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen
static class Constants
{
public const int MaxShaderStorageBuffers = 16;
+
+ public const int ConstantBufferSize = 0x10000; // In bytes
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
index a8cabaaf..e8b44961 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
@@ -210,7 +210,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
context.EnterScope();
- string ubSize = "[" + NumberFormatter.FormatInt(context.Config.MaxCBufferSize / 16) + "]";
+ string ubSize = "[" + NumberFormatter.FormatInt(Constants.ConstantBufferSize / 16) + "]";
context.AppendLine("vec4 " + OperandManager.GetUbName(context.Config.Stage, cbufSlot) + ubSize + ";");
diff --git a/Ryujinx.Graphics.Shader/ShaderConfig.cs b/Ryujinx.Graphics.Shader/ShaderConfig.cs
index 6ab4689a..3583fa64 100644
--- a/Ryujinx.Graphics.Shader/ShaderConfig.cs
+++ b/Ryujinx.Graphics.Shader/ShaderConfig.cs
@@ -8,7 +8,6 @@ namespace Ryujinx.Graphics.Shader
public TranslationFlags Flags { get; }
- public int MaxCBufferSize { get; }
public int MaxOutputVertices { get; }
public OutputTopology OutputTopology { get; }
@@ -16,13 +15,11 @@ namespace Ryujinx.Graphics.Shader
public ShaderConfig(
ShaderStage stage,
TranslationFlags flags,
- int maxCBufferSize,
int maxOutputVertices,
OutputTopology outputTopology)
{
Stage = stage;
Flags = flags;
- MaxCBufferSize = maxCBufferSize;
MaxOutputVertices = maxOutputVertices;
OutputTopology = outputTopology;
}
diff --git a/Ryujinx.Graphics.Shader/Translation/TranslationConfig.cs b/Ryujinx.Graphics.Shader/Translation/TranslationConfig.cs
deleted file mode 100644
index e5fa6d14..00000000
--- a/Ryujinx.Graphics.Shader/Translation/TranslationConfig.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-
-namespace Ryujinx.Graphics.Shader.Translation
-{
- public struct TranslationConfig
- {
- public int MaxCBufferSize { get; }
-
- public int Version { get; }
-
- public TranslationFlags Flags { get; }
-
- public TranslationConfig(int maxCBufferSize, int version, TranslationFlags flags)
- {
- if (maxCBufferSize <= 0)
- {
- throw new ArgumentOutOfRangeException(nameof(maxCBufferSize));
- }
-
- MaxCBufferSize = maxCBufferSize;
- Version = version;
- Flags = flags;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs
index 2f33997c..9c1eb08e 100644
--- a/Ryujinx.Graphics.Shader/Translation/Translator.cs
+++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs
@@ -48,10 +48,10 @@ namespace Ryujinx.Graphics.Shader.Translation
return code.Slice(0, headerSize + (int)endAddress);
}
- public static ShaderProgram Translate(Span<byte> code, TranslationConfig translationConfig)
+ public static ShaderProgram Translate(Span<byte> code, TranslationFlags flags)
{
- bool compute = (translationConfig.Flags & TranslationFlags.Compute) != 0;
- bool debugMode = (translationConfig.Flags & TranslationFlags.DebugMode) != 0;
+ bool compute = (flags & TranslationFlags.Compute) != 0;
+ bool debugMode = (flags & TranslationFlags.DebugMode) != 0;
Operation[] ops = DecodeShader(
code,
@@ -83,25 +83,23 @@ namespace Ryujinx.Graphics.Shader.Translation
ShaderConfig config = new ShaderConfig(
stage,
- translationConfig.Flags,
- translationConfig.MaxCBufferSize,
+ flags,
maxOutputVertexCount,
outputTopology);
return Translate(ops, config, size);
}
- public static ShaderProgram Translate(Span<byte> vpACode, Span<byte> vpBCode, TranslationConfig translationConfig)
+ public static ShaderProgram Translate(Span<byte> vpACode, Span<byte> vpBCode, TranslationFlags flags)
{
- bool debugMode = (translationConfig.Flags & TranslationFlags.DebugMode) != 0;
+ bool debugMode = (flags & TranslationFlags.DebugMode) != 0;
Operation[] vpAOps = DecodeShader(vpACode, compute: false, debugMode, out _, out _);
Operation[] vpBOps = DecodeShader(vpBCode, compute: false, debugMode, out ShaderHeader header, out int sizeB);
ShaderConfig config = new ShaderConfig(
header.Stage,
- translationConfig.Flags,
- translationConfig.MaxCBufferSize,
+ flags,
header.MaxOutputVertexCount,
header.OutputTopology);
diff --git a/Ryujinx.ShaderTools/Program.cs b/Ryujinx.ShaderTools/Program.cs
index c0afa4f1..6fa043a3 100644
--- a/Ryujinx.ShaderTools/Program.cs
+++ b/Ryujinx.ShaderTools/Program.cs
@@ -19,9 +19,7 @@ namespace Ryujinx.ShaderTools
byte[] data = File.ReadAllBytes(args[args.Length - 1]);
- TranslationConfig translationConfig = new TranslationConfig(0x10000, 0, flags);
-
- string code = Translator.Translate(data, translationConfig).Code;
+ string code = Translator.Translate(data, flags).Code;
Console.WriteLine(code);
}