diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index 9c39f719..7c626f54 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -76,13 +76,22 @@ namespace Ryujinx.Graphics.OpenGL _componentMasks[index] = 0xf; } - var v4Zero = new Vector4 { X = 0f, Y = 0f, Z = 0f, W = 0f }; - new Span>(_renderScale).Fill(v4Zero); + var defaultScale = new Vector4 { X = 1f, Y = 0f, Z = 0f, W = 0f }; + new Span>(_renderScale).Fill(defaultScale); _tfbs = new BufferHandle[Constants.MaxTransformFeedbackBuffers]; _tfbTargets = new BufferRange[Constants.MaxTransformFeedbackBuffers]; } + public void Initialize() + { + _supportBuffer = Buffer.Create(SupportBuffer.RequiredSize); + GL.BindBufferBase(BufferRangeTarget.UniformBuffer, 0, Unsafe.As(ref _supportBuffer)); + + SetSupportBufferData>(SupportBuffer.FragmentIsBgraOffset, _fpIsBgra, SupportBuffer.FragmentIsBgraCount); + SetSupportBufferData>(SupportBuffer.FragmentRenderScaleOffset, _renderScale, SupportBuffer.RenderScaleMaxCount); + } + public void Barrier() { GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits); @@ -1207,12 +1216,6 @@ namespace Ryujinx.Graphics.OpenGL private void SetSupportBufferData(int offset, ReadOnlySpan data, int count) where T : unmanaged { - if (_supportBuffer == BufferHandle.Null) - { - _supportBuffer = Buffer.Create(SupportBuffer.RequiredSize); - GL.BindBufferBase(BufferRangeTarget.UniformBuffer, 0, Unsafe.As(ref _supportBuffer)); - } - Buffer.SetData(_supportBuffer, offset, MemoryMarshal.Cast(data.Slice(0, count))); } diff --git a/Ryujinx.Graphics.OpenGL/Renderer.cs b/Ryujinx.Graphics.OpenGL/Renderer.cs index 22648fd1..01072176 100644 --- a/Ryujinx.Graphics.OpenGL/Renderer.cs +++ b/Ryujinx.Graphics.OpenGL/Renderer.cs @@ -144,6 +144,7 @@ namespace Ryujinx.Graphics.OpenGL GL.Arb.MaxShaderCompilerThreads(Math.Min(Environment.ProcessorCount, 8)); } + _pipeline.Initialize(); _counters.Initialize(); } diff --git a/Ryujinx.Graphics.Shader/SupportBuffer.cs b/Ryujinx.Graphics.Shader/SupportBuffer.cs index 78f24401..f76d2c92 100644 --- a/Ryujinx.Graphics.Shader/SupportBuffer.cs +++ b/Ryujinx.Graphics.Shader/SupportBuffer.cs @@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Shader public const int ComputeRenderScaleOffset = FragmentRenderScaleOffset + FieldSize; // Skip first scale that is used for the render target // One for the render target, 32 for the textures, and 8 for the images. - private const int RenderScaleMaxCount = 1 + 32 + 8; + public const int RenderScaleMaxCount = 1 + 32 + 8; public const int RequiredSize = FragmentRenderScaleOffset + RenderScaleMaxCount * FieldSize; }