1/* 2 * Copyright © 2022 Imagination Technologies Ltd. 3 * 4 * based on intel anv code: 5 * Copyright © 2015 Intel Corporation 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal 9 * in the Software without restriction, including without limitation the rights 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 * copies of the Software, and to permit persons to whom the Software is 12 * furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the next 15 * paragraph) shall be included in all copies or substantial portions of the 16 * Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 * SOFTWARE. 25 */ 26 27#include <stdint.h> 28#include <stddef.h> 29#include <stdbool.h> 30#include <vulkan/vulkan.h> 31 32#include "pvr_private.h" 33#include "util/u_atomic.h" 34#include "vk_object.h" 35#include "wsi_common.h" 36 37static PFN_vkVoidFunction pvr_wsi_proc_addr(VkPhysicalDevice physicalDevice, 38 const char *pName) 39{ 40 PVR_FROM_HANDLE(pvr_physical_device, pdevice, physicalDevice); 41 42 return vk_instance_get_proc_addr_unchecked(&pdevice->instance->vk, pName); 43} 44 45VkResult pvr_wsi_init(struct pvr_physical_device *pdevice) 46{ 47 VkResult result; 48 49 result = wsi_device_init(&pdevice->wsi_device, 50 pvr_physical_device_to_handle(pdevice), 51 pvr_wsi_proc_addr, 52 &pdevice->vk.instance->alloc, 53 pdevice->master_fd, 54 NULL, 55 false); 56 if (result != VK_SUCCESS) 57 return result; 58 59 pdevice->wsi_device.supports_modifiers = true; 60 pdevice->vk.wsi_device = &pdevice->wsi_device; 61 62 return VK_SUCCESS; 63} 64 65void pvr_wsi_finish(struct pvr_physical_device *pdevice) 66{ 67 pdevice->vk.wsi_device = NULL; 68 wsi_device_finish(&pdevice->wsi_device, &pdevice->vk.instance->alloc); 69} 70 71VkResult pvr_QueuePresentKHR(VkQueue _queue, 72 const VkPresentInfoKHR *pPresentInfo) 73{ 74 PVR_FROM_HANDLE(pvr_queue, queue, _queue); 75 VkResult result; 76 77 result = wsi_common_queue_present(&queue->device->pdevice->wsi_device, 78 pvr_device_to_handle(queue->device), 79 _queue, 80 0, 81 pPresentInfo); 82 if (result != VK_SUCCESS) 83 return result; 84 85 p_atomic_inc(&queue->device->global_queue_present_count); 86 87 return VK_SUCCESS; 88} 89