Shaders: fix packed SV_ClipDistance/SV_CullDistance widths and channel offsets #3339

Open
Kalmarv wants to merge 1 commit from upstream-pr/3339 into main
Kalmarv commented 2026-11-29 09:26:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T09:26:53Z.


What changed

  • Shared a single gpu::recomp::output_channel_span helper in crates/xcl/src/gpu/recomp/mod.rs that computes (start_channel, component_count) for SV_ClipDistance / SV_CullDistance outputs from the active bit span of their OSG1 mask (start = (mask & 0xF).trailing_zeros(), count = hi - start + 1, with (0, 1) fallback for empty masks) while leaving user semantics as full 4-vectors from .x.
  • Updated the direct DXIL vertex-shader translator (crates/xcl/src/gpu/dxil/lower_gfx.rs), the HLSL vertex-shader recompiler (crates/xcl/src/gpu/recomp/emit.rs::export_graphics and out_comps), and the mesh/geometry pass-through (crates/xcl/src/gpu/recomp/emit.rs::mesh_passthrough_for) to declare each packed clip/cull element with its true component count and read from register channels start..start + count (.y, .zw, .w, etc.) instead of always starting at .x.
  • Updated crates/xcl/src/gpu/dxil/graphics.rs::sig_part to sort ISG1/OSG1 rows by (stream, register, semantic_name_rank, mask.trailing_zeros()), matching DXC's program-signature writer so elements sharing a register and semantic name stay adjacent even when another semantic packs between their columns (e.g. SV_ClipDistance0 at .x, SV_CullDistance0 at .y, SV_ClipDistance1 at .z).
  • Added unit, DXC/DXIL validation, and RTX 5070 Ti GPU draw tests in crates/xcl/src/gpu/recomp/mod.rs, crates/xcl/src/gpu/recomp/tests.rs, and crates/xcl/src/gpu/dxil/core_tests.rs.

Why

Both lower_gfx.rs::out_comps and emit.rs::out_comps previously computed clip/cull component count as 8 - e.mask.leading_zeros(), ignoring mask.trailing_zeros(), and always read channels 0..count from .x. When DXC packs multiple clip/cull outputs into one register (for example SV_ClipDistance0 in .xyz + SV_ClipDistance1 in .w at one register and SV_CullDistance0 in .xy at the next, or SV_ClipDistance0 in .x + SV_CullDistance0 in .y in one register):

  1. A .w element (mask = 0x8) inflated to float4 (pushing valid 6-component signatures to 9 > D3D12's 8-distance limit so DXC and dxil.dll rejected the shader).
  2. Non-.x clip/cull outputs copied earlier channels (such as another clip plane or unused register channels) into the wrong clip/cull planes instead of reading from their own channel offset.
  3. In direct DXIL, graphics.rs::sig_part previously sorted signature rows by (register, mask.trailing_zeros()), causing dxil.dll container validation to reject interleaved packed signatures (SV_ClipDistance0, SV_CullDistance0, SV_ClipDistance1) with Container part 'Program Output Signature' does not match expected for module.

Tested

  • Environment: Windows 11 Pro (Build 26200), AMD Ryzen 9 9950X, NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), rustc 1.99.0, DXC 1.9.2609.5 (dxil.dll 1.9.2609.5).
  • cargo check --workspace --all-targets: passed with 0 errors and 0 new warnings.
  • Targeted CPU + DXC + RTX 5070 Ti GPU tests (31 passed; 0 failed; 0 ignored):
    • gpu::recomp::attribute_tests::output_channel_span_preserves_packed_clip_and_cull_offsets
    • gpu::recomp::tests::packed_clip_and_cull_outputs_keep_width_and_channel_offset_in_hlsl_mesh_and_rect_gs (compiled vs_6_6, both ms_6_6 pass-through variants, and gs_6_6 with DXC 1.9)
    • gpu::dxil::core_tests::packed_clip_and_cull_distances_validate_and_draw_on_gpu (validated 6-distance and interleaved single-register direct DXIL shaders with dxil.dll and executed both direct DXIL and HLSL draws on RTX 5070 Ti, verifying exact top-right quadrant survival with negative poison on unused .z and full-triangle culling via .y)
    • All 25 gpu::dxil::graphics::tests::* tests, plus rect_list_gs_outputs, mesh_split_accounts_vertex_chunks, and mesh_layout_independent_of_group_count.
  • Full workspace GPU test suite (cargo test --workspace -- --test-threads=4, XCL_DXC_DIR set): passed (exit 0, 136.1 s).
  • Real-title 150 s smoke (62d532671d43a5b60fe1abfac9fe262e10a3ca71, rebased onto origin/main 3b6a91ed, XCL_HEAP_WINDOWS=1, XCL_DIRECT_DXIL=all, XCL_DRED=1), 0 minidumps, 0 display events:

Baseline (main ancestor f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):

xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB

This PR (62d532671d43a5b60fe1abfac9fe262e10a3ca71):

xcl-smoke v1
commit: 62d532671d43a5b60fe1abfac9fe262e10a3ca71
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1536 (PresentX 1536)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33098 MB

Not tested

  • AMD wave64-only GPU paths (tested on NVIDIA RTX 5070 Ti wave32 hardware; wave64-only GPU tests skip on wave32 hardware).
  • exp pos1–pos3 clip/cull exports without an exp param (intentionally left untouched to avoid overlapping open PR #1350).

AI use

Written, verified, and tested with an AI coding assistant; all compiler, DXC/DXIL validator, GPU draw, full workspace test suite, and 150 s real-title smoke runs were executed directly on this machine.

<!-- greyfinch-sync:ivall/xcl:issue:5549402807 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3339). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T09:26:53Z. --- **What changed** - Shared a single `gpu::recomp::output_channel_span` helper in `crates/xcl/src/gpu/recomp/mod.rs` that computes `(start_channel, component_count)` for `SV_ClipDistance` / `SV_CullDistance` outputs from the active bit span of their OSG1 `mask` (`start = (mask & 0xF).trailing_zeros()`, `count = hi - start + 1`, with `(0, 1)` fallback for empty masks) while leaving user semantics as full 4-vectors from `.x`. - Updated the direct DXIL vertex-shader translator (`crates/xcl/src/gpu/dxil/lower_gfx.rs`), the HLSL vertex-shader recompiler (`crates/xcl/src/gpu/recomp/emit.rs::export_graphics` and `out_comps`), and the mesh/geometry pass-through (`crates/xcl/src/gpu/recomp/emit.rs::mesh_passthrough_for`) to declare each packed clip/cull element with its true component count and read from register channels `start..start + count` (`.y`, `.zw`, `.w`, etc.) instead of always starting at `.x`. - Updated `crates/xcl/src/gpu/dxil/graphics.rs::sig_part` to sort `ISG1`/`OSG1` rows by `(stream, register, semantic_name_rank, mask.trailing_zeros())`, matching DXC's program-signature writer so elements sharing a register and semantic name stay adjacent even when another semantic packs between their columns (e.g. `SV_ClipDistance0` at `.x`, `SV_CullDistance0` at `.y`, `SV_ClipDistance1` at `.z`). - Added unit, DXC/DXIL validation, and RTX 5070 Ti GPU draw tests in `crates/xcl/src/gpu/recomp/mod.rs`, `crates/xcl/src/gpu/recomp/tests.rs`, and `crates/xcl/src/gpu/dxil/core_tests.rs`. **Why** Both `lower_gfx.rs::out_comps` and `emit.rs::out_comps` previously computed clip/cull component count as `8 - e.mask.leading_zeros()`, ignoring `mask.trailing_zeros()`, and always read channels `0..count` from `.x`. When DXC packs multiple clip/cull outputs into one register (for example `SV_ClipDistance0` in `.xyz` + `SV_ClipDistance1` in `.w` at one register and `SV_CullDistance0` in `.xy` at the next, or `SV_ClipDistance0` in `.x` + `SV_CullDistance0` in `.y` in one register): 1. A `.w` element (`mask = 0x8`) inflated to `float4` (pushing valid 6-component signatures to 9 > D3D12's 8-distance limit so DXC and `dxil.dll` rejected the shader). 2. Non-`.x` clip/cull outputs copied earlier channels (such as another clip plane or unused register channels) into the wrong clip/cull planes instead of reading from their own channel offset. 3. In direct DXIL, `graphics.rs::sig_part` previously sorted signature rows by `(register, mask.trailing_zeros())`, causing `dxil.dll` container validation to reject interleaved packed signatures (`SV_ClipDistance0`, `SV_CullDistance0`, `SV_ClipDistance1`) with `Container part 'Program Output Signature' does not match expected for module`. **Tested** - Environment: Windows 11 Pro (Build 26200), AMD Ryzen 9 9950X, NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), `rustc 1.99.0`, DXC `1.9.2609.5` (`dxil.dll 1.9.2609.5`). - `cargo check --workspace --all-targets`: passed with 0 errors and 0 new warnings. - Targeted CPU + DXC + RTX 5070 Ti GPU tests (`31 passed; 0 failed; 0 ignored`): - `gpu::recomp::attribute_tests::output_channel_span_preserves_packed_clip_and_cull_offsets` - `gpu::recomp::tests::packed_clip_and_cull_outputs_keep_width_and_channel_offset_in_hlsl_mesh_and_rect_gs` (compiled `vs_6_6`, both `ms_6_6` pass-through variants, and `gs_6_6` with DXC 1.9) - `gpu::dxil::core_tests::packed_clip_and_cull_distances_validate_and_draw_on_gpu` (validated 6-distance and interleaved single-register direct DXIL shaders with `dxil.dll` and executed both direct DXIL and HLSL draws on RTX 5070 Ti, verifying exact top-right quadrant survival with negative poison on unused `.z` and full-triangle culling via `.y`) - All 25 `gpu::dxil::graphics::tests::*` tests, plus `rect_list_gs_outputs`, `mesh_split_accounts_vertex_chunks`, and `mesh_layout_independent_of_group_count`. - Full workspace GPU test suite (`cargo test --workspace -- --test-threads=4`, `XCL_DXC_DIR` set): passed (`exit 0`, 136.1 s). - Real-title 150 s smoke (`62d532671d43a5b60fe1abfac9fe262e10a3ca71`, rebased onto `origin/main` `3b6a91ed`, `XCL_HEAP_WINDOWS=1`, `XCL_DIRECT_DXIL=all`, `XCL_DRED=1`), 0 minidumps, 0 display events: Baseline (`main` ancestor `f0e8fdd5c3942ddd399d5ee11384c8595c5aacff`): ``` xcl-smoke v1 commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1695 (PresentX 1695) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31546 MB ``` This PR (`62d532671d43a5b60fe1abfac9fe262e10a3ca71`): ``` xcl-smoke v1 commit: 62d532671d43a5b60fe1abfac9fe262e10a3ca71 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1536 (PresentX 1536) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 33098 MB ``` **Not tested** - AMD wave64-only GPU paths (tested on NVIDIA RTX 5070 Ti wave32 hardware; wave64-only GPU tests skip on wave32 hardware). - `exp pos1`–`pos3` clip/cull exports without an `exp param` (intentionally left untouched to avoid overlapping open PR `#1350`). **AI use** Written, verified, and tested with an AI coding assistant; all compiler, DXC/DXIL validator, GPU draw, full workspace test suite, and 150 s real-title smoke runs were executed directly on this machine.
Aniseto commented 2026-11-29 12:57:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T12:57:05Z.


Ran the packed clip/cull output tests at c5a9a056 on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib output_channel_span_preserves_packed_clip_and_cull_offsets -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib packed_clip_and_cull_distances_validate_and_draw_on_gpu -- --test-threads=1: 1 passed, 0 failed, 0 ignored. The GPU draw ran here, with no SKIPPED line.

What this adds
Both tests pass: packed SV_ClipDistance/SV_CullDistance elements keep their true component width and channel offset, and the generated DXIL validates and draws on the card. The thread already has an RTX 5070 Ti report from the author; this adds an independent run on driver 32.0.16.2140. Synthetic draw only, no title.

Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

<!-- greyfinch-sync:ivall/xcl:comment:7256179938 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3339#issuecomment-7256179938). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-29T12:57:05Z. --- Ran the packed clip/cull output tests at `c5a9a056` on an NVIDIA Blackwell desktop part. **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40) - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: debug **Results** - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib output_channel_span_preserves_packed_clip_and_cull_offsets -- --test-threads=1`: 1 passed, 0 failed, 0 ignored. - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib packed_clip_and_cull_distances_validate_and_draw_on_gpu -- --test-threads=1`: 1 passed, 0 failed, 0 ignored. The GPU draw ran here, with no SKIPPED line. **What this adds** Both tests pass: packed `SV_ClipDistance`/`SV_CullDistance` elements keep their true component width and channel offset, and the generated DXIL validates and draws on the card. The thread already has an RTX 5070 Ti report from the author; this adds an independent run on driver 32.0.16.2140. Synthetic draw only, no title. **Not tested** A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - ran the commands above on this machine and wrote this report; no game data was used.
Aniseto commented 2026-11-29 14:20:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T14:20:52Z.


Re-ran the packed clip/cull tests at 62d53267 after the head moved from c5a9a056; this is a new response in the same thread, not an edit of my earlier report: https://github.com/xcl-dev/xcl/pull/3339#issuecomment-7256179938

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib output_channel_span_preserves_packed_clip_and_cull_offsets -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib packed_clip_and_cull_distances_validate_and_draw_on_gpu -- --test-threads=1: 1 passed, 0 failed, 0 ignored. The GPU draw ran here, with no SKIPPED line.

What this adds
Both tests still pass at the new head, including the DXIL validation and D3D12 draw. This adds the new head and driver 32.0.16.2140 as dimensions; no title run was made.

Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

<!-- greyfinch-sync:ivall/xcl:comment:7257232049 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3339#issuecomment-7257232049). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-29T14:20:52Z. --- Re-ran the packed clip/cull tests at `62d53267` after the head moved from `c5a9a056`; this is a new response in the same thread, not an edit of my earlier report: https://github.com/xcl-dev/xcl/pull/3339#issuecomment-7256179938 **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40) - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: debug **Results** - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib output_channel_span_preserves_packed_clip_and_cull_offsets -- --test-threads=1`: 1 passed, 0 failed, 0 ignored. - `XCL_ADAPTER=NVIDIA cargo test -p xcl --lib packed_clip_and_cull_distances_validate_and_draw_on_gpu -- --test-threads=1`: 1 passed, 0 failed, 0 ignored. The GPU draw ran here, with no SKIPPED line. **What this adds** Both tests still pass at the new head, including the DXIL validation and D3D12 draw. This adds the new head and driver 32.0.16.2140 as dimensions; no title run was made. **Not tested** A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - ran the commands above on this machine and wrote this report; no game data was used.
Foniass commented 2026-12-01 05:41:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:41:54Z.


merge-check
base: d0832e614f
head: 62d532671d
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2893 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (gpu/dxil graphics.rs, lower_gfx.rs, core_tests.rs; gpu/recomp emit.rs, mod.rs, tests.rs). It changes the default path: every title with clip/cull distances that don't start at .x changes on both the HLSL and the direct DXIL path, and the new sig_part order applies to every direct DXIL signature. No correctness bug found. Mesh records store whole registers, so reading .w / .zw in the pass-through is right. Pixel shaders never declare clip/cull inputs and clip/cull pack after the user rows, so VS -> PS linkage can't shift. The VS, the rect-list GS (out_struct) and the pass-through use the same widths, and the new sort (stream, register, name-table order, column) matches the row order DXC writes. The tests fail on main (.w comes out 4 components wide, 9 > 8, and the draw reads the -10 poison channel). Findings: (1) the PR's CI run is red on 16 tests in files it doesn't touch (title_textures, pipeline_library, warm_library, geometry_tests, lower_mem stage guards), the same failures an unrelated run that day had; they all pass in the run above on current main, so that CI failure came from the old base. (2) Some DXC compiles in the new tests are skipped silently without printing SKIPPED (part 1 of the core_tests.rs test, the end of the recomp test). The name de-duplication and stream key in sig_part (~610-622) change nothing. (3) AI use names no tool or model; Tested has no suite counts; the PR's smoke runs used non-default XCL_DIRECT_DXIL=all XCL_HEAP_WINDOWS=1 XCL_DRED=1 and end at 0 presents.
performance: 60 s smoke of a retail title, main d0832e61 vs this merge (a2d47467): 1516 -> 1681 frames shown (110 %; last presents per 2 s: 60 61 60), peak commit 18133 -> 17239 MB, 0 device removals, 0 crashes.
verdict: safe to merge (after a rebase and green CI rerun; the description should name the AI model and give the suite counts)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7302041907 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3339#issuecomment-7302041907). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:41:54Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: 62d532671d43a5b60fe1abfac9fe262e10a3ca71 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2893 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (gpu/dxil graphics.rs, lower_gfx.rs, core_tests.rs; gpu/recomp emit.rs, mod.rs, tests.rs). It changes the default path: every title with clip/cull distances that don't start at `.x` changes on both the HLSL and the direct DXIL path, and the new `sig_part` order applies to every direct DXIL signature. No correctness bug found. Mesh records store whole registers, so reading `.w` / `.zw` in the pass-through is right. Pixel shaders never declare clip/cull inputs and clip/cull pack after the user rows, so VS -> PS linkage can't shift. The VS, the rect-list GS (`out_struct`) and the pass-through use the same widths, and the new sort (stream, register, name-table order, column) matches the row order DXC writes. The tests fail on main (`.w` comes out 4 components wide, 9 > 8, and the draw reads the -10 poison channel). Findings: (1) the PR's CI run is red on 16 tests in files it doesn't touch (title_textures, pipeline_library, warm_library, geometry_tests, lower_mem stage guards), the same failures an unrelated run that day had; they all pass in the run above on current main, so that CI failure came from the old base. (2) Some DXC compiles in the new tests are skipped silently without printing SKIPPED (part 1 of the core_tests.rs test, the end of the recomp test). The name de-duplication and `stream` key in `sig_part` (~610-622) change nothing. (3) AI use names no tool or model; **Tested** has no suite counts; the PR's smoke runs used non-default `XCL_DIRECT_DXIL=all XCL_HEAP_WINDOWS=1 XCL_DRED=1` and end at 0 presents. performance: 60 s smoke of a retail title, main d0832e61 vs this merge (a2d47467): 1516 -> 1681 frames shown (110 %; last presents per 2 s: 60 61 60), peak commit 18133 -> 17239 MB, 0 device removals, 0 crashes. verdict: safe to merge (after a rebase and green CI rerun; the description should name the AI model and give the suite counts) hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
bmjask commented 2026-12-02 00:18:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T00:18:11Z.

Code review location: crates/xcl/src/gpu/recomp/mod.rs; line 582

@@ -570,6 +570,25 @@ pub fn elements_at(sig: &[SigElement], with_clip: bool, register: u32) -> Vec<us
     ranked(sig, with_clip).iter().enumerate().filter(|(_, e)| e.register == register).map(|(j, _)| j).collect()
 }
 
