Skip to content

Linux vulkan present flush - #13

Merged
TheForgotten69 merged 11 commits into
linux-vulkanfrom
linux-vulkan-present-flush
Oct 10, 2026
Merged

TheForgotten69 merged 11 commits into
linux-vulkanfrom
linux-vulkan-present-flush

Conversation

@TheForgotten69

Copy link
Copy Markdown
Owner

No description provided.

TheForgotten69 and others added 11 commits October 2, 2026 01:09
… the back buffer

- ReShadeVulkanRequestDeviceExtension (include/reshade_vulkan_interop.h): add-ons
  ask, from AddonInit, for device extensions that ReShade enables at
  vkCreateDevice when supported. "VK_KHR_buffer_device_address" also enables the
  feature, editing the game's own feature structure when it has one.
- ReShadeVulkanGetDeviceInterop: the instance, physical device, the next layer's
  vkGet*ProcAddr, the API version and what was enabled, for add-ons that drive
  the game's device natively.
- During the present event, the first flush of the immediate command list waits
  on the present's semaphores, so add-ons can flush and wait for the back buffer
  (ReShadePresentEventFlushWaits).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…verywhere

- ReShadeVulkanRequestQueue(flags): add-ons ask, from AddonInit, for a queue of
  their own with the given capabilities. ReShade adds it at vkCreateDevice in
  the family with the fewest other capabilities that has room, after the
  game's queues, and reports it in ReShadeVulkanDeviceInterop::queues together
  with the device's queue families (for concurrent sharing).
- Requesting VK_NV_optical_flow also enables its opticalFlow feature, when
  supported (the bundled headers predate the extension: its constants are
  defined locally).
- Timeline semaphores are enabled on every Vulkan 1.2+ device, not only when the
  game passes VkPhysicalDeviceVulkan12Features: create_fence failed on devices
  such as Dolphin's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… for add-ons

- vkCmdSetViewportWithCount reaches bind_viewports, and viewports bound by
  add-ons use the same call as the application
- vkCmdBindDescriptorSets2 and vkCmdPushDescriptorSet2 reach the descriptor
  events (loaded by hand before Vulkan 1.4, where they are VK_KHR_maintenance6)
- ReShadeVulkanHideDeviceExtension: an add-on can hide a device extension from
  the application, e.g. VK_EXT_descriptor_heap, so that it binds through calls
  the add-on can follow
An add-on can live there together with the files it needs, apart from
ReShade's configuration and logs.
…ring

ReShadeVulkanInterruptRendering ends the rendering a command buffer is in and
returns what it was begun with; ReShadeVulkanResumeRendering begins it again
with the attachments loaded. For add-ons that record copies or compute work at
a point of the application's frame (for example between its 3D scene and its
HUD). Rendering with extension structures is refused, except the attachment
flags of VK_KHR_maintenance10, which DXVK chains and which are kept.
ReShadeVulkanGetMappedBuffer returns the address of a buffer's first byte
while the application has its memory mapped (vkMapMemory and vkMapMemory2 are
followed), for add-ons that read what the application writes to its buffers,
such as the constants of a draw.
…-ons

As bind_pipeline_states events (stencil_enable; the faces' operations and
comparison), like the stencil masks and reference already are: an add-on that
changes the stencil test for some draws can put the application's back.
…and put its state back

- ReShadeVulkanRestoreState: the graphics pipeline, descriptor sets, vertex
  buffers and dynamic state the application last set on a command buffer are
  followed (viewports and scissors with count, depth bias, culling, front face,
  depth bounds, depth and stencil tests) and set again on request.
- ReShadeVulkanObserveGraphicsPipelines: an add-on is shown each graphics
  pipeline with the create info it was made from, to build pipelines of its
  own like the application's.
- ReShadeVulkanGetShaderModuleCode: the SPIR-V of a shader module.
…object's private data is a short list, not a hash map

Below the Steam overlay's layer, every vkGetSwapchainImagesKHR opens a handle to the GPU device that is never closed, and the driver's answer slows with each one; add-ons asking for the back buffer every present paid for it. The private data of a command buffer is looked up by add-ons on every draw.
…ique samples it; the per-second reversed-depth log lines are gone

With 44 effects loaded and one sharpening technique enabled, a 4K frame went from 1.29 to 0.78 ms in the test game: a disabled effect declaring a depth texture no longer costs a full-size copy every frame. The runtime answers whether any enabled technique binds a texture of a given semantic.
@TheForgotten69 TheForgotten69 self-assigned this Oct 10, 2026
@TheForgotten69
TheForgotten69 changed the base branch from main to linux-vulkan October 10, 2026 14:33
@TheForgotten69
TheForgotten69 merged commit 7df0dfa into linux-vulkan Oct 10, 2026
1 check failed
@TheForgotten69
TheForgotten69 deleted the linux-vulkan-present-flush branch October 10, 2026 14:35
TheForgotten69 added a commit that referenced this pull request Oct 12, 2026
* Linux Vulkan: add-on device interop and present flushes that wait for the back buffer

