2 * Copyright © 2019 Raspberry Pi
4 * based in part on anv driver which is:
5 * Copyright © 2015 Intel Corporation
7 * based in part on radv driver which is:
8 * Copyright © 2016 Red Hat.
9 * Copyright © 2016 Bas Nieuwenhuizen
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice (including the next
19 * paragraph) shall be included in all copies or substantial portions of the
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #ifndef LIBRESOC_PRIVATE_H
31 #define LIBRESOC_PRIVATE_H
35 #include <vulkan/vulkan.h>
36 #include <vulkan/vk_icd.h>
38 //#include "common/libresoc_device_info.h"
40 #include "vk_debug_report.h"
41 #include "util/xmlconfig.h"
43 #include "libresoc_entrypoints.h"
44 #include "libresoc_extensions.h"
46 struct libresoc_instance
;
48 struct libresoc_device
{
49 VK_LOADER_DATA _loader_data
;
51 VkAllocationCallbacks alloc
;
53 struct libresoc_instance
*instance
;
55 struct libresoc_device_extension_table enabled_extensions
;
56 struct libresoc_device_dispatch_table dispatch
;
62 struct libresoc_physical_device
{
63 VK_LOADER_DATA _loader_data
;
65 struct libresoc_instance
*instance
;
67 struct libresoc_device_extension_table supported_extensions
;
68 struct libresoc_physical_device_dispatch_table dispatch
;
73 struct libresoc_app_info
{
76 const char *engine_name
;
77 uint32_t engine_version
;
81 struct libresoc_instance
{
82 VK_LOADER_DATA _loader_data
;
84 VkAllocationCallbacks alloc
;
86 struct libresoc_app_info app_info
;
88 struct libresoc_instance_extension_table enabled_extensions
;
89 struct libresoc_instance_dispatch_table dispatch
;
90 struct libresoc_device_dispatch_table device_dispatch
;
92 int physicalDeviceCount
;
93 struct libresoc_physical_device physicalDevice
;
95 struct vk_debug_report_instance debug_report_callbacks
;
98 struct libresoc_queue
{
99 VK_LOADER_DATA _loader_data
;
101 struct libresoc_device
*device
;
103 VkDeviceQueueCreateFlags flags
;
108 struct libresoc_cmd_buffer
{
109 VK_LOADER_DATA _loader_data
;
111 struct libresoc_device
*device
;
116 uint32_t libresoc_physical_device_api_version(struct libresoc_physical_device
*dev
);
118 int libresoc_get_instance_entrypoint_index(const char *name
);
119 int libresoc_get_device_entrypoint_index(const char *name
);
120 int libresoc_get_physical_device_entrypoint_index(const char *name
);
122 const char *libresoc_get_instance_entry_name(int index
);
123 const char *libresoc_get_physical_device_entry_name(int index
);
124 const char *libresoc_get_device_entry_name(int index
);
127 libresoc_instance_entrypoint_is_enabled(int index
, uint32_t core_version
,
128 const struct libresoc_instance_extension_table
*instance
);
130 libresoc_physical_device_entrypoint_is_enabled(int index
, uint32_t core_version
,
131 const struct libresoc_instance_extension_table
*instance
);
133 libresoc_device_entrypoint_is_enabled(int index
, uint32_t core_version
,
134 const struct libresoc_instance_extension_table
*instance
,
135 const struct libresoc_device_extension_table
*device
);
137 void *libresoc_lookup_entrypoint(const char *name
);
139 #define libresoc_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
141 VkResult
__vk_errorf(struct libresoc_instance
*instance
, VkResult error
,
142 const char *file
, int line
,
143 const char *format
, ...);
145 #define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL);
146 #define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__);
148 void libresoc_loge(const char *format
, ...) libresoc_printflike(1, 2);
149 void libresoc_loge_v(const char *format
, va_list va
);
151 #define LIBRESOC_DEFINE_HANDLE_CASTS(__libresoc_type, __VkType) \
153 static inline struct __libresoc_type * \
154 __libresoc_type ## _from_handle(__VkType _handle) \
156 return (struct __libresoc_type *) _handle; \
159 static inline __VkType \
160 __libresoc_type ## _to_handle(struct __libresoc_type *_obj) \
162 return (__VkType) _obj; \
165 #define LIBRESOC_FROM_HANDLE(__libresoc_type, __name, __handle) \
166 struct __libresoc_type *__name = __libresoc_type ## _from_handle(__handle)
168 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_cmd_buffer
, VkCommandBuffer
)
169 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_device
, VkDevice
)
170 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_instance
, VkInstance
)
171 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_physical_device
, VkPhysicalDevice
)
172 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_queue
, VkQueue
)
175 #endif /* LIBRESOC_PRIVATE_H */