+/// Starting channel and component count `(start, count)` of a vertex / mesh output element:
+/// `SV_ClipDistance` / `SV_CullDistance` span the active bits of their OSG1 `mask` (so elements
+/// packed into `.y`, `.zw`, or `.w` keep their true width and channel offset without exceeding
+/// D3D12's 8-component clip/cull budget or reading earlier channels); other outputs stay full
+/// 4-vectors from `.x`.
+pub fn output_channel_span(e: &SigElement) -> (u8, u8) {
+    if matches!(e.system_value, 2 | 3) {
+        let m = e.mask & 0xF;
+        if m == 0 {
+            return (0, 1);

Not certain about this one: output_channel_span returns (0, 1) for an empty mask, so a clip/cull element with mask 0 becomes a real 1-component distance that reads channel .x of its register. If OSG1 has SV_CullDistance0 at r2.x (mask 0x1) and an SV_ClipDistance at r2 with mask 0, both the direct DXIL path (lower_gfx.rs ~331) and the HLSL path (emit.rs ~2372) copy r2.x into the clip distance, so a negative cull value also clips pixels. It also uses one of the 8 clip/cull slots, which can push a full 8-distance signature to 9, the rejection this PR fixes. Skipping mask-0 elements, as SigElement::from_d3d does by returning None, would avoid both.

<!-- greyfinch-sync:ivall/xcl:review-comment:4762933610 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3339#discussion_r4762933610). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T00:18:11Z. **Code review location:** `crates/xcl/src/gpu/recomp/mod.rs`; line 582 ~~~~diff @@ -570,6 +570,25 @@ pub fn elements_at(sig: &[SigElement], with_clip: bool, register: u32) -> Vec<us ranked(sig, with_clip).iter().enumerate().filter(|(_, e)| e.register == register).map(|(j, _)| j).collect() } +/// Starting channel and component count `(start, count)` of a vertex / mesh output element: +/// `SV_ClipDistance` / `SV_CullDistance` span the active bits of their OSG1 `mask` (so elements +/// packed into `.y`, `.zw`, or `.w` keep their true width and channel offset without exceeding +/// D3D12's 8-component clip/cull budget or reading earlier channels); other outputs stay full +/// 4-vectors from `.x`. +pub fn output_channel_span(e: &SigElement) -> (u8, u8) { + if matches!(e.system_value, 2 | 3) { + let m = e.mask & 0xF; + if m == 0 { + return (0, 1); ~~~~ --- Not certain about this one: `output_channel_span` returns (0, 1) for an empty mask, so a clip/cull element with mask 0 becomes a real 1-component distance that reads channel .x of its register. If OSG1 has SV_CullDistance0 at r2.x (mask 0x1) and an SV_ClipDistance at r2 with mask 0, both the direct DXIL path (lower_gfx.rs ~331) and the HLSL path (emit.rs ~2372) copy r2.x into the clip distance, so a negative cull value also clips pixels. It also uses one of the 8 clip/cull slots, which can push a full 8-distance signature to 9, the rejection this PR fixes. Skipping mask-0 elements, as `SigElement::from_d3d` does by returning None, would avoid both.
bmjask commented 2026-12-02 00:18:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T00:18:11Z.

Review: COMMENTED


Review of 62d53267: 1 finding(s). 1 are inline.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6142567490 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3339#pullrequestreview-6142567490). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T00:18:11Z. **Review:** COMMENTED --- Review of `62d53267`: 1 finding(s). 1 are inline. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3339:upstream-pr/3339'
git switch 'upstream-pr/3339'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3339'
git switch 'upstream-pr/3339'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3339'
git switch 'upstream-pr/3339'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3339'
git switch 'main'
git merge --squash 'upstream-pr/3339'
git switch 'main'
git merge --ff-only 'upstream-pr/3339'
git switch 'main'
git merge 'upstream-pr/3339'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3339
No description provided.