xref: /aosp_15_r20/frameworks/native/vulkan/libvulkan/driver.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright 2016 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker  *
4*38e8c45fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker  *
8*38e8c45fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker  *
10*38e8c45fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker  * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker  */
16*38e8c45fSAndroid Build Coastguard Worker 
17*38e8c45fSAndroid Build Coastguard Worker #ifndef LIBVULKAN_DRIVER_H
18*38e8c45fSAndroid Build Coastguard Worker #define LIBVULKAN_DRIVER_H 1
19*38e8c45fSAndroid Build Coastguard Worker 
20*38e8c45fSAndroid Build Coastguard Worker #include <inttypes.h>
21*38e8c45fSAndroid Build Coastguard Worker 
22*38e8c45fSAndroid Build Coastguard Worker #include <bitset>
23*38e8c45fSAndroid Build Coastguard Worker #include <type_traits>
24*38e8c45fSAndroid Build Coastguard Worker 
25*38e8c45fSAndroid Build Coastguard Worker #include <log/log.h>
26*38e8c45fSAndroid Build Coastguard Worker 
27*38e8c45fSAndroid Build Coastguard Worker #include <vulkan/vulkan.h>
28*38e8c45fSAndroid Build Coastguard Worker #include <hardware/hwvulkan.h>
29*38e8c45fSAndroid Build Coastguard Worker 
30*38e8c45fSAndroid Build Coastguard Worker #include "api_gen.h"
31*38e8c45fSAndroid Build Coastguard Worker #include "driver_gen.h"
32*38e8c45fSAndroid Build Coastguard Worker #include "debug_report.h"
33*38e8c45fSAndroid Build Coastguard Worker #include "swapchain.h"
34*38e8c45fSAndroid Build Coastguard Worker 
35*38e8c45fSAndroid Build Coastguard Worker namespace vulkan {
36*38e8c45fSAndroid Build Coastguard Worker 
37*38e8c45fSAndroid Build Coastguard Worker // This is here so that we can embed api::{Instance,Device}Data in
38*38e8c45fSAndroid Build Coastguard Worker // driver::{Instance,Device}Data to avoid pointer chasing.  They are
39*38e8c45fSAndroid Build Coastguard Worker // considered opaque to the driver layer.
40*38e8c45fSAndroid Build Coastguard Worker namespace api {
41*38e8c45fSAndroid Build Coastguard Worker 
42*38e8c45fSAndroid Build Coastguard Worker struct InstanceData {
43*38e8c45fSAndroid Build Coastguard Worker     InstanceDispatchTable dispatch;
44*38e8c45fSAndroid Build Coastguard Worker 
45*38e8c45fSAndroid Build Coastguard Worker     // LayerChain::ActiveLayer array
46*38e8c45fSAndroid Build Coastguard Worker     void* layers;
47*38e8c45fSAndroid Build Coastguard Worker     uint32_t layer_count;
48*38e8c45fSAndroid Build Coastguard Worker 
49*38e8c45fSAndroid Build Coastguard Worker     // debug.vulkan.enable_callback
50*38e8c45fSAndroid Build Coastguard Worker     PFN_vkDestroyDebugReportCallbackEXT destroy_debug_callback;
51*38e8c45fSAndroid Build Coastguard Worker     VkDebugReportCallbackEXT debug_callback;
52*38e8c45fSAndroid Build Coastguard Worker };
53*38e8c45fSAndroid Build Coastguard Worker 
54*38e8c45fSAndroid Build Coastguard Worker struct DeviceData {
55*38e8c45fSAndroid Build Coastguard Worker     DeviceDispatchTable dispatch;
56*38e8c45fSAndroid Build Coastguard Worker };
57*38e8c45fSAndroid Build Coastguard Worker 
58*38e8c45fSAndroid Build Coastguard Worker }  // namespace api
59*38e8c45fSAndroid Build Coastguard Worker 
60*38e8c45fSAndroid Build Coastguard Worker namespace driver {
61*38e8c45fSAndroid Build Coastguard Worker 
62*38e8c45fSAndroid Build Coastguard Worker VK_DEFINE_HANDLE(InstanceDispatchable)
63*38e8c45fSAndroid Build Coastguard Worker VK_DEFINE_HANDLE(DeviceDispatchable)
64*38e8c45fSAndroid Build Coastguard Worker 
65*38e8c45fSAndroid Build Coastguard Worker struct InstanceData {
InstanceDataInstanceData66*38e8c45fSAndroid Build Coastguard Worker     explicit InstanceData(const VkAllocationCallbacks& alloc)
67*38e8c45fSAndroid Build Coastguard Worker         : opaque_api_data(),
68*38e8c45fSAndroid Build Coastguard Worker           allocator(alloc),
69*38e8c45fSAndroid Build Coastguard Worker           driver(),
70*38e8c45fSAndroid Build Coastguard Worker           get_device_proc_addr(nullptr) {}
71*38e8c45fSAndroid Build Coastguard Worker 
72*38e8c45fSAndroid Build Coastguard Worker     api::InstanceData opaque_api_data;
73*38e8c45fSAndroid Build Coastguard Worker 
74*38e8c45fSAndroid Build Coastguard Worker     const VkAllocationCallbacks allocator;
75*38e8c45fSAndroid Build Coastguard Worker 
76*38e8c45fSAndroid Build Coastguard Worker     std::bitset<ProcHook::EXTENSION_COUNT> hook_extensions;
77*38e8c45fSAndroid Build Coastguard Worker 
78*38e8c45fSAndroid Build Coastguard Worker     InstanceDriverTable driver;
79*38e8c45fSAndroid Build Coastguard Worker     PFN_vkGetDeviceProcAddr get_device_proc_addr;
80*38e8c45fSAndroid Build Coastguard Worker 
81*38e8c45fSAndroid Build Coastguard Worker     DebugReportCallbackList debug_report_callbacks;
82*38e8c45fSAndroid Build Coastguard Worker };
83*38e8c45fSAndroid Build Coastguard Worker 
84*38e8c45fSAndroid Build Coastguard Worker struct DeviceData {
DeviceDataDeviceData85*38e8c45fSAndroid Build Coastguard Worker     DeviceData(const VkAllocationCallbacks& alloc,
86*38e8c45fSAndroid Build Coastguard Worker                const DebugReportCallbackList& debug_report_callbacks_)
87*38e8c45fSAndroid Build Coastguard Worker         : opaque_api_data(),
88*38e8c45fSAndroid Build Coastguard Worker           allocator(alloc),
89*38e8c45fSAndroid Build Coastguard Worker           debug_report_callbacks(debug_report_callbacks_),
90*38e8c45fSAndroid Build Coastguard Worker           driver() {}
91*38e8c45fSAndroid Build Coastguard Worker 
92*38e8c45fSAndroid Build Coastguard Worker     api::DeviceData opaque_api_data;
93*38e8c45fSAndroid Build Coastguard Worker 
94*38e8c45fSAndroid Build Coastguard Worker     const VkAllocationCallbacks allocator;
95*38e8c45fSAndroid Build Coastguard Worker     const DebugReportCallbackList& debug_report_callbacks;
96*38e8c45fSAndroid Build Coastguard Worker 
97*38e8c45fSAndroid Build Coastguard Worker     std::bitset<ProcHook::EXTENSION_COUNT> hook_extensions;
98*38e8c45fSAndroid Build Coastguard Worker 
99*38e8c45fSAndroid Build Coastguard Worker     VkDevice driver_device;
100*38e8c45fSAndroid Build Coastguard Worker     DeviceDriverTable driver;
101*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice driver_physical_device;
102*38e8c45fSAndroid Build Coastguard Worker };
103*38e8c45fSAndroid Build Coastguard Worker 
104*38e8c45fSAndroid Build Coastguard Worker bool OpenHAL();
105*38e8c45fSAndroid Build Coastguard Worker const VkAllocationCallbacks& GetDefaultAllocator();
106*38e8c45fSAndroid Build Coastguard Worker 
107*38e8c45fSAndroid Build Coastguard Worker void QueryPresentationProperties(
108*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
109*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties);
110*38e8c45fSAndroid Build Coastguard Worker 
111*38e8c45fSAndroid Build Coastguard Worker bool GetAndroidNativeBufferSpecVersion9Support(VkPhysicalDevice physicalDevice);
112*38e8c45fSAndroid Build Coastguard Worker 
113*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance,
114*38e8c45fSAndroid Build Coastguard Worker                                                   const char* pName);
115*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device,
116*38e8c45fSAndroid Build Coastguard Worker                                                 const char* pName);
117*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult
118*38e8c45fSAndroid Build Coastguard Worker EnumerateInstanceExtensionProperties(const char* pLayerName,
119*38e8c45fSAndroid Build Coastguard Worker                                      uint32_t* pPropertyCount,
120*38e8c45fSAndroid Build Coastguard Worker                                      VkExtensionProperties* pProperties);
121*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult
122*38e8c45fSAndroid Build Coastguard Worker EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
123*38e8c45fSAndroid Build Coastguard Worker                                    const char* pLayerName,
124*38e8c45fSAndroid Build Coastguard Worker                                    uint32_t* pPropertyCount,
125*38e8c45fSAndroid Build Coastguard Worker                                    VkExtensionProperties* pProperties);
126*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo,
127*38e8c45fSAndroid Build Coastguard Worker                                    const VkAllocationCallbacks* pAllocator,
128*38e8c45fSAndroid Build Coastguard Worker                                    VkInstance* pInstance);
129*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void DestroyInstance(VkInstance instance,
130*38e8c45fSAndroid Build Coastguard Worker                                 const VkAllocationCallbacks* pAllocator);
131*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult CreateDevice(VkPhysicalDevice physicalDevice,
132*38e8c45fSAndroid Build Coastguard Worker                                  const VkDeviceCreateInfo* pCreateInfo,
133*38e8c45fSAndroid Build Coastguard Worker                                  const VkAllocationCallbacks* pAllocator,
134*38e8c45fSAndroid Build Coastguard Worker                                  VkDevice* pDevice);
135*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void DestroyDevice(VkDevice device,
136*38e8c45fSAndroid Build Coastguard Worker                               const VkAllocationCallbacks* pAllocator);
137*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult
138*38e8c45fSAndroid Build Coastguard Worker EnumeratePhysicalDevices(VkInstance instance,
139*38e8c45fSAndroid Build Coastguard Worker                          uint32_t* pPhysicalDeviceCount,
140*38e8c45fSAndroid Build Coastguard Worker                          VkPhysicalDevice* pPhysicalDevices);
141*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult EnumeratePhysicalDeviceGroups(
142*38e8c45fSAndroid Build Coastguard Worker     VkInstance instance,
143*38e8c45fSAndroid Build Coastguard Worker     uint32_t* pPhysicalDeviceGroupCount,
144*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties);
145*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetDeviceQueue(VkDevice device,
146*38e8c45fSAndroid Build Coastguard Worker                                uint32_t queueFamilyIndex,
147*38e8c45fSAndroid Build Coastguard Worker                                uint32_t queueIndex,
148*38e8c45fSAndroid Build Coastguard Worker                                VkQueue* pQueue);
149*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetDeviceQueue2(VkDevice device,
150*38e8c45fSAndroid Build Coastguard Worker                                 const VkDeviceQueueInfo2* pQueueInfo,
151*38e8c45fSAndroid Build Coastguard Worker                                 VkQueue* pQueue);
152*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult
153*38e8c45fSAndroid Build Coastguard Worker AllocateCommandBuffers(VkDevice device,
154*38e8c45fSAndroid Build Coastguard Worker                        const VkCommandBufferAllocateInfo* pAllocateInfo,
155*38e8c45fSAndroid Build Coastguard Worker                        VkCommandBuffer* pCommandBuffers);
156*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult QueueSubmit(VkQueue queue,
157*38e8c45fSAndroid Build Coastguard Worker                                 uint32_t submitCount,
158*38e8c45fSAndroid Build Coastguard Worker                                 const VkSubmitInfo* pSubmits,
159*38e8c45fSAndroid Build Coastguard Worker                                 VkFence fence);
160*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceFeatures2(
161*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
162*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDeviceFeatures2* pFeatures);
163*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceProperties2(
164*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
165*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDeviceProperties2* pProperties);
166*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceFormatProperties2(
167*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
168*38e8c45fSAndroid Build Coastguard Worker     VkFormat format,
169*38e8c45fSAndroid Build Coastguard Worker     VkFormatProperties2* pFormatProperties);
170*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR VkResult GetPhysicalDeviceImageFormatProperties2(
171*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
172*38e8c45fSAndroid Build Coastguard Worker     const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo,
173*38e8c45fSAndroid Build Coastguard Worker     VkImageFormatProperties2* pImageFormatProperties);
174*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceQueueFamilyProperties2(
175*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
176*38e8c45fSAndroid Build Coastguard Worker     uint32_t* pQueueFamilyPropertyCount,
177*38e8c45fSAndroid Build Coastguard Worker     VkQueueFamilyProperties2* pQueueFamilyProperties);
178*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceMemoryProperties2(
179*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
180*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDeviceMemoryProperties2* pMemoryProperties);
181*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceSparseImageFormatProperties2(
182*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
183*38e8c45fSAndroid Build Coastguard Worker     const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo,
184*38e8c45fSAndroid Build Coastguard Worker     uint32_t* pPropertyCount,
185*38e8c45fSAndroid Build Coastguard Worker     VkSparseImageFormatProperties2* pProperties);
186*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceExternalBufferProperties(
187*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
188*38e8c45fSAndroid Build Coastguard Worker     const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
189*38e8c45fSAndroid Build Coastguard Worker     VkExternalBufferProperties* pExternalBufferProperties);
190*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceExternalSemaphoreProperties(
191*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
192*38e8c45fSAndroid Build Coastguard Worker     const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
193*38e8c45fSAndroid Build Coastguard Worker     VkExternalSemaphoreProperties* pExternalSemaphoreProperties);
194*38e8c45fSAndroid Build Coastguard Worker VKAPI_ATTR void GetPhysicalDeviceExternalFenceProperties(
195*38e8c45fSAndroid Build Coastguard Worker     VkPhysicalDevice physicalDevice,
196*38e8c45fSAndroid Build Coastguard Worker     const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo,
197*38e8c45fSAndroid Build Coastguard Worker     VkExternalFenceProperties* pExternalFenceProperties);
198*38e8c45fSAndroid Build Coastguard Worker 
199*38e8c45fSAndroid Build Coastguard Worker template <typename DispatchableType>
StaticAssertDispatchable(DispatchableType)200*38e8c45fSAndroid Build Coastguard Worker void StaticAssertDispatchable(DispatchableType) {
201*38e8c45fSAndroid Build Coastguard Worker     static_assert(
202*38e8c45fSAndroid Build Coastguard Worker         std::is_same<DispatchableType, VkInstance>::value ||
203*38e8c45fSAndroid Build Coastguard Worker             std::is_same<DispatchableType, VkPhysicalDevice>::value ||
204*38e8c45fSAndroid Build Coastguard Worker             std::is_same<DispatchableType, VkDevice>::value ||
205*38e8c45fSAndroid Build Coastguard Worker             std::is_same<DispatchableType, InstanceDispatchable>::value ||
206*38e8c45fSAndroid Build Coastguard Worker             std::is_same<DispatchableType, VkQueue>::value ||
207*38e8c45fSAndroid Build Coastguard Worker             std::is_same<DispatchableType, VkCommandBuffer>::value ||
208*38e8c45fSAndroid Build Coastguard Worker             std::is_same<DispatchableType, DeviceDispatchable>::value,
209*38e8c45fSAndroid Build Coastguard Worker         "unrecognized dispatchable type");
210*38e8c45fSAndroid Build Coastguard Worker }
211*38e8c45fSAndroid Build Coastguard Worker 
212*38e8c45fSAndroid Build Coastguard Worker template <typename DispatchableType>
SetDataInternal(DispatchableType dispatchable,const void * data)213*38e8c45fSAndroid Build Coastguard Worker bool SetDataInternal(DispatchableType dispatchable, const void* data) {
214*38e8c45fSAndroid Build Coastguard Worker     StaticAssertDispatchable(dispatchable);
215*38e8c45fSAndroid Build Coastguard Worker 
216*38e8c45fSAndroid Build Coastguard Worker     hwvulkan_dispatch_t* dispatch =
217*38e8c45fSAndroid Build Coastguard Worker         reinterpret_cast<hwvulkan_dispatch_t*>(dispatchable);
218*38e8c45fSAndroid Build Coastguard Worker     // must be magic or already set
219*38e8c45fSAndroid Build Coastguard Worker     if (dispatch->magic != HWVULKAN_DISPATCH_MAGIC && dispatch->vtbl != data) {
220*38e8c45fSAndroid Build Coastguard Worker         ALOGE("invalid dispatchable object magic 0x%" PRIxPTR, dispatch->magic);
221*38e8c45fSAndroid Build Coastguard Worker         return false;
222*38e8c45fSAndroid Build Coastguard Worker     }
223*38e8c45fSAndroid Build Coastguard Worker 
224*38e8c45fSAndroid Build Coastguard Worker     dispatch->vtbl = data;
225*38e8c45fSAndroid Build Coastguard Worker 
226*38e8c45fSAndroid Build Coastguard Worker     return true;
227*38e8c45fSAndroid Build Coastguard Worker }
228*38e8c45fSAndroid Build Coastguard Worker 
229*38e8c45fSAndroid Build Coastguard Worker template <typename DispatchableType>
GetDataInternal(DispatchableType dispatchable)230*38e8c45fSAndroid Build Coastguard Worker void* GetDataInternal(DispatchableType dispatchable) {
231*38e8c45fSAndroid Build Coastguard Worker     StaticAssertDispatchable(dispatchable);
232*38e8c45fSAndroid Build Coastguard Worker 
233*38e8c45fSAndroid Build Coastguard Worker     const hwvulkan_dispatch_t* dispatch =
234*38e8c45fSAndroid Build Coastguard Worker         reinterpret_cast<const hwvulkan_dispatch_t*>(dispatchable);
235*38e8c45fSAndroid Build Coastguard Worker 
236*38e8c45fSAndroid Build Coastguard Worker     return const_cast<void*>(dispatch->vtbl);
237*38e8c45fSAndroid Build Coastguard Worker }
238*38e8c45fSAndroid Build Coastguard Worker 
SetData(VkInstance instance,const InstanceData & data)239*38e8c45fSAndroid Build Coastguard Worker inline bool SetData(VkInstance instance, const InstanceData& data) {
240*38e8c45fSAndroid Build Coastguard Worker     return SetDataInternal(instance, &data);
241*38e8c45fSAndroid Build Coastguard Worker }
242*38e8c45fSAndroid Build Coastguard Worker 
SetData(VkPhysicalDevice physical_dev,const InstanceData & data)243*38e8c45fSAndroid Build Coastguard Worker inline bool SetData(VkPhysicalDevice physical_dev, const InstanceData& data) {
244*38e8c45fSAndroid Build Coastguard Worker     return SetDataInternal(physical_dev, &data);
245*38e8c45fSAndroid Build Coastguard Worker }
246*38e8c45fSAndroid Build Coastguard Worker 
SetData(InstanceDispatchable dispatchable,const InstanceData & data)247*38e8c45fSAndroid Build Coastguard Worker inline bool SetData(InstanceDispatchable dispatchable,
248*38e8c45fSAndroid Build Coastguard Worker                     const InstanceData& data) {
249*38e8c45fSAndroid Build Coastguard Worker     return SetDataInternal(dispatchable, &data);
250*38e8c45fSAndroid Build Coastguard Worker }
251*38e8c45fSAndroid Build Coastguard Worker 
SetData(VkDevice dev,const DeviceData & data)252*38e8c45fSAndroid Build Coastguard Worker inline bool SetData(VkDevice dev, const DeviceData& data) {
253*38e8c45fSAndroid Build Coastguard Worker     return SetDataInternal(dev, &data);
254*38e8c45fSAndroid Build Coastguard Worker }
255*38e8c45fSAndroid Build Coastguard Worker 
SetData(VkQueue queue,const DeviceData & data)256*38e8c45fSAndroid Build Coastguard Worker inline bool SetData(VkQueue queue, const DeviceData& data) {
257*38e8c45fSAndroid Build Coastguard Worker     return SetDataInternal(queue, &data);
258*38e8c45fSAndroid Build Coastguard Worker }
259*38e8c45fSAndroid Build Coastguard Worker 
SetData(VkCommandBuffer cmd,const DeviceData & data)260*38e8c45fSAndroid Build Coastguard Worker inline bool SetData(VkCommandBuffer cmd, const DeviceData& data) {
261*38e8c45fSAndroid Build Coastguard Worker     return SetDataInternal(cmd, &data);
262*38e8c45fSAndroid Build Coastguard Worker }
263*38e8c45fSAndroid Build Coastguard Worker 
SetData(DeviceDispatchable dispatchable,const DeviceData & data)264*38e8c45fSAndroid Build Coastguard Worker inline bool SetData(DeviceDispatchable dispatchable, const DeviceData& data) {
265*38e8c45fSAndroid Build Coastguard Worker     return SetDataInternal(dispatchable, &data);
266*38e8c45fSAndroid Build Coastguard Worker }
267*38e8c45fSAndroid Build Coastguard Worker 
GetData(VkInstance instance)268*38e8c45fSAndroid Build Coastguard Worker inline InstanceData& GetData(VkInstance instance) {
269*38e8c45fSAndroid Build Coastguard Worker     return *reinterpret_cast<InstanceData*>(GetDataInternal(instance));
270*38e8c45fSAndroid Build Coastguard Worker }
271*38e8c45fSAndroid Build Coastguard Worker 
GetData(VkPhysicalDevice physical_dev)272*38e8c45fSAndroid Build Coastguard Worker inline InstanceData& GetData(VkPhysicalDevice physical_dev) {
273*38e8c45fSAndroid Build Coastguard Worker     return *reinterpret_cast<InstanceData*>(GetDataInternal(physical_dev));
274*38e8c45fSAndroid Build Coastguard Worker }
275*38e8c45fSAndroid Build Coastguard Worker 
GetData(InstanceDispatchable dispatchable)276*38e8c45fSAndroid Build Coastguard Worker inline InstanceData& GetData(InstanceDispatchable dispatchable) {
277*38e8c45fSAndroid Build Coastguard Worker     return *reinterpret_cast<InstanceData*>(GetDataInternal(dispatchable));
278*38e8c45fSAndroid Build Coastguard Worker }
279*38e8c45fSAndroid Build Coastguard Worker 
GetData(VkDevice dev)280*38e8c45fSAndroid Build Coastguard Worker inline DeviceData& GetData(VkDevice dev) {
281*38e8c45fSAndroid Build Coastguard Worker     return *reinterpret_cast<DeviceData*>(GetDataInternal(dev));
282*38e8c45fSAndroid Build Coastguard Worker }
283*38e8c45fSAndroid Build Coastguard Worker 
GetData(VkQueue queue)284*38e8c45fSAndroid Build Coastguard Worker inline DeviceData& GetData(VkQueue queue) {
285*38e8c45fSAndroid Build Coastguard Worker     return *reinterpret_cast<DeviceData*>(GetDataInternal(queue));
286*38e8c45fSAndroid Build Coastguard Worker }
287*38e8c45fSAndroid Build Coastguard Worker 
GetData(VkCommandBuffer cmd)288*38e8c45fSAndroid Build Coastguard Worker inline DeviceData& GetData(VkCommandBuffer cmd) {
289*38e8c45fSAndroid Build Coastguard Worker     return *reinterpret_cast<DeviceData*>(GetDataInternal(cmd));
290*38e8c45fSAndroid Build Coastguard Worker }
291*38e8c45fSAndroid Build Coastguard Worker 
GetData(DeviceDispatchable dispatchable)292*38e8c45fSAndroid Build Coastguard Worker inline DeviceData& GetData(DeviceDispatchable dispatchable) {
293*38e8c45fSAndroid Build Coastguard Worker     return *reinterpret_cast<DeviceData*>(GetDataInternal(dispatchable));
294*38e8c45fSAndroid Build Coastguard Worker }
295*38e8c45fSAndroid Build Coastguard Worker 
296*38e8c45fSAndroid Build Coastguard Worker template <typename DispatchableType>
Logger(DispatchableType dispatchable)297*38e8c45fSAndroid Build Coastguard Worker const DebugReportLogger Logger(DispatchableType dispatchable) {
298*38e8c45fSAndroid Build Coastguard Worker     return DebugReportLogger(GetData(dispatchable).debug_report_callbacks);
299*38e8c45fSAndroid Build Coastguard Worker }
300*38e8c45fSAndroid Build Coastguard Worker 
301*38e8c45fSAndroid Build Coastguard Worker }  // namespace driver
302*38e8c45fSAndroid Build Coastguard Worker }  // namespace vulkan
303*38e8c45fSAndroid Build Coastguard Worker 
304*38e8c45fSAndroid Build Coastguard Worker #endif  // LIBVULKAN_DRIVER_H
305