Skip to content

Commit 7c6c8a6

Browse files
committed
rendervulkan: evict stale screenshot images, for reuse
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.
1 parent 71b07c8 commit 7c6c8a6

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/rendervulkan.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,6 +3597,15 @@ gamescope::Rc<CVulkanTexture> vulkan_acquire_screenshot_texture(uint32_t width,
35973597
{
35983598
for (auto& pScreenshotImage : g_output.pScreenshotImages)
35993599
{
3600+
// Evict a stale screenshot image, and reuse it
3601+
if (pScreenshotImage && pScreenshotImage->GetRefCount() == 0 &&
3602+
(width != pScreenshotImage->width() ||
3603+
height != pScreenshotImage->height() ||
3604+
drmFormat != pScreenshotImage->drmFormat()))
3605+
{
3606+
pScreenshotImage = nullptr;
3607+
}
3608+
36003609
if (pScreenshotImage == nullptr)
36013610
{
36023611
pScreenshotImage = new CVulkanTexture();

0 commit comments

Comments
 (0)