- ReShadeVulkanRequestDeviceExtension (include/reshade_vulkan_interop.h): add-ons
  ask, from AddonInit, for device extensions that ReShade enables at
  vkCreateDevice when supported. "VK_KHR_buffer_device_address" also enables the
  feature, editing the game's own feature structure when it has one.
- ReShadeVulkanGetDeviceInterop: the instance, physical device, the next layer's
  vkGet*ProcAddr, the API version and what was enabled, for add-ons that drive
  the game's device natively.
- During the present event, the first flush of the immediate command list waits
  on the present's semaphores, so add-ons can flush and wait for the back buffer
  (ReShadePresentEventFlushWaits).

* Linux Vulkan: queues for add-ons, optical flow, timeline semaphores everywhere

- ReShadeVulkanRequestQueue(flags): add-ons ask, from AddonInit, for a queue of
  their own with the given capabilities. ReShade adds it at vkCreateDevice in
  the family with the fewest other capabilities that has room, after the
  game's queues, and reports it in ReShadeVulkanDeviceInterop::queues together
  with the device's queue families (for concurrent sharing).
- Requesting VK_NV_optical_flow also enables its opticalFlow feature, when
  supported (the bundled headers predate the extension: its constants are
  defined locally).
- Timeline semaphores are enabled on every Vulkan 1.2+ device, not only when the
  game passes VkPhysicalDeviceVulkan12Features: create_fence failed on devices
  such as Dolphin's.

* Linux Vulkan: hooks for what DXVK calls, and hiding device extensions for add-ons

- vkCmdSetViewportWithCount reaches bind_viewports, and viewports bound by
  add-ons use the same call as the application
- vkCmdBindDescriptorSets2 and vkCmdPushDescriptorSet2 reach the descriptor
  events (loaded by hand before Vulkan 1.4, where they are VK_KHR_maintenance6)
- ReShadeVulkanHideDeviceExtension: an add-on can hide a device extension from
  the application, e.g. VK_EXT_descriptor_heap, so that it binds through calls
  the add-on can follow

* Linux: load add-ons from an 'addon' folder too

An add-on can live there together with the files it needs, apart from
ReShade's configuration and logs.

* Linux Vulkan: let an add-on interrupt the application's dynamic rendering

ReShadeVulkanInterruptRendering ends the rendering a command buffer is in and
returns what it was begun with; ReShadeVulkanResumeRendering begins it again
with the attachments loaded. For add-ons that record copies or compute work at
a point of the application's frame (for example between its 3D scene and its
HUD). Rendering with extension structures is refused, except the attachment
flags of VK_KHR_maintenance10, which DXVK chains and which are kept.

* Linux Vulkan: tell add-ons where the application has a buffer mapped

ReShadeVulkanGetMappedBuffer returns the address of a buffer's first byte
while the application has its memory mapped (vkMapMemory and vkMapMemory2 are
followed), for add-ons that read what the application writes to its buffers,
such as the constants of a draw.

* Vulkan: report vkCmdSetStencilTestEnable and vkCmdSetStencilOp to add-ons

As bind_pipeline_states events (stencil_enable; the faces' operations and
comparison), like the stencil masks and reference already are: an add-on that
changes the stencil test for some draws can put the application's back.

* Linux Vulkan: let an add-on draw in the application's command buffer and put its state back

- ReShadeVulkanRestoreState: the graphics pipeline, descriptor sets, vertex
  buffers and dynamic state the application last set on a command buffer are
  followed (viewports and scissors with count, depth bias, culling, front face,
  depth bounds, depth and stencil tests) and set again on request.
- ReShadeVulkanObserveGraphicsPipelines: an add-on is shown each graphics
  pipeline with the create info it was made from, to build pipelines of its
  own like the application's.
- ReShadeVulkanGetShaderModuleCode: the SPIR-V of a shader module.

* Comments removed from the lines this branch adds over upstream

* Vulkan: a swapchain's images are asked for once, at its creation; an object's private data is a short list, not a hash map

Below the Steam overlay's layer, every vkGetSwapchainImagesKHR opens a handle to the GPU device that is never closed, and the driver's answer slows with each one; add-ons asking for the back buffer every present paid for it. The private data of a command buffer is looked up by add-ons on every draw.

* Generic Depth: the depth buffer is copied only while an enabled technique samples it; the per-second reversed-depth log lines are gone

With 44 effects loaded and one sharpening technique enabled, a 4K frame went from 1.29 to 0.78 ms in the test game: a disabled effect declaring a depth texture no longer costs a full-size copy every frame. The runtime answers whether any enabled technique binds a texture of a given semantic.
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