Skip to content

startup: cap v_fract_f32 at 0x3f7fffff like pixel_aot already does - #2010

Merged
R0Y00 merged 7 commits into
R0Y00:mainfrom
thepatrickworld:panam/1741-fract32
Nov 25, 2026
Merged

R0Y00 merged 7 commits into
R0Y00:mainfrom
thepatrickworld:panam/1741-fract32

Conversation

@thepatrickworld

@thepatrickworld thepatrickworld commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

v_fract_f32 now lowers through the capped fract32 helper that tools/pixel_aot.py has always used, instead of a bare D3D frac.

The asymmetry. Two translators in this tree lower the same instruction differently:

// tools/pixel_aot.py, since long before this patch
// v_fract_f32: x - floor(x) clamped to 0x3f7fffff, so a tiny negative input cannot round up to 1.0.
// D3D frac has no clamp and differs between adapters.
float fract32(float value) {
    float f = frac(value);
    return asuint(f) == 0x3f800000u ? asfloat(0x3f7fffffu) : f;
}

tools/startup/gfx2hlsl.py emitted frac({0}) for v_fract_f32 with no cap, so the two paths disagreed on the one instruction whose comment in this repository says adapters disagree.

What the reports show. Two independent NVIDIA runs fail startup_gfx2hlsl_float_round_hardware on the input 0xb0800000 (-2^-30) in #1741, both with expected=3f7fffff actual=3f800000: an RTX 3070 Ti on driver 32.0.16.2101, and a Quadro M1000M (Maxwell) on 32.0.15.7371. The same draw passes on WARP, on an Intel HD Graphics 530 and on the RDNA 4 card used here.

What changes. The helper goes into the common preamble next to ftz32, which already carries a Match pixel_aot note, the table entry points at it, and a new check pins the emitted statement of the _e32 and _e64 forms, the cap in the preamble, and rejects both a bare frac and a cap written with min. The cap is a comparison rather than min because D3D min returns its other operand for a NaN, and a NaN input has to stay a NaN. Only v_fract_f32 changes.

On the ISA wording, because it cuts the other way. The RDNA 2 guide gives D.f = S0.f + -floor(S0.f) for V_FRACT_F32 with no cap, and for -2^-30 that expression rounds to 1.0 — which is exactly what the Quadro returns. The cap is therefore not read off that formula. It is what D3D's frac() produces on WARP, on an Intel Gen9 part and on this RDNA 4 card, and it is what the reference in this tree encodes. The P2 in #1741 asked for the lowering to be fixed rather than for a new draw to fail on an adapter, and suggested min(..., 0x3f7fffff); this patch takes the comparison form so that a NaN input stays a NaN. If the console's own frac is later shown to return 1.0 here, the cap and the reference have to be revisited together — they must agree, and today three of the four implementations we can observe agree on the cap.

What is verified here. On an AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010), the whole gfx2hlsl suite passes with this patch on today's main: 41 of 41, including the new startup_gfx2hlsl_fract and the existing translation controls. docs_links_check and bidi_controls_check pass.

What is not verified, and matters. There is no NVIDIA adapter on this machine. The Maxwell and Turing failures are not reproduced here, and this patch does not demonstrate that they disappear. What is established is narrower: the lowering no longer emits the uncapped frac, the cap matches the rule the repository already wrote for pixel_aot, and the adapters that were already returning 0x3f7fffff keep doing so. The two reported adapters are what would confirm the fix.

The draw that exercises v_fract_f32 is not on main yet — it arrives with #1741 — so this change is verified at the level of the emitted text and of the existing suite, not by a draw of its own. Rebasing #1741 onto today's main conflicts in this preamble, because the branch predates the ftz32/mad32 helpers, so its draws need a rebase before they can run here.

cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl' -V

AI-assisted.

Why the comparison is on the encoding. FXC treats frac as strictly below 1, so frac(value) >= 1.0f
folds to false and the helper compiled to a bare frc — the cap disappeared on the Quadro M1000M and the
RTX 3070 Ti, which still read 3f800000 for 0xb0800000. Comparing the bits survives FXC (frc, ieq,
movc), and frac can only reach the cap by rounding to exactly +1.0, so the equality covers the same
case while a NaN still misses it and passes through.

Cache revision. The cap changes already-translated shaders, so the seed goes to x2w-startup-shader-8
in tools/startup/gfx2hlsl.py and src/startup_stubs/d3d12_draw.inl; a control asserts both spellings
agree and that the -7 seed keys differently.

