diff --git a/runtime/tests/test_gl_scale_invariance.c b/runtime/tests/test_gl_scale_invariance.c index 937664bf..7a2aebf3 100644 --- a/runtime/tests/test_gl_scale_invariance.c +++ b/runtime/tests/test_gl_scale_invariance.c @@ -773,6 +773,14 @@ static int passes_main(int scale, int window) { s_interp_source_path = GL_PRES_VRAM; s_pass_verify = 1; uint64_t before = fnv(vram, sizeof vram, 0xcbf29ce484222325ull); + int fw = FRAME_W * scale, fh = FRAME_H * scale, ow = 0, oh = 0; + uint32_t *pixels = (uint32_t *)malloc((size_t)fw * fh * 4u); + int count = pixels ? gl_renderer_read_display_hires(0, 0, FRAME_W, + FRAME_H, pixels, fw * fh, &ow, &oh) : 0; + check(count == fw * fh && ow == fw && oh == fh, + "HD pass baseline display readback"); + uint64_t frame_before = count == fw * fh + ? fnv(pixels, (size_t)fw * fh * 4u, 0xcbf29ce484222325ull) : 0; int opened = gl_renderer_pass_begin(0, 0, FRAME_W, FRAME_H, 1, 2, 0); check(opened, "HD pass opens"); if (opened) { @@ -786,6 +794,25 @@ static int passes_main(int scale, int window) { check(fnv(vram, sizeof vram, 0xcbf29ce484222325ull) == before, "HD pass leaves native VRAM identical"); } + opened = gl_renderer_pass_begin(0, 0, FRAME_W, FRAME_H, 1, 2, 0); + check(opened, "HD discard pass opens"); + if (opened) { + glb_draw_flat_rect(20, 20, 32, 32, 0x03e0); + flush_flat_batch(); + gl_renderer_pass_end(0, 0); /* callback failed: keep no image */ + check(gl_renderer_pass_verify_vram(), + "discarded HD pass restores GPU and CPU VRAM"); + check(fnv(vram, sizeof vram, 0xcbf29ce484222325ull) == before, + "discarded HD pass preserves authoritative CPU digest"); + ow = oh = 0; + count = pixels ? gl_renderer_read_display_hires(0, 0, FRAME_W, + FRAME_H, pixels, fw * fh, &ow, &oh) : 0; + check(count == fw * fh && ow == fw && oh == fh && + fnv(pixels, (size_t)fw * fh * 4u, + 0xcbf29ce484222325ull) == frame_before, + "discarded HD pass restores presented pixel digest"); + } + free(pixels); gl_renderer_set_hd_texture_mode(0); } check(glGetError() == GL_NO_ERROR, "GL error");