Simpler fix for Intel
This commit is contained in:
parent
306bc2c89d
commit
c8eb35c979
3 changed files with 9 additions and 117 deletions
|
@ -95,13 +95,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
PortabilitySubsetFlags portabilitySubset,
|
PortabilitySubsetFlags portabilitySubset,
|
||||||
uint vertexBufferAlignment,
|
uint vertexBufferAlignment,
|
||||||
uint subTexelPrecisionBits,
|
uint subTexelPrecisionBits,
|
||||||
ulong minResourceAlignment,
|
ulong minResourceAlignment)
|
||||||
uint maxPerStageSampledImages,
|
|
||||||
uint maxPerStageSamplers,
|
|
||||||
uint maxPerStageStorageBuffers,
|
|
||||||
uint maxPerStageStorageImages,
|
|
||||||
uint maxPerStageUniformBuffers,
|
|
||||||
uint maxPerStageResources)
|
|
||||||
{
|
{
|
||||||
SupportsIndexTypeUint8 = supportsIndexTypeUint8;
|
SupportsIndexTypeUint8 = supportsIndexTypeUint8;
|
||||||
SupportsCustomBorderColor = supportsCustomBorderColor;
|
SupportsCustomBorderColor = supportsCustomBorderColor;
|
||||||
|
@ -139,12 +133,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
VertexBufferAlignment = vertexBufferAlignment;
|
VertexBufferAlignment = vertexBufferAlignment;
|
||||||
SubTexelPrecisionBits = subTexelPrecisionBits;
|
SubTexelPrecisionBits = subTexelPrecisionBits;
|
||||||
MinResourceAlignment = minResourceAlignment;
|
MinResourceAlignment = minResourceAlignment;
|
||||||
MaxPerStageSampledImages = maxPerStageSampledImages;
|
|
||||||
MaxPerStageSamplers = maxPerStageSamplers;
|
|
||||||
MaxPerStageStorageBuffers = maxPerStageStorageBuffers;
|
|
||||||
MaxPerStageStorageImages = maxPerStageStorageImages;
|
|
||||||
MaxPerStageUniformBuffers = maxPerStageUniformBuffers;
|
|
||||||
MaxPerStageResources = maxPerStageResources;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,100 +10,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
static class PipelineLayoutFactory
|
static class PipelineLayoutFactory
|
||||||
{
|
{
|
||||||
private struct ResourceCounts
|
|
||||||
{
|
|
||||||
private Array5<int> _uniformBuffersCount;
|
|
||||||
private Array5<int> _storageBuffersCount;
|
|
||||||
private Array5<int> _texturesCount;
|
|
||||||
private Array5<int> _imagesCount;
|
|
||||||
private Array5<int> _samplersCount;
|
|
||||||
private Array5<int> _totalCount;
|
|
||||||
|
|
||||||
private void AddToStage(in ResourceDescriptor descriptor, int stageIndex)
|
|
||||||
{
|
|
||||||
switch (descriptor.Type)
|
|
||||||
{
|
|
||||||
case ResourceType.UniformBuffer:
|
|
||||||
_uniformBuffersCount[stageIndex] += descriptor.Count;
|
|
||||||
break;
|
|
||||||
case ResourceType.StorageBuffer:
|
|
||||||
_storageBuffersCount[stageIndex] += descriptor.Count;
|
|
||||||
break;
|
|
||||||
case ResourceType.Texture:
|
|
||||||
case ResourceType.TextureAndSampler:
|
|
||||||
case ResourceType.BufferTexture:
|
|
||||||
_texturesCount[stageIndex] += descriptor.Count;
|
|
||||||
break;
|
|
||||||
case ResourceType.Image:
|
|
||||||
case ResourceType.BufferImage:
|
|
||||||
_imagesCount[stageIndex] += descriptor.Count;
|
|
||||||
break;
|
|
||||||
case ResourceType.Sampler:
|
|
||||||
_samplersCount[stageIndex] += descriptor.Count;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_totalCount[stageIndex] += descriptor.Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(in ResourceDescriptor descriptor)
|
|
||||||
{
|
|
||||||
if (descriptor.Stages.HasFlag(ResourceStages.Vertex) || descriptor.Stages.HasFlag(ResourceStages.Compute))
|
|
||||||
{
|
|
||||||
AddToStage(descriptor, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor.Stages.HasFlag(ResourceStages.TessellationControl))
|
|
||||||
{
|
|
||||||
AddToStage(descriptor, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor.Stages.HasFlag(ResourceStages.TessellationEvaluation))
|
|
||||||
{
|
|
||||||
AddToStage(descriptor, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor.Stages.HasFlag(ResourceStages.Geometry))
|
|
||||||
{
|
|
||||||
AddToStage(descriptor, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor.Stages.HasFlag(ResourceStages.Fragment))
|
|
||||||
{
|
|
||||||
AddToStage(descriptor, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int Sum(ReadOnlySpan<int> values)
|
|
||||||
{
|
|
||||||
int sum = 0;
|
|
||||||
|
|
||||||
foreach (int value in values)
|
|
||||||
{
|
|
||||||
sum += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsExceedingAnyMaxLimit(VulkanRenderer gd)
|
|
||||||
{
|
|
||||||
int maxUniformBuffers = Sum(_uniformBuffersCount.AsSpan());
|
|
||||||
int maxStorageBuffers = Sum(_storageBuffersCount.AsSpan());
|
|
||||||
int maxTextures = Sum(_texturesCount.AsSpan());
|
|
||||||
int maxImages = Sum(_imagesCount.AsSpan());
|
|
||||||
int maxSamplers = Sum(_samplersCount.AsSpan());
|
|
||||||
int maxTotal = Sum(_totalCount.AsSpan());
|
|
||||||
|
|
||||||
return (uint)maxUniformBuffers > gd.Capabilities.MaxPerStageUniformBuffers ||
|
|
||||||
(uint)maxStorageBuffers > gd.Capabilities.MaxPerStageStorageBuffers ||
|
|
||||||
(uint)maxTextures > gd.Capabilities.MaxPerStageSampledImages ||
|
|
||||||
(uint)maxImages > gd.Capabilities.MaxPerStageStorageImages ||
|
|
||||||
(uint)maxSamplers > gd.Capabilities.MaxPerStageSamplers ||
|
|
||||||
(uint)maxTotal > gd.Capabilities.MaxPerStageResources;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static unsafe ResourceLayouts Create(
|
public static unsafe ResourceLayouts Create(
|
||||||
VulkanRenderer gd,
|
VulkanRenderer gd,
|
||||||
Device device,
|
Device device,
|
||||||
|
@ -119,7 +25,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
ResourceDescriptorCollection rdc = setDescriptors[setIndex];
|
ResourceDescriptorCollection rdc = setDescriptors[setIndex];
|
||||||
|
|
||||||
ResourceCounts counts = new();
|
|
||||||
ResourceStages activeStages = ResourceStages.None;
|
ResourceStages activeStages = ResourceStages.None;
|
||||||
|
|
||||||
if (isMoltenVk)
|
if (isMoltenVk)
|
||||||
|
@ -132,6 +37,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
DescriptorSetLayoutBinding[] layoutBindings = new DescriptorSetLayoutBinding[rdc.Descriptors.Count];
|
DescriptorSetLayoutBinding[] layoutBindings = new DescriptorSetLayoutBinding[rdc.Descriptors.Count];
|
||||||
|
|
||||||
|
bool hasArray = false;
|
||||||
|
|
||||||
for (int descIndex = 0; descIndex < rdc.Descriptors.Count; descIndex++)
|
for (int descIndex = 0; descIndex < rdc.Descriptors.Count; descIndex++)
|
||||||
{
|
{
|
||||||
ResourceDescriptor descriptor = rdc.Descriptors[descIndex];
|
ResourceDescriptor descriptor = rdc.Descriptors[descIndex];
|
||||||
|
@ -152,7 +59,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
StageFlags = stages.Convert(),
|
StageFlags = stages.Convert(),
|
||||||
};
|
};
|
||||||
|
|
||||||
counts.Add(descriptor);
|
if (descriptor.Count > 1)
|
||||||
|
{
|
||||||
|
hasArray = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed (DescriptorSetLayoutBinding* pLayoutBindings = layoutBindings)
|
fixed (DescriptorSetLayoutBinding* pLayoutBindings = layoutBindings)
|
||||||
|
@ -164,7 +74,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
flags = DescriptorSetLayoutCreateFlags.PushDescriptorBitKhr;
|
flags = DescriptorSetLayoutCreateFlags.PushDescriptorBitKhr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counts.IsExceedingAnyMaxLimit(gd))
|
if (gd.Vendor == Vendor.Intel && hasArray)
|
||||||
{
|
{
|
||||||
// Some vendors (like Intel) have low per-stage limits.
|
// Some vendors (like Intel) have low per-stage limits.
|
||||||
// We must set the flag if we exceed those limits.
|
// We must set the flag if we exceed those limits.
|
||||||
|
|
|
@ -402,13 +402,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
portabilityFlags,
|
portabilityFlags,
|
||||||
vertexBufferAlignment,
|
vertexBufferAlignment,
|
||||||
properties.Limits.SubTexelPrecisionBits,
|
properties.Limits.SubTexelPrecisionBits,
|
||||||
minResourceAlignment,
|
minResourceAlignment);
|
||||||
properties.Limits.MaxPerStageDescriptorSampledImages,
|
|
||||||
properties.Limits.MaxPerStageDescriptorSamplers,
|
|
||||||
properties.Limits.MaxPerStageDescriptorStorageBuffers,
|
|
||||||
properties.Limits.MaxPerStageDescriptorStorageImages,
|
|
||||||
properties.Limits.MaxPerStageDescriptorUniformBuffers,
|
|
||||||
properties.Limits.MaxPerStageResources);
|
|
||||||
|
|
||||||
IsSharedMemory = MemoryAllocator.IsDeviceMemoryShared(_physicalDevice);
|
IsSharedMemory = MemoryAllocator.IsDeviceMemoryShared(_physicalDevice);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue