From 29f3df5bd86b0ee52ec895f8f439dbac5bc97591 Mon Sep 17 00:00:00 2001 From: Gabriel A Date: Fri, 27 Oct 2023 21:33:25 -0300 Subject: [PATCH] Format style --- .../Commands/RegisterBindlessSamplerCommand.cs | 2 +- .../Commands/RegisterBindlessTextureAndSamplerCommand.cs | 2 +- .../Commands/RegisterBindlessTextureCommand.cs | 2 +- src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs | 4 ++-- src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs | 2 +- src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs | 2 +- src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs | 4 ++-- src/Ryujinx.Graphics.OpenGL/Image/BindlessManager.cs | 4 ++-- .../CodeGen/Spirv/Instructions.cs | 3 ++- .../Translation/HelperFunctionManager.cs | 2 +- .../Translation/Transforms/TexturePass.cs | 2 +- src/Ryujinx.Graphics.Vulkan/BindlessManager.cs | 9 +++------ src/Ryujinx.Graphics.Vulkan/PipelineLayoutUsageInfo.cs | 6 +++--- src/Ryujinx.Graphics.Vulkan/PipelineState.cs | 6 ++---- 14 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessSamplerCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessSamplerCommand.cs index ec26ca38d..36493166a 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessSamplerCommand.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessSamplerCommand.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands { struct RegisterBindlessSamplerCommand : IGALCommand, IGALCommand { - public CommandType CommandType => CommandType.RegisterBindlessSampler; + public readonly CommandType CommandType => CommandType.RegisterBindlessSampler; private int _samplerId; private TableRef _sampler; diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureAndSamplerCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureAndSamplerCommand.cs index 27463cce6..6c422c29d 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureAndSamplerCommand.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureAndSamplerCommand.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands { struct RegisterBindlessTextureAndSamplerCommand : IGALCommand, IGALCommand { - public CommandType CommandType => CommandType.RegisterBindlessTextureAndSampler; + public readonly CommandType CommandType => CommandType.RegisterBindlessTextureAndSampler; private int _textureId; private int _samplerId; private TableRef _texture; diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureCommand.cs index 1e3389844..039921a89 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureCommand.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/RegisterBindlessTextureCommand.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands { struct RegisterBindlessTextureCommand : IGALCommand, IGALCommand { - public CommandType CommandType => CommandType.RegisterBindlessTexture; + public readonly CommandType CommandType => CommandType.RegisterBindlessTexture; private int _textureId; private TableRef _texture; private float _textureScale; diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs index 660676350..79fe6fecf 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs @@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the font filter width. /// /// Font filter width - public int UnpackFontFilterWidth() + public readonly int UnpackFontFilterWidth() { return (int)(Word0 >> 14) & 7; } @@ -126,7 +126,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the font filter height. /// /// Font filter height - public int UnpackFontFilterHeight() + public readonly int UnpackFontFilterHeight() { return (int)(Word0 >> 17) & 7; } diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index ea2bd00ba..26ef5a53e 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -813,7 +813,7 @@ namespace Ryujinx.Graphics.Gpu.Image // Ensure that the buffer texture is using the correct buffer as storage. // Buffers are frequently re-created to accomodate larger data, so we need to re-bind // to ensure we're not using a old buffer that was already deleted. - TextureBindingInfo bindingInfo = new TextureBindingInfo(texture.Target, texture.Format, 0, 0, 0, TextureUsageFlags.None); + TextureBindingInfo bindingInfo = new(texture.Target, texture.Format, 0, 0, 0, TextureUsageFlags.None); ulong address = texture.Range.GetSubRange(0).Address; ulong size = texture.Size; _channel.BufferManager.SetBufferTextureStorage(texture.HostTexture, address, size, bindingInfo, texture.Format, false, textureId); diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index cbb163b5b..ee652355a 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -275,7 +275,7 @@ namespace Ryujinx.Graphics.Gpu.Image return null; } - TextureInfo info = GetInfo(descriptor, out int layerSize); + TextureInfo info = GetInfo(descriptor, out _); TextureValidationResult validationResult = TextureValidation.Validate(ref info); if (validationResult != TextureValidationResult.Valid) diff --git a/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs b/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs index 43a3b22c4..3cc8f94b9 100644 --- a/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs +++ b/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.OpenGL { static class HwCapabilities { - private static readonly Lazy _supportsArbBindlessTexture = new Lazy(() => HasExtension("GL_ARB_bindless_texture")); + private static readonly Lazy _supportsArbBindlessTexture = new(() => HasExtension("GL_ARB_bindless_texture")); 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")); @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.OpenGL 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 _supportsNvBindlessTexture = new Lazy(() => HasExtension("GL_NV_bindless_texture")); + private static readonly Lazy _supportsNvBindlessTexture = new(() => HasExtension("GL_NV_bindless_texture")); 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); diff --git a/src/Ryujinx.Graphics.OpenGL/Image/BindlessManager.cs b/src/Ryujinx.Graphics.OpenGL/Image/BindlessManager.cs index 773cc1a99..5a0dcba2d 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/BindlessManager.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/BindlessManager.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.OpenGL.Image private readonly Dictionary _separateTextures; private readonly Dictionary _separateSamplers; - private readonly HashSet _handles = new HashSet(); + private readonly HashSet _handles = new(); public BindlessManager(OpenGLRenderer renderer) { @@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.OpenGL.Image if (hasDeletedSamplers) { - List toRemove = new List(); + List toRemove = new(); foreach ((int samplerId, ISampler sampler) in _separateSamplers) { diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs index a6f49c692..1cf9df4a5 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs @@ -1262,7 +1262,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv } SpvInstruction pCoords = AssemblePVector(pCount); - SpvInstruction bindlessIndex = isBindless ? GenerateBindlessTextureHandleToIndex(context, bindlessHandle) : null; + + _ = isBindless ? GenerateBindlessTextureHandleToIndex(context, bindlessHandle) : null; SpvInstruction AssembleDerivativesVector(int count) { diff --git a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs index 3ed56cc4d..30c7c5fc9 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs @@ -497,7 +497,7 @@ namespace Ryujinx.Graphics.Shader.Translation } } - private Operand GetBindlessScale(EmitterContext context, Operand nvHandle) + private static Operand GetBindlessScale(EmitterContext context, Operand nvHandle) { int bindlessTableBinding = SetBindingPair.Pack(Constants.BindlessTextureSetIndex, Constants.BindlessTableBinding); int bindlessScalesBinding = SetBindingPair.Pack(Constants.BindlessTextureSetIndex, Constants.BindlessScalesBinding); diff --git a/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs b/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs index 94c20cded..4c7fbab0a 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Transforms/TexturePass.cs @@ -870,7 +870,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms // Try to detect a indexed access. // The access is considered indexed if the handle is loaded with a LDC instruction // from the driver reserved constant buffer used for texture handles. - if (!(texOp.GetSource(0).AsgOp is Operation handleAsgOp)) + if (texOp.GetSource(0).AsgOp is not Operation handleAsgOp) { return false; } diff --git a/src/Ryujinx.Graphics.Vulkan/BindlessManager.cs b/src/Ryujinx.Graphics.Vulkan/BindlessManager.cs index 0190e8fb0..46e599433 100644 --- a/src/Ryujinx.Graphics.Vulkan/BindlessManager.cs +++ b/src/Ryujinx.Graphics.Vulkan/BindlessManager.cs @@ -2,8 +2,8 @@ using Ryujinx.Common; using Ryujinx.Graphics.GAL; using Silk.NET.Vulkan; using System; -using System.Numerics; using System.Collections.Generic; +using System.Numerics; using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Vulkan @@ -187,10 +187,7 @@ namespace Ryujinx.Graphics.Vulkan int idMapBufferSizeInBytes = _idMap.Length * sizeof(int); - if (_idMapBuffer == null) - { - _idMapBuffer = gd.BufferManager.Create(gd, idMapBufferSizeInBytes); - } + _idMapBuffer ??= gd.BufferManager.Create(gd, idMapBufferSizeInBytes); if (_idMapDataDirty) { @@ -324,7 +321,7 @@ namespace Ryujinx.Graphics.Vulkan } } - private void Bind( + private static void Bind( VulkanRenderer gd, ShaderCollection program, CommandBufferScoped cbs, diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutUsageInfo.cs b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutUsageInfo.cs index 81d32b1de..ab894774c 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutUsageInfo.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutUsageInfo.cs @@ -2,7 +2,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct PipelineLayoutUsageInfo : IEquatable + readonly struct PipelineLayoutUsageInfo : IEquatable { public readonly uint BindlessTexturesCount; public readonly uint BindlessSamplersCount; @@ -20,14 +20,14 @@ namespace Ryujinx.Graphics.Vulkan return obj is PipelineLayoutUsageInfo other && Equals(other); } - public bool Equals(PipelineLayoutUsageInfo other) + public readonly bool Equals(PipelineLayoutUsageInfo other) { return BindlessTexturesCount == other.BindlessTexturesCount && BindlessSamplersCount == other.BindlessSamplersCount && UsePushDescriptors == other.UsePushDescriptors; } - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(BindlessTexturesCount, BindlessSamplersCount, UsePushDescriptors); } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index 90893e839..60219b2be 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -312,14 +312,12 @@ namespace Ryujinx.Graphics.Vulkan } public uint BindlessTexturesCount - { - get => (uint)((Internal.Id10 >> 0) & 0xFFFFFFFF); + { readonly get => (uint)((Internal.Id10 >> 0) & 0xFFFFFFFF); set => Internal.Id10 = (Internal.Id10 & 0xFFFFFFFF00000000) | ((ulong)value << 0); } public uint BindlessSamplersCount - { - get => (uint)((Internal.Id10 >> 32) & 0xFFFFFFFF); + { readonly get => (uint)((Internal.Id10 >> 32) & 0xFFFFFFFF); set => Internal.Id10 = (Internal.Id10 & 0xFFFFFFFF) | ((ulong)value << 32); }