Skip to content

Commit 38ce152

Browse files
MarkY-LunarGjzulauf-lunarg
authored andcommitted
codegen: Generate vulkan handle wrapping to endFile
Generate the Vulkan struct handle wrapping content at endFile time instead of generate_feature time.
1 parent 635ea5c commit 38ce152

File tree

2 files changed

+53
-57
lines changed

2 files changed

+53
-57
lines changed

framework/generated/khronos_generators/vulkan_generators/vulkan_struct_handle_wrappers_body_generator.py

+29-31
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,35 @@ def beginFile(self, gen_opts):
9595

9696
def endFile(self):
9797
"""Method override."""
98+
for struct in self.get_all_filtered_struct_names():
99+
if (
100+
(struct in self.structs_with_handles)
101+
or (struct in self.GENERIC_HANDLE_STRUCTS)
102+
) and (struct not in self.STRUCT_MAPPERS_BLACKLIST):
103+
handle_members = dict()
104+
generic_handle_members = dict()
105+
106+
if struct in self.structs_with_handles:
107+
handle_members = self.structs_with_handles[struct]
108+
if struct in self.GENERIC_HANDLE_STRUCTS:
109+
generic_handle_members = self.GENERIC_HANDLE_STRUCTS[struct
110+
]
111+
112+
body = '\n'
113+
body += 'void UnwrapStructHandles({}* value, HandleUnwrapMemory* unwrap_memory)\n'.format(
114+
struct
115+
)
116+
body += '{\n'
117+
body += ' if (value != nullptr)\n'
118+
body += ' {\n'
119+
body += self.make_struct_handle_unwrappings(
120+
struct, handle_members, generic_handle_members
121+
)
122+
body += ' }\n'
123+
body += '}'
124+
125+
write(body, file=self.outFile)
126+
98127
# Generate the pNext shallow copy code, for pNext structs that don't have handles, but need to be preserved in the overall copy for handle wrapping.
99128
self.newline()
100129
write(
@@ -233,37 +262,6 @@ def need_feature_generation(self):
233262
return True
234263
return False
235264

236-
def generate_feature(self):
237-
"""Performs C++ code generation for the feature."""
238-
for struct in self.get_filtered_struct_names():
239-
if (
240-
(struct in self.structs_with_handles)
241-
or (struct in self.GENERIC_HANDLE_STRUCTS)
242-
) and (struct not in self.STRUCT_MAPPERS_BLACKLIST):
243-
handle_members = dict()
244-
generic_handle_members = dict()
245-
246-
if struct in self.structs_with_handles:
247-
handle_members = self.structs_with_handles[struct]
248-
if struct in self.GENERIC_HANDLE_STRUCTS:
249-
generic_handle_members = self.GENERIC_HANDLE_STRUCTS[struct
250-
]
251-
252-
body = '\n'
253-
body += 'void UnwrapStructHandles({}* value, HandleUnwrapMemory* unwrap_memory)\n'.format(
254-
struct
255-
)
256-
body += '{\n'
257-
body += ' if (value != nullptr)\n'
258-
body += ' {\n'
259-
body += self.make_struct_handle_unwrappings(
260-
struct, handle_members, generic_handle_members
261-
)
262-
body += ' }\n'
263-
body += '}'
264-
265-
write(body, file=self.outFile)
266-
267265
def make_struct_handle_unwrappings(
268266
self, name, handle_members, generic_handle_members
269267
):

framework/generated/khronos_generators/vulkan_generators/vulkan_struct_handle_wrappers_header_generator.py

+24-26
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,30 @@ def beginFile(self, gen_opts):
100100

101101
def endFile(self):
102102
"""Method override."""
103+
# Check for output structures, which retrieve handles that need to be wrapped.
104+
for cmd in self.all_cmd_params:
105+
info = self.all_cmd_params[cmd]
106+
values = info[2]
107+
108+
for value in values:
109+
if self.is_output_parameter(value) and self.is_struct(
110+
value.base_type
111+
) and (value.base_type in self.structs_with_handles
112+
) and (value.base_type not in self.output_structs):
113+
self.output_structs.append(value.base_type)
114+
115+
# Generate unwrap and rewrap code for input structures.
116+
for struct in self.get_all_filtered_struct_names():
117+
if (
118+
(struct in self.structs_with_handles)
119+
or (struct in self.GENERIC_HANDLE_STRUCTS)
120+
) and (struct not in self.STRUCT_MAPPERS_BLACKLIST):
121+
body = '\n'
122+
body += 'void UnwrapStructHandles({}* value, HandleUnwrapMemory* unwrap_memory);'.format(
123+
struct
124+
)
125+
write(body, file=self.outFile)
126+
103127
self.newline()
104128
write(
105129
'VkBaseInStructure* CopyPNextStruct(const VkBaseInStructure* base, HandleUnwrapMemory* unwrap_memory);',
@@ -235,32 +259,6 @@ def need_feature_generation(self):
235259
return True
236260
return False
237261

238-
def generate_feature(self):
239-
"""Performs C++ code generation for the feature."""
240-
# Check for output structures, which retrieve handles that need to be wrapped.
241-
for cmd in self.feature_cmd_params:
242-
info = self.feature_cmd_params[cmd]
243-
values = info[2]
244-
245-
for value in values:
246-
if self.is_output_parameter(value) and self.is_struct(
247-
value.base_type
248-
) and (value.base_type in self.structs_with_handles
249-
) and (value.base_type not in self.output_structs):
250-
self.output_structs.append(value.base_type)
251-
252-
# Generate unwrap and rewrap code for input structures.
253-
for struct in self.get_filtered_struct_names():
254-
if (
255-
(struct in self.structs_with_handles)
256-
or (struct in self.GENERIC_HANDLE_STRUCTS)
257-
) and (struct not in self.STRUCT_MAPPERS_BLACKLIST):
258-
body = '\n'
259-
body += 'void UnwrapStructHandles({}* value, HandleUnwrapMemory* unwrap_memory);'.format(
260-
struct
261-
)
262-
write(body, file=self.outFile)
263-
264262
def generate_create_wrapper_funcs(self):
265263
"""Generates functions that wrap struct handle members."""
266264
for struct in self.output_structs:

0 commit comments

Comments
 (0)