diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2022-09-19 16:12:56 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-19 16:12:56 -0300 |
| commit | da75a9a6ea89787c551b20e068a2bed8a8dc4f92 (patch) | |
| tree | 812f5d63819c0b4ab2e27d1256c0d7c37ac53813 /Ryujinx.Graphics.OpenGL/Pipeline.cs | |
| parent | 41790aa7434a5e6d132fad2e24844d450378205b (diff) | |
OpenGL: Fix blit from non-multisample to multisample texture (#3596)
* OpenGL: Fix blit from non-multisample to multisample texture
* New approach for multisample copy using compute shaders
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Pipeline.cs')
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/Pipeline.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index d7cd6fbd..5f224625 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -11,6 +11,8 @@ namespace Ryujinx.Graphics.OpenGL { class Pipeline : IPipeline, IDisposable { + private const int SavedImages = 2; + private readonly DrawTextureEmulation _drawTexture; internal ulong DrawCount { get; private set; } @@ -46,6 +48,7 @@ namespace Ryujinx.Graphics.OpenGL private Vector4<float>[] _renderScale = new Vector4<float>[73]; private int _fragmentScaleCount; + private (TextureBase, Format)[] _images; private TextureBase _unit0Texture; private Sampler _unit0Sampler; @@ -78,6 +81,8 @@ namespace Ryujinx.Graphics.OpenGL _fragmentOutputMap = uint.MaxValue; _componentMasks = uint.MaxValue; + _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); @@ -907,6 +912,11 @@ namespace Ryujinx.Graphics.OpenGL public void SetImage(int binding, ITexture texture, Format imageFormat) { + if ((uint)binding < SavedImages) + { + _images[binding] = (texture as TextureBase, imageFormat); + } + if (texture == null) { return; @@ -1608,6 +1618,32 @@ namespace Ryujinx.Graphics.OpenGL } } + public void RestoreProgram() + { + _program?.Bind(); + } + + public void RestoreImages1And2() + { + for (int i = 0; i < SavedImages; i++) + { + (TextureBase texBase, Format imageFormat) = _images[i]; + + if (texBase != null) + { + SizedInternalFormat format = FormatTable.GetImageFormat(imageFormat); + + if (format != 0) + { + GL.BindImageTexture(i, texBase.Handle, 0, true, 0, TextureAccess.ReadWrite, format); + continue; + } + } + + GL.BindImageTexture(i, 0, 0, true, 0, TextureAccess.ReadWrite, SizedInternalFormat.Rgba8); + } + } + public bool TryHostConditionalRendering(ICounterEvent value, ulong compare, bool isEqual) { if (value is CounterQueueEvent) |
