Skip to content

shader: clear gfx2hlsl scalar min/max SCC on ties - #3881

Open
Leyukaka wants to merge 4 commits into
R0Y00:mainfrom
Leyukaka:take-3435
Open

Leyukaka wants to merge 4 commits into
R0Y00:mainfrom
Leyukaka:take-3435

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Carries #3435 by @nanyoudegege with their commits. Refs #3434.

#3435 has two open requests for a cache revision bump and no update since 11-29. The author's commit is kept unchanged (d1ac43d4a, a clean cherry-pick of 710fb44d); one commit on top adds the bump. @nanyoudegege, if you would rather continue in #3435, say so and I will close this PR.

Change

From #3435 (see its description for the ISA reference and the Linux validation):

  • tools/startup/gfx2hlsl.py: s_min_{i,u}32 and s_max_{i,u}32 set SCC with a strict compare, so equal operands clear it, as the direct compute path already does.
  • The Case S oracle, the scalar-null check and the s-min-inclusive control follow the strict rule.

Added here, in 3117f8ba8:

  • The startup shader cache revisions move from x2w-startup-shader-29 / 29cs to 31 / 31cs in tools/startup/gfx2hlsl.py, src/startup_stubs/d3d12_draw.inl, src/shader_compute_request.cpp and tools/patch_manifest.py, with the tests and docs that carry the string. Without it, translations cached under revision 29 keep setting SCC on ties.
  • Revision 30 is skipped on purpose. shader: decode buffer FORMAT 47 (10_10_10_2 SSCALED) from hardware descriptors #3382 (open) moves 29 to 30. Two identical 29 -> 30 edits would merge without a conflict and share one revision; with 31 here, whichever of the two merges second gets a textual conflict on the same lines and has to pick the next number.
  • The pinned keys in tests/shader_compute_request_check.cpp, tests/startup_shader_cache_key_check.py and tests/startup_compute_request_offline_check.py are recomputed at 31/31cs. The revision-28 values are kept.
  • Revision-28 archives are still read. The slot 57 mesh key is unchanged.
  • docs/startup-runtime.md gains a "Revision 31" paragraph.

Validation

Windows, MSVC, dev preset, full build, head 3117f8ba8.

ctest --preset dev --no-tests=error -R "^(startup_gfx2hlsl_compute_(controls|warp|hardware|s-min-inclusive_(warp|hardware)|s-borrow-flipped_(warp|hardware))|startup_gfx2hlsl_scalar_null_(controls|warp|hardware)|shader_compute_request_.*|gfx1013_compute_clear_.*|native_compile_dxil_rekey|startup_compute_request_offline|startup_gfx2hlsl_buffer_store|startup_gfx2hlsl_fract|startup_gfx2hlsl_ps57in|startup_shader_cache_(key|rekey|revision)|startup_indirect_draw(_indexed)?_(warp|hardware)|startup_resource_retire_title_.*|startup_ui_texture_bands_.*|startup_packed_screen_position_provenance.*|patch_manifest_controls|runtime_shader_cache_rekey_cli_check)$"

Result: all selected tests passed.

This filter includes startup_gfx2hlsl_compute_warp and startup_gfx2hlsl_compute_s-min-inclusive_warp, which the pr preset filter does not select.

Known limits

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I checked 3117f8b. The strict SCC compares and the revision-31 graphics and compute keys agree across the runtime, translator and offline manifest tooling. The exact head passed the independent Windows Python checks startup_gfx2hlsl_compute_check.py, startup_gfx2hlsl_scalar_null_check.py, startup_shader_cache_key_check.py and startup_compute_request_offline_check.py (4/4), including refusal of stale or mismatched keys. Please keep the revision ordering with #3382 in the landing branch and coordinate with @nanyoudegege on whether to continue in #3435 or here.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I also ran ctest --preset dev --no-tests=error -j 1 -V -R '^startup_gfx2hlsl_compute_(s-min-inclusive_)?(warp|hardware)$' on 3117f8b. All four cases passed on Windows 11 build 26300, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 with debug layers enabled. The equal-operand control catches the inclusive SCC predicate on both adapters. The original-PR coordination is still pending.

@Makto94

