Three pointers from the sibling forks: fxceless's submission-thread work, rdna::LEGACY on NVIDIA, an LLVM pass over the DXIL #66

Open
opened 2026-11-27 00:40:46 +00:00 by github-bot · 4 comments
Owner

@⁠marekpastuszczak-lang on GitHub · 2026-11-26 21:28 UTC · original

Not a report of a problem, so the template does not fit: three pointers from reading this tree next to fxceless/victory-fork and avatarmanz/VIctory-7900XTX. Nothing here was run in the game on my side; where a number is a measurement it says whose and of what.

1. Submission-thread work in fxceless that is not here

This tree comes from avatarmanz's, which left fxceless at a26859f (2026-11-25). Since then fxceless landed three things that are frame time on the thread that prepares submissions, and I could not find them here under any name (heap_worker, lookup_cache):

  • VICTORY_HEAP_WORKER=1 (crates/victory-gpu/src/heap_worker.rs, needs VICTORY_LATE_WAIT): textures picked by index are uploaded and detiled on a thread of their own. Their runs 311 to 316: the first boat mission from 6.2-6.7 to 8.65, 9.50 and 9.53 frames a second.
  • VICTORY_LOOKUP_CACHE=1 (shadow.rs, their pull request 1237): about 14 ms a frame there, off by default on their side.
  • Card hashing split over a group of threads (e4245f3): -10 ms a frame there.

Your panel shows the card at 87% in the boat scene, so the processor side is probably still part of the 21 fps.

2. rdna::LEGACY on an NVIDIA card

The cheaper legacy_mul (emit/lower.rs, first branch) only runs where set_host_rdna is true, that is an AMD card with waves of 32 and 64. The reasoning in it (a product is not 0 only where one factor is 0 and the other an infinity or no number) does not look specific to AMD. In a census of the archive on a build without it (fxceless 085ee7c, 25,635 programs) compares of a float against zero were 6.7% of all host instructions and the whole legacy pattern an estimated 12 to 15%. avatarmanz measured the saving at 0.4 ms of 18.4 on an RX 7900 XTX, so it is small in card time there; on the RTX 4090 it is not measured at all as far as I can see.

3. An LLVM pass over the finished DXIL module

The passes in emit/bitcode/opt.rs are the only optimiser. I fed 400 translated modules from a shader cache (the same fxceless build) to DXC's IDxcOptimizer (dxcompiler.dll 1.8.2502 from the Windows SDK) and counted instructions from the disassembly: -instcombine -gvn -adce -simplifycfg gives -9.3%, a wider set ending in -strip-dead-prototypes -11.2%, at 0.03 to 0.07 s a shader. The gain is in bitcast, select, shifts and branches. dxil.dll's validator accepts 386 of the 400 after the passes against 388 of 400 as translated; the two new refusals are "Flags must match usage", so the shader flags would have to be recomputed. The card's time with it is not measured.

The same notes with more detail are filed at avatarmanz and fxceless: https://github.com/avatarmanz/VIctory-7900XTX/issues/382, https://github.com/fxceless/victory-fork/issues/1383.

