mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 17:29:57 -04:00
Frame dumps keep each shader's guest program, and a test switch runs an edited SPIR-V in place of a compute shader.
NX2NAVI_DUMP writes sh_<hash>.code next to sh_<hash>.spv: the guest program the shader was translated from, as its stored inputs hold it, for a disassembler (a compute program as it is, a graphics stage after its 128-byte header). NX2NAVI_SPV_OVERRIDE=<dir> runs <dir>/<hash>.spv in place of the compute shader whose SPIR-V has that hash, an edited copy with the same interface, to look at a shader's intermediate values in a frame dump. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -487,7 +487,7 @@ __attribute__((format(printf, 2, 3))) static void sp(Str *b, const char *fmt, ..
|
||||
b->n += (size_t)k;
|
||||
}
|
||||
|
||||
// SPIR-V hash of a shader; the first time, its SPIR-V goes to sh_<hash>.spv.
|
||||
// SPIR-V hash of a shader; the first time, its SPIR-V goes to sh_<hash>.spv and its guest program to sh_<hash>.code.
|
||||
static uint64_t shader_hash(const GfxShader *s) {
|
||||
static struct { const GfxShader *s; uint64_t h; } tab[1024];
|
||||
static int n;
|
||||
@@ -502,6 +502,8 @@ static uint64_t shader_hash(const GfxShader *s) {
|
||||
snprintf(path, sizeof path, "%s/sh_%016llx.spv", dir, (unsigned long long)h);
|
||||
FILE *f = fopen(path, "wb");
|
||||
if (f) fwrite(w, 4, (size_t)words, f), fclose(f);
|
||||
snprintf(path, sizeof path, "%s/sh_%016llx.code", dir, (unsigned long long)h); // the guest program it came from
|
||||
gfx_shader_write_code(s, path);
|
||||
if (n < 1024) tab[n].s = s, tab[n].h = h, n++;
|
||||
return h;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user