From 8ae4fe805f6e38028bd01592c5fb680a25c2ca4a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Jul 2026 11:48:00 +0530 Subject: [PATCH] Also output input attr name mapping for generated glsl --- kitty/shaders/slang.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kitty/shaders/slang.py b/kitty/shaders/slang.py index a0edc76cb..fb5104110 100644 --- a/kitty/shaders/slang.py +++ b/kitty/shaders/slang.py @@ -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)) # }}}