diff options
Diffstat (limited to 'src/Ryujinx.Graphics.OpenGL')
14 files changed, 28 insertions, 132 deletions
diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs b/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs index 5daaf8c4..1a130beb 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs @@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects originalInfo.SwizzleB, originalInfo.SwizzleA); - _intermediaryTexture = new TextureStorage(_renderer, info, view.ScaleFactor); + _intermediaryTexture = new TextureStorage(_renderer, info); _intermediaryTexture.CreateDefaultView(); } diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs index c8f17084..93654ac7 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs @@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects if (_textureStorage == null || _textureStorage.Info.Width != view.Width || _textureStorage.Info.Height != view.Height) { _textureStorage?.Dispose(); - _textureStorage = new TextureStorage(_renderer, view.Info, view.ScaleFactor); + _textureStorage = new TextureStorage(_renderer, view.Info); _textureStorage.CreateDefaultView(); } diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs index eede852f..b3f6cb1e 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs @@ -147,8 +147,8 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa SwizzleComponent.Blue, SwizzleComponent.Alpha); - _areaTexture = new TextureStorage(_renderer, areaInfo, 1); - _searchTexture = new TextureStorage(_renderer, searchInfo, 1); + _areaTexture = new TextureStorage(_renderer, areaInfo); + _searchTexture = new TextureStorage(_renderer, searchInfo); var areaTexture = EmbeddedResources.Read("Ryujinx.Graphics.OpenGL/Effects/Textures/SmaaAreaTexture.bin"); var searchTexture = EmbeddedResources.Read("Ryujinx.Graphics.OpenGL/Effects/Textures/SmaaSearchTexture.bin"); @@ -165,11 +165,11 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa if (_outputTexture == null || _outputTexture.Info.Width != view.Width || _outputTexture.Info.Height != view.Height) { _outputTexture?.Dispose(); - _outputTexture = new TextureStorage(_renderer, view.Info, view.ScaleFactor); + _outputTexture = new TextureStorage(_renderer, view.Info); _outputTexture.CreateDefaultView(); - _edgeOutputTexture = new TextureStorage(_renderer, view.Info, view.ScaleFactor); + _edgeOutputTexture = new TextureStorage(_renderer, view.Info); _edgeOutputTexture.CreateDefaultView(); - _blendOutputTexture = new TextureStorage(_renderer, view.Info, view.ScaleFactor); + _blendOutputTexture = new TextureStorage(_renderer, view.Info); _blendOutputTexture.CreateDefaultView(); DeleteShaders(); diff --git a/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs b/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs index 1a08f973..64ee73fb 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs @@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.OpenGL.Image SwizzleComponent.Red, SwizzleComponent.Green, SwizzleComponent.Blue, - SwizzleComponent.Alpha), 1f); + SwizzleComponent.Alpha)); } public void Dispose() diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureBase.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureBase.cs index 2ab9dffb..070a36b5 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureBase.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureBase.cs @@ -11,15 +11,13 @@ namespace Ryujinx.Graphics.OpenGL.Image public int Width => Info.Width; public int Height => Info.Height; - public float ScaleFactor { get; } public Target Target => Info.Target; public Format Format => Info.Format; - public TextureBase(TextureCreateInfo info, float scaleFactor = 1f) + public TextureBase(TextureCreateInfo info) { Info = info; - ScaleFactor = scaleFactor; Handle = GL.GenTexture(); } diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs index bb1911e8..e33940cb 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs @@ -349,7 +349,7 @@ namespace Ryujinx.Graphics.OpenGL.Image public TextureView BgraSwap(TextureView from) { - TextureView to = (TextureView)_renderer.CreateTexture(from.Info, from.ScaleFactor); + TextureView to = (TextureView)_renderer.CreateTexture(from.Info); EnsurePbo(from); diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs index d714caf3..79c6cb68 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs @@ -8,7 +8,6 @@ namespace Ryujinx.Graphics.OpenGL.Image { public ITextureInfo Storage => this; public int Handle { get; private set; } - public float ScaleFactor { get; private set; } public TextureCreateInfo Info { get; } @@ -18,13 +17,12 @@ namespace Ryujinx.Graphics.OpenGL.Image internal ITexture DefaultView { get; private set; } - public TextureStorage(OpenGLRenderer renderer, TextureCreateInfo info, float scaleFactor) + public TextureStorage(OpenGLRenderer renderer, TextureCreateInfo info) { _renderer = renderer; Info = info; Handle = GL.GenTexture(); - ScaleFactor = scaleFactor; CreateImmutableStorage(); } diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs index 21d8e449..f4b1e0da 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs @@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.OpenGL.Image TextureStorage parent, TextureCreateInfo info, int firstLayer, - int firstLevel) : base(info, parent.ScaleFactor) + int firstLevel) : base(info) { _renderer = renderer; _parent = parent; diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index b4c567a8..1ad927ea 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -95,7 +95,7 @@ namespace Ryujinx.Graphics.OpenGL return new Sampler(info); } - public ITexture CreateTexture(TextureCreateInfo info, float scaleFactor) + public ITexture CreateTexture(TextureCreateInfo info) { if (info.Target == Target.TextureBuffer) { @@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.OpenGL } else { - return ResourcePool.GetTextureOrNull(info, scaleFactor) ?? new TextureStorage(this, info, scaleFactor).CreateDefaultView(); + return ResourcePool.GetTextureOrNull(info) ?? new TextureStorage(this, info).CreateDefaultView(); } } @@ -194,9 +194,9 @@ namespace Ryujinx.Graphics.OpenGL ResourcePool.Tick(); } - public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, bool hostReserved) + public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved) { - return _counters.QueueReport(type, resultHandler, _pipeline.DrawCount, hostReserved); + return _counters.QueueReport(type, resultHandler, divisor, _pipeline.DrawCount, hostReserved); } public void Initialize(GraphicsDebugLevel glLogLevel) @@ -210,7 +210,6 @@ namespace Ryujinx.Graphics.OpenGL GL.Arb.MaxShaderCompilerThreads(Math.Min(Environment.ProcessorCount, 8)); } - _pipeline.Initialize(this); _counters.Initialize(_pipeline); // This is required to disable [0, 1] clamping for SNorm outputs on compatibility profiles. diff --git a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs index df618d5b..85f5b113 100644 --- a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -44,9 +44,7 @@ namespace Ryujinx.Graphics.OpenGL private CounterQueueEvent _activeConditionalRender; - private readonly Vector4<int>[] _fpIsBgra = new Vector4<int>[SupportBuffer.FragmentIsBgraCount]; - private readonly Vector4<float>[] _renderScale = new Vector4<float>[73]; - private int _fragmentScaleCount; + private Vector4<int>[] _fpIsBgra = new Vector4<int>[SupportBuffer.FragmentIsBgraCount]; private readonly (TextureBase, Format)[] _images; private TextureBase _unit0Texture; @@ -66,7 +64,6 @@ namespace Ryujinx.Graphics.OpenGL private bool _tfEnabled; private TransformFeedbackPrimitiveType _tfTopology; - private SupportBufferUpdater _supportBuffer; private readonly BufferHandle[] _tfbs; private readonly BufferRange[] _tfbTargets; @@ -84,22 +81,10 @@ namespace Ryujinx.Graphics.OpenGL _images = new (TextureBase, Format)[SavedImages]; - var defaultScale = new Vector4<float> { X = 1f, Y = 0f, Z = 0f, W = 0f }; - new Span<Vector4<float>>(_renderScale).Fill(defaultScale); - _tfbs = new BufferHandle[Constants.MaxTransformFeedbackBuffers]; _tfbTargets = new BufferRange[Constants.MaxTransformFeedbackBuffers]; } - public void Initialize(OpenGLRenderer renderer) - { - _supportBuffer = new SupportBufferUpdater(renderer); - GL.BindBufferBase(BufferRangeTarget.UniformBuffer, 0, Unsafe.As<BufferHandle, int>(ref _supportBuffer.Handle)); - - _supportBuffer.UpdateFragmentIsBgra(_fpIsBgra, 0, SupportBuffer.FragmentIsBgraCount); - _supportBuffer.UpdateRenderScale(_renderScale, 0, SupportBuffer.RenderScaleMaxCount); - } - public void Barrier() { GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits); @@ -684,8 +669,6 @@ namespace Ryujinx.Graphics.OpenGL { if (texture is TextureView view && sampler is Sampler samp) { - _supportBuffer.Commit(); - if (HwCapabilities.SupportsDrawTexture) { GL.NV.DrawTexture( @@ -777,16 +760,6 @@ namespace Ryujinx.Graphics.OpenGL _tfEnabled = false; } - public double GetCounterDivisor(CounterType type) - { - if (type == CounterType.SamplesPassed) - { - return _renderScale[0].X * _renderScale[0].X; - } - - return 1; - } - public void SetAlphaTest(bool enable, float reference, CompareOp op) { if (!enable) @@ -1172,12 +1145,6 @@ namespace Ryujinx.Graphics.OpenGL _rasterizerDiscard = discard; } - public void SetRenderTargetScale(float scale) - { - _renderScale[0].X = scale; - _supportBuffer.UpdateRenderScale(_renderScale, 0, 1); // Just the first element. - } - public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMasks) { _componentMasks = 0; @@ -1194,8 +1161,6 @@ namespace Ryujinx.Graphics.OpenGL { EnsureFramebuffer(); - bool isBgraChanged = false; - for (int index = 0; index < colors.Length; index++) { TextureView color = (TextureView)colors[index]; @@ -1209,18 +1174,12 @@ namespace Ryujinx.Graphics.OpenGL if (_fpIsBgra[index].X != isBgra) { _fpIsBgra[index].X = isBgra; - isBgraChanged = true; RestoreComponentMask(index); } } } - if (isBgraChanged) - { - _supportBuffer.UpdateFragmentIsBgra(_fpIsBgra, 0, SupportBuffer.FragmentIsBgraCount); - } - TextureView depthStencilView = (TextureView)depthStencil; _framebuffer.AttachDepthStencil(depthStencilView); @@ -1411,7 +1370,7 @@ namespace Ryujinx.Graphics.OpenGL _vertexArray.SetVertexBuffers(vertexBuffers); } - public void SetViewports(ReadOnlySpan<Viewport> viewports, bool disableTransform) + public void SetViewports(ReadOnlySpan<Viewport> viewports) { Array.Resize(ref _viewportArray, viewports.Length * 4); Array.Resize(ref _depthRangeArray, viewports.Length * 2); @@ -1450,19 +1409,6 @@ namespace Ryujinx.Graphics.OpenGL GL.ViewportArray(0, viewports.Length, viewportArray); GL.DepthRangeArray(0, viewports.Length, depthRangeArray); - - float disableTransformF = disableTransform ? 1.0f : 0.0f; - if (_supportBuffer.Data.ViewportInverse.W != disableTransformF || disableTransform) - { - float scale = _renderScale[0].X; - _supportBuffer.UpdateViewportInverse(new Vector4<float> - { - X = scale * 2f / viewports[0].Region.Width, - Y = scale * 2f / viewports[0].Region.Height, - Z = 1, - W = disableTransformF - }); - } } public void TextureBarrier() @@ -1552,36 +1498,9 @@ namespace Ryujinx.Graphics.OpenGL return (_boundDrawFramebuffer, _boundReadFramebuffer); } - public void UpdateRenderScale(ReadOnlySpan<float> scales, int totalCount, int fragmentCount) - { - bool changed = false; - - for (int index = 0; index < totalCount; index++) - { - if (_renderScale[1 + index].X != scales[index]) - { - _renderScale[1 + index].X = scales[index]; - changed = true; - } - } - - // Only update fragment count if there are scales after it for the vertex stage. - if (fragmentCount != totalCount && fragmentCount != _fragmentScaleCount) - { - _fragmentScaleCount = fragmentCount; - _supportBuffer.UpdateFragmentRenderScaleCount(_fragmentScaleCount); - } - - if (changed) - { - _supportBuffer.UpdateRenderScale(_renderScale, 0, 1 + totalCount); - } - } - private void PrepareForDispatch() { _unit0Texture?.Bind(0); - _supportBuffer.Commit(); } private void PreDraw(int vertexCount) @@ -1601,7 +1520,6 @@ namespace Ryujinx.Graphics.OpenGL DrawCount++; _unit0Texture?.Bind(0); - _supportBuffer.Commit(); } private void PostDraw() @@ -1752,8 +1670,6 @@ namespace Ryujinx.Graphics.OpenGL public void Dispose() { - _supportBuffer?.Dispose(); - for (int i = 0; i < Constants.MaxTransformFeedbackBuffers; i++) { if (_tfbs[i] != BufferHandle.Null) diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs index ff7e9a3e..1724616e 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs @@ -107,7 +107,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries } } - public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler, ulong lastDrawIndex, bool hostReserved) + public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, bool hostReserved) { CounterQueueEvent result; ulong draws = lastDrawIndex - _current.DrawIndex; @@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries _current.ReserveForHostAccess(); } - _current.Complete(draws > 0, _pipeline.GetCounterDivisor(Type)); + _current.Complete(draws > 0, divisor); _events.Enqueue(_current); _current.OnResult += resultHandler; diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs b/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs index 91554eba..88e8bf91 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs @@ -23,9 +23,9 @@ namespace Ryujinx.Graphics.OpenGL.Queries } } - public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, ulong lastDrawIndex, bool hostReserved) + public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, bool hostReserved) { - return _counterQueues[(int)type].QueueReport(resultHandler, lastDrawIndex, hostReserved); + return _counterQueues[(int)type].QueueReport(resultHandler, divisor, lastDrawIndex, hostReserved); } public void QueueReset(CounterType type) diff --git a/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs b/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs index bba5c5cb..43410c99 100644 --- a/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs +++ b/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs @@ -9,7 +9,6 @@ namespace Ryujinx.Graphics.OpenGL { public TextureCreateInfo Info; public TextureView View; - public float ScaleFactor; public int RemainingFrames; } @@ -42,7 +41,6 @@ namespace Ryujinx.Graphics.OpenGL { Info = view.Info, View = view, - ScaleFactor = view.ScaleFactor, RemainingFrames = DisposedLiveFrames }); } @@ -52,9 +50,8 @@ namespace Ryujinx.Graphics.OpenGL /// Attempt to obtain a texture from the resource cache with the desired parameters. /// </summary> /// <param name="info">The creation info for the desired texture</param> - /// <param name="scaleFactor">The scale factor for the desired texture</param> /// <returns>A TextureView with the description specified, or null if one was not found.</returns> - public TextureView GetTextureOrNull(TextureCreateInfo info, float scaleFactor) + public TextureView GetTextureOrNull(TextureCreateInfo info) { lock (_lock) { @@ -65,11 +62,8 @@ namespace Ryujinx.Graphics.OpenGL foreach (DisposedTexture texture in list) { - if (scaleFactor == texture.ScaleFactor) - { - list.Remove(texture); - return texture.View; - } + list.Remove(texture); + return texture.View; } return null; diff --git a/src/Ryujinx.Graphics.OpenGL/Window.cs b/src/Ryujinx.Graphics.OpenGL/Window.cs index a928772f..a8e6031b 100644 --- a/src/Ryujinx.Graphics.OpenGL/Window.cs +++ b/src/Ryujinx.Graphics.OpenGL/Window.cs @@ -111,12 +111,11 @@ namespace Ryujinx.Graphics.OpenGL GL.Clear(ClearBufferMask.ColorBufferBit); int srcX0, srcX1, srcY0, srcY1; - float scale = viewConverted.ScaleFactor; if (crop.Left == 0 && crop.Right == 0) { srcX0 = 0; - srcX1 = (int)(viewConverted.Width / scale); + srcX1 = viewConverted.Width; } else { @@ -127,7 +126,7 @@ namespace Ryujinx.Graphics.OpenGL if (crop.Top == 0 && crop.Bottom == 0) { srcY0 = 0; - srcY1 = (int)(viewConverted.Height / scale); + srcY1 = viewConverted.Height; } else { @@ -135,14 +134,6 @@ namespace Ryujinx.Graphics.OpenGL srcY1 = crop.Bottom; } - if (scale != 1f) - { - srcX0 = (int)(srcX0 * scale); - srcY0 = (int)(srcY0 * scale); - srcX1 = (int)Math.Ceiling(srcX1 * scale); - srcY1 = (int)Math.Ceiling(srcY1 * scale); - } - float ratioX = crop.IsStretched ? 1.0f : MathF.Min(1.0f, _height * crop.AspectRatioX / (_width * crop.AspectRatioY)); float ratioY = crop.IsStretched ? 1.0f : MathF.Min(1.0f, _width * crop.AspectRatioY / (_height * crop.AspectRatioX)); @@ -408,7 +399,7 @@ namespace Ryujinx.Graphics.OpenGL SwizzleComponent.Alpha); _isBgra = forceBgra; - _upscaledTexture = _renderer.CreateTexture(info, 1) as TextureView; + _upscaledTexture = _renderer.CreateTexture(info) as TextureView; } public void SetScalingFilterLevel(float level) |