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
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
(["tests/startup_flat_param_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_bit_alu_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_mad_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_compute_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_swap_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_shift64_check.py", "binary", "llvm-mc-15"], {}),
(["tests/startup_gfx2hlsl_vopc_sdwa_check.py", "binary", "llvm-mc-15"], {}),
Expand Down Expand Up @@ -225,6 +226,7 @@ jobs:
tests/startup_flat_param_check.py \
tests/startup_gfx2hlsl_bit_alu_check.py \
tests/startup_gfx2hlsl_mad_check.py \
tests/startup_gfx2hlsl_compute_check.py \
tests/startup_gfx2hlsl_swap_check.py \
tests/startup_gfx2hlsl_shift64_check.py \
tests/startup_gfx2hlsl_vopc_sdwa_check.py \
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ python3 -m venv out/pe-env
./out/pe-env/bin/python -B tests/startup_image_load_mip_check.py
./out/pe-env/bin/python -B tests/startup_gfx2hlsl_operand_count_check.py
./out/pe-env/bin/python -B tests/startup_gfx2hlsl_mad_check.py
./out/pe-env/bin/python -B tests/startup_gfx2hlsl_compute_check.py
./out/pe-env/bin/python -B tests/startup_gfx2hlsl_swap_check.py
./out/pe-env/bin/python -B tests/startup_image_2d_array_check.py
./out/pe-env/bin/python -B tests/startup_image_sample_a16_check.py
Expand Down
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2695,6 +2695,22 @@ if(EXISTS "${INTAKE_PYTHON}")
set_tests_properties(startup_gfx2hlsl_mad_dispatch_${adapter} startup_gfx2hlsl_mad_preserve_${adapter}
PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
endforeach()
# gfx2hlsl compute stage: entry registers, numthreads and the offen buffer store, dispatched on a plain device (#1412).
add_test(NAME startup_gfx2hlsl_compute_controls COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_compute_check.py")
foreach(adapter IN ITEMS warp hardware)
add_test(NAME startup_gfx2hlsl_compute_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_compute_check.py" dispatch "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(startup_gfx2hlsl_compute_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
foreach(control IN ITEMS swapped-axes dropped-store b-offset c-unpredicated)
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})
set_tests_properties(startup_gfx2hlsl_compute_${control}_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77
PASS_REGULAR_EXPRESSION "control ${control}: rejected at word=[0-9]+ ")
endforeach()
endforeach()
# gfx2hlsl 64-bit VOP3 shifts: binary round-trip, overlap, guards and WARP/hardware draws (Refs #1723).
add_test(NAME startup_gfx2hlsl_shift64_controls COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_gfx2hlsl_shift64_check.py")
Expand Down
58 changes: 58 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -12161,6 +12161,64 @@ ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_mad_' -V
python -B tests/startup_gfx2hlsl_mad_check.py binary llvm-mc-15
```

## Compute stage in the startup translator

`gfx2hlsl.ComputePipeline` translates one gfx1013 compute program with the root and resource model of
the graphics stages. The caller passes `COMPUTE_PGM_RSRC2` and the thread group size, which are pipeline
register state. Each group-ID axis enabled by `TGID_X/Y/Z_EN` gets the next SGPR after the user
SGPRs, with no gap for an omitted axis (`SV_GroupID`). v0-v2 hold `SV_GroupThreadID` up to
`TIDIG_COMP_CNT`. This is how `compute_store_aot` decodes `COMPUTE_PGM_RSRC2` (#1608).
`TG_SIZE_EN` stays refused.

Root parameters are placed from s4, which is an inference, like the graphics stages' s8. #1608 defines no
root placement. The only in-repo evidence is the local compute-record scan above, whose table bindings
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.

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
target. The only store lowered is `buffer_store_dword[x2|x3|x4]` in the `offen` form: a per-lane byte VGPR, plus
the scalar offset and the immediate, through a descriptor at a fixed root-table offset. It writes a
`RWByteAddressBuffer`. All four descriptor words must still be the words the `s_load` returned. Refused:
- the `off` and `idxen` forms, and the cache-policy flags;
- an immediate offset that is not a multiple of 4;
- a descriptor word that was moved, overwritten or modified;
- a descriptor that is also loaded.

As in #2059, the run-time part of the address is rounded down to a multiple of 4. That rounding, and the
handling of out-of-range stores, are assumptions, not measurements.
The runtime has no slot-67 path yet, so no translated compute program runs in the stand-in.

`startup_gfx2hlsl_compute_check.py` translates three source-built programs:
- Case A enables all three group-ID axes and v0-v2, with group size 2x3x4 and 3x2x2 groups, and stores one word.
- Case B enables X and Z only, so Z is s8, with group size 5x2x1 and 4x1x3 groups. It stores two words at an
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.

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.

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.

On Windows 11 (26300), all 320 words matched in every case on WARP (10.0.26100.10068) and on an RTX 5090
(32.0.16.2135), with the debug layer on.

```powershell
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_' -V
python -B tests/startup_gfx2hlsl_compute_check.py binary llvm-mc-15
```

## Startup translator: refusal census

The startup shader translator normally stops a pipeline at its first refusal. Fixing that refusal can expose gaps that were previously hidden, as documented in the [issue #1723 census](https://github.com/R0Y00/Xbox2Windows/issues/1723).
Expand Down
Loading
Loading