diff options
author | gdkchan <gab.dark.100@gmail.com> | 2022-11-02 18:17:19 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 18:17:19 -0300 |
commit | f82309fa2dd46d4339e0709ab835d927fd25361b (patch) | |
tree | f864424c938b289780f07a12dc2e52db49721da6 /Ryujinx.Graphics.Vulkan/ShaderCollection.cs | |
parent | 7d8e198c33b7ad283db53315129209a2bd310f23 (diff) |
Vulkan: Implement multisample <-> non-multisample copies and depth-stencil resolve (#3723)1.1.337
* 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>
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/ShaderCollection.cs')
-rw-r--r-- | Ryujinx.Graphics.Vulkan/ShaderCollection.cs | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/Ryujinx.Graphics.Vulkan/ShaderCollection.cs b/Ryujinx.Graphics.Vulkan/ShaderCollection.cs index 82866f7b..ab0ea2e9 100644 --- a/Ryujinx.Graphics.Vulkan/ShaderCollection.cs +++ b/Ryujinx.Graphics.Vulkan/ShaderCollection.cs @@ -26,6 +26,8 @@ namespace Ryujinx.Graphics.Vulkan public ProgramLinkStatus LinkStatus { get; private set; } + public readonly SpecDescription[] SpecDescriptions; + public bool IsLinked { get @@ -40,7 +42,7 @@ namespace Ryujinx.Graphics.Vulkan } private HashTableSlim<PipelineUid, Auto<DisposablePipeline>> _graphicsPipelineCache; - private Auto<DisposablePipeline> _computePipeline; + private HashTableSlim<SpecData, Auto<DisposablePipeline>> _computePipelineCache; private VulkanRenderer _gd; private Device _device; @@ -52,17 +54,24 @@ namespace Ryujinx.Graphics.Vulkan private Task _compileTask; private bool _firstBackgroundUse; - public ShaderCollection(VulkanRenderer gd, Device device, ShaderSource[] shaders, bool isMinimal = false) + public ShaderCollection(VulkanRenderer gd, Device device, ShaderSource[] shaders, SpecDescription[] specDescription = null, bool isMinimal = false) { _gd = gd; _device = device; + if (specDescription != null && specDescription.Length != shaders.Length) + { + throw new ArgumentException($"{nameof(specDescription)} array length must match {nameof(shaders)} array if provided"); + } + gd.Shaders.Add(this); var internalShaders = new Shader[shaders.Length]; _infos = new PipelineShaderStageCreateInfo[shaders.Length]; + SpecDescriptions = specDescription; + LinkStatus = ProgramLinkStatus.Incomplete; uint stages = 0; @@ -314,14 +323,9 @@ namespace Ryujinx.Graphics.Vulkan return null; } - public void AddComputePipeline(Auto<DisposablePipeline> pipeline) + public void AddComputePipeline(ref SpecData key, Auto<DisposablePipeline> pipeline) { - _computePipeline = pipeline; - } - - public void RemoveComputePipeline() - { - _computePipeline = null; + (_computePipelineCache ??= new()).Add(ref key, pipeline); } public void AddGraphicsPipeline(ref PipelineUid key, Auto<DisposablePipeline> pipeline) @@ -329,10 +333,20 @@ namespace Ryujinx.Graphics.Vulkan (_graphicsPipelineCache ??= new()).Add(ref key, pipeline); } - public bool TryGetComputePipeline(out Auto<DisposablePipeline> pipeline) + public bool TryGetComputePipeline(ref SpecData key, out Auto<DisposablePipeline> pipeline) { - pipeline = _computePipeline; - return pipeline != null; + if (_computePipelineCache == null) + { + pipeline = default; + return false; + } + + if (_computePipelineCache.TryGetValue(ref key, out pipeline)) + { + return true; + } + + return false; } public bool TryGetGraphicsPipeline(ref PipelineUid key, out Auto<DisposablePipeline> pipeline) @@ -390,7 +404,14 @@ namespace Ryujinx.Graphics.Vulkan } } - _computePipeline?.Dispose(); + if (_computePipelineCache != null) + { + foreach (Auto<DisposablePipeline> pipeline in _computePipelineCache.Values) + { + pipeline.Dispose(); + } + } + if (_dummyRenderPass.Value.Handle != 0) { _dummyRenderPass.Dispose(); |