port: D397 — file-select background + gun-barrel comb look: stale RENDERTILE import (fix in tree, by-eye owed)

Root-caused the D397 interlaced/comb symptom on the file-select
background and intro gun-barrel (first display, not round-trip):
titleRenderFolderMenuBackgroundLines loads 299 one-pixel 440-byte I8
rows with gDPLoadTextureBlock(I, 8b) and samples G_TX_RENDERTILE but
never emits gSPSetTile, so the tile's fmt/siz is whatever the previous
screen left (CI/4b spectrum-screen leftover, D116 probe). fast3d ran
the I8 bytes through import_texture_ci4 against a stale/all-zero
16-entry palette -> periodic black rows (GL texture-cache artifact,
not a ground-truth dither — no ROM RLE decode needed).

- gfx_pc.cpp import_texture: route the import through the source's
  fmt/siz when a CI/RGBA tile genuinely disagrees with an I8 8b load
  (mirrors the D229 case); real CI/RGBA textures untouched.
- gfx_opengl.cpp: GE_D397SH env-gated shader-formula probe for the
  file-select gunbarrel combine (label initially written as D398,
  renamed to avoid the PC-Options-label finding collision).
- findings: D397 row -> FIX LANDED (by-eye + PCDUMP verification
  owed); tail section notes the fix. CSV regenerated.

Cross-ref D182(2) (same symptom family), D159/D183 (disproven leads),
D229 (mirror-case precedent).
This commit is contained in:
James Dansereau committed 2026-09-27 22:04:03 -04:00
1 parent 545b2c7792
commit a2b2f78dd1
4 files changed
+50 -2

No files matched your search

+30
View File
@@ -560,6 +560,36 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
vs_buf[vs_len] = '\0';
fs_buf[fs_len] = '\0';
#ifdef PORT
/* D397 TEMP probe (env-gated): dump the generated texel formula per
* shader so the file-select gunbarrel combine can be inspected. */
{
static int d397_on = -1;
if (d397_on < 0) d397_on = getenv("GE_D397SH") != NULL;
if (d397_on) {
fprintf(stderr,
"D397SH: id0=%016llx id1=%08x 2cyc=%d alpha=%d noise=%d edge=%d blur=%d grey=%d "
"c0r=(%u,%u,%u,%u) c0a=(%u,%u,%u,%u) c1r=(%u,%u,%u,%u) c1a=(%u,%u,%u,%u) "
"single(%d,%d/%d,%d) mult(%d,%d/%d,%d) mix(%d,%d/%d,%d)\n",
(unsigned long long)shader_id0, (unsigned)shader_id1,
(int)cc_features.opt_2cyc, (int)cc_features.opt_alpha, (int)cc_features.opt_noise,
(int)cc_features.opt_texture_edge, (int)cc_features.opt_blur, (int)cc_features.opt_grayscale,
cc_features.c[0][0][0], cc_features.c[0][0][1], cc_features.c[0][0][2], cc_features.c[0][0][3],
cc_features.c[0][1][0], cc_features.c[0][1][1], cc_features.c[0][1][2], cc_features.c[0][1][3],
cc_features.c[1][0][0], cc_features.c[1][0][1], cc_features.c[1][0][2], cc_features.c[1][0][3],
cc_features.c[1][1][0], cc_features.c[1][1][1], cc_features.c[1][1][2], cc_features.c[1][1][3],
(int)cc_features.do_single[0][0], (int)cc_features.do_single[0][1],
(int)cc_features.do_single[1][0], (int)cc_features.do_single[1][1],
(int)cc_features.do_multiply[0][0], (int)cc_features.do_multiply[0][1],
(int)cc_features.do_multiply[1][0], (int)cc_features.do_multiply[1][1],
(int)cc_features.do_mix[0][0], (int)cc_features.do_mix[0][1],
(int)cc_features.do_mix[1][0], (int)cc_features.do_mix[1][1]);
const char* tf = strstr(fs_buf, "texel = ");
if (tf) fprintf(stderr, "D397SHF: %s;\n", tf);
}
}
#endif
const GLchar* sources[2] = { vs_buf, fs_buf };
const GLint lengths[2] = { (GLint)vs_len, (GLint)fs_len };
GLint success;
+16
View File
@@ -1329,6 +1329,22 @@ static void import_texture(int i, int tile, bool importReplacement) {
* palette path instead -- the port-layer equivalent of the ucode's
* expand-at-load. Only fires when the tile format genuinely disagrees
* with the loaded source, so real RGBA16 textures are untouched. */
/* D397: comb/interlace grain on the file-select background + intro
* gun-barrel. titleRenderFolderMenuBackgroundLines loads 299 one-pixel
* 440-byte I8 rows with gDPLoadTextureBlock(I, 8b) and samples
* G_TX_RENDERTILE but never emits gSPSetTile, so the tile's fmt/siz is
* whatever the previous screen left (D116 probe: CI/4b -- the
* spectrum-screen leftover). fast3d then ran the I8 bytes through
* import_texture_ci4 against a 16-entry palette (stale / all-zero)
* -> periodic black rows. Route the import through the source's
* format, exactly like the D229 mirror case above. Only fires when
* the tile format genuinely disagrees with the loaded source (CI or
* RGBA tile over an I8 load), so real CI/RGBA textures are untouched. */
if (loaded_texture.src_fmt == G_IM_FMT_I && siz == G_IM_SIZ_8b &&
(fmt_eff == G_IM_FMT_CI || fmt_eff == G_IM_FMT_RGBA)) {
fmt_eff = G_IM_FMT_I;
siz_eff = G_IM_SIZ_8b;
}
if (fmt_eff == G_IM_FMT_RGBA && siz == G_IM_SIZ_16b &&
loaded_texture.src_fmt == G_IM_FMT_CI) {
#ifdef PORT