diff options
| author | 2023-06-05 21:43:43 -0700 | |
|---|---|---|
| committer | 2023-06-05 21:43:43 -0700 | |
| commit | cb95d7fe1b6d81899fe6b279400da2c991e3132c (patch) | |
| tree | a856ac45b1053009c4c11ee141c49d7faa4c8a19 /src/video_core/vulkan_common | |
| parent | Merge pull request #10611 from liamwhite/audio-deadlock (diff) | |
| parent | Merge pull request #10633 from t895/variable-surface-ratio (diff) | |
| download | yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.gz yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.xz yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.zip | |
Merge pull request #10508 from yuzu-emu/lime
Project Lime - yuzu Android Port
Diffstat (limited to 'src/video_core/vulkan_common')
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_debug_callback.cpp | 28 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.cpp | 103 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 14 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_library.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_library.h | 6 |
5 files changed, 155 insertions, 14 deletions
diff --git a/src/video_core/vulkan_common/vulkan_debug_callback.cpp b/src/video_core/vulkan_common/vulkan_debug_callback.cpp index 10a001b8f..9de484c29 100644 --- a/src/video_core/vulkan_common/vulkan_debug_callback.cpp +++ b/src/video_core/vulkan_common/vulkan_debug_callback.cpp | |||
| @@ -13,11 +13,39 @@ VkBool32 Callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, | |||
| 13 | [[maybe_unused]] void* user_data) { | 13 | [[maybe_unused]] void* user_data) { |
| 14 | // Skip logging known false-positive validation errors | 14 | // Skip logging known false-positive validation errors |
| 15 | switch (static_cast<u32>(data->messageIdNumber)) { | 15 | switch (static_cast<u32>(data->messageIdNumber)) { |
| 16 | #ifdef ANDROID | ||
| 17 | case 0xbf9cf353u: // VUID-vkCmdBindVertexBuffers2-pBuffers-04111 | ||
| 18 | // The below are due to incorrect reporting of extendedDynamicState | ||
| 19 | case 0x1093bebbu: // VUID-vkCmdSetCullMode-None-03384 | ||
| 20 | case 0x9215850fu: // VUID-vkCmdSetDepthTestEnable-None-03352 | ||
| 21 | case 0x86bf18dcu: // VUID-vkCmdSetDepthWriteEnable-None-03354 | ||
| 22 | case 0x0792ad08u: // VUID-vkCmdSetStencilOp-None-03351 | ||
| 23 | case 0x93e1ba4eu: // VUID-vkCmdSetFrontFace-None-03383 | ||
| 24 | case 0xac9c13c5u: // VUID-vkCmdSetStencilTestEnable-None-03350 | ||
| 25 | case 0xc9a2001bu: // VUID-vkCmdSetDepthBoundsTestEnable-None-03349 | ||
| 26 | case 0x8b7159a7u: // VUID-vkCmdSetDepthCompareOp-None-03353 | ||
| 27 | // The below are due to incorrect reporting of extendedDynamicState2 | ||
| 28 | case 0xb13c8036u: // VUID-vkCmdSetDepthBiasEnable-None-04872 | ||
| 29 | case 0xdff2e5c1u: // VUID-vkCmdSetRasterizerDiscardEnable-None-04871 | ||
| 30 | case 0x0cc85f41u: // VUID-vkCmdSetPrimitiveRestartEnable-None-04866 | ||
| 31 | case 0x01257b492: // VUID-vkCmdSetLogicOpEXT-None-0486 | ||
| 32 | // The below are due to incorrect reporting of vertexInputDynamicState | ||
| 33 | case 0x398e0dabu: // VUID-vkCmdSetVertexInputEXT-None-04790 | ||
| 34 | // The below are due to incorrect reporting of extendedDynamicState3 | ||
| 35 | case 0x970c11a5u: // VUID-vkCmdSetColorWriteMaskEXT-extendedDynamicState3ColorWriteMask-07364 | ||
| 36 | case 0x6b453f78u: // VUID-vkCmdSetColorBlendEnableEXT-extendedDynamicState3ColorBlendEnable-07355 | ||
| 37 | case 0xf66469d0u: // VUID-vkCmdSetColorBlendEquationEXT-extendedDynamicState3ColorBlendEquation-07356 | ||
| 38 | case 0x1d43405eu: // VUID-vkCmdSetLogicOpEnableEXT-extendedDynamicState3LogicOpEnable-07365 | ||
| 39 | case 0x638462e8u: // VUID-vkCmdSetDepthClampEnableEXT-extendedDynamicState3DepthClampEnable-07448 | ||
| 40 | // Misc | ||
| 41 | case 0xe0a2da61u: // VUID-vkCmdDrawIndexed-format-07753 | ||
| 42 | #else | ||
| 16 | case 0x682a878au: // VUID-vkCmdBindVertexBuffers2EXT-pBuffers-parameter | 43 | case 0x682a878au: // VUID-vkCmdBindVertexBuffers2EXT-pBuffers-parameter |
| 17 | case 0x99fb7dfdu: // UNASSIGNED-RequiredParameter (vkCmdBindVertexBuffers2EXT pBuffers[0]) | 44 | case 0x99fb7dfdu: // UNASSIGNED-RequiredParameter (vkCmdBindVertexBuffers2EXT pBuffers[0]) |
| 18 | case 0xe8616bf2u: // Bound VkDescriptorSet 0x0[] was destroyed. Likely push_descriptor related | 45 | case 0xe8616bf2u: // Bound VkDescriptorSet 0x0[] was destroyed. Likely push_descriptor related |
| 19 | case 0x1608dec0u: // Image layout in vkUpdateDescriptorSet doesn't match descriptor use | 46 | case 0x1608dec0u: // Image layout in vkUpdateDescriptorSet doesn't match descriptor use |
| 20 | case 0x55362756u: // Descriptor binding and framebuffer attachment overlap | 47 | case 0x55362756u: // Descriptor binding and framebuffer attachment overlap |
| 48 | #endif | ||
| 21 | return VK_FALSE; | 49 | return VK_FALSE; |
| 22 | default: | 50 | default: |
| 23 | break; | 51 | break; |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index aea677cb3..0158b6b0d 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -18,6 +18,10 @@ | |||
| 18 | #include "video_core/vulkan_common/vulkan_device.h" | 18 | #include "video_core/vulkan_common/vulkan_device.h" |
| 19 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 19 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| 20 | 20 | ||
| 21 | #if defined(ANDROID) && defined(ARCHITECTURE_arm64) | ||
| 22 | #include <adrenotools/bcenabler.h> | ||
| 23 | #endif | ||
| 24 | |||
| 21 | namespace Vulkan { | 25 | namespace Vulkan { |
| 22 | using namespace Common::Literals; | 26 | using namespace Common::Literals; |
| 23 | namespace { | 27 | namespace { |
| @@ -262,6 +266,32 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::Physica | |||
| 262 | return format_properties; | 266 | return format_properties; |
| 263 | } | 267 | } |
| 264 | 268 | ||
| 269 | #if defined(ANDROID) && defined(ARCHITECTURE_arm64) | ||
| 270 | void OverrideBcnFormats(std::unordered_map<VkFormat, VkFormatProperties>& format_properties) { | ||
| 271 | // These properties are extracted from Adreno driver 512.687.0 | ||
| 272 | constexpr VkFormatFeatureFlags tiling_features{ | ||
| 273 | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT | | ||
| 274 | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | | ||
| 275 | VK_FORMAT_FEATURE_TRANSFER_DST_BIT}; | ||
| 276 | |||
| 277 | constexpr VkFormatFeatureFlags buffer_features{VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT}; | ||
| 278 | |||
| 279 | static constexpr std::array bcn_formats{ | ||
| 280 | VK_FORMAT_BC1_RGBA_SRGB_BLOCK, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, VK_FORMAT_BC2_SRGB_BLOCK, | ||
| 281 | VK_FORMAT_BC2_UNORM_BLOCK, VK_FORMAT_BC3_SRGB_BLOCK, VK_FORMAT_BC3_UNORM_BLOCK, | ||
| 282 | VK_FORMAT_BC4_SNORM_BLOCK, VK_FORMAT_BC4_UNORM_BLOCK, VK_FORMAT_BC5_SNORM_BLOCK, | ||
| 283 | VK_FORMAT_BC5_UNORM_BLOCK, VK_FORMAT_BC6H_SFLOAT_BLOCK, VK_FORMAT_BC6H_UFLOAT_BLOCK, | ||
| 284 | VK_FORMAT_BC7_SRGB_BLOCK, VK_FORMAT_BC7_UNORM_BLOCK, | ||
| 285 | }; | ||
| 286 | |||
| 287 | for (const auto format : bcn_formats) { | ||
| 288 | format_properties[format].linearTilingFeatures = tiling_features; | ||
| 289 | format_properties[format].optimalTilingFeatures = tiling_features; | ||
| 290 | format_properties[format].bufferFeatures = buffer_features; | ||
| 291 | } | ||
| 292 | } | ||
| 293 | #endif | ||
| 294 | |||
| 265 | NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical, | 295 | NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical, |
| 266 | const std::set<std::string, std::less<>>& exts) { | 296 | const std::set<std::string, std::less<>>& exts) { |
| 267 | if (exts.contains(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME)) { | 297 | if (exts.contains(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME)) { |
| @@ -302,6 +332,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 302 | const bool is_suitable = GetSuitability(surface != nullptr); | 332 | const bool is_suitable = GetSuitability(surface != nullptr); |
| 303 | 333 | ||
| 304 | const VkDriverId driver_id = properties.driver.driverID; | 334 | const VkDriverId driver_id = properties.driver.driverID; |
| 335 | const auto device_id = properties.properties.deviceID; | ||
| 305 | const bool is_radv = driver_id == VK_DRIVER_ID_MESA_RADV; | 336 | const bool is_radv = driver_id == VK_DRIVER_ID_MESA_RADV; |
| 306 | const bool is_amd_driver = | 337 | const bool is_amd_driver = |
| 307 | driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE; | 338 | driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE; |
| @@ -310,9 +341,12 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 310 | const bool is_intel_anv = driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA; | 341 | const bool is_intel_anv = driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA; |
| 311 | const bool is_nvidia = driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY; | 342 | const bool is_nvidia = driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY; |
| 312 | const bool is_mvk = driver_id == VK_DRIVER_ID_MOLTENVK; | 343 | const bool is_mvk = driver_id == VK_DRIVER_ID_MOLTENVK; |
| 344 | const bool is_qualcomm = driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY; | ||
| 345 | const bool is_turnip = driver_id == VK_DRIVER_ID_MESA_TURNIP; | ||
| 346 | const bool is_s8gen2 = device_id == 0x43050a01; | ||
| 313 | 347 | ||
| 314 | if (is_mvk && !is_suitable) { | 348 | if ((is_mvk || is_qualcomm || is_turnip) && !is_suitable) { |
| 315 | LOG_WARNING(Render_Vulkan, "Unsuitable driver is MoltenVK, continuing anyway"); | 349 | LOG_WARNING(Render_Vulkan, "Unsuitable driver, continuing anyway"); |
| 316 | } else if (!is_suitable) { | 350 | } else if (!is_suitable) { |
| 317 | throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER); | 351 | throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER); |
| 318 | } | 352 | } |
| @@ -355,6 +389,59 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 355 | CollectPhysicalMemoryInfo(); | 389 | CollectPhysicalMemoryInfo(); |
| 356 | CollectToolingInfo(); | 390 | CollectToolingInfo(); |
| 357 | 391 | ||
| 392 | #ifdef ANDROID | ||
| 393 | if (is_qualcomm || is_turnip) { | ||
| 394 | LOG_WARNING(Render_Vulkan, | ||
| 395 | "Qualcomm and Turnip drivers have broken VK_EXT_custom_border_color"); | ||
| 396 | extensions.custom_border_color = false; | ||
| 397 | loaded_extensions.erase(VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); | ||
| 398 | } | ||
| 399 | |||
| 400 | if (is_qualcomm) { | ||
| 401 | must_emulate_scaled_formats = true; | ||
| 402 | |||
| 403 | LOG_WARNING(Render_Vulkan, "Qualcomm drivers have broken VK_EXT_extended_dynamic_state"); | ||
| 404 | extensions.extended_dynamic_state = false; | ||
| 405 | loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); | ||
| 406 | |||
| 407 | LOG_WARNING(Render_Vulkan, | ||
| 408 | "Qualcomm drivers have a slow VK_KHR_push_descriptor implementation"); | ||
| 409 | extensions.push_descriptor = false; | ||
| 410 | loaded_extensions.erase(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | ||
| 411 | |||
| 412 | #ifdef ARCHITECTURE_arm64 | ||
| 413 | // Patch the driver to enable BCn textures. | ||
| 414 | const auto major = (properties.properties.driverVersion >> 24) << 2; | ||
| 415 | const auto minor = (properties.properties.driverVersion >> 12) & 0xFFFU; | ||
| 416 | const auto vendor = properties.properties.vendorID; | ||
| 417 | const auto patch_status = adrenotools_get_bcn_type(major, minor, vendor); | ||
| 418 | |||
| 419 | if (patch_status == ADRENOTOOLS_BCN_PATCH) { | ||
| 420 | LOG_INFO(Render_Vulkan, "Patching Adreno driver to support BCn texture formats"); | ||
| 421 | if (adrenotools_patch_bcn( | ||
| 422 | reinterpret_cast<void*>(dld.vkGetPhysicalDeviceFormatProperties))) { | ||
| 423 | OverrideBcnFormats(format_properties); | ||
| 424 | } else { | ||
| 425 | LOG_ERROR(Render_Vulkan, "Patch failed! Driver code may now crash"); | ||
| 426 | } | ||
| 427 | } else if (patch_status == ADRENOTOOLS_BCN_BLOB) { | ||
| 428 | LOG_INFO(Render_Vulkan, "Adreno driver supports BCn textures without patches"); | ||
| 429 | } else { | ||
| 430 | LOG_WARNING(Render_Vulkan, "Adreno driver can't be patched to enable BCn textures"); | ||
| 431 | } | ||
| 432 | #endif // ARCHITECTURE_arm64 | ||
| 433 | } | ||
| 434 | |||
| 435 | const bool is_arm = driver_id == VK_DRIVER_ID_ARM_PROPRIETARY; | ||
| 436 | if (is_arm) { | ||
| 437 | must_emulate_scaled_formats = true; | ||
| 438 | |||
| 439 | LOG_WARNING(Render_Vulkan, "ARM drivers have broken VK_EXT_extended_dynamic_state"); | ||
| 440 | extensions.extended_dynamic_state = false; | ||
| 441 | loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); | ||
| 442 | } | ||
| 443 | #endif // ANDROID | ||
| 444 | |||
| 358 | if (is_nvidia) { | 445 | if (is_nvidia) { |
| 359 | const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff; | 446 | const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff; |
| 360 | const auto arch = GetNvidiaArchitecture(physical, supported_extensions); | 447 | const auto arch = GetNvidiaArchitecture(physical, supported_extensions); |
| @@ -388,7 +475,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 388 | loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); | 475 | loaded_extensions.erase(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); |
| 389 | } | 476 | } |
| 390 | } | 477 | } |
| 391 | if (extensions.extended_dynamic_state2 && is_radv) { | 478 | if (extensions.extended_dynamic_state2 && (is_radv || is_qualcomm)) { |
| 392 | const u32 version = (properties.properties.driverVersion << 3) >> 3; | 479 | const u32 version = (properties.properties.driverVersion << 3) >> 3; |
| 393 | if (version < VK_MAKE_API_VERSION(0, 22, 3, 1)) { | 480 | if (version < VK_MAKE_API_VERSION(0, 22, 3, 1)) { |
| 394 | LOG_WARNING( | 481 | LOG_WARNING( |
| @@ -415,7 +502,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 415 | dynamic_state3_enables = false; | 502 | dynamic_state3_enables = false; |
| 416 | } | 503 | } |
| 417 | } | 504 | } |
| 418 | if (extensions.vertex_input_dynamic_state && is_radv) { | 505 | if (extensions.vertex_input_dynamic_state && (is_radv || is_qualcomm)) { |
| 506 | // Qualcomm S8gen2 drivers do not properly support vertex_input_dynamic_state. | ||
| 419 | // TODO(ameerj): Blacklist only offending driver versions | 507 | // TODO(ameerj): Blacklist only offending driver versions |
| 420 | // TODO(ameerj): Confirm if RDNA1 is affected | 508 | // TODO(ameerj): Confirm if RDNA1 is affected |
| 421 | const bool is_rdna2 = | 509 | const bool is_rdna2 = |
| @@ -467,8 +555,8 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 467 | LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits"); | 555 | LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits"); |
| 468 | cant_blit_msaa = true; | 556 | cant_blit_msaa = true; |
| 469 | } | 557 | } |
| 470 | if (is_intel_anv) { | 558 | if (is_intel_anv || (is_qualcomm && !is_s8gen2)) { |
| 471 | LOG_WARNING(Render_Vulkan, "ANV driver does not support native BGR format"); | 559 | LOG_WARNING(Render_Vulkan, "Driver does not support native BGR format"); |
| 472 | must_emulate_bgr565 = true; | 560 | must_emulate_bgr565 = true; |
| 473 | } | 561 | } |
| 474 | if (extensions.push_descriptor && is_intel_anv) { | 562 | if (extensions.push_descriptor && is_intel_anv) { |
| @@ -633,7 +721,8 @@ bool Device::ShouldBoostClocks() const { | |||
| 633 | driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE || | 721 | driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE || |
| 634 | driver_id == VK_DRIVER_ID_MESA_RADV || driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY || | 722 | driver_id == VK_DRIVER_ID_MESA_RADV || driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY || |
| 635 | driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS || | 723 | driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS || |
| 636 | driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA; | 724 | driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA || |
| 725 | driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY || driver_id == VK_DRIVER_ID_MESA_TURNIP; | ||
| 637 | 726 | ||
| 638 | const bool is_steam_deck = vendor_id == 0x1002 && device_id == 0x163F; | 727 | const bool is_steam_deck = vendor_id == 0x1002 && device_id == 0x163F; |
| 639 | 728 | ||
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 5f1c63ff9..b692b4be4 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -295,6 +295,11 @@ public: | |||
| 295 | return features.features.textureCompressionASTC_LDR; | 295 | return features.features.textureCompressionASTC_LDR; |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | /// Returns true if descriptor aliasing is natively supported. | ||
| 299 | bool IsDescriptorAliasingSupported() const { | ||
| 300 | return GetDriverID() != VK_DRIVER_ID_QUALCOMM_PROPRIETARY; | ||
| 301 | } | ||
| 302 | |||
| 298 | /// Returns true if the device supports float16 natively. | 303 | /// Returns true if the device supports float16 natively. |
| 299 | bool IsFloat16Supported() const { | 304 | bool IsFloat16Supported() const { |
| 300 | return features.shader_float16_int8.shaderFloat16; | 305 | return features.shader_float16_int8.shaderFloat16; |
| @@ -495,6 +500,10 @@ public: | |||
| 495 | } | 500 | } |
| 496 | 501 | ||
| 497 | bool HasTimelineSemaphore() const { | 502 | bool HasTimelineSemaphore() const { |
| 503 | if (GetDriverID() == VK_DRIVER_ID_QUALCOMM_PROPRIETARY) { | ||
| 504 | // Timeline semaphores do not work properly on all Qualcomm drivers. | ||
| 505 | return false; | ||
| 506 | } | ||
| 498 | return features.timeline_semaphore.timelineSemaphore; | 507 | return features.timeline_semaphore.timelineSemaphore; |
| 499 | } | 508 | } |
| 500 | 509 | ||
| @@ -551,6 +560,10 @@ public: | |||
| 551 | return cant_blit_msaa; | 560 | return cant_blit_msaa; |
| 552 | } | 561 | } |
| 553 | 562 | ||
| 563 | bool MustEmulateScaledFormats() const { | ||
| 564 | return must_emulate_scaled_formats; | ||
| 565 | } | ||
| 566 | |||
| 554 | bool MustEmulateBGR565() const { | 567 | bool MustEmulateBGR565() const { |
| 555 | return must_emulate_bgr565; | 568 | return must_emulate_bgr565; |
| 556 | } | 569 | } |
| @@ -666,6 +679,7 @@ private: | |||
| 666 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached | 679 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached |
| 667 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. | 680 | bool supports_d24_depth{}; ///< Supports D24 depth buffers. |
| 668 | bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. | 681 | bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. |
| 682 | bool must_emulate_scaled_formats{}; ///< Requires scaled vertex format emulation | ||
| 669 | bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. | 683 | bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. |
| 670 | bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. | 684 | bool dynamic_state3_blending{}; ///< Has all blending features of dynamic_state3. |
| 671 | bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. | 685 | bool dynamic_state3_enables{}; ///< Has all enables features of dynamic_state3. |
diff --git a/src/video_core/vulkan_common/vulkan_library.cpp b/src/video_core/vulkan_common/vulkan_library.cpp index 4eb3913ee..47f6f2a03 100644 --- a/src/video_core/vulkan_common/vulkan_library.cpp +++ b/src/video_core/vulkan_common/vulkan_library.cpp | |||
| @@ -10,29 +10,35 @@ | |||
| 10 | 10 | ||
| 11 | namespace Vulkan { | 11 | namespace Vulkan { |
| 12 | 12 | ||
| 13 | Common::DynamicLibrary OpenLibrary() { | 13 | std::shared_ptr<Common::DynamicLibrary> OpenLibrary( |
| 14 | [[maybe_unused]] Core::Frontend::GraphicsContext* context) { | ||
| 14 | LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library"); | 15 | LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library"); |
| 15 | Common::DynamicLibrary library; | 16 | #if defined(ANDROID) && defined(ARCHITECTURE_arm64) |
| 17 | // Android manages its Vulkan driver from the frontend. | ||
| 18 | return context->GetDriverLibrary(); | ||
| 19 | #else | ||
| 20 | auto library = std::make_shared<Common::DynamicLibrary>(); | ||
| 16 | #ifdef __APPLE__ | 21 | #ifdef __APPLE__ |
| 17 | // Check if a path to a specific Vulkan library has been specified. | 22 | // Check if a path to a specific Vulkan library has been specified. |
| 18 | char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); | 23 | char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); |
| 19 | if (!libvulkan_env || !library.Open(libvulkan_env)) { | 24 | if (!libvulkan_env || !library->Open(libvulkan_env)) { |
| 20 | // Use the libvulkan.dylib from the application bundle. | 25 | // Use the libvulkan.dylib from the application bundle. |
| 21 | const auto filename = | 26 | const auto filename = |
| 22 | Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.dylib"; | 27 | Common::FS::GetBundleDirectory() / "Contents/Frameworks/libvulkan.dylib"; |
| 23 | void(library.Open(Common::FS::PathToUTF8String(filename).c_str())); | 28 | void(library->Open(Common::FS::PathToUTF8String(filename).c_str())); |
| 24 | } | 29 | } |
| 25 | #else | 30 | #else |
| 26 | std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); | 31 | std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); |
| 27 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library: {}", filename); | 32 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library: {}", filename); |
| 28 | if (!library.Open(filename.c_str())) { | 33 | if (!library->Open(filename.c_str())) { |
| 29 | // Android devices may not have libvulkan.so.1, only libvulkan.so. | 34 | // Android devices may not have libvulkan.so.1, only libvulkan.so. |
| 30 | filename = Common::DynamicLibrary::GetVersionedFilename("vulkan"); | 35 | filename = Common::DynamicLibrary::GetVersionedFilename("vulkan"); |
| 31 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library (second attempt): {}", filename); | 36 | LOG_DEBUG(Render_Vulkan, "Trying Vulkan library (second attempt): {}", filename); |
| 32 | void(library.Open(filename.c_str())); | 37 | void(library->Open(filename.c_str())); |
| 33 | } | 38 | } |
| 34 | #endif | 39 | #endif |
| 35 | return library; | 40 | return library; |
| 41 | #endif | ||
| 36 | } | 42 | } |
| 37 | 43 | ||
| 38 | } // namespace Vulkan | 44 | } // namespace Vulkan |
diff --git a/src/video_core/vulkan_common/vulkan_library.h b/src/video_core/vulkan_common/vulkan_library.h index 364ca979b..e1734525e 100644 --- a/src/video_core/vulkan_common/vulkan_library.h +++ b/src/video_core/vulkan_common/vulkan_library.h | |||
| @@ -3,10 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | ||
| 7 | |||
| 6 | #include "common/dynamic_library.h" | 8 | #include "common/dynamic_library.h" |
| 9 | #include "core/frontend/graphics_context.h" | ||
| 7 | 10 | ||
| 8 | namespace Vulkan { | 11 | namespace Vulkan { |
| 9 | 12 | ||
| 10 | Common::DynamicLibrary OpenLibrary(); | 13 | std::shared_ptr<Common::DynamicLibrary> OpenLibrary( |
| 14 | [[maybe_unused]] Core::Frontend::GraphicsContext* context = nullptr); | ||
| 11 | 15 | ||
| 12 | } // namespace Vulkan | 16 | } // namespace Vulkan |