upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 21:31:45 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 21:31:45 -0500
commit702fbaa96963eb809ecbbfcf3e1472f69fbbd5fc (patch)
treee7bbbe549b4ffd51267b5de2d1f5c2ade98b1a8f /runtime
parentb21b47b052f4c5f190d319a1519b1accf9a2e418 (diff)
test: keep geometry_views_test's GeometryViews off the stack
Since #2098 every TitleBufferWindows carries a 128 KiB published_ array, so the eight GeometryViews this test puts on the stack pass the 1 MiB Windows default and the test died at startup with a stack overflow. They are heap-allocated now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/test/geometry_views_test.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/runtime/test/geometry_views_test.cpp b/runtime/test/geometry_views_test.cpp
index 3d2ff098c..ccfd04728 100644
--- a/runtime/test/geometry_views_test.cpp
+++ b/runtime/test/geometry_views_test.cpp
@@ -20,6 +20,7 @@
20#include <cstdlib> 20#include <cstdlib>
21#include <cstring> 21#include <cstring>
22#include <utility> 22#include <utility>
23#include <memory>
23#include <vector> 24#include <vector>
24 25
25#include "../shims/d3d12_geometry_views.h" 26#include "../shims/d3d12_geometry_views.h"
@@ -138,7 +139,8 @@ int main() {
138 const auto base = reinterpret_cast<std::uintptr_t>(title); 139 const auto base = reinterpret_cast<std::uintptr_t>(title);
139 140
140 FakeDevice device; 141 FakeDevice device;
141 rt::d3d12::GeometryViews views; 142 const auto views_owner = std::make_unique<rt::d3d12::GeometryViews>();
143 auto& views = *views_owner;
142 g_copies.clear(); 144 g_copies.clear();
143 const std::uint64_t va = views.resolve(device, base, kView, copy); 145 const std::uint64_t va = views.resolve(device, base, kView, copy);
144 check(va != 0 && g_copies.size() == 1 && g_copies[0] == kView, "a new 1 MiB view is copied whole"); 146 check(va != 0 && g_copies.size() == 1 && g_copies[0] == kView, "a new 1 MiB view is copied whole");
@@ -194,7 +196,9 @@ int main() {
194 const auto range_b = sbase + kView; 196 const auto range_b = sbase + kView;
195 const auto range_c = sbase + 2 * kView; 197 const auto range_c = sbase + 2 * kView;
196 198
197 rt::d3d12::GeometryViews capped(2 * kView); 199 const auto capped_owner = std::make_unique<rt::d3d12::GeometryViews>(2 * kView);
200
201 auto& capped = *capped_owner;
198 const std::uint64_t va_a = capped.resolve(device, range_a, kView, copy); 202 const std::uint64_t va_a = capped.resolve(device, range_a, kView, copy);
199 const std::uint64_t va_b = capped.resolve(device, range_b, kView, copy); 203 const std::uint64_t va_b = capped.resolve(device, range_b, kView, copy);
200 check(va_a != 0 && va_b != 0 && capped.bytes() == 2 * kView && capped.reserved() == 2 * kView && 204 check(va_a != 0 && va_b != 0 && capped.bytes() == 2 * kView && capped.reserved() == 2 * kView &&
@@ -270,7 +274,8 @@ int main() {
270 const auto pbase = reinterpret_cast<std::uintptr_t>(pool_title); 274 const auto pbase = reinterpret_cast<std::uintptr_t>(pool_title);
271 275
272 // 8. note_released outside [watched_lo, watched_hi) is ignored; inside is queued. 276 // 8. note_released outside [watched_lo, watched_hi) is ignored; inside is queued.
273 rt::d3d12::GeometryViews watched(6 * kView); 277 const auto watched_owner = std::make_unique<rt::d3d12::GeometryViews>(6 * kView);
278 auto& watched = *watched_owner;
274 const std::uint64_t va_w1 = watched.resolve(device, pbase, kView, copy); 279 const std::uint64_t va_w1 = watched.resolve(device, pbase, kView, copy);
275 const std::uint64_t va_w2 = watched.resolve(device, pbase + kView, kView, copy); 280 const std::uint64_t va_w2 = watched.resolve(device, pbase + kView, kView, copy);
276 check(va_w1 != 0 && va_w2 != 0 && watched.live_views() == 2 && watched.block_count() == 1 && 281 check(va_w1 != 0 && va_w2 != 0 && watched.live_views() == 2 && watched.block_count() == 1 &&
@@ -322,7 +327,8 @@ int main() {
322 check(g_live_buffers == 0 && g_live_allocs == 0, "watched teardown frees its block"); 327 check(g_live_buffers == 0 && g_live_allocs == 0, "watched teardown frees its block");
323 328
324 // 10. Spare 4 MiB block: retiring and reaping the sole view keeps the block empty and the next view reuses it. 329 // 10. Spare 4 MiB block: retiring and reaping the sole view keeps the block empty and the next view reuses it.
325 rt::d3d12::GeometryViews spare(6 * kView); 330 const auto spare_owner = std::make_unique<rt::d3d12::GeometryViews>(6 * kView);
331 auto& spare = *spare_owner;
326 const std::uint64_t va_s1 = spare.resolve(device, pbase, kView, copy); 332 const std::uint64_t va_s1 = spare.resolve(device, pbase, kView, copy);
327 const int allocs_after_first = g_total_allocs; 333 const int allocs_after_first = g_total_allocs;
328 check(va_s1 != 0 && spare.block_count() == 1 && spare.empty_blocks() == 0 && spare.reserved() == 4 * kView && 334 check(va_s1 != 0 && spare.block_count() == 1 && spare.empty_blocks() == 0 && spare.reserved() == 4 * kView &&
@@ -350,7 +356,9 @@ int main() {
350 spare.release(device); 356 spare.release(device);
351 check(g_live_buffers == 0 && g_live_allocs == 0, "spare teardown frees its block"); 357 check(g_live_buffers == 0 && g_live_allocs == 0, "spare teardown frees its block");
352 358
353 rt::d3d12::GeometryViews tight(9 * kView); 359 const auto tight_owner = std::make_unique<rt::d3d12::GeometryViews>(9 * kView);
360
361 auto& tight = *tight_owner;
354 const std::uint64_t va_t1 = tight.resolve(device, pbase, 3 * kView, copy); 362 const std::uint64_t va_t1 = tight.resolve(device, pbase, 3 * kView, copy);
355 const std::uint64_t va_t2 = tight.resolve(device, pbase + 3 * kView, 2 * kView, copy); 363 const std::uint64_t va_t2 = tight.resolve(device, pbase + 3 * kView, 2 * kView, copy);
356 check(va_t1 != 0 && va_t2 != 0 && tight.block_count() == 2 && tight.reserved() == 8 * kView, 364 check(va_t1 != 0 && va_t2 != 0 && tight.block_count() == 2 && tight.reserved() == 8 * kView,
@@ -380,8 +388,10 @@ int main() {
380 const auto shbase = reinterpret_cast<std::uintptr_t>(shared_title); 388 const auto shbase = reinterpret_cast<std::uintptr_t>(shared_title);
381 389
382 { 390 {
383 rt::d3d12::GeometryViews dev_a(2 * kView); 391 const auto dev_a_owner = std::make_unique<rt::d3d12::GeometryViews>(2 * kView);
384 rt::d3d12::GeometryViews dev_b(2 * kView); 392 auto& dev_a = *dev_a_owner;
393 const auto dev_b_owner = std::make_unique<rt::d3d12::GeometryViews>(2 * kView);
394 auto& dev_b = *dev_b_owner;
385 const std::uint64_t va_a1 = dev_a.resolve(device, shbase, kView, copy); 395 const std::uint64_t va_a1 = dev_a.resolve(device, shbase, kView, copy);
386 const std::uint64_t va_b1 = dev_b.resolve(device, shbase, kView, copy); 396 const std::uint64_t va_b1 = dev_b.resolve(device, shbase, kView, copy);
387 check(va_a1 != 0 && va_b1 != 0 && dev_a.live_views() == 1 && dev_b.live_views() == 1 && 397 check(va_a1 != 0 && va_b1 != 0 && dev_a.live_views() == 1 && dev_b.live_views() == 1 &&
@@ -405,7 +415,8 @@ int main() {
405 check(va_keep != 0 && dev_a.live_views() == 1 && dev_a.bytes() == kView, 415 check(va_keep != 0 && dev_a.live_views() == 1 && dev_a.bytes() == kView,
406 "surviving instance resolves a second range"); 416 "surviving instance resolves a second range");
407 { 417 {
408 rt::d3d12::GeometryViews ephemeral(2 * kView); 418 const auto ephemeral_owner = std::make_unique<rt::d3d12::GeometryViews>(2 * kView);
419 auto& ephemeral = *ephemeral_owner;
409 const std::uint64_t va_eph = ephemeral.resolve(device, shbase + kView, kView, copy); 420 const std::uint64_t va_eph = ephemeral.resolve(device, shbase + kView, kView, copy);
410 check(va_eph != 0 && ephemeral.live_views() == 1, "scoped instance resolves the same range"); 421 check(va_eph != 0 && ephemeral.live_views() == 1, "scoped instance resolves the same range");
411 ephemeral.release(device); 422 ephemeral.release(device);