diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2021-06-02 12:27:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-02 13:27:30 +0200 |
| commit | fe29aff266ede26d44270a39b186231dce186356 (patch) | |
| tree | 2dfa520b1433327c224e7d5667bcefc2adc0abb5 /Ryujinx.Graphics.OpenGL | |
| parent | 7527c5b906b386eedaf285a0b0923174e37bb6d4 (diff) | |
Use Quads on OpenGL host when supported. (#2331)
Improves OpenGL performance on FAST RMX and Xenoblade DE/2. Will probably only work on NVIDIA GPUs, but the emulated quads path will still be valid for other GPUs. Note: SLOW RMX gets a bit faster in handheld mode.
I'd recommend checking on platforms without supported host quads to make sure a GL error is actually thrown when attempting GL.Begin(PrimitiveType.Quads)
Diffstat (limited to 'Ryujinx.Graphics.OpenGL')
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/HwCapabilities.cs | 11 | ||||
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/Pipeline.cs | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.OpenGL/HwCapabilities.cs b/Ryujinx.Graphics.OpenGL/HwCapabilities.cs index c994113d..97574aea 100644 --- a/Ryujinx.Graphics.OpenGL/HwCapabilities.cs +++ b/Ryujinx.Graphics.OpenGL/HwCapabilities.cs @@ -11,6 +11,7 @@ namespace Ryujinx.Graphics.OpenGL private static readonly Lazy<bool> _supportsViewportSwizzle = new Lazy<bool>(() => HasExtension("GL_NV_viewport_swizzle")); private static readonly Lazy<bool> _supportsSeamlessCubemapPerTexture = new Lazy<bool>(() => HasExtension("GL_ARB_seamless_cubemap_per_texture")); private static readonly Lazy<bool> _supportsParallelShaderCompile = new Lazy<bool>(() => HasExtension("GL_ARB_parallel_shader_compile")); + private static readonly Lazy<bool> _supportsQuads = new Lazy<bool>(SupportsQuadsCheck); private static readonly Lazy<int> _maximumComputeSharedMemorySize = new Lazy<int>(() => GetLimit(All.MaxComputeSharedMemorySize)); private static readonly Lazy<int> _storageBufferOffsetAlignment = new Lazy<int>(() => GetLimit(All.ShaderStorageBufferOffsetAlignment)); @@ -36,6 +37,7 @@ namespace Ryujinx.Graphics.OpenGL public static bool SupportsViewportSwizzle => _supportsViewportSwizzle.Value; public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value; public static bool SupportsParallelShaderCompile => _supportsParallelShaderCompile.Value; + public static bool SupportsQuads => _supportsQuads.Value; public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia; public static bool RequiresSyncFlush => _gpuVendor.Value == GpuVendor.Amd || _gpuVendor.Value == GpuVendor.IntelWindows || _gpuVendor.Value == GpuVendor.IntelUnix; public static bool SupportsMismatchingViewFormat => _gpuVendor.Value != GpuVendor.Amd && _gpuVendor.Value != GpuVendor.IntelWindows; @@ -88,5 +90,14 @@ namespace Ryujinx.Graphics.OpenGL return GpuVendor.Unknown; } } + + private static bool SupportsQuadsCheck() + { + GL.GetError(); // Clear any existing error. + GL.Begin(PrimitiveType.Quads); + GL.End(); + + return GL.GetError() == ErrorCode.NoError; + } } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index ed3507a3..a651dc75 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -182,11 +182,11 @@ namespace Ryujinx.Graphics.OpenGL PreDraw(); - if (_primitiveType == PrimitiveType.Quads) + if (_primitiveType == PrimitiveType.Quads && !HwCapabilities.SupportsQuads) { DrawQuadsImpl(vertexCount, instanceCount, firstVertex, firstInstance); } - else if (_primitiveType == PrimitiveType.QuadStrip) + else if (_primitiveType == PrimitiveType.QuadStrip && !HwCapabilities.SupportsQuads) { DrawQuadStripImpl(vertexCount, instanceCount, firstVertex, firstInstance); } @@ -310,7 +310,7 @@ namespace Ryujinx.Graphics.OpenGL IntPtr indexBaseOffset = _indexBaseOffset + firstIndex * indexElemSize; - if (_primitiveType == PrimitiveType.Quads) + if (_primitiveType == PrimitiveType.Quads && !HwCapabilities.SupportsQuads) { DrawQuadsIndexedImpl( indexCount, @@ -320,7 +320,7 @@ namespace Ryujinx.Graphics.OpenGL firstVertex, firstInstance); } - else if (_primitiveType == PrimitiveType.QuadStrip) + else if (_primitiveType == PrimitiveType.QuadStrip && !HwCapabilities.SupportsQuads) { DrawQuadStripIndexedImpl( indexCount, |
