Skip to content

Lower add-on dispatch cost, fix depth detection and depth flicker - #12

Merged
TheForgotten69 merged 6 commits into
linux-vulkanfrom
linux-vulkan-perf
Oct 1, 2026
Merged

TheForgotten69 merged 6 commits into
linux-vulkanfrom
linux-vulkan-perf

Conversation

@TheForgotten69

Copy link
Copy Markdown
Owner

Three fixes found while profiling the Vulkan layer.

Add-on dispatch (linux: look up add-on modules with _dl_find_object)
The built-in Generic Depth add-on means every event goes through find_addon, which called dladdr1 and took the loader lock for each callback. _dl_find_object is lock-free. Needs glibc 2.35 (CI has 2.38). vkcube with 4 effects, add-ons off: ReShade's app-thread overhead goes from about 892k to 299k instructions per frame and from about 40 to 29 us.

Reversed depth detection (depth: let unknown compare ops abstain ...)
Any draw with an always/equal test or unresolved dynamic depth state set the unknown bit, and the exact match then dropped every vote. UI and sky draws were enough to stop detection. In Suzerain it never decided and gave up after 600 frames; now it picks reversed after 120 frames. Contradicting evidence still blocks the vote. Tests extended.

Depth flicker (depth: keep the shader resource view when the backup texture is reused)
fc8ce90 clears the selected view when the previous depth-stencil is untracked, but the next check skips creating one if the revived backup texture is unchanged. A game that alternates between two depth buffers (RPCS3) ended every second frame without a view and rebound the effects every frame. Over 300 frames in inFamous: 150 null views and 300 runtime updates before, 0 and 1 after. Upstream has the same code.

Tested in vkcube, Suzerain (Proton) and RPCS3 (inFamous). Linux portability tests pass.

TheForgotten69 and others added 6 commits October 1, 2026 01:29
Enables VK_EXT_external_memory_host when available so add-ons can share
frames with another process through mapped memory, the only transport a
Wine/Proton process can use with a native one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds VK_IMAGE_USAGE_TRANSFER_DST_BIT alongside the usage ReShade already
requests, so add-ons can copy results back into the back buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The glad loader sends names containing "Properties" to vkGetInstanceProcAddr,
which returned a function that crashed vkCreateDevice for this device-level
entry point. Exclude it like the "Handle" functions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
find_addon runs for every add-on callback of every event, and dladdr1
takes the loader lock each time. _dl_find_object is lock-free.
Needs glibc 2.35.
Draws that test with always/equal or have unresolved dynamic depth state
set the unknown bit, and the exact match then discarded every vote. UI and
sky draws made detection fail in most games. Unknown evidence now abstains;
contradicting evidence still blocks the vote.
fc8ce90 clears the selected view when the previous depth-stencil is
untracked, but the following check skips creating a view if the revived
backup texture is unchanged. A game that alternates between two depth
buffers (RPCS3) ended every second frame without a view and rebound the
effects on every frame. Carry the previous view over in that case.
@TheForgotten69 TheForgotten69 self-assigned this Oct 1, 2026
@TheForgotten69
TheForgotten69 merged commit f297527 into linux-vulkan Oct 1, 2026
1 check passed
@TheForgotten69
TheForgotten69 deleted the linux-vulkan-perf branch October 1, 2026 19:53
TheForgotten69 added a commit that referenced this pull request Oct 12, 2026
* vulkan: import host memory as buffers with resource_flags::shared_host

Enables VK_EXT_external_memory_host when available so add-ons can share
frames with another process through mapped memory, the only transport a
Wine/Proton process can use with a native one.

* vulkan: allow copies into swap chain images

Adds VK_IMAGE_USAGE_TRANSFER_DST_BIT alongside the usage ReShade already
requests, so add-ons can copy results back into the back buffer.

* vulkan: load vkGetMemoryHostPointerPropertiesEXT through the device

The glad loader sends names containing "Properties" to vkGetInstanceProcAddr,
which returned a function that crashed vkCreateDevice for this device-level
entry point. Exclude it like the "Handle" functions.

* linux: look up add-on modules with _dl_find_object

find_addon runs for every add-on callback of every event, and dladdr1
takes the loader lock each time. _dl_find_object is lock-free.
Needs glibc 2.35.

* depth: let unknown compare ops abstain in reversed depth detection

Draws that test with always/equal or have unresolved dynamic depth state
set the unknown bit, and the exact match then discarded every vote. UI and
sky draws made detection fail in most games. Unknown evidence now abstains;
contradicting evidence still blocks the vote.

* depth: keep the shader resource view when the backup texture is reused

fc8ce90 clears the selected view when the previous depth-stencil is
untracked, but the following check skips creating a view if the revived
backup texture is unchanged. A game that alternates between two depth
buffers (RPCS3) ended every second frame without a view and rebound the
effects on every frame. Carry the previous view over in that case.
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.

1 participant