mirror of
https://github.com/Ryujinx-NX/Ryujinx.git
synced 2024-11-14 13:07:41 -07:00
Remove TranslatorConfig struct
This commit is contained in:
parent
6a8ba6d600
commit
3ca675223a
@ -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();
|
||||
|
||||
|
@ -3,5 +3,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen
|
||||
static class Constants
|
||||
{
|
||||
public const int MaxShaderStorageBuffers = 16;
|
||||
|
||||
public const int ConstantBufferSize = 0x10000; // In bytes
|
||||
}
|
||||
}
|
@ -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 + ";");
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user