Fix ~3500 analyser issues

See merge request ryubing/ryujinx!44
This commit is contained in:
MrKev 2025-05-30 17:08:34 -05:00 committed by LotP
parent 417df486b1
commit 361d0c5632
622 changed files with 3080 additions and 2652 deletions

View file

@ -289,7 +289,7 @@ namespace Ryujinx.Graphics.Vulkan
if (_pendingData != null)
{
_mirrors.Clear();
};
}
}
public void ClearMirrors(CommandBufferScoped cbs, int offset, int size)
@ -309,7 +309,7 @@ namespace Ryujinx.Graphics.Vulkan
{
_gd.PipelineInternal.Rebind(_buffer, offset, size);
}
};
}
}
public void UseMirrors()

View file

@ -172,7 +172,7 @@ namespace Ryujinx.Graphics.Vulkan
{
return null;
}
List<Range> result = null;
int index = BinarySearch(list, offset, size);

View file

@ -194,12 +194,12 @@ namespace Ryujinx.Graphics.Vulkan
private static bool IsBufferType(ResourceType type)
{
return type == ResourceType.UniformBuffer || type == ResourceType.StorageBuffer;
return type is ResourceType.UniformBuffer or ResourceType.StorageBuffer;
}
private static bool IsBufferTextureType(ResourceType type)
{
return type == ResourceType.BufferTexture || type == ResourceType.BufferImage;
return type is ResourceType.BufferTexture or ResourceType.BufferImage;
}
public unsafe void Dispose()

View file

