sample mask: port OMSetSampleMaskX (masked pixel shader twins) from main to amd #183

Open
mahhnameisjeff wants to merge 1 commit from upstream-pr/183 into amd
mahhnameisjeff commented 2026-12-03 15:15:52 +00:00 (Migrated from github.com)

Imported from eikkapine/jaxe. Originally posted by mahhnameisjeff on 2026-12-03T15:15:52Z.


Base: origin/amd (0902398). Independent of the other PRs from this batch.

Command list slot 142 (0x470) is OMSetSampleMaskX(u64 QuadSampleMask). On amd it was
ignored. The title fades between an object's levels of detail with it: the two levels are
drawn with complementary masks, a pixel of each 2x2 quad more every few frames. Ignored, both
levels draw every pixel.

This ports origin/main's implementation (itself from upstream 0938dd9, GPL-3.0-or-later):

  • translator: with_pixel_mask / PixelMask: a second form of a pixel program that discards,
    at entry, each pixel whose place in its 2x2 quad has its bit clear in a host-set dword
    (USER_PIXEL_MASK = 0x10a, as main). A program without SV_Position is given it in the row
    the vertex or mesh program writes it (position_row). quad_pixels / quad_place.
  • shader cache: the masked form has keys of its own (mask_key); plain keys are unchanged,
    so nothing cached before is translated again.
  • pipelines: a masked twin of the pixel shader (Shader::masked, keyed apart in
    Pending::new) and of the pipeline (host_pipeline_masked), made on the first draw under
    a mask without waiting (make::masked_for); the title's pipeline draws meanwhile.
    GraphicsState gets a Clone that copies its input names.
  • draws: State::pixel_mask, cleared by a graphics pipeline set and by a list reset;
    graphics_pipeline picks the twin for draws and indirect draws; the dword in host_word.
  • lists: slot 142 calls sample_mask_x and, with JAXE_THIN=1, is recorded in the stream
    (SAMPLE_MASK), in order with the draws and pipelines; set at the call instead, the
    replayed SET_PIPELINE after it cleared it before any draw (first run: 0 masked shaders).
  • JAXE_SAMPLE_MASK=0: ignored, as before.

Not ported: main's twin also follows the bound targets' formats; amd's pipelines do not vary
by bound formats, so the twin keeps the title pipeline's.

Measured on RX 6700 XT (Series S profile, JAXE_THIN=1), one run of ~150 s: 131,072
OMSetSampleMaskX calls, 62,799 leaving pixels out; 65 pixel shaders translated in the masked
form, none failed; 94 pipelines made in the run (the twins, kept in the pipeline library
after); draws per frame at the end 5,613; no crash. Visibly fewer visual problems in play.
main's tests for the mask bits, the draw state, the switch and the keys are ported and pass;
jaxe-shader's tests pass.

🤖 Generated with Claude Code

<!-- greyfinch-sync:eikkapine/jaxe:issue:5629321478 --> Imported from [eikkapine/jaxe](https://github.com/eikkapine/jaxe/pull/183). Originally posted by [mahhnameisjeff](https://github.com/mahhnameisjeff) on 2026-12-03T15:15:52Z. --- Base: origin/amd (0902398). Independent of the other PRs from this batch. Command list slot 142 (0x470) is `OMSetSampleMaskX(u64 QuadSampleMask)`. On amd it was ignored. The title fades between an object's levels of detail with it: the two levels are drawn with complementary masks, a pixel of each 2x2 quad more every few frames. Ignored, both levels draw every pixel. This ports origin/main's implementation (itself from upstream 0938dd9, GPL-3.0-or-later): - translator: `with_pixel_mask` / `PixelMask`: a second form of a pixel program that discards, at entry, each pixel whose place in its 2x2 quad has its bit clear in a host-set dword (`USER_PIXEL_MASK` = 0x10a, as main). A program without `SV_Position` is given it in the row the vertex or mesh program writes it (`position_row`). `quad_pixels` / `quad_place`. - shader cache: the masked form has keys of its own (`mask_key`); plain keys are unchanged, so nothing cached before is translated again. - pipelines: a masked twin of the pixel shader (`Shader::masked`, keyed apart in `Pending::new`) and of the pipeline (`host_pipeline_masked`), made on the first draw under a mask without waiting (`make::masked_for`); the title's pipeline draws meanwhile. `GraphicsState` gets a `Clone` that copies its input names. - draws: `State::pixel_mask`, cleared by a graphics pipeline set and by a list reset; `graphics_pipeline` picks the twin for draws and indirect draws; the dword in `host_word`. - lists: slot 142 calls `sample_mask_x` and, with `JAXE_THIN=1`, is recorded in the stream (`SAMPLE_MASK`), in order with the draws and pipelines; set at the call instead, the replayed `SET_PIPELINE` after it cleared it before any draw (first run: 0 masked shaders). - `JAXE_SAMPLE_MASK=0`: ignored, as before. Not ported: main's twin also follows the bound targets' formats; amd's pipelines do not vary by bound formats, so the twin keeps the title pipeline's. Measured on RX 6700 XT (Series S profile, JAXE_THIN=1), one run of ~150 s: 131,072 OMSetSampleMaskX calls, 62,799 leaving pixels out; 65 pixel shaders translated in the masked form, none failed; 94 pipelines made in the run (the twins, kept in the pipeline library after); draws per frame at the end 5,613; no crash. Visibly fewer visual problems in play. main's tests for the mask bits, the draw state, the switch and the keys are ported and pass; jaxe-shader's tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/183:upstream-pr/183'
git switch 'upstream-pr/183'

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 'amd'
git merge --no-ff 'upstream-pr/183'
git switch 'upstream-pr/183'
git rebase 'amd'
git switch 'amd'
git merge --ff-only 'upstream-pr/183'
git switch 'upstream-pr/183'
git rebase 'amd'
git switch 'amd'
git merge --no-ff 'upstream-pr/183'
git switch 'amd'
git merge --squash 'upstream-pr/183'
git switch 'amd'
git merge --ff-only 'upstream-pr/183'
git switch 'amd'
git merge 'upstream-pr/183'
git push origin 'amd'
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
eikkapine/jaxe!183
No description provided.