Skip to content

Commit

Permalink
remove hacky texture
Browse files Browse the repository at this point in the history
This will use more hardware planes, causing some devices to composite yeilding lower framerates
  • Loading branch information
BoukeHaarsma23 authored and alkazar committed Oct 18, 2024
1 parent 85c2c68 commit da32b35
Showing 1 changed file with 17 additions and 45 deletions.
62 changes: 17 additions & 45 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ bool MouseCursor::getTexture()
{
pixels[i * image->width + j] = image->pixels[i * image->width + j];
}
}
}
std::vector<uint32_t> resizeBuffer( nDesiredWidth * nDesiredHeight );
stbir_resize_uint8_srgb( (unsigned char *)pixels.data(), image->width, image->height, 0,
(unsigned char *)resizeBuffer.data(), nDesiredWidth, nDesiredHeight, 0,
Expand Down Expand Up @@ -2316,15 +2316,15 @@ paint_all(bool async)
}
}
}

int nOldLayerCount = frameInfo.layerCount;

uint32_t flags = 0;
if ( !bHasVideoUnderlay )
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 )
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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<steamcompmgr_win_t*>& vecPossibleFocusWindows, bool globalFocus, const std::vector<uint32_t>& ctxFocusControlAppIDs)
Expand Down Expand Up @@ -3296,7 +3268,7 @@ found:;

if ( focus )
{
if ( window_has_commits( focus ) )
if ( window_has_commits( focus ) )
out->focusWindow = focus;
else
focus->outdatedInteractiveFocus = true;
Expand Down Expand Up @@ -3339,9 +3311,9 @@ found:;
override_focus = fake_override;
goto found2;
}
}
}
}

found2:;
resolveTransientOverrides( true );
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
}
}

Expand Down

0 comments on commit da32b35

Please sign in to comment.