diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index fc4bf778b9..7ad00f32ea 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -145,8 +145,6 @@ namespace Ryujinx.Graphics.Gpu.Shader gpShaders.Shaders[3] = TranslateGraphicsShader(state, ShaderStage.Geometry, addresses.Geometry); gpShaders.Shaders[4] = TranslateGraphicsShader(state, ShaderStage.Fragment, addresses.Fragment); - BackpropQualifiers(gpShaders); - List hostShaders = new List(); for (int stage = 0; stage < gpShaders.Shaders.Length; stage++) @@ -375,45 +373,6 @@ namespace Ryujinx.Graphics.Gpu.Shader return new CachedShader(program, codeCached); } - /// - /// Performs backwards propagation of interpolation qualifiers or later shader stages input, - /// to ealier shader stages output. - /// This is required by older versions of OpenGL (pre-4.3). - /// - /// Graphics shader cached code - private void BackpropQualifiers(GraphicsShader program) - { - ShaderProgram fragmentShader = program.Shaders[4]?.Program; - - bool isFirst = true; - - for (int stage = 3; stage >= 0; stage--) - { - if (program.Shaders[stage] == null) - { - continue; - } - - // We need to iterate backwards, since we do name replacement, - // and it would otherwise replace a subset of the longer names. - for (int attr = 31; attr >= 0; attr--) - { - string iq = fragmentShader?.Info.InterpolationQualifiers[attr].ToGlslQualifier() ?? string.Empty; - - if (isFirst && !string.IsNullOrEmpty(iq)) - { - program.Shaders[stage].Program.Replace($"{DefineNames.OutQualifierPrefixName}{attr}", iq); - } - else - { - program.Shaders[stage].Program.Replace($"{DefineNames.OutQualifierPrefixName}{attr} ", string.Empty); - } - } - - isFirst = false; - } - } - /// /// Gets the primitive topology for the current draw. /// This is required by geometry shaders. diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index a47c461121..fb58f84a6c 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -400,9 +400,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { for (int attr = 0; attr < MaxAttributes; attr++) { - string iq = $"{DefineNames.OutQualifierPrefixName}{attr} "; - - context.AppendLine($"layout (location = {attr}) {iq}out vec4 {DefaultNames.OAttributePrefix}{attr};"); + context.AppendLine($"layout (location = {attr}) out vec4 {DefaultNames.OAttributePrefix}{attr};"); } foreach (int attr in info.OAttributes.OrderBy(x => x).Where(x => x >= MaxAttributes)) diff --git a/Ryujinx.Graphics.Shader/DefineNames.cs b/Ryujinx.Graphics.Shader/DefineNames.cs deleted file mode 100644 index b043049919..0000000000 --- a/Ryujinx.Graphics.Shader/DefineNames.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ryujinx.Graphics.Shader -{ - public static class DefineNames - { - public const string OutQualifierPrefixName = "S_OUT_QUALIFIER"; - } -} \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/InterpolationQualifier.cs b/Ryujinx.Graphics.Shader/InterpolationQualifier.cs index e710427dde..b7a0c1c9a8 100644 --- a/Ryujinx.Graphics.Shader/InterpolationQualifier.cs +++ b/Ryujinx.Graphics.Shader/InterpolationQualifier.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Shader { [Flags] - public enum InterpolationQualifier + enum InterpolationQualifier { None = 0, @@ -17,18 +17,17 @@ namespace Ryujinx.Graphics.Shader FlagsMask = Centroid | Sample } - public static class InterpolationQualifierExtensions + static class InterpolationQualifierExtensions { public static string ToGlslQualifier(this InterpolationQualifier iq) { - string output = string.Empty; - - switch (iq & ~InterpolationQualifier.FlagsMask) + string output = (iq & ~InterpolationQualifier.FlagsMask) switch { - case InterpolationQualifier.Flat: output = "flat"; break; - case InterpolationQualifier.NoPerspective: output = "noperspective"; break; - case InterpolationQualifier.Smooth: output = "smooth"; break; - } + InterpolationQualifier.Flat => "flat", + InterpolationQualifier.NoPerspective => "noperspective", + InterpolationQualifier.Smooth => "smooth", + _ => string.Empty + }; if ((iq & InterpolationQualifier.Centroid) != 0) { diff --git a/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs b/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs index 1ff602a240..d91c96132d 100644 --- a/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs +++ b/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs @@ -10,25 +10,20 @@ namespace Ryujinx.Graphics.Shader public ReadOnlyCollection Textures { get; } public ReadOnlyCollection Images { get; } - public ReadOnlyCollection InterpolationQualifiers { get; } - public bool UsesInstanceId { get; } internal ShaderProgramInfo( - BufferDescriptor[] cBuffers, - BufferDescriptor[] sBuffers, - TextureDescriptor[] textures, - TextureDescriptor[] images, - InterpolationQualifier[] interpolationQualifiers, - bool usesInstanceId) + BufferDescriptor[] cBuffers, + BufferDescriptor[] sBuffers, + TextureDescriptor[] textures, + TextureDescriptor[] images, + bool usesInstanceId) { CBuffers = Array.AsReadOnly(cBuffers); SBuffers = Array.AsReadOnly(sBuffers); Textures = Array.AsReadOnly(textures); Images = Array.AsReadOnly(images); - InterpolationQualifiers = Array.AsReadOnly(interpolationQualifiers); - UsesInstanceId = usesInstanceId; } } diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs index a333db9529..164e10a7cc 100644 --- a/Ryujinx.Graphics.Shader/Translation/Translator.cs +++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs @@ -79,7 +79,6 @@ namespace Ryujinx.Graphics.Shader.Translation program.SBufferDescriptors, program.TextureDescriptors, program.ImageDescriptors, - sInfo.InterpolationQualifiers, sInfo.UsesInstanceId); string glslCode = program.Code;