From 2cfbd593f6a7df09afdfd230eae6511837ca38ec Mon Sep 17 00:00:00 2001 From: notquiteog Date: Sun, 8 Nov 2026 17:12:58 -0600 Subject: [PATCH] fix: stop test_mem_trim matching a bc_scratch_layout call that has moved on tests/test_mem_trim.py fails on main with "a BC3 upload uses a scratch it did not ask for". It is the test, not the renderer: the assertion counts the exact string "if (!bc_scratch_layout(cmd)) return false;", and the uneven BC levels work gave that guard a second argument. Both call sites still check the return (vk_texture.cpp:700 and :2196), so the property the check is about -- every user asks for the scratch first and stops when it cannot be made -- holds; only the literal changed. Matches the call with the argument list left open, so adding an argument does not break it again. Confirmed not vacuous: with the guard at :2196 reduced to a bare call the check still fails, and passes again when restored. Assisted-by: Claude Opus 5 Co-Authored-By: Claude Opus 5 --- tests/test_mem_trim.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_mem_trim.py b/tests/test_mem_trim.py index 67fa98f34..94f4c6cd5 100644 --- a/tests/test_mem_trim.py +++ b/tests/test_mem_trim.py @@ -6,6 +6,7 @@ a floor, and the spare ones are counted out as well as in. python -I -B tests/test_mem_trim.py """ +import re from pathlib import Path ROOT = Path(__file__).resolve().parents[1] @@ -42,7 +43,10 @@ def main(): need(begin.index("r.streams.resize(1)") < begin.index("r.si = 0"), "the streams given back are used after") tex = (ROOT / "gpu/vk/vk_texture.cpp").read_text(encoding="utf-8") - need(tex.count("if (!bc_scratch_layout(cmd)) return false;") == 2, "a BC3 upload uses a scratch it did not ask for") + # (the guard takes a second argument since the uneven BC levels work; what matters is that both + # users ask for the scratch and stop when it cannot be made, not the exact argument list) + need(len(re.findall(r"if \(!bc_scratch_layout\(cmd[^)]*\)\) return false;", tex)) == 2, + "a BC3 upload uses a scratch it did not ask for") need("bc_have = false" in block(tex, "void bc_scratch_idle("), "the scratch given back is still taken for made") need("dead.push_back" in block(tex, "void bc_scratch_idle("), "the scratch is freed with no wait for the GPU") need("total_bytes -= std::min(total_bytes, tex.bytes + tex.pad)" in tex, "a texture leaves the budget by its texels only")