Dynamic resolution: shrink the copy/stencil scratch after a step

A step grows the scratch to hold the old level's displayed rect and draw
area, and it stayed that size: every tiled stencil rebuild renders into it,
so on GL-on-Metal its size cost bandwidth on each one. Return it to the size
a surface allocated at the new level starts with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shokunin
2026-10-06 03:50:20 -07:00
parent 4560540c6d
commit e2b3dce09d
+15
View File
@@ -9159,6 +9159,21 @@ static int dyn_apply(int snew) {
wst_all(i); /* colour only */
}
}
/* 5b. The copy/stencil scratch back to its size for a surface allocated
* at snew (alloc_hr_targets): the step grew it to the old level's
* rects, and every tiled stencil rebuild renders into it. */
{
int hw = VRAM_W * snew, hh = VRAM_H * snew;
int sw = snew <= 2 ? hw : (hw < GL_SCRATCH_TILE ? hw : GL_SCRATCH_TILE);
int sh = snew <= 2 ? hh : (hh < GL_SCRATCH_TILE ? hh : GL_SCRATCH_TILE);
if (s_scratch_w > sw || s_scratch_h > sh) {
p_glActiveTexture(PSXGL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, s_scratch_tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, sw, sh, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
s_scratch_w = sw; s_scratch_h = sh;
}
}
const uint64_t t5 = dyn_mark();
/* 6. The new scale. */
s_hr_scale = s_out_scale = snew;