1 /* 2 * Copyright © 2023 Google Inc. 3 * 4 * derived from panvk_private.h driver which is: 5 * Copyright © 2021 Collabora Ltd. 6 * Copyright © 2016 Red Hat. 7 * Copyright © 2016 Bas Nieuwenhuizen 8 * Copyright © 2015 Intel Corporation 9 * 10 * Permission is hereby granted, free of charge, to any person obtaining a 11 * copy of this software and associated documentation files (the "Software"), 12 * to deal in the Software without restriction, including without limitation 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 * and/or sell copies of the Software, and to permit persons to whom the 15 * Software is furnished to do so, subject to the following conditions: 16 * 17 * The above copyright notice and this permission notice (including the next 18 * paragraph) shall be included in all copies or substantial portions of the 19 * Software. 20 * 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 * DEALINGS IN THE SOFTWARE. 28 */ 29 30 #ifndef GFXSTREAM_VK_PRIVATE_H 31 #define GFXSTREAM_VK_PRIVATE_H 32 33 #include <assert.h> 34 #include <stdint.h> 35 #include <stdio.h> 36 #include <stdlib.h> 37 #include <string.h> 38 #include <vulkan/vk_icd.h> 39 #include <vulkan/vulkan.h> 40 41 #include <vector> 42 43 #include "gfxstream_vk_entrypoints.h" 44 #include "vk_alloc.h" 45 #include "vk_buffer.h" 46 #include "vk_command_buffer.h" 47 #include "vk_command_pool.h" 48 #include "vk_device.h" 49 #include "vk_extensions.h" 50 #include "vk_fence.h" 51 #include "vk_image.h" 52 #include "vk_instance.h" 53 #include "vk_log.h" 54 #include "vk_object.h" 55 #include "vk_physical_device.h" 56 #include "vk_queue.h" 57 #include "vk_semaphore.h" 58 #include "vulkan/wsi/wsi_common.h" 59 60 struct gfxstream_vk_instance { 61 struct vk_instance vk; 62 uint32_t api_version; 63 VkInstance internal_object; 64 }; 65 66 struct gfxstream_vk_physical_device { 67 struct vk_physical_device vk; 68 69 struct wsi_device wsi_device; 70 const struct vk_sync_type* sync_types[2]; 71 struct gfxstream_vk_instance* instance; 72 VkPhysicalDevice internal_object; 73 }; 74 75 struct gfxstream_vk_device { 76 struct vk_device vk; 77 78 struct vk_device_dispatch_table cmd_dispatch; 79 struct gfxstream_vk_physical_device* physical_device; 80 VkDevice internal_object; 81 }; 82 83 struct gfxstream_vk_queue { 84 struct vk_queue vk; 85 struct gfxstream_vk_device* device; 86 VkQueue internal_object; 87 }; 88 89 struct gfxstream_vk_buffer { 90 struct vk_buffer vk; 91 VkBuffer internal_object; 92 }; 93 94 struct gfxstream_vk_command_pool { 95 struct vk_command_pool vk; 96 VkCommandPool internal_object; 97 }; 98 99 struct gfxstream_vk_command_buffer { 100 struct vk_command_buffer vk; 101 VkCommandBuffer internal_object; 102 }; 103 104 struct gfxstream_vk_fence { 105 struct vk_fence vk; 106 VkFence internal_object; 107 }; 108 109 struct gfxstream_vk_semaphore { 110 struct vk_semaphore vk; 111 VkSemaphore internal_object; 112 }; 113 114 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_command_buffer, vk.base, VkCommandBuffer, 115 VK_OBJECT_TYPE_COMMAND_BUFFER) 116 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE) 117 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE) 118 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_physical_device, vk.base, VkPhysicalDevice, 119 VK_OBJECT_TYPE_PHYSICAL_DEVICE) 120 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE) 121 122 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_command_pool, vk.base, VkCommandPool, 123 VK_OBJECT_TYPE_COMMAND_POOL) 124 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_buffer, vk.base, VkBuffer, VK_OBJECT_TYPE_BUFFER) 125 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_fence, vk.base, VkFence, VK_OBJECT_TYPE_FENCE) 126 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_semaphore, vk.base, VkSemaphore, 127 VK_OBJECT_TYPE_SEMAPHORE) 128 129 VkResult gfxstream_vk_wsi_init(struct gfxstream_vk_physical_device* physical_device); 130 131 void gfxstream_vk_wsi_finish(struct gfxstream_vk_physical_device* physical_device); 132 133 std::vector<VkSemaphore> transformVkSemaphoreList(const VkSemaphore* pSemaphores, 134 uint32_t semaphoreCount); 135 136 std::vector<VkFence> transformVkFenceList(const VkFence* pFences, uint32_t fenceCount); 137 138 std::vector<VkSemaphoreSubmitInfo> transformVkSemaphoreSubmitInfoList( 139 const VkSemaphoreSubmitInfo* pSemaphoreSubmitInfos, uint32_t semaphoreSubmitInfoCount); 140 141 #endif /* GFXSTREAM_VK_PRIVATE_H */ 142