From da32b357fc0b580fcefcd8453979df739cd86390 Mon Sep 17 00:00:00 2001 From: Bouke Sybren Haarsma Date: Wed, 3 Jan 2024 17:03:04 +0100 Subject: [PATCH] remove hacky texture This will use more hardware planes, causing some devices to composite yeilding lower framerates --- src/steamcompmgr.cpp | 62 ++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 45 deletions(-) diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 11a7cade6..0b0d17f8e 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -1621,7 +1621,7 @@ bool MouseCursor::getTexture() { pixels[i * image->width + j] = image->pixels[i * image->width + j]; } - } + } std::vector resizeBuffer( nDesiredWidth * nDesiredHeight ); stbir_resize_uint8_srgb( (unsigned char *)pixels.data(), image->width, image->height, 0, (unsigned char *)resizeBuffer.data(), nDesiredWidth, nDesiredHeight, 0, @@ -2316,7 +2316,7 @@ paint_all(bool async) } } } - + int nOldLayerCount = frameInfo.layerCount; uint32_t flags = 0; @@ -2324,7 +2324,7 @@ paint_all(bool async) flags |= PaintWindowFlag::BasePlane; paint_window(w, w, &frameInfo, global_focus.cursor, flags); update_touch_scaling( &frameInfo ); - + // paint UI unless it's fully hidden, which it communicates to us through opacity=0 // we paint it to extract scaling coefficients above, then remove the layer if one was added if ( w->opacity == TRANSLUCENT && bHasVideoUnderlay && nOldLayerCount < frameInfo.layerCount ) @@ -2337,7 +2337,7 @@ paint_all(bool async) float opacityScale = g_bPendingFade ? 0.0f : ((currentTime - fadeOutStartTime) / (float)g_FadeOutDuration); - + paint_cached_base_layer(g_HeldCommits[HELD_COMMIT_FADE], g_CachedPlanes[HELD_COMMIT_FADE], &frameInfo, 1.0f - opacityScale, false); paint_window(w, w, &frameInfo, global_focus.cursor, PaintWindowFlag::BasePlane | PaintWindowFlag::FadeTarget | PaintWindowFlag::DrawBorders, opacityScale, override); } @@ -2411,34 +2411,6 @@ paint_all(bool async) if ( overlay == global_focus.inputFocusWindow ) update_touch_scaling( &frameInfo ); } - else if ( !GetBackend()->UsesVulkanSwapchain() && GetBackend()->IsSessionBased() ) - { - auto tex = vulkan_get_hacky_blank_texture(); - if ( tex != nullptr ) - { - // HACK! HACK HACK HACK - // To avoid stutter when toggling the overlay on - int curLayer = frameInfo.layerCount++; - - FrameInfo_t::Layer_t *layer = &frameInfo.layers[ curLayer ]; - - - layer->scale.x = g_nOutputWidth == tex->width() ? 1.0f : tex->width() / (float)g_nOutputWidth; - layer->scale.y = g_nOutputHeight == tex->height() ? 1.0f : tex->height() / (float)g_nOutputHeight; - layer->offset.x = 0.0f; - layer->offset.y = 0.0f; - layer->opacity = 1.0f; // BLAH - layer->zpos = g_zposOverlay; - layer->applyColorMgmt = g_ColorMgmt.pending.enabled; - - layer->colorspace = GAMESCOPE_APP_TEXTURE_COLORSPACE_LINEAR; - layer->ctm = nullptr; - layer->tex = tex; - - layer->filter = GamescopeUpscaleFilter::NEAREST; - layer->blackBorder = true; - } - } if (notification) { @@ -3043,7 +3015,7 @@ win_maybe_a_dropdown( steamcompmgr_win_t *w ) // // TODO: Come back to me for original Age of Empires HD launcher. // Does that use it? It wants blending! - // + // // Only do this if we have CONTROLPARENT right now. Some other apps, such as the // Street Fighter V (310950) Splash Screen also use LAYERED and TOOLWINDOW, and we don't // want that to be overlayed. @@ -3058,12 +3030,12 @@ win_maybe_a_dropdown( steamcompmgr_win_t *w ) // Josh: // The logic here is as follows. The window will be treated as a dropdown if: - // + // // If this window has a fixed position on the screen + static gravity: // - If the window has either skipPage or skipTaskbar // - If the window isn't a dialog, always treat it as a dropdown, as it's // probably meant to be some form of popup. - // - If the window is a dialog + // - If the window is a dialog // - If the window has transient for, disregard it, as it is trying to redirecting us elsewhere // ie. a settings menu dialog popup or something. // - If the window has both skip taskbar and pager, treat it as a dialog. @@ -3155,7 +3127,7 @@ static bool is_good_override_candidate( steamcompmgr_win_t *override, steamcompm return false; return override != focus && override->GetGeometry().nX >= 0 && override->GetGeometry().nY >= 0; -} +} static bool pick_primary_focus_and_override(focus_t *out, Window focusControlWindow, const std::vector& vecPossibleFocusWindows, bool globalFocus, const std::vector& ctxFocusControlAppIDs) @@ -3296,7 +3268,7 @@ found:; if ( focus ) { - if ( window_has_commits( focus ) ) + if ( window_has_commits( focus ) ) out->focusWindow = focus; else focus->outdatedInteractiveFocus = true; @@ -3339,9 +3311,9 @@ found:; override_focus = fake_override; goto found2; } - } + } } - + found2:; resolveTransientOverrides( true ); } @@ -4603,7 +4575,7 @@ finish_destroy_win(xwayland_ctx_t *ctx, Window id, bool gone) { if (gone) finish_unmap_win (ctx, w); - + { std::unique_lock lock( ctx->list_mutex ); *prev = w->xwayland().next; @@ -4660,7 +4632,7 @@ destroy_win(xwayland_ctx_t *ctx, Window id, bool gone, bool fade) global_focus.overrideWindow = nullptr; if (x11_win(global_focus.fadeWindow) == id && gone) global_focus.fadeWindow = nullptr; - + MakeFocusDirty(); finish_destroy_win(ctx, id, gone); @@ -5284,7 +5256,7 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev) { get_win_type(ctx, w); MakeFocusDirty(); - } + } } if (ev->atom == ctx->atoms.sizeHintsAtom) { @@ -6187,7 +6159,7 @@ void handle_done_commits_xdg( bool vblank, uint64_t vblank_idx ) commits_before_their_time.push_back( entry ); continue; } - + if (!entry.earliestPresentTime) { entry.earliestPresentTime = next_refresh_time; @@ -7209,7 +7181,7 @@ void update_mode_atoms(xwayland_ctx_t *root_ctx, bool* needs_flush = nullptr) } XChangeProperty(root_ctx->dpy, root_ctx->root, root_ctx->atoms.gamescopeDisplayModeListExternal, XA_STRING, 8, PropModeReplace, (unsigned char *)modes, strlen(modes) + 1 ); - + uint32_t one = 1; XChangeProperty(root_ctx->dpy, root_ctx->root, root_ctx->atoms.gamescopeDisplayIsExternal, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&one, 1 ); @@ -8054,7 +8026,7 @@ void steamcompmgr_send_frame_done_to_focus_window() { wlserver_lock(); wlserver_send_frame_done( global_focus.focusWindow->xwayland().surface.main_surface , &now ); - wlserver_unlock(); + wlserver_unlock(); } }