mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 19:13:04 +00:00
3e6e0e4afa
* Add support for large sampler arrays on Vulkan * Shader cache version bump * Format whitespace * Move DescriptorSetManager to PipelineLayoutCacheEntry to allow different pool sizes per layout * Handle array textures with different types on the same buffer * Somewhat better caching system * Avoid useless buffer data modification checks * Move redundant bindings update checking to the backend * Fix an issue where texture arrays would get the same bindings across stages on Vulkan * Backport some fixes from part 2 * Fix typo * PR feedback * Format whitespace * Add some missing XML docs
57 lines
2.2 KiB
C#
57 lines
2.2 KiB
C#
using Ryujinx.Graphics.GAL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Ryujinx.Graphics.Vulkan
|
|
{
|
|
class ResourceLayoutBuilder
|
|
{
|
|
private const int TotalSets = PipelineBase.DescriptorSetLayouts;
|
|
|
|
private readonly List<ResourceDescriptor>[] _resourceDescriptors;
|
|
private readonly List<ResourceUsage>[] _resourceUsages;
|
|
|
|
public ResourceLayoutBuilder()
|
|
{
|
|
_resourceDescriptors = new List<ResourceDescriptor>[TotalSets];
|
|
_resourceUsages = new List<ResourceUsage>[TotalSets];
|
|
|
|
for (int index = 0; index < TotalSets; index++)
|
|
{
|
|
_resourceDescriptors[index] = new();
|
|
_resourceUsages[index] = new();
|
|
}
|
|
}
|
|
|
|
public ResourceLayoutBuilder Add(ResourceStages stages, ResourceType type, int binding)
|
|
{
|
|
int setIndex = type switch
|
|
{
|
|
ResourceType.UniformBuffer => PipelineBase.UniformSetIndex,
|
|
ResourceType.StorageBuffer => PipelineBase.StorageSetIndex,
|
|
ResourceType.TextureAndSampler or ResourceType.BufferTexture => PipelineBase.TextureSetIndex,
|
|
ResourceType.Image or ResourceType.BufferImage => PipelineBase.ImageSetIndex,
|
|
_ => throw new ArgumentException($"Invalid resource type \"{type}\"."),
|
|
};
|
|
|
|
_resourceDescriptors[setIndex].Add(new ResourceDescriptor(binding, 1, type, stages));
|
|
_resourceUsages[setIndex].Add(new ResourceUsage(binding, 1, type, stages));
|
|
|
|
return this;
|
|
}
|
|
|
|
public ResourceLayout Build()
|
|
{
|
|
var descriptors = new ResourceDescriptorCollection[TotalSets];
|
|
var usages = new ResourceUsageCollection[TotalSets];
|
|
|
|
for (int index = 0; index < TotalSets; index++)
|
|
{
|
|
descriptors[index] = new ResourceDescriptorCollection(_resourceDescriptors[index].ToArray().AsReadOnly());
|
|
usages[index] = new ResourceUsageCollection(_resourceUsages[index].ToArray().AsReadOnly());
|
|
}
|
|
|
|
return new ResourceLayout(descriptors.AsReadOnly(), usages.AsReadOnly());
|
|
}
|
|
}
|
|
}
|