| 1 |
/* |
| 2 |
* Copyright 2023 Google LLC |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
#include "gfxstream_vk_entrypoints.h" |
| 7 |
#include "gfxstream_vk_private.h" |
| 8 |
#include "wsi_common.h" |
| 9 |
|
| 10 |
static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL |
| 11 |
gfxstream_vk_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char* pName) { |
| 12 |
VK_FROM_HANDLE(gfxstream_vk_physical_device, pdevice, physicalDevice); |
| 13 |
return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName); |
| 14 |
} |
| 15 |
|
| 16 |
VkResult gfxstream_vk_wsi_init(struct gfxstream_vk_physical_device* physical_device) { |
| 17 |
VkResult result = (VkResult)0; |
| 18 |
|
| 19 |
const struct wsi_device_options options = {.sw_device = false}; |
| 20 |
result = wsi_device_init( |
| 21 |
&physical_device->wsi_device, gfxstream_vk_physical_device_to_handle(physical_device), |
| 22 |
gfxstream_vk_wsi_proc_addr, &physical_device->instance->vk.alloc, -1, NULL, &options); |
| 23 |
if (result != VK_SUCCESS) return result; |
| 24 |
|
| 25 |
// Allow guest-side modifier code paths |
| 26 |
physical_device->wsi_device.supports_modifiers = true; |
| 27 |
// Support wsi_image_create_info::scanout |
| 28 |
physical_device->wsi_device.supports_scanout = true; |
| 29 |
|
| 30 |
physical_device->vk.wsi_device = &physical_device->wsi_device; |
| 31 |
|
| 32 |
return result; |
| 33 |
} |
| 34 |
|
| 35 |
void gfxstream_vk_wsi_finish(struct gfxstream_vk_physical_device* physical_device) { |
| 36 |
physical_device->vk.wsi_device = NULL; |
| 37 |
wsi_device_finish(&physical_device->wsi_device, &physical_device->instance->vk.alloc); |
| 38 |
} |