vk: draws and clears into BC textures through block views (RADV) #1332
Open
BiasedMonkey wants to merge 1 commit from
BiasedMonkey/fix/bc-block-view-targets into main
pull from: BiasedMonkey/fix/bc-block-view-targets
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!1332
Loading…
Reference in a new issue
No description provided.
Delete branch "BiasedMonkey/fix/bc-block-view-targets"
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: OoT draws into and clears a 16-layer BC4 texture array through an RGBA16UI view of its blocks (one 8-byte block = one RGBA16UI texel). Compressed images were never created with
COLOR_ATTACHMENT, somake_view()returned null for those views and the draws and clears were silently left out. This is theview of texture 0x1133ccb000 (vk 139) as vk 95 type 1 levels 0+1 layers N+1 not madeline found in the AMD haze reports (#914, #1101), 16 times, one per layer.Changes (
gpu/vk/vk_texture.cpp,vk_draw.cpp,vk_xfer.cpp):COLOR_ATTACHMENTwhen the raw block format can be a color attachment andvkGetPhysicalDeviceImageFormatPropertiesaccepts it. This is asked separately fromSTORAGE, so a refusal does not cost the raw storage views (the amdvlk note there).COLOR_ATTACHMENTfirst, then withoutSTORAGE(as before).targets(), region clears inclear_tex()) is computed in blocks (view_texels()), not in the image's texels. The clear rect is clamped to it.RX_VK_BC_TARGETS=1/0turns it on / off on any driver.usage … not in the image's …, or thevkCreateImageViewresult), and compressed images log when one of their block-view usages is refused.How it was found:
MUTABLE_FORMAT | BLOCK_TEXEL_VIEW_COMPATIBLE | EXTENDED_USAGE, plus a storage view as RGBA16UI / R32G32UI) passes on RADV with the Khronos validation layer and no message. So the driver was not refusing it.not made: usage 0x10 not in the image's 0xf. The image hadSTORAGE; the game wantedCOLOR_ATTACHMENT.COLOR_ATTACHMENT, cleared one layer through an RGBA16UI view with dynamic rendering, and read it back: all 16384 blocks held the clear value, with no validation message, on an RX 7700S (NAVI33) and a 780M (PHOENIX), Mesa 26.2.6.Tested: v2.0.11 + this commit (rebased here onto main, builds), RX 7700S, CachyOS, Mesa 26.2.6. Only
hookshot_vk.sowas rebuilt (RX_VK_ONLY=1).Log before (v2.0.11):
Diagnostic build:
After:
Not tested: NVIDIA, amdvlk, Intel (unchanged by default;
RX_VK_BC_TARGETS=1to try). No visible change on this machine: the white haze over outdoor scenes (#1004) is still there with this commit, so it has another cause. This PR only stops the draws and clears into that texture from being skipped.(Update: on this machine the washed-out picture turned out to be #1042, the swapchain's colour space on KDE Wayland: with #1086's change applied to v2.0.11 the picture is right again, so #1086 is confirmed on an RX 7700S, RADV, Mesa 26.2.6. This PR is independent of it.)
AI-assisted (Claude Code) on behalf of the author: diagnosis, repros, patch and write-up; built and run on the machine above.
🤖 Generated with Claude Code
@BiasedMonkey we hit the same views from the NVIDIA side, and I opened #1338 eight minutes after this without having seen it. Sorry for the overlap. The two are close, and I think they combine well. What #1338 adds, and could just as well be folded in here:
53509044401d78d2. The foliage's LOD crossfade reads that noise. With it at zero, trees go bare at mid distance, full again near and far (#1151).RX_VK_SKIP_PROG's default list on main, so even with the views made, the volumes are never written unless it comes off. It was put there for device losses on first starts. Those fit the render area being the texels' 64×64 over a 16×16 view, which both PRs now size in blocks.So I'd suggest enabling it on NVIDIA too, not only RADV, and taking
53509044401d78d2off the default skip list. I'm happy to close #1338 in favour of this PR if you add those, or to rebase #1338 onto it. Whichever the maintainers prefer. I can test a build of this PR on the 3070 at the same spots.Thanks, the diagnosis is solid and the diagnostics (the reason in the "not made" line, the dropped-usage log) are useful on their own. The retry chain (without COLOR_ATTACHMENT, then without STORAGE) is also the safer way to add the usage. A few things:
The noise pass is still skipped by default.
53509044401d78d2is still onRX_VK_SKIP_PROG's default list invk_draw.cpp, so on RADV the draws of that program never run and the volume stays zero (this fits your "no visible change"). As #1338 / Nitnek's comment on this PR say, that program renders OoT's 64^3 BC4 noise volumes that the foliage LOD crossfade reads (#1151). The skip was added for device losses that fit the oversized render area, which you now fix, so I'd drop it from the default list here (or in a follow-up), otherwise the fix isn't exercised in normal play.RADV-only default. Understood, since you only tested RADV. But Nitnek reports 12/12 clean starts on an RTX 3070 with the usage on, so it looks safe to enable for NVIDIA too. The query-gated retry chain here makes that low risk, so I'd widen it once you're happy with that data.
3D images. #1338 mentions the noise volumes are 3D (64^3) and that the usage query doesn't cover the 2D_ARRAY_COMPATIBLE per-slice views, so it takes the usage for 3D images unqueried. Here a 3D BC image whose query fails simply doesn't get the usage, so those volumes would stay unwritten. Worth checking which of 2D array / 3D the game's texture 0x1133ccb000 actually is; if 3D, this needs the same handling (your fallback chain already covers the case where creation is then refused).
Clear rect units. In
clear_tex()the render area becomesvw x vhblocks, buts.x/s.y/s.w/s.hare still in image texels and are only clamped, not divided by 4. For a sub-rect clear of a block view this clears the wrong region (full-surface clears are fine). Probably a conversion withview_texels-style rounding is what you want. Nit-ish since OoT's clears are probably full-surface.Nit: no test is added (#1338 adds
tests/test_bc_raw_targets.py, a source check; you could borrow it, adjusting for the retry chain). CI shows no checks on the branch, so the Windows build hasn't been exercised; nothing in the diff looks like it would break it.On overlap with #1338: both make the same
targets()block-size fix and add COLOR_ATTACHMENT for BC images. This PR is more complete on the Vulkan side (clear_tex path, retry on image-creation failure, diagnostics). #1338 is more complete on what ships (3D images, removes the skip-list entry, all drivers, test). Neither alone is the full fix, and they will conflict invk_texture.cpp/vk_draw.cpp. Folding items 1-3 into this one (as Nitnek offered) and closing #1338 looks like the cleanest path.Tested this PR on NVIDIA (RTX 3070, Windows 11), merged onto main
7dbdcdc. Each run loads a Hyrule Field save near Lon Lon Ranch and is dumped 10 s later withRX_VK_DUMP_SAMPLEDon the spruce LOD programs. The table reads the noise volume the foliage samples.0x1133ccb000not madeRX_VK_BC_TARGETS=153509044401d78d2isleft out (RX_VK_SKIP_PROG)RX_VK_BC_TARGETS=1+RX_VK_SKIP_PROG=-So on NVIDIA the PR works once the noise pass is allowed to run. That confirms point 1 of @hckrman101's review.
On the 2D array vs 3D question: the texture is 3D, 64×64×64, BC4 (NVN 0x49), target 2. The game renders its 64 slices one by one as 2D views, two volumes, 128 draws.
Heads-up: this conflicts with main now (a lot landed today). Could you merge main into the branch (or rebase) and resolve the conflicts? Thanks!
I think this can be closed. Main already does what it does:
9d6936a) adds COLOR_ATTACHMENT to BC images on every driver, not only RADV, after askingvkGetPhysicalDeviceImageFormatProperties. It also sizestargets()in blocks for raw views and takes 53509044401d78d2 off the default skip list.5daa99cmade clear_tex convert the area and the clear rect to blocks and retry without the attachment usage. That's the point-4 bug the earlier review raised, which this branch still has.The extra "not made" reason in the log is the only part main lacks, and it would be a small follow-up on current main. Thanks for the diagnosis; it's what led to the fix that landed.