mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-22 00:53:35 +00:00
Check if the subgroup size is supported before passing a explicit size
This commit is contained in:
parent
4f086b0ec9
commit
1edc85c26e
3 changed files with 51 additions and 13 deletions
|
@ -1,16 +1,27 @@
|
||||||
namespace Ryujinx.Graphics.Vulkan
|
using Silk.NET.Vulkan;
|
||||||
|
|
||||||
|
namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
struct HardwareCapabilities
|
struct HardwareCapabilities
|
||||||
{
|
{
|
||||||
public bool SupportsConditionalRendering { get; }
|
public bool SupportsConditionalRendering { get; }
|
||||||
public bool SupportsExtendedDynamicState { get; }
|
public bool SupportsExtendedDynamicState { get; }
|
||||||
|
public uint MinSubgroupSize { get; }
|
||||||
|
public uint MaxSubgroupSize { get; }
|
||||||
|
public ShaderStageFlags RequiredSubgroupSizeStages { get; }
|
||||||
|
|
||||||
public HardwareCapabilities(
|
public HardwareCapabilities(
|
||||||
bool supportsConditionalRendering,
|
bool supportsConditionalRendering,
|
||||||
bool supportsExtendedDynamicState)
|
bool supportsExtendedDynamicState,
|
||||||
|
uint minSubgroupSize,
|
||||||
|
uint maxSubgroupSize,
|
||||||
|
ShaderStageFlags requiredSubgroupSizeStages)
|
||||||
{
|
{
|
||||||
SupportsConditionalRendering = supportsConditionalRendering;
|
SupportsConditionalRendering = supportsConditionalRendering;
|
||||||
SupportsExtendedDynamicState = supportsExtendedDynamicState;
|
SupportsExtendedDynamicState = supportsExtendedDynamicState;
|
||||||
|
MinSubgroupSize = minSubgroupSize;
|
||||||
|
MaxSubgroupSize = maxSubgroupSize;
|
||||||
|
RequiredSubgroupSizeStages = requiredSubgroupSizeStages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
struct PipelineState : IDisposable
|
struct PipelineState : IDisposable
|
||||||
{
|
{
|
||||||
|
private const int RequiredSubgroupSize = 32;
|
||||||
|
|
||||||
public PipelineUid Internal;
|
public PipelineUid Internal;
|
||||||
|
|
||||||
public float LineWidth
|
public float LineWidth
|
||||||
|
@ -309,7 +311,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
StageRequiredSubgroupSizes[index] = new PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT()
|
StageRequiredSubgroupSizes[index] = new PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT()
|
||||||
{
|
{
|
||||||
SType = StructureType.PipelineShaderStageRequiredSubgroupSizeCreateInfoExt,
|
SType = StructureType.PipelineShaderStageRequiredSubgroupSizeCreateInfoExt,
|
||||||
RequiredSubgroupSize = 32
|
RequiredSubgroupSize = RequiredSubgroupSize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +329,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (gd.SupportsSubgroupSizeControl)
|
if (gd.SupportsSubgroupSizeControl)
|
||||||
{
|
{
|
||||||
UpdateStageRequiredSubgroupSizes(1);
|
UpdateStageRequiredSubgroupSizes(gd, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pipelineCreateInfo = new ComputePipelineCreateInfo()
|
var pipelineCreateInfo = new ComputePipelineCreateInfo()
|
||||||
|
@ -516,7 +518,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (gd.SupportsSubgroupSizeControl)
|
if (gd.SupportsSubgroupSizeControl)
|
||||||
{
|
{
|
||||||
UpdateStageRequiredSubgroupSizes((int)StagesCount);
|
UpdateStageRequiredSubgroupSizes(gd, (int)StagesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pipelineCreateInfo = new GraphicsPipelineCreateInfo()
|
var pipelineCreateInfo = new GraphicsPipelineCreateInfo()
|
||||||
|
@ -548,11 +550,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void UpdateStageRequiredSubgroupSizes(int count)
|
private unsafe void UpdateStageRequiredSubgroupSizes(VulkanGraphicsDevice gd, int count)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < count; index++)
|
for (int index = 0; index < count; index++)
|
||||||
{
|
{
|
||||||
Stages[index].PNext = StageRequiredSubgroupSizes.Pointer + index;
|
bool canUseExplicitSubgroupSize =
|
||||||
|
(gd.Capabilities.RequiredSubgroupSizeStages & Stages[index].Stage) != 0 &&
|
||||||
|
gd.Capabilities.MinSubgroupSize <= RequiredSubgroupSize &&
|
||||||
|
gd.Capabilities.MaxSubgroupSize >= RequiredSubgroupSize;
|
||||||
|
|
||||||
|
Stages[index].PNext = canUseExplicitSubgroupSize ? StageRequiredSubgroupSizes.Pointer + index : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
Samplers = new HashSet<SamplerHolder>();
|
Samplers = new HashSet<SamplerHolder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupContext(GraphicsDebugLevel logLevel)
|
private unsafe void SetupContext(GraphicsDebugLevel logLevel)
|
||||||
{
|
{
|
||||||
var api = Vk.GetApi();
|
var api = Vk.GetApi();
|
||||||
|
|
||||||
|
@ -119,10 +119,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
_device = VulkanInitialization.CreateDevice(api, _physicalDevice, queueFamilyIndex, supportedExtensions, maxQueueCount);
|
_device = VulkanInitialization.CreateDevice(api, _physicalDevice, queueFamilyIndex, supportedExtensions, maxQueueCount);
|
||||||
|
|
||||||
Capabilities = new HardwareCapabilities(
|
|
||||||
supportedExtensions.Contains(ExtConditionalRendering.ExtensionName),
|
|
||||||
supportedExtensions.Contains(ExtExtendedDynamicState.ExtensionName));
|
|
||||||
|
|
||||||
SupportsIndexTypeUint8 = supportedExtensions.Contains("VK_EXT_index_type_uint8");
|
SupportsIndexTypeUint8 = supportedExtensions.Contains("VK_EXT_index_type_uint8");
|
||||||
SupportsCustomBorderColor = supportedExtensions.Contains("VK_EXT_custom_border_color");
|
SupportsCustomBorderColor = supportedExtensions.Contains("VK_EXT_custom_border_color");
|
||||||
SupportsIndirectParameters = supportedExtensions.Contains(KhrDrawIndirectCount.ExtensionName);
|
SupportsIndirectParameters = supportedExtensions.Contains(KhrDrawIndirectCount.ExtensionName);
|
||||||
|
@ -165,7 +161,31 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
BackgroundQueueLock = new object();
|
BackgroundQueueLock = new object();
|
||||||
}
|
}
|
||||||
|
|
||||||
Api.GetPhysicalDeviceProperties(_physicalDevice, out var properties);
|
PhysicalDeviceProperties2 properties2 = new PhysicalDeviceProperties2()
|
||||||
|
{
|
||||||
|
SType = StructureType.PhysicalDeviceProperties2
|
||||||
|
};
|
||||||
|
|
||||||
|
PhysicalDeviceSubgroupSizeControlPropertiesEXT propertiesSubgroupSizeControl = new PhysicalDeviceSubgroupSizeControlPropertiesEXT()
|
||||||
|
{
|
||||||
|
SType = StructureType.PhysicalDeviceSubgroupSizeControlPropertiesExt
|
||||||
|
};
|
||||||
|
|
||||||
|
if (SupportsSubgroupSizeControl)
|
||||||
|
{
|
||||||
|
properties2.PNext = &propertiesSubgroupSizeControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Api.GetPhysicalDeviceProperties2(_physicalDevice, &properties2);
|
||||||
|
|
||||||
|
Capabilities = new HardwareCapabilities(
|
||||||
|
supportedExtensions.Contains(ExtConditionalRendering.ExtensionName),
|
||||||
|
supportedExtensions.Contains(ExtExtendedDynamicState.ExtensionName),
|
||||||
|
propertiesSubgroupSizeControl.MinSubgroupSize,
|
||||||
|
propertiesSubgroupSizeControl.MaxSubgroupSize,
|
||||||
|
propertiesSubgroupSizeControl.RequiredSubgroupSizeStages);
|
||||||
|
|
||||||
|
ref var properties = ref properties2.Properties;
|
||||||
|
|
||||||
MemoryAllocator = new MemoryAllocator(api, _device, properties.Limits.MaxMemoryAllocationCount);
|
MemoryAllocator = new MemoryAllocator(api, _device, properties.Limits.MaxMemoryAllocationCount);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue