1 /* This file is generated by venus-protocol. See vn_protocol_driver.h. */
2
3 /*
4 * Copyright 2020 Google LLC
5 * SPDX-License-Identifier: MIT
6 */
7
8 #ifndef VN_PROTOCOL_DRIVER_INSTANCE_H
9 #define VN_PROTOCOL_DRIVER_INSTANCE_H
10
11 #include "vn_instance.h"
12 #include "vn_protocol_driver_structs.h"
13
14 /*
15 * These structs/unions/commands are not included
16 *
17 * vkGetInstanceProcAddr
18 */
19
20 /* struct VkApplicationInfo chain */
21
22 static inline size_t
vn_sizeof_VkApplicationInfo_pnext(const void * val)23 vn_sizeof_VkApplicationInfo_pnext(const void *val)
24 {
25 /* no known/supported struct */
26 return vn_sizeof_simple_pointer(NULL);
27 }
28
29 static inline size_t
vn_sizeof_VkApplicationInfo_self(const VkApplicationInfo * val)30 vn_sizeof_VkApplicationInfo_self(const VkApplicationInfo *val)
31 {
32 size_t size = 0;
33 /* skip val->{sType,pNext} */
34 if (val->pApplicationName) {
35 const size_t string_size = strlen(val->pApplicationName) + 1;
36 size += vn_sizeof_array_size(string_size);
37 size += vn_sizeof_char_array(val->pApplicationName, string_size);
38 } else {
39 size += vn_sizeof_array_size(0);
40 }
41 size += vn_sizeof_uint32_t(&val->applicationVersion);
42 if (val->pEngineName) {
43 const size_t string_size = strlen(val->pEngineName) + 1;
44 size += vn_sizeof_array_size(string_size);
45 size += vn_sizeof_char_array(val->pEngineName, string_size);
46 } else {
47 size += vn_sizeof_array_size(0);
48 }
49 size += vn_sizeof_uint32_t(&val->engineVersion);
50 size += vn_sizeof_uint32_t(&val->apiVersion);
51 return size;
52 }
53
54 static inline size_t
vn_sizeof_VkApplicationInfo(const VkApplicationInfo * val)55 vn_sizeof_VkApplicationInfo(const VkApplicationInfo *val)
56 {
57 size_t size = 0;
58
59 size += vn_sizeof_VkStructureType(&val->sType);
60 size += vn_sizeof_VkApplicationInfo_pnext(val->pNext);
61 size += vn_sizeof_VkApplicationInfo_self(val);
62
63 return size;
64 }
65
66 static inline void
vn_encode_VkApplicationInfo_pnext(struct vn_cs_encoder * enc,const void * val)67 vn_encode_VkApplicationInfo_pnext(struct vn_cs_encoder *enc, const void *val)
68 {
69 /* no known/supported struct */
70 vn_encode_simple_pointer(enc, NULL);
71 }
72
73 static inline void
vn_encode_VkApplicationInfo_self(struct vn_cs_encoder * enc,const VkApplicationInfo * val)74 vn_encode_VkApplicationInfo_self(struct vn_cs_encoder *enc, const VkApplicationInfo *val)
75 {
76 /* skip val->{sType,pNext} */
77 if (val->pApplicationName) {
78 const size_t string_size = strlen(val->pApplicationName) + 1;
79 vn_encode_array_size(enc, string_size);
80 vn_encode_char_array(enc, val->pApplicationName, string_size);
81 } else {
82 vn_encode_array_size(enc, 0);
83 }
84 vn_encode_uint32_t(enc, &val->applicationVersion);
85 if (val->pEngineName) {
86 const size_t string_size = strlen(val->pEngineName) + 1;
87 vn_encode_array_size(enc, string_size);
88 vn_encode_char_array(enc, val->pEngineName, string_size);
89 } else {
90 vn_encode_array_size(enc, 0);
91 }
92 vn_encode_uint32_t(enc, &val->engineVersion);
93 vn_encode_uint32_t(enc, &val->apiVersion);
94 }
95
96 static inline void
vn_encode_VkApplicationInfo(struct vn_cs_encoder * enc,const VkApplicationInfo * val)97 vn_encode_VkApplicationInfo(struct vn_cs_encoder *enc, const VkApplicationInfo *val)
98 {
99 assert(val->sType == VK_STRUCTURE_TYPE_APPLICATION_INFO);
100 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_APPLICATION_INFO });
101 vn_encode_VkApplicationInfo_pnext(enc, val->pNext);
102 vn_encode_VkApplicationInfo_self(enc, val);
103 }
104
105 /* struct VkInstanceCreateInfo chain */
106
107 static inline size_t
vn_sizeof_VkInstanceCreateInfo_pnext(const void * val)108 vn_sizeof_VkInstanceCreateInfo_pnext(const void *val)
109 {
110 /* no known/supported struct */
111 return vn_sizeof_simple_pointer(NULL);
112 }
113
114 static inline size_t
vn_sizeof_VkInstanceCreateInfo_self(const VkInstanceCreateInfo * val)115 vn_sizeof_VkInstanceCreateInfo_self(const VkInstanceCreateInfo *val)
116 {
117 size_t size = 0;
118 /* skip val->{sType,pNext} */
119 size += vn_sizeof_VkFlags(&val->flags);
120 size += vn_sizeof_simple_pointer(val->pApplicationInfo);
121 if (val->pApplicationInfo)
122 size += vn_sizeof_VkApplicationInfo(val->pApplicationInfo);
123 size += vn_sizeof_uint32_t(&val->enabledLayerCount);
124 if (val->ppEnabledLayerNames) {
125 size += vn_sizeof_array_size(val->enabledLayerCount);
126 for (uint32_t i = 0; i < val->enabledLayerCount; i++) {
127 const size_t string_size = strlen(val->ppEnabledLayerNames[i]) + 1;
128 size += vn_sizeof_array_size(string_size);
129 size += vn_sizeof_char_array(val->ppEnabledLayerNames[i], string_size);
130 }
131 } else {
132 size += vn_sizeof_array_size(0);
133 }
134 size += vn_sizeof_uint32_t(&val->enabledExtensionCount);
135 if (val->ppEnabledExtensionNames) {
136 size += vn_sizeof_array_size(val->enabledExtensionCount);
137 for (uint32_t i = 0; i < val->enabledExtensionCount; i++) {
138 const size_t string_size = strlen(val->ppEnabledExtensionNames[i]) + 1;
139 size += vn_sizeof_array_size(string_size);
140 size += vn_sizeof_char_array(val->ppEnabledExtensionNames[i], string_size);
141 }
142 } else {
143 size += vn_sizeof_array_size(0);
144 }
145 return size;
146 }
147
148 static inline size_t
vn_sizeof_VkInstanceCreateInfo(const VkInstanceCreateInfo * val)149 vn_sizeof_VkInstanceCreateInfo(const VkInstanceCreateInfo *val)
150 {
151 size_t size = 0;
152
153 size += vn_sizeof_VkStructureType(&val->sType);
154 size += vn_sizeof_VkInstanceCreateInfo_pnext(val->pNext);
155 size += vn_sizeof_VkInstanceCreateInfo_self(val);
156
157 return size;
158 }
159
160 static inline void
vn_encode_VkInstanceCreateInfo_pnext(struct vn_cs_encoder * enc,const void * val)161 vn_encode_VkInstanceCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
162 {
163 /* no known/supported struct */
164 vn_encode_simple_pointer(enc, NULL);
165 }
166
167 static inline void
vn_encode_VkInstanceCreateInfo_self(struct vn_cs_encoder * enc,const VkInstanceCreateInfo * val)168 vn_encode_VkInstanceCreateInfo_self(struct vn_cs_encoder *enc, const VkInstanceCreateInfo *val)
169 {
170 /* skip val->{sType,pNext} */
171 vn_encode_VkFlags(enc, &val->flags);
172 if (vn_encode_simple_pointer(enc, val->pApplicationInfo))
173 vn_encode_VkApplicationInfo(enc, val->pApplicationInfo);
174 vn_encode_uint32_t(enc, &val->enabledLayerCount);
175 if (val->ppEnabledLayerNames) {
176 vn_encode_array_size(enc, val->enabledLayerCount);
177 for (uint32_t i = 0; i < val->enabledLayerCount; i++) {
178 const size_t string_size = strlen(val->ppEnabledLayerNames[i]) + 1;
179 vn_encode_array_size(enc, string_size);
180 vn_encode_char_array(enc, val->ppEnabledLayerNames[i], string_size);
181 }
182 } else {
183 vn_encode_array_size(enc, 0);
184 }
185 vn_encode_uint32_t(enc, &val->enabledExtensionCount);
186 if (val->ppEnabledExtensionNames) {
187 vn_encode_array_size(enc, val->enabledExtensionCount);
188 for (uint32_t i = 0; i < val->enabledExtensionCount; i++) {
189 const size_t string_size = strlen(val->ppEnabledExtensionNames[i]) + 1;
190 vn_encode_array_size(enc, string_size);
191 vn_encode_char_array(enc, val->ppEnabledExtensionNames[i], string_size);
192 }
193 } else {
194 vn_encode_array_size(enc, 0);
195 }
196 }
197
198 static inline void
vn_encode_VkInstanceCreateInfo(struct vn_cs_encoder * enc,const VkInstanceCreateInfo * val)199 vn_encode_VkInstanceCreateInfo(struct vn_cs_encoder *enc, const VkInstanceCreateInfo *val)
200 {
201 assert(val->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
202 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO });
203 vn_encode_VkInstanceCreateInfo_pnext(enc, val->pNext);
204 vn_encode_VkInstanceCreateInfo_self(enc, val);
205 }
206
vn_sizeof_vkCreateInstance(const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)207 static inline size_t vn_sizeof_vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
208 {
209 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateInstance_EXT;
210 const VkFlags cmd_flags = 0;
211 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
212
213 cmd_size += vn_sizeof_simple_pointer(pCreateInfo);
214 if (pCreateInfo)
215 cmd_size += vn_sizeof_VkInstanceCreateInfo(pCreateInfo);
216 cmd_size += vn_sizeof_simple_pointer(pAllocator);
217 if (pAllocator)
218 assert(false);
219 cmd_size += vn_sizeof_simple_pointer(pInstance);
220 if (pInstance)
221 cmd_size += vn_sizeof_VkInstance(pInstance);
222
223 return cmd_size;
224 }
225
vn_encode_vkCreateInstance(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)226 static inline void vn_encode_vkCreateInstance(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
227 {
228 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateInstance_EXT;
229
230 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
231 vn_encode_VkFlags(enc, &cmd_flags);
232
233 if (vn_encode_simple_pointer(enc, pCreateInfo))
234 vn_encode_VkInstanceCreateInfo(enc, pCreateInfo);
235 if (vn_encode_simple_pointer(enc, pAllocator))
236 assert(false);
237 if (vn_encode_simple_pointer(enc, pInstance))
238 vn_encode_VkInstance(enc, pInstance);
239 }
240
vn_sizeof_vkCreateInstance_reply(const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)241 static inline size_t vn_sizeof_vkCreateInstance_reply(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
242 {
243 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateInstance_EXT;
244 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
245
246 VkResult ret;
247 cmd_size += vn_sizeof_VkResult(&ret);
248 /* skip pCreateInfo */
249 /* skip pAllocator */
250 cmd_size += vn_sizeof_simple_pointer(pInstance);
251 if (pInstance)
252 cmd_size += vn_sizeof_VkInstance(pInstance);
253
254 return cmd_size;
255 }
256
vn_decode_vkCreateInstance_reply(struct vn_cs_decoder * dec,const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)257 static inline VkResult vn_decode_vkCreateInstance_reply(struct vn_cs_decoder *dec, const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
258 {
259 VkCommandTypeEXT command_type;
260 vn_decode_VkCommandTypeEXT(dec, &command_type);
261 assert(command_type == VK_COMMAND_TYPE_vkCreateInstance_EXT);
262
263 VkResult ret;
264 vn_decode_VkResult(dec, &ret);
265 /* skip pCreateInfo */
266 /* skip pAllocator */
267 if (vn_decode_simple_pointer(dec)) {
268 vn_decode_VkInstance(dec, pInstance);
269 } else {
270 pInstance = NULL;
271 }
272
273 return ret;
274 }
275
vn_sizeof_vkDestroyInstance(VkInstance instance,const VkAllocationCallbacks * pAllocator)276 static inline size_t vn_sizeof_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator)
277 {
278 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyInstance_EXT;
279 const VkFlags cmd_flags = 0;
280 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
281
282 cmd_size += vn_sizeof_VkInstance(&instance);
283 cmd_size += vn_sizeof_simple_pointer(pAllocator);
284 if (pAllocator)
285 assert(false);
286
287 return cmd_size;
288 }
289
vn_encode_vkDestroyInstance(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkInstance instance,const VkAllocationCallbacks * pAllocator)290 static inline void vn_encode_vkDestroyInstance(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkInstance instance, const VkAllocationCallbacks* pAllocator)
291 {
292 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyInstance_EXT;
293
294 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
295 vn_encode_VkFlags(enc, &cmd_flags);
296
297 vn_encode_VkInstance(enc, &instance);
298 if (vn_encode_simple_pointer(enc, pAllocator))
299 assert(false);
300 }
301
vn_sizeof_vkDestroyInstance_reply(VkInstance instance,const VkAllocationCallbacks * pAllocator)302 static inline size_t vn_sizeof_vkDestroyInstance_reply(VkInstance instance, const VkAllocationCallbacks* pAllocator)
303 {
304 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyInstance_EXT;
305 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
306
307 /* skip instance */
308 /* skip pAllocator */
309
310 return cmd_size;
311 }
312
vn_decode_vkDestroyInstance_reply(struct vn_cs_decoder * dec,VkInstance instance,const VkAllocationCallbacks * pAllocator)313 static inline void vn_decode_vkDestroyInstance_reply(struct vn_cs_decoder *dec, VkInstance instance, const VkAllocationCallbacks* pAllocator)
314 {
315 VkCommandTypeEXT command_type;
316 vn_decode_VkCommandTypeEXT(dec, &command_type);
317 assert(command_type == VK_COMMAND_TYPE_vkDestroyInstance_EXT);
318
319 /* skip instance */
320 /* skip pAllocator */
321 }
322
vn_sizeof_vkEnumerateInstanceVersion(uint32_t * pApiVersion)323 static inline size_t vn_sizeof_vkEnumerateInstanceVersion(uint32_t* pApiVersion)
324 {
325 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceVersion_EXT;
326 const VkFlags cmd_flags = 0;
327 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
328
329 cmd_size += vn_sizeof_simple_pointer(pApiVersion); /* out */
330
331 return cmd_size;
332 }
333
vn_encode_vkEnumerateInstanceVersion(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,uint32_t * pApiVersion)334 static inline void vn_encode_vkEnumerateInstanceVersion(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, uint32_t* pApiVersion)
335 {
336 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceVersion_EXT;
337
338 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
339 vn_encode_VkFlags(enc, &cmd_flags);
340
341 vn_encode_simple_pointer(enc, pApiVersion); /* out */
342 }
343
vn_sizeof_vkEnumerateInstanceVersion_reply(uint32_t * pApiVersion)344 static inline size_t vn_sizeof_vkEnumerateInstanceVersion_reply(uint32_t* pApiVersion)
345 {
346 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceVersion_EXT;
347 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
348
349 VkResult ret;
350 cmd_size += vn_sizeof_VkResult(&ret);
351 cmd_size += vn_sizeof_simple_pointer(pApiVersion);
352 if (pApiVersion)
353 cmd_size += vn_sizeof_uint32_t(pApiVersion);
354
355 return cmd_size;
356 }
357
vn_decode_vkEnumerateInstanceVersion_reply(struct vn_cs_decoder * dec,uint32_t * pApiVersion)358 static inline VkResult vn_decode_vkEnumerateInstanceVersion_reply(struct vn_cs_decoder *dec, uint32_t* pApiVersion)
359 {
360 VkCommandTypeEXT command_type;
361 vn_decode_VkCommandTypeEXT(dec, &command_type);
362 assert(command_type == VK_COMMAND_TYPE_vkEnumerateInstanceVersion_EXT);
363
364 VkResult ret;
365 vn_decode_VkResult(dec, &ret);
366 if (vn_decode_simple_pointer(dec)) {
367 vn_decode_uint32_t(dec, pApiVersion);
368 } else {
369 pApiVersion = NULL;
370 }
371
372 return ret;
373 }
374
vn_sizeof_vkEnumerateInstanceLayerProperties(uint32_t * pPropertyCount,VkLayerProperties * pProperties)375 static inline size_t vn_sizeof_vkEnumerateInstanceLayerProperties(uint32_t* pPropertyCount, VkLayerProperties* pProperties)
376 {
377 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceLayerProperties_EXT;
378 const VkFlags cmd_flags = 0;
379 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
380
381 cmd_size += vn_sizeof_simple_pointer(pPropertyCount);
382 if (pPropertyCount)
383 cmd_size += vn_sizeof_uint32_t(pPropertyCount);
384 if (pProperties) {
385 cmd_size += vn_sizeof_array_size((pPropertyCount ? *pPropertyCount : 0));
386 for (uint32_t i = 0; i < (pPropertyCount ? *pPropertyCount : 0); i++)
387 cmd_size += vn_sizeof_VkLayerProperties_partial(&pProperties[i]);
388 } else {
389 cmd_size += vn_sizeof_array_size(0);
390 }
391
392 return cmd_size;
393 }
394
vn_encode_vkEnumerateInstanceLayerProperties(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,uint32_t * pPropertyCount,VkLayerProperties * pProperties)395 static inline void vn_encode_vkEnumerateInstanceLayerProperties(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, uint32_t* pPropertyCount, VkLayerProperties* pProperties)
396 {
397 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceLayerProperties_EXT;
398
399 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
400 vn_encode_VkFlags(enc, &cmd_flags);
401
402 if (vn_encode_simple_pointer(enc, pPropertyCount))
403 vn_encode_uint32_t(enc, pPropertyCount);
404 if (pProperties) {
405 vn_encode_array_size(enc, (pPropertyCount ? *pPropertyCount : 0));
406 for (uint32_t i = 0; i < (pPropertyCount ? *pPropertyCount : 0); i++)
407 vn_encode_VkLayerProperties_partial(enc, &pProperties[i]);
408 } else {
409 vn_encode_array_size(enc, 0);
410 }
411 }
412
vn_sizeof_vkEnumerateInstanceLayerProperties_reply(uint32_t * pPropertyCount,VkLayerProperties * pProperties)413 static inline size_t vn_sizeof_vkEnumerateInstanceLayerProperties_reply(uint32_t* pPropertyCount, VkLayerProperties* pProperties)
414 {
415 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceLayerProperties_EXT;
416 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
417
418 VkResult ret;
419 cmd_size += vn_sizeof_VkResult(&ret);
420 cmd_size += vn_sizeof_simple_pointer(pPropertyCount);
421 if (pPropertyCount)
422 cmd_size += vn_sizeof_uint32_t(pPropertyCount);
423 if (pProperties) {
424 cmd_size += vn_sizeof_array_size((pPropertyCount ? *pPropertyCount : 0));
425 for (uint32_t i = 0; i < (pPropertyCount ? *pPropertyCount : 0); i++)
426 cmd_size += vn_sizeof_VkLayerProperties(&pProperties[i]);
427 } else {
428 cmd_size += vn_sizeof_array_size(0);
429 }
430
431 return cmd_size;
432 }
433
vn_decode_vkEnumerateInstanceLayerProperties_reply(struct vn_cs_decoder * dec,uint32_t * pPropertyCount,VkLayerProperties * pProperties)434 static inline VkResult vn_decode_vkEnumerateInstanceLayerProperties_reply(struct vn_cs_decoder *dec, uint32_t* pPropertyCount, VkLayerProperties* pProperties)
435 {
436 VkCommandTypeEXT command_type;
437 vn_decode_VkCommandTypeEXT(dec, &command_type);
438 assert(command_type == VK_COMMAND_TYPE_vkEnumerateInstanceLayerProperties_EXT);
439
440 VkResult ret;
441 vn_decode_VkResult(dec, &ret);
442 if (vn_decode_simple_pointer(dec)) {
443 vn_decode_uint32_t(dec, pPropertyCount);
444 } else {
445 pPropertyCount = NULL;
446 }
447 if (vn_peek_array_size(dec)) {
448 const uint32_t iter_count = vn_decode_array_size(dec, (pPropertyCount ? *pPropertyCount : 0));
449 for (uint32_t i = 0; i < iter_count; i++)
450 vn_decode_VkLayerProperties(dec, &pProperties[i]);
451 } else {
452 vn_decode_array_size_unchecked(dec);
453 pProperties = NULL;
454 }
455
456 return ret;
457 }
458
vn_sizeof_vkEnumerateInstanceExtensionProperties(const char * pLayerName,uint32_t * pPropertyCount,VkExtensionProperties * pProperties)459 static inline size_t vn_sizeof_vkEnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
460 {
461 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceExtensionProperties_EXT;
462 const VkFlags cmd_flags = 0;
463 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
464
465 if (pLayerName) {
466 const size_t string_size = strlen(pLayerName) + 1;
467 cmd_size += vn_sizeof_array_size(string_size);
468 cmd_size += vn_sizeof_char_array(pLayerName, string_size);
469 } else {
470 cmd_size += vn_sizeof_array_size(0);
471 }
472 cmd_size += vn_sizeof_simple_pointer(pPropertyCount);
473 if (pPropertyCount)
474 cmd_size += vn_sizeof_uint32_t(pPropertyCount);
475 if (pProperties) {
476 cmd_size += vn_sizeof_array_size((pPropertyCount ? *pPropertyCount : 0));
477 for (uint32_t i = 0; i < (pPropertyCount ? *pPropertyCount : 0); i++)
478 cmd_size += vn_sizeof_VkExtensionProperties_partial(&pProperties[i]);
479 } else {
480 cmd_size += vn_sizeof_array_size(0);
481 }
482
483 return cmd_size;
484 }
485
vn_encode_vkEnumerateInstanceExtensionProperties(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,const char * pLayerName,uint32_t * pPropertyCount,VkExtensionProperties * pProperties)486 static inline void vn_encode_vkEnumerateInstanceExtensionProperties(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
487 {
488 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceExtensionProperties_EXT;
489
490 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
491 vn_encode_VkFlags(enc, &cmd_flags);
492
493 if (pLayerName) {
494 const size_t string_size = strlen(pLayerName) + 1;
495 vn_encode_array_size(enc, string_size);
496 vn_encode_char_array(enc, pLayerName, string_size);
497 } else {
498 vn_encode_array_size(enc, 0);
499 }
500 if (vn_encode_simple_pointer(enc, pPropertyCount))
501 vn_encode_uint32_t(enc, pPropertyCount);
502 if (pProperties) {
503 vn_encode_array_size(enc, (pPropertyCount ? *pPropertyCount : 0));
504 for (uint32_t i = 0; i < (pPropertyCount ? *pPropertyCount : 0); i++)
505 vn_encode_VkExtensionProperties_partial(enc, &pProperties[i]);
506 } else {
507 vn_encode_array_size(enc, 0);
508 }
509 }
510
vn_sizeof_vkEnumerateInstanceExtensionProperties_reply(const char * pLayerName,uint32_t * pPropertyCount,VkExtensionProperties * pProperties)511 static inline size_t vn_sizeof_vkEnumerateInstanceExtensionProperties_reply(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
512 {
513 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkEnumerateInstanceExtensionProperties_EXT;
514 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
515
516 VkResult ret;
517 cmd_size += vn_sizeof_VkResult(&ret);
518 /* skip pLayerName */
519 cmd_size += vn_sizeof_simple_pointer(pPropertyCount);
520 if (pPropertyCount)
521 cmd_size += vn_sizeof_uint32_t(pPropertyCount);
522 if (pProperties) {
523 cmd_size += vn_sizeof_array_size((pPropertyCount ? *pPropertyCount : 0));
524 for (uint32_t i = 0; i < (pPropertyCount ? *pPropertyCount : 0); i++)
525 cmd_size += vn_sizeof_VkExtensionProperties(&pProperties[i]);
526 } else {
527 cmd_size += vn_sizeof_array_size(0);
528 }
529
530 return cmd_size;
531 }
532
vn_decode_vkEnumerateInstanceExtensionProperties_reply(struct vn_cs_decoder * dec,const char * pLayerName,uint32_t * pPropertyCount,VkExtensionProperties * pProperties)533 static inline VkResult vn_decode_vkEnumerateInstanceExtensionProperties_reply(struct vn_cs_decoder *dec, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
534 {
535 VkCommandTypeEXT command_type;
536 vn_decode_VkCommandTypeEXT(dec, &command_type);
537 assert(command_type == VK_COMMAND_TYPE_vkEnumerateInstanceExtensionProperties_EXT);
538
539 VkResult ret;
540 vn_decode_VkResult(dec, &ret);
541 /* skip pLayerName */
542 if (vn_decode_simple_pointer(dec)) {
543 vn_decode_uint32_t(dec, pPropertyCount);
544 } else {
545 pPropertyCount = NULL;
546 }
547 if (vn_peek_array_size(dec)) {
548 const uint32_t iter_count = vn_decode_array_size(dec, (pPropertyCount ? *pPropertyCount : 0));
549 for (uint32_t i = 0; i < iter_count; i++)
550 vn_decode_VkExtensionProperties(dec, &pProperties[i]);
551 } else {
552 vn_decode_array_size_unchecked(dec);
553 pProperties = NULL;
554 }
555
556 return ret;
557 }
558
vn_submit_vkCreateInstance(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance,struct vn_instance_submit_command * submit)559 static inline void vn_submit_vkCreateInstance(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance, struct vn_instance_submit_command *submit)
560 {
561 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
562 void *cmd_data = local_cmd_data;
563 size_t cmd_size = vn_sizeof_vkCreateInstance(pCreateInfo, pAllocator, pInstance);
564 if (cmd_size > sizeof(local_cmd_data)) {
565 cmd_data = malloc(cmd_size);
566 if (!cmd_data)
567 cmd_size = 0;
568 }
569 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateInstance_reply(pCreateInfo, pAllocator, pInstance) : 0;
570
571 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
572 if (cmd_size) {
573 vn_encode_vkCreateInstance(enc, cmd_flags, pCreateInfo, pAllocator, pInstance);
574 vn_instance_submit_command(vn_instance, submit);
575 if (cmd_data != local_cmd_data)
576 free(cmd_data);
577 }
578 }
579
vn_submit_vkDestroyInstance(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkInstance instance,const VkAllocationCallbacks * pAllocator,struct vn_instance_submit_command * submit)580 static inline void vn_submit_vkDestroyInstance(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkInstance instance, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit)
581 {
582 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
583 void *cmd_data = local_cmd_data;
584 size_t cmd_size = vn_sizeof_vkDestroyInstance(instance, pAllocator);
585 if (cmd_size > sizeof(local_cmd_data)) {
586 cmd_data = malloc(cmd_size);
587 if (!cmd_data)
588 cmd_size = 0;
589 }
590 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyInstance_reply(instance, pAllocator) : 0;
591
592 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
593 if (cmd_size) {
594 vn_encode_vkDestroyInstance(enc, cmd_flags, instance, pAllocator);
595 vn_instance_submit_command(vn_instance, submit);
596 if (cmd_data != local_cmd_data)
597 free(cmd_data);
598 }
599 }
600
vn_submit_vkEnumerateInstanceVersion(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,uint32_t * pApiVersion,struct vn_instance_submit_command * submit)601 static inline void vn_submit_vkEnumerateInstanceVersion(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, uint32_t* pApiVersion, struct vn_instance_submit_command *submit)
602 {
603 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
604 void *cmd_data = local_cmd_data;
605 size_t cmd_size = vn_sizeof_vkEnumerateInstanceVersion(pApiVersion);
606 if (cmd_size > sizeof(local_cmd_data)) {
607 cmd_data = malloc(cmd_size);
608 if (!cmd_data)
609 cmd_size = 0;
610 }
611 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkEnumerateInstanceVersion_reply(pApiVersion) : 0;
612
613 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
614 if (cmd_size) {
615 vn_encode_vkEnumerateInstanceVersion(enc, cmd_flags, pApiVersion);
616 vn_instance_submit_command(vn_instance, submit);
617 if (cmd_data != local_cmd_data)
618 free(cmd_data);
619 }
620 }
621
vn_submit_vkEnumerateInstanceLayerProperties(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,uint32_t * pPropertyCount,VkLayerProperties * pProperties,struct vn_instance_submit_command * submit)622 static inline void vn_submit_vkEnumerateInstanceLayerProperties(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, uint32_t* pPropertyCount, VkLayerProperties* pProperties, struct vn_instance_submit_command *submit)
623 {
624 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
625 void *cmd_data = local_cmd_data;
626 size_t cmd_size = vn_sizeof_vkEnumerateInstanceLayerProperties(pPropertyCount, pProperties);
627 if (cmd_size > sizeof(local_cmd_data)) {
628 cmd_data = malloc(cmd_size);
629 if (!cmd_data)
630 cmd_size = 0;
631 }
632 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkEnumerateInstanceLayerProperties_reply(pPropertyCount, pProperties) : 0;
633
634 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
635 if (cmd_size) {
636 vn_encode_vkEnumerateInstanceLayerProperties(enc, cmd_flags, pPropertyCount, pProperties);
637 vn_instance_submit_command(vn_instance, submit);
638 if (cmd_data != local_cmd_data)
639 free(cmd_data);
640 }
641 }
642
vn_submit_vkEnumerateInstanceExtensionProperties(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,const char * pLayerName,uint32_t * pPropertyCount,VkExtensionProperties * pProperties,struct vn_instance_submit_command * submit)643 static inline void vn_submit_vkEnumerateInstanceExtensionProperties(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties, struct vn_instance_submit_command *submit)
644 {
645 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
646 void *cmd_data = local_cmd_data;
647 size_t cmd_size = vn_sizeof_vkEnumerateInstanceExtensionProperties(pLayerName, pPropertyCount, pProperties);
648 if (cmd_size > sizeof(local_cmd_data)) {
649 cmd_data = malloc(cmd_size);
650 if (!cmd_data)
651 cmd_size = 0;
652 }
653 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkEnumerateInstanceExtensionProperties_reply(pLayerName, pPropertyCount, pProperties) : 0;
654
655 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
656 if (cmd_size) {
657 vn_encode_vkEnumerateInstanceExtensionProperties(enc, cmd_flags, pLayerName, pPropertyCount, pProperties);
658 vn_instance_submit_command(vn_instance, submit);
659 if (cmd_data != local_cmd_data)
660 free(cmd_data);
661 }
662 }
663
vn_call_vkCreateInstance(struct vn_instance * vn_instance,const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)664 static inline VkResult vn_call_vkCreateInstance(struct vn_instance *vn_instance, const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
665 {
666 VN_TRACE_FUNC();
667
668 struct vn_instance_submit_command submit;
669 vn_submit_vkCreateInstance(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, pCreateInfo, pAllocator, pInstance, &submit);
670 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
671 if (dec) {
672 const VkResult ret = vn_decode_vkCreateInstance_reply(dec, pCreateInfo, pAllocator, pInstance);
673 vn_instance_free_command_reply(vn_instance, &submit);
674 return ret;
675 } else {
676 return VK_ERROR_OUT_OF_HOST_MEMORY;
677 }
678 }
679
vn_async_vkCreateInstance(struct vn_instance * vn_instance,const VkInstanceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkInstance * pInstance)680 static inline void vn_async_vkCreateInstance(struct vn_instance *vn_instance, const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
681 {
682 struct vn_instance_submit_command submit;
683 vn_submit_vkCreateInstance(vn_instance, 0, pCreateInfo, pAllocator, pInstance, &submit);
684 }
685
vn_call_vkDestroyInstance(struct vn_instance * vn_instance,VkInstance instance,const VkAllocationCallbacks * pAllocator)686 static inline void vn_call_vkDestroyInstance(struct vn_instance *vn_instance, VkInstance instance, const VkAllocationCallbacks* pAllocator)
687 {
688 VN_TRACE_FUNC();
689
690 struct vn_instance_submit_command submit;
691 vn_submit_vkDestroyInstance(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, instance, pAllocator, &submit);
692 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
693 if (dec) {
694 vn_decode_vkDestroyInstance_reply(dec, instance, pAllocator);
695 vn_instance_free_command_reply(vn_instance, &submit);
696 }
697 }
698
vn_async_vkDestroyInstance(struct vn_instance * vn_instance,VkInstance instance,const VkAllocationCallbacks * pAllocator)699 static inline void vn_async_vkDestroyInstance(struct vn_instance *vn_instance, VkInstance instance, const VkAllocationCallbacks* pAllocator)
700 {
701 struct vn_instance_submit_command submit;
702 vn_submit_vkDestroyInstance(vn_instance, 0, instance, pAllocator, &submit);
703 }
704
vn_call_vkEnumerateInstanceVersion(struct vn_instance * vn_instance,uint32_t * pApiVersion)705 static inline VkResult vn_call_vkEnumerateInstanceVersion(struct vn_instance *vn_instance, uint32_t* pApiVersion)
706 {
707 VN_TRACE_FUNC();
708
709 struct vn_instance_submit_command submit;
710 vn_submit_vkEnumerateInstanceVersion(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, pApiVersion, &submit);
711 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
712 if (dec) {
713 const VkResult ret = vn_decode_vkEnumerateInstanceVersion_reply(dec, pApiVersion);
714 vn_instance_free_command_reply(vn_instance, &submit);
715 return ret;
716 } else {
717 return VK_ERROR_OUT_OF_HOST_MEMORY;
718 }
719 }
720
vn_async_vkEnumerateInstanceVersion(struct vn_instance * vn_instance,uint32_t * pApiVersion)721 static inline void vn_async_vkEnumerateInstanceVersion(struct vn_instance *vn_instance, uint32_t* pApiVersion)
722 {
723 struct vn_instance_submit_command submit;
724 vn_submit_vkEnumerateInstanceVersion(vn_instance, 0, pApiVersion, &submit);
725 }
726
vn_call_vkEnumerateInstanceLayerProperties(struct vn_instance * vn_instance,uint32_t * pPropertyCount,VkLayerProperties * pProperties)727 static inline VkResult vn_call_vkEnumerateInstanceLayerProperties(struct vn_instance *vn_instance, uint32_t* pPropertyCount, VkLayerProperties* pProperties)
728 {
729 VN_TRACE_FUNC();
730
731 struct vn_instance_submit_command submit;
732 vn_submit_vkEnumerateInstanceLayerProperties(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, pPropertyCount, pProperties, &submit);
733 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
734 if (dec) {
735 const VkResult ret = vn_decode_vkEnumerateInstanceLayerProperties_reply(dec, pPropertyCount, pProperties);
736 vn_instance_free_command_reply(vn_instance, &submit);
737 return ret;
738 } else {
739 return VK_ERROR_OUT_OF_HOST_MEMORY;
740 }
741 }
742
vn_async_vkEnumerateInstanceLayerProperties(struct vn_instance * vn_instance,uint32_t * pPropertyCount,VkLayerProperties * pProperties)743 static inline void vn_async_vkEnumerateInstanceLayerProperties(struct vn_instance *vn_instance, uint32_t* pPropertyCount, VkLayerProperties* pProperties)
744 {
745 struct vn_instance_submit_command submit;
746 vn_submit_vkEnumerateInstanceLayerProperties(vn_instance, 0, pPropertyCount, pProperties, &submit);
747 }
748
vn_call_vkEnumerateInstanceExtensionProperties(struct vn_instance * vn_instance,const char * pLayerName,uint32_t * pPropertyCount,VkExtensionProperties * pProperties)749 static inline VkResult vn_call_vkEnumerateInstanceExtensionProperties(struct vn_instance *vn_instance, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
750 {
751 VN_TRACE_FUNC();
752
753 struct vn_instance_submit_command submit;
754 vn_submit_vkEnumerateInstanceExtensionProperties(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, pLayerName, pPropertyCount, pProperties, &submit);
755 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
756 if (dec) {
757 const VkResult ret = vn_decode_vkEnumerateInstanceExtensionProperties_reply(dec, pLayerName, pPropertyCount, pProperties);
758 vn_instance_free_command_reply(vn_instance, &submit);
759 return ret;
760 } else {
761 return VK_ERROR_OUT_OF_HOST_MEMORY;
762 }
763 }
764
vn_async_vkEnumerateInstanceExtensionProperties(struct vn_instance * vn_instance,const char * pLayerName,uint32_t * pPropertyCount,VkExtensionProperties * pProperties)765 static inline void vn_async_vkEnumerateInstanceExtensionProperties(struct vn_instance *vn_instance, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
766 {
767 struct vn_instance_submit_command submit;
768 vn_submit_vkEnumerateInstanceExtensionProperties(vn_instance, 0, pLayerName, pPropertyCount, pProperties, &submit);
769 }
770
771 #endif /* VN_PROTOCOL_DRIVER_INSTANCE_H */
772