aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-10-18 20:24:15 -0300
committerGitHub <noreply@github.com>2021-10-18 20:24:15 -0300
commit63f1663fa959d8809d1762d99e9364565ba9b3d8 (patch)
tree4317d6067048cbd912eed16b563b76d6b9ab6cfe /Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions
parent052deebf26beb5e62e677e8d31c2eb024beaa82f (diff)
Fix shader 8-bit and 16-bit STS/STG (#2741)
* Fix 8 and 16-bit STG * Fix 8 and 16-bit STS * Shader cache version bump
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs12
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs4
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs64
3 files changed, 80 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs
index 4c2582f0..4f059149 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs
@@ -185,9 +185,21 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
case Instruction.StoreShared:
return StoreShared(context, operation);
+ case Instruction.StoreShared16:
+ return StoreShared16(context, operation);
+
+ case Instruction.StoreShared8:
+ return StoreShared8(context, operation);
+
case Instruction.StoreStorage:
return StoreStorage(context, operation);
+ case Instruction.StoreStorage16:
+ return StoreStorage16(context, operation);
+
+ case Instruction.StoreStorage8:
+ return StoreStorage8(context, operation);
+
case Instruction.TextureSample:
return TextureSample(context, operation);
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs
index 022cd746..c2d59ff7 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs
@@ -113,7 +113,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
Add(Instruction.StoreAttribute, InstType.Special);
Add(Instruction.StoreLocal, InstType.Special);
Add(Instruction.StoreShared, InstType.Special);
+ Add(Instruction.StoreShared16, InstType.Special);
+ Add(Instruction.StoreShared8, InstType.Special);
Add(Instruction.StoreStorage, InstType.Special);
+ Add(Instruction.StoreStorage16, InstType.Special);
+ Add(Instruction.StoreStorage8, InstType.Special);
Add(Instruction.Subtract, InstType.OpBinary, "-", 2);
Add(Instruction.SwizzleAdd, InstType.CallTernary, HelperFunctionNames.SwizzleAdd);
Add(Instruction.TextureSample, InstType.Special);
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
index 5e46bb46..f976ec5e 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
@@ -365,6 +365,34 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
return $"{arrayName}[{offsetExpr}] = {src}";
}
+ public static string StoreShared16(CodeGenContext context, AstOperation operation)
+ {
+ IAstNode src1 = operation.GetSource(0);
+ IAstNode src2 = operation.GetSource(1);
+
+ string offsetExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
+
+ VariableType srcType = OperandManager.GetNodeDestType(context, src2);
+
+ string src = TypeConversion.ReinterpretCast(context, src2, srcType, VariableType.U32);
+
+ return $"{HelperFunctionNames.StoreShared16}({offsetExpr}, {src})";
+ }
+
+ public static string StoreShared8(CodeGenContext context, AstOperation operation)
+ {
+ IAstNode src1 = operation.GetSource(0);
+ IAstNode src2 = operation.GetSource(1);
+
+ string offsetExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
+
+ VariableType srcType = OperandManager.GetNodeDestType(context, src2);
+
+ string src = TypeConversion.ReinterpretCast(context, src2, srcType, VariableType.U32);
+
+ return $"{HelperFunctionNames.StoreShared8}({offsetExpr}, {src})";
+ }
+
public static string StoreStorage(CodeGenContext context, AstOperation operation)
{
IAstNode src1 = operation.GetSource(0);
@@ -383,6 +411,42 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
return $"{sb} = {src}";
}
+ public static string StoreStorage16(CodeGenContext context, AstOperation operation)
+ {
+ IAstNode src1 = operation.GetSource(0);
+ IAstNode src2 = operation.GetSource(1);
+ IAstNode src3 = operation.GetSource(2);
+
+ string indexExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
+ string offsetExpr = GetSoureExpr(context, src2, GetSrcVarType(operation.Inst, 1));
+
+ VariableType srcType = OperandManager.GetNodeDestType(context, src3);
+
+ string src = TypeConversion.ReinterpretCast(context, src3, srcType, VariableType.U32);
+
+ string sb = GetStorageBufferAccessor(indexExpr, offsetExpr, context.Config.Stage);
+
+ return $"{HelperFunctionNames.StoreStorage16}({indexExpr}, {offsetExpr}, {src})";
+ }
+
+ public static string StoreStorage8(CodeGenContext context, AstOperation operation)
+ {
+ IAstNode src1 = operation.GetSource(0);
+ IAstNode src2 = operation.GetSource(1);
+ IAstNode src3 = operation.GetSource(2);
+
+ string indexExpr = GetSoureExpr(context, src1, GetSrcVarType(operation.Inst, 0));
+ string offsetExpr = GetSoureExpr(context, src2, GetSrcVarType(operation.Inst, 1));
+
+ VariableType srcType = OperandManager.GetNodeDestType(context, src3);
+
+ string src = TypeConversion.ReinterpretCast(context, src3, srcType, VariableType.U32);
+
+ string sb = GetStorageBufferAccessor(indexExpr, offsetExpr, context.Config.Stage);
+
+ return $"{HelperFunctionNames.StoreStorage8}({indexExpr}, {offsetExpr}, {src})";
+ }
+
public static string TextureSample(CodeGenContext context, AstOperation operation)
{
AstTextureOperation texOp = (AstTextureOperation)operation;