From a11a9e99da0b5cf45d530ef6745035d35e24b6b9 Mon Sep 17 00:00:00 2001 From: sharkautarch <128002472+sharkautarch@users.noreply.github.com> Date: Tue, 18 Jun 2024 22:12:07 -0400 Subject: [PATCH] WSI: prefetcher: fix issue w/ attempting to prefetch xcb stuff for pure wayland surfaces --- layer/VkLayer_FROG_gamescope_wsi.cpp | 2 +- layer/xcb_helpers.hpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/layer/VkLayer_FROG_gamescope_wsi.cpp b/layer/VkLayer_FROG_gamescope_wsi.cpp index f26819a60..ce011dcd7 100644 --- a/layer/VkLayer_FROG_gamescope_wsi.cpp +++ b/layer/VkLayer_FROG_gamescope_wsi.cpp @@ -1234,7 +1234,7 @@ namespace GamescopeWSILayer { continue; } - xcb::Prefetcher prefetcher(gamescopeSurface->connection, gamescopeSurface->window); + auto prefetcher = xcb::Prefetcher::GetPrefetcherIf(!gamescopeSurface->isWayland(), gamescopeSurface->connection, gamescopeSurface->window); const bool canBypass = gamescopeSurface->canBypassXWayland(); if (canBypass != gamescopeSwapchain->isBypassingXWayland) UpdateSwapchainResult(canBypass ? VK_SUBOPTIMAL_KHR : VK_ERROR_OUT_OF_DATE_KHR); diff --git a/layer/xcb_helpers.hpp b/layer/xcb_helpers.hpp index 72d0ec092..b7ea9701e 100644 --- a/layer/xcb_helpers.hpp +++ b/layer/xcb_helpers.hpp @@ -16,6 +16,13 @@ namespace xcb { //Note: this class is currently only meant to be used within GamescopeWSILayer::VkDeviceOverrides::QueuePresentKHR: struct Prefetcher { + static std::optional GetPrefetcherIf(bool bCond, xcb_connection_t* connection, const xcb_window_t window) { + if (bCond) + return std::optional(std::in_place_t{}, connection, window); + + return std::nullopt; + } + explicit Prefetcher(xcb_connection_t* connection, const xcb_window_t window) { g_cache = { .window = window,