WIP: [pr-fix][rendering][shaders][INTEL] Mesh corners: exact barycentrics for mesh pipelines without native ones #40

Draft
kisekinopureya wants to merge 14 commits from kisekinopureya:kisekinopureya/pr/mesh-corners into main
Contributor

Contributor role (optional)

  • Fluxer ID: 1576376229534109696

What it changes

A mesh pipeline's pixel program on the barycentric fallback had approximate weights (a third each):
the door artefacts in the prison cell. Now:

  • the mesh program keeps each vertex's clip x, y, w and the corner values in group shared memory;
  • after a group barrier at its end, it writes per primitive the corner values and two rows of the
    inverse of the corners' matrix, plus the clip position as a vertex output;
  • the pixel program takes each weight as a row dotted with the interpolated position
    (emit/lower/corners.rs).

A pixel program that reads none of this keeps the plain link.

Note: VIctory-NVIDIA also refuses mesh corners in the paired form, whose lanes leave early and would
miss the corners' barrier. That guard reads Lower::twin, from the paired-lanes PR (#43), so this
branch leaves it out. Whichever of the two merges second must put these lines back at the start of
corner_end:

// (the paired form has lanes leave early, which would miss the barrier below)
if self.twin.is_some() {
    return Err("mesh corners in the paired form");
}

How it was tested

  • Tested revision: 43a589458b (rebased onto 1a5286a7; the gates re-run there)
  • Commands and results: both clippy gates clean; the shader cache key, menu and panel tests pass.
  • Gameplay: base branch on an Arc A770, prison cell; mesh objects drawn (user).
  • Coverage gaps: the door artefacts were not checked separately.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on #39, which depends on #32 and #31

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #10 (also changes crates/darner-shader/src/emit/lower.rs).

🤖 Generated with Claude Code

## Contributor role (optional) - Fluxer ID: 1576376229534109696 ## What it changes A mesh pipeline's pixel program on the barycentric fallback had approximate weights (a third each): the door artefacts in the prison cell. Now: - the mesh program keeps each vertex's clip x, y, w and the corner values in group shared memory; - after a group barrier at its end, it writes per primitive the corner values and two rows of the inverse of the corners' matrix, plus the clip position as a vertex output; - the pixel program takes each weight as a row dotted with the interpolated position (`emit/lower/corners.rs`). A pixel program that reads none of this keeps the plain link. Note: VIctory-NVIDIA also refuses mesh corners in the paired form, whose lanes leave early and would miss the corners' barrier. That guard reads `Lower::twin`, from the paired-lanes PR (#43), so this branch leaves it out. Whichever of the two merges second must put these lines back at the start of `corner_end`: // (the paired form has lanes leave early, which would miss the barrier below) if self.twin.is_some() { return Err("mesh corners in the paired form"); } ## How it was tested - Tested revision: 43a589458b (rebased onto `1a5286a7`; the gates re-run there) - Commands and results: both clippy gates clean; the shader cache key, menu and panel tests pass. - Gameplay: base branch on an Arc A770, prison cell; mesh objects drawn (user). - Coverage gaps: the door artefacts were not checked separately. ## Checklist - [ ] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on #39, which depends on #32 and #31 ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #10 (also changes `crates/darner-shader/src/emit/lower.rs`). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The vendor is part of the host settings and the translation fingerprint
(lower::host_intel, set when the device is made), for the Intel-only forms
that follow.

In VIctory-NVIDIA this came with leaving the particle light atlas
unfolded on Intel cards (the folded CS_lightAtlas programs hung an Arc
A770's device in the prison cell in three runs of three). Darner already
leaves it unfolded on every card (UNFOLDED_BY_DEFAULT), so only the vendor
detection is ported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 18e8c457d1c80244e9da74b094dc70311e397428)
An Intel Arc A-series card reports no native barycentrics, so every pixel
program that reads SV_Barycentrics or GetAttributeAtVertex was refused at
pipeline creation. Such programs are now translated to read the basis and
each vertex's value from private inputs, and the vertex-to-pixel pipeline
gets a geometry stage that supplies them (ported from the AMD tree). The
device's caps decide; DARNER_BARYCENTRICS=emulate forces the stage on any
card. The setting is part of the translation fingerprint and host settings.

Also: SFI0/PSV0 readers, LShift/RShift/Space for DARNER_KEYS, and the FP64
test skipped on hosts without double-precision shader operations.

Darner: the fixture's geometry-stage HostShader gets ray_queries (a field added on Darner).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 8000ddfd8d8641a4f3fe115eaa3c1f8992f705c1)
DARNER_BARYCENTRICS=approximate (diagnostics builds, on a host without
native barycentrics): barycentrics are a third each and values at
computed weights are the input interpolated as usual, so no geometry
stage is needed and mesh pipelines are not refused for them. Wrong in
detail; for finding what the refused pipelines change on screen.

pixel_wave_lanes_on_the_card (ignored; needs dxc and a card) reports the
host's pixel wave width: 8 lanes on an Arc A770.

docs/arc-a770.md records the checkerboard causes ruled out since.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f6e75b4e6c463611d20baf1b51f0d9583ceaa262)
With barycentrics of a third each, the one consistent model is three
vertices holding the interpolated value: P0 is that value, P10 and P20
are 0. eval_channel returned the value for every weighted read, so the
second half of a computed-weight pair (old + j P20) gave twice it, and
P10/P20 reads gave it instead of 0. A GPU test draws 4 (8 before).

