Skip to content

Commit

Permalink
WSI: prefetcher: fix issue w/ attempting to prefetch xcb stuff for pu…
Browse files Browse the repository at this point in the history
…re wayland surfaces
  • Loading branch information
sharkautarch committed Jun 19, 2024
1 parent b80fa9b commit 1b59621
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion layer/VkLayer_FROG_gamescope_wsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion layer/xcb_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Prefetcher> GetPrefetcherIf(bool bCond, xcb_connection_t* connection, const xcb_window_t window) {
if (bCond)
return std::optional<Prefetcher>(std::in_place_t{}, connection, window);

return std::nullopt;
}

explicit Prefetcher(xcb_connection_t* connection, const xcb_window_t window) {
g_cache = {
.window = window,
Expand Down Expand Up @@ -90,7 +97,7 @@ namespace xcb {
inline Reply<Reply_RetType> operator()(xcb_connection_t* conn, xcb_window_t window) {
const bool tryCached = pthread_equal(g_cache_tid, pthread_self())
&& g_cache.window == window;
if (!tryCached) [[unlikely]]
if (!tryCached)
return Reply<Reply_RetType> { m_replyFunc(conn, m_cookieFunc(conn, window), nullptr) };

auto ret = getCachedReply(conn);
Expand Down

0 comments on commit 1b59621

Please sign in to comment.