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
This commit is contained in:
gdkchan 2022-09-19 16:12:56 -03:00 committed by GitHub
parent 41790aa743
commit da75a9a6ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 329 additions and 156 deletions

View file

@ -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)