Bugfix: blank menu text on AMD GPUs - order a new texture's clear before its first upload #228
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!228
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-menu-text"
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?
What this fixes
All title, menu and save text is blank on AMD: the menu bars draw but have no letters.
RX 6750 XT (RDNA2), AMD driver 32.0.21045.16010 (Adrenalin 26.10.1), Windows 10 22H2, Ryzen 5 5600X, 32 GB.
Game
0400486024DEC000v131072, builde0f3ccfa, built from a.nupwith theamd-shared-memoryHookshotBuilder (bundled source =
cbed9ad).Each string's letters are written by the CPU into a new linear R8 texture (256x46, 640x46, …), which program
0ed5737e4ec64d5ddraws once into the string's label. On the GPU that R8 texture is all zero, so the labelstays transparent:
The letters are in guest memory before the texture's first upload, and
upload()reads them: a temporaryprobe on the linear path counted 2703 non-zero bytes of 11776, read in place, with no capture shadow. They
get lost on the GPU side.
Cause
create()moves a new image to GENERAL and clears it in the upload command buffer. The first upload, avkCmdCopyBufferToImageinupload(), is recorded right after it in the same command buffer, with no barrierbetween the clear and the copy. With no dependency between two transfer writes to the same image, they can
execute in either order. NVIDIA's driver runs them in order. On AMD the (fast) clear lands last, so a texture
uploaded in the recording that created it reads zeros. Textures redrawn every frame hide this, but a label drawn
only once stays blank. Compressed textures (ASTC/BC) aren't cleared, so they're unaffected.
Change
gpu/vk/vk_texture.cpp: an image barrier right after the creation clear (transfer writes → all commands,GENERAL → GENERAL), only for the images that are cleared. 13 lines; nothing changes for images that aren't cleared.
Tested
hookshot_vk.dllandhookshot.exerebuilt with the change (oncbed9ad).readable.
RX_VK_NO_FOLLOW=1,RX_VK_OOT_VISUAL=0,HOS_NO_RENDERER_WAIT=1,RX_VK_MIRROR=0,RX_VK_PRECOMPILE=0,RX_VK_CPU_OVER_GPU=1,RX_VK_UPLOAD_ALL=1,RX_VK_TEX_CAPTURE=0,RX_VK_CAPTURE=0.2a9fe7f(currentmain, with the Linux support). Upstream's changes tovk_texture.cppsince
cbed9adare elsewhere in the file; the hunk applies as tested.Not covered
5fa56485a6b07619after the Deku Tree scene. Same as#166, and avoided here with
RX_VK_NOOPT=1.text corrupted).
No game files, shader binaries, caches, images or saves are included.
Thank you!