0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-23 09:15:46 +00:00

Remove TranslatorConfig struct

This commit is contained in:
gdk 2019-11-19 11:41:45 -03:00 committed by Thog
parent 6a8ba6d600
commit 3ca675223a
7 changed files with 14 additions and 48 deletions

View file

@ -197,11 +197,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
TranslationFlags.DebugMode | TranslationFlags.DebugMode |
TranslationFlags.Unspecialized; TranslationFlags.Unspecialized;
TranslationConfig translationConfig = new TranslationConfig(0x10000, _dumper.CurrentDumpIndex, flags);
Span<byte> code = _context.MemoryAccessor.Read(gpuVa, MaxProgramSize); 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(); int[] codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();
@ -233,8 +231,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
TranslationFlags.DebugMode | TranslationFlags.DebugMode |
TranslationFlags.Unspecialized; TranslationFlags.Unspecialized;
TranslationConfig translationConfig = new TranslationConfig(0x10000, _dumper.CurrentDumpIndex, flags);
int[] codeCached = null; int[] codeCached = null;
if (gpuVaA != 0) if (gpuVaA != 0)
@ -242,7 +238,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
Span<byte> codeA = _context.MemoryAccessor.Read(gpuVaA, MaxProgramSize); Span<byte> codeA = _context.MemoryAccessor.Read(gpuVaA, MaxProgramSize);
Span<byte> codeB = _context.MemoryAccessor.Read(gpuVa, 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. // TODO: We should also check "codeA" into account.
codeCached = MemoryMarshal.Cast<byte, int>(codeB.Slice(0, program.Size)).ToArray(); 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); 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(); codeCached = MemoryMarshal.Cast<byte, int>(code.Slice(0, program.Size)).ToArray();

View file

@ -3,5 +3,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen
static class Constants static class Constants
{ {
public const int MaxShaderStorageBuffers = 16; public const int MaxShaderStorageBuffers = 16;
public const int ConstantBufferSize = 0x10000; // In bytes
} }
} }

View file

@ -210,7 +210,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
context.EnterScope(); 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 + ";"); context.AppendLine("vec4 " + OperandManager.GetUbName(context.Config.Stage, cbufSlot) + ubSize + ";");

View file

@ -8,7 +8,6 @@ namespace Ryujinx.Graphics.Shader
public TranslationFlags Flags { get; } public TranslationFlags Flags { get; }
public int MaxCBufferSize { get; }
public int MaxOutputVertices { get; } public int MaxOutputVertices { get; }
public OutputTopology OutputTopology { get; } public OutputTopology OutputTopology { get; }
@ -16,13 +15,11 @@ namespace Ryujinx.Graphics.Shader
public ShaderConfig( public ShaderConfig(
ShaderStage stage, ShaderStage stage,
TranslationFlags flags, TranslationFlags flags,
int maxCBufferSize,
int maxOutputVertices, int maxOutputVertices,
OutputTopology outputTopology) OutputTopology outputTopology)
{ {
Stage = stage; Stage = stage;
Flags = flags; Flags = flags;
MaxCBufferSize = maxCBufferSize;
MaxOutputVertices = maxOutputVertices; MaxOutputVertices = maxOutputVertices;
OutputTopology = outputTopology; OutputTopology = outputTopology;
} }

View file

@ -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;
}
}
}

View file

@ -48,10 +48,10 @@ namespace Ryujinx.Graphics.Shader.Translation
return code.Slice(0, headerSize + (int)endAddress); 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 compute = (flags & TranslationFlags.Compute) != 0;
bool debugMode = (translationConfig.Flags & TranslationFlags.DebugMode) != 0; bool debugMode = (flags & TranslationFlags.DebugMode) != 0;
Operation[] ops = DecodeShader( Operation[] ops = DecodeShader(
code, code,
@ -83,25 +83,23 @@ namespace Ryujinx.Graphics.Shader.Translation
ShaderConfig config = new ShaderConfig( ShaderConfig config = new ShaderConfig(
stage, stage,
translationConfig.Flags, flags,
translationConfig.MaxCBufferSize,
maxOutputVertexCount, maxOutputVertexCount,
outputTopology); outputTopology);
return Translate(ops, config, size); 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[] vpAOps = DecodeShader(vpACode, compute: false, debugMode, out _, out _);
Operation[] vpBOps = DecodeShader(vpBCode, compute: false, debugMode, out ShaderHeader header, out int sizeB); Operation[] vpBOps = DecodeShader(vpBCode, compute: false, debugMode, out ShaderHeader header, out int sizeB);
ShaderConfig config = new ShaderConfig( ShaderConfig config = new ShaderConfig(
header.Stage, header.Stage,
translationConfig.Flags, flags,
translationConfig.MaxCBufferSize,
header.MaxOutputVertexCount, header.MaxOutputVertexCount,
header.OutputTopology); header.OutputTopology);

View file

@ -19,9 +19,7 @@ namespace Ryujinx.ShaderTools
byte[] data = File.ReadAllBytes(args[args.Length - 1]); byte[] data = File.ReadAllBytes(args[args.Length - 1]);
TranslationConfig translationConfig = new TranslationConfig(0x10000, 0, flags); string code = Translator.Translate(data, flags).Code;
string code = Translator.Translate(data, translationConfig).Code;
Console.WriteLine(code); Console.WriteLine(code);
} }