[pr-fix][shaders][INTEL] Mesh programs declare the output counts they request (DARNER_MESH_COUNTS=exact; Arc A770 device losses in LinearDepthPreSkin) #425

Open
kisekinopureya wants to merge 1 commit from kisekinopureya/Darner:kisekinopureya/pr/mesh-counts into main
Contributor

Contributor role (optional)

  • Fluxer ID: 1576376229534109696

What it changes

  • The problem on main: on an Intel Arc A770, the device is lost (0x887A0006, DRED: a page fault at a 64 KiB-aligned 0x8000… address that DRED ties to no allocation, so in the driver's own memory) inside the indirect mesh draws of MS_VS_LinearDepthPreSkin (mesh 824dc1956e7e38b6, also 6be582cb5252bc65; DRED's stopped list ends on command 448 ran [mesh 824dc1956e7e38b6, pixel 0b079b0d230eecef] (indirect kind 10 max 1 …)). In two runs of two it happened the first time the player stepped outside one building into the sun.

A mesh program's translation declares the program's maxima (here 128 vertices, 128 primitives) at its start, culls every primitive up front, and the lanes then write their primitives again. The console program asks for its real counts instead: thread 0 sends them (s_sendmsg GS_ALLOC_REQ, m0 = vertices | primitives << 12), with one culled primitive of its own on the path for an empty or oversized meshlet, and a barrier every thread passes comes before the exports.

DARNER_MESH_COUNTS=exact (off by default; keyed in the shader cache) translates that shape as the console has it. Thread 0 keeps its request in two dwords of group shared memory. After that barrier, with a group barrier of its own, the program declares the requested counts (SetMeshOutputCounts, within the declared maxima). Primitives are culled up front only when the request's path exported its culled primitive, which is left out there, so each primitive is written once. The site must be a block every thread passes once, after the request, that dominates every export outside the request's path. A program without one request, or without such a block, keeps the maxima.

Off by default because only one card was tested; turning it on for Intel cards needs the translator to know the card is Intel's (#31), so that would be a follow-up.

How it was tested

  • Tested revision: in the game, the same change at 3fcd4c67 on my intel-arc branch (this change on top of my open Intel drafts and of #292), with DARNER_MESH_COUNTS=exact. On this branch (b7e8f43e, on main f3840d73): the cargo gates below only.

  • Commands and results:

    • cargo test -p darner-shader --lib -- mesh: 13 passed. The new test a_mesh_request_gives_the_counts_with_the_switch builds a 128-thread wave64 mesh program with a request, a fallback culled primitive and a barrier, and checks that the counts are declared once after the barrier with the switch, never without it, and never for a program without a request. Both translations pass the DXIL validator.
    • The game's 824dc1956e7e38b6, translated offline as on the A770 (waves of 32 at most, Intel host, emulated barycentrics), passes the DXIL validator with the switch on and off.
  • Changes a default: no.

  • A/B result: off by default, so checked as follows, on an Intel Arc A770, Series S profile, XeSS ultra performance, same save, same door:

    A (off) B (DARNER_MESH_COUNTS=exact)
    Device lost at the first step outside 2 of 2 runs 0 of 6 crossings in 1 run

    A is intel-arc at f73316fa (the same branch without this change): one run with its defaults (lost after 53.5 minutes, at the door), one with indirect clamp batching off as well (DARNER_INDIRECT_BATCH=0 DARNER_INDIRECT_WINDOW=0, lost after 29 minutes, at the door). Earlier A runs lost the device elsewhere too (after 13.5, 21 and 38.7 minutes), not all traced to this door.

    Also with A: skipping both LinearDepthPreSkin variants (DARNER_SKIP_PIPELINES=6be582cb5252bc65,824dc1956e7e38b6) got past the door in 1 run; DARNER_MESH_REST=0 lost the device (a hang, no page fault) after about 70 s, before reaching it. With B the run went on among people outside for about 19 minutes in all, without a loss, and closed normally. No frame-rate claim: the B run started on a freshly rebuilt shader cache and pipeline library.

  • Gates run on b7e8f43e:

    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.
    • cargo test --workspace --locked: darner-shader 556 passed, 3 failed, 16 ignored. The three (valu_tests::whole_wave_f64_sum_and_cvt_f32_f64, waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders, wave64_tests::a_pair_that_runs_out_stores_nothing_more_and_notes_its_program) fail the same way on main f3840d73 without this change, on this PC. The other crates (--no-fail-fast): all pass but darner-gpu's watch::tests::ask_once_by_res_splits_reservations_without_refusals, which fails in the full darner-gpu run on main f3840d73 too and passes when run alone on both.
  • Gameplay: Intel Arc A770, Series S profile, XeSS ultra performance, no frame generation, no ray tracing.

  • Shader wave sizes tested: 32 (the A770's waves are 8 to 32 lanes) in the game; the unit test's host is this PC's.

  • Hardware dependence: untested elsewhere. The device loss was only seen on the A770; the change is off unless set.

  • Coverage gaps: one card, one place in the world, one B run (six crossings). Not run with the switch on an NVIDIA or AMD card.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #292 (constant reads; on the A770 it removed the black ground flicker but not these losses), #41 (mesh first lane, same mesh programs), #31 (the translator knowing an Intel card, for a default later). Related issue: #102 (Arc B580 device removed at world entry; different evidence, not claimed fixed here).
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

## Contributor role (optional) - Fluxer ID: 1576376229534109696 ## What it changes - The problem on main: on an Intel Arc A770, the device is lost (`0x887A0006`, DRED: a page fault at a 64 KiB-aligned `0x8000…` address that DRED ties to no allocation, so in the driver's own memory) inside the indirect mesh draws of `MS_VS_LinearDepthPreSkin` (mesh `824dc1956e7e38b6`, also `6be582cb5252bc65`; DRED's stopped list ends on `command 448 ran [mesh 824dc1956e7e38b6, pixel 0b079b0d230eecef] (indirect kind 10 max 1 …)`). In two runs of two it happened the first time the player stepped outside one building into the sun. A mesh program's translation declares the program's maxima (here 128 vertices, 128 primitives) at its start, culls every primitive up front, and the lanes then write their primitives again. The console program asks for its real counts instead: thread 0 sends them (`s_sendmsg` GS_ALLOC_REQ, m0 = vertices | primitives << 12), with one culled primitive of its own on the path for an empty or oversized meshlet, and a barrier every thread passes comes before the exports. `DARNER_MESH_COUNTS=exact` (off by default; keyed in the shader cache) translates that shape as the console has it. Thread 0 keeps its request in two dwords of group shared memory. After that barrier, with a group barrier of its own, the program declares the requested counts (`SetMeshOutputCounts`, within the declared maxima). Primitives are culled up front only when the request's path exported its culled primitive, which is left out there, so each primitive is written once. The site must be a block every thread passes once, after the request, that dominates every export outside the request's path. A program without one request, or without such a block, keeps the maxima. Off by default because only one card was tested; turning it on for Intel cards needs the translator to know the card is Intel's (#31), so that would be a follow-up. ## How it was tested - Tested revision: in the game, the same change at `3fcd4c67` on my `intel-arc` branch (this change on top of my open Intel drafts and of #292), with `DARNER_MESH_COUNTS=exact`. On this branch (`b7e8f43e`, on main `f3840d73`): the cargo gates below only. - Commands and results: - `cargo test -p darner-shader --lib -- mesh`: 13 passed. The new test `a_mesh_request_gives_the_counts_with_the_switch` builds a 128-thread wave64 mesh program with a request, a fallback culled primitive and a barrier, and checks that the counts are declared once after the barrier with the switch, never without it, and never for a program without a request. Both translations pass the DXIL validator. - The game's `824dc1956e7e38b6`, translated offline as on the A770 (waves of 32 at most, Intel host, emulated barycentrics), passes the DXIL validator with the switch on and off. - Changes a default: no. - A/B result: off by default, so checked as follows, on an Intel Arc A770, Series S profile, XeSS ultra performance, same save, same door: | | A (off) | B (`DARNER_MESH_COUNTS=exact`) | |---|---|---| | Device lost at the first step outside | 2 of 2 runs | 0 of 6 crossings in 1 run | A is `intel-arc` at `f73316fa` (the same branch without this change): one run with its defaults (lost after 53.5 minutes, at the door), one with indirect clamp batching off as well (`DARNER_INDIRECT_BATCH=0 DARNER_INDIRECT_WINDOW=0`, lost after 29 minutes, at the door). Earlier A runs lost the device elsewhere too (after 13.5, 21 and 38.7 minutes), not all traced to this door. Also with A: skipping both `LinearDepthPreSkin` variants (`DARNER_SKIP_PIPELINES=6be582cb5252bc65,824dc1956e7e38b6`) got past the door in 1 run; `DARNER_MESH_REST=0` lost the device (a hang, no page fault) after about 70 s, before reaching it. With B the run went on among people outside for about 19 minutes in all, without a loss, and closed normally. No frame-rate claim: the B run started on a freshly rebuilt shader cache and pipeline library. - Gates run on `b7e8f43e`: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test --workspace --locked`: darner-shader 556 passed, 3 failed, 16 ignored. The three (`valu_tests::whole_wave_f64_sum_and_cvt_f32_f64`, `waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders`, `wave64_tests::a_pair_that_runs_out_stores_nothing_more_and_notes_its_program`) fail the same way on main `f3840d73` without this change, on this PC. The other crates (`--no-fail-fast`): all pass but `darner-gpu`'s `watch::tests::ask_once_by_res_splits_reservations_without_refusals`, which fails in the full `darner-gpu` run on main `f3840d73` too and passes when run alone on both. - Gameplay: Intel Arc A770, Series S profile, XeSS ultra performance, no frame generation, no ray tracing. - Shader wave sizes tested: 32 (the A770's waves are 8 to 32 lanes) in the game; the unit test's host is this PC's. - Hardware dependence: untested elsewhere. The device loss was only seen on the A770; the change is off unless set. - Coverage gaps: one card, one place in the world, one B run (six crossings). Not run with the switch on an NVIDIA or AMD card. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] 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: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #292 (constant reads; on the A770 it removed the black ground flicker but not these losses), #41 (mesh first lane, same mesh programs), #31 (the translator knowing an Intel card, for a default later). Related issue: #102 (Arc B580 device removed at world entry; different evidence, not claimed fixed here). - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Off by default and keyed in the shader cache. A mesh program whose
thread 0 requests the group's outputs (s_sendmsg GS_ALLOC_REQ) ahead of a
barrier every thread passes once declares the counts it requested after
that barrier, not the declared maxima at its start; primitives are culled
up front only where the request's own path exported one (the empty or
oversized meshlet's culled primitive), so each primitive is written once.
Programs without such a request keep the maxima.

Why: the Arc A770 lost the device (a page fault in the driver's memory)
in MS_VS_LinearDepthPreSkin's indirect mesh draws (824dc1956e7e38b6), at
the first step outside a building in two runs of two. Skipping those
draws, and exact counts, each got past it; with exact counts, six times
through that door and a walk among people.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

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-counts'
git switch 'kisekinopureya-kisekinopureya/pr/mesh-counts'
git rebase 'main'
git switch 'main'
git merge --ff-only 'kisekinopureya-kisekinopureya/pr/mesh-counts'
git switch 'kisekinopureya-kisekinopureya/pr/mesh-counts'
git rebase 'main'
git switch 'main'
git merge --no-ff 'kisekinopureya-kisekinopureya/pr/mesh-counts'
git switch 'main'
git merge --squash 'kisekinopureya-kisekinopureya/pr/mesh-counts'
git switch 'main'
git merge --ff-only 'kisekinopureya-kisekinopureya/pr/mesh-counts'
git switch 'main'
git merge 'kisekinopureya-kisekinopureya/pr/mesh-counts'
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!425
No description provided.