Skip to content

Commit 8b1d8f2

Browse files
committed
- improve handling of templated types in cgu, remove stray #include statements that were not being removed from monolithic source
1 parent d5e8aa8 commit 8b1d8f2

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

cgu.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,15 @@ def format_source(source, indent_size):
158158

159159
# returns the name of a type.. ie struct <name>, enum <name>
160160
def type_name(type_declaration):
161-
pos = type_declaration.find("{")
162-
name = type_declaration[:pos].strip().split()[1]
163-
return name
161+
# skip past templates (allow multiple template parameters)
162+
if type_declaration.find("<") != -1:
163+
template_end = enclose("<", ">", type_declaration, 0)
164+
return type_declaration[template_end:].strip().split()[0]
165+
else:
166+
# assume the type name is the second token
167+
pos = type_declaration.find("{")
168+
name = type_declaration[:pos].strip().split()[1]
169+
return name
164170

165171

166172
# get the typename stripping resource_array[21] arrays and return (resource_array, 21)

pmfx_pipeline.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,14 @@ def load_pmfx_jsn(filepath, root):
10261026
to_search.add(import_name)
10271027
if line.startswith("{"):
10281028
break
1029+
# strip rouge includes
1030+
if all_shader_source.find("#include") != -1:
1031+
src = all_shader_source.splitlines()
1032+
strip_src = ""
1033+
for line in src:
1034+
if line.find("#include") == -1:
1035+
strip_src += line + "\n"
1036+
all_shader_source = strip_src
10291037
return (pmfx, all_shader_source, all_included_files)
10301038

10311039

0 commit comments

Comments
 (0)