misc: chore: Use collection expressions in Vulkan project
This commit is contained in:
parent
9cb3b40ffc
commit
ed2590a8ac
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -150,10 +150,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
else
|
||||
{
|
||||
_ranges = new List<Range>
|
||||
{
|
||||
new(offset, size)
|
||||
};
|
||||
_ranges = [new(offset, size)];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (!_ranges.TryGetValue(key, out List<Entry> value))
|
||||
{
|
||||
value = new List<Entry>();
|
||||
value = [];
|
||||
_ranges.Add(key, value);
|
||||
}
|
||||
|
||||
|
@ -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 = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,11 +142,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];
|
||||
@ -218,7 +218,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (isMainPipeline)
|
||||
{
|
||||
FeedbackLoopHazards = new();
|
||||
FeedbackLoopHazards = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,9 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
|
||||
_sampler = _renderer.CreateSampler(SamplerCreateInfo.Create(MinFilter.Linear, MagFilter.Linear));
|
||||
|
||||
_scalingProgram = _renderer.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(scalingShader, ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, scalingResourceLayout);
|
||||
_scalingProgram = _renderer.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(scalingShader, ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], scalingResourceLayout);
|
||||
}
|
||||
|
||||
public void Run(
|
||||
@ -70,8 +69,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,
|
||||
@ -79,8 +78,8 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
destination.X1,
|
||||
destination.X2,
|
||||
destination.Y1,
|
||||
destination.Y2,
|
||||
};
|
||||
destination.Y2
|
||||
];
|
||||
|
||||
int rangeSize = dimensionsBuffer.Length * sizeof(float);
|
||||
using ScopedTemporaryBuffer buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
|
||||
@ -90,7 +89,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();
|
||||
|
@ -70,15 +70,13 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
|
||||
_sampler = _renderer.CreateSampler(SamplerCreateInfo.Create(MinFilter.Linear, MagFilter.Linear));
|
||||
|
||||
_scalingProgram = _renderer.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(scalingShader, ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, scalingResourceLayout);
|
||||
_scalingProgram = _renderer.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(scalingShader, ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], scalingResourceLayout);
|
||||
|
||||
_sharpeningProgram = _renderer.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(sharpeningShader, ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, sharpeningResourceLayout);
|
||||
_sharpeningProgram = _renderer.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(sharpeningShader, ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], sharpeningResourceLayout);
|
||||
}
|
||||
|
||||
public void Run(
|
||||
@ -127,8 +125,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,
|
||||
@ -138,14 +136,14 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
destination.Y1,
|
||||
destination.Y2,
|
||||
scaleX,
|
||||
scaleY,
|
||||
};
|
||||
scaleY
|
||||
];
|
||||
|
||||
int rangeSize = dimensionsBuffer.Length * sizeof(float);
|
||||
using ScopedTemporaryBuffer 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 ScopedTemporaryBuffer sharpeningBuffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, sizeof(float));
|
||||
sharpeningBuffer.Holder.SetDataUnchecked(sharpeningBuffer.Offset, sharpeningBufferData);
|
||||
|
||||
@ -153,7 +151,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 +159,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();
|
||||
|
@ -46,10 +46,9 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
|
||||
_samplerLinear = _renderer.CreateSampler(SamplerCreateInfo.Create(MinFilter.Linear, MagFilter.Linear));
|
||||
|
||||
_shaderProgram = _renderer.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(shader, ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, resourceLayout);
|
||||
_shaderProgram = _renderer.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(shader, ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], resourceLayout);
|
||||
}
|
||||
|
||||
public TextureView Run(TextureView view, CommandBufferScoped cbs, int width, int height)
|
||||
@ -64,13 +63,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 ScopedTemporaryBuffer 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)]);
|
||||
|
||||
int dispatchX = BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize);
|
||||
int dispatchY = BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize);
|
||||
|
@ -117,20 +117,17 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
(4, SpecConstType.Float32),
|
||||
(5, SpecConstType.Float32));
|
||||
|
||||
_edgeProgram = _renderer.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(edgeShader, ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, edgeResourceLayout, new[] { specInfo });
|
||||
_edgeProgram = _renderer.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(edgeShader, ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], edgeResourceLayout, [specInfo]);
|
||||
|
||||
_blendProgram = _renderer.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(blendShader, ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, blendResourceLayout, new[] { specInfo });
|
||||
_blendProgram = _renderer.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(blendShader, ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], blendResourceLayout, [specInfo]);
|
||||
|
||||
_neighbourProgram = _renderer.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(neighbourShader, ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, neighbourResourceLayout, new[] { specInfo });
|
||||
_neighbourProgram = _renderer.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(neighbourShader, ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], neighbourResourceLayout, [specInfo]);
|
||||
}
|
||||
|
||||
public void DeletePipelines()
|
||||
@ -214,12 +211,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 ScopedTemporaryBuffer 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();
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,8 @@ 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,
|
||||
@ -27,10 +28,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
GAL.Format.R16G16B16A16Uscaled,
|
||||
GAL.Format.R16G16B16A16Sscaled,
|
||||
GAL.Format.R10G10B10A2Uscaled,
|
||||
GAL.Format.R10G10B10A2Sscaled,
|
||||
};
|
||||
GAL.Format.R10G10B10A2Sscaled
|
||||
];
|
||||
|
||||
private static readonly GAL.Format[] _intFormats = {
|
||||
private static readonly GAL.Format[] _intFormats =
|
||||
[
|
||||
GAL.Format.R8Uint,
|
||||
GAL.Format.R8Sint,
|
||||
GAL.Format.R16Uint,
|
||||
@ -48,8 +50,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
GAL.Format.R16G16B16A16Uint,
|
||||
GAL.Format.R16G16B16A16Sint,
|
||||
GAL.Format.R10G10B10A2Uint,
|
||||
GAL.Format.R10G10B10A2Sint,
|
||||
};
|
||||
GAL.Format.R10G10B10A2Sint
|
||||
];
|
||||
|
||||
private readonly FormatFeatureFlags[] _bufferTable;
|
||||
private readonly FormatFeatureFlags[] _optimalTable;
|
||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
bool isDepthStencil = format.IsDepthOrStencil();
|
||||
|
||||
_device = device;
|
||||
_attachments = new[] { view.GetImageViewForAttachment() };
|
||||
_attachments = [view.GetImageViewForAttachment()];
|
||||
_validColorAttachments = isDepthStencil ? 0u : 1u;
|
||||
_baseAttachment = view;
|
||||
|
||||
@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
else
|
||||
{
|
||||
_colors = new TextureView[] { view };
|
||||
_colors = [view];
|
||||
_colorsCanonical = _colors;
|
||||
}
|
||||
|
||||
@ -57,9 +57,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();
|
||||
|
||||
|
@ -89,10 +89,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
else
|
||||
{
|
||||
bucket.Entries = new[]
|
||||
{
|
||||
entry,
|
||||
};
|
||||
bucket.Entries =
|
||||
[
|
||||
entry
|
||||
];
|
||||
}
|
||||
|
||||
bucket.Length++;
|
||||
|
@ -69,109 +69,95 @@ 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);
|
||||
new ShaderSource(ReadSpirv("ColorBlitFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("ColorBlitMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("ColorBlitClearAlphaFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], blitResourceLayout);
|
||||
|
||||
ResourceLayout 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);
|
||||
new ShaderSource(ReadSpirv("ColorClearFFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("ColorClearSIFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("ColorClearUIFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("DepthStencilClearFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], colorClearResourceLayout);
|
||||
|
||||
ResourceLayout 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[]
|
||||
{
|
||||
new ShaderSource(ReadSpirv("ChangeBufferStride.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, strideChangeResourceLayout);
|
||||
_programStrideChange = gd.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(ReadSpirv("ChangeBufferStride.spv"), ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], strideChangeResourceLayout);
|
||||
|
||||
ResourceLayout 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[]
|
||||
{
|
||||
new ShaderSource(ReadSpirv("ColorCopyShorteningCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, colorCopyResourceLayout);
|
||||
_programColorCopyShortening = gd.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(ReadSpirv("ColorCopyShorteningCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], colorCopyResourceLayout);
|
||||
|
||||
_programColorCopyToNonMs = gd.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(ReadSpirv("ColorCopyToNonMsCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, colorCopyResourceLayout);
|
||||
_programColorCopyToNonMs = gd.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(ReadSpirv("ColorCopyToNonMsCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], colorCopyResourceLayout);
|
||||
|
||||
_programColorCopyWidening = gd.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(ReadSpirv("ColorCopyWideningCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, colorCopyResourceLayout);
|
||||
_programColorCopyWidening = gd.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(ReadSpirv("ColorCopyWideningCompute.spv"), ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], colorCopyResourceLayout);
|
||||
|
||||
ResourceLayout 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);
|
||||
new ShaderSource(ReadSpirv("ColorDrawToMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], colorDrawToMsResourceLayout);
|
||||
|
||||
ResourceLayout 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[]
|
||||
{
|
||||
new ShaderSource(ReadSpirv("ConvertD32S8ToD24S8.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, convertD32S8ToD24S8ResourceLayout);
|
||||
_programConvertD32S8ToD24S8 = gd.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(ReadSpirv("ConvertD32S8ToD24S8.spv"), ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], convertD32S8ToD24S8ResourceLayout);
|
||||
|
||||
ResourceLayout 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[]
|
||||
{
|
||||
new ShaderSource(ReadSpirv("ConvertIndexBuffer.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, convertIndexBufferResourceLayout);
|
||||
_programConvertIndexBuffer = gd.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(ReadSpirv("ConvertIndexBuffer.spv"), ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], convertIndexBufferResourceLayout);
|
||||
|
||||
ResourceLayout convertIndirectDataResourceLayout = new ResourceLayoutBuilder()
|
||||
.Add(ResourceStages.Compute, ResourceType.UniformBuffer, 0)
|
||||
@ -179,60 +165,51 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 2, true)
|
||||
.Add(ResourceStages.Compute, ResourceType.StorageBuffer, 3).Build();
|
||||
|
||||
_programConvertIndirectData = gd.CreateProgramWithMinimalLayout(new[]
|
||||
{
|
||||
new ShaderSource(ReadSpirv("ConvertIndirectData.spv"), ShaderStage.Compute, TargetLanguage.Spirv),
|
||||
}, convertIndirectDataResourceLayout);
|
||||
_programConvertIndirectData = gd.CreateProgramWithMinimalLayout([
|
||||
new ShaderSource(ReadSpirv("ConvertIndirectData.spv"), ShaderStage.Compute, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("DepthBlitFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("DepthBlitMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("DepthDrawToMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("DepthDrawToNonMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("StencilBlitFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("StencilBlitMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("StencilDrawToMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], 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);
|
||||
new ShaderSource(ReadSpirv("StencilDrawToNonMsFragment.spv"), ShaderStage.Fragment, TargetLanguage.Spirv)
|
||||
], colorDrawToMsResourceLayout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,7 +384,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];
|
||||
|
||||
@ -450,8 +427,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)
|
||||
{
|
||||
@ -503,7 +480,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];
|
||||
|
||||
@ -526,7 +503,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);
|
||||
|
||||
@ -657,7 +634,7 @@ 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];
|
||||
|
||||
@ -689,7 +666,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
||||
_pipeline.SetRenderTargetColorMasks(new[] { 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();
|
||||
@ -717,9 +694,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
using ScopedTemporaryBuffer 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];
|
||||
|
||||
@ -735,7 +712,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_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));
|
||||
@ -776,7 +753,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];
|
||||
|
||||
@ -852,7 +829,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];
|
||||
|
||||
@ -915,7 +892,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
gd.Api.CmdFillBuffer(cbs.CommandBuffer, dstBuffer, 0, Vk.WholeSize, 0);
|
||||
|
||||
List<BufferCopy> bufferCopy = new();
|
||||
List<BufferCopy> bufferCopy = [];
|
||||
int outputOffset = 0;
|
||||
|
||||
// Try to merge copies of adjacent indices to reduce copy count.
|
||||
@ -1030,7 +1007,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Format srcFormat = GetFormat(componentSize, srcBpp / componentSize);
|
||||
Format 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++)
|
||||
{
|
||||
@ -1111,7 +1088,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)
|
||||
{
|
||||
@ -1130,7 +1107,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);
|
||||
|
||||
@ -1251,12 +1228,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)
|
||||
{
|
||||
@ -1578,9 +1555,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
srcIndirectBufferOffset,
|
||||
indirectDataSize);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, drawCountBufferAligned) });
|
||||
_pipeline.SetUniformBuffers([new BufferAssignment(0, drawCountBufferAligned)]);
|
||||
_pipeline.SetStorageBuffers(1, new[] { srcIndirectBuffer.GetBuffer(), dstIndirectBuffer.GetBuffer() });
|
||||
_pipeline.SetStorageBuffers(stackalloc[] { new BufferAssignment(3, patternScoped.Range) });
|
||||
_pipeline.SetStorageBuffers([new BufferAssignment(3, patternScoped.Range)]);
|
||||
|
||||
_pipeline.SetProgram(_programConvertIndirectData);
|
||||
_pipeline.DispatchCompute(1, 1, 1);
|
||||
@ -1607,7 +1584,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
0,
|
||||
convertedCount * outputIndexSize);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(patternScoped.Handle, patternScoped.Offset, ParamsBufferSize)) });
|
||||
_pipeline.SetUniformBuffers([new BufferAssignment(0, new BufferRange(patternScoped.Handle, patternScoped.Offset, ParamsBufferSize))
|
||||
]);
|
||||
_pipeline.SetStorageBuffers(1, new[] { srcIndexBuffer.GetBuffer(), dstIndexBuffer.GetBuffer() });
|
||||
|
||||
_pipeline.SetProgram(_programConvertIndexBuffer);
|
||||
@ -1675,7 +1653,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];
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_hostMemoryApi = hostMemoryApi;
|
||||
_device = device;
|
||||
|
||||
_allocations = new List<HostMemoryAllocation>();
|
||||
_allocations = [];
|
||||
_allocationTree = new IntervalTree<ulong, HostMemoryAllocation>();
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public IdList()
|
||||
{
|
||||
_list = new List<T>();
|
||||
_list = [];
|
||||
_freeMin = 0;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (storages == null)
|
||||
{
|
||||
storages = new HashSet<TextureStorage>();
|
||||
storages = [];
|
||||
|
||||
for (int index = 0; index < _textureRefs.Length; index++)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Memory = memory;
|
||||
HostPointer = hostPointer;
|
||||
Size = size;
|
||||
_freeRanges = new List<Range>
|
||||
{
|
||||
new(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;
|
||||
|
@ -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()
|
||||
|
@ -136,8 +136,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()
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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] = [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
FreeCompletedManualDescriptorSets();
|
||||
|
||||
List<ManualDescriptorSetEntry> list = _manualDsCache[setIndex] ??= new();
|
||||
List<ManualDescriptorSetEntry> list = _manualDsCache[setIndex] ??= [];
|
||||
Span<ManualDescriptorSetEntry> span = CollectionsMarshal.AsSpan(list);
|
||||
|
||||
Queue<int> freeQueue = _freeManualDsCacheEntries[setIndex];
|
||||
|
@ -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)
|
||||
|
@ -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] = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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++)
|
||||
@ -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;
|
||||
@ -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;
|
||||
|
@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
_gd = gd;
|
||||
_device = device;
|
||||
_handles = new List<SyncHandle>();
|
||||
_handles = [];
|
||||
}
|
||||
|
||||
public void RegisterFlush()
|
||||
|
@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (storages == null)
|
||||
{
|
||||
storages = new HashSet<TextureStorage>();
|
||||
storages = [];
|
||||
|
||||
for (int index = 0; index < _textureRefs.Length; index++)
|
||||
{
|
||||
|
@ -21,7 +21,8 @@ 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,16 +47,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
"VK_KHR_8bit_storage",
|
||||
"VK_KHR_maintenance2",
|
||||
"VK_EXT_attachment_feedback_loop_layout",
|
||||
"VK_EXT_attachment_feedback_loop_dynamic_state",
|
||||
};
|
||||
"VK_EXT_attachment_feedback_loop_dynamic_state"
|
||||
];
|
||||
|
||||
private static readonly string[] _requiredExtensions = {
|
||||
KhrSwapchain.ExtensionName,
|
||||
};
|
||||
private static readonly string[] _requiredExtensions =
|
||||
[
|
||||
KhrSwapchain.ExtensionName
|
||||
];
|
||||
|
||||
internal static VulkanInstance CreateInstance(Vk api, GraphicsDebugLevel logLevel, string[] requiredExtensions)
|
||||
{
|
||||
List<string> enabledLayers = new();
|
||||
List<string> enabledLayers = [];
|
||||
|
||||
IReadOnlySet<string> instanceExtensions = VulkanInstance.GetInstanceExtensions(api);
|
||||
IReadOnlySet<string> instanceLayers = VulkanInstance.GetInstanceLayers(api);
|
||||
@ -197,12 +199,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)
|
||||
{
|
||||
|
@ -84,8 +84,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; }
|
||||
@ -522,7 +522,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
else
|
||||
{
|
||||
_pdReservedBindings = Array.Empty<int>();
|
||||
_pdReservedBindings = [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -832,7 +832,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
Logger.Error?.PrintMsg(LogClass.Gpu, $"Error querying Vulkan devices: {ex.Message}");
|
||||
|
||||
return Array.Empty<DeviceInfo>();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -845,7 +845,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
catch (Exception)
|
||||
{
|
||||
// If we got an exception here, Vulkan is most likely not supported.
|
||||
return Array.Empty<DeviceInfo>();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
Semaphore semaphore = _renderFinishedSemaphores[semaphoreIndex];
|
||||
|
Loading…
x
Reference in New Issue
Block a user