Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b2a1957
startup: keep sample_b and get_lod past a divergent EXEC with a per-q…
tedin7 Nov 26, 2026
b006a05
Merge remote-tracking branch 'origin/main' into x2w-texflow-votes
tedin7 Nov 26, 2026
087c789
startup: vote EXEC branches with an arithmetic helper and only over v…
tedin7 Nov 26, 2026
5c907dd
tests: draw the saved-and-restored EXEC shape in the derivative flow …
tedin7 Nov 26, 2026
9402a52
startup: refuse a per-lane sample_b bias past a divergent EXEC
tedin7 Nov 26, 2026
c45dc9e
Merge remote-tracking branch 'origin/main' into x2w-texflow-votes
tedin7 Nov 26, 2026
48529ed
Merge remote-tracking branch 'origin/main' into x2w-texflow-votes
tedin7 Nov 26, 2026
5debc65
Merge branch 'main' into x2w-texflow-votes
Nov 26, 2026
1b7ae02
fix: quad vote and lane-exact EXEC for derivative ops (review threads)
Nov 26, 2026
083b949
Merge remote-tracking branch 'origin/main' into HEAD
Nov 26, 2026
af91d6b
Merge remote-tracking branch 'origin/main' into x2w-texflow-votes
Nov 26, 2026
1d648da
Merge remote-tracking branch 'fork/x2w-texflow-votes' into x2w-texflo…
Nov 26, 2026
ef78635
Merge remote-tracking branch 'origin/main' into x2w-texflow-votes
Nov 26, 2026
c95028f
chore: merge main
Nov 26, 2026
706fc08
fix: refuse a restore of a pre-s_wqm EXEC copy and 32-bit EXEC source…
Nov 26, 2026
073ee10
fix: a 32-bit EXEC write is never lane-exact, even from a constant
Nov 26, 2026
780a8fa
test: use the 64-bit EXEC clear where a test expects the derivative p…
Nov 26, 2026
e4b9d1b
test: inside_y keeps u equal in every lane and varies v with y, so on…
Nov 26, 2026
a99c0a5
chore: merge main (shader cache revision 26 / 26cs)
Nov 26, 2026
74e0074
test: draw the quad vote alone with one lane of the quad set at each …
Nov 26, 2026
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
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3889,6 +3889,24 @@ if(EXISTS "${INTAKE_PYTHON}")
"$<TARGET_FILE:offscreen_check>" ${adapter} $<$<BOOL:${STARTUP_FXC}>:${STARTUP_FXC}>)
set_tests_properties(startup_image_sample_b_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
endforeach()
# gfx2hlsl image_sample_b past a divergent EXEC: EXEC branches decided per quad, drawn against a CPU reference.
add_test(NAME startup_image_sample_b_flow_controls COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_image_sample_b_flow_check.py")
foreach(adapter IN ITEMS warp hardware)
add_test(NAME startup_image_sample_b_flow_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_image_sample_b_flow_check.py" draw "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter} $<$<BOOL:${STARTUP_FXC}>:${STARTUP_FXC}>)
set_tests_properties(startup_image_sample_b_flow_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
endforeach()
# gfx2hlsl image_get_lod past a divergent EXEC: EXEC branches decided per quad, drawn against a CPU reference.
add_test(NAME startup_image_get_lod_flow_controls COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_image_get_lod_flow_check.py")
foreach(adapter IN ITEMS warp hardware)
add_test(NAME startup_image_get_lod_flow_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_image_get_lod_flow_check.py" draw "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter} $<$<BOOL:${STARTUP_FXC}>:${STARTUP_FXC}>)
set_tests_properties(startup_image_get_lod_flow_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
endforeach()
# Constant-sampler LOD limits of image_sample, _l and _lz (#2177): each form drawn alone against a plain-smp control.
foreach(adapter IN ITEMS warp hardware)
add_test(NAME startup_image_sample_lod_${adapter} COMMAND "${INTAKE_PYTHON}" -B
Expand Down
16 changes: 16 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -17279,6 +17279,22 @@ or `scalar_wide_op()`). Reads where incoming SCC is unverified are refused: at s
control-flow joins/branch targets, after descriptor-elided SCC writes, and after unmodeled SCC writers in
`SCC_UNMODELLED` such as `s_add_u32` (after `s_add_u32` finishes reading its own sources). Run
`ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_src_scc$' -V`.


## Startup translator: derivative image ops under a divergent EXEC

`image_sample_b` and `image_get_lod` take implicit derivatives of the four lanes of a pixel quad. A pixel program
with such an op and no backward branch now decides its `s_cbranch_execz` / `s_cbranch_execnz` per quad
(`x2w_quad_any(exec)`: some lane of the 2x2 quad has its EXEC bit, from fine derivatives of the 0/1 bit), as the guest's
wave skips a block only when no lane is active and runs it with the other lanes masked. A voted branch parts no quad,
so it keeps `uniform_cf` (#2659); the vote reads the quad, so it is taken only while the control flow is quad-uniform
and no lane-exec break (`s_wqm` of a narrowed EXEC, a discard under an unknown EXEC) came first. With that, a derivative
op may sit under `v_cmpx`, inside an `execz` block, past an `execnz` kill branch, or after an EXEC restore. Still
refused: any branch that can differ between lanes and is not an EXEC branch (VCC, SCC not proven uniform), loops with
such a branch, and an `s_wqm` of a narrowed EXEC before the op.
`tests/startup_image_sample_b_flow_check.py` and `tests/startup_image_get_lod_flow_check.py` draw each shape against a
CPU reference (DXC ps_6_0 and FXC ps_5_1) with wrong-value controls.

The `_dispatch_warp` and `_dispatch_hardware` tests run `s_cmp_eq_u32` then `s_mov_b32 sX, src_scc` on a D3D12
UAV dispatch and compare each lane with the CPU reference (SCC 0 and SCC 1, distinct per-case data). A copy of the
lowering mutated to `(scc ? 0u : 1u)` must read back wrong. Run
Expand Down
2 changes: 1 addition & 1 deletion docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ The translation is refused when:
- either header has another size;
- the code reads an attribute the table does not list.

Graphics and compute use cache revisions `x2w-startup-shader-25` and `x2w-startup-shader-25cs`.
Graphics and compute use cache revisions `x2w-startup-shader-26` and `x2w-startup-shader-26cs`.
Revision 25 preserves the sign of zero in binary16 multiply, including the packed and SDWA forms.
Revision 24 invalidates translations that revision 23 wrongly accepted: `vcc_hi_scalar_mask_read` now also
treats a whole-word lane-read writer (`v_readfirstlane`/`v_readlane`) of vcc_hi, in branch order too, as
Expand Down
4 changes: 2 additions & 2 deletions src/startup_stubs/d3d12_draw.inl
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Translation* cached_translation(const void* a, std::size_t a_bytes, const void*
{
// Keep pre-fix desktop bytecode and manifests out of this ABI's cache.
// tools/startup/gfx2hlsl.py hashes the same bytes, without a trailing NUL.
constexpr char revision[] = "x2w-startup-shader-25";
constexpr char revision[] = "x2w-startup-shader-26";
const u64 seed = fnv_bytes(revision, sizeof(revision) - 1);
u64 key = fnv_bytes(root_blob.data(), root_blob.size(), fnv_bytes(b, b_bytes, fnv_bytes(a, a_bytes, seed)));
// A stream's input layout (stream_input_layout) feeds the vertex fetch, so it is part of the key.
Expand Down Expand Up @@ -474,7 +474,7 @@ u64 publish_compute_request(const void* desc)
std::vector<unsigned char> fields(sizeof(words));
words[0] = words[1] = words[3] = words[5] = words[7] = words[9] = words[10] = 0;
std::memcpy(fields.data(), words, sizeof(words));
constexpr char compute_revision[] = "x2w-startup-shader-25cs"; // tools/startup/gfx2hlsl.py compute_key
constexpr char compute_revision[] = "x2w-startup-shader-26cs"; // tools/startup/gfx2hlsl.py compute_key
u64 key = fnv_bytes(compute_revision, sizeof(compute_revision) - 1);
const std::vector<unsigned char>* order[] = {&code, &data, &root_blob, &fields, &state_a, &state_b};
for (const auto* part : order) key = fnv_part(*part, key);
Expand Down
4 changes: 2 additions & 2 deletions tests/startup_compute_request_offline_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
DESC = struct.pack('<12Q', 0, 0, 24, 0, 20, 0, len(CODE), 0, len(DATA), 0, 0, 11)
STATE_A = struct.pack('<3Q', 1, 0x2c, 0xfff0000000000003)
STATE_B = struct.pack('<5I', 0x1234abcd, 0xffff0000, 0, 0, 0)
KEY = 0xc654194497506ecd # framed key at revision 25cs
KEY = 0x8adb64c8a0cdeb72 # framed key at revision 26cs


def framed_key():
h = 1469598103934665603
for b in b'x2w-startup-shader-25cs':
for b in b'x2w-startup-shader-26cs':
h = ((h ^ b) * 1099511628211) & 0xffffffffffffffff
for part in (CODE, DATA, ROOT, DESC, STATE_A, STATE_B):
for b in struct.pack('<Q', len(part)) + part:
Expand Down
4 changes: 2 additions & 2 deletions tests/startup_gfx2hlsl_buffer_store_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def main():
'%s %s' % (result, fail_reason(name)))

# 8. The cache revision moved, so a translation from before the store lowering is never loaded.
check('cache key uses revision 25', G.pipeline_key(b'a', b'b', ROOT) ==
G.fnv(ROOT, G.fnv(b'b', G.fnv(b'a', G.fnv(b'x2w-startup-shader-25')))))
check('cache key uses revision 26', G.pipeline_key(b'a', b'b', ROOT) ==
G.fnv(ROOT, G.fnv(b'b', G.fnv(b'a', G.fnv(b'x2w-startup-shader-26')))))

if failures:
print('FAILED: ' + ', '.join(failures))
Expand Down
2 changes: 1 addition & 1 deletion tests/startup_gfx2hlsl_const_copy_join_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""`s_mov_b32` copy of a plain constant SGPR in tools/startup/gfx2hlsl.py: run-time write and join.

The copy folds the constant into later reads (revision x2w-startup-shader-25), and these two cases pin what must
The copy folds the constant into later reads (revision x2w-startup-shader-26), and these two cases pin what must
stay true next to the fold:
- the copy still assigns its register at run time (`s12 = ...;` is emitted), so a reader the fold does not reach
(a branch target after a join) sees a real value;
Expand Down
4 changes: 2 additions & 2 deletions tests/startup_gfx2hlsl_fract_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def float_capped(word):
repr((seed and seed.group(1), literal and literal.group(1))))
check('the two literals are identical', seed and literal and seed.group(1) == literal.group(1),
repr((seed and seed.group(1), literal and literal.group(1))))
check('the revision is x2w-startup-shader-25, after the vcc_hi lane-read writer guard',
bool(seed and seed.group(1) == 'x2w-startup-shader-25'), repr(seed and seed.group(1)))
check('the revision is x2w-startup-shader-26, after the vcc_hi lane-read writer guard',
bool(seed and seed.group(1) == 'x2w-startup-shader-26'), repr(seed and seed.group(1)))


def key_from_seed(word):
Expand Down
11 changes: 6 additions & 5 deletions tests/startup_gfx2hlsl_image_get_lod_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(image_get_lod; the decoder reads it back with a 2-register address), sampler word 2 loaded from a literal (mip
filter point), and for the second form dmask 0x3.
Checks: dmask 0x1, 0x2 and 0x3 lower to the two calls on the sampler, which carries its LOD limits. A uniform join
before the read is accepted. Controls (refused): dmask 0x4, a 2D array, divergent EXEC, s_cbranch_vccz/execz before
before the read is accepted. Controls (refused): dmask 0x4, a 2D array, s_cbranch_vccz/execz before
the read, a sampler LOD bias, a sampler with mipmapping disabled, and the stage without op_image_get_lod
(negative control: refused as on main).
draw <dxc> [fxc]: also compile the dmask 0x3 stage with dxc ps_6_0 (and fxc ps_5_1).
Expand Down Expand Up @@ -58,8 +58,8 @@ def stage(dmask=1, dim=1, branch=False, divergent=False, join=False, cf_op=None,
insert += sopp(4, 0)
if join: # uniform forward join; every lane still has the entry EXEC at the read
insert += (bytes.fromhex('800380be') + bytes.fromhex('008006bf') + sopp(5, 1) + bytes.fromhex('810381be'))
if divergent: # s_mov_b32 exec_lo, 0: the entry-mask proof is gone
insert += bytes.fromhex('8003febe')
if divergent: # s_mov_b64 exec, 0: the entry-mask proof is gone
insert += bytes.fromhex('8004febe')
if cf_op is not None: # s_mov; s_cbranch_<op> +1; s_mov (vcc/exec: divergent CF)
insert += bytes.fromhex('800380be') + sopp(cf_op, 1) + bytes.fromhex('810381be')
if insert:
Expand Down Expand Up @@ -98,7 +98,8 @@ def controls():
assert call in text and 'v4 = U(t.x);' in text, text
refused(stage(dmask=4), 'image_get_lod form')
refused(stage(dim=5), 'image_get_lod form') # SQ_RSRC_IMG_2D_ARRAY
refused(stage(divergent=True), 'image_get_lod needs implicit derivatives')
_, text = ps(stage(divergent=True)) # a cleared EXEC is an exact per-lane write: the quad program keeps the proof
assert call in text, text
for op in (7, 9): # vccnz, execnz back edge after the read
refused(stage(back_op=op), 'image_get_lod needs implicit derivatives')
for op in (6, 7, 8, 9): # vccz, vccnz, execz, execnz
Expand All @@ -112,7 +113,7 @@ def controls():
finally:
G.Stage.op_image_get_lod = saved
print('image_get_lod: CalculateLevelOfDetail / Unclamped for dmask 0x1, 0x2 and 0x3; uniform join/branch before '
'the read accepted; dmask 0x4, a 2D array, divergent EXEC, vcc/exec branches, a sampler bias and a '
'the read accepted, also after a cleared EXEC; dmask 0x4, a 2D array, vcc/exec branches, a sampler bias and a '
'sampler without mipmapping refused; refused without the handler')
return pipe

Expand Down
Loading
Loading