Repository navigation
vulkan_memory_budget: saturate multi-heap uint64_t sums in sum_vram_budget - #2333
narekshaghoyandev wants to merge 1 commit into
Conversation
lixonik
left a comment
There was a problem hiding this comment.
Ran vulkan_memory_budget_test.cpp directly with GCC 11 and UBSan on Ubuntu/WSL. All cases, including saturated multi-heap totals, passed with no sanitizer report. Could this executable be registered in CTest? I found no current test target for the new source.
AI-assisted.
wavehs
left a comment
There was a problem hiding this comment.
macOS arm64 check of #2333 (vulkan_memory_budget saturation). A two-file change with no device dependency; I built its new test by hand because the build system does not - see the finding.
Tested head 6376bbc20 merged onto main bdbc7e923 as merge f7ba677a4 (clean, no conflicts).
Environment: Apple M3 Pro arm64, macOS 27.2.1, Apple clang 21.0.0, CMake 4.5.0, CPython 3.15.2, SPIRV-Tools v2026.4, Vulkan headers from /opt/homebrew/include (Vulkan-Headers 1.4.363.0).
The fix and its test
runtime/src/vulkan_memory_budget.h:19-37:add_satclamps each heap'sheapUsage/heapBudgetcontribution atUINT64_MAXinstead of wrapping, andavailablestill keys offlocal_budget != 0, so wide multi-heap devices keep reporting a figure. That is the right shape: the only consumers are the HUD's display (a ratio) and the null-query guard, and a saturated numerator/denominator is a saner answer than a wrapped one.- I compiled and ran the new test directly (
clang++ -std=c++17 -I runtime -I /opt/homebrew/include runtime/test/vulkan_memory_budget_test.cpp): printsvulkan_memory_budget_test: ok, exit 0. - NC (keep the new test, revert only
runtime/src/vulkan_memory_budget.htomain): compile OK, run fails atline 44: saturated.available- the wrappedlocal_budgetbecomes 0 and the code reports "VRAM n/a". The regression is real and the test detects it.
Finding: the new test is never built or run - it is not in runtime/CMakeLists.txt
runtime/test/vulkan_memory_budget_test.cpp is a new file, but runtime/CMakeLists.txt has no add_executable(vulkan_memory_budget_test ...) or add_test for it (I grepped the source list and the test list; ctest --test-dir build2304 -N shows 112 tests and none mentions memory_budget). Every other test in runtime/test is registered explicitly (title_hud_test at :852-859, list_value_wait_budget_test at :1508-1509), and there is no glob, so this file is dead in every build: ctest, the Windows runtime job and Wine will all skip it, which is exactly the regression coverage the PR is adding. The existing guard tests/test_ctest_registration.py cannot see it - its test_all_test_executables_have_an_add_test compares targets that exist against add_test commands, so a file with no target at all is invisible (it passes on this merge; I ran it).
Two things I would ask for in the same PR:
- Register the target. It needs only the Vulkan headers (
target_link_libraries(vulkan_memory_budget_test PRIVATE Vulkan::Headers)), so noWIN32/MSVCguard is needed and it runs on macOS, Linux and Windows alike. - Close the hole in
tests/test_ctest_registration.py: compareruntime/test/*_test.cppagainst the target names in the CMake source, and fail on a file with noadd_executable. Otherwise this class of "test that never runs" will keep getting through, and the PR's own body can say "tested" while CI tests nothing.
Not run: the Windows-only title HUD test (title_hud_test links user32/psapi) and the full ctest suite, neither of which is affected by this header. No GPU work here.
python -I scripts/check_no_game_data.py on both changed files: clean.
No game files. AI-assisted.
|
#2333 | head 6376bbc (merged cleanly with main 1bc055e) | |
timbot103
left a comment
There was a problem hiding this comment.
Static audit of 6376bbc20 only. No builds, tests, or GPU runs.
runtime/src/vulkan_memory_budget.h:22 correctly caps local heapBudget, local heapUsage, and shared heapUsage. The loop stops at VK_MAX_MEMORY_HEAPS even if memoryHeapCount is larger, and heap size does not enter these totals. The arithmetic uses <cstdint> and standard unsigned operations on MSVC and Linux. The HUD and overlay format each total independently by dividing by a fixed GiB constant in runtime/src/memory_figures.h:42.
runtime/test/vulkan_memory_budget_test.cpp:43covers overflow in all three totals, butruntime/CMakeLists.txthas no executable or CTest entry for it. Please register it whereVulkan::Headersis available so runtime CI exercises the regression.runtime/test/d3d12_vram_budget_test.cpp:90adds the two usage totals to check whether either is nonzero. If local usage saturates and shared usage is1, the sum wraps to zero and the assertion fails. Please compare the fields independently withEXPECT(after.local_usage != 0 || after.shared_usage != 0).
AI-assisted.
|
TAKEN by OreoFR (Windows, RTX 4070 8 GB) |
|
Verified by OreoFR — READY
Ready to merge per the maintainers' plan. AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR. |
|
Verified on this machine (Windows 11, MSVC 19.44.35226), and the finding is about the wiring, not the code: this pull request's own test is never built or run by anyone. 1. It applies. 2. The test is not registered anywhere. Every other 3. It compiles and passes once registered, which I checked by adding the two lines locally (in my worktree only, nothing pushed): add_executable(vulkan_memory_budget_test test/vulkan_memory_budget_test.cpp)
target_link_libraries(vulkan_memory_budget_test PRIVATE Vulkan::Headers)So the code is fine and the omission is the whole problem - three lines in Why this one matters beyond itself: this is exactly what #2668's What I did not test: the behaviour. The test feeds made-up heaps to the two Vulkan structures; whether the HUD shows the right budget under Written with an AI assistant. |
Prevents
uint64_twraparound when summing multiple Vulkan memory heaps inleonida::sum_vram_budget()(runtime/src/vulkan_memory_budget.h):out.local_usage += ...,out.local_budget += ..., andout.shared_usage += ...could wrap around modulolocal_budgetto0and falsely markingout.available = false("VRAM n/a").UINT64_MAXcap) forlocal_usage,local_budget, andshared_usage.runtime/test/vulkan_memory_budget_test.cpp.Verification
g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Wno-missing-field-initializers -Iruntime/src runtime/test/vulkan_memory_budget_test.cpppassedg++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Wno-missing-field-initializers -Iruntime/src runtime/test/vulkan_memory_budget_test.cpppassedsaturated.available, exit 1) against unmodifiedubiq/mainpython3 -I scripts/check_no_game_data.py runtime/src/vulkan_memory_budget.h runtime/test/vulkan_memory_budget_test.cppcleanClaimed in the coordination issue as: RT-VULKAN-MEMORY-BUDGET-SATURATE (#1608 (comment))
AI-assisted: yes (Gemini)