From 5720c8fdc83bfbae082db9fecde482b2c1f53a48 Mon Sep 17 00:00:00 2001 From: mizhen Date: Fri, 31 Mar 2017 09:08:16 -0600 Subject: scripts: Add ceiling function to vk_struct_size_helper Change-Id: Ia377c52e43442fec17b823c888df6685eff0aca5 --- scripts/helper_file_generator.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py index 2e7c7b2d..0d35b837 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' -- cgit v1.2.3