Workaround for AMD and Intel view format bug (#1050)

* Workaround for Intel view format bug

* Dispose of the intermmediate texture aswell

* Apply workaround on AMD aswell
This commit is contained in:
gdkchan 2020-03-29 09:48:39 -03:00 committed by GitHub
parent 5c1757f7c2
commit b18ef8e3a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 222 additions and 119 deletions

View file

@ -10,9 +10,13 @@ namespace Ryujinx.Graphics.OpenGL
private FramebufferAttachment _lastDsAttachment;
private readonly TextureView[] _colors;
public Framebuffer()
{
Handle = GL.GenFramebuffer();
_colors = new TextureView[8];
}
public void Bind()
@ -22,11 +26,19 @@ namespace Ryujinx.Graphics.OpenGL
public void AttachColor(int index, TextureView color)
{
GL.FramebufferTexture(
FramebufferTarget.Framebuffer,
FramebufferAttachment.ColorAttachment0 + index,
color?.Handle ?? 0,
0);
FramebufferAttachment attachment = FramebufferAttachment.ColorAttachment0 + index;
if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.Amd ||
HwCapabilities.Vendor == HwCapabilities.GpuVendor.Intel)
{
GL.FramebufferTexture(FramebufferTarget.Framebuffer, attachment, color?.GetIncompatibleFormatViewHandle() ?? 0, 0);
_colors[index] = color;
}
else
{
GL.FramebufferTexture(FramebufferTarget.Framebuffer, attachment, color?.Handle ?? 0, 0);
}
}
public void AttachDepthStencil(TextureView depthStencil)
@ -68,6 +80,21 @@ namespace Ryujinx.Graphics.OpenGL
}
}
public void SignalModified()
{
if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.Amd ||
HwCapabilities.Vendor == HwCapabilities.GpuVendor.Intel)
{
for (int i = 0; i < 8; i++)
{
if (_colors[i] != null)
{
_colors[i].SignalModified();
}
}
}
}
public void SetDrawBuffers(int colorsCount)
{
DrawBuffersEnum[] drawBuffers = new DrawBuffersEnum[colorsCount];