Draw task and mesh programs through the mesh fallback by default on AMD's Windows driver for RDNA 1 and 2, where native mesh pipelines lost the device in play; mesh_fallback = 0 draws them natively again.

Every RX 6000 loss whose pass marks named a pass was in one that starts with a native mesh draw, on every version from 0.6.0 to 0.9.2 and with every other setting tried each way; RDNA 1 cards on the same driver draw through the fallback and RDNA 3 and 4 on AMD's other driver draw natively, and neither has such a report. That the native mesh path is the cause is not shown. The decision moves into vk_mesh_path.h with a test of each device kind and setting; has_mesh_shader keeps saying what the hardware has, so the recorder thread and the low-end card test do not change. On those cards no native mesh pipeline is built any more: the seed list and the boot prewarm skip them. The early tail stays off with the fallback, a combination never measured. The fatal line names the mesh path, and NX2NAVI_VK_NOOPT's default applies with mesh_fallback = 0 alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 12:30:42 -05:00
parent 1f4818fb6b
commit 46d71da8aa
9 changed files with 183 additions and 28 deletions

View File

@@ -323,7 +323,8 @@ static const CfgMeta metas[] = {
{"DRAW_WRITERS_WAIT", "1", "0|1", RESTART}, // vk_exec_draw.c writers_wait_on
{"PREPARE_PIPELINES", "all", "0|mesh|all", RESTART}, // vk_pipeline.c seed_pipelines
// vk_device.c: task and mesh programs through compute passes (vk_exec_draw.c "mesh fallback"); auto: on a device
// without mesh shaders. The megabytes are the buffers the passes write (vk_mesh_fb.c).
// without mesh shaders and on AMD's Windows driver for RDNA 1 and 2 (vk_mesh_path.h). The megabytes are the
// buffers the passes write (vk_mesh_fb.c).
{"MESH_FALLBACK", "auto", "auto|0|1", RESTART}, {"MESH_FALLBACK_MB", "128", "16..4096", RESTART},
{"MESH_FALLBACK_WORKERS", "auto", "auto|1|2|3|4", RESTART}, // vk_exec_draw.c mfb_worker_count
{"PIPE_AHEAD", "1", "0|1", RESTART}, // vk_exec.c vk_exec_ahead, vk_pipeline.c vk_pipeline_hint

View File

@@ -73,7 +73,7 @@ typedef struct VkCtx {
lists_low_latency, // the driver lists one of the two, left out: the run started with the mode off
has_mesh_queries; // meshShaderQueries, kept while NX2NAVI_GPU_PASSES or NX2NAVI_DUMP is set
int mesh_fallback; // task and mesh programs run as compute passes and are drawn from buffers
// (mesh_fallback: auto without has_mesh_shader; vk_exec_draw.c "mesh fallback")
// (mesh_fallback: auto as vk_mesh_path.h decides; vk_exec_draw.c "mesh fallback")
// Feedback loops (maxwell.md 1.9, vk_exec_draw.c feedback_prepare): a draw samples a target of its open pass that
// an earlier draw of the pass wrote. NX2NAVI_FEEDBACK=0: VK_FEEDBACK_OFF (sampled in GENERAL without a barrier, the
// old behaviour); VK_FEEDBACK_LAYOUT with VK_EXT_attachment_feedback_loop_layout and dynamicRenderingLocalRead

View File

@@ -19,6 +19,7 @@
#include "vk_fg.h"
#include "vk_dlssg.h"
#include "vk_lowlat.h"
#include "vk_mesh_path.h"
// The loader's vkGetDeviceProcAddr until Streamline is on the device (see vk.h).
PFN_vkGetDeviceProcAddr vk_dpa = vkGetDeviceProcAddr;
@@ -606,19 +607,23 @@ static int create_device(void) {
if (!c->mesh.meshShader || !c->mesh.taskShader) g_vk.has_mesh_shader = 0;
rt_log("vk: mesh shaders: %s", g_vk.has_mesh_shader ? "VK_EXT_mesh_shader" : "the extension is there, its task or mesh feature is not");
} // vkGetDeviceFaultInfoEXT needs the feature, not just the extension
{ // mesh_fallback: auto (on a device without mesh shaders), 1 (on every device, for testing) or 0
// without mesh shaders the mesh emulation (NX2NAVI_MESH_EMULATION, on unless 0) draws them; mesh_emulation = 0
// leaves them to this fallback
const char *mf = cfg_value("NX2NAVI_MESH_FALLBACK"), *me = cfg_value("NX2NAVI_MESH_EMULATION");
int emu = !g_vk.has_mesh_shader && strcmp(me, "0");
g_vk.mesh_fallback = !emu && (!strcmp(mf, "1") || (strcmp(mf, "0") && !g_vk.has_mesh_shader));
g_mesh_path = emu ? "emulated (mesh_emulation)" : g_vk.mesh_fallback ? "through the mesh fallback (compute passes)"
: g_vk.has_mesh_shader ? "native (VK_EXT_mesh_shader)" : "skipped (no mesh shaders, mesh_fallback = 0)";
if (emu) rt_log("vk: mesh shaders: emulated with compute (mesh_emulation = 1); mesh_fallback is not used");
else if (g_vk.mesh_fallback)
{ // mesh_fallback: auto, 1 (on every device) or 0 (vk_mesh_path.h says when auto takes it, and why on AMD's driver
// for RDNA 1 and 2). Without mesh shaders the mesh emulation (mesh_emulation = 1) draws them instead.
// has_mesh_shader keeps saying what the hardware has: the recorder thread (vk_rec.c) and the low-end card
// test (vk_low_end_card) go by it, not by how mesh programs are drawn.
const char *mf = cfg_value("NX2NAVI_MESH_FALLBACK"), *me = cfg_value("NX2NAVI_MESH_EMULATION"), *why = "";
int path = mesh_path_decide(g_vk.has_mesh_shader, vk_caps.amd_sc, mf, me, &why);
g_vk.mesh_fallback = path == MESH_PATH_FALLBACK;
g_mesh_path = path == MESH_PATH_EMULATION ? "emulated (mesh_emulation)"
: path == MESH_PATH_FALLBACK ? (g_vk.has_mesh_shader ? "through the mesh fallback on a device with mesh "
"shaders (compute passes)"
: "through the mesh fallback (compute passes)")
: path == MESH_PATH_NATIVE ? "native (VK_EXT_mesh_shader)" : "skipped (no mesh shaders, mesh_fallback = 0)";
if (path == MESH_PATH_EMULATION) rt_log("vk: mesh shaders: emulated with compute (mesh_emulation = 1); mesh_fallback is not used");
else if (path == MESH_PATH_FALLBACK)
rt_log("vk: mesh fallback: task and mesh programs run as compute passes and are drawn from their buffers (%s)",
g_vk.has_mesh_shader ? "mesh_fallback = 1" : "this device has no mesh shaders");
else if (!g_vk.has_mesh_shader)
why);
else if (path == MESH_PATH_NONE)
rt_log("vk: mesh shaders: not supported and mesh_fallback = 0 (task/mesh draws are skipped)");
}
if (g_vk.has_maximal_reconvergence && !c->mrc.shaderMaximalReconvergence) g_vk.has_maximal_reconvergence = 0;

View File

@@ -1165,7 +1165,8 @@ static uint64_t n_parts, n_subs, n_idle_parts, n_pass_splits, n_cuts;
// tests there; in area loads and some places a tail hands the CPU results and goes as before. The pictures matched
// those without it standing, along the route and through warps to five areas. Not measured with the lazy write-back
// (NVIDIA's and Intel's default), where a tail's uniform updates are noted as writes and no tail goes early.
// Not with shadow storage, emulated mesh shaders, a frame dump or a pass capture, nor inside a chunk or a continuation.
// Not with shadow storage, emulated mesh shaders, the mesh fallback (vk_mesh_path.h: never measured with the early
// tail), a frame dump or a pass capture, nor inside a chunk or a continuation.
static struct {
int on; // the submission's tail is being recorded
int live0; // vk_mem_live_swap's note from before it
@@ -2639,7 +2640,9 @@ static void rec_claim(void) {
void vk_exec_tail_begin(VkExec *ex) {
if (!tail_enabled() || TL.on || ex != x_cur || rw_chunk || evo_in) return;
if (Q.drained != Q.out) group_drain(ex, PW_OP); // the cut needs every piece of the part
if (!vk_sync_wb_split() || !vk_mesh_shader_native() || vk_dump_armed || vk_gpu_passes_capturing()) return;
if (!vk_sync_wb_split() || !vk_mesh_shader_native() || vk_ctx()->mesh_fallback || vk_dump_armed ||
vk_gpu_passes_capturing())
return;
if (!vk_sync_tail_ok()) return;
if (ex->in_pass) vk_exec_pass_end(ex);
vk_exec_barrier(ex); // the command buffer so far ends behind a full barrier, every image back in GENERAL

48
runtime/vk_mesh_path.h Normal file
View File

@@ -0,0 +1,48 @@
// How the game's task and mesh programs are drawn (vk_device.c create_device). Header only, so that
// tests/mesh_path_check.c checks the decision without a device.
//
// native VK_EXT_mesh_shader pipelines
// fallback the mesh fallback: the programs run as compute passes and an ordinary draw reads what they wrote
// (vk_exec_draw.c "mesh fallback", vk_mesh_fb.c)
// emulation the mesh emulation (mesh_emulation = 1 on a device without mesh shaders, vk_exec_draw.c)
// none a device without mesh shaders with both off: mesh draws are skipped
//
// mesh_fallback = auto (the default) takes the fallback on a device without mesh shaders, and on AMD's Windows driver
// for RDNA 1 and 2 (vk_caps.amd_sc), which has them on RDNA 2. That driver lost the device ("No fault detected", a
// timeout) minutes into play on RX 6600 to RX 6950 XT cards in every version from 0.6.0 to 0.9.2 (0.10.x built its mesh
// pipelines without the driver's optimiser, NX2NAVI_VK_NOOPT, which no reporter has confirmed), with the pipeline
// library, the replay workers, the asynchronous replay, the lazy write-back and the low-end GPU mode each on and off.
// Where the pass marks named the pass the GPU was in, it was one that starts with a native mesh draw. The same driver
// on RDNA 1 has no mesh shaders and draws through this fallback, and AMD's driver for RDNA 3 and 4 (LLPC) draws them
// natively; neither has such a report. That the native mesh path is the cause is not shown: the fallback is what the
// marks leave to try, at the cost of a compute pass and a pass break per mesh draw, and of mesh programs that are
// left out of the picture until their compute passes are built, at their first sight in a run. mesh_fallback = 0
// draws them natively again; 1 takes the fallback on every device.
#pragma once
#include <string.h>
enum { MESH_PATH_NATIVE, MESH_PATH_FALLBACK, MESH_PATH_EMULATION, MESH_PATH_NONE };
// has_mesh: the device has VK_EXT_mesh_shader with task and mesh shaders; amd_sc: AMD's Windows driver for RDNA 1 and
// 2; fallback: the mesh_fallback setting ("auto", "0", "1"; anything else reads as auto); emulation: mesh_emulation
// ("0" off). *why: the reason, for the boot line.
static inline int mesh_path_decide(int has_mesh, int amd_sc, const char *fallback, const char *emulation,
const char **why) {
const char *w;
int path;
if (!has_mesh && strcmp(emulation, "0"))
path = MESH_PATH_EMULATION, w = "mesh_emulation = 1 on a device without mesh shaders";
else if (!strcmp(fallback, "1"))
path = MESH_PATH_FALLBACK, w = "mesh_fallback = 1";
else if (!strcmp(fallback, "0"))
path = has_mesh ? MESH_PATH_NATIVE : MESH_PATH_NONE, w = "mesh_fallback = 0";
else if (!has_mesh)
path = MESH_PATH_FALLBACK, w = "this device has no mesh shaders";
else if (amd_sc)
path = MESH_PATH_FALLBACK, w = "the default on AMD's driver for RDNA 1 and 2, where native mesh pipelines lost "
"the device in play; mesh_fallback = 0 draws them natively";
else
path = MESH_PATH_NATIVE, w = "VK_EXT_mesh_shader";
if (why) *why = w;
return path;
}

View File

@@ -1038,7 +1038,7 @@ static VkPipelineCreateFlags noopt_flag_for(int mesh);
static void mesh_lib_init(const VkCtx *c) {
const char *why = !c->has_mesh_shader ? "this GPU has no mesh shaders"
: c->mesh_fallback ? "mesh draws go through the mesh fallback (mesh_fallback = 1)"
: c->mesh_fallback ? "mesh draws go through the mesh fallback (vk_device.c, mesh_fallback)"
: !vk_caps.gpl ? "the graphics pipeline library is off"
: !cfg_bool("NX2NAVI_GPL_MESH") ? "NX2NAVI_GPL_MESH=0"
: noopt_flag_for(1) != noopt_flag_for(0) ? "they alone are built without the driver's optimiser "
@@ -3379,11 +3379,14 @@ static int is_src1(unsigned f) { return f >= NVN_BLEND_FUNC_SRC1_COLOR && f <= N
// ("No fault detected", a timeout) minutes into play on RX 6600 to RX 6950 XT cards in every version from 0.6.0 to
// 0.9.2, with the pipeline library on or off and the lazy write-back on or off. Where the reports' pass marks name a
// pass the GPU was in, twelve logs of five reporters, it is a pass whose first draw is a mesh pipeline (mesh shader
// ba4302f1 with fragment shader f64a96dd in nine, the one-draw pass of 1bbdb17e with 6cc3a476 in three); the five
// logs of 0.9.1 and 0.9.2 stop between the compute dispatch before such a pass and the pass. No reporter ran with
// the optimiser off, so that it is the cause is not shown: it is the one suspect the marks leave, it costs shader
// speed in those pipelines and not the picture, and NX2NAVI_VK_NOOPT=0 gives the optimised ones back. The flag is
// part of what the driver's cache keys a pipeline by, so those pipelines are built once more after the change.
// ba4302f1 with fragment shader f64a96dd in nine, the one-draw pass of 1bbdb17e with 6cc3a476 in three). The logs of
// 0.9.1 and 0.9.2 end with the game's dispatch of cs d7566eb1 finished and nothing after it marked: the group of draws
// that followed was recorded by the replay workers, whose passes have no marks, so which draw of it hung is not known.
// No reporter ran with the optimiser off, so that it is the cause is not shown: it costs shader speed in those
// pipelines and not the picture, and NX2NAVI_VK_NOOPT=0 gives the optimised ones back. The flag is part of what the
// driver's cache keys a pipeline by, so those pipelines are built once more after the change.
// Since then that driver draws mesh programs through the mesh fallback by default (vk_mesh_path.h), and no mesh
// pipeline is built there: this applies with mesh_fallback = 0 alone, as the 0.10.x way to compare against.
static VkPipelineCreateFlags noopt_flag_for(int mesh) {
static int on = -1;
if (on < 0) {
@@ -6031,8 +6034,9 @@ static void prewarm_run(void) {
// (NX2NAVI_MESH_EMULATION) it is a vertex pipeline and its compute stages (pipe_miss: layout_get_emu), built
// here like the others: left to the first draw, each took 113-830 ms on an RX 580 and the draws waiting for it
// were skipped (22 of the 48 pipelines missed entering Kokiri Forest, 0.9.1), frames held back or shown without
// them.
if (is_mesh(&s) && !vk_ctx()->has_mesh_shader && !mesh_emu_on()) {
// them. With the mesh fallback on a device that has mesh shaders (vk_mesh_path.h: AMD's driver for RDNA 1 and
// 2) none is built either: no mesh draw uses one, and that driver is not to compile them.
if (is_mesh(&s) && (vk_ctx()->mesh_fallback || (!vk_ctx()->has_mesh_shader && !mesh_emu_on()))) {
dropped++;
continue;
}
@@ -8338,7 +8342,7 @@ static int seed_pipelines(const char *dir) {
other++;
continue;
}
if (is_mesh(&s) && !vk_ctx()->has_mesh_shader) { // this GPU draws no mesh pipeline
if (is_mesh(&s) && (!vk_ctx()->has_mesh_shader || vk_ctx()->mesh_fallback)) { // no mesh draw uses one
no_mesh++;
continue;
}
@@ -8840,7 +8844,7 @@ static int save_with(uint32_t wait_ms, int exiting) {
(unsigned long long)P.g.ready_fresh);
// The mesh pipelines by themselves: with stage libraries the first two numbers follow each other and the
// times are a link's; without (the start's line says why) none is linked and the time is a whole build's.
if (vk_ctx()->has_mesh_shader)
if (vk_ctx()->has_mesh_shader && !vk_ctx()->mesh_fallback)
rt_log("vk_pipeline: gpl: mesh pipelines (%s): %llu fast links (avg %.2f ms, max %.2f ms); the %llu a draw "
"missed were usable after avg %.1f ms, longest %.0f ms, %llu of them through a fast link (the others "
"after their whole build); their libraries made in this run: %llu of task and mesh stages (avg %.1f "