| 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 |
bool init_failed; |
| 66 |
VkInstance internal_object; |
| 67 |
}; |
| 68 |
|
| 69 |
struct gfxstream_vk_physical_device { |
| 70 |
struct vk_physical_device vk; |
| 71 |
|
| 72 |
struct wsi_device wsi_device; |
| 73 |
const struct vk_sync_type* sync_types[2]; |
| 74 |
struct gfxstream_vk_instance* instance; |
| 75 |
bool doImageDrmFormatModifierEmulation; |
| 76 |
VkPhysicalDevice internal_object; |
| 77 |
}; |
| 78 |
|
| 79 |
struct gfxstream_vk_device { |
| 80 |
struct vk_device vk; |
| 81 |
|
| 82 |
struct vk_device_dispatch_table cmd_dispatch; |
| 83 |
struct gfxstream_vk_physical_device* physical_device; |
| 84 |
|
| 85 |
/* unique queue family indices in which to create the device queues */ |
| 86 |
uint32_t* queue_families; |
| 87 |
uint32_t queue_family_count; |
| 88 |
|
| 89 |
struct gfxstream_vk_queue* queues; |
| 90 |
uint32_t queue_count; |
| 91 |
|
| 92 |
VkDevice internal_object; |
| 93 |
}; |
| 94 |
|
| 95 |
struct gfxstream_vk_queue { |
| 96 |
struct vk_queue vk; |
| 97 |
struct gfxstream_vk_device* device; |
| 98 |
VkQueue internal_object; |
| 99 |
}; |
| 100 |
|
| 101 |
struct gfxstream_vk_buffer { |
| 102 |
struct vk_buffer vk; |
| 103 |
VkBuffer internal_object; |
| 104 |
}; |
| 105 |
|
| 106 |
struct gfxstream_vk_command_pool { |
| 107 |
struct vk_command_pool vk; |
| 108 |
VkCommandPool internal_object; |
| 109 |
}; |
| 110 |
|
| 111 |
struct gfxstream_vk_command_buffer { |
| 112 |
struct vk_command_buffer vk; |
| 113 |
VkCommandBuffer internal_object; |
| 114 |
}; |
| 115 |
|
| 116 |
struct gfxstream_vk_fence { |
| 117 |
struct vk_fence vk; |
| 118 |
VkFence internal_object; |
| 119 |
}; |
| 120 |
|
| 121 |
struct gfxstream_vk_semaphore { |
| 122 |
struct vk_semaphore vk; |
| 123 |
VkSemaphore internal_object; |
| 124 |
}; |
| 125 |
|
| 126 |
VK_DEFINE_HANDLE_CASTS(gfxstream_vk_command_buffer, vk.base, VkCommandBuffer, |
| 127 |
VK_OBJECT_TYPE_COMMAND_BUFFER) |
| 128 |
VK_DEFINE_HANDLE_CASTS(gfxstream_vk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE) |
| 129 |
VK_DEFINE_HANDLE_CASTS(gfxstream_vk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE) |
| 130 |
VK_DEFINE_HANDLE_CASTS(gfxstream_vk_physical_device, vk.base, VkPhysicalDevice, |
| 131 |
VK_OBJECT_TYPE_PHYSICAL_DEVICE) |
| 132 |
VK_DEFINE_HANDLE_CASTS(gfxstream_vk_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE) |
| 133 |
|
| 134 |
VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_command_pool, vk.base, VkCommandPool, |
| 135 |
VK_OBJECT_TYPE_COMMAND_POOL) |
| 136 |
VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_buffer, vk.base, VkBuffer, VK_OBJECT_TYPE_BUFFER) |
| 137 |
VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_fence, vk.base, VkFence, VK_OBJECT_TYPE_FENCE) |
| 138 |
VK_DEFINE_NONDISP_HANDLE_CASTS(gfxstream_vk_semaphore, vk.base, VkSemaphore, |
| 139 |
VK_OBJECT_TYPE_SEMAPHORE) |
| 140 |
|
| 141 |
VkResult gfxstream_vk_wsi_init(struct gfxstream_vk_physical_device* physical_device); |
| 142 |
|
| 143 |
void gfxstream_vk_wsi_finish(struct gfxstream_vk_physical_device* physical_device); |
| 144 |
|
| 145 |
std::vector<VkSemaphore> transformVkSemaphoreList(const VkSemaphore* pSemaphores, |
| 146 |
uint32_t semaphoreCount); |
| 147 |
|
| 148 |
std::vector<VkFence> transformVkFenceList(const VkFence* pFences, uint32_t fenceCount); |
| 149 |
|
| 150 |
std::vector<VkSemaphoreSubmitInfo> transformVkSemaphoreSubmitInfoList( |
| 151 |
const VkSemaphoreSubmitInfo* pSemaphoreSubmitInfos, uint32_t semaphoreSubmitInfoCount); |
| 152 |
|
| 153 |
float linearChannelToSRGB(float cl); |
| 154 |
float srgbFormatNeedsConversionForClearColor(const VkFormat& format); |
| 155 |
|
| 156 |
#endif /* GFXSTREAM_VK_PRIVATE_H */ |