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_PIPELINE_LAYOUT_H 9#define VN_PROTOCOL_DRIVER_PIPELINE_LAYOUT_H 10 11#include "vn_instance.h" 12#include "vn_protocol_driver_structs.h" 13 14/* struct VkPushConstantRange */ 15 16static inline size_t 17vn_sizeof_VkPushConstantRange(const VkPushConstantRange *val) 18{ 19 size_t size = 0; 20 size += vn_sizeof_VkFlags(&val->stageFlags); 21 size += vn_sizeof_uint32_t(&val->offset); 22 size += vn_sizeof_uint32_t(&val->size); 23 return size; 24} 25 26static inline void 27vn_encode_VkPushConstantRange(struct vn_cs_encoder *enc, const VkPushConstantRange *val) 28{ 29 vn_encode_VkFlags(enc, &val->stageFlags); 30 vn_encode_uint32_t(enc, &val->offset); 31 vn_encode_uint32_t(enc, &val->size); 32} 33 34/* struct VkPipelineLayoutCreateInfo chain */ 35 36static inline size_t 37vn_sizeof_VkPipelineLayoutCreateInfo_pnext(const void *val) 38{ 39 /* no known/supported struct */ 40 return vn_sizeof_simple_pointer(NULL); 41} 42 43static inline size_t 44vn_sizeof_VkPipelineLayoutCreateInfo_self(const VkPipelineLayoutCreateInfo *val) 45{ 46 size_t size = 0; 47 /* skip val->{sType,pNext} */ 48 size += vn_sizeof_VkFlags(&val->flags); 49 size += vn_sizeof_uint32_t(&val->setLayoutCount); 50 if (val->pSetLayouts) { 51 size += vn_sizeof_array_size(val->setLayoutCount); 52 for (uint32_t i = 0; i < val->setLayoutCount; i++) 53 size += vn_sizeof_VkDescriptorSetLayout(&val->pSetLayouts[i]); 54 } else { 55 size += vn_sizeof_array_size(0); 56 } 57 size += vn_sizeof_uint32_t(&val->pushConstantRangeCount); 58 if (val->pPushConstantRanges) { 59 size += vn_sizeof_array_size(val->pushConstantRangeCount); 60 for (uint32_t i = 0; i < val->pushConstantRangeCount; i++) 61 size += vn_sizeof_VkPushConstantRange(&val->pPushConstantRanges[i]); 62 } else { 63 size += vn_sizeof_array_size(0); 64 } 65 return size; 66} 67 68static inline size_t 69vn_sizeof_VkPipelineLayoutCreateInfo(const VkPipelineLayoutCreateInfo *val) 70{ 71 size_t size = 0; 72 73 size += vn_sizeof_VkStructureType(&val->sType); 74 size += vn_sizeof_VkPipelineLayoutCreateInfo_pnext(val->pNext); 75 size += vn_sizeof_VkPipelineLayoutCreateInfo_self(val); 76 77 return size; 78} 79 80static inline void 81vn_encode_VkPipelineLayoutCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val) 82{ 83 /* no known/supported struct */ 84 vn_encode_simple_pointer(enc, NULL); 85} 86 87static inline void 88vn_encode_VkPipelineLayoutCreateInfo_self(struct vn_cs_encoder *enc, const VkPipelineLayoutCreateInfo *val) 89{ 90 /* skip val->{sType,pNext} */ 91 vn_encode_VkFlags(enc, &val->flags); 92 vn_encode_uint32_t(enc, &val->setLayoutCount); 93 if (val->pSetLayouts) { 94 vn_encode_array_size(enc, val->setLayoutCount); 95 for (uint32_t i = 0; i < val->setLayoutCount; i++) 96 vn_encode_VkDescriptorSetLayout(enc, &val->pSetLayouts[i]); 97 } else { 98 vn_encode_array_size(enc, 0); 99 } 100 vn_encode_uint32_t(enc, &val->pushConstantRangeCount); 101 if (val->pPushConstantRanges) { 102 vn_encode_array_size(enc, val->pushConstantRangeCount); 103 for (uint32_t i = 0; i < val->pushConstantRangeCount; i++) 104 vn_encode_VkPushConstantRange(enc, &val->pPushConstantRanges[i]); 105 } else { 106 vn_encode_array_size(enc, 0); 107 } 108} 109 110static inline void 111vn_encode_VkPipelineLayoutCreateInfo(struct vn_cs_encoder *enc, const VkPipelineLayoutCreateInfo *val) 112{ 113 assert(val->sType == VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO); 114 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }); 115 vn_encode_VkPipelineLayoutCreateInfo_pnext(enc, val->pNext); 116 vn_encode_VkPipelineLayoutCreateInfo_self(enc, val); 117} 118 119static inline size_t vn_sizeof_vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout) 120{ 121 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreatePipelineLayout_EXT; 122 const VkFlags cmd_flags = 0; 123 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 124 125 cmd_size += vn_sizeof_VkDevice(&device); 126 cmd_size += vn_sizeof_simple_pointer(pCreateInfo); 127 if (pCreateInfo) 128 cmd_size += vn_sizeof_VkPipelineLayoutCreateInfo(pCreateInfo); 129 cmd_size += vn_sizeof_simple_pointer(pAllocator); 130 if (pAllocator) 131 assert(false); 132 cmd_size += vn_sizeof_simple_pointer(pPipelineLayout); 133 if (pPipelineLayout) 134 cmd_size += vn_sizeof_VkPipelineLayout(pPipelineLayout); 135 136 return cmd_size; 137} 138 139static inline void vn_encode_vkCreatePipelineLayout(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout) 140{ 141 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreatePipelineLayout_EXT; 142 143 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 144 vn_encode_VkFlags(enc, &cmd_flags); 145 146 vn_encode_VkDevice(enc, &device); 147 if (vn_encode_simple_pointer(enc, pCreateInfo)) 148 vn_encode_VkPipelineLayoutCreateInfo(enc, pCreateInfo); 149 if (vn_encode_simple_pointer(enc, pAllocator)) 150 assert(false); 151 if (vn_encode_simple_pointer(enc, pPipelineLayout)) 152 vn_encode_VkPipelineLayout(enc, pPipelineLayout); 153} 154 155static inline size_t vn_sizeof_vkCreatePipelineLayout_reply(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout) 156{ 157 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreatePipelineLayout_EXT; 158 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 159 160 VkResult ret; 161 cmd_size += vn_sizeof_VkResult(&ret); 162 /* skip device */ 163 /* skip pCreateInfo */ 164 /* skip pAllocator */ 165 cmd_size += vn_sizeof_simple_pointer(pPipelineLayout); 166 if (pPipelineLayout) 167 cmd_size += vn_sizeof_VkPipelineLayout(pPipelineLayout); 168 169 return cmd_size; 170} 171 172static inline VkResult vn_decode_vkCreatePipelineLayout_reply(struct vn_cs_decoder *dec, VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout) 173{ 174 VkCommandTypeEXT command_type; 175 vn_decode_VkCommandTypeEXT(dec, &command_type); 176 assert(command_type == VK_COMMAND_TYPE_vkCreatePipelineLayout_EXT); 177 178 VkResult ret; 179 vn_decode_VkResult(dec, &ret); 180 /* skip device */ 181 /* skip pCreateInfo */ 182 /* skip pAllocator */ 183 if (vn_decode_simple_pointer(dec)) { 184 vn_decode_VkPipelineLayout(dec, pPipelineLayout); 185 } else { 186 pPipelineLayout = NULL; 187 } 188 189 return ret; 190} 191 192static inline size_t vn_sizeof_vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator) 193{ 194 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyPipelineLayout_EXT; 195 const VkFlags cmd_flags = 0; 196 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 197 198 cmd_size += vn_sizeof_VkDevice(&device); 199 cmd_size += vn_sizeof_VkPipelineLayout(&pipelineLayout); 200 cmd_size += vn_sizeof_simple_pointer(pAllocator); 201 if (pAllocator) 202 assert(false); 203 204 return cmd_size; 205} 206 207static inline void vn_encode_vkDestroyPipelineLayout(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator) 208{ 209 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyPipelineLayout_EXT; 210 211 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 212 vn_encode_VkFlags(enc, &cmd_flags); 213 214 vn_encode_VkDevice(enc, &device); 215 vn_encode_VkPipelineLayout(enc, &pipelineLayout); 216 if (vn_encode_simple_pointer(enc, pAllocator)) 217 assert(false); 218} 219 220static inline size_t vn_sizeof_vkDestroyPipelineLayout_reply(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator) 221{ 222 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyPipelineLayout_EXT; 223 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 224 225 /* skip device */ 226 /* skip pipelineLayout */ 227 /* skip pAllocator */ 228 229 return cmd_size; 230} 231 232static inline void vn_decode_vkDestroyPipelineLayout_reply(struct vn_cs_decoder *dec, VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator) 233{ 234 VkCommandTypeEXT command_type; 235 vn_decode_VkCommandTypeEXT(dec, &command_type); 236 assert(command_type == VK_COMMAND_TYPE_vkDestroyPipelineLayout_EXT); 237 238 /* skip device */ 239 /* skip pipelineLayout */ 240 /* skip pAllocator */ 241} 242 243static inline void vn_submit_vkCreatePipelineLayout(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout, struct vn_instance_submit_command *submit) 244{ 245 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 246 void *cmd_data = local_cmd_data; 247 size_t cmd_size = vn_sizeof_vkCreatePipelineLayout(device, pCreateInfo, pAllocator, pPipelineLayout); 248 if (cmd_size > sizeof(local_cmd_data)) { 249 cmd_data = malloc(cmd_size); 250 if (!cmd_data) 251 cmd_size = 0; 252 } 253 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreatePipelineLayout_reply(device, pCreateInfo, pAllocator, pPipelineLayout) : 0; 254 255 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 256 if (cmd_size) { 257 vn_encode_vkCreatePipelineLayout(enc, cmd_flags, device, pCreateInfo, pAllocator, pPipelineLayout); 258 vn_instance_submit_command(vn_instance, submit); 259 if (cmd_data != local_cmd_data) 260 free(cmd_data); 261 } 262} 263 264static inline void vn_submit_vkDestroyPipelineLayout(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit) 265{ 266 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 267 void *cmd_data = local_cmd_data; 268 size_t cmd_size = vn_sizeof_vkDestroyPipelineLayout(device, pipelineLayout, pAllocator); 269 if (cmd_size > sizeof(local_cmd_data)) { 270 cmd_data = malloc(cmd_size); 271 if (!cmd_data) 272 cmd_size = 0; 273 } 274 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyPipelineLayout_reply(device, pipelineLayout, pAllocator) : 0; 275 276 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 277 if (cmd_size) { 278 vn_encode_vkDestroyPipelineLayout(enc, cmd_flags, device, pipelineLayout, pAllocator); 279 vn_instance_submit_command(vn_instance, submit); 280 if (cmd_data != local_cmd_data) 281 free(cmd_data); 282 } 283} 284 285static inline VkResult vn_call_vkCreatePipelineLayout(struct vn_instance *vn_instance, VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout) 286{ 287 VN_TRACE_FUNC(); 288 289 struct vn_instance_submit_command submit; 290 vn_submit_vkCreatePipelineLayout(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pPipelineLayout, &submit); 291 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 292 if (dec) { 293 const VkResult ret = vn_decode_vkCreatePipelineLayout_reply(dec, device, pCreateInfo, pAllocator, pPipelineLayout); 294 vn_instance_free_command_reply(vn_instance, &submit); 295 return ret; 296 } else { 297 return VK_ERROR_OUT_OF_HOST_MEMORY; 298 } 299} 300 301static inline void vn_async_vkCreatePipelineLayout(struct vn_instance *vn_instance, VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout) 302{ 303 struct vn_instance_submit_command submit; 304 vn_submit_vkCreatePipelineLayout(vn_instance, 0, device, pCreateInfo, pAllocator, pPipelineLayout, &submit); 305} 306 307static inline void vn_call_vkDestroyPipelineLayout(struct vn_instance *vn_instance, VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator) 308{ 309 VN_TRACE_FUNC(); 310 311 struct vn_instance_submit_command submit; 312 vn_submit_vkDestroyPipelineLayout(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pipelineLayout, pAllocator, &submit); 313 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 314 if (dec) { 315 vn_decode_vkDestroyPipelineLayout_reply(dec, device, pipelineLayout, pAllocator); 316 vn_instance_free_command_reply(vn_instance, &submit); 317 } 318} 319 320static inline void vn_async_vkDestroyPipelineLayout(struct vn_instance *vn_instance, VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator) 321{ 322 struct vn_instance_submit_command submit; 323 vn_submit_vkDestroyPipelineLayout(vn_instance, 0, device, pipelineLayout, pAllocator, &submit); 324} 325 326#endif /* VN_PROTOCOL_DRIVER_PIPELINE_LAYOUT_H */ 327