mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-21 16:43:35 +00:00
Don't create query pools for unsupported query types
This commit is contained in:
parent
5a6a70e3d5
commit
9f0feb8879
3 changed files with 52 additions and 14 deletions
|
@ -6,6 +6,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
{
|
||||
public bool SupportsConditionalRendering { get; }
|
||||
public bool SupportsExtendedDynamicState { get; }
|
||||
public bool SupportsTransformFeedback { get; }
|
||||
public bool SupportsGeometryShader { get; }
|
||||
public uint MinSubgroupSize { get; }
|
||||
public uint MaxSubgroupSize { get; }
|
||||
public ShaderStageFlags RequiredSubgroupSizeStages { get; }
|
||||
|
@ -13,12 +15,16 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
public HardwareCapabilities(
|
||||
bool supportsConditionalRendering,
|
||||
bool supportsExtendedDynamicState,
|
||||
bool supportsTransformFeedback,
|
||||
bool supportsGeometryShader,
|
||||
uint minSubgroupSize,
|
||||
uint maxSubgroupSize,
|
||||
ShaderStageFlags requiredSubgroupSizeStages)
|
||||
{
|
||||
SupportsConditionalRendering = supportsConditionalRendering;
|
||||
SupportsExtendedDynamicState = supportsExtendedDynamicState;
|
||||
SupportsTransformFeedback = supportsTransformFeedback;
|
||||
SupportsGeometryShader = supportsGeometryShader;
|
||||
MinSubgroupSize = minSubgroupSize;
|
||||
MaxSubgroupSize = maxSubgroupSize;
|
||||
RequiredSubgroupSizeStages = requiredSubgroupSizeStages;
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
private readonly IntPtr _bufferMap;
|
||||
private readonly CounterType _type;
|
||||
private bool _result32Bit;
|
||||
private bool _isSupported;
|
||||
|
||||
private long _defaultValue;
|
||||
|
||||
|
@ -35,6 +36,10 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
_type = type;
|
||||
_result32Bit = result32Bit;
|
||||
|
||||
_isSupported = QueryTypeSupported(gd, type);
|
||||
|
||||
if (_isSupported)
|
||||
{
|
||||
QueryPipelineStatisticFlags flags = type == CounterType.PrimitivesGenerated ?
|
||||
QueryPipelineStatisticFlags.QueryPipelineStatisticGeometryShaderPrimitivesBit : 0;
|
||||
|
||||
|
@ -47,6 +52,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
};
|
||||
|
||||
gd.Api.CreateQueryPool(device, queryPoolCreateInfo, null, out _queryPool).ThrowOnError();
|
||||
}
|
||||
|
||||
var buffer = gd.BufferManager.Create(gd, sizeof(long), forConditionalRendering: true);
|
||||
|
||||
|
@ -56,6 +62,17 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
_buffer = buffer;
|
||||
}
|
||||
|
||||
private bool QueryTypeSupported(VulkanGraphicsDevice gd, CounterType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
CounterType.SamplesPassed => true,
|
||||
CounterType.TransformFeedbackPrimitivesWritten => gd.Capabilities.SupportsTransformFeedback,
|
||||
CounterType.PrimitivesGenerated => gd.Capabilities.SupportsGeometryShader,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
private static QueryType GetQueryType(CounterType type)
|
||||
{
|
||||
return type switch
|
||||
|
@ -79,16 +96,22 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
}
|
||||
|
||||
public void Begin()
|
||||
{
|
||||
if (_isSupported)
|
||||
{
|
||||
_pipeline.BeginQuery(this, _queryPool, !_isReset);
|
||||
}
|
||||
_isReset = false;
|
||||
}
|
||||
|
||||
public unsafe void End(bool withResult)
|
||||
{
|
||||
if (_isSupported)
|
||||
{
|
||||
_pipeline.EndQuery(_queryPool);
|
||||
}
|
||||
|
||||
if (withResult)
|
||||
if (withResult && _isSupported)
|
||||
{
|
||||
Marshal.WriteInt64(_bufferMap, _defaultValue);
|
||||
_pipeline.CopyQueryResults(this);
|
||||
|
@ -140,8 +163,11 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
}
|
||||
|
||||
public void PoolReset(CommandBuffer cmd)
|
||||
{
|
||||
if (_isSupported)
|
||||
{
|
||||
_api.CmdResetQueryPool(cmd, _queryPool, 0, 1);
|
||||
}
|
||||
_isReset = true;
|
||||
}
|
||||
|
||||
|
@ -170,7 +196,10 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
public unsafe void Dispose()
|
||||
{
|
||||
_buffer.Dispose();
|
||||
if (_isSupported)
|
||||
{
|
||||
_api.DestroyQueryPool(_device, _queryPool, null);
|
||||
}
|
||||
_queryPool = default;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
var queueFamilyIndex = VulkanInitialization.FindSuitableQueueFamily(api, _physicalDevice, _surface, out uint maxQueueCount);
|
||||
var supportedExtensions = VulkanInitialization.GetSupportedExtensions(api, _physicalDevice);
|
||||
var supportedFeatures = api.GetPhysicalDeviceFeature(_physicalDevice);
|
||||
|
||||
_device = VulkanInitialization.CreateDevice(api, _physicalDevice, queueFamilyIndex, supportedExtensions, maxQueueCount);
|
||||
|
||||
|
@ -184,6 +185,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
Capabilities = new HardwareCapabilities(
|
||||
supportedExtensions.Contains(ExtConditionalRendering.ExtensionName),
|
||||
supportedExtensions.Contains(ExtExtendedDynamicState.ExtensionName),
|
||||
supportedExtensions.Contains(ExtTransformFeedback.ExtensionName),
|
||||
supportedFeatures.GeometryShader,
|
||||
propertiesSubgroupSizeControl.MinSubgroupSize,
|
||||
propertiesSubgroupSizeControl.MaxSubgroupSize,
|
||||
propertiesSubgroupSizeControl.RequiredSubgroupSizeStages);
|
||||
|
|
Loading…
Reference in a new issue