diff --git a/src/venus/venus-protocol/vn_protocol_renderer.h b/src/venus/venus-protocol/vn_protocol_renderer.h index 21bac7b..1331532 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer.h +++ b/src/venus/venus-protocol/vn_protocol_renderer.h @@ -1,4 +1,4 @@ -/* This file is generated by venus-protocol git-2c162241. */ +/* This file is generated by venus-protocol git-712f11f6. */ /* * Copyright 2020 Google LLC diff --git a/src/venus/venus-protocol/vn_protocol_renderer_buffer.h b/src/venus/venus-protocol/vn_protocol_renderer_buffer.h index 91b3c8c..6c3ecf1 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_buffer.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_buffer.h @@ -732,10 +732,10 @@ static inline void vn_decode_vkBindBufferMemory2_args_temp(struct vn_cs_decoder vn_decode_VkDevice_lookup(dec, &args->device); vn_decode_uint32_t(dec, &args->bindInfoCount); if (vn_peek_array_size(dec)) { - args->pBindInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBindInfos) * args->bindInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->bindInfoCount); + args->pBindInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBindInfos) * iter_count); if (!args->pBindInfos) return; - vn_decode_array_size(dec, args->bindInfoCount); - for (uint32_t i = 0; i < args->bindInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBindBufferMemoryInfo_temp(dec, &((VkBindBufferMemoryInfo *)args->pBindInfos)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_command_buffer.h b/src/venus/venus-protocol/vn_protocol_renderer_command_buffer.h index 3b015be..63ebac0 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_command_buffer.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_command_buffer.h @@ -447,14 +447,14 @@ vn_decode_VkImageBlit_temp(struct vn_cs_decoder *dec, VkImageBlit *val) { vn_decode_VkImageSubresourceLayers_temp(dec, &val->srcSubresource); { - vn_decode_array_size(dec, 2); - for (uint32_t i = 0; i < 2; i++) + const uint32_t iter_count = vn_decode_array_size(dec, 2); + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkOffset3D_temp(dec, &val->srcOffsets[i]); } vn_decode_VkImageSubresourceLayers_temp(dec, &val->dstSubresource); { - vn_decode_array_size(dec, 2); - for (uint32_t i = 0; i < 2; i++) + const uint32_t iter_count = vn_decode_array_size(dec, 2); + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkOffset3D_temp(dec, &val->dstOffsets[i]); } } @@ -837,10 +837,10 @@ vn_decode_VkDeviceGroupRenderPassBeginInfo_self_temp(struct vn_cs_decoder *dec, vn_decode_uint32_t(dec, &val->deviceMask); vn_decode_uint32_t(dec, &val->deviceRenderAreaCount); if (vn_peek_array_size(dec)) { - val->pDeviceRenderAreas = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDeviceRenderAreas) * val->deviceRenderAreaCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->deviceRenderAreaCount); + val->pDeviceRenderAreas = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDeviceRenderAreas) * iter_count); if (!val->pDeviceRenderAreas) return; - vn_decode_array_size(dec, val->deviceRenderAreaCount); - for (uint32_t i = 0; i < val->deviceRenderAreaCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkRect2D_temp(dec, &((VkRect2D *)val->pDeviceRenderAreas)[i]); } else { vn_decode_array_size(dec, 0); @@ -909,10 +909,10 @@ vn_decode_VkRenderPassAttachmentBeginInfo_self_temp(struct vn_cs_decoder *dec, V /* skip val->{sType,pNext} */ vn_decode_uint32_t(dec, &val->attachmentCount); if (vn_peek_array_size(dec)) { - val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * val->attachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->attachmentCount); + val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * iter_count); if (!val->pAttachments) return; - vn_decode_array_size(dec, val->attachmentCount); - for (uint32_t i = 0; i < val->attachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageView_lookup(dec, &((VkImageView *)val->pAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -1011,10 +1011,10 @@ vn_decode_VkRenderPassBeginInfo_self_temp(struct vn_cs_decoder *dec, VkRenderPas vn_decode_VkRect2D_temp(dec, &val->renderArea); vn_decode_uint32_t(dec, &val->clearValueCount); if (vn_peek_array_size(dec)) { - val->pClearValues = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pClearValues) * val->clearValueCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->clearValueCount); + val->pClearValues = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pClearValues) * iter_count); if (!val->pClearValues) return; - vn_decode_array_size(dec, val->clearValueCount); - for (uint32_t i = 0; i < val->clearValueCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkClearValue_temp(dec, &((VkClearValue *)val->pClearValues)[i]); } else { vn_decode_array_size(dec, 0); @@ -1195,10 +1195,10 @@ static inline void vn_decode_vkAllocateCommandBuffers_args_temp(struct vn_cs_dec vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCommandBuffers) * (args->pAllocateInfo ? args->pAllocateInfo->commandBufferCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pAllocateInfo ? args->pAllocateInfo->commandBufferCount : 0)); + args->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCommandBuffers) * iter_count); if (!args->pCommandBuffers) return; - vn_decode_array_size(dec, (args->pAllocateInfo ? args->pAllocateInfo->commandBufferCount : 0)); - for (uint32_t i = 0; i < (args->pAllocateInfo ? args->pAllocateInfo->commandBufferCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkCommandBuffer_temp(dec, &args->pCommandBuffers[i]); } else { vn_decode_array_size(dec, 0); @@ -1236,10 +1236,10 @@ static inline void vn_decode_vkFreeCommandBuffers_args_temp(struct vn_cs_decoder vn_decode_VkCommandPool_lookup(dec, &args->commandPool); vn_decode_uint32_t(dec, &args->commandBufferCount); if (vn_peek_array_size(dec)) { - args->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCommandBuffers) * args->commandBufferCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->commandBufferCount); + args->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCommandBuffers) * iter_count); if (!args->pCommandBuffers) return; - vn_decode_array_size(dec, args->commandBufferCount); - for (uint32_t i = 0; i < args->commandBufferCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkCommandBuffer_lookup(dec, &((VkCommandBuffer *)args->pCommandBuffers)[i]); } else { vn_decode_array_size(dec, 0); @@ -1365,10 +1365,10 @@ static inline void vn_decode_vkCmdSetViewport_args_temp(struct vn_cs_decoder *de vn_decode_uint32_t(dec, &args->firstViewport); vn_decode_uint32_t(dec, &args->viewportCount); if (vn_peek_array_size(dec)) { - args->pViewports = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pViewports) * args->viewportCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->viewportCount); + args->pViewports = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pViewports) * iter_count); if (!args->pViewports) return; - vn_decode_array_size(dec, args->viewportCount); - for (uint32_t i = 0; i < args->viewportCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkViewport_temp(dec, &((VkViewport *)args->pViewports)[i]); } else { vn_decode_array_size(dec, 0); @@ -1403,10 +1403,10 @@ static inline void vn_decode_vkCmdSetScissor_args_temp(struct vn_cs_decoder *dec vn_decode_uint32_t(dec, &args->firstScissor); vn_decode_uint32_t(dec, &args->scissorCount); if (vn_peek_array_size(dec)) { - args->pScissors = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pScissors) * args->scissorCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->scissorCount); + args->pScissors = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pScissors) * iter_count); if (!args->pScissors) return; - vn_decode_array_size(dec, args->scissorCount); - for (uint32_t i = 0; i < args->scissorCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkRect2D_temp(dec, &((VkRect2D *)args->pScissors)[i]); } else { vn_decode_array_size(dec, 0); @@ -1604,10 +1604,10 @@ static inline void vn_decode_vkCmdBindDescriptorSets_args_temp(struct vn_cs_deco vn_decode_uint32_t(dec, &args->firstSet); vn_decode_uint32_t(dec, &args->descriptorSetCount); if (vn_peek_array_size(dec)) { - args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * args->descriptorSetCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->descriptorSetCount); + args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * iter_count); if (!args->pDescriptorSets) return; - vn_decode_array_size(dec, args->descriptorSetCount); - for (uint32_t i = 0; i < args->descriptorSetCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorSet_lookup(dec, &((VkDescriptorSet *)args->pDescriptorSets)[i]); } else { vn_decode_array_size(dec, 0); @@ -1686,10 +1686,10 @@ static inline void vn_decode_vkCmdBindVertexBuffers_args_temp(struct vn_cs_decod vn_decode_uint32_t(dec, &args->firstBinding); vn_decode_uint32_t(dec, &args->bindingCount); if (vn_peek_array_size(dec)) { - args->pBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBuffers) * args->bindingCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->bindingCount); + args->pBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBuffers) * iter_count); if (!args->pBuffers) return; - vn_decode_array_size(dec, args->bindingCount); - for (uint32_t i = 0; i < args->bindingCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBuffer_lookup(dec, &((VkBuffer *)args->pBuffers)[i]); } else { vn_decode_array_size(dec, 0); @@ -1904,10 +1904,10 @@ static inline void vn_decode_vkCmdCopyBuffer_args_temp(struct vn_cs_decoder *dec vn_decode_VkBuffer_lookup(dec, &args->dstBuffer); vn_decode_uint32_t(dec, &args->regionCount); if (vn_peek_array_size(dec)) { - args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * args->regionCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->regionCount); + args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * iter_count); if (!args->pRegions) return; - vn_decode_array_size(dec, args->regionCount); - for (uint32_t i = 0; i < args->regionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBufferCopy_temp(dec, &((VkBufferCopy *)args->pRegions)[i]); } else { vn_decode_array_size(dec, 0); @@ -1947,10 +1947,10 @@ static inline void vn_decode_vkCmdCopyImage_args_temp(struct vn_cs_decoder *dec, vn_decode_VkImageLayout(dec, &args->dstImageLayout); vn_decode_uint32_t(dec, &args->regionCount); if (vn_peek_array_size(dec)) { - args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * args->regionCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->regionCount); + args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * iter_count); if (!args->pRegions) return; - vn_decode_array_size(dec, args->regionCount); - for (uint32_t i = 0; i < args->regionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageCopy_temp(dec, &((VkImageCopy *)args->pRegions)[i]); } else { vn_decode_array_size(dec, 0); @@ -1994,10 +1994,10 @@ static inline void vn_decode_vkCmdBlitImage_args_temp(struct vn_cs_decoder *dec, vn_decode_VkImageLayout(dec, &args->dstImageLayout); vn_decode_uint32_t(dec, &args->regionCount); if (vn_peek_array_size(dec)) { - args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * args->regionCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->regionCount); + args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * iter_count); if (!args->pRegions) return; - vn_decode_array_size(dec, args->regionCount); - for (uint32_t i = 0; i < args->regionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageBlit_temp(dec, &((VkImageBlit *)args->pRegions)[i]); } else { vn_decode_array_size(dec, 0); @@ -2043,10 +2043,10 @@ static inline void vn_decode_vkCmdCopyBufferToImage_args_temp(struct vn_cs_decod vn_decode_VkImageLayout(dec, &args->dstImageLayout); vn_decode_uint32_t(dec, &args->regionCount); if (vn_peek_array_size(dec)) { - args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * args->regionCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->regionCount); + args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * iter_count); if (!args->pRegions) return; - vn_decode_array_size(dec, args->regionCount); - for (uint32_t i = 0; i < args->regionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBufferImageCopy_temp(dec, &((VkBufferImageCopy *)args->pRegions)[i]); } else { vn_decode_array_size(dec, 0); @@ -2087,10 +2087,10 @@ static inline void vn_decode_vkCmdCopyImageToBuffer_args_temp(struct vn_cs_decod vn_decode_VkBuffer_lookup(dec, &args->dstBuffer); vn_decode_uint32_t(dec, &args->regionCount); if (vn_peek_array_size(dec)) { - args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * args->regionCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->regionCount); + args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * iter_count); if (!args->pRegions) return; - vn_decode_array_size(dec, args->regionCount); - for (uint32_t i = 0; i < args->regionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBufferImageCopy_temp(dec, &((VkBufferImageCopy *)args->pRegions)[i]); } else { vn_decode_array_size(dec, 0); @@ -2203,10 +2203,10 @@ static inline void vn_decode_vkCmdClearColorImage_args_temp(struct vn_cs_decoder } vn_decode_uint32_t(dec, &args->rangeCount); if (vn_peek_array_size(dec)) { - args->pRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRanges) * args->rangeCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->rangeCount); + args->pRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRanges) * iter_count); if (!args->pRanges) return; - vn_decode_array_size(dec, args->rangeCount); - for (uint32_t i = 0; i < args->rangeCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageSubresourceRange_temp(dec, &((VkImageSubresourceRange *)args->pRanges)[i]); } else { vn_decode_array_size(dec, 0); @@ -2254,10 +2254,10 @@ static inline void vn_decode_vkCmdClearDepthStencilImage_args_temp(struct vn_cs_ } vn_decode_uint32_t(dec, &args->rangeCount); if (vn_peek_array_size(dec)) { - args->pRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRanges) * args->rangeCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->rangeCount); + args->pRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRanges) * iter_count); if (!args->pRanges) return; - vn_decode_array_size(dec, args->rangeCount); - for (uint32_t i = 0; i < args->rangeCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageSubresourceRange_temp(dec, &((VkImageSubresourceRange *)args->pRanges)[i]); } else { vn_decode_array_size(dec, 0); @@ -2296,10 +2296,10 @@ static inline void vn_decode_vkCmdClearAttachments_args_temp(struct vn_cs_decode vn_decode_VkCommandBuffer_lookup(dec, &args->commandBuffer); vn_decode_uint32_t(dec, &args->attachmentCount); if (vn_peek_array_size(dec)) { - args->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pAttachments) * args->attachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->attachmentCount); + args->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pAttachments) * iter_count); if (!args->pAttachments) return; - vn_decode_array_size(dec, args->attachmentCount); - for (uint32_t i = 0; i < args->attachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkClearAttachment_temp(dec, &((VkClearAttachment *)args->pAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -2307,10 +2307,10 @@ static inline void vn_decode_vkCmdClearAttachments_args_temp(struct vn_cs_decode } vn_decode_uint32_t(dec, &args->rectCount); if (vn_peek_array_size(dec)) { - args->pRects = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRects) * args->rectCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->rectCount); + args->pRects = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRects) * iter_count); if (!args->pRects) return; - vn_decode_array_size(dec, args->rectCount); - for (uint32_t i = 0; i < args->rectCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkClearRect_temp(dec, &((VkClearRect *)args->pRects)[i]); } else { vn_decode_array_size(dec, 0); @@ -2353,10 +2353,10 @@ static inline void vn_decode_vkCmdResolveImage_args_temp(struct vn_cs_decoder *d vn_decode_VkImageLayout(dec, &args->dstImageLayout); vn_decode_uint32_t(dec, &args->regionCount); if (vn_peek_array_size(dec)) { - args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * args->regionCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->regionCount); + args->pRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pRegions) * iter_count); if (!args->pRegions) return; - vn_decode_array_size(dec, args->regionCount); - for (uint32_t i = 0; i < args->regionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageResolve_temp(dec, &((VkImageResolve *)args->pRegions)[i]); } else { vn_decode_array_size(dec, 0); @@ -2442,10 +2442,10 @@ static inline void vn_decode_vkCmdWaitEvents_args_temp(struct vn_cs_decoder *dec vn_decode_VkCommandBuffer_lookup(dec, &args->commandBuffer); vn_decode_uint32_t(dec, &args->eventCount); if (vn_peek_array_size(dec)) { - args->pEvents = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pEvents) * args->eventCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->eventCount); + args->pEvents = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pEvents) * iter_count); if (!args->pEvents) return; - vn_decode_array_size(dec, args->eventCount); - for (uint32_t i = 0; i < args->eventCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkEvent_lookup(dec, &((VkEvent *)args->pEvents)[i]); } else { vn_decode_array_size(dec, 0); @@ -2455,10 +2455,10 @@ static inline void vn_decode_vkCmdWaitEvents_args_temp(struct vn_cs_decoder *dec vn_decode_VkFlags(dec, &args->dstStageMask); vn_decode_uint32_t(dec, &args->memoryBarrierCount); if (vn_peek_array_size(dec)) { - args->pMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryBarriers) * args->memoryBarrierCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->memoryBarrierCount); + args->pMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryBarriers) * iter_count); if (!args->pMemoryBarriers) return; - vn_decode_array_size(dec, args->memoryBarrierCount); - for (uint32_t i = 0; i < args->memoryBarrierCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkMemoryBarrier_temp(dec, &((VkMemoryBarrier *)args->pMemoryBarriers)[i]); } else { vn_decode_array_size(dec, 0); @@ -2466,10 +2466,10 @@ static inline void vn_decode_vkCmdWaitEvents_args_temp(struct vn_cs_decoder *dec } vn_decode_uint32_t(dec, &args->bufferMemoryBarrierCount); if (vn_peek_array_size(dec)) { - args->pBufferMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBufferMemoryBarriers) * args->bufferMemoryBarrierCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->bufferMemoryBarrierCount); + args->pBufferMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBufferMemoryBarriers) * iter_count); if (!args->pBufferMemoryBarriers) return; - vn_decode_array_size(dec, args->bufferMemoryBarrierCount); - for (uint32_t i = 0; i < args->bufferMemoryBarrierCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBufferMemoryBarrier_temp(dec, &((VkBufferMemoryBarrier *)args->pBufferMemoryBarriers)[i]); } else { vn_decode_array_size(dec, 0); @@ -2477,10 +2477,10 @@ static inline void vn_decode_vkCmdWaitEvents_args_temp(struct vn_cs_decoder *dec } vn_decode_uint32_t(dec, &args->imageMemoryBarrierCount); if (vn_peek_array_size(dec)) { - args->pImageMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pImageMemoryBarriers) * args->imageMemoryBarrierCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->imageMemoryBarrierCount); + args->pImageMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pImageMemoryBarriers) * iter_count); if (!args->pImageMemoryBarriers) return; - vn_decode_array_size(dec, args->imageMemoryBarrierCount); - for (uint32_t i = 0; i < args->imageMemoryBarrierCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageMemoryBarrier_temp(dec, &((VkImageMemoryBarrier *)args->pImageMemoryBarriers)[i]); } else { vn_decode_array_size(dec, 0); @@ -2540,10 +2540,10 @@ static inline void vn_decode_vkCmdPipelineBarrier_args_temp(struct vn_cs_decoder vn_decode_VkFlags(dec, &args->dependencyFlags); vn_decode_uint32_t(dec, &args->memoryBarrierCount); if (vn_peek_array_size(dec)) { - args->pMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryBarriers) * args->memoryBarrierCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->memoryBarrierCount); + args->pMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryBarriers) * iter_count); if (!args->pMemoryBarriers) return; - vn_decode_array_size(dec, args->memoryBarrierCount); - for (uint32_t i = 0; i < args->memoryBarrierCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkMemoryBarrier_temp(dec, &((VkMemoryBarrier *)args->pMemoryBarriers)[i]); } else { vn_decode_array_size(dec, 0); @@ -2551,10 +2551,10 @@ static inline void vn_decode_vkCmdPipelineBarrier_args_temp(struct vn_cs_decoder } vn_decode_uint32_t(dec, &args->bufferMemoryBarrierCount); if (vn_peek_array_size(dec)) { - args->pBufferMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBufferMemoryBarriers) * args->bufferMemoryBarrierCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->bufferMemoryBarrierCount); + args->pBufferMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBufferMemoryBarriers) * iter_count); if (!args->pBufferMemoryBarriers) return; - vn_decode_array_size(dec, args->bufferMemoryBarrierCount); - for (uint32_t i = 0; i < args->bufferMemoryBarrierCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBufferMemoryBarrier_temp(dec, &((VkBufferMemoryBarrier *)args->pBufferMemoryBarriers)[i]); } else { vn_decode_array_size(dec, 0); @@ -2562,10 +2562,10 @@ static inline void vn_decode_vkCmdPipelineBarrier_args_temp(struct vn_cs_decoder } vn_decode_uint32_t(dec, &args->imageMemoryBarrierCount); if (vn_peek_array_size(dec)) { - args->pImageMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pImageMemoryBarriers) * args->imageMemoryBarrierCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->imageMemoryBarrierCount); + args->pImageMemoryBarriers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pImageMemoryBarriers) * iter_count); if (!args->pImageMemoryBarriers) return; - vn_decode_array_size(dec, args->imageMemoryBarrierCount); - for (uint32_t i = 0; i < args->imageMemoryBarrierCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageMemoryBarrier_temp(dec, &((VkImageMemoryBarrier *)args->pImageMemoryBarriers)[i]); } else { vn_decode_array_size(dec, 0); @@ -2864,10 +2864,10 @@ static inline void vn_decode_vkCmdExecuteCommands_args_temp(struct vn_cs_decoder vn_decode_VkCommandBuffer_lookup(dec, &args->commandBuffer); vn_decode_uint32_t(dec, &args->commandBufferCount); if (vn_peek_array_size(dec)) { - args->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCommandBuffers) * args->commandBufferCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->commandBufferCount); + args->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCommandBuffers) * iter_count); if (!args->pCommandBuffers) return; - vn_decode_array_size(dec, args->commandBufferCount); - for (uint32_t i = 0; i < args->commandBufferCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkCommandBuffer_lookup(dec, &((VkCommandBuffer *)args->pCommandBuffers)[i]); } else { vn_decode_array_size(dec, 0); @@ -3131,10 +3131,10 @@ static inline void vn_decode_vkCmdBindTransformFeedbackBuffersEXT_args_temp(stru vn_decode_uint32_t(dec, &args->firstBinding); vn_decode_uint32_t(dec, &args->bindingCount); if (vn_peek_array_size(dec)) { - args->pBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBuffers) * args->bindingCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->bindingCount); + args->pBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBuffers) * iter_count); if (!args->pBuffers) return; - vn_decode_array_size(dec, args->bindingCount); - for (uint32_t i = 0; i < args->bindingCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBuffer_lookup(dec, &((VkBuffer *)args->pBuffers)[i]); } else { vn_decode_array_size(dec, 0); @@ -3191,10 +3191,10 @@ static inline void vn_decode_vkCmdBeginTransformFeedbackEXT_args_temp(struct vn_ vn_decode_uint32_t(dec, &args->firstCounterBuffer); vn_decode_uint32_t(dec, &args->counterBufferCount); if (vn_peek_array_size(dec)) { - args->pCounterBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCounterBuffers) * args->counterBufferCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->counterBufferCount); + args->pCounterBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCounterBuffers) * iter_count); if (!args->pCounterBuffers) return; - vn_decode_array_size(dec, args->counterBufferCount); - for (uint32_t i = 0; i < args->counterBufferCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBuffer_lookup(dec, &((VkBuffer *)args->pCounterBuffers)[i]); } else { vn_decode_array_size(dec, 0); @@ -3240,10 +3240,10 @@ static inline void vn_decode_vkCmdEndTransformFeedbackEXT_args_temp(struct vn_cs vn_decode_uint32_t(dec, &args->firstCounterBuffer); vn_decode_uint32_t(dec, &args->counterBufferCount); if (vn_peek_array_size(dec)) { - args->pCounterBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCounterBuffers) * args->counterBufferCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->counterBufferCount); + args->pCounterBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCounterBuffers) * iter_count); if (!args->pCounterBuffers) return; - vn_decode_array_size(dec, args->counterBufferCount); - for (uint32_t i = 0; i < args->counterBufferCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBuffer_lookup(dec, &((VkBuffer *)args->pCounterBuffers)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_pool.h b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_pool.h index 805173c..32fcdc6 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_pool.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_pool.h @@ -49,10 +49,10 @@ vn_decode_VkDescriptorPoolCreateInfo_self_temp(struct vn_cs_decoder *dec, VkDesc vn_decode_uint32_t(dec, &val->maxSets); vn_decode_uint32_t(dec, &val->poolSizeCount); if (vn_peek_array_size(dec)) { - val->pPoolSizes = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPoolSizes) * val->poolSizeCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->poolSizeCount); + val->pPoolSizes = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPoolSizes) * iter_count); if (!val->pPoolSizes) return; - vn_decode_array_size(dec, val->poolSizeCount); - for (uint32_t i = 0; i < val->poolSizeCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorPoolSize_temp(dec, &((VkDescriptorPoolSize *)val->pPoolSizes)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set.h b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set.h index b0f01cb..d7b8b03 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set.h @@ -125,10 +125,10 @@ vn_decode_VkDescriptorSetAllocateInfo_self_temp(struct vn_cs_decoder *dec, VkDes vn_decode_VkDescriptorPool_lookup(dec, &val->descriptorPool); vn_decode_uint32_t(dec, &val->descriptorSetCount); if (vn_peek_array_size(dec)) { - val->pSetLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSetLayouts) * val->descriptorSetCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorSetCount); + val->pSetLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSetLayouts) * iter_count); if (!val->pSetLayouts) return; - vn_decode_array_size(dec, val->descriptorSetCount); - for (uint32_t i = 0; i < val->descriptorSetCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorSetLayout_lookup(dec, &((VkDescriptorSetLayout *)val->pSetLayouts)[i]); } else { vn_decode_array_size(dec, 0); @@ -240,30 +240,30 @@ vn_decode_VkWriteDescriptorSet_self_temp(struct vn_cs_decoder *dec, VkWriteDescr vn_decode_uint32_t(dec, &val->descriptorCount); vn_decode_VkDescriptorType(dec, &val->descriptorType); if (vn_peek_array_size(dec)) { - val->pImageInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageInfo) * val->descriptorCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorCount); + val->pImageInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageInfo) * iter_count); if (!val->pImageInfo) return; - vn_decode_array_size(dec, val->descriptorCount); - for (uint32_t i = 0; i < val->descriptorCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorImageInfo_temp(dec, &((VkDescriptorImageInfo *)val->pImageInfo)[i]); } else { vn_decode_array_size(dec, 0); val->pImageInfo = NULL; } if (vn_peek_array_size(dec)) { - val->pBufferInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBufferInfo) * val->descriptorCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorCount); + val->pBufferInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBufferInfo) * iter_count); if (!val->pBufferInfo) return; - vn_decode_array_size(dec, val->descriptorCount); - for (uint32_t i = 0; i < val->descriptorCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorBufferInfo_temp(dec, &((VkDescriptorBufferInfo *)val->pBufferInfo)[i]); } else { vn_decode_array_size(dec, 0); val->pBufferInfo = NULL; } if (vn_peek_array_size(dec)) { - val->pTexelBufferView = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pTexelBufferView) * val->descriptorCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorCount); + val->pTexelBufferView = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pTexelBufferView) * iter_count); if (!val->pTexelBufferView) return; - vn_decode_array_size(dec, val->descriptorCount); - for (uint32_t i = 0; i < val->descriptorCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBufferView_lookup(dec, &((VkBufferView *)val->pTexelBufferView)[i]); } else { vn_decode_array_size(dec, 0); @@ -407,10 +407,10 @@ static inline void vn_decode_vkAllocateDescriptorSets_args_temp(struct vn_cs_dec vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0)); + args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * iter_count); if (!args->pDescriptorSets) return; - vn_decode_array_size(dec, (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0)); - for (uint32_t i = 0; i < (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorSet(dec, &args->pDescriptorSets[i]); } else { vn_decode_array_size(dec, 0); @@ -448,10 +448,10 @@ static inline void vn_decode_vkFreeDescriptorSets_args_temp(struct vn_cs_decoder vn_decode_VkDescriptorPool_lookup(dec, &args->descriptorPool); vn_decode_uint32_t(dec, &args->descriptorSetCount); if (vn_peek_array_size(dec)) { - args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * args->descriptorSetCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->descriptorSetCount); + args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * iter_count); if (!args->pDescriptorSets) return; - vn_decode_array_size(dec, args->descriptorSetCount); - for (uint32_t i = 0; i < args->descriptorSetCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorSet_lookup(dec, &((VkDescriptorSet *)args->pDescriptorSets)[i]); } else { vn_decode_array_size(dec, 0); @@ -486,10 +486,10 @@ static inline void vn_decode_vkUpdateDescriptorSets_args_temp(struct vn_cs_decod vn_decode_VkDevice_lookup(dec, &args->device); vn_decode_uint32_t(dec, &args->descriptorWriteCount); if (vn_peek_array_size(dec)) { - args->pDescriptorWrites = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorWrites) * args->descriptorWriteCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->descriptorWriteCount); + args->pDescriptorWrites = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorWrites) * iter_count); if (!args->pDescriptorWrites) return; - vn_decode_array_size(dec, args->descriptorWriteCount); - for (uint32_t i = 0; i < args->descriptorWriteCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkWriteDescriptorSet_temp(dec, &((VkWriteDescriptorSet *)args->pDescriptorWrites)[i]); } else { vn_decode_array_size(dec, 0); @@ -497,10 +497,10 @@ static inline void vn_decode_vkUpdateDescriptorSets_args_temp(struct vn_cs_decod } vn_decode_uint32_t(dec, &args->descriptorCopyCount); if (vn_peek_array_size(dec)) { - args->pDescriptorCopies = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorCopies) * args->descriptorCopyCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->descriptorCopyCount); + args->pDescriptorCopies = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorCopies) * iter_count); if (!args->pDescriptorCopies) return; - vn_decode_array_size(dec, args->descriptorCopyCount); - for (uint32_t i = 0; i < args->descriptorCopyCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkCopyDescriptorSet_temp(dec, &((VkCopyDescriptorSet *)args->pDescriptorCopies)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set_layout.h b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set_layout.h index e26d7c1..21b5c03 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set_layout.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_set_layout.h @@ -24,10 +24,10 @@ vn_decode_VkDescriptorSetLayoutBinding_temp(struct vn_cs_decoder *dec, VkDescrip vn_decode_uint32_t(dec, &val->descriptorCount); vn_decode_VkFlags(dec, &val->stageFlags); if (vn_peek_array_size(dec)) { - val->pImmutableSamplers = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImmutableSamplers) * val->descriptorCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorCount); + val->pImmutableSamplers = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImmutableSamplers) * iter_count); if (!val->pImmutableSamplers) return; - vn_decode_array_size(dec, val->descriptorCount); - for (uint32_t i = 0; i < val->descriptorCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSampler_lookup(dec, &((VkSampler *)val->pImmutableSamplers)[i]); } else { vn_decode_array_size(dec, 0); @@ -65,10 +65,10 @@ vn_decode_VkDescriptorSetLayoutBindingFlagsCreateInfo_self_temp(struct vn_cs_dec /* skip val->{sType,pNext} */ vn_decode_uint32_t(dec, &val->bindingCount); if (vn_peek_array_size(dec)) { - val->pBindingFlags = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBindingFlags) * val->bindingCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->bindingCount); + val->pBindingFlags = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBindingFlags) * iter_count); if (!val->pBindingFlags) return; - vn_decode_array_size(dec, val->bindingCount); - for (uint32_t i = 0; i < val->bindingCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkFlags(dec, &((VkDescriptorBindingFlags *)val->pBindingFlags)[i]); } else { vn_decode_array_size(dec, 0); @@ -154,10 +154,10 @@ vn_decode_VkDescriptorSetLayoutCreateInfo_self_temp(struct vn_cs_decoder *dec, V vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->bindingCount); if (vn_peek_array_size(dec)) { - val->pBindings = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBindings) * val->bindingCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->bindingCount); + val->pBindings = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBindings) * iter_count); if (!val->pBindings) return; - vn_decode_array_size(dec, val->bindingCount); - for (uint32_t i = 0; i < val->bindingCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorSetLayoutBinding_temp(dec, &((VkDescriptorSetLayoutBinding *)val->pBindings)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_update_template.h b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_update_template.h index 7ab941b..51892bb 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_descriptor_update_template.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_descriptor_update_template.h @@ -56,10 +56,10 @@ vn_decode_VkDescriptorUpdateTemplateCreateInfo_self_temp(struct vn_cs_decoder *d vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->descriptorUpdateEntryCount); if (vn_peek_array_size(dec)) { - val->pDescriptorUpdateEntries = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDescriptorUpdateEntries) * val->descriptorUpdateEntryCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorUpdateEntryCount); + val->pDescriptorUpdateEntries = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDescriptorUpdateEntries) * iter_count); if (!val->pDescriptorUpdateEntries) return; - vn_decode_array_size(dec, val->descriptorUpdateEntryCount); - for (uint32_t i = 0; i < val->descriptorUpdateEntryCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorUpdateTemplateEntry_temp(dec, &((VkDescriptorUpdateTemplateEntry *)val->pDescriptorUpdateEntries)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_device.h b/src/venus/venus-protocol/vn_protocol_renderer_device.h index 6bddbee..cb36c58 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_device.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_device.h @@ -283,7 +283,7 @@ vn_encode_VkPhysicalDeviceProperties(struct vn_cs_encoder *enc, const VkPhysical vn_encode_uint32_t(enc, &val->deviceID); vn_encode_VkPhysicalDeviceType(enc, &val->deviceType); vn_encode_array_size(enc, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE); - vn_encode_blob_array(enc, val->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE); + vn_encode_char_array(enc, val->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE); vn_encode_array_size(enc, VK_UUID_SIZE); vn_encode_uint8_t_array(enc, val->pipelineCacheUUID, VK_UUID_SIZE); vn_encode_VkPhysicalDeviceLimits(enc, &val->limits); @@ -376,14 +376,14 @@ vn_decode_VkPhysicalDeviceMemoryProperties_partial_temp(struct vn_cs_decoder *de { /* skip val->memoryTypeCount */ { - vn_decode_array_size(dec, VK_MAX_MEMORY_TYPES); - for (uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++) + const uint32_t iter_count = vn_decode_array_size(dec, VK_MAX_MEMORY_TYPES); + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkMemoryType_partial_temp(dec, &val->memoryTypes[i]); } /* skip val->memoryHeapCount */ { - vn_decode_array_size(dec, VK_MAX_MEMORY_HEAPS); - for (uint32_t i = 0; i < VK_MAX_MEMORY_HEAPS; i++) + const uint32_t iter_count = vn_decode_array_size(dec, VK_MAX_MEMORY_HEAPS); + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkMemoryHeap_partial_temp(dec, &val->memoryHeaps[i]); } } @@ -4213,10 +4213,10 @@ vn_decode_VkDeviceGroupDeviceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkD /* skip val->{sType,pNext} */ vn_decode_uint32_t(dec, &val->physicalDeviceCount); if (vn_peek_array_size(dec)) { - val->pPhysicalDevices = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPhysicalDevices) * val->physicalDeviceCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->physicalDeviceCount); + val->pPhysicalDevices = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPhysicalDevices) * iter_count); if (!val->pPhysicalDevices) return; - vn_decode_array_size(dec, val->physicalDeviceCount); - for (uint32_t i = 0; i < val->physicalDeviceCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPhysicalDevice_lookup(dec, &((VkPhysicalDevice *)val->pPhysicalDevices)[i]); } else { vn_decode_array_size(dec, 0); @@ -4489,10 +4489,10 @@ vn_decode_VkDeviceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkDeviceCreate vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->queueCreateInfoCount); if (vn_peek_array_size(dec)) { - val->pQueueCreateInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pQueueCreateInfos) * val->queueCreateInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->queueCreateInfoCount); + val->pQueueCreateInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pQueueCreateInfos) * iter_count); if (!val->pQueueCreateInfos) return; - vn_decode_array_size(dec, val->queueCreateInfoCount); - for (uint32_t i = 0; i < val->queueCreateInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDeviceQueueCreateInfo_temp(dec, &((VkDeviceQueueCreateInfo *)val->pQueueCreateInfos)[i]); } else { vn_decode_array_size(dec, 0); @@ -4500,14 +4500,14 @@ vn_decode_VkDeviceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkDeviceCreate } vn_decode_uint32_t(dec, &val->enabledLayerCount); if (vn_peek_array_size(dec)) { - val->ppEnabledLayerNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledLayerNames) * val->enabledLayerCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->enabledLayerCount); + val->ppEnabledLayerNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledLayerNames) * iter_count); if (!val->ppEnabledLayerNames) return; - vn_decode_array_size(dec, val->enabledLayerCount); - for (uint32_t i = 0; i < val->enabledLayerCount; i++) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + for (uint32_t i = 0; i < iter_count; i++) { + const size_t string_size = vn_decode_array_size_unchecked(dec); ((char **)val->ppEnabledLayerNames)[i] = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledLayerNames[i]) * string_size); if (!val->ppEnabledLayerNames[i]) return; - vn_decode_blob_array(dec, ((char **)val->ppEnabledLayerNames)[i], string_size); + vn_decode_char_array(dec, ((char **)val->ppEnabledLayerNames)[i], string_size); } } else { vn_decode_array_size(dec, 0); @@ -4515,14 +4515,14 @@ vn_decode_VkDeviceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkDeviceCreate } vn_decode_uint32_t(dec, &val->enabledExtensionCount); if (vn_peek_array_size(dec)) { - val->ppEnabledExtensionNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledExtensionNames) * val->enabledExtensionCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->enabledExtensionCount); + val->ppEnabledExtensionNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledExtensionNames) * iter_count); if (!val->ppEnabledExtensionNames) return; - vn_decode_array_size(dec, val->enabledExtensionCount); - for (uint32_t i = 0; i < val->enabledExtensionCount; i++) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + for (uint32_t i = 0; i < iter_count; i++) { + const size_t string_size = vn_decode_array_size_unchecked(dec); ((char **)val->ppEnabledExtensionNames)[i] = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledExtensionNames[i]) * string_size); if (!val->ppEnabledExtensionNames[i]) return; - vn_decode_blob_array(dec, ((char **)val->ppEnabledExtensionNames)[i], string_size); + vn_decode_char_array(dec, ((char **)val->ppEnabledExtensionNames)[i], string_size); } } else { vn_decode_array_size(dec, 0); @@ -4694,9 +4694,9 @@ vn_encode_VkPhysicalDeviceDriverProperties_self(struct vn_cs_encoder *enc, const /* skip val->{sType,pNext} */ vn_encode_VkDriverId(enc, &val->driverID); vn_encode_array_size(enc, VK_MAX_DRIVER_NAME_SIZE); - vn_encode_blob_array(enc, val->driverName, VK_MAX_DRIVER_NAME_SIZE); + vn_encode_char_array(enc, val->driverName, VK_MAX_DRIVER_NAME_SIZE); vn_encode_array_size(enc, VK_MAX_DRIVER_INFO_SIZE); - vn_encode_blob_array(enc, val->driverInfo, VK_MAX_DRIVER_INFO_SIZE); + vn_encode_char_array(enc, val->driverInfo, VK_MAX_DRIVER_INFO_SIZE); vn_encode_VkConformanceVersion(enc, &val->conformanceVersion); } @@ -5612,9 +5612,9 @@ vn_encode_VkPhysicalDeviceVulkan12Properties_self(struct vn_cs_encoder *enc, con /* skip val->{sType,pNext} */ vn_encode_VkDriverId(enc, &val->driverID); vn_encode_array_size(enc, VK_MAX_DRIVER_NAME_SIZE); - vn_encode_blob_array(enc, val->driverName, VK_MAX_DRIVER_NAME_SIZE); + vn_encode_char_array(enc, val->driverName, VK_MAX_DRIVER_NAME_SIZE); vn_encode_array_size(enc, VK_MAX_DRIVER_INFO_SIZE); - vn_encode_blob_array(enc, val->driverInfo, VK_MAX_DRIVER_INFO_SIZE); + vn_encode_char_array(enc, val->driverInfo, VK_MAX_DRIVER_INFO_SIZE); vn_encode_VkConformanceVersion(enc, &val->conformanceVersion); vn_encode_VkShaderFloatControlsIndependence(enc, &val->denormBehaviorIndependence); vn_encode_VkShaderFloatControlsIndependence(enc, &val->roundingModeIndependence); @@ -6106,10 +6106,10 @@ vn_decode_VkDrmFormatModifierPropertiesListEXT_self_partial_temp(struct vn_cs_de /* skip val->{sType,pNext} */ /* skip val->drmFormatModifierCount */ if (vn_peek_array_size(dec)) { - val->pDrmFormatModifierProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDrmFormatModifierProperties) * val->drmFormatModifierCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->drmFormatModifierCount); + val->pDrmFormatModifierProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDrmFormatModifierProperties) * iter_count); if (!val->pDrmFormatModifierProperties) return; - vn_decode_array_size(dec, val->drmFormatModifierCount); - for (uint32_t i = 0; i < val->drmFormatModifierCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDrmFormatModifierPropertiesEXT_partial_temp(dec, &val->pDrmFormatModifierProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -7338,8 +7338,8 @@ vn_decode_VkPhysicalDeviceGroupProperties_self_partial_temp(struct vn_cs_decoder /* skip val->{sType,pNext} */ /* skip val->physicalDeviceCount */ { - vn_decode_array_size(dec, VK_MAX_DEVICE_GROUP_SIZE); - for (uint32_t i = 0; i < VK_MAX_DEVICE_GROUP_SIZE; i++) + const uint32_t iter_count = vn_decode_array_size(dec, VK_MAX_DEVICE_GROUP_SIZE); + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPhysicalDevice_temp(dec, &val->physicalDevices[i]); } /* skip val->subsetAllocation */ @@ -7431,10 +7431,10 @@ static inline void vn_decode_vkEnumeratePhysicalDevices_args_temp(struct vn_cs_d vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pPhysicalDevices = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPhysicalDevices) * (args->pPhysicalDeviceCount ? *args->pPhysicalDeviceCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPhysicalDeviceCount ? *args->pPhysicalDeviceCount : 0)); + args->pPhysicalDevices = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPhysicalDevices) * iter_count); if (!args->pPhysicalDevices) return; - vn_decode_array_size(dec, (args->pPhysicalDeviceCount ? *args->pPhysicalDeviceCount : 0)); - for (uint32_t i = 0; i < (args->pPhysicalDeviceCount ? *args->pPhysicalDeviceCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPhysicalDevice_temp(dec, &args->pPhysicalDevices[i]); } else { vn_decode_array_size(dec, 0); @@ -7506,10 +7506,10 @@ static inline void vn_decode_vkGetPhysicalDeviceQueueFamilyProperties_args_temp( vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pQueueFamilyProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pQueueFamilyProperties) * (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0)); + args->pQueueFamilyProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pQueueFamilyProperties) * iter_count); if (!args->pQueueFamilyProperties) return; - vn_decode_array_size(dec, (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkQueueFamilyProperties_partial_temp(dec, &args->pQueueFamilyProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -7754,10 +7754,10 @@ static inline void vn_decode_vkEnumerateDeviceLayerProperties_args_temp(struct v vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * (args->pPropertyCount ? *args->pPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); + args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * iter_count); if (!args->pProperties) return; - vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pPropertyCount ? *args->pPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkLayerProperties_partial_temp(dec, &args->pProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -7793,10 +7793,10 @@ static inline void vn_decode_vkEnumerateDeviceExtensionProperties_args_temp(stru { vn_decode_VkPhysicalDevice_lookup(dec, &args->physicalDevice); if (vn_peek_array_size(dec)) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + const size_t string_size = vn_decode_array_size_unchecked(dec); args->pLayerName = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pLayerName) * string_size); if (!args->pLayerName) return; - vn_decode_blob_array(dec, (char *)args->pLayerName, string_size); + vn_decode_char_array(dec, (char *)args->pLayerName, string_size); } else { vn_decode_array_size(dec, 0); args->pLayerName = NULL; @@ -7810,10 +7810,10 @@ static inline void vn_decode_vkEnumerateDeviceExtensionProperties_args_temp(stru vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * (args->pPropertyCount ? *args->pPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); + args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * iter_count); if (!args->pProperties) return; - vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pPropertyCount ? *args->pPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkExtensionProperties_partial_temp(dec, &args->pProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -7916,10 +7916,10 @@ static inline void vn_decode_vkGetPhysicalDeviceSparseImageFormatProperties_args vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * (args->pPropertyCount ? *args->pPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); + args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * iter_count); if (!args->pProperties) return; - vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pPropertyCount ? *args->pPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseImageFormatProperties_partial_temp(dec, &args->pProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -8099,10 +8099,10 @@ static inline void vn_decode_vkGetPhysicalDeviceQueueFamilyProperties2_args_temp vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pQueueFamilyProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pQueueFamilyProperties) * (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0)); + args->pQueueFamilyProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pQueueFamilyProperties) * iter_count); if (!args->pQueueFamilyProperties) return; - vn_decode_array_size(dec, (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pQueueFamilyPropertyCount ? *args->pQueueFamilyPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkQueueFamilyProperties2_partial_temp(dec, &args->pQueueFamilyProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -8181,10 +8181,10 @@ static inline void vn_decode_vkGetPhysicalDeviceSparseImageFormatProperties2_arg vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * (args->pPropertyCount ? *args->pPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); + args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * iter_count); if (!args->pProperties) return; - vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pPropertyCount ? *args->pPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseImageFormatProperties2_partial_temp(dec, &args->pProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -8347,10 +8347,10 @@ static inline void vn_decode_vkEnumeratePhysicalDeviceGroups_args_temp(struct vn vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pPhysicalDeviceGroupProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPhysicalDeviceGroupProperties) * (args->pPhysicalDeviceGroupCount ? *args->pPhysicalDeviceGroupCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPhysicalDeviceGroupCount ? *args->pPhysicalDeviceGroupCount : 0)); + args->pPhysicalDeviceGroupProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPhysicalDeviceGroupProperties) * iter_count); if (!args->pPhysicalDeviceGroupProperties) return; - vn_decode_array_size(dec, (args->pPhysicalDeviceGroupCount ? *args->pPhysicalDeviceGroupCount : 0)); - for (uint32_t i = 0; i < (args->pPhysicalDeviceGroupCount ? *args->pPhysicalDeviceGroupCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPhysicalDeviceGroupProperties_partial_temp(dec, &args->pPhysicalDeviceGroupProperties[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_device_memory.h b/src/venus/venus-protocol/vn_protocol_renderer_device_memory.h index da62720..6156eff 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_device_memory.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_device_memory.h @@ -703,10 +703,10 @@ static inline void vn_decode_vkFlushMappedMemoryRanges_args_temp(struct vn_cs_de vn_decode_VkDevice_lookup(dec, &args->device); vn_decode_uint32_t(dec, &args->memoryRangeCount); if (vn_peek_array_size(dec)) { - args->pMemoryRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryRanges) * args->memoryRangeCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->memoryRangeCount); + args->pMemoryRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryRanges) * iter_count); if (!args->pMemoryRanges) return; - vn_decode_array_size(dec, args->memoryRangeCount); - for (uint32_t i = 0; i < args->memoryRangeCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkMappedMemoryRange_temp(dec, &((VkMappedMemoryRange *)args->pMemoryRanges)[i]); } else { vn_decode_array_size(dec, 0); @@ -739,10 +739,10 @@ static inline void vn_decode_vkInvalidateMappedMemoryRanges_args_temp(struct vn_ vn_decode_VkDevice_lookup(dec, &args->device); vn_decode_uint32_t(dec, &args->memoryRangeCount); if (vn_peek_array_size(dec)) { - args->pMemoryRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryRanges) * args->memoryRangeCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->memoryRangeCount); + args->pMemoryRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pMemoryRanges) * iter_count); if (!args->pMemoryRanges) return; - vn_decode_array_size(dec, args->memoryRangeCount); - for (uint32_t i = 0; i < args->memoryRangeCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkMappedMemoryRange_temp(dec, &((VkMappedMemoryRange *)args->pMemoryRanges)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_fence.h b/src/venus/venus-protocol/vn_protocol_renderer_fence.h index b79094c..5e862ad 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_fence.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_fence.h @@ -230,10 +230,10 @@ static inline void vn_decode_vkResetFences_args_temp(struct vn_cs_decoder *dec, vn_decode_VkDevice_lookup(dec, &args->device); vn_decode_uint32_t(dec, &args->fenceCount); if (vn_peek_array_size(dec)) { - args->pFences = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pFences) * args->fenceCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->fenceCount); + args->pFences = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pFences) * iter_count); if (!args->pFences) return; - vn_decode_array_size(dec, args->fenceCount); - for (uint32_t i = 0; i < args->fenceCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkFence_lookup(dec, &((VkFence *)args->pFences)[i]); } else { vn_decode_array_size(dec, 0); @@ -287,10 +287,10 @@ static inline void vn_decode_vkWaitForFences_args_temp(struct vn_cs_decoder *dec vn_decode_VkDevice_lookup(dec, &args->device); vn_decode_uint32_t(dec, &args->fenceCount); if (vn_peek_array_size(dec)) { - args->pFences = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pFences) * args->fenceCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->fenceCount); + args->pFences = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pFences) * iter_count); if (!args->pFences) return; - vn_decode_array_size(dec, args->fenceCount); - for (uint32_t i = 0; i < args->fenceCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkFence_lookup(dec, &((VkFence *)args->pFences)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_framebuffer.h b/src/venus/venus-protocol/vn_protocol_renderer_framebuffer.h index 20798ec..a715c78 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_framebuffer.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_framebuffer.h @@ -108,10 +108,10 @@ vn_decode_VkFramebufferAttachmentsCreateInfo_self_temp(struct vn_cs_decoder *dec /* skip val->{sType,pNext} */ vn_decode_uint32_t(dec, &val->attachmentImageInfoCount); if (vn_peek_array_size(dec)) { - val->pAttachmentImageInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachmentImageInfos) * val->attachmentImageInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->attachmentImageInfoCount); + val->pAttachmentImageInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachmentImageInfos) * iter_count); if (!val->pAttachmentImageInfos) return; - vn_decode_array_size(dec, val->attachmentImageInfoCount); - for (uint32_t i = 0; i < val->attachmentImageInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkFramebufferAttachmentImageInfo_temp(dec, &((VkFramebufferAttachmentImageInfo *)val->pAttachmentImageInfos)[i]); } else { vn_decode_array_size(dec, 0); @@ -201,10 +201,10 @@ vn_decode_VkFramebufferCreateInfo_self_temp(struct vn_cs_decoder *dec, VkFramebu vn_decode_VkRenderPass_lookup(dec, &val->renderPass); vn_decode_uint32_t(dec, &val->attachmentCount); if (vn_peek_array_size(dec)) { - val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * val->attachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->attachmentCount); + val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * iter_count); if (!val->pAttachments) return; - vn_decode_array_size(dec, val->attachmentCount); - for (uint32_t i = 0; i < val->attachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkImageView_lookup(dec, &((VkImageView *)val->pAttachments)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_image.h b/src/venus/venus-protocol/vn_protocol_renderer_image.h index 6867c2d..9ec99a5 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_image.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_image.h @@ -220,10 +220,10 @@ vn_decode_VkImageDrmFormatModifierExplicitCreateInfoEXT_self_temp(struct vn_cs_d vn_decode_uint64_t(dec, &val->drmFormatModifier); vn_decode_uint32_t(dec, &val->drmFormatModifierPlaneCount); if (vn_peek_array_size(dec)) { - val->pPlaneLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPlaneLayouts) * val->drmFormatModifierPlaneCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->drmFormatModifierPlaneCount); + val->pPlaneLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPlaneLayouts) * iter_count); if (!val->pPlaneLayouts) return; - vn_decode_array_size(dec, val->drmFormatModifierPlaneCount); - for (uint32_t i = 0; i < val->drmFormatModifierPlaneCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSubresourceLayout_temp(dec, &((VkSubresourceLayout *)val->pPlaneLayouts)[i]); } else { vn_decode_array_size(dec, 0); @@ -495,10 +495,10 @@ vn_decode_VkBindImageMemoryDeviceGroupInfo_self_temp(struct vn_cs_decoder *dec, } vn_decode_uint32_t(dec, &val->splitInstanceBindRegionCount); if (vn_peek_array_size(dec)) { - val->pSplitInstanceBindRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSplitInstanceBindRegions) * val->splitInstanceBindRegionCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->splitInstanceBindRegionCount); + val->pSplitInstanceBindRegions = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSplitInstanceBindRegions) * iter_count); if (!val->pSplitInstanceBindRegions) return; - vn_decode_array_size(dec, val->splitInstanceBindRegionCount); - for (uint32_t i = 0; i < val->splitInstanceBindRegionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkRect2D_temp(dec, &((VkRect2D *)val->pSplitInstanceBindRegions)[i]); } else { vn_decode_array_size(dec, 0); @@ -1146,10 +1146,10 @@ static inline void vn_decode_vkGetImageSparseMemoryRequirements_args_temp(struct vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pSparseMemoryRequirements = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSparseMemoryRequirements) * (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0)); + args->pSparseMemoryRequirements = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSparseMemoryRequirements) * iter_count); if (!args->pSparseMemoryRequirements) return; - vn_decode_array_size(dec, (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0)); - for (uint32_t i = 0; i < (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseImageMemoryRequirements_partial_temp(dec, &args->pSparseMemoryRequirements[i]); } else { vn_decode_array_size(dec, 0); @@ -1303,10 +1303,10 @@ static inline void vn_decode_vkBindImageMemory2_args_temp(struct vn_cs_decoder * vn_decode_VkDevice_lookup(dec, &args->device); vn_decode_uint32_t(dec, &args->bindInfoCount); if (vn_peek_array_size(dec)) { - args->pBindInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBindInfos) * args->bindInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->bindInfoCount); + args->pBindInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBindInfos) * iter_count); if (!args->pBindInfos) return; - vn_decode_array_size(dec, args->bindInfoCount); - for (uint32_t i = 0; i < args->bindInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBindImageMemoryInfo_temp(dec, &((VkBindImageMemoryInfo *)args->pBindInfos)[i]); } else { vn_decode_array_size(dec, 0); @@ -1393,10 +1393,10 @@ static inline void vn_decode_vkGetImageSparseMemoryRequirements2_args_temp(struc vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pSparseMemoryRequirements = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSparseMemoryRequirements) * (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0)); + args->pSparseMemoryRequirements = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSparseMemoryRequirements) * iter_count); if (!args->pSparseMemoryRequirements) return; - vn_decode_array_size(dec, (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0)); - for (uint32_t i = 0; i < (args->pSparseMemoryRequirementCount ? *args->pSparseMemoryRequirementCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseImageMemoryRequirements2_partial_temp(dec, &args->pSparseMemoryRequirements[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_instance.h b/src/venus/venus-protocol/vn_protocol_renderer_instance.h index aadd596..5c1f4c7 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_instance.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_instance.h @@ -36,20 +36,20 @@ vn_decode_VkApplicationInfo_self_temp(struct vn_cs_decoder *dec, VkApplicationIn { /* skip val->{sType,pNext} */ if (vn_peek_array_size(dec)) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + const size_t string_size = vn_decode_array_size_unchecked(dec); val->pApplicationName = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pApplicationName) * string_size); if (!val->pApplicationName) return; - vn_decode_blob_array(dec, (char *)val->pApplicationName, string_size); + vn_decode_char_array(dec, (char *)val->pApplicationName, string_size); } else { vn_decode_array_size(dec, 0); val->pApplicationName = NULL; } vn_decode_uint32_t(dec, &val->applicationVersion); if (vn_peek_array_size(dec)) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + const size_t string_size = vn_decode_array_size_unchecked(dec); val->pEngineName = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pEngineName) * string_size); if (!val->pEngineName) return; - vn_decode_blob_array(dec, (char *)val->pEngineName, string_size); + vn_decode_char_array(dec, (char *)val->pEngineName, string_size); } else { vn_decode_array_size(dec, 0); val->pEngineName = NULL; @@ -126,14 +126,14 @@ vn_decode_VkInstanceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkInstanceCr } vn_decode_uint32_t(dec, &val->enabledLayerCount); if (vn_peek_array_size(dec)) { - val->ppEnabledLayerNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledLayerNames) * val->enabledLayerCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->enabledLayerCount); + val->ppEnabledLayerNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledLayerNames) * iter_count); if (!val->ppEnabledLayerNames) return; - vn_decode_array_size(dec, val->enabledLayerCount); - for (uint32_t i = 0; i < val->enabledLayerCount; i++) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + for (uint32_t i = 0; i < iter_count; i++) { + const size_t string_size = vn_decode_array_size_unchecked(dec); ((char **)val->ppEnabledLayerNames)[i] = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledLayerNames[i]) * string_size); if (!val->ppEnabledLayerNames[i]) return; - vn_decode_blob_array(dec, ((char **)val->ppEnabledLayerNames)[i], string_size); + vn_decode_char_array(dec, ((char **)val->ppEnabledLayerNames)[i], string_size); } } else { vn_decode_array_size(dec, 0); @@ -141,14 +141,14 @@ vn_decode_VkInstanceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkInstanceCr } vn_decode_uint32_t(dec, &val->enabledExtensionCount); if (vn_peek_array_size(dec)) { - val->ppEnabledExtensionNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledExtensionNames) * val->enabledExtensionCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->enabledExtensionCount); + val->ppEnabledExtensionNames = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledExtensionNames) * iter_count); if (!val->ppEnabledExtensionNames) return; - vn_decode_array_size(dec, val->enabledExtensionCount); - for (uint32_t i = 0; i < val->enabledExtensionCount; i++) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + for (uint32_t i = 0; i < iter_count; i++) { + const size_t string_size = vn_decode_array_size_unchecked(dec); ((char **)val->ppEnabledExtensionNames)[i] = vn_cs_decoder_alloc_temp(dec, sizeof(*val->ppEnabledExtensionNames[i]) * string_size); if (!val->ppEnabledExtensionNames[i]) return; - vn_decode_blob_array(dec, ((char **)val->ppEnabledExtensionNames)[i], string_size); + vn_decode_char_array(dec, ((char **)val->ppEnabledExtensionNames)[i], string_size); } } else { vn_decode_array_size(dec, 0); @@ -305,10 +305,10 @@ static inline void vn_decode_vkEnumerateInstanceLayerProperties_args_temp(struct vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * (args->pPropertyCount ? *args->pPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); + args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * iter_count); if (!args->pProperties) return; - vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pPropertyCount ? *args->pPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkLayerProperties_partial_temp(dec, &args->pProperties[i]); } else { vn_decode_array_size(dec, 0); @@ -341,10 +341,10 @@ static inline void vn_encode_vkEnumerateInstanceLayerProperties_reply(struct vn_ static inline void vn_decode_vkEnumerateInstanceExtensionProperties_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkEnumerateInstanceExtensionProperties *args) { if (vn_peek_array_size(dec)) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + const size_t string_size = vn_decode_array_size_unchecked(dec); args->pLayerName = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pLayerName) * string_size); if (!args->pLayerName) return; - vn_decode_blob_array(dec, (char *)args->pLayerName, string_size); + vn_decode_char_array(dec, (char *)args->pLayerName, string_size); } else { vn_decode_array_size(dec, 0); args->pLayerName = NULL; @@ -358,10 +358,10 @@ static inline void vn_decode_vkEnumerateInstanceExtensionProperties_args_temp(st vn_cs_decoder_set_fatal(dec); } if (vn_peek_array_size(dec)) { - args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * (args->pPropertyCount ? *args->pPropertyCount : 0)); + const uint32_t iter_count = vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); + args->pProperties = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pProperties) * iter_count); if (!args->pProperties) return; - vn_decode_array_size(dec, (args->pPropertyCount ? *args->pPropertyCount : 0)); - for (uint32_t i = 0; i < (args->pPropertyCount ? *args->pPropertyCount : 0); i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkExtensionProperties_partial_temp(dec, &args->pProperties[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_pipeline.h b/src/venus/venus-protocol/vn_protocol_renderer_pipeline.h index 897f58b..6254f39 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_pipeline.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_pipeline.h @@ -39,10 +39,10 @@ vn_decode_VkSpecializationInfo_temp(struct vn_cs_decoder *dec, VkSpecializationI { vn_decode_uint32_t(dec, &val->mapEntryCount); if (vn_peek_array_size(dec)) { - val->pMapEntries = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pMapEntries) * val->mapEntryCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->mapEntryCount); + val->pMapEntries = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pMapEntries) * iter_count); if (!val->pMapEntries) return; - vn_decode_array_size(dec, val->mapEntryCount); - for (uint32_t i = 0; i < val->mapEntryCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSpecializationMapEntry_temp(dec, &((VkSpecializationMapEntry *)val->pMapEntries)[i]); } else { vn_decode_array_size(dec, 0); @@ -91,10 +91,10 @@ vn_decode_VkPipelineShaderStageCreateInfo_self_temp(struct vn_cs_decoder *dec, V vn_decode_VkShaderStageFlagBits(dec, &val->stage); vn_decode_VkShaderModule_lookup(dec, &val->module); if (vn_peek_array_size(dec)) { - const size_t string_size = vn_decode_array_size(dec, UINT64_MAX); + const size_t string_size = vn_decode_array_size_unchecked(dec); val->pName = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pName) * string_size); if (!val->pName) return; - vn_decode_blob_array(dec, (char *)val->pName, string_size); + vn_decode_char_array(dec, (char *)val->pName, string_size); } else { vn_decode_array_size(dec, 0); val->pName = NULL; @@ -208,10 +208,10 @@ vn_decode_VkPipelineVertexInputStateCreateInfo_self_temp(struct vn_cs_decoder *d vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->vertexBindingDescriptionCount); if (vn_peek_array_size(dec)) { - val->pVertexBindingDescriptions = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pVertexBindingDescriptions) * val->vertexBindingDescriptionCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->vertexBindingDescriptionCount); + val->pVertexBindingDescriptions = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pVertexBindingDescriptions) * iter_count); if (!val->pVertexBindingDescriptions) return; - vn_decode_array_size(dec, val->vertexBindingDescriptionCount); - for (uint32_t i = 0; i < val->vertexBindingDescriptionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkVertexInputBindingDescription_temp(dec, &((VkVertexInputBindingDescription *)val->pVertexBindingDescriptions)[i]); } else { vn_decode_array_size(dec, 0); @@ -219,10 +219,10 @@ vn_decode_VkPipelineVertexInputStateCreateInfo_self_temp(struct vn_cs_decoder *d } vn_decode_uint32_t(dec, &val->vertexAttributeDescriptionCount); if (vn_peek_array_size(dec)) { - val->pVertexAttributeDescriptions = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pVertexAttributeDescriptions) * val->vertexAttributeDescriptionCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->vertexAttributeDescriptionCount); + val->pVertexAttributeDescriptions = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pVertexAttributeDescriptions) * iter_count); if (!val->pVertexAttributeDescriptions) return; - vn_decode_array_size(dec, val->vertexAttributeDescriptionCount); - for (uint32_t i = 0; i < val->vertexAttributeDescriptionCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkVertexInputAttributeDescription_temp(dec, &((VkVertexInputAttributeDescription *)val->pVertexAttributeDescriptions)[i]); } else { vn_decode_array_size(dec, 0); @@ -497,10 +497,10 @@ vn_decode_VkPipelineViewportStateCreateInfo_self_temp(struct vn_cs_decoder *dec, vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->viewportCount); if (vn_peek_array_size(dec)) { - val->pViewports = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pViewports) * val->viewportCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->viewportCount); + val->pViewports = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pViewports) * iter_count); if (!val->pViewports) return; - vn_decode_array_size(dec, val->viewportCount); - for (uint32_t i = 0; i < val->viewportCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkViewport_temp(dec, &((VkViewport *)val->pViewports)[i]); } else { vn_decode_array_size(dec, 0); @@ -508,10 +508,10 @@ vn_decode_VkPipelineViewportStateCreateInfo_self_temp(struct vn_cs_decoder *dec, } vn_decode_uint32_t(dec, &val->scissorCount); if (vn_peek_array_size(dec)) { - val->pScissors = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pScissors) * val->scissorCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->scissorCount); + val->pScissors = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pScissors) * iter_count); if (!val->pScissors) return; - vn_decode_array_size(dec, val->scissorCount); - for (uint32_t i = 0; i < val->scissorCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkRect2D_temp(dec, &((VkRect2D *)val->pScissors)[i]); } else { vn_decode_array_size(dec, 0); @@ -953,10 +953,10 @@ vn_decode_VkPipelineColorBlendStateCreateInfo_self_temp(struct vn_cs_decoder *de vn_decode_VkLogicOp(dec, &val->logicOp); vn_decode_uint32_t(dec, &val->attachmentCount); if (vn_peek_array_size(dec)) { - val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * val->attachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->attachmentCount); + val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * iter_count); if (!val->pAttachments) return; - vn_decode_array_size(dec, val->attachmentCount); - for (uint32_t i = 0; i < val->attachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPipelineColorBlendAttachmentState_temp(dec, &((VkPipelineColorBlendAttachmentState *)val->pAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -1102,10 +1102,10 @@ vn_decode_VkGraphicsPipelineCreateInfo_self_temp(struct vn_cs_decoder *dec, VkGr vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->stageCount); if (vn_peek_array_size(dec)) { - val->pStages = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pStages) * val->stageCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->stageCount); + val->pStages = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pStages) * iter_count); if (!val->pStages) return; - vn_decode_array_size(dec, val->stageCount); - for (uint32_t i = 0; i < val->stageCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPipelineShaderStageCreateInfo_temp(dec, &((VkPipelineShaderStageCreateInfo *)val->pStages)[i]); } else { vn_decode_array_size(dec, 0); @@ -1320,10 +1320,10 @@ static inline void vn_decode_vkCreateGraphicsPipelines_args_temp(struct vn_cs_de vn_decode_VkPipelineCache_lookup(dec, &args->pipelineCache); vn_decode_uint32_t(dec, &args->createInfoCount); if (vn_peek_array_size(dec)) { - args->pCreateInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfos) * args->createInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->createInfoCount); + args->pCreateInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfos) * iter_count); if (!args->pCreateInfos) return; - vn_decode_array_size(dec, args->createInfoCount); - for (uint32_t i = 0; i < args->createInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkGraphicsPipelineCreateInfo_temp(dec, &((VkGraphicsPipelineCreateInfo *)args->pCreateInfos)[i]); } else { vn_decode_array_size(dec, 0); @@ -1335,10 +1335,10 @@ static inline void vn_decode_vkCreateGraphicsPipelines_args_temp(struct vn_cs_de args->pAllocator = NULL; } if (vn_peek_array_size(dec)) { - args->pPipelines = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPipelines) * args->createInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->createInfoCount); + args->pPipelines = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPipelines) * iter_count); if (!args->pPipelines) return; - vn_decode_array_size(dec, args->createInfoCount); - for (uint32_t i = 0; i < args->createInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPipeline(dec, &args->pPipelines[i]); } else { vn_decode_array_size(dec, 0); @@ -1384,10 +1384,10 @@ static inline void vn_decode_vkCreateComputePipelines_args_temp(struct vn_cs_dec vn_decode_VkPipelineCache_lookup(dec, &args->pipelineCache); vn_decode_uint32_t(dec, &args->createInfoCount); if (vn_peek_array_size(dec)) { - args->pCreateInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfos) * args->createInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->createInfoCount); + args->pCreateInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfos) * iter_count); if (!args->pCreateInfos) return; - vn_decode_array_size(dec, args->createInfoCount); - for (uint32_t i = 0; i < args->createInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkComputePipelineCreateInfo_temp(dec, &((VkComputePipelineCreateInfo *)args->pCreateInfos)[i]); } else { vn_decode_array_size(dec, 0); @@ -1399,10 +1399,10 @@ static inline void vn_decode_vkCreateComputePipelines_args_temp(struct vn_cs_dec args->pAllocator = NULL; } if (vn_peek_array_size(dec)) { - args->pPipelines = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPipelines) * args->createInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->createInfoCount); + args->pPipelines = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPipelines) * iter_count); if (!args->pPipelines) return; - vn_decode_array_size(dec, args->createInfoCount); - for (uint32_t i = 0; i < args->createInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPipeline(dec, &args->pPipelines[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_pipeline_cache.h b/src/venus/venus-protocol/vn_protocol_renderer_pipeline_cache.h index 1ebb0df..d6d89ff 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_pipeline_cache.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_pipeline_cache.h @@ -210,10 +210,10 @@ static inline void vn_decode_vkMergePipelineCaches_args_temp(struct vn_cs_decode vn_decode_VkPipelineCache_lookup(dec, &args->dstCache); vn_decode_uint32_t(dec, &args->srcCacheCount); if (vn_peek_array_size(dec)) { - args->pSrcCaches = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSrcCaches) * args->srcCacheCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->srcCacheCount); + args->pSrcCaches = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSrcCaches) * iter_count); if (!args->pSrcCaches) return; - vn_decode_array_size(dec, args->srcCacheCount); - for (uint32_t i = 0; i < args->srcCacheCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPipelineCache_lookup(dec, &((VkPipelineCache *)args->pSrcCaches)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_pipeline_layout.h b/src/venus/venus-protocol/vn_protocol_renderer_pipeline_layout.h index 0d1eac1..ae00299 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_pipeline_layout.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_pipeline_layout.h @@ -50,10 +50,10 @@ vn_decode_VkPipelineLayoutCreateInfo_self_temp(struct vn_cs_decoder *dec, VkPipe vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->setLayoutCount); if (vn_peek_array_size(dec)) { - val->pSetLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSetLayouts) * val->setLayoutCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->setLayoutCount); + val->pSetLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSetLayouts) * iter_count); if (!val->pSetLayouts) return; - vn_decode_array_size(dec, val->setLayoutCount); - for (uint32_t i = 0; i < val->setLayoutCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkDescriptorSetLayout_lookup(dec, &((VkDescriptorSetLayout *)val->pSetLayouts)[i]); } else { vn_decode_array_size(dec, 0); @@ -61,10 +61,10 @@ vn_decode_VkPipelineLayoutCreateInfo_self_temp(struct vn_cs_decoder *dec, VkPipe } vn_decode_uint32_t(dec, &val->pushConstantRangeCount); if (vn_peek_array_size(dec)) { - val->pPushConstantRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPushConstantRanges) * val->pushConstantRangeCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->pushConstantRangeCount); + val->pPushConstantRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPushConstantRanges) * iter_count); if (!val->pPushConstantRanges) return; - vn_decode_array_size(dec, val->pushConstantRangeCount); - for (uint32_t i = 0; i < val->pushConstantRangeCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkPushConstantRange_temp(dec, &((VkPushConstantRange *)val->pPushConstantRanges)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_queue.h b/src/venus/venus-protocol/vn_protocol_renderer_queue.h index 7c4fd29..8ca8f3a 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_queue.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_queue.h @@ -294,20 +294,20 @@ vn_decode_VkSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkSubmitInfo *val) /* skip val->{sType,pNext} */ vn_decode_uint32_t(dec, &val->waitSemaphoreCount); if (vn_peek_array_size(dec)) { - val->pWaitSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphores) * val->waitSemaphoreCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->waitSemaphoreCount); + val->pWaitSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphores) * iter_count); if (!val->pWaitSemaphores) return; - vn_decode_array_size(dec, val->waitSemaphoreCount); - for (uint32_t i = 0; i < val->waitSemaphoreCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pWaitSemaphores)[i]); } else { vn_decode_array_size(dec, 0); val->pWaitSemaphores = NULL; } if (vn_peek_array_size(dec)) { - val->pWaitDstStageMask = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitDstStageMask) * val->waitSemaphoreCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->waitSemaphoreCount); + val->pWaitDstStageMask = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitDstStageMask) * iter_count); if (!val->pWaitDstStageMask) return; - vn_decode_array_size(dec, val->waitSemaphoreCount); - for (uint32_t i = 0; i < val->waitSemaphoreCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkFlags(dec, &((VkPipelineStageFlags *)val->pWaitDstStageMask)[i]); } else { vn_decode_array_size(dec, 0); @@ -315,10 +315,10 @@ vn_decode_VkSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkSubmitInfo *val) } vn_decode_uint32_t(dec, &val->commandBufferCount); if (vn_peek_array_size(dec)) { - val->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pCommandBuffers) * val->commandBufferCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->commandBufferCount); + val->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pCommandBuffers) * iter_count); if (!val->pCommandBuffers) return; - vn_decode_array_size(dec, val->commandBufferCount); - for (uint32_t i = 0; i < val->commandBufferCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkCommandBuffer_lookup(dec, &((VkCommandBuffer *)val->pCommandBuffers)[i]); } else { vn_decode_array_size(dec, 0); @@ -326,10 +326,10 @@ vn_decode_VkSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkSubmitInfo *val) } vn_decode_uint32_t(dec, &val->signalSemaphoreCount); if (vn_peek_array_size(dec)) { - val->pSignalSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphores) * val->signalSemaphoreCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->signalSemaphoreCount); + val->pSignalSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphores) * iter_count); if (!val->pSignalSemaphores) return; - vn_decode_array_size(dec, val->signalSemaphoreCount); - for (uint32_t i = 0; i < val->signalSemaphoreCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pSignalSemaphores)[i]); } else { vn_decode_array_size(dec, 0); @@ -430,10 +430,10 @@ vn_decode_VkSparseBufferMemoryBindInfo_temp(struct vn_cs_decoder *dec, VkSparseB vn_decode_VkBuffer_lookup(dec, &val->buffer); vn_decode_uint32_t(dec, &val->bindCount); if (vn_peek_array_size(dec)) { - val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * val->bindCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->bindCount); + val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * iter_count); if (!val->pBinds) return; - vn_decode_array_size(dec, val->bindCount); - for (uint32_t i = 0; i < val->bindCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseMemoryBind_temp(dec, &((VkSparseMemoryBind *)val->pBinds)[i]); } else { vn_decode_array_size(dec, 0); @@ -460,10 +460,10 @@ vn_decode_VkSparseImageOpaqueMemoryBindInfo_temp(struct vn_cs_decoder *dec, VkSp vn_decode_VkImage_lookup(dec, &val->image); vn_decode_uint32_t(dec, &val->bindCount); if (vn_peek_array_size(dec)) { - val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * val->bindCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->bindCount); + val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * iter_count); if (!val->pBinds) return; - vn_decode_array_size(dec, val->bindCount); - for (uint32_t i = 0; i < val->bindCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseMemoryBind_temp(dec, &((VkSparseMemoryBind *)val->pBinds)[i]); } else { vn_decode_array_size(dec, 0); @@ -514,10 +514,10 @@ vn_decode_VkSparseImageMemoryBindInfo_temp(struct vn_cs_decoder *dec, VkSparseIm vn_decode_VkImage_lookup(dec, &val->image); vn_decode_uint32_t(dec, &val->bindCount); if (vn_peek_array_size(dec)) { - val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * val->bindCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->bindCount); + val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * iter_count); if (!val->pBinds) return; - vn_decode_array_size(dec, val->bindCount); - for (uint32_t i = 0; i < val->bindCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseImageMemoryBind_temp(dec, &((VkSparseImageMemoryBind *)val->pBinds)[i]); } else { vn_decode_array_size(dec, 0); @@ -640,10 +640,10 @@ vn_decode_VkBindSparseInfo_self_temp(struct vn_cs_decoder *dec, VkBindSparseInfo /* skip val->{sType,pNext} */ vn_decode_uint32_t(dec, &val->waitSemaphoreCount); if (vn_peek_array_size(dec)) { - val->pWaitSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphores) * val->waitSemaphoreCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->waitSemaphoreCount); + val->pWaitSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphores) * iter_count); if (!val->pWaitSemaphores) return; - vn_decode_array_size(dec, val->waitSemaphoreCount); - for (uint32_t i = 0; i < val->waitSemaphoreCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pWaitSemaphores)[i]); } else { vn_decode_array_size(dec, 0); @@ -651,10 +651,10 @@ vn_decode_VkBindSparseInfo_self_temp(struct vn_cs_decoder *dec, VkBindSparseInfo } vn_decode_uint32_t(dec, &val->bufferBindCount); if (vn_peek_array_size(dec)) { - val->pBufferBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBufferBinds) * val->bufferBindCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->bufferBindCount); + val->pBufferBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBufferBinds) * iter_count); if (!val->pBufferBinds) return; - vn_decode_array_size(dec, val->bufferBindCount); - for (uint32_t i = 0; i < val->bufferBindCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseBufferMemoryBindInfo_temp(dec, &((VkSparseBufferMemoryBindInfo *)val->pBufferBinds)[i]); } else { vn_decode_array_size(dec, 0); @@ -662,10 +662,10 @@ vn_decode_VkBindSparseInfo_self_temp(struct vn_cs_decoder *dec, VkBindSparseInfo } vn_decode_uint32_t(dec, &val->imageOpaqueBindCount); if (vn_peek_array_size(dec)) { - val->pImageOpaqueBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageOpaqueBinds) * val->imageOpaqueBindCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->imageOpaqueBindCount); + val->pImageOpaqueBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageOpaqueBinds) * iter_count); if (!val->pImageOpaqueBinds) return; - vn_decode_array_size(dec, val->imageOpaqueBindCount); - for (uint32_t i = 0; i < val->imageOpaqueBindCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseImageOpaqueMemoryBindInfo_temp(dec, &((VkSparseImageOpaqueMemoryBindInfo *)val->pImageOpaqueBinds)[i]); } else { vn_decode_array_size(dec, 0); @@ -673,10 +673,10 @@ vn_decode_VkBindSparseInfo_self_temp(struct vn_cs_decoder *dec, VkBindSparseInfo } vn_decode_uint32_t(dec, &val->imageBindCount); if (vn_peek_array_size(dec)) { - val->pImageBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageBinds) * val->imageBindCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->imageBindCount); + val->pImageBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageBinds) * iter_count); if (!val->pImageBinds) return; - vn_decode_array_size(dec, val->imageBindCount); - for (uint32_t i = 0; i < val->imageBindCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSparseImageMemoryBindInfo_temp(dec, &((VkSparseImageMemoryBindInfo *)val->pImageBinds)[i]); } else { vn_decode_array_size(dec, 0); @@ -684,10 +684,10 @@ vn_decode_VkBindSparseInfo_self_temp(struct vn_cs_decoder *dec, VkBindSparseInfo } vn_decode_uint32_t(dec, &val->signalSemaphoreCount); if (vn_peek_array_size(dec)) { - val->pSignalSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphores) * val->signalSemaphoreCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->signalSemaphoreCount); + val->pSignalSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphores) * iter_count); if (!val->pSignalSemaphores) return; - vn_decode_array_size(dec, val->signalSemaphoreCount); - for (uint32_t i = 0; i < val->signalSemaphoreCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pSignalSemaphores)[i]); } else { vn_decode_array_size(dec, 0); @@ -769,10 +769,10 @@ static inline void vn_decode_vkQueueSubmit_args_temp(struct vn_cs_decoder *dec, vn_decode_VkQueue_lookup(dec, &args->queue); vn_decode_uint32_t(dec, &args->submitCount); if (vn_peek_array_size(dec)) { - args->pSubmits = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSubmits) * args->submitCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->submitCount); + args->pSubmits = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSubmits) * iter_count); if (!args->pSubmits) return; - vn_decode_array_size(dec, args->submitCount); - for (uint32_t i = 0; i < args->submitCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSubmitInfo_temp(dec, &((VkSubmitInfo *)args->pSubmits)[i]); } else { vn_decode_array_size(dec, 0); @@ -826,10 +826,10 @@ static inline void vn_decode_vkQueueBindSparse_args_temp(struct vn_cs_decoder *d vn_decode_VkQueue_lookup(dec, &args->queue); vn_decode_uint32_t(dec, &args->bindInfoCount); if (vn_peek_array_size(dec)) { - args->pBindInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBindInfo) * args->bindInfoCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->bindInfoCount); + args->pBindInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBindInfo) * iter_count); if (!args->pBindInfo) return; - vn_decode_array_size(dec, args->bindInfoCount); - for (uint32_t i = 0; i < args->bindInfoCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkBindSparseInfo_temp(dec, &((VkBindSparseInfo *)args->pBindInfo)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_render_pass.h b/src/venus/venus-protocol/vn_protocol_renderer_render_pass.h index 5f8389e..dbf22b2 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_render_pass.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_render_pass.h @@ -69,10 +69,10 @@ vn_decode_VkSubpassDescription_temp(struct vn_cs_decoder *dec, VkSubpassDescript vn_decode_VkPipelineBindPoint(dec, &val->pipelineBindPoint); vn_decode_uint32_t(dec, &val->inputAttachmentCount); if (vn_peek_array_size(dec)) { - val->pInputAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pInputAttachments) * val->inputAttachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->inputAttachmentCount); + val->pInputAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pInputAttachments) * iter_count); if (!val->pInputAttachments) return; - vn_decode_array_size(dec, val->inputAttachmentCount); - for (uint32_t i = 0; i < val->inputAttachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentReference_temp(dec, &((VkAttachmentReference *)val->pInputAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -80,20 +80,20 @@ vn_decode_VkSubpassDescription_temp(struct vn_cs_decoder *dec, VkSubpassDescript } vn_decode_uint32_t(dec, &val->colorAttachmentCount); if (vn_peek_array_size(dec)) { - val->pColorAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pColorAttachments) * val->colorAttachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->colorAttachmentCount); + val->pColorAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pColorAttachments) * iter_count); if (!val->pColorAttachments) return; - vn_decode_array_size(dec, val->colorAttachmentCount); - for (uint32_t i = 0; i < val->colorAttachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentReference_temp(dec, &((VkAttachmentReference *)val->pColorAttachments)[i]); } else { vn_decode_array_size(dec, 0); val->pColorAttachments = NULL; } if (vn_peek_array_size(dec)) { - val->pResolveAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pResolveAttachments) * val->colorAttachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->colorAttachmentCount); + val->pResolveAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pResolveAttachments) * iter_count); if (!val->pResolveAttachments) return; - vn_decode_array_size(dec, val->colorAttachmentCount); - for (uint32_t i = 0; i < val->colorAttachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentReference_temp(dec, &((VkAttachmentReference *)val->pResolveAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -295,10 +295,10 @@ vn_decode_VkRenderPassInputAttachmentAspectCreateInfo_self_temp(struct vn_cs_dec /* skip val->{sType,pNext} */ vn_decode_uint32_t(dec, &val->aspectReferenceCount); if (vn_peek_array_size(dec)) { - val->pAspectReferences = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAspectReferences) * val->aspectReferenceCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->aspectReferenceCount); + val->pAspectReferences = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAspectReferences) * iter_count); if (!val->pAspectReferences) return; - vn_decode_array_size(dec, val->aspectReferenceCount); - for (uint32_t i = 0; i < val->aspectReferenceCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkInputAttachmentAspectReference_temp(dec, &((VkInputAttachmentAspectReference *)val->pAspectReferences)[i]); } else { vn_decode_array_size(dec, 0); @@ -395,10 +395,10 @@ vn_decode_VkRenderPassCreateInfo_self_temp(struct vn_cs_decoder *dec, VkRenderPa vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->attachmentCount); if (vn_peek_array_size(dec)) { - val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * val->attachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->attachmentCount); + val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * iter_count); if (!val->pAttachments) return; - vn_decode_array_size(dec, val->attachmentCount); - for (uint32_t i = 0; i < val->attachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentDescription_temp(dec, &((VkAttachmentDescription *)val->pAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -406,10 +406,10 @@ vn_decode_VkRenderPassCreateInfo_self_temp(struct vn_cs_decoder *dec, VkRenderPa } vn_decode_uint32_t(dec, &val->subpassCount); if (vn_peek_array_size(dec)) { - val->pSubpasses = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSubpasses) * val->subpassCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->subpassCount); + val->pSubpasses = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSubpasses) * iter_count); if (!val->pSubpasses) return; - vn_decode_array_size(dec, val->subpassCount); - for (uint32_t i = 0; i < val->subpassCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSubpassDescription_temp(dec, &((VkSubpassDescription *)val->pSubpasses)[i]); } else { vn_decode_array_size(dec, 0); @@ -417,10 +417,10 @@ vn_decode_VkRenderPassCreateInfo_self_temp(struct vn_cs_decoder *dec, VkRenderPa } vn_decode_uint32_t(dec, &val->dependencyCount); if (vn_peek_array_size(dec)) { - val->pDependencies = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDependencies) * val->dependencyCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->dependencyCount); + val->pDependencies = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDependencies) * iter_count); if (!val->pDependencies) return; - vn_decode_array_size(dec, val->dependencyCount); - for (uint32_t i = 0; i < val->dependencyCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSubpassDependency_temp(dec, &((VkSubpassDependency *)val->pDependencies)[i]); } else { vn_decode_array_size(dec, 0); @@ -892,10 +892,10 @@ vn_decode_VkSubpassDescription2_self_temp(struct vn_cs_decoder *dec, VkSubpassDe vn_decode_uint32_t(dec, &val->viewMask); vn_decode_uint32_t(dec, &val->inputAttachmentCount); if (vn_peek_array_size(dec)) { - val->pInputAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pInputAttachments) * val->inputAttachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->inputAttachmentCount); + val->pInputAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pInputAttachments) * iter_count); if (!val->pInputAttachments) return; - vn_decode_array_size(dec, val->inputAttachmentCount); - for (uint32_t i = 0; i < val->inputAttachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentReference2_temp(dec, &((VkAttachmentReference2 *)val->pInputAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -903,20 +903,20 @@ vn_decode_VkSubpassDescription2_self_temp(struct vn_cs_decoder *dec, VkSubpassDe } vn_decode_uint32_t(dec, &val->colorAttachmentCount); if (vn_peek_array_size(dec)) { - val->pColorAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pColorAttachments) * val->colorAttachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->colorAttachmentCount); + val->pColorAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pColorAttachments) * iter_count); if (!val->pColorAttachments) return; - vn_decode_array_size(dec, val->colorAttachmentCount); - for (uint32_t i = 0; i < val->colorAttachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentReference2_temp(dec, &((VkAttachmentReference2 *)val->pColorAttachments)[i]); } else { vn_decode_array_size(dec, 0); val->pColorAttachments = NULL; } if (vn_peek_array_size(dec)) { - val->pResolveAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pResolveAttachments) * val->colorAttachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->colorAttachmentCount); + val->pResolveAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pResolveAttachments) * iter_count); if (!val->pResolveAttachments) return; - vn_decode_array_size(dec, val->colorAttachmentCount); - for (uint32_t i = 0; i < val->colorAttachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentReference2_temp(dec, &((VkAttachmentReference2 *)val->pResolveAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -1092,10 +1092,10 @@ vn_decode_VkRenderPassCreateInfo2_self_temp(struct vn_cs_decoder *dec, VkRenderP vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->attachmentCount); if (vn_peek_array_size(dec)) { - val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * val->attachmentCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->attachmentCount); + val->pAttachments = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pAttachments) * iter_count); if (!val->pAttachments) return; - vn_decode_array_size(dec, val->attachmentCount); - for (uint32_t i = 0; i < val->attachmentCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkAttachmentDescription2_temp(dec, &((VkAttachmentDescription2 *)val->pAttachments)[i]); } else { vn_decode_array_size(dec, 0); @@ -1103,10 +1103,10 @@ vn_decode_VkRenderPassCreateInfo2_self_temp(struct vn_cs_decoder *dec, VkRenderP } vn_decode_uint32_t(dec, &val->subpassCount); if (vn_peek_array_size(dec)) { - val->pSubpasses = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSubpasses) * val->subpassCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->subpassCount); + val->pSubpasses = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSubpasses) * iter_count); if (!val->pSubpasses) return; - vn_decode_array_size(dec, val->subpassCount); - for (uint32_t i = 0; i < val->subpassCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSubpassDescription2_temp(dec, &((VkSubpassDescription2 *)val->pSubpasses)[i]); } else { vn_decode_array_size(dec, 0); @@ -1114,10 +1114,10 @@ vn_decode_VkRenderPassCreateInfo2_self_temp(struct vn_cs_decoder *dec, VkRenderP } vn_decode_uint32_t(dec, &val->dependencyCount); if (vn_peek_array_size(dec)) { - val->pDependencies = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDependencies) * val->dependencyCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->dependencyCount); + val->pDependencies = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDependencies) * iter_count); if (!val->pDependencies) return; - vn_decode_array_size(dec, val->dependencyCount); - for (uint32_t i = 0; i < val->dependencyCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSubpassDependency2_temp(dec, &((VkSubpassDependency2 *)val->pDependencies)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_semaphore.h b/src/venus/venus-protocol/vn_protocol_renderer_semaphore.h index 90840be..a20e85c 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_semaphore.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_semaphore.h @@ -180,10 +180,10 @@ vn_decode_VkSemaphoreWaitInfo_self_temp(struct vn_cs_decoder *dec, VkSemaphoreWa vn_decode_VkFlags(dec, &val->flags); vn_decode_uint32_t(dec, &val->semaphoreCount); if (vn_peek_array_size(dec)) { - val->pSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSemaphores) * val->semaphoreCount); + const uint32_t iter_count = vn_decode_array_size(dec, val->semaphoreCount); + val->pSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSemaphores) * iter_count); if (!val->pSemaphores) return; - vn_decode_array_size(dec, val->semaphoreCount); - for (uint32_t i = 0; i < val->semaphoreCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pSemaphores)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_structs.h b/src/venus/venus-protocol/vn_protocol_renderer_structs.h index 6287523..8694bb6 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_structs.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_structs.h @@ -60,11 +60,11 @@ static inline void vn_encode_VkLayerProperties(struct vn_cs_encoder *enc, const VkLayerProperties *val) { vn_encode_array_size(enc, VK_MAX_EXTENSION_NAME_SIZE); - vn_encode_blob_array(enc, val->layerName, VK_MAX_EXTENSION_NAME_SIZE); + vn_encode_char_array(enc, val->layerName, VK_MAX_EXTENSION_NAME_SIZE); vn_encode_uint32_t(enc, &val->specVersion); vn_encode_uint32_t(enc, &val->implementationVersion); vn_encode_array_size(enc, VK_MAX_DESCRIPTION_SIZE); - vn_encode_blob_array(enc, val->description, VK_MAX_DESCRIPTION_SIZE); + vn_encode_char_array(enc, val->description, VK_MAX_DESCRIPTION_SIZE); } static inline void @@ -82,7 +82,7 @@ static inline void vn_encode_VkExtensionProperties(struct vn_cs_encoder *enc, const VkExtensionProperties *val) { vn_encode_array_size(enc, VK_MAX_EXTENSION_NAME_SIZE); - vn_encode_blob_array(enc, val->extensionName, VK_MAX_EXTENSION_NAME_SIZE); + vn_encode_char_array(enc, val->extensionName, VK_MAX_EXTENSION_NAME_SIZE); vn_encode_uint32_t(enc, &val->specVersion); } @@ -91,7 +91,7 @@ vn_decode_VkExtensionProperties_temp(struct vn_cs_decoder *dec, VkExtensionPrope { { const size_t array_size = vn_decode_array_size(dec, VK_MAX_EXTENSION_NAME_SIZE); - vn_decode_blob_array(dec, val->extensionName, array_size); + vn_decode_char_array(dec, val->extensionName, array_size); } vn_decode_uint32_t(dec, &val->specVersion); } diff --git a/src/venus/venus-protocol/vn_protocol_renderer_transport.h b/src/venus/venus-protocol/vn_protocol_renderer_transport.h index 7bb052e..fbf4f15 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_transport.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_transport.h @@ -324,10 +324,10 @@ static inline void vn_decode_vkExecuteCommandStreamsMESA_args_temp(struct vn_cs_ { vn_decode_uint32_t(dec, &args->streamCount); if (vn_peek_array_size(dec)) { - args->pStreams = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pStreams) * args->streamCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->streamCount); + args->pStreams = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pStreams) * iter_count); if (!args->pStreams) return; - vn_decode_array_size(dec, args->streamCount); - for (uint32_t i = 0; i < args->streamCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkCommandStreamDescriptionMESA_temp(dec, &((VkCommandStreamDescriptionMESA *)args->pStreams)[i]); } else { vn_decode_array_size(dec, 0); @@ -344,10 +344,10 @@ static inline void vn_decode_vkExecuteCommandStreamsMESA_args_temp(struct vn_cs_ } vn_decode_uint32_t(dec, &args->dependencyCount); if (vn_peek_array_size(dec)) { - args->pDependencies = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDependencies) * args->dependencyCount); + const uint32_t iter_count = vn_decode_array_size(dec, args->dependencyCount); + args->pDependencies = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDependencies) * iter_count); if (!args->pDependencies) return; - vn_decode_array_size(dec, args->dependencyCount); - for (uint32_t i = 0; i < args->dependencyCount; i++) + for (uint32_t i = 0; i < iter_count; i++) vn_decode_VkCommandStreamDependencyMESA_temp(dec, &((VkCommandStreamDependencyMESA *)args->pDependencies)[i]); } else { vn_decode_array_size(dec, 0); diff --git a/src/venus/venus-protocol/vn_protocol_renderer_types.h b/src/venus/venus-protocol/vn_protocol_renderer_types.h index 28044d8..f370014 100644 --- a/src/venus/venus-protocol/vn_protocol_renderer_types.h +++ b/src/venus/venus-protocol/vn_protocol_renderer_types.h @@ -137,6 +137,25 @@ vn_decode_blob_array(struct vn_cs_decoder *dec, void *val, size_t size) vn_decode(dec, (size + 3) & ~3, val, size); } +/* string */ + +static inline void +vn_encode_char_array(struct vn_cs_encoder *enc, const char *val, size_t size) +{ + assert(size && strlen(val) < size); + vn_encode_blob_array(enc, val, size); +} + +static inline void +vn_decode_char_array(struct vn_cs_decoder *dec, char *val, size_t size) +{ + vn_decode_blob_array(dec, val, size); + if (size) + val[size - 1] = '\0'; + else + vn_cs_decoder_set_fatal(dec); +} + /* array size (uint64_t) */ static inline void @@ -146,17 +165,25 @@ vn_encode_array_size(struct vn_cs_encoder *enc, uint64_t size) } static inline uint64_t -vn_decode_array_size(struct vn_cs_decoder *dec, uint64_t max_size) +vn_decode_array_size(struct vn_cs_decoder *dec, uint64_t expected_size) { uint64_t size; vn_decode_uint64_t(dec, &size); - if (size > max_size) { + if (size != expected_size) { vn_cs_decoder_set_fatal(dec); size = 0; } return size; } +static inline uint64_t +vn_decode_array_size_unchecked(struct vn_cs_decoder *dec) +{ + uint64_t size; + vn_decode_uint64_t(dec, &size); + return size; +} + static inline uint64_t vn_peek_array_size(struct vn_cs_decoder *dec) { @@ -177,7 +204,7 @@ vn_encode_simple_pointer(struct vn_cs_encoder *enc, const void *val) static inline bool vn_decode_simple_pointer(struct vn_cs_decoder *dec) { - return vn_decode_array_size(dec, 1); + return vn_decode_array_size_unchecked(dec); } /* uint32_t */