Fix struct naming in ported cell shader

This commit is contained in:
Kovid Goyal 2026-07-04 06:07:02 +05:30
parent 9bfae5041e
commit b23a5cf518
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 8 deletions

View file

@ -18,7 +18,7 @@ extern static const bool ONLY_FOREGROUND;
extern static const bool ONLY_BACKGROUND;
// Inputs {{{
struct CellRenderDataStruct
struct CellRenderData
{
float use_cell_bg_for_selection_fg, use_cell_fg_for_selection_fg, use_cell_for_selection_bg;
@ -34,15 +34,15 @@ struct CellRenderDataStruct
};
// Uniform Blocks (adjust binding slots as needed for your pipeline layout)
ConstantBuffer<CellRenderDataStruct> crd;
ConstantBuffer<CellRenderData> crd;
struct ColorTableStruct
struct ColorTable
{
uint color_table[NUM_COLORS + MARK_MASK + MARK_MASK + 2];
};
ConstantBuffer<ColorTableStruct> ColorTable;
#define color_table ColorTable.color_table
ConstantBuffer<ColorTable> ctb;
#define color_table ctb.color_table
uniform float gamma_lut[256];
uniform Sampler2D<uint4> sprite_decorations_map;

View file

@ -423,6 +423,7 @@ def fixup_opengl_code(glsl_code: str, path: str) -> tuple[str, dict[str, Any]]:
in_uniform_block_contents = False
uniform_block_is_struct = False
current_uniform_struct_members: dict[str, str] = {}
current_uniform_struct_name: str = ''
uniform_blocks = {}
current_uniform_names: list[str] = []
uniform_names: dict[str, str] = {}
@ -446,8 +447,7 @@ def fixup_opengl_code(glsl_code: str, path: str) -> tuple[str, dict[str, Any]]:
in_uniform_block = in_uniform_block_contents = False
block_name = line.lstrip('}').rstrip(';').strip()
if uniform_block_is_struct:
uniform_structs[block_name.rpartition('_')[0]] = {
'name': block_name, 'members': current_uniform_struct_members}
uniform_structs[current_uniform_struct_name] = current_uniform_struct_members
else:
uniform_blocks[block_name] = current_uniform_names
line = '// ' + line
@ -484,6 +484,9 @@ def fixup_opengl_code(glsl_code: str, path: str) -> tuple[str, dict[str, Any]]:
in_uniform_block_contents = False
uniform_block_is_struct = line.startswith('layout(std140') # )
if uniform_block_is_struct:
current_uniform_struct_name = words[-1]
assert current_uniform_struct_name.startswith('block_')
current_uniform_struct_name = current_uniform_struct_name[len('block_'):].rpartition('_')[0]
current_uniform_struct_members = {}
else:
line = '// ' + line
@ -521,7 +524,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, indent=2, sort_keys=True))
f.write(json.dumps(metadata, indent=2, sort_keys=False))
# }}}