Zebediah Figura (@zfigura) commented about libs/vkd3d-shader/fx.c:
+{ + struct fx_context fx_ctx = { .raw_section_size = 4 }; + struct vkd3d_bytecode_buffer buffer = { 0 }; + + fx_foreach_technique(ctx->globals, fx_technique_collect_stats, &fx_ctx, &buffer); + fx_ctx.raw_section_size = align(fx_ctx.raw_section_size, 4); + + put_u32(&buffer, ctx->profile->minor_version == 0 ? 0xfeff1001 : 0xfeff1011); /* Version. */ + put_u32(&buffer, 0); /* Buffer count. */ + put_u32(&buffer, 0); /* Variable count. */ + put_u32(&buffer, 0); /* Object count. */ + put_u32(&buffer, 0); /* Pool buffer count. */ + put_u32(&buffer, 0); /* Pool variable count. */ + put_u32(&buffer, 0); /* Pool object count. */ + put_u32(&buffer, fx_ctx.technique_count); + put_u32(&buffer, fx_ctx.raw_section_size); The point of set_u32() is that you can set these offsets after writing them, instead of needing to do two passes over the same data.
-- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/443#note_51758