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