• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2022 Collabora Ltd. and Red Hat Inc.
3  * SPDX-License-Identifier: MIT
4  */
5 #include "nvk_wsi.h"
6 #include "nvk_instance.h"
7 #include "wsi_common.h"
8 
9 static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
nvk_wsi_proc_addr(VkPhysicalDevice physicalDevice,const char * pName)10 nvk_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName)
11 {
12    VK_FROM_HANDLE(nvk_physical_device, pdev, physicalDevice);
13    return vk_instance_get_proc_addr_unchecked(pdev->vk.instance, pName);
14 }
15 
16 VkResult
nvk_init_wsi(struct nvk_physical_device * pdev)17 nvk_init_wsi(struct nvk_physical_device *pdev)
18 {
19    VkResult result;
20 
21    struct wsi_device_options wsi_options = {
22       .sw_device = false
23    };
24    result = wsi_device_init(&pdev->wsi_device,
25                             nvk_physical_device_to_handle(pdev),
26                             nvk_wsi_proc_addr, &pdev->vk.instance->alloc,
27                             pdev->master_fd, &nvk_physical_device_instance(pdev)->dri_options, &wsi_options);
28    if (result != VK_SUCCESS)
29       return result;
30 
31    pdev->wsi_device.supports_scanout = false;
32 
33    pdev->vk.wsi_device = &pdev->wsi_device;
34 
35    return result;
36 }
37 
38 void
nvk_finish_wsi(struct nvk_physical_device * pdev)39 nvk_finish_wsi(struct nvk_physical_device *pdev)
40 {
41    pdev->vk.wsi_device = NULL;
42    wsi_device_finish(&pdev->wsi_device, &pdev->vk.instance->alloc);
43 }
44