Path: blob/21.2-virgl/src/virtio/venus-protocol/vn_protocol_driver_image_view.h
4560 views
/* This file is generated by venus-protocol. See vn_protocol_driver.h. */12/*3* Copyright 2020 Google LLC4* SPDX-License-Identifier: MIT5*/67#ifndef VN_PROTOCOL_DRIVER_IMAGE_VIEW_H8#define VN_PROTOCOL_DRIVER_IMAGE_VIEW_H910#include "vn_device.h"11#include "vn_protocol_driver_structs.h"1213/* struct VkImageViewUsageCreateInfo chain */1415static inline size_t16vn_sizeof_VkImageViewUsageCreateInfo_pnext(const void *val)17{18/* no known/supported struct */19return vn_sizeof_simple_pointer(NULL);20}2122static inline size_t23vn_sizeof_VkImageViewUsageCreateInfo_self(const VkImageViewUsageCreateInfo *val)24{25size_t size = 0;26/* skip val->{sType,pNext} */27size += vn_sizeof_VkFlags(&val->usage);28return size;29}3031static inline size_t32vn_sizeof_VkImageViewUsageCreateInfo(const VkImageViewUsageCreateInfo *val)33{34size_t size = 0;3536size += vn_sizeof_VkStructureType(&val->sType);37size += vn_sizeof_VkImageViewUsageCreateInfo_pnext(val->pNext);38size += vn_sizeof_VkImageViewUsageCreateInfo_self(val);3940return size;41}4243static inline void44vn_encode_VkImageViewUsageCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)45{46/* no known/supported struct */47vn_encode_simple_pointer(enc, NULL);48}4950static inline void51vn_encode_VkImageViewUsageCreateInfo_self(struct vn_cs_encoder *enc, const VkImageViewUsageCreateInfo *val)52{53/* skip val->{sType,pNext} */54vn_encode_VkFlags(enc, &val->usage);55}5657static inline void58vn_encode_VkImageViewUsageCreateInfo(struct vn_cs_encoder *enc, const VkImageViewUsageCreateInfo *val)59{60assert(val->sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO);61vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO });62vn_encode_VkImageViewUsageCreateInfo_pnext(enc, val->pNext);63vn_encode_VkImageViewUsageCreateInfo_self(enc, val);64}6566/* struct VkImageViewCreateInfo chain */6768static inline size_t69vn_sizeof_VkImageViewCreateInfo_pnext(const void *val)70{71const VkBaseInStructure *pnext = val;72size_t size = 0;7374while (pnext) {75switch ((int32_t)pnext->sType) {76case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO:77size += vn_sizeof_simple_pointer(pnext);78size += vn_sizeof_VkStructureType(&pnext->sType);79size += vn_sizeof_VkImageViewCreateInfo_pnext(pnext->pNext);80size += vn_sizeof_VkImageViewUsageCreateInfo_self((const VkImageViewUsageCreateInfo *)pnext);81return size;82case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:83size += vn_sizeof_simple_pointer(pnext);84size += vn_sizeof_VkStructureType(&pnext->sType);85size += vn_sizeof_VkImageViewCreateInfo_pnext(pnext->pNext);86size += vn_sizeof_VkSamplerYcbcrConversionInfo_self((const VkSamplerYcbcrConversionInfo *)pnext);87return size;88default:89/* ignore unknown/unsupported struct */90break;91}92pnext = pnext->pNext;93}9495return vn_sizeof_simple_pointer(NULL);96}9798static inline size_t99vn_sizeof_VkImageViewCreateInfo_self(const VkImageViewCreateInfo *val)100{101size_t size = 0;102/* skip val->{sType,pNext} */103size += vn_sizeof_VkFlags(&val->flags);104size += vn_sizeof_VkImage(&val->image);105size += vn_sizeof_VkImageViewType(&val->viewType);106size += vn_sizeof_VkFormat(&val->format);107size += vn_sizeof_VkComponentMapping(&val->components);108size += vn_sizeof_VkImageSubresourceRange(&val->subresourceRange);109return size;110}111112static inline size_t113vn_sizeof_VkImageViewCreateInfo(const VkImageViewCreateInfo *val)114{115size_t size = 0;116117size += vn_sizeof_VkStructureType(&val->sType);118size += vn_sizeof_VkImageViewCreateInfo_pnext(val->pNext);119size += vn_sizeof_VkImageViewCreateInfo_self(val);120121return size;122}123124static inline void125vn_encode_VkImageViewCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)126{127const VkBaseInStructure *pnext = val;128129while (pnext) {130switch ((int32_t)pnext->sType) {131case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO:132vn_encode_simple_pointer(enc, pnext);133vn_encode_VkStructureType(enc, &pnext->sType);134vn_encode_VkImageViewCreateInfo_pnext(enc, pnext->pNext);135vn_encode_VkImageViewUsageCreateInfo_self(enc, (const VkImageViewUsageCreateInfo *)pnext);136return;137case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:138vn_encode_simple_pointer(enc, pnext);139vn_encode_VkStructureType(enc, &pnext->sType);140vn_encode_VkImageViewCreateInfo_pnext(enc, pnext->pNext);141vn_encode_VkSamplerYcbcrConversionInfo_self(enc, (const VkSamplerYcbcrConversionInfo *)pnext);142return;143default:144/* ignore unknown/unsupported struct */145break;146}147pnext = pnext->pNext;148}149150vn_encode_simple_pointer(enc, NULL);151}152153static inline void154vn_encode_VkImageViewCreateInfo_self(struct vn_cs_encoder *enc, const VkImageViewCreateInfo *val)155{156/* skip val->{sType,pNext} */157vn_encode_VkFlags(enc, &val->flags);158vn_encode_VkImage(enc, &val->image);159vn_encode_VkImageViewType(enc, &val->viewType);160vn_encode_VkFormat(enc, &val->format);161vn_encode_VkComponentMapping(enc, &val->components);162vn_encode_VkImageSubresourceRange(enc, &val->subresourceRange);163}164165static inline void166vn_encode_VkImageViewCreateInfo(struct vn_cs_encoder *enc, const VkImageViewCreateInfo *val)167{168assert(val->sType == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);169vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO });170vn_encode_VkImageViewCreateInfo_pnext(enc, val->pNext);171vn_encode_VkImageViewCreateInfo_self(enc, val);172}173174static inline size_t vn_sizeof_vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)175{176const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateImageView_EXT;177const VkFlags cmd_flags = 0;178size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);179180cmd_size += vn_sizeof_VkDevice(&device);181cmd_size += vn_sizeof_simple_pointer(pCreateInfo);182if (pCreateInfo)183cmd_size += vn_sizeof_VkImageViewCreateInfo(pCreateInfo);184cmd_size += vn_sizeof_simple_pointer(pAllocator);185if (pAllocator)186assert(false);187cmd_size += vn_sizeof_simple_pointer(pView);188if (pView)189cmd_size += vn_sizeof_VkImageView(pView);190191return cmd_size;192}193194static inline void vn_encode_vkCreateImageView(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)195{196const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateImageView_EXT;197198vn_encode_VkCommandTypeEXT(enc, &cmd_type);199vn_encode_VkFlags(enc, &cmd_flags);200201vn_encode_VkDevice(enc, &device);202if (vn_encode_simple_pointer(enc, pCreateInfo))203vn_encode_VkImageViewCreateInfo(enc, pCreateInfo);204if (vn_encode_simple_pointer(enc, pAllocator))205assert(false);206if (vn_encode_simple_pointer(enc, pView))207vn_encode_VkImageView(enc, pView);208}209210static inline size_t vn_sizeof_vkCreateImageView_reply(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)211{212const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateImageView_EXT;213size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);214215VkResult ret;216cmd_size += vn_sizeof_VkResult(&ret);217/* skip device */218/* skip pCreateInfo */219/* skip pAllocator */220cmd_size += vn_sizeof_simple_pointer(pView);221if (pView)222cmd_size += vn_sizeof_VkImageView(pView);223224return cmd_size;225}226227static inline VkResult vn_decode_vkCreateImageView_reply(struct vn_cs_decoder *dec, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)228{229VkCommandTypeEXT command_type;230vn_decode_VkCommandTypeEXT(dec, &command_type);231assert(command_type == VK_COMMAND_TYPE_vkCreateImageView_EXT);232233VkResult ret;234vn_decode_VkResult(dec, &ret);235/* skip device */236/* skip pCreateInfo */237/* skip pAllocator */238if (vn_decode_simple_pointer(dec)) {239vn_decode_VkImageView(dec, pView);240} else {241pView = NULL;242}243244return ret;245}246247static inline size_t vn_sizeof_vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)248{249const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyImageView_EXT;250const VkFlags cmd_flags = 0;251size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);252253cmd_size += vn_sizeof_VkDevice(&device);254cmd_size += vn_sizeof_VkImageView(&imageView);255cmd_size += vn_sizeof_simple_pointer(pAllocator);256if (pAllocator)257assert(false);258259return cmd_size;260}261262static inline void vn_encode_vkDestroyImageView(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)263{264const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyImageView_EXT;265266vn_encode_VkCommandTypeEXT(enc, &cmd_type);267vn_encode_VkFlags(enc, &cmd_flags);268269vn_encode_VkDevice(enc, &device);270vn_encode_VkImageView(enc, &imageView);271if (vn_encode_simple_pointer(enc, pAllocator))272assert(false);273}274275static inline size_t vn_sizeof_vkDestroyImageView_reply(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)276{277const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyImageView_EXT;278size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);279280/* skip device */281/* skip imageView */282/* skip pAllocator */283284return cmd_size;285}286287static inline void vn_decode_vkDestroyImageView_reply(struct vn_cs_decoder *dec, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)288{289VkCommandTypeEXT command_type;290vn_decode_VkCommandTypeEXT(dec, &command_type);291assert(command_type == VK_COMMAND_TYPE_vkDestroyImageView_EXT);292293/* skip device */294/* skip imageView */295/* skip pAllocator */296}297298static 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)299{300uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];301void *cmd_data = local_cmd_data;302size_t cmd_size = vn_sizeof_vkCreateImageView(device, pCreateInfo, pAllocator, pView);303if (cmd_size > sizeof(local_cmd_data)) {304cmd_data = malloc(cmd_size);305if (!cmd_data)306cmd_size = 0;307}308const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateImageView_reply(device, pCreateInfo, pAllocator, pView) : 0;309310struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);311if (cmd_size) {312vn_encode_vkCreateImageView(enc, cmd_flags, device, pCreateInfo, pAllocator, pView);313vn_instance_submit_command(vn_instance, submit);314if (cmd_data != local_cmd_data)315free(cmd_data);316}317}318319static 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)320{321uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];322void *cmd_data = local_cmd_data;323size_t cmd_size = vn_sizeof_vkDestroyImageView(device, imageView, pAllocator);324if (cmd_size > sizeof(local_cmd_data)) {325cmd_data = malloc(cmd_size);326if (!cmd_data)327cmd_size = 0;328}329const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyImageView_reply(device, imageView, pAllocator) : 0;330331struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);332if (cmd_size) {333vn_encode_vkDestroyImageView(enc, cmd_flags, device, imageView, pAllocator);334vn_instance_submit_command(vn_instance, submit);335if (cmd_data != local_cmd_data)336free(cmd_data);337}338}339340static inline VkResult vn_call_vkCreateImageView(struct vn_instance *vn_instance, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)341{342struct vn_instance_submit_command submit;343vn_submit_vkCreateImageView(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pView, &submit);344struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);345if (dec) {346const VkResult ret = vn_decode_vkCreateImageView_reply(dec, device, pCreateInfo, pAllocator, pView);347vn_instance_free_command_reply(vn_instance, &submit);348return ret;349} else {350return VK_ERROR_OUT_OF_HOST_MEMORY;351}352}353354static inline void vn_async_vkCreateImageView(struct vn_instance *vn_instance, VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)355{356struct vn_instance_submit_command submit;357vn_submit_vkCreateImageView(vn_instance, 0, device, pCreateInfo, pAllocator, pView, &submit);358}359360static inline void vn_call_vkDestroyImageView(struct vn_instance *vn_instance, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)361{362struct vn_instance_submit_command submit;363vn_submit_vkDestroyImageView(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, imageView, pAllocator, &submit);364struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);365if (dec) {366vn_decode_vkDestroyImageView_reply(dec, device, imageView, pAllocator);367vn_instance_free_command_reply(vn_instance, &submit);368}369}370371static inline void vn_async_vkDestroyImageView(struct vn_instance *vn_instance, VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)372{373struct vn_instance_submit_command submit;374vn_submit_vkDestroyImageView(vn_instance, 0, device, imageView, pAllocator, &submit);375}376377#endif /* VN_PROTOCOL_DRIVER_IMAGE_VIEW_H */378379380