Prefer using collection expressions with implicit object creation when the type is clear

This commit is contained in:
Marco Carvalho
2024-12-27 13:23:31 -03:00
parent 850df38f1e
commit 57d1486da9
510 changed files with 6022 additions and 6212 deletions

View File

@@ -69,7 +69,7 @@ namespace Ryujinx.Graphics.Vulkan
_gd = gd;
_device = device;
_resources = new Dictionary<Thread, BackgroundResource>();
_resources = [];
}
private void Cleanup()

View File

@@ -19,9 +19,9 @@ namespace Ryujinx.Graphics.Vulkan
private readonly NativeArray<BufferMemoryBarrier> _bufferBarrierBatch = new(MaxBarriersPerCall);
private readonly NativeArray<ImageMemoryBarrier> _imageBarrierBatch = new(MaxBarriersPerCall);
private readonly List<BarrierWithStageFlags<MemoryBarrier, int>> _memoryBarriers = new();
private readonly List<BarrierWithStageFlags<BufferMemoryBarrier, int>> _bufferBarriers = new();
private readonly List<BarrierWithStageFlags<ImageMemoryBarrier, TextureStorage>> _imageBarriers = new();
private readonly List<BarrierWithStageFlags<MemoryBarrier, int>> _memoryBarriers = [];
private readonly List<BarrierWithStageFlags<BufferMemoryBarrier, int>> _bufferBarriers = [];
private readonly List<BarrierWithStageFlags<ImageMemoryBarrier, TextureStorage>> _imageBarriers = [];
private int _queuedBarrierCount;
private enum IncoherentBarrierType
@@ -145,7 +145,7 @@ namespace Ryujinx.Graphics.Vulkan
stages |= PipelineStageFlags.DrawIndirectBit;
}
MemoryBarrier barrier = new MemoryBarrier()
MemoryBarrier barrier = new()
{
SType = StructureType.MemoryBarrier,
SrcAccessMask = access,
@@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Vulkan
{
// Feedback loop barrier.
MemoryBarrier barrier = new MemoryBarrier()
MemoryBarrier barrier = new()
{
SType = StructureType.MemoryBarrier,
SrcAccessMask = AccessFlags.ShaderWriteBit,

View File

@@ -486,7 +486,7 @@ namespace Ryujinx.Graphics.Vulkan
(int keyOffset, int keySize) = FromMirrorKey(key);
if (!(offset + size <= keyOffset || offset >= keyOffset + keySize))
{
toRemove ??= new List<ulong>();
toRemove ??= [];
toRemove.Add(key);
}
@@ -551,7 +551,7 @@ namespace Ryujinx.Graphics.Vulkan
if (_pendingData == null)
{
_pendingData = new byte[Size];
_mirrors = new Dictionary<ulong, StagingBufferReserved>();
_mirrors = [];
}
data[..dataSize].CopyTo(_pendingData.AsSpan(offset, dataSize));

View File

@@ -207,14 +207,14 @@ namespace Ryujinx.Graphics.Vulkan
fixed (SparseMemoryBind* pMemoryBinds = memoryBinds)
{
SparseBufferMemoryBindInfo bufferBind = new SparseBufferMemoryBindInfo()
SparseBufferMemoryBindInfo bufferBind = new()
{
Buffer = buffer,
BindCount = (uint)memoryBinds.Length,
PBinds = pMemoryBinds
};
BindSparseInfo bindSparseInfo = new BindSparseInfo()
BindSparseInfo bindSparseInfo = new()
{
SType = StructureType.BindSparseInfo,
BufferBindCount = 1,

View File

@@ -150,10 +150,10 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
_ranges = new List<Range>
{
new Range(offset, size)
};
_ranges =
[
new(offset, size)
];
}
}

View File

@@ -249,7 +249,7 @@ namespace Ryujinx.Graphics.Vulkan
{
if (entry.DependencyList == null)
{
entry.DependencyList = new List<Dependency>();
entry.DependencyList = [];
entries[i] = entry;
}
@@ -340,7 +340,7 @@ namespace Ryujinx.Graphics.Vulkan
DestroyEntry(entry);
}
(toRemove ??= new List<ulong>()).Add(range.Key);
(toRemove ??= []).Add(range.Key);
}
}
@@ -356,13 +356,13 @@ namespace Ryujinx.Graphics.Vulkan
private List<Entry> GetEntries(int offset, int size)
{
_ranges ??= new Dictionary<ulong, List<Entry>>();
_ranges ??= [];
ulong key = PackRange(offset, size);
if (!_ranges.TryGetValue(key, out List<Entry> value))
{
value = new List<Entry>();
value = [];
_ranges.Add(key, value);
}

View File

@@ -47,8 +47,8 @@ namespace Ryujinx.Graphics.Vulkan
api.AllocateCommandBuffers(device, in allocateInfo, out CommandBuffer);
Dependants = new List<IAuto>();
Waitables = new List<MultiFenceHolder>();
Dependants = [];
Waitables = [];
}
}

View File

@@ -167,8 +167,7 @@ namespace Ryujinx.Graphics.Vulkan
int consumedDescriptors,
bool updateAfterBind)
{
Span<DescriptorSetLayout> layouts = stackalloc DescriptorSetLayout[1];
layouts[0] = layout;
Span<DescriptorSetLayout> layouts = [layout];
return AllocateDescriptorSets(api, layouts, poolSizes, poolIndex, consumedDescriptors, updateAfterBind);
}

View File

@@ -141,11 +141,11 @@ namespace Ryujinx.Graphics.Vulkan
_bufferTextureRefs = new TextureBuffer[Constants.MaxTextureBindings * 2];
_bufferImageRefs = new TextureBuffer[Constants.MaxImageBindings * 2];
_textureArrayRefs = Array.Empty<ArrayRef<TextureArray>>();
_imageArrayRefs = Array.Empty<ArrayRef<ImageArray>>();
_textureArrayRefs = [];
_imageArrayRefs = [];
_textureArrayExtraRefs = Array.Empty<ArrayRef<TextureArray>>();
_imageArrayExtraRefs = Array.Empty<ArrayRef<ImageArray>>();
_textureArrayExtraRefs = [];
_imageArrayExtraRefs = [];
_uniformBuffers = new DescriptorBufferInfo[Constants.MaxUniformBufferBindings];
_storageBuffers = new DescriptorBufferInfo[Constants.MaxStorageBufferBindings];
@@ -217,7 +217,7 @@ namespace Ryujinx.Graphics.Vulkan
if (isMainPipeline)
{
FeedbackLoopHazards = new();
FeedbackLoopHazards = [];
}
}
@@ -937,7 +937,7 @@ namespace Ryujinx.Graphics.Vulkan
var sets = dsc.GetSets();
_templateUpdater.Commit(_gd, _device, sets[0]);
_gd.Api.CmdBindDescriptorSets(cbs.CommandBuffer, pbp, _program.PipelineLayout, (uint)setIndex, 1, sets, 0, ReadOnlySpan<uint>.Empty);
_gd.Api.CmdBindDescriptorSets(cbs.CommandBuffer, pbp, _program.PipelineLayout, (uint)setIndex, 1, sets, 0, []);
}
private void UpdateAndBindTexturesWithoutTemplate(CommandBufferScoped cbs, ShaderCollection program, PipelineBindPoint pbp)
@@ -1017,7 +1017,7 @@ namespace Ryujinx.Graphics.Vulkan
var sets = dsc.GetSets();
_gd.Api.CmdBindDescriptorSets(cbs.CommandBuffer, pbp, _program.PipelineLayout, (uint)setIndex, 1, sets, 0, ReadOnlySpan<uint>.Empty);
_gd.Api.CmdBindDescriptorSets(cbs.CommandBuffer, pbp, _program.PipelineLayout, (uint)setIndex, 1, sets, 0, []);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -1129,7 +1129,7 @@ namespace Ryujinx.Graphics.Vulkan
if (sets != null)
{
_gd.Api.CmdBindDescriptorSets(cbs.CommandBuffer, pbp, _program.PipelineLayout, (uint)setIndex, 1, sets, 0, ReadOnlySpan<uint>.Empty);
_gd.Api.CmdBindDescriptorSets(cbs.CommandBuffer, pbp, _program.PipelineLayout, (uint)setIndex, 1, sets, 0, []);
}
}
}

