Skip to content

R-7: sample with each immediate sampler a join picks - #56

Open
sanchaton wants to merge 2 commits into
ProjectLeonidaL:mainfrom
sanchaton:pr/r7-sampler-join
Open

sanchaton wants to merge 2 commits into
ProjectLeonidaL:mainfrom
sanchaton:pr/r7-sampler-join

Conversation

@sanchaton

Copy link
Copy Markdown
Contributor

What changed

R-7 (partial): the 40 programs that failed with "emit: a descriptor chosen by control flow" now translate (37 pixel shaders: PS_TexturedLit*, PS_TexturedDeferred, PS_MirrorReflectionTexturedDeferred, PS_PuddleDetect; 3 mesh shaders: MST_DS_TerrainTransform, MST_DS_CascadeShadows_PNTriTexture). The join was between two immediate samplers (one clamping, one wrapping), and descriptor_phi only joins heap loads. The join now picks a static sampler number; the sample is made with each sampler it can be and its channels are selected by that number. Exact, at the cost of one more sample per affected read. A join of an immediate and a loaded sampler is still refused ("a sampler chosen by control flow").

How it was tested

  • Not run in game: tests and a shader census only. The draws these shaders bring back have not been measured in game yet; no frame-rate change is claimed.

Checks run on this branch:

  • cargo test --workspace --locked: 656 passed, 0 failed, 18 ignored (run with -j 2 -- --test-threads=4)
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo xtask policy

New unit test: emit::lower::tests::a_sampler_chosen_by_control_flow_samples_with_each (a compute program picks one of two immediate samplers by a root constant; both are declared).

leonida translate --list --validate --jobs 2 with a release build:

Cause Before After
emit: a descriptor chosen by control flow 40 0

All 40 are emitted and pass the DXIL validator. The validator failures that remain (output signatures, mesh output over 32,768, out-of-bound coordinates) are on other programs; none of the 40 is among them.

AI

  • AI-assisted: investigation, fix, unit test, shader census and review.

A join of two immediate samplers (one clamping, one wrapping) was refused as a descriptor chosen by control flow: descriptor_phi only joins heap loads. The join now picks a static sampler number; the sample is made with each sampler it can be and its channels are selected by that number.
@ShinniUwU

Copy link
Copy Markdown
Contributor

Two things before this can merge:

  1. In resampled, when call_with returns None the other sampler is skipped silently and the sample keeps the first one, so that path draws with the wrong sampler. Could that be an error instead ("a sampler chosen by control flow")? Same for anything else that takes the sampler handle, like LOD queries.
  2. This adds a second sample to PS_TexturedLit*, PS_TexturedDeferred and the cascade shadows, which run all the time. Could you do a scripts\measure-run.ps1 pair (main against this branch, after translate --warm all) and put the frame times in the PR?

Also: this and #55 both add to the top of "Newest" in docs/fork-notes.md, so the second one will need a quick rebase.

When the sample cannot be made again with another sampler a join picks, or a level-of-detail query takes a picked sampler, the program is refused as a sampler chosen by control flow instead of drawing with the first sampler. A gather's four texel reads take no sampler and keep their path. AI-assisted.
@sanchaton

Copy link
Copy Markdown
Contributor Author

Thanks, both points taken.

  1. Fixed in 10ebb6f. resampled now returns an error ("a sampler chosen by control flow") when the sample cannot be made again with one of the other samplers the join picks, instead of keeping the first one. A level-of-detail query (image_get_lod) on a picked sampler is refused the same way. The gather path that reads its four texels with textureLoad takes no sampler, so it keeps its path. cargo clippy -p leonida-shader --all-targets -- -D warnings is clean and cargo test -p leonida-shader gives 216 passed, 0 failed, 3 ignored.

  2. Agreed. I will do the scripts\measure-run.ps1 pair (main against this branch, after translate --warm all) and put the frame times in the Playtest section of the description. Until then, consider the cost of the second sample on PS_TexturedLit*, PS_TexturedDeferred and the cascade shadows unmeasured.

On docs/fork-notes.md: noted, I will rebase whichever of #55 and #56 is merged second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants