diff options
| author | Aslan2142 <jan.trencansky@protonmail.com> | 2026-11-26 16:30:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-26 16:30:54 +0100 |
| commit | 246791612080cae89dc40cd20c5cdb8d92f90066 (patch) | |
| tree | 29cc4c568eb59d8fe479cbd9fe5526671258729d /runtime/test/xmem_test.cpp | |
| parent | fbf100b1b10e391625585fe6a8bf4e653662ca9a (diff) | |
| parent | 248b58c42d2cc5bbdb9aaf81ed122a379926d518 (diff) | |
Merge pull request #2356 from aslan2142/geometry-remap-release-opt-in
Self-merge by a maintainer: it fixes two regressions that our own merge of #2350 caused (a world run on main lost the device within about a minute). Tested on main fbf100b1b: Linux ctest 112/112; Wine suite (clang-cl + xwin, RDNA2 iGPU, RADV) with no test going from pass to fail; three world runs on the RX 7900 XTX with the two variables set by hand, the one with both off holding 5+ minutes in the world. No game run from this exact build yet; the next world run from main is that check. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2).
Diffstat (limited to 'runtime/test/xmem_test.cpp')
| -rw-r--r-- | runtime/test/xmem_test.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp index adc24cca3..d5e866a76 100644 --- a/runtime/test/xmem_test.cpp +++ b/runtime/test/xmem_test.cpp | |||
| @@ -464,7 +464,25 @@ void test_remap_releases(const PhysicalApi& api) { | |||
| 464 | return false; | 464 | return false; |
| 465 | }; | 465 | }; |
| 466 | 466 | ||
| 467 | // Off by default: a remap keeps the address valid, and a root view recorded before it (or a placed buffer view) | ||
| 468 | // names the copy's address after it, so a copy freed then is read by the GPU (a page fault and a lost device). | ||
| 469 | char previous[8]{}; | ||
| 470 | const DWORD had = GetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", previous, sizeof(previous)); | ||
| 471 | SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", nullptr); | ||
| 472 | rt::xmem::reload_remap_release_setting(); | ||
| 467 | const uint64_t first[kPages] = {pages[0], pages[1], pages[2]}; | 473 | const uint64_t first[kPages] = {pages[0], pages[1], pages[2]}; |
| 474 | const uint64_t other[kPages] = {pages[3], pages[2], pages[1]}; | ||
| 475 | check(api.map(window, kPages, first) == window && api.map(window, kPages, other) == window && take().empty(), | ||
| 476 | "remap releases: off by default, a remap releases nothing"); | ||
| 477 | SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", "0"); | ||
| 478 | rt::xmem::reload_remap_release_setting(); | ||
| 479 | check(api.map(window, kPages, first) == window && take().empty(), | ||
| 480 | "remap releases: LEONIDA_GEOMETRY_REMAP_RELEASE=0 releases nothing"); | ||
| 481 | check(api.map(window, kPages, nullptr) == window && !take().empty() && covers(base, base + 3 * kPage64k), | ||
| 482 | "remap releases: unmapping releases the range whatever the setting"); | ||
| 483 | SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", "1"); | ||
| 484 | rt::xmem::reload_remap_release_setting(); | ||
| 485 | |||
| 468 | check(api.map(window, kPages, first) == window && take().empty(), | 486 | check(api.map(window, kPages, first) == window && take().empty(), |
| 469 | "remap releases: a first mapping of unmapped pages releases nothing"); | 487 | "remap releases: a first mapping of unmapped pages releases nothing"); |
| 470 | check(api.map(window + kPage64k, 1, &pages[1]) == window + kPage64k && take().empty(), | 488 | check(api.map(window + kPage64k, 1, &pages[1]) == window + kPage64k && take().empty(), |
| @@ -496,6 +514,9 @@ void test_remap_releases(const PhysicalApi& api) { | |||
| 496 | 514 | ||
| 497 | check(api.map(window, kPages, nullptr) == window && !take().empty() && covers(base, base + 3 * kPage64k), | 515 | check(api.map(window, kPages, nullptr) == window && !take().empty() && covers(base, base + 3 * kPage64k), |
| 498 | "remap releases: unmapping releases the range"); | 516 | "remap releases: unmapping releases the range"); |
| 517 | SetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", | ||
| 518 | had > 0 && had < sizeof(previous) ? previous : nullptr); | ||
| 519 | rt::xmem::reload_remap_release_setting(); | ||
| 499 | for (uint64_t i = 0; i < kPages; ++i) watch::release(base + i * kPage64k); | 520 | for (uint64_t i = 0; i < kPages; ++i) watch::release(base + i * kPage64k); |
| 500 | watch::unsubscribe(queue); | 521 | watch::unsubscribe(queue); |
| 501 | api.free_pages(4, pages); | 522 | api.free_pages(4, pages); |