barrier_merge is on by default

With the unwritten-read rule every read that stays merged comes from a draw that samples a target it also writes,
the case Savage Wind runs the same way on every GPU. Shrine on the RDNA2 iGPU (AMD Windows driver, 1080p): passes
581 -> 128 a frame, GPU time unchanged (37.2 ms off, 38.0 and 36.5 ms on), the picture the same. PR #1237 measured
the waterfall on RADV at 1105 -> 117 passes and GPU 8.3 -> 4.1 ms, and an RTX 4080 shrine at +3% mean fps with the
1% low 83 -> 98. barrier_merge = 0 brings back a full barrier at each such Barrier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-24 09:15:23 +03:00
1 parent 5aaa718eb6
commit dca69306fb
4 files changed
+21 -15

No files matched your search

+1 -1
View File
@@ -222,7 +222,7 @@ static const CfgMeta metas[] = {
{"FREE_CORES", "0", "0|1", RESTART}, {"TIMER_1MS", "1", "0|1", RESTART},
// shaders and pipelines
{"PIPE_WAIT", "default", "default|draw", RESTART}, {"PIPE_SKIP", "fullscreen", "strict|any|fullscreen", RESTART},
{"BARRIER_MERGE", "0", "0|1", RESTART}, {"LIB_PREBUILD", "1", "0|1", RESTART}, {"LIB_PREBUILD_THREADS", "", "1..64", RESTART},
{"BARRIER_MERGE", "1", "0|1", RESTART}, {"LIB_PREBUILD", "1", "0|1", RESTART}, {"LIB_PREBUILD_THREADS", "", "1..64", RESTART},
{"PIPE_PREBUILD", "1", "0|1", RESTART}, {"PREWARM_XLATE", "", "1..64", RESTART}, {"GPL", "1", "0|1", RESTART},
// textures and memory
{"ASTC", "auto", "auto|gpu|native|cpu", RESTART}, {"MEMORY", "auto", "auto|import|mirror|verify", RESTART},
+9 -5
View File
@@ -984,7 +984,7 @@ static void clear_ds(VkExec *ex, const p_clear_ds *c) {
// ---- the op loop
// barrier_merge (TOTK_BARRIER_MERGE, off by default): TotK calls Barrier(ORDER_FRAGMENTS | INVALIDATE_TEXTURE) about
// barrier_merge (TOTK_BARRIER_MERGE, on by default): TotK calls Barrier(ORDER_FRAGMENTS | INVALIDATE_TEXTURE) about
// 1200 times a frame in some scenes (water, decals): the next draw reads the render targets the last one wrote. A full
// barrier there ends the Vulkan pass and flips every target's layout. What such a barrier asks for, an attachment write
// made visible to a later fragment shader read of the open pass, feedback_prepare / feedback_barrier already do before the
@@ -992,10 +992,14 @@ static void clear_ds(VkExec *ex, const p_clear_ds *c) {
// that may write a storage buffer or image (pass_storage), which only a full barrier makes visible, or the barrier asks for
// more than those two bits, or the feedback layout is not in use, or a target is a 3D BC stand-in (its texture gets the
// pass's writes only at the pass end, bc_copy_back). The reads the by-region barrier does not cover end the pass at the
// draw that makes them (vk_exec_draw.c merge_guard). The by-region barrier orders only reads of the pixel a fragment
// writes; NVN's ORDER_FRAGMENTS orders every pixel (ORDER_FRAGMENTS_TILED is the per-region one), so a draw that reads a
// neighbouring pixel of a target written in the pass relies on the driver running the barrier for the whole target, as
// RADV does; hence experimental.
// draw that makes them (vk_exec_draw.c merge_guard), and so do reads of a target the draw does not write itself
// (vk_exec_draw.c merge_unwritten_reads): the by-region barrier orders only reads of the pixel a fragment writes, while
// NVN's ORDER_FRAGMENTS orders every pixel (ORDER_FRAGMENTS_TILED is the per-region one). What stays merged is a draw
// that samples a target it also writes, which Savage Wind runs the same way on every GPU. If such a draw read a
// neighbouring pixel, it would rely on the driver running the barrier for the whole target, as RADV and the desktop
// drivers do. On 1.4.3 every read after a merged Barrier in the shrine, the town and the field is of that kind. Passes
// a frame in the shrine: 581 -> 128 on an RDNA2 iGPU with no GPU time change on AMD's Windows driver; the waterfall
// on RADV: 1105 -> 117, GPU 8.3 -> 4.1 ms.
int vk_exec_barrier_merge_on(void) {
static int on = -1;
if (on < 0) on = cfg_bool("TOTK_BARRIER_MERGE");