From b6b70491323c7c93af021a6b168791a0cf44aba7 Mon Sep 17 00:00:00 2001 From: Leyukaka <45659323+Leyukaka@users.noreply.github.com> Date: Sun, 29 Nov 2026 10:32:25 +0100 Subject: [PATCH 1/4] docs: mesh frontend exchange refusals, partial writes and VCC branches --- .../experiments/native-mesh-frontend-rules.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 docs/experiments/native-mesh-frontend-rules.md diff --git a/docs/experiments/native-mesh-frontend-rules.md b/docs/experiments/native-mesh-frontend-rules.md new file mode 100644 index 0000000000..3e3238a989 --- /dev/null +++ b/docs/experiments/native-mesh-frontend-rules.md @@ -0,0 +1,58 @@ +# Mesh frontend exchange refusals, partial writes and VCC branches + +This note covers the C++ mesh frontend behind `gfx1013-raw-ms` on main at `1a0120ba` after changes #3420, #3422 and #3423. +The [test fixture](../../tests/native_direct_mesh_check.py) runs +`compile_dxil SDK CACHE gfx1013-raw-ms INPUT OUTPUT` with a sibling `.mslayout` +containing a `mesh1` line (lines 84-99). + +## Named exchange refusals (#3420) + +The frontend accepts the group-index and count exchanges when their matchers +accept the instruction sequence and entry state. The fixture covers accepted +sequences in `group` (line 280) and `group-counts` (line 220). +The fallback in [gfx1013_direct_mesh.inl](../../src/gfx1013_direct_mesh.inl) +distinguishes these cases (lines 1121-1132). + +- A group-index opener `s_mov_b64 exec, 1` (word `0xbefe0481`) that reaches the fallback gets + `mesh group-index exchange shape or entry state is not covered` (line 1123). + See `mismatched-barriers` and `missing-exec-save` (fixture lines 283 and 286). +- An `s_barrier` followed by a word matching `(word & 0xffffff80) == 0xbf008000` + (an SGPR comparison with zero) gets + `mesh count exchange shape or entry state is not covered` (lines 1124-1127). + See `wrong-count-slot` (fixture line 224). +- Other `s_barrier` and `ds_*` operations get `mesh group memory outside a proven exchange` + (lines 1128-1130), subject to the three DS exceptions below. + See `standalone-barrier` and `standalone-ds-write` (fixture lines 263-264). +- The remaining fallback appends the operation name to `unsupported mesh instruction or EXEC state: ` + (line 1131). This includes `ds_swizzle_b32`, `ds_permute_b32` and `ds_bpermute_b32`. + See `standalone-ds-swizzle`, `standalone-ds-permute`, `standalone-ds-bpermute` + and `unsupported-sleep` (fixture lines 265-271). + +## Partial writes at the count exchange (#3422) + +After accepting the count exchange, the frontend restores full EXEC and clears +the VGPR values still tracked as partial writes in +[gfx1013_direct_mesh.inl](../../src/gfx1013_direct_mesh.inl) (lines 449-453). +A later read of cleared `v10` gets `graphics register undefined on an incoming path: 266` +from [gfx1013_direct_compute.inl](../../src/gfx1013_direct_compute.inl) (line 141). +Both `count-exceeds-writer-bound` and `count-equals-writer-bound` expect this refusal +(fixture lines 244-254). + +## VCC branches (#3423) + +For `s_cbranch_vccz` and `s_cbranch_vccnz`, the frontend uses the tracked VCC +nonempty value when available, or both tracked VCC mask words. Without either +proof it emits `mesh VCC branch lacks a proven guest whole-wave mask` in +[gfx1013_direct_mesh.inl](../../src/gfx1013_direct_mesh.inl) (lines 624-648, refusal at line 644). +A supported VOPC compare into VCC records nonemptiness when both operands are wave-uniform +and EXEC is full, has a known wave mask, or has a lane predicate equal to the +enclosing EXECZ skip's guard (lines 218-220 and 737-760). +Writes to `s106` or `s107` clear the tracked values, as does clearing either +register at a per-lane EXECZ skip exit or CMPX lane diamond join (lines 33-39, 319 and 360). +The fixture accepts `root-vcc-branch`, which compares a root constant with 6 (lines 141-150). +It refuses `lane-vcc-branch`, `narrowed-vcc-branch`, `overwritten-vcc-branch`, +`skip-uniform-vcc` and `diamond-known-vcc` (lines 152-174). + +**Reproduce** with `ctest --preset dev --no-tests=error -R '^native_direct_mesh$'`. + +**Open**. Not measured: how many recorded mesh requests reach each refusal. From 95143c1b3ff82237c3fd550e74a2498838de2166 Mon Sep 17 00:00:00 2001 From: Leyukaka <45659323+Leyukaka@users.noreply.github.com> Date: Sun, 29 Nov 2026 10:39:46 +0100 Subject: [PATCH 2/4] docs: state the mesh frontend conditions precisely --- docs/experiments/native-mesh-frontend-rules.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/experiments/native-mesh-frontend-rules.md b/docs/experiments/native-mesh-frontend-rules.md index 3e3238a989..a0fbd7eac9 100644 --- a/docs/experiments/native-mesh-frontend-rules.md +++ b/docs/experiments/native-mesh-frontend-rules.md @@ -17,7 +17,8 @@ distinguishes these cases (lines 1121-1132). `mesh group-index exchange shape or entry state is not covered` (line 1123). See `mismatched-barriers` and `missing-exec-save` (fixture lines 283 and 286). - An `s_barrier` followed by a word matching `(word & 0xffffff80) == 0xbf008000` - (an SGPR comparison with zero) gets + (a comparison with zero whose source field can encode an SGPR, `vcc_lo`, `vcc_hi`, + `m0`, `exec_lo`, or `exec_hi`) gets `mesh count exchange shape or entry state is not covered` (lines 1124-1127). See `wrong-count-slot` (fixture line 224). - Other `s_barrier` and `ds_*` operations get `mesh group memory outside a proven exchange` @@ -44,11 +45,12 @@ For `s_cbranch_vccz` and `s_cbranch_vccnz`, the frontend uses the tracked VCC nonempty value when available, or both tracked VCC mask words. Without either proof it emits `mesh VCC branch lacks a proven guest whole-wave mask` in [gfx1013_direct_mesh.inl](../../src/gfx1013_direct_mesh.inl) (lines 624-648, refusal at line 644). -A supported VOPC compare into VCC records nonemptiness when both operands are wave-uniform +A supported non-SDWA VOPC compare into VCC records nonemptiness when both operands are wave-uniform and EXEC is full, has a known wave mask, or has a lane predicate equal to the enclosing EXECZ skip's guard (lines 218-220 and 737-760). Writes to `s106` or `s107` clear the tracked values, as does clearing either -register at a per-lane EXECZ skip exit or CMPX lane diamond join (lines 33-39, 319 and 360). +register at a per-lane EXECZ skip exit or at the join of either a CMPX lane diamond or an +`s_and_b64` EXEC diamond (lines 33-39, 319, 360, 587-602 and 823-844). The fixture accepts `root-vcc-branch`, which compares a root constant with 6 (lines 141-150). It refuses `lane-vcc-branch`, `narrowed-vcc-branch`, `overwritten-vcc-branch`, `skip-uniform-vcc` and `diamond-known-vcc` (lines 152-174). From 7808ee8fe76b8b207f68f380c544a87947e09a01 Mon Sep 17 00:00:00 2001 From: Leyukaka <45659323+Leyukaka@users.noreply.github.com> Date: Sun, 29 Nov 2026 10:46:13 +0100 Subject: [PATCH 3/4] docs: state the operand range the mesh compare mask accepts --- docs/experiments/native-mesh-frontend-rules.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/experiments/native-mesh-frontend-rules.md b/docs/experiments/native-mesh-frontend-rules.md index a0fbd7eac9..06b4b3be63 100644 --- a/docs/experiments/native-mesh-frontend-rules.md +++ b/docs/experiments/native-mesh-frontend-rules.md @@ -17,8 +17,8 @@ distinguishes these cases (lines 1121-1132). `mesh group-index exchange shape or entry state is not covered` (line 1123). See `mismatched-barriers` and `missing-exec-save` (fixture lines 283 and 286). - An `s_barrier` followed by a word matching `(word & 0xffffff80) == 0xbf008000` - (a comparison with zero whose source field can encode an SGPR, `vcc_lo`, `vcc_hi`, - `m0`, `exec_lo`, or `exec_hi`) gets + (a comparison with zero whose source field can contain any scalar operand + code from 0 through 127) gets `mesh count exchange shape or entry state is not covered` (lines 1124-1127). See `wrong-count-slot` (fixture line 224). - Other `s_barrier` and `ds_*` operations get `mesh group memory outside a proven exchange` From 0801dd30f8bae7d98b61151d2361974ff1277734 Mon Sep 17 00:00:00 2001 From: Leyukaka <45659323+Leyukaka@users.noreply.github.com> Date: Sun, 29 Nov 2026 11:55:34 +0100 Subject: [PATCH 4/4] docs: tighten three mesh frontend rule statements --- docs/experiments/native-mesh-frontend-rules.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/experiments/native-mesh-frontend-rules.md b/docs/experiments/native-mesh-frontend-rules.md index 06b4b3be63..bea6668bf6 100644 --- a/docs/experiments/native-mesh-frontend-rules.md +++ b/docs/experiments/native-mesh-frontend-rules.md @@ -16,12 +16,14 @@ distinguishes these cases (lines 1121-1132). - A group-index opener `s_mov_b64 exec, 1` (word `0xbefe0481`) that reaches the fallback gets `mesh group-index exchange shape or entry state is not covered` (line 1123). See `mismatched-barriers` and `missing-exec-save` (fixture lines 283 and 286). -- An `s_barrier` followed by a word matching `(word & 0xffffff80) == 0xbf008000` +- A raw word `0xbf8a0000` (`s_barrier`) that reaches the fallback and is + followed by a word matching `(word & 0xffffff80) == 0xbf008000` (a comparison with zero whose source field can contain any scalar operand code from 0 through 127) gets `mesh count exchange shape or entry state is not covered` (lines 1124-1127). See `wrong-count-slot` (fixture line 224). -- Other `s_barrier` and `ds_*` operations get `mesh group memory outside a proven exchange` +- Other `s_barrier` and `ds_*` operations that reach the fallback get + `mesh group memory outside a proven exchange` (lines 1128-1130), subject to the three DS exceptions below. See `standalone-barrier` and `standalone-ds-write` (fixture lines 263-264). - The remaining fallback appends the operation name to `unsupported mesh instruction or EXEC state: ` @@ -42,12 +44,13 @@ Both `count-exceeds-writer-bound` and `count-equals-writer-bound` expect this re ## VCC branches (#3423) For `s_cbranch_vccz` and `s_cbranch_vccnz`, the frontend uses the tracked VCC -nonempty value when available, or both tracked VCC mask words. Without either -proof it emits `mesh VCC branch lacks a proven guest whole-wave mask` in +nonempty value when available, or both tracked VCC mask words. After the scalar branch legality checks, +the frontend emits `mesh VCC branch lacks a proven guest whole-wave mask` if neither proof is available. +See [gfx1013_direct_mesh.inl](../../src/gfx1013_direct_mesh.inl) (lines 624-648, refusal at line 644). A supported non-SDWA VOPC compare into VCC records nonemptiness when both operands are wave-uniform -and EXEC is full, has a known wave mask, or has a lane predicate equal to the -enclosing EXECZ skip's guard (lines 218-220 and 737-760). +and EXEC is full, has a tracked wave-nonempty predicate, or has a lane predicate equal to +the enclosing EXECZ skip's guard (lines 218-220 and 737-760). Writes to `s106` or `s107` clear the tracked values, as does clearing either register at a per-lane EXECZ skip exit or at the join of either a CMPX lane diamond or an `s_and_b64` EXEC diamond (lines 33-39, 319, 360, 587-602 and 823-844).