diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-23 04:43:04 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-23 04:43:12 -0500 |
| commit | 18151aedfb173d1bb17c1d4cb0cdea1c4f7a2be2 (patch) | |
| tree | 42a643c3e6441aba0298a028875acd45ae8fdb05 /runtime/test | |
| parent | 57c175391db7b70ac2ec8dc7a7bf04afec52cb88 (diff) | |
Revert #4098: a second rewrite of the XDXR builder on top of #3315's, and xdxr_build_check fails with both
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test')
| -rw-r--r-- | runtime/test/d3d12_xdxr_rt_test.cpp | 13 | ||||
| -rw-r--r-- | runtime/test/vk_xdxr_build_test.cpp | 27 |
2 files changed, 10 insertions, 30 deletions
diff --git a/runtime/test/d3d12_xdxr_rt_test.cpp b/runtime/test/d3d12_xdxr_rt_test.cpp index 23c7a4698..5ea1b1ead 100644 --- a/runtime/test/d3d12_xdxr_rt_test.cpp +++ b/runtime/test/d3d12_xdxr_rt_test.cpp | |||
| @@ -383,12 +383,9 @@ int main(int argc, char** argv) { | |||
| 383 | std::memcpy(sizes, p, sizeof sizes); | 383 | std::memcpy(sizes, p, sizeof sizes); |
| 384 | info_rb->Unmap(0, nullptr); | 384 | info_rb->Unmap(0, nullptr); |
| 385 | } | 385 | } |
| 386 | // A build's size is the nodes it wrote, within the prebuild size (room for the most a tree of that many | 386 | // the builds are exactly their prebuild size, so the compacted size is that size |
| 387 | // elements can have), and it is already as small as it gets: COMPACTED_SIZE and CURRENT_SIZE are that size. The | 387 | if (sizes[0] != blas_info.ResultDataMaxSizeInBytes || sizes[1] != tlas_info.ResultDataMaxSizeInBytes || |
| 388 | // same TLAS built twice has the same tree. | 388 | sizes[2] != tlas_info.ResultDataMaxSizeInBytes) { |
| 389 | auto fits = [](UINT64 size, UINT64 max) { return size && size % 64 == 0 && size <= max; }; | ||
| 390 | if (!fits(sizes[0], blas_info.ResultDataMaxSizeInBytes) || !fits(sizes[1], tlas_info.ResultDataMaxSizeInBytes) || | ||
| 391 | sizes[2] != sizes[1]) { | ||
| 392 | std::fprintf(stderr, "postbuild sizes %llu %llu %llu, prebuild %llu %llu\n", | 389 | std::fprintf(stderr, "postbuild sizes %llu %llu %llu, prebuild %llu %llu\n", |
| 393 | static_cast<unsigned long long>(sizes[0]), static_cast<unsigned long long>(sizes[1]), | 390 | static_cast<unsigned long long>(sizes[0]), static_cast<unsigned long long>(sizes[1]), |
| 394 | static_cast<unsigned long long>(sizes[2]), | 391 | static_cast<unsigned long long>(sizes[2]), |
| @@ -443,9 +440,7 @@ int main(int argc, char** argv) { | |||
| 443 | std::memcpy(&box16_size, p, 8); | 440 | std::memcpy(&box16_size, p, 8); |
| 444 | info_rb->Unmap(0, nullptr); | 441 | info_rb->Unmap(0, nullptr); |
| 445 | } | 442 | } |
| 446 | // the nodes the build wrote and the spare unit, within the prebuild size and below the BOX32 build's own size | 443 | if (box16_size != box16_info.ResultDataMaxSizeInBytes) return fail("MINIMIZE_MEMORY postbuild size"); |
| 447 | if (!box16_size || box16_size % 64 || box16_size > box16_info.ResultDataMaxSizeInBytes || box16_size >= sizes[0]) | ||
| 448 | return fail("MINIMIZE_MEMORY postbuild size"); | ||
| 449 | if (!dump(box16_rb.p, box16_info.ResultDataMaxSizeInBytes, "d3d12_blas_box16", | 444 | if (!dump(box16_rb.p, box16_info.ResultDataMaxSizeInBytes, "d3d12_blas_box16", |
| 450 | "{\"kind\": \"blas\", \"pairs\": false, \"box16\": true, \"address\": " + | 445 | "{\"kind\": \"blas\", \"pairs\": false, \"box16\": true, \"address\": " + |
| 451 | std::to_string(box16_blas->GetGPUVirtualAddress()) + | 446 | std::to_string(box16_blas->GetGPUVirtualAddress()) + |
diff --git a/runtime/test/vk_xdxr_build_test.cpp b/runtime/test/vk_xdxr_build_test.cpp index a0b3f8b6a..98dde6184 100644 --- a/runtime/test/vk_xdxr_build_test.cpp +++ b/runtime/test/vk_xdxr_build_test.cpp | |||
| @@ -76,14 +76,6 @@ bool write_file(const std::string& path, const void* data, std::size_t bytes) { | |||
| 76 | return bool(f); | 76 | return bool(f); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | // The size a structure's header gives (totalSizeIn64BNodes does not count the header): the nodes the build wrote, | ||
| 80 | // at most the layout's size, which leaves room for the most a tree of that many elements can have. | ||
| 81 | std::size_t header_size(const void* structure) { | ||
| 82 | std::uint32_t units = 0; | ||
| 83 | std::memcpy(&units, static_cast<const char*>(structure) + 4, 4); | ||
| 84 | return (std::size_t(units) + 1) * 64; | ||
| 85 | } | ||
| 86 | |||
| 87 | std::string tris_json(const std::vector<Tri>& tris) { | 79 | std::string tris_json(const std::vector<Tri>& tris) { |
| 88 | std::string s = "["; | 80 | std::string s = "["; |
| 89 | for (std::size_t i = 0; i < tris.size(); ++i) { | 81 | for (std::size_t i = 0; i < tris.size(); ++i) { |
| @@ -128,7 +120,6 @@ void expand(const Geometry& g, std::uint32_t geometry, std::vector<Tri>& out) { | |||
| 128 | 120 | ||
| 129 | struct Built { | 121 | struct Built { |
| 130 | std::uint64_t address = 0; | 122 | std::uint64_t address = 0; |
| 131 | std::size_t size = 0; // as the header gives it | ||
| 132 | std::vector<Tri> tris; | 123 | std::vector<Tri> tris; |
| 133 | }; | 124 | }; |
| 134 | 125 | ||
| @@ -192,7 +183,6 @@ int build_blas(vktest::Device& gpu, XdxrBuilder& builder, const std::string& dir | |||
| 192 | return recorded; | 183 | return recorded; |
| 193 | })); | 184 | })); |
| 194 | built.address = base; | 185 | built.address = base; |
| 195 | built.size = header_size(static_cast<const char*>(dst.map) + (base - dst.address)); | ||
| 196 | auto dump = [&](const std::string& case_name, const Buffer& buffer, std::uint64_t at, const std::vector<Tri>& tris) { | 186 | auto dump = [&](const std::string& case_name, const Buffer& buffer, std::uint64_t at, const std::vector<Tri>& tris) { |
| 197 | const auto* bytes = static_cast<const char*>(buffer.map) + (at - buffer.address); | 187 | const auto* bytes = static_cast<const char*>(buffer.map) + (at - buffer.address); |
| 198 | const std::string json = "{\"kind\": \"blas\", \"address\": " + std::to_string(at) + | 188 | const std::string json = "{\"kind\": \"blas\", \"address\": " + std::to_string(at) + |
| @@ -202,9 +192,7 @@ int build_blas(vktest::Device& gpu, XdxrBuilder& builder, const std::string& dir | |||
| 202 | (box16 ? ", \"box16\": true" : ", \"box16\": false") + | 192 | (box16 ? ", \"box16\": true" : ", \"box16\": false") + |
| 203 | (name == "blas_paired_rotations" ? ", \"all_rotations\": true" : "") + | 193 | (name == "blas_paired_rotations" ? ", \"all_rotations\": true" : "") + |
| 204 | ", \"triangles\": " + tris_json(tris) + "}\n"; | 194 | ", \"triangles\": " + tris_json(tris) + "}\n"; |
| 205 | const std::size_t size = header_size(bytes); | 195 | return write_file(dir + "/" + case_name + ".bin", bytes, layout.size) && |
| 206 | if (size > layout.size) return false; | ||
| 207 | return write_file(dir + "/" + case_name + ".bin", bytes, size) && | ||
| 208 | write_file(dir + "/" + case_name + ".json", json.data(), json.size()); | 196 | write_file(dir + "/" + case_name + ".json", json.data(), json.size()); |
| 209 | }; | 197 | }; |
| 210 | if (!moved) { | 198 | if (!moved) { |
| @@ -505,9 +493,7 @@ int main(int argc, char** argv) { | |||
| 505 | barrier_to_host(gpu, cb); | 493 | barrier_to_host(gpu, cb); |
| 506 | return recorded; | 494 | return recorded; |
| 507 | })); | 495 | })); |
| 508 | const char* tlas_bytes = static_cast<const char*>(dst.map) + (base - dst.address); | 496 | EXPECT(write_file(dir + "/tlas.bin", static_cast<const char*>(dst.map) + (base - dst.address), layout.size)); |
| 509 | EXPECT(header_size(tlas_bytes) <= layout.size); | ||
| 510 | EXPECT(write_file(dir + "/tlas.bin", tlas_bytes, header_size(tlas_bytes))); | ||
| 511 | std::string json = "{\"kind\": \"tlas\", \"address\": " + std::to_string(base) + ", \"bias\": " + | 497 | std::string json = "{\"kind\": \"tlas\", \"address\": " + std::to_string(base) + ", \"bias\": " + |
| 512 | std::to_string(bias) + ", \"blas\": [\"blas_random\", " + | 498 | std::to_string(bias) + ", \"blas\": [\"blas_random\", " + |
| 513 | "\"blas_grid_u16_stride16\"], \"instances\": ["; | 499 | "\"blas_grid_u16_stride16\"], \"instances\": ["; |
| @@ -535,7 +521,7 @@ int main(int argc, char** argv) { | |||
| 535 | barrier_to_host(gpu, cb); | 521 | barrier_to_host(gpu, cb); |
| 536 | return recorded; | 522 | return recorded; |
| 537 | })); | 523 | })); |
| 538 | EXPECT(write_file(dir + "/tlas_refit.bin", tlas_bytes, header_size(tlas_bytes))); | 524 | EXPECT(write_file(dir + "/tlas_refit.bin", static_cast<const char*>(dst.map) + (base - dst.address), layout.size)); |
| 539 | std::string json2 = "{\"kind\": \"tlas\", \"address\": " + std::to_string(base) + ", \"bias\": " + | 525 | std::string json2 = "{\"kind\": \"tlas\", \"address\": " + std::to_string(base) + ", \"bias\": " + |
| 540 | std::to_string(bias) + ", \"blas\": [\"blas_random\", \"blas_grid_u16_stride16\"], \"instances\": ["; | 526 | std::to_string(bias) + ", \"blas\": [\"blas_random\", \"blas_grid_u16_stride16\"], \"instances\": ["; |
| 541 | for (std::uint32_t i = 0; i < count; ++i) { | 527 | for (std::uint32_t i = 0; i < count; ++i) { |
| @@ -567,8 +553,7 @@ int main(int argc, char** argv) { | |||
| 567 | std::uint64_t compacted = 0, clone_size = 0; | 553 | std::uint64_t compacted = 0, clone_size = 0; |
| 568 | std::memcpy(&compacted, info.map, 8); | 554 | std::memcpy(&compacted, info.map, 8); |
| 569 | std::memcpy(&clone_size, static_cast<char*>(info.map) + 8, 8); | 555 | std::memcpy(&clone_size, static_cast<char*>(info.map) + 8, 8); |
| 570 | // a build is already as small as it gets: the size its header gives, within the layout's room | 556 | EXPECT(compacted == blas_layout.size); // a build is exactly its layout's size |
| 571 | EXPECT(compacted == random.size && compacted <= blas_layout.size); | ||
| 572 | EXPECT(clone_size == compacted); | 557 | EXPECT(clone_size == compacted); |
| 573 | auto dump_blas = [&](const std::string& name, const Buffer& b, std::uint64_t at, std::size_t bytes) { | 558 | auto dump_blas = [&](const std::string& name, const Buffer& b, std::uint64_t at, std::size_t bytes) { |
| 574 | const std::string j = "{\"kind\": \"blas\", \"address\": " + std::to_string(at) + | 559 | const std::string j = "{\"kind\": \"blas\", \"address\": " + std::to_string(at) + |
| @@ -576,7 +561,7 @@ int main(int argc, char** argv) { | |||
| 576 | return write_file(dir + "/" + name + ".bin", static_cast<const char*>(b.map) + (at - b.address), bytes) && | 561 | return write_file(dir + "/" + name + ".bin", static_cast<const char*>(b.map) + (at - b.address), bytes) && |
| 577 | write_file(dir + "/" + name + ".json", j.data(), j.size()); | 562 | write_file(dir + "/" + name + ".json", j.data(), j.size()); |
| 578 | }; | 563 | }; |
| 579 | EXPECT(dump_blas("blas_clone", clone, clone_at, std::size_t(compacted))); | 564 | EXPECT(dump_blas("blas_clone", clone, clone_at, blas_layout.size)); |
| 580 | // COMPACT into exactly the compacted size; a guard word after it must survive | 565 | // COMPACT into exactly the compacted size; a guard word after it must survive |
| 581 | Buffer packed = make(gpu, std::size_t(compacted) + 256 + 4); | 566 | Buffer packed = make(gpu, std::size_t(compacted) + 256 + 4); |
| 582 | EXPECT(packed.buffer); | 567 | EXPECT(packed.buffer); |
| @@ -602,7 +587,7 @@ int main(int argc, char** argv) { | |||
| 602 | return ok; | 587 | return ok; |
| 603 | })); | 588 | })); |
| 604 | EXPECT(write_file(dir + "/tlas_refit_clone.bin", static_cast<const char*>(tclone.map) + (tclone_at - tclone.address), | 589 | EXPECT(write_file(dir + "/tlas_refit_clone.bin", static_cast<const char*>(tclone.map) + (tclone_at - tclone.address), |
| 605 | header_size(tlas_bytes))); | 590 | layout.size)); |
| 606 | std::string json3 = json2; | 591 | std::string json3 = json2; |
| 607 | json3.replace(json3.find(std::to_string(base)), std::to_string(base).size(), std::to_string(tclone_at)); | 592 | json3.replace(json3.find(std::to_string(base)), std::to_string(base).size(), std::to_string(tclone_at)); |
| 608 | EXPECT(write_file(dir + "/tlas_refit_clone.json", json3.data(), json3.size())); | 593 | EXPECT(write_file(dir + "/tlas_refit_clone.json", json3.data(), json3.size())); |