Skip to content

fix(vk): mesh fallback flicker: wait for the last draw before clearing the shared buffers (#1383 review) - #1509

Merged
NotRexed merged 1 commit into
NotRexed:mainfrom
rakefire-impala:fix/mesh-fallback-flicker-barrier-before-reset
Nov 10, 2026
Merged

NotRexed merged 1 commit into
NotRexed:mainfrom
rakefire-impala:fix/mesh-fallback-flicker-barrier-before-reset

Conversation

@rakefire-impala

@rakefire-impala rakefire-impala commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Since #1383, a recording thread's mesh fallback programs share one record/payload buffer pair. Each fallback draw clears it at the start, but nothing ordered that clear after the previous fallback draw finished reading it. This adds the barrier. It's the write-after-read hazard raised in #1383's review, which the merged version doesn't include yet.

Part of splitting up #1023.

Problem

fallback_record does, in order:

  1. end_pass(cmd)
  2. vkCmdFillBuffer(records ...), and the payload fill
  3. full_barrier(cmd)
  4. the task and mesh dispatches, then the draw

The previous fallback draw's vertex stage reads those records. Without a barrier between that draw and step 2, the fill can overwrite records an earlier draw in flight is still reading. On a GPU without mesh shaders, that can show up as fallback-drawn geometry (foliage, grass) flickering or drawing the wrong primitives.

Change

A full_barrier(cmd) after end_pass, before the fills. Six lines, including the comment and a test check. full_barrier already skips itself when nothing was recorded since the last one, so back-to-back fallback draws pay one barrier, not two.

Tests

tests/test_mesh_fallback.py checks for a barrier between end_pass and the first records fill. The check fails on main without this change.

Risk

Only fallback draws (GPUs without VK_EXT_mesh_shader) take this path. The cost is one barrier per fallback draw, which already has several.

Tested on

GPU AMD Radeon RX 5500M (RDNA1, 4 GB VRAM, no VK_EXT_mesh_shader)
Result Game-free tests pass; part of the build being played now

…w read them

Since NotRexed#1383 a recording thread's fallback programs share one record and
payload pair. fallback_record clears the records (and the payload) at
the start of each fallback draw, but the first barrier came after the
clears: nothing ordered them after the previous fallback draw's vertex
stage, which reads those records. The clear could overwrite records a
draw still in flight was reading (the hazard raised in NotRexed#1383's review).

A full barrier after end_pass, before the clears. tests/test_mesh_fallback.py
checks it.
@rakefire-impala
rakefire-impala force-pushed the fix/mesh-fallback-flicker-barrier-before-reset branch from afb9212 to 946a7a4 Compare November 10, 2026 11:31
@NotRexed
NotRexed merged commit b60edb9 into NotRexed:main Nov 10, 2026
10 checks passed
lucasvinicius73 pushed a commit to lucasvinicius73/Hookshot that referenced this pull request Nov 10, 2026
…w read them (NotRexed#1509)

Since NotRexed#1383 a recording thread's fallback programs share one record and
payload pair. fallback_record clears the records (and the payload) at
the start of each fallback draw, but the first barrier came after the
clears: nothing ordered them after the previous fallback draw's vertex
stage, which reads those records. The clear could overwrite records a
draw still in flight was reading (the hazard raised in NotRexed#1383's review).

A full barrier after end_pass, before the clears. tests/test_mesh_fallback.py
checks it.
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