Skip to content

Commit 7df5754

Browse files
committed
Instead of using sequential indices, use CRC32 of padding contents
Sequential indices are problematic for future updates, as updates in the middle of the structure are common, and they will result in larger and less readable diffs. Instead we can use the CRC32 of the padding contents to name the field.
1 parent 1eb7ce6 commit 7df5754

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

generate.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import urllib
88
import xml.etree.ElementTree as etree
99
import urllib.request
10+
import zlib
1011

1112
cmdversions = {
1213
"vkCmdSetDiscardRectangleEnableEXT": 2,
@@ -157,15 +158,17 @@ def cdepends(key):
157158
for key in block_keys:
158159
blocks[key] = ''
159160

160-
devi = 0
161+
devp = {}
161162

162163
for (group, cmdnames) in command_groups.items():
163164
ifdef = '#if ' + group + '\n'
164-
devt = 0
165165

166166
for key in block_keys:
167167
blocks[key] += ifdef
168168

169+
devt = 0
170+
devo = len(blocks['DEVICE_TABLE'])
171+
169172
for name in sorted(cmdnames):
170173
cmd = commands[name]
171174
type = cmd.findtext('param[1]/type')
@@ -192,9 +195,12 @@ def cdepends(key):
192195
if blocks[key].endswith(ifdef):
193196
blocks[key] = blocks[key][:-len(ifdef)]
194197
elif key == 'DEVICE_TABLE':
195-
devi += 1
198+
devh = zlib.crc32(blocks[key][devo:].encode())
199+
assert(devh not in devp)
200+
devp[devh] = True
201+
196202
blocks[key] += '#else\n'
197-
blocks[key] += '\tPFN_vkVoidFunction padding' + str(devi) + '[' + str(devt) + '];\n'
203+
blocks[key] += f'\tPFN_vkVoidFunction padding_{devh:x}[{devt}];\n'
198204
blocks[key] += '#endif /* ' + group + ' */\n'
199205
else:
200206
blocks[key] += '#endif /* ' + group + ' */\n'

0 commit comments

Comments
 (0)