2021-11-11 20:53:46 +01:00
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/)
# pragma once
2022-01-12 21:45:05 +01:00
# include <vulkan/vulkan_raii.hpp>
2021-11-11 20:53:46 +01:00
# include <common.h>
2021-12-01 18:35:38 +01:00
namespace skyline : : gpu {
2021-11-11 20:53:46 +01:00
/**
2022-01-22 15:45:28 +01:00
* @ brief Checks and stores all the traits of the host GPU discovered at runtime
2021-11-11 20:53:46 +01:00
*/
2022-01-22 15:45:28 +01:00
class TraitManager {
2021-11-11 20:53:46 +01:00
public :
2021-12-28 07:02:02 +01:00
bool supportsUint8Indices { } ; //!< If the device supports using uint8 indices in index buffers (with VK_EXT_index_type_uint8)
bool supportsSamplerMirrorClampToEdge { } ; //!< If the device supports a mirrored clamp to edge as a sampler address mode (with VK_KHR_sampler_mirror_clamp_to_edge)
bool supportsSamplerReductionMode { } ; //!< If the device supports explicitly specifying a reduction mode for sampling (with VK_EXT_sampler_filter_minmax)
bool supportsCustomBorderColor { } ; //!< If the device supports a custom border color without format (VK_EXT_custom_border_color)
2021-11-11 20:53:46 +01:00
bool supportsLastProvokingVertex { } ; //!< If the device supports setting the last vertex as the provoking vertex (with VK_EXT_provoking_vertex)
2021-11-12 15:45:32 +01:00
bool supportsLogicOp { } ; //!< If the device supports framebuffer logical operations during blending
2021-11-16 06:02:01 +01:00
bool supportsVertexAttributeDivisor { } ; //!< If the device supports a divisor for instance-rate vertex attributes (with VK_EXT_vertex_attribute_divisor)
2021-11-16 09:23:28 +01:00
bool supportsVertexAttributeZeroDivisor { } ; //!< If the device supports a zero divisor for instance-rate vertex attributes (with VK_EXT_vertex_attribute_divisor)
2021-12-01 18:29:31 +01:00
bool supportsMultipleViewports { } ; //!< If the device supports more than one viewport
2021-12-05 17:35:03 +01:00
bool supportsShaderViewportIndexLayer { } ; //!< If the device supports retrieving the viewport index in shaders (with VK_EXT_shader_viewport_index_layer)
2021-12-05 15:08:46 +01:00
bool supportsSpirv14 { } ; //!< If SPIR-V 1.4 is supported (with VK_KHR_spirv_1_4)
2022-01-10 22:53:52 +01:00
bool supportsShaderDemoteToHelper { } ; //!< If a shader invocation can be demoted to a helper invocation (with VK_EXT_shader_demote_to_helper_invocation)
2021-12-05 15:08:46 +01:00
bool supportsFloat16 { } ; //!< If 16-bit floating point integers are supported in shaders
bool supportsInt8 { } ; //!< If 8-bit integers are supported in shaders
bool supportsInt16 { } ; //!< If 16-bit integers are supported in shaders
bool supportsInt64 { } ; //!< If 64-bit integers are supported in shaders
bool supportsAtomicInt64 { } ; //!< If atomic operations on 64-bit integers are supported in shaders
bool supportsFloatControls { } ; //!< If extensive control over FP behavior is exposed (with VK_KHR_shader_float_controls)
2021-12-05 17:19:43 +01:00
vk : : PhysicalDeviceFloatControlsProperties floatControls { } ; //!< Specifics of FP behavior control (All members will be zero'd out when unavailable)
2021-12-05 15:08:46 +01:00
bool supportsImageReadWithoutFormat { } ; //!< If a storage image can be read without a format
2021-12-05 17:19:43 +01:00
bool supportsSubgroupVote { } ; //!< If subgroup votes are supported in shaders with SPV_KHR_subgroup_vote
u32 subgroupSize { } ; //!< Size of a subgroup on the host GPU
2021-11-11 20:53:46 +01:00
2022-01-22 20:41:21 +01:00
/**
* @ brief Manages a list of any vendor / device - specific errata in the host GPU
*/
struct QuirkManager {
2022-03-07 12:14:08 +01:00
bool needsIndividualTextureBindingWrites { } ; //!< [Adreno Proprietary] A bug that requires descriptor set writes for VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER to be done individually with descriptorCount = 1 rather than batched
2022-03-12 15:31:52 +01:00
bool vkImageMutableFormatCostly { } ; //!< [Adreno Proprietary/Freedreno] An indication that VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is costly and should not be enabled unless absolutely necessary (Disables UBWC on Adreno GPUs)
2022-03-16 22:14:52 +01:00
bool brokenDescriptorAliasing { } ; //!< [Adreno Proprietary] A bug that causes alised descriptor sets to be incorrectly interpreted by the shader compiler leading to it buggering up LLVM function argument types and crashing
2022-03-28 11:11:37 +02:00
u32 maxSubpassCount { std : : numeric_limits < u32 > : : max ( ) } ; //!< The maximum amount of subpasses within a renderpass, this is limited to 64 on older Adreno proprietary drivers
2022-01-22 20:41:21 +01:00
QuirkManager ( ) = default ;
QuirkManager ( const vk : : PhysicalDeviceProperties & deviceProperties , const vk : : PhysicalDeviceDriverProperties & driverProperties ) ;
/**
* @ return A summary of all the GPU quirks as a human - readable string
*/
std : : string Summary ( ) ;
} quirks ;
2022-01-22 15:45:28 +01:00
TraitManager ( ) = default ;
2021-11-11 20:53:46 +01:00
2022-01-22 20:41:21 +01:00
using DeviceProperties2 = vk : : StructureChain < vk : : PhysicalDeviceProperties2 , vk : : PhysicalDeviceDriverProperties , vk : : PhysicalDeviceFloatControlsProperties , vk : : PhysicalDeviceSubgroupProperties > ;
2021-12-05 17:19:43 +01:00
2022-02-28 22:13:16 +01:00
using DeviceFeatures2 = vk : : StructureChain < vk : : PhysicalDeviceFeatures2 , vk : : PhysicalDeviceCustomBorderColorFeaturesEXT , vk : : PhysicalDeviceVertexAttributeDivisorFeaturesEXT , vk : : PhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT , vk : : PhysicalDeviceShaderFloat16Int8Features , vk : : PhysicalDeviceShaderAtomicInt64Features , vk : : PhysicalDeviceUniformBufferStandardLayoutFeatures , vk : : PhysicalDeviceShaderDrawParametersFeatures , vk : : PhysicalDeviceProvokingVertexFeaturesEXT > ;
2021-11-16 09:01:12 +01:00
2022-01-22 15:45:28 +01:00
TraitManager ( const DeviceFeatures2 & deviceFeatures2 , DeviceFeatures2 & enabledFeatures2 , const std : : vector < vk : : ExtensionProperties > & deviceExtensions , std : : vector < std : : array < char , VK_MAX_EXTENSION_NAME_SIZE > > & enabledExtensions , const DeviceProperties2 & deviceProperties2 ) ;
2021-11-12 15:55:24 +01:00
2022-01-12 21:45:05 +01:00
/**
* @ brief Applies driver specific binary patches to the driver ( e . g . BCeNabler )
*/
void ApplyDriverPatches ( const vk : : raii : : Context & context ) ;
2021-11-12 15:55:24 +01:00
/**
2022-01-22 15:45:28 +01:00
* @ return A summary of all the GPU traits as a human - readable string
2021-11-12 15:55:24 +01:00
*/
std : : string Summary ( ) ;
2021-11-11 20:53:46 +01:00
} ;
}