From 8dbcae1ff88927dc0734d5f0e24fbf8781d68590 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 26 Jul 2020 00:03:40 -0300 Subject: Implement BGRA texture support (#1418) * Implement BGRA texture support * Missing AppendLine * Remove empty lines * Address PR feedback --- Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs | 6 ++++++ Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs | 2 ++ Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'Ryujinx.Graphics.Shader/CodeGen') diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index efd30143..40e277e0 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -139,6 +139,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl if (context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) { + if (context.Config.Stage == ShaderStage.Fragment) + { + context.AppendLine($"uniform bool {DefaultNames.IsBgraName}[8];"); + context.AppendLine(); + } + if (DeclareRenderScale(context)) { context.AppendLine(); diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs index 4da38b2d..d1cf4636 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs @@ -23,5 +23,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl public const string SharedMemoryName = "shared_mem"; public const string UndefinedName = "undef"; + + public const string IsBgraName = "is_bgra"; } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs index 8801fc11..4ae9a00a 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs @@ -64,6 +64,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { AttributeConsts.GtMask, new BuiltInAttribute("unpackUint2x32(gl_SubGroupGtMaskARB).x", VariableType.U32) }, { AttributeConsts.LeMask, new BuiltInAttribute("unpackUint2x32(gl_SubGroupLeMaskARB).x", VariableType.U32) }, { AttributeConsts.LtMask, new BuiltInAttribute("unpackUint2x32(gl_SubGroupLtMaskARB).x", VariableType.U32) }, + + // Support uniforms. + { AttributeConsts.FragmentOutputIsBgraBase + 0, new BuiltInAttribute($"{DefaultNames.IsBgraName}[0]", VariableType.Bool) }, + { AttributeConsts.FragmentOutputIsBgraBase + 4, new BuiltInAttribute($"{DefaultNames.IsBgraName}[1]", VariableType.Bool) }, + { AttributeConsts.FragmentOutputIsBgraBase + 8, new BuiltInAttribute($"{DefaultNames.IsBgraName}[2]", VariableType.Bool) }, + { AttributeConsts.FragmentOutputIsBgraBase + 12, new BuiltInAttribute($"{DefaultNames.IsBgraName}[3]", VariableType.Bool) }, + { AttributeConsts.FragmentOutputIsBgraBase + 16, new BuiltInAttribute($"{DefaultNames.IsBgraName}[4]", VariableType.Bool) }, + { AttributeConsts.FragmentOutputIsBgraBase + 20, new BuiltInAttribute($"{DefaultNames.IsBgraName}[5]", VariableType.Bool) }, + { AttributeConsts.FragmentOutputIsBgraBase + 24, new BuiltInAttribute($"{DefaultNames.IsBgraName}[6]", VariableType.Bool) }, + { AttributeConsts.FragmentOutputIsBgraBase + 28, new BuiltInAttribute($"{DefaultNames.IsBgraName}[7]", VariableType.Bool) } }; private Dictionary _locals; @@ -149,8 +159,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl char swzMask = GetSwizzleMask((value >> 2) & 3); - if (value >= AttributeConsts.UserAttributeBase && - value < AttributeConsts.UserAttributeEnd) + if (value >= AttributeConsts.UserAttributeBase && value < AttributeConsts.UserAttributeEnd) { value -= AttributeConsts.UserAttributeBase; @@ -169,8 +178,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl } else { - if (value >= AttributeConsts.FragmentOutputColorBase && - value < AttributeConsts.FragmentOutputColorEnd) + if (value >= AttributeConsts.FragmentOutputColorBase && value < AttributeConsts.FragmentOutputColorEnd) { value -= AttributeConsts.FragmentOutputColorBase; -- cgit v1.2.3