1bf215546Sopenharmony_ci/* This file is generated by venus-protocol.  See vn_protocol_driver.h. */
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_ci/*
4bf215546Sopenharmony_ci * Copyright 2020 Google LLC
5bf215546Sopenharmony_ci * SPDX-License-Identifier: MIT
6bf215546Sopenharmony_ci */
7bf215546Sopenharmony_ci
8bf215546Sopenharmony_ci#ifndef VN_PROTOCOL_DRIVER_SAMPLER_H
9bf215546Sopenharmony_ci#define VN_PROTOCOL_DRIVER_SAMPLER_H
10bf215546Sopenharmony_ci
11bf215546Sopenharmony_ci#include "vn_instance.h"
12bf215546Sopenharmony_ci#include "vn_protocol_driver_structs.h"
13bf215546Sopenharmony_ci
14bf215546Sopenharmony_ci/* struct VkSamplerReductionModeCreateInfo chain */
15bf215546Sopenharmony_ci
16bf215546Sopenharmony_cistatic inline size_t
17bf215546Sopenharmony_civn_sizeof_VkSamplerReductionModeCreateInfo_pnext(const void *val)
18bf215546Sopenharmony_ci{
19bf215546Sopenharmony_ci    /* no known/supported struct */
20bf215546Sopenharmony_ci    return vn_sizeof_simple_pointer(NULL);
21bf215546Sopenharmony_ci}
22bf215546Sopenharmony_ci
23bf215546Sopenharmony_cistatic inline size_t
24bf215546Sopenharmony_civn_sizeof_VkSamplerReductionModeCreateInfo_self(const VkSamplerReductionModeCreateInfo *val)
25bf215546Sopenharmony_ci{
26bf215546Sopenharmony_ci    size_t size = 0;
27bf215546Sopenharmony_ci    /* skip val->{sType,pNext} */
28bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerReductionMode(&val->reductionMode);
29bf215546Sopenharmony_ci    return size;
30bf215546Sopenharmony_ci}
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_cistatic inline size_t
33bf215546Sopenharmony_civn_sizeof_VkSamplerReductionModeCreateInfo(const VkSamplerReductionModeCreateInfo *val)
34bf215546Sopenharmony_ci{
35bf215546Sopenharmony_ci    size_t size = 0;
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci    size += vn_sizeof_VkStructureType(&val->sType);
38bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerReductionModeCreateInfo_pnext(val->pNext);
39bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerReductionModeCreateInfo_self(val);
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_ci    return size;
42bf215546Sopenharmony_ci}
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_cistatic inline void
45bf215546Sopenharmony_civn_encode_VkSamplerReductionModeCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
46bf215546Sopenharmony_ci{
47bf215546Sopenharmony_ci    /* no known/supported struct */
48bf215546Sopenharmony_ci    vn_encode_simple_pointer(enc, NULL);
49bf215546Sopenharmony_ci}
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_cistatic inline void
52bf215546Sopenharmony_civn_encode_VkSamplerReductionModeCreateInfo_self(struct vn_cs_encoder *enc, const VkSamplerReductionModeCreateInfo *val)
53bf215546Sopenharmony_ci{
54bf215546Sopenharmony_ci    /* skip val->{sType,pNext} */
55bf215546Sopenharmony_ci    vn_encode_VkSamplerReductionMode(enc, &val->reductionMode);
56bf215546Sopenharmony_ci}
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_cistatic inline void
59bf215546Sopenharmony_civn_encode_VkSamplerReductionModeCreateInfo(struct vn_cs_encoder *enc, const VkSamplerReductionModeCreateInfo *val)
60bf215546Sopenharmony_ci{
61bf215546Sopenharmony_ci    assert(val->sType == VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO);
62bf215546Sopenharmony_ci    vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO });
63bf215546Sopenharmony_ci    vn_encode_VkSamplerReductionModeCreateInfo_pnext(enc, val->pNext);
64bf215546Sopenharmony_ci    vn_encode_VkSamplerReductionModeCreateInfo_self(enc, val);
65bf215546Sopenharmony_ci}
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ci/* struct VkSamplerCustomBorderColorCreateInfoEXT chain */
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_cistatic inline size_t
70bf215546Sopenharmony_civn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_pnext(const void *val)
71bf215546Sopenharmony_ci{
72bf215546Sopenharmony_ci    /* no known/supported struct */
73bf215546Sopenharmony_ci    return vn_sizeof_simple_pointer(NULL);
74bf215546Sopenharmony_ci}
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_cistatic inline size_t
77bf215546Sopenharmony_civn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_self(const VkSamplerCustomBorderColorCreateInfoEXT *val)
78bf215546Sopenharmony_ci{
79bf215546Sopenharmony_ci    size_t size = 0;
80bf215546Sopenharmony_ci    /* skip val->{sType,pNext} */
81bf215546Sopenharmony_ci    size += vn_sizeof_VkClearColorValue(&val->customBorderColor);
82bf215546Sopenharmony_ci    size += vn_sizeof_VkFormat(&val->format);
83bf215546Sopenharmony_ci    return size;
84bf215546Sopenharmony_ci}
85bf215546Sopenharmony_ci
86bf215546Sopenharmony_cistatic inline size_t
87bf215546Sopenharmony_civn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT(const VkSamplerCustomBorderColorCreateInfoEXT *val)
88bf215546Sopenharmony_ci{
89bf215546Sopenharmony_ci    size_t size = 0;
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_ci    size += vn_sizeof_VkStructureType(&val->sType);
92bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_pnext(val->pNext);
93bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_self(val);
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci    return size;
96bf215546Sopenharmony_ci}
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_cistatic inline void
99bf215546Sopenharmony_civn_encode_VkSamplerCustomBorderColorCreateInfoEXT_pnext(struct vn_cs_encoder *enc, const void *val)
100bf215546Sopenharmony_ci{
101bf215546Sopenharmony_ci    /* no known/supported struct */
102bf215546Sopenharmony_ci    vn_encode_simple_pointer(enc, NULL);
103bf215546Sopenharmony_ci}
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_cistatic inline void
106bf215546Sopenharmony_civn_encode_VkSamplerCustomBorderColorCreateInfoEXT_self(struct vn_cs_encoder *enc, const VkSamplerCustomBorderColorCreateInfoEXT *val)
107bf215546Sopenharmony_ci{
108bf215546Sopenharmony_ci    /* skip val->{sType,pNext} */
109bf215546Sopenharmony_ci    vn_encode_VkClearColorValue(enc, &val->customBorderColor);
110bf215546Sopenharmony_ci    vn_encode_VkFormat(enc, &val->format);
111bf215546Sopenharmony_ci}
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_cistatic inline void
114bf215546Sopenharmony_civn_encode_VkSamplerCustomBorderColorCreateInfoEXT(struct vn_cs_encoder *enc, const VkSamplerCustomBorderColorCreateInfoEXT *val)
115bf215546Sopenharmony_ci{
116bf215546Sopenharmony_ci    assert(val->sType == VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT);
117bf215546Sopenharmony_ci    vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT });
118bf215546Sopenharmony_ci    vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_pnext(enc, val->pNext);
119bf215546Sopenharmony_ci    vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_self(enc, val);
120bf215546Sopenharmony_ci}
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ci/* struct VkSamplerCreateInfo chain */
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_cistatic inline size_t
125bf215546Sopenharmony_civn_sizeof_VkSamplerCreateInfo_pnext(const void *val)
126bf215546Sopenharmony_ci{
127bf215546Sopenharmony_ci    const VkBaseInStructure *pnext = val;
128bf215546Sopenharmony_ci    size_t size = 0;
129bf215546Sopenharmony_ci
130bf215546Sopenharmony_ci    while (pnext) {
131bf215546Sopenharmony_ci        switch ((int32_t)pnext->sType) {
132bf215546Sopenharmony_ci        case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
133bf215546Sopenharmony_ci            size += vn_sizeof_simple_pointer(pnext);
134bf215546Sopenharmony_ci            size += vn_sizeof_VkStructureType(&pnext->sType);
135bf215546Sopenharmony_ci            size += vn_sizeof_VkSamplerCreateInfo_pnext(pnext->pNext);
136bf215546Sopenharmony_ci            size += vn_sizeof_VkSamplerYcbcrConversionInfo_self((const VkSamplerYcbcrConversionInfo *)pnext);
137bf215546Sopenharmony_ci            return size;
138bf215546Sopenharmony_ci        case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO:
139bf215546Sopenharmony_ci            size += vn_sizeof_simple_pointer(pnext);
140bf215546Sopenharmony_ci            size += vn_sizeof_VkStructureType(&pnext->sType);
141bf215546Sopenharmony_ci            size += vn_sizeof_VkSamplerCreateInfo_pnext(pnext->pNext);
142bf215546Sopenharmony_ci            size += vn_sizeof_VkSamplerReductionModeCreateInfo_self((const VkSamplerReductionModeCreateInfo *)pnext);
143bf215546Sopenharmony_ci            return size;
144bf215546Sopenharmony_ci        case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
145bf215546Sopenharmony_ci            if (!vn_cs_renderer_protocol_has_extension(288 /* VK_EXT_custom_border_color */))
146bf215546Sopenharmony_ci                break;
147bf215546Sopenharmony_ci            size += vn_sizeof_simple_pointer(pnext);
148bf215546Sopenharmony_ci            size += vn_sizeof_VkStructureType(&pnext->sType);
149bf215546Sopenharmony_ci            size += vn_sizeof_VkSamplerCreateInfo_pnext(pnext->pNext);
150bf215546Sopenharmony_ci            size += vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_self((const VkSamplerCustomBorderColorCreateInfoEXT *)pnext);
151bf215546Sopenharmony_ci            return size;
152bf215546Sopenharmony_ci        default:
153bf215546Sopenharmony_ci            /* ignore unknown/unsupported struct */
154bf215546Sopenharmony_ci            break;
155bf215546Sopenharmony_ci        }
156bf215546Sopenharmony_ci        pnext = pnext->pNext;
157bf215546Sopenharmony_ci    }
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci    return vn_sizeof_simple_pointer(NULL);
160bf215546Sopenharmony_ci}
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_cistatic inline size_t
163bf215546Sopenharmony_civn_sizeof_VkSamplerCreateInfo_self(const VkSamplerCreateInfo *val)
164bf215546Sopenharmony_ci{
165bf215546Sopenharmony_ci    size_t size = 0;
166bf215546Sopenharmony_ci    /* skip val->{sType,pNext} */
167bf215546Sopenharmony_ci    size += vn_sizeof_VkFlags(&val->flags);
168bf215546Sopenharmony_ci    size += vn_sizeof_VkFilter(&val->magFilter);
169bf215546Sopenharmony_ci    size += vn_sizeof_VkFilter(&val->minFilter);
170bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerMipmapMode(&val->mipmapMode);
171bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerAddressMode(&val->addressModeU);
172bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerAddressMode(&val->addressModeV);
173bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerAddressMode(&val->addressModeW);
174bf215546Sopenharmony_ci    size += vn_sizeof_float(&val->mipLodBias);
175bf215546Sopenharmony_ci    size += vn_sizeof_VkBool32(&val->anisotropyEnable);
176bf215546Sopenharmony_ci    size += vn_sizeof_float(&val->maxAnisotropy);
177bf215546Sopenharmony_ci    size += vn_sizeof_VkBool32(&val->compareEnable);
178bf215546Sopenharmony_ci    size += vn_sizeof_VkCompareOp(&val->compareOp);
179bf215546Sopenharmony_ci    size += vn_sizeof_float(&val->minLod);
180bf215546Sopenharmony_ci    size += vn_sizeof_float(&val->maxLod);
181bf215546Sopenharmony_ci    size += vn_sizeof_VkBorderColor(&val->borderColor);
182bf215546Sopenharmony_ci    size += vn_sizeof_VkBool32(&val->unnormalizedCoordinates);
183bf215546Sopenharmony_ci    return size;
184bf215546Sopenharmony_ci}
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_cistatic inline size_t
187bf215546Sopenharmony_civn_sizeof_VkSamplerCreateInfo(const VkSamplerCreateInfo *val)
188bf215546Sopenharmony_ci{
189bf215546Sopenharmony_ci    size_t size = 0;
190bf215546Sopenharmony_ci
191bf215546Sopenharmony_ci    size += vn_sizeof_VkStructureType(&val->sType);
192bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerCreateInfo_pnext(val->pNext);
193bf215546Sopenharmony_ci    size += vn_sizeof_VkSamplerCreateInfo_self(val);
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ci    return size;
196bf215546Sopenharmony_ci}
197bf215546Sopenharmony_ci
198bf215546Sopenharmony_cistatic inline void
199bf215546Sopenharmony_civn_encode_VkSamplerCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
200bf215546Sopenharmony_ci{
201bf215546Sopenharmony_ci    const VkBaseInStructure *pnext = val;
202bf215546Sopenharmony_ci
203bf215546Sopenharmony_ci    while (pnext) {
204bf215546Sopenharmony_ci        switch ((int32_t)pnext->sType) {
205bf215546Sopenharmony_ci        case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
206bf215546Sopenharmony_ci            vn_encode_simple_pointer(enc, pnext);
207bf215546Sopenharmony_ci            vn_encode_VkStructureType(enc, &pnext->sType);
208bf215546Sopenharmony_ci            vn_encode_VkSamplerCreateInfo_pnext(enc, pnext->pNext);
209bf215546Sopenharmony_ci            vn_encode_VkSamplerYcbcrConversionInfo_self(enc, (const VkSamplerYcbcrConversionInfo *)pnext);
210bf215546Sopenharmony_ci            return;
211bf215546Sopenharmony_ci        case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO:
212bf215546Sopenharmony_ci            vn_encode_simple_pointer(enc, pnext);
213bf215546Sopenharmony_ci            vn_encode_VkStructureType(enc, &pnext->sType);
214bf215546Sopenharmony_ci            vn_encode_VkSamplerCreateInfo_pnext(enc, pnext->pNext);
215bf215546Sopenharmony_ci            vn_encode_VkSamplerReductionModeCreateInfo_self(enc, (const VkSamplerReductionModeCreateInfo *)pnext);
216bf215546Sopenharmony_ci            return;
217bf215546Sopenharmony_ci        case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
218bf215546Sopenharmony_ci            if (!vn_cs_renderer_protocol_has_extension(288 /* VK_EXT_custom_border_color */))
219bf215546Sopenharmony_ci                break;
220bf215546Sopenharmony_ci            vn_encode_simple_pointer(enc, pnext);
221bf215546Sopenharmony_ci            vn_encode_VkStructureType(enc, &pnext->sType);
222bf215546Sopenharmony_ci            vn_encode_VkSamplerCreateInfo_pnext(enc, pnext->pNext);
223bf215546Sopenharmony_ci            vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_self(enc, (const VkSamplerCustomBorderColorCreateInfoEXT *)pnext);
224bf215546Sopenharmony_ci            return;
225bf215546Sopenharmony_ci        default:
226bf215546Sopenharmony_ci            /* ignore unknown/unsupported struct */
227bf215546Sopenharmony_ci            break;
228bf215546Sopenharmony_ci        }
229bf215546Sopenharmony_ci        pnext = pnext->pNext;
230bf215546Sopenharmony_ci    }
231bf215546Sopenharmony_ci
232bf215546Sopenharmony_ci    vn_encode_simple_pointer(enc, NULL);
233bf215546Sopenharmony_ci}
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_cistatic inline void
236bf215546Sopenharmony_civn_encode_VkSamplerCreateInfo_self(struct vn_cs_encoder *enc, const VkSamplerCreateInfo *val)
237bf215546Sopenharmony_ci{
238bf215546Sopenharmony_ci    /* skip val->{sType,pNext} */
239bf215546Sopenharmony_ci    vn_encode_VkFlags(enc, &val->flags);
240bf215546Sopenharmony_ci    vn_encode_VkFilter(enc, &val->magFilter);
241bf215546Sopenharmony_ci    vn_encode_VkFilter(enc, &val->minFilter);
242bf215546Sopenharmony_ci    vn_encode_VkSamplerMipmapMode(enc, &val->mipmapMode);
243bf215546Sopenharmony_ci    vn_encode_VkSamplerAddressMode(enc, &val->addressModeU);
244bf215546Sopenharmony_ci    vn_encode_VkSamplerAddressMode(enc, &val->addressModeV);
245bf215546Sopenharmony_ci    vn_encode_VkSamplerAddressMode(enc, &val->addressModeW);
246bf215546Sopenharmony_ci    vn_encode_float(enc, &val->mipLodBias);
247bf215546Sopenharmony_ci    vn_encode_VkBool32(enc, &val->anisotropyEnable);
248bf215546Sopenharmony_ci    vn_encode_float(enc, &val->maxAnisotropy);
249bf215546Sopenharmony_ci    vn_encode_VkBool32(enc, &val->compareEnable);
250bf215546Sopenharmony_ci    vn_encode_VkCompareOp(enc, &val->compareOp);
251bf215546Sopenharmony_ci    vn_encode_float(enc, &val->minLod);
252bf215546Sopenharmony_ci    vn_encode_float(enc, &val->maxLod);
253bf215546Sopenharmony_ci    vn_encode_VkBorderColor(enc, &val->borderColor);
254bf215546Sopenharmony_ci    vn_encode_VkBool32(enc, &val->unnormalizedCoordinates);
255bf215546Sopenharmony_ci}
256bf215546Sopenharmony_ci
257bf215546Sopenharmony_cistatic inline void
258bf215546Sopenharmony_civn_encode_VkSamplerCreateInfo(struct vn_cs_encoder *enc, const VkSamplerCreateInfo *val)
259bf215546Sopenharmony_ci{
260bf215546Sopenharmony_ci    assert(val->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
261bf215546Sopenharmony_ci    vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO });
262bf215546Sopenharmony_ci    vn_encode_VkSamplerCreateInfo_pnext(enc, val->pNext);
263bf215546Sopenharmony_ci    vn_encode_VkSamplerCreateInfo_self(enc, val);
264bf215546Sopenharmony_ci}
265bf215546Sopenharmony_ci
266bf215546Sopenharmony_cistatic inline size_t vn_sizeof_vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
267bf215546Sopenharmony_ci{
268bf215546Sopenharmony_ci    const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSampler_EXT;
269bf215546Sopenharmony_ci    const VkFlags cmd_flags = 0;
270bf215546Sopenharmony_ci    size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
271bf215546Sopenharmony_ci
272bf215546Sopenharmony_ci    cmd_size += vn_sizeof_VkDevice(&device);
273bf215546Sopenharmony_ci    cmd_size += vn_sizeof_simple_pointer(pCreateInfo);
274bf215546Sopenharmony_ci    if (pCreateInfo)
275bf215546Sopenharmony_ci        cmd_size += vn_sizeof_VkSamplerCreateInfo(pCreateInfo);
276bf215546Sopenharmony_ci    cmd_size += vn_sizeof_simple_pointer(pAllocator);
277bf215546Sopenharmony_ci    if (pAllocator)
278bf215546Sopenharmony_ci        assert(false);
279bf215546Sopenharmony_ci    cmd_size += vn_sizeof_simple_pointer(pSampler);
280bf215546Sopenharmony_ci    if (pSampler)
281bf215546Sopenharmony_ci        cmd_size += vn_sizeof_VkSampler(pSampler);
282bf215546Sopenharmony_ci
283bf215546Sopenharmony_ci    return cmd_size;
284bf215546Sopenharmony_ci}
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_cistatic inline void vn_encode_vkCreateSampler(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
287bf215546Sopenharmony_ci{
288bf215546Sopenharmony_ci    const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSampler_EXT;
289bf215546Sopenharmony_ci
290bf215546Sopenharmony_ci    vn_encode_VkCommandTypeEXT(enc, &cmd_type);
291bf215546Sopenharmony_ci    vn_encode_VkFlags(enc, &cmd_flags);
292bf215546Sopenharmony_ci
293bf215546Sopenharmony_ci    vn_encode_VkDevice(enc, &device);
294bf215546Sopenharmony_ci    if (vn_encode_simple_pointer(enc, pCreateInfo))
295bf215546Sopenharmony_ci        vn_encode_VkSamplerCreateInfo(enc, pCreateInfo);
296bf215546Sopenharmony_ci    if (vn_encode_simple_pointer(enc, pAllocator))
297bf215546Sopenharmony_ci        assert(false);
298bf215546Sopenharmony_ci    if (vn_encode_simple_pointer(enc, pSampler))
299bf215546Sopenharmony_ci        vn_encode_VkSampler(enc, pSampler);
300bf215546Sopenharmony_ci}
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_cistatic inline size_t vn_sizeof_vkCreateSampler_reply(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
303bf215546Sopenharmony_ci{
304bf215546Sopenharmony_ci    const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSampler_EXT;
305bf215546Sopenharmony_ci    size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_ci    VkResult ret;
308bf215546Sopenharmony_ci    cmd_size += vn_sizeof_VkResult(&ret);
309bf215546Sopenharmony_ci    /* skip device */
310bf215546Sopenharmony_ci    /* skip pCreateInfo */
311bf215546Sopenharmony_ci    /* skip pAllocator */
312bf215546Sopenharmony_ci    cmd_size += vn_sizeof_simple_pointer(pSampler);
313bf215546Sopenharmony_ci    if (pSampler)
314bf215546Sopenharmony_ci        cmd_size += vn_sizeof_VkSampler(pSampler);
315bf215546Sopenharmony_ci
316bf215546Sopenharmony_ci    return cmd_size;
317bf215546Sopenharmony_ci}
318bf215546Sopenharmony_ci
319bf215546Sopenharmony_cistatic inline VkResult vn_decode_vkCreateSampler_reply(struct vn_cs_decoder *dec, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
320bf215546Sopenharmony_ci{
321bf215546Sopenharmony_ci    VkCommandTypeEXT command_type;
322bf215546Sopenharmony_ci    vn_decode_VkCommandTypeEXT(dec, &command_type);
323bf215546Sopenharmony_ci    assert(command_type == VK_COMMAND_TYPE_vkCreateSampler_EXT);
324bf215546Sopenharmony_ci
325bf215546Sopenharmony_ci    VkResult ret;
326bf215546Sopenharmony_ci    vn_decode_VkResult(dec, &ret);
327bf215546Sopenharmony_ci    /* skip device */
328bf215546Sopenharmony_ci    /* skip pCreateInfo */
329bf215546Sopenharmony_ci    /* skip pAllocator */
330bf215546Sopenharmony_ci    if (vn_decode_simple_pointer(dec)) {
331bf215546Sopenharmony_ci        vn_decode_VkSampler(dec, pSampler);
332bf215546Sopenharmony_ci    } else {
333bf215546Sopenharmony_ci        pSampler = NULL;
334bf215546Sopenharmony_ci    }
335bf215546Sopenharmony_ci
336bf215546Sopenharmony_ci    return ret;
337bf215546Sopenharmony_ci}
338bf215546Sopenharmony_ci
339bf215546Sopenharmony_cistatic inline size_t vn_sizeof_vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
340bf215546Sopenharmony_ci{
341bf215546Sopenharmony_ci    const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySampler_EXT;
342bf215546Sopenharmony_ci    const VkFlags cmd_flags = 0;
343bf215546Sopenharmony_ci    size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
344bf215546Sopenharmony_ci
345bf215546Sopenharmony_ci    cmd_size += vn_sizeof_VkDevice(&device);
346bf215546Sopenharmony_ci    cmd_size += vn_sizeof_VkSampler(&sampler);
347bf215546Sopenharmony_ci    cmd_size += vn_sizeof_simple_pointer(pAllocator);
348bf215546Sopenharmony_ci    if (pAllocator)
349bf215546Sopenharmony_ci        assert(false);
350bf215546Sopenharmony_ci
351bf215546Sopenharmony_ci    return cmd_size;
352bf215546Sopenharmony_ci}
353bf215546Sopenharmony_ci
354bf215546Sopenharmony_cistatic inline void vn_encode_vkDestroySampler(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
355bf215546Sopenharmony_ci{
356bf215546Sopenharmony_ci    const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySampler_EXT;
357bf215546Sopenharmony_ci
358bf215546Sopenharmony_ci    vn_encode_VkCommandTypeEXT(enc, &cmd_type);
359bf215546Sopenharmony_ci    vn_encode_VkFlags(enc, &cmd_flags);
360bf215546Sopenharmony_ci
361bf215546Sopenharmony_ci    vn_encode_VkDevice(enc, &device);
362bf215546Sopenharmony_ci    vn_encode_VkSampler(enc, &sampler);
363bf215546Sopenharmony_ci    if (vn_encode_simple_pointer(enc, pAllocator))
364bf215546Sopenharmony_ci        assert(false);
365bf215546Sopenharmony_ci}
366bf215546Sopenharmony_ci
367bf215546Sopenharmony_cistatic inline size_t vn_sizeof_vkDestroySampler_reply(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
368bf215546Sopenharmony_ci{
369bf215546Sopenharmony_ci    const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySampler_EXT;
370bf215546Sopenharmony_ci    size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
371bf215546Sopenharmony_ci
372bf215546Sopenharmony_ci    /* skip device */
373bf215546Sopenharmony_ci    /* skip sampler */
374bf215546Sopenharmony_ci    /* skip pAllocator */
375bf215546Sopenharmony_ci
376bf215546Sopenharmony_ci    return cmd_size;
377bf215546Sopenharmony_ci}
378bf215546Sopenharmony_ci
379bf215546Sopenharmony_cistatic inline void vn_decode_vkDestroySampler_reply(struct vn_cs_decoder *dec, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
380bf215546Sopenharmony_ci{
381bf215546Sopenharmony_ci    VkCommandTypeEXT command_type;
382bf215546Sopenharmony_ci    vn_decode_VkCommandTypeEXT(dec, &command_type);
383bf215546Sopenharmony_ci    assert(command_type == VK_COMMAND_TYPE_vkDestroySampler_EXT);
384bf215546Sopenharmony_ci
385bf215546Sopenharmony_ci    /* skip device */
386bf215546Sopenharmony_ci    /* skip sampler */
387bf215546Sopenharmony_ci    /* skip pAllocator */
388bf215546Sopenharmony_ci}
389bf215546Sopenharmony_ci
390bf215546Sopenharmony_cistatic inline void vn_submit_vkCreateSampler(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler, struct vn_instance_submit_command *submit)
391bf215546Sopenharmony_ci{
392bf215546Sopenharmony_ci    uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
393bf215546Sopenharmony_ci    void *cmd_data = local_cmd_data;
394bf215546Sopenharmony_ci    size_t cmd_size = vn_sizeof_vkCreateSampler(device, pCreateInfo, pAllocator, pSampler);
395bf215546Sopenharmony_ci    if (cmd_size > sizeof(local_cmd_data)) {
396bf215546Sopenharmony_ci        cmd_data = malloc(cmd_size);
397bf215546Sopenharmony_ci        if (!cmd_data)
398bf215546Sopenharmony_ci            cmd_size = 0;
399bf215546Sopenharmony_ci    }
400bf215546Sopenharmony_ci    const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateSampler_reply(device, pCreateInfo, pAllocator, pSampler) : 0;
401bf215546Sopenharmony_ci
402bf215546Sopenharmony_ci    struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
403bf215546Sopenharmony_ci    if (cmd_size) {
404bf215546Sopenharmony_ci        vn_encode_vkCreateSampler(enc, cmd_flags, device, pCreateInfo, pAllocator, pSampler);
405bf215546Sopenharmony_ci        vn_instance_submit_command(vn_instance, submit);
406bf215546Sopenharmony_ci        if (cmd_data != local_cmd_data)
407bf215546Sopenharmony_ci            free(cmd_data);
408bf215546Sopenharmony_ci    }
409bf215546Sopenharmony_ci}
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_cistatic inline void vn_submit_vkDestroySampler(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit)
412bf215546Sopenharmony_ci{
413bf215546Sopenharmony_ci    uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
414bf215546Sopenharmony_ci    void *cmd_data = local_cmd_data;
415bf215546Sopenharmony_ci    size_t cmd_size = vn_sizeof_vkDestroySampler(device, sampler, pAllocator);
416bf215546Sopenharmony_ci    if (cmd_size > sizeof(local_cmd_data)) {
417bf215546Sopenharmony_ci        cmd_data = malloc(cmd_size);
418bf215546Sopenharmony_ci        if (!cmd_data)
419bf215546Sopenharmony_ci            cmd_size = 0;
420bf215546Sopenharmony_ci    }
421bf215546Sopenharmony_ci    const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroySampler_reply(device, sampler, pAllocator) : 0;
422bf215546Sopenharmony_ci
423bf215546Sopenharmony_ci    struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
424bf215546Sopenharmony_ci    if (cmd_size) {
425bf215546Sopenharmony_ci        vn_encode_vkDestroySampler(enc, cmd_flags, device, sampler, pAllocator);
426bf215546Sopenharmony_ci        vn_instance_submit_command(vn_instance, submit);
427bf215546Sopenharmony_ci        if (cmd_data != local_cmd_data)
428bf215546Sopenharmony_ci            free(cmd_data);
429bf215546Sopenharmony_ci    }
430bf215546Sopenharmony_ci}
431bf215546Sopenharmony_ci
432bf215546Sopenharmony_cistatic inline VkResult vn_call_vkCreateSampler(struct vn_instance *vn_instance, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
433bf215546Sopenharmony_ci{
434bf215546Sopenharmony_ci    VN_TRACE_FUNC();
435bf215546Sopenharmony_ci
436bf215546Sopenharmony_ci    struct vn_instance_submit_command submit;
437bf215546Sopenharmony_ci    vn_submit_vkCreateSampler(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pSampler, &submit);
438bf215546Sopenharmony_ci    struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
439bf215546Sopenharmony_ci    if (dec) {
440bf215546Sopenharmony_ci        const VkResult ret = vn_decode_vkCreateSampler_reply(dec, device, pCreateInfo, pAllocator, pSampler);
441bf215546Sopenharmony_ci        vn_instance_free_command_reply(vn_instance, &submit);
442bf215546Sopenharmony_ci        return ret;
443bf215546Sopenharmony_ci    } else {
444bf215546Sopenharmony_ci        return VK_ERROR_OUT_OF_HOST_MEMORY;
445bf215546Sopenharmony_ci    }
446bf215546Sopenharmony_ci}
447bf215546Sopenharmony_ci
448bf215546Sopenharmony_cistatic inline void vn_async_vkCreateSampler(struct vn_instance *vn_instance, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
449bf215546Sopenharmony_ci{
450bf215546Sopenharmony_ci    struct vn_instance_submit_command submit;
451bf215546Sopenharmony_ci    vn_submit_vkCreateSampler(vn_instance, 0, device, pCreateInfo, pAllocator, pSampler, &submit);
452bf215546Sopenharmony_ci}
453bf215546Sopenharmony_ci
454bf215546Sopenharmony_cistatic inline void vn_call_vkDestroySampler(struct vn_instance *vn_instance, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
455bf215546Sopenharmony_ci{
456bf215546Sopenharmony_ci    VN_TRACE_FUNC();
457bf215546Sopenharmony_ci
458bf215546Sopenharmony_ci    struct vn_instance_submit_command submit;
459bf215546Sopenharmony_ci    vn_submit_vkDestroySampler(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, sampler, pAllocator, &submit);
460bf215546Sopenharmony_ci    struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
461bf215546Sopenharmony_ci    if (dec) {
462bf215546Sopenharmony_ci        vn_decode_vkDestroySampler_reply(dec, device, sampler, pAllocator);
463bf215546Sopenharmony_ci        vn_instance_free_command_reply(vn_instance, &submit);
464bf215546Sopenharmony_ci    }
465bf215546Sopenharmony_ci}
466bf215546Sopenharmony_ci
467bf215546Sopenharmony_cistatic inline void vn_async_vkDestroySampler(struct vn_instance *vn_instance, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
468bf215546Sopenharmony_ci{
469bf215546Sopenharmony_ci    struct vn_instance_submit_command submit;
470bf215546Sopenharmony_ci    vn_submit_vkDestroySampler(vn_instance, 0, device, sampler, pAllocator, &submit);
471bf215546Sopenharmony_ci}
472bf215546Sopenharmony_ci
473bf215546Sopenharmony_ci#endif /* VN_PROTOCOL_DRIVER_SAMPLER_H */
474