View File

@@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroyBuffer(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroyBuffer(_device, Value, []);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroyBufferView(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroyBufferView(_device, Value, []);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroyFramebuffer(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroyFramebuffer(_device, Value, []);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroyImage(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroyImage(_device, Value, []);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroyImageView(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroyImageView(_device, Value, []);
}
}
}

View File

@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.FreeMemory(_device, _memory, Span<AllocationCallbacks>.Empty);
_api.FreeMemory(_device, _memory, []);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroyPipeline(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroyPipeline(_device, Value, []);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroyRenderPass(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroyRenderPass(_device, Value, []);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan
public void Dispose()
{
_api.DestroySampler(_device, Value, Span<AllocationCallbacks>.Empty);
_api.DestroySampler(_device, Value, []);
}
}
}

View File

@@ -50,10 +50,10 @@ namespace Ryujinx.Graphics.Vulkan.Effects
_sampler = _renderer.CreateSampler(SamplerCreateInfo.Create(MinFilter.Linear, MagFilter.Linear));
_scalingProgram = _renderer.CreateProgramWithMinimalLayout(new[]
{
_scalingProgram = _renderer.CreateProgramWithMinimalLayout(
[
new ShaderSource(scalingShader, ShaderStage.Compute, TargetLanguage.Spirv),
}, scalingResourceLayout);
], scalingResourceLayout);
}
public void Run(
@@ -70,8 +70,8 @@ namespace Ryujinx.Graphics.Vulkan.Effects
_pipeline.SetProgram(_scalingProgram);
_pipeline.SetTextureAndSampler(ShaderStage.Compute, 1, view, _sampler);
ReadOnlySpan<float> dimensionsBuffer = stackalloc float[]
{
ReadOnlySpan<float> dimensionsBuffer =
[
source.X1,
source.X2,
source.Y1,
@@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Vulkan.Effects
destination.X2,
destination.Y1,
destination.Y2,
};
];
int rangeSize = dimensionsBuffer.Length * sizeof(float);
using var buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
@@ -90,7 +90,7 @@ namespace Ryujinx.Graphics.Vulkan.Effects
int dispatchX = (width + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchY = (height + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(2, buffer.Range)]);
_pipeline.SetImage(0, destinationTexture);
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
_pipeline.ComputeBarrier();

View File

@@ -70,15 +70,15 @@ namespace Ryujinx.Graphics.Vulkan.Effects
_sampler = _renderer.CreateSampler(SamplerCreateInfo.Create(MinFilter.Linear, MagFilter.Linear));
_scalingProgram = _renderer.CreateProgramWithMinimalLayout(new[]
{
_scalingProgram = _renderer.CreateProgramWithMinimalLayout(
[
new ShaderSource(scalingShader, ShaderStage.Compute, TargetLanguage.Spirv),
}, scalingResourceLayout);
], scalingResourceLayout);
_sharpeningProgram = _renderer.CreateProgramWithMinimalLayout(new[]
{
_sharpeningProgram = _renderer.CreateProgramWithMinimalLayout(
[
new ShaderSource(sharpeningShader, ShaderStage.Compute, TargetLanguage.Spirv),
}, sharpeningResourceLayout);
], sharpeningResourceLayout);
}
public void Run(
@@ -127,8 +127,8 @@ namespace Ryujinx.Graphics.Vulkan.Effects
float scaleX = srcWidth / view.Width;
float scaleY = srcHeight / view.Height;
ReadOnlySpan<float> dimensionsBuffer = stackalloc float[]
{
ReadOnlySpan<float> dimensionsBuffer =
[
source.X1,
source.X2,
source.Y1,
@@ -139,13 +139,13 @@ namespace Ryujinx.Graphics.Vulkan.Effects
destination.Y2,
scaleX,
scaleY,
};
];
int rangeSize = dimensionsBuffer.Length * sizeof(float);
using var buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
buffer.Holder.SetDataUnchecked(buffer.Offset, dimensionsBuffer);
ReadOnlySpan<float> sharpeningBufferData = stackalloc float[] { 1.5f - (Level * 0.01f * 1.5f) };
ReadOnlySpan<float> sharpeningBufferData = [1.5f - (Level * 0.01f * 1.5f)];
using var sharpeningBuffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, sizeof(float));
sharpeningBuffer.Holder.SetDataUnchecked(sharpeningBuffer.Offset, sharpeningBufferData);
@@ -153,7 +153,7 @@ namespace Ryujinx.Graphics.Vulkan.Effects
int dispatchX = (width + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchY = (height + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(2, buffer.Range)]);
_pipeline.SetImage(ShaderStage.Compute, 0, _intermediaryTexture.GetView(FormatTable.ConvertRgba8SrgbToUnorm(view.Info.Format)));
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
_pipeline.ComputeBarrier();
@@ -161,7 +161,7 @@ namespace Ryujinx.Graphics.Vulkan.Effects
// Sharpening pass
_pipeline.SetProgram(_sharpeningProgram);
_pipeline.SetTextureAndSampler(ShaderStage.Compute, 1, _intermediaryTexture, _sampler);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(4, sharpeningBuffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(4, sharpeningBuffer.Range)]);
_pipeline.SetImage(0, destinationTexture);
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
_pipeline.ComputeBarrier();

View File

@@ -46,10 +46,10 @@ namespace Ryujinx.Graphics.Vulkan.Effects
_samplerLinear = _renderer.CreateSampler(SamplerCreateInfo.Create(MinFilter.Linear, MagFilter.Linear));
_shaderProgram = _renderer.CreateProgramWithMinimalLayout(new[]
{
_shaderProgram = _renderer.CreateProgramWithMinimalLayout(
[
new ShaderSource(shader, ShaderStage.Compute, TargetLanguage.Spirv),
}, resourceLayout);
], resourceLayout);
}
public TextureView Run(TextureView view, CommandBufferScoped cbs, int width, int height)
@@ -64,13 +64,13 @@ namespace Ryujinx.Graphics.Vulkan.Effects
_pipeline.SetProgram(_shaderProgram);
_pipeline.SetTextureAndSampler(ShaderStage.Compute, 1, view, _samplerLinear);
ReadOnlySpan<float> resolutionBuffer = stackalloc float[] { view.Width, view.Height };
ReadOnlySpan<float> resolutionBuffer = [view.Width, view.Height];
int rangeSize = resolutionBuffer.Length * sizeof(float);
using var buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
buffer.Holder.SetDataUnchecked(buffer.Offset, resolutionBuffer);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(2, buffer.Range)]);
var dispatchX = BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize);
var dispatchY = BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize);

View File

