Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3188,7 +3188,8 @@ if(EXISTS "${INTAKE_PYTHON}")
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_compute_check.py" control mbcnt "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(startup_gfx2hlsl_compute_mbcnt_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
foreach(control IN ITEMS swapped-axes dropped-store b-offset c-unpredicated f-peer f-broadcast g-swapped-offsets g-overlap)
foreach(control IN ITEMS swapped-axes dropped-store b-offset c-unpredicated f-peer f-broadcast g-swapped-offsets g-overlap
j-scalar-dropped h-inner-unpredicated k-block-entered)
add_test(NAME startup_gfx2hlsl_compute_${control}_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_compute_check.py" control ${control} "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
Expand Down
56 changes: 51 additions & 5 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -13737,9 +13737,41 @@ root placement. The only in-repo evidence is the local compute-record scan above
used s4 or s5. A numeric read of a user SGPR that the root signature does not place, including s0-s3,
is refused because its value is unknown.

Inside a block that `s_cbranch_execz` skips, a scalar instruction is refused. The wave runs that block
when any lane is active, while the one-lane model would skip it for an inactive lane. An image sample
with implicit LOD is also refused, because a compute lane has no derivatives.
A block that `s_cbranch_execz` skips needs a liveness check. The wave runs the block when any lane is
active, so its scalar results are the same for every lane. The one-lane model skips the block for an
inactive lane. That lane can only differ from the wave by reading scalar state the block defines after the
join. When no lane is active, the wave skips the block too. The block is therefore translated unchanged
when every SGPR, `vcc`, `m0` and SCC it may define is dead where it joins. A backward liveness pass over
the program's instructions checks this. `m0` is always treated as live.

Exec writes inside the block are accepted when the block is straight-line (no branch in it and none into
it) and the write cannot set the exec bit of a lane whose bit is clear, because that lane's bit is clear on
entry. Accepted forms:
- `s_and_saveexec` and `v_cmpx`;
- `s_and` or `s_andn2` that keeps exec;
- `s_or`, `s_xor` or a move whose other source only ever holds a copy of exec made earlier in the same block.

That covers a nested `if` without its own branch. The copies are tracked in program order, which is every path
only in a straight-line block.

Each instruction's reads and writes come from its printed operands, checked against the repository
decoder's spelling:
- `v_cmpx` prints no destination (its e64 form prints an unused SDST field), so all of its operands are reads;
- `s_setpc` and `s_movrel*` do not write their printed operand;
- `v_div_fmas` reads `vcc`;
- the high half of a mask is tracked apart from the low half.

The block is still refused in these cases:
- a definition that is live at the join;
- any other exec write: exec set from a compare alone, restored from a mask saved before the block, or written
in a block with a branch or entered by one (a proven calculated `s_setpc_b64` jump counts), or restored through a 64-bit move, `s_or` or `s_xor` (the tracked copies name
registers, not which exec half they hold);
- an effect outside scalar registers, such as a scalar store or atomic, a barrier, `s_endpgm` or `v_writelane`;
- a branch out of the block;
- a backward `s_cbranch_execz`.

Graphics stages keep today's per-lane behaviour. An image sample with implicit LOD is refused, because a
compute lane has no derivatives.

The output is a `cs` HLSL main with `[numthreads]` and a version 2 manifest. The manifest has
`stage cs` and `group` lines, plus one `uav <slot> table <param> <byte offset>` line for each store
Expand Down Expand Up @@ -13774,14 +13806,28 @@ The runtime has no slot-67 path yet, so no translated compute program runs in th
immediate offset.
- Case C enables Y only, with group size 8x1x1 and 1x5x1 groups. It stores four words from every lane, then
three words under an exec mask set from a compare.
- Case J leaves three of eight lanes active, then enters a block that `s_cbranch_execz` skips for the other
lanes. Inside the block it loads the store descriptor and computes a scalar from the group ID and the root
constants, which the active lanes store. The block's scalars are dead at the join. A control that drops one
of the block's scalar statements must mismatch.
- Case H nests an `s_and_saveexec`/`s_or` if inside such a block. Three lanes store two words, three more lanes
store one word, and the rest store nothing. A control that drops the inner exec predicate must mismatch.
- Case K enters such a block only in group 1; in the other three groups the whole wave skips it. A control that
runs the block for the skipped waves must mismatch.

Each thread reads a read buffer at its own index and stores to its own destination. DXC compiles the HLSL
for `cs_6_0`, and a plain D3D12 device dispatches it. The root signature is the test runner's (a root SRV,
a root UAV and the root constants), so the manifest's table lines and the descriptor fetch are not exercised
on the GPU. All 320 words are compared, including the sentinels. Four controls must each mismatch: swapping
the X and Y group IDs, dropping the store, dropping case B's immediate offset, and dropping case C's exec
predicate. The pure-Python controls refuse every reviewed input that was previously accepted: a modified
descriptor word, an execz-skipped scalar write, an implicit-LOD sample and a misaligned immediate offset.
predicate. Three more cover the execz cases: dropping a scalar statement in case J's block, dropping case H's
inner exec predicate, and running case K's block for the skipped waves.

The pure-Python controls cover:
- accepted and refused execz blocks: a dead definition is accepted; a live scalar definition, SCC consumed
after the join, a nested block and a backward branch are refused;
- a modified descriptor word, an implicit-LOD sample and a misaligned immediate offset, all refused;
- a store past the descriptor's range, which today translates with no range check.

Translating every cached graphics request before and after the descriptor-tracking change gave identical
output and refusals. The local check covered 925 requests, 123 of which translate.
Expand Down
Loading
Loading