Makto94 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Slot 57 translations use the same SCC lowering, but this PR leaves their cache key at x2w-startup-mesh-57-4. Since #3531 a runtime path can load those translations. Code reading and a Python probe at 3117f8ba; no hardware run.

Probe (local script, not proposed for the branch): the source-built MESH and PIXEL of tests/startup_mesh57_skeleton_check.py, with s_min_u32 s20, 1, 1 and s_cselect_b32 s21, 1, 0 spliced after the prefetch, through G.MeshPipeline(ms, ps, root).hlsl_ms() and G.mesh57_key(ms, ps, root).

merge base b68e954c head 3117f8ba
SCC line in the mesh HLSL scc = ((0x00000001u) <= (0x00000001u)); scc = ((0x00000001u) < (0x00000001u));
mesh57_key 8043e4c1c9f13305 8043e4c1c9f13305

No wrong output observed, and I did not compile the probe to DXIL. Only pairs published after #3531 are affected.

Could you either bump the mesh key with the other two, or add to Known limits that slot 57 pairs published between #3531 and this change stay in use under X2W_ALLOW_PUBLISHED_MESH57_PAIR? A bump also changes the .s57 and .mesh57-state names derived from the key, as discussed in #3435 (and .mesh57-state in #3531).

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I independently confirmed the Mesh57 stale-cache case raised above, including pixel readback. On 3117f8ba trial-merged onto 8a2f84d1, I used the source-built startup_mesh57_skeleton_check.py fixture. Insert 83a88181 852980f2 immediately after the initial bfa00003 (s_min_u32 s40, 1, 1; s_cselect_b32 s41, 1.0, 0), and use vertex_red("7e0e0229") to make the selected float reach the red output.

The old and new translators both produce Mesh57 key 84361cba95c62e55, but compile different .ms57.cso bytes. With the old full pair in the cache, the new pending_keys says there is nothing to translate. Directly drawing the published binaries with the existing offscreen fixture on WARP and RTX 4060 Laptop showed the visible difference: the old output matches the red=1 reference, the fresh output matches red=0, and drawing the old binary against the fresh reference differs in 259 of 1,024 pixels on each adapter. Windows build 26300, SDK DXC, WARP 10.0.26100.9818, RTX driver 32.0.16.1656, D3D12 debug layer enabled, no skips. This measures published bytecode and cache scheduling with source-built inputs.

Please cover the opt-in published Mesh57 path in the revision change. Bump its shared request revision and keep a regression showing that a previously completed pair does not suppress work on the new key. Coordinate the graphics/compute revision with #3382 separately.

nanyoudegege and others added 4 commits December 3, 2026 07:55
… fix

Translations cached under revision 29 still set SCC when s_min/s_max
see equal operands, and pending_keys skips their completed results.
Move the graphics and compute revisions from 29/29cs to 31/31cs in
gfx2hlsl.py, d3d12_draw.inl and shader_compute_request.cpp, with the
tests and docs that carry the string. Revision 30 stays with R0Y00#3382,
which bumps 29 to 30 for FORMAT 47, so the two changes cannot share a
revision. Revision-28 archives are still read; the slot 57 mesh key is
unchanged.

The pinned keys in shader_compute_request_check.cpp,
startup_shader_cache_key_check.py and
startup_compute_request_offline_check.py are recomputed at 31/31cs.
Slot 57 mesh translations use the same scalar min/max SCC lowering as
graphics and compute, but their request key stayed at
x2w-startup-mesh-57-4. pending_keys treats a request as done once
<key>.ms57.txt and complete .ms57.cso/.ps57.cso exist, so pairs
translated before the fix were reused. Move the mesh key to
x2w-startup-mesh-57-5 in gfx2hlsl.py, shader_compute_request.cpp,
d3d12_draw.inl and native_mesh57.inl, with the tests and docs that
carry the string. The pinned mesh keys in
shader_compute_request_check.cpp are recomputed at revision 5.