`replay --retranslate` now honours DARNER_BARYCENTRICS (emulate,
approximate) as the host does; without a device it always translated
with native barycentrics.

Not the cause of the Arc's coloured triangles: mesh pixel program
573d1857e903fab5 interpolates plainly, which the approximate path
already gets exactly; docs/arc-a770.md corrects the earlier note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 27246ca9525dc74eb7625fb4618df5047b0cea3f)
computed_weight_pixel_without_barycentrics came with the geometry-stage
fallback and was never used (a dead-code warning, an error with the
gates' -D warnings).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 021cc0b0538421c979987089d0461c77ee96982a)
A range for the basis modes and ok_or for a constant error: the
workspace's clippy gate (-D warnings) refused the two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 6307286ee744a28145bc47f2a9b197fff2c326ff)
The geometry-stage barycentrics name their hidden inputs DARNER_INTERNAL;
the translator's switch list picks the name up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 07d060d40a5c3e5225dab9a8bbda1f5532b164e6)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 6279be59e941d7f8cf7b8b722680f180db5f397a)
The interior checkerboard on Intel Arc (A770, and reported on a B580)
came from CS_GenerateShadowMasks_Checkerboard_NoHair: one lane hands
each 4x8 group's atlas slot to the others through LDS with no
s_barrier, as one console wave may. In D3D12 that is a race, and
Intel's compiler reorders it, so lanes wrote their mask pixels into
other tiles' slots and whole 8x8 tiles were lit or dark at random. A
shared-memory fence (barrier mode 8, no wait) now goes before each LDS
access of a compute program whose console wave is not split: on by
default on Intel, DARNER_LDS_WAVE_FENCE=0/1 off/on on any card, and in
the shader cache's key. In replay the frame becomes repeatable (69.9 dB
between runs, against 25.6) and the checkerboard is gone, in gameplay
too, with no frame-time cost measured.

Barycentrics on Intel:
- the geometry-stage fallback is used by default on an Intel card even
  where it reports native barycentrics (DARNER_BARYCENTRICS=native
  opts out);
- a mesh pipeline whose pixel program needs that fallback (a geometry
  stage cannot follow a mesh stage) gets a second translation of the
  pixel program with approximate barycentrics, cached apart, instead
  of being refused: 327 refusals to 0, and the prison's windows,
  posters and table objects are drawn;
- a pixel program whose exact fallback exceeds the host's pixel input
  registers is translated with approximate barycentrics instead of
  failing (44 failures to 0).
Vertex pipelines that fit keep the exact fallback.

an_unsplit_wave_fences_its_lds_accesses covers the fence.

Darner: a mesh pair that does not link is still made as translated (#4672); the approximate pixel program is the one linked, when the mesh needs it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 77b349ea28e616a1a1748da84c284d32921ce02c)
Docs that stay in VIctory-NVIDIA (the Arc tracker, the XeSS notes) are
named as its; the product is Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 679dac648a1999f8492b25519e158fd62be78160)
A geometry stage cannot follow a mesh stage, so a mesh pipeline's pixel
program that needs the barycentric fallback had approximate weights (a
third each): the door artefacts in the prison cell. The mesh program now
keeps each vertex's clip x, y, w and the corner values in group shared
memory and, after a group barrier at its end, writes per primitive the
corner values and two rows of the inverse of the corners' matrix, plus
the clip position as a vertex output; the pixel program takes each weight
as a row dotted with the interpolated position.

Tried first for such pipelines, falling back on the approximate form when
either program does not translate so; DARNER_MESH_CORNERS=0 keeps the
approximate form. The draw test gives the exact value at every pixel on
the A770 and WARP. Replay: --retranslate takes
DARNER_RETRANSLATE_MESH_CORNERS pairs; the three door pairs translate
and play on the A770 without a device loss.

Darner: without corners, a mesh pair that does not link is still made as translated (#4672).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7bc19059ee5a82028dfa3efc4efe6ee3717ec4c8)
In corners-smoke 22 mesh pipelines fell back on approximate barycentrics
because their pixel program, once linked, kept no private input: it needs
no corners, so its mesh program is linked as before. Also records the run:
no device loss, both door pairs took mesh corners, 102 pipelines kept the
approximate form for mesh outputs past 32 KiB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit fcc9819d855930049bcda9f889a5030163cd5766)
Docs that stay in VIctory-NVIDIA (the Arc tracker, the XeSS notes) are
named as its; the product is Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit a6c5ebf4c5c217e1d60dd66295b4018b58f69531)
The guard against mesh corners in the paired form (whose lanes leave
early and would miss the corners' group barrier) reads Lower::twin, which
comes with the paired-lanes pull request. Whichever of the two is merged
second puts it back in corner_end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This pull request is broken due to missing fork information.
View command line instructions

Checkout

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

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 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git switch 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git rebase 'main'
git switch 'main'
git merge --ff-only 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git switch 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git rebase 'main'
git switch 'main'
git merge --no-ff 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git switch 'main'
git merge --squash 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git switch 'main'
git merge --ff-only 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git switch 'main'
git merge 'kisekinopureya-kisekinopureya/pr/mesh-corners'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!40
No description provided.