Skip to content

[EXPERIMENTAL] vk: Patch AMD grass/foliage flickering on RDNA 2 (RX family) - #196

Closed
ajsea1sy wants to merge 1 commit into
pixl27:mainfrom
ajsea1sy:main
Closed

ajsea1sy wants to merge 1 commit into
pixl27:mainfrom
ajsea1sy:main

Conversation

@ajsea1sy

@ajsea1sy ajsea1sy commented Nov 23, 2026 •

Copy link
Copy Markdown

I see how its meant to be formatted now
Claude assisted in diagnosing the issues

Bug

On AMD's Vulkan driver (tested on RX 5500), grass and foliage flicker or disappear entirely each frame.

Fix

grid_patch_want is instead set unconditionally rather only when indirect == true.
Opt out RX_VK_NO_GRID_PATCH=1.

SSBO stretch (read-only single-binding compute SSBOs to the pool's end, up to 64 MB) is now default on.
Opt out RX_VK_NO_SSBO_STRETCH=1.

On VK_DRIVER_ID_AMD_PROPRIETARY, a -77 result in both guarded_compute and build_graphics now retries once without the optimizer before blacklisting. RX_VK_FAULT_RETRY=1 already covered this manually.

Why

All three issues are AMD driver-specific and interact with how foliage culling is structured. The grid_patch and retry changes only activate when something has already gone wrong and cannot make things worse. SSBO stretch reads within memory the process already owns (which is the same pool allocation), the worst outcome of an edge case is a minor visual glitch rather than a crash. All changes are opt-out with environment variables if a regression appears on another driver.

Four overlapping bugs caused grass and foliage to flicker or disappear
entirely on AMD's proprietary Vulkan driver (RX 6600, RDNA 2):

1. grid_patch_want: OoT's foliage culling chains write the *next*
   dispatch's group counts on the GPU within the same frame.
   grid_patch_want was only set for indirect==true, so direct dispatches
   whose counts were still GPU-written read stale (last-frame) bounds,
   causing the culling program to flicker geometry in and out each frame.
   Fix: set grid_patch_want unconditionally; RX_VK_NO_GRID_PATCH=1 opts out.

2. SSBO stretch default-on: the foliage task/mesh programs read 12-18 MB
   past the declared SSBO size word; when bound to only the declared size,
   reads past it return 0, culling every grass blade. RX_VK_SSBO_STRETCH=1
   already existed as an opt-in. Make it default-on for read-only
   single-binding SSBOs in compute. RX_VK_NO_SSBO_STRETCH=1 opts back out.

3. guarded_compute -77 retry: on AMD's proprietary driver
   VK_ERROR_INITIALIZATION_FAILED (-77) is a compiler hang in the
   optimised path, not a true GPU fault; the unoptimised build succeeds.
   Previously -77 always blacklisted the pipeline immediately (unlike -13
   which was retried). On VK_DRIVER_ID_AMD_PROPRIETARY, retry once without
   the optimizer before blacklisting. fault_retry_on() (RX_VK_FAULT_RETRY)
   already covered this manually; this makes it implicit on AMD.

4. build_graphics -77 retry: same as above for the graphics pipeline path.
   Added amd_prop_retry flag so -77 on AMD proprietary goes through the
   existing no-optimizer retry branch.

Affected programs known to trigger these bugs on RX 6600:
  6eaa646d07ea4e43, 9ef43d77b041f01d (foliage/grass culling shaders)

Env vars:
  RX_VK_NO_GRID_PATCH=1    — disable grid_patch entirely
  RX_VK_NO_SSBO_STRETCH=1  — revert SSBO stretch to opt-in
  RX_VK_SSBO_STRETCH=1     — force SSBO stretch on (old opt-in, still works)
  RX_VK_FAULT_RETRY=1      — retry all -77 faults without optimizer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLcQ6J6pKQztrA2UPk5Ldq
@ajsea1sy ajsea1sy closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants