Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Selecting a different PhysicalDevice in Vulkan



  • I wish to select a different physical device at start up as I am in the situation of having both an integrated GPU and discrete GPU (a.k.a optimus) and I'm using optimus-manager in order to do Vulkan development. I need to select the discrete GPU.

    qt.vulkan: 6 physical devices
    qt.vulkan: Physical device [0]: name 'Intel(R) Haswell Mobile' version 19.0.2
    qt.vulkan: Physical device [1]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Physical device [2]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Physical device [3]: name 'Intel(R) Haswell Mobile' version 19.0.2
    qt.vulkan: Physical device [4]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Physical device [5]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Using physical device [0]
    

    like this:

    deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
    


  • Because this kind of thing happens:

    11:20:11: Starting /...../build-examples-Desktop-Debug/vulkan/hellovulkancubes/hellovulkancubes...
    INTEL-MESA: warning: Haswell Vulkan support is incomplete
    INTEL-MESA: warning: Haswell Vulkan support is incomplete
    qt.qpa.xcb: QXcbConnection: XCB error: 9 (BadDrawable), sequence: 531, resource id: 106954769, major code: 149 (Unknown), minor code: 4
    qt.qpa.xcb: QXcbConnection: XCB error: 9 (BadDrawable), sequence: 533, resource id: 106954771, major code: 149 (Unknown), minor code: 4
    vkDebug: anv: 0: ../mesa-19.0.2/src/intel/vulkan/anv_device.c:2159: GPU hung on one of our command buffers (VK_ERROR_DEVICE_LOST)
    QVulkanWindow: Device lost
    INTEL-MESA: error: ../mesa-19.0.2/src/intel/vulkan/anv_device.c:2159: GPU hung on one of our command buffers (VK_ERROR_DEVICE_LOST)


  • I notice that there is a:

    m_window->setPhysicalDeviceIndex()
    

    method but is that the right way to do it? also when or at which stage should this function be called to make that pysical device selected?



  • Althought this is what happens when I change the index to 1, 2, 4, or 5:

    INTEL-MESA: warning: Haswell Vulkan support is incomplete
    INTEL-MESA: warning: Haswell Vulkan support is incomplete
    qt.vulkan: Vulkan init (libvulkan.so)
    qt.vulkan: Supported Vulkan instance layers: QVector(QVulkanLayer("VK_LAYER_RENDERDOC_Capture" 2 1.1.73 "Debugging capture layer for RenderDoc"), QVulkanLayer("VK_LAYER_PRIMUS_PrimusVK" 1 1.1.0 "Primus-vk - https://github.com/felixdoerre/primus_vk"), QVulkanLayer("VK_LAYER_RENDERDOC_Capture" 2 1.1.73 "Debugging capture layer for RenderDoc"), QVulkanLayer("VK_LAYER_PRIMUS_PrimusVK" 1 1.1.0 "Primus-vk - https://github.com/felixdoerre/primus_vk"), QVulkanLayer("VK_LAYER_VALVE_steam_overlay_32" 1 1.1.73 "Steam Overlay Layer"), QVulkanLayer("VK_LAYER_VALVE_steam_overlay_64" 1 1.1.73 "Steam Overlay Layer"), QVulkanLayer("VK_LAYER_LUNARG_monitor" 1 1.1.97 "Execution Monitoring Layer"), QVulkanLayer("VK_LAYER_LUNARG_screenshot" 1 1.1.97 "LunarG image capture layer"), QVulkanLayer("VK_LAYER_LUNARG_api_dump" 2 1.1.97 "LunarG debug layer"), QVulkanLayer("VK_LAYER_LUNARG_device_simulation" 1 1.1.97 "LunarG device simulation layer"), QVulkanLayer("VK_LAYER_LUNARG_vktrace" 1 1.1.97 "Vktrace tracing library"), QVulkanLayer("VK_LAYER_GOOGLE_threading" 1 1.1.100 "Google Validation Layer"), QVulkanLayer("VK_LAYER_LUNARG_object_tracker" 1 1.1.100 "LunarG Validation Layer"), QVulkanLayer("VK_LAYER_LUNARG_parameter_validation" 1 1.1.100 "LunarG Validation Layer"), QVulkanLayer("VK_LAYER_GOOGLE_unique_objects" 1 1.1.100 "Google Validation Layer"), QVulkanLayer("VK_LAYER_LUNARG_standard_validation" 1 1.1.100 "LunarG Standard Validation"), QVulkanLayer("VK_LAYER_LUNARG_core_validation" 1 1.1.100 "LunarG Validation Layer"), QVulkanLayer("VK_LAYER_LUNARG_monitor" 1 1.1.97 "Execution Monitoring Layer"), QVulkanLayer("VK_LAYER_LUNARG_screenshot" 1 1.1.97 "LunarG image capture layer"), QVulkanLayer("VK_LAYER_LUNARG_api_dump" 2 1.1.97 "LunarG debug layer"), QVulkanLayer("VK_LAYER_LUNARG_device_simulation" 1 1.1.97 "LunarG device simulation layer"), QVulkanLayer("VK_LAYER_LUNARG_vktrace" 1 1.1.97 "Vktrace tracing library"), QVulkanLayer("VK_LAYER_GOOGLE_threading" 1 1.1.100 "Google Validation Layer"), QVulkanLayer("VK_LAYER_LUNARG_object_tracker" 1 1.1.100 "LunarG Validation Layer"), QVulkanLayer("VK_LAYER_LUNARG_parameter_validation" 1 1.1.100 "LunarG Validation Layer"), QVulkanLayer("VK_LAYER_GOOGLE_unique_objects" 1 1.1.100 "Google Validation Layer"), QVulkanLayer("VK_LAYER_LUNARG_standard_validation" 1 1.1.100 "LunarG Standard Validation"), QVulkanLayer("VK_LAYER_LUNARG_core_validation" 1 1.1.100 "LunarG Validation Layer"))
    qt.vulkan: Supported Vulkan instance extensions: QVector(QVulkanExtension("VK_KHR_device_group_creation" 1), QVulkanExtension("VK_KHR_display" 21), QVulkanExtension("VK_KHR_external_fence_capabilities" 1), QVulkanExtension("VK_KHR_external_memory_capabilities" 1), QVulkanExtension("VK_KHR_external_semaphore_capabilities" 1), QVulkanExtension("VK_KHR_get_display_properties2" 1), QVulkanExtension("VK_KHR_get_physical_device_properties2" 1), QVulkanExtension("VK_KHR_get_surface_capabilities2" 1), QVulkanExtension("VK_KHR_surface" 25), QVulkanExtension("VK_KHR_xcb_surface" 6), QVulkanExtension("VK_KHR_xlib_surface" 6), QVulkanExtension("VK_EXT_acquire_xlib_display" 1), QVulkanExtension("VK_EXT_debug_report" 9), QVulkanExtension("VK_EXT_debug_utils" 1), QVulkanExtension("VK_EXT_direct_mode_display" 1), QVulkanExtension("VK_EXT_display_surface_counter" 1), QVulkanExtension("VK_KHR_wayland_surface" 6))
    qt.vulkan: Enabling Vulkan instance layers: ("VK_LAYER_LUNARG_standard_validation")
    qt.vulkan: Enabling Vulkan instance extensions: ("VK_EXT_debug_report", "VK_KHR_surface", "VK_KHR_xcb_surface")
    qt.vulkan: QVulkanWindow init
    qt.vulkan: 6 physical devices
    qt.vulkan: Physical device [0]: name 'Intel(R) Haswell Mobile' version 19.0.2
    qt.vulkan: Physical device [1]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Physical device [2]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Physical device [3]: name 'Intel(R) Haswell Mobile' version 19.0.2
    qt.vulkan: Physical device [4]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Physical device [5]: name 'GeForce 840M' version 418.224.0
    qt.vulkan: Using physical device [1]
    qt.vulkan: queue family 0: flags=0xf count=16 supportsPresent=1
    qt.vulkan: queue family 1: flags=0x4 count=1 supportsPresent=0
    qt.vulkan: Using queue families: graphics = 0 present = 0
    qt.vulkan: Supported device extensions: QVector(QVulkanExtension("VK_KHR_8bit_storage" 1), QVulkanExtension("VK_KHR_16bit_storage" 1), QVulkanExtension("VK_KHR_bind_memory2" 1), QVulkanExtension("VK_KHR_create_renderpass2" 1), QVulkanExtension("VK_KHR_dedicated_allocation" 3), QVulkanExtension("VK_KHR_depth_stencil_resolve" 1), QVulkanExtension("VK_KHR_descriptor_update_template" 1), QVulkanExtension("VK_KHR_device_group" 3), QVulkanExtension("VK_KHR_draw_indirect_count" 1), QVulkanExtension("VK_KHR_driver_properties" 1), QVulkanExtension("VK_KHR_external_fence" 1), QVulkanExtension("VK_KHR_external_fence_fd" 1), QVulkanExtension("VK_KHR_external_memory" 1), QVulkanExtension("VK_KHR_external_memory_fd" 1), QVulkanExtension("VK_KHR_external_semaphore" 1), QVulkanExtension("VK_KHR_external_semaphore_fd" 1), QVulkanExtension("VK_KHR_get_memory_requirements2" 1), QVulkanExtension("VK_KHR_image_format_list" 1), QVulkanExtension("VK_KHR_maintenance1" 2), QVulkanExtension("VK_KHR_maintenance2" 1), QVulkanExtension("VK_KHR_maintenance3" 1), QVulkanExtension("VK_KHR_multiview" 1), QVulkanExtension("VK_KHR_push_descriptor" 2), QVulkanExtension("VK_KHR_relaxed_block_layout" 1), QVulkanExtension("VK_KHR_sampler_mirror_clamp_to_edge" 1), QVulkanExtension("VK_KHR_sampler_ycbcr_conversion" 1), QVulkanExtension("VK_KHR_shader_atomic_int64" 1), QVulkanExtension("VK_KHR_shader_draw_parameters" 1), QVulkanExtension("VK_KHR_shader_float16_int8" 1), QVulkanExtension("VK_KHR_shader_float_controls" 1), QVulkanExtension("VK_KHR_storage_buffer_storage_class" 1), QVulkanExtension("VK_KHR_swapchain" 70), QVulkanExtension("VK_KHR_swapchain_mutable_format" 1), QVulkanExtension("VK_KHR_variable_pointers" 1), QVulkanExtension("VK_KHR_vulkan_memory_model" 2), QVulkanExtension("VK_EXT_blend_operation_advanced" 2), QVulkanExtension("VK_EXT_conditional_rendering" 1), QVulkanExtension("VK_EXT_depth_range_unrestricted" 1), QVulkanExtension("VK_EXT_descriptor_indexing" 2), QVulkanExtension("VK_EXT_discard_rectangles" 1), QVulkanExtension("VK_EXT_display_control" 1), QVulkanExtension("VK_EXT_global_priority" 2), QVulkanExtension("VK_EXT_inline_uniform_block" 1), QVulkanExtension("VK_EXT_scalar_block_layout" 1), QVulkanExtension("VK_EXT_shader_subgroup_ballot" 1), QVulkanExtension("VK_EXT_shader_subgroup_vote" 1), QVulkanExtension("VK_EXT_transform_feedback" 1), QVulkanExtension("VK_EXT_vertex_attribute_divisor" 3), QVulkanExtension("VK_NV_dedicated_allocation" 1), QVulkanExtension("VK_NV_device_diagnostic_checkpoints" 2), QVulkanExtension("VK_NV_shader_subgroup_partitioned" 1), QVulkanExtension("VK_NVX_device_generated_commands" 3), QVulkanExtension("VK_NVX_multiview_per_view_attributes" 1))
    qt.vulkan: Enabling device extensions: QVector(VK_KHR_swapchain)
    qt.vulkan: memtype 0: flags=0x0
    ANOM_ABEND auid=1000 uid=1000 gid=1000 ses=2 pid=5573 comm="hellovulkanwind" exe="/...../examples/vulkan/build-hellovulkanwindow-Desktop-Debug/hellovulkanwindow" sig=11 res=1
    qt.vulkan: memtype 1: flags=0x0
    qt.vulkan: memtype 2: flags=0x0
    qt.vulkan: memtype 3: flags=0x0
    qt.vulkan: memtype 4: flags=0x0
    qt.vulkan: memtype 5: flags=0x0
    qt.vulkan: memtype 6: flags=0x0
    qt.vulkan: memtype 7: flags=0x1
    qt.vulkan: memtype 8: flags=0x1
    qt.vulkan: memtype 9: flags=0x6
    qt.vulkan: memtype 10: flags=0xe
    qt.vulkan: Picked memtype 10 for host visible memory
    qt.vulkan: Picked memtype 7 for device local memory
    23:15:22: The program has unexpectedly finished.
    23:15:22: The process was ended forcefully.
    

    with the following code in the hellowvulkanwindow project:

    VulkanRenderer::VulkanRenderer(QVulkanWindow *w)
        : m_window(w)
    {
        m_window->setPhysicalDeviceIndex(1);
    }
    

Log in to reply