diff options
| author | 2023-10-14 22:20:28 +0100 | |
|---|---|---|
| committer | 2023-10-19 19:54:31 +0100 | |
| commit | e02ee8e59d099692678bed09332b7d8aad1ce271 (patch) | |
| tree | 8ea0de01f31cee80075441fab4c746e0615a7ff7 /src/video_core/vulkan_common | |
| parent | Merge pull request #11810 from liamwhite/clang-17 (diff) | |
| download | yuzu-e02ee8e59d099692678bed09332b7d8aad1ce271.tar.gz yuzu-e02ee8e59d099692678bed09332b7d8aad1ce271.tar.xz yuzu-e02ee8e59d099692678bed09332b7d8aad1ce271.zip | |
Manually robust on Maxwell and earlier
Diffstat (limited to 'src/video_core/vulkan_common')
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 35 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 18 |
2 files changed, 33 insertions, 20 deletions
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 876cec2e8..e518756d2 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -83,15 +83,6 @@ constexpr std::array VK_FORMAT_A4B4G4R4_UNORM_PACK16{ | |||
| 83 | 83 | ||
| 84 | } // namespace Alternatives | 84 | } // namespace Alternatives |
| 85 | 85 | ||
| 86 | enum class NvidiaArchitecture { | ||
| 87 | KeplerOrOlder, | ||
| 88 | Maxwell, | ||
| 89 | Pascal, | ||
| 90 | Volta, | ||
| 91 | Turing, | ||
| 92 | AmpereOrNewer, | ||
| 93 | }; | ||
| 94 | |||
| 95 | template <typename T> | 86 | template <typename T> |
| 96 | void SetNext(void**& next, T& data) { | 87 | void SetNext(void**& next, T& data) { |
| 97 | *next = &data; | 88 | *next = &data; |
| @@ -326,9 +317,9 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical, | |||
| 326 | if (shading_rate_props.primitiveFragmentShadingRateWithMultipleViewports) { | 317 | if (shading_rate_props.primitiveFragmentShadingRateWithMultipleViewports) { |
| 327 | // Only Ampere and newer support this feature | 318 | // Only Ampere and newer support this feature |
| 328 | // TODO: Find a way to differentiate Ampere and Ada | 319 | // TODO: Find a way to differentiate Ampere and Ada |
| 329 | return NvidiaArchitecture::AmpereOrNewer; | 320 | return NvidiaArchitecture::Arch_AmpereOrNewer; |
| 330 | } | 321 | } |
| 331 | return NvidiaArchitecture::Turing; | 322 | return NvidiaArchitecture::Arch_Turing; |
| 332 | } | 323 | } |
| 333 | 324 | ||
| 334 | if (exts.contains(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME)) { | 325 | if (exts.contains(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME)) { |
| @@ -340,7 +331,7 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical, | |||
| 340 | physical_properties.pNext = &advanced_blending_props; | 331 | physical_properties.pNext = &advanced_blending_props; |
| 341 | physical.GetProperties2(physical_properties); | 332 | physical.GetProperties2(physical_properties); |
| 342 | if (advanced_blending_props.advancedBlendMaxColorAttachments == 1) { | 333 | if (advanced_blending_props.advancedBlendMaxColorAttachments == 1) { |
| 343 | return NvidiaArchitecture::Maxwell; | 334 | return NvidiaArchitecture::Arch_Maxwell; |
| 344 | } | 335 | } |
| 345 | 336 | ||
| 346 | if (exts.contains(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME)) { | 337 | if (exts.contains(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME)) { |
| @@ -350,13 +341,13 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical, | |||
| 350 | physical_properties.pNext = &conservative_raster_props; | 341 | physical_properties.pNext = &conservative_raster_props; |
| 351 | physical.GetProperties2(physical_properties); | 342 | physical.GetProperties2(physical_properties); |
| 352 | if (conservative_raster_props.degenerateLinesRasterized) { | 343 | if (conservative_raster_props.degenerateLinesRasterized) { |
| 353 | return NvidiaArchitecture::Volta; | 344 | return NvidiaArchitecture::Arch_Volta; |
| 354 | } | 345 | } |
| 355 | return NvidiaArchitecture::Pascal; | 346 | return NvidiaArchitecture::Arch_Pascal; |
| 356 | } | 347 | } |
| 357 | } | 348 | } |
| 358 | 349 | ||
| 359 | return NvidiaArchitecture::KeplerOrOlder; | 350 | return NvidiaArchitecture::Arch_KeplerOrOlder; |
| 360 | } | 351 | } |
| 361 | 352 | ||
| 362 | std::vector<const char*> ExtensionListForVulkan( | 353 | std::vector<const char*> ExtensionListForVulkan( |
| @@ -436,6 +427,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 436 | throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER); | 427 | throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER); |
| 437 | } | 428 | } |
| 438 | 429 | ||
| 430 | if (is_nvidia) { | ||
| 431 | nvidia_arch = GetNvidiaArchitecture(physical, supported_extensions); | ||
| 432 | } | ||
| 433 | |||
| 439 | SetupFamilies(surface); | 434 | SetupFamilies(surface); |
| 440 | const auto queue_cis = GetDeviceQueueCreateInfos(); | 435 | const auto queue_cis = GetDeviceQueueCreateInfos(); |
| 441 | 436 | ||
| @@ -532,11 +527,11 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 532 | 527 | ||
| 533 | if (is_nvidia) { | 528 | if (is_nvidia) { |
| 534 | const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff; | 529 | const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff; |
| 535 | const auto arch = GetNvidiaArchitecture(physical, supported_extensions); | 530 | const auto arch = GetNvidiaArch(); |
| 536 | if (arch >= NvidiaArchitecture::AmpereOrNewer) { | 531 | if (arch >= NvidiaArchitecture::Arch_AmpereOrNewer) { |
| 537 | LOG_WARNING(Render_Vulkan, "Ampere and newer have broken float16 math"); | 532 | LOG_WARNING(Render_Vulkan, "Ampere and newer have broken float16 math"); |
| 538 | features.shader_float16_int8.shaderFloat16 = false; | 533 | features.shader_float16_int8.shaderFloat16 = false; |
| 539 | } else if (arch <= NvidiaArchitecture::Volta) { | 534 | } else if (arch <= NvidiaArchitecture::Arch_Volta) { |
| 540 | if (nv_major_version < 527) { | 535 | if (nv_major_version < 527) { |
| 541 | LOG_WARNING(Render_Vulkan, "Volta and older have broken VK_KHR_push_descriptor"); | 536 | LOG_WARNING(Render_Vulkan, "Volta and older have broken VK_KHR_push_descriptor"); |
| 542 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | 537 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
| @@ -686,8 +681,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 686 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | 681 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
| 687 | } | 682 | } |
| 688 | } else if (extensions.push_descriptor && is_nvidia) { | 683 | } else if (extensions.push_descriptor && is_nvidia) { |
| 689 | const auto arch = GetNvidiaArchitecture(physical, supported_extensions); | 684 | const auto arch = GetNvidiaArch(); |
| 690 | if (arch <= NvidiaArchitecture::Pascal) { | 685 | if (arch <= NvidiaArchitecture::Arch_Pascal) { |
| 691 | LOG_WARNING(Render_Vulkan, | 686 | LOG_WARNING(Render_Vulkan, |
| 692 | "Pascal and older architectures have broken VK_KHR_push_descriptor"); | 687 | "Pascal and older architectures have broken VK_KHR_push_descriptor"); |
| 693 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | 688 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 282a2925d..b213ed7dd 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -177,6 +177,15 @@ enum class FormatType { Linear, Optimal, Buffer }; | |||
| 177 | /// Subgroup size of the guest emulated hardware (Nvidia has 32 threads per subgroup). | 177 | /// Subgroup size of the guest emulated hardware (Nvidia has 32 threads per subgroup). |
| 178 | const u32 GuestWarpSize = 32; | 178 | const u32 GuestWarpSize = 32; |
| 179 | 179 | ||
| 180 | enum class NvidiaArchitecture { | ||
| 181 | Arch_KeplerOrOlder, | ||
| 182 | Arch_Maxwell, | ||
| 183 | Arch_Pascal, | ||
| 184 | Arch_Volta, | ||
| 185 | Arch_Turing, | ||
| 186 | Arch_AmpereOrNewer, | ||
| 187 | }; | ||
| 188 | |||
| 180 | /// Handles data specific to a physical device. | 189 | /// Handles data specific to a physical device. |
| 181 | class Device { | 190 | class Device { |
| 182 | public: | 191 | public: |
| @@ -670,6 +679,14 @@ public: | |||
| 670 | return false; | 679 | return false; |
| 671 | } | 680 | } |
| 672 | 681 | ||
| 682 | bool IsNvidia() const noexcept { | ||
| 683 | return properties.driver.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY; | ||
| 684 | } | ||
| 685 | |||
| 686 | NvidiaArchitecture GetNvidiaArch() const noexcept { | ||
| 687 | return nvidia_arch; | ||
| 688 | } | ||
| 689 | |||
| 673 | private: | 690 | private: |
| 674 | /// Checks if the physical device is suitable and configures the object state | 691 | /// Checks if the physical device is suitable and configures the object state |
| 675 | /// with all necessary info about its properties. | 692 | /// with all necessary info about its properties. |
| @@ -788,6 +805,7 @@ private: | |||
| 788 | bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow. | 805 | bool supports_conditional_barriers{}; ///< Allows barriers in conditional control flow. |
| 789 | u64 device_access_memory{}; ///< Total size of device local memory in bytes. | 806 | u64 device_access_memory{}; ///< Total size of device local memory in bytes. |
| 790 | u32 sets_per_pool{}; ///< Sets per Description Pool | 807 | u32 sets_per_pool{}; ///< Sets per Description Pool |
| 808 | NvidiaArchitecture nvidia_arch{NvidiaArchitecture::Arch_AmpereOrNewer}; | ||
| 791 | 809 | ||
| 792 | // Telemetry parameters | 810 | // Telemetry parameters |
| 793 | std::set<std::string, std::less<>> supported_extensions; ///< Reported Vulkan extensions. | 811 | std::set<std::string, std::less<>> supported_extensions; ///< Reported Vulkan extensions. |