shader: keep 9-bit mesh primitive indices #3377

Manually merged
github merged 1 commit from github-bot/gh-3375 into gh-pr/3375/base 2026-11-28 18:12:40 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-11-28 16:06 UTC · original
lambirou:gpu/mesh-edge-mask → main · +10 −1 · 2 files · 1 commits · merged 2026-11-28 18:08 UTC

The direct mesh primitive export packs three 10-bit slots. Each slot holds a 9-bit vertex index with the edge flag in bit 9 (docs/experiments.md, primitive export row). The C++ frontend masked with 1023, so an index with the edge flag set became 512..1023 and the triangle[c] >= vertices guard culled the primitive. gfx2hlsl.py already masks with 511.

This keeps the 9-bit index and leaves the bit-31 null check unchanged.

The existing native_direct_mesh fixture used 0x00200400, which has no edge flags. It now also covers 0x20280600: indices (0,1,2) with all three edge flags set. The old mask fails the new assertion.

cmake --build --preset dev --target compile_dxil
ctest --preset dev --no-tests=error -R '^native_direct_mesh$' -V

Result: 1/1 passed. Negative control with the old 1023 mask: 0/1, assertion on the 511 mask fails.

Refs #2413.

**@⁠lambirou** on GitHub · 2026-11-28 16:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3375) `lambirou:gpu/mesh-edge-mask` → `main` · +10 −1 · 2 files · 1 commits · merged 2026-11-28 18:08 UTC The direct mesh primitive export packs three 10-bit slots. Each slot holds a 9-bit vertex index with the edge flag in bit 9 (docs/experiments.md, primitive export row). The C++ frontend masked with 1023, so an index with the edge flag set became 512..1023 and the `triangle[c] >= vertices` guard culled the primitive. `gfx2hlsl.py` already masks with 511. This keeps the 9-bit index and leaves the bit-31 null check unchanged. The existing `native_direct_mesh` fixture used `0x00200400`, which has no edge flags. It now also covers `0x20280600`: indices (0,1,2) with all three edge flags set. The old mask fails the new assertion. ```powershell cmake --build --preset dev --target compile_dxil ctest --preset dev --no-tests=error -R '^native_direct_mesh$' -V ``` Result: 1/1 passed. Negative control with the old 1023 mask: 0/1, assertion on the 511 mask fails. Refs #2413.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 16:11:34 +00:00
Author
Owner

@⁠lambirou on GitHub · 2026-11-28 16:07 UTC · original

Release /O2 also passes on the same tree: \cmake --build --preset release --target compile_dxil\ then \ctest --preset release --no-tests=error -R '^native_direct_mesh$' -V\ -> 1/1 passed, 0 failed, 0 skips.

**@⁠lambirou** on GitHub · 2026-11-28 16:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3375#issuecomment-7241994972) Release /O2 also passes on the same tree: \cmake --build --preset release --target compile_dxil\ then \ctest --preset release --no-tests=error -R '^native_direct_mesh$' -V\ -> 1/1 passed, 0 failed, 0 skips.
github-bot changed target branch from main to gh-pr/3375/base 2026-11-28 18:12:40 +00:00
github manually merged commit 24b895d774 into gh-pr/3375/base 2026-11-28 18:12:40 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-28 18:08 UTC · original · approved these changes

GPU review of 24b895d7.

  • Each primitive index is 9 bits with the edge flag in bit 9. Masking with 1023 counted the flag as part of the index: for 0x20280600 it gave 512/513/514 and the triangle was culled; 511 gives (0, 1, 2).
  • Run here in Windows Sandbox, network off, vGPU, Windows 11 build 26300 host, release build of main d418f70e with this PR and 11 other open PRs merged locally: native_direct_mesh passes, and putting 1023 back makes it fail.

Approve.

**@⁠Leyukaka** on GitHub · 2026-11-28 18:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3375#pullrequestreview-6099485895) · **approved these changes** GPU review of `24b895d7`. - Each primitive index is 9 bits with the edge flag in bit 9. Masking with 1023 counted the flag as part of the index: for `0x20280600` it gave 512/513/514 and the triangle was culled; 511 gives (0, 1, 2). - Run here in Windows Sandbox, network off, vGPU, Windows 11 build 26300 host, release build of `main` `d418f70e` with this PR and 11 other open PRs merged locally: `native_direct_mesh` passes, and putting 1023 back makes it fail. Approve.
This discussion has been locked. Commenting is limited to contributors.
No description provided.