• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2023 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "gfxstream_vk_entrypoints.h"
16 #include "gfxstream_vk_private.h"
17 #include "wsi_common.h"
18 
19 static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
gfxstream_vk_wsi_proc_addr(VkPhysicalDevice physicalDevice,const char * pName)20 gfxstream_vk_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char* pName) {
21     VK_FROM_HANDLE(gfxstream_vk_physical_device, pdevice, physicalDevice);
22     return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName);
23 }
24 
gfxstream_vk_wsi_init(struct gfxstream_vk_physical_device * physical_device)25 VkResult gfxstream_vk_wsi_init(struct gfxstream_vk_physical_device* physical_device) {
26     VkResult result = (VkResult)0;
27 
28     const struct wsi_device_options options = {.sw_device = false};
29     result = wsi_device_init(
30         &physical_device->wsi_device, gfxstream_vk_physical_device_to_handle(physical_device),
31         gfxstream_vk_wsi_proc_addr, &physical_device->instance->vk.alloc, -1, NULL, &options);
32     if (result != VK_SUCCESS) return result;
33 
34     // Allow guest-side modifier code paths
35     physical_device->wsi_device.supports_modifiers = true;
36     // Support wsi_image_create_info::scanout
37     physical_device->wsi_device.supports_scanout = true;
38 
39     physical_device->vk.wsi_device = &physical_device->wsi_device;
40 
41     return result;
42 }
43 
gfxstream_vk_wsi_finish(struct gfxstream_vk_physical_device * physical_device)44 void gfxstream_vk_wsi_finish(struct gfxstream_vk_physical_device* physical_device) {
45     physical_device->vk.wsi_device = NULL;
46     wsi_device_finish(&physical_device->wsi_device, &physical_device->instance->vk.alloc);
47 }
48