test(rt): an empty scene's TLAS builds, then grows and shrinks

TLASEmptyBuild builds frame 0's TLAS with no elements registered and
checks it is a real acceleration structure, then adds an instance and
removes it again, rebuilding each time. Before the fix the first build
threw on NVIDIA (VK_ERROR_OUT_OF_DEVICE_MEMORY).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-19 03:03:16 +02:00
commit e5cfbd249c
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
2 changed files with 159 additions and 0 deletions

View file

@ -528,6 +528,32 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
tbc.GetInterfacesAndImplementations(ifaces, tlasBarrierImpls);
cfg.tests.push_back(std::move(tlasBarrierTest));
// BuildTLAS on an empty scene (no elements registered yet) builds a
// valid empty TLAS instead of creating zero-size buffers, and adding
// and removing instances afterwards still rebuilds it. Needs a Vulkan
// RT device at runtime, like TLASHighWaterMark.
Test tlasEmptyTest;
Configuration& tec = tlasEmptyTest.config;
tec.path = cfg.path;
tec.name = "TLASEmptyBuild";
tec.outputName = "TLASEmptyBuild";
tec.type = ConfigurationType::Executable;
tec.target = cfg.target;
tec.march = cfg.march;
tec.mtune = cfg.mtune;
tec.debug = cfg.debug;
tec.sysroot = cfg.sysroot;
tec.dependencies = cfg.dependencies;
tec.externalDependencies = cfg.externalDependencies;
tec.compileFlags = cfg.compileFlags;
tec.linkFlags = cfg.linkFlags;
tec.defines = cfg.defines;
tec.cFiles = cfg.cFiles;
std::vector<fs::path> tlasEmptyImpls(impls.begin(), impls.end());
tlasEmptyImpls.emplace_back("tests/TLASEmptyBuild/main");
tec.GetInterfacesAndImplementations(ifaces, tlasEmptyImpls);
cfg.tests.push_back(std::move(tlasEmptyTest));
// Issue #118: the per-frame TLAS instance+metadata host rebuild copies
// (and flushes) only the slots whose element's host-authored data
// changed, tracked via RenderingElement3D::hostDataVersion against the