Skip to content

rendervulkan: evict stale screenshot images, for reuse#2170

Merged
misyltoad merged 2 commits into
ValveSoftware:masterfrom
oSoMoN:rendervulkan-evict-stale-screenshot-images
May 15, 2026
Merged

rendervulkan: evict stale screenshot images, for reuse#2170
misyltoad merged 2 commits into
ValveSoftware:masterfrom
oSoMoN:rendervulkan-evict-stale-screenshot-images

Conversation

@oSoMoN
Copy link
Copy Markdown

@oSoMoN oSoMoN commented May 11, 2026

Fixes a crash that happened when cycling through more than 2 screen recording resolutions in the Steam client: pScreenshotImages would fill up and as a consequence a call to vulkan_acquire_screenshot_texture with a new resolution would return a null pointer.

@oSoMoN
Copy link
Copy Markdown
Author

oSoMoN commented May 11, 2026

Note: this PR supersedes #1896.

@misyltoad
Copy link
Copy Markdown
Collaborator

This might conflict with taking a screenshot while in recording

Fixes a crash that happened when cycling through more than 2 screen recording
resolutions in the Steam client: pScreenshotImages would fill up and as a
consequence a call to vulkan_acquire_screenshot_texture with a new resolution
would return a null pointer.
@oSoMoN
Copy link
Copy Markdown
Author

oSoMoN commented May 14, 2026

This might conflict with taking a screenshot while in recording

I am indeed seeing a problem. When requesting screenshots in the AVIF format, the resulting files have always the expected dimensions (1280×800). However when requesting screenshots in the PNG format while a screencast is being recorded at a different resolution, the resulting files have either incorrect dimensions, or the dimensions are correct but the texture is repeated horizontally wrapping at the width of the current screencast.

So the PNG screenshot is reusing the texture currently in use by the screencast.

@oSoMoN
Copy link
Copy Markdown
Author

oSoMoN commented May 14, 2026

Okay, I can see what's going on with my change. When a PNG screenshot is requested while a screencast is ongoing, vulkan_acquire_screenshot_texture() is incorrectly evicting the first texture in the array that is being used by pipewire, under the assumption that it is not used any longer because its ref count is 0 (because paint_pipewire() calls vulkan_wait() with bReset=true, resetting all command buffers).

It seems that we would be much better off with two separate pools of textures, one for actual screenshots, and one for screencasts?

@oSoMoN oSoMoN marked this pull request as draft May 14, 2026 17:50
@oSoMoN
Copy link
Copy Markdown
Author

oSoMoN commented May 15, 2026

I am indeed seeing a problem. When requesting screenshots in the AVIF format, the resulting files have always the expected dimensions (1280×800). However when requesting screenshots in the PNG format while a screencast is being recorded at a different resolution, the resulting files have either incorrect dimensions, or the dimensions are correct but the texture is repeated horizontally wrapping at the width of the current screencast.

So the PNG screenshot is reusing the texture currently in use by the screencast.

This is in fact a separate problem: the PNG code path uses currentOutputWidth/currentOutputHeight which are global variables that paint_pipewire() temporarily modifies with the stream's dimensions and then restores. I submitted #2181 to address it separately.

…ideo capture

Avoids running out of textures when requesting a screenshot while a screen
capture is ongoing.

Both pools can hold two textures to account for concurrent requests in
different formats or at different resolutions.
@oSoMoN oSoMoN force-pushed the rendervulkan-evict-stale-screenshot-images branch from 7c6c8a6 to beccb1f Compare May 15, 2026 19:39
@oSoMoN oSoMoN marked this pull request as ready for review May 15, 2026 19:39
@oSoMoN
Copy link
Copy Markdown
Author

oSoMoN commented May 15, 2026

It seems that we would be much better off with two separate pools of textures, one for actual screenshots, and one for screencasts?

I pushed an additional commit that implements this (two separate texture pools, one for screenshots and one for screencasts).

@misyltoad misyltoad merged commit 01c47b9 into ValveSoftware:master May 15, 2026
1 check passed
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