From 40f2bd37e3b025ae3b932d15971d8a8e2f8b9866 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:10:55 +0200 Subject: [PATCH] [Ryujinx.Graphics.OpenGL] Address dotnet-format issues (#5372) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Address or silence dotnet format IDE1006 warnings * Fix IDE0090 after rebase * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Another rebase, another dotnet format run * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback --- .../BackgroundContextWorker.cs | 10 +- src/Ryujinx.Graphics.OpenGL/Debugger.cs | 16 ++- .../DrawTextureEmulation.cs | 8 +- .../Effects/FsrScalingFilter.cs | 4 +- .../Effects/FxaaPostProcessingEffect.cs | 2 +- .../Effects/IPostProcessingEffect.cs | 4 +- .../Effects/IScalingFilter.cs | 2 +- .../Effects/ShaderHelper.cs | 1 - .../Effects/SmaaPostProcessingEffect.cs | 2 +- src/Ryujinx.Graphics.OpenGL/FormatInfo.cs | 42 +++---- src/Ryujinx.Graphics.OpenGL/FormatTable.cs | 8 +- src/Ryujinx.Graphics.OpenGL/Framebuffer.cs | 2 +- src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs | 103 +++++++++--------- .../Image/IntermmediatePool.cs | 2 +- src/Ryujinx.Graphics.OpenGL/Image/Sampler.cs | 4 +- .../Image/TextureBuffer.cs | 4 +- .../Image/TextureCopy.cs | 32 +++--- .../Image/TextureCopyIncompatible.cs | 6 +- .../Image/TextureCopyMS.cs | 6 +- .../Image/TextureStorage.cs | 2 +- .../Image/TextureView.cs | 8 +- src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs | 10 +- .../PersistentBuffers.cs | 10 +- src/Ryujinx.Graphics.OpenGL/Pipeline.cs | 26 +++-- src/Ryujinx.Graphics.OpenGL/Program.cs | 2 +- .../Queries/BufferedQuery.cs | 8 +- .../Queries/CounterQueue.cs | 25 ++--- .../Queries/CounterQueueEvent.cs | 4 +- .../Queries/Counters.cs | 4 +- src/Ryujinx.Graphics.OpenGL/ResourcePool.cs | 8 +- src/Ryujinx.Graphics.OpenGL/Sync.cs | 22 ++-- src/Ryujinx.Graphics.OpenGL/VertexArray.cs | 4 +- src/Ryujinx.Graphics.OpenGL/Window.cs | 4 +- 33 files changed, 198 insertions(+), 197 deletions(-) diff --git a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs index 764ea7159d..ae647e388f 100644 --- a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs +++ b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs @@ -9,12 +9,12 @@ namespace Ryujinx.Graphics.OpenGL { [ThreadStatic] public static bool InBackground; - private Thread _thread; + private readonly Thread _thread; private bool _running; - private AutoResetEvent _signal; - private Queue _work; - private ObjectPool _invokePool; + private readonly AutoResetEvent _signal; + private readonly Queue _work; + private readonly ObjectPool _invokePool; private readonly IOpenGLContext _backgroundContext; public BackgroundContextWorker(IOpenGLContext backgroundContext) @@ -88,4 +88,4 @@ namespace Ryujinx.Graphics.OpenGL _signal.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/Debugger.cs b/src/Ryujinx.Graphics.OpenGL/Debugger.cs index 9f67cfc67a..7606bdbfd7 100644 --- a/src/Ryujinx.Graphics.OpenGL/Debugger.cs +++ b/src/Ryujinx.Graphics.OpenGL/Debugger.cs @@ -63,10 +63,18 @@ namespace Ryujinx.Graphics.OpenGL switch (type) { - case DebugType.DebugTypeError : Logger.Error?.Print(LogClass.Gpu, $"{severity}: {msg}\nCallStack={Environment.StackTrace}", "GLERROR"); break; - case DebugType.DebugTypePerformance: Logger.Warning?.Print(LogClass.Gpu, $"{severity}: {msg}", "GLPERF"); break; - case DebugType.DebugTypePushGroup : Logger.Info?.Print(LogClass.Gpu, $"{{ ({id}) {severity}: {msg}", "GLINFO"); break; - case DebugType.DebugTypePopGroup : Logger.Info?.Print(LogClass.Gpu, $"}} ({id}) {severity}: {msg}", "GLINFO"); break; + case DebugType.DebugTypeError: + Logger.Error?.Print(LogClass.Gpu, $"{severity}: {msg}\nCallStack={Environment.StackTrace}", "GLERROR"); + break; + case DebugType.DebugTypePerformance: + Logger.Warning?.Print(LogClass.Gpu, $"{severity}: {msg}", "GLPERF"); + break; + case DebugType.DebugTypePushGroup: + Logger.Info?.Print(LogClass.Gpu, $"{{ ({id}) {severity}: {msg}", "GLINFO"); + break; + case DebugType.DebugTypePopGroup: + Logger.Info?.Print(LogClass.Gpu, $"}} ({id}) {severity}: {msg}", "GLINFO"); + break; default: if (source == DebugSource.DebugSourceApplication) { diff --git a/src/Ryujinx.Graphics.OpenGL/DrawTextureEmulation.cs b/src/Ryujinx.Graphics.OpenGL/DrawTextureEmulation.cs index 509e20fe25..7a6af95ea2 100644 --- a/src/Ryujinx.Graphics.OpenGL/DrawTextureEmulation.cs +++ b/src/Ryujinx.Graphics.OpenGL/DrawTextureEmulation.cs @@ -65,16 +65,12 @@ void main() if (x0 > x1) { - float temp = s0; - s0 = s1; - s1 = temp; + (s1, s0) = (s0, s1); } if (y0 > y1) { - float temp = t0; - t0 = t1; - t1 = temp; + (t1, t0) = (t0, t1); } GL.Uniform1(_uniformSrcX0Location, s0); diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs b/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs index 16678bb7b9..5daaf8c451 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs @@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects } } - public FsrScalingFilter(OpenGLRenderer renderer, IPostProcessingEffect filter) + public FsrScalingFilter(OpenGLRenderer renderer) { Initialize(); @@ -174,4 +174,4 @@ namespace Ryujinx.Graphics.OpenGL.Effects GL.ActiveTexture((TextureUnit)previousUnit); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs index 3a2d685b73..c8f170846d 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs @@ -78,4 +78,4 @@ namespace Ryujinx.Graphics.OpenGL.Effects return textureView; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/IPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/IPostProcessingEffect.cs index 7a045a0212..154e74921b 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/IPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/IPostProcessingEffect.cs @@ -3,9 +3,9 @@ using System; namespace Ryujinx.Graphics.OpenGL.Effects { - internal interface IPostProcessingEffect : IDisposable + internal interface IPostProcessingEffect : IDisposable { const int LocalGroupSize = 64; TextureView Run(TextureView view, int width, int height); } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/IScalingFilter.cs b/src/Ryujinx.Graphics.OpenGL/Effects/IScalingFilter.cs index e1e1b2c1d0..b5c80878ac 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/IScalingFilter.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/IScalingFilter.cs @@ -15,4 +15,4 @@ namespace Ryujinx.Graphics.OpenGL.Effects Extents2D source, Extents2D destination); } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/ShaderHelper.cs b/src/Ryujinx.Graphics.OpenGL/Effects/ShaderHelper.cs index 72c5a98f54..976b3410b8 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/ShaderHelper.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/ShaderHelper.cs @@ -1,5 +1,4 @@ using OpenTK.Graphics.OpenGL; -using System; namespace Ryujinx.Graphics.OpenGL.Effects { diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs index 1ad300c888..eede852f74 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa private int[] _neighbourShaderPrograms; private TextureStorage _edgeOutputTexture; private TextureStorage _blendOutputTexture; - private string[] _qualities; + private readonly string[] _qualities; private int _inputUniform; private int _outputUniform; private int _samplerAreaUniform; diff --git a/src/Ryujinx.Graphics.OpenGL/FormatInfo.cs b/src/Ryujinx.Graphics.OpenGL/FormatInfo.cs index aef4dbad39..c1a97e81a2 100644 --- a/src/Ryujinx.Graphics.OpenGL/FormatInfo.cs +++ b/src/Ryujinx.Graphics.OpenGL/FormatInfo.cs @@ -4,42 +4,42 @@ namespace Ryujinx.Graphics.OpenGL { readonly struct FormatInfo { - public int Components { get; } + public int Components { get; } public bool Normalized { get; } - public bool Scaled { get; } + public bool Scaled { get; } public PixelInternalFormat PixelInternalFormat { get; } - public PixelFormat PixelFormat { get; } - public PixelType PixelType { get; } + public PixelFormat PixelFormat { get; } + public PixelType PixelType { get; } public bool IsCompressed { get; } public FormatInfo( - int components, - bool normalized, - bool scaled, - All pixelInternalFormat, + int components, + bool normalized, + bool scaled, + All pixelInternalFormat, PixelFormat pixelFormat, - PixelType pixelType) + PixelType pixelType) { - Components = components; - Normalized = normalized; - Scaled = scaled; + Components = components; + Normalized = normalized; + Scaled = scaled; PixelInternalFormat = (PixelInternalFormat)pixelInternalFormat; - PixelFormat = pixelFormat; - PixelType = pixelType; - IsCompressed = false; + PixelFormat = pixelFormat; + PixelType = pixelType; + IsCompressed = false; } public FormatInfo(int components, bool normalized, bool scaled, All pixelFormat) { - Components = components; - Normalized = normalized; - Scaled = scaled; + Components = components; + Normalized = normalized; + Scaled = scaled; PixelInternalFormat = 0; - PixelFormat = (PixelFormat)pixelFormat; - PixelType = 0; - IsCompressed = true; + PixelFormat = (PixelFormat)pixelFormat; + PixelType = 0; + IsCompressed = true; } } } diff --git a/src/Ryujinx.Graphics.OpenGL/FormatTable.cs b/src/Ryujinx.Graphics.OpenGL/FormatTable.cs index 281f0004fe..3dac33b94b 100644 --- a/src/Ryujinx.Graphics.OpenGL/FormatTable.cs +++ b/src/Ryujinx.Graphics.OpenGL/FormatTable.cs @@ -4,10 +4,10 @@ using System; namespace Ryujinx.Graphics.OpenGL { - struct FormatTable + readonly struct FormatTable { - private static FormatInfo[] _table; - private static SizedInternalFormat[] _tableImage; + private static readonly FormatInfo[] _table; + private static readonly SizedInternalFormat[] _tableImage; static FormatTable() { @@ -16,6 +16,7 @@ namespace Ryujinx.Graphics.OpenGL _table = new FormatInfo[tableSize]; _tableImage = new SizedInternalFormat[tableSize]; +#pragma warning disable IDE0055 // Disable formatting Add(Format.R8Unorm, new FormatInfo(1, true, false, All.R8, PixelFormat.Red, PixelType.UnsignedByte)); Add(Format.R8Snorm, new FormatInfo(1, true, false, All.R8Snorm, PixelFormat.Red, PixelType.Byte)); Add(Format.R8Uint, new FormatInfo(1, false, false, All.R8ui, PixelFormat.RedInteger, PixelType.UnsignedByte)); @@ -200,6 +201,7 @@ namespace Ryujinx.Graphics.OpenGL Add(Format.R10G10B10A2Unorm, (SizedInternalFormat)All.Rgb10A2); Add(Format.R10G10B10A2Uint, (SizedInternalFormat)All.Rgb10A2ui); Add(Format.R11G11B10Float, (SizedInternalFormat)All.R11fG11fB10f); +#pragma warning restore IDE0055 } private static void Add(Format format, FormatInfo info) diff --git a/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs b/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs index b180b8578a..3b79c5d6b1 100644 --- a/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs +++ b/src/Ryujinx.Graphics.OpenGL/Framebuffer.cs @@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.OpenGL _colorsCount = colorsCount; } - private void SetDrawBuffersImpl(int colorsCount) + private static void SetDrawBuffersImpl(int colorsCount) { DrawBuffersEnum[] drawBuffers = new DrawBuffersEnum[colorsCount]; diff --git a/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs b/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs index dd0b1501fb..d7d993459e 100644 --- a/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs +++ b/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs @@ -5,30 +5,30 @@ namespace Ryujinx.Graphics.OpenGL { static class HwCapabilities { - private static readonly Lazy _supportsAlphaToCoverageDitherControl = new Lazy(() => HasExtension("GL_NV_alpha_to_coverage_dither_control")); - private static readonly Lazy _supportsAstcCompression = new Lazy(() => HasExtension("GL_KHR_texture_compression_astc_ldr")); - private static readonly Lazy _supportsBlendEquationAdvanced = new Lazy(() => HasExtension("GL_NV_blend_equation_advanced")); - private static readonly Lazy _supportsDrawTexture = new Lazy(() => HasExtension("GL_NV_draw_texture")); - private static readonly Lazy _supportsFragmentShaderInterlock = new Lazy(() => HasExtension("GL_ARB_fragment_shader_interlock")); - private static readonly Lazy _supportsFragmentShaderOrdering = new Lazy(() => HasExtension("GL_INTEL_fragment_shader_ordering")); - private static readonly Lazy _supportsGeometryShaderPassthrough = new Lazy(() => HasExtension("GL_NV_geometry_shader_passthrough")); - private static readonly Lazy _supportsImageLoadFormatted = new Lazy(() => HasExtension("GL_EXT_shader_image_load_formatted")); - private static readonly Lazy _supportsIndirectParameters = new Lazy(() => HasExtension("GL_ARB_indirect_parameters")); - private static readonly Lazy _supportsParallelShaderCompile = new Lazy(() => HasExtension("GL_ARB_parallel_shader_compile")); - private static readonly Lazy _supportsPolygonOffsetClamp = new Lazy(() => HasExtension("GL_EXT_polygon_offset_clamp")); - private static readonly Lazy _supportsQuads = new Lazy(SupportsQuadsCheck); - private static readonly Lazy _supportsSeamlessCubemapPerTexture = new Lazy(() => HasExtension("GL_ARB_seamless_cubemap_per_texture")); - private static readonly Lazy _supportsShaderBallot = new Lazy(() => HasExtension("GL_ARB_shader_ballot")); - private static readonly Lazy _supportsShaderViewportLayerArray = new Lazy(() => HasExtension("GL_ARB_shader_viewport_layer_array")); - private static readonly Lazy _supportsViewportArray2 = new Lazy(() => HasExtension("GL_NV_viewport_array2")); - private static readonly Lazy _supportsTextureCompressionBptc = new Lazy(() => HasExtension("GL_EXT_texture_compression_bptc")); - private static readonly Lazy _supportsTextureCompressionRgtc = new Lazy(() => HasExtension("GL_EXT_texture_compression_rgtc")); - private static readonly Lazy _supportsTextureCompressionS3tc = new Lazy(() => HasExtension("GL_EXT_texture_compression_s3tc")); - private static readonly Lazy _supportsTextureShadowLod = new Lazy(() => HasExtension("GL_EXT_texture_shadow_lod")); - private static readonly Lazy _supportsViewportSwizzle = new Lazy(() => HasExtension("GL_NV_viewport_swizzle")); + private static readonly Lazy _supportsAlphaToCoverageDitherControl = new(() => HasExtension("GL_NV_alpha_to_coverage_dither_control")); + private static readonly Lazy _supportsAstcCompression = new(() => HasExtension("GL_KHR_texture_compression_astc_ldr")); + private static readonly Lazy _supportsBlendEquationAdvanced = new(() => HasExtension("GL_NV_blend_equation_advanced")); + private static readonly Lazy _supportsDrawTexture = new(() => HasExtension("GL_NV_draw_texture")); + private static readonly Lazy _supportsFragmentShaderInterlock = new(() => HasExtension("GL_ARB_fragment_shader_interlock")); + private static readonly Lazy _supportsFragmentShaderOrdering = new(() => HasExtension("GL_INTEL_fragment_shader_ordering")); + private static readonly Lazy _supportsGeometryShaderPassthrough = new(() => HasExtension("GL_NV_geometry_shader_passthrough")); + private static readonly Lazy _supportsImageLoadFormatted = new(() => HasExtension("GL_EXT_shader_image_load_formatted")); + private static readonly Lazy _supportsIndirectParameters = new(() => HasExtension("GL_ARB_indirect_parameters")); + private static readonly Lazy _supportsParallelShaderCompile = new(() => HasExtension("GL_ARB_parallel_shader_compile")); + private static readonly Lazy _supportsPolygonOffsetClamp = new(() => HasExtension("GL_EXT_polygon_offset_clamp")); + private static readonly Lazy _supportsQuads = new(SupportsQuadsCheck); + private static readonly Lazy _supportsSeamlessCubemapPerTexture = new(() => HasExtension("GL_ARB_seamless_cubemap_per_texture")); + private static readonly Lazy _supportsShaderBallot = new(() => HasExtension("GL_ARB_shader_ballot")); + private static readonly Lazy _supportsShaderViewportLayerArray = new(() => HasExtension("GL_ARB_shader_viewport_layer_array")); + private static readonly Lazy _supportsViewportArray2 = new(() => HasExtension("GL_NV_viewport_array2")); + private static readonly Lazy _supportsTextureCompressionBptc = new(() => HasExtension("GL_EXT_texture_compression_bptc")); + private static readonly Lazy _supportsTextureCompressionRgtc = new(() => HasExtension("GL_EXT_texture_compression_rgtc")); + private static readonly Lazy _supportsTextureCompressionS3tc = new(() => HasExtension("GL_EXT_texture_compression_s3tc")); + private static readonly Lazy _supportsTextureShadowLod = new(() => HasExtension("GL_EXT_texture_shadow_lod")); + private static readonly Lazy _supportsViewportSwizzle = new(() => HasExtension("GL_NV_viewport_swizzle")); - private static readonly Lazy _maximumComputeSharedMemorySize = new Lazy(() => GetLimit(All.MaxComputeSharedMemorySize)); - private static readonly Lazy _storageBufferOffsetAlignment = new Lazy(() => GetLimit(All.ShaderStorageBufferOffsetAlignment)); + private static readonly Lazy _maximumComputeSharedMemorySize = new(() => GetLimit(All.MaxComputeSharedMemorySize)); + private static readonly Lazy _storageBufferOffsetAlignment = new(() => GetLimit(All.ShaderStorageBufferOffsetAlignment)); public enum GpuVendor { @@ -40,45 +40,44 @@ namespace Ryujinx.Graphics.OpenGL Nvidia } - private static readonly Lazy _gpuVendor = new Lazy(GetGpuVendor); + private static readonly Lazy _gpuVendor = new(GetGpuVendor); - private static bool _isAMD => _gpuVendor.Value == GpuVendor.AmdWindows || _gpuVendor.Value == GpuVendor.AmdUnix; - private static bool _isIntel => _gpuVendor.Value == GpuVendor.IntelWindows || _gpuVendor.Value == GpuVendor.IntelUnix; + private static bool IsIntel => _gpuVendor.Value == GpuVendor.IntelWindows || _gpuVendor.Value == GpuVendor.IntelUnix; public static GpuVendor Vendor => _gpuVendor.Value; - private static Lazy _maxSupportedAnisotropy = new Lazy(GL.GetFloat((GetPName)All.MaxTextureMaxAnisotropy)); + private static readonly Lazy _maxSupportedAnisotropy = new(GL.GetFloat((GetPName)All.MaxTextureMaxAnisotropy)); - public static bool UsePersistentBufferForFlush => _gpuVendor.Value == GpuVendor.AmdWindows || _gpuVendor.Value == GpuVendor.Nvidia; + public static bool UsePersistentBufferForFlush => _gpuVendor.Value == GpuVendor.AmdWindows || _gpuVendor.Value == GpuVendor.Nvidia; public static bool SupportsAlphaToCoverageDitherControl => _supportsAlphaToCoverageDitherControl.Value; - public static bool SupportsAstcCompression => _supportsAstcCompression.Value; - public static bool SupportsBlendEquationAdvanced => _supportsBlendEquationAdvanced.Value; - public static bool SupportsDrawTexture => _supportsDrawTexture.Value; - public static bool SupportsFragmentShaderInterlock => _supportsFragmentShaderInterlock.Value; - public static bool SupportsFragmentShaderOrdering => _supportsFragmentShaderOrdering.Value; - public static bool SupportsGeometryShaderPassthrough => _supportsGeometryShaderPassthrough.Value; - public static bool SupportsImageLoadFormatted => _supportsImageLoadFormatted.Value; - public static bool SupportsIndirectParameters => _supportsIndirectParameters.Value; - public static bool SupportsParallelShaderCompile => _supportsParallelShaderCompile.Value; - public static bool SupportsPolygonOffsetClamp => _supportsPolygonOffsetClamp.Value; - public static bool SupportsQuads => _supportsQuads.Value; - public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value; - public static bool SupportsShaderBallot => _supportsShaderBallot.Value; - public static bool SupportsShaderViewportLayerArray => _supportsShaderViewportLayerArray.Value; - public static bool SupportsViewportArray2 => _supportsViewportArray2.Value; - public static bool SupportsTextureCompressionBptc => _supportsTextureCompressionBptc.Value; - public static bool SupportsTextureCompressionRgtc => _supportsTextureCompressionRgtc.Value; - public static bool SupportsTextureCompressionS3tc => _supportsTextureCompressionS3tc.Value; - public static bool SupportsTextureShadowLod => _supportsTextureShadowLod.Value; - public static bool SupportsViewportSwizzle => _supportsViewportSwizzle.Value; + public static bool SupportsAstcCompression => _supportsAstcCompression.Value; + public static bool SupportsBlendEquationAdvanced => _supportsBlendEquationAdvanced.Value; + public static bool SupportsDrawTexture => _supportsDrawTexture.Value; + public static bool SupportsFragmentShaderInterlock => _supportsFragmentShaderInterlock.Value; + public static bool SupportsFragmentShaderOrdering => _supportsFragmentShaderOrdering.Value; + public static bool SupportsGeometryShaderPassthrough => _supportsGeometryShaderPassthrough.Value; + public static bool SupportsImageLoadFormatted => _supportsImageLoadFormatted.Value; + public static bool SupportsIndirectParameters => _supportsIndirectParameters.Value; + public static bool SupportsParallelShaderCompile => _supportsParallelShaderCompile.Value; + public static bool SupportsPolygonOffsetClamp => _supportsPolygonOffsetClamp.Value; + public static bool SupportsQuads => _supportsQuads.Value; + public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value; + public static bool SupportsShaderBallot => _supportsShaderBallot.Value; + public static bool SupportsShaderViewportLayerArray => _supportsShaderViewportLayerArray.Value; + public static bool SupportsViewportArray2 => _supportsViewportArray2.Value; + public static bool SupportsTextureCompressionBptc => _supportsTextureCompressionBptc.Value; + public static bool SupportsTextureCompressionRgtc => _supportsTextureCompressionRgtc.Value; + public static bool SupportsTextureCompressionS3tc => _supportsTextureCompressionS3tc.Value; + public static bool SupportsTextureShadowLod => _supportsTextureShadowLod.Value; + public static bool SupportsViewportSwizzle => _supportsViewportSwizzle.Value; - public static bool SupportsMismatchingViewFormat => _gpuVendor.Value != GpuVendor.AmdWindows && _gpuVendor.Value != GpuVendor.IntelWindows; + public static bool SupportsMismatchingViewFormat => _gpuVendor.Value != GpuVendor.AmdWindows && _gpuVendor.Value != GpuVendor.IntelWindows; public static bool SupportsNonConstantTextureOffset => _gpuVendor.Value == GpuVendor.Nvidia; - public static bool RequiresSyncFlush => _gpuVendor.Value == GpuVendor.AmdWindows || _isIntel; + public static bool RequiresSyncFlush => _gpuVendor.Value == GpuVendor.AmdWindows || IsIntel; public static int MaximumComputeSharedMemorySize => _maximumComputeSharedMemorySize.Value; - public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value; + public static int StorageBufferOffsetAlignment => _storageBufferOffsetAlignment.Value; public static float MaximumSupportedAnisotropy => _maxSupportedAnisotropy.Value; @@ -139,4 +138,4 @@ namespace Ryujinx.Graphics.OpenGL return GL.GetError() == ErrorCode.NoError; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs b/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs index 4f167e8933..1a08f973a6 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs @@ -100,4 +100,4 @@ namespace Ryujinx.Graphics.OpenGL.Image _entries.Clear(); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/Image/Sampler.cs b/src/Ryujinx.Graphics.OpenGL/Image/Sampler.cs index f705aa3e78..18dd1b72a3 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/Sampler.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/Sampler.cs @@ -39,8 +39,8 @@ namespace Ryujinx.Graphics.OpenGL.Image GL.SamplerParameter(Handle, SamplerParameterName.TextureBorderColor, borderColor); } - GL.SamplerParameter(Handle, SamplerParameterName.TextureMinLod, info.MinLod); - GL.SamplerParameter(Handle, SamplerParameterName.TextureMaxLod, info.MaxLod); + GL.SamplerParameter(Handle, SamplerParameterName.TextureMinLod, info.MinLod); + GL.SamplerParameter(Handle, SamplerParameterName.TextureMaxLod, info.MaxLod); GL.SamplerParameter(Handle, SamplerParameterName.TextureLodBias, info.MipLodBias); GL.SamplerParameter(Handle, SamplerParameterName.TextureMaxAnisotropyExt, info.MaxAnisotropy); diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs index 116f70cc7f..c177ae9c62 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.OpenGL.Image { class TextureBuffer : TextureBase, ITexture { - private OpenGLRenderer _renderer; + private readonly OpenGLRenderer _renderer; private int _bufferOffset; private int _bufferSize; private int _bufferCount; @@ -58,7 +58,7 @@ namespace Ryujinx.Graphics.OpenGL.Image { var dataSpan = data.AsSpan(); - Buffer.SetData(_buffer, _bufferOffset, dataSpan.Slice(0, Math.Min(dataSpan.Length, _bufferSize))); + Buffer.SetData(_buffer, _bufferOffset, dataSpan[..Math.Min(dataSpan.Length, _bufferSize)]); } public void SetData(SpanOrArray data, int layer, int level) diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs index a4b08787b7..bb1911e8b3 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs @@ -26,13 +26,13 @@ namespace Ryujinx.Graphics.OpenGL.Image public void Copy( TextureView src, TextureView dst, - Extents2D srcRegion, - Extents2D dstRegion, - bool linearFilter, - int srcLayer = 0, - int dstLayer = 0, - int srcLevel = 0, - int dstLevel = 0) + Extents2D srcRegion, + Extents2D dstRegion, + bool linearFilter, + int srcLayer = 0, + int dstLayer = 0, + int srcLevel = 0, + int dstLevel = 0) { int levels = Math.Min(src.Info.Levels - srcLevel, dst.Info.Levels - dstLevel); int layers = Math.Min(src.Info.GetLayers() - srcLayer, dst.Info.GetLayers() - dstLayer); @@ -43,15 +43,15 @@ namespace Ryujinx.Graphics.OpenGL.Image public void Copy( TextureView src, TextureView dst, - Extents2D srcRegion, - Extents2D dstRegion, - bool linearFilter, - int srcLayer, - int dstLayer, - int srcLevel, - int dstLevel, - int layers, - int levels) + Extents2D srcRegion, + Extents2D dstRegion, + bool linearFilter, + int srcLayer, + int dstLayer, + int srcLevel, + int dstLevel, + int layers, + int levels) { TextureView srcConverted = src.Format.IsBgr() != dst.Format.IsBgr() ? BgraSwap(src) : src; diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs index c8fbfbc6a6..6b5fb376bb 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs @@ -1,5 +1,4 @@ using OpenTK.Graphics.OpenGL; -using Ryujinx.Graphics.GAL; using System; using System.Collections.Generic; using System.Globalization; @@ -81,9 +80,6 @@ void main() public void CopyIncompatibleFormats(ITextureInfo src, ITextureInfo dst, int srcLayer, int dstLayer, int srcLevel, int dstLevel, int depth, int levels) { - TextureCreateInfo srcInfo = src.Info; - TextureCreateInfo dstInfo = dst.Info; - int srcBpp = src.Info.BytesPerPixel; int dstBpp = dst.Info.BytesPerPixel; @@ -176,7 +172,7 @@ void main() return GetShader(ComputeShaderWidening, _wideningProgramHandles, componentSize, srcComponentsCount, dstComponentsCount); } - private int GetShader( + private static int GetShader( string code, Dictionary programHandles, int componentSize, diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyMS.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyMS.cs index 9963dc661f..39f2327234 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyMS.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyMS.cs @@ -94,8 +94,8 @@ void main() }"; private readonly OpenGLRenderer _renderer; - private int[] _msToNonMSProgramHandles; - private int[] _nonMSToMSProgramHandles; + private readonly int[] _msToNonMSProgramHandles; + private readonly int[] _nonMSToMSProgramHandles; public TextureCopyMS(OpenGLRenderer renderer) { @@ -219,7 +219,7 @@ void main() return GetShader(ComputeShaderNonMSToMS, _nonMSToMSProgramHandles, bytesPerPixel); } - private int GetShader(string code, int[] programHandles, int bytesPerPixel) + private static int GetShader(string code, int[] programHandles, int bytesPerPixel) { int index = BitOperations.Log2((uint)bytesPerPixel); diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs index c058ac885d..d714caf381 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL.Image public TextureStorage(OpenGLRenderer renderer, TextureCreateInfo info, float scaleFactor) { _renderer = renderer; - Info = info; + Info = info; Handle = GL.GenTexture(); ScaleFactor = scaleFactor; diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs index 90a2936d06..21d8e449c9 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs @@ -88,9 +88,7 @@ namespace Ryujinx.Graphics.OpenGL.Image { // Swap B <-> R for BGRA formats, as OpenGL has no support for them // and we need to manually swap the components on read/write on the GPU. - int temp = swizzleRgba[0]; - swizzleRgba[0] = swizzleRgba[2]; - swizzleRgba[2] = temp; + (swizzleRgba[2], swizzleRgba[0]) = (swizzleRgba[0], swizzleRgba[2]); } GL.TexParameter(target, TextureParameterName.TextureSwizzleRgba, swizzleRgba); @@ -186,8 +184,8 @@ namespace Ryujinx.Graphics.OpenGL.Image // This approach uses blit, which causes a resolution loss since some samples will be lost // in the process. - Extents2D srcRegion = new Extents2D(0, 0, Width, Height); - Extents2D dstRegion = new Extents2D(0, 0, destinationView.Width, destinationView.Height); + Extents2D srcRegion = new(0, 0, Width, Height); + Extents2D dstRegion = new(0, 0, destinationView.Width, destinationView.Height); if (destinationView.Target.IsMultisample()) { diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index c7c01a37b1..b4c567a816 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -21,13 +21,13 @@ namespace Ryujinx.Graphics.OpenGL public IWindow Window => _window; - private TextureCopy _textureCopy; - private TextureCopy _backgroundTextureCopy; + private readonly TextureCopy _textureCopy; + private readonly TextureCopy _backgroundTextureCopy; internal TextureCopy TextureCopy => BackgroundContextWorker.InBackground ? _backgroundTextureCopy : _textureCopy; internal TextureCopyIncompatible TextureCopyIncompatible { get; } internal TextureCopyMS TextureCopyMS { get; } - private Sync _sync; + private readonly Sync _sync; public event EventHandler ScreenCaptured; @@ -222,9 +222,9 @@ namespace Ryujinx.Graphics.OpenGL private void PrintGpuInformation() { - GpuVendor = GL.GetString(StringName.Vendor); + GpuVendor = GL.GetString(StringName.Vendor); GpuRenderer = GL.GetString(StringName.Renderer); - GpuVersion = GL.GetString(StringName.Version); + GpuVersion = GL.GetString(StringName.Version); Logger.Notice.Print(LogClass.Gpu, $"{GpuVendor} {GpuRenderer} ({GpuVersion})"); } diff --git a/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs b/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs index aac288b7ea..ebfe3ad644 100644 --- a/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs +++ b/src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs @@ -11,10 +11,10 @@ namespace Ryujinx.Graphics.OpenGL { class PersistentBuffers : IDisposable { - private PersistentBuffer _main = new PersistentBuffer(); - private PersistentBuffer _background = new PersistentBuffer(); + private readonly PersistentBuffer _main = new(); + private readonly PersistentBuffer _background = new(); - private Dictionary _maps = new Dictionary(); + private readonly Dictionary _maps = new(); public PersistentBuffer Default => BackgroundContextWorker.InBackground ? _background : _main; @@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.OpenGL return _dataMap; } - private void Sync() + private static void Sync() { GL.MemoryBarrier(MemoryBarrierFlags.ClientMappedBufferBarrierBit); @@ -133,7 +133,7 @@ namespace Ryujinx.Graphics.OpenGL Sync(); - return new ReadOnlySpan(_bufferMap.ToPointer(), size).Slice(offset); + return new ReadOnlySpan(_bufferMap.ToPointer(), size)[offset..]; } public unsafe ReadOnlySpan GetBufferData(BufferHandle buffer, int offset, int size) diff --git a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs index 6b6d0289c1..df618d5bce 100644 --- a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -44,11 +44,11 @@ namespace Ryujinx.Graphics.OpenGL private CounterQueueEvent _activeConditionalRender; - private Vector4[] _fpIsBgra = new Vector4[SupportBuffer.FragmentIsBgraCount]; - private Vector4[] _renderScale = new Vector4[73]; + private readonly Vector4[] _fpIsBgra = new Vector4[SupportBuffer.FragmentIsBgraCount]; + private readonly Vector4[] _renderScale = new Vector4[73]; private int _fragmentScaleCount; - private (TextureBase, Format)[] _images; + private readonly (TextureBase, Format)[] _images; private TextureBase _unit0Texture; private Sampler _unit0Sampler; @@ -260,7 +260,7 @@ namespace Ryujinx.Graphics.OpenGL PostDraw(); } - private void DrawQuadsImpl( + private static void DrawQuadsImpl( int vertexCount, int instanceCount, int firstVertex, @@ -285,7 +285,7 @@ namespace Ryujinx.Graphics.OpenGL quadsCount); } - private void DrawQuadStripImpl( + private static void DrawQuadStripImpl( int vertexCount, int instanceCount, int firstVertex, @@ -366,8 +366,12 @@ namespace Ryujinx.Graphics.OpenGL switch (_elementsType) { - case DrawElementsType.UnsignedShort: indexElemSize = 2; break; - case DrawElementsType.UnsignedInt: indexElemSize = 4; break; + case DrawElementsType.UnsignedShort: + indexElemSize = 2; + break; + case DrawElementsType.UnsignedInt: + indexElemSize = 4; + break; } IntPtr indexBaseOffset = _indexBaseOffset + firstIndex * indexElemSize; @@ -1471,7 +1475,7 @@ namespace Ryujinx.Graphics.OpenGL GL.MemoryBarrier(MemoryBarrierFlags.TextureFetchBarrierBit); } - private void SetBuffers(ReadOnlySpan buffers, bool isStorage) + private static void SetBuffers(ReadOnlySpan buffers, bool isStorage) { BufferRangeTarget target = isStorage ? BufferRangeTarget.ShaderStorageBuffer : BufferRangeTarget.UniformBuffer; @@ -1701,11 +1705,9 @@ namespace Ryujinx.Graphics.OpenGL public bool TryHostConditionalRendering(ICounterEvent value, ulong compare, bool isEqual) { - if (value is CounterQueueEvent) + // Compare an event and a constant value. + if (value is CounterQueueEvent evt) { - // Compare an event and a constant value. - CounterQueueEvent evt = (CounterQueueEvent)value; - // Easy host conditional rendering when the check matches what GL can do: // - Event is of type samples passed. // - Result is not a combination of multiple queries. diff --git a/src/Ryujinx.Graphics.OpenGL/Program.cs b/src/Ryujinx.Graphics.OpenGL/Program.cs index a6009108a6..cc9120c7c5 100644 --- a/src/Ryujinx.Graphics.OpenGL/Program.cs +++ b/src/Ryujinx.Graphics.OpenGL/Program.cs @@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.OpenGL if (log.Length > MaxShaderLogLength) { - log = log.Substring(0, MaxShaderLogLength) + "..."; + log = log[..MaxShaderLogLength] + "..."; } Logger.Warning?.Print(LogClass.Gpu, $"Shader linking failed: \n{log}"); diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs index 9d43f6c3fd..1470f5aaa5 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs @@ -14,9 +14,9 @@ namespace Ryujinx.Graphics.OpenGL.Queries public int Query { get; } - private int _buffer; - private IntPtr _bufferMap; - private QueryTarget _type; + private readonly int _buffer; + private readonly IntPtr _bufferMap; + private readonly QueryTarget _type; public BufferedQuery(QueryTarget type) { @@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries } } - private bool WaitingForValue(long data) + private static bool WaitingForValue(long data) { return data == DefaultValue || ((ulong)data & HighMask) == (unchecked((ulong)DefaultValue) & HighMask); diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs index 648600bc2f..ff7e9a3ee8 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries private readonly Pipeline _pipeline; - private Queue _events = new Queue(); + private readonly Queue _events = new(); private CounterQueueEvent _current; private ulong _accumulatedCounter; @@ -23,12 +23,12 @@ namespace Ryujinx.Graphics.OpenGL.Queries private readonly object _lock = new(); - private Queue _queryPool; - private AutoResetEvent _queuedEvent = new AutoResetEvent(false); - private AutoResetEvent _wakeSignal = new AutoResetEvent(false); - private AutoResetEvent _eventConsumed = new AutoResetEvent(false); + private readonly Queue _queryPool; + private readonly AutoResetEvent _queuedEvent = new(false); + private readonly AutoResetEvent _wakeSignal = new(false); + private readonly AutoResetEvent _eventConsumed = new(false); - private Thread _consumerThread; + private readonly Thread _consumerThread; internal CounterQueue(Pipeline pipeline, CounterType type) { @@ -148,14 +148,13 @@ namespace Ryujinx.Graphics.OpenGL.Queries private static QueryTarget GetTarget(CounterType type) { - switch (type) + return type switch { - case CounterType.SamplesPassed: return QueryTarget.SamplesPassed; - case CounterType.PrimitivesGenerated: return QueryTarget.PrimitivesGenerated; - case CounterType.TransformFeedbackPrimitivesWritten: return QueryTarget.TransformFeedbackPrimitivesWritten; - } - - return QueryTarget.SamplesPassed; + CounterType.SamplesPassed => QueryTarget.SamplesPassed, + CounterType.PrimitivesGenerated => QueryTarget.PrimitivesGenerated, + CounterType.TransformFeedbackPrimitivesWritten => QueryTarget.TransformFeedbackPrimitivesWritten, + _ => QueryTarget.SamplesPassed, + }; } public void Flush(bool blocking) diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs index ffe1f774f5..7d22490685 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs @@ -18,8 +18,8 @@ namespace Ryujinx.Graphics.OpenGL.Queries public ulong DrawIndex { get; } - private CounterQueue _queue; - private BufferedQuery _counter; + private readonly CounterQueue _queue; + private readonly BufferedQuery _counter; private bool _hostAccessReserved = false; private int _refCount = 1; // Starts with a reference from the counter queue. diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs b/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs index e6c7ab2bde..91554ebad2 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries { class Counters : IDisposable { - private CounterQueue[] _counterQueues; + private readonly CounterQueue[] _counterQueues; public Counters() { @@ -54,4 +54,4 @@ namespace Ryujinx.Graphics.OpenGL.Queries } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs b/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs index 69d2a78e1c..bba5c5cb72 100644 --- a/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs +++ b/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL private const int DisposedLiveFrames = 2; private readonly object _lock = new(); - private readonly Dictionary> _textures = new Dictionary>(); + private readonly Dictionary> _textures = new(); /// /// Add a texture that is not being used anymore to the resource pool to be used later. @@ -32,8 +32,7 @@ namespace Ryujinx.Graphics.OpenGL { lock (_lock) { - List list; - if (!_textures.TryGetValue(view.Info, out list)) + if (!_textures.TryGetValue(view.Info, out List list)) { list = new List(); _textures.Add(view.Info, list); @@ -59,8 +58,7 @@ namespace Ryujinx.Graphics.OpenGL { lock (_lock) { - List list; - if (!_textures.TryGetValue(info, out list)) + if (!_textures.TryGetValue(info, out List list)) { return null; } diff --git a/src/Ryujinx.Graphics.OpenGL/Sync.cs b/src/Ryujinx.Graphics.OpenGL/Sync.cs index 58818e6a7b..54e9c6d3f5 100644 --- a/src/Ryujinx.Graphics.OpenGL/Sync.cs +++ b/src/Ryujinx.Graphics.OpenGL/Sync.cs @@ -15,13 +15,13 @@ namespace Ryujinx.Graphics.OpenGL } private ulong _firstHandle = 0; - private ClientWaitSyncFlags _syncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit; + private static ClientWaitSyncFlags SyncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit; - private List _handles = new List(); + private readonly List _handles = new(); public void Create(ulong id) { - SyncHandle handle = new SyncHandle + SyncHandle handle = new() { ID = id, Handle = GL.FenceSync(SyncCondition.SyncGpuCommandsComplete, WaitSyncFlags.None) @@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.OpenGL if (handle.ID > lastHandle) { - WaitSyncStatus syncResult = GL.ClientWaitSync(handle.Handle, _syncFlags, 0); + WaitSyncStatus syncResult = GL.ClientWaitSync(handle.Handle, SyncFlags, 0); if (syncResult == WaitSyncStatus.AlreadySignaled) { @@ -101,8 +101,8 @@ namespace Ryujinx.Graphics.OpenGL return; } - WaitSyncStatus syncResult = GL.ClientWaitSync(result.Handle, _syncFlags, 1000000000); - + WaitSyncStatus syncResult = GL.ClientWaitSync(result.Handle, SyncFlags, 1000000000); + if (syncResult == WaitSyncStatus.TimeoutExpired) { Logger.Error?.PrintMsg(LogClass.Gpu, $"GL Sync Object {result.ID} failed to signal within 1000ms. Continuing..."); @@ -123,9 +123,12 @@ namespace Ryujinx.Graphics.OpenGL first = _handles.FirstOrDefault(); } - if (first == null) break; + if (first == null) + { + break; + } - WaitSyncStatus syncResult = GL.ClientWaitSync(first.Handle, _syncFlags, 0); + WaitSyncStatus syncResult = GL.ClientWaitSync(first.Handle, SyncFlags, 0); if (syncResult == WaitSyncStatus.AlreadySignaled) { @@ -140,7 +143,8 @@ namespace Ryujinx.Graphics.OpenGL first.Handle = IntPtr.Zero; } } - } else + } + else { // This sync handle and any following have not been reached yet. break; diff --git a/src/Ryujinx.Graphics.OpenGL/VertexArray.cs b/src/Ryujinx.Graphics.OpenGL/VertexArray.cs index 7d22033ec4..32211e7831 100644 --- a/src/Ryujinx.Graphics.OpenGL/VertexArray.cs +++ b/src/Ryujinx.Graphics.OpenGL/VertexArray.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.OpenGL private uint _vertexBuffersLimited; private BufferRange _indexBuffer; - private BufferHandle _tempIndexBuffer; + private readonly BufferHandle _tempIndexBuffer; private BufferHandle _tempVertexBuffer; private int _tempVertexBufferSize; @@ -102,7 +102,7 @@ namespace Ryujinx.Graphics.OpenGL } int offset = attrib.Offset; - int size = fmtInfo.Components; + int size = fmtInfo.Components; bool isFloat = fmtInfo.PixelType == PixelType.Float || fmtInfo.PixelType == PixelType.HalfFloat; diff --git a/src/Ryujinx.Graphics.OpenGL/Window.cs b/src/Ryujinx.Graphics.OpenGL/Window.cs index cc9836e06a..a928772fd3 100644 --- a/src/Ryujinx.Graphics.OpenGL/Window.cs +++ b/src/Ryujinx.Graphics.OpenGL/Window.cs @@ -375,7 +375,7 @@ namespace Ryujinx.Graphics.OpenGL if (_scalingFilter is not FsrScalingFilter) { _scalingFilter?.Dispose(); - _scalingFilter = new FsrScalingFilter(_renderer, _antiAliasing); + _scalingFilter = new FsrScalingFilter(_renderer); } _isLinear = false; _scalingFilter.Level = _scalingFilterLevel; @@ -417,4 +417,4 @@ namespace Ryujinx.Graphics.OpenGL _updateScalingFilter = true; } } -} \ No newline at end of file +}