vkCreateInstance() 在验证层和 VSCode 上花费了不合理的时间
vkCreateInstance() taking an unreasonable amount of time with validation layers and VSCode
我注意到我的 Vulkan 程序在 window 创建后需要将近 10 秒才能真正响应;经过一些测试,我将原因归结为 vkCreateInstance()
.
这是有趣的部分:这个问题 仅在 运行 通过 VSCode 时发生 - 调试或不调试 - 和 如果程序正在使用 验证层 (VK_EXT_debug_utils
)。也就是说:
程序在以下条件下工作:
- 它是 运行 独立的(没有 VSCode)with debug utils
- 它是运行独立的(没有VSCode)没有调试实用程序
- 在 VSCode 中 运行, 没有 调试实用程序
但是程序不工作当:
- 正在 运行 VSCode 和 调试实用程序。
('work' 我的意思是 运行 没有任何重大延迟)
我在 Linux 上使用 Radeon RX 480,使用 RADV (Mesa) 驱动程序。
更新 1
看起来我在创建实例时没有使用验证层 - 现在我已经这样做了,并且在 vkCreateInstance()
期间通过 [=76= 启动时返回以下输出]:
[vlk] Searching for layer manifest files
[vlk] In following folders:
[vlk] /home/jack/.config/vulkan/implicit_layer.d
[vlk] /etc/xdg/vulkan/implicit_layer.d
[vlk] /etc/vulkan/implicit_layer.d
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d
[vlk] /usr/local/share/vulkan/implicit_layer.d
[vlk] /usr/share/vulkan/implicit_layer.d
[vlk] Found the following files:
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_i386.json
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_x86_64.json
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_i386.json
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_x86_64.json
[vlk] /usr/share/vulkan/implicit_layer.d/amd_icd64.json
[vlk] /usr/share/vulkan/implicit_layer.d/amd_icd32.json
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_i386.json (file version "1.0.0")
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_x86_64.json (file version "1.0.0")
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_i386.json (file version "1.0.0")
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_x86_64.json (file version "1.0.0")
[vlk] Found manifest file /usr/share/vulkan/implicit_layer.d/amd_icd64.json (file version "1.0.0")
[vlk] Found manifest file /usr/share/vulkan/implicit_layer.d/amd_icd32.json (file version "1.0.0")
[vlk] Searching for layer manifest files
[vlk] In following folders:
[vlk] /home/jack/.config/vulkan/explicit_layer.d
[vlk] /etc/xdg/vulkan/explicit_layer.d
[vlk] /etc/vulkan/explicit_layer.d
[vlk] /home/jack/.local/share/vulkan/explicit_layer.d
[vlk] /usr/local/share/vulkan/explicit_layer.d
[vlk] /usr/share/vulkan/explicit_layer.d
[vlk] Found the following files:
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_screenshot.json
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_monitor.json
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_api_dump.json
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_device_simulation.json
[vlk] /usr/share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_screenshot.json (file version "1.2.0")
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_monitor.json (file version "1.0.0")
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_api_dump.json (file version "1.2.0")
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_device_simulation.json (file version "1.2.0")
[vlk] Found manifest file /usr/share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json (file version "1.2.0")
[vlk] Searching for driver manifest files
[vlk] In following folders:
[vlk] /usr/share/vulkan/icd.d/radeon_icd.x86_64.json
[vlk] Found the following files:
[vlk] /usr/share/vulkan/icd.d/radeon_icd.x86_64.json
[vlk] Found ICD manifest file /usr/share/vulkan/icd.d/radeon_icd.x86_64.json, version "1.0.0"
[vlk] Searching for ICD drivers named /usr/lib/libvulkan_radeon.so
[vlk] Build ICD instance extension list
[vlk] Loading layer library libVkLayer_khronos_validation.so
[vlk] Insert instance layer VK_LAYER_KHRONOS_validation (libVkLayer_khronos_validation.so)
[vlk] /usr/lib32/amdvlk32.so: wrong ELF class: ELFCLASS32
[vlk] Loading layer library /usr/lib/amdvlk64.so
[vlk] Insert instance layer VK_LAYER_AMD_switchable_graphics_64 (/usr/lib/amdvlk64.so)
[vlk] Requested layer VK_LAYER_AMD_switchable_graphics_32 was wrong bit-type.
[vlk] Build ICD instance extension list
输出日志在Visual Studio代码之外是一样的。
在深入研究该问题后,我找到了一个解决方法,虽然它不能完全消除延迟,但可以将延迟最小化到 几乎 瞬间。大约 8-9 秒下降到平均大约 2-3 秒。不完美,但比上一次联赛领先。
结果是 GDB,无论出于何种原因,导致了此延迟。也许 GDB 或 Vulkan 团队的某个人应该研究一下?我不知道。无论如何,VSCode 正在使用 GDB 调试程序。
所以要解决这个问题:改用 LLDB。 幸运的是,我不限于出于任何原因使用 GDB,而且 LLDB 似乎也是一个非常好的调试器。可能还有其他我不知道的更好的工作......我会在未来的某个时候进一步研究它。
在我的例子中,因为我使用 VSCode,this extension 对于将 LLDB 集成到 Code 拥有的 launch.json 系统中很有用。
我注意到我的 Vulkan 程序在 window 创建后需要将近 10 秒才能真正响应;经过一些测试,我将原因归结为 vkCreateInstance()
.
这是有趣的部分:这个问题 仅在 运行 通过 VSCode 时发生 - 调试或不调试 - 和 如果程序正在使用 验证层 (VK_EXT_debug_utils
)。也就是说:
程序在以下条件下工作:
- 它是 运行 独立的(没有 VSCode)with debug utils
- 它是运行独立的(没有VSCode)没有调试实用程序
- 在 VSCode 中 运行, 没有 调试实用程序
但是程序不工作当:
- 正在 运行 VSCode 和 调试实用程序。
('work' 我的意思是 运行 没有任何重大延迟)
我在 Linux 上使用 Radeon RX 480,使用 RADV (Mesa) 驱动程序。
更新 1
看起来我在创建实例时没有使用验证层 - 现在我已经这样做了,并且在 vkCreateInstance()
期间通过 [=76= 启动时返回以下输出]:
[vlk] Searching for layer manifest files
[vlk] In following folders:
[vlk] /home/jack/.config/vulkan/implicit_layer.d
[vlk] /etc/xdg/vulkan/implicit_layer.d
[vlk] /etc/vulkan/implicit_layer.d
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d
[vlk] /usr/local/share/vulkan/implicit_layer.d
[vlk] /usr/share/vulkan/implicit_layer.d
[vlk] Found the following files:
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_i386.json
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_x86_64.json
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_i386.json
[vlk] /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_x86_64.json
[vlk] /usr/share/vulkan/implicit_layer.d/amd_icd64.json
[vlk] /usr/share/vulkan/implicit_layer.d/amd_icd32.json
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_i386.json (file version "1.0.0")
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_x86_64.json (file version "1.0.0")
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamoverlay_i386.json (file version "1.0.0")
[vlk] Found manifest file /home/jack/.local/share/vulkan/implicit_layer.d/steamfossilize_x86_64.json (file version "1.0.0")
[vlk] Found manifest file /usr/share/vulkan/implicit_layer.d/amd_icd64.json (file version "1.0.0")
[vlk] Found manifest file /usr/share/vulkan/implicit_layer.d/amd_icd32.json (file version "1.0.0")
[vlk] Searching for layer manifest files
[vlk] In following folders:
[vlk] /home/jack/.config/vulkan/explicit_layer.d
[vlk] /etc/xdg/vulkan/explicit_layer.d
[vlk] /etc/vulkan/explicit_layer.d
[vlk] /home/jack/.local/share/vulkan/explicit_layer.d
[vlk] /usr/local/share/vulkan/explicit_layer.d
[vlk] /usr/share/vulkan/explicit_layer.d
[vlk] Found the following files:
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_screenshot.json
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_monitor.json
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_api_dump.json
[vlk] /etc/vulkan/explicit_layer.d/VkLayer_device_simulation.json
[vlk] /usr/share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_screenshot.json (file version "1.2.0")
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_monitor.json (file version "1.0.0")
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_api_dump.json (file version "1.2.0")
[vlk] Found manifest file /etc/vulkan/explicit_layer.d/VkLayer_device_simulation.json (file version "1.2.0")
[vlk] Found manifest file /usr/share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json (file version "1.2.0")
[vlk] Searching for driver manifest files
[vlk] In following folders:
[vlk] /usr/share/vulkan/icd.d/radeon_icd.x86_64.json
[vlk] Found the following files:
[vlk] /usr/share/vulkan/icd.d/radeon_icd.x86_64.json
[vlk] Found ICD manifest file /usr/share/vulkan/icd.d/radeon_icd.x86_64.json, version "1.0.0"
[vlk] Searching for ICD drivers named /usr/lib/libvulkan_radeon.so
[vlk] Build ICD instance extension list
[vlk] Loading layer library libVkLayer_khronos_validation.so
[vlk] Insert instance layer VK_LAYER_KHRONOS_validation (libVkLayer_khronos_validation.so)
[vlk] /usr/lib32/amdvlk32.so: wrong ELF class: ELFCLASS32
[vlk] Loading layer library /usr/lib/amdvlk64.so
[vlk] Insert instance layer VK_LAYER_AMD_switchable_graphics_64 (/usr/lib/amdvlk64.so)
[vlk] Requested layer VK_LAYER_AMD_switchable_graphics_32 was wrong bit-type.
[vlk] Build ICD instance extension list
输出日志在Visual Studio代码之外是一样的。
在深入研究该问题后,我找到了一个解决方法,虽然它不能完全消除延迟,但可以将延迟最小化到 几乎 瞬间。大约 8-9 秒下降到平均大约 2-3 秒。不完美,但比上一次联赛领先。
结果是 GDB,无论出于何种原因,导致了此延迟。也许 GDB 或 Vulkan 团队的某个人应该研究一下?我不知道。无论如何,VSCode 正在使用 GDB 调试程序。
所以要解决这个问题:改用 LLDB。 幸运的是,我不限于出于任何原因使用 GDB,而且 LLDB 似乎也是一个非常好的调试器。可能还有其他我不知道的更好的工作......我会在未来的某个时候进一步研究它。
在我的例子中,因为我使用 VSCode,this extension 对于将 LLDB 集成到 Code 拥有的 launch.json 系统中很有用。