fix(vk): rainbow block-noise textures on low-VRAM cards: a failed BC3 upload is tried again, not drawn as noise #1505
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!1505
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/rainbow-textures-retry-failed-bc3-upload"
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?
On a low-VRAM card, a BC3 texture whose upload failed was drawn as coloured block noise and stayed that way until the area was left. This makes a failed upload get tried again instead.
Related: #993 (garbled / rainbow textures, VRAM over budget, 4-8 GB cards). Part of splitting up #1023, as asked there.
Problem
ASTC textures are decoded on the GPU and re-encoded to BC3. That needs staging memory for the ASTC blocks and a BC3 scratch (an image plus an output buffer, 160-288 MB), which is given back after 20 s unused. On a 4 GB RX 5500M, after an alt-tab or a scene change:
create_device_buffer), and VRAM was full.The result was paths, trees, the Kokiri's clothes and the minimap turning to rainbow block noise.
Change
Texture::bc_retry_frame).vk: BC3 texture #... its upload failed (no staging memory for its ASTC blocks): tried again in 30 frames. Other causes are "no memory for the BC3 scratch", "its layout" and so on.Between a failed upload and its retry, a texture can still show noise briefly; before this change it was permanent.
How to check
On a low-VRAM card, alt-tab out for a few seconds and come back, or change areas. Instead of noise that stays, any failure appears in the log as above and the texture recovers within a moment.
Risk
Only the failure path changes. A texture whose upload succeeds is untouched, so cards with enough VRAM see no difference.
Overlaps #1130 (draft), which spreads large BC3 uploads over several submissions and retries a failed continuation. This PR covers a failed first upload being marked uploaded. Both touch
upload_astc_gpu's callers, so whichever lands second needs a small rebase, which I'm happy to do.Tests
tests/test_bc_upload_retry.py(new) checks the retry, its spacing, the logged cause and the scratch fallback.tests/test_mem_trim.pynow matches the call without its old one-line form; the check itself is unchanged.Tested on
More low-VRAM cards would help, especially AMD ones.