@@ -116,20 +116,20 @@ namespace Ryujinx.Graphics.Vulkan.Effects
(4, SpecConstType.Float32),
(5, SpecConstType.Float32));
_edgeProgram = _renderer.CreateProgramWithMinimalLayout(new[]
{
_edgeProgram = _renderer.CreateProgramWithMinimalLayout(
[
new ShaderSource(edgeShader, ShaderStage.Compute, TargetLanguage.Spirv),
}, edgeResourceLayout, new[] { specInfo });
], edgeResourceLayout, [specInfo]);
_blendProgram = _renderer.CreateProgramWithMinimalLayout(new[]
{
_blendProgram = _renderer.CreateProgramWithMinimalLayout(
[
new ShaderSource(blendShader, ShaderStage.Compute, TargetLanguage.Spirv),
}, blendResourceLayout, new[] { specInfo });
], blendResourceLayout, [specInfo]);
_neighbourProgram = _renderer.CreateProgramWithMinimalLayout(new[]
{
_neighbourProgram = _renderer.CreateProgramWithMinimalLayout(
[
new ShaderSource(neighbourShader, ShaderStage.Compute, TargetLanguage.Spirv),
}, neighbourResourceLayout, new[] { specInfo });
], neighbourResourceLayout, [specInfo]);
}
public void DeletePipelines()
@@ -213,12 +213,12 @@ namespace Ryujinx.Graphics.Vulkan.Effects
_pipeline.SetTextureAndSampler(ShaderStage.Compute, 1, view, _samplerLinear);
_pipeline.Specialize(_specConstants);
ReadOnlySpan<float> resolutionBuffer = stackalloc float[] { view.Width, view.Height };
ReadOnlySpan<float> resolutionBuffer = [view.Width, view.Height];
int rangeSize = resolutionBuffer.Length * sizeof(float);
using var buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
buffer.Holder.SetDataUnchecked(buffer.Offset, resolutionBuffer);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(2, buffer.Range)]);
_pipeline.SetImage(ShaderStage.Compute, 0, _edgeOutputTexture.GetView(FormatTable.ConvertRgba8SrgbToUnorm(view.Info.Format)));
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
_pipeline.ComputeBarrier();
@@ -249,13 +249,9 @@ namespace Ryujinx.Graphics.Vulkan.Effects
private void Clear(TextureView texture)
{
Span<uint> colorMasks = stackalloc uint[1];
Span<uint> colorMasks = [0xf];
colorMasks[0] = 0xf;
Span<Rectangle<int>> scissors = stackalloc Rectangle<int>[1];
scissors[0] = new Rectangle<int>(0, 0, texture.Width, texture.Height);
Span<Rectangle<int>> scissors = [new Rectangle<int>(0, 0, texture.Width, texture.Height)];
_pipeline.SetRenderTarget(texture, (uint)texture.Width, (uint)texture.Height);
_pipeline.SetRenderTargetColorMasks(colorMasks);

View File

@@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Vulkan
{
if (Interlocked.Decrement(ref _referenceCount) == 0)
{
_api.DestroyFence(_device, _fence, Span<AllocationCallbacks>.Empty);
_api.DestroyFence(_device, _fence, []);
_fence = default;
}
}
@@ -110,7 +110,7 @@ namespace Ryujinx.Graphics.Vulkan
try
{
FenceHelper.WaitAllIndefinitely(_api, _device, stackalloc Fence[] { _fence });
FenceHelper.WaitAllIndefinitely(_api, _device, [_fence]);
}
finally
{
@@ -119,7 +119,7 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
FenceHelper.WaitAllIndefinitely(_api, _device, stackalloc Fence[] { _fence });
FenceHelper.WaitAllIndefinitely(_api, _device, [_fence]);
}
}
@@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.Vulkan
try
{
return FenceHelper.AllSignaled(_api, _device, stackalloc Fence[] { _fence });
return FenceHelper.AllSignaled(_api, _device, [_fence]);
}
finally
{
@@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
return FenceHelper.AllSignaled(_api, _device, stackalloc Fence[] { _fence });
return FenceHelper.AllSignaled(_api, _device, [_fence]);
}
}

View File

@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Vulkan
{
class FormatCapabilities
{
private static readonly GAL.Format[] _scaledFormats = {
private static readonly GAL.Format[] _scaledFormats = [
GAL.Format.R8Uscaled,
GAL.Format.R8Sscaled,
GAL.Format.R16Uscaled,
@@ -28,9 +28,9 @@ namespace Ryujinx.Graphics.Vulkan
GAL.Format.R16G16B16A16Sscaled,
GAL.Format.R10G10B10A2Uscaled,
GAL.Format.R10G10B10A2Sscaled,
};
];
private static readonly GAL.Format[] _intFormats = {
private static readonly GAL.Format[] _intFormats = [
GAL.Format.R8Uint,
GAL.Format.R8Sint,
GAL.Format.R16Uint,
@@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Vulkan
GAL.Format.R16G16B16A16Sint,
GAL.Format.R10G10B10A2Uint,
GAL.Format.R10G10B10A2Sint,
};
];
private readonly FormatFeatureFlags[] _bufferTable;
private readonly FormatFeatureFlags[] _optimalTable;

View File

@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Vulkan
static FormatTable()
{
_table = new VkFormat[Enum.GetNames<Format>().Length];
_reverseMap = new Dictionary<VkFormat, Format>();
_reverseMap = [];
#pragma warning disable IDE0055 // Disable formatting
Add(Format.R8Unorm, VkFormat.R8Unorm);

View File

@@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Vulkan
bool isDepthStencil = format.IsDepthOrStencil();
_device = device;
_attachments = new[] { view.GetImageViewForAttachment() };
_attachments = [view.GetImageViewForAttachment()];
_validColorAttachments = isDepthStencil ? 0u : 1u;
_baseAttachment = view;
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
_colors = new TextureView[] { view };
_colors = [view];
_colorsCanonical = _colors;
}
@@ -56,9 +56,9 @@ namespace Ryujinx.Graphics.Vulkan
Height = height;
Layers = 1;
AttachmentSamples = new[] { (uint)view.Info.Samples };
AttachmentFormats = new[] { view.VkFormat };
AttachmentIndices = isDepthStencil ? Array.Empty<int>() : new[] { 0 };
AttachmentSamples = [(uint)view.Info.Samples];
AttachmentFormats = [view.VkFormat];
AttachmentIndices = isDepthStencil ? [] : [0];
AttachmentIntegerFormatMask = format.IsInteger() ? 1u : 0u;
LogicOpsAllowed = !format.IsFloatOrSrgb();

View File

@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Vulkan
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly Span<Entry> AsSpan()
{
return Entries == null ? Span<Entry>.Empty : Entries.AsSpan(0, Length);
return Entries == null ? [] : Entries.AsSpan(0, Length);
}
}
@@ -89,10 +89,10 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
bucket.Entries = new[]
{
bucket.Entries =
[
entry,
};
];
}
bucket.Length++;

View File

@@ -68,109 +68,109 @@ namespace Ryujinx.Graphics.Vulkan
.Add(ResourceStages.Vertex, ResourceType.UniformBuffer, 1)
.Add(ResourceStages.Fragment, ResourceType.TextureAndSampler, 0).Build();
_programColorBlit = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorBlit = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorBlitVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("ColorBlitFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, blitResourceLayout);
], blitResourceLayout);
_programColorBlitMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorBlitMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorBlitVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("ColorBlitMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, blitResourceLayout);
], blitResourceLayout);
_programColorBlitClearAlpha = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorBlitClearAlpha = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorBlitVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("ColorBlitClearAlphaFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, blitResourceLayout);
], blitResourceLayout);
var colorClearResourceLayout = new ResourceLayoutBuilder().Add(ResourceStages.Vertex, ResourceType.UniformBuffer, 1).Build();
_programColorClearF = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorClearF = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorClearVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("ColorClearFFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorClearResourceLayout);
], colorClearResourceLayout);
_programColorClearSI = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorClearSI = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorClearVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("ColorClearSIFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorClearResourceLayout);
], colorClearResourceLayout);
_programColorClearUI = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorClearUI = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorClearVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("ColorClearUIFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorClearResourceLayout);
], colorClearResourceLayout);
_programDepthStencilClear = gd.CreateProgramWithMinimalLayout(new[]
{
_programDepthStencilClear = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorClearVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("DepthStencilClearFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorClearResourceLayout);
], colorClearResourceLayout);
var strideChangeResourceLayout = new ResourceLayoutBuilder()
.Add(ResourceStages.Compute, ResourceType.UniformBuffer, 0)
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 1)
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 2, true).Build();
_programStrideChange = gd.CreateProgramWithMinimalLayout(new[]
{
_programStrideChange = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ChangeBufferStride.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
}, strideChangeResourceLayout);
], strideChangeResourceLayout);
var colorCopyResourceLayout = new ResourceLayoutBuilder()
.Add(ResourceStages.Compute, ResourceType.UniformBuffer, 0)
.Add(ResourceStages.Compute, ResourceType.TextureAndSampler, 0)
.Add(ResourceStages.Compute, ResourceType.Image, 0, true).Build();
_programColorCopyShortening = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorCopyShortening = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorCopyShorteningCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
}, colorCopyResourceLayout);
], colorCopyResourceLayout);
_programColorCopyToNonMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorCopyToNonMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorCopyToNonMsCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
}, colorCopyResourceLayout);
], colorCopyResourceLayout);
_programColorCopyWidening = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorCopyWidening = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorCopyWideningCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
}, colorCopyResourceLayout);
], colorCopyResourceLayout);
var colorDrawToMsResourceLayout = new ResourceLayoutBuilder()
.Add(ResourceStages.Fragment, ResourceType.UniformBuffer, 0)
.Add(ResourceStages.Fragment, ResourceType.TextureAndSampler, 0).Build();
_programColorDrawToMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programColorDrawToMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorDrawToMsVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("ColorDrawToMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorDrawToMsResourceLayout);
], colorDrawToMsResourceLayout);
var convertD32S8ToD24S8ResourceLayout = new ResourceLayoutBuilder()
.Add(ResourceStages.Compute, ResourceType.UniformBuffer, 0)
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 1)
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 2, true).Build();
_programConvertD32S8ToD24S8 = gd.CreateProgramWithMinimalLayout(new[]
{
_programConvertD32S8ToD24S8 = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ConvertD32S8ToD24S8.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
}, convertD32S8ToD24S8ResourceLayout);
], convertD32S8ToD24S8ResourceLayout);
var convertIndexBufferResourceLayout = new ResourceLayoutBuilder()
.Add(ResourceStages.Compute, ResourceType.UniformBuffer, 0)
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 1)
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 2, true).Build();
_programConvertIndexBuffer = gd.CreateProgramWithMinimalLayout(new[]
{
_programConvertIndexBuffer = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ConvertIndexBuffer.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
}, convertIndexBufferResourceLayout);
], convertIndexBufferResourceLayout);
var convertIndirectDataResourceLayout = new ResourceLayoutBuilder()
.Add(ResourceStages.Compute, ResourceType.UniformBuffer, 0)
@@ -178,60 +178,60 @@ namespace Ryujinx.Graphics.Vulkan
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 2, true)
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 3).Build();
_programConvertIndirectData = gd.CreateProgramWithMinimalLayout(new[]
{
_programConvertIndirectData = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ConvertIndirectData.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
}, convertIndirectDataResourceLayout);
], convertIndirectDataResourceLayout);
_programDepthBlit = gd.CreateProgramWithMinimalLayout(new[]
{
_programDepthBlit = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorBlitVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("DepthBlitFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, blitResourceLayout);
], blitResourceLayout);
_programDepthBlitMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programDepthBlitMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorBlitVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("DepthBlitMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, blitResourceLayout);
], blitResourceLayout);
_programDepthDrawToMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programDepthDrawToMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorDrawToMsVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("DepthDrawToMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorDrawToMsResourceLayout);
], colorDrawToMsResourceLayout);
_programDepthDrawToNonMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programDepthDrawToNonMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorDrawToMsVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("DepthDrawToNonMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorDrawToMsResourceLayout);
], colorDrawToMsResourceLayout);
if (gd.Capabilities.SupportsShaderStencilExport)
{
_programStencilBlit = gd.CreateProgramWithMinimalLayout(new[]
{
_programStencilBlit = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorBlitVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("StencilBlitFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, blitResourceLayout);
], blitResourceLayout);
_programStencilBlitMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programStencilBlitMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorBlitVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("StencilBlitMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, blitResourceLayout);
], blitResourceLayout);
_programStencilDrawToMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programStencilDrawToMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorDrawToMsVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("StencilDrawToMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorDrawToMsResourceLayout);
], colorDrawToMsResourceLayout);
_programStencilDrawToNonMs = gd.CreateProgramWithMinimalLayout(new[]
{
_programStencilDrawToNonMs = gd.CreateProgramWithMinimalLayout(
[
new ShaderSource(ReadSpirv("ColorDrawToMsVertex.spv"), ShaderStage.Vertex, TargetLanguage.Spirv),
new ShaderSource(ReadSpirv("StencilDrawToNonMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv),
}, colorDrawToMsResourceLayout);
], colorDrawToMsResourceLayout);
}
}
@@ -385,12 +385,13 @@ namespace Ryujinx.Graphics.Vulkan
_pipeline.SetTextureAndSamplerIdentitySwizzle(ShaderStage.Fragment, 0, src, sampler);
Span<float> region = stackalloc float[RegionBufferSize / sizeof(float)];
region[0] = (float)srcRegion.X1 / src.Width;
region[1] = (float)srcRegion.X2 / src.Width;
region[2] = (float)srcRegion.Y1 / src.Height;
region[3] = (float)srcRegion.Y2 / src.Height;
Span<float> region =
[
(float)srcRegion.X1 / src.Width,
(float)srcRegion.X2 / src.Width,
(float)srcRegion.Y1 / src.Height,
(float)srcRegion.Y2 / src.Height,
];
if (dstRegion.X1 > dstRegion.X2)
{
@@ -406,7 +407,7 @@ namespace Ryujinx.Graphics.Vulkan
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, region);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(1, buffer.Range)]);
Span<Viewport> viewports = stackalloc Viewport[1];
@@ -449,8 +450,8 @@ namespace Ryujinx.Graphics.Vulkan
int dstHeight = dst.Height;
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
_pipeline.SetRenderTargetColorMasks(new uint[] { 0xf });
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) });
_pipeline.SetRenderTargetColorMasks([0xf]);
_pipeline.SetScissors([new Rectangle<int>(0, 0, dstWidth, dstHeight)]);
if (clearAlpha)
{
@@ -481,12 +482,13 @@ namespace Ryujinx.Graphics.Vulkan
const int RegionBufferSize = 16;
Span<float> region = stackalloc float[RegionBufferSize / sizeof(float)];
region[0] = (float)srcRegion.X1 / src.Width;
region[1] = (float)srcRegion.X2 / src.Width;
region[2] = (float)srcRegion.Y1 / src.Height;
region[3] = (float)srcRegion.Y2 / src.Height;
Span<float> region =
[
(float)srcRegion.X1 / src.Width,
(float)srcRegion.X2 / src.Width,
(float)srcRegion.Y1 / src.Height,
(float)srcRegion.Y2 / src.Height,
];
if (dstRegion.X1 > dstRegion.X2)
{
@@ -502,7 +504,7 @@ namespace Ryujinx.Graphics.Vulkan
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, region);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(1, buffer.Range)]);
Span<Viewport> viewports = stackalloc Viewport[1];
@@ -525,7 +527,7 @@ namespace Ryujinx.Graphics.Vulkan
int dstHeight = dst.Height;
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) });
_pipeline.SetScissors([new Rectangle<int>(0, 0, dstWidth, dstHeight)]);
_pipeline.SetViewports(viewports);
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
@@ -656,18 +658,19 @@ namespace Ryujinx.Graphics.Vulkan
buffer.Holder.SetDataUnchecked(buffer.Offset, clearColor);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(1, buffer.Range)]);
Span<Viewport> viewports = stackalloc Viewport[1];
viewports[0] = new Viewport(
new Rectangle<float>(0, 0, dstWidth, dstHeight),
ViewportSwizzle.PositiveX,
ViewportSwizzle.PositiveY,
ViewportSwizzle.PositiveZ,
ViewportSwizzle.PositiveW,
0f,
1f);
Span<Viewport> viewports =
[
new Viewport(
new Rectangle<float>(0, 0, dstWidth, dstHeight),
ViewportSwizzle.PositiveX,
ViewportSwizzle.PositiveY,
ViewportSwizzle.PositiveZ,
ViewportSwizzle.PositiveW,
0f,
1f),
];
IProgram program;
@@ -686,9 +689,9 @@ namespace Ryujinx.Graphics.Vulkan
_pipeline.SetProgram(program);
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
_pipeline.SetRenderTargetColorMasks(new[] { componentMask });
_pipeline.SetRenderTargetColorMasks([componentMask]);
_pipeline.SetViewports(viewports);
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor });
_pipeline.SetScissors([scissor]);
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
_pipeline.Draw(4, 1, 0, 0);
_pipeline.Finish();
@@ -716,25 +719,26 @@ namespace Ryujinx.Graphics.Vulkan
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ClearColorBufferSize);
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, stackalloc float[] { depthValue });
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, [depthValue]);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(1, buffer.Range)]);
Span<Viewport> viewports = stackalloc Viewport[1];
viewports[0] = new Viewport(
new Rectangle<float>(0, 0, dstWidth, dstHeight),
ViewportSwizzle.PositiveX,
ViewportSwizzle.PositiveY,
ViewportSwizzle.PositiveZ,
ViewportSwizzle.PositiveW,
0f,
1f);
Span<Viewport> viewports =
[
new Viewport(
new Rectangle<float>(0, 0, dstWidth, dstHeight),
ViewportSwizzle.PositiveX,
ViewportSwizzle.PositiveY,
ViewportSwizzle.PositiveZ,
ViewportSwizzle.PositiveW,
0f,
1f),
];
_pipeline.SetProgram(_programDepthStencilClear);
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
_pipeline.SetViewports(viewports);
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor });
_pipeline.SetScissors([scissor]);
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
_pipeline.SetDepthTest(new DepthTestDescriptor(true, depthMask, CompareOp.Always));
_pipeline.SetStencilTest(CreateStencilTestDescriptor(stencilMask != 0, stencilValue, 0xff, stencilMask));
@@ -754,12 +758,13 @@ namespace Ryujinx.Graphics.Vulkan
pipeline.SetTextureAndSampler(ShaderStage.Fragment, 0, src, srcSampler);
Span<float> region = stackalloc float[RegionBufferSize / sizeof(float)];
region[0] = srcRegion.X1 / src.Width;
region[1] = srcRegion.X2 / src.Width;
region[2] = srcRegion.Y1 / src.Height;
region[3] = srcRegion.Y2 / src.Height;
Span<float> region =
[
srcRegion.X1 / src.Width,
srcRegion.X2 / src.Width,
srcRegion.Y1 / src.Height,
srcRegion.Y2 / src.Height,
];
if (dstRegion.X1 > dstRegion.X2)
{
@@ -775,7 +780,7 @@ namespace Ryujinx.Graphics.Vulkan
gd.BufferManager.SetData<float>(bufferHandle, 0, region);
pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, new BufferRange(bufferHandle, 0, RegionBufferSize)) });
pipeline.SetUniformBuffers([new BufferAssignment(1, new BufferRange(bufferHandle, 0, RegionBufferSize))]);
Span<Viewport> viewports = stackalloc Viewport[1];
@@ -838,12 +843,7 @@ namespace Ryujinx.Graphics.Vulkan
{
const int ParamsBufferSize = 16;
Span<int> shaderParams = stackalloc int[ParamsBufferSize / sizeof(int)];
shaderParams[0] = stride;
shaderParams[1] = newStride;
shaderParams[2] = size;
shaderParams[3] = srcOffset;
Span<int> shaderParams = [stride, newStride, size, srcOffset];
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
@@ -851,7 +851,7 @@ namespace Ryujinx.Graphics.Vulkan
_pipeline.SetCommandBuffer(cbs);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(0, buffer.Range)]);
Span<Auto<DisposableBuffer>> sbRanges = new Auto<DisposableBuffer>[2];
@@ -914,7 +914,7 @@ namespace Ryujinx.Graphics.Vulkan
gd.Api.CmdFillBuffer(cbs.CommandBuffer, dstBuffer, 0, Vk.WholeSize, 0);
var bufferCopy = new List<BufferCopy>();
List<BufferCopy> bufferCopy = [];
int outputOffset = 0;
// Try to merge copies of adjacent indices to reduce copy count.
@@ -1029,7 +1029,7 @@ namespace Ryujinx.Graphics.Vulkan
var srcFormat = GetFormat(componentSize, srcBpp / componentSize);
var dstFormat = GetFormat(componentSize, dstBpp / componentSize);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(0, buffer.Range)]);
for (int l = 0; l < levels; l++)
{
@@ -1110,7 +1110,7 @@ namespace Ryujinx.Graphics.Vulkan
1);
_pipeline.SetCommandBuffer(cbs);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(0, buffer.Range)]);
if (isDepthOrStencil)
{
@@ -1129,7 +1129,7 @@ namespace Ryujinx.Graphics.Vulkan
0f,
1f);
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dst.Width, dst.Height) });
_pipeline.SetScissors([new Rectangle<int>(0, 0, dst.Width, dst.Height)]);
_pipeline.SetViewports(viewports);
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
@@ -1250,12 +1250,12 @@ namespace Ryujinx.Graphics.Vulkan
0f,
1f);
_pipeline.SetRenderTargetColorMasks(new uint[] { 0xf });
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dst.Width, dst.Height) });
_pipeline.SetRenderTargetColorMasks([0xf]);
_pipeline.SetScissors([new Rectangle<int>(0, 0, dst.Width, dst.Height)]);
_pipeline.SetViewports(viewports);
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(0, buffer.Range)]);
if (isDepthOrStencil)
{
@@ -1577,9 +1577,9 @@ namespace Ryujinx.Graphics.Vulkan
srcIndirectBufferOffset,
indirectDataSize);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, drawCountBufferAligned) });
_pipeline.SetStorageBuffers(1, new[] { srcIndirectBuffer.GetBuffer(), dstIndirectBuffer.GetBuffer() });
_pipeline.SetStorageBuffers(stackalloc[] { new BufferAssignment(3, patternScoped.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(0, drawCountBufferAligned)]);
_pipeline.SetStorageBuffers(1, [srcIndirectBuffer.GetBuffer(), dstIndirectBuffer.GetBuffer()]);
_pipeline.SetStorageBuffers([new BufferAssignment(3, patternScoped.Range)]);
_pipeline.SetProgram(_programConvertIndirectData);
_pipeline.DispatchCompute(1, 1, 1);
@@ -1606,8 +1606,8 @@ namespace Ryujinx.Graphics.Vulkan
0,
convertedCount * outputIndexSize);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(patternScoped.Handle, patternScoped.Offset, ParamsBufferSize)) });
_pipeline.SetStorageBuffers(1, new[] { srcIndexBuffer.GetBuffer(), dstIndexBuffer.GetBuffer() });
_pipeline.SetUniformBuffers([new BufferAssignment(0, new BufferRange(patternScoped.Handle, patternScoped.Offset, ParamsBufferSize))]);
_pipeline.SetStorageBuffers(1, [srcIndexBuffer.GetBuffer(), dstIndexBuffer.GetBuffer()]);
_pipeline.SetProgram(_programConvertIndexBuffer);
_pipeline.DispatchComputeIndirect(patternBufferAuto, patternScoped.Offset + ParamsIndirectDispatchOffset);
@@ -1663,10 +1663,7 @@ namespace Ryujinx.Graphics.Vulkan
const int ParamsBufferSize = sizeof(int) * 2;
Span<int> shaderParams = stackalloc int[2];
shaderParams[0] = pixelCount;
shaderParams[1] = dstOffset;
Span<int> shaderParams = [pixelCount, dstOffset];
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
@@ -1674,7 +1671,7 @@ namespace Ryujinx.Graphics.Vulkan
_pipeline.SetCommandBuffer(cbs);
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
_pipeline.SetUniformBuffers([new BufferAssignment(0, buffer.Range)]);
Span<Auto<DisposableBuffer>> sbRanges = new Auto<DisposableBuffer>[2];

View File

@@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Vulkan
_hostMemoryApi = hostMemoryApi;
_device = device;
_allocations = new List<HostMemoryAllocation>();
_allocations = [];
_allocationTree = new IntervalTree<ulong, HostMemoryAllocation>();
}
@@ -183,7 +183,7 @@ namespace Ryujinx.Graphics.Vulkan
});
}
_api.FreeMemory(_device, memory, ReadOnlySpan<AllocationCallbacks>.Empty);
_api.FreeMemory(_device, memory, []);
}
}
}

View File

@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Vulkan
public IdList()
{
_list = new List<T>();
_list = [];
_freeMin = 0;
}

View File

@@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Vulkan
if (storages == null)
{
storages = new HashSet<TextureStorage>();
storages = [];
for (int index = 0; index < _textureRefs.Length; index++)
{

View File

@@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Vulkan
_api = api;
_physicalDevice = physicalDevice;
_device = device;
_blockLists = new List<MemoryAllocatorBlockList>();
_blockLists = [];
_blockAlignment = (int)Math.Min(int.MaxValue, MaxDeviceMemoryUsageEstimate / _physicalDevice.PhysicalDeviceProperties.Limits.MaxMemoryAllocationCount);
_lock = new(LockRecursionPolicy.NoRecursion);
}

View File

@@ -42,10 +42,10 @@ namespace Ryujinx.Graphics.Vulkan
Memory = memory;
HostPointer = hostPointer;
Size = size;
_freeRanges = new List<Range>
{
new Range(0, size),
};
_freeRanges =
[
new(0, size),
];
}
public ulong Allocate(ulong size, ulong alignment)
@@ -171,7 +171,7 @@ namespace Ryujinx.Graphics.Vulkan
public MemoryAllocatorBlockList(Vk api, Device device, int memoryTypeIndex, int blockAlignment, bool forBuffer)
{
_blocks = new List<Block>();
_blocks = [];
_api = api;
_device = device;
MemoryTypeIndex = memoryTypeIndex;

View File

@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK
path = path[..^VulkanLib.Length] + "libMoltenVK.dylib";
return [path];
}
return Array.Empty<string>();
return [];
}
public static void InitializeResolver()

