aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation/Translator.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2019-12-06 19:37:00 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commitcb171f6ebfa7e1aa5721503d1c1115719957932d (patch)
tree20de7fca78819fe436fbde629544aa547f446cc8 /Ryujinx.Graphics.Shader/Translation/Translator.cs
parente25b7c9848b6ec486eb513297b5c536857665c7f (diff)
Support shared color mask, implement more shader instructions
Support shared color masks (used by Nouveau and maybe the NVIDIA driver). Support draw buffers (also required by OpenGL). Support viewport transform disable (disabled for now as it breaks some games). Fix instanced rendering draw being ignored for multi draw. Fix IADD and IADD3 immediate shader encodings, that was not matching some ops. Implement FFMA32I shader instruction. Implement IMAD shader instruction.
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/Translator.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/Translator.cs34
1 files changed, 14 insertions, 20 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs
index b129be93..69e63ae1 100644
--- a/Ryujinx.Graphics.Shader/Translation/Translator.cs
+++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs
@@ -49,15 +49,9 @@ namespace Ryujinx.Graphics.Shader.Translation
public static ShaderProgram Translate(Span<byte> code, ShaderCapabilities capabilities, TranslationFlags flags)
{
- bool compute = (flags & TranslationFlags.Compute) != 0;
- bool debugMode = (flags & TranslationFlags.DebugMode) != 0;
+ bool compute = (flags & TranslationFlags.Compute) != 0;
- Operation[] ops = DecodeShader(
- code,
- compute,
- debugMode,
- out ShaderHeader header,
- out int size);
+ Operation[] ops = DecodeShader(code, capabilities, flags, out ShaderHeader header, out int size);
ShaderStage stage;
@@ -94,8 +88,8 @@ namespace Ryujinx.Graphics.Shader.Translation
{
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);
+ Operation[] vpAOps = DecodeShader(vpACode, capabilities, flags, out _, out _);
+ Operation[] vpBOps = DecodeShader(vpBCode, capabilities, flags, out ShaderHeader header, out int sizeB);
ShaderConfig config = new ShaderConfig(
header.Stage,
@@ -142,23 +136,23 @@ namespace Ryujinx.Graphics.Shader.Translation
}
private static Operation[] DecodeShader(
- Span<byte> code,
- bool compute,
- bool debugMode,
- out ShaderHeader header,
- out int size)
+ Span<byte> code,
+ ShaderCapabilities capabilities,
+ TranslationFlags flags,
+ out ShaderHeader header,
+ out int size)
{
Block[] cfg;
EmitterContext context;
- if (compute)
+ if ((flags & TranslationFlags.Compute) != 0)
{
header = null;
cfg = Decoder.Decode(code, 0);
- context = new EmitterContext(ShaderStage.Compute, header);
+ context = new EmitterContext(ShaderStage.Compute, header, capabilities, flags);
}
else
{
@@ -166,7 +160,7 @@ namespace Ryujinx.Graphics.Shader.Translation
cfg = Decoder.Decode(code, HeaderSize);
- context = new EmitterContext(header.Stage, header);
+ context = new EmitterContext(header.Stage, header, capabilities, flags);
}
if (cfg == null)
@@ -197,7 +191,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
OpCode op = block.OpCodes[opIndex];
- if (debugMode)
+ if ((flags & TranslationFlags.DebugMode) != 0)
{
string instName;
@@ -274,7 +268,7 @@ namespace Ryujinx.Graphics.Shader.Translation
}
}
- size = (int)maxEndAddress + (compute ? 0 : HeaderSize);
+ size = (int)maxEndAddress + (((flags & TranslationFlags.Compute) != 0) ? 0 : HeaderSize);
return context.GetOperations();
}