aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-06-28 18:10:55 +0200
committerGitHub <noreply@github.com>2023-06-28 18:10:55 +0200
commit40f2bd37e3b025ae3b932d15971d8a8e2f8b9866 (patch)
tree9a40a53902f11c9005562625c890b4970e7069e1
parent9288ffd26d0b0b831f62cfc0281c71662d251884 (diff)
[Ryujinx.Graphics.OpenGL] Address dotnet-format issues (#5372)1.1.933
* 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
-rw-r--r--src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs10
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Debugger.cs16
-rw-r--r--src/Ryujinx.Graphics.OpenGL/DrawTextureEmulation.cs8
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Effects/FsrScalingFilter.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Effects/FxaaPostProcessingEffect.cs2
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Effects/IPostProcessingEffect.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Effects/IScalingFilter.cs2
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Effects/ShaderHelper.cs1
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs2
-rw-r--r--src/Ryujinx.Graphics.OpenGL/FormatInfo.cs42
-rw-r--r--src/Ryujinx.Graphics.OpenGL/FormatTable.cs8
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Framebuffer.cs2
-rw-r--r--src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs107
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/IntermmediatePool.cs2
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/Sampler.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs32
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureCopyIncompatible.cs6
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureCopyMS.cs6
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureStorage.cs2
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs8
-rw-r--r--src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs10
-rw-r--r--src/Ryujinx.Graphics.OpenGL/PersistentBuffers.cs10
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Pipeline.cs26
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Program.cs2
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs8
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs25
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/ResourcePool.cs8
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Sync.cs22
-rw-r--r--src/Ryujinx.Graphics.OpenGL/VertexArray.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Window.cs4
33 files changed, 200 insertions, 199 deletions
diff --git a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs
index 764ea715..ae647e38 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<Action> _work;
- private ObjectPool<ManualResetEventSlim> _invokePool;
+ private readonly AutoResetEvent _signal;
+ private readonly Queue<Action> _work;
+ private readonly ObjectPool<ManualResetEventSlim> _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 9f67cfc6..7606bdbf 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 509e20fe..7a6af95e 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 16678bb7..5daaf8c4 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 3a2d685b..c8f17084 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 7a045a02..154e7492 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 e1e1b2c1..b5c80878 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 72c5a98f..976b3410 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 1ad300c8..eede852f 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 aef4dbad..c1a97e81 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 281f0004..3dac33b9 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 b180b857..3b79c5d6 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 dd0b1501..d7d99345 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<bool> _supportsAlphaToCoverageDitherControl = new Lazy<bool>(() => HasExtension("GL_NV_alpha_to_coverage_dither_control"));
- private static readonly Lazy<bool> _supportsAstcCompression = new Lazy<bool>(() => HasExtension("GL_KHR_texture_compression_astc_ldr"));
- private static readonly Lazy<bool> _supportsBlendEquationAdvanced = new Lazy<bool>(() => HasExtension("GL_NV_blend_equation_advanced"));
- private static readonly Lazy<bool> _supportsDrawTexture = new Lazy<bool>(() => HasExtension("GL_NV_draw_texture"));
- private static readonly Lazy<bool> _supportsFragmentShaderInterlock = new Lazy<bool>(() => HasExtension("GL_ARB_fragment_shader_interlock"));
- private static readonly Lazy<bool> _supportsFragmentShaderOrdering = new Lazy<bool>(() => HasExtension("GL_INTEL_fragment_shader_ordering"));
- private static readonly Lazy<bool> _supportsGeometryShaderPassthrough = new Lazy<bool>(() => HasExtension("GL_NV_geometry_shader_passthrough"));
- private static readonly Lazy<bool> _supportsImageLoadFormatted = new Lazy<bool>(() => HasExtension("GL_EXT_shader_image_load_formatted"));
- private static readonly Lazy<bool> _supportsIndirectParameters = new Lazy<bool>(() => HasExtension("GL_ARB_indirect_parameters"));
- private static readonly Lazy<bool> _supportsParallelShaderCompile = new Lazy<bool>(() => HasExtension("GL_ARB_parallel_shader_compile"));
- private static readonly Lazy<bool> _supportsPolygonOffsetClamp = new Lazy<bool>(() => HasExtension("GL_EXT_polygon_offset_clamp"));
- private static readonly Lazy<bool> _supportsQuads = new Lazy<bool>(SupportsQuadsCheck);
- private static readonly Lazy<bool> _supportsSeamlessCubemapPerTexture = new Lazy<bool>(() => HasExtension("GL_ARB_seamless_cubemap_per_texture"));
- private static readonly Lazy<bool> _supportsShaderBallot = new Lazy<bool>(() => HasExtension("GL_ARB_shader_ballot"));
- private static readonly Lazy<bool> _supportsShaderViewportLayerArray = new Lazy<bool>(() => HasExtension("GL_ARB_shader_viewport_layer_array"));
- private static readonly Lazy<bool> _supportsViewportArray2 = new Lazy<bool>(() => HasExtension("GL_NV_viewport_array2"));
- private static readonly Lazy<bool> _supportsTextureCompressionBptc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_bptc"));
- private static readonly Lazy<bool> _supportsTextureCompressionRgtc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_rgtc"));
- private static readonly Lazy<bool> _supportsTextureCompressionS3tc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_s3tc"));
- private static readonly Lazy<bool> _supportsTextureShadowLod = new Lazy<bool>(() => HasExtension("GL_EXT_texture_shadow_lod"));
- private static readonly Lazy<bool> _supportsViewportSwizzle = new Lazy<bool>(() => HasExtension("GL_NV_viewport_swizzle"));
-
- 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 static readonly Lazy<bool> _supportsAlphaToCoverageDitherControl = new(() => HasExtension("GL_NV_alpha_to_coverage_dither_control"));
+ private static readonly Lazy<bool> _supportsAstcCompression = new(() => HasExtension("GL_KHR_texture_compression_astc_ldr"));
+ private static readonly Lazy<bool> _supportsBlendEquationAdvanced = new(() => HasExtension("GL_NV_blend_equation_advanced"));
+ private static readonly Lazy<bool> _supportsDrawTexture = new(() => HasExtension("GL_NV_draw_texture"));
+ private static readonly Lazy<bool> _supportsFragmentShaderInterlock = new(() => HasExtension("GL_ARB_fragment_shader_interlock"));
+ private static readonly Lazy<bool> _supportsFragmentShaderOrdering = new(() => HasExtension("GL_INTEL_fragment_shader_ordering"));
+ private static readonly Lazy<bool> _supportsGeometryShaderPassthrough = new(() => HasExtension("GL_NV_geometry_shader_passthrough"));
+ private static readonly Lazy<bool> _supportsImageLoadFormatted = new(() => HasExtension("GL_EXT_shader_image_load_formatted"));
+ private static readonly Lazy<bool> _supportsIndirectParameters = new(() => HasExtension("GL_ARB_indirect_parameters"));
+ private static readonly Lazy<bool> _supportsParallelShaderCompile = new(() => HasExtension("GL_ARB_parallel_shader_compile"));
+ private static readonly Lazy<bool> _supportsPolygonOffsetClamp = new(() => HasExtension("GL_EXT_polygon_offset_clamp"));
+ private static readonly Lazy<bool> _supportsQuads = new(SupportsQuadsCheck);
+ private static readonly Lazy<bool> _supportsSeamlessCubemapPerTexture = new(() => HasExtension("GL_ARB_seamless_cubemap_per_texture"));
+ private static readonly Lazy<bool> _supportsShaderBallot = new(() => HasExtension("GL_ARB_shader_ballot"));
+ private static readonly Lazy<bool> _supportsShaderViewportLayerArray = new(() => HasExtension("GL_ARB_shader_viewport_layer_array"));
+ private static readonly Lazy<bool> _supportsViewportArray2 = new(() => HasExtension("GL_NV_viewport_array2"));
+ private static readonly Lazy<bool> _supportsTextureCompressionBptc = new(() => HasExtension("GL_EXT_texture_compression_bptc"));
+ private static readonly Lazy<bool> _supportsTextureCompressionRgtc = new(() => HasExtension("GL_EXT_texture_compression_rgtc"));
+ private static readonly Lazy<bool> _supportsTextureCompressionS3tc = new(() => HasExtension("GL_EXT_texture_compression_s3tc"));
+ private static readonly Lazy<bool> _supportsTextureShadowLod = new(() => HasExtension("GL_EXT_texture_shadow_lod"));
+ private static readonly Lazy<bool> _supportsViewportSwizzle = new(() => HasExtension("GL_NV_viewport_swizzle"));
+
+ private static readonly Lazy<int> _maximumComputeSharedMemorySize = new(() => GetLimit(All.MaxComputeSharedMemorySize));
+ private static readonly Lazy<int> _storageBufferOffsetAlignment = new(() => GetLimit(All.ShaderStorageBufferOffsetAlignment));
public enum GpuVendor
{
@@ -40,45 +40,44 @@ namespace Ryujinx.Graphics.OpenGL
Nvidia
}
- private static readonly Lazy<GpuVendor> _gpuVendor = new Lazy<GpuVendor>(GetGpuVendor);
+ private static readonly Lazy<GpuVendor> _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<float> _maxSupportedAnisotropy = new Lazy<float>(GL.GetFloat((GetPName)All.MaxTextureMaxAnisotropy));
+ private static readonly Lazy<float> _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 SupportsMismatchingViewFormat => _gpuVendor.Value != GpuVendor.AmdWindows && _gpuVendor.Value != GpuVendor.IntelWindows;
+ 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 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 4f167e89..1a08f973 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 f705aa3e..18dd1b72 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 116f70cc..c177ae9c 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<byte> data, int layer, int level)
diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs
index a4b08787..bb1911e8 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 c8fbfbc6..6b5fb376 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<int, int> programHandles,
int componentSize,
diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyMS.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopyMS.cs
index 9963dc66..39f23272 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 c058ac88..d714caf3 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 90a2936d..21d8e449 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 c7c01a37..b4c567a8 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<ScreenCaptureImageInfo> 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 aac288b7..ebfe3ad6 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<BufferHandle, IntPtr> _maps = new Dictionary<BufferHandle, IntPtr>();
+ private readonly Dictionary<BufferHandle, IntPtr> _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<byte>(_bufferMap.ToPointer(), size).Slice(offset);
+ return new ReadOnlySpan<byte>(_bufferMap.ToPointer(), size)[offset..];
}
public unsafe ReadOnlySpan<byte> GetBufferData(BufferHandle buffer, int offset, int size)
diff --git a/src/Ryujinx.Graphics.OpenGL/Pipeline.cs b/src/Ryujinx.Graphics.OpenGL/Pipeline.cs
index 6b6d0289..df618d5b 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<int>[] _fpIsBgra = new Vector4<int>[SupportBuffer.FragmentIsBgraCount];
- private Vector4<float>[] _renderScale = new Vector4<float>[73];
+ private readonly Vector4<int>[] _fpIsBgra = new Vector4<int>[SupportBuffer.FragmentIsBgraCount];
+ private readonly Vector4<float>[] _renderScale = new Vector4<float>[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<BufferAssignment> buffers, bool isStorage)
+ private static void SetBuffers(ReadOnlySpan<BufferAssignment> 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 a6009108..cc9120c7 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 9d43f6c3..1470f5aa 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 648600bc..ff7e9a3e 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<CounterQueueEvent> _events = new Queue<CounterQueueEvent>();
+ private readonly Queue<CounterQueueEvent> _events = new();
private CounterQueueEvent _current;
private ulong _accumulatedCounter;
@@ -23,12 +23,12 @@ namespace Ryujinx.Graphics.OpenGL.Queries
private readonly object _lock = new();
- private Queue<BufferedQuery> _queryPool;
- private AutoResetEvent _queuedEvent = new AutoResetEvent(false);
- private AutoResetEvent _wakeSignal = new AutoResetEvent(false);
- private AutoResetEvent _eventConsumed = new AutoResetEvent(false);
+ private readonly Queue<BufferedQuery> _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 ffe1f774..7d224906 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 e6c7ab2b..91554eba 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 69d2a78e..bba5c5cb 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<TextureCreateInfo, List<DisposedTexture>> _textures = new Dictionary<TextureCreateInfo, List<DisposedTexture>>();
+ private readonly Dictionary<TextureCreateInfo, List<DisposedTexture>> _textures = new();
/// <summary>
/// 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<DisposedTexture> list;
- if (!_textures.TryGetValue(view.Info, out list))
+ if (!_textures.TryGetValue(view.Info, out List<DisposedTexture> list))
{
list = new List<DisposedTexture>();
_textures.Add(view.Info, list);
@@ -59,8 +58,7 @@ namespace Ryujinx.Graphics.OpenGL
{
lock (_lock)
{
- List<DisposedTexture> list;
- if (!_textures.TryGetValue(info, out list))
+ if (!_textures.TryGetValue(info, out List<DisposedTexture> list))
{
return null;
}
diff --git a/src/Ryujinx.Graphics.OpenGL/Sync.cs b/src/Ryujinx.Graphics.OpenGL/Sync.cs
index 58818e6a..54e9c6d3 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<SyncHandle> _handles = new List<SyncHandle>();
+ private readonly List<SyncHandle> _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 7d22033e..32211e78 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 cc9836e0..a928772f 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
+}