diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/sc.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -314,14 +314,17 @@ void write_csh( const Desc& d, const std::vector<uint32_t>* stages ) { - int hsize = 8, i, coff; + int hsize = 16, i, coff; FILE* f = fopen(fname, "wb"); if (!f) { print_err("Failed to open %s\n", fname); pbreak(500); } + int c; fwrite("CSH2", 4, 1, f); fwrite(&d.type, 4, 1, f); + c = d.attrs.size(); fwrite(&c, 4, 1, f); + c = d.trgts.size(); fwrite(&c, 4, 1, f); for (const auto& a : d.attrs) { char buf[28]; memset(buf, 0, sizeof buf); @@ -338,14 +341,18 @@ void write_csh( fwrite(&t.type, 4, 1, f); hsize += 32; } + hsize += shader_type_count * 8; for (i = 0, coff = 0; i < shader_type_count; i++) { int o = 0; - if (d.entrypoints[i].empty()) + if (d.entrypoints[i].empty()) { fwrite(&o, 4, 1, f); - else { + fwrite(&o, 4, 1, f); + } else { + int size = stages[i].size() * sizeof(uint32_t); o = hsize + coff; fwrite(&o, 4, 1, f); - coff += stages[i].size() * sizeof(uint32_t); + fwrite(&size, 4, 1, f); + coff += size; } } for (i = 0; i < shader_type_count; i++) |