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_COMMAND_POOL_H 9#define VN_PROTOCOL_DRIVER_COMMAND_POOL_H 10 11#include "vn_instance.h" 12#include "vn_protocol_driver_structs.h" 13 14/* struct VkCommandPoolCreateInfo chain */ 15 16static inline size_t 17vn_sizeof_VkCommandPoolCreateInfo_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_VkCommandPoolCreateInfo_self(const VkCommandPoolCreateInfo *val) 25{ 26 size_t size = 0; 27 /* skip val->{sType,pNext} */ 28 size += vn_sizeof_VkFlags(&val->flags); 29 size += vn_sizeof_uint32_t(&val->queueFamilyIndex); 30 return size; 31} 32 33static inline size_t 34vn_sizeof_VkCommandPoolCreateInfo(const VkCommandPoolCreateInfo *val) 35{ 36 size_t size = 0; 37 38 size += vn_sizeof_VkStructureType(&val->sType); 39 size += vn_sizeof_VkCommandPoolCreateInfo_pnext(val->pNext); 40 size += vn_sizeof_VkCommandPoolCreateInfo_self(val); 41 42 return size; 43} 44 45static inline void 46vn_encode_VkCommandPoolCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val) 47{ 48 /* no known/supported struct */ 49 vn_encode_simple_pointer(enc, NULL); 50} 51 52static inline void 53vn_encode_VkCommandPoolCreateInfo_self(struct vn_cs_encoder *enc, const VkCommandPoolCreateInfo *val) 54{ 55 /* skip val->{sType,pNext} */ 56 vn_encode_VkFlags(enc, &val->flags); 57 vn_encode_uint32_t(enc, &val->queueFamilyIndex); 58} 59 60static inline void 61vn_encode_VkCommandPoolCreateInfo(struct vn_cs_encoder *enc, const VkCommandPoolCreateInfo *val) 62{ 63 assert(val->sType == VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO); 64 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }); 65 vn_encode_VkCommandPoolCreateInfo_pnext(enc, val->pNext); 66 vn_encode_VkCommandPoolCreateInfo_self(enc, val); 67} 68 69static inline size_t vn_sizeof_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) 70{ 71 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateCommandPool_EXT; 72 const VkFlags cmd_flags = 0; 73 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 74 75 cmd_size += vn_sizeof_VkDevice(&device); 76 cmd_size += vn_sizeof_simple_pointer(pCreateInfo); 77 if (pCreateInfo) 78 cmd_size += vn_sizeof_VkCommandPoolCreateInfo(pCreateInfo); 79 cmd_size += vn_sizeof_simple_pointer(pAllocator); 80 if (pAllocator) 81 assert(false); 82 cmd_size += vn_sizeof_simple_pointer(pCommandPool); 83 if (pCommandPool) 84 cmd_size += vn_sizeof_VkCommandPool(pCommandPool); 85 86 return cmd_size; 87} 88 89static inline void vn_encode_vkCreateCommandPool(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) 90{ 91 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateCommandPool_EXT; 92 93 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 94 vn_encode_VkFlags(enc, &cmd_flags); 95 96 vn_encode_VkDevice(enc, &device); 97 if (vn_encode_simple_pointer(enc, pCreateInfo)) 98 vn_encode_VkCommandPoolCreateInfo(enc, pCreateInfo); 99 if (vn_encode_simple_pointer(enc, pAllocator)) 100 assert(false); 101 if (vn_encode_simple_pointer(enc, pCommandPool)) 102 vn_encode_VkCommandPool(enc, pCommandPool); 103} 104 105static inline size_t vn_sizeof_vkCreateCommandPool_reply(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) 106{ 107 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateCommandPool_EXT; 108 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 109 110 VkResult ret; 111 cmd_size += vn_sizeof_VkResult(&ret); 112 /* skip device */ 113 /* skip pCreateInfo */ 114 /* skip pAllocator */ 115 cmd_size += vn_sizeof_simple_pointer(pCommandPool); 116 if (pCommandPool) 117 cmd_size += vn_sizeof_VkCommandPool(pCommandPool); 118 119 return cmd_size; 120} 121 122static inline VkResult vn_decode_vkCreateCommandPool_reply(struct vn_cs_decoder *dec, VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) 123{ 124 VkCommandTypeEXT command_type; 125 vn_decode_VkCommandTypeEXT(dec, &command_type); 126 assert(command_type == VK_COMMAND_TYPE_vkCreateCommandPool_EXT); 127 128 VkResult ret; 129 vn_decode_VkResult(dec, &ret); 130 /* skip device */ 131 /* skip pCreateInfo */ 132 /* skip pAllocator */ 133 if (vn_decode_simple_pointer(dec)) { 134 vn_decode_VkCommandPool(dec, pCommandPool); 135 } else { 136 pCommandPool = NULL; 137 } 138 139 return ret; 140} 141 142static inline size_t vn_sizeof_vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator) 143{ 144 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyCommandPool_EXT; 145 const VkFlags cmd_flags = 0; 146 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 147 148 cmd_size += vn_sizeof_VkDevice(&device); 149 cmd_size += vn_sizeof_VkCommandPool(&commandPool); 150 cmd_size += vn_sizeof_simple_pointer(pAllocator); 151 if (pAllocator) 152 assert(false); 153 154 return cmd_size; 155} 156 157static inline void vn_encode_vkDestroyCommandPool(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator) 158{ 159 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyCommandPool_EXT; 160 161 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 162 vn_encode_VkFlags(enc, &cmd_flags); 163 164 vn_encode_VkDevice(enc, &device); 165 vn_encode_VkCommandPool(enc, &commandPool); 166 if (vn_encode_simple_pointer(enc, pAllocator)) 167 assert(false); 168} 169 170static inline size_t vn_sizeof_vkDestroyCommandPool_reply(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator) 171{ 172 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyCommandPool_EXT; 173 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 174 175 /* skip device */ 176 /* skip commandPool */ 177 /* skip pAllocator */ 178 179 return cmd_size; 180} 181 182static inline void vn_decode_vkDestroyCommandPool_reply(struct vn_cs_decoder *dec, VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator) 183{ 184 VkCommandTypeEXT command_type; 185 vn_decode_VkCommandTypeEXT(dec, &command_type); 186 assert(command_type == VK_COMMAND_TYPE_vkDestroyCommandPool_EXT); 187 188 /* skip device */ 189 /* skip commandPool */ 190 /* skip pAllocator */ 191} 192 193static inline size_t vn_sizeof_vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) 194{ 195 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkResetCommandPool_EXT; 196 const VkFlags cmd_flags = 0; 197 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 198 199 cmd_size += vn_sizeof_VkDevice(&device); 200 cmd_size += vn_sizeof_VkCommandPool(&commandPool); 201 cmd_size += vn_sizeof_VkFlags(&flags); 202 203 return cmd_size; 204} 205 206static inline void vn_encode_vkResetCommandPool(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) 207{ 208 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkResetCommandPool_EXT; 209 210 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 211 vn_encode_VkFlags(enc, &cmd_flags); 212 213 vn_encode_VkDevice(enc, &device); 214 vn_encode_VkCommandPool(enc, &commandPool); 215 vn_encode_VkFlags(enc, &flags); 216} 217 218static inline size_t vn_sizeof_vkResetCommandPool_reply(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) 219{ 220 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkResetCommandPool_EXT; 221 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 222 223 VkResult ret; 224 cmd_size += vn_sizeof_VkResult(&ret); 225 /* skip device */ 226 /* skip commandPool */ 227 /* skip flags */ 228 229 return cmd_size; 230} 231 232static inline VkResult vn_decode_vkResetCommandPool_reply(struct vn_cs_decoder *dec, VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) 233{ 234 VkCommandTypeEXT command_type; 235 vn_decode_VkCommandTypeEXT(dec, &command_type); 236 assert(command_type == VK_COMMAND_TYPE_vkResetCommandPool_EXT); 237 238 VkResult ret; 239 vn_decode_VkResult(dec, &ret); 240 /* skip device */ 241 /* skip commandPool */ 242 /* skip flags */ 243 244 return ret; 245} 246 247static inline size_t vn_sizeof_vkTrimCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags) 248{ 249 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkTrimCommandPool_EXT; 250 const VkFlags cmd_flags = 0; 251 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 252 253 cmd_size += vn_sizeof_VkDevice(&device); 254 cmd_size += vn_sizeof_VkCommandPool(&commandPool); 255 cmd_size += vn_sizeof_VkFlags(&flags); 256 257 return cmd_size; 258} 259 260static inline void vn_encode_vkTrimCommandPool(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags) 261{ 262 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkTrimCommandPool_EXT; 263 264 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 265 vn_encode_VkFlags(enc, &cmd_flags); 266 267 vn_encode_VkDevice(enc, &device); 268 vn_encode_VkCommandPool(enc, &commandPool); 269 vn_encode_VkFlags(enc, &flags); 270} 271 272static inline size_t vn_sizeof_vkTrimCommandPool_reply(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags) 273{ 274 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkTrimCommandPool_EXT; 275 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 276 277 /* skip device */ 278 /* skip commandPool */ 279 /* skip flags */ 280 281 return cmd_size; 282} 283 284static inline void vn_decode_vkTrimCommandPool_reply(struct vn_cs_decoder *dec, VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags) 285{ 286 VkCommandTypeEXT command_type; 287 vn_decode_VkCommandTypeEXT(dec, &command_type); 288 assert(command_type == VK_COMMAND_TYPE_vkTrimCommandPool_EXT); 289 290 /* skip device */ 291 /* skip commandPool */ 292 /* skip flags */ 293} 294 295static inline void vn_submit_vkCreateCommandPool(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool, struct vn_instance_submit_command *submit) 296{ 297 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 298 void *cmd_data = local_cmd_data; 299 size_t cmd_size = vn_sizeof_vkCreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); 300 if (cmd_size > sizeof(local_cmd_data)) { 301 cmd_data = malloc(cmd_size); 302 if (!cmd_data) 303 cmd_size = 0; 304 } 305 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateCommandPool_reply(device, pCreateInfo, pAllocator, pCommandPool) : 0; 306 307 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 308 if (cmd_size) { 309 vn_encode_vkCreateCommandPool(enc, cmd_flags, device, pCreateInfo, pAllocator, pCommandPool); 310 vn_instance_submit_command(vn_instance, submit); 311 if (cmd_data != local_cmd_data) 312 free(cmd_data); 313 } 314} 315 316static inline void vn_submit_vkDestroyCommandPool(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit) 317{ 318 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 319 void *cmd_data = local_cmd_data; 320 size_t cmd_size = vn_sizeof_vkDestroyCommandPool(device, commandPool, pAllocator); 321 if (cmd_size > sizeof(local_cmd_data)) { 322 cmd_data = malloc(cmd_size); 323 if (!cmd_data) 324 cmd_size = 0; 325 } 326 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyCommandPool_reply(device, commandPool, pAllocator) : 0; 327 328 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 329 if (cmd_size) { 330 vn_encode_vkDestroyCommandPool(enc, cmd_flags, device, commandPool, pAllocator); 331 vn_instance_submit_command(vn_instance, submit); 332 if (cmd_data != local_cmd_data) 333 free(cmd_data); 334 } 335} 336 337static inline void vn_submit_vkResetCommandPool(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags, struct vn_instance_submit_command *submit) 338{ 339 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 340 void *cmd_data = local_cmd_data; 341 size_t cmd_size = vn_sizeof_vkResetCommandPool(device, commandPool, flags); 342 if (cmd_size > sizeof(local_cmd_data)) { 343 cmd_data = malloc(cmd_size); 344 if (!cmd_data) 345 cmd_size = 0; 346 } 347 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkResetCommandPool_reply(device, commandPool, flags) : 0; 348 349 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 350 if (cmd_size) { 351 vn_encode_vkResetCommandPool(enc, cmd_flags, device, commandPool, flags); 352 vn_instance_submit_command(vn_instance, submit); 353 if (cmd_data != local_cmd_data) 354 free(cmd_data); 355 } 356} 357 358static inline void vn_submit_vkTrimCommandPool(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags, struct vn_instance_submit_command *submit) 359{ 360 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 361 void *cmd_data = local_cmd_data; 362 size_t cmd_size = vn_sizeof_vkTrimCommandPool(device, commandPool, flags); 363 if (cmd_size > sizeof(local_cmd_data)) { 364 cmd_data = malloc(cmd_size); 365 if (!cmd_data) 366 cmd_size = 0; 367 } 368 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkTrimCommandPool_reply(device, commandPool, flags) : 0; 369 370 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 371 if (cmd_size) { 372 vn_encode_vkTrimCommandPool(enc, cmd_flags, device, commandPool, flags); 373 vn_instance_submit_command(vn_instance, submit); 374 if (cmd_data != local_cmd_data) 375 free(cmd_data); 376 } 377} 378 379static inline VkResult vn_call_vkCreateCommandPool(struct vn_instance *vn_instance, VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) 380{ 381 VN_TRACE_FUNC(); 382 383 struct vn_instance_submit_command submit; 384 vn_submit_vkCreateCommandPool(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pCommandPool, &submit); 385 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 386 if (dec) { 387 const VkResult ret = vn_decode_vkCreateCommandPool_reply(dec, device, pCreateInfo, pAllocator, pCommandPool); 388 vn_instance_free_command_reply(vn_instance, &submit); 389 return ret; 390 } else { 391 return VK_ERROR_OUT_OF_HOST_MEMORY; 392 } 393} 394 395static inline void vn_async_vkCreateCommandPool(struct vn_instance *vn_instance, VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool) 396{ 397 struct vn_instance_submit_command submit; 398 vn_submit_vkCreateCommandPool(vn_instance, 0, device, pCreateInfo, pAllocator, pCommandPool, &submit); 399} 400 401static inline void vn_call_vkDestroyCommandPool(struct vn_instance *vn_instance, VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator) 402{ 403 VN_TRACE_FUNC(); 404 405 struct vn_instance_submit_command submit; 406 vn_submit_vkDestroyCommandPool(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, commandPool, pAllocator, &submit); 407 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 408 if (dec) { 409 vn_decode_vkDestroyCommandPool_reply(dec, device, commandPool, pAllocator); 410 vn_instance_free_command_reply(vn_instance, &submit); 411 } 412} 413 414static inline void vn_async_vkDestroyCommandPool(struct vn_instance *vn_instance, VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator) 415{ 416 struct vn_instance_submit_command submit; 417 vn_submit_vkDestroyCommandPool(vn_instance, 0, device, commandPool, pAllocator, &submit); 418} 419 420static inline VkResult vn_call_vkResetCommandPool(struct vn_instance *vn_instance, VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) 421{ 422 VN_TRACE_FUNC(); 423 424 struct vn_instance_submit_command submit; 425 vn_submit_vkResetCommandPool(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, commandPool, flags, &submit); 426 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 427 if (dec) { 428 const VkResult ret = vn_decode_vkResetCommandPool_reply(dec, device, commandPool, flags); 429 vn_instance_free_command_reply(vn_instance, &submit); 430 return ret; 431 } else { 432 return VK_ERROR_OUT_OF_HOST_MEMORY; 433 } 434} 435 436static inline void vn_async_vkResetCommandPool(struct vn_instance *vn_instance, VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) 437{ 438 struct vn_instance_submit_command submit; 439 vn_submit_vkResetCommandPool(vn_instance, 0, device, commandPool, flags, &submit); 440} 441 442static inline void vn_call_vkTrimCommandPool(struct vn_instance *vn_instance, VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags) 443{ 444 VN_TRACE_FUNC(); 445 446 struct vn_instance_submit_command submit; 447 vn_submit_vkTrimCommandPool(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, commandPool, flags, &submit); 448 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 449 if (dec) { 450 vn_decode_vkTrimCommandPool_reply(dec, device, commandPool, flags); 451 vn_instance_free_command_reply(vn_instance, &submit); 452 } 453} 454 455static inline void vn_async_vkTrimCommandPool(struct vn_instance *vn_instance, VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags) 456{ 457 struct vn_instance_submit_command submit; 458 vn_submit_vkTrimCommandPool(vn_instance, 0, device, commandPool, flags, &submit); 459} 460 461#endif /* VN_PROTOCOL_DRIVER_COMMAND_POOL_H */ 462