shader: clear gfx2hlsl scalar min/max SCC on ties #3437
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3437
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3435"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@nanyoudegege on GitHub · 2026-11-29 08:14 UTC · original
nanyoudegege:shader/gfx2hlsl-minmax-scc-ties→main· +24 −17 · 4 files · 1 commits · openRefs #3436.
AMD's public RDNA 2 ISA reference, §12.1 (pp. 102–103, SOP2 opcodes 6–9), uses strict comparisons for the signed and unsigned scalar min/max instructions. Equal operands therefore leave the numerical min/max unchanged and clear SCC. The direct compute emitters already use strict comparisons. This patch changes only the gfx2hlsl SCC predicate, updates the Case S oracle and scalar-null test, and replaces the old negative control with one that restores the inclusive predicate.
Validation on Linux, based on
1a44cee5ee29ab7da2a4cd09eb5bc052020022ac:python3 -B tests/startup_gfx2hlsl_compute_check.pyandpython3 -B tests/startup_gfx2hlsl_scalar_null_check.py: both fail with the updated tests on the old translator and pass with the patch. All 118 registered no-argument startup_gfx2hlsl Python checks passed (no skips);git diff --checkwas clean.python3 -B tests/startup_gfx2hlsl_compute_check.py binary llvm-mc-15: the source-built fixture matched its stored bytes. Case S compiled with DXC (dxc -T cs_6_0 -E main -Fo case-s.dxil case-s.hlsl).00000000, got00000100). The checked-in CTest selectors for Windows arectest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_(warp|s-min-inclusive_warp)$' -Vif those targets are configured; no Windows WARP, physical GPU, or native direct-backend dispatch was run in this cloud environment.AI-assisted implementation and independent review. Only the repository's source-built fixtures were used.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-29 08:15 UTC · original · edited 2026-11-29 08:18 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
710fb44ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-29 08:18 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
710fb44d6bℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@ -11493,3 +11493,3 @@return '(((((%s) ^ (%s)) & ((%s) ^ (%s))) >> 31) != 0)' % (a, b, a, result)cast = 'int' if base.endswith('_i32') else ''return '(%s(%s) %s %s(%s))' % (cast, a, '<=' if base.startswith('s_min') else '>=', cast, b)return '(%s(%s) %s %s(%s))' % (cast, a, '<' if base.startswith('s_min') else '>', cast, b)@chatgpt-codex-connector[bot] on GitHub · 2026-11-29 08:18 UTC · original
When upgrading while retaining a populated
X2W_SHADER_CACHEon the gfx2hlsl path, completed shaders continue using the inclusive predicate.pipeline_key()andcompute_key()still use revision 29, matching the unchanged runtime constants insrc/startup_stubs/d3d12_draw.inl, andpending_keys()skips existing manifest/bytecode pairs without checking translator changes. The bundled Case S produces different HLSL but retains its previous cache key, so affected cached shaders still set SCC on ties until the cache is manually cleared. Advance the affected cache revisions on both translator and runtime sides, or otherwise invalidate completed translations, alongside this semantic change.Useful? React with 👍 / 👎.
@ -11493,3 +11493,3 @@return '(((((%s) ^ (%s)) & ((%s) ^ (%s))) >> 31) != 0)' % (a, b, a, result)cast = 'int' if base.endswith('_i32') else ''return '(%s(%s) %s %s(%s))' % (cast, a, '<=' if base.startswith('s_min') else '>=', cast, b)return '(%s(%s) %s %s(%s))' % (cast, a, '<' if base.startswith('s_min') else '>', cast, b)@nanyoudegege on GitHub · 2026-11-29 08:27 UTC · original
Confirmed on Linux with source-built inputs: the same warm cache caused
gfx2hlsl.py --pendingto skip Case S compute, a graphics pair, and a slot-57 mesh+pixel pair. Cold translation produced different DXIL for all three. The slot-57 pixel path shares this SCC lowering but has its own key; that key also names captured.mesh57-state/.s57inputs, so a blanket bump needs a capture-compatibility plan. #3384 also uses30/30csfor a different translation change. I’m leaving the review open rather than reusing those seeds. Would you prefer to stage the SCC invalidation after #3384 with a coordinated revision and slot-57 compatibility plan?@Leyukaka on GitHub · 2026-11-29 08:27 UTC · original · requested changes
Reviewed
710fb44dby reading the diff; nothing built or run. It merges cleanly into maind58a9f63.The only translator change is
tools/startup/gfx2hlsl.py:11495,<=/>=to</>. With it gfx2hlsl gives the same SCC as the direct path for all four ops when S0 == S1 (SCC clear):src/gfx1013_direct_compute.inl:4007at this head,cmp(sign + (... == "min" ? "lt" : "gt"), a, b), andsrc/gfx1013_compute_native.cpp:1329,scc=lhs < rhs/lhs > rhs(unsigned forms). The description cites an ISA reference (§12.1, SOP2 opcodes 6-9) for the strict rule and states that no WARP, hardware or direct-backend dispatch was run. The Case S oracle, thes-min-inclusivecontrol (pinned at word 0, bit 8),check_scc_modelledand the fournullstrings instartup_gfx2hlsl_scalar_null_check.pyfollow the strict rule; no assertion of the inclusive rule is left.Changes requested:
src/startup_stubs/d3d12_draw.inl:419-420andgfx2hlsl.py:12966,12976still usex2w-startup-shader-29/29cs, so translations already in the cache keep setting SCC on ties. #2778, which introduced the inclusive rule, advanced the revision (26 -> 27) on both sides. This change needs the same bump (src/shader_compute_request.cpp:180,191and the tests and docs that pin 29 carry the string too).Not covered:
s_min/s_maxblock ofgfx1013-direct-csstill has no SCC test with S0 == S1.prtest preset filter does not matchstartup_gfx2hlsl_compute_warporstartup_gfx2hlsl_compute_s-min-inclusive_warp, so CI did not run the Case S dispatch or the new control.@Leyukaka on GitHub · 2026-11-29 08:44 UTC · original
Either order works, as long as the revision is chosen at merge time. #3384 (open,
025f16dd) moves onlyx2w-startup-shader-29/29csto30/30cs(at its head: d3d12_draw.inl:393-394, shader_compute_request.cpp:180/191, gfx2hlsl.py:12973/12983, tools/patch_manifest.py:24) and leavesx2w-startup-mesh-57-3unchanged; this PR changes no revision string, andgit merge-treeof the two heads is clean. Two identical 29 -> 30 edits would also merge without a conflict, and a cache filled between the two merges would then stay valid across the second change, so whichever PR merges second needs one more step (31/31cs here if #3384 lands first).The slot-57 key does not depend on that order. At main
1cd07194,x2w-startup-mesh-57-3seeds the request key and the variant that namesreq_<variant>.s57and<variant>.mesh57-state(native_mesh57.inl:247-251, mesh57_pixel_entry.py:28-31);compile_dxil --rekeyandshader_cache_rekey.pyrekey the.m57/.ps57/.rootrequests but not those two files, so a bump of that key leaves existing archives and profiles under names that no longer match.Nothing in
src/loads the.ms57.cso/.ps57.csotranslation outputs (gfx2hlsl.py:13424: "No runtime path loads these names yet"), so translations cached under the unchanged mesh-57 key are not used at run time.@JohnConnorNPC on GitHub · 2026-11-29 12:55 UTC · original
Review of
710fb44dagainst main77d1ba4d. Verdict: hold for Leyukaka's open change request (the cache revision bump). I found nothing else.MUST
git grep -n 'x2w-startup-shader-29' origin/main -- src toolsstill listsd3d12_draw.inl:420andgfx2hlsl.py:12970, and this PR changes neither line. Leyukaka's comment above covers the ordering with #3384.What I checked and ran:
git merge-tree --write-tree origin/main 710fb44d→ treea36bd61e):tests/startup_gfx2hlsl_compute_check.pyrc=0 andtests/startup_gfx2hlsl_scalar_null_check.pyrc=0.tools/startup/gfx2hlsl.pymakes both checks fail. The compute check fails atAssertionError: ('s_min_u32 s23, s7, 4', ...incheck_scc_modelled, so the updated tests do pin the strict rule.X2W_NATIVE_SHADERS_ONLY=1, set since #3451, gfx2hlsl compute manifests aren't loaded (load_compute_translation:if (native_shaders_only()) { ... return nullptr; }). So this fix reaches-Translateruns only, and the native path already uses strict compares.Linux, Python 3.13, no WARP or GPU run.
AI-assisted.
@Leyukaka on GitHub · 2026-12-02 18:40 UTC · original
Thank you for this fix, @nanyoudegege. To get it past the open revision request, I carried your commit unchanged into #3881 and added the cache revision bump on top; if you would rather continue here, say so and I will close mine.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.