Skip to content

startup: read smpc comparison samplers in published compute manifests (#3075) - #3083

Merged
tedin7 merged 5 commits into
R0Y00:mainfrom
Not-Saii:claude/native-compute-smpc-f57377
Nov 27, 2026
Merged

tedin7 merged 5 commits into
R0Y00:mainfrom
Not-Saii:claude/native-compute-smpc-f57377

Conversation

@Not-Saii

Copy link
Copy Markdown
Contributor

Change

The stand-in reads the published translation of a slot 67 compute request from <key>.txt (load_compute_translation in src/startup_stubs/d3d12_compute_dispatch.inl). It refused every smpc line there with a comparison sampler. It now reads smpc <i> <w0> <w1> <w2> <w3> under the same index and whole-line checks as smp and smpl, through TranslatedSamplers::read_manifest_line. decode_statics already decodes the line to a comparison static sampler for the draw path. smpheap stays refused with a sampler from the sampler heap.

Fixes #3075. Part of #2935.

Scope. #3075 first described this as the in-process route (X2W_NATIVE_SHADERS). The refusal is in the reader of a published manifest, and that is what this changes:

  • Only tools/startup/gfx2hlsl.py writes smpc for a compute program today. Before this change the runtime refused that translation when it loaded the manifest, so a compute request with a comparison sampler could not be dispatched.
  • format_compute_runtime_manifest (src/direct_compute_cache.cpp) still returns no manifest for a comparison sampler, so compile_dxil publishes no compute smpc line.
  • translate_compute_natively is not changed. It reads no manifest lines and refuses every sampler.

Overlap. #3049, #3006 and #2981 also touch d3d12_compute_dispatch.inl. None of them changes the sampler lines of the reader. #3049 also edits tests/startup_compute_dispatch_texture_check.py and tests/startup_stream_consumer.cpp. Its hunks share no line with this change, but its edit of main() in the texture check is next to the one-line call added here, so whichever lands second may need a small rebase.

Verification

Commit cef30beb on main at e1ea515d. main has since moved to 2a4bbff5 (#3059), which touches none of these files.

.\tools\dev.ps1
cmake --build --preset dev --target startup_stream_consumer
ctest --preset dev --no-tests=error -R '^startup_compute_dispatch_texture_(warp|hardware)$' -V

Environment: Windows 11 build 26300.9974, Windows SDK 10.0.26100, DXC 1.9.2602.17, Debug build, D3D12 debug layer enabled.

Test Adapter, driver Result
startup_compute_dispatch_texture_hardware NVIDIA GeForce RTX 4090, 32.0.16.1088 PASS (18.81 s)
startup_compute_dispatch_texture_warp Microsoft Basic Render Driver, 10.0.26100.9818 PASS (7.72 s)

There was no capability skip. The new line, the same on both adapters:

compared input: an smpc point, clamp, LESS sampler passes at 144 of the 288 written words and all 320 words match the CPU model; the same program under GREATER matches its model (108 pass, 252 words differ from LESS); debug layer: enabled, no error message

Negative control. With src/startup_stubs/d3d12_compute_dispatch.inl put back to e1ea515d and the same target rebuilt, the same ctest command fails both tests in the new case, after the cases before it pass:

AssertionError: smpc LESS: x2w-draw compute e9f1d94c2215f572 Dispatch(3, 2, 2) refused: a comparison sampler

Also run: python -B tests/docs_links_check.py (77 Markdown files and 588 links checked, no error).

Not run: the rest of the ctest suite and the Linux Python checks.

Evidence and follow-up

Fixture. tests/startup_compute_dispatch_texture_check.py gains a compared case. It is source-built: case A of startup_gfx2hlsl_compute_check.py with image_sample_c_lz under a constant point, clamp, LESS sampler spliced in before the store.

  • The five new instructions were hand-encoded, not assembled by llvm-mc. The check asserts that the Python decoder reads them as written, and that the translation holds SampleCmpLevelZero and ends with smpc 0 0x8001012 0x0 0x0 0x0.
  • The consumer's new mode dispatch-sampled-depth binds a 2x1 R32_FLOAT texture with depths 1.0 and 2.5. The reference is the thread's z id (0.0 to 3.0) and u its x id, so the written words hold both outcomes.
  • All 320 words are compared with a CPU model of reference < texel.
  • In-test control: the same program with the manifest's function changed to GREATER must match the model of reference > texel. The two models differ at 252 words.
  • The older control in that file rewrote an smpl line as smpc and expected the refusal. This case replaces it. The smpheap refusal check stays.

Not measured. A bilinear comparison filter, a border address mode, a 2D array and the other six functions. The comparison is the desktop sampler's; console behaviour is not measured.

Docs. The note is docs/experiments/startup-compute-comparison-sampler.md. The older paragraph in docs/experiments.md that says smpc is refused now points to it.

Follow-up.

  • Static samplers on the in-process route (translate_compute_natively). This comes after runtime: bind native compute table buffers and texture views #3049, which adds its texture inputs and keeps its sampler refusal.
  • smpc from format_compute_runtime_manifest, so the C++ compiler's published compute translations can carry a comparison sampler.
  • The sampler heap table (smpheap) for compute.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

🤖 Generated with Claude Code

Not-Saii and others added 2 commits November 27, 2026 16:28
The reader of a published <key>.txt for a slot 67 compute request refused
every smpc line with "a comparison sampler". It now takes the line under
the same index and whole-line checks as smp and smpl, through
TranslatedSamplers::read_manifest_line, which already decodes it to a
comparison static sampler for the draw path. smpheap stays refused.

startup_compute_dispatch_texture_check.py gains a compared case: case A
with image_sample_c_lz under a constant point, clamp, LESS sampler reads a
2x1 R32_FLOAT texture (new consumer mode dispatch-sampled-depth) and all
320 words are compared with a CPU model of the comparison. The control
changes the manifest's function to GREATER. The old control that expected
an smpc line to be refused is replaced by this case.

Refs R0Y00#3075

AI-assisted.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Command, result and environment for the compared case of
startup_compute_dispatch_texture_{warp,hardware}, the reverted-reader
negative control, and what the change does not cover (the C++ compiler's
publisher and the in-process route).

Refs R0Y00#3075

AI-assisted.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Read through this and checked what can be checked off Windows.

  • On current main (63a30dc) the merge is clean, and the related Linux checks pass:
    • startup_gfx2hlsl_compute_check, startup_image_sample_c_check, startup_compute_translate_check
    • startup_compute_request_offline_check, docs links, bidi
  • The six hand-encoded words match llvm-mc 19 for gfx1013.
  • The scope statements hold: format_compute_runtime_manifest still returns no manifest for a comparison sampler,
    and translate_compute_natively still refuses samplers.
  • It also merges cleanly with runtime: bind native compute table buffers and texture views #3049 today.

One thing to fix: docs/experiments.md still says, in the "Static samplers with a LOD clamp" section, that smpc
is "still refused, as "a comparison sampler"". The next paragraph says "The smpc and smpheap lines refuse with
their reasons". This PR removes both the refusal and that control. Could those two sentences drop smpc and keep
the pointer to the new note?

Two smaller notes, no change needed for this PR:

  • The case can't tell point from linear comparison filtering, or clamp from mirror in U. u is 0 or 1 on a 2-texel
    row, so both settings give the same 320 words. A u of 0.75 would separate point from linear, if you want the
    printed "point, clamp" to be measured.
  • A malformed smpc line is now refused as "a sampler that is not a plain static one". A comparison-specific reason
    might read better in triage.

The PR CI's pr preset doesn't run startup_compute_dispatch_texture_*, so the Windows result here is from your run.

This comment was AI-assisted.

Not-Saii and others added 2 commits November 27, 2026 20:12
The "Static samplers with a LOD clamp" section still said that an smpc
line is refused and that the texture check controls it. Both sentences
now name smpheap only and keep the pointer to the new note.

Refs R0Y00#3075

AI-assisted.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@Not-Saii

Copy link
Copy Markdown
Contributor Author

Fixed in 73f3cad: both sentences in that section now name smpheap only, and the first keeps the pointer to the new note.

On the two notes:

  • Agreed that the case does not separate point from linear or clamp from mirror. The note lists the bilinear filter and the other address modes under "Not measured"; the printed "point, clamp" is the manifest's setting. A u of 0.75 is a good follow-up.
  • The reason for a malformed smpc line is left as it is here, to keep the diff to the one refusal.

AI-assisted.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 0517c12 (the change from cef30be, updated with main; the PR's own diff is unchanged). Comment only.

The reader now parses smpc <i> <w0> <w1> <w2> <w3> with the same whole-line and index checks as smp and smpl and hands it to TranslatedSamplers::read_manifest_line; smpheap stays refused. The texture check draws with a comparison sampler on WARP and compares against a CPU reference. The change does not touch the native compiler (compile_dxil, direct_compute_cache.cpp) or translate_compute_natively, as the description says. As noted there, #3049 edits a neighbouring line of the texture check; whichever lands second needs a small rebase.

Windows results are in the comment below.

Commands: git diff origin/main...pull/3083/head (read), plus the Windows commands listed in the comment.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Windows Server 2025 verification of 0517c1233403a54e26796a5669deddc10af92ac1 (D3D12 WARP, MSVC 14.44.35207):

  • dev: cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer compile_dxil; ctest --preset dev -R '^startup_(compute_dispatch|stream)': 100% tests passed out of 38 (36 passed, 2 capability skips), including startup_compute_dispatch_texture_warp and _hardware
  • release: same targets with --preset release; ctest --preset release -R '^startup_(compute_dispatch|stream)': 100% tests passed out of 38 (36 passed, 2 skipped)

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Windows Server 2025 re-verification of 00682b60f32f2068754e123cb0fcbf9b18196023 (the same change, updated with main again; D3D12 WARP, MSVC 14.44.35207):

  • dev: cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer compile_dxil; ctest --preset dev -R '^startup_(compute_dispatch|stream)': 100% tests passed out of 38 (36 passed, 2 capability skips), including startup_compute_dispatch_texture_warp and _hardware
  • release: same targets with --preset release; ctest --preset release -R '^startup_(compute_dispatch|stream)': 100% tests passed out of 38 (36 passed, 2 skipped)

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit a5dad84 into R0Y00:main Nov 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

native compute: accept comparison static samplers (smpc) on the in-process route

3 participants