Repository navigation
shader: clear gfx2hlsl scalar min/max SCC on ties - #3435
nanyoudegege wants to merge 1 commit into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 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
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| 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) |
There was a problem hiding this comment.
Invalidate cached translations for the new SCC semantics
When upgrading while retaining a populated X2W_SHADER_CACHE on the gfx2hlsl path, completed shaders continue using the inclusive predicate. pipeline_key() and compute_key() still use revision 29, matching the unchanged runtime constants in src/startup_stubs/d3d12_draw.inl, and pending_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 👍 / 👎.
There was a problem hiding this comment.
Confirmed on Linux with source-built inputs: the same warm cache caused gfx2hlsl.py --pending to 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 / .s57 inputs, so a blanket bump needs a capture-compatibility plan. #3382 also uses 30/30cs for a different translation change. I’m leaving the review open rather than reusing those seeds. Would you prefer to stage the SCC invalidation after #3382 with a coordinated revision and slot-57 compatibility plan?
Leyukaka
left a comment
There was a problem hiding this comment.
Reviewed 710fb44 by reading the diff; nothing built or run. It merges cleanly into main d58a9f6.
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:4007 at this head, cmp(sign + (... == "min" ? "lt" : "gt"), a, b), and src/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, the s-min-inclusive control (pinned at word 0, bit 8), check_scc_modelled and the four null strings in startup_gfx2hlsl_scalar_null_check.py follow the strict rule; no assertion of the inclusive rule is left.
Changes requested:
- Cache revision:
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:
- No test compares the two paths, as #3434 suggested. Case S compares gfx2hlsl with a Python reference; the general
s_min/s_maxblock ofgfx1013-direct-csstill has no SCC test with S0 == S1. - The
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.
|
Either order works, as long as the revision is chosen at merge time. #3382 (open, 025f16d) moves only |
|
Review of MUST
What I checked and ran:
Linux, Python 3.13, no WARP or GPU run. AI-assisted. |
Refs #3434.
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.