The draw. tests/startup_gfx2hlsl_fract_draw_check.py compiles the generated pair with FXC (ps_5_1)
and DXC (ps_6_0) and compares raw words on 0xb0800000, 1.5, 0.0 and -2.5. The uncapped mutant is
recorded rather than asserted: on this machine WARP and the RX 9070 XT both clamp a bare frc themselves and
read the capped word anyway, so the control cannot separate the two forms here. The separation is observed on
the NVIDIA reports above, and on the head that carries this form an independent re-run passes on WARP, on the
Quadro M1000M that failed before and on an Intel HD 530, all three reading 3f000000,3effffff,3f7fffff,3f000000
for 49742408,3effffff,b0800000,4affffff under fxc and dxc. Turing remains unmeasured.

AI-assisted; runs executed on the machine above.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Ran it, broke it four ways, and checked the arithmetic the description rests on

Windows 11 build 26300.9974, device-free:

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_fract_check.py
control: a min-form clamp is rejected: ok
control: a cap other than 0x3f7fffff is rejected: ok
PASS      exit 0
mutation result
fract32({0}) → frac({0}) (the pre-change lowering) caught
f >= 1.0f → f > 1.0f caught
the cap 0x3f7fffffu → 0x3f7ffffeu caught
the comparison form → min(f, asfloat(0x3f7fffffu)) caught (also your own control)

The second is the one I would have expected to slip: with a strict > the exact case the helper exists for — frac rounding up to 1.0 —
no longer fires. Your fixture separates > from >=, which means it carries the boundary input, not just a mid-range one.

The two claims in the comment, checked as arithmetic

I reimplemented frac in float32 and evaluated the boundary:

CAP = 0.9999999404  (bits 0x3f7fffff)

x=-1e-30   frac=1            >=1.0: True   -> capped to 0.9999999404
x=-1e-20   frac=1            >=1.0: True   -> capped to 0.9999999404
x=-1e-10   frac=1            >=1.0: True   -> capped to 0.9999999404
x=-1e-08   frac=1            >=1.0: True   -> capped to 0.9999999404
x=-1e-07   frac=0.9999998808 >=1.0: False  -> passes through
x=0, 0.25, 0.5, -0.5, 1.5, -1.5, 3.75      -> pass through unchanged

So "a tiny negative input cannot round up to 1.0" is exactly right, and the threshold sits where the description says it does: the boundary is
between 1e-8 and 1e-7, because 1 - 1e-8 rounds to 1.0 in float32 and 1 - 1e-7 does not.

The NaN half also holds: nan >= 1.0 is false, so the comparison form returns the NaN and lets it propagate, whereas a min-form returns the
non-NaN operand in D3D semantics — min would turn a NaN into 0.99999994. That is a value difference, not a style preference, and the comment
says so.

On the asymmetry this PR is really about

Two translators lowering the same instruction differently is the kind of divergence that costs days later, and the fix goes toward the older,
more careful one rather than the newer one — that is the right direction. Worth keeping in docs/experiments.md (you did) that pixel_aot was
already right, so a future reader does not "unify" them the other way.

Scope

The emitted helper is checked as text plus the two controls; no shader was compiled or run here. Whether adapter frac differences are the
reason pixel_aot chose the cap is a claim from the earlier work, not something this check measures.

Verdict

Reviewed. Four mutations caught, and the numeric claim holds at the boundary.

Notes

  • AI-assisted review.

@thepatrickworld

Copy link
Copy Markdown
Contributor Author

Thanks — the >= → > mutation is the sharpest of the four, and it is the one the check exists for: with a strict > the input the helper is there for, frac rounding up to 1.0, no longer fires.

On the origin of the cap, since you flagged it as not measured here: it is not in the ISA. The RDNA 2 guide gives D.f = S0.f + -floor(S0.f) for V_FRACT_F32 with no cap, and for -2^-30 that expression rounds to 1.0, so the Quadro matches the formula. The cap is D3D's observed frac behaviour on WARP, on an Intel Gen9 part and on the RDNA 4 card used here, which is also what the reference encodes. I added that to the description after your review. If the console's own frac is later shown to return 1.0, the cap and the reference have to be revisited together, not the lowering alone.

There is no NVIDIA adapter on this machine, so the adapter half of the argument still rests on the two reports in #1741 rather than on anything measurable here.

AI-assisted.

@Makto94

Makto94 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Hardware data for the NVIDIA gap, from an RTX 3070 Ti (driver 32.0.16.2101, Windows 11 build 26300.9974, DXC 1.9.2602.17, FXC from SDK 10.0.26100, debug layer on).

On top of the #1741 head (8ff3ddd, uncommitted) I copied the fract32 helper from this PR verbatim, changed the v_fract_f32 table entry from frac({0}) to fract32({0}) as this PR does, adapted the mutation regex of startup_gfx2hlsl_float_round_check.py (U\(frac\(F -> U\(fract32\(F), and ran that draw test. In my build the registered test passes an empty FXC argument, so I ran the script directly:

python -B tests/startup_gfx2hlsl_float_round_check.py draw <dxc.exe> <offscreen_check.exe> hardware <fxc.exe>
  • DXC (same command without the FXC argument): passes (10 draws matched, 5 mutated).
  • FXC: still fails, startup_flat_param reads 3f800000 where 3f7fffff is expected.

FXC compiles frac(value) to a lone frc and drops the comparison. Changing one line keeps ge/movc in the output:

float f = value - floor(value);

With it, FXC and DXC both pass on hardware (20 draws, 10 mutated, 0 debug errors), and WARP passes too. On this PR's head (8c99dd3), startup_gfx2hlsl_fract_check.py and the other 22 startup_gfx2hlsl_* checks stay green with this line.

Not measured: Quadro, AMD and Intel with this variant; NaN, inf and -0 (not in the draws).

@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

The cap fixes already translated shaders. Please bump the startup shader cache revision in both gfx2hlsl.py and d3d12_draw.inl after #1997, and check that the pre-fix key no longer hits. The source-built test currently checks the form of the HLSL. Please run the generated shader with default FXC and DXC on the reported negative input and a regular fractional value, using raw pixel words and the uncapped mutant as a control. If WARP already caps the uncapped input, record that separately.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor

Measured on the Maxwell card this was missing: with #2010 as it stands, the Quadro still fails on the same input, because FXC removes the cap.

