Apply workaround on AMD aswell

This commit is contained in:
gdkchan 2020-03-29 00:36:01 -03:00
parent 3072138b34
commit 784d052326
3 changed files with 27 additions and 20 deletions

View file

@ -28,9 +28,10 @@ namespace Ryujinx.Graphics.OpenGL
{
FramebufferAttachment attachment = FramebufferAttachment.ColorAttachment0 + index;
if (HwCapabilities.IsIntelDriver)
if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.Amd ||
HwCapabilities.Vendor == HwCapabilities.GpuVendor.Intel)
{
GL.FramebufferTexture(FramebufferTarget.Framebuffer, attachment, color?.GetIntelWarViewHandle() ?? 0, 0);
GL.FramebufferTexture(FramebufferTarget.Framebuffer, attachment, color?.GetIncompatibleFormatViewHandle() ?? 0, 0);
_colors[index] = color;
}
@ -81,7 +82,8 @@ namespace Ryujinx.Graphics.OpenGL
public void SignalModified()
{
if (HwCapabilities.IsIntelDriver)
if (HwCapabilities.Vendor == HwCapabilities.GpuVendor.Amd ||
HwCapabilities.Vendor == HwCapabilities.GpuVendor.Intel)
{
for (int i = 0; i < 8; i++)
{

View file

@ -10,16 +10,17 @@ namespace Ryujinx.Graphics.OpenGL
private static readonly Lazy<int> _maximumComputeSharedMemorySize = new Lazy<int>(() => GetLimit(All.MaxComputeSharedMemorySize));
private static readonly Lazy<int> _storageBufferOffsetAlignment = new Lazy<int>(() => GetLimit(All.ShaderStorageBufferOffsetAlignment));
private enum GpuVendor
public enum GpuVendor
{
Unknown,
Amd,
Intel,
Nvidia
}
private static readonly Lazy<GpuVendor> _gpuVendor = new Lazy<GpuVendor>(GetGpuVendor);
public static bool IsIntelDriver => _gpuVendor.Value == GpuVendor.Intel;
public static GpuVendor Vendor => _gpuVendor.Value;
public static bool SupportsAstcCompression => _supportsAstcCompression.Value;
public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia;
@ -49,16 +50,20 @@ namespace Ryujinx.Graphics.OpenGL
private static GpuVendor GetGpuVendor()
{
string vendor = GL.GetString(StringName.Vendor);
string vendor = GL.GetString(StringName.Vendor).ToLower();
if (vendor == "NVIDIA Corporation")
if (vendor == "nvidia corporation")
{
return GpuVendor.Nvidia;
}
else if (vendor == "Intel")
else if (vendor == "intel")
{
return GpuVendor.Intel;
}
else if (vendor == "ati technologies inc." || vendor == "advanced micro devices, inc.")
{
return GpuVendor.Amd;
}
else
{
return GpuVendor.Unknown;

View file

@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.OpenGL
private TextureView _emulatedViewParent;
private TextureView _intelWarView;
private TextureView _incompatibleFormatView;
private readonly TextureCreateInfo _info;
@ -125,22 +125,22 @@ namespace Ryujinx.Graphics.OpenGL
}
}
public int GetIntelWarViewHandle()
public int GetIncompatibleFormatViewHandle()
{
// Intel has a bug where the view format is always ignored,
// AMD and Intel has a bug where the view format is always ignored,
// it uses the parent format instead.
// As workaround we create a new texture with the correct
// format, and then do a copy after the draw.
if (_parent.Info.Format != Format)
{
if (_intelWarView == null)
if (_incompatibleFormatView == null)
{
_intelWarView = (TextureView)_renderer.CreateTexture(_info);
_incompatibleFormatView = (TextureView)_renderer.CreateTexture(_info);
}
TextureCopyUnscaled.Copy(_parent.Info, _intelWarView._info, _parent.Handle, _intelWarView.Handle, FirstLayer, 0, FirstLevel, 0);
TextureCopyUnscaled.Copy(_parent.Info, _incompatibleFormatView._info, _parent.Handle, _incompatibleFormatView.Handle, FirstLayer, 0, FirstLevel, 0);
return _intelWarView.Handle;
return _incompatibleFormatView.Handle;
}
return Handle;
@ -148,9 +148,9 @@ namespace Ryujinx.Graphics.OpenGL
public void SignalModified()
{
if (_intelWarView != null)
if (_incompatibleFormatView != null)
{
TextureCopyUnscaled.Copy(_intelWarView._info, _parent.Info, _intelWarView.Handle, _parent.Handle, 0, FirstLayer, 0, FirstLevel);
TextureCopyUnscaled.Copy(_incompatibleFormatView._info, _parent.Info, _incompatibleFormatView.Handle, _parent.Handle, 0, FirstLayer, 0, FirstLevel);
}
}
@ -433,11 +433,11 @@ namespace Ryujinx.Graphics.OpenGL
public void Dispose()
{
if (_intelWarView != null)
if (_incompatibleFormatView != null)
{
_intelWarView.Dispose();
_incompatibleFormatView.Dispose();
_intelWarView = null;
_incompatibleFormatView = null;
}
if (Handle != 0)