startup_gfx2hlsl_watch_check.py now checks that a pair completed under
revision 4 leaves the revision 5 request pending, with the same pair
under the new key as the done control. startup_mesh57_skeleton_check.py
adds a mesh that feeds s_min_u32 s40, 1, 1 into s_cselect_b32 s41,
1.0, 0 and draws s41 as red, which must stay 0.
The fixed-state variant key extends the slot 57 request key, so the
revision 5 bump also renames every req_<variant>.s57 archive and
<variant>.mesh57-state profile. Neither rekey tool carries them over,
and the archive stores the request key in its header. Document the
manual step: capture again with X2W_MESH57_CAPTURE_STATE=1, then run
mesh57_profile.py on each new archive with its reviewed JSON.
@Leyukaka

Leyukaka commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you both. The slot 57 key is bumped in 95f532506, with a doc note in f723cbb09. The branch is rebased on main at 29bb2aed7; the two earlier commits are unchanged in content.

Slot 57 revision. x2w-startup-mesh-57-4 becomes x2w-startup-mesh-57-5 everywhere it is spelled: mesh57_key in tools/startup/gfx2hlsl.py, mesh57_request_key in src/shader_compute_request.cpp, shader_cache::mesh57_revision in src/startup_stubs/d3d12_draw.inl (so revision.txt names it too), the key in prepare_native_mesh57 (src/startup_stubs/native_mesh57.inl), the C++ fixtures (tests/startup_mesh57_runtime.inl, tests/startup_indirect_draw_indexed.cpp), the string checks (native_compile_dxil_rekey_check.py, shader_compute_request_meta_check.py, patch_manifest_check.py) and the docs. The two pinned mesh keys in shader_compute_request_check.cpp are recomputed at revision 5 (0x07e6b2fe8d1fb5a5, 0x73813dabf7162a79).

Regression for the stale pair. startup_gfx2hlsl_watch_check.py (mesh57_revision_controls) publishes a revision 5 request, then a complete .ms57.txt, .ms57.cso and .ps57.cso set under the revision 4 key of the same parts. pending_keys must still return the revision 5 key, both cold and with a warm completed map, and the map must record neither key. As a control, the same set under the revision 5 key makes the request done.

SCC tie fixture. @R0Y00, your reproduction is in startup_mesh57_skeleton_check.py as SCC_TIE_CASES: 83a88181 852980f2 right after the initial bfa00003, with vertex_red("7e0e0229"). The offline check requires it to translate, and the draw mode compares it with a red 0 reference (a translation that sets SCC on the tie draws 255).

Known limitation: fixed-state archives and profiles. @Makto94, as you noted, the bump also renames every req_<variant>.s57 archive and <variant>.mesh57-state profile. compile_dxil --rekey and shader_cache_rekey.py copy only .m57/.ps57/.root, and an archive also stores the request key in its header, so neither is carried over. f723cbb09 documents the manual step in docs/experiments/native-fixed-mesh57.md: run once more with X2W_MESH57_CAPTURE_STATE=1, then run mesh57_profile.py on each new archive with its existing reviewed JSON. Until then those pipelines take the absent-profile path. Teaching the rekey tools to carry archives and profiles can be a follow-up if you prefer.

#3382. The graphics/compute revision ordering with #3382 is unchanged by these commits (still 31/31cs here) and remains to be settled there.

Tests. Windows, MSVC, WARP and a hardware adapter: 46/46 passed. This covers startup_gfx2hlsl_watch, startup_mesh57_skeleton, startup_mesh57_skeleton_draw_{warp,hardware}, startup_mesh57_skeleton_exchange_{warp,hardware}, shader_compute_request_fnv_and_keys and shader_compute_request_all (which confirm the recomputed keys), native_compile_dxil_rekey, patch_manifest_controls, startup_mesh57_runtime_{warp,hardware} and the native_fixed_mesh57_* checks.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Re-reviewed f723cbb. The Mesh57 revision-5 bump and its stale-pair regression address my previous change request. Independent Windows checks passed: the watch and Mesh57 skeleton controls, shader-cache-key and offline request checks, the MSVC C++ request fixture (10/10), and both Mesh57 skeleton draws on WARP and RTX 4060 Laptop, including the SCC tie. The revision-4 fixed-state profiles still require recapture as documented. The technical review is clear on this head. The required CI and coordination with the original PR #3435 remain before landing; whichever of this and #3382 lands second must use a fresh graphics/compute revision.

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.

4 participants