@ -314,17 +314,17 @@ void OverrideBcnFormats(std::unordered_map<VkFormat, VkFormatProperties>& format
NvidiaArchitecture GetNvidiaArchitecture ( vk : : PhysicalDevice physical ,
const std : : set < std : : string , std : : less < > > & exts ) {
VkPhysicalDeviceProperties2 physical_properties { } ;
physical_properties . sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 ;
physical_properties . pNext = nullptr ;
if ( exts . contains ( VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME ) ) {
VkPhysicalDeviceFragmentShadingRatePropertiesKHR shading_rate_props { } ;
shading_rate_props . sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR ;
VkPhysicalDeviceProperties2 physical_properties { } ;
physical_properties . sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 ;
physical_properties . pNext = & shading_rate_props ;
physical . GetProperties2 ( physical_properties ) ;
if ( shading_rate_props . primitiveFragmentShadingRateWithMultipleViewports ) {
// Only Ampere and newer support this feature
// TODO: Find a way to differentiate Ampere and Ada
return NvidiaArchitecture : : Arch_AmpereOrNewer ;
}
return NvidiaArchitecture : : Arch_Turing ;
@ -334,8 +334,6 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical,
VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT advanced_blending_props { } ;
advanced_blending_props . sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT ;
VkPhysicalDeviceProperties2 physical_properties { } ;
physical_properties . sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 ;
physical_properties . pNext = & advanced_blending_props ;
physical . GetProperties2 ( physical_properties ) ;
if ( advanced_blending_props . advancedBlendMaxColorAttachments = = 1 ) {
@ -447,7 +445,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
const void * first_next = & features2 ;
VkDeviceDiagnosticsConfigCreateInfoNV diagnostics_nv { } ;
if ( Settings : : values . enable_nsight_aftermath & & extensions . device_diagnostics_config ) {
const bool use_diagnostics_nv = Settings : : values . enable_nsight_aftermath & & extensions . device_diagnostics_config ;
if ( use_diagnostics_nv ) {
nsight_aftermath_tracker = std : : make_unique < NsightAftermathTracker > ( ) ;
diagnostics_nv = {
@ -460,6 +459,18 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
first_next = & diagnostics_nv ;
}
VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptor_indexing {
. sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT ,
. pNext = use_diagnostics_nv ? static_cast < void * > ( & diagnostics_nv ) : static_cast < void * > ( & features2 ) ,
. shaderSampledImageArrayNonUniformIndexing = VK_TRUE ,
. descriptorBindingPartiallyBound = VK_TRUE ,
. descriptorBindingVariableDescriptorCount = VK_TRUE ,
} ;
if ( extensions . descriptor_indexing & & Settings : : values . descriptor_indexing . GetValue ( ) ) {
first_next = & descriptor_indexing ;
}
is_blit_depth24_stencil8_supported = TestDepthStencilBlits ( VK_FORMAT_D24_UNORM_S8_UINT ) ;
is_blit_depth32_stencil8_supported = TestDepthStencilBlits ( VK_FORMAT_D32_SFLOAT_S8_UINT ) ;
is_optimal_astc_supported = ComputeIsOptimalAstcSupported ( ) ;
@ -490,7 +501,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
if ( is_qualcomm ) {
LOG_WARNING ( Render_Vulkan ,
" Qualcomm drivers have a slow VK_KHR_push_descriptor implementation " ) ;
RemoveExtension ( extensions . push_descriptor , VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME ) ;
//RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
# if defined(ANDROID) && defined(ARCHITECTURE_arm64)
// Patch the driver to enable BCn textures.
@ -524,7 +535,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
} else if ( arch < = NvidiaArchitecture : : Arch_Volta ) {
if ( nv_major_version < 527 ) {
LOG_WARNING ( Render_Vulkan , " Volta and older have broken VK_KHR_push_descriptor " ) ;
RemoveExtension ( extensions . push_descriptor , VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME ) ;
//RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
}
}
if ( nv_major_version > = 510 ) {
@ -641,9 +652,9 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
const u32 version = ( properties . properties . driverVersion < < 3 ) > > 3 ;
if ( version < VK_MAKE_API_VERSION ( 27 , 20 , 100 , 0 ) ) {
LOG_WARNING ( Render_Vulkan , " Intel has broken VK_EXT_vertex_input_dynamic_state " ) ;
RemoveExtensionFeature ( extensions . vertex_input_dynamic_state ,
features . vertex_input_dynamic_state ,
VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME ) ;
//RemoveExtensionFeature(extensions.vertex_input_dynamic_state,
//features.vertex_input_dynamic_state,
//VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME);
}
}
if ( features . shader_float16_int8 . shaderFloat16 & & is_intel_windows ) {
@ -670,14 +681,14 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
// mesa/mesa/-/commit/ff91c5ca42bc80aa411cb3fd8f550aa6fdd16bdc
LOG_WARNING ( Render_Vulkan ,
" ANV drivers 22.3.0 to 23.1.0 have broken VK_KHR_push_descriptor " ) ;
RemoveExtension ( extensions . push_descriptor , VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME ) ;
//RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
}
} else if ( extensions . push_descriptor & & is_nvidia ) {
const auto arch = GetNvidiaArch ( ) ;
if ( arch < = NvidiaArchitecture : : Arch_Pascal ) {
LOG_WARNING ( Render_Vulkan ,
" Pascal and older architectures have broken VK_KHR_push_descriptor " ) ;
RemoveExtension ( extensions . push_descriptor , VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME ) ;
//RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
}
}
@ -715,7 +726,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
must_emulate_scaled_formats = true ;
LOG_INFO ( Render_Vulkan , " Dynamic state is disabled (dyna_state = 0), forcing scaled format emulation ON " ) ;
// Remove all dynamic state 1-2 extensions and feature s
// Disable dynamic state 1-3 and all extension s
RemoveExtensionFeature ( extensions . custom_border_color , features . custom_border_color ,
VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME ) ;
@ -728,15 +739,12 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
RemoveExtensionFeature ( extensions . vertex_input_dynamic_state , features . vertex_input_dynamic_state ,
VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME ) ;
// Disable extended dynamic state 3 features
features . extended_dynamic_state3 . extendedDynamicState3ColorBlendEnable = false ;
features . extended_dynamic_state3 . extendedDynamicState3ColorBlendEquation = false ;
features . extended_dynamic_state3 . extendedDynamicState3DepthClampEnable = false ;
RemoveExtensionFeature ( extensions . extended_dynamic_state3 , features . extended_dynamic_state3 ,
VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME ) ;
dynamic_state3_blending = false ;
dynamic_state3_enables = false ;
LOG_INFO ( Render_Vulkan , " Dynamic state extensions and features have been fully disabled" ) ;
LOG_INFO ( Render_Vulkan , " All dynamic state extensions and features have been disabled" ) ;
} else {
must_emulate_scaled_formats = false ;
LOG_INFO ( Render_Vulkan , " Dynamic state is enabled (dyna_state = 1-3), disabling scaled format emulation " ) ;
@ -963,6 +971,11 @@ bool Device::GetSuitability(bool requires_swapchain) {
// Assume we will be suitable.
bool suitable = true ;
// Configure properties.
VkPhysicalDeviceVulkan12Features features_1_2 { } ;
VkPhysicalDeviceVulkan13Features features_1_3 { } ;
VkPhysicalDeviceVulkan14Features features_1_4 { } ;
// Configure properties.
properties . properties = physical . GetProperties ( ) ;
@ -1036,6 +1049,19 @@ bool Device::GetSuitability(bool requires_swapchain) {
// Set next pointer.
void * * next = & features2 . pNext ;
// Vulkan 1.2, 1.3 and 1.4 features
if ( instance_version > = VK_API_VERSION_1_2 ) {
features_1_2 . sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES ;
features_1_3 . sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES ;
features_1_4 . sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_4_FEATURES ;
features_1_2 . pNext = & features_1_3 ;
features_1_3 . pNext = & features_1_4 ;
* next = & features_1_2 ;
// next = &features_1_4.pNext;
}
// Test all features we know about. If the feature is not available in core at our
// current API version, and was not enabled by an extension, skip testing the feature.
// We set the structure sType explicitly here as it is zeroed by the constructor.
@ -1068,6 +1094,8 @@ bool Device::GetSuitability(bool requires_swapchain) {
// Perform the feature test.
physical . GetFeatures2 ( features2 ) ;
// Base Vulkan 1.0 features are always valid regardless of instance version.
features . features = features2 . features ;
// Some features are mandatory. Check those.
@ -1126,6 +1154,8 @@ bool Device::GetSuitability(bool requires_swapchain) {
// Perform the property fetch.
physical . GetProperties2 ( properties2 ) ;
// Store base properties
properties . properties = properties2 . properties ;
// Unload extensions if feature support is insufficient.
@ -1208,8 +1238,8 @@ void Device::RemoveUnsuitableExtensions() {
extensions . provoking_vertex =
features . provoking_vertex . provokingVertexLast & &
features . provoking_vertex . transformFeedbackPreservesProvokingVertex ;
RemoveExtensionFeatureIfUnsuitable ( extensions . provoking_vertex , features . provoking_vertex ,
VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME ) ;
// RemoveExtensionFeatureIfUnsuitable(extensions.provoking_vertex, features.provoking_vertex,
// VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME);
// VK_KHR_shader_atomic_int64
extensions . shader_atomic_int64 = features . shader_atomic_int64 . shaderBufferInt64Atomics & &
@ -1247,9 +1277,9 @@ void Device::RemoveUnsuitableExtensions() {
// VK_EXT_vertex_input_dynamic_state
extensions . vertex_input_dynamic_state =
features . vertex_input_dynamic_state . vertexInputDynamicState ;
RemoveExtensionFeatureIfUnsuitable ( extensions . vertex_input_dynamic_state ,
features . vertex_input_dynamic_state ,
VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME ) ;
//RemoveExtensionFeatureIfUnsuitable(extensions.vertex_input_dynamic_state,
//features.vertex_input_dynamic_state,
//VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME);
// VK_KHR_pipeline_executable_properties
if ( Settings : : values . renderer_shader_feedback . GetValue ( ) ) {