aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/Shader
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-08-19 22:25:26 -0300
committergdkchan <gab.dark.100@gmail.com>2018-08-19 22:25:26 -0300
commit726de8c46ab10f1b0684fe14bca1ca96ba6d2832 (patch)
tree5da68699e9062f1c01ef3da9d9eceb75657b2f93 /Ryujinx.Graphics/Gal/Shader
parent056c2840b1851657c3855fb72776837c89ff59d3 (diff)
Rendertarget attachments, texture and image changes (#358)
* Add multiple color outputs for fragment shaders * Add registers and gal enums * Use textures for framebuffers and split color and zeta framebuffers * Abstract texture and framebuffer targets as an image * Share images between framebuffers and textures * Unstub formats * Add some formats * Disable multiple attachments * Cache framebuffer attachments * Handle format types * Add some rendertarget formats * Code cleanup * Fixup half float types * Address feedback * Disable multiple attachments in shaders * Add A4B4G4R4 image format * Add reversed section for image enums
Diffstat (limited to 'Ryujinx.Graphics/Gal/Shader')
-rw-r--r--Ryujinx.Graphics/Gal/Shader/GlslDecl.cs7
-rw-r--r--Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs11
2 files changed, 13 insertions, 5 deletions
diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs
index ccc59e04..56745bc1 100644
--- a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs
+++ b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs
@@ -16,6 +16,7 @@ namespace Ryujinx.Graphics.Gal.Shader
public const int VertexIdAttr = 0x2fc;
public const int FaceAttr = 0x3fc;
+ public const int MaxFrameBufferAttachments = 8;
public const int MaxUboSize = 1024;
public const int GlPositionVec4Index = 7;
@@ -99,7 +100,11 @@ namespace Ryujinx.Graphics.Gal.Shader
if (ShaderType == GalShaderType.Fragment)
{
- m_Gprs.Add(0, new ShaderDeclInfo(FragmentOutputName, 0, false, 0, 4));
+ //Note: Replace 1 with MaxFrameBufferAttachments when attachments start to work
+ for (int Index = 0; Index < 1; Index++)
+ {
+ m_Gprs.Add(Index * 4, new ShaderDeclInfo(FragmentOutputName + Index, Index * 4, false, 0, 4));
+ }
}
foreach (ShaderIrBlock Block in Blocks)
diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs
index 7f1cfabc..72637984 100644
--- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs
+++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs
@@ -352,9 +352,9 @@ namespace Ryujinx.Graphics.Gal.Shader
{
Name = CustomType + " " + DeclInfo.Name + Suffix + ";";
}
- else if (DeclInfo.Name == GlslDecl.FragmentOutputName)
+ else if (DeclInfo.Name.Contains(GlslDecl.FragmentOutputName))
{
- Name = "layout (location = 0) out vec4 " + DeclInfo.Name + Suffix + ";" + Environment.NewLine;
+ Name = "layout (location = " + DeclInfo.Index / 4 + ") out vec4 " + DeclInfo.Name + Suffix + ";";
}
else
{
@@ -829,8 +829,11 @@ namespace Ryujinx.Graphics.Gal.Shader
{
return "gl_PointSize";
}
+ }
- throw new InvalidOperationException();
+ if (DeclInfo.Index >= 16)
+ {
+ throw new InvalidOperationException($"Shader attribute offset {Abuf.Offs} is invalid.");
}
if (Decl.ShaderType == GalShaderType.Geometry)
@@ -876,7 +879,7 @@ namespace Ryujinx.Graphics.Gal.Shader
private string GetNameWithSwizzle(IReadOnlyDictionary<int, ShaderDeclInfo> Dict, int Index)
{
- int VecIndex = Index >> 2;
+ int VecIndex = Index & ~3;
if (Dict.TryGetValue(VecIndex, out ShaderDeclInfo DeclInfo))
{