Search Unity

Question Convert VkPhysicalDevice to uint64_t* adapterId

Discussion in 'General Graphics' started by nfynt-zap, Sep 14, 2022.

  1. nfynt-zap

    nfynt-zap

    Joined:
    Jun 3, 2021
    Posts:
    20
    I am trying to work up a vulkan based graphics plugin for Unity and could some of your help.

    Unity has got the following interface, where I need to convert the VkPhysicalDevice to uint64_t* adapterId
    Code (CSharp):
    1. /// Get the adapter LUID, etc. for the adapter connected to the preferred XR SDK plugin.
    2. ///
    3. /// @param[in] userData User specified data.
    4. /// @param[in] renderer The graphics renderer type that is being initialized.
    5. /// @param[in] rendererData Graphics renderer specific information needed for initialization.
    6. /// @param[out] adapterId Returns the LUID/VkPhysicalDevice/id[MTLDevice] for the connected graphics adapter.
    7. /// @return true on success, false on failure.
    8. bool(UNITY_INTERFACE_API * GetGraphicsAdapterId)(void* userData, UnityXRPreInitRenderer renderer, uint64_t rendererData, uint64_t* adapterId);
    I assumed that I could pass the vkPhysicalDeviceProperties.deviceID here, but apparently not! Results in fault addr 0x0 from Unity. Any ideas how I should go about this?
     
  2. nfynt-zap

    nfynt-zap

    Joined:
    Jun 3, 2021
    Posts:
    20
    Never mind! Casting the device handle itself to uint64_t* works.
     
  3. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    672
    Based on the description you posted, adapterId is an output parameter, so you have to call it like this:

    uint64_t adapterId;
    GetGraphicsAdapterId(...., &adapterId);