WIP: fix(vk): a draw left out after it took its occlusion query no longer reports "hidden" #253
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/upscaling
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!253
Loading…
Reference in a new issue
No description provided.
Delete branch "jarynclouatre/Longshot:fix/occlusion-skipped-draw"
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?
Why
A draw that is left out partway through
draw()could tell the game its object is hidden. With the occlusion counts of #197, the game leaves out of its draw lists the objects whose report reads 0. A draw whose query was begun and that then returned before its draw command (descriptors that could not be bound, an index buffer or the indirect records not found, a negative count from the game) ended a query that had counted nothing: available, with a count of 0. The object was then left out though nothing had tested it. The rule for such a draw is "visible", as the comment at the guard says; it only held for a draw that returned before the query was begun.What changed
gpu/vk/vk_draw.cpp,draw):OccGuardno longer begins the query where it is made. It has abegin()that begins it once, andocc_guard.begin()stands before eachvkCmdDraw*ofdraw()(nine places covering its thirteen draw commands). The destructor ends the query only if it was begun. A draw that takes anySKIP_HERE()after the guard leaves its query unused, andocc_collect(gpu/vk/vk_replay.cpp, unchanged) keeps its report "visible" once the submission is done.tests/test_vk_occlusion_queries.py): the guard is cut fromvk_draw.cppand run against the ring with spies for the two query commands. A draw that reaches its command begins once (asked twice) and ends; one that does not begins nothing, and the report of the run stays 4096. The source check now readsdraw(): novkCmdBeginQueryafter the guard, every draw command hasocc_guard.begin()ahead of it, and nothing returns between the two.Flags and settings
None.
Measurements
main:
fbd42024(2026-11-13)this PR: fix/occlusion-skipped-draw @
b3075e9fHardware: none used (game-free checks on a Linux x86-64 PC, g++ 15, Python 3.14.4); the Windows back end cross-built with llvm-mingw 20261104
Scene: none, the game was not run yet
Method:
python3 -I -B tests/run_all.py, two runs each, interleaved (main, PR, main, PR), both runs of a side gave the same counts; this PR'stests/test_vk_occlusion_queries.pyalso run against main's sourcesHow to reproduce: the commands above in a checkout of each commit
fbd42024b3075e9ftests/run_all.py(run 1, run 2)test_bake_portability.pytest_vk_occlusion_queries.pylongshot_vk.dllfor Windows (RX_VK_ONLY=1 RX_RELEASE=1 nx2/build.py --standalone)test_bake_portability.pyfails here for a missing Python module (zstandard), on main as well.Testing
Tested: the game-free suite on a Linux PC, as in Measurements. The Windows back end builds from this branch. The Linux back end was not built here yet.
Not tested: the game itself. What a run has to show: with the default occlusion queries, the log's occlusion line (reports with a count, with 0, unknown) is the same on main and on this PR in a scene where no draw is left out, and the picture is the same. This stays work in progress until that run is done on Windows 11 (RTX 4070 Ti SUPER); its result goes in a comment here. I have no scene in which a draw is left out after its query on demand, so that path is covered by the fixture only.
Needs other testers: None.
Screenshots
Nothing on screen.
Risk and rollback
The query now covers the draw command alone, not the binds before it; only draw commands produce samples, so the counts are the same. A draw command added to
draw()later withoutocc_guard.begin()would leave its query unused, which costs culling for that report and never an object; the source check fails on it.RX_VK_OCC_QUERIES=0turns the occlusion counts off as before, and reverting the commit puts the old guard back.Reviewer notes
git diff main...HEAD -- gpu/vk/vk_draw.cppis the guard and nine one-line additions.Issues
None.
Checklist
For everyone
type(scope): description).main.python -I -B tests/run_all.pyrun and passing (any failure that also fails onmainis named above).third_party/untouched (a new folder with aPROVENANCE.mdinstead).If applicable
tests/that reads changed source updated in this PR, not weakened.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.