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_SHADER_MODULE_H
9 #define VN_PROTOCOL_DRIVER_SHADER_MODULE_H
10
11 #include "vn_instance.h"
12 #include "vn_protocol_driver_structs.h"
13
14 /* struct VkShaderModuleCreateInfo chain */
15
16 static inline size_t
vn_sizeof_VkShaderModuleCreateInfo_pnext(const void * val)17 vn_sizeof_VkShaderModuleCreateInfo_pnext(const void *val)
18 {
19 /* no known/supported struct */
20 return vn_sizeof_simple_pointer(NULL);
21 }
22
23 static inline size_t
vn_sizeof_VkShaderModuleCreateInfo_self(const VkShaderModuleCreateInfo * val)24 vn_sizeof_VkShaderModuleCreateInfo_self(const VkShaderModuleCreateInfo *val)
25 {
26 size_t size = 0;
27 /* skip val->{sType,pNext} */
28 size += vn_sizeof_VkFlags(&val->flags);
29 size += vn_sizeof_size_t(&val->codeSize);
30 if (val->pCode) {
31 size += vn_sizeof_array_size(val->codeSize / 4);
32 size += vn_sizeof_uint32_t_array(val->pCode, val->codeSize / 4);
33 } else {
34 size += vn_sizeof_array_size(0);
35 }
36 return size;
37 }
38
39 static inline size_t
vn_sizeof_VkShaderModuleCreateInfo(const VkShaderModuleCreateInfo * val)40 vn_sizeof_VkShaderModuleCreateInfo(const VkShaderModuleCreateInfo *val)
41 {
42 size_t size = 0;
43
44 size += vn_sizeof_VkStructureType(&val->sType);
45 size += vn_sizeof_VkShaderModuleCreateInfo_pnext(val->pNext);
46 size += vn_sizeof_VkShaderModuleCreateInfo_self(val);
47
48 return size;
49 }
50
51 static inline void
vn_encode_VkShaderModuleCreateInfo_pnext(struct vn_cs_encoder * enc,const void * val)52 vn_encode_VkShaderModuleCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
53 {
54 /* no known/supported struct */
55 vn_encode_simple_pointer(enc, NULL);
56 }
57
58 static inline void
vn_encode_VkShaderModuleCreateInfo_self(struct vn_cs_encoder * enc,const VkShaderModuleCreateInfo * val)59 vn_encode_VkShaderModuleCreateInfo_self(struct vn_cs_encoder *enc, const VkShaderModuleCreateInfo *val)
60 {
61 /* skip val->{sType,pNext} */
62 vn_encode_VkFlags(enc, &val->flags);
63 vn_encode_size_t(enc, &val->codeSize);
64 if (val->pCode) {
65 vn_encode_array_size(enc, val->codeSize / 4);
66 vn_encode_uint32_t_array(enc, val->pCode, val->codeSize / 4);
67 } else {
68 vn_encode_array_size(enc, 0);
69 }
70 }
71
72 static inline void
vn_encode_VkShaderModuleCreateInfo(struct vn_cs_encoder * enc,const VkShaderModuleCreateInfo * val)73 vn_encode_VkShaderModuleCreateInfo(struct vn_cs_encoder *enc, const VkShaderModuleCreateInfo *val)
74 {
75 assert(val->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
76 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO });
77 vn_encode_VkShaderModuleCreateInfo_pnext(enc, val->pNext);
78 vn_encode_VkShaderModuleCreateInfo_self(enc, val);
79 }
80
vn_sizeof_vkCreateShaderModule(VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule)81 static inline size_t vn_sizeof_vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
82 {
83 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateShaderModule_EXT;
84 const VkFlags cmd_flags = 0;
85 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
86
87 cmd_size += vn_sizeof_VkDevice(&device);
88 cmd_size += vn_sizeof_simple_pointer(pCreateInfo);
89 if (pCreateInfo)
90 cmd_size += vn_sizeof_VkShaderModuleCreateInfo(pCreateInfo);
91 cmd_size += vn_sizeof_simple_pointer(pAllocator);
92 if (pAllocator)
93 assert(false);
94 cmd_size += vn_sizeof_simple_pointer(pShaderModule);
95 if (pShaderModule)
96 cmd_size += vn_sizeof_VkShaderModule(pShaderModule);
97
98 return cmd_size;
99 }
100
vn_encode_vkCreateShaderModule(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule)101 static inline void vn_encode_vkCreateShaderModule(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
102 {
103 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateShaderModule_EXT;
104
105 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
106 vn_encode_VkFlags(enc, &cmd_flags);
107
108 vn_encode_VkDevice(enc, &device);
109 if (vn_encode_simple_pointer(enc, pCreateInfo))
110 vn_encode_VkShaderModuleCreateInfo(enc, pCreateInfo);
111 if (vn_encode_simple_pointer(enc, pAllocator))
112 assert(false);
113 if (vn_encode_simple_pointer(enc, pShaderModule))
114 vn_encode_VkShaderModule(enc, pShaderModule);
115 }
116
vn_sizeof_vkCreateShaderModule_reply(VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule)117 static inline size_t vn_sizeof_vkCreateShaderModule_reply(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
118 {
119 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateShaderModule_EXT;
120 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
121
122 VkResult ret;
123 cmd_size += vn_sizeof_VkResult(&ret);
124 /* skip device */
125 /* skip pCreateInfo */
126 /* skip pAllocator */
127 cmd_size += vn_sizeof_simple_pointer(pShaderModule);
128 if (pShaderModule)
129 cmd_size += vn_sizeof_VkShaderModule(pShaderModule);
130
131 return cmd_size;
132 }
133
vn_decode_vkCreateShaderModule_reply(struct vn_cs_decoder * dec,VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule)134 static inline VkResult vn_decode_vkCreateShaderModule_reply(struct vn_cs_decoder *dec, VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
135 {
136 VkCommandTypeEXT command_type;
137 vn_decode_VkCommandTypeEXT(dec, &command_type);
138 assert(command_type == VK_COMMAND_TYPE_vkCreateShaderModule_EXT);
139
140 VkResult ret;
141 vn_decode_VkResult(dec, &ret);
142 /* skip device */
143 /* skip pCreateInfo */
144 /* skip pAllocator */
145 if (vn_decode_simple_pointer(dec)) {
146 vn_decode_VkShaderModule(dec, pShaderModule);
147 } else {
148 pShaderModule = NULL;
149 }
150
151 return ret;
152 }
153
vn_sizeof_vkDestroyShaderModule(VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator)154 static inline size_t vn_sizeof_vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
155 {
156 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyShaderModule_EXT;
157 const VkFlags cmd_flags = 0;
158 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
159
160 cmd_size += vn_sizeof_VkDevice(&device);
161 cmd_size += vn_sizeof_VkShaderModule(&shaderModule);
162 cmd_size += vn_sizeof_simple_pointer(pAllocator);
163 if (pAllocator)
164 assert(false);
165
166 return cmd_size;
167 }
168
vn_encode_vkDestroyShaderModule(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator)169 static inline void vn_encode_vkDestroyShaderModule(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
170 {
171 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyShaderModule_EXT;
172
173 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
174 vn_encode_VkFlags(enc, &cmd_flags);
175
176 vn_encode_VkDevice(enc, &device);
177 vn_encode_VkShaderModule(enc, &shaderModule);
178 if (vn_encode_simple_pointer(enc, pAllocator))
179 assert(false);
180 }
181
vn_sizeof_vkDestroyShaderModule_reply(VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator)182 static inline size_t vn_sizeof_vkDestroyShaderModule_reply(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
183 {
184 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyShaderModule_EXT;
185 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
186
187 /* skip device */
188 /* skip shaderModule */
189 /* skip pAllocator */
190
191 return cmd_size;
192 }
193
vn_decode_vkDestroyShaderModule_reply(struct vn_cs_decoder * dec,VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator)194 static inline void vn_decode_vkDestroyShaderModule_reply(struct vn_cs_decoder *dec, VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
195 {
196 VkCommandTypeEXT command_type;
197 vn_decode_VkCommandTypeEXT(dec, &command_type);
198 assert(command_type == VK_COMMAND_TYPE_vkDestroyShaderModule_EXT);
199
200 /* skip device */
201 /* skip shaderModule */
202 /* skip pAllocator */
203 }
204
vn_submit_vkCreateShaderModule(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule,struct vn_instance_submit_command * submit)205 static inline void vn_submit_vkCreateShaderModule(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule, struct vn_instance_submit_command *submit)
206 {
207 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
208 void *cmd_data = local_cmd_data;
209 size_t cmd_size = vn_sizeof_vkCreateShaderModule(device, pCreateInfo, pAllocator, pShaderModule);
210 if (cmd_size > sizeof(local_cmd_data)) {
211 cmd_data = malloc(cmd_size);
212 if (!cmd_data)
213 cmd_size = 0;
214 }
215 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateShaderModule_reply(device, pCreateInfo, pAllocator, pShaderModule) : 0;
216
217 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
218 if (cmd_size) {
219 vn_encode_vkCreateShaderModule(enc, cmd_flags, device, pCreateInfo, pAllocator, pShaderModule);
220 vn_instance_submit_command(vn_instance, submit);
221 if (cmd_data != local_cmd_data)
222 free(cmd_data);
223 }
224 }
225
vn_submit_vkDestroyShaderModule(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator,struct vn_instance_submit_command * submit)226 static inline void vn_submit_vkDestroyShaderModule(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit)
227 {
228 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
229 void *cmd_data = local_cmd_data;
230 size_t cmd_size = vn_sizeof_vkDestroyShaderModule(device, shaderModule, pAllocator);
231 if (cmd_size > sizeof(local_cmd_data)) {
232 cmd_data = malloc(cmd_size);
233 if (!cmd_data)
234 cmd_size = 0;
235 }
236 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyShaderModule_reply(device, shaderModule, pAllocator) : 0;
237
238 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
239 if (cmd_size) {
240 vn_encode_vkDestroyShaderModule(enc, cmd_flags, device, shaderModule, pAllocator);
241 vn_instance_submit_command(vn_instance, submit);
242 if (cmd_data != local_cmd_data)
243 free(cmd_data);
244 }
245 }
246
vn_call_vkCreateShaderModule(struct vn_instance * vn_instance,VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule)247 static inline VkResult vn_call_vkCreateShaderModule(struct vn_instance *vn_instance, VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
248 {
249 VN_TRACE_FUNC();
250
251 struct vn_instance_submit_command submit;
252 vn_submit_vkCreateShaderModule(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pShaderModule, &submit);
253 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
254 if (dec) {
255 const VkResult ret = vn_decode_vkCreateShaderModule_reply(dec, device, pCreateInfo, pAllocator, pShaderModule);
256 vn_instance_free_command_reply(vn_instance, &submit);
257 return ret;
258 } else {
259 return VK_ERROR_OUT_OF_HOST_MEMORY;
260 }
261 }
262
vn_async_vkCreateShaderModule(struct vn_instance * vn_instance,VkDevice device,const VkShaderModuleCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkShaderModule * pShaderModule)263 static inline void vn_async_vkCreateShaderModule(struct vn_instance *vn_instance, VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
264 {
265 struct vn_instance_submit_command submit;
266 vn_submit_vkCreateShaderModule(vn_instance, 0, device, pCreateInfo, pAllocator, pShaderModule, &submit);
267 }
268
vn_call_vkDestroyShaderModule(struct vn_instance * vn_instance,VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator)269 static inline void vn_call_vkDestroyShaderModule(struct vn_instance *vn_instance, VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
270 {
271 VN_TRACE_FUNC();
272
273 struct vn_instance_submit_command submit;
274 vn_submit_vkDestroyShaderModule(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, shaderModule, pAllocator, &submit);
275 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
276 if (dec) {
277 vn_decode_vkDestroyShaderModule_reply(dec, device, shaderModule, pAllocator);
278 vn_instance_free_command_reply(vn_instance, &submit);
279 }
280 }
281
vn_async_vkDestroyShaderModule(struct vn_instance * vn_instance,VkDevice device,VkShaderModule shaderModule,const VkAllocationCallbacks * pAllocator)282 static inline void vn_async_vkDestroyShaderModule(struct vn_instance *vn_instance, VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
283 {
284 struct vn_instance_submit_command submit;
285 vn_submit_vkDestroyShaderModule(vn_instance, 0, device, shaderModule, pAllocator, &submit);
286 }
287
288 #endif /* VN_PROTOCOL_DRIVER_SHADER_MODULE_H */
289