Vulkan: Use templates for descriptor updates (#6014)

* WIP: Descriptor template update

* Make configurable

* Wording

* Simplify template creation

* Whitespace

* UTF-8 whatever

* Leave only templated path, better template updater
This commit is contained in:
riperiperi 2024-01-20 14:07:33 +00:00 committed by GitHub
parent a772b073ec
commit 331c07807f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 256 additions and 8 deletions

View file

@ -26,6 +26,7 @@ namespace Ryujinx.Graphics.Vulkan
public ResourceBindingSegment[][] ClearSegments { get; }
public ResourceBindingSegment[][] BindingSegments { get; }
public DescriptorSetTemplate[] Templates { get; }
public ProgramLinkStatus LinkStatus { get; private set; }
@ -118,6 +119,7 @@ namespace Ryujinx.Graphics.Vulkan
ClearSegments = BuildClearSegments(resourceLayout.Sets);
BindingSegments = BuildBindingSegments(resourceLayout.SetUsages);
Templates = BuildTemplates();
_compileTask = Task.CompletedTask;
_firstBackgroundUse = false;
@ -241,6 +243,23 @@ namespace Ryujinx.Graphics.Vulkan
return segments;
}
private DescriptorSetTemplate[] BuildTemplates()
{
var templates = new DescriptorSetTemplate[BindingSegments.Length];
for (int setIndex = 0; setIndex < BindingSegments.Length; setIndex++)
{
ResourceBindingSegment[] segments = BindingSegments[setIndex];
if (segments != null && segments.Length > 0)
{
templates[setIndex] = new DescriptorSetTemplate(_gd, _device, segments, _plce, IsCompute ? PipelineBindPoint.Compute : PipelineBindPoint.Graphics, setIndex);
}
}
return templates;
}
private async Task BackgroundCompilation()
{
await Task.WhenAll(_shaders.Select(shader => shader.CompileTask));
@ -504,6 +523,11 @@ namespace Ryujinx.Graphics.Vulkan
}
}
for (int i = 0; i < Templates.Length; i++)
{
Templates[i]?.Dispose();
}
if (_dummyRenderPass.Value.Handle != 0)
{
_dummyRenderPass.Dispose();