Setup: pr-1741 (8ff3ddd) merged with pr-2010 (8c99dd3) locally (only docs/experiments.md conflicted; gfx2hlsl.py merged cleanly). The v_fract_f32 mutation pattern in tests/startup_gfx2hlsl_float_round_check.py still matches U(frac(...)), so I changed it locally to fract32( to get past the controls (that pin needs the same update when the branches meet). Then I ran startup_gfx2hlsl_float_round_{controls,warp,hardware}.

Adapter #2010 helper (f >= 1.0f ? ... : f)
WARP 10.0.26100 pass
Intel HD 530 (31.0.101.2111) pass
NVIDIA Quadro M1000M (32.0.15.7371) fail: fxc v_fract_f32, expected=...3f7fffff... actual=...3f800000... on 0xb0800000

The reason shows in FXC's own output (fxc.exe 10.0.26100.0, /T ps_5_1). FXC treats frac as strictly below 1, so frac(x) >= 1.0f folds to false and the helper compiles to the bare instruction:

frc o0.x, CB0[0][0].x

precise float f = frac(value) folds the same way (frc [precise(x)], no compare). DXC keeps the compare (fcmp fast oge + select), which is why pixel_aot, which only compiles with DXC, never hit this.

A compare on the bits survives FXC:

float fract32(float value) {
    float f = frac(value);
    return asuint(f) == 0x3f800000u ? asfloat(0x3f7fffffu) : f;
}

FXC emits frc, ieq r0.y, r0.x, l(0x3f800000), movc. frac can only reach the cap by rounding up to exactly +1.0, so the equality test covers the same case, and a NaN still fails it and passes through. With only that line changed in the preamble, all three adapters pass:

Adapter bit-compare helper
WARP pass
Intel HD 530 pass
NVIDIA Quadro M1000M pass: fxc and dxc both read 3f000000,3effffff,3f7fffff,3f000000 for 49742408, 3effffff, b0800000, 4affffff

tests/startup_gfx2hlsl_fract_check.py requires the text f >= 1.0f ? asfloat(0x3f7fffffu) : f, so it would need the new form. It might be worth having it reject the >= form under FXC explicitly. Not checked: Turing (no such card here), and whether a driver could fold DXC's fast oge too. On this Quadro it did not.

Panam added 2 commits November 25, 2026 01:27
The gfx2hlsl table emitted a bare D3D frac for v_fract_f32, while
tools/pixel_aot.py has always lowered the same instruction through fract32,
which caps x - floor(x) at 0x3f7fffff because D3D frac has no upper bound
and differs between adapters. Two NVIDIA reports fail the draw on the input
0xb0800000 (-2^-30) with 3f800000 where the instruction returns 3f7fffff:
an RTX 3070 Ti on 32.0.16.2101 and a Quadro M1000M on 32.0.15.7371. The
same draw passes on WARP, on Intel HD Graphics 530 and on the RDNA 4 card
used here.

The helper is the comparison form, not min, so a NaN stays a NaN. A new
check pins the emitted statement of the e32 and e64 forms, the cap in the
preamble, and rejects an uncapped frac and a min-form cap.

No NVIDIA adapter is available here: the Maxwell and Turing results are not
reproduced. What is verified is the emitted text, the pixel_aot rule it now
matches, and the adapters that already returned 0x3f7fffff.
…he cache revision

FXC treats frac as strictly below 1, so frac(value) >= 1.0f folds to false and
the helper compiled to a bare frc: on the Quadro M1000M and the RTX 3070 Ti the
cap was gone and v_fract_f32 still read 3f800000 for 0xb0800000. Comparing the
encoding survives FXC (frc, ieq, movc), and frac can only reach the cap by
rounding to exactly +1.0, so the equality covers the same case.

The cap therefore changes translated shaders that are already cached: the
revision seed goes to x2w-startup-shader-8 in gfx2hlsl.py and d3d12_draw.inl,
and a control asserts both spellings agree and that the -7 seed keys
differently.
@thepatrickworld

Copy link
Copy Markdown
Contributor Author

All three points are on the branch head (5eb88127).

The cap. fract32 now compares the encoding — asuint(f) == 0x3f800000u ? asfloat(0x3f7fffffu) : f — the form legacy-code-archaeologist measured on the Quadro and Makto94 on the 3070 Ti. Thank you both: FXC folding frac(value) >= 1.0f to false is exactly what this PR could not see from here, because DXC keeps the compare and pixel_aot only ever compiles with DXC.

The cache revision. It goes to x2w-startup-shader-8 in tools/startup/gfx2hlsl.py and in src/startup_stubs/d3d12_draw.inl. A control asserts the two spellings carry the same seed and that the -7 seed produces a different pipeline_key, so a pre-fix entry cannot be hit.

The draw. tests/startup_gfx2hlsl_fract_draw_check.py compiles the generated pair with the default FXC (ps_5_1) and DXC (ps_6_0), draws one pixel through --startup-flat-param and compares raw words. On 0xb0800000, 1.5, 0.0 and -2.5 it reads 3f7fffff,3f000000,00000000,3f000000.

The uncapped control, recorded separately as you asked. On this machine it does not separate the two forms: with the lowering left uncapped, WARP and the RX 9070 XT both read 3f7fffff,3f000000,00000000,3f000000 anyway, so both adapters clamp a bare frc themselves and the mutant cannot be told apart. The check prints that observation instead of asserting a mismatch it cannot produce. The separation rests on the two NVIDIA reports above, which is the reason the form changed.

4/4 fract tests and 53/53 ^startup_gfx2hlsl green here.

AI-assisted; runs executed on the machine above.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor

Re-ran the new head 5eb88127 on the same Maxwell card: it passes.

Setup as before: pr-1741 (8ff3ddd) merged with this head locally (docs/experiments.md and CMakeLists.txt conflicted; I took #1741's side, since the check script does not depend on either). #1741's v_fract_f32 mutation pattern changed locally from U(frac( to U(fract32(. Then startup_gfx2hlsl_float_round_check.py controls and draw … <warp|hardware> <fxc>, plus startup_gfx2hlsl_fract_check.py.

Adapter Driver Result v_fract_f32 on 49742408, 3effffff, b0800000, 4affffff (fxc and dxc)
WARP 10.0.26100.8972 pass 3f000000,3effffff,3f7fffff,3f000000
NVIDIA Quadro M1000M 32.0.15.7371 pass 3f000000,3effffff,3f7fffff,3f000000
Intel HD Graphics 530 31.0.101.2111 pass 3f000000,3effffff,3f7fffff,3f000000

Controls exit 0, and startup_gfx2hlsl_fract_check.py prints PASS. Windows 11 build 26100, debug layer unavailable. Turing remains unmeasured here. When #1741 rebases, the only test-side change it needs is that mutation pattern.

@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 head 5eb8812708e16b82bc74ca2829507b29fc49e2f8 (comment only, no approval).

Verdict: no P1, no P2. Looks correct.

What I checked:

  • v_fract_f32 now lowers to fract32(), defined in the common preamble next to ftz32. Same semantics as tools/pixel_aot.py:406: the result is capped at 0x3f7fffff when frac rounds up to 1.0.
  • The bit comparison (asuint(f) == 0x3f800000u) is sound. frac can only reach the cap by returning exactly +1.0. NaN misses the equality and passes through, same as pixel_aot. The comment explains why >= 1.0f is avoided (FXC folds it).
  • Cache seed x2w-startup-shader-7 to -8 in src/startup_stubs/d3d12_draw.inl:207 matches the changed HLSL. The check pins that the old seed gives a different key.
  • CI on this head: Linux checks, Windows build and gfx1013 fixtures all pass. The /O2 job and the chart job were skipped. Mergeable. Title and body are neutral.

Commands run locally on the PR head (Linux):

  • python3 -B tests/startup_gfx2hlsl_fract_check.py -> PASS
  • python3 -B tests/startup_gfx2hlsl_fract_draw_check.py (controls mode) -> PASS
  • python3 tests/docs_links_check.py -> 18 files, 395 links, OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean

Mutations (both reverted afterwards with git checkout -- .):

  1. Table entry fract32({0}) changed back to frac({0}): the check exits 1.
  2. Cap condition == 0x3f800000u changed to >= 0x3f800001u: the check exits 1 (FAIL).

Both are killed by the new test.

Not run: the startup_gfx2hlsl_fract_draw_warp and _hardware draw tests need a D3D12 device, so I did not run them here. I did not start a Win2025 run. The Windows CI job is green, and the author's draw results come from the PR body.

Nits (non-blocking):

  • N1: tools/pixel_aot.py:406-409 still uses f >= 1.0f. The new comment says FXC folds that form to false. If pixel_aot goes through FXC, it may lose the cap on the same adapters. Worth a follow-up issue or check. It is out of scope here.
  • N2: CMakeLists.txt comment says the uncapped pair "must read 0x3f800000". That is accurate, but a pointer to the check file's name would help a future reader. Optional.

AI-assisted; commands listed were executed locally.

@thepatrickworld

Copy link
Copy Markdown
Contributor Author

Thank you for the review, and for killing the mutations on that form.

I checked N1, because it decides whether the cap in pixel_aot is real or just nominal.

fxc appears in this repository only on the startup path: tools/startup/gfx2hlsl.py finds it and runs it to compile the translated pair. No pixel_aot output goes through it. Of the 49 test files that mention pixel_aot, four also carry ps_5_1 or cs_5_1, and in all four the SM5 profile belongs to startup fixtures — those files only do from pixel_aot import disassemble. Every file that compiles a shader produced by pixel_aot uses ps_6_0 or cs_6_0.

So the f >= 1.0f form in pixel_aot still has its cap today, and this PR is not leaving a live copy of the bug behind. That is worth saying out loud, since the review could not see it from the diff.

It is nonetheless a latent trap in exactly the direction you point at: if pixel_aot is ever compiled through FXC — an SM5 fallback, a smoke test, someone copying the pair — the cap disappears and nothing fails, which is what happened here until a Quadro read 3f800000. Two cheap ways to close it: a comment beside that comparison saying the form depends on the compiler keeping it, which is why the startup helper now carries the bit form; or use the same bit form there, which is the same semantics under both compilers.

N2 is fair. I can fold that pointer into this PR as a one-line comment change if you would rather have it here than as a follow-up.

AI-assisted.

@stan495 stan495 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified head 5eb88127 on Windows x64 (dev preset, MSVC 19.44.35228.0, SDK 10.0.26100.0, DXC/FXC 10.0.26100.0):

  • cmake --build --preset dev --target offscreen_check -> succeeded
  • ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_fract' -V -> 4/4 passed (startup_gfx2hlsl_fract, startup_gfx2hlsl_fract_draw_controls, startup_gfx2hlsl_fract_draw_warp, startup_gfx2hlsl_fract_draw_hardware)
    • Both FXC and DXC capped runs read 3f7fffff,3f000000,00000000,3f000000 with debug_layer=enabled, debug_errors=0 debug_warnings=0 (and as recorded in the test, both WARP and this hardware adapter also clamp bare frc on the -2^-30 input).
    • Hardware: AMD Radeon RX 7900 XTX (vendor=1002 device=744c, driver 32.0.32029.2010)
    • WARP: Microsoft Basic Render Driver (vendor=1414 device=008c, driver 10.0.26100.9818)

Verdict: Approved at 5eb88127.

@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Hardware result for head 5eb88127 on an NVIDIA adapter: startup_gfx2hlsl_fract_draw_hardware passes with FXC and with DXC.

.\tools\dev.ps1; ctest --preset dev --no-tests=error -j1 -R '^startup_gfx2hlsl_fract_draw_hardware$' -V

NVIDIA GeForce RTX 3070 Ti (10de:2482), driver 32.0.16.2101, Windows 11 build 26300.9974, Debug build, fxc 10.0.26100.9457, dxc 1.9.2602.17, debug layer enabled, 0 capability skips (77). The log shows both compilers:

  • FXC capped pair reads 3f7fffff,3f000000,00000000,3f000000; uncapped control reads 3f800000,3f000000,00000000,3f000000.
  • DXC reads the same two sets of words.
  • debug_errors=0 debug_warnings=0 in all four runs.

This adds an NVIDIA Ampere adapter to stan495's AMD run on this head. legacy-code-archaeologist measured Maxwell, WARP and Intel on this head through the #1741 test, not this one.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

@thepatrickworld could you rebase this branch onto current main and force-push?

GitHub reports head 5eb88127 as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (4aaea119):

  • CMakeLists.txt
  • src/startup_stubs/d3d12_draw.inl
  • tools/startup/gfx2hlsl.py

Commands run locally:

git fetch origin main pull/2010/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 2010 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

…evision conflicts

Main moved the startup shader cache revision to x2w-startup-shader-14 on its
own, so this branch's bump lands on 15: the bit comparison of v_fract_f32 is
kept as written, and the cache literals, the tests that pin them and the
runtime doc follow. CMakeLists keeps main's small_texture_4k_xg tests and this
branch's fract tests, both.
@thepatrickworld

Copy link
Copy Markdown
Contributor Author

Merged origin/main (7092683a) into the branch. The conflicts were on CMakeLists.txt, src/startup_stubs/d3d12_draw.inl and tools/startup/gfx2hlsl.py; the substantive one was the cache revision, which origin/main moved to 14 (via #2059). The branch now carries 15 in tools/startup/gfx2hlsl.py, src/startup_stubs/d3d12_draw.inl, tests/startup_indirect_draw_indexed.cpp, tests/startup_gfx2hlsl_buffer_store_check.py, tests/startup_gfx2hlsl_fract_check.py and docs/startup-runtime.md. The compute revision stays at 14cs, since the compute path does not change.

On the RX 9070 XT (1002:7550, driver 32.0.32029.2010), head eb648061, backend hardware. The fixture compiles each profile itself — ps_5_1 through fxc, ps_6_0 through dxc:

  • startup_gfx2hlsl_fract_draw_check.py draw <dxc> <offscreen_check> hardware <fxc> ends with PASS (13 checks, no failure) and reads startup_flat_param words=3f7fffff,3f000000,00000000,3f000000
  • the same run records that this adapter clamps a bare frc itself, so the control cannot separate the two forms on it; the failing reports in the docstring are NVIDIA
  • startup_gfx2hlsl_fract_check.py (translator only) ends with PASS too (29 checks, no failure)

AI-assisted.

legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
# Conflicts:
#	CMakeLists.txt
#	src/startup_stubs/d3d12_draw.inl
#	tools/startup/gfx2hlsl.py
legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
# Conflicts:
#	CMakeLists.txt
#	src/startup_stubs/d3d12_draw.inl
#	tools/startup/gfx2hlsl.py
legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
The union resolver truncated the R0Y00#2404 lds_b128 control block (missing
PASS_REGULAR_EXPRESSION and endforeach) and registered fma_mix, fract and
fract_draw twice after the updated R0Y00#2055/R0Y00#2010 heads. Configure succeeds again;
every add_test of the merged PR heads is present once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 head 5a544a3 (own diff identical to the previously reviewed 29d0fe9; only a merge of main was added). Comment review, no approval.

Checked:

  • v_fract_f32 now lowers to fract32({0}); the helper is in the common preamble and compares the encoding (asuint(f) == 0x3f800000u), matching the pixel_aot behavior and avoiding the FXC fold of a float compare.
  • Cache revision moved to x2w-startup-shader-15 in gfx2hlsl.py, d3d12_draw.inl and tests/startup_indirect_draw_indexed.cpp. The compute revision (-14cs) is a separate key and is consistent between the two files.
  • Tests: startup_gfx2hlsl_fract (text/lowering), startup_gfx2hlsl_fract_draw_controls, and startup_gfx2hlsl_fract_draw_{warp,hardware} (real D3D12 draw, FXC 5_1 and DXC, readback of the -2^-30 lane). Sibling cache-key test updated to revision 15.
  • This is a numeric-parity fix reported by hardware runs in #1741; it does not claim a startup advance by itself.

Commands run on Linux:

  • python3 -B tests/startup_gfx2hlsl_fract_check.py -> PASS
  • python3 -B tests/startup_gfx2hlsl_buffer_store_check.py -> ok
  • python3 tests/docs_links_check.py -> pass; python3 tests/bidi_controls_check.py -> pass; git diff --check origin/main...HEAD -> clean
  • Mutation: cap comparison changed to 0x3f800001u -> fract check exits 1. Mutation: fract32({0}) reverted to frac({0}) -> fract check exits 1.

Win2025 WARP dev+release on this head follows in a separate receipt.

AI-assisted; commands listed were executed locally.

@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Hardware run and Windows 11 MSVC build at head 5a544a3a (merge of main into 29d0fe9f; cache revision 15). The NVIDIA result I posted for 5eb88127 is repeated here on the new head.

Environment: Windows 11 Pro build 26300.9974, Debug (dev preset), MSVC toolset 14.44.35207 (cl 19.44.35230.0), driver 32.0.16.2101. The hardware test prints adapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482 and backend=hardware debug_layer=enabled, with debug_errors=0 debug_warnings=0 in every case. The runs were serial (-j1).

Build: cmake --build --preset dev exited 0. This PR changes C++ (src/startup_stubs/d3d12_draw.inl, tests/startup_indirect_draw_indexed.cpp), so this is a full build.

Tests:

  • ctest --preset dev --no-tests=error -j1 -R '^startup_gfx2hlsl_fract' -E hardware -V: 3/3 passed (startup_gfx2hlsl_fract, startup_gfx2hlsl_fract_draw_controls, startup_gfx2hlsl_fract_draw_warp).
  • ctest --preset dev --no-tests=error -j1 -R '^startup_gfx2hlsl_fract.*_hardware$' -V: 1/1 passed (startup_gfx2hlsl_fract_draw_hardware). 0 capability skips (77).

startup_gfx2hlsl_fract also checks the cache: the revision is x2w-startup-shader-15, pipeline_key hashes the seed the source spells, and the -14 seed gives a different key.

The hardware test runs the generated pair with FXC and with DXC, each with the capped helper and with the uncapped control:

  • FXC capped: 3f7fffff,3f000000,00000000,3f000000. FXC uncapped control: 3f800000,3f000000,00000000,3f000000, so the control fails as intended.
  • DXC capped and DXC uncapped control read the same two sets of words.

The WARP run (adapter=Microsoft Basic Render Driver, driver 10.0.26100.9818) reads the capped word 3f7fffff,3f000000,00000000,3f000000 for all four runs, with debug_errors=0 debug_warnings=0. WARP clamps a bare frc itself, so the control cannot separate the two forms there; the test records this.

Not covered by this run: this run is NVIDIA only (the PR already lists an AMD run); only the startup_gfx2hlsl_fract* tests were run, not the full ctest suite.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head 5a544a3 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 5a544a3a72313254c8cc5b4872383f37b5a31770:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2): 31.42s (configure 0.00s)
    • Test (ctest --preset dev -R 'startup_gfx2hlsl_fract(_draw_(controls|warp))?$|startup_gfx2hlsl_buffer_store' --parallel 2 --no-tests=error --output-on-failure): 4/4 passed (1.00s: startup_gfx2hlsl_fract_draw_warp 0.65s, startup_gfx2hlsl_buffer_store 0.64s, startup_gfx2hlsl_fract 0.14s, startup_gfx2hlsl_fract_draw_controls 0.12s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_indirect_draw_indexed -- -j 2): 2.51s (configure 0.00s)
    • Test (ctest --preset release -R 'startup_gfx2hlsl_fract(_draw_(controls|warp))?$|startup_gfx2hlsl_buffer_store' --parallel 2 --no-tests=error --output-on-failure): 4/4 passed (0.85s: startup_gfx2hlsl_fract 0.10s, startup_gfx2hlsl_fract_draw_controls 0.10s, startup_gfx2hlsl_buffer_store 0.45s, startup_gfx2hlsl_fract_draw_warp 0.51s)
  • Windows Python checks: tests/mesh_heap_sampler_check.py ok (0.7s), tests/startup_buffer_address_check.py ok (0.4s), tests/startup_compute_request_offline_check.py ok (0.4s), tests/startup_compute_translate_check.py ok (0.2s), tests/startup_flat_param_check.py ok (0.1s), tests/startup_gfx2hlsl_add_sub_co_check.py ok (0.1s), tests/startup_gfx2hlsl_add_sub_co_ci_check.py ok (0.1s), tests/startup_gfx2hlsl_bit_alu_check.py ok (0.6s), tests/startup_gfx2hlsl_capture_check.py ok (0.9s), tests/startup_gfx2hlsl_cmp16_check.py ok (0.2s), tests/startup_gfx2hlsl_compare_dst_check.py ok (0.1s), tests/startup_gfx2hlsl_compute_check.py ok (0.3s), tests/startup_gfx2hlsl_cselect_mask_check.py ok (0.1s), tests/startup_gfx2hlsl_cvt_alu_check.py ok (0.1s), tests/startup_gfx2hlsl_f32_lg_check.py ok (1.3s), tests/startup_gfx2hlsl_f32_nan_check.py ok (5.1s), tests/startup_gfx2hlsl_getpc_refusal_check.py ok (0.1s), tests/startup_gfx2hlsl_handler_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_get_lod_check.py ok (0.1s), tests/startup_gfx2hlsl_int_med3_check.py ok (0.1s), tests/startup_gfx2hlsl_join_symbols_check.py ok (0.2s), tests/startup_gfx2hlsl_loop_constants_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_overwrite_check.py ok (0.1s), tests/startup_gfx2hlsl_operand_count_check.py ok (0.3s), tests/startup_gfx2hlsl_readfirstlane_recompute_check.py ok (0.1s), tests/startup_gfx2hlsl_readfirstlane_uniform_check.py ok (0.1s), tests/startup_gfx2hlsl_refusals_check.py ok (0.5s), tests/startup_gfx2hlsl_root_check.py ok (0.7s), tests/startup_gfx2hlsl_saveexec_same_reg_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_arity_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_brev_fold_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_m0_check.py ok (0.1s), tests/startup_gfx2hlsl_sdwa_cvt_check.py ok (0.2s), tests/startup_gfx2hlsl_sgpr_spill_check.py ok (0.1s), tests/startup_gfx2hlsl_shift64_check.py ok (0.1s), tests/startup_gfx2hlsl_smem_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_sop2_complement_check.py ok (5.7s), tests/startup_gfx2hlsl_sopk_accum_check.py ok (0.8s), tests/startup_gfx2hlsl_sopk_signext_check.py ok (0.1s), tests/startup_gfx2hlsl_swap_check.py ok (0.3s), tests/startup_gfx2hlsl_vopc_sdwa_check.py ok (4.1s), tests/startup_gfx2hlsl_waitcnt_depctr_check.py ok (0.1s), tests/startup_gfx2hlsl_watch_check.py ok (2.4s), tests/startup_image_2d_array_check.py ok (0.2s), tests/startup_image_3d_check.py ok (0.1s), tests/startup_image_gather_lz_check.py ok (0.6s), tests/startup_image_load_d16_check.py ok (0.8s), tests/startup_image_sample_a16_check.py ok (0.1s), tests/startup_image_sample_b_check.py ok (0.1s), tests/startup_image_sample_c_check.py ok (0.2s), tests/startup_image_sample_l_check.py ok (0.2s), tests/startup_image_sample_lod_check.py ok (0.6s), tests/startup_inline_sampler_check.py ok (0.2s), tests/startup_mesh57_skeleton_check.py ok (0.1s), tests/startup_run_ps1_check.py ok (8.9s), tests/startup_run_sh_check.py FAIL (0.1s), tests/startup_sampler_heap_check.py ok (0.1s), tests/startup_smem_address_check.py ok (0.1s), tests/startup_stream_fetch_check.py ok (0.2s), tests/startup_stream_interface_check.py ok (0.2s), tests/startup_translator_check.py ok (0.4s)
  • Note: tests/startup_run_sh_check.py is a Windows-host shell check unrelated to this change; the pipeline still reports PASS (dev 4/4, release 4/4 on the PR tests).
  • sccache: 3/6 hits; wall 83.3s

AI-assisted; commands listed were executed locally.

@MasterDomino

Copy link
Copy Markdown
Collaborator

Heads-up on the startup cache revision: #2467 merged as ae5d482a and moved main to x2w-startup-shader-15 / 15cs. This branch also bumps to 15, so after the next rebase please take the next free number. #2095 plans 16, so whichever of the two lands later needs 17. Bump the compute Ncs string together with the graphics one, since compute shares the preamble.

AI-assisted.

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks for flagging the shared cache keys. The current candidate c1c99ec9 includes the mainline revision-15 change and advances graphics/compute to 16/16cs, plus the fixed slot-57 mesh key to 2. The runtime publishers and offline readers use the same versions. The exact Windows Release run passed 24/24, including FXC/DXC fract boundary and wrong-reference cases, the compute key and cache scan, slot-57 publisher/exchange, and the title-memory-retirement fixture. If #2095 lands after this, it should take the next free revision. This validates the source-built behavior; any actual EXE comparison still needs a matching cache.

legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
- VEC_U held v_mul_i32_i24/v_mad_i32_i24 twice (main's R0Y00#2410 and a local copy);
  the later local entries hid main's, so its mutation controls saw no change.
- s_ff1_i32_b32's compute-entry path read self.kind directly; kind-less probes
  (startup_gfx2hlsl_scalar_arity) raised AttributeError.
- tests/startup_stream_fetch_check.py back to main: its extra sub_co_ci case
  pinned the text of the local co_ci handler that main's R0Y00#2428 replaced.
- startup_resource_retire_title writes its draw translation with the cache
  revision; this branch is at x2w-startup-shader-15 (R0Y00#2010).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@R0Y00
R0Y00 merged commit 2072562 into R0Y00:main Nov 25, 2026
5 checks passed
thepatrickworld pushed a commit to thepatrickworld/Xbox2Windows that referenced this pull request Nov 25, 2026
main moved to 16 through R0Y00#2010, so this branch takes 17 and moves the
compute key with it (17cs), as MasterDomino asked in R0Y00#2095.
MasterDomino pushed a commit that referenced this pull request Nov 25, 2026
…rce (#2095)

* startup: return the minimum of the three on v_med3_f32 with a NaN source

* tests: supply the eight entry words the med3 draw fixture declares

* Bump the startup shader cache revision to 16 for the med3 lowering

* Update the readfirstlane uniformity fixture for the med3_32 helper rename

* Bump the startup shader cache revision to 17 for the med3 lowering

main moved to 16 through #2010, so this branch takes 17 and moves the
compute key with it (17cs), as MasterDomino asked in #2095.

---------

Co-authored-by: Panam <panam@thepatrick.world>
Co-authored-by: root <root@srv1960403.hstgr.cloud>
Co-authored-by: thepatrickworld <patrick@example.com>
Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>
Co-authored-by: panam <panam@local>
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.

8 participants