View File

@@ -133,8 +133,8 @@ namespace Ryujinx.Graphics.Vulkan
{
_descriptorSetUpdater.Initialize(IsMainPipeline);
QuadsToTrisPattern = new IndexBufferPattern(Gd, 4, 6, 0, new[] { 0, 1, 2, 0, 2, 3 }, 4, false);
TriFanToTrisPattern = new IndexBufferPattern(Gd, 3, 3, 2, new[] { int.MinValue, -1, 0 }, 1, true);
QuadsToTrisPattern = new IndexBufferPattern(Gd, 4, 6, 0, [0, 1, 2, 0, 2, 3], 4, false);
TriFanToTrisPattern = new IndexBufferPattern(Gd, 3, 3, 2, [int.MinValue, -1, 0], 1, true);
}
public unsafe void Barrier()
@@ -159,9 +159,9 @@ namespace Ryujinx.Graphics.Vulkan
1,
new ReadOnlySpan<MemoryBarrier>(in memoryBarrier),
0,
ReadOnlySpan<BufferMemoryBarrier>.Empty,
[],
0,
ReadOnlySpan<ImageMemoryBarrier>.Empty);
[]);
}
public void BeginTransformFeedback(PrimitiveTopology topology)
@@ -1393,7 +1393,7 @@ namespace Ryujinx.Graphics.Vulkan
{
if (!_framebufferUsingColorWriteMask)
{
_preMaskColors = colors.ToArray();
_preMaskColors = [.. colors];
_preMaskDepthStencil = depthStencil;
}

View File

@@ -22,10 +22,10 @@ namespace Ryujinx.Graphics.Vulkan
public PipelineFull(VulkanRenderer gd, Device device) : base(gd, device)
{
_activeQueries = new List<(QueryPool, bool)>();
_pendingQueryCopies = new();
_backingSwaps = new();
_activeBufferMirrors = new();
_activeQueries = [];
_pendingQueryCopies = [];
_backingSwaps = [];
_activeBufferMirrors = [];
CommandBuffer = (Cbs = gd.CommandBufferPool.Rent()).CommandBuffer;
@@ -60,11 +60,7 @@ namespace Ryujinx.Graphics.Vulkan
return;
}
Span<float> clearColor = stackalloc float[4];
clearColor[0] = color.Red;
clearColor[1] = color.Green;
clearColor[2] = color.Blue;
clearColor[3] = color.Alpha;
Span<float> clearColor = [color.Red, color.Green, color.Blue, color.Alpha];
// TODO: Clear only the specified layer.
Gd.HelperShader.Clear(

View File

@@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.Vulkan
for (int j = 0; j < _dsCache[i].Length; j++)
{
_dsCache[i][j] = new List<Auto<DescriptorSetCollection>>();
_dsCache[i][j] = [];
}
}
@@ -126,7 +126,7 @@ namespace Ryujinx.Graphics.Vulkan
if (usePushDescriptors)
{
_pdDescriptors = setDescriptors[0];
_pdTemplates = new();
_pdTemplates = [];
}
_descriptorSetManager = new DescriptorSetManager(_device, setDescriptors.Count);
@@ -173,7 +173,7 @@ namespace Ryujinx.Graphics.Vulkan
{
FreeCompletedManualDescriptorSets();
var list = _manualDsCache[setIndex] ??= new();
var list = _manualDsCache[setIndex] ??= [];
var span = CollectionsMarshal.AsSpan(list);
Queue<int> freeQueue = _freeManualDsCacheEntries[setIndex];

View File

@@ -144,7 +144,7 @@ namespace Ryujinx.Graphics.Vulkan
_textures = textures;
_key = key;
_forcedFences = new List<ForcedFence>();
_forcedFences = [];
}
public Auto<DisposableFramebuffer> GetFramebuffer(VulkanRenderer gd, CommandBufferScoped cbs, FramebufferParams fb)

View File

@@ -18,8 +18,8 @@ namespace Ryujinx.Graphics.Vulkan
for (int index = 0; index < TotalSets; index++)
{
_resourceDescriptors[index] = new();
_resourceUsages[index] = new();
_resourceDescriptors[index] = [];
_resourceUsages[index] = [];
}
}

View File

@@ -168,7 +168,7 @@ namespace Ryujinx.Graphics.Vulkan
// If binding 3 is immediately used, use an alternate set of reserved bindings.
ReadOnlyCollection<ResourceUsage> uniformUsage = layout.SetUsages[0].Usages;
bool hasBinding3 = uniformUsage.Any(x => x.Binding == 3);
int[] reserved = isCompute ? Array.Empty<int>() : gd.GetPushDescriptorReservedBindings(hasBinding3);
int[] reserved = isCompute ? [] : gd.GetPushDescriptorReservedBindings(hasBinding3);
// Can't use any of the reserved usages.
for (int i = 0; i < uniformUsage.Count; i++)
@@ -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)
@@ -249,7 +249,7 @@ namespace Ryujinx.Graphics.Vulkan
for (int setIndex = 0; setIndex < sets.Count; setIndex++)
{
List<ResourceBindingSegment> currentSegments = new();
List<ResourceBindingSegment> currentSegments = [];
ResourceDescriptor currentDescriptor = default;
int currentCount = 0;
@@ -293,7 +293,7 @@ namespace Ryujinx.Graphics.Vulkan
currentDescriptor.Count > 1));
}
segments[setIndex] = currentSegments.ToArray();
segments[setIndex] = [.. currentSegments];
}
return segments;
@@ -307,7 +307,7 @@ namespace Ryujinx.Graphics.Vulkan
for (int setIndex = 0; setIndex < setUsages.Count; setIndex++)
{
List<ResourceBindingSegment> currentSegments = new();
List<ResourceBindingSegment> currentSegments = [];
ResourceUsage currentUsage = default;
int currentCount = 0;
@@ -356,7 +356,7 @@ namespace Ryujinx.Graphics.Vulkan
currentUsage.ArrayLength > 1));
}
segments[setIndex] = currentSegments.ToArray();
segments[setIndex] = [.. currentSegments];
}
return segments;

View File

@@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Vulkan
{
_gd = gd;
_device = device;
_handles = new List<SyncHandle>();
_handles = [];
}
public void RegisterFlush()

View File

@@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.Vulkan
if (storages == null)
{
storages = new HashSet<TextureStorage>();
storages = [];
for (int index = 0; index < _textureRefs.Length; index++)
{

View File

@@ -379,33 +379,33 @@ namespace Ryujinx.Graphics.Vulkan
PNext = &subpassDsResolve,
};
AttachmentDescription2[] attachmentDescs = new AttachmentDescription2[2];
attachmentDescs[0] = new AttachmentDescription2(
StructureType.AttachmentDescription2,
null,
0,
src.VkFormat,
TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)src.Info.Samples),
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
ImageLayout.General,
ImageLayout.General);
attachmentDescs[1] = new AttachmentDescription2(
StructureType.AttachmentDescription2,
null,
0,
dst.VkFormat,
TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)dst.Info.Samples),
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
ImageLayout.General,
ImageLayout.General);
AttachmentDescription2[] attachmentDescs =
[
new AttachmentDescription2(
StructureType.AttachmentDescription2,
null,
0,
src.VkFormat,
TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)src.Info.Samples),
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
ImageLayout.General,
ImageLayout.General),
new AttachmentDescription2(
StructureType.AttachmentDescription2,
null,
0,
dst.VkFormat,
TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)dst.Info.Samples),
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
AttachmentLoadOp.Load,
AttachmentStoreOp.Store,
ImageLayout.General,
ImageLayout.General),
];
var subpassDependency = PipelineConverter.CreateSubpassDependency2(gd);

View File

@@ -184,7 +184,7 @@ namespace Ryujinx.Graphics.Vulkan
{
if (_aliasedStorages == null || !_aliasedStorages.TryGetValue(format, out var storage))
{
_aliasedStorages ??= new Dictionary<Format, TextureStorage>();
_aliasedStorages ??= [];
var info = NewCreateInfoWith(ref _info, format, _info.BytesPerPixel);

View File

@@ -594,7 +594,7 @@ namespace Ryujinx.Graphics.Vulkan
Info.SwizzleB,
Info.SwizzleA), 0, 0);
(_selfManagedViews ??= new Dictionary<Format, TextureView>()).Add(format, view);
(_selfManagedViews ??= []).Add(format, view);
return view;
}
@@ -624,7 +624,7 @@ namespace Ryujinx.Graphics.Vulkan
bufferHolder.WaitForFences();
byte[] bitmap = new byte[size];
GetDataFromBuffer(bufferHolder.GetDataStorage(0, size), size, Span<byte>.Empty).CopyTo(bitmap);
GetDataFromBuffer(bufferHolder.GetDataStorage(0, size), size, []).CopyTo(bitmap);
return bitmap;
}

View File