@ -235,7 +235,7 @@ namespace Ryujinx.Graphics.Vulkan
// Check stage bindings
_uniformMirrored.Union(_uniformSet).SignalSet((int binding, int count) =>
_uniformMirrored.Union(_uniformSet).SignalSet((binding, count) =>
{
for (int i = 0; i < count; i++)
{
@ -257,7 +257,7 @@ namespace Ryujinx.Graphics.Vulkan
}
});
_storageMirrored.Union(_storageSet).SignalSet((int binding, int count) =>
_storageMirrored.Union(_storageSet).SignalSet((binding, count) =>
{
for (int i = 0; i < count; i++)
{
@ -348,16 +348,16 @@ namespace Ryujinx.Graphics.Vulkan
if (segment.IsArray)
{
if (segment.Type == ResourceType.Texture ||
segment.Type == ResourceType.Sampler ||
segment.Type == ResourceType.TextureAndSampler ||
segment.Type == ResourceType.BufferTexture)
if (segment.Type is ResourceType.Texture or
ResourceType.Sampler or
ResourceType.TextureAndSampler or
ResourceType.BufferTexture)
{
ref ArrayRef<TextureArray> arrayRef = ref _textureArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts];
PipelineStageFlags stageFlags = arrayRef.Stage.ConvertToPipelineStageFlags();
arrayRef.Array?.QueueWriteToReadBarriers(cbs, stageFlags);
}
else if (segment.Type == ResourceType.Image || segment.Type == ResourceType.BufferImage)
else if (segment.Type is ResourceType.Image or ResourceType.BufferImage)
{
ref ArrayRef<ImageArray> arrayRef = ref _imageArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts];
PipelineStageFlags stageFlags = arrayRef.Stage.ConvertToPipelineStageFlags();
@ -1072,7 +1072,7 @@ namespace Ryujinx.Graphics.Vulkan
private void Initialize(CommandBufferScoped cbs, int setIndex, DescriptorSetCollection dsc)
{
// We don't support clearing texture descriptors currently.
if (setIndex != PipelineBase.UniformSetIndex && setIndex != PipelineBase.StorageSetIndex)
if (setIndex is not PipelineBase.UniformSetIndex and not PipelineBase.StorageSetIndex)
{
return;
}
@ -1102,10 +1102,10 @@ namespace Ryujinx.Graphics.Vulkan
{
DescriptorSet[] sets = null;
if (segment.Type == ResourceType.Texture ||
segment.Type == ResourceType.Sampler ||
segment.Type == ResourceType.TextureAndSampler ||
segment.Type == ResourceType.BufferTexture)
if (segment.Type is ResourceType.Texture or
ResourceType.Sampler or
ResourceType.TextureAndSampler or
ResourceType.BufferTexture)
{
sets = _textureArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts].Array.GetDescriptorSets(
_device,
@ -1116,7 +1116,7 @@ namespace Ryujinx.Graphics.Vulkan
_dummyTexture,
_dummySampler);
}
else if (segment.Type == ResourceType.Image || segment.Type == ResourceType.BufferImage)
else if (segment.Type is ResourceType.Image or ResourceType.BufferImage)
{
sets = _imageArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts].Array.GetDescriptorSets(
_device,

View file

@ -24,6 +24,7 @@ namespace Ryujinx.Graphics.Vulkan
{
// Keep waiting while the fence is not signaled.
}
result.ThrowOnError();
}
}

View file

@ -222,14 +222,14 @@ namespace Ryujinx.Graphics.Vulkan
public static bool IsD24S8(Format format)
{
return format == Format.D24UnormS8Uint || format == Format.S8UintD24Unorm || format == Format.X8UintD24Unorm;
return format is Format.D24UnormS8Uint or Format.S8UintD24Unorm or Format.X8UintD24Unorm;
}
private static bool IsRGB16IntFloat(Format format)
{
return format == Format.R16G16B16Float ||
format == Format.R16G16B16Sint ||
format == Format.R16G16B16Uint;
return format is Format.R16G16B16Float or
Format.R16G16B16Sint or
Format.R16G16B16Uint;
}
}
}

View file

@ -33,29 +33,29 @@ namespace Ryujinx.Graphics.Vulkan
private readonly PipelineHelperShader _pipeline;
private readonly ISampler _samplerLinear;
private readonly ISampler _samplerNearest;
private readonly IProgram _programColorBlit;
private readonly IProgram _programColorBlitMs;
private readonly IProgram _programColorBlitClearAlpha;
private readonly IProgram _programColorClearF;
private readonly IProgram _programColorClearSI;
private readonly IProgram _programColorClearUI;
private readonly IProgram _programDepthStencilClear;
private readonly IProgram _programStrideChange;
private readonly IProgram _programConvertD32S8ToD24S8;
private readonly IProgram _programConvertIndexBuffer;
private readonly IProgram _programConvertIndirectData;
private readonly IProgram _programColorCopyShortening;
private readonly IProgram _programColorCopyToNonMs;
private readonly IProgram _programColorCopyWidening;
private readonly IProgram _programColorDrawToMs;
private readonly IProgram _programDepthBlit;
private readonly IProgram _programDepthBlitMs;
private readonly IProgram _programDepthDrawToMs;
private readonly IProgram _programDepthDrawToNonMs;
private readonly IProgram _programStencilBlit;
private readonly IProgram _programStencilBlitMs;
private readonly IProgram _programStencilDrawToMs;
private readonly IProgram _programStencilDrawToNonMs;
private readonly ShaderCollection _programColorBlit;
private readonly ShaderCollection _programColorBlitMs;
private readonly ShaderCollection _programColorBlitClearAlpha;
private readonly ShaderCollection _programColorClearF;
private readonly ShaderCollection _programColorClearSI;
private readonly ShaderCollection _programColorClearUI;
private readonly ShaderCollection _programDepthStencilClear;
private readonly ShaderCollection _programStrideChange;
private readonly ShaderCollection _programConvertD32S8ToD24S8;
private readonly ShaderCollection _programConvertIndexBuffer;
private readonly ShaderCollection _programConvertIndirectData;
private readonly ShaderCollection _programColorCopyShortening;
private readonly ShaderCollection _programColorCopyToNonMs;
private readonly ShaderCollection _programColorCopyWidening;
private readonly ShaderCollection _programColorDrawToMs;
private readonly ShaderCollection _programDepthBlit;
private readonly ShaderCollection _programDepthBlitMs;
private readonly ShaderCollection _programDepthDrawToMs;
private readonly ShaderCollection _programDepthDrawToNonMs;
private readonly ShaderCollection _programStencilBlit;
private readonly ShaderCollection _programStencilBlitMs;
private readonly ShaderCollection _programStencilDrawToMs;
private readonly ShaderCollection _programStencilDrawToNonMs;
public HelperShader(VulkanRenderer gd, Device device)
{

View file

@ -40,6 +40,7 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK
path = path[..^VulkanLib.Length] + "libMoltenVK.dylib";
return [path];
}
return [];
}

View file

@ -1548,7 +1548,7 @@ namespace Ryujinx.Graphics.Vulkan
}
return false;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool UpdateFeedbackLoop()

View file

@ -192,14 +192,14 @@ namespace Ryujinx.Graphics.Vulkan
private readonly void RecordFeedbackLoop(ExtAttachmentFeedbackLoopDynamicState api, CommandBuffer commandBuffer)
{
ImageAspectFlags aspects = (_feedbackLoopAspects & FeedbackLoopAspects.Color) != 0 ? ImageAspectFlags.ColorBit : 0;
ImageAspectFlags aspects = (_feedbackLoopAspects & FeedbackLoopAspects.Color) != 0 ? ImageAspectFlags.ColorBit : 0;
if ((_feedbackLoopAspects & FeedbackLoopAspects.Depth) != 0)
{
aspects |= ImageAspectFlags.DepthBit | ImageAspectFlags.StencilBit;
}
if ((_feedbackLoopAspects & FeedbackLoopAspects.Depth) != 0)
{
aspects |= ImageAspectFlags.DepthBit | ImageAspectFlags.StencilBit;
}
api.CmdSetAttachmentFeedbackLoopEnable(commandBuffer, aspects);
api.CmdSetAttachmentFeedbackLoopEnable(commandBuffer, aspects);
}
}
}

