fix(vk): a read-back pool whose command buffer or fence failed is made again, not used half made #1251
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
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/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1251
Loading…
Reference in a new issue
No description provided.
Delete branch "jcabarca/Longshot:fix/vk-readback-pending"
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?
Type: fix · Risk: low · Tested on: Windows, AMD Radeon RX 9070 XT · Needs: none
Why
If allocating the read-back command buffer or fence fails, the pool is kept, so the next read-back skips creation and begins a null command buffer (VUID-vkBeginCommandBuffer-commandBuffer-parameter): a crash.
The same fix was first sent as part of #287 together with other changes; this PR sends it alone, one fix per PR.
How to reproduce
Seen on: not seen in the game: found by reading
readback_begin()ingpu/vk/vk_texture.cpp; it happens whenvkAllocateCommandBuffersorvkCreateFencefails (out of memory) on the first read-backSettings and switches: defaults
Steps: game-free:
python -I -B tests/test_readback_pending.pywith this PR's test on a main checkoutExpected: the pool is destroyed and all three handles are nulled, so the next call makes them again
Actual: on main: "a read-back pool whose command buffer or fence failed is kept half made"
What changed
On that failure
readback_begin()destroysrb_pool(which frees its command buffer) and setsrb_pool,rb_cmdandrb_fencetoVK_NULL_HANDLE.gpu/vk/vk_texture.cpp:readback_begin()as above.tests/test_readback_pending.py(new) andtests/test_readback_timeout_reuse.py(one line: it still finds its code).The bug, step by step:
readback_begin()createsrb_poolonly when it is null, then allocatesrb_cmdand createsrb_fence.rb_poolset.vkResetCommandPoolandvkBeginCommandBufferwith a nullrb_cmd.The rules:
vkDestroyCommandPoolfrees the pool's command buffers; none is pending here (nothing was submitted), soVUID-vkDestroyCommandPool-commandPool-00041holds.Measurements
Verdict: it fixes the bug:
tests/test_readback_pending.pyfails on main and passes with this PR, in both interleaved runs. No speed change is expected: the change is on a failure or check path.Hardware: AMD Radeon RX 9070 XT, Windows; the test itself is game-free (it runs on the CPU, compiled with clang++ from llvm-mingw where it builds a fixture); Python 3.12
Scene: none, game-free
Method: this PR's test files on each side's checkout, 2 runs each, interleaved (main, PR, main, PR); the result is pass/fail, so the median is the result both runs gave
How to reproduce:
python -I -B tests/test_readback_pending.pyon each sideac7787512efece40tests/test_readback_pending.py, run 1tests/test_readback_pending.py, run 2Flags and settings
None.
Testing
Tested: on this branch, Windows, Python 3.12, clang++ from llvm-mingw:
tests/test_readback_pending.pypasses (fails on main).Built and played: this commit builds on Windows (llvm-mingw back end) and on Linux (
longshot_vk.so, without and with AMD FSR 4). Played on Windows, AMD Radeon RX 9070 XT: the game runs normally.Not tested: the failure path itself in the game (it needs a driver failure or a format pair the RX 9070 XT does not produce on demand). Linux was built, not run.
Must be tested: None: the change is the same on every GPU and OS, and the game-free test covers it.
Risks
What could break: none expected: only the failure path changes.
Turning it off: revert the commit.
Compatibility: Nothing changes.
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). (the check that reads the changed code, on this PR, Windows:tests/test_readback_pending.py)third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here. (tests/test_readback_pending.py)tests/that reads changed source updated in this PR, not weakened.Tested in game: Played on Windows, AMD Radeon RX 9070 XT: the game runs normally.
I am juliotec, the original author of this fix. It was first sent as part of #287 together with other changes; this PR sends it alone, one fix per PR, rebased on current main.
WIP: fix(vk): a read-back pool whose command buffer or fence failed is made again, not used half madeto fix(vk): a read-back pool whose command buffer or fence failed is made again, not used half made