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_BUFFER_VIEW_H 9#define VN_PROTOCOL_DRIVER_BUFFER_VIEW_H 10 11#include "vn_instance.h" 12#include "vn_protocol_driver_structs.h" 13 14/* struct VkBufferViewCreateInfo chain */ 15 16static inline size_t 17vn_sizeof_VkBufferViewCreateInfo_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_VkBufferViewCreateInfo_self(const VkBufferViewCreateInfo *val) 25{ 26 size_t size = 0; 27 /* skip val->{sType,pNext} */ 28 size += vn_sizeof_VkFlags(&val->flags); 29 size += vn_sizeof_VkBuffer(&val->buffer); 30 size += vn_sizeof_VkFormat(&val->format); 31 size += vn_sizeof_VkDeviceSize(&val->offset); 32 size += vn_sizeof_VkDeviceSize(&val->range); 33 return size; 34} 35 36static inline size_t 37vn_sizeof_VkBufferViewCreateInfo(const VkBufferViewCreateInfo *val) 38{ 39 size_t size = 0; 40 41 size += vn_sizeof_VkStructureType(&val->sType); 42 size += vn_sizeof_VkBufferViewCreateInfo_pnext(val->pNext); 43 size += vn_sizeof_VkBufferViewCreateInfo_self(val); 44 45 return size; 46} 47 48static inline void 49vn_encode_VkBufferViewCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val) 50{ 51 /* no known/supported struct */ 52 vn_encode_simple_pointer(enc, NULL); 53} 54 55static inline void 56vn_encode_VkBufferViewCreateInfo_self(struct vn_cs_encoder *enc, const VkBufferViewCreateInfo *val) 57{ 58 /* skip val->{sType,pNext} */ 59 vn_encode_VkFlags(enc, &val->flags); 60 vn_encode_VkBuffer(enc, &val->buffer); 61 vn_encode_VkFormat(enc, &val->format); 62 vn_encode_VkDeviceSize(enc, &val->offset); 63 vn_encode_VkDeviceSize(enc, &val->range); 64} 65 66static inline void 67vn_encode_VkBufferViewCreateInfo(struct vn_cs_encoder *enc, const VkBufferViewCreateInfo *val) 68{ 69 assert(val->sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO); 70 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO }); 71 vn_encode_VkBufferViewCreateInfo_pnext(enc, val->pNext); 72 vn_encode_VkBufferViewCreateInfo_self(enc, val); 73} 74 75static inline size_t vn_sizeof_vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) 76{ 77 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateBufferView_EXT; 78 const VkFlags cmd_flags = 0; 79 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 80 81 cmd_size += vn_sizeof_VkDevice(&device); 82 cmd_size += vn_sizeof_simple_pointer(pCreateInfo); 83 if (pCreateInfo) 84 cmd_size += vn_sizeof_VkBufferViewCreateInfo(pCreateInfo); 85 cmd_size += vn_sizeof_simple_pointer(pAllocator); 86 if (pAllocator) 87 assert(false); 88 cmd_size += vn_sizeof_simple_pointer(pView); 89 if (pView) 90 cmd_size += vn_sizeof_VkBufferView(pView); 91 92 return cmd_size; 93} 94 95static inline void vn_encode_vkCreateBufferView(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) 96{ 97 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateBufferView_EXT; 98 99 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 100 vn_encode_VkFlags(enc, &cmd_flags); 101 102 vn_encode_VkDevice(enc, &device); 103 if (vn_encode_simple_pointer(enc, pCreateInfo)) 104 vn_encode_VkBufferViewCreateInfo(enc, pCreateInfo); 105 if (vn_encode_simple_pointer(enc, pAllocator)) 106 assert(false); 107 if (vn_encode_simple_pointer(enc, pView)) 108 vn_encode_VkBufferView(enc, pView); 109} 110 111static inline size_t vn_sizeof_vkCreateBufferView_reply(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) 112{ 113 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateBufferView_EXT; 114 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 115 116 VkResult ret; 117 cmd_size += vn_sizeof_VkResult(&ret); 118 /* skip device */ 119 /* skip pCreateInfo */ 120 /* skip pAllocator */ 121 cmd_size += vn_sizeof_simple_pointer(pView); 122 if (pView) 123 cmd_size += vn_sizeof_VkBufferView(pView); 124 125 return cmd_size; 126} 127 128static inline VkResult vn_decode_vkCreateBufferView_reply(struct vn_cs_decoder *dec, VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) 129{ 130 VkCommandTypeEXT command_type; 131 vn_decode_VkCommandTypeEXT(dec, &command_type); 132 assert(command_type == VK_COMMAND_TYPE_vkCreateBufferView_EXT); 133 134 VkResult ret; 135 vn_decode_VkResult(dec, &ret); 136 /* skip device */ 137 /* skip pCreateInfo */ 138 /* skip pAllocator */ 139 if (vn_decode_simple_pointer(dec)) { 140 vn_decode_VkBufferView(dec, pView); 141 } else { 142 pView = NULL; 143 } 144 145 return ret; 146} 147 148static inline size_t vn_sizeof_vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) 149{ 150 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyBufferView_EXT; 151 const VkFlags cmd_flags = 0; 152 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags); 153 154 cmd_size += vn_sizeof_VkDevice(&device); 155 cmd_size += vn_sizeof_VkBufferView(&bufferView); 156 cmd_size += vn_sizeof_simple_pointer(pAllocator); 157 if (pAllocator) 158 assert(false); 159 160 return cmd_size; 161} 162 163static inline void vn_encode_vkDestroyBufferView(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) 164{ 165 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyBufferView_EXT; 166 167 vn_encode_VkCommandTypeEXT(enc, &cmd_type); 168 vn_encode_VkFlags(enc, &cmd_flags); 169 170 vn_encode_VkDevice(enc, &device); 171 vn_encode_VkBufferView(enc, &bufferView); 172 if (vn_encode_simple_pointer(enc, pAllocator)) 173 assert(false); 174} 175 176static inline size_t vn_sizeof_vkDestroyBufferView_reply(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) 177{ 178 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyBufferView_EXT; 179 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type); 180 181 /* skip device */ 182 /* skip bufferView */ 183 /* skip pAllocator */ 184 185 return cmd_size; 186} 187 188static inline void vn_decode_vkDestroyBufferView_reply(struct vn_cs_decoder *dec, VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) 189{ 190 VkCommandTypeEXT command_type; 191 vn_decode_VkCommandTypeEXT(dec, &command_type); 192 assert(command_type == VK_COMMAND_TYPE_vkDestroyBufferView_EXT); 193 194 /* skip device */ 195 /* skip bufferView */ 196 /* skip pAllocator */ 197} 198 199static inline void vn_submit_vkCreateBufferView(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView, struct vn_instance_submit_command *submit) 200{ 201 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 202 void *cmd_data = local_cmd_data; 203 size_t cmd_size = vn_sizeof_vkCreateBufferView(device, pCreateInfo, pAllocator, pView); 204 if (cmd_size > sizeof(local_cmd_data)) { 205 cmd_data = malloc(cmd_size); 206 if (!cmd_data) 207 cmd_size = 0; 208 } 209 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateBufferView_reply(device, pCreateInfo, pAllocator, pView) : 0; 210 211 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 212 if (cmd_size) { 213 vn_encode_vkCreateBufferView(enc, cmd_flags, device, pCreateInfo, pAllocator, pView); 214 vn_instance_submit_command(vn_instance, submit); 215 if (cmd_data != local_cmd_data) 216 free(cmd_data); 217 } 218} 219 220static inline void vn_submit_vkDestroyBufferView(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit) 221{ 222 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE]; 223 void *cmd_data = local_cmd_data; 224 size_t cmd_size = vn_sizeof_vkDestroyBufferView(device, bufferView, pAllocator); 225 if (cmd_size > sizeof(local_cmd_data)) { 226 cmd_data = malloc(cmd_size); 227 if (!cmd_data) 228 cmd_size = 0; 229 } 230 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyBufferView_reply(device, bufferView, pAllocator) : 0; 231 232 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size); 233 if (cmd_size) { 234 vn_encode_vkDestroyBufferView(enc, cmd_flags, device, bufferView, pAllocator); 235 vn_instance_submit_command(vn_instance, submit); 236 if (cmd_data != local_cmd_data) 237 free(cmd_data); 238 } 239} 240 241static inline VkResult vn_call_vkCreateBufferView(struct vn_instance *vn_instance, VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) 242{ 243 VN_TRACE_FUNC(); 244 245 struct vn_instance_submit_command submit; 246 vn_submit_vkCreateBufferView(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pView, &submit); 247 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 248 if (dec) { 249 const VkResult ret = vn_decode_vkCreateBufferView_reply(dec, device, pCreateInfo, pAllocator, pView); 250 vn_instance_free_command_reply(vn_instance, &submit); 251 return ret; 252 } else { 253 return VK_ERROR_OUT_OF_HOST_MEMORY; 254 } 255} 256 257static inline void vn_async_vkCreateBufferView(struct vn_instance *vn_instance, VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) 258{ 259 struct vn_instance_submit_command submit; 260 vn_submit_vkCreateBufferView(vn_instance, 0, device, pCreateInfo, pAllocator, pView, &submit); 261} 262 263static inline void vn_call_vkDestroyBufferView(struct vn_instance *vn_instance, VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) 264{ 265 VN_TRACE_FUNC(); 266 267 struct vn_instance_submit_command submit; 268 vn_submit_vkDestroyBufferView(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, bufferView, pAllocator, &submit); 269 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit); 270 if (dec) { 271 vn_decode_vkDestroyBufferView_reply(dec, device, bufferView, pAllocator); 272 vn_instance_free_command_reply(vn_instance, &submit); 273 } 274} 275 276static inline void vn_async_vkDestroyBufferView(struct vn_instance *vn_instance, VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator) 277{ 278 struct vn_instance_submit_command submit; 279 vn_submit_vkDestroyBufferView(vn_instance, 0, device, bufferView, pAllocator, &submit); 280} 281 282#endif /* VN_PROTOCOL_DRIVER_BUFFER_VIEW_H */ 283