GPU: reuse compiled shaders for the PresentX compositor #3693

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3693 into main
andrewpozdnakov7-jpg commented 2026-11-28 08:05:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T08:05:23Z.


PresentX rebuilds the compositor when the swap-chain format changes. Its fixed fullscreen vertex and pixel programs use the same bytecode for each format. Keep the first successfully compiled pair in memory and use it to create the format-specific pipeline states. A failed compile still returns its error and can be retried.

On signed app-local WARP 1.0.22 and Agility 1.620.2, six layered frames alternated between RGBA8 and BGRA8. Both revisions created six compositors and read the expected blend pixel and dimensions on every frame. The number of D3DCompile calls fell from 12 to 2. In 11 alternating measurement pairs, the median time for 48 compositor creations after warmup fell from 283.90 ms to 45.46 ms. That measurement includes pipeline and descriptor creation and excludes presentation.

The compositor bytecode reuse, pipeline creation, primary-plane fallback and swap-chain retry tests passed, as did strict GPU Clippy and the asset policy.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5538156958 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3693). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T08:05:23Z. --- PresentX rebuilds the compositor when the swap-chain format changes. Its fixed fullscreen vertex and pixel programs use the same bytecode for each format. Keep the first successfully compiled pair in memory and use it to create the format-specific pipeline states. A failed compile still returns its error and can be retried. On signed app-local WARP 1.0.22 and Agility 1.620.2, six layered frames alternated between RGBA8 and BGRA8. Both revisions created six compositors and read the expected blend pixel and dimensions on every frame. The number of D3DCompile calls fell from 12 to 2. In 11 alternating measurement pairs, the median time for 48 compositor creations after warmup fell from 283.90 ms to 45.46 ms. That measurement includes pipeline and descriptor creation and excludes presentation. The compositor bytecode reuse, pipeline creation, primary-plane fallback and swap-chain retry tests passed, as did strict GPU Clippy and the asset policy. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 08:08:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T08:08:34Z.


Windows CI passed at 47b34fa, including Clippy in both configurations and the workspace tests. The six-frame WARP comparison used the expected blended pixel on RGBA8 and BGRA8 in every frame. The compiled programs were built twice in total instead of twelve times.

The next step is maintainer review. The measured improvement is in compositor construction during format changes.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding this change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7236390536 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3693#issuecomment-7236390536). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T08:08:34Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46124173155/job/140914944117) passed at `47b34fa`, including Clippy in both configurations and the workspace tests. The six-frame WARP comparison used the expected blended pixel on RGBA8 and BGRA8 in every frame. The compiled programs were built twice in total instead of twelve times. The next step is maintainer review. The measured improvement is in compositor construction during format changes. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding this change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 08:36:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T08:36:50Z.


I combined this PR with #3695 in 291544e. The compositor retains format-specific pipeline states and descriptor heaps, and the vertex and pixel bytecode is shared by all of them.

I drew eight generated frames on signed app-local WARP, visiting RGBA8, BGRA8, R10G10B10A2 and RGBA16F twice each. Every pixel matched the expected output. The test counted four compositor creations and still held four at the end. The two shader stages compiled once each. The same result held with the D3D12 debug switch off and on, and the fallback-and-reuse regression, focused compositor tests, strict GPU Clippy and asset policy passed.

A maintainer can use the combined branch if both changes land together. Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the changes into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7236696166 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3693#issuecomment-7236696166). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T08:36:50Z. --- I combined this PR with #3695 in [291544e](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/291544e747ec87b850ba96af84c33734a8be7f30). The compositor retains format-specific pipeline states and descriptor heaps, and the vertex and pixel bytecode is shared by all of them. I drew eight generated frames on signed app-local WARP, visiting RGBA8, BGRA8, R10G10B10A2 and RGBA16F twice each. Every pixel matched the expected output. The test counted four compositor creations and still held four at the end. The two shader stages compiled once each. The same result held with the D3D12 debug switch off and on, and the fallback-and-reuse regression, focused compositor tests, strict GPU Clippy and asset policy passed. A maintainer can use the combined branch if both changes land together. Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the changes into another commit. AI-assisted with OpenAI Codex.
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/3693:upstream-pr/3693'
git switch 'upstream-pr/3693'

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 'upstream-pr/3693'
git switch 'upstream-pr/3693'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3693'
git switch 'upstream-pr/3693'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3693'
git switch 'main'
git merge --squash 'upstream-pr/3693'
git switch 'main'
git merge --ff-only 'upstream-pr/3693'
git switch 'main'
git merge 'upstream-pr/3693'
git push origin 'main'
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
Marvisak/VIctory!3693
No description provided.