1 /*
2 * Copyright 2020 Google LLC
3 * SPDX-License-Identifier: MIT
4 */
5
6 #include "vkr_physical_device.h"
7
8 #include "venus-protocol/vn_protocol_renderer_device.h"
9 #include "venus-protocol/vn_protocol_renderer_info.h"
10
11 #include "vkr_context.h"
12 #include "vkr_device.h"
13 #include "vkr_instance.h"
14
15 void
vkr_physical_device_destroy(struct vkr_context * ctx,struct vkr_physical_device * physical_dev)16 vkr_physical_device_destroy(struct vkr_context *ctx,
17 struct vkr_physical_device *physical_dev)
18 {
19 struct vkr_device *dev, *tmp;
20 LIST_FOR_EACH_ENTRY_SAFE (dev, tmp, &physical_dev->devices, base.track_head)
21 vkr_device_destroy(ctx, dev);
22
23 free(physical_dev->extensions);
24
25 vkr_context_remove_object(ctx, &physical_dev->base);
26 }
27
28 static VkResult
vkr_instance_enumerate_physical_devices(struct vkr_instance * instance)29 vkr_instance_enumerate_physical_devices(struct vkr_instance *instance)
30 {
31 if (instance->physical_device_count)
32 return VK_SUCCESS;
33
34 uint32_t count;
35 VkResult result =
36 vkEnumeratePhysicalDevices(instance->base.handle.instance, &count, NULL);
37 if (result != VK_SUCCESS)
38 return result;
39
40 VkPhysicalDevice *handles = calloc(count, sizeof(*handles));
41 struct vkr_physical_device **physical_devs = calloc(count, sizeof(*physical_devs));
42 if (!handles || !physical_devs) {
43 free(physical_devs);
44 free(handles);
45 return VK_ERROR_OUT_OF_HOST_MEMORY;
46 }
47
48 result = vkEnumeratePhysicalDevices(instance->base.handle.instance, &count, handles);
49 if (result != VK_SUCCESS) {
50 free(physical_devs);
51 free(handles);
52 return result;
53 }
54
55 instance->physical_device_count = count;
56 instance->physical_device_handles = handles;
57 instance->physical_devices = physical_devs;
58
59 return VK_SUCCESS;
60 }
61
62 static struct vkr_physical_device *
vkr_instance_lookup_physical_device(struct vkr_instance * instance,VkPhysicalDevice handle)63 vkr_instance_lookup_physical_device(struct vkr_instance *instance,
64 VkPhysicalDevice handle)
65 {
66 for (uint32_t i = 0; i < instance->physical_device_count; i++) {
67 /* XXX this assumes VkPhysicalDevice handles are unique */
68 if (instance->physical_device_handles[i] == handle)
69 return instance->physical_devices[i];
70 }
71 return NULL;
72 }
73
74 static void
vkr_physical_device_init_memory_properties(struct vkr_physical_device * physical_dev)75 vkr_physical_device_init_memory_properties(struct vkr_physical_device *physical_dev)
76 {
77 VkPhysicalDevice handle = physical_dev->base.handle.physical_device;
78 vkGetPhysicalDeviceMemoryProperties(handle, &physical_dev->memory_properties);
79 }
80
81 static void
vkr_physical_device_init_extensions(struct vkr_physical_device * physical_dev,struct vkr_instance * instance)82 vkr_physical_device_init_extensions(struct vkr_physical_device *physical_dev,
83 struct vkr_instance *instance)
84 {
85 VkPhysicalDevice handle = physical_dev->base.handle.physical_device;
86
87 VkExtensionProperties *exts;
88 uint32_t count;
89 VkResult result = vkEnumerateDeviceExtensionProperties(handle, NULL, &count, NULL);
90 if (result != VK_SUCCESS)
91 return;
92
93 exts = malloc(sizeof(*exts) * count);
94 if (!exts)
95 return;
96
97 result = vkEnumerateDeviceExtensionProperties(handle, NULL, &count, exts);
98 if (result != VK_SUCCESS) {
99 free(exts);
100 return;
101 }
102
103 uint32_t advertised_count = 0;
104 for (uint32_t i = 0; i < count; i++) {
105 VkExtensionProperties *props = &exts[i];
106
107 if (!strcmp(props->extensionName, "VK_KHR_external_memory_fd"))
108 physical_dev->KHR_external_memory_fd = true;
109 else if (!strcmp(props->extensionName, "VK_EXT_external_memory_dma_buf"))
110 physical_dev->EXT_external_memory_dma_buf = true;
111 else if (!strcmp(props->extensionName, "VK_KHR_external_fence_fd"))
112 physical_dev->KHR_external_fence_fd = true;
113
114 const uint32_t spec_ver = vn_info_extension_spec_version(props->extensionName);
115 if (spec_ver) {
116 if (props->specVersion > spec_ver)
117 props->specVersion = spec_ver;
118 exts[advertised_count++] = exts[i];
119 }
120 }
121
122 if (physical_dev->KHR_external_fence_fd) {
123 const VkPhysicalDeviceExternalFenceInfo fence_info = {
124 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO,
125 .handleType = VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT,
126 };
127 VkExternalFenceProperties fence_props = {
128 .sType = VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES,
129 };
130 PFN_vkGetPhysicalDeviceExternalFenceProperties get_fence_props =
131 (PFN_vkGetPhysicalDeviceExternalFenceProperties)vkGetInstanceProcAddr(
132 instance->base.handle.instance, "vkGetPhysicalDeviceExternalFenceProperties");
133 get_fence_props(handle, &fence_info, &fence_props);
134
135 if (!(fence_props.externalFenceFeatures & VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT))
136 physical_dev->KHR_external_fence_fd = false;
137 }
138
139 physical_dev->extensions = exts;
140 physical_dev->extension_count = advertised_count;
141 }
142
143 static void
vkr_physical_device_init_properties(struct vkr_physical_device * physical_dev)144 vkr_physical_device_init_properties(struct vkr_physical_device *physical_dev)
145 {
146 VkPhysicalDevice handle = physical_dev->base.handle.physical_device;
147 vkGetPhysicalDeviceProperties(handle, &physical_dev->properties);
148
149 VkPhysicalDeviceProperties *props = &physical_dev->properties;
150 props->driverVersion = 0;
151
152 /* TODO lie about props->pipelineCacheUUID and patch cache header */
153 }
154
155 static void
vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context * dispatch,struct vn_command_vkEnumeratePhysicalDevices * args)156 vkr_dispatch_vkEnumeratePhysicalDevices(struct vn_dispatch_context *dispatch,
157 struct vn_command_vkEnumeratePhysicalDevices *args)
158 {
159 struct vkr_context *ctx = dispatch->data;
160
161 struct vkr_instance *instance = vkr_instance_from_handle(args->instance);
162 if (instance != ctx->instance) {
163 vkr_cs_decoder_set_fatal(&ctx->decoder);
164 return;
165 }
166
167 args->ret = vkr_instance_enumerate_physical_devices(instance);
168 if (args->ret != VK_SUCCESS)
169 return;
170
171 uint32_t count = instance->physical_device_count;
172 if (!args->pPhysicalDevices) {
173 *args->pPhysicalDeviceCount = count;
174 args->ret = VK_SUCCESS;
175 return;
176 }
177
178 if (count > *args->pPhysicalDeviceCount) {
179 count = *args->pPhysicalDeviceCount;
180 args->ret = VK_INCOMPLETE;
181 } else {
182 *args->pPhysicalDeviceCount = count;
183 args->ret = VK_SUCCESS;
184 }
185
186 uint32_t i;
187 for (i = 0; i < count; i++) {
188 struct vkr_physical_device *physical_dev = instance->physical_devices[i];
189 const vkr_object_id id = vkr_cs_handle_load_id(
190 (const void **)&args->pPhysicalDevices[i], VK_OBJECT_TYPE_PHYSICAL_DEVICE);
191
192 if (physical_dev) {
193 if (physical_dev->base.id != id) {
194 vkr_cs_decoder_set_fatal(&ctx->decoder);
195 break;
196 }
197 continue;
198 }
199
200 if (!vkr_context_validate_object_id(ctx, id))
201 break;
202
203 physical_dev =
204 vkr_object_alloc(sizeof(*physical_dev), VK_OBJECT_TYPE_PHYSICAL_DEVICE, id);
205 if (!physical_dev) {
206 args->ret = VK_ERROR_OUT_OF_HOST_MEMORY;
207 break;
208 }
209
210 physical_dev->base.handle.physical_device = instance->physical_device_handles[i];
211
212 vkr_physical_device_init_properties(physical_dev);
213 physical_dev->api_version =
214 MIN2(physical_dev->properties.apiVersion, instance->api_version);
215 vkr_physical_device_init_extensions(physical_dev, instance);
216 vkr_physical_device_init_memory_properties(physical_dev);
217
218 list_inithead(&physical_dev->devices);
219
220 instance->physical_devices[i] = physical_dev;
221
222 vkr_context_add_object(ctx, &physical_dev->base);
223 }
224 /* remove all physical devices on errors */
225 if (i < count) {
226 for (i = 0; i < instance->physical_device_count; i++) {
227 struct vkr_physical_device *physical_dev = instance->physical_devices[i];
228 if (!physical_dev)
229 break;
230 free(physical_dev->extensions);
231 vkr_context_remove_object(ctx, &physical_dev->base);
232 instance->physical_devices[i] = NULL;
233 }
234 }
235 }
236
237 static void
vkr_dispatch_vkEnumeratePhysicalDeviceGroups(struct vn_dispatch_context * dispatch,struct vn_command_vkEnumeratePhysicalDeviceGroups * args)238 vkr_dispatch_vkEnumeratePhysicalDeviceGroups(
239 struct vn_dispatch_context *dispatch,
240 struct vn_command_vkEnumeratePhysicalDeviceGroups *args)
241 {
242 struct vkr_context *ctx = dispatch->data;
243
244 struct vkr_instance *instance = vkr_instance_from_handle(args->instance);
245 if (instance != ctx->instance) {
246 vkr_cs_decoder_set_fatal(&ctx->decoder);
247 return;
248 }
249
250 args->ret = vkr_instance_enumerate_physical_devices(instance);
251 if (args->ret != VK_SUCCESS)
252 return;
253
254 VkPhysicalDeviceGroupProperties *orig_props = args->pPhysicalDeviceGroupProperties;
255 if (orig_props) {
256 args->pPhysicalDeviceGroupProperties =
257 malloc(sizeof(*orig_props) * *args->pPhysicalDeviceGroupCount);
258 if (!args->pPhysicalDeviceGroupProperties) {
259 args->ret = VK_ERROR_OUT_OF_HOST_MEMORY;
260 return;
261 }
262 }
263
264 vn_replace_vkEnumeratePhysicalDeviceGroups_args_handle(args);
265 args->ret =
266 vkEnumeratePhysicalDeviceGroups(args->instance, args->pPhysicalDeviceGroupCount,
267 args->pPhysicalDeviceGroupProperties);
268 if (args->ret != VK_SUCCESS)
269 return;
270
271 if (!orig_props)
272 return;
273
274 /* XXX this assumes vkEnumeratePhysicalDevices is called first */
275 /* replace VkPhysicalDevice handles by object ids */
276 for (uint32_t i = 0; i < *args->pPhysicalDeviceGroupCount; i++) {
277 const VkPhysicalDeviceGroupProperties *props =
278 &args->pPhysicalDeviceGroupProperties[i];
279 VkPhysicalDeviceGroupProperties *out = &orig_props[i];
280
281 out->physicalDeviceCount = props->physicalDeviceCount;
282 out->subsetAllocation = props->subsetAllocation;
283 for (uint32_t j = 0; j < props->physicalDeviceCount; j++) {
284 const struct vkr_physical_device *physical_dev =
285 vkr_instance_lookup_physical_device(instance, props->physicalDevices[j]);
286 vkr_cs_handle_store_id((void **)&out->physicalDevices[j], physical_dev->base.id,
287 VK_OBJECT_TYPE_PHYSICAL_DEVICE);
288 }
289 }
290
291 free(args->pPhysicalDeviceGroupProperties);
292 args->pPhysicalDeviceGroupProperties = orig_props;
293 }
294
295 static void
vkr_dispatch_vkEnumerateDeviceExtensionProperties(struct vn_dispatch_context * dispatch,struct vn_command_vkEnumerateDeviceExtensionProperties * args)296 vkr_dispatch_vkEnumerateDeviceExtensionProperties(
297 struct vn_dispatch_context *dispatch,
298 struct vn_command_vkEnumerateDeviceExtensionProperties *args)
299 {
300 struct vkr_context *ctx = dispatch->data;
301
302 struct vkr_physical_device *physical_dev =
303 vkr_physical_device_from_handle(args->physicalDevice);
304 if (args->pLayerName) {
305 vkr_cs_decoder_set_fatal(&ctx->decoder);
306 return;
307 }
308
309 if (!args->pProperties) {
310 *args->pPropertyCount = physical_dev->extension_count;
311 args->ret = VK_SUCCESS;
312 return;
313 }
314
315 uint32_t count = physical_dev->extension_count;
316 if (count > *args->pPropertyCount) {
317 count = *args->pPropertyCount;
318 args->ret = VK_INCOMPLETE;
319 } else {
320 *args->pPropertyCount = count;
321 args->ret = VK_SUCCESS;
322 }
323
324 memcpy(args->pProperties, physical_dev->extensions,
325 sizeof(*args->pProperties) * count);
326 }
327
328 static void
vkr_dispatch_vkGetPhysicalDeviceFeatures(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceFeatures * args)329 vkr_dispatch_vkGetPhysicalDeviceFeatures(
330 UNUSED struct vn_dispatch_context *dispatch,
331 struct vn_command_vkGetPhysicalDeviceFeatures *args)
332 {
333 vn_replace_vkGetPhysicalDeviceFeatures_args_handle(args);
334 vkGetPhysicalDeviceFeatures(args->physicalDevice, args->pFeatures);
335 }
336
337 static void
vkr_dispatch_vkGetPhysicalDeviceProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceProperties * args)338 vkr_dispatch_vkGetPhysicalDeviceProperties(
339 UNUSED struct vn_dispatch_context *dispatch,
340 struct vn_command_vkGetPhysicalDeviceProperties *args)
341 {
342 struct vkr_physical_device *physical_dev =
343 vkr_physical_device_from_handle(args->physicalDevice);
344
345 *args->pProperties = physical_dev->properties;
346 }
347
348 static void
vkr_dispatch_vkGetPhysicalDeviceQueueFamilyProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceQueueFamilyProperties * args)349 vkr_dispatch_vkGetPhysicalDeviceQueueFamilyProperties(
350 UNUSED struct vn_dispatch_context *dispatch,
351 struct vn_command_vkGetPhysicalDeviceQueueFamilyProperties *args)
352 {
353 vn_replace_vkGetPhysicalDeviceQueueFamilyProperties_args_handle(args);
354 vkGetPhysicalDeviceQueueFamilyProperties(args->physicalDevice,
355 args->pQueueFamilyPropertyCount,
356 args->pQueueFamilyProperties);
357 }
358
359 static void
vkr_dispatch_vkGetPhysicalDeviceMemoryProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceMemoryProperties * args)360 vkr_dispatch_vkGetPhysicalDeviceMemoryProperties(
361 UNUSED struct vn_dispatch_context *dispatch,
362 struct vn_command_vkGetPhysicalDeviceMemoryProperties *args)
363 {
364 /* TODO lie about this */
365 vn_replace_vkGetPhysicalDeviceMemoryProperties_args_handle(args);
366 vkGetPhysicalDeviceMemoryProperties(args->physicalDevice, args->pMemoryProperties);
367 }
368
369 static void
vkr_dispatch_vkGetPhysicalDeviceFormatProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceFormatProperties * args)370 vkr_dispatch_vkGetPhysicalDeviceFormatProperties(
371 UNUSED struct vn_dispatch_context *dispatch,
372 struct vn_command_vkGetPhysicalDeviceFormatProperties *args)
373 {
374 vn_replace_vkGetPhysicalDeviceFormatProperties_args_handle(args);
375 vkGetPhysicalDeviceFormatProperties(args->physicalDevice, args->format,
376 args->pFormatProperties);
377 }
378
379 static void
vkr_dispatch_vkGetPhysicalDeviceImageFormatProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceImageFormatProperties * args)380 vkr_dispatch_vkGetPhysicalDeviceImageFormatProperties(
381 UNUSED struct vn_dispatch_context *dispatch,
382 struct vn_command_vkGetPhysicalDeviceImageFormatProperties *args)
383 {
384 vn_replace_vkGetPhysicalDeviceImageFormatProperties_args_handle(args);
385 args->ret = vkGetPhysicalDeviceImageFormatProperties(
386 args->physicalDevice, args->format, args->type, args->tiling, args->usage,
387 args->flags, args->pImageFormatProperties);
388 }
389
390 static void
vkr_dispatch_vkGetPhysicalDeviceSparseImageFormatProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceSparseImageFormatProperties * args)391 vkr_dispatch_vkGetPhysicalDeviceSparseImageFormatProperties(
392 UNUSED struct vn_dispatch_context *dispatch,
393 struct vn_command_vkGetPhysicalDeviceSparseImageFormatProperties *args)
394 {
395 vn_replace_vkGetPhysicalDeviceSparseImageFormatProperties_args_handle(args);
396 vkGetPhysicalDeviceSparseImageFormatProperties(
397 args->physicalDevice, args->format, args->type, args->samples, args->usage,
398 args->tiling, args->pPropertyCount, args->pProperties);
399 }
400
401 static void
vkr_dispatch_vkGetPhysicalDeviceFeatures2(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceFeatures2 * args)402 vkr_dispatch_vkGetPhysicalDeviceFeatures2(
403 UNUSED struct vn_dispatch_context *dispatch,
404 struct vn_command_vkGetPhysicalDeviceFeatures2 *args)
405 {
406 vn_replace_vkGetPhysicalDeviceFeatures2_args_handle(args);
407 vkGetPhysicalDeviceFeatures2(args->physicalDevice, args->pFeatures);
408 }
409
410 static void
vkr_dispatch_vkGetPhysicalDeviceProperties2(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceProperties2 * args)411 vkr_dispatch_vkGetPhysicalDeviceProperties2(
412 UNUSED struct vn_dispatch_context *dispatch,
413 struct vn_command_vkGetPhysicalDeviceProperties2 *args)
414 {
415 struct vkr_physical_device *physical_dev =
416 vkr_physical_device_from_handle(args->physicalDevice);
417
418 vn_replace_vkGetPhysicalDeviceProperties2_args_handle(args);
419 vkGetPhysicalDeviceProperties2(args->physicalDevice, args->pProperties);
420
421 union {
422 VkBaseOutStructure *pnext;
423 VkPhysicalDeviceProperties2 *props;
424 VkPhysicalDeviceVulkan11Properties *vk11;
425 VkPhysicalDeviceVulkan12Properties *vk12;
426 VkPhysicalDeviceIDProperties *id;
427 VkPhysicalDeviceDriverProperties *driver;
428 } u;
429
430 u.pnext = (VkBaseOutStructure *)args->pProperties;
431 while (u.pnext) {
432 switch (u.pnext->sType) {
433 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2:
434 u.props->properties = physical_dev->properties;
435 break;
436 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES:
437 memset(u.vk11->deviceUUID, 0, sizeof(u.vk11->deviceUUID));
438 memset(u.vk11->driverUUID, 0, sizeof(u.vk11->driverUUID));
439 memset(u.vk11->deviceLUID, 0, sizeof(u.vk11->deviceLUID));
440 u.vk11->deviceNodeMask = 0;
441 u.vk11->deviceLUIDValid = false;
442 break;
443 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES:
444 u.vk12->driverID = 0;
445 memset(u.vk12->driverName, 0, sizeof(u.vk12->driverName));
446 memset(u.vk12->driverInfo, 0, sizeof(u.vk12->driverInfo));
447 memset(&u.vk12->conformanceVersion, 0, sizeof(u.vk12->conformanceVersion));
448 break;
449 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
450 memset(u.id->deviceUUID, 0, sizeof(u.id->deviceUUID));
451 memset(u.id->driverUUID, 0, sizeof(u.id->driverUUID));
452 memset(u.id->deviceLUID, 0, sizeof(u.id->deviceLUID));
453 u.id->deviceNodeMask = 0;
454 u.id->deviceLUIDValid = false;
455 break;
456 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES:
457 u.driver->driverID = 0;
458 memset(u.driver->driverName, 0, sizeof(u.driver->driverName));
459 memset(u.driver->driverInfo, 0, sizeof(u.driver->driverInfo));
460 memset(&u.driver->conformanceVersion, 0, sizeof(u.driver->conformanceVersion));
461 break;
462 default:
463 break;
464 }
465
466 u.pnext = u.pnext->pNext;
467 }
468 }
469
470 static void
vkr_dispatch_vkGetPhysicalDeviceQueueFamilyProperties2(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceQueueFamilyProperties2 * args)471 vkr_dispatch_vkGetPhysicalDeviceQueueFamilyProperties2(
472 UNUSED struct vn_dispatch_context *dispatch,
473 struct vn_command_vkGetPhysicalDeviceQueueFamilyProperties2 *args)
474 {
475 vn_replace_vkGetPhysicalDeviceQueueFamilyProperties2_args_handle(args);
476 vkGetPhysicalDeviceQueueFamilyProperties2(args->physicalDevice,
477 args->pQueueFamilyPropertyCount,
478 args->pQueueFamilyProperties);
479 }
480
481 static void
vkr_dispatch_vkGetPhysicalDeviceMemoryProperties2(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceMemoryProperties2 * args)482 vkr_dispatch_vkGetPhysicalDeviceMemoryProperties2(
483 UNUSED struct vn_dispatch_context *dispatch,
484 struct vn_command_vkGetPhysicalDeviceMemoryProperties2 *args)
485 {
486 /* TODO lie about this */
487 vn_replace_vkGetPhysicalDeviceMemoryProperties2_args_handle(args);
488 vkGetPhysicalDeviceMemoryProperties2(args->physicalDevice, args->pMemoryProperties);
489 }
490
491 static void
vkr_dispatch_vkGetPhysicalDeviceFormatProperties2(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceFormatProperties2 * args)492 vkr_dispatch_vkGetPhysicalDeviceFormatProperties2(
493 UNUSED struct vn_dispatch_context *dispatch,
494 struct vn_command_vkGetPhysicalDeviceFormatProperties2 *args)
495 {
496 vn_replace_vkGetPhysicalDeviceFormatProperties2_args_handle(args);
497 vkGetPhysicalDeviceFormatProperties2(args->physicalDevice, args->format,
498 args->pFormatProperties);
499 }
500
501 static void
vkr_dispatch_vkGetPhysicalDeviceImageFormatProperties2(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceImageFormatProperties2 * args)502 vkr_dispatch_vkGetPhysicalDeviceImageFormatProperties2(
503 UNUSED struct vn_dispatch_context *dispatch,
504 struct vn_command_vkGetPhysicalDeviceImageFormatProperties2 *args)
505 {
506 vn_replace_vkGetPhysicalDeviceImageFormatProperties2_args_handle(args);
507 args->ret = vkGetPhysicalDeviceImageFormatProperties2(
508 args->physicalDevice, args->pImageFormatInfo, args->pImageFormatProperties);
509 }
510
511 static void
vkr_dispatch_vkGetPhysicalDeviceSparseImageFormatProperties2(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceSparseImageFormatProperties2 * args)512 vkr_dispatch_vkGetPhysicalDeviceSparseImageFormatProperties2(
513 UNUSED struct vn_dispatch_context *dispatch,
514 struct vn_command_vkGetPhysicalDeviceSparseImageFormatProperties2 *args)
515 {
516 vn_replace_vkGetPhysicalDeviceSparseImageFormatProperties2_args_handle(args);
517 vkGetPhysicalDeviceSparseImageFormatProperties2(
518 args->physicalDevice, args->pFormatInfo, args->pPropertyCount, args->pProperties);
519 }
520
521 static void
vkr_dispatch_vkGetPhysicalDeviceExternalBufferProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceExternalBufferProperties * args)522 vkr_dispatch_vkGetPhysicalDeviceExternalBufferProperties(
523 UNUSED struct vn_dispatch_context *dispatch,
524 struct vn_command_vkGetPhysicalDeviceExternalBufferProperties *args)
525 {
526 vn_replace_vkGetPhysicalDeviceExternalBufferProperties_args_handle(args);
527 vkGetPhysicalDeviceExternalBufferProperties(
528 args->physicalDevice, args->pExternalBufferInfo, args->pExternalBufferProperties);
529 }
530
531 static void
vkr_dispatch_vkGetPhysicalDeviceExternalSemaphoreProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceExternalSemaphoreProperties * args)532 vkr_dispatch_vkGetPhysicalDeviceExternalSemaphoreProperties(
533 UNUSED struct vn_dispatch_context *dispatch,
534 struct vn_command_vkGetPhysicalDeviceExternalSemaphoreProperties *args)
535 {
536 vn_replace_vkGetPhysicalDeviceExternalSemaphoreProperties_args_handle(args);
537 vkGetPhysicalDeviceExternalSemaphoreProperties(args->physicalDevice,
538 args->pExternalSemaphoreInfo,
539 args->pExternalSemaphoreProperties);
540 }
541
542 static void
vkr_dispatch_vkGetPhysicalDeviceExternalFenceProperties(UNUSED struct vn_dispatch_context * dispatch,struct vn_command_vkGetPhysicalDeviceExternalFenceProperties * args)543 vkr_dispatch_vkGetPhysicalDeviceExternalFenceProperties(
544 UNUSED struct vn_dispatch_context *dispatch,
545 struct vn_command_vkGetPhysicalDeviceExternalFenceProperties *args)
546 {
547 vn_replace_vkGetPhysicalDeviceExternalFenceProperties_args_handle(args);
548 vkGetPhysicalDeviceExternalFenceProperties(
549 args->physicalDevice, args->pExternalFenceInfo, args->pExternalFenceProperties);
550 }
551
552 void
vkr_context_init_physical_device_dispatch(struct vkr_context * ctx)553 vkr_context_init_physical_device_dispatch(struct vkr_context *ctx)
554 {
555 struct vn_dispatch_context *dispatch = &ctx->dispatch;
556
557 dispatch->dispatch_vkEnumeratePhysicalDevices =
558 vkr_dispatch_vkEnumeratePhysicalDevices;
559 dispatch->dispatch_vkEnumeratePhysicalDeviceGroups =
560 vkr_dispatch_vkEnumeratePhysicalDeviceGroups;
561 dispatch->dispatch_vkEnumerateDeviceExtensionProperties =
562 vkr_dispatch_vkEnumerateDeviceExtensionProperties;
563 dispatch->dispatch_vkEnumerateDeviceLayerProperties = NULL;
564
565 dispatch->dispatch_vkGetPhysicalDeviceFeatures =
566 vkr_dispatch_vkGetPhysicalDeviceFeatures;
567 dispatch->dispatch_vkGetPhysicalDeviceProperties =
568 vkr_dispatch_vkGetPhysicalDeviceProperties;
569 dispatch->dispatch_vkGetPhysicalDeviceQueueFamilyProperties =
570 vkr_dispatch_vkGetPhysicalDeviceQueueFamilyProperties;
571 dispatch->dispatch_vkGetPhysicalDeviceMemoryProperties =
572 vkr_dispatch_vkGetPhysicalDeviceMemoryProperties;
573 dispatch->dispatch_vkGetPhysicalDeviceFormatProperties =
574 vkr_dispatch_vkGetPhysicalDeviceFormatProperties;
575 dispatch->dispatch_vkGetPhysicalDeviceImageFormatProperties =
576 vkr_dispatch_vkGetPhysicalDeviceImageFormatProperties;
577 dispatch->dispatch_vkGetPhysicalDeviceSparseImageFormatProperties =
578 vkr_dispatch_vkGetPhysicalDeviceSparseImageFormatProperties;
579 dispatch->dispatch_vkGetPhysicalDeviceFeatures2 =
580 vkr_dispatch_vkGetPhysicalDeviceFeatures2;
581 dispatch->dispatch_vkGetPhysicalDeviceProperties2 =
582 vkr_dispatch_vkGetPhysicalDeviceProperties2;
583 dispatch->dispatch_vkGetPhysicalDeviceQueueFamilyProperties2 =
584 vkr_dispatch_vkGetPhysicalDeviceQueueFamilyProperties2;
585 dispatch->dispatch_vkGetPhysicalDeviceMemoryProperties2 =
586 vkr_dispatch_vkGetPhysicalDeviceMemoryProperties2;
587 dispatch->dispatch_vkGetPhysicalDeviceFormatProperties2 =
588 vkr_dispatch_vkGetPhysicalDeviceFormatProperties2;
589 dispatch->dispatch_vkGetPhysicalDeviceImageFormatProperties2 =
590 vkr_dispatch_vkGetPhysicalDeviceImageFormatProperties2;
591 dispatch->dispatch_vkGetPhysicalDeviceSparseImageFormatProperties2 =
592 vkr_dispatch_vkGetPhysicalDeviceSparseImageFormatProperties2;
593 dispatch->dispatch_vkGetPhysicalDeviceExternalBufferProperties =
594 vkr_dispatch_vkGetPhysicalDeviceExternalBufferProperties;
595 dispatch->dispatch_vkGetMemoryFdKHR = NULL;
596 dispatch->dispatch_vkGetMemoryFdPropertiesKHR = NULL;
597 dispatch->dispatch_vkGetPhysicalDeviceExternalSemaphoreProperties =
598 vkr_dispatch_vkGetPhysicalDeviceExternalSemaphoreProperties;
599 dispatch->dispatch_vkGetPhysicalDeviceExternalFenceProperties =
600 vkr_dispatch_vkGetPhysicalDeviceExternalFenceProperties;
601 }
602