Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
0192a5e
feat: record the compute root signature and descriptor tables (slots …
tedin7 Nov 24, 2026
682b0e0
feat: record compute descriptor tables (slot 35) and clear them on a …
tedin7 Nov 25, 2026
bb6b9a1
merge: keep the main-based compute root rework over the first draft
tedin7 Nov 25, 2026
033f40c
startup: record SetComputeRoot32BitConstant(s) (list slots 37, 39)
tedin7 Nov 24, 2026
9c87260
merge: sync with origin/main (keep compute tables and compute root SR…
tedin7 Nov 25, 2026
d8cc1ac
feat: record command-list slot 14 Dispatch on the desktop list
tedin7 Nov 24, 2026
48635dd
startup: refuse Dispatch under a compute root with unforwarded argume…
tedin7 Nov 25, 2026
7307c2f
startup: gate Dispatch on bound compute root SRVs and a pipeline buil…
tedin7 Nov 25, 2026
cffe8ce
startup: record SetComputeRoot32BitConstant(s) (list slots 37, 39)
tedin7 Nov 24, 2026
e0966b9
feat: record command-list slot 14 Dispatch on the desktop list
tedin7 Nov 24, 2026
f3b91dd
startup: refuse Dispatch under a compute root with unforwarded argume…
tedin7 Nov 25, 2026
c18cacb
startup: gate Dispatch on bound compute root SRVs and a pipeline buil…
tedin7 Nov 25, 2026
24c5f55
fix: pass pipeline root out-param in slot86 mesh cached pipeline build
tedin7 Nov 25, 2026
8a4df52
Merge origin/main into x2w-frontier-slot14-dispatch
tedin7 Nov 25, 2026
be1bce6
Merge branch 'pr1803' into startup/compute-dispatch-translated
NiiRoZz Nov 25, 2026
9828b5d
fix: track which compute root constant words were set; drop slot 40 c…
tedin7 Nov 25, 2026
44f0a23
Merge branch 'pr1974' into startup/compute-dispatch-translated
NiiRoZz Nov 25, 2026
2e25282
Merge branch 'pr1975' into startup/compute-dispatch-translated
NiiRoZz Nov 25, 2026
1e567a0
Dispatch translated compute programs with raw table buffers
NiiRoZz Nov 25, 2026
aca6e89
Log untranslated compute dispatches on their own line budget
NiiRoZz Nov 25, 2026
8e14a74
Count compute dispatches per key with their first refusal
NiiRoZz Nov 25, 2026
f2f7bfc
Dispatch translated compute programs that store to 2D textures
NiiRoZz Nov 25, 2026
15e8b7a
Dispatch translated compute programs that read 2D textures
NiiRoZz Nov 25, 2026
509dc53
Check a compute manifest without entry values at Dispatch
NiiRoZz Nov 25, 2026
d3c396c
Document texture views and the census of translated compute Dispatch
NiiRoZz Nov 25, 2026
70b27f2
Check the device on every 64th translated Dispatch and drop a livenes…
NiiRoZz Nov 25, 2026
d0b9e77
Compute dispatch: allow two outputs of one texture, refuse packed out…
NiiRoZz Nov 25, 2026
6e64faa
Merge branch 'main' into startup/compute-dispatch-translated
tedin7 Nov 25, 2026
771b935
Merge origin/main into pr2470
NiiRoZz Nov 25, 2026
15cdaff
Merge pr2470 (origin/main) into pr2490
NiiRoZz Nov 25, 2026
b49c738
Merge remote-tracking branch 'fork/startup/compute-dispatch-translate…
NiiRoZz Nov 25, 2026
f67f80a
Merge branch 'pr2470' into pr2490
NiiRoZz Nov 25, 2026
f5c3c85
startup: compute input named by a resource heap record a root constan…
NiiRoZz Nov 25, 2026
b6bc3c3
startup: drop a heap record control whose branch target was inside an…
NiiRoZz Nov 25, 2026
5bade3c
Merge main into the heap record branch
NiiRoZz Nov 25, 2026
7bbd141
Merge remote-tracking branch 'origin/main' into startup/compute-dispa…
NiiRoZz Nov 25, 2026
fdba779
startup: read the stage kind as the other handlers do in the heap load
NiiRoZz Nov 25, 2026
d17d262
Merge the current slot 14 Dispatch head (8a4df523)
NiiRoZz Nov 25, 2026
a205217
Merge the current root-constant store head (9828b5d8); pin the entry-…
NiiRoZz Nov 25, 2026
c821b4b
startup: avoid calling the compute driver after process termination b…
RavenCurseBurg Nov 25, 2026
67f25a9
Merge the reworked dispatch branch; a compute list transitions a samp…
NiiRoZz Nov 25, 2026
1f5fb5e
Repair a broken line in the dispatch check
NiiRoZz Nov 25, 2026
7728caf
Merge branch 'pr2470' into pr2490
NiiRoZz Nov 25, 2026
76ce41b
Pin four existing texture dispatch refusals: integer view format, man…
NiiRoZz Nov 25, 2026
1efce19
Merge the reworked dispatch and texture branches
NiiRoZz Nov 25, 2026
ba79c8b
startup: bind a compute heap record whose index is a table buffer wor…
NiiRoZz Nov 25, 2026
b306d44
Merge remote-tracking branch 'origin/main' into HEAD
NiiRoZz Nov 25, 2026
5c248dc
docs: a compute heap record whose index is read from a table buffer
NiiRoZz Nov 25, 2026
62b5ccc
docs: state the measured first refusals and the heap-record ceiling e…
NiiRoZz Nov 25, 2026
f5b0303
Drop the repeated compute root reset left by merging two slot 14 snap…
NiiRoZz Nov 25, 2026
190e00a
Merge startup/compute-dispatch-translated (f5b03039) into startup/com…
NiiRoZz Nov 25, 2026
6d64c36
Merge branch 'startup/compute-dispatch-heap-rootconst' into startup/c…
NiiRoZz Nov 25, 2026
5955e40
startup: keep the descriptor load tag when checking the index word's …
NiiRoZz Nov 25, 2026
6c1960c
startup: read the pipe's modified set tolerantly in the heap index wo…
NiiRoZz Nov 25, 2026
38a752a
startup: bind LOD-clamped static samplers (smpl) in the translated co…
NiiRoZz Nov 25, 2026
5e185ab
Merge upstream main; use upstream's process-exit flag and DllMain
NiiRoZz Nov 25, 2026
63875b3
Merge commit '1991fd08a123604ae9c9ffb90de16d201214589a' into startup/…
NiiRoZz Nov 25, 2026
1991fd0
Merge commit '5e185ab7df261b7574e92eca77df063b69bb0ba5' into pr2490-fu
NiiRoZz Nov 25, 2026
356b805
Merge commit '63875b310533d5f872414130a3d4c2e839717d14' into startup/…
NiiRoZz Nov 25, 2026
6940a36
Merge commit '356b805fd38e3cb0120554bfc3612457393fc213' into startup/…
NiiRoZz Nov 25, 2026
8e393e1
Merge upstream main
NiiRoZz Nov 25, 2026
2221bd8
Merge upstream main
NiiRoZz Nov 25, 2026
ddb21ba
Merge commit '2221bd8f2f60ac03a9cf09cc9620cef36eeb209a' into startup/…
NiiRoZz Nov 25, 2026
9caf8fd
Merge remote-tracking branch 'origin/main' into startup/compute-dispa…
NiiRoZz Nov 25, 2026
9d74bec
Merge branch 'startup/compute-dispatch-translated' into startup/compu…
NiiRoZz Nov 25, 2026
d756657
Merge remote-tracking branch 'fork/startup/compute-dispatch-textures'…
NiiRoZz Nov 25, 2026
8c242e3
Merge branch 'startup/compute-dispatch-heap-rootconst' into startup/c…
NiiRoZz Nov 25, 2026
01dc3fc
Merge branch 'startup/compute-dispatch-heap-bufindex' into startup/co…
NiiRoZz Nov 25, 2026
60304f3
Merge upstream main
NiiRoZz Nov 26, 2026
aa11b13
Merge commit '60304f30' into HEAD
NiiRoZz Nov 26, 2026
502aa90
Merge commit 'aa11b13642b5020088a5d8dea3ac2cd319a61db7' into HEAD
NiiRoZz Nov 26, 2026
206749e
Merge upstream main
NiiRoZz Nov 26, 2026
d3fe030
Merge upstream main
NiiRoZz Nov 26, 2026
28c44d5
Merge upstream main
NiiRoZz Nov 26, 2026
c314f36
Merge upstream main
NiiRoZz Nov 26, 2026
8e02291
Merge upstream main
NiiRoZz Nov 26, 2026
03aa5ff
Merge origin/main into startup/compute-dispatch-samplers
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
8 changes: 8 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -16650,6 +16650,14 @@ cmake --build --preset dev --target startup_stream_consumer
ctest --preset dev --no-tests=error -R "^startup_compute_dispatch_" -V
```

### Static samplers with a LOD clamp

The translator writes a constant sampler of `image_sample`, `_l` or `_lz` whose mip filter is not 0 as an `smpl` line (#2482): a static sampler whose MinLOD and MaxLOD come from the descriptor's word 1. The compute Dispatch now reads `smpl` lines as the draw path does, through the same `TranslatedSamplers::read_manifest_line` and `create_translated_root`; the only difference for compute is that the root signature is set with `SetComputeRootSignature`, and static samplers need nothing else. A comparison sampler (`smpc`) and the run-time sampler heap table (`smpheap`) are still refused, as "a comparison sampler" and "a sampler from the sampler heap". Binding the heap table for compute would need the draw path's sampler snapshot (`snapshot_samplers`, `create_sampler_snapshot_heap`) taken from the compute root's sampler heap pointer, the sampler heap set with `SetDescriptorHeaps` and its table set with `SetComputeRootDescriptorTable`.

`tests/startup_compute_dispatch_texture_check.py` adds a filtered case: the texture input program with a wrap, linear sampler (`smpl 0 0x0 0xc00000 0x18500000 0x0`) reads a 2x1 RGBA8 texture whose left texel has red 0 and right texel red 1.0, at the left edge. Only a linear filter that wraps reads 0.5 there. On WARP and on a physical adapter, every thread read red 0.5, and the debug layer reported no error. The control is the same program with the manifest's sampler changed to clamp: it reads red 0, which the check refuses. The `smpc` and `smpheap` lines refuse with their reasons and leave the output untouched. Without the new `smpl` reading, the Dispatch refuses with "a sampler that is not a plain static one" and the case fails. The texture has one mip, so the LOD clamp itself is not exercised here.

In a local census, 7 compute programs (about 135 thousand Dispatch calls) had an `smpl` line as their first refusal, each with one or two `smpl` lines and no other sampler form. Read against the classifier, all 7 manifests now load; their next refusal, if any, comes from the bindings at Dispatch and has not been measured.

### An input named by a resource heap record

A compute root signature that indexes the resource heap directly (root flag 0x400) passes the heap pointer in one SGPR after the root parameters. `gfx2hlsl.py` lowers one form of a load through that pointer: `s_lshl_b32 R, <root constant word>, 5`, then, with no write of `R` and no branch target in between, `s_load_dwordx4 D, s[H:H+1], R` with a constant zero in `s[H+1]` and no `offset:` modifier. `D` is then a buffer descriptor, and the manifest names it `srv <i> buf heap rootconst <parameter> <word>`. Slot 32 now records the title memory of the list's view heap on every call; at Dispatch the stand-in reads the 16-byte descriptor at byte `word << 5` (32-bit arithmetic, as the program computes it) of that memory and binds the buffer through the path a `table` record takes. A record outside the heap refuses the dispatch (`a heap record is outside the list's view heap`) and binds nothing.
Expand Down
7 changes: 6 additions & 1 deletion src/startup_stubs/d3d12_compute_dispatch.inl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ const char* load_compute_translation(ComputeTranslation& tr)
tr.uavs.push_back({a, b, true});
else if (std::sscanf(line.c_str(), "srv %u tex2d table %d %d%n", &i, &a, &b, &used) == 3 && whole() && i == tr.srvs.size())
tr.srvs.push_back({a, b, true});
else if (std::sscanf(line.c_str(), "smp %u %x %x %x %x%n", &i, &x, &y, &z, &w, &used) == 5 && whole() &&
// A static sampler, plain (smp) or with the descriptor's LOD clamp (smpl), decoded as the draw path does.
// Not modelled here: comparison samplers (smpc) and the run-time sampler heap table (smpheap).
else if (line.rfind("smpc", 0) == 0) return "a comparison sampler";
else if (line.rfind("smpheap", 0) == 0) return "a sampler from the sampler heap";
else if ((std::sscanf(line.c_str(), "smp %u %x %x %x %x%n", &i, &x, &y, &z, &w, &used) == 5 ||
std::sscanf(line.c_str(), "smpl %u %x %x %x %x%n", &i, &x, &y, &z, &w, &used) == 5) && whole() &&
i == tr.samplers.statics.size())
tr.samplers.read_manifest_line(line.c_str());
else return line.rfind("srv", 0) == 0 ? "a resource that is not a raw table buffer or a 2D texture"
Expand Down
65 changes: 65 additions & 0 deletions tests/startup_compute_dispatch_texture_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
is 1.0 and a shader resource view of it (device slot 18). After translation all 320 words equal the case's
expectation XOR the bits of 1.0f; dispatch-sampled-unbound (no view created) is refused with one logged reason and
every word keeps the sentinel.

Filtered input: the texture input case with a constant wrap, linear sampler that the translator writes as `smpl`
and a 2x1 texture (dispatch-sampled-2x1): red 0.5 at the left edge. The same program with the manifest's sampler
changed to clamp reads red 0 (the control); `smpc` and `smpheap` lines are refused with their reasons.
Exit 77 when the adapter is not available.
"""
import os
Expand Down Expand Up @@ -199,13 +203,74 @@ def sample(directory, consumer, dxc, env):
f'view; debug layer: {layer}')


# The texture input case with a constant sampler instead of the zero one: s21 MAX_LOD 12, s22 linear min, mag and mip
# filters, s20 wrap in U, V and W. A mip filter makes the translator write it as `smpl` (its LOD clamp carried over).
WRAP_LINEAR = (0x0, 0xc00000, 0x18500000, 0x0)
LOD_SAMPLED = SAMPLED[:2] + ('s_mov_b32 s21, 0xc00000', 's_mov_b32 s22, 0x18500000') + SAMPLED[2:]


def filtered(directory, consumer, dxc, env):
"""The sampler bound is the manifest's: a 2x1 texture (red 0, 1.0) read at the left edge (the coordinates are the
bits of the thread ids, 0 or a denormal) gives red 0.5 only through a linear filter that wraps; clamp gives 0."""
cache, base = prepare(directory)
env = dict(base, **env)
(directory / 'compute_root').write_bytes(C.root_blob(table_range=True))
env['X2W_TEST_COMPUTE_ROOT'] = str(directory / 'compute_root')
_, _, rsrc2, group, _ = C.CASES['A']
C.SPLICE.update({XOR: '05190a3a', LOD_SAMPLED[2]: 'ff0395be0000c000', LOD_SAMPLED[3]: 'ff0396be00005018'})
code = C.splice(*LOD_SAMPLED)
line = 'smpl 0 %s' % ' '.join('0x%x' % w for w in WRAP_LINEAR)
assert C.translate('A', code=code).manifest().endswith(line + '\n'), C.translate('A', code=code).manifest()
(directory / 'program').write_bytes(code)
(directory / 'data').write_bytes(DATA)
(directory / 'state').write_bytes(state_a(group, rsrc2))
written = 24 * 3 * 2 * 2
plain = C.expected('A')
layout = '<%dI' % C.WORDS

def reds(got):
assert got[written:] == plain[written:], 'a word past the threads changed'
return {struct.unpack('<f', struct.pack('<I', g ^ p))[0] for g, p in zip(got[:written], plain[:written])}

got, result = run(directory, consumer, env, 'dispatch-sampled-2x1', layout)
assert got == [C.SENTINEL] * C.WORDS, 'a Dispatch without a translation wrote the output'
key = int(lines(result, 'x2w-draw compute request')[0].split()[3], 16)
translate(cache, dxc, key)

got, result = run(directory, consumer, env, 'dispatch-sampled-2x1', layout)
assert len(lines(result, 'Dispatch(3, 2, 2) translated')) == 1, result.stderr[-3000:]
red = reds(got)
# 8-bit filter weights may round the half: one step of an 8-bit channel is the tolerance.
assert len(red) == 1 and abs(next(iter(red)) - 0.5) <= 1 / 255, (sorted(red), result.stderr[-3000:])
layer = clean(result)

# Control: the same program under the manifest's sampler changed to clamp in U, V and W reads red 0, which the
# check above refuses; a comparison sampler and a sampler heap table stay refused, each with its reason.
manifest = cache / f'{key:016x}.txt'
original = manifest.read_text()
assert original.count(line) == 1, original
manifest.write_bytes(original.replace(line, line.replace('smpl 0 0x0 ', 'smpl 0 0x92 ')).encode())
got, result = run(directory, consumer, env, 'dispatch-sampled-2x1', layout)
assert len(lines(result, 'Dispatch(3, 2, 2) translated')) == 1 and reds(got) == {0.0}, result.stderr[-3000:]
for new, reason in ((line.replace('smpl', 'smpc'), 'a comparison sampler'),
(line + '\nsmpheap 2048 1 fallback 2047', 'a sampler from the sampler heap')):
manifest.write_bytes(original.replace(line, new).encode())
got, result = run(directory, consumer, env, 'dispatch-sampled-2x1', layout)
refused = lines(result, 'refused: ')
assert got == [C.SENTINEL] * C.WORDS and len(refused) == 1 and refused[0].endswith('refused: ' + reason), (
reason, refused, result.stderr[-3000:])
print(f'filtered input: an smpl wrap and linear sampler reads red 0.5 at the left edge of a 2x1 texture; the same '
f'program with a clamp sampler reads 0; comparison and heap samplers refused; debug layer: {layer}')


def main(consumer, dxc, adapter):
env = dict(X2W_D3D12_LIST_NOOP='1', X2W_D3D12_DEBUG='1') # guest lists; debug-layer messages go to the log
if adapter == 'hardware':
env['X2W_TEST_DISPATCH_HARDWARE'] = '1'
with tempfile.TemporaryDirectory() as temporary:
store(Path(temporary) / 'store', consumer, dxc, env)
sample(Path(temporary) / 'sample', consumer, dxc, env)
filtered(Path(temporary) / 'filtered', consumer, dxc, env)
print(f'startup_compute_dispatch_texture: PASS on {adapter}')


Expand Down
13 changes: 9 additions & 4 deletions tests/startup_stream_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void* desktop_pipeline(void* device)
// data-pointer valid, with the first data qword pointing at state block A
// code-zero, data-zero, no-root, code-unreadable, code-past-end, data-unreadable, state-unreadable,
// stateb-unreadable, desc-unreadable
// dispatch, dispatch-swapped, dispatch-none, dispatch-sampled, dispatch-sampled-unbound, dispatch-heap,
// dispatch, dispatch-swapped, dispatch-none, dispatch-sampled, dispatch-sampled-unbound, dispatch-sampled-2x1, dispatch-heap,
// dispatch-heap-outside, dispatch-heap-word*: one creation, then dispatch_slot67 below
// texture-store, texture-store-none, texture-store-denied, texture-store-occupied, texture-store-copied: one creation, then texture_slot67 below
// The unreadable cases point at a PAGE_NOACCESS page; code-past-end ends the code on the last byte before one.
Expand Down Expand Up @@ -192,6 +192,7 @@ static void* make_committed(void* device, D3D12_HEAP_TYPE type, const D3D12_RESO
// dispatch-sampled adds what the sampling variant of the case reads: a committed 1x1 RGBA8 texture filled by
// CopyTextureRegion (list slot 16) and a shader resource view of it (device slot 18) whose token the stand-in
// writes at table byte 64. dispatch-sampled-unbound creates no view, so that entry holds no token.
// dispatch-sampled-2x1 makes the texture 2x1 with red 0 in its left texel and 1.0 in its right one.
// dispatch-heap runs the program of startup_gfx2hlsl_heap_record_check.py: a third root constant, 2, indexes the
// 32-byte heap record that holds the input descriptor (heap byte 64). Heap bytes 0 and 32 hold the output's
// descriptor, so an index that is ignored or scaled by 16 names a buffer the dispatch refuses as an input.
Expand Down Expand Up @@ -258,19 +259,23 @@ static int dispatch_slot67(void* device, const std::string& mode)
if (FAILED(static_cast<HRESULT>(invoke(list, 139, word(allocator))))) return 74;
bind();
if (mode.rfind("dispatch-sampled", 0) == 0) {
const D3D12_RESOURCE_DESC texture_desc{D3D12_RESOURCE_DIMENSION_TEXTURE2D, 0, 1, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, {1, 0}};
const UINT width = mode == "dispatch-sampled-2x1" ? 2 : 1;
const D3D12_RESOURCE_DESC texture_desc{D3D12_RESOURCE_DIMENSION_TEXTURE2D, 0, width, 1, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, {1, 0}};
const D3D12_RESOURCE_DESC upload_desc{D3D12_RESOURCE_DIMENSION_BUFFER, 0, 256, 1, 1, 1, DXGI_FORMAT_UNKNOWN, {1, 0},
D3D12_TEXTURE_LAYOUT_ROW_MAJOR};
void* const texture = make_committed(device, D3D12_HEAP_TYPE_DEFAULT, texture_desc, D3D12_RESOURCE_STATE_COMMON);
void* const upload = make_committed(device, D3D12_HEAP_TYPE_UPLOAD, upload_desc, D3D12_RESOURCE_STATE_GENERIC_READ);
void* texel = nullptr;
if (!texture || !upload || FAILED(static_cast<HRESULT>(invoke(upload, 8, 0, 0, word(&texel)))) || !texel) return 80;
const unsigned char rgba[4] = {255, 64, 128, 32}; // the program reads red: 1.0f
// The program reads red: 1.0f. The 2x1 texture's left texel has red 0, so only a linear filter that wraps
// reads 0.5 at the left edge (point or clamp read 0).
unsigned char rgba[8] = {255, 64, 128, 32, 255, 64, 128, 32};
if (width == 2) rgba[0] = 0;
std::memcpy(texel, rgba, sizeof(rgba));
invoke(upload, 9, 0, 0);
D3D12_TEXTURE_COPY_LOCATION image{static_cast<ID3D12Resource*>(texture), D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX};
D3D12_TEXTURE_COPY_LOCATION source{static_cast<ID3D12Resource*>(upload), D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT};
source.PlacedFootprint = {0, {DXGI_FORMAT_R8G8B8A8_UNORM, 1, 1, 1, 256}};
source.PlacedFootprint = {0, {DXGI_FORMAT_R8G8B8A8_UNORM, width, 1, 1, 256}};
invoke(list, 16, word(&image), 0, 0, 0, word(&source), 0);
D3D12_SHADER_RESOURCE_VIEW_DESC view{DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_SRV_DIMENSION_TEXTURE2D, D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING};
view.Texture2D.MipLevels = 1;
Expand Down
Loading