Skip to content

native: admit fixed pixel entries with zero or more than seven interpolants - #3527

Open
Leyukaka wants to merge 3 commits into
R0Y00:mainfrom
Leyukaka:native-fixed-entry-interpolant-range
Open

Leyukaka wants to merge 3 commits into
R0Y00:mainfrom
Leyukaka:native-fixed-entry-interpolant-range

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Refs #870 (claim: #870 (comment), parts (a) and (b) in one PR).

Why

With the interface catalog installed (#3521), a fixed slot-57 PSI1 pixel entry reaches the layout check in prepare_direct_graphics (src/direct_compute_cache.cpp). On main that check refuses an interpolant count of zero or above seven with captured interpolation count disagrees with pixel interface, and any captured/reviewed address pair other than 0x0002/0x0002 and 0x8002/0x0302 with unsupported fixed pixel entry layout. Those pairs get no native graphics pipeline.

What

Count rule, prepare_direct_graphics:

  • Zero interpolants is admitted only for a reviewed exact pair. A raw, non-exact pair with count zero is still refused.
  • The upper bound is min(D3D12_VS_OUTPUT_REGISTER_COUNT, reviewed pixel attribute count) instead of 7.

Address rule, same function. The captured address must equal the reviewed address, except for the existing 0x8002/0x0302 packed-XY pair, which now also requires a nonzero count. Admitted values:

  • 0x0002, any admitted count;
  • 0x0000, zero count only;
  • a nonzero subset of 0x0f00 (float position bits), zero count only. The matching SV_Position float input is skipped in the post-link input check.

Zero count:

  • The center I/J input (kind 28) is no longer skipped in the post-link check when the captured count is zero, so a zero-count entry that consumes barycentrics is refused with raw and reflected interpolation inputs disagree.
  • A pixel shader that reads a VGPR the address does not allocate is refused earlier, during lowering, by the existing unsupported pixel entry VGPR n check in src/gfx1013_direct_graphics.inl. The two refusals are separate fixtures with separate diagnostics.

Exact pairs:

  • New GuestShaderStage::pixel_interpolant_count (src/guest_shader_container.h), set from the captured count.
  • The VINTRP lowering in gfx1013_direct_graphics.inl refuses an attribute location at or above that count.
  • The reflected TEXCOORD rows of a fixed exact pair skip the per-PARAM index check; the VS/PS link still applies.

Raw pairs with more than seven interpolants:

  • translate_graphics_pair takes extended_fixed_params; read_raw_graphics then accepts 32 PARAMs instead of 7 (src/gfx1013_compute_native.cpp).
  • New pack_fixed_graphics_varyings keeps the provisional rows when they fit. Otherwise it packs one register per (PARAM, flat/smooth) with the same channel assignment on both stages, and refuses past the 32-register budget with invalid signature register or component mask.
  • Counts of seven or fewer take the unchanged path.

Tests

New CTest startup_native_graphics_fixed_entry_{warp,hardware}: tests/startup_native_graphics_draw_check.py --fixed-slot57. It draws through the catalog with native shaders only and compares every pixel: zero count at addresses 0, 2, 0x100, 0x300, then exact and raw pairs at counts 8 and 32.

tests/native_graphics_interface_library_check.py adds compile cases with refusal controls. Each refusal checks the diagnostic and that no output is published.

Case Expected
zero-{0,2,100,300} accepted
zero-position-mismatch, zero-center-position unsupported fixed pixel entry layout
zero-inexact, zero-param refused
zero-unallocated-vgpr unsupported pixel entry VGPR 4
zero-barycentrics raw and reflected interpolation inputs disagree
exact-{8,32}, raw-{8,32} accepted, signature rows checked with dxc -dumpbin
exact-location-{8,32}, raw-location-32 (count one below a consumed location) refused
count-above-interface-{8,32} refused
exact-missing-producer-channel graphics stages disagree
raw-full-budget (31 full exports) accepted
raw-overflowing-signature invalid signature register or component mask

Local Windows build of a1b10c5, dev preset, 8/8 passed: startup_native_graphics_draw_{warp,hardware}, startup_native_graphics_fixed_entry_{warp,hardware}, native_direct_container, native_direct_mesh, native_graphics_interface_library, startup_gfx2hlsl_ps57in.

Mutations, each applied alone, then restored and rebuilt to 8/8:

Mutation Failing tests
count check restored to !n || n > 7 native_graphics_interface_library, startup_native_graphics_fixed_entry_warp
zero count kept, n > 7 restored same two, on the count-8 cases
captured_interp_count != 0 guard dropped from the kind-28 skip native_graphics_interface_library (zero-barycentrics accepted)
old expected text for zero-unallocated-vgpr native_graphics_interface_library (unsupported pixel entry VGPR 4)

An earlier Windows Sandbox run of the same eight tests on 9c6d359 gave 7/8. native_graphics_interface_library failed: the zero-barycentrics fixture exported an unallocated v4, so lowering refused it with unsupported pixel entry VGPR 4 before the zero-count check. a1b10c5 changes only that test: the original bytes become zero-unallocated-vgpr with the lowering diagnostic, and a new zero-barycentrics fixture exports center I and an initialized v2 to reach the zero-count check. No source change after 9c6d359. The Sandbox run was not repeated on a1b10c5.

Not covered

  • No full-run measurement of the application yet; the effect on native pipeline counts is not measured.
  • Other input address forms (centroid, sample, linear, front face, pull model) are still refused with unsupported fixed pixel entry layout.
  • Other fixed-entry refusals are unchanged.

@lukaslw-lab lukaslw-lab 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.

Reviewed a1b10c53 by reading the diff, then ran it merged onto main 44a3ad5a with #3506, #3516, #3464, #3521 and #3097 (native shaders only, interface catalog installed, its tests not run). Reads correct for what it admits; one real-title case it still refuses, filed as #3560.

  • The case. A full-screen pass into one R8G8B8A8_UNORM target, native-only key 05dc00b8b79c1d4b. Its captured PSI1 is SPI_PS_INPUT_ADDR = 0x8080 (bit 15 POS_FIXED_PT, and bit 7) with NUM_INTERP = 0.
  • Still refused with this PR at direct_compute_cache.cpp:730 (captured interpolation count disagrees with pixel interface), so the pair is not exact. An exact pair would stop at :733-737: zero count is admitted only for 0x0000 or a subset of 0x0f00.
  • Effect. The pass never draws, so the 3840×2160 layer it writes is never redrawn and earlier frames persist on screen during a fresh start, with or without this PR. Drawing only this pipeline from its published translation removes that.
  • Suggestion. Admitting zero interpolants with POS_FIXED_PT for a non-exact pair would fit this PR's count and address rules; a fixture with ADDR 0x8080, NUM_INTERP 0 would pin it. Details and the run table are in #3560. A follow-up works too.

RTX 3080 Ti, Windows 10 19045, Agility SDK 1.620. This review was AI-assisted.

@mumba17

mumba17 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Data point for this PR's area, from a native-shader run tonight: main d5970858 plus #3635/#3645/#3646 (mesh frontend only), run_preset.py --set translate=false, RTX 3090, Windows 11, saved profile, about 8 minutes.

The run cache has 376 graphics requests; 19 compile and 357 are refused. The top reason is unsupported fixed pixel entry layout (214). For most of those, the PSI1 control word is not a plain interpolant count. d3d12_draw.inl:1346 captures SPI_PS_IN_CONTROL with its flags intact, but direct_compute_cache.cpp:772-790 uses the whole dword as interpolants:

PSI1 (ADDR, control) Requests Control decoded
0x8080, 0x8000 180 NUM_INTERP 0, PS_W32_EN (bit 15) set
0x8080, 0 74 accepted (packed position only)
0x2, 1..3 58 accepted
0x8002, 0x8002 4 NUM_INTERP 2, PS_W32_EN set
others (0x8c02, 0x8402, 0x80, 0x8002 with 3..8) ~30 different ADDR or count

So 184 of the 214 are wave32 pixel shaders: 0x8000 != 0 defeats packed_position_only, and the address check then refuses. Masking NUM_INTERP (bits 5:0) is not enough alone. Bit 15 should also set the pixel entry of stage_wave32, so the raw frontend lowers the pixel program's lane masks as wave32.

#3527 rewrites these exact lines, so I'm not claiming it separately. Leyukaka, do you want to fold it into this PR, or should I open a follow-up on top of it once it merges? I can retest either way on this cache.

@Leyukaka
Leyukaka force-pushed the native-fixed-entry-interpolant-range branch from a1b10c5 to 0b62bd6 Compare December 1, 2026 17:35

@lukaslw-lab lukaslw-lab 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.

Reviewed 0b62bd6f by reading the diff; not built or run.

Verdict: approve. The new count and address rules fail closed, and the rebase keeps main's 0x8080 zero-count path separate from them. No MUST.

  • SHOULD The local 8/8 runs and the mutations in the description are from a1b10c53. The rebase onto ce7eb9d3 resolved conflicts in these same lines, and of the eight tests only native_direct_mesh, which this PR does not change, is in the Windows pr preset filter. CI at this head ran none of the seven that cover the change. One local run of the same eight at 0b62bd6f would cover the merged code.
  • Checked, no finding:
    • Main's packed_position_only (direct_compute_cache.cpp:803) is skipped by both the new count/address block (:843) and the post-link check (:913). So #3560's case does not hit the new kind-28 rule at :917.
    • The kind-28 skip at :917. captured_interp_count != 0 is an optional compared with 0. It still skips for requests without a fixed entry (nullopt) and stops only for a captured zero.
    • The new upper bound fails closed. The count is still the whole SPI_PS_IN_CONTROL dword. Raising the bound from 7 to min(32, attributes) admits only values that are pure NUM_INTERP; any flag bit (6 and up) stays above it and is refused.
    • pack_fixed_graphics_varyings (gfx1013_compute_native.cpp:2435). Provisional rows reach 1 + 4·31 + 3 = 128, which fits both the 128-entry channel array and the uint8_t row. Splitting by flat/smooth per PARAM keeps DXIL packing legal, and the budget check refuses before row 32.
    • The pixel_interpolant_count guard (gfx1013_direct_graphics.inl:46) is set only for exact pairs (:872), so it does not touch the raw path.

Tests: native_graphics_interface_library covers each count, address and budget refusal with its diagnostic and no published output. startup_native_graphics_fixed_entry_{warp,hardware} draws the accepted cases through the catalog and compares every pixel.

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Independently verified 0b62bd6f in a clean trial merge with main 162fab1f. MSVC 19.51, SDK 10.0.26100, Windows build 26300, WARP 10.0.26100.9818 and RTX 4060 Laptop GPU (616.56), D3D12 debug layer enabled. Release /O2, with X2W_WITH_OPUS=OFF for this graphics-only build. cmake --build --preset release --target compile_dxil d3d12_xs_shim startup_stream_consumer -j 5 passed. ctest --preset release --no-tests=error -j 1 -R '^(startup_native_graphics_(draw|fixed_entry)_(warp|hardware)|native_direct_(container|mesh)|native_graphics_interface_library|startup_gfx2hlsl_ps57in)$' --output-on-failure: 8 passed, 0 failed, 0 skipped. Both fixed-entry GPU fixtures ran and passed.

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

After #3521 landed, pushed c53ffed4 to preserve both the launcher catalog checks and the fixed-entry fixtures in the shared Python test. Rebuilt Release and reran the same eight tests on this head. Seven passed in the sandbox. native_graphics_interface_library hit Windows error 32 when deleting the synthetic watcher's log. The same test rerun outside the sandbox passed 1/1, on the same binaries and commit. PR CI is running on c53ffed4.

@lukaslw-lab lukaslw-lab 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.

Re-reviewed c53ffed4 by reading the diff; not built or run.

Verdict: approve. The PR's own source change is identical to 0b62bd6f: the src/ diff against main has the same patch ID. The two new commits are merges of main. No MUST, no open points.

  • R0Y00's run of the eight tests on a trial merge of 0b62bd6f with main 162fab1f closes our SHOULD. That covers the merged code, including the seven tests outside the pr preset.
  • c53ffed4 resolves tests/native_graphics_interface_library_check.py by keeping both sides:
    • #3521's launcher cases (run_case, with the catalog error control);
    • this PR's fixed-entry cases (zero_fixed_cases, fixed_varying_case and the varying-row jobs).
      Both import sets are kept. The only failure reported on this head is the sandbox's file-delete error 32, which passed when rerun outside the sandbox.

Tests: CI is green at this head. The fixed-entry fixtures still run only in R0Y00's local runs, because they are outside the pr preset.

@Leyukaka
Leyukaka force-pushed the native-fixed-entry-interpolant-range branch from c53ffed to 0b4ec28 Compare December 2, 2026 07:32
@Leyukaka

Leyukaka commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main (f365f12); the new head is 0b4ec28e8 and replaces the merge c53ffed4. Two conflicts: the import block of tests/native_graphics_interface_library_check.py (both sides kept, so the file is identical to the one in c53ffed4) and the signature of translate_graphics_pair (the new extended_fixed_params parameter plus the function-try-block from main). No other change; the CTest selection from the description passes again on the new head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P0 Highest project priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants