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_SEMAPHORE_H 9#define VN_PROTOCOL_DRIVER_SEMAPHORE_H 10 11#include "vn_instance.h" 12#include "vn_protocol_driver_structs.h" 13 14/* struct VkExportSemaphoreCreateInfo chain */ 15 16static inline size_t 17vn_sizeof_VkExportSemaphoreCreateInfo_pnext(const void *val) 18{ 19 /* no known/supported struct */ 20 return vn_sizeof_simple_pointer(NULL); 21} 22 23static inline size_t 24vn_sizeof_VkExportSemaphoreCreateInfo_self(const VkExportSemaphoreCreateInfo *val) 25{ 26 size_t size = 0; 27 /* skip val->{sType,pNext} */ 28 size += vn_sizeof_VkFlags(&val->handleTypes); 29 return size; 30} 31 32static inline size_t 33vn_sizeof_VkExportSemaphoreCreateInfo(const VkExportSemaphoreCreateInfo *val) 34{ 35 size_t size = 0; 36 37 size += vn_sizeof_VkStructureType(&val->sType); 38 size += vn_sizeof_VkExportSemaphoreCreateInfo_pnext(val->pNext); 39 size += vn_sizeof_VkExportSemaphoreCreateInfo_self(val); 40 41 return size; 42} 43 44static inline void 45vn_encode_VkExportSemaphoreCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val) 46{ 47 /* no known/supported struct */ 48 vn_encode_simple_pointer(enc, NULL); 49} 50 51static inline void 52vn_encode_VkExportSemaphoreCreateInfo_self(struct vn_cs_encoder *enc, const VkExportSemaphoreCreateInfo *val) 53{ 54 /* skip val->{sType,pNext} */ 55 vn_encode_VkFlags(enc, &val->handleTypes); 56} 57 58static inline void 59vn_encode_VkExportSemaphoreCreateInfo(struct vn_cs_encoder *enc, const VkExportSemaphoreCreateInfo *val) 60{ 61 assert(val->sType == VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO); 62 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO }); 63 vn_encode_VkExportSemaphoreCreateInfo_pnext(enc, val->pNext); 64 vn_encode_VkExportSemaphoreCreateInfo_self(enc, val); 65} 66 67/* struct VkSemaphoreCreateInfo chain */ 68 69static inline size_t 70vn_sizeof_VkSemaphoreCreateInfo_pnext(const void *val) 71{ 72 const VkBaseInStructure *pnext = val; 73 size_t size = 0; 74 75 while (pnext) { 76 switch ((int32_t)pnext->sType) { 77 case VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO: 78 size += vn_sizeof_simple_pointer(pnext); 79 size += vn_sizeof_VkStructureType(&pnext->sType); 80 size += vn_sizeof_VkSemaphoreCreateInfo_pnext(pnext->pNext); 81 size += vn_sizeof_VkExportSemaphoreCreateInfo_self((const VkExportSemaphoreCreateInfo *)pnext); 82 return size; 83 case VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO: 84 size += vn_sizeof_simple_pointer(pnext); 85 size += vn_sizeof_VkStructureType(&pnext->sType); 86 size += vn_sizeof_VkSemaphoreCreateInfo_pnext(pnext->pNext); 87 size += vn_sizeof_VkSemaphoreTypeCreateInfo_self((const VkSemaphoreTypeCreateInfo *)pnext); 88 return size; 89 default: 90 /* ignore unknown/unsupported struct */ 91 break; 92 } 93 pnext = pnext->pNext; 94 } 95 96 return vn_sizeof_simple_pointer(NULL); 97} 98 99static inline size_t 100vn_sizeof_VkSemaphoreCreateInfo_self(const VkSemaphoreCreateInfo *val) 101{ 102 size_t size = 0; 103 /* skip val->{sType,pNext} */ 104 size += vn_sizeof_VkFlags(&val->flags); 105 return size; 106} 107 108static inline size_t 109vn_sizeof_VkSemaphoreCreateInfo(const VkSemaphoreCreateInfo *val) 110{ 111 size_t size = 0; 112 113 size += vn_sizeof_VkStructureType(&val->sType); 114 size += vn_sizeof_VkSemaphoreCreateInfo_pnext(val->pNext); 115 size += vn_sizeof_VkSemaphoreCreateInfo_self(val); 116 117 return size; 118} 119 120static inline void 121vn_encode_VkSemaphoreCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val) 122{ 123 const VkBaseInStructure *pnext = val; 124 125 while (pnext) { 126 switch ((int32_t)pnext->sType) { 127 case VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO: 128 vn_encode_simple_pointer(enc, pnext); 129 vn_encode_VkStructureType(enc, &pnext->sType); 130 vn_encode_VkSemaphoreCreateInfo_pnext(enc, pnext->pNext); 131 vn_encode_VkExportSemaphoreCreateInfo_self(enc, (const VkExportSemaphoreCreateInfo *)pnext); 132 return; 133 case VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO: 134 vn_encode_simple_pointer(enc, pnext); 135 vn_encode_VkStructureType(enc, &pnext->sType); 136 vn_encode_VkSemaphoreCreateInfo_pnext(enc, pnext->pNext); 137 vn_encode_VkSemaphoreTypeCreateInfo_self(enc, (const VkSemaphoreTypeCreateInfo *)pnext); 138 return; 139 default: 140 /* ignore unknown/unsupported struct */ 141 break; 142 } 143 pnext = pnext->pNext; 144 } 145 146 vn_encode_simple_pointer(enc, NULL); 147} 148 149static inline void 150vn_encode_VkSemaphoreCreateInfo_self(struct vn_cs_encoder *enc, const VkSemaphoreCreateInfo *val) 151{ 152 /* skip val->{sType,pNext} */ 153 vn_encode_VkFlags(enc, &val->flags); 154} 155 156static inline void 157vn_encode_VkSemaphoreCreateInfo(struct vn_cs_encoder *enc, const VkSemaphoreCreateInfo *val) 158{ 159 assert(val->sType == VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO); 160 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }); 161 vn_encode_VkSemaphoreCreateInfo_pnext(enc, val->pNext); 162 vn_encode_VkSemaphoreCreateInfo_self(enc, val); 163} 164 165/* struct VkSemaphoreWaitInfo chain */ 166 167static inline size_t 168vn_sizeof_VkSemaphoreWaitInfo_pnext(const void *val) 169{ 170 /* no known/supported struct */ 171 return vn_sizeof_simple_pointer(NULL); 172} 173 174static inline size_t 175vn_sizeof_VkSemaphoreWaitInfo_self(const VkSemaphoreWaitInfo *val) 176{ 177 size_t size = 0; 178 /* skip val->{sType,pNext} */ 179 size += vn_sizeof_VkFlags(&val->flags); 180 size += vn_sizeof_uint32_t(&val->semaphoreCount); 181 if (val->pSemaphores) { 182 size += vn_sizeof_array_size(val->semaphoreCount); 183 for (uint32_t i = 0; i < val->semaphoreCount; i++) 184 size += vn_sizeof_VkSemaphore(&val->pSemaphores[i]); 185 } else { 186 size += vn_sizeof_array_size(0); 187 } 188 if (val->pValues) { 189 size += vn_sizeof_array_size(val->semaphoreCount); 190 size += vn_sizeof_uint64_t_array(val->pValues, val->semaphoreCount); 191 } else { 192 size += vn_sizeof_array_size(0); 193 } 194 return size; 195} 196 197static inline size_t 198vn_sizeof_VkSemaphoreWaitInfo(const VkSemaphoreWaitInfo *val) 199{ 200 size_t size = 0; 201 202 size += vn_sizeof_VkStructureType(&val->sType); 203 size += vn_sizeof_VkSemaphoreWaitInfo_pnext(val->pNext); 204 size += vn_sizeof_VkSemaphoreWaitInfo_self(val); 205 206 return size; 207} 208 209static inline void 210vn_encode_VkSemaphoreWaitInfo_pnext(struct vn_cs_encoder *enc, const void *val) 211{ 212 /* no known/supported struct */ 213 vn_encode_simple_pointer(enc, NULL); 214} 215 216static inline void 217vn_encode_VkSemaphoreWaitInfo_self(struct vn_cs_encoder *enc, const VkSemaphoreWaitInfo *val) 218{ 219 /* skip val->{sType,pNext} */ 220 vn_encode_VkFlags(enc, &val->flags); 221 vn_encode_uint32_t(enc, &val->semaphoreCount); 222 if (val->pSemaphores) { 223 vn_encode_array_size(enc, val->semaphoreCount); 224 for (uint32_t i = 0; i < val->semaphoreCount; i++) 225 vn_encode_VkSemaphore(enc, &val->pSemaphores[i]); 226 } else { 227 vn_encode_array_size(enc, 0); 228 } 229 if (val->pValues) { 230 vn_encode_array_size(enc, val->semaphoreCount); 231 vn_encode_uint64_t_array(enc, val->pValues, val->semaphoreCount); 232 } else { 233 vn_encode_array_size(enc, 0); 234 } 235} 236 237static inline void 238vn_encode_VkSemaphoreWaitInfo(struct vn_cs_encoder *enc, const VkSemaphoreWaitInfo *val) 239{ 240 assert(val->sType == VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO); 241 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO }); 242 vn_encode_VkSemaphoreWaitInfo_pnext(enc, val->pNext); 243 vn_encode_VkSemaphoreWaitInfo_self(enc, val); 244} 245 246/* struct VkSemaphoreSignalInfo chain */ 247 248static inline size_t 249vn_sizeof_VkSemaphoreSignalInfo_pnext(const void *val) 250{ 251 /* no known/supported struct */ 252 return vn_sizeof_simple_pointer(NULL); 253} 254 255static inline size_t 256vn_sizeof_VkSemaphoreSignalInfo_self(const VkSemaphoreSignalInfo *val) 257{ 258 size_t size = 0; 259 /* skip val->{sType,pNext} */ 260 size += vn_sizeof_VkSemaphore(&val->semaphore); 261 size += vn_sizeof_uint64_t(&val->value); 262 return size; 263} 264 265static inline size_t 266vn_sizeof_VkSemaphoreSignalInfo(const VkSemaphoreSignalInfo *val) 267{ 268 size_t size = 0; 269 270 size += vn_sizeof_VkStructureType(&val->sType); 271 size += vn_sizeof_VkSemaphoreSignalInfo_pnext(val->pNext); 272 size += vn_sizeof_VkSemaphoreSignalInfo_self(val); 273 274 return size; 275} 276 277static inline void 278vn_encode_VkSemaphoreSignalInfo_pnext(struct vn_cs_encoder *enc, const void *val) 279{ 280 /* no known/supported struct */ 281 vn_encode_simple_pointer(enc, NULL); 282} 283 284static inline void 285vn_encode_VkSemaphoreSignalInfo_self(struct vn_cs_encoder *enc, const VkSemaphoreSignalInfo *val) 286{ 287 /* skip val->{sType,pNext} */ 288 vn_encode_VkSemaphore(enc, &val->semaphore); 289 vn_encode_uint64_t(enc, &val->value); 290} 291 292static inline void 293vn_encode_VkSemaphoreSignalInfo(struct vn_cs_encoder *enc, const VkSemaphoreSignalInfo *val) 294{ 295 assert(val->sType == VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO); 296 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO }); 297 vn_encode_VkSemaphoreSignalInfo_pnext(enc, val->pNext); 298 vn_encode_VkSemaphoreSignalInfo_self(enc, val); 299} 300 301static inline void 302vn_decode_VkSemaphoreSignalInfo_pnext(struct vn_cs_decoder *dec, const void *val) 303{ 304 /* no known/supported struct */ 305 if (vn_decode_simple_pointer(dec)) 306 assert(false); 307} 308 309static inline void 310vn_decode_VkSemaphoreSignalInfo_self(struct vn_cs_decoder *dec, VkSemaphoreSignalInfo *val) 311{ 312 /* skip val->{sType,pNext} */ 313 vn_decode_VkSemaphore(dec, &val->semaphore); 314 vn_decode_uint64_t(dec, &val->value); 315} 316 317static inline void 318vn_decode_VkSemaphoreSignalInfo(struct vn_cs_decoder *dec, VkSemaphoreSignalInfo *val) 319{ 320 VkStructureType stype; 321 vn_decode_VkStructureType(dec, &stype); 322 assert(stype == VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO); 323 324 assert(val->sType == stype); 325 vn_decode_VkSemaphoreSignalInfo_pnext(dec, val->pNext); 326 vn_decode_VkSemaphoreSignalInfo_self(dec, val); 327} 328 329static inline size_t vn_sizeof_vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore) 330{ 331 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSemaphore_EXT; 332 const VkFlags cmd_flags = 0; 333 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 334 335 cmd_size += vn_sizeof_VkDevice(&device); 336 cmd_size += vn_sizeof_simple_pointer(pCreateInfo); 337 if (pCreateInfo) 338 cmd_size += vn_sizeof_VkSemaphoreCreateInfo(pCreateInfo); 339 cmd_size += vn_sizeof_simple_pointer(pAllocator); 340 if (pAllocator) 341 assert(false); 342 cmd_size += vn_sizeof_simple_pointer(pSemaphore); 343 if (pSemaphore) 344 cmd_size += vn_sizeof_VkSemaphore(pSemaphore); 345 346 return cmd_size; 347} 348 349static inline void vn_encode_vkCreateSemaphore(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore) 350{ 351 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSemaphore_EXT; 352 353 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 354 vn_encode_VkFlags(enc, &cmd_flags); 355 356 vn_encode_VkDevice(enc, &device); 357 if (vn_encode_simple_pointer(enc, pCreateInfo)) 358 vn_encode_VkSemaphoreCreateInfo(enc, pCreateInfo); 359 if (vn_encode_simple_pointer(enc, pAllocator)) 360 assert(false); 361 if (vn_encode_simple_pointer(enc, pSemaphore)) 362 vn_encode_VkSemaphore(enc, pSemaphore); 363} 364 365static inline size_t vn_sizeof_vkCreateSemaphore_reply(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore) 366{ 367 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSemaphore_EXT; 368 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 369 370 VkResult ret; 371 cmd_size += vn_sizeof_VkResult(&ret); 372 /* skip device */ 373 /* skip pCreateInfo */ 374 /* skip pAllocator */ 375 cmd_size += vn_sizeof_simple_pointer(pSemaphore); 376 if (pSemaphore) 377 cmd_size += vn_sizeof_VkSemaphore(pSemaphore); 378 379 return cmd_size; 380} 381 382static inline VkResult vn_decode_vkCreateSemaphore_reply(struct vn_cs_decoder *dec, VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore) 383{ 384 VkCommandTypeEXT command_type; 385 vn_decode_VkCommandTypeEXT(dec, &command_type); 386 assert(command_type == VK_COMMAND_TYPE_vkCreateSemaphore_EXT); 387 388 VkResult ret; 389 vn_decode_VkResult(dec, &ret); 390 /* skip device */ 391 /* skip pCreateInfo */ 392 /* skip pAllocator */ 393 if (vn_decode_simple_pointer(dec)) { 394 vn_decode_VkSemaphore(dec, pSemaphore); 395 } else { 396 pSemaphore = NULL; 397 } 398 399 return ret; 400} 401 402static inline size_t vn_sizeof_vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) 403{ 404 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySemaphore_EXT; 405 const VkFlags cmd_flags = 0; 406 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 407 408 cmd_size += vn_sizeof_VkDevice(&device); 409 cmd_size += vn_sizeof_VkSemaphore(&semaphore); 410 cmd_size += vn_sizeof_simple_pointer(pAllocator); 411 if (pAllocator) 412 assert(false); 413 414 return cmd_size; 415} 416 417static inline void vn_encode_vkDestroySemaphore(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) 418{ 419 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySemaphore_EXT; 420 421 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 422 vn_encode_VkFlags(enc, &cmd_flags); 423 424 vn_encode_VkDevice(enc, &device); 425 vn_encode_VkSemaphore(enc, &semaphore); 426 if (vn_encode_simple_pointer(enc, pAllocator)) 427 assert(false); 428} 429 430static inline size_t vn_sizeof_vkDestroySemaphore_reply(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) 431{ 432 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySemaphore_EXT; 433 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 434 435 /* skip device */ 436 /* skip semaphore */ 437 /* skip pAllocator */ 438 439 return cmd_size; 440} 441 442static inline void vn_decode_vkDestroySemaphore_reply(struct vn_cs_decoder *dec, VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) 443{ 444 VkCommandTypeEXT command_type; 445 vn_decode_VkCommandTypeEXT(dec, &command_type); 446 assert(command_type == VK_COMMAND_TYPE_vkDestroySemaphore_EXT); 447 448 /* skip device */ 449 /* skip semaphore */ 450 /* skip pAllocator */ 451} 452 453static inline size_t vn_sizeof_vkGetSemaphoreCounterValue(VkDevice device, VkSemaphore semaphore, uint64_t* pValue) 454{ 455 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkGetSemaphoreCounterValue_EXT; 456 const VkFlags cmd_flags = 0; 457 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 458 459 cmd_size += vn_sizeof_VkDevice(&device); 460 cmd_size += vn_sizeof_VkSemaphore(&semaphore); 461 cmd_size += vn_sizeof_simple_pointer(pValue); /* out */ 462 463 return cmd_size; 464} 465 466static inline void vn_encode_vkGetSemaphoreCounterValue(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSemaphore semaphore, uint64_t* pValue) 467{ 468 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkGetSemaphoreCounterValue_EXT; 469 470 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 471 vn_encode_VkFlags(enc, &cmd_flags); 472 473 vn_encode_VkDevice(enc, &device); 474 vn_encode_VkSemaphore(enc, &semaphore); 475 vn_encode_simple_pointer(enc, pValue); /* out */ 476} 477 478static inline size_t vn_sizeof_vkGetSemaphoreCounterValue_reply(VkDevice device, VkSemaphore semaphore, uint64_t* pValue) 479{ 480 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkGetSemaphoreCounterValue_EXT; 481 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 482 483 VkResult ret; 484 cmd_size += vn_sizeof_VkResult(&ret); 485 /* skip device */ 486 /* skip semaphore */ 487 cmd_size += vn_sizeof_simple_pointer(pValue); 488 if (pValue) 489 cmd_size += vn_sizeof_uint64_t(pValue); 490 491 return cmd_size; 492} 493 494static inline VkResult vn_decode_vkGetSemaphoreCounterValue_reply(struct vn_cs_decoder *dec, VkDevice device, VkSemaphore semaphore, uint64_t* pValue) 495{ 496 VkCommandTypeEXT command_type; 497 vn_decode_VkCommandTypeEXT(dec, &command_type); 498 assert(command_type == VK_COMMAND_TYPE_vkGetSemaphoreCounterValue_EXT); 499 500 VkResult ret; 501 vn_decode_VkResult(dec, &ret); 502 /* skip device */ 503 /* skip semaphore */ 504 if (vn_decode_simple_pointer(dec)) { 505 vn_decode_uint64_t(dec, pValue); 506 } else { 507 pValue = NULL; 508 } 509 510 return ret; 511} 512 513static inline size_t vn_sizeof_vkWaitSemaphores(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout) 514{ 515 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkWaitSemaphores_EXT; 516 const VkFlags cmd_flags = 0; 517 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 518 519 cmd_size += vn_sizeof_VkDevice(&device); 520 cmd_size += vn_sizeof_simple_pointer(pWaitInfo); 521 if (pWaitInfo) 522 cmd_size += vn_sizeof_VkSemaphoreWaitInfo(pWaitInfo); 523 cmd_size += vn_sizeof_uint64_t(&timeout); 524 525 return cmd_size; 526} 527 528static inline void vn_encode_vkWaitSemaphores(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout) 529{ 530 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkWaitSemaphores_EXT; 531 532 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 533 vn_encode_VkFlags(enc, &cmd_flags); 534 535 vn_encode_VkDevice(enc, &device); 536 if (vn_encode_simple_pointer(enc, pWaitInfo)) 537 vn_encode_VkSemaphoreWaitInfo(enc, pWaitInfo); 538 vn_encode_uint64_t(enc, &timeout); 539} 540 541static inline size_t vn_sizeof_vkWaitSemaphores_reply(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout) 542{ 543 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkWaitSemaphores_EXT; 544 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 545 546 VkResult ret; 547 cmd_size += vn_sizeof_VkResult(&ret); 548 /* skip device */ 549 /* skip pWaitInfo */ 550 /* skip timeout */ 551 552 return cmd_size; 553} 554 555static inline VkResult vn_decode_vkWaitSemaphores_reply(struct vn_cs_decoder *dec, VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout) 556{ 557 VkCommandTypeEXT command_type; 558 vn_decode_VkCommandTypeEXT(dec, &command_type); 559 assert(command_type == VK_COMMAND_TYPE_vkWaitSemaphores_EXT); 560 561 VkResult ret; 562 vn_decode_VkResult(dec, &ret); 563 /* skip device */ 564 /* skip pWaitInfo */ 565 /* skip timeout */ 566 567 return ret; 568} 569 570static inline size_t vn_sizeof_vkSignalSemaphore(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo) 571{ 572 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkSignalSemaphore_EXT; 573 const VkFlags cmd_flags = 0; 574 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 575 576 cmd_size += vn_sizeof_VkDevice(&device); 577 cmd_size += vn_sizeof_simple_pointer(pSignalInfo); 578 if (pSignalInfo) 579 cmd_size += vn_sizeof_VkSemaphoreSignalInfo(pSignalInfo); 580 581 return cmd_size; 582} 583 584static inline void vn_encode_vkSignalSemaphore(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo) 585{ 586 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkSignalSemaphore_EXT; 587 588 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 589 vn_encode_VkFlags(enc, &cmd_flags); 590 591 vn_encode_VkDevice(enc, &device); 592 if (vn_encode_simple_pointer(enc, pSignalInfo)) 593 vn_encode_VkSemaphoreSignalInfo(enc, pSignalInfo); 594} 595 596static inline size_t vn_sizeof_vkSignalSemaphore_reply(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo) 597{ 598 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkSignalSemaphore_EXT; 599 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 600 601 VkResult ret; 602 cmd_size += vn_sizeof_VkResult(&ret); 603 /* skip device */ 604 /* skip pSignalInfo */ 605 606 return cmd_size; 607} 608 609static inline VkResult vn_decode_vkSignalSemaphore_reply(struct vn_cs_decoder *dec, VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo) 610{ 611 VkCommandTypeEXT command_type; 612 vn_decode_VkCommandTypeEXT(dec, &command_type); 613 assert(command_type == VK_COMMAND_TYPE_vkSignalSemaphore_EXT); 614 615 VkResult ret; 616 vn_decode_VkResult(dec, &ret); 617 /* skip device */ 618 /* skip pSignalInfo */ 619 620 return ret; 621} 622 623static inline void vn_submit_vkCreateSemaphore(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore, struct vn_instance_submit_command *submit) 624{ 625 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 626 void *cmd_data = local_cmd_data; 627 size_t cmd_size = vn_sizeof_vkCreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore); 628 if (cmd_size > sizeof(local_cmd_data)) { 629 cmd_data = malloc(cmd_size); 630 if (!cmd_data) 631 cmd_size = 0; 632 } 633 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateSemaphore_reply(device, pCreateInfo, pAllocator, pSemaphore) : 0; 634 635 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 636 if (cmd_size) { 637 vn_encode_vkCreateSemaphore(enc, cmd_flags, device, pCreateInfo, pAllocator, pSemaphore); 638 vn_instance_submit_command(vn_instance, submit); 639 if (cmd_data != local_cmd_data) 640 free(cmd_data); 641 } 642} 643 644static inline void vn_submit_vkDestroySemaphore(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit) 645{ 646 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 647 void *cmd_data = local_cmd_data; 648 size_t cmd_size = vn_sizeof_vkDestroySemaphore(device, semaphore, pAllocator); 649 if (cmd_size > sizeof(local_cmd_data)) { 650 cmd_data = malloc(cmd_size); 651 if (!cmd_data) 652 cmd_size = 0; 653 } 654 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroySemaphore_reply(device, semaphore, pAllocator) : 0; 655 656 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 657 if (cmd_size) { 658 vn_encode_vkDestroySemaphore(enc, cmd_flags, device, semaphore, pAllocator); 659 vn_instance_submit_command(vn_instance, submit); 660 if (cmd_data != local_cmd_data) 661 free(cmd_data); 662 } 663} 664 665static inline void vn_submit_vkGetSemaphoreCounterValue(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSemaphore semaphore, uint64_t* pValue, struct vn_instance_submit_command *submit) 666{ 667 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 668 void *cmd_data = local_cmd_data; 669 size_t cmd_size = vn_sizeof_vkGetSemaphoreCounterValue(device, semaphore, pValue); 670 if (cmd_size > sizeof(local_cmd_data)) { 671 cmd_data = malloc(cmd_size); 672 if (!cmd_data) 673 cmd_size = 0; 674 } 675 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkGetSemaphoreCounterValue_reply(device, semaphore, pValue) : 0; 676 677 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 678 if (cmd_size) { 679 vn_encode_vkGetSemaphoreCounterValue(enc, cmd_flags, device, semaphore, pValue); 680 vn_instance_submit_command(vn_instance, submit); 681 if (cmd_data != local_cmd_data) 682 free(cmd_data); 683 } 684} 685 686static inline void vn_submit_vkWaitSemaphores(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout, struct vn_instance_submit_command *submit) 687{ 688 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 689 void *cmd_data = local_cmd_data; 690 size_t cmd_size = vn_sizeof_vkWaitSemaphores(device, pWaitInfo, timeout); 691 if (cmd_size > sizeof(local_cmd_data)) { 692 cmd_data = malloc(cmd_size); 693 if (!cmd_data) 694 cmd_size = 0; 695 } 696 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkWaitSemaphores_reply(device, pWaitInfo, timeout) : 0; 697 698 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 699 if (cmd_size) { 700 vn_encode_vkWaitSemaphores(enc, cmd_flags, device, pWaitInfo, timeout); 701 vn_instance_submit_command(vn_instance, submit); 702 if (cmd_data != local_cmd_data) 703 free(cmd_data); 704 } 705} 706 707static inline void vn_submit_vkSignalSemaphore(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo, struct vn_instance_submit_command *submit) 708{ 709 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 710 void *cmd_data = local_cmd_data; 711 size_t cmd_size = vn_sizeof_vkSignalSemaphore(device, pSignalInfo); 712 if (cmd_size > sizeof(local_cmd_data)) { 713 cmd_data = malloc(cmd_size); 714 if (!cmd_data) 715 cmd_size = 0; 716 } 717 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkSignalSemaphore_reply(device, pSignalInfo) : 0; 718 719 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 720 if (cmd_size) { 721 vn_encode_vkSignalSemaphore(enc, cmd_flags, device, pSignalInfo); 722 vn_instance_submit_command(vn_instance, submit); 723 if (cmd_data != local_cmd_data) 724 free(cmd_data); 725 } 726} 727 728static inline VkResult vn_call_vkCreateSemaphore(struct vn_instance *vn_instance, VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore) 729{ 730 VN_TRACE_FUNC(); 731 732 struct vn_instance_submit_command submit; 733 vn_submit_vkCreateSemaphore(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pSemaphore, &submit); 734 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 735 if (dec) { 736 const VkResult ret = vn_decode_vkCreateSemaphore_reply(dec, device, pCreateInfo, pAllocator, pSemaphore); 737 vn_instance_free_command_reply(vn_instance, &submit); 738 return ret; 739 } else { 740 return VK_ERROR_OUT_OF_HOST_MEMORY; 741 } 742} 743 744static inline void vn_async_vkCreateSemaphore(struct vn_instance *vn_instance, VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore) 745{ 746 struct vn_instance_submit_command submit; 747 vn_submit_vkCreateSemaphore(vn_instance, 0, device, pCreateInfo, pAllocator, pSemaphore, &submit); 748} 749 750static inline void vn_call_vkDestroySemaphore(struct vn_instance *vn_instance, VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) 751{ 752 VN_TRACE_FUNC(); 753 754 struct vn_instance_submit_command submit; 755 vn_submit_vkDestroySemaphore(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, semaphore, pAllocator, &submit); 756 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 757 if (dec) { 758 vn_decode_vkDestroySemaphore_reply(dec, device, semaphore, pAllocator); 759 vn_instance_free_command_reply(vn_instance, &submit); 760 } 761} 762 763static inline void vn_async_vkDestroySemaphore(struct vn_instance *vn_instance, VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator) 764{ 765 struct vn_instance_submit_command submit; 766 vn_submit_vkDestroySemaphore(vn_instance, 0, device, semaphore, pAllocator, &submit); 767} 768 769static inline VkResult vn_call_vkGetSemaphoreCounterValue(struct vn_instance *vn_instance, VkDevice device, VkSemaphore semaphore, uint64_t* pValue) 770{ 771 VN_TRACE_FUNC(); 772 773 struct vn_instance_submit_command submit; 774 vn_submit_vkGetSemaphoreCounterValue(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, semaphore, pValue, &submit); 775 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 776 if (dec) { 777 const VkResult ret = vn_decode_vkGetSemaphoreCounterValue_reply(dec, device, semaphore, pValue); 778 vn_instance_free_command_reply(vn_instance, &submit); 779 return ret; 780 } else { 781 return VK_ERROR_OUT_OF_HOST_MEMORY; 782 } 783} 784 785static inline void vn_async_vkGetSemaphoreCounterValue(struct vn_instance *vn_instance, VkDevice device, VkSemaphore semaphore, uint64_t* pValue) 786{ 787 struct vn_instance_submit_command submit; 788 vn_submit_vkGetSemaphoreCounterValue(vn_instance, 0, device, semaphore, pValue, &submit); 789} 790 791static inline VkResult vn_call_vkWaitSemaphores(struct vn_instance *vn_instance, VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout) 792{ 793 VN_TRACE_FUNC(); 794 795 struct vn_instance_submit_command submit; 796 vn_submit_vkWaitSemaphores(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pWaitInfo, timeout, &submit); 797 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 798 if (dec) { 799 const VkResult ret = vn_decode_vkWaitSemaphores_reply(dec, device, pWaitInfo, timeout); 800 vn_instance_free_command_reply(vn_instance, &submit); 801 return ret; 802 } else { 803 return VK_ERROR_OUT_OF_HOST_MEMORY; 804 } 805} 806 807static inline void vn_async_vkWaitSemaphores(struct vn_instance *vn_instance, VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout) 808{ 809 struct vn_instance_submit_command submit; 810 vn_submit_vkWaitSemaphores(vn_instance, 0, device, pWaitInfo, timeout, &submit); 811} 812 813static inline VkResult vn_call_vkSignalSemaphore(struct vn_instance *vn_instance, VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo) 814{ 815 VN_TRACE_FUNC(); 816 817 struct vn_instance_submit_command submit; 818 vn_submit_vkSignalSemaphore(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pSignalInfo, &submit); 819 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 820 if (dec) { 821 const VkResult ret = vn_decode_vkSignalSemaphore_reply(dec, device, pSignalInfo); 822 vn_instance_free_command_reply(vn_instance, &submit); 823 return ret; 824 } else { 825 return VK_ERROR_OUT_OF_HOST_MEMORY; 826 } 827} 828 829static inline void vn_async_vkSignalSemaphore(struct vn_instance *vn_instance, VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo) 830{ 831 struct vn_instance_submit_command submit; 832 vn_submit_vkSignalSemaphore(vn_instance, 0, device, pSignalInfo, &submit); 833} 834 835#endif /* VN_PROTOCOL_DRIVER_SEMAPHORE_H */ 836