fix(vk): RX 580 2048SP foliage on AMD's Windows driver: BC arrays without cube compatibility, alpha-to-coverage in the pipeline #2821
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2821
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/bc-array-no-cube"
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?
Summary
On an RX 580 2048SP with AMD's Windows driver, foliage drew with coloured speckles and the Kakariko tree canopy was missing (#2520, #717). The reporter's run that restored it had, besides the shared warp already on
mainfrom #2158, two changes, and this PR is those two, for AMD's Windows driver on GCN (Polaris, Vega) only. Every other GPU and driver is untouched.bc_array_no_cube, no switch). A frame capture showed the draw sampling three 128 x 128 BC arrays of 88 layers (BC3, BC5, BC4). They gotVK_IMAGE_CREATE_CUBE_COMPATIBLE_BITbecause they are square with 6 layers or more, and that driver sampled them wrong with it. On those GPUs a BC 2D array whose layer count is not a multiple of 6 is now made without the bit; explicit cube targets, other formats and multiples of 6 keep it. A cube view of such an image is refused, as an image without the bit always was, and now logged (at most 8 lines). Rule:gpu/vk/cube_compat.h.a2c_in_pipeline). That driver applies the dynamic state even when it says off.RX_VK_A2C_IN_PIPELINE=0goes back to the dynamic state.From the patch attached to #2520, cleaned up: its opt-in env reads became device-policy fields (a row in
gpu/vk/switches.deffor the second), its renames and diagnostic logs are gone. Its third change, building the mesh fallback's compute pipelines without the driver's optimizer, is left out: the issue's A/B held it constant, so nothing shows the foliage needs it, and it costs run time. If the foliage is still wrong with this PR,RX_VK_NOOPT=1tests it with no new code.The issue's A/B only isolated (1), with (2) held on; (2) ships because the run that fixed the foliage had it on, and matches a known driver bug (NX2navi issue 67). The traversal stutter in #2520 is not addressed. Read
gpu/vk/device_policy.h(the two fields and their rule),vk_main.cpp(dev.eds3_a2cafter the policy) andvk_texture.cppfirst.Testing
Tested:
tests/test_cube_compat.py(compiles and runs the rule, both ways: the driver's rule on and off) andtests/test_device_policy.py(a new PC, the RX 580 2048SP on AMD's Windows driver, with both fields on; the switch both ways; rule edges: RDNA, RADV on GCN and Linux stay off). Not run in the game: opened without a run at the author's request. On this PC (RTX 3090) the bug cannot show.Still to test:
@Beanstalkon a GCN card).RX_VK_A2C_IN_PIPELINE=0, expecting the same or a worse picture, which says whether (2) is needed; withRX_VK_NOOPT=1, if the foliage is still wrong (by hand, the reporter).cube view of texture ... refusedline, expecting none: one would mean a draw cubes an array of non-multiple-of-6 layers, which now gets no view there (by hand).Measurements
Verdict: not measured. The issue reports 33.0–33.1 fps in Kakariko and 38.8–39.2 fps in Kokiri on its patch, with the fallback built unoptimised, which this PR does not do; the control drew different foliage, so those figures are not a comparison. This is a correctness fix for one GPU family, not a performance change.
Setup: none run for this PR. Expected cost: (1) is an image flag at creation, none at run time; (2) adds alpha-to-coverage to the pipeline key there, so a few more pipeline compiles on those GPUs. Nothing changes on any other GPU.
Risks
Only AMD's Windows driver on GCN. An array of a layer count that is not a multiple of 6 that a draw views as a cube (or a subset of its layers as a cube array) gets no view there, where it got one before; the log line above shows it if one exists. A revert is enough. Players on other GPUs notice nothing.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (the two checks above pass; 26 others need the Vulkan headers, not installed on this PC;test_switch_table.pyfails only onLONGSHOT_LAUNCHER_STARTUP, a file this PR does not touch)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def. (RX_VK_A2C_IN_PIPELINE: the default is the configuration the issue's run had, not measured here)tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
WIP: fix(vk): a BC 2D array whose layer count is not a multiple of 6 is made without cube compatibilityto fix(vk): a BC 2D array whose layer count is not a multiple of 6 is made without cube compatibilityAdded the patch's other two changes, which I had left out wrongly: the issue's A/B held them on, so the run that restored the foliage had them. Alpha-to-coverage kept in the pipeline and the mesh fallback built without the optimizer are now device-policy fields on for AMD's Windows driver on GCN (RX_VK_A2C_IN_PIPELINE, RX_VK_GCN_FALLBACK_NOOPT), with test_device_policy.py covering a new RX 580 2048SP PC. Title and description updated.
fix(vk): a BC 2D array whose layer count is not a multiple of 6 is made without cube compatibilityto fix(vk): RX 580 2048SP foliage on AMD's Windows driver: BC arrays without cube compatibility, alpha-to-coverage in the pipeline@review
Recommendation: Request changes. The cube rule can turn valid cube views into dummy textures on every GPU. The GCN workarounds also need hardware testing to establish the fix and their runtime cost.
The change aims to restore foliage on AMD's Windows GCN driver by changing BC image flags and pipeline creation. The cube change also removes a previously supported view on all drivers, while the two additional workarounds add unmeasured pipeline costs.
Blocking (2): must change before merging.
gpu/vk/vk_texture.cpp:3138: Removing cube compatibility for every non-multiple-of-six BC array also removes valid cube views of a subset of its layers. (more on the line) Do: Preserve cube sampling for these arrays, for example by creating a compatible image or a synchronized cube-compatible representation when a cube view is requested, while retaining the affected driver's ordinary-array workaround.@fixor@rebasetry first). (for the author)Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_texture.cpp:3138: The actual PR has not been run on the affected driver or on the other systems whose image creation changes. (more on the line) Do: Run the named Kakariko and Kokiri cases on Windows GCN against the base and this head, and check representative BC-array and cube rendering on affected Tier 1 Windows, Linux and Steam Deck configurations. (@fixdoes its part first: Preserve cube-compatible views for arrays that need them, reducing the cross-vendor behavior change.)gpu/vk/vk_draw.cpp:8798: The fallback now disables driver optimization by default on all Windows GCN devices, without an isolated cost or correctness measurement. (more on the line) Do: On Windows GCN, compare interleaved runs with each new switch independently on and off, checking foliage, average and 1% low fps, frame times and pipeline compilation behavior.@fixcan do L1 and L2.Questions (2) (not confirmed from the code; they don't hold the recommendation)
tests/test_cube_compat.py:18: Is there a current image-flag regression that this test misses, rather than a hypothetical future change?Checks: Failing on this head, which is behind its base, where they pass:
CI / Third-party parts and guide screenshots (pull_request),CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request).@rebase(or@fix) brings it up to date and runs them again; not held against it. Cancelled on this head (no result):PR description / Title and description (pull_request_target). Still running: 6 checks.More: does it help, other systems, switches, what was read
Does it help: Unproven for this head: the reported corrected run used a separate patch, and this PR has not run in the game. Its 33.0–33.1 fps and 38.8–39.2 fps figures have no comparable control drawing the same foliage.
Other systems: The cube rule affects BC images on Windows and Linux across vendors, including ASTC textures converted to BC. The pipeline policy affects AMD proprietary Windows GCN devices; disabling dynamic alpha-to-coverage also disables the graphics pipeline library path. No runs on this head establish behavior on those systems.
Switches: RX_VK_A2C_IN_PIPELINE and RX_VK_GCN_FALLBACK_NOOPT are added, both on for AMD proprietary Windows GCN and off elsewhere, with switch-table rows. Their defaults reproduce the reported fixed configuration, but neither its necessity nor its cost is isolated.
Reviewed:
b160dccadcagainst6f5f99fce9: Read the repository rules, PR template, standards, commits and complete diff; read the new cube files and test in full and inspected the changed sections and surrounding paths in the larger renderer and policy files. Skimmed mise.lock and the device-policy test changes; the full large renderer files and the rest of the device-policy test were not read in full. The named review checklist and sibling Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: No code, tests or scripts were run, as requested. The supplied CI checks are still running or have no result.
Overlaps and merge order: Not established from the offline checkout; #2158 is described as already merged.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -8796,3 +8796,3 @@ci.stage = si;ci.layout = p.layout;if (dev.task_mesh_fallback || env_on("RX_VK_NOOPT"))if (dev.task_mesh_fallback || dev.policy.gcn_fallback_no_optimizer || env_on("RX_VK_NOOPT"))L3 (should fix): The fallback now disables driver optimization by default on all Windows GCN devices, without an isolated cost or correctness measurement.
When: Every mesh-fallback compute pipeline on those devices is compiled without optimization; the reported fps uses that setting but has no comparable run with optimization enabled and the corrected foliage intact.
Do: On Windows GCN, compare interleaved runs with each new switch independently on and off, checking foliage, average and 1% low fps, frame times and pipeline compilation behavior.
@ -3136,0 +3135,4 @@{ // (cube_compat.h: an ordinary BC array whose layers are not a multiple of 6 is no stack of cubes, and AMD's Windows driver on GCN sampled it wrong with the bit)const bool could_be_cube = x.type == VK_IMAGE_TYPE_2D && x.layers >= 6 && x.width == x.height &&x.samples == VK_SAMPLE_COUNT_1_BIT;if (cube_compat::compatible(could_be_cube, d.target == NVN_TEXTURE_TARGET_2D_ARRAY, is_bc(x.format), x.layers)) {L1 (blocking): Removing cube compatibility for every non-multiple-of-six BC array also removes valid cube views of a subset of its layers.
When: A square seven-layer BC 2D array sampled by a cube shader using its first six layers previously produced a cube view. The image is now created without the flag, texture_view returns null, and texture_view_of binds the dummy instead, on every GPU.
Do: Preserve cube sampling for these arrays, for example by creating a compatible image or a synchronized cube-compatible representation when a cube view is requested, while retaining the affected driver's ordinary-array workaround.
L2 (should fix): The actual PR has not been run on the affected driver or on the other systems whose image creation changes.
When: The reported A/B used an attached patch rather than these commits; it cannot establish that this integration restores the canopy or that changed BC views still render correctly on other drivers.
Do: Run the named Kakariko and Kokiri cases on Windows GCN against the base and this head, and check representative BC-array and cube rendering on affected Tier 1 Windows, Linux and Steam Deck configurations.
b160dccadcaee603c135Rebased onto
mainand pushed one commit; addressing BeanBot's review:bc_array_no_cube, on only for AMD's Windows driver on GCN (witha2c_in_pipeline); every other driver keeps the bit and its cube views. On those GPUs a cube view of such an array is still refused, so it is logged (8 lines at most) to show if a draw asks for one. I did not build a synchronised cube-compatible copy: nothing seen asks for the view, and it would cost memory and a copy on the driver this is for.RX_VK_NOOPT=1tests it without code.RX_VK_A2C_IN_PIPELINE=0to check whether that part is needed.