Skip to content

Commit e396c3d

Browse files
committed
Python code generator reorg
Remove some unused python code. Move configuration info into its own vkconfig.py file.
1 parent 3ed5836 commit e396c3d

4 files changed

Lines changed: 261 additions & 301 deletions

File tree

scripts/lava.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import argparse
99
import struct
10+
import vkconfig as vk
1011

1112
# New functions that we implement
1213
fake_functions = [ 'vkAssertBufferARM', 'vkSyncBufferTRACETOOLTEST', 'vkGetDeviceTracingObjectPropertyTRACETOOLTEST',
@@ -100,14 +101,14 @@ def out(lst, str=''):
100101
out([wrh], '\ttrace_records();')
101102
out([wrh])
102103
for name in spec.all_handles:
103-
out([wrh], '\ttrace_remap<%s, %s> %s_index;' % (name, util.trackable_type_map_trace.get(name, 'trackable'), name))
104+
out([wrh], '\ttrace_remap<%s, %s> %s_index;' % (name, vk.trackable_type_map_trace.get(name, 'trackable'), name))
104105
if name != 'VkDeviceMemory':
105106
out(targets_read, 'replay_remap<%s> index_to_%s;' % (name, name))
106107
out(targets_read_headers, 'extern replay_remap<%s> index_to_%s;' % (name, name))
107108
for name in spec.all_handles:
108109
if name != 'VkDeviceMemory':
109-
out(targets_read, 'std::vector<%s> %s_index;' % (util.trackable_type_map_replay.get(name, 'trackable'), name))
110-
out(targets_read_headers, 'extern std::vector<%s> %s_index;' % (util.trackable_type_map_replay.get(name, 'trackable'), name))
110+
out(targets_read, 'std::vector<%s> %s_index;' % (vk.trackable_type_map_replay.get(name, 'trackable'), name))
111+
out(targets_read_headers, 'extern std::vector<%s> %s_index;' % (vk.trackable_type_map_replay.get(name, 'trackable'), name))
111112

112113
out([wrh, wr] + targets_read)
113114
out([wrh], '\tconst std::unordered_map<std::string, uint16_t> function_table;')
@@ -436,7 +437,7 @@ def out(lst, str=''):
436437
out(targets_read, '\t{')
437438
idx = 0
438439
for f in spec.functions:
439-
if f in util.functions_noop or f in spec.disabled_functions or spec.str_contains_vendor(f):
440+
if f in vk.functions_noop or f in spec.disabled_functions or spec.str_contains_vendor(f):
440441
out(targets_read, '\tcase %d:' % idx)
441442
out(targets_read, '\t\tDLOG3("Attempt to use retrace_getcall on unimplemented function %s with index %d.");' % (f, idx))
442443
out(targets_read, '\t\treturn nullptr;')
@@ -469,7 +470,7 @@ def out(lst, str=''):
469470
for f in spec.functions:
470471
if f in spec.protected_funcs:
471472
out([wr], '#ifdef %s' % spec.protected_funcs[f])
472-
if f in util.functions_noop or f in spec.disabled_functions or spec.str_contains_vendor(f):
473+
if f in vk.functions_noop or f in spec.disabled_functions or spec.str_contains_vendor(f):
473474
out([wr], '\tcase %d:' % idx)
474475
out([wr], '\t\tDLOG("Attempt to use trace_getcall on unimplemented function %s with index %s.");' % (f, idx))
475476
out([wr], '\t\treturn nullptr;')
@@ -510,9 +511,9 @@ def out(lst, str=''):
510511
out(targets_write, '\tif (instance->records.%s_index.size())' % name)
511512
out(targets_write, '\t{')
512513
out(targets_write, '\t\tv["%s"] = Json::arrayValue;' % name)
513-
out(targets_write, '\t\tfor (const %s* data : instance->records.%s_index.iterate())' % (util.trackable_type_map_trace.get(name, 'trackable'), name))
514+
out(targets_write, '\t\tfor (const %s* data : instance->records.%s_index.iterate())' % (vk.trackable_type_map_trace.get(name, 'trackable'), name))
514515
out(targets_write, '\t\t{')
515-
out(targets_write, '\t\t\tJson::Value vv = %s_json(data);' % util.trackable_type_map_trace.get(name, 'trackable'))
516+
out(targets_write, '\t\t\tJson::Value vv = %s_json(data);' % vk.trackable_type_map_trace.get(name, 'trackable'))
516517
out(targets_write, '\t\t\tvv["index"] = data->index;')
517518
out(targets_write, '\t\t\tv["%s"].append(vv);' % name)
518519
out(targets_write, '\t\t}')
@@ -532,7 +533,7 @@ def out(lst, str=''):
532533
continue
533534
name = v.find('name').text
534535
if spec.str_contains_vendor(name): continue
535-
out(targets_read, '\tif (v.isMember("%s")) for (const auto& i : v["%s"]) %s_index.push_back(%s_json(i));' % (name, name, name, util.trackable_type_map_replay.get(name, 'trackable')))
536+
out(targets_read, '\tif (v.isMember("%s")) for (const auto& i : v["%s"]) %s_index.push_back(%s_json(i));' % (name, name, name, vk.trackable_type_map_replay.get(name, 'trackable')))
536537
for e in extra_tracked_structs:
537538
out(targets_read, '\tif (v.isMember("%s")) { has_%s = true; read%s(v["%s"], stored_%s); }' % (e, e, e, e, e))
538539
out(targets_read, '}')

scripts/struct.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import spec
66
import util
77
import os
8+
import vkconfig as vk
89

910
# Do not generate read/write functions for these
1011
skiplist = [ 'VkXlibSurfaceCreateInfoKHR', 'VkXcbSurfaceCreateInfoKHR', 'VkBaseOutStructure', 'VkBaseInStructure', 'VkAllocationCallbacks',
@@ -26,7 +27,7 @@
2627
z = util.getspool()
2728

2829
def skip(name, selected):
29-
if not name in spec.structures or (selected and name != selected) or name in util.struct_noop:
30+
if not name in spec.structures or (selected and name != selected) or name in vk.struct_noop:
3031
return True
3132
if name in skiplist:
3233
return True
@@ -51,7 +52,7 @@ def struct_header_write(w, selected = None):
5152
if name in spec.protected_types:
5253
print('#ifdef %s' % spec.protected_types[name], file=w)
5354
accessor = '%s* sptr' % name
54-
modifier = 'const ' if not name in util.deconst_struct else ''
55+
modifier = 'const ' if not name in vk.deconst_struct else ''
5556
print('static void write_%s(lava_file_writer& writer, %s%s);' % (name, modifier, accessor), file=w)
5657
if name in spec.protected_types:
5758
print('#endif // %s' % spec.protected_types[name], file=w)
@@ -114,7 +115,7 @@ def struct_impl_write(w, selected = None):
114115
if name == 'VkPipelineViewportStateCreateInfo': special = ', const VkPipelineDynamicStateCreateInfo* pDynamicState'
115116
elif name == 'VkCommandBufferBeginInfo': special = ', trackedcmdbuffer_trace* tcmd'
116117
elif name == 'VkWriteDescriptorSet': special = ', bool ignoreDstSet'
117-
modifier = 'const ' if not name in util.deconst_struct else ''
118+
modifier = 'const ' if not name in vk.deconst_struct else ''
118119
print('static void write_%s(lava_file_writer& writer, %s%s%s)' % (name, modifier, accessor, special), file=w)
119120
print('{', file=w)
120121
if v.attrib.get('alias'):

0 commit comments

Comments
 (0)