From 3bd357045f7581ee10d6c86ed8049bcebe35eda0 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 16 Feb 2022 19:15:39 -0300 Subject: Do not allow render targets not explicitly written by the fragment shader to be modified (#3063) * Do not allow render targets not explicitly written by the fragment shader to be modified * Shader cache version bump * Remove blank lines * Avoid redundant color mask updates * HostShaderCacheEntry can be null * Avoid more redundant glColorMask calls * nit: Mask -> Masks * Fix currentComponentMask * More efficient way to update _currentComponentMasks --- Ryujinx.Graphics.OpenGL/Program.cs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'Ryujinx.Graphics.OpenGL/Program.cs') diff --git a/Ryujinx.Graphics.OpenGL/Program.cs b/Ryujinx.Graphics.OpenGL/Program.cs index 95902990..838162cc 100644 --- a/Ryujinx.Graphics.OpenGL/Program.cs +++ b/Ryujinx.Graphics.OpenGL/Program.cs @@ -1,11 +1,8 @@ using OpenTK.Graphics.OpenGL; using Ryujinx.Common.Logging; using Ryujinx.Graphics.GAL; -using Ryujinx.Graphics.Shader.CodeGen.Glsl; using System; using System.Buffers.Binary; -using System.Collections.Generic; -using System.Linq; namespace Ryujinx.Graphics.OpenGL { @@ -29,7 +26,10 @@ namespace Ryujinx.Graphics.OpenGL private ProgramLinkStatus _status = ProgramLinkStatus.Incomplete; private IShader[] _shaders; - public Program(IShader[] shaders) + public bool HasFragmentShader; + public int FragmentOutputMap { get; } + + public Program(IShader[] shaders, int fragmentOutputMap) { Handle = GL.CreateProgram(); @@ -37,17 +37,23 @@ namespace Ryujinx.Graphics.OpenGL for (int index = 0; index < shaders.Length; index++) { - int shaderHandle = ((Shader)shaders[index]).Handle; + Shader shader = (Shader)shaders[index]; - GL.AttachShader(Handle, shaderHandle); + if (shader.IsFragment) + { + HasFragmentShader = true; + } + + GL.AttachShader(Handle, shader.Handle); } GL.LinkProgram(Handle); _shaders = shaders; + FragmentOutputMap = fragmentOutputMap; } - public Program(ReadOnlySpan code) + public Program(ReadOnlySpan code, bool hasFragmentShader, int fragmentOutputMap) { BinaryFormat binaryFormat = (BinaryFormat)BinaryPrimitives.ReadInt32LittleEndian(code.Slice(code.Length - 4, 4)); @@ -60,6 +66,9 @@ namespace Ryujinx.Graphics.OpenGL GL.ProgramBinary(Handle, binaryFormat, (IntPtr)ptr, code.Length - 4); } } + + HasFragmentShader = hasFragmentShader; + FragmentOutputMap = fragmentOutputMap; } public void Bind() -- cgit v1.2.3