test: indirect RT scratch size without nested std::max, miscompiled by MSVC 19.52 (TEST-INDIRECT-RT-ARENA) #954
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!954
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/954/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@TheGeogeo on GitHub · 2026-11-24 15:40 UTC · original
TheGeogeo:fix/indirect-rt-arena→main· +4 −2 · 1 files · 1 commits · merged 2026-11-24 20:44 UTCClaimed in the coordination issue as: TEST-INDIRECT-RT-ARENA
What and why
d3d12_indirect_rtandd3d12_indirect_rt_upload_sysmemstopped atGPU address arena full ... buffer size in KiB: 105903andFAIL: CreateCommittedResource(compaction/clone buffers)on an RTX 3080.The sizes are not the problem. Printed on that GPU, in bytes (hex, result/scratch): BLAS
a00/200, TLAS800/300, the compaction BLAS from the layera00/200, and fromvkGetAccelerationStructureBuildSizesKHRb00/500. The compaction scratch buffer should be0x600bytes.The cause is the compiler. MSVC 19.52.37029 (toolset 14.52) at
/O2 /Ob1compiles the test'sto this.
_Right$is meant to hold the inner result, but nothing inmainstores it under that name. It shares its stack slot withtv7896, the savedvkDestroyDevicepointer. The code loads that pointer and reads the first eight bytes of the function as the size:That value is not a size, so
arena_allocaterefused it for being larger than the arena. The message prints the size throughint(Width / 1024), so105903may be truncated.The fix takes the maximum of the three values with one
std::maxover a list (and includes<algorithm>for it). The layer and the arena allocator are unchanged. Nothing is skipped.Tested
Windows 11, MSVC 19.52.37029 (
RelWithDebInfo).After the rebase on
main6293c1c4(d6b40a0a, same patch as2bd79535). The head is nowf4fc7623on58be9cdf, with the same patch;runtime/onmaindid not change between the two, so these were not rerun:main, both tests fail witharena full ... buffer size in KiB: 105903. With this commit both pass, 4 runs out of 4.ctest -j 1 --timeout 300: 259 passed, 1 failed, 12 skipped,gameinputdisabled. The failure isd3d12_execute_indirect_validation, also failing in the first run below (#1066 is open for it). The skipped tests are the 12 listed below.First run, on
maina2892784:LEONIDA_ARENA_LOG=1the first allocation after the RT buffers is0x600bytes, as expected.cmovb. Compiled with 14.52 and linked the same way, it fails. Adding only aprintfof the values after the calculation also made the 14.52 build pass, so the failure depends on the surrounding code.gta6rt_d3d12_comsources, built with the same flags, have nocmovfrom a_Left$/_Right$slot that is never stored.<algorithm>: pass.ctest -j 1 --timeout 300: 257 passed, 1 failed, 12 skipped (the log of the baselinef3e26be7: 255 passed, 3 failed, 12 skipped). The only failure isd3d12_execute_indirect_validation, which also fails in the baseline and is known (#306, #749). Every other result is unchanged. Skipped, as in the baseline (the run predates the<algorithm>line):shader_library_corpus,bink_decode,bink_abi,bink_play_headless,fsr_dispatch,bvh_builder,bink_audio,vk_sync_validation,d3d12_sparse_queue_family_contract,d3d12_rgb9e5_rtv,d3d12_boot_movie,d3d12_first_light. Disabled:gameinput.git diff --checkandpython -I scripts/check_no_game_data.py runtime/test/d3d12_indirect_rt_test.cpp: clean.a902c78a) and #710 (296508e1) each merge onto this commit without conflicts. Neither changes this calculation. Those merged trees were not built.No CPU regression: the fault is in the code the compiler makes for this function, and a small standalone copy of the calculation, built with the same options, does not reproduce it.
With GPU-assisted validation on, the RayQueryKHR check misses on
mainand on this branch alike, with fourVUID-vkCmdBuildAccelerationStructuresKHR-pInfos-12281reports; #710 describes the same result and covers the addresses. It is a separate topic and was not rerun here.Not covered: the parts of these tests that need
glslangValidator(the drawing andRayQueryKHRchecks) are not built on this PC, the validation layer was off, GCC and Clang were not used. Whether other MSVC 14.52 builds have the same fault elsewhere was only checked in the files above.GPUs tested: NVIDIA GeForce RTX 3080, driver 621.24, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)@sodove on GitHub · 2026-11-24 15:53 UTC · original
Independent Windows check against parent
a28927849and PR head2bd795357. Bothd3d12_indirect_rtandd3d12_indirect_rt_upload_sysmempassed on both revisions with MSVC 19.44.35220, RelWithDebInfo, Windows 11 26100.7623, NVIDIA RTX 5070 Ti (610.74).Both memory modes exercised BLAS clone and compaction. Each reported a compacted size of 1,152 bytes and the ray query produced one hit and one miss on both revisions. Core and synchronization validation were active, both test modes reported zero validation errors, and the validation self-test passed. This covers the older compiler. The 19.52-specific failure remains covered by the author's run.
Synthetic inputs only. AI-assisted: OpenAI Codex.
@Timon360SB on GitHub · 2026-11-24 17:49 UTC · original
Independent testing results
Tested the indirect ray tracing scratch-size change on NVIDIA Blackwell hardware with Vulkan validation enabled.
Both BASE and HEAD exhibit a reproducible RayQueryKHR failure with matching acceleration structure validation diagnostics.
Tested revisions
a28927849adb4e40dfdec8c32fb6758dcd205a372bd795357da1b7a2a4215873aa32f64279f8d530Test environment
Test configuration
Both revisions compiled successfully.
Execution logs and run timestamps confirm that tests were executed again during subsequent attempts.
CTest results
d3d12_indirect_rtd3d12_indirect_rt_upload_sysmemvk_sync_validationAll 18 CTest process invocations completed with exit code 8 due to the indirect RT test failures.
RayQueryKHR failure
Both indirect RT test variants consistently reported:
The failure reproduced in all 36 executions of the two indirect RT tests across BASE and HEAD.
Acceleration structure validation
The failing tests reported:
VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-12281Representative diagnostic:
The validation layer reports invalid acceleration structure references in the instance geometry passed to
vkCmdBuildAccelerationStructuresKHR.The same diagnostic category and functional failure were present on both revisions.
The exact root cause of the invalid acceleration structure references was not established during this verification.
Upload heap configurations
The failure reproduced with both upload heap configurations:
DEVICE_LOCAL | HOST_VISIBLEmemory with Resizable BAR.LEONIDA_UPLOAD_SYSMEM.Consequently, the observed failure was not limited to the VRAM upload heap configuration.
Successful subchecks
Despite the overall indirect RT test failures, the following subchecks passed consistently:
The recorded compaction size results remained identical between BASE and HEAD.
No scratch-buffer GPU address arena exhaustion diagnostic matching the original reported failure was identified in the examined logs.
Compiler-specific limitation
The compiler used here was MSVC 19.44.35230.
This differs from MSVC 19.52.37029, which is associated with the nested
std::maxmiscompilation addressed by this PR.Therefore, these results do not independently reproduce or confirm the original compiler-specific fix.
Synchronization validation
All
vk_sync_validationexecutions passed.The expected intentional
WRITE_AFTER_WRITEhazard without a barrier and zero errors with a barrier were observed consistently.Conclusion
Result: FAIL on both revisions — no new failure introduced by HEAD was identified in the tested scenarios.
The indirect ray tracing tests consistently failed on both BASE and HEAD due to a RayQueryKHR output mismatch accompanied by invalid acceleration structure reference validation diagnostics.
The original compiler-specific scratch-size issue could not be independently verified with this MSVC version.
The acceleration structure reference issue appears to warrant separate investigation. Testing with the affected MSVC 19.52 toolchain would be required to directly verify the intended fix.
Testing was limited to one NVIDIA GPU, synthetic fixtures and validation-enabled execution. No real-title testing was performed.
AI-assisted log analysis and report preparation.
@TheGeogeo on GitHub · 2026-11-24 19:45 UTC · original
Rebased on
main6293c1c4: the head is nowd6b40a0a, with the same patch as2bd79535(git range-diffreports it unchanged).CI. The failed run built this branch on
a28927849, and both failures come from that base:windowsstopped at thegta6rt.exelink:leonida_xma2_decoder.libhad unresolvedWaitOnAddress/WakeByAddress*. #877 addssynchronizationto its libraries.linux-gpu-toolsfailedcs_imgload_tfeandcs_imgload_d16_tfe. #892 corrects those two fixtures.Both are in the new base. The new CI run has not finished, so this is read from the logs and those changes.
@Timon360SB's report (thanks). The RayQueryKHR miss and the four
VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-12281reports are the same on the base and on this branch, and #710 describes the same result under GPU-assisted validation onmain: the layer replaces the instance's BLAS with its dummy one, so the ray misses. #710 changes how arena acceleration structures get their addresses, and says the RayQueryKHR check still misses under GPU-AV with it. I left that out of this pull request, which only changes the test's scratch-size calculation. I did not rerun GPU-AV.Rerun on Windows 11, MSVC 19.52.37029 (
RelWithDebInfo), RTX 3080, driver 621.24, on the new base:main: bothd3d12_indirect_rtandd3d12_indirect_rt_upload_sysmemfail witharena full ... buffer size in KiB: 105903.ctest -j 1 --timeout 300: 259 passed, 1 failed, 12 skipped. The failure isd3d12_execute_indirect_validation, which #1066 addresses.AI-assisted: yes (Claude Code).
@QemmHD on GitHub · 2026-11-24 20:44 UTC · original
Merging.
Why merged: TEST-INDIRECT-RT-ARENA: d3d12_indirect_rt_test replaces a nested std::max with an initializer-list std::max to work around an MSVC 19.52 miscompile. It's 6 lines. sodove passed both revisions, and the current head is a content-identical rebase.
Why it's good: indirect_rt and indirect_rt_upload_sysmem: PASS with 0 validation errors, and the RayQuery got hit=1 here under validation. Timon360SB's hit=0 on a 5070 with GPU-assisted validation shows up on the base too, so it isn't this PR.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #517, #907, #927, #954 and #1074 merged onto main
32a5d9698(after aslan2142's runtime merges). There the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The 2 failures are d3d12_depth_resolve (pre-existing) and d3d12_close_parity, which fails on plain32a5d9698too: a regression from #510, reported there, not from these PRs. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).