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

Open
github-bot wants to merge 1 commit from github-bot/gh-183 into amd AGit
Owner

@⁠mahhnameisjeff on GitHub · 2026-12-03 15:15 UTC · original
mahhnameisjeff:amd-sample-mask → amd · +539 −12 · 10 files · 1 commits · open

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

**@⁠mahhnameisjeff** on GitHub · 2026-12-03 15:15 UTC · [original](https://github.com/eikkapine/jaxe/pull/183) `mahhnameisjeff:amd-sample-mask` → `amd` · +539 −12 · 10 files · 1 commits · open 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)
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.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 15:20:24 +00:00
This pull request can be merged automatically.
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 origin '+refs/pull/183/head:github-bot/gh-183'
git switch 'github-bot/gh-183'

Merge

Merge the changes and update on Forgejo.
git switch 'amd'
git merge --no-ff 'github-bot/gh-183'
git switch 'github-bot/gh-183'
git rebase 'amd'
git switch 'amd'
git merge --ff-only 'github-bot/gh-183'
git switch 'github-bot/gh-183'
git rebase 'amd'
git switch 'amd'
git merge --no-ff 'github-bot/gh-183'
git switch 'amd'
git merge --squash 'github-bot/gh-183'
git switch 'amd'
git merge --ff-only 'github-bot/gh-183'
git switch 'amd'
git merge 'github-bot/gh-183'
git push origin 'amd'
This discussion has been locked. Commenting is limited to contributors.
No description provided.