Vulkan: Implement multisample <-> non-multisample copies and depth-stencil resolve (#3723)

* Vulkan: Implement multisample <-> non-multisample copies and depth-stencil resolve

* FramebufferParams is no longer required there

* Implement Specialization Constants and merge CopyMS Shaders (#15)

* Vulkan: Initial Specialization Constants

* Replace with specialized helper shader

* Reimplement everything

Fix nonexistant interaction with Ryu pipeline caching
Decouple specialization info from data and relocate them
Generalize mapping and add type enum to better match spv types
Use local fixed scopes instead of global unmanaged allocs

* Fix misses in initial implementation

Use correct info variable in Create2DLayerView
Add ShaderStorageImageMultisample to required feature set

* Use texture for source image

* No point in using ReadOnlyMemory

* Apply formatting feedback

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Apply formatting suggestions on shader source

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Support conversion with samples count that does not match the requested count, other minor changes

Co-authored-by: mageven <62494521+mageven@users.noreply.github.com>
This commit is contained in:
gdkchan 2022-11-02 18:17:19 -03:00 committed by GitHub
parent 7d8e198c33
commit f82309fa2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 997 additions and 222 deletions

View file

@ -312,6 +312,7 @@ namespace Ryujinx.Graphics.Vulkan
public NativeArray<PipelineShaderStageCreateInfo> Stages;
public NativeArray<PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT> StageRequiredSubgroupSizes;
public PipelineLayout PipelineLayout;
public SpecData SpecializationData;
public void Initialize()
{
@ -334,7 +335,7 @@ namespace Ryujinx.Graphics.Vulkan
ShaderCollection program,
PipelineCache cache)
{
if (program.TryGetComputePipeline(out var pipeline))
if (program.TryGetComputePipeline(ref SpecializationData, out var pipeline))
{
return pipeline;
}
@ -354,20 +355,36 @@ namespace Ryujinx.Graphics.Vulkan
Pipeline pipelineHandle = default;
gd.Api.CreateComputePipelines(device, cache, 1, &pipelineCreateInfo, null, &pipelineHandle).ThrowOnError();
bool hasSpec = program.SpecDescriptions != null;
var desc = hasSpec ? program.SpecDescriptions[0] : SpecDescription.Empty;
if (hasSpec && SpecializationData.Length < (int)desc.Info.DataSize)
{
throw new InvalidOperationException("Specialization data size does not match description");
}
fixed (SpecializationInfo* info = &desc.Info)
fixed (SpecializationMapEntry* map = desc.Map)
fixed (byte* data = SpecializationData.Span)
{
if (hasSpec)
{
info->PMapEntries = map;
info->PData = data;
pipelineCreateInfo.Stage.PSpecializationInfo = info;
}
gd.Api.CreateComputePipelines(device, cache, 1, &pipelineCreateInfo, null, &pipelineHandle).ThrowOnError();
}
pipeline = new Auto<DisposablePipeline>(new DisposablePipeline(gd.Api, device, pipelineHandle));
program.AddComputePipeline(pipeline);
program.AddComputePipeline(ref SpecializationData, pipeline);
return pipeline;
}
public unsafe void DestroyComputePipeline(ShaderCollection program)
{
program.RemoveComputePipeline();
}
public unsafe Auto<DisposablePipeline> CreateGraphicsPipeline(
VulkanRenderer gd,
Device device,