**@⁠marekpastuszczak-lang** on GitHub · 2026-11-26 21:28 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/66) Not a report of a problem, so the template does not fit: three pointers from reading this tree next to fxceless/victory-fork and avatarmanz/VIctory-7900XTX. Nothing here was run in the game on my side; where a number is a measurement it says whose and of what. ## 1. Submission-thread work in fxceless that is not here This tree comes from avatarmanz's, which left fxceless at `a26859f` (2026-11-25). Since then fxceless landed three things that are frame time on the thread that prepares submissions, and I could not find them here under any name (`heap_worker`, `lookup_cache`): - **`VICTORY_HEAP_WORKER=1`** (`crates/victory-gpu/src/heap_worker.rs`, needs `VICTORY_LATE_WAIT`): textures picked by index are uploaded and detiled on a thread of their own. Their runs 311 to 316: the first boat mission from 6.2-6.7 to 8.65, 9.50 and 9.53 frames a second. - **`VICTORY_LOOKUP_CACHE=1`** (`shadow.rs`, their pull request 1237): about 14 ms a frame there, off by default on their side. - **Card hashing split over a group of threads** (`e4245f3`): -10 ms a frame there. Your panel shows the card at 87% in the boat scene, so the processor side is probably still part of the 21 fps. ## 2. `rdna::LEGACY` on an NVIDIA card The cheaper `legacy_mul` (`emit/lower.rs`, first branch) only runs where `set_host_rdna` is true, that is an AMD card with waves of 32 and 64. The reasoning in it (a product is not 0 only where one factor is 0 and the other an infinity or no number) does not look specific to AMD. In a census of the archive on a build without it (fxceless `085ee7c`, 25,635 programs) compares of a float against zero were 6.7% of all host instructions and the whole legacy pattern an estimated 12 to 15%. avatarmanz measured the saving at 0.4 ms of 18.4 on an RX 7900 XTX, so it is small in card time there; on the RTX 4090 it is not measured at all as far as I can see. ## 3. An LLVM pass over the finished DXIL module The passes in `emit/bitcode/opt.rs` are the only optimiser. I fed 400 translated modules from a shader cache (the same fxceless build) to DXC's `IDxcOptimizer` (`dxcompiler.dll` 1.8.2502 from the Windows SDK) and counted instructions from the disassembly: `-instcombine -gvn -adce -simplifycfg` gives -9.3%, a wider set ending in `-strip-dead-prototypes` -11.2%, at 0.03 to 0.07 s a shader. The gain is in bitcast, select, shifts and branches. `dxil.dll`'s validator accepts 386 of the 400 after the passes against 388 of 400 as translated; the two new refusals are "Flags must match usage", so the shader flags would have to be recomputed. The card's time with it is not measured. The same notes with more detail are filed at avatarmanz and fxceless: https://github.com/avatarmanz/VIctory-7900XTX/issues/382, https://github.com/fxceless/victory-fork/issues/1383.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:40:46 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 22:33 UTC · original

Thanks for checking the sibling forks against the source. Vice-Tay already caches registered buffer lookups and runs card hashing in groups. The texture worker moves the heap walk and upload-list preparation as well. I’ll check those costs and make sure a reused slot can’t publish an older upload.

The legacy multiply needs output checks for signed zero and subnormals on NVIDIA. Could you share the two shader hashes and validator messages from the DXIL optimizer failures? I’d like to retest those exact inputs and pass order.

**@⁠TaynanGT** on GitHub · 2026-11-26 22:33 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/66#issuecomment-7204779309) Thanks for checking the sibling forks against the source. Vice-Tay already caches registered buffer lookups and runs card hashing in groups. The texture worker moves the heap walk and upload-list preparation as well. I’ll check those costs and make sure a reused slot can’t publish an older upload. The legacy multiply needs output checks for signed zero and subnormals on NVIDIA. Could you share the two shader hashes and validator messages from the DXIL optimizer failures? I’d like to retest those exact inputs and pass order.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 01:31 UTC · original

I checked the texture worker against Vice-Tay main at cc9ed86. The heap walk and upload recording still run on the recording thread here. The fxceless worker requires the late-submission path. Vice-Tay already has that path enabled through VICTORY_RELAY=2 in play.ps1.

The worker queues the upload ahead of the title’s lists and checks the slot’s descriptor generation before publishing. mirror() reads the descriptor again, so a useful regression test would replace the slot between those reads and assert that only the view with a matching queued upload can be published. Worker gate and queue · Slot check

For an RTX 4090 A/B, I’d use the same build, warm cache, Series S boat checkpoint and late-wait mode in both runs, with only the worker toggled. I’d compare median and p90 frame times, heap-pass and detiling time, and textures uploaded by the first bake. I’d also check the same checkpoint for missing textures. I haven’t measured the worker on the 4090 yet.

