From: mizhen Date: Fri, 31 Mar 2017 15:08:16 +0000 (-0600) Subject: scripts: Add ceiling function to vk_struct_size_helper X-Git-Tag: upstream/1.1.92~1368 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5720c8fdc83bfbae082db9fecde482b2c1f53a48;p=platform%2Fupstream%2FVulkan-Tools.git scripts: Add ceiling function to vk_struct_size_helper Change-Id: Ia377c52e43442fec17b823c888df6685eff0aca5 --- diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py index 2e7c7b2..0d35b83 100644 --- a/scripts/helper_file_generator.py +++ b/scripts/helper_file_generator.py @@ -209,7 +209,15 @@ class HelperFileOutputGenerator(OutputGenerator): if not match or match.group(1) != match.group(4): raise 'Unrecognized latexmath expression' name = match.group(2) - decoratedName = '{}/{}'.format(*match.group(2, 3)) + # Need to add 1 for ceiling function; otherwise, the allocated packet + # size will be less than needed during capture for some title which use + # this in VkPipelineMultisampleStateCreateInfo. based on ceiling function + # definition,it is '{0}%{1}?{0}/{1} + 1:{0}/{1}'.format(*match.group(2, 3)), + # its value <= '{}/{} + 1'. + if match.group(1) == 'ceil': + decoratedName = '{}/{} + 1'.format(*match.group(2, 3)) + else: + decoratedName = '{}/{}'.format(*match.group(2, 3)) else: # Matches expressions similar to 'latexmath : [dataSize \over 4]' match = re.match(r'latexmath\s*\:\s*\[\s*(\w+)\s*\\over\s*(\d+)\s*\]', source) @@ -437,7 +445,7 @@ class HelperFileOutputGenerator(OutputGenerator): checked_type = member.type if checked_type == 'void': checked_type = 'void*' - struct_size_body += ' struct_size += struct_ptr->%s * sizeof(%s);\n' % (member.len, checked_type) + struct_size_body += ' struct_size += (struct_ptr->%s ) * sizeof(%s);\n' % (member.len, checked_type) struct_size_body += ' }\n' struct_size_body += ' return struct_size;\n' struct_size_body += '}\n'