Skip to content

Metal: Do not reset barrier fence index after first wait.#67

Merged
DarioSamo merged 1 commit intorenderbag:mainfrom
squidbus:fix-barrier
Dec 9, 2025
Merged

Metal: Do not reset barrier fence index after first wait.#67
DarioSamo merged 1 commit intorenderbag:mainfrom
squidbus:fix-barrier

Conversation

@squidbus
Copy link
Copy Markdown
Contributor

@squidbus squidbus commented Nov 26, 2025

Unleashed Recompiled can do the following for resolve passes:

  • Issue barriers for source and destination textures for both color and depth at once.
  • Set color framebuffer and execute shader color copy draw.
  • Set depth framebuffer and execute shader depth copy draw.

The current logic for barriers here will reset the fence index after the placed barrier is waited on by the next encoder. This was a mistaken optimization that does not account for when encoders are split for reasons other than a new barrier. As a result, subsequent encoders are not blocked on the barrier fence like they should be, and can run out-of-order with the operations before the barrier.

In this particular scenario, the copies are separated into different render encoders due to the framebuffer change, it forgets about the last barrier before the second encoder, and the result is the following:

  • Wait for fence N and signal fence N + 1 in the color copy
  • Perform no fence wait at all and signal fence N + 1 in the depth copy

As a result the depth copy may be reordered to before the barrier, causing e.g. water to flicker in Apotos with anti-aliasing turned off (because this causes both resolves to be shader copy draws).

Fix the issue by removing the lines that reset the fence index to -1 after a wait.

@DarioSamo DarioSamo merged commit cb140dd into renderbag:main Dec 9, 2025
10 checks passed
@squidbus squidbus deleted the fix-barrier branch December 12, 2025 13:50
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