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 "vk_object.h"
44 #include "libresoc_entrypoints.h"
45 #include "libresoc_extensions.h"
47 struct libresoc_instance
;
49 struct libresoc_device
{
50 VK_LOADER_DATA _loader_data
;
52 VkAllocationCallbacks alloc
;
54 struct libresoc_instance
*instance
;
56 struct libresoc_device_extension_table enabled_extensions
;
57 struct libresoc_device_dispatch_table dispatch
;
63 struct libresoc_physical_device
{
64 VK_LOADER_DATA _loader_data
;
66 struct libresoc_instance
*instance
;
68 struct libresoc_device_extension_table supported_extensions
;
69 struct libresoc_physical_device_dispatch_table dispatch
;
74 struct libresoc_app_info
{
77 const char *engine_name
;
78 uint32_t engine_version
;
82 struct libresoc_instance
{
83 struct vk_object_base base
;
84 VK_LOADER_DATA _loader_data
;
86 VkAllocationCallbacks alloc
;
88 struct libresoc_app_info app_info
;
90 struct libresoc_instance_extension_table enabled_extensions
;
91 struct libresoc_instance_dispatch_table dispatch
;
92 struct libresoc_device_dispatch_table device_dispatch
;
94 int physical_device_count
;
95 struct libresoc_physical_device physical_device
;
97 struct vk_debug_report_instance debug_report_callbacks
;
100 struct libresoc_queue
{
101 VK_LOADER_DATA _loader_data
;
103 struct libresoc_device
*device
;
105 VkDeviceQueueCreateFlags flags
;
110 struct libresoc_cmd_buffer
{
111 VK_LOADER_DATA _loader_data
;
113 struct libresoc_device
*device
;
118 uint32_t libresoc_physical_device_api_version(struct libresoc_physical_device
*dev
);
120 int libresoc_get_instance_entrypoint_index(const char *name
);
121 int libresoc_get_device_entrypoint_index(const char *name
);
122 int libresoc_get_physical_device_entrypoint_index(const char *name
);
124 const char *libresoc_get_instance_entry_name(int index
);
125 const char *libresoc_get_physical_device_entry_name(int index
);
126 const char *libresoc_get_device_entry_name(int index
);
129 libresoc_instance_entrypoint_is_enabled(int index
, uint32_t core_version
,
130 const struct libresoc_instance_extension_table
*instance
);
132 libresoc_physical_device_entrypoint_is_enabled(int index
, uint32_t core_version
,
133 const struct libresoc_instance_extension_table
*instance
);
135 libresoc_device_entrypoint_is_enabled(int index
, uint32_t core_version
,
136 const struct libresoc_instance_extension_table
*instance
,
137 const struct libresoc_device_extension_table
*device
);
139 void *libresoc_lookup_entrypoint(const char *name
);
141 #define libresoc_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
143 VkResult
__vk_errorf(struct libresoc_instance
*instance
, VkResult error
,
144 const char *file
, int line
,
145 const char *format
, ...);
147 #define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL);
148 #define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__);
150 void libresoc_loge(const char *format
, ...) libresoc_printflike(1, 2);
151 void libresoc_loge_v(const char *format
, va_list va
);
153 #define LIBRESOC_DEFINE_HANDLE_CASTS(__libresoc_type, __VkType) \
155 static inline struct __libresoc_type * \
156 __libresoc_type ## _from_handle(__VkType _handle) \
158 return (struct __libresoc_type *) _handle; \
161 static inline __VkType \
162 __libresoc_type ## _to_handle(struct __libresoc_type *_obj) \
164 return (__VkType) _obj; \
167 #define LIBRESOC_FROM_HANDLE(__libresoc_type, __name, __handle) \
168 struct __libresoc_type *__name = __libresoc_type ## _from_handle(__handle)
170 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_cmd_buffer
, VkCommandBuffer
)
171 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_device
, VkDevice
)
172 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_instance
, VkInstance
)
173 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_physical_device
, VkPhysicalDevice
)
174 LIBRESOC_DEFINE_HANDLE_CASTS(libresoc_queue
, VkQueue
)
177 #endif /* LIBRESOC_PRIVATE_H */