2018-07-19 06:33:27 +01:00
|
|
|
|
using OpenTK.Graphics.OpenGL;
|
2019-03-02 10:50:21 +00:00
|
|
|
|
using Ryujinx.Common.Logging;
|
2018-09-25 23:55:30 +01:00
|
|
|
|
using System;
|
2018-07-19 06:33:27 +01:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gal.OpenGL
|
|
|
|
|
{
|
|
|
|
|
static class OGLExtension
|
|
|
|
|
{
|
2019-03-02 10:50:21 +00:00
|
|
|
|
// Private lazy backing variables
|
2018-09-25 23:55:30 +01:00
|
|
|
|
private static Lazy<bool> s_EnhancedLayouts = new Lazy<bool>(() => HasExtension("GL_ARB_enhanced_layouts"));
|
|
|
|
|
private static Lazy<bool> s_TextureMirrorClamp = new Lazy<bool>(() => HasExtension("GL_EXT_texture_mirror_clamp"));
|
|
|
|
|
private static Lazy<bool> s_ViewportArray = new Lazy<bool>(() => HasExtension("GL_ARB_viewport_array"));
|
2018-07-19 06:33:27 +01:00
|
|
|
|
|
2019-02-28 01:12:24 +00:00
|
|
|
|
private static Lazy<bool> s_NvidiaDriver = new Lazy<bool>(() => IsNvidiaDriver());
|
|
|
|
|
|
2019-03-02 10:50:21 +00:00
|
|
|
|
// Public accessors
|
2018-09-25 23:55:30 +01:00
|
|
|
|
public static bool EnhancedLayouts => s_EnhancedLayouts.Value;
|
|
|
|
|
public static bool TextureMirrorClamp => s_TextureMirrorClamp.Value;
|
|
|
|
|
public static bool ViewportArray => s_ViewportArray.Value;
|
2019-03-02 10:50:21 +00:00
|
|
|
|
|
2019-02-28 01:12:24 +00:00
|
|
|
|
public static bool NvidiaDrvier => s_NvidiaDriver.Value;
|
2018-07-19 06:33:27 +01:00
|
|
|
|
|
|
|
|
|
private static bool HasExtension(string Name)
|
|
|
|
|
{
|
|
|
|
|
int NumExtensions = GL.GetInteger(GetPName.NumExtensions);
|
|
|
|
|
|
|
|
|
|
for (int Extension = 0; Extension < NumExtensions; Extension++)
|
|
|
|
|
{
|
|
|
|
|
if (GL.GetString(StringNameIndexed.Extensions, Extension) == Name)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-02 10:50:21 +00:00
|
|
|
|
Logger.PrintInfo(LogClass.Gpu, $"OpenGL extension {Name} unavailable. You may experience some performance degredation");
|
|
|
|
|
|
2018-07-19 06:33:27 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-02-28 01:12:24 +00:00
|
|
|
|
|
2019-03-02 10:50:21 +00:00
|
|
|
|
private static bool IsNvidiaDriver()
|
|
|
|
|
{
|
2019-02-28 01:12:24 +00:00
|
|
|
|
return GL.GetString(StringName.Vendor).Equals("NVIDIA Corporation");
|
|
|
|
|
}
|
2019-03-02 10:50:21 +00:00
|
|
|
|
|
|
|
|
|
public static class Required
|
|
|
|
|
{
|
|
|
|
|
// Public accessors
|
|
|
|
|
public static bool EnhancedLayouts => s_EnhancedLayoutsRequired.Value;
|
|
|
|
|
public static bool TextureMirrorClamp => s_TextureMirrorClampRequired.Value;
|
|
|
|
|
public static bool ViewportArray => s_ViewportArrayRequired.Value;
|
|
|
|
|
|
|
|
|
|
// Private lazy backing variables
|
|
|
|
|
private static Lazy<bool> s_EnhancedLayoutsRequired = new Lazy<bool>(() => HasExtensionRequired(OGLExtension.EnhancedLayouts, "GL_ARB_enhanced_layouts"));
|
|
|
|
|
private static Lazy<bool> s_TextureMirrorClampRequired = new Lazy<bool>(() => HasExtensionRequired(OGLExtension.TextureMirrorClamp, "GL_EXT_texture_mirror_clamp"));
|
|
|
|
|
private static Lazy<bool> s_ViewportArrayRequired = new Lazy<bool>(() => HasExtensionRequired(OGLExtension.ViewportArray, "GL_ARB_viewport_array"));
|
|
|
|
|
|
|
|
|
|
private static bool HasExtensionRequired(bool Value, string Name)
|
|
|
|
|
{
|
|
|
|
|
if (Value)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.PrintWarning(LogClass.Gpu, $"Required OpenGL extension {Name} unavailable. You may experience some rendering issues");
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-19 06:33:27 +01:00
|
|
|
|
}
|
2019-03-02 10:50:21 +00:00
|
|
|
|
}
|