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