Home | History | Annotate | Line # | Download | only in venus-protocol
      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_IMAGE_VIEW_H
      9 #define VN_PROTOCOL_DRIVER_IMAGE_VIEW_H
     10 
     11 #include "vn_instance.h"
     12 #include "vn_protocol_driver_structs.h"
     13 
     14 /* struct VkImageViewUsageCreateInfo chain */
     15 
     16 static inline size_t
     17 vn_sizeof_VkImageViewUsageCreateInfo_pnext(const void *val)
     18 {
     19     /* no known/supported struct */
     20     return vn_sizeof_simple_pointer(NULL);
     21 }
     22 
     23 static inline size_t
     24 vn_sizeof_VkImageViewUsageCreateInfo_self(const VkImageViewUsageCreateInfo *val)
     25 {
     26     size_t size = 0;
     27     /* skip val->{sType,pNext} */
     28     size += vn_sizeof_VkFlags(&val->usage);
     29     return size;
     30 }
     31 
     32 static inline size_t
     33 vn_sizeof_VkImageViewUsageCreateInfo(const VkImageViewUsageCreateInfo *val)
     34 {
     35     size_t size = 0;
     36 
     37     size += vn_sizeof_VkStructureType(&val->sType);
     38     size += vn_sizeof_VkImageViewUsageCreateInfo_pnext(val->pNext);
     39     size += vn_sizeof_VkImageViewUsageCreateInfo_self(val);
     40 
     41     return size;
     42 }
     43 
     44 static inline void
     45 vn_encode_VkImageViewUsageCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
     46 {
     47     /* no known/supported struct */
     48     vn_encode_simple_pointer(enc, NULL);
     49 }
     50 
     51 static inline void
     52 vn_encode_VkImageViewUsageCreateInfo_self(struct vn_cs_encoder *enc, const VkImageViewUsageCreateInfo *val)
     53 {
     54     /* skip val->{sType,pNext} */
     55     vn_encode_VkFlags(enc, &val->usage);
     56 }
     57 
     58 static inline void
     59 vn_encode_VkImageViewUsageCreateInfo(struct vn_cs_encoder *enc, const VkImageViewUsageCreateInfo *val)
     60 {
     61     assert(val->sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO);
     62     vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO });
     63     vn_encode_VkImageViewUsageCreateInfo_pnext(enc, val->pNext);
     64     vn_encode_VkImageViewUsageCreateInfo_self(enc, val);
     65 }
     66 
     67 /* struct VkImageViewCreateInfo chain */
     68 
     69 static inline size_t
     70 vn_sizeof_VkImageViewCreateInfo_pnext(const void *val)
     71 {
     72     const VkBaseInStructure *pnext = val;
     73     size_t size = 0;
     74 
     75     while (pnext) {
     76         switch ((int32_t)pnext->sType) {
     77         case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO:
     78             size += vn_sizeof_simple_pointer(pnext);
     79             size += vn_sizeof_VkStructureType(&pnext->sType);
     80             size += vn_sizeof_VkImageViewCreateInfo_pnext(pnext->pNext);
     81             size += vn_sizeof_VkImageViewUsageCreateInfo_self((const VkImageViewUsageCreateInfo *)pnext);
     82             return size;
     83         case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
     84             size += vn_sizeof_simple_pointer(pnext);
     85             size += vn_sizeof_VkStructureType(&pnext->sType);
     86             size += vn_sizeof_VkImageViewCreateInfo_pnext(pnext->pNext);
     87             size += vn_sizeof_VkSamplerYcbcrConversionInfo_self((const VkSamplerYcbcrConversionInfo *)pnext);
     88             return size;
     89         default:
     90             /* ignore unknown/unsupported struct */
     91             break;
     92         }
     93         pnext = pnext->pNext;
     94     }
     95 
     96     return vn_sizeof_simple_pointer(NULL);
     97 }
     98 
     99 static inline size_t
    100 vn_sizeof_VkImageViewCreateInfo_self(const VkImageViewCreateInfo *val)
    101 {
    102     size_t size = 0;
    103     /* skip val->{sType,pNext} */
    104     size += vn_sizeof_VkFlags(&val->flags);
    105     size += vn_sizeof_VkImage(&val->image);
    106     size += vn_sizeof_VkImageViewType(&val->viewType);
    107     size += vn_sizeof_VkFormat(&val->format);
    108     size += vn_sizeof_VkComponentMapping(&val->components);
    109     size += vn_sizeof_VkImageSubresourceRange(&val->subresourceRange);
    110     return size;
    111 }
    112 
    113 static inline size_t
    114 vn_sizeof_VkImageViewCreateInfo(const VkImageViewCreateInfo *val)
    115 {
    116     size_t size = 0;
    117 
    118     size += vn_sizeof_VkStructureType(&val->sType);
    119     size += vn_sizeof_VkImageViewCreateInfo_pnext(val->pNext);
    120     size += vn_sizeof_VkImageViewCreateInfo_self(val);
    121 
    122     return size;
    123 }
    124 
    125 static inline void
    126 vn_encode_VkImageViewCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
    127 {
    128     const VkBaseInStructure *pnext = val;
    129 
    130     while (pnext) {
    131         switch ((int32_t)pnext->sType) {
    132         case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO:
    133             vn_encode_simple_pointer(enc, pnext);
    134             vn_encode_VkStructureType(enc, &pnext->sType);
    135             vn_encode_VkImageViewCreateInfo_pnext(enc, pnext->pNext);
    136             vn_encode_VkImageViewUsageCreateInfo_self(enc, (const VkImageViewUsageCreateInfo *)pnext);
    137             return;
    138         case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
    139             vn_encode_simple_pointer(enc, pnext);
    140             vn_encode_VkStructureType(enc, &pnext->sType);
    141             vn_encode_VkImageViewCreateInfo_pnext(enc, pnext->pNext);
    142             vn_encode_VkSamplerYcbcrConversionInfo_self(enc, (const VkSamplerYcbcrConversionInfo *)pnext);
    143             return;
    144         default:
    145             /* ignore unknown/unsupported struct */
    146             break;
    147         }
    148         pnext = pnext->pNext;
    149     }
    150 
    151     vn_encode_simple_pointer(enc, NULL);
    152 }
    153 
    154 static inline void
    155 vn_encode_VkImageViewCreateInfo_self(struct vn_cs_encoder *enc, const VkImageViewCreateInfo *val)
    156 {
    157     /* skip val->{sType,pNext} */
    158     vn_encode_VkFlags(enc, &val->flags);
    159     vn_encode_VkImage(enc, &val->image);
    160     vn_encode_VkImageViewType(enc, &val->viewType);
    161     vn_encode_VkFormat(enc, &val->format);
    162     vn_encode_VkComponentMapping(enc, &val->components);
    163     vn_encode_VkImageSubresourceRange(enc, &val->subresourceRange);
    164 }
    165 
    166 static inline void
    167 vn_encode_VkImageViewCreateInfo(struct vn_cs_encoder *enc, const VkImageViewCreateInfo *val)
    168 {
    169     assert(val->sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
    170     vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO });
    171     vn_encode_VkImageViewCreateInfo_pnext(enc, val->pNext);
    172     vn_encode_VkImageViewCreateInfo_self(enc, val);
    173 }
    174 
    175 static inline size_t vn_sizeof_vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
    176 {
    177     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateImageView_EXT;
    178     const VkFlags cmd_flags = 0;
    179     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
    180 
    181     cmd_size += vn_sizeof_VkDevice(&device);
    182     cmd_size += vn_sizeof_simple_pointer(pCreateInfo);
    183     if (pCreateInfo)
    184         cmd_size += vn_sizeof_VkImageViewCreateInfo(pCreateInfo);
    185     cmd_size += vn_sizeof_simple_pointer(pAllocator);
    186     if (pAllocator)
    187         assert(false);
    188     cmd_size += vn_sizeof_simple_pointer(pView);
    189     if (pView)
    190         cmd_size += vn_sizeof_VkImageView(pView);
    191 
    192     return cmd_size;
    193 }
    194 
    195 static inline void vn_encode_vkCreateImageView(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
    196 {
    197     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateImageView_EXT;
    198 
    199     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
    200     vn_encode_VkFlags(enc, &cmd_flags);
    201 
    202     vn_encode_VkDevice(enc, &device);
    203     if (vn_encode_simple_pointer(enc, pCreateInfo))
    204         vn_encode_VkImageViewCreateInfo(enc, pCreateInfo);
    205     if (vn_encode_simple_pointer(enc, pAllocator))
    206         assert(false);
    207     if (vn_encode_simple_pointer(enc, pView))
    208         vn_encode_VkImageView(enc, pView);
    209 }
    210 
    211 static inline size_t vn_sizeof_vkCreateImageView_reply(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
    212 {
    213     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateImageView_EXT;
    214     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
    215 
    216     VkResult ret;
    217     cmd_size += vn_sizeof_VkResult(&ret);
    218     /* skip device */
    219     /* skip pCreateInfo */
    220     /* skip pAllocator */
    221     cmd_size += vn_sizeof_simple_pointer(pView);
    222     if (pView)
    223         cmd_size += vn_sizeof_VkImageView(pView);
    224 
    225     return cmd_size;
    226 }
    227 
    228 static inline VkResult vn_decode_vkCreateImageView_reply(struct vn_cs_decoder *dec, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
    229 {
    230     VkCommandTypeEXT command_type;
    231     vn_decode_VkCommandTypeEXT(dec, &command_type);
    232     assert(command_type == VK_COMMAND_TYPE_vkCreateImageView_EXT);
    233 
    234     VkResult ret;
    235     vn_decode_VkResult(dec, &ret);
    236     /* skip device */
    237     /* skip pCreateInfo */
    238     /* skip pAllocator */
    239     if (vn_decode_simple_pointer(dec)) {
    240         vn_decode_VkImageView(dec, pView);
    241     } else {
    242         pView = NULL;
    243     }
    244 
    245     return ret;
    246 }
    247 
    248 static inline size_t vn_sizeof_vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
    249 {
    250     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyImageView_EXT;
    251     const VkFlags cmd_flags = 0;
    252     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
    253 
    254     cmd_size += vn_sizeof_VkDevice(&device);
    255     cmd_size += vn_sizeof_VkImageView(&imageView);
    256     cmd_size += vn_sizeof_simple_pointer(pAllocator);
    257     if (pAllocator)
    258         assert(false);
    259 
    260     return cmd_size;
    261 }
    262 
    263 static inline void vn_encode_vkDestroyImageView(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
    264 {
    265     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyImageView_EXT;
    266 
    267     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
    268     vn_encode_VkFlags(enc, &cmd_flags);
    269 
    270     vn_encode_VkDevice(enc, &device);
    271     vn_encode_VkImageView(enc, &imageView);
    272     if (vn_encode_simple_pointer(enc, pAllocator))
    273         assert(false);
    274 }
    275 
    276 static inline size_t vn_sizeof_vkDestroyImageView_reply(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
    277 {
    278     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyImageView_EXT;
    279     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
    280 
    281     /* skip device */
    282     /* skip imageView */
    283     /* skip pAllocator */
    284 
    285     return cmd_size;
    286 }
    287 
    288 static inline void vn_decode_vkDestroyImageView_reply(struct vn_cs_decoder *dec, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
    289 {
    290     VkCommandTypeEXT command_type;
    291     vn_decode_VkCommandTypeEXT(dec, &command_type);
    292     assert(command_type == VK_COMMAND_TYPE_vkDestroyImageView_EXT);
    293 
    294     /* skip device */
    295     /* skip imageView */
    296     /* skip pAllocator */
    297 }
    298 
    299 static inline void vn_submit_vkCreateImageView(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView, struct vn_instance_submit_command *submit)
    300 {
    301     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
    302     void *cmd_data = local_cmd_data;
    303     size_t cmd_size = vn_sizeof_vkCreateImageView(device, pCreateInfo, pAllocator, pView);
    304     if (cmd_size > sizeof(local_cmd_data)) {
    305         cmd_data = malloc(cmd_size);
    306         if (!cmd_data)
    307             cmd_size = 0;
    308     }
    309     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateImageView_reply(device, pCreateInfo, pAllocator, pView) : 0;
    310 
    311     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
    312     if (cmd_size) {
    313         vn_encode_vkCreateImageView(enc, cmd_flags, device, pCreateInfo, pAllocator, pView);
    314         vn_instance_submit_command(vn_instance, submit);
    315         if (cmd_data != local_cmd_data)
    316             free(cmd_data);
    317     }
    318 }
    319 
    320 static inline void vn_submit_vkDestroyImageView(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit)
    321 {
    322     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
    323     void *cmd_data = local_cmd_data;
    324     size_t cmd_size = vn_sizeof_vkDestroyImageView(device, imageView, pAllocator);
    325     if (cmd_size > sizeof(local_cmd_data)) {
    326         cmd_data = malloc(cmd_size);
    327         if (!cmd_data)
    328             cmd_size = 0;
    329     }
    330     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyImageView_reply(device, imageView, pAllocator) : 0;
    331 
    332     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
    333     if (cmd_size) {
    334         vn_encode_vkDestroyImageView(enc, cmd_flags, device, imageView, pAllocator);
    335         vn_instance_submit_command(vn_instance, submit);
    336         if (cmd_data != local_cmd_data)
    337             free(cmd_data);
    338     }
    339 }
    340 
    341 static inline VkResult vn_call_vkCreateImageView(struct vn_instance *vn_instance, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
    342 {
    343     VN_TRACE_FUNC();
    344 
    345     struct vn_instance_submit_command submit;
    346     vn_submit_vkCreateImageView(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pView, &submit);
    347     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
    348     if (dec) {
    349         const VkResult ret = vn_decode_vkCreateImageView_reply(dec, device, pCreateInfo, pAllocator, pView);
    350         vn_instance_free_command_reply(vn_instance, &submit);
    351         return ret;
    352     } else {
    353         return VK_ERROR_OUT_OF_HOST_MEMORY;
    354     }
    355 }
    356 
    357 static inline void vn_async_vkCreateImageView(struct vn_instance *vn_instance, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
    358 {
    359     struct vn_instance_submit_command submit;
    360     vn_submit_vkCreateImageView(vn_instance, 0, device, pCreateInfo, pAllocator, pView, &submit);
    361 }
    362 
    363 static inline void vn_call_vkDestroyImageView(struct vn_instance *vn_instance, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
    364 {
    365     VN_TRACE_FUNC();
    366 
    367     struct vn_instance_submit_command submit;
    368     vn_submit_vkDestroyImageView(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, imageView, pAllocator, &submit);
    369     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
    370     if (dec) {
    371         vn_decode_vkDestroyImageView_reply(dec, device, imageView, pAllocator);
    372         vn_instance_free_command_reply(vn_instance, &submit);
    373     }
    374 }
    375 
    376 static inline void vn_async_vkDestroyImageView(struct vn_instance *vn_instance, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
    377 {
    378     struct vn_instance_submit_command submit;
    379     vn_submit_vkDestroyImageView(vn_instance, 0, device, imageView, pAllocator, &submit);
    380 }
    381 
    382 #endif /* VN_PROTOCOL_DRIVER_IMAGE_VIEW_H */
    383