@@ -76,7 +76,7 @@ namespace Ryujinx.Graphics.Vulkan
DebugUtilsMessengerEXT messengerHandle = default;
Result result = _debugUtils.CreateDebugUtilsMessenger(_instance, SpanHelpers.AsReadOnlySpan(ref debugUtilsMessengerCreateInfo), ReadOnlySpan<AllocationCallbacks>.Empty, SpanHelpers.AsSpan(ref messengerHandle));
Result result = _debugUtils.CreateDebugUtilsMessenger(_instance, SpanHelpers.AsReadOnlySpan(ref debugUtilsMessengerCreateInfo), [], SpanHelpers.AsSpan(ref messengerHandle));
if (result == Result.Success)
{
@@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Vulkan
{
if (_debugUtilsMessenger.HasValue)
{
_debugUtils.DestroyDebugUtilsMessenger(_instance, _debugUtilsMessenger.Value, Span<AllocationCallbacks>.Empty);
_debugUtils.DestroyDebugUtilsMessenger(_instance, _debugUtilsMessenger.Value, []);
}
_disposed = true;

View File

@@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Vulkan
private const string AppName = "Ryujinx.Graphics.Vulkan";
private const int QueuesCount = 2;
private static readonly string[] _desirableExtensions = {
private static readonly string[] _desirableExtensions = [
ExtConditionalRendering.ExtensionName,
ExtExtendedDynamicState.ExtensionName,
ExtTransformFeedback.ExtensionName,
@@ -46,15 +46,15 @@ namespace Ryujinx.Graphics.Vulkan
"VK_KHR_maintenance2",
"VK_EXT_attachment_feedback_loop_layout",
"VK_EXT_attachment_feedback_loop_dynamic_state",
};
];
private static readonly string[] _requiredExtensions = {
private static readonly string[] _requiredExtensions = [
KhrSwapchain.ExtensionName,
};
];
internal static VulkanInstance CreateInstance(Vk api, GraphicsDebugLevel logLevel, string[] requiredExtensions)
{
var enabledLayers = new List<string>();
List<string> enabledLayers = [];
var instanceExtensions = VulkanInstance.GetInstanceExtensions(api);
var instanceLayers = VulkanInstance.GetInstanceLayers(api);
@@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Vulkan
if (instanceExtensions.Contains("VK_EXT_debug_utils"))
{
enabledExtensions = enabledExtensions.Append(ExtDebugUtils.ExtensionName).ToArray();
enabledExtensions = [.. enabledExtensions, ExtDebugUtils.ExtensionName];
}
var appName = Marshal.StringToHGlobalAnsi(AppName);
@@ -196,12 +196,12 @@ namespace Ryujinx.Graphics.Vulkan
// TODO: Remove this once we relax our initialization codepaths.
if (instance.InstanceVersion < _minimalInstanceVulkanVersion)
{
return Array.Empty<DeviceInfo>();
return [];
}
instance.EnumeratePhysicalDevices(out VulkanPhysicalDevice[] physicalDevices).ThrowOnError();
List<DeviceInfo> deviceInfos = new();
List<DeviceInfo> deviceInfos = [];
foreach (VulkanPhysicalDevice physicalDevice in physicalDevices)
{
@@ -213,7 +213,7 @@ namespace Ryujinx.Graphics.Vulkan
deviceInfos.Add(physicalDevice.ToDeviceInfo());
}
return deviceInfos.ToArray();
return [.. deviceInfos];
}
private static bool IsPreferredAndSuitableDevice(Vk api, VulkanPhysicalDevice physicalDevice, SurfaceKHR surface, string preferredGpuId)

View File

@@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Vulkan
Instance rawInstance = default;
Result result = api.CreateInstance(SpanHelpers.AsReadOnlySpan(ref createInfo), ReadOnlySpan<AllocationCallbacks>.Empty, SpanHelpers.AsSpan(ref rawInstance));
Result result = api.CreateInstance(SpanHelpers.AsReadOnlySpan(ref createInfo), [], SpanHelpers.AsSpan(ref rawInstance));
if (result == Result.Success)
{
@@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Vulkan
uint physicalDeviceCount = 0;
Result result = _api.EnumeratePhysicalDevices(Instance, SpanHelpers.AsSpan(ref physicalDeviceCount), Span<PhysicalDevice>.Empty);
Result result = _api.EnumeratePhysicalDevices(Instance, SpanHelpers.AsSpan(ref physicalDeviceCount), []);
if (result != Result.Success)
{
@@ -86,11 +86,11 @@ namespace Ryujinx.Graphics.Vulkan
{
uint propertiesCount = 0;
api.EnumerateInstanceExtensionProperties(ReadOnlySpan<byte>.Empty, SpanHelpers.AsSpan(ref propertiesCount), Span<ExtensionProperties>.Empty).ThrowOnError();
api.EnumerateInstanceExtensionProperties([], SpanHelpers.AsSpan(ref propertiesCount), []).ThrowOnError();
ExtensionProperties[] extensionProperties = new ExtensionProperties[propertiesCount];
api.EnumerateInstanceExtensionProperties(ReadOnlySpan<byte>.Empty, SpanHelpers.AsSpan(ref propertiesCount), extensionProperties).ThrowOnError();
api.EnumerateInstanceExtensionProperties([], SpanHelpers.AsSpan(ref propertiesCount), extensionProperties).ThrowOnError();
unsafe
{
@@ -102,7 +102,7 @@ namespace Ryujinx.Graphics.Vulkan
{
uint propertiesCount = 0;
api.EnumerateInstanceLayerProperties(SpanHelpers.AsSpan(ref propertiesCount), Span<LayerProperties>.Empty).ThrowOnError();
api.EnumerateInstanceLayerProperties(SpanHelpers.AsSpan(ref propertiesCount), []).ThrowOnError();
LayerProperties[] layerProperties = new LayerProperties[propertiesCount];
@@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Vulkan
{
if (!_disposed)
{
_api.DestroyInstance(Instance, ReadOnlySpan<AllocationCallbacks>.Empty);
_api.DestroyInstance(Instance, []);
_disposed = true;
}

View File

@@ -36,17 +36,17 @@ namespace Ryujinx.Graphics.Vulkan
uint propertiesCount = 0;
api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, SpanHelpers.AsSpan(ref propertiesCount), Span<QueueFamilyProperties>.Empty);
api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, SpanHelpers.AsSpan(ref propertiesCount), []);
QueueFamilyProperties = new QueueFamilyProperties[propertiesCount];
api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, SpanHelpers.AsSpan(ref propertiesCount), QueueFamilyProperties);
api.EnumerateDeviceExtensionProperties(PhysicalDevice, Span<byte>.Empty, SpanHelpers.AsSpan(ref propertiesCount), Span<ExtensionProperties>.Empty).ThrowOnError();
api.EnumerateDeviceExtensionProperties(PhysicalDevice, [], SpanHelpers.AsSpan(ref propertiesCount), []).ThrowOnError();
ExtensionProperties[] extensionProperties = new ExtensionProperties[propertiesCount];
api.EnumerateDeviceExtensionProperties(PhysicalDevice, Span<byte>.Empty, SpanHelpers.AsSpan(ref propertiesCount), extensionProperties).ThrowOnError();
api.EnumerateDeviceExtensionProperties(PhysicalDevice, [], SpanHelpers.AsSpan(ref propertiesCount), extensionProperties).ThrowOnError();
unsafe
{

View File

@@ -83,8 +83,8 @@ namespace Ryujinx.Graphics.Vulkan
private readonly string _preferredGpuId;
private int[] _pdReservedBindings;
private readonly static int[] _pdReservedBindingsNvn = { 3, 18, 21, 36, 30 };
private readonly static int[] _pdReservedBindingsOgl = { 17, 18, 34, 35, 36 };
private readonly static int[] _pdReservedBindingsNvn = [3, 18, 21, 36, 30];
private readonly static int[] _pdReservedBindingsOgl = [17, 18, 34, 35, 36];
internal Vendor Vendor { get; private set; }
internal bool IsAmdWindows { get; private set; }
@@ -214,7 +214,7 @@ namespace Ryujinx.Graphics.Vulkan
bool supportsPushDescriptors = _physicalDevice.IsDeviceExtensionPresent(KhrPushDescriptor.ExtensionName);
PhysicalDevicePushDescriptorPropertiesKHR propertiesPushDescriptor = new PhysicalDevicePushDescriptorPropertiesKHR()
PhysicalDevicePushDescriptorPropertiesKHR propertiesPushDescriptor = new()
{
SType = StructureType.PhysicalDevicePushDescriptorPropertiesKhr
};
@@ -521,7 +521,7 @@ namespace Ryujinx.Graphics.Vulkan
}
else
{
_pdReservedBindings = Array.Empty<int>();
_pdReservedBindings = [];
}
}
@@ -831,7 +831,7 @@ namespace Ryujinx.Graphics.Vulkan
{
Logger.Error?.PrintMsg(LogClass.Gpu, $"Error querying Vulkan devices: {ex.Message}");
return Array.Empty<DeviceInfo>();
return [];
}
}
@@ -844,7 +844,7 @@ namespace Ryujinx.Graphics.Vulkan
catch (Exception)
{
// If we got an exception here, Vulkan is most likely not supported.
return Array.Empty<DeviceInfo>();
return [];
}
}

View File

@@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Vulkan
}
}
_gd.SwapchainApi.DestroySwapchain(_device, oldSwapchain, Span<AllocationCallbacks>.Empty);
_gd.SwapchainApi.DestroySwapchain(_device, oldSwapchain, []);
CreateSwapchain();
}
@@ -394,7 +394,7 @@ namespace Ryujinx.Graphics.Vulkan
_gd.CommandBufferPool.Return(
cbs,
null,
stackalloc[] { PipelineStageFlags.ColorAttachmentOutputBit },
[PipelineStageFlags.ColorAttachmentOutputBit],
null);
_gd.FlushAllCommands();
cbs.GetFence().Wait();
@@ -457,9 +457,9 @@ namespace Ryujinx.Graphics.Vulkan
_gd.CommandBufferPool.Return(
cbs,
stackalloc[] { _imageAvailableSemaphores[semaphoreIndex] },
stackalloc[] { PipelineStageFlags.ColorAttachmentOutputBit },
stackalloc[] { _renderFinishedSemaphores[semaphoreIndex] });
[_imageAvailableSemaphores[semaphoreIndex]],
[PipelineStageFlags.ColorAttachmentOutputBit],
[_renderFinishedSemaphores[semaphoreIndex]]);
// TODO: Present queue.
var semaphore = _renderFinishedSemaphores[semaphoreIndex];