mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-07-10 09:43:26 +00:00
Also output input attr name mapping for generated glsl
This commit is contained in:
parent
b2537e322b
commit
8ae4fe805f
1 changed files with 8 additions and 2 deletions
|
|
@ -418,6 +418,7 @@ def fixup_opengl_code(glsl_code: str, path: str) -> tuple[str, dict[str, Any]]:
|
|||
current_uniform_names: list[str] = []
|
||||
uniform_names: dict[str, str] = {}
|
||||
uniform_structs = {}
|
||||
input_attr_names = {}
|
||||
|
||||
def add_uniform_name(name: str, uniform_names: dict[str, str] = uniform_names) -> str:
|
||||
name = name.rstrip(';')
|
||||
|
|
@ -478,6 +479,9 @@ def fixup_opengl_code(glsl_code: str, path: str) -> tuple[str, dict[str, Any]]:
|
|||
line = '// ' + line
|
||||
elif words[0] == 'uniform' and len(words) > 2 and words[1].startswith('sampler'):
|
||||
add_uniform_name(words[2])
|
||||
elif words[0] == 'in':
|
||||
name = words[-1].rstrip(';')
|
||||
input_attr_names[name.rpartition('_')[0]] = name
|
||||
lines.append(line)
|
||||
ans = '\n'.join(lines)
|
||||
for block_name, names in uniform_blocks.items():
|
||||
|
|
@ -488,7 +492,9 @@ def fixup_opengl_code(glsl_code: str, path: str) -> tuple[str, dict[str, Any]]:
|
|||
ans = ans.replace('gl_BaseVertex', '0')
|
||||
ans = ans.replace('gl_InstanceIndex', 'gl_InstanceID')
|
||||
ans = ans.replace('gl_BaseInstance', '0')
|
||||
return ans, {'loose_uniforms': uniform_names, 'uniform_structs': uniform_structs}
|
||||
return ans, {
|
||||
'loose_uniforms': uniform_names, 'uniform_structs': uniform_structs, 'input_attr_names': input_attr_names
|
||||
}
|
||||
|
||||
|
||||
def fixup_opengl_files(*paths: str) -> None:
|
||||
|
|
@ -505,7 +511,7 @@ def fixup_opengl_files(*paths: str) -> None:
|
|||
f.truncate()
|
||||
f.write(fixed)
|
||||
with open(path + '.json', 'w') as f:
|
||||
f.write(json.dumps(metadata))
|
||||
f.write(json.dumps(metadata, indent=2, sort_keys=True))
|
||||
# }}}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue