Skip to content

Commit

Permalink
- improve handling of templated types in cgu, remove stray #include s…
Browse files Browse the repository at this point in the history
…tatements that were not being removed from monolithic source
  • Loading branch information
polymonster committed Apr 20, 2023
1 parent d5e8aa8 commit 8b1d8f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cgu.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ def format_source(source, indent_size):

# returns the name of a type.. ie struct <name>, enum <name>
def type_name(type_declaration):
pos = type_declaration.find("{")
name = type_declaration[:pos].strip().split()[1]
return name
# skip past templates (allow multiple template parameters)
if type_declaration.find("<") != -1:
template_end = enclose("<", ">", type_declaration, 0)
return type_declaration[template_end:].strip().split()[0]
else:
# assume the type name is the second token
pos = type_declaration.find("{")
name = type_declaration[:pos].strip().split()[1]
return name


# get the typename stripping resource_array[21] arrays and return (resource_array, 21)
Expand Down
8 changes: 8 additions & 0 deletions pmfx_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,14 @@ def load_pmfx_jsn(filepath, root):
to_search.add(import_name)
if line.startswith("{"):
break
# strip rouge includes
if all_shader_source.find("#include") != -1:
src = all_shader_source.splitlines()
strip_src = ""
for line in src:
if line.find("#include") == -1:
strip_src += line + "\n"
all_shader_source = strip_src
return (pmfx, all_shader_source, all_included_files)


Expand Down

0 comments on commit 8b1d8f2

Please sign in to comment.