**@⁠TaynanGT** on GitHub · 2026-11-27 01:31 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/66#issuecomment-7207353149) I checked the texture worker against Vice-Tay `main` at `cc9ed86`. The heap walk and upload recording still run on the recording thread here. The fxceless worker requires the late-submission path. Vice-Tay already has that path enabled through `VICTORY_RELAY=2` in `play.ps1`. The worker queues the upload ahead of the title’s lists and checks the slot’s descriptor generation before publishing. `mirror()` reads the descriptor again, so a useful regression test would replace the slot between those reads and assert that only the view with a matching queued upload can be published. [Worker gate and queue](https://github.com/fxceless/victory-fork/blob/1f5d17a6b149f5ef95ba6d0be8826f4f9b62e363/crates/victory-gpu/src/heap_worker.rs#L179-L197) · [Slot check](https://github.com/fxceless/victory-fork/blob/1f5d17a6b149f5ef95ba6d0be8826f4f9b62e363/crates/victory-gpu/src/descriptor/host.rs#L2409-L2444) For an RTX 4090 A/B, I’d use the same build, warm cache, Series S boat checkpoint and late-wait mode in both runs, with only the worker toggled. I’d compare median and p90 frame times, heap-pass and detiling time, and textures uploaded by the first bake. I’d also check the same checkpoint for missing textures. I haven’t measured the worker on the 4090 yet.
Author
Owner

@⁠marekpastuszczak-lang on GitHub · 2026-11-27 06:40 UTC · original

Here are the two, re-run on the same sample (400 entries, the same seed). Both fail the same way with either pass set, and the cause is one thing.

Shader cache entry Bitcode before -> after (-instcombine -gvn -adce -simplifycfg) Validator
de2741054ae2471a177d2c4b1cdf19f95709081ce697d6cdc10cdb963efa9fae 7,412 -> 6,592 bytes error: Flags must match usage. note: Flags declared=1074790400, actual=1073741824
5bb53a59f4d2cc7f644fd38aa38d6af18fe0de2426b5804928c394711c6a00d2 10,424 -> 9,164 bytes error: Flags must match usage. note: Flags declared=1075314704, actual=1074266128

In both the difference is the one bit 0x100000, the 64-bit integer flag. Before the passes the modules use i64 only for address arithmetic of this shape:

%14 = zext i32 %13 to i64
%15 = shl i64 %14, 8
%16 = trunc i64 %15 to i32
%17 = lshr i64 %15, 32
%18 = trunc i64 %17 to i32

and

%138 = zext i32 %136 to i64
%139 = zext i32 %137 to i64
%140 = shl i64 %139, 32
%141 = or i64 %138, %140
%142 = shl i64 %141, 2

-instcombine narrows all of it to i32 (26 and 12 lines with i64 before, none after apart from the data layout line), so the flag the translator set (flags::INT64) no longer matches. So it is not a wrong result: the flags need to be recomputed from the module after the passes, or that one bit dropped when no i64 instruction is left. With that the count would be 388 of 400, the same as the modules as translated.

The names are cache keys of fxceless build 085ee7c with its default translator settings, so they will not be found in a cache of yours; the entry does not carry the guest shader's hash and I did not map them back. Any shader whose only 64-bit use is that address arithmetic should reproduce it.

For completeness, the 12 of 400 the validator refuses already as translated, untouched by any pass (so not from the optimiser): "vertex plus primitive output size is greater than 32768" (4), "signature element ... has interpolation mode that differs from another element packed into the same row" (5), "Container part 'Program Input/Output Signature' does not match expected for module" (3). The driver takes them, but they are there if you want them.

Tools: dxcompiler.dll and dxil.dll 1.8.2502.11 from the Windows SDK 10.0.26100, IDxcOptimizer::RunOptimizer on the bitcode alone, the result put back into the container's DXIL part and the whole container given to IDxcValidator. The wider set was -sroa -early-cse -simplifycfg -instcombine -reassociate -sccp -jump-threading -correlated-propagation -simplifycfg -instcombine -licm -gvn -dse -bdce -adce -simplifycfg -instcombine -strip-dead-prototypes.

**@⁠marekpastuszczak-lang** on GitHub · 2026-11-27 06:40 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/66#issuecomment-7211749308) Here are the two, re-run on the same sample (400 entries, the same seed). Both fail the same way with either pass set, and the cause is one thing. | Shader cache entry | Bitcode before -> after (`-instcombine -gvn -adce -simplifycfg`) | Validator | |---|---|---| | `de2741054ae2471a177d2c4b1cdf19f95709081ce697d6cdc10cdb963efa9fae` | 7,412 -> 6,592 bytes | `error: Flags must match usage.` `note: Flags declared=1074790400, actual=1073741824` | | `5bb53a59f4d2cc7f644fd38aa38d6af18fe0de2426b5804928c394711c6a00d2` | 10,424 -> 9,164 bytes | `error: Flags must match usage.` `note: Flags declared=1075314704, actual=1074266128` | In both the difference is the one bit `0x100000`, the 64-bit integer flag. Before the passes the modules use `i64` only for address arithmetic of this shape: ``` %14 = zext i32 %13 to i64 %15 = shl i64 %14, 8 %16 = trunc i64 %15 to i32 %17 = lshr i64 %15, 32 %18 = trunc i64 %17 to i32 ``` and ``` %138 = zext i32 %136 to i64 %139 = zext i32 %137 to i64 %140 = shl i64 %139, 32 %141 = or i64 %138, %140 %142 = shl i64 %141, 2 ``` `-instcombine` narrows all of it to `i32` (26 and 12 lines with `i64` before, none after apart from the data layout line), so the flag the translator set (`flags::INT64`) no longer matches. So it is not a wrong result: the flags need to be recomputed from the module after the passes, or that one bit dropped when no `i64` instruction is left. With that the count would be 388 of 400, the same as the modules as translated. The names are cache keys of fxceless build `085ee7c` with its default translator settings, so they will not be found in a cache of yours; the entry does not carry the guest shader's hash and I did not map them back. Any shader whose only 64-bit use is that address arithmetic should reproduce it. For completeness, the 12 of 400 the validator refuses already as translated, untouched by any pass (so not from the optimiser): "vertex plus primitive output size is greater than 32768" (4), "signature element ... has interpolation mode that differs from another element packed into the same row" (5), "Container part 'Program Input/Output Signature' does not match expected for module" (3). The driver takes them, but they are there if you want them. Tools: `dxcompiler.dll` and `dxil.dll` 1.8.2502.11 from the Windows SDK 10.0.26100, `IDxcOptimizer::RunOptimizer` on the bitcode alone, the result put back into the container's DXIL part and the whole container given to `IDxcValidator`. The wider set was `-sroa -early-cse -simplifycfg -instcombine -reassociate -sccp -jump-threading -correlated-propagation -simplifycfg -instcombine -licm -gvn -dse -bdce -adce -simplifycfg -instcombine -strip-dead-prototypes`.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 06:49 UTC · original

@⁠marekpastuszczak-lang The matching 0x100000 difference on both entries is the useful result. Vice-Tay already checks module usage and clears unused feature flags after its internal optimisation passes, before writing the container. The external DXC pass runs after that point, so it would need to regenerate the flags from the optimised module and validate the resulting container before replacing anything. Your 12 baseline refusals give us separate fixtures to track by validator error.

**@⁠TaynanGT** on GitHub · 2026-11-27 06:49 UTC · [original](https://github.com/TaynanGT/Vice-Tay/issues/66#issuecomment-7211888306) @⁠marekpastuszczak-lang The matching `0x100000` difference on both entries is the useful result. Vice-Tay already checks module usage and clears unused feature flags after its internal optimisation passes, before writing the container. The external DXC pass runs after that point, so it would need to regenerate the flags from the optimised module and validate the resulting container before replacing anything. Your 12 baseline refusals give us separate fixtures to track by validator error.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/TaynanGT--Vice-Tay#66
No description provided.