View file

@ -433,11 +433,11 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
topologySupportsRestart = Topology == PrimitiveTopology.LineStrip ||
Topology == PrimitiveTopology.TriangleStrip ||
Topology == PrimitiveTopology.TriangleFan ||
Topology == PrimitiveTopology.LineStripWithAdjacency ||
Topology == PrimitiveTopology.TriangleStripWithAdjacency;
topologySupportsRestart = Topology is PrimitiveTopology.LineStrip or
PrimitiveTopology.TriangleStrip or
PrimitiveTopology.TriangleFan or
PrimitiveTopology.LineStripWithAdjacency or
PrimitiveTopology.TriangleStripWithAdjacency;
}
primitiveRestartEnable &= topologySupportsRestart;

View file

@ -105,6 +105,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
bool isOcclusion = _type == CounterType.SamplesPassed;
_pipeline.BeginQuery(this, _queryPool, needsReset, isOcclusion, isOcclusion && resetSequence != null);
}
_resetSequence = null;
}
@ -211,6 +212,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
{
_api.DestroyQueryPool(_device, _queryPool, null);
}
_queryPool = default;
}
}

View file

@ -198,6 +198,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
{
return; // If not blocking, then return when we encounter an event that is not ready yet.
}
_events.Dequeue();
}
}

View file

@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Vulkan
float minLod = info.MinLod;
float maxLod = info.MaxLod;
if (info.MinFilter == MinFilter.Nearest || info.MinFilter == MinFilter.Linear)
if (info.MinFilter is MinFilter.Nearest or MinFilter.Linear)
{
minLod = 0;
maxLod = 0.25f;

View file

@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Vulkan
return false;
}
}
//Prevent the sum of descriptors from exceeding MaxPushDescriptors
int totalDescriptors = 0;
foreach (ResourceDescriptor desc in layout.Sets.First().Descriptors)
@ -190,6 +190,7 @@ namespace Ryujinx.Graphics.Vulkan
if (!reserved.Contains(desc.Binding))
totalDescriptors += desc.Count;
}
if (totalDescriptors > gd.Capabilities.MaxPushDescriptors)
return false;
@ -391,7 +392,7 @@ namespace Ryujinx.Graphics.Vulkan
return templates;
}
private PipelineStageFlags GetPipelineStages(ResourceStages stages)
private static PipelineStageFlags GetPipelineStages(ResourceStages stages)
{
PipelineStageFlags result = 0;
@ -428,7 +429,7 @@ namespace Ryujinx.Graphics.Vulkan
return result;
}
private (PipelineStageFlags Buffer, PipelineStageFlags Texture) BuildIncoherentStages(ReadOnlyCollection<ResourceUsageCollection> setUsages)
private static (PipelineStageFlags Buffer, PipelineStageFlags Texture) BuildIncoherentStages(ReadOnlyCollection<ResourceUsageCollection> setUsages)
{
PipelineStageFlags buffer = PipelineStageFlags.None;
PipelineStageFlags texture = PipelineStageFlags.None;

View file

@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Vulkan
ImageCreateFlags flags = ImageCreateFlags.CreateMutableFormatBit | ImageCreateFlags.CreateExtendedUsageBit;
// This flag causes mipmapped texture arrays to break on AMD GCN, so for that copy dependencies are forced for aliasing as cube.
bool isCube = info.Target == Target.Cubemap || info.Target == Target.CubemapArray;
bool isCube = info.Target is Target.Cubemap or Target.CubemapArray;
bool cubeCompatible = gd.IsAmdGcn ? isCube : (info.Width == info.Height && layers >= 6);
if (type == ImageType.Type2D && cubeCompatible)
@ -336,7 +336,7 @@ namespace Ryujinx.Graphics.Vulkan
public static SampleCountFlags ConvertToSampleCountFlags(SampleCountFlags supportedSampleCounts, uint samples)
{
if (samples == 0 || samples > (uint)SampleCountFlags.Count64Bit)
if (samples is 0 or > ((uint)SampleCountFlags.Count64Bit))
{
return SampleCountFlags.Count1Bit;
}

View file

@ -78,9 +78,9 @@ namespace Ryujinx.Graphics.Vulkan
ComponentSwizzle swizzleB = info.SwizzleB.Convert();
ComponentSwizzle swizzleA = info.SwizzleA.Convert();
if (info.Format == Format.R5G5B5A1Unorm ||
info.Format == Format.R5G5B5X1Unorm ||
info.Format == Format.R5G6B5Unorm)
if (info.Format is Format.R5G5B5A1Unorm or
Format.R5G5B5X1Unorm or
Format.R5G6B5Unorm)
{
(swizzleB, swizzleR) = (swizzleR, swizzleB);
}

View file

@ -360,11 +360,11 @@ namespace Ryujinx.Graphics.Vulkan
IsAmdWindows = Vendor == Vendor.Amd && OperatingSystem.IsWindows();
IsIntelWindows = Vendor == Vendor.Intel && OperatingSystem.IsWindows();
IsTBDR =
Vendor == Vendor.Apple ||
Vendor == Vendor.Qualcomm ||
Vendor == Vendor.ARM ||
Vendor == Vendor.Broadcom ||
Vendor == Vendor.ImgTec;
Vendor is Vendor.Apple or
Vendor.Qualcomm or
Vendor.ARM or
Vendor.Broadcom or
Vendor.ImgTec;
GpuVendor = VendorUtils.GetNameFromId(properties.VendorID);
GpuDriver = hasDriverProperties && !OperatingSystem.IsMacOS() ?
@ -378,7 +378,7 @@ namespace Ryujinx.Graphics.Vulkan
GpuVersion = $"Vulkan v{ParseStandardVulkanVersion(properties.ApiVersion)}, Driver v{ParseDriverVersion(ref properties)}";
IsAmdGcn = !IsMoltenVk && Vendor == Vendor.Amd && Patterns.AmdGcn.IsMatch(GpuRenderer);
IsAmdRdna3 = Vendor == Vendor.Amd && (Patterns.AmdRdna3.IsMatch(GpuRenderer)
// ROG Ally (X) Device IDs
|| properties.DeviceID is 0x15BF or 0x15C8);
@ -903,7 +903,7 @@ namespace Ryujinx.Graphics.Vulkan
gpuInfoMessage = gpuInfoMessage.Prepend(GpuVendor);
Logger.Notice.Print(LogClass.Gpu, gpuInfoMessage);
Logger.Notice.Print(LogClass.Gpu, $"GPU Memory: {GetTotalGPUMemory() / (1024 * 1024)} MiB");
}

View file

@ -544,6 +544,7 @@ namespace Ryujinx.Graphics.Vulkan
_effect?.Dispose();
_effect = new SmaaPostProcessingEffect(_gd, _device, quality);
}
break;
}
}
@ -575,6 +576,7 @@ namespace Ryujinx.Graphics.Vulkan
_scalingFilter?.Dispose();
_scalingFilter = new AreaScalingFilter(_gd, _device);
}
break;
}
}