Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions docs/experiments/native-mesh-frontend-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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).
- 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 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: `
(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. 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 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).
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.
Loading