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 #define GFXSTREAM_DEFAULT_ALIGN 8 61 62 struct gfxstream_vk_instance { 63 struct vk_instance vk; 64 uint32_t api_version; 65 VkInstance internal_object; 66 }; 67 68 struct gfxstream_vk_physical_device { 69 struct vk_physical_device vk; 70 71 struct wsi_device wsi_device; 72 const struct vk_sync_type* sync_types[2]; 73 struct gfxstream_vk_instance* instance; 74 VkPhysicalDevice internal_object; 75 }; 76 77 struct gfxstream_vk_device { 78 struct vk_device vk; 79 80 struct vk_device_dispatch_table cmd_dispatch; 81 struct gfxstream_vk_physical_device* physical_device; 82 VkDevice internal_object; 83 }; 84 85 struct gfxstream_vk_queue { 86 struct vk_queue vk; 87 struct gfxstream_vk_device* device; 88 VkQueue internal_object; 89 }; 90 91 struct gfxstream_vk_buffer { 92 struct vk_buffer vk; 93 VkBuffer internal_object; 94 }; 95 96 struct gfxstream_vk_command_pool { 97 struct vk_command_pool vk; 98 VkCommandPool internal_object; 99 }; 100 101 struct gfxstream_vk_command_buffer { 102 struct vk_command_buffer vk; 103 VkCommandBuffer internal_object; 104 }; 105 106 struct gfxstream_vk_fence { 107 struct vk_fence vk; 108 VkFence internal_object; 109 }; 110 111 struct gfxstream_vk_semaphore { 112 struct vk_semaphore vk; 113 VkSemaphore internal_object; 114 }; 115 116 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_command_buffer, vk.base, VkCommandBuffer, 117 VK_OBJECT_TYPE_COMMAND_BUFFER) 118 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE) 119 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE) 120 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_physical_device, vk.base, VkPhysicalDevice, 121 VK_OBJECT_TYPE_PHYSICAL_DEVICE) 122 VK_DEFINE_HANDLE_CASTS(gfxstream_vk_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE) 123 124 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_command_pool, vk.base, VkCommandPool, 125 VK_OBJECT_TYPE_COMMAND_POOL) 126 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_buffer, vk.base, VkBuffer, VK_OBJECT_TYPE_BUFFER) 127 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_fence, vk.base, VkFence, VK_OBJECT_TYPE_FENCE) 128 VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_semaphore, vk.base, VkSemaphore, 129 VK_OBJECT_TYPE_SEMAPHORE) 130 131 VkResult gfxstream_vk_wsi_init(struct gfxstream_vk_physical_device* physical_device); 132 133 void gfxstream_vk_wsi_finish(struct gfxstream_vk_physical_device* physical_device); 134 135 std::vector<VkSemaphore> transformVkSemaphoreList(const VkSemaphore* pSemaphores, 136 uint32_t semaphoreCount); 137 138 std::vector<VkFence> transformVkFenceList(const VkFence* pFences, uint32_t fenceCount); 139 140 std::vector<VkSemaphoreSubmitInfo> transformVkSemaphoreSubmitInfoList( 141 const VkSemaphoreSubmitInfo* pSemaphoreSubmitInfos, uint32_t semaphoreSubmitInfoCount); 142 143 #endif /* GFXSTREAM_VK